Prevent model selection synchronizing to DOMSelection during selection. #151
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current behavior: Now there are some selection issues that are bothering me, e.g.
A NodeView with margin(margin-left and margin-right), when select from NodeView's right to left, the selection is collapsed accidentally.
A NodeView that regardless of margin, when select from NodeView's right to left, and shuffling between text and NodeView, the anchor of the selection was be collapse to NodeView left.
A NodeView that has content in the schema but does not set with contentDOM, when select from NodeView's right to left, and shuffling between text and NodeView, the anchor of the selection was be collapse to NodeView left.
Expected behavior: The selection should not be affected by the element style and "anchor" should be fixed while moving the "focus"
Through some experiments, I found that when I set the selection in the selectionChange callback triggered by mouse interaction, when the set selection is not the "legal" position considered by the browser, the browser may readjust the selection. Therefore, I boldly submitted a PR - In the callback of selectionChange triggered by mouse interaction, do not synchronize selection from model to DOM. I think there might be some unexpected effects, so I'm looking forward to your insight.
Demo to reproduce the issue: Glitch.