Skip to content

Comments

feat!: rewrite sanity-bridge for direct Sanity-to-Schema conversion#2207

Draft
christianhg wants to merge 3 commits intomainfrom
bridge-v3
Draft

feat!: rewrite sanity-bridge for direct Sanity-to-Schema conversion#2207
christianhg wants to merge 3 commits intomainfrom
bridge-v3

Conversation

@christianhg
Copy link
Member

Summary

Rewrites sanitySchemaToPortableTextSchema to produce a PTE Schema directly from the Sanity schema, removing the intermediate PortableTextMemberSchemaTypes representation.

This is a follow-up to the v6 work on editor-remove-sanity-deps. With PTE v6 no longer exporting PortableTextMemberSchemaTypes or using it internally, the bridge no longer needs the two-step conversion (createPortableTextMemberSchemaTypes then portableTextMemberSchemaTypesToSchema). The rewritten function walks the Sanity schema and maps directly to the PTE Schema shape.

Changes

Rewritten:

  • sanitySchemaToPortableTextSchema - walks the compiled Sanity ArraySchemaType and produces a PTE Schema directly. The extraction logic (finding block type, span type, styles, decorators, lists, annotations, block objects, inline objects) and the mapping logic (converting Sanity types to PTE schema types) are combined into a single pass.

Removed:

  • compileSchemaDefinitionToPortableTextMemberSchemaTypes - no consumers after v6 (editor tests migrated to @portabletext/schema)
  • portableTextMemberSchemaTypesToSchema - only consumer was sanitySchemaToPortableTextSchema (now rewritten)
  • schema-definition-to-portable-text-member-schema-types.test.ts - tests for the removed function

Kept (Studio still imports these):

  • createPortableTextMemberSchemaTypes - Studio uses this in its own PortableTextMemberSchemaTypesProvider context
  • PortableTextMemberSchemaTypes type - used by Studio's type firewall pattern

Tests:

  • Updated sanity-schema-to-portable-text-schema.test.ts: removed the "compiled back and forth" test (used removed functions), replaced with a "compiled schema with custom block and inline objects" test that verifies the direct path handles block objects and inline objects correctly.

Breaking changes

  • compileSchemaDefinitionToPortableTextMemberSchemaTypes removed
  • portableTextMemberSchemaTypesToSchema removed

Rewrite sanitySchemaToPortableTextSchema to produce a PTE Schema
directly from the Sanity schema, removing the intermediate
PortableTextMemberSchemaTypes representation.

Removed exports:
- compileSchemaDefinitionToPortableTextMemberSchemaTypes
- portableTextMemberSchemaTypesToSchema

Kept exports (Studio still uses these):
- createPortableTextMemberSchemaTypes
- PortableTextMemberSchemaTypes type
- sanitySchemaToPortableTextSchema
@changeset-bot
Copy link

changeset-bot bot commented Feb 19, 2026

🦋 Changeset detected

Latest commit: 69673ea

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

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

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

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

Request Review

These were only used by the removed
compileSchemaDefinitionToPortableTextMemberSchemaTypes function.
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