MCPcopy Index your code
hub / github.com/hackmdio/codimd / toggleTodoEvent

Function toggleTodoEvent

public/js/extra.js:914–930  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

912}
913
914function toggleTodoEvent (e) {
915 const startline = $(this).closest('li').attr('data-startline') - 1
916 const line = window.editor.getLine(startline)
917 const matches = line.match(/^[>\s-]*[-+*]\s\[([x ])\]/)
918 if (matches && matches.length >= 2) {
919 let checked = null
920 if (matches[1] === 'x') { checked = true } else if (matches[1] === ' ') { checked = false }
921 const replacements = matches[0].match(/(^[>\s-]*[-+*]\s\[)([x ])(\])/)
922 window.editor.replaceRange(checked ? ' ' : 'x', {
923 line: startline,
924 ch: replacements[1].length
925 }, {
926 line: startline,
927 ch: replacements[1].length + 1
928 }, '+input')
929 }
930}
931
932// remove hash
933function removeHash () {

Callers

nothing calls this directly

Calls 1

getLineMethod · 0.80

Tested by

no test coverage detected