ProseMirror / prosemirror

The ProseMirror WYSIWYM editor
http://prosemirror.net/
MIT License
7.61k stars 336 forks source link

Inline NodeView with text content doesn't handle deletion correctly when last character is deleted #1365

Open bdbch opened 1 year ago

bdbch commented 1 year ago

Hey guys. I'm currently looking into an issue with our NodeViews not handling the deletion of text content correctly when an inline node view has content: 'text*' in it's schema.

See this issue: https://github.com/ueberdosis/tiptap/issues/3451

You can see inside the codesandbox provided (https://codesandbox.io/s/dazzling-james-xn3fnn?file=/src/App.js) that the node length will stay 1 when each character is deleted one by one or 0 if it's deleted by SelectAll => Backspace.

After that, the state for the node doesn't seem to update anymore (the nodes length stays 1/0 and the changes done inside are not written into the state).

This doesn't happen, if the content is set to paragraph* for example since then it seems the schema is working correctly.

Now the question would be - is it actually correct to use text directly in a Node? From what I've seen it feels like the state drops the node internally whenever the content is empty - but our node view renderer is not reflecting that change?

Would love to hear some insight - don't need a direct solution but maybe a heads up on what could happen here and if this is even correct Prosemirror behavior / usage.

Thanks! 😀

marijnh commented 1 year ago

Can this issue be reproduced without the React/Tiptap stuff?

bdbch commented 1 year ago

I'll give it a shot, I'll come back to this issue tomorrow

Nantris commented 1 year ago

@bdbch could you update on this issue?