fix(editor): revert task list dependence on ids
continuous-integration/drone/push Build is failing Details

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 #2091 (comment)
This commit is contained in:
kolaente 2024-02-17 23:13:51 +01:00
parent a2951570a7
commit f120d72211
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 3 additions and 16 deletions

View File

@ -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
},
}),