[SuperEditor][SuperReader] - Change Document from list of nodes to tree of nodes (Resolves #2278) #2385
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.
[SuperEditor][SuperReader] - Documents within documents (Resolves #2278)
Breaking Change Intentions
This PR is the most impactful change made to
super_editorto date. At the heart of everything insuper_editoris theDocument. This PR changes the fundamental structure ofDocument. Therefore, it's unavoidable that this PR will create many breaking changes.However, in this PR I'm attempting to minimize those breakages where I can. For example, all
EditRequests andEditCommands must now take a node path, instead of a node ID, because nodes are in a tree. Rather than force everyone to deal with this immediately, this PR retains the existingnodeIdproperty, deprecates it, and adds adocumentPathproperty to these objects. This way, existing apps that only use a list of nodes will still work, and apps that want a document tree can opt in, by passing a path instead of a node ID.Migration Guide
Document Position Node ID:
Get node path from node:
Sometimes you have a reference to a
DocumentNodeand you need the full path within the document to get to that node. To obtain that, you need to ask theDocumentfor the path:Get node from node path:
Sometimes you have a
NodePathand you want theDocumentNodethat the path points to. You could iteratively query the document tree, but that's very tedious. TheDocumentprovides a query to get the node for a node path: