mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
Merge pull request #1234 from hedgedoc/fix/numbered-task-lists
Fix click handler for numbered task lists
This commit is contained in:
commit
9d3902d208
1 changed files with 6 additions and 6 deletions
|
@ -266,9 +266,9 @@ export function finishView (view) {
|
||||||
li.innerHTML = html
|
li.innerHTML = html
|
||||||
let disabled = 'disabled'
|
let disabled = 'disabled'
|
||||||
if (typeof editor !== 'undefined' && window.havePermission()) { disabled = '' }
|
if (typeof editor !== 'undefined' && window.havePermission()) { disabled = '' }
|
||||||
if (/^\s*\[[x ]\]\s*/.test(html)) {
|
if (/^\s*\[[xX ]]\s*/.test(html)) {
|
||||||
li.innerHTML = html.replace(/^\s*\[ \]\s*/, `<input type="checkbox" class="task-list-item-checkbox "${disabled}><label></label>`)
|
li.innerHTML = html.replace(/^\s*\[ ]\s*/, `<input type="checkbox" class="task-list-item-checkbox" ${disabled}><label></label>`)
|
||||||
.replace(/^\s*\[x\]\s*/, `<input type="checkbox" class="task-list-item-checkbox" checked ${disabled}><label></label>`)
|
.replace(/^\s*\[[xX]]\s*/, `<input type="checkbox" class="task-list-item-checkbox" checked ${disabled}><label></label>`)
|
||||||
if (li.tagName.toLowerCase() !== 'li') {
|
if (li.tagName.toLowerCase() !== 'li') {
|
||||||
li.parentElement.setAttribute('class', 'task-list-item')
|
li.parentElement.setAttribute('class', 'task-list-item')
|
||||||
} else {
|
} else {
|
||||||
|
@ -705,11 +705,11 @@ $.fn.sortByDepth = function () {
|
||||||
function toggleTodoEvent (e) {
|
function toggleTodoEvent (e) {
|
||||||
const startline = $(this).closest('li').attr('data-startline') - 1
|
const startline = $(this).closest('li').attr('data-startline') - 1
|
||||||
const line = window.editor.getLine(startline)
|
const line = window.editor.getLine(startline)
|
||||||
const matches = line.match(/^[>\s-]*[-+*]\s\[([x ])\]/)
|
const matches = line.match(/^[>\s-]*(?:[-+*]|\d+[.)])\s\[([xX ])]/)
|
||||||
if (matches && matches.length >= 2) {
|
if (matches && matches.length >= 2) {
|
||||||
let checked = null
|
let checked = null
|
||||||
if (matches[1] === 'x') { checked = true } else if (matches[1] === ' ') { checked = false }
|
if (matches[1].toLowerCase() === 'x') { checked = true } else if (matches[1] === ' ') { checked = false }
|
||||||
const replacements = matches[0].match(/(^[>\s-]*[-+*]\s\[)([x ])(\])/)
|
const replacements = matches[0].match(/(^[>\s-]*(?:[-+*]|\d+[.)])\s\[)([xX ])(])/)
|
||||||
window.editor.replaceRange(checked ? ' ' : 'x', {
|
window.editor.replaceRange(checked ? ' ' : 'x', {
|
||||||
line: startline,
|
line: startline,
|
||||||
ch: replacements[1].length
|
ch: replacements[1].length
|
||||||
|
|
Loading…
Reference in a new issue