fix: prevent checkbox change when editor isn’t editable, fix #1386

This commit is contained in:
Philipp Kühn
2021-05-27 18:33:15 +02:00
parent c1e2edce46
commit c58a753e94

View File

@@ -86,9 +86,17 @@ export const TaskItem = Node.create<TaskItemOptions>({
checkboxWrapper.contentEditable = 'false'
checkbox.type = 'checkbox'
checkbox.addEventListener('change', event => {
// if the editor isnt editable
// we have to undo the latest change
if (!editor.isEditable) {
checkbox.checked = !checkbox.checked
return
}
const { checked } = event.target as any
if (typeof getPos === 'function') {
if (editor.isEditable && typeof getPos === 'function') {
editor
.chain()
.focus()