fix(editor): revert task list dependence on ids
This partially reverts 3969f6ae66
. Adding ids to task list items is not as simple and actually made it worse in some cases. Hence we stick to comparing the content of nodes for now, until this is properly fixed in tiptap.
Related https://kolaente.dev/vikunja/vikunja/issues/2091#issuecomment-60063
This commit is contained in:
@ -389,20 +389,7 @@ const editor = useEditor({
|
|||||||
CustomImage,
|
CustomImage,
|
||||||
|
|
||||||
TaskList,
|
TaskList,
|
||||||
TaskItem.extend({
|
TaskItem.configure({
|
||||||
addAttributes() {
|
|
||||||
return {
|
|
||||||
...this.parent?.(),
|
|
||||||
id: {
|
|
||||||
default: () => createRandomID(),
|
|
||||||
parseHTML: element => element.getAttribute('data-id'),
|
|
||||||
renderHTML: attributes => ({
|
|
||||||
'data-id': attributes.id,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}).configure({
|
|
||||||
nested: true,
|
nested: true,
|
||||||
onReadOnlyChecked: (node: Node, checked: boolean): boolean => {
|
onReadOnlyChecked: (node: Node, checked: boolean): boolean => {
|
||||||
if (!isEditEnabled) {
|
if (!isEditEnabled) {
|
||||||
@ -414,7 +401,7 @@ const editor = useEditor({
|
|||||||
// https://github.com/ueberdosis/tiptap/issues/3676
|
// https://github.com/ueberdosis/tiptap/issues/3676
|
||||||
|
|
||||||
editor.value!.state.doc.descendants((subnode, pos) => {
|
editor.value!.state.doc.descendants((subnode, pos) => {
|
||||||
if (node.attrs.id === subnode.attrs.id) {
|
if (node.eq(subnode)) {
|
||||||
const {tr} = editor.value!.state
|
const {tr} = editor.value!.state
|
||||||
tr.setNodeMarkup(pos, undefined, {
|
tr.setNodeMarkup(pos, undefined, {
|
||||||
...node.attrs,
|
...node.attrs,
|
||||||
@ -422,10 +409,10 @@ const editor = useEditor({
|
|||||||
})
|
})
|
||||||
editor.value!.view.dispatch(tr)
|
editor.value!.view.dispatch(tr)
|
||||||
bubbleSave()
|
bubbleSave()
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
Reference in New Issue
Block a user