Skip to content

Change editor controls to properly edit block markdown - #2139

Closed
MoshiKoi wants to merge 5 commits into
codidact:developfrom
MoshiKoi:editor-block-markdown
Closed

Change editor controls to properly edit block markdown#2139
MoshiKoi wants to merge 5 commits into
codidact:developfrom
MoshiKoi:editor-block-markdown

Conversation

@MoshiKoi

Copy link
Copy Markdown
Member

Fixes #2051

Block markdown should place the markdown symbols at the start of each line, rather than in the middle, even if that's where the selection is.

line 1

line 2

line 3

Blockquoted

> line 1
> 
> line 2
> 
> line 3

Numbered list

1. line 1

2. line 2

3. line 3

Block markdown should place the markdown symbols at the start of each line, rather than the middle.
Blockquotes, lists, and headers fall under this category.

Fixes codidact#2051
Comment thread app/assets/javascripts/markdown.js Outdated
$field[0].setSelectionRange(startPos, endPos);
const lines = $field.val().substring(startPos, endPos).split('\n');
let jdx = 0;
for (let idx = 0; idx < lines.length; ++idx) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does a for-let block work here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, (assuming you meant for (let line of lines). The way it works is that it has to actually reassign the lines. A range for does not do reassignment like that; I can't write line = this.callback(line) to change the actual array item.

Comment thread app/assets/javascripts/markdown.js
Comment thread app/assets/javascripts/markdown.js Outdated
Comment thread app/assets/javascripts/markdown.js Outdated
Comment thread app/assets/javascripts/markdown.js Outdated
Comment thread app/assets/javascripts/markdown.js Outdated
MoshiKoi and others added 4 commits August 19, 2026 16:24
Co-authored-by: ArtOfCode <ArtOfCode-@users.noreply.github.com>
We don't expect action to be null or invalid since it comes directly from the buttons.
If somehow that occurs, it shouldn't be silently ignored.
@MoshiKoi

Copy link
Copy Markdown
Member Author

Closing in favor of #2140 for CI purposes

@MoshiKoi MoshiKoi closed this Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editor quote button should quote entire selection, not just first line

3 participants