feat: add BlockPathMap with incremental updates#2261
Closed
christianhg wants to merge 2 commits intomainfrom
Closed
feat: add BlockPathMap with incremental updates#2261christianhg wants to merge 2 commits intomainfrom
christianhg wants to merge 2 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 7e3cf64 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
4f926d4 to
680521c
Compare
680521c to
9f96de2
Compare
9f96de2 to
0659d36
Compare
0659d36 to
279cb35
Compare
c68d07d to
9d158ef
Compare
Adds a new `BlockPathMap` class that maps serialized key-paths to indexed paths. Unlike `EditorSnapshot.blockIndexMap` which rebuilds on every structural operation, `BlockPathMap` uses incremental updates, O(affected siblings) instead of O(total blocks).
9d158ef to
1b2cbae
Compare
de45693 to
271858f
Compare
271858f to
4adf9b0
Compare
4adf9b0 to
7e3cf64
Compare
4219e12 to
7e3cf64
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed
Removes the
valuewrapper and__inlineflag from block objects and inline objects in the Slate tree. PT properties now live directly on Slate nodes.The void-child span stays in Slate's tree for cursor behavior — that's a Slate rendering concern, not a data concern. Everything else is pure PT.
Also adds
BlockPathMap— an incremental key-to-path index onEditorSnapshotfor O(1) block lookups.Why
Foundation for container (nested block) support. With the tree PT-native, a container block is just an element with real
children— no special wrapping, no void model to work around.How
PT-native tree (18 files, -188 net lines):
types/slate.ts—VoidElementreplaced withObjectElementvalues.ts—toSlateBlock/fromSlateBlockspread PT properties directlyapply-operation-to-portable-text.ts— removed allvalue/__inlineunwrappingoperation-to-patches.ts— properties read directly from nodesapplyPatch.ts— patches applied directly to nodesslate-plugin.schema.ts—isInlineuses schema onlyrender.element.tsx/render.inline-object.tsx— schema-based inline detectionBlockPathMap:
snapshot.blockPathMap.get(keyPath)— returns the full Slate pathsnapshot.blockPathMap.getIndex(keyPath)— returns the block's index within its parentapplyOperation()blockIndexMappreserved on snapshot for backward compatibility