diff --git a/packages/editor/biome.json b/packages/editor/biome.json
index 235ab0cbd..6a5df69ac 100644
--- a/packages/editor/biome.json
+++ b/packages/editor/biome.json
@@ -4,16 +4,6 @@
"rules": {
"complexity": {
"useLiteralKeys": "off"
- },
- "style": {
- "noRestrictedImports": {
- "level": "error",
- "options": {
- "paths": {
- "@sanity/types": "Import from 'types/sanity-types' instead to maintain visibility over @sanity/types usage."
- }
- }
- }
}
}
}
diff --git a/packages/editor/package.json b/packages/editor/package.json
index 51fadf4b3..b5fa236e1 100644
--- a/packages/editor/package.json
+++ b/packages/editor/package.json
@@ -90,8 +90,6 @@
"@portabletext/patches": "workspace:^",
"@portabletext/schema": "workspace:^",
"@portabletext/to-html": "^5.0.1",
- "@sanity/schema": "^5.6.0",
- "@sanity/types": "^5.6.0",
"@xstate/react": "^6.0.0",
"debug": "^4.4.3",
"slate": "^0.120.0",
@@ -100,7 +98,6 @@
"xstate": "^5.25.0"
},
"devDependencies": {
- "@portabletext/sanity-bridge": "workspace:*",
"@portabletext/test": "workspace:^",
"@sanity/diff-match-patch": "^3.2.0",
"@sanity/pkg-utils": "^10.2.1",
@@ -129,7 +126,6 @@
"vitest-browser-react": "^2.0.2"
},
"peerDependencies": {
- "@portabletext/sanity-bridge": "workspace:^2.0.0",
"react": "^19.2.3",
"rxjs": "^7.8.2"
},
diff --git a/packages/editor/src/converters/converter.text-html.deserialize.test.ts b/packages/editor/src/converters/converter.text-html.deserialize.test.ts
index a25fd037e..7703e3fed 100644
--- a/packages/editor/src/converters/converter.text-html.deserialize.test.ts
+++ b/packages/editor/src/converters/converter.text-html.deserialize.test.ts
@@ -1,4 +1,3 @@
-import {compileSchemaDefinitionToPortableTextMemberSchemaTypes} from '@portabletext/sanity-bridge'
import {
compileSchema,
defineSchema,
@@ -6,13 +5,14 @@ import {
} from '@portabletext/schema'
import {describe, expect, test} from 'vitest'
import {createTestSnapshot} from '../internal-utils/create-test-snapshot'
-import {createConverterTextHtml} from './converter.text-html'
+import {converterTextHtml} from './converter.text-html'
-function createSnapshot(schema: SchemaDefinition) {
+function createSnapshot(schemaDefinition: SchemaDefinition) {
+ const schema = compileSchema(schemaDefinition)
return createTestSnapshot({
context: {
converters: [],
- schema: compileSchema(schema),
+ schema,
},
})
}
@@ -25,12 +25,8 @@ const unorderedList = '
'
const orderedList = '- foo
- bar
'
const nestedList = '- foo
'
-describe(createConverterTextHtml.name, () => {
+describe(converterTextHtml.mimeType, () => {
test('paragraph with unknown decorators', () => {
- const converterTextHtml = createConverterTextHtml(
- compileSchemaDefinitionToPortableTextMemberSchemaTypes(defineSchema({})),
- )
-
expect(
converterTextHtml.deserialize({
snapshot: createSnapshot(defineSchema({})),
@@ -60,14 +56,6 @@ describe(createConverterTextHtml.name, () => {
})
test('paragraph with known decorators', () => {
- const converterTextHtml = createConverterTextHtml(
- compileSchemaDefinitionToPortableTextMemberSchemaTypes(
- defineSchema({
- decorators: [{name: 'strong'}, {name: 'em'}, {name: 'code'}],
- }),
- ),
- )
-
expect(
converterTextHtml.deserialize({
snapshot: createSnapshot(
@@ -113,13 +101,6 @@ describe(createConverterTextHtml.name, () => {
})
test('image', () => {
- const converterTextHtml = createConverterTextHtml(
- compileSchemaDefinitionToPortableTextMemberSchemaTypes(
- defineSchema({
- blockObjects: [{name: 'image'}],
- }),
- ),
- )
expect(
converterTextHtml.deserialize({
snapshot: createSnapshot(
@@ -138,10 +119,6 @@ describe(createConverterTextHtml.name, () => {
})
test('paragraph with unknown link', () => {
- const converterTextHtml = createConverterTextHtml(
- compileSchemaDefinitionToPortableTextMemberSchemaTypes(defineSchema({})),
- )
-
expect(
converterTextHtml.deserialize({
snapshot: createSnapshot(defineSchema({})),
@@ -171,16 +148,6 @@ describe(createConverterTextHtml.name, () => {
})
test('paragraph with known link', () => {
- const converterTextHtml = createConverterTextHtml(
- compileSchemaDefinitionToPortableTextMemberSchemaTypes(
- defineSchema({
- annotations: [
- {name: 'link', fields: [{name: 'href', type: 'string'}]},
- ],
- }),
- ),
- )
-
expect(
converterTextHtml.deserialize({
snapshot: createSnapshot(
@@ -228,14 +195,6 @@ describe(createConverterTextHtml.name, () => {
})
test('unordered list', () => {
- const converterTextHtml = createConverterTextHtml(
- compileSchemaDefinitionToPortableTextMemberSchemaTypes(
- defineSchema({
- lists: [{name: 'bullet'}],
- }),
- ),
- )
-
expect(
converterTextHtml.deserialize({
snapshot: createSnapshot(
@@ -287,14 +246,6 @@ describe(createConverterTextHtml.name, () => {
})
test('ordered list', () => {
- const converterTextHtml = createConverterTextHtml(
- compileSchemaDefinitionToPortableTextMemberSchemaTypes(
- defineSchema({
- lists: [{name: 'number'}],
- }),
- ),
- )
-
expect(
converterTextHtml.deserialize({
snapshot: createSnapshot(
@@ -346,14 +297,6 @@ describe(createConverterTextHtml.name, () => {
})
test('nested list', () => {
- const converterTextHtml = createConverterTextHtml(
- compileSchemaDefinitionToPortableTextMemberSchemaTypes(
- defineSchema({
- lists: [{name: 'bullet'}, {name: 'number'}],
- }),
- ),
- )
-
expect(
converterTextHtml.deserialize({
snapshot: createSnapshot(
diff --git a/packages/editor/src/converters/converter.text-html.serialize.test.ts b/packages/editor/src/converters/converter.text-html.serialize.test.ts
index f4b04d04d..e7d229830 100644
--- a/packages/editor/src/converters/converter.text-html.serialize.test.ts
+++ b/packages/editor/src/converters/converter.text-html.serialize.test.ts
@@ -1,4 +1,3 @@
-import {compileSchemaDefinitionToPortableTextMemberSchemaTypes} from '@portabletext/sanity-bridge'
import {
compileSchema,
defineSchema,
@@ -9,7 +8,7 @@ import {
import {describe, expect, test} from 'vitest'
import {createTestSnapshot} from '../internal-utils/create-test-snapshot'
import type {EditorSelection} from '../types/editor'
-import {createConverterTextHtml} from './converter.text-html'
+import {converterTextHtml} from './converter.text-html'
const decoratedParagraph: PortableTextTextBlock = {
_key: 'k0',
@@ -76,22 +75,22 @@ const paragraphWithInlineBlock: PortableTextTextBlock = {
],
}
-function createSnapshot(schema: SchemaDefinition, selection: EditorSelection) {
+function createSnapshot(
+ schemaDefinition: SchemaDefinition,
+ selection: EditorSelection,
+) {
+ const schema = compileSchema(schemaDefinition)
return createTestSnapshot({
context: {
converters: [],
- schema: compileSchema(schema),
+ schema,
selection,
value: [decoratedParagraph, image, b2, paragraphWithInlineBlock],
},
})
}
-const converterTextHtml = createConverterTextHtml(
- compileSchemaDefinitionToPortableTextMemberSchemaTypes(defineSchema({})),
-)
-
-describe(converterTextHtml.serialize.name, () => {
+describe(converterTextHtml.mimeType, () => {
test('paragraph with decorators', () => {
expect(
converterTextHtml.serialize({
@@ -183,15 +182,16 @@ describe(converterTextHtml.serialize.name, () => {
})
test('lists', () => {
+ const schema = compileSchema(
+ defineSchema({
+ lists: [{name: 'bullet'}, {name: 'number'}],
+ }),
+ )
expect(
converterTextHtml.serialize({
snapshot: createTestSnapshot({
context: {
- schema: compileSchema(
- defineSchema({
- lists: [{name: 'bullet'}, {name: 'number'}],
- }),
- ),
+ schema,
converters: [],
value: [
{
diff --git a/packages/editor/src/converters/converter.text-html.ts b/packages/editor/src/converters/converter.text-html.ts
index fc23b79bc..afd3c1a4a 100644
--- a/packages/editor/src/converters/converter.text-html.ts
+++ b/packages/editor/src/converters/converter.text-html.ts
@@ -1,87 +1,79 @@
import {htmlToBlocks} from '@portabletext/block-tools'
-import type {PortableTextBlock} from '@portabletext/schema'
import {toHTML} from '@portabletext/to-html'
import {getSelectedValue} from '../selectors/selector.get-selected-value'
-import type {PortableTextMemberSchemaTypes} from '../types/editor'
import {parseBlock} from '../utils/parse-blocks'
import {defineConverter} from './converter.types'
-export function createConverterTextHtml(
- legacySchema: PortableTextMemberSchemaTypes,
-) {
- return defineConverter({
- mimeType: 'text/html',
- serialize: ({snapshot, event}) => {
- const selection = snapshot.context.selection
+export const converterTextHtml = defineConverter({
+ mimeType: 'text/html',
+ serialize: ({snapshot, event}) => {
+ const selection = snapshot.context.selection
- if (!selection) {
- return {
- type: 'serialization.failure',
- mimeType: 'text/html',
- originEvent: event.originEvent,
- reason: 'No selection',
- }
+ if (!selection) {
+ return {
+ type: 'serialization.failure',
+ mimeType: 'text/html',
+ originEvent: event.originEvent,
+ reason: 'No selection',
}
+ }
- const blocks = getSelectedValue(snapshot)
-
- const html = toHTML(blocks, {
- onMissingComponent: false,
- components: {
- unknownType: ({children}) =>
- children !== undefined ? `${children}` : '',
- },
- })
+ const blocks = getSelectedValue(snapshot)
- if (html === '') {
- return {
- type: 'serialization.failure',
- mimeType: 'text/html',
- originEvent: event.originEvent,
- reason: 'Serialized HTML is empty',
- }
- }
+ const html = toHTML(blocks, {
+ onMissingComponent: false,
+ components: {
+ unknownType: ({children}) =>
+ children !== undefined ? `${children}` : '',
+ },
+ })
+ if (html === '') {
return {
- type: 'serialization.success',
- data: html,
+ type: 'serialization.failure',
mimeType: 'text/html',
originEvent: event.originEvent,
+ reason: 'Serialized HTML is empty',
}
- },
- deserialize: ({snapshot, event}) => {
- const blocks = htmlToBlocks(event.data, legacySchema.portableText, {
- keyGenerator: snapshot.context.keyGenerator,
- unstable_whitespaceOnPasteMode:
- legacySchema.block.options.unstable_whitespaceOnPasteMode,
- }) as Array
+ }
- const parsedBlocks = blocks.flatMap((block) => {
- const parsedBlock = parseBlock({
- context: snapshot.context,
- block,
- options: {
- normalize: false,
- removeUnusedMarkDefs: true,
- validateFields: false,
- },
- })
- return parsedBlock ? [parsedBlock] : []
- })
+ return {
+ type: 'serialization.success',
+ data: html,
+ mimeType: 'text/html',
+ originEvent: event.originEvent,
+ }
+ },
+ deserialize: ({snapshot, event}) => {
+ const blocks = htmlToBlocks(event.data, snapshot.context.schema, {
+ keyGenerator: snapshot.context.keyGenerator,
+ })
- if (parsedBlocks.length === 0) {
- return {
- type: 'deserialization.failure',
- mimeType: 'text/html',
- reason: 'No blocks deserialized',
- }
- }
+ const parsedBlocks = blocks.flatMap((block) => {
+ const parsedBlock = parseBlock({
+ context: snapshot.context,
+ block,
+ options: {
+ normalize: false,
+ removeUnusedMarkDefs: true,
+ validateFields: false,
+ },
+ })
+ return parsedBlock ? [parsedBlock] : []
+ })
+ if (parsedBlocks.length === 0) {
return {
- type: 'deserialization.success',
- data: parsedBlocks,
+ type: 'deserialization.failure',
mimeType: 'text/html',
+ reason: 'No blocks deserialized',
}
- },
- })
-}
+ }
+
+ return {
+ type: 'deserialization.success',
+ data: parsedBlocks,
+ mimeType: 'text/html',
+ }
+ },
+})
diff --git a/packages/editor/src/converters/converter.text-plain.test.ts b/packages/editor/src/converters/converter.text-plain.test.ts
index 98461d887..467380803 100644
--- a/packages/editor/src/converters/converter.text-plain.test.ts
+++ b/packages/editor/src/converters/converter.text-plain.test.ts
@@ -1,4 +1,3 @@
-import {compileSchemaDefinitionToPortableTextMemberSchemaTypes} from '@portabletext/sanity-bridge'
import {
compileSchema,
defineSchema,
@@ -9,7 +8,7 @@ import {
import {expect, test} from 'vitest'
import {createTestSnapshot} from '../internal-utils/create-test-snapshot'
import type {EditorSelection} from '../types/editor'
-import {createConverterTextPlain} from './converter.text-plain'
+import {converterTextPlain} from './converter.text-plain'
const b1: PortableTextTextBlock = {
_type: 'block',
@@ -67,31 +66,28 @@ const b4: PortableTextTextBlock = {
}
function createSnapshot({
- schema,
+ schemaDefinition,
selection,
}: {
- schema: SchemaDefinition
+ schemaDefinition: SchemaDefinition
selection: EditorSelection
}) {
+ const schema = compileSchema(schemaDefinition)
return createTestSnapshot({
context: {
converters: [],
- schema: compileSchema(schema),
+ schema,
selection,
value: [b1, b2, b3, b4],
},
})
}
-const converterTextPlain = createConverterTextPlain(
- compileSchemaDefinitionToPortableTextMemberSchemaTypes(defineSchema({})),
-)
-
-test(converterTextPlain.serialize.name, () => {
+test(converterTextPlain.mimeType, () => {
expect(
converterTextPlain.serialize({
snapshot: createSnapshot({
- schema: defineSchema({}),
+ schemaDefinition: defineSchema({}),
selection: {
anchor: {
path: [{_key: b3._key}, 'children', {_key: b3.children[0]!._key}],
@@ -115,7 +111,7 @@ test(converterTextPlain.serialize.name, () => {
expect(
converterTextPlain.serialize({
snapshot: createSnapshot({
- schema: defineSchema({}),
+ schemaDefinition: defineSchema({}),
selection: {
anchor: {
path: [{_key: b1._key}, 'children', {_key: b1.children[0]!._key}],
@@ -139,7 +135,7 @@ test(converterTextPlain.serialize.name, () => {
expect(
converterTextPlain.serialize({
snapshot: createSnapshot({
- schema: defineSchema({}),
+ schemaDefinition: defineSchema({}),
selection: {
anchor: {
path: [{_key: b2._key}],
@@ -163,7 +159,7 @@ test(converterTextPlain.serialize.name, () => {
expect(
converterTextPlain.serialize({
snapshot: createSnapshot({
- schema: defineSchema({
+ schemaDefinition: defineSchema({
blockObjects: [
{
name: 'image',
@@ -193,7 +189,7 @@ test(converterTextPlain.serialize.name, () => {
expect(
converterTextPlain.serialize({
snapshot: createSnapshot({
- schema: defineSchema({}),
+ schemaDefinition: defineSchema({}),
selection: {
anchor: {
path: [{_key: b4._key}, 'children', {_key: b4.children[0]!._key}],
@@ -217,7 +213,7 @@ test(converterTextPlain.serialize.name, () => {
expect(
converterTextPlain.serialize({
snapshot: createSnapshot({
- schema: defineSchema({
+ schemaDefinition: defineSchema({
inlineObjects: [
{
name: 'stock-ticker',
diff --git a/packages/editor/src/converters/converter.text-plain.ts b/packages/editor/src/converters/converter.text-plain.ts
index 0fa36bb1c..c75fa880e 100644
--- a/packages/editor/src/converters/converter.text-plain.ts
+++ b/packages/editor/src/converters/converter.text-plain.ts
@@ -1,113 +1,106 @@
import {htmlToBlocks} from '@portabletext/block-tools'
-import {isTextBlock, type PortableTextBlock} from '@portabletext/schema'
+import {isTextBlock} from '@portabletext/schema'
import {getSelectedValue} from '../selectors/selector.get-selected-value'
-import type {PortableTextMemberSchemaTypes} from '../types/editor'
import {parseBlock} from '../utils/parse-blocks'
import {defineConverter} from './converter.types'
-export function createConverterTextPlain(
- legacySchema: PortableTextMemberSchemaTypes,
-) {
- return defineConverter({
- mimeType: 'text/plain',
- serialize: ({snapshot, event}) => {
- const selection = snapshot.context.selection
+export const converterTextPlain = defineConverter({
+ mimeType: 'text/plain',
+ serialize: ({snapshot, event}) => {
+ const selection = snapshot.context.selection
- if (!selection) {
- return {
- type: 'serialization.failure',
- mimeType: 'text/plain',
- originEvent: event.originEvent,
- reason: 'No selection',
- }
+ if (!selection) {
+ return {
+ type: 'serialization.failure',
+ mimeType: 'text/plain',
+ originEvent: event.originEvent,
+ reason: 'No selection',
}
+ }
- const blocks = getSelectedValue(snapshot)
+ const blocks = getSelectedValue(snapshot)
- const data = blocks
- .map((block) => {
- if (isTextBlock(snapshot.context, block)) {
- return block.children
- .map((child) => {
- if (child._type === snapshot.context.schema.span.name) {
- return child.text
- }
+ const data = blocks
+ .map((block) => {
+ if (isTextBlock(snapshot.context, block)) {
+ return block.children
+ .map((child) => {
+ if (child._type === snapshot.context.schema.span.name) {
+ return child.text
+ }
- return event.originEvent === 'drag.dragstart'
- ? `[${
- snapshot.context.schema.inlineObjects.find(
- (inlineObjectType) =>
- inlineObjectType.name === child._type,
- )?.title ?? 'Object'
- }]`
- : ''
- })
- .join('')
- }
+ return event.originEvent === 'drag.dragstart'
+ ? `[${
+ snapshot.context.schema.inlineObjects.find(
+ (inlineObjectType) =>
+ inlineObjectType.name === child._type,
+ )?.title ?? 'Object'
+ }]`
+ : ''
+ })
+ .join('')
+ }
- return event.originEvent === 'drag.dragstart'
- ? `[${
- snapshot.context.schema.blockObjects.find(
- (blockObjectType) => blockObjectType.name === block._type,
- )?.title ?? 'Object'
- }]`
- : ''
- })
- .filter((block) => block !== '')
- .join('\n\n')
+ return event.originEvent === 'drag.dragstart'
+ ? `[${
+ snapshot.context.schema.blockObjects.find(
+ (blockObjectType) => blockObjectType.name === block._type,
+ )?.title ?? 'Object'
+ }]`
+ : ''
+ })
+ .filter((block) => block !== '')
+ .join('\n\n')
- return {
- type: 'serialization.success',
- data,
- mimeType: 'text/plain',
- originEvent: event.originEvent,
- }
- },
- deserialize: ({snapshot, event}) => {
- const html = escapeHtml(event.data)
- .split(/\n{2,}/)
- .map((line) =>
- line
- ? `${line.replace(/(?:\r\n|\r|\n)/g, '
')}
`
- : '',
- )
- .join('')
+ return {
+ type: 'serialization.success',
+ data,
+ mimeType: 'text/plain',
+ originEvent: event.originEvent,
+ }
+ },
+ deserialize: ({snapshot, event}) => {
+ const html = escapeHtml(event.data)
+ .split(/\n{2,}/)
+ .map((line) =>
+ line ? `${line.replace(/(?:\r\n|\r|\n)/g, '
')}
` : '',
+ )
+ .join('')
- const textToHtml = `${html}`
+ const textToHtml = `${html}`
- const blocks = htmlToBlocks(textToHtml, legacySchema.portableText, {
- keyGenerator: snapshot.context.keyGenerator,
- }) as Array
+ const blocks = htmlToBlocks(textToHtml, snapshot.context.schema, {
+ keyGenerator: snapshot.context.keyGenerator,
+ })
- const parsedBlocks = blocks.flatMap((block) => {
- const parsedBlock = parseBlock({
- context: snapshot.context,
- block,
- options: {
- normalize: false,
- removeUnusedMarkDefs: true,
- validateFields: false,
- },
- })
- return parsedBlock ? [parsedBlock] : []
+ const parsedBlocks = blocks.flatMap((block) => {
+ const parsedBlock = parseBlock({
+ context: snapshot.context,
+ block,
+ options: {
+ normalize: false,
+ removeUnusedMarkDefs: true,
+ validateFields: false,
+ },
})
+ return parsedBlock ? [parsedBlock] : []
+ })
- if (parsedBlocks.length === 0) {
- return {
- type: 'deserialization.failure',
- mimeType: 'text/plain',
- reason: 'No blocks deserialized',
- }
- }
-
+ if (parsedBlocks.length === 0) {
return {
- type: 'deserialization.success',
- data: parsedBlocks,
+ type: 'deserialization.failure',
mimeType: 'text/plain',
+ reason: 'No blocks deserialized',
}
- },
- })
-}
+ }
+
+ return {
+ type: 'deserialization.success',
+ data: parsedBlocks,
+ mimeType: 'text/plain',
+ }
+ },
+})
const entityMap: Record = {
'&': '&',
diff --git a/packages/editor/src/converters/converters.core.ts b/packages/editor/src/converters/converters.core.ts
index 52896e08f..f94e45185 100644
--- a/packages/editor/src/converters/converters.core.ts
+++ b/packages/editor/src/converters/converters.core.ts
@@ -1,18 +1,13 @@
-import type {PortableTextMemberSchemaTypes} from '../types/editor'
import {converterJson} from './converter.json'
import {converterPortableText} from './converter.portable-text'
-import {createConverterTextHtml} from './converter.text-html'
+import {converterTextHtml} from './converter.text-html'
import {converterTextMarkdown} from './converter.text-markdown'
-import {createConverterTextPlain} from './converter.text-plain'
+import {converterTextPlain} from './converter.text-plain'
-export function createCoreConverters(
- legacySchema: PortableTextMemberSchemaTypes,
-) {
- return [
- converterJson,
- converterPortableText,
- converterTextMarkdown,
- createConverterTextHtml(legacySchema),
- createConverterTextPlain(legacySchema),
- ]
-}
+export const coreConverters = [
+ converterJson,
+ converterPortableText,
+ converterTextMarkdown,
+ converterTextHtml,
+ converterTextPlain,
+]
diff --git a/packages/editor/src/editor.ts b/packages/editor/src/editor.ts
index 7e226b524..c6d54b28f 100644
--- a/packages/editor/src/editor.ts
+++ b/packages/editor/src/editor.ts
@@ -6,7 +6,6 @@ import type {EditorDom} from './editor/editor-dom'
import type {ExternalEditorEvent} from './editor/editor-machine'
import type {EditorSnapshot} from './editor/editor-snapshot'
import type {EditorEmittedEvent} from './editor/relay-machine'
-import type {ArrayDefinition, ArraySchemaType} from './types/sanity-types'
/**
* @public
@@ -18,16 +17,8 @@ export type EditorConfig = {
keyGenerator?: () => string
readOnly?: boolean
initialValue?: Array
-} & (
- | {
- schemaDefinition: SchemaDefinition
- schema?: undefined
- }
- | {
- schemaDefinition?: undefined
- schema: ArraySchemaType | ArrayDefinition
- }
-)
+ schemaDefinition: SchemaDefinition
+}
/**
* @public
diff --git a/packages/editor/src/editor/PortableTextEditor.tsx b/packages/editor/src/editor/PortableTextEditor.tsx
index 06aa04a45..3ab36f36b 100644
--- a/packages/editor/src/editor/PortableTextEditor.tsx
+++ b/packages/editor/src/editor/PortableTextEditor.tsx
@@ -2,6 +2,8 @@ import type {
PortableTextBlock,
PortableTextChild,
PortableTextObject,
+ Schema,
+ SchemaDefinition,
} from '@portabletext/schema'
import {
Component,
@@ -20,10 +22,8 @@ import type {
EditorChanges,
EditorSelection,
PatchObservable,
- PortableTextMemberSchemaTypes,
} from '../types/editor'
import type {Path} from '../types/paths'
-import type {ArrayDefinition, ArraySchemaType} from '../types/sanity-types'
import {createInternalEditor, type InternalEditor} from './create-editor'
import {EditorActorContext} from './editor-actor-context'
import type {EditorActor} from './editor-machine'
@@ -61,7 +61,7 @@ export type PortableTextEditorProps<
/**
* Schema type for the portable text field
*/
- schemaType: ArraySchemaType | ArrayDefinition
+ schemaType: SchemaDefinition
/**
* Function used to generate keys for array items (`_key`)
@@ -111,7 +111,7 @@ export class PortableTextEditor extends Component<
/**
* A lookup table for all the relevant schema types for this portable text type.
*/
- public schemaTypes: PortableTextMemberSchemaTypes
+ public schemaTypes: Schema
/**
* The editor instance
*/
@@ -136,24 +136,21 @@ export class PortableTextEditor extends Component<
if (props.editor) {
this.editor = props.editor as InternalEditor
- this.schemaTypes = this.editor._internal.editorActor
- .getSnapshot()
- .context.getLegacySchema()
+ this.schemaTypes =
+ this.editor._internal.editorActor.getSnapshot().context.schema
} else {
const {actors, editor, subscriptions} = createInternalEditor({
initialValue: props.value,
keyGenerator: props.keyGenerator,
readOnly: props.readOnly,
- schema: props.schemaType,
+ schemaDefinition: props.schemaType,
})
this.subscriptions = subscriptions
this.actors = actors
this.editor = editor
- this.schemaTypes = actors.editorActor
- .getSnapshot()
- .context.getLegacySchema()
+ this.schemaTypes = actors.editorActor.getSnapshot().context.schema
}
this.editable = this.editor._internal.editable
diff --git a/packages/editor/src/editor/create-editor.ts b/packages/editor/src/editor/create-editor.ts
index d3ca7c535..7a26eb3b2 100644
--- a/packages/editor/src/editor/create-editor.ts
+++ b/packages/editor/src/editor/create-editor.ts
@@ -1,14 +1,8 @@
-import {
- compileSchemaDefinitionToPortableTextMemberSchemaTypes,
- createPortableTextMemberSchemaTypes,
- portableTextMemberSchemaTypesToSchema,
-} from '@portabletext/sanity-bridge'
import {compileSchema} from '@portabletext/schema'
import {createActor} from 'xstate'
-import {createCoreConverters} from '../converters/converters.core'
+import {coreConverters} from '../converters/converters.core'
import type {Editor, EditorConfig} from '../editor'
import {debug} from '../internal-utils/debug'
-import {compileType} from '../internal-utils/schema'
import {corePriority} from '../priority/priority.core'
import {createEditorPriority} from '../priority/priority.types'
import type {EditableAPI} from '../types/editor'
@@ -159,11 +153,10 @@ export function createInternalEditor(config: EditorConfig): {
}
function editorConfigToMachineInput(config: EditorConfig) {
- const {legacySchema, schema} = compileSchemasFromEditorConfig(config)
+ const schema = compileSchema(config.schemaDefinition)
return {
- converters: createCoreConverters(legacySchema),
- getLegacySchema: () => legacySchema,
+ converters: coreConverters,
keyGenerator: config.keyGenerator ?? defaultKeyGenerator,
readOnly: config.readOnly,
schema,
@@ -171,26 +164,6 @@ function editorConfigToMachineInput(config: EditorConfig) {
} as const
}
-function compileSchemasFromEditorConfig(config: EditorConfig) {
- const legacySchema = config.schemaDefinition
- ? compileSchemaDefinitionToPortableTextMemberSchemaTypes(
- config.schemaDefinition,
- )
- : createPortableTextMemberSchemaTypes(
- config.schema.hasOwnProperty('jsonType')
- ? config.schema
- : compileType(config.schema),
- )
- const schema = config.schemaDefinition
- ? compileSchema(config.schemaDefinition)
- : portableTextMemberSchemaTypesToSchema(legacySchema)
-
- return {
- legacySchema,
- schema,
- }
-}
-
function createActors(config: {
editorActor: EditorActor
relayActor: RelayActor
diff --git a/packages/editor/src/editor/editor-machine.ts b/packages/editor/src/editor/editor-machine.ts
index f99fb887f..419e88852 100644
--- a/packages/editor/src/editor/editor-machine.ts
+++ b/packages/editor/src/editor/editor-machine.ts
@@ -23,10 +23,7 @@ import {debug} from '../internal-utils/debug'
import type {EventPosition} from '../internal-utils/event-position'
import {sortByPriority} from '../priority/priority.sort'
import type {NamespaceEvent, OmitFromUnion} from '../type-utils'
-import type {
- EditorSelection,
- PortableTextMemberSchemaTypes,
-} from '../types/editor'
+import type {EditorSelection} from '../types/editor'
import type {PortableTextSlateEditor} from '../types/slate-editor'
import type {EditorSchema} from './editor-schema'
import type {
@@ -178,7 +175,6 @@ export const editorMachine = setup({
behaviors: Set
behaviorsSorted: boolean
converters: Set
- getLegacySchema: () => PortableTextMemberSchemaTypes
keyGenerator: () => string
pendingEvents: Array
pendingIncomingPatchesEvents: Array
@@ -196,7 +192,6 @@ export const editorMachine = setup({
emitted: {} as InternalEditorEmittedEvent,
input: {} as {
converters?: Array
- getLegacySchema: () => PortableTextMemberSchemaTypes
keyGenerator: () => string
readOnly?: boolean
schema: EditorSchema
@@ -383,7 +378,6 @@ export const editorMachine = setup({
behaviors: new Set(coreBehaviorsConfig),
behaviorsSorted: false,
converters: new Set(input.converters ?? []),
- getLegacySchema: input.getLegacySchema,
keyGenerator: input.keyGenerator,
pendingEvents: [],
pendingIncomingPatchesEvents: [],
diff --git a/packages/editor/src/editor/render.block-object.tsx b/packages/editor/src/editor/render.block-object.tsx
index 4d7863ffa..7d3f2c582 100644
--- a/packages/editor/src/editor/render.block-object.tsx
+++ b/packages/editor/src/editor/render.block-object.tsx
@@ -3,11 +3,7 @@ import {useContext, useRef, type ReactElement} from 'react'
import type {Element as SlateElement} from 'slate'
import type {RenderElementProps} from 'slate-react'
import type {DropPosition} from '../behaviors/behavior.core.drop-position'
-import type {
- BlockRenderProps,
- PortableTextMemberSchemaTypes,
- RenderBlockFunction,
-} from '../types/editor'
+import type {BlockRenderProps, RenderBlockFunction} from '../types/editor'
import type {EditorSchema} from './editor-schema'
import {RenderDefaultBlockObject} from './render.default-object'
import {DropIndicator} from './render.drop-indicator'
@@ -19,7 +15,6 @@ export function RenderBlockObject(props: {
dropPosition?: DropPosition['positionBlock']
children: ReactElement
element: SlateElement
- legacySchema: PortableTextMemberSchemaTypes
readOnly: boolean
renderBlock?: RenderBlockFunction
schema: EditorSchema
@@ -30,11 +25,11 @@ export function RenderBlockObject(props: {
const selected = selectedBlockKeys.has(props.element._key)
const focused = focusedBlockKey === props.element._key
- const legacySchemaType = props.legacySchema.blockObjects.find(
+ const blockObjectSchemaType = props.schema.blockObjects.find(
(schemaType) => schemaType.name === props.element._type,
)
- if (!legacySchemaType) {
+ if (!blockObjectSchemaType) {
console.error(
`Unable to find Block Object "${props.element._type}" in Schema`,
)
@@ -60,15 +55,14 @@ export function RenderBlockObject(props: {
contentEditable={false}
draggable={!props.readOnly}
>
- {props.renderBlock && legacySchemaType ? (
+ {props.renderBlock && blockObjectSchemaType ? (
@@ -90,7 +84,6 @@ function RenderBlock({
path,
schemaType,
selected,
- type,
value,
}: {
renderBlock: RenderBlockFunction
@@ -102,7 +95,6 @@ function RenderBlock({
path,
schemaType,
selected,
- type,
value,
})
}
diff --git a/packages/editor/src/editor/render.element.tsx b/packages/editor/src/editor/render.element.tsx
index 6c3b9fbaf..fde277ec3 100644
--- a/packages/editor/src/editor/render.element.tsx
+++ b/packages/editor/src/editor/render.element.tsx
@@ -29,9 +29,6 @@ export function RenderElement(props: {
}) {
const editorActor = useContext(EditorActorContext)
const schema = useSelector(editorActor, (s) => s.context.schema)
- const legacySchema = useSelector(editorActor, (s) =>
- s.context.getLegacySchema(),
- )
const slateStatic = useSlateStatic()
const isInline =
@@ -42,7 +39,6 @@ export function RenderElement(props: {
@@ -89,7 +85,6 @@ export function RenderElement(props: {
: undefined
}
element={props.element}
- legacySchema={legacySchema}
readOnly={props.readOnly}
renderBlock={props.renderBlock}
schema={schema}
diff --git a/packages/editor/src/editor/render.inline-object.tsx b/packages/editor/src/editor/render.inline-object.tsx
index 46e89413d..1914e4ed5 100644
--- a/packages/editor/src/editor/render.inline-object.tsx
+++ b/packages/editor/src/editor/render.inline-object.tsx
@@ -3,11 +3,7 @@ import type {Element as SlateElement} from 'slate'
import {DOMEditor} from 'slate-dom'
import {useSlateStatic, type RenderElementProps} from 'slate-react'
import {getPointBlock} from '../internal-utils/slate-utils'
-import type {
- BlockChildRenderProps,
- PortableTextMemberSchemaTypes,
- RenderChildFunction,
-} from '../types/editor'
+import type {BlockChildRenderProps, RenderChildFunction} from '../types/editor'
import type {EditorSchema} from './editor-schema'
import {RenderDefaultInlineObject} from './render.default-object'
import {SelectionStateContext} from './selection-state-context'
@@ -16,7 +12,6 @@ export function RenderInlineObject(props: {
attributes: RenderElementProps['attributes']
children: ReactElement
element: SlateElement
- legacySchema: PortableTextMemberSchemaTypes
readOnly: boolean
renderChild?: RenderChildFunction
schema: EditorSchema
@@ -28,11 +23,11 @@ export function RenderInlineObject(props: {
const selected = selectedChildKeys.has(props.element._key)
const focused = focusedChildKey === props.element._key
- const legacySchemaType = props.legacySchema.inlineObjects.find(
- (inlineObject) => inlineObject.name === props.element._type,
+ const inlineObjectSchemaType = props.schema.inlineObjects.find(
+ (schemaType) => schemaType.name === props.element._type,
)
- if (!legacySchemaType) {
+ if (!inlineObjectSchemaType) {
console.error(
`Unable to find Inline Object "${props.element._type}" in Schema`,
)
@@ -72,7 +67,7 @@ export function RenderInlineObject(props: {
>
{props.children}
- {props.renderChild && block && legacySchemaType ? (
+ {props.renderChild && block && inlineObjectSchemaType ? (
@@ -104,7 +98,6 @@ function RenderChild({
schemaType,
selected,
value,
- type,
}: {
renderChild: RenderChildFunction
} & BlockChildRenderProps) {
@@ -117,6 +110,5 @@ function RenderChild({
schemaType,
selected,
value,
- type,
})
}
diff --git a/packages/editor/src/editor/render.span.tsx b/packages/editor/src/editor/render.span.tsx
index 11c6be6dc..359d06462 100644
--- a/packages/editor/src/editor/render.span.tsx
+++ b/packages/editor/src/editor/render.span.tsx
@@ -1,3 +1,4 @@
+import type {InlineObjectSchemaType} from '@portabletext/schema'
import {useSelector} from '@xstate/react'
import {useContext, useMemo, useRef, type ReactElement} from 'react'
import {useSlateStatic, type RenderLeafProps} from 'slate-react'
@@ -23,10 +24,12 @@ export interface RenderSpanProps extends RenderLeafProps {
export function RenderSpan(props: RenderSpanProps) {
const slateEditor = useSlateStatic()
const editorActor = useContext(EditorActorContext)
- const legacySchema = useSelector(editorActor, (s) =>
- s.context.getLegacySchema(),
- )
+ const schema = useSelector(editorActor, (s) => s.context.schema)
const spanRef = useRef(null)
+ const schemaType = {
+ name: schema.span.name,
+ fields: [],
+ } satisfies InlineObjectSchemaType
const selectionState = useContext(SelectionStateContext)
const focused = selectionState.focusedChildKey === props.leaf._key
@@ -75,11 +78,11 @@ export function RenderSpan(props: RenderSpanProps) {
* Support `renderDecorator` render function for each Decorator
*/
for (const mark of decorators) {
- const legacyDecoratorSchemaType = legacySchema.decorators.find(
- (dec) => dec.value === mark,
+ const decoratorSchemaType = schema.decorators.find(
+ (dec) => dec.name === mark,
)
- if (path && legacyDecoratorSchemaType && props.renderDecorator) {
+ if (path && decoratorSchemaType && props.renderDecorator) {
children = (
{children}
@@ -101,10 +103,10 @@ export function RenderSpan(props: RenderSpanProps) {
* Support `renderAnnotation` render function for each Annotation
*/
for (const annotationMarkDef of annotationMarkDefs) {
- const legacyAnnotationSchemaType = legacySchema.annotations.find(
+ const annotationSchemaType = schema.annotations.find(
(t) => t.name === annotationMarkDef._type,
)
- if (legacyAnnotationSchemaType) {
+ if (annotationSchemaType) {
if (block && path && props.renderAnnotation) {
children = (
@@ -115,9 +117,8 @@ export function RenderSpan(props: RenderSpanProps) {
focused={focused}
path={path}
selected={selected}
- schemaType={legacyAnnotationSchemaType}
+ schemaType={annotationSchemaType}
value={annotationMarkDef}
- type={legacyAnnotationSchemaType}
>
{children}
@@ -145,10 +146,9 @@ export function RenderSpan(props: RenderSpanProps) {
editorElementRef={spanRef}
focused={focused}
path={path}
- schemaType={legacySchema.span}
+ schemaType={schemaType}
selected={selected}
value={child}
- type={legacySchema.span}
>
{children}
@@ -173,7 +173,6 @@ function RenderAnnotation({
schemaType,
selected,
value,
- type,
}: {
renderAnnotation: RenderAnnotationFunction
} & BlockAnnotationRenderProps) {
@@ -186,7 +185,6 @@ function RenderAnnotation({
schemaType,
selected,
value,
- type,
})
}
@@ -199,7 +197,6 @@ function RenderDecorator({
schemaType,
selected,
value,
- type,
}: {
renderDecorator: RenderDecoratorFunction
} & BlockDecoratorRenderProps) {
@@ -211,7 +208,6 @@ function RenderDecorator({
schemaType,
selected,
value,
- type,
})
}
@@ -225,7 +221,6 @@ function RenderChild({
schemaType,
selected,
value,
- type,
}: {
renderChild: RenderChildFunction
} & BlockChildRenderProps) {
@@ -238,6 +233,5 @@ function RenderChild({
schemaType,
selected,
value,
- type,
})
}
diff --git a/packages/editor/src/editor/render.text-block.tsx b/packages/editor/src/editor/render.text-block.tsx
index d1a520898..2c8fc4b97 100644
--- a/packages/editor/src/editor/render.text-block.tsx
+++ b/packages/editor/src/editor/render.text-block.tsx
@@ -1,4 +1,7 @@
-import type {PortableTextTextBlock} from '@portabletext/schema'
+import type {
+ BlockObjectSchemaType,
+ PortableTextTextBlock,
+} from '@portabletext/schema'
import {useContext, useRef, type ReactElement} from 'react'
import type {Element as SlateElement} from 'slate'
import {useSlateSelector, type RenderElementProps} from 'slate-react'
@@ -7,11 +10,11 @@ import type {
BlockListItemRenderProps,
BlockRenderProps,
BlockStyleRenderProps,
- PortableTextMemberSchemaTypes,
RenderBlockFunction,
RenderListItemFunction,
RenderStyleFunction,
} from '../types/editor'
+import type {EditorSchema} from './editor-schema'
import {DropIndicator} from './render.drop-indicator'
import {SelectionStateContext} from './selection-state-context'
@@ -20,16 +23,19 @@ export function RenderTextBlock(props: {
children: ReactElement
dropPosition?: DropPosition['positionBlock']
element: SlateElement
- legacySchema: PortableTextMemberSchemaTypes
readOnly: boolean
renderBlock?: RenderBlockFunction
renderListItem?: RenderListItemFunction
renderStyle?: RenderStyleFunction
+ schema: EditorSchema
spellCheck?: boolean
textBlock: PortableTextTextBlock
}) {
const blockRef = useRef(null)
-
+ const schemaType = {
+ name: props.schema.block.name,
+ fields: props.schema.block.fields ?? [],
+ } satisfies BlockObjectSchemaType
const {selectedBlockKeys, focusedBlockKey} = useContext(SelectionStateContext)
const selected = selectedBlockKeys.has(props.textBlock._key)
const focused = focusedBlockKey === props.textBlock._key
@@ -40,14 +46,14 @@ export function RenderTextBlock(props: {
let children = props.children
if (props.renderStyle && props.textBlock.style) {
- const legacyStyleSchemaType =
+ const styleSchemaType =
props.textBlock.style !== undefined
- ? props.legacySchema.styles.find(
+ ? props.schema.styles.find(
(style) => style.value === props.textBlock.style,
)
: undefined
- if (legacyStyleSchemaType) {
+ if (styleSchemaType) {
children = (
@@ -70,11 +76,11 @@ export function RenderTextBlock(props: {
}
if (props.renderListItem && props.textBlock.listItem) {
- const legacyListItemSchemaType = props.legacySchema.lists.find(
+ const listItemSchemaType = props.schema.lists.find(
(list) => list.value === props.textBlock.listItem,
)
- if (legacyListItemSchemaType) {
+ if (listItemSchemaType) {
children = (
{children}
@@ -150,9 +156,8 @@ export function RenderTextBlock(props: {
listItem={props.textBlock.listItem}
path={[{_key: props.textBlock._key}]}
selected={selected}
- schemaType={props.legacySchema.block}
+ schemaType={schemaType}
style={props.textBlock.style}
- type={props.legacySchema.block}
value={props.textBlock}
>
{children}
@@ -177,7 +182,6 @@ function RenderBlock({
selected,
style,
schemaType,
- type,
value,
}: {
renderBlock: RenderBlockFunction
@@ -192,7 +196,6 @@ function RenderBlock({
selected,
style,
schemaType,
- type,
value,
})
}
diff --git a/packages/editor/src/index.ts b/packages/editor/src/index.ts
index 3115e6573..cf814c06d 100644
--- a/packages/editor/src/index.ts
+++ b/packages/editor/src/index.ts
@@ -75,7 +75,6 @@ export type {
PasteData,
PatchChange,
PatchObservable,
- PortableTextMemberSchemaTypes,
RangeDecoration,
RangeDecorationOnMovedDetails,
ReadyChange,
diff --git a/packages/editor/src/internal-utils/operation-to-patches.test.ts b/packages/editor/src/internal-utils/operation-to-patches.test.ts
index 6914d3ade..121a2fae2 100644
--- a/packages/editor/src/internal-utils/operation-to-patches.test.ts
+++ b/packages/editor/src/internal-utils/operation-to-patches.test.ts
@@ -1,4 +1,3 @@
-import {compileSchemaDefinitionToPortableTextMemberSchemaTypes} from '@portabletext/sanity-bridge'
import {
compileSchema,
defineSchema,
@@ -26,13 +25,10 @@ const schemaDefinition = defineSchema({
inlineObjects: [{name: 'someObject'}],
})
const schema = compileSchema(schemaDefinition)
-const legacySchema =
- compileSchemaDefinitionToPortableTextMemberSchemaTypes(schemaDefinition)
const editorActor = createActor(editorMachine, {
input: {
schema,
keyGenerator: defaultKeyGenerator,
- getLegacySchema: () => legacySchema,
},
})
const relayActor = createActor(relayMachine)
diff --git a/packages/editor/src/internal-utils/schema.ts b/packages/editor/src/internal-utils/schema.ts
deleted file mode 100644
index b52b887fe..000000000
--- a/packages/editor/src/internal-utils/schema.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import {Schema} from '@sanity/schema'
-
-export function compileType(rawType: any) {
- return Schema.compile({
- name: 'blockTypeSchema',
- types: [rawType],
- }).get(rawType.name)
-}
diff --git a/packages/editor/src/types/editor.ts b/packages/editor/src/types/editor.ts
index ba44d59b3..fb3410b8f 100644
--- a/packages/editor/src/types/editor.ts
+++ b/packages/editor/src/types/editor.ts
@@ -1,9 +1,15 @@
import type {Patch} from '@portabletext/patches'
import type {
+ AnnotationSchemaType,
+ BlockObjectSchemaType,
+ DecoratorSchemaType,
+ InlineObjectSchemaType,
+ ListSchemaType,
PortableTextBlock,
PortableTextChild,
PortableTextObject,
PortableTextTextBlock,
+ StyleSchemaType,
TypedObject,
} from '@portabletext/schema'
import type {
@@ -16,15 +22,9 @@ import type {
} from 'react'
import type {Observable, Subject} from 'rxjs'
import type {PortableTextEditableProps} from '../editor/Editable'
+import type {EditorSchema} from '../editor/editor-schema'
import type {PortableTextEditor} from '../editor/PortableTextEditor'
import type {BlockPath, Path} from './paths'
-import type {
- ArraySchemaType,
- BlockDecoratorDefinition,
- BlockListDefinition,
- BlockStyleDefinition,
- ObjectSchemaType,
-} from './sanity-types'
/** @beta */
export interface EditableAPIDeleteOptions {
@@ -310,7 +310,7 @@ export type OnPasteResultOrPromise = OnPasteResult | Promise
export interface PasteData {
event: ClipboardEvent
path: Path
- schemaTypes: PortableTextMemberSchemaTypes
+ schemaTypes: EditorSchema
value: PortableTextBlock[] | undefined
}
@@ -346,9 +346,7 @@ export interface BlockRenderProps {
path: BlockPath
selected: boolean
style?: string
- schemaType: ObjectSchemaType
- /** @deprecated Use `schemaType` instead */
- type: ObjectSchemaType
+ schemaType: BlockObjectSchemaType
value: PortableTextBlock
}
@@ -360,9 +358,7 @@ export interface BlockChildRenderProps {
focused: boolean
path: Path
selected: boolean
- schemaType: ObjectSchemaType
- /** @deprecated Use `schemaType` instead */
- type: ObjectSchemaType
+ schemaType: InlineObjectSchemaType
value: PortableTextChild
}
@@ -373,10 +369,8 @@ export interface BlockAnnotationRenderProps {
editorElementRef: RefObject
focused: boolean
path: Path
- schemaType: ObjectSchemaType
+ schemaType: AnnotationSchemaType
selected: boolean
- /** @deprecated Use `schemaType` instead */
- type: ObjectSchemaType
value: PortableTextObject
}
/** @beta */
@@ -385,10 +379,8 @@ export interface BlockDecoratorRenderProps {
editorElementRef: RefObject
focused: boolean
path: Path
- schemaType: BlockDecoratorDefinition
+ schemaType: DecoratorSchemaType
selected: boolean
- /** @deprecated Use `schemaType` instead */
- type: BlockDecoratorDefinition
value: string
}
/** @beta */
@@ -399,7 +391,7 @@ export interface BlockListItemRenderProps {
focused: boolean
level: number
path: Path
- schemaType: BlockListDefinition
+ schemaType: ListSchemaType
selected: boolean
value: string
}
@@ -434,7 +426,7 @@ export interface BlockStyleRenderProps {
focused: boolean
path: Path
selected: boolean
- schemaType: BlockStyleDefinition
+ schemaType: StyleSchemaType
value: string
}
@@ -495,16 +487,3 @@ export interface RangeDecoration {
*/
payload?: Record
}
-
-/** @beta */
-export type PortableTextMemberSchemaTypes = {
- annotations: (ObjectSchemaType & {i18nTitleKey?: string})[]
- block: ObjectSchemaType
- blockObjects: ObjectSchemaType[]
- decorators: BlockDecoratorDefinition[]
- inlineObjects: ObjectSchemaType[]
- portableText: ArraySchemaType
- span: ObjectSchemaType
- styles: BlockStyleDefinition[]
- lists: BlockListDefinition[]
-}
diff --git a/packages/editor/src/types/sanity-types.ts b/packages/editor/src/types/sanity-types.ts
deleted file mode 100644
index 289252c92..000000000
--- a/packages/editor/src/types/sanity-types.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * This file centralizes all imports from @sanity/types.
- * Any types needed from @sanity/types should be re-exported here
- * to maintain visibility over the dependency.
- */
-
-export type {
- ArrayDefinition,
- ArraySchemaType,
- BlockDecoratorDefinition,
- BlockListDefinition,
- BlockStyleDefinition,
- ObjectSchemaType,
- // biome-ignore lint/style/noRestrictedImports: This is the designated file for @sanity/types imports
-} from '@sanity/types'
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index c529db995..20c674e54 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -422,7 +422,7 @@ importers:
version: link:../schema
'@sanity/types':
specifier: ^5.6.0
- version: 5.6.0(@types/react@19.2.8)(debug@4.4.3)
+ version: 5.6.0(@types/react@19.2.8)
devDependencies:
'@portabletext/test':
specifier: workspace:^
@@ -432,7 +432,7 @@ importers:
version: 10.2.1(@types/babel__core@7.20.5)(@types/node@20.19.25)(babel-plugin-react-compiler@1.0.0)(debug@4.4.3)(typescript@5.9.3)
'@sanity/schema':
specifier: ^5.6.0
- version: 5.6.0(@types/react@19.2.8)(debug@4.4.3)
+ version: 5.6.0(@types/react@19.2.8)
'@types/jsdom':
specifier: ^27.0.0
version: 27.0.0
@@ -472,12 +472,6 @@ importers:
'@portabletext/to-html':
specifier: ^5.0.1
version: 5.0.1
- '@sanity/schema':
- specifier: ^5.6.0
- version: 5.6.0(@types/react@19.2.8)(debug@4.4.3)
- '@sanity/types':
- specifier: ^5.6.0
- version: 5.6.0(@types/react@19.2.8)(debug@4.4.3)
'@xstate/react':
specifier: ^6.0.0
version: 6.0.0(@types/react@19.2.8)(react@19.2.3)(xstate@5.25.0)
@@ -497,9 +491,6 @@ importers:
specifier: ^5.25.0
version: 5.25.0
devDependencies:
- '@portabletext/sanity-bridge':
- specifier: workspace:*
- version: link:../sanity-bridge
'@portabletext/test':
specifier: workspace:^
version: link:../test
@@ -917,7 +908,7 @@ importers:
version: link:../patches
'@sanity/schema':
specifier: ^5.6.0
- version: 5.6.0(@types/react@19.2.8)(debug@4.4.3)
+ version: 5.6.0(@types/react@19.2.8)
'@sanity/sdk-react':
specifier: ^2.1.2
version: 2.3.1(@types/react@19.2.8)(immer@11.0.1)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(use-sync-external-store@1.6.0(react@19.2.3))
@@ -926,7 +917,7 @@ importers:
version: 2.1.0
'@sanity/types':
specifier: ^5.6.0
- version: 5.6.0(@types/react@19.2.8)(debug@4.4.3)
+ version: 5.6.0(@types/react@19.2.8)
'@types/react':
specifier: ^19.2.8
version: 19.2.8
@@ -1118,10 +1109,10 @@ importers:
version: link:../schema
'@sanity/schema':
specifier: ^5.6.0
- version: 5.6.0(@types/react@19.2.8)(debug@4.4.3)
+ version: 5.6.0(@types/react@19.2.8)
'@sanity/types':
specifier: ^5.6.0
- version: 5.6.0(@types/react@19.2.8)(debug@4.4.3)
+ version: 5.6.0(@types/react@19.2.8)
devDependencies:
'@sanity/pkg-utils':
specifier: ^10.2.1
@@ -10998,7 +10989,7 @@ snapshots:
'@sanity/browserslist-config@1.0.5': {}
- '@sanity/client@7.14.0(debug@4.4.3)':
+ '@sanity/client@7.14.0':
dependencies:
'@sanity/eventsource': 5.0.2
get-it: 8.7.0(debug@4.4.3)
@@ -11050,7 +11041,7 @@ snapshots:
'@sanity/mutate@0.12.6':
dependencies:
- '@sanity/client': 7.14.0(debug@4.4.3)
+ '@sanity/client': 7.14.0
'@sanity/diff-match-patch': 3.2.0
'@sanity/uuid': 3.0.2
hotscript: 1.0.13
@@ -11209,11 +11200,11 @@ snapshots:
- debug
- supports-color
- '@sanity/schema@5.6.0(@types/react@19.2.8)(debug@4.4.3)':
+ '@sanity/schema@5.6.0(@types/react@19.2.8)':
dependencies:
'@sanity/descriptors': 1.3.0
'@sanity/generate-help-url': 4.0.0
- '@sanity/types': 5.6.0(@types/react@19.2.8)(debug@4.4.3)
+ '@sanity/types': 5.6.0(@types/react@19.2.8)
arrify: 2.0.1
groq-js: 1.25.0
humanize-list: 1.0.1
@@ -11227,7 +11218,7 @@ snapshots:
'@sanity/sdk-react@2.3.1(@types/react@19.2.8)(immer@11.0.1)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(use-sync-external-store@1.6.0(react@19.2.3))':
dependencies:
- '@sanity/client': 7.14.0(debug@4.4.3)
+ '@sanity/client': 7.14.0
'@sanity/message-protocol': 0.12.0
'@sanity/sdk': 2.3.1(@types/react@19.2.8)(immer@11.0.1)(react@19.2.3)(use-sync-external-store@1.6.0(react@19.2.3))
'@sanity/types': 3.99.0(@types/react@19.2.8)
@@ -11249,7 +11240,7 @@ snapshots:
'@sanity/sdk@2.3.1(@types/react@19.2.8)(immer@11.0.1)(react@19.2.3)(use-sync-external-store@1.6.0(react@19.2.3))':
dependencies:
'@sanity/bifur-client': 0.4.1
- '@sanity/client': 7.14.0(debug@4.4.3)
+ '@sanity/client': 7.14.0
'@sanity/comlink': 3.1.1
'@sanity/diff-match-patch': 3.2.0
'@sanity/diff-patch': 6.0.0
@@ -11277,7 +11268,7 @@ snapshots:
'@sanity/types@3.99.0(@types/react@19.2.8)':
dependencies:
- '@sanity/client': 7.14.0(debug@4.4.3)
+ '@sanity/client': 7.14.0
'@sanity/media-library-types': 1.2.0
'@types/react': 19.2.8
transitivePeerDependencies:
@@ -11285,15 +11276,15 @@ snapshots:
'@sanity/types@4.22.0(@types/react@19.2.8)':
dependencies:
- '@sanity/client': 7.14.0(debug@4.4.3)
+ '@sanity/client': 7.14.0
'@sanity/media-library-types': 1.2.0
'@types/react': 19.2.8
transitivePeerDependencies:
- debug
- '@sanity/types@5.6.0(@types/react@19.2.8)(debug@4.4.3)':
+ '@sanity/types@5.6.0(@types/react@19.2.8)':
dependencies:
- '@sanity/client': 7.14.0(debug@4.4.3)
+ '@sanity/client': 7.14.0
'@sanity/media-library-types': 1.2.0
'@types/react': 19.2.8
transitivePeerDependencies: