fix: remove internal compound operations completely#2346
Merged
christianhg merged 5 commits intomainfrom Mar 11, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 20650bf 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 |
Contributor
📦 Bundle Stats —
|
| Metric | Value | vs main (d312abd) |
|---|---|---|
| Internal (raw) | 798.3 KB | -2.7 KB, -0.3% |
| Internal (gzip) | 150.0 KB | -281 B, -0.2% |
| Bundled (raw) | 1.40 MB | -2.7 KB, -0.2% |
| Bundled (gzip) | 313.0 KB | -262 B, -0.1% |
| Import time | 102ms | +0ms, +0.4% |
@portabletext/editor/behaviors
| Metric | Value | vs main (d312abd) |
|---|---|---|
| Internal (raw) | 467 B | - |
| Internal (gzip) | 207 B | - |
| Bundled (raw) | 424 B | - |
| Bundled (gzip) | 171 B | - |
| Import time | 6ms | +0ms, +0.8% |
@portabletext/editor/plugins
| Metric | Value | vs main (d312abd) |
|---|---|---|
| Internal (raw) | 2.5 KB | - |
| Internal (gzip) | 910 B | - |
| Bundled (raw) | 2.3 KB | - |
| Bundled (gzip) | 839 B | - |
| Import time | 12ms | -0ms, -0.6% |
@portabletext/editor/selectors
| Metric | Value | vs main (d312abd) |
|---|---|---|
| Internal (raw) | 60.2 KB | - |
| Internal (gzip) | 9.4 KB | - |
| Bundled (raw) | 56.7 KB | - |
| Bundled (gzip) | 8.6 KB | - |
| Import time | 11ms | +0ms, +0.9% |
@portabletext/editor/utils
| Metric | Value | vs main (d312abd) |
|---|---|---|
| Internal (raw) | 24.2 KB | - |
| Internal (gzip) | 4.7 KB | - |
| Bundled (raw) | 22.2 KB | - |
| Bundled (gzip) | 4.4 KB | - |
| Import time | 10ms | +0ms, +1.0% |
Details
- Import time regressions over 10% are flagged with
⚠️ - Treemap artifacts are attached to the CI run for detailed size analysis
- Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
c111aea to
f11577b
Compare
f11577b to
f85dd09
Compare
f85dd09 to
a46b5a0
Compare
b8a5e2c to
90b25b1
Compare
Remove `merge_node`, `split_node`, and `move_node` from the internal Slate `Operation` union, `Operation.inverse`, `Path.transform`, `Point.transform`, and `operationCanTransformPath`. These compound operations are no longer emitted through `editor.apply` (they were decomposed into lower-level operations in the patch-compliant operations work). The apply helpers (`applyMergeNode`, `applySplitNode`, `applyMoveNode`) still construct virtual compound operations internally for ref pre-transformation, but now inline the transform logic directly instead of delegating to `Path.transform`/`Point.transform`. Adds `rangeRefAffinities` helper to correctly resolve per-point affinity for `RangeRef`s during inlined transforms (inward affinity on a forward range needs `anchor=forward`, `focus=backward`). Also removes dead `split_node` check in `diff-text.ts`.
e41c00f to
20650bf
Compare
Merged
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.
After #2327 decomposed
split_node,merge_node, andmove_nodeinto lower-level operations, the compound types lingered in the Slate type system -Path.transform,Point.transform,Operation.inverse, and theOperationunion all still handled cases that could never fire. This PR removes them entirely, inlines the transform logic that the two remaining apply helpers need, and deletesapplyMoveNodealong with the dead code paths it was keeping alive.applyMergeNodeandapplySplitNodedecompose compound operations into lower-level ones, but they still need the compound operation's ref-transform semantics: a merge shifts paths differently than the equivalentinsert_text+remove_nodesequence. Previously they delegated toPath.transformandPoint.transformfor this, which meant those functions had to keep the compound operation cases around even though no other code path used them. This PR inlines the transform logic directly into each helper as localtransformPathForMerge,transformPointForMerge(and equivalents for split), then removes the compound types fromPath.transform,Point.transform,Operation.inverse,operationCanTransformPath, theOperationunion, andCustomTypes.Path.transformdrops from 130 lines to 30 - it now only handlesinsert_nodeandremove_node.Point.transformandOperation.inverseeach lose three cases, including the most complex one (move_nodeinverse required transforming paths through the operation itself).applyMoveNodeis removed entirely. Its two call sites (operation.move.block.tsanddelete-text.ts) now use plainremove_node+insert_nodedirectly. The move helper's 180+ lines of ref pre-transform machinery had zero test coverage because the selection fixup it provided was redundant at both call sites:operation.move.block.tsalready does manual selection fixup after the move, anddelete-text.tsrelies onapplyMergeNodeto handle selection immediately after.The inlining surfaced a subtle detail in how
RangeRefaffinities are resolved. When aRangeRefhas'inward'affinity, the anchor and focus need different per-point affinities: on a forward range, the anchor gets'forward'and the focus gets'backward'(they contract toward each other). The old code got this for free through theRange.transform->Point.transformchain. The inlined version needs it explicitly. A sharedrangeRefAffinitieshelper resolves per-point affinities forapplySplitNode- the only remaining helper where affinity matters, since merge point transforms don't depend on affinity.Also cleans up dead code exposed by the removal: a
split_nodecheck intransformPendingPoint(diff-text.ts) that could never trigger, the unusedpropertiesparameter onapplyMergeNode, dead inline-Element and block-level branches inapplyInsertNodeAtPoint(impossible in the PT-native tree where inline objects are ObjectNodes, not Elements), and unused insert options onapplyInsertNodeAtPath/applyInsertNodeAtPoint.The operation vocabulary is now fully reduced:
insert_node,remove_node,insert_text,remove_text,set_node, andset_selection. Two helpers remain (applySplitNode,applyMergeNode) that compose these into higher-level semantics with correct ref transforms. The next step is generalizingoperation-to-patches.tsto use key-based paths for container support (#2336).