sibiraj-s/svelte-tiptap

Cursor can not be moved upwards out of svelte editable component

zwz opened this issue · 4 comments

zwz commented

I tried the demo on https://sibiraj-s.github.io/svelte-tiptap/

  1. locate the cursor on the first paragraph.
  2. move the cursor downwards with arrow down key until the last paragraph (everything works well)
  3. move the cursor upwards with arrow up key, you'll set it is stuck in the editable component.

If you try the the demo on tiptap.dev , no such issue.

Thanks. Will check this. Sorry for the delay.

aivo0 commented

@zwz this is not a library problem but library documentation issue - the example is broken. Note that it is even worse on Firefox where one cannot even move with the down arrow. If you look at https://tiptap.dev/guide/node-views/react the span in the Component.jsx has contentEditable={false} . The reason is explained by ProseMirror's author here: https://discuss.prosemirror.net/t/nodeviews-with-contentdom-stops-the-cursor-movement-for-a-node-with-text-content/3208/6 "Generally, if you’re going to add non-content DOM structure in a node view, you have to make sure you set it uneditable, or the browser will move the cursor into it (and then ProseMirror will move it out again because it doesn’t consider that position a valid selection endpoint)."
I added contentEditable={false} to the span in https://github.com/sibiraj-s/svelte-tiptap/blob/master/src/routes/_components/Editable.svelte and it fixed the issue.

Thanks @aivo0 . I did not notice your comment. Yes indeed that is the solution. Make sure to add contenteditable=false to the elements that are not intended to be edited.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in the thread.