diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-01 21:08:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-01 21:08:46 +0300 |
commit | 1c7a88b121670eb5732ff4ddac3a2121fb36395a (patch) | |
tree | 5ca1e7e6b9e3e0a61908cfbd5ac86fb55dfc4699 /app/assets/javascripts/lib | |
parent | cdd826bc3ad3e6f234f96a861efa129dba5e2502 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r-- | app/assets/javascripts/lib/utils/text_markdown.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/assets/javascripts/lib/utils/text_markdown.js b/app/assets/javascripts/lib/utils/text_markdown.js index 18eca11ac42..a5e2ee463a9 100644 --- a/app/assets/javascripts/lib/utils/text_markdown.js +++ b/app/assets/javascripts/lib/utils/text_markdown.js @@ -11,6 +11,9 @@ const LINK_TAG_PATTERN = '[{text}](url)'; // followed by one or more whitespace characters const LIST_LINE_HEAD_PATTERN = /^(?<indent>\s*)(?<leader>((?<isUl>[*+-])|(?<isOl>\d+\.))( \[([xX ])\])?\s)(?<content>.)?/; +// detect a horizontal rule that might be mistaken for a list item (not full pattern for an <hr>) +const HR_PATTERN = /^((\s{0,3}-+\s*-+\s*-+\s*[\s-]*)|(\s{0,3}\*+\s*\*+\s*\*+\s*[\s*]*))$/; + function selectedText(text, textarea) { return text.substring(textarea.selectionStart, textarea.selectionEnd); } @@ -381,13 +384,15 @@ function handleContinueList(e, textArea) { let itemToInsert; + // Behaviors specific to either `ol` or `ul` if (isOl) { const nextLine = lineAfter(textArea.value, textArea, false); const nextLineResult = nextLine.match(LIST_LINE_HEAD_PATTERN); itemToInsert = continueOlText(result, nextLineResult); } else { - // isUl + if (currentLine.match(HR_PATTERN)) return; + itemToInsert = `${indent}${leader}`; } |