Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with decorations in nested and repeater fields #403

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

jonathonherbert
Copy link
Contributor

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

  • The automated tests should pass. They should cover nested, repeated, and nested repeated/repeated nested elements.

How can we measure success?

Problems with decorations in complex documents are resolved downstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant