Skip to content

Comments

Add SDK notes app for testing SDK value plugin#2222

Draft
christianhg wants to merge 8 commits intomainfrom
feat/sdk-notes-app
Draft

Add SDK notes app for testing SDK value plugin#2222
christianhg wants to merge 8 commits intomainfrom
feat/sdk-notes-app

Conversation

@christianhg
Copy link
Member

Minimal React app in apps/sdk-notes/ for testing the SDK value plugin end-to-end against a real Sanity content lake.

What

A notes app that connects to Sanity project q444gl2w via @sanity/sdk-react. Features:

  • Note list sidebar (useDocuments + useDocumentPreview)
  • Create new notes (createDocument)
  • Title editing (useDocument + useEditDocument)
  • Body editing via PTE + SDKValuePlugin
  • Built-in auth (browser login redirect, no tokens)

How to run

pnpm --filter sdk-notes dev

Opens at http://localhost:5173/. First load redirects to Sanity login.

Notes

  • Private app, not published
  • Schema: note doc type with title (string) + body (portable text)
  • Vite aliases resolve workspace packages to src/ for live development

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.
lodash is CJS-only and doesn't resolve under Node's ESM module
resolution. Since the editor package is "type": "module", downstream
consumers running tests in Node (e.g. Vitest) fail with
"Cannot find module 'lodash/debounce'".

Replaces the two lodash imports from vendored Slate with minimal
inline implementations and removes lodash from dependencies.
@vercel
Copy link

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

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Feb 20, 2026

🦋 Changeset detected

Latest commit: 0acd377

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

This PR includes changesets to release 12 packages
Name Type
@portabletext/editor Minor
sdk-notes Patch
@portabletext/plugin-character-pair-decorator Major
@portabletext/plugin-emoji-picker Patch
@portabletext/plugin-input-rule Patch
@portabletext/plugin-markdown-shortcuts Major
@portabletext/plugin-one-line Major
@portabletext/plugin-paste-link Major
@portabletext/plugin-sdk-value Major
@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

@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedvitest@​4.0.18961007999100
Added@​sanity/​sdk@​2.7.09810082100100
Added@​sanity/​sdk-react@​2.7.089100100100100

View full report

Minimal React app in apps/sdk-notes/ for testing the SDK value plugin
end-to-end with a real Sanity content lake connection.

Features:
- SanityApp provider with built-in auth (browser login redirect)
- Note list sidebar using useDocuments + useDocumentPreview
- Create new notes via useApplyDocumentActions + createDocument
- Title editing via useEditDocument
- PTE body editing via EditorProvider + SDKValuePlugin
- Vite aliases for workspace packages (editor, patches, schema, plugin-sdk-value)

Project: q444gl2w, dataset: production, doc type: note
Run with: pnpm --filter sdk-notes dev
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