ueberdosis / tiptap

The headless rich text editor framework for web artisans.
https://tiptap.dev
MIT License
26.35k stars 2.22k forks source link

[Bug/Missing feature]: OnReadOnlyChecked #4521

Open SeDemal opened 10 months ago

SeDemal commented 10 months ago

Which packages did you experience the bug in?

Extension-task-item

What Tiptap version are you using?

2.1.11

What’s the bug you are facing?

The function OnReadOnlyCheck doesn't update the editor, only the checkbox visibly. task-item.ts line 135 It has the node and value of the tick in it's parameters to try and offer the possibility to manually update the editor but running the following function:

onReadOnlyChecked: (node, checked) => {
  editor!.state.doc.descendants((subnode, pos) => {
    if (node.eq(subnode)) {
      const { tr } = editor!.state;
      tr.setNodeMarkup(pos, undefined, {
        ...node.attrs,
        checked: checked,
      });
      editor!.view.dispatch(tr);
    }
  });
  return true;
},

The nodes never match using node.eq(subnode). <= This is what I think is a bug unless I am doing something wrong.

Now that test would not be needed if the position was also given in the parameters. <= Missing feature? It would also be nice if we could get the editor as parameter, like the other basic events do.

What browser are you using?

Other

Code example

No response

What did you expect to happen?

For node.eq(subnode) to return "true" once. I actually tried to isolate those nodes values and found that they should in fact be matching but yet aren't.w

Anything to add? (optional)

No response

Did you update your dependencies?

Are you sponsoring us?

SeDemal commented 10 months ago

I've noticed #3676 also refers to the same problem but isn't solved nor does it offer a simple solution that isn't "patchwork".