feat: support container normalization#2481
Merged
christianhg merged 1 commit intomainfrom Apr 9, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: 1ec7153 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 (3a75130) |
|---|---|---|
| Internal (raw) | 765.4 KB | +8.4 KB, +1.1% |
| Internal (gzip) | 144.6 KB | +1.6 KB, +1.1% |
| Bundled (raw) | 1.36 MB | +8.4 KB, +0.6% |
| Bundled (gzip) | 305.1 KB | +1.6 KB, +0.5% |
| Import time | 94ms | +0ms, +0.2% |
@portabletext/editor/behaviors
| Metric | Value | vs main (3a75130) |
|---|---|---|
| Internal (raw) | 467 B | - |
| Internal (gzip) | 207 B | - |
| Bundled (raw) | 424 B | - |
| Bundled (gzip) | 171 B | - |
| Import time | 2ms | -0ms, -1.7% |
@portabletext/editor/plugins
| Metric | Value | vs main (3a75130) |
|---|---|---|
| Internal (raw) | 2.5 KB | - |
| Internal (gzip) | 910 B | - |
| Bundled (raw) | 2.3 KB | - |
| Bundled (gzip) | 839 B | - |
| Import time | 8ms | -0ms, -0.2% |
@portabletext/editor/selectors
| Metric | Value | vs main (3a75130) |
|---|---|---|
| Internal (raw) | 60.5 KB | - |
| Internal (gzip) | 9.5 KB | - |
| Bundled (raw) | 56.9 KB | - |
| Bundled (gzip) | 8.7 KB | - |
| Import time | 6ms | -0ms, -1.8% |
@portabletext/editor/utils
| Metric | Value | vs main (3a75130) |
|---|---|---|
| Internal (raw) | 24.2 KB | - |
| Internal (gzip) | 4.7 KB | - |
| Bundled (raw) | 22.2 KB | - |
| Bundled (gzip) | 4.4 KB | - |
| Import time | 6ms | -0ms, -1.5% |
🗺️ . · ./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.
de118c1 to
326d89e
Compare
326d89e to
7dba465
Compare
7dba465 to
d813b86
Compare
cbaaa79 to
6d0b46b
Compare
6d0b46b to
4ea2047
Compare
e6a1343 to
1ec7153
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.
Editable containers need the same structural guarantees as text blocks: their child array field must exist and must not be empty. Without this, a cursor can never be placed inside a container, because there's no leaf node to anchor to.
The normalization is schema-driven and scope-aware. Container types use scoped dot-separated names in
editableTypes(e.g.,table,table.row,table.row.cell), but nodes in the tree only carry bare type names (row,cell). Every function that needs to identify a container type must reconstruct the scoped name by walking ancestor nodes. This applies tonormalize-node.ts,modify.ts, andget-dirty-paths.ts.getDirtyPathsis the critical piece. When an operation inserts or replaces nodes, their descendants need to be dirtied so the normalizer visits them.collectDescendantPathsthreads ascopePrefixthrough recursion, building the scoped name at each level. Forset_node(where the sync machine replaces a container's child array atomically),buildScopeContextwalks the tree to the target node to recover the scope. Numeric indices are used throughout instead of keyed lookups, because pre-normalization nodes can have duplicate keys.The normalization is gated by
editableTypes, which is only populated when a renderer is registered. This PR includes the internal rendering pipeline so the normalization can be tested. The pipeline has no public API surface. Tests configure it by sendingregister rendererevents directly to the editor actor.When a renderer is registered after the editor is already loaded (late registration),
syncEditableTypescallsnormalize(force: true)to visit existing container nodes, theneditor.onChange()to flow the changes back to the machine context.15 browser tests cover: table and callout normalization cascades, text blocks with missing children inside containers, duplicate keys, void containers left untouched, incoming patches that unset container fields, remote value updates with deeply nested childless blocks, removing the last child from a container, and late renderer registration.