-
Notifications
You must be signed in to change notification settings - Fork 135
Description
Hi,
I was not sure what was the right place to report issues for the the Codemirror NodeView demo, but since source for it is here I've decided to do it here.
Here is the list of things I found to not behave according to (at least my) expectations:
-
If you place a cursor right after the editor view and hit backspace it moves text under the text editor into the editor itself. I am not entirely sure what would make sense here. I suspect one of the following:
- Select an editor NodeView as it matches what happens if you had a "Horizontal rule" in the place of editor. If you do press
backspaceonce again delete the whole editor view. I think even though this requires additional press onbackspaceit does provide user clear signal what's about to happen. - Select an editor NodeView when cursor is right in front or after the NodeView. I think this would clearly communicate that delete / backspace will get rid of NodeView without extra keypress.
- Just move cursor into the
NodeView, essentially do whatArrowLeftwould have done. I'm not sure if that behavior would be intuitive but I suspect less surprising. - Move cursor into the
NodeViewand delete last character in it. I'm not really in favor of it, but that is certainly an option.
I think it would also make sense to add
Ctrl-Backspacekeybinding to perform current behavior (move text after cursor into the editor view) and extendCtrl-Enterkeybinding to somewhat do what it already does but more closely mirrorCtrl-Backspacein otherCtrlmodifier would allow you to move text in & out of the editor view. - Select an editor NodeView as it matches what happens if you had a "Horizontal rule" in the place of editor. If you do press
-
If you place cursor right before the editor view and hit delete it appends editor content to the previous line removing editor if line of the cursor isn't empty, or it remove empty line the cursor is on and moves cursor into an editor.
Not going to list all the options here but would expect option to just mirror choice above. I also would expect that behavior to be the same regardless of whether line of cursor is empty or not.
-
If you delete all the content of the editor and keep pressing
backspacenothing happens. In fact only way to remove editor is to delete all the content then place cursor in front of the editor and press delete. Here's options I think would provide more intuitive behavior:- If highlighting an
NodeViewon first backspace / delete is a chosen solution, then there's nothing to do it would actually cover this. - If editor content is emptied and
backspaceis pressed just deleteNodeView. Same fordeleteif editor content is empty it should probably just delete editor node.
- If highlighting an
-
If you have text selected before the editor and keep extending selection with
Shift-ArrowRight/Shift-ArrowDownkeys nothing happens. On the other hand if you have text selected right after the editor and useShift-ArrowLeftit extends selection with in the editor but only per line basis andShift-ArrowUpdoes nothing. Also note that extending selection from with-in the editor to the outside of it does not work at all.- I'm not sure that extending selection with in the editor makes much sense, maybe treating as
NodeViewas atomic would make more sense here.
- I'm not sure that extending selection with in the editor makes much sense, maybe treating as
-
If you have selection with-in the editor and you click outside of the editor text remains selected. Not saying it's incorrect but I wanted to point this out as well as it would help in the summary below.
Summary
I think my general observation is that there must be two different types of NodeView:
Atomic NodeView (kind of a Portal)
Such NodeView could be treated be treated from the outside as a single characters, except when cursor moves across it (cursor is moved across it or user clicks it) NodeView hook could onEnter(dir) is invoked which NodeView could cancel to take over the ProseMirror's events and perform all the range manipulation internally. It can also possibly exit itself whenever that makes sense (like when cursor is moved passed it's own content or Ctrl-Enter etc...)
all the events are from the ProseMirror are delegated to it. NodeView could also be responsible of triggering exiting itself (moving cursor past the NodeView).
Inline NodeView (just a alternate rendering of text range)
I need to look into more details to write something up, but my intuition is that it might be useful to have a NodeView which does just a rendering of a text range, meaning that all of the actual event handling (cursor positioning, selection, etc...) is taken care of by a ProseMirror while the rendering of the state is delegated to this NodeView.
As I don't know nearly enough about ProseMirror I might be drawing wrong conclusions, but it seems to me there would be a value in some of the cursor handling out to the NodeView interface so that NodeView implementer does not need to handle all of the edge cases for entering / deleting NodeView or care about details of keymap that ProseMirror has being setup with (for example I tend to use ctrl-f / ctr-b for navigation which works as expected in ProseMirror except it won't actually enter the the embedded editor as no mapping was setup).