Skip to content

fix: make diffMatchPatch container-aware#2494

Merged
christianhg merged 1 commit intomainfrom
fix/container-aware-diffmatchpatch
Apr 13, 2026
Merged

fix: make diffMatchPatch container-aware#2494
christianhg merged 1 commit intomainfrom
fix/container-aware-diffmatchpatch

Conversation

@christianhg
Copy link
Copy Markdown
Member

Incoming diffMatchPatch patches assume the target span lives at depth 2: root block → children → span → text. This breaks for containers where the span can be at any depth.

The fix replaces the manual findBlock + findBlockChild lookup with getNode(editor, spanPath) which resolves the span at any depth using the schema-aware node traversal. The path from the patch is used directly for insert_text/remove_text operations instead of being reconstructed from block and child keys.

findBlock and findBlockChild were only used by diffMatchPatch and are now deleted.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 13, 2026

🦋 Changeset detected

Latest commit: 884f6ee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@portabletext/editor Patch
@portabletext/plugin-character-pair-decorator Patch
@portabletext/plugin-emoji-picker Patch
@portabletext/plugin-input-rule Patch
@portabletext/plugin-markdown-shortcuts Patch
@portabletext/plugin-one-line Patch
@portabletext/plugin-paste-link Patch
@portabletext/plugin-sdk-value Patch
@portabletext/plugin-typeahead-picker Patch
@portabletext/plugin-typography Patch
@portabletext/toolbar Patch

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

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
portable-text-editor-documentation Ready Ready Preview, Comment Apr 13, 2026 11:52am
portable-text-example-basic Ready Ready Preview, Comment Apr 13, 2026 11:52am
portable-text-playground Ready Ready Preview, Comment Apr 13, 2026 11:52am

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

📦 Bundle Stats — @portabletext/editor

Compared against main (e3651501)

@portabletext/editor

Metric Value vs main (e365150)
Internal (raw) 755.4 KB -1.0 KB, -0.1%
Internal (gzip) 142.9 KB -218 B, -0.1%
Bundled (raw) 1.35 MB -1.0 KB, -0.1%
Bundled (gzip) 303.6 KB -220 B, -0.1%
Import time 99ms +1ms, +0.8%

@portabletext/editor/behaviors

Metric Value vs main (e365150)
Internal (raw) 467 B -
Internal (gzip) 207 B -
Bundled (raw) 424 B -
Bundled (gzip) 171 B -
Import time 3ms +0ms, +0.1%

@portabletext/editor/plugins

Metric Value vs main (e365150)
Internal (raw) 2.5 KB -
Internal (gzip) 910 B -
Bundled (raw) 2.3 KB -
Bundled (gzip) 839 B -
Import time 8ms +0ms, +2.8%

@portabletext/editor/selectors

Metric Value vs main (e365150)
Internal (raw) 60.5 KB -
Internal (gzip) 9.5 KB -
Bundled (raw) 56.9 KB -
Bundled (gzip) 8.7 KB -
Import time 6ms -0ms, -0.7%

@portabletext/editor/utils

Metric Value vs main (e365150)
Internal (raw) 24.2 KB -
Internal (gzip) 4.7 KB -
Bundled (raw) 22.2 KB -
Bundled (gzip) 4.4 KB -
Import time 6ms +0ms, +0.1%

🗺️ . · ./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.

@christianhg christianhg enabled auto-merge (rebase) April 13, 2026 11:53
@christianhg christianhg merged commit 7d1ab61 into main Apr 13, 2026
17 checks passed
@christianhg christianhg deleted the fix/container-aware-diffmatchpatch branch April 13, 2026 11:56
@ecoscript ecoscript bot mentioned this pull request Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant