Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
775a9851
Commit
775a9851
authored
Mar 30, 2022
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New task list items should always be unchecked
parent
3ef0cb53
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
app/assets/javascripts/lib/utils/text_markdown.js
app/assets/javascripts/lib/utils/text_markdown.js
+3
-1
spec/frontend/lib/utils/text_markdown_spec.js
spec/frontend/lib/utils/text_markdown_spec.js
+6
-2
No files found.
app/assets/javascripts/lib/utils/text_markdown.js
View file @
775a9851
...
...
@@ -9,7 +9,7 @@ const LINK_TAG_PATTERN = '[{text}](url)';
// a bullet point character (*+-) and an optional checkbox ([ ] [x])
// OR a number with a . after it and an optional checkbox ([ ] [x])
// 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
+
\.))(
\[([
x
X
])\])?\s)(?<
content>.
)?
/
;
function
selectedText
(
text
,
textarea
)
{
return
text
.
substring
(
textarea
.
selectionStart
,
textarea
.
selectionEnd
);
...
...
@@ -391,6 +391,8 @@ function handleContinueList(e, textArea) {
itemToInsert
=
`
${
indent
}${
leader
}
`
;
}
itemToInsert
=
itemToInsert
.
replace
(
/
\[
x
\]
/i
,
'
[ ]
'
);
e
.
preventDefault
();
updateText
({
...
...
spec/frontend/lib/utils/text_markdown_spec.js
View file @
775a9851
...
...
@@ -179,11 +179,13 @@ describe('init markdown', () => {
text | expected
${
'
- 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
-
'
}
${
'
1. item
'
}
|
${
'
1. item
\n
2.
'
}
${
'
1. [ ] item
'
}
|
${
'
1. [ ] item
\n
2. [ ]
'
}
${
'
1. [x] item
'
}
|
${
'
1. [x] item
\n
2. [x]
'
}
${
'
1. [x] item
'
}
|
${
'
1. [x] item
\n
2. [ ]
'
}
${
'
1. [X] item
'
}
|
${
'
1. [X] item
\n
2. [ ]
'
}
${
'
108. item
'
}
|
${
'
108. item
\n
109.
'
}
${
'
108. item
\n
- second
'
}
|
${
'
108. item
\n
- second
\n
-
'
}
${
'
108. item
\n
1. second
'
}
|
${
'
108. item
\n
1. second
\n
2.
'
}
...
...
@@ -207,10 +209,12 @@ describe('init markdown', () => {
${
'
- item
\n
-
'
}
|
${
'
- item
\n
'
}
${
'
- [ ] item
\n
- [ ]
'
}
|
${
'
- [ ] item
\n
'
}
${
'
- [x] item
\n
- [x]
'
}
|
${
'
- [x] item
\n
'
}
${
'
- [X] item
\n
- [X]
'
}
|
${
'
- [X] item
\n
'
}
${
'
- item
\n
- second
\n
-
'
}
|
${
'
- item
\n
- second
\n
'
}
${
'
1. item
\n
2.
'
}
|
${
'
1. item
\n
'
}
${
'
1. [ ] item
\n
2. [ ]
'
}
|
${
'
1. [ ] item
\n
'
}
${
'
1. [x] item
\n
2. [x]
'
}
|
${
'
1. [x] item
\n
'
}
${
'
1. [X] item
\n
2. [X]
'
}
|
${
'
1. [X] item
\n
'
}
${
'
108. item
\n
109.
'
}
|
${
'
108. item
\n
'
}
${
'
108. item
\n
- second
\n
-
'
}
|
${
'
108. item
\n
- second
\n
'
}
${
'
108. item
\n
1. second
\n
1.
'
}
|
${
'
108. item
\n
1. second
\n
'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment