/** * @public */ type Schema = { block: { name: string; fields?: ReadonlyArray; }; span: { name: string; }; styles: ReadonlyArray; lists: ReadonlyArray; decorators: ReadonlyArray; annotations: ReadonlyArray; blockObjects: ReadonlyArray; inlineObjects: ReadonlyArray; }; /** * @public */ type StyleSchemaType = BaseDefinition & { /** * @deprecated * Use `name` instead */ value: string; }; /** * @public */ type ListSchemaType = BaseDefinition & { /** * @deprecated * Use `name` instead */ value: string; }; /** * @public */ type DecoratorSchemaType = BaseDefinition & { /** * @deprecated * Use `name` instead */ value: string; }; /** * @public */ type AnnotationSchemaType = BaseDefinition & { fields: ReadonlyArray; }; /** * @public */ type BlockObjectSchemaType = BaseDefinition & { fields: ReadonlyArray; }; /** * @public */ type InlineObjectSchemaType = BaseDefinition & { fields: ReadonlyArray; }; /** * @public */ type FieldDefinition = BaseDefinition & { type: 'string' | 'number' | 'boolean' | 'array' | 'object'; }; /** * @public */ type BaseDefinition = { name: string; title?: string; }; /** * @public */ type SchemaDefinition = { block?: { name?: string; fields?: ReadonlyArray; }; styles?: ReadonlyArray; lists?: ReadonlyArray; decorators?: ReadonlyArray; annotations?: ReadonlyArray; blockObjects?: ReadonlyArray; inlineObjects?: ReadonlyArray; }; /** * @public * A helper wrapper that adds editor support, such as autocomplete and type checking, for a schema definition. * @example * ```ts * import { defineSchema } from '@portabletext/editor' * * const schemaDefinition = defineSchema({ * decorators: [{name: 'strong'}, {name: 'em'}, {name: 'underline'}], * annotations: [{name: 'link'}], * styles: [ * {name: 'normal'}, * {name: 'h1'}, * {name: 'h2'}, * {name: 'h3'}, * {name: 'blockquote'}, * ], * lists: [], * inlineObjects: [], * blockObjects: [], * } * ``` */ declare function defineSchema(definition: TSchemaDefinition): TSchemaDefinition; /** * @public */ type StyleDefinition = TBaseDefinition; /** * @public */ type ListDefinition = TBaseDefinition; /** * @public */ type DecoratorDefinition = TBaseDefinition; /** * @public */ type AnnotationDefinition = TBaseDefinition & { fields?: ReadonlyArray; }; /** * @public */ type BlockObjectDefinition = TBaseDefinition & { fields?: ReadonlyArray; }; /** * @public */ type InlineObjectDefinition = TBaseDefinition & { fields?: ReadonlyArray; }; /** * @public */ declare function compileSchema(definition: SchemaDefinition): Schema; /** * @public */ interface TypedObject { [key: string]: unknown; _type: string; } /** * @public */ declare function isTypedObject(object: unknown): object is TypedObject; /** * @public */ type PortableTextBlock = PortableTextTextBlock | PortableTextObject; /** * @public */ interface PortableTextTextBlock { _type: string; _key: string; children: TChild[]; markDefs?: PortableTextObject[]; listItem?: string; style?: string; level?: number; } /** * @public */ declare function isTextBlock(context: { schema: Schema; }, block: unknown): block is PortableTextTextBlock; /** * @public */ interface PortableTextSpan { _key: string; _type: 'span'; text: string; marks?: string[]; } /** * @public */ declare function isSpan(context: { schema: Schema; }, child: unknown): child is PortableTextSpan; /** * @public */ interface PortableTextObject { _type: string; _key: string; [other: string]: unknown; } /** * @public */ type PortableTextChild = PortableTextSpan | PortableTextObject; /** * @public */ interface PortableTextListBlock extends PortableTextTextBlock { listItem: string; level: number; } export { type AnnotationDefinition, type AnnotationSchemaType, type BaseDefinition, type BlockObjectDefinition, type BlockObjectSchemaType, type DecoratorDefinition, type DecoratorSchemaType, type FieldDefinition, type InlineObjectDefinition, type InlineObjectSchemaType, type ListDefinition, type ListSchemaType, type PortableTextBlock, type PortableTextChild, type PortableTextListBlock, type PortableTextObject, type PortableTextSpan, type PortableTextTextBlock, type Schema, type SchemaDefinition, type StyleDefinition, type StyleSchemaType, type TypedObject, compileSchema, defineSchema, isSpan, isTextBlock, isTypedObject }; //# sourceMappingURL=index.d.ts.map