feat: Portable Text-native node traversal#2398
Merged
christianhg merged 1 commit intomainfrom Mar 24, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: 79e7e88 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📦 Bundle Stats —
|
| Metric | Value | vs main (055bdb1) |
|---|---|---|
| Internal (raw) | 759.2 KB | +4.2 KB, +0.6% |
| Internal (gzip) | 142.9 KB | +937 B, +0.6% |
| Bundled (raw) | 1.37 MB | +4.2 KB, +0.3% |
| Bundled (gzip) | 305.7 KB | +877 B, +0.3% |
| Import time | 97ms | -3ms, -3.3% |
@portabletext/editor/behaviors
| Metric | Value | vs main (055bdb1) |
|---|---|---|
| Internal (raw) | 467 B | - |
| Internal (gzip) | 207 B | - |
| Bundled (raw) | 424 B | - |
| Bundled (gzip) | 171 B | - |
| Import time | 6ms | +0ms, +0.0% |
@portabletext/editor/plugins
| Metric | Value | vs main (055bdb1) |
|---|---|---|
| Internal (raw) | 2.5 KB | - |
| Internal (gzip) | 910 B | - |
| Bundled (raw) | 2.3 KB | - |
| Bundled (gzip) | 839 B | - |
| Import time | 12ms | -0ms, -0.1% |
@portabletext/editor/selectors
| Metric | Value | vs main (055bdb1) |
|---|---|---|
| Internal (raw) | 60.2 KB | - |
| Internal (gzip) | 9.4 KB | - |
| Bundled (raw) | 56.7 KB | - |
| Bundled (gzip) | 8.6 KB | - |
| Import time | 10ms | -0ms, -0.5% |
@portabletext/editor/utils
| Metric | Value | vs main (055bdb1) |
|---|---|---|
| Internal (raw) | 24.2 KB | - |
| Internal (gzip) | 4.7 KB | - |
| Bundled (raw) | 22.2 KB | - |
| Bundled (gzip) | 4.4 KB | - |
| Import time | 9ms | +0ms, +0.8% |
🗺️ . · ./behaviors · ./plugins · ./selectors · ./utils · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
e1709db to
54eedf1
Compare
54eedf1 to
cfdcf10
Compare
a16d425 to
285fe40
Compare
cfdcf10 to
d648f4d
Compare
88a9829 to
d8e304e
Compare
e1ed99b to
5ceaf3a
Compare
Replaces the vendored Slate traversal system with schema-driven functions that resolve children on any node type, not just `.children`. The old system hardcoded `.children` as the only child field, which blocks first-class nesting where children will live in schema-defined fields like `rows`, `cells`, or `content`.
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.
Replaces the vendored Slate traversal system with schema-driven functions that resolve children on any node type, not just
.children. The old system hardcoded.childrenas the only field containing child nodes. The new functions useresolveChildArrayFieldto look up schema-defined child fields for container types like tables, where children live in fields likerows,cells, orcontent. Container traversal is gated byeditableTypes, aSeton the editor listing which object types have registered renderers. Currently empty, so containers traverse as leaf nodes today. A future PR populates it based on registered renderers, enabling container editing without changes to the traversal layer.All traversal functions return
{node, path} | undefinedinstead of throwing on invalid paths. The editor runs in a racy DOM environment where transient path mismatches during React re-renders are expected, not exceptional.This PR makes node finding container-aware. Node manipulation (operations, patches, normalization) still accesses
.childrendirectly and assumes a flat block/span structure. That layer is next.Some call sites grew when higher-level wrappers like
above(),levels(), andnodes()were inlined. These wrappers bundled Location resolution (converting Range/Point/Path to a starting path), ancestor walking, and match filtering into single calls. With them gone, callers compose the primitives directly, which is more explicit but more verbose.getAncestorTextBlockandgetAncestorObjectNodecover the most common patterns cleanly. The remaining cases, particularly indelete-text.tsandremove-nodes.ts, carry the Location resolution and mode-filtering logic that the wrappers used to hide.Also removes
isElementReadOnly,hasInlines, andelementReadOnly(dead code).