Fix issues with decorations in nested and repeater fields #403
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.
co-authored-by: @rhystmills
What does this change?
#349 fixes a problem with decorations in
NestedFieldView
elements, but introduces an issue with repeater fields – the problem is illustrated in 14586e2.The likely cause of this problem is that prosemirror-elements has always passed decorations directly to child editor instances without altering their depth.
This seems to have worked while the decorations and the document have been in sync – by mapping Decorations to ensure that the relevant field always indexes into the correct position, child editors pick up the correct decoration set and ignore other decorations. (I think this is an artefact of the way Decorations are structured, as they are indexed with a start and end position, and as long as these line up with the relevant
Node
, things work as they normally would.)But as we traverse the boundary between parent and child editors supporting elements, as we do in
NestedElementFieldView
, we introduce a shift in the document structure that introduces out-of-bounds errors. A detailed write up of this case to come.The solution is likely to be to only pass exactly the decorations that are needed to each view, building on the useful API that was introduced in implementing #349.
How to test
How can we measure success?
Problems with decorations in complex documents are resolved downstream.