Skip to content
Snippets Groups Projects

Markdown toolbar inserts code blocks

Merged Phil Hughes requested to merge md-toolbar-multiline-code into master

What does this MR do?

Adds the ability to insert code blocks with the markdown toolbar buttons. This is done by selecting the block & then clicking the code button.

What are the relevant issue numbers?

Closes #19173 (closed)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
10 10 gl.text.selectedText = (text, textarea) ->
11 11 text.substring(textarea.selectionStart, textarea.selectionEnd)
12 12
13 gl.text.insertText = (textArea, text, tag, selected, wrap) ->
13 gl.text.lineBefore = (text, textarea) ->
14 split = text.substring(0, textarea.selectionStart).trim().split('\n')
15 split[split.length - 1]
16
17 gl.text.lineAfter = (text, textarea) ->
18 text.substring(textarea.selectionEnd).trim().split('\n')[0]
  • You might have a problem with wrapping text. I haven't see it yet but you might. So I am happy to merge but maybe keep an eye out? I just know that splitting by \n doesn't really guarantee anything as far as I know.

  • @iamphill Let's watch this one to make sure it is stable over time. Try it out on dev often.

  • Good job :sparkles:

  • Jacob Schatz Status changed to merged

    Status changed to merged

  • Jacob Schatz mentioned in commit 9c2fbcb0

    mentioned in commit 9c2fbcb0

  • Please register or sign in to reply
    Loading