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

Support serialization / deserialization of annotations #3092

Closed

Conversation

justinweiss
Copy link
Collaborator

Is this adding or improving a feature or fixing a bug?

Adding a feature

What's the new behavior?

Annotations can now be serialized and deserialized in the same way marks can.

How does this change work?

For serializing, we do the same thing as with marks -- we figure out which annotations apply to a node and pass them to a serializer.

Deserializing is harder, because we don't have paths to the nodes at the time we deserialize them. Instead, when we deserialize an annotation, we add the annotation object to a property of the serializer, and we keep a node-to-annotations lookup table. When we're done deserializing, we walk the value's nodes. If we find a node that has an annotation, we update the path of that annotation to include the node. If an annotation spans several nodes, we expand anchor / focus to span the entire range of those nodes.

Have you checked that...?

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn prettier.)
  • The relevant examples still work. (Run examples with yarn watch.)

Does this fix any issues or need any specific reviewers?

Fixes: #3030
Reviewers: @

@ianstormtaylor
Copy link
Owner

As of #3093 (which was just merged), I believe this issue is no longer applicable, because a lot has changed. I'm going through and closing out any potential issues that are not out of date with the overhaul. Thanks for understanding.

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.

allow annotations to be serialized/deserialized
2 participants