From f120d72211fee2bc55995b346c046d4a5beb0878 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 17 Feb 2024 23:13:51 +0100 Subject: [PATCH] fix(editor): revert task list dependence on ids This partially reverts 3969f6ae663ef30896454eb228dc478cf9cf14a3. 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 --- .../src/components/input/editor/TipTap.vue | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/input/editor/TipTap.vue b/frontend/src/components/input/editor/TipTap.vue index 7a95159d19..7ecb1e548d 100644 --- a/frontend/src/components/input/editor/TipTap.vue +++ b/frontend/src/components/input/editor/TipTap.vue @@ -389,20 +389,7 @@ const editor = useEditor({ CustomImage, TaskList, - TaskItem.extend({ - addAttributes() { - return { - ...this.parent?.(), - id: { - default: () => createRandomID(), - parseHTML: element => element.getAttribute('data-id'), - renderHTML: attributes => ({ - 'data-id': attributes.id, - }), - }, - } - }, - }).configure({ + TaskItem.configure({ nested: true, onReadOnlyChecked: (node: Node, checked: boolean): boolean => { if (!isEditEnabled) { @@ -414,7 +401,7 @@ const editor = useEditor({ // https://github.com/ueberdosis/tiptap/issues/3676 editor.value!.state.doc.descendants((subnode, pos) => { - if (node.attrs.id === subnode.attrs.id) { + if (node.eq(subnode)) { const {tr} = editor.value!.state tr.setNodeMarkup(pos, undefined, { ...node.attrs, @@ -422,10 +409,10 @@ const editor = useEditor({ }) editor.value!.view.dispatch(tr) bubbleSave() - return true } }) + return true }, }),