refactor: remove compound op types from Path.transform and Point.transform#2343
Closed
christianhg wants to merge 1 commit intomainfrom
Closed
refactor: remove compound op types from Path.transform and Point.transform#2343christianhg wants to merge 1 commit intomainfrom
christianhg wants to merge 1 commit intomainfrom
Conversation
…sform Remove merge_node, split_node, and move_node from the 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 ops 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 RangeRefs during inlined transforms (inward affinity on a forward range needs anchor=forward, focus=backward). Also removes dead split_node check in diff-text.ts.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Contributor
📦 Bundle Stats —
|
| Metric | Value | vs main (d312abd) |
|---|---|---|
| Internal (raw) | 801.3 KB | +291 B, +0.0% |
| Internal (gzip) | 150.4 KB | +82 B, +0.1% |
| Bundled (raw) | 1.41 MB | +291 B, +0.0% |
| Bundled (gzip) | 313.3 KB | +98 B, +0.0% |
| Import time | 92ms | +1ms, +0.6% |
@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, -1.0% |
@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 | 11ms | -0ms, -0.7% |
@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 | 10ms | -0ms, -0.5% |
@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 | 9ms | +0ms, +2.6% |
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.
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.
Slate's
Path.transformandPoint.transformstill handledmerge_node,split_node, andmove_nodeoperations even though these compound types are no longer emitted througheditor.apply- they were decomposed into lower-level operations in #2327. This PR removes the compound types from the Slate type system entirely and inlines the transform logic into the three apply helpers that still need it.After #2327,
applyMergeNode,applySplitNode, andapplyMoveNodedecompose compound operations intoinsert_node,remove_node,insert_text, andremove_text. But they still need the compound operation's ref-transform semantics: a merge shifts paths differently than the equivalentinsert_text+remove_nodesequence. The helpers handle this by pre-transforming all active refs with the compound semantics, then suppressing ref transforms for the decomposed operations.Previously, this pre-transform step delegated to
Path.transformandPoint.transform, 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 and move). The compound types are then removed fromPath.transform,Point.transform,Operation.inverse,operationCanTransformPath, theOperationunion, andCustomTypes.Path.transformnow only handlesinsert_nodeandremove_node. The 130-line function drops to 30 lines.Point.transformloses three cases.Operation.inverseloses three cases (including the most complex one -move_nodeinverse required transforming paths through the operation itself).The inlining surfaced a subtle bug in how
RangeRefaffinities were being 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 for all three apply helpers.Also removes a dead
split_nodecheck indiff-text.ts(transformPendingPoint) that could never trigger sincesplit_nodeoperations are no longer emitted.