Skip to content

Upgrade to slate 0.142.1 and sync the bundled history with slate-history - #5172

Merged
zbeyens merged 13 commits into
mainfrom
slate-0.136
Oct 16, 2026
Merged

zbeyens merged 13 commits into
mainfrom
slate-0.136

Conversation

@dylans

@dylans dylans commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator
  • Auto release

Plan (when applicable): none.

Why

main pins slate 0.132.0, slate-dom 0.132.0, slate-react 0.132.0 and slate-hyperscript 0.129.1. This PR moves Plate to the latest releases: slate 0.142.1, slate-dom 0.142.0, slate-react 0.142.0 and slate-hyperscript 0.138.3. The releases in between carry Android and IME input fixes, Firefox and WebKit caret fixes, scrolling fixes and core transform fixes.

The upgrade needs two changes in @platejs/slate:

  • hasRange. slate 0.134 added editor.hasRange to core, and DOMEditor.hasRange now delegates to it. syncLegacyMethods copies core editor methods into editor.api, so core's hasRange, which throws on a missing range, replaced Plate's try/catch version.
  • History. Plate's bundled copy of slate-history predates four upstream PRs (#5837, #5866, #6063, #6308). Each fixes a live bug in Plate, and each fixed case has a test in this PR that fails without the fix.

Scope

  • packages/core, packages/slate, packages/test-utils, apps/www: bump the slate packages. The lockfile changes only the slate entries.
  • packages/slate/src/internal/dom-editor/hasRange.ts: calls slate's hasRange inside the existing try/catch. create-editor.ts also assigns it to editor.hasRange, so editor.hasRange, editor.api.hasRange and DOMEditor.hasRange share one implementation and can't call each other in a loop.
  • packages/slate/src/slate-history/history.ts:
    • withoutSaving, withoutMerging, withMerging and withNewBatch restore their flags in finally (slate #5837, #6063).
    • A nested withNewBatch keeps the outer split (#6063).
  • packages/slate/src/slate-history/with-history.ts:
    • An operation merges into the last batch only when that batch's last op ran in the current tick (#5866), not whenever any operation ran in the tick.
    • Inside withoutMerging, a transform's normalization stays in the same undo step as the transform (#6308).
  • The bundled history now matches slate-history 0.140.0. Plate's own additions are unchanged: restoring the selection on redo, setNodesBatch and cloneRange.
  • Changesets: @platejs/core and @platejs/slate patch.

Blast radius

Every Plate editor gets the new slate, slate-dom and slate-react. These are the changes since 0.132 that users or plugin authors may notice:

  • Paste. Multi-line plain-text paste outside an inline now calls insertFragment once instead of insertText per line, with an insert_node per middle line instead of a split_node (slate #6265). Plugins that override insertText to catch multi-line pastes no longer see them. Editors with MarkdownPlugin parse plain text first and don't reach this path. Pasting a block void such as an image mid-block now splits the block (#5937).
  • Deletion. Deleting a range from the start of one block to the start of a later sibling removes the selected blocks instead of emptying them (#6282). Triple-click whole-block deletion applies only to top-level blocks, so table cells survive cut and drag (#6287).
  • Words. Word deletion and movement use Intl.Segmenter, so Chinese, Japanese and Thai text steps by word (#6268).
  • Read-only editors. slate-react now calls caller-provided event handlers on read-only editors (#6294). Plate plugin handlers on read-only editors now run unless the plugin sets editOnly, because Plate's pipeHandler already decides that per plugin.
  • Errors. Slate's DOM handlers no longer throw DOM mapping errors. A failure after the DOM settles goes to editor.onDOMError, which calls reportError by default (#6266). An invalid mergeNodes call that mixes block and inline children now throws instead of letting normalization discard content (#6304).
  • Other. insertText keeps a null selection unless called with select: true (#6281). Copied HTML keeps list wrappers when the selection spans list items (#6241). The placeholder sets aria-placeholder on the editor root and aria-hidden on its span (#6306).

The history changes affect undo grouping only in these cases: a callback that throws, a nested withNewBatch, a selection change followed by an edit in the same tick, and normalization inside withoutMerging.

Verification

  • pnpm check exits 0 on the head commit (workflow check, lint, typecheck, test:all, test:slowest). CI is green.
  • New tests that fail without the fix:
    • packages/slate/src/slate-history/upstream-parity.spec.tsx: one case per history fix.
    • packages/slate/src/internal/dom-editor/hasRange.spec.ts: the missing-range case throws without the fix.
  • Browser smoke on /blocks/playground with slate 0.142.1, Chromium: typing, Enter, word delete, undo and redo grouping, and multi-line plain-text paste with a one-step undo. No console errors. An earlier run on 0.136 covered Chromium, Firefox and WebKit, including bold, markdown shortcuts, select-all delete, copy and paste, and Chinese IME composition in Chromium.
  • Not tested: tables, drag and drop, comments, AI and mobile devices. Plate's e2e suite is disabled in CI, so these have no browser coverage.

@dylans
dylans requested a review from a team October 14, 2026 16:21
@codesandbox

codesandbox Bot commented Oct 14, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web Editor • VS Code • Insiders

Open Preview

@changeset-bot

changeset-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 37826dd

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

This PR includes changesets to release 3 packages
Name Type
@platejs/core Patch
@platejs/slate Patch
@platejs/test-utils 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

@dylans dylans changed the title Upgrade to slate 0.136 and sync the bundled history with slate-history Upgrade to slate 0.137 and sync the bundled history with slate-history Oct 14, 2026
@dylans dylans changed the title Upgrade to slate 0.137 and sync the bundled history with slate-history Upgrade to slate 0.138 and sync the bundled history with slate-history Oct 14, 2026
# Conflicts:
#	apps/www/package.json
#	packages/core/package.json
#	packages/slate/package.json
#	packages/test-utils/package.json
#	pnpm-lock.yaml
# Conflicts:
#	apps/www/package.json
#	packages/core/package.json
#	packages/slate/package.json
#	packages/test-utils/package.json
#	pnpm-lock.yaml
…rging

Port slate-history 0.140.0 (ianstormtaylor/slate#6308) to the bundled
history: a new undo step starts only once the document is normalized.
@dylans dylans changed the title Upgrade to slate 0.138 and sync the bundled history with slate-history Upgrade to slate 0.142.1 and sync the bundled history with slate-history Oct 16, 2026
@zbeyens
zbeyens merged commit 9a7c657 into main Oct 16, 2026
14 checks passed
@zbeyens
zbeyens deleted the slate-0.136 branch October 16, 2026 22:47
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.

2 participants