Nested Editor Instance

I have a NodeView that uses an inner PM instance to manage its content. The innerView dispatches transactions to update the outerView’s document and selection. Similar to the Footnote example.

My issue is that when the innerView sets the outerView’s selection, the outerView immediately resets its selection to the first position within the NodeView.

It looks like from a trace() that when the outerView updates, it sees a selection change and fires readDOMChange and syncs its selection to the DOM. Since the NodeView is opaque to it, it sets selection to the first position in the NodeView. This happens even when the outerView is not focused.

For the NodeView, stopEvent, and ignoreMutation are both set to true, and the mousedown event on the innerView is set to make sure focus is on the innerView rather than the outerView.

I thought this was working correctly ~ 6 months ago. Any idea what I am doing wrong? Is it possible to suppress the outerView from updating the selection?

1 Like

This rfc aims to solve this. I’ll try to move it forward today.

On second thought—since you are using a nested ProseMirror, the selection should already not be on the outer editor, so this problem shouldn’t be occurring.

Could it be that there’s no uneditable wrapper node around your inner editor? That might mess up the focus division (the browser will treat both editors as a single editable element and focus the outer one when you are working in the inner one) and cause this issue (along with a number of other issues in the inner editor).

Hi Marijn, thanks for the response.

since you are using a nested ProseMirror, the selection should already not be on the outer editor, so this problem shouldn’t be occurring.

I dispatch transactions from the innerView to the outerView to explicity update the selection on the outerEditor.

Could it be that there’s no uneditable wrapper node around your inner editor? That might mess up the focus division (the browser will treat both editors as a single editable element and focus the outer one when you are working in the inner one) and cause this issue (along with a number of other issues in the inner editor).

No, there is an uneditable wrapper around the inner editor. I have confirmed that after the innerView is focused, that focus stays on the innerView even when the outerView updates its selection. Focus is not a problem.

This rfc aims to solve this. I’ll try to move it forward today.

Awesome.