fix(editor): add workaround for checklist tiptap bug
This commit is contained in:
parent
8b9e5e54af
commit
ea7dab68ae
@ -200,7 +200,9 @@ const CustomTableCell = TableCell.extend({
|
|||||||
})
|
})
|
||||||
|
|
||||||
type CacheKey = `${ITask['id']}-${IAttachment['id']}`
|
type CacheKey = `${ITask['id']}-${IAttachment['id']}`
|
||||||
const loadedAttachments = ref<{ [key: CacheKey]: string }>({})
|
const loadedAttachments = ref<{
|
||||||
|
[key: CacheKey]: string
|
||||||
|
}>({})
|
||||||
|
|
||||||
const CustomImage = Image.extend({
|
const CustomImage = Image.extend({
|
||||||
addAttributes() {
|
addAttributes() {
|
||||||
@ -356,13 +358,28 @@ const editor = useEditor({
|
|||||||
TaskItem.configure({
|
TaskItem.configure({
|
||||||
nested: true,
|
nested: true,
|
||||||
onReadOnlyChecked: (node: Node, checked: boolean): boolean => {
|
onReadOnlyChecked: (node: Node, checked: boolean): boolean => {
|
||||||
if (isEditEnabled) {
|
if (!isEditEnabled) {
|
||||||
node.attrs.checked = checked
|
return false
|
||||||
bubbleSave()
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
// The following is a workaround for this bug:
|
||||||
|
// https://github.com/ueberdosis/tiptap/issues/4521
|
||||||
|
// https://github.com/ueberdosis/tiptap/issues/3676
|
||||||
|
|
||||||
|
editor.value!.state.doc.descendants((subnode, pos) => {
|
||||||
|
if (node.eq(subnode)) {
|
||||||
|
const {tr} = editor.value!.state
|
||||||
|
tr.setNodeMarkup(pos, undefined, {
|
||||||
|
...node.attrs,
|
||||||
|
checked,
|
||||||
|
})
|
||||||
|
editor.value!.view.dispatch(tr)
|
||||||
|
bubbleSave()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
return true
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user