Commit d5704e80 authored by Peter Hegman's avatar Peter Hegman

Merge branch...

Merge branch '357318-markdown-automatic-lists-should-not-add-additional-completed-tasks' into 'master'

[markdown] Automatic lists should not add additional completed tasks

See merge request gitlab-org/gitlab!84022
parents 71e3d907 775a9851
...@@ -9,7 +9,7 @@ const LINK_TAG_PATTERN = '[{text}](url)'; ...@@ -9,7 +9,7 @@ const LINK_TAG_PATTERN = '[{text}](url)';
// a bullet point character (*+-) and an optional checkbox ([ ] [x]) // a bullet point character (*+-) and an optional checkbox ([ ] [x])
// OR a number with a . after it and an optional checkbox ([ ] [x]) // OR a number with a . after it and an optional checkbox ([ ] [x])
// followed by one or more whitespace characters // followed by one or more whitespace characters
const LIST_LINE_HEAD_PATTERN = /^(?<indent>\s*)(?<leader>((?<isUl>[*+-])|(?<isOl>\d+\.))( \[([x ])\])?\s)(?<content>.)?/; const LIST_LINE_HEAD_PATTERN = /^(?<indent>\s*)(?<leader>((?<isUl>[*+-])|(?<isOl>\d+\.))( \[([xX ])\])?\s)(?<content>.)?/;
function selectedText(text, textarea) { function selectedText(text, textarea) {
return text.substring(textarea.selectionStart, textarea.selectionEnd); return text.substring(textarea.selectionStart, textarea.selectionEnd);
...@@ -391,6 +391,8 @@ function handleContinueList(e, textArea) { ...@@ -391,6 +391,8 @@ function handleContinueList(e, textArea) {
itemToInsert = `${indent}${leader}`; itemToInsert = `${indent}${leader}`;
} }
itemToInsert = itemToInsert.replace(/\[x\]/i, '[ ]');
e.preventDefault(); e.preventDefault();
updateText({ updateText({
......
...@@ -179,11 +179,13 @@ describe('init markdown', () => { ...@@ -179,11 +179,13 @@ describe('init markdown', () => {
text | expected text | expected
${'- item'} | ${'- item\n- '} ${'- item'} | ${'- item\n- '}
${'- [ ] item'} | ${'- [ ] item\n- [ ] '} ${'- [ ] item'} | ${'- [ ] item\n- [ ] '}
${'- [x] item'} | ${'- [x] item\n- [x] '} ${'- [x] item'} | ${'- [x] item\n- [ ] '}
${'- [X] item'} | ${'- [X] item\n- [ ] '}
${'- item\n - second'} | ${'- item\n - second\n - '} ${'- item\n - second'} | ${'- item\n - second\n - '}
${'1. item'} | ${'1. item\n2. '} ${'1. item'} | ${'1. item\n2. '}
${'1. [ ] item'} | ${'1. [ ] item\n2. [ ] '} ${'1. [ ] item'} | ${'1. [ ] item\n2. [ ] '}
${'1. [x] item'} | ${'1. [x] item\n2. [x] '} ${'1. [x] item'} | ${'1. [x] item\n2. [ ] '}
${'1. [X] item'} | ${'1. [X] item\n2. [ ] '}
${'108. item'} | ${'108. item\n109. '} ${'108. item'} | ${'108. item\n109. '}
${'108. item\n - second'} | ${'108. item\n - second\n - '} ${'108. item\n - second'} | ${'108. item\n - second\n - '}
${'108. item\n 1. second'} | ${'108. item\n 1. second\n 2. '} ${'108. item\n 1. second'} | ${'108. item\n 1. second\n 2. '}
...@@ -207,10 +209,12 @@ describe('init markdown', () => { ...@@ -207,10 +209,12 @@ describe('init markdown', () => {
${'- item\n- '} | ${'- item\n'} ${'- item\n- '} | ${'- item\n'}
${'- [ ] item\n- [ ] '} | ${'- [ ] item\n'} ${'- [ ] item\n- [ ] '} | ${'- [ ] item\n'}
${'- [x] item\n- [x] '} | ${'- [x] item\n'} ${'- [x] item\n- [x] '} | ${'- [x] item\n'}
${'- [X] item\n- [X] '} | ${'- [X] item\n'}
${'- item\n - second\n - '} | ${'- item\n - second\n'} ${'- item\n - second\n - '} | ${'- item\n - second\n'}
${'1. item\n2. '} | ${'1. item\n'} ${'1. item\n2. '} | ${'1. item\n'}
${'1. [ ] item\n2. [ ] '} | ${'1. [ ] item\n'} ${'1. [ ] item\n2. [ ] '} | ${'1. [ ] item\n'}
${'1. [x] item\n2. [x] '} | ${'1. [x] item\n'} ${'1. [x] item\n2. [x] '} | ${'1. [x] item\n'}
${'1. [X] item\n2. [X] '} | ${'1. [X] item\n'}
${'108. item\n109. '} | ${'108. item\n'} ${'108. item\n109. '} | ${'108. item\n'}
${'108. item\n - second\n - '} | ${'108. item\n - second\n'} ${'108. item\n - second\n - '} | ${'108. item\n - second\n'}
${'108. item\n 1. second\n 1. '} | ${'108. item\n 1. second\n'} ${'108. item\n 1. second\n 1. '} | ${'108. item\n 1. second\n'}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment