Skip to content

Comments

fix: bypass editor methods#2200

Open
christianhg wants to merge 4 commits intofeat-vendor-slatefrom
fix-bypass-editor-methods
Open

fix: bypass editor methods#2200
christianhg wants to merge 4 commits intofeat-vendor-slatefrom
fix-bypass-editor-methods

Conversation

@christianhg
Copy link
Member

No description provided.

Vendor `slate@0.120.0`, `slate-dom@0.119.0`, and `slate-react@0.120.0` source
from github.com/ianstormtaylor/slate (tag: slate@0.120.0).

Pure copy of src/ directories — no modifications, no git history.

  packages/editor/src/slate/       — 118 files (slate core)
  packages/editor/src/slate-dom/   — 14 files (DOM integration)
  packages/editor/src/slate-react/ — 40 files (React bindings)
Rewire all bare 'slate', 'slate-dom', 'slate-react' imports to relative
paths. Fix module augmentation (declare module '../slate/index' instead
of 'slate'). Remove slate/slate-dom/slate-react npm dependencies, add
their transitive deps (direction, is-hotkey, lodash, etc.).

Fix 583 TypeScript errors from vendored source hitting PTE's strict
tsconfig (@sanity/tsconfig strictest):

Structural fixes:
- Widen DOMEditor/ReactEditor params to Editor (resolves CustomTypes)
- withDOM/withReact generic: <T extends BaseEditor> → <T extends Editor>
- Remove vendored CustomTypes augmentation (PTE's types/slate.ts is source)
- Convert enum to const object (erasableSyntaxOnly)
- Cast create-editor.ts delegates through any (incremental object build)

Mechanical fixes:
- verbatimModuleSyntax: type-only re-exports (biome --fix)
- erasableSyntaxOnly: angle bracket → as assertions, import aliases
- noUncheckedIndexedAccess: non-null assertions on bounded array access
- Unused variables prefixed with _
- override keyword on React lifecycle methods
- JSX namespace imports for React 19
- React 19 ref types (RefObject<T | null>, useRef(undefined))

Lint fixes:
- Rename String component to SlateString (no shadow global)
- Block statements for single-line ifs
- Explicit types for uninitialized let declarations
- biome-ignore for Slate upstream patterns (hooks in conditionals,
  assignment in expressions, non-null after optional chain)

All 317 unit tests pass. Zero type errors. Zero lint errors.
The vendored Slate source files are now raw TypeScript compiled alongside
PTE, which means the React Compiler babel plugin transforms them. Slate's
components use manual React.memo with custom equality functions that the
React Compiler interferes with, causing incorrect re-render optimization
(skipping renders that should happen).

Exclude src/slate/, src/slate-dom/, and src/slate-react/ from
@vitejs/plugin-react so the React Compiler doesn't process them.
esbuild still handles JSX transformation for these files.
@vercel
Copy link

vercel bot commented Feb 18, 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 Feb 18, 2026 1:35pm
portable-text-example-basic Ready Ready Preview, Comment Feb 18, 2026 1:35pm
portable-text-playground Ready Ready Preview, Comment Feb 18, 2026 1:35pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Feb 18, 2026

⚠️ No Changeset found

Latest commit: 8023585

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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