@portabletext/schema 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/dist/index.cjs +0 -69
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -209
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/schema",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Portable Text Schema",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portabletext",
|
|
@@ -22,23 +22,23 @@
|
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
24
|
"source": "./src/index.ts",
|
|
25
|
-
"import": "./dist/index.js",
|
|
26
|
-
"require": "./dist/index.cjs",
|
|
27
25
|
"default": "./dist/index.js"
|
|
28
26
|
},
|
|
29
27
|
"./package.json": "./package.json"
|
|
30
28
|
},
|
|
31
|
-
"main": "./dist/index.
|
|
32
|
-
"module": "./dist/index.js",
|
|
29
|
+
"main": "./dist/index.js",
|
|
33
30
|
"types": "./dist/index.d.ts",
|
|
34
31
|
"files": [
|
|
35
32
|
"dist",
|
|
36
33
|
"src"
|
|
37
34
|
],
|
|
38
35
|
"devDependencies": {
|
|
39
|
-
"@sanity/pkg-utils": "^
|
|
40
|
-
"typescript": "
|
|
41
|
-
"vitest": "^
|
|
36
|
+
"@sanity/pkg-utils": "^9.0.0",
|
|
37
|
+
"typescript": "5.9.3",
|
|
38
|
+
"vitest": "^4.0.5"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20.19 <22 || >=22.12"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "pkg-utils build --strict --check --clean",
|
package/dist/index.cjs
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
function compileSchema(definition) {
|
|
4
|
-
const styles = (definition.styles ?? []).map((style) => ({
|
|
5
|
-
...style,
|
|
6
|
-
value: style.name
|
|
7
|
-
})), blockFields = [];
|
|
8
|
-
if (definition.block?.fields)
|
|
9
|
-
for (const field of definition.block.fields) {
|
|
10
|
-
if (field.name === "_type" || field.name === "_key" || field.name === "children" || field.name === "markDefs" || field.name === "style" || field.name === "listItem" || field.name === "level") {
|
|
11
|
-
console.warn(
|
|
12
|
-
`"${field.name}" is a reserved field name on Portable Text blocks`
|
|
13
|
-
);
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
blockFields.push(field);
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
block: {
|
|
20
|
-
name: definition.block?.name ?? "block",
|
|
21
|
-
...blockFields.length > 0 ? { fields: blockFields } : {}
|
|
22
|
-
},
|
|
23
|
-
span: {
|
|
24
|
-
name: "span"
|
|
25
|
-
},
|
|
26
|
-
styles: styles.some((style) => style.value === "normal") ? styles : [{ value: "normal", name: "normal", title: "Normal" }, ...styles],
|
|
27
|
-
lists: (definition.lists ?? []).map((list) => ({
|
|
28
|
-
...list,
|
|
29
|
-
value: list.name
|
|
30
|
-
})),
|
|
31
|
-
decorators: (definition.decorators ?? []).map((decorator) => ({
|
|
32
|
-
...decorator,
|
|
33
|
-
value: decorator.name
|
|
34
|
-
})),
|
|
35
|
-
annotations: (definition.annotations ?? []).map((annotation) => ({
|
|
36
|
-
...annotation,
|
|
37
|
-
fields: annotation.fields ?? []
|
|
38
|
-
})),
|
|
39
|
-
blockObjects: (definition.blockObjects ?? []).map((blockObject) => ({
|
|
40
|
-
...blockObject,
|
|
41
|
-
fields: blockObject.fields ?? []
|
|
42
|
-
})),
|
|
43
|
-
inlineObjects: (definition.inlineObjects ?? []).map((inlineObject) => ({
|
|
44
|
-
...inlineObject,
|
|
45
|
-
fields: inlineObject.fields ?? []
|
|
46
|
-
}))
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function defineSchema(definition) {
|
|
50
|
-
return definition;
|
|
51
|
-
}
|
|
52
|
-
function isTypedObject(object) {
|
|
53
|
-
return isRecord(object) && typeof object._type == "string";
|
|
54
|
-
}
|
|
55
|
-
function isRecord(value) {
|
|
56
|
-
return !!value && (typeof value == "object" || typeof value == "function");
|
|
57
|
-
}
|
|
58
|
-
function isTextBlock(context, block) {
|
|
59
|
-
return !(!isTypedObject(block) || block._type !== context.schema.block.name || !Array.isArray(block.children));
|
|
60
|
-
}
|
|
61
|
-
function isSpan(context, child) {
|
|
62
|
-
return !(!isTypedObject(child) || child._type !== context.schema.span.name || typeof child.text != "string");
|
|
63
|
-
}
|
|
64
|
-
exports.compileSchema = compileSchema;
|
|
65
|
-
exports.defineSchema = defineSchema;
|
|
66
|
-
exports.isSpan = isSpan;
|
|
67
|
-
exports.isTextBlock = isTextBlock;
|
|
68
|
-
exports.isTypedObject = isTypedObject;
|
|
69
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/compile-schema.ts","../src/define-schema.ts","../src/types.ts"],"sourcesContent":["import type {SchemaDefinition} from './define-schema'\nimport type {FieldDefinition, Schema} from './schema'\n\n/**\n * @public\n */\nexport function compileSchema(definition: SchemaDefinition): Schema {\n const styles = (definition.styles ?? []).map((style) => ({\n ...style,\n value: style.name,\n }))\n\n const blockFields: Array<FieldDefinition> = []\n\n if (definition.block?.fields) {\n for (const field of definition.block.fields) {\n if (\n field.name === '_type' ||\n field.name === '_key' ||\n field.name === 'children' ||\n field.name === 'markDefs' ||\n field.name === 'style' ||\n field.name === 'listItem' ||\n field.name === 'level'\n ) {\n console.warn(\n `\"${field.name}\" is a reserved field name on Portable Text blocks`,\n )\n continue\n }\n\n blockFields.push(field)\n }\n }\n\n return {\n block: {\n name: definition.block?.name ?? 'block',\n ...(blockFields.length > 0 ? {fields: blockFields} : {}),\n },\n span: {\n name: 'span',\n },\n styles: !styles.some((style) => style.value === 'normal')\n ? [{value: 'normal', name: 'normal', title: 'Normal'}, ...styles]\n : styles,\n lists: (definition.lists ?? []).map((list) => ({\n ...list,\n value: list.name,\n })),\n decorators: (definition.decorators ?? []).map((decorator) => ({\n ...decorator,\n value: decorator.name,\n })),\n annotations: (definition.annotations ?? []).map((annotation) => ({\n ...annotation,\n fields: annotation.fields ?? [],\n })),\n blockObjects: (definition.blockObjects ?? []).map((blockObject) => ({\n ...blockObject,\n fields: blockObject.fields ?? [],\n })),\n inlineObjects: (definition.inlineObjects ?? []).map((inlineObject) => ({\n ...inlineObject,\n fields: inlineObject.fields ?? [],\n })),\n }\n}\n","import type {BaseDefinition, FieldDefinition} from './schema'\n\n/**\n * @public\n */\nexport type SchemaDefinition = {\n block?: {\n name?: string\n fields?: ReadonlyArray<FieldDefinition>\n }\n styles?: ReadonlyArray<StyleDefinition>\n lists?: ReadonlyArray<ListDefinition>\n decorators?: ReadonlyArray<DecoratorDefinition>\n annotations?: ReadonlyArray<AnnotationDefinition>\n blockObjects?: ReadonlyArray<BlockObjectDefinition>\n inlineObjects?: ReadonlyArray<InlineObjectDefinition>\n}\n\n/**\n * @public\n * A helper wrapper that adds editor support, such as autocomplete and type checking, for a schema definition.\n * @example\n * ```ts\n * import { defineSchema } from '@portabletext/editor'\n *\n * const schemaDefinition = defineSchema({\n * decorators: [{name: 'strong'}, {name: 'em'}, {name: 'underline'}],\n * annotations: [{name: 'link'}],\n * styles: [\n * {name: 'normal'},\n * {name: 'h1'},\n * {name: 'h2'},\n * {name: 'h3'},\n * {name: 'blockquote'},\n * ],\n * lists: [],\n * inlineObjects: [],\n * blockObjects: [],\n * }\n * ```\n */\nexport function defineSchema<const TSchemaDefinition extends SchemaDefinition>(\n definition: TSchemaDefinition,\n): TSchemaDefinition {\n return definition\n}\n\n/**\n * @public\n */\nexport type StyleDefinition<\n TBaseDefinition extends BaseDefinition = BaseDefinition,\n> = TBaseDefinition\n\n/**\n * @public\n */\nexport type ListDefinition<\n TBaseDefinition extends BaseDefinition = BaseDefinition,\n> = TBaseDefinition\n\n/**\n * @public\n */\nexport type DecoratorDefinition<\n TBaseDefinition extends BaseDefinition = BaseDefinition,\n> = TBaseDefinition\n\n/**\n * @public\n */\nexport type AnnotationDefinition<\n TBaseDefinition extends BaseDefinition = BaseDefinition,\n> = TBaseDefinition & {\n fields?: ReadonlyArray<FieldDefinition>\n}\n\n/**\n * @public\n */\nexport type BlockObjectDefinition<\n TBaseDefinition extends BaseDefinition = BaseDefinition,\n> = TBaseDefinition & {\n fields?: ReadonlyArray<FieldDefinition>\n}\n\n/**\n * @public\n */\nexport type InlineObjectDefinition<\n TBaseDefinition extends BaseDefinition = BaseDefinition,\n> = TBaseDefinition & {\n fields?: ReadonlyArray<FieldDefinition>\n}\n","import type {Schema} from './schema'\n\n/**\n * @public\n */\nexport interface TypedObject {\n [key: string]: unknown\n _type: string\n}\n\n/**\n * @public\n */\nexport function isTypedObject(object: unknown): object is TypedObject {\n return isRecord(object) && typeof object._type === 'string'\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && (typeof value === 'object' || typeof value === 'function')\n}\n\n/**\n * @public\n */\nexport type PortableTextBlock = PortableTextTextBlock | PortableTextObject\n\n/**\n * @public\n */\nexport interface PortableTextTextBlock<\n TChild = PortableTextSpan | PortableTextObject,\n> {\n _type: string\n _key: string\n children: TChild[]\n markDefs?: PortableTextObject[]\n listItem?: string\n style?: string\n level?: number\n}\n\n/**\n * @public\n */\nexport function isTextBlock(\n context: {schema: Schema},\n block: unknown,\n): block is PortableTextTextBlock {\n if (!isTypedObject(block)) {\n return false\n }\n\n if (block._type !== context.schema.block.name) {\n return false\n }\n\n if (!Array.isArray(block.children)) {\n return false\n }\n\n return true\n}\n\n/**\n * @public\n */\nexport interface PortableTextSpan {\n _key: string\n _type: 'span'\n text: string\n marks?: string[]\n}\n\n/**\n * @public\n */\nexport function isSpan(\n context: {schema: Schema},\n child: unknown,\n): child is PortableTextSpan {\n if (!isTypedObject(child)) {\n return false\n }\n\n if (child._type !== context.schema.span.name) {\n return false\n }\n\n if (typeof child.text !== 'string') {\n return false\n }\n\n return true\n}\n\n/**\n * @public\n */\nexport interface PortableTextObject {\n _type: string\n _key: string\n [other: string]: unknown\n}\n"],"names":[],"mappings":";;AAMO,SAAS,cAAc,YAAsC;AAClE,QAAM,UAAU,WAAW,UAAU,CAAA,GAAI,IAAI,CAAC,WAAW;AAAA,IACvD,GAAG;AAAA,IACH,OAAO,MAAM;AAAA,EAAA,EACb,GAEI,cAAsC,CAAA;AAE5C,MAAI,WAAW,OAAO;AACpB,eAAW,SAAS,WAAW,MAAM,QAAQ;AAC3C,UACE,MAAM,SAAS,WACf,MAAM,SAAS,UACf,MAAM,SAAS,cACf,MAAM,SAAS,cACf,MAAM,SAAS,WACf,MAAM,SAAS,cACf,MAAM,SAAS,SACf;AACA,gBAAQ;AAAA,UACN,IAAI,MAAM,IAAI;AAAA,QAAA;AAEhB;AAAA,MACF;AAEA,kBAAY,KAAK,KAAK;AAAA,IACxB;AAGF,SAAO;AAAA,IACL,OAAO;AAAA,MACL,MAAM,WAAW,OAAO,QAAQ;AAAA,MAChC,GAAI,YAAY,SAAS,IAAI,EAAC,QAAQ,YAAA,IAAe,CAAA;AAAA,IAAC;AAAA,IAExD,MAAM;AAAA,MACJ,MAAM;AAAA,IAAA;AAAA,IAER,QAAS,OAAO,KAAK,CAAC,UAAU,MAAM,UAAU,QAAQ,IAEpD,SADA,CAAC,EAAC,OAAO,UAAU,MAAM,UAAU,OAAO,SAAA,GAAW,GAAG,MAAM;AAAA,IAElE,QAAQ,WAAW,SAAS,CAAA,GAAI,IAAI,CAAC,UAAU;AAAA,MAC7C,GAAG;AAAA,MACH,OAAO,KAAK;AAAA,IAAA,EACZ;AAAA,IACF,aAAa,WAAW,cAAc,CAAA,GAAI,IAAI,CAAC,eAAe;AAAA,MAC5D,GAAG;AAAA,MACH,OAAO,UAAU;AAAA,IAAA,EACjB;AAAA,IACF,cAAc,WAAW,eAAe,CAAA,GAAI,IAAI,CAAC,gBAAgB;AAAA,MAC/D,GAAG;AAAA,MACH,QAAQ,WAAW,UAAU,CAAA;AAAA,IAAC,EAC9B;AAAA,IACF,eAAe,WAAW,gBAAgB,CAAA,GAAI,IAAI,CAAC,iBAAiB;AAAA,MAClE,GAAG;AAAA,MACH,QAAQ,YAAY,UAAU,CAAA;AAAA,IAAC,EAC/B;AAAA,IACF,gBAAgB,WAAW,iBAAiB,CAAA,GAAI,IAAI,CAAC,kBAAkB;AAAA,MACrE,GAAG;AAAA,MACH,QAAQ,aAAa,UAAU,CAAA;AAAA,IAAC,EAChC;AAAA,EAAA;AAEN;AC1BO,SAAS,aACd,YACmB;AACnB,SAAO;AACT;AChCO,SAAS,cAAc,QAAwC;AACpE,SAAO,SAAS,MAAM,KAAK,OAAO,OAAO,SAAU;AACrD;AAEA,SAAS,SAAS,OAAkD;AAClE,SAAO,CAAC,CAAC,UAAU,OAAO,SAAU,YAAY,OAAO,SAAU;AACnE;AAyBO,SAAS,YACd,SACA,OACgC;AAShC,SARI,EAAA,CAAC,cAAc,KAAK,KAIpB,MAAM,UAAU,QAAQ,OAAO,MAAM,QAIrC,CAAC,MAAM,QAAQ,MAAM,QAAQ;AAKnC;AAeO,SAAS,OACd,SACA,OAC2B;AAS3B,SARI,EAAA,CAAC,cAAc,KAAK,KAIpB,MAAM,UAAU,QAAQ,OAAO,KAAK,QAIpC,OAAO,MAAM,QAAS;AAK5B;;;;;;"}
|
package/dist/index.d.cts
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @public
|
|
3
|
-
*/
|
|
4
|
-
type Schema = {
|
|
5
|
-
block: {
|
|
6
|
-
name: string;
|
|
7
|
-
fields?: ReadonlyArray<FieldDefinition>;
|
|
8
|
-
};
|
|
9
|
-
span: {
|
|
10
|
-
name: string;
|
|
11
|
-
};
|
|
12
|
-
styles: ReadonlyArray<StyleSchemaType>;
|
|
13
|
-
lists: ReadonlyArray<ListSchemaType>;
|
|
14
|
-
decorators: ReadonlyArray<DecoratorSchemaType>;
|
|
15
|
-
annotations: ReadonlyArray<AnnotationSchemaType>;
|
|
16
|
-
blockObjects: ReadonlyArray<BlockObjectSchemaType>;
|
|
17
|
-
inlineObjects: ReadonlyArray<InlineObjectSchemaType>;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
type StyleSchemaType = BaseDefinition & {
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated
|
|
25
|
-
* Use `name` instead
|
|
26
|
-
*/
|
|
27
|
-
value: string;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
type ListSchemaType = BaseDefinition & {
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated
|
|
35
|
-
* Use `name` instead
|
|
36
|
-
*/
|
|
37
|
-
value: string;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* @public
|
|
41
|
-
*/
|
|
42
|
-
type DecoratorSchemaType = BaseDefinition & {
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated
|
|
45
|
-
* Use `name` instead
|
|
46
|
-
*/
|
|
47
|
-
value: string;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* @public
|
|
51
|
-
*/
|
|
52
|
-
type AnnotationSchemaType = BaseDefinition & {
|
|
53
|
-
fields: ReadonlyArray<FieldDefinition>;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
type BlockObjectSchemaType = BaseDefinition & {
|
|
59
|
-
fields: ReadonlyArray<FieldDefinition>;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* @public
|
|
63
|
-
*/
|
|
64
|
-
type InlineObjectSchemaType = BaseDefinition & {
|
|
65
|
-
fields: ReadonlyArray<FieldDefinition>;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* @public
|
|
69
|
-
*/
|
|
70
|
-
type FieldDefinition = BaseDefinition & {
|
|
71
|
-
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* @public
|
|
75
|
-
*/
|
|
76
|
-
type BaseDefinition = {
|
|
77
|
-
name: string;
|
|
78
|
-
title?: string;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* @public
|
|
82
|
-
*/
|
|
83
|
-
type SchemaDefinition = {
|
|
84
|
-
block?: {
|
|
85
|
-
name?: string;
|
|
86
|
-
fields?: ReadonlyArray<FieldDefinition>;
|
|
87
|
-
};
|
|
88
|
-
styles?: ReadonlyArray<StyleDefinition>;
|
|
89
|
-
lists?: ReadonlyArray<ListDefinition>;
|
|
90
|
-
decorators?: ReadonlyArray<DecoratorDefinition>;
|
|
91
|
-
annotations?: ReadonlyArray<AnnotationDefinition>;
|
|
92
|
-
blockObjects?: ReadonlyArray<BlockObjectDefinition>;
|
|
93
|
-
inlineObjects?: ReadonlyArray<InlineObjectDefinition>;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* @public
|
|
97
|
-
* A helper wrapper that adds editor support, such as autocomplete and type checking, for a schema definition.
|
|
98
|
-
* @example
|
|
99
|
-
* ```ts
|
|
100
|
-
* import { defineSchema } from '@portabletext/editor'
|
|
101
|
-
*
|
|
102
|
-
* const schemaDefinition = defineSchema({
|
|
103
|
-
* decorators: [{name: 'strong'}, {name: 'em'}, {name: 'underline'}],
|
|
104
|
-
* annotations: [{name: 'link'}],
|
|
105
|
-
* styles: [
|
|
106
|
-
* {name: 'normal'},
|
|
107
|
-
* {name: 'h1'},
|
|
108
|
-
* {name: 'h2'},
|
|
109
|
-
* {name: 'h3'},
|
|
110
|
-
* {name: 'blockquote'},
|
|
111
|
-
* ],
|
|
112
|
-
* lists: [],
|
|
113
|
-
* inlineObjects: [],
|
|
114
|
-
* blockObjects: [],
|
|
115
|
-
* }
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
declare function defineSchema<const TSchemaDefinition extends SchemaDefinition>(definition: TSchemaDefinition): TSchemaDefinition;
|
|
119
|
-
/**
|
|
120
|
-
* @public
|
|
121
|
-
*/
|
|
122
|
-
type StyleDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition;
|
|
123
|
-
/**
|
|
124
|
-
* @public
|
|
125
|
-
*/
|
|
126
|
-
type ListDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition;
|
|
127
|
-
/**
|
|
128
|
-
* @public
|
|
129
|
-
*/
|
|
130
|
-
type DecoratorDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition;
|
|
131
|
-
/**
|
|
132
|
-
* @public
|
|
133
|
-
*/
|
|
134
|
-
type AnnotationDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition & {
|
|
135
|
-
fields?: ReadonlyArray<FieldDefinition>;
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* @public
|
|
139
|
-
*/
|
|
140
|
-
type BlockObjectDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition & {
|
|
141
|
-
fields?: ReadonlyArray<FieldDefinition>;
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* @public
|
|
145
|
-
*/
|
|
146
|
-
type InlineObjectDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition & {
|
|
147
|
-
fields?: ReadonlyArray<FieldDefinition>;
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* @public
|
|
151
|
-
*/
|
|
152
|
-
declare function compileSchema(definition: SchemaDefinition): Schema;
|
|
153
|
-
/**
|
|
154
|
-
* @public
|
|
155
|
-
*/
|
|
156
|
-
interface TypedObject {
|
|
157
|
-
[key: string]: unknown;
|
|
158
|
-
_type: string;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* @public
|
|
162
|
-
*/
|
|
163
|
-
declare function isTypedObject(object: unknown): object is TypedObject;
|
|
164
|
-
/**
|
|
165
|
-
* @public
|
|
166
|
-
*/
|
|
167
|
-
type PortableTextBlock = PortableTextTextBlock | PortableTextObject;
|
|
168
|
-
/**
|
|
169
|
-
* @public
|
|
170
|
-
*/
|
|
171
|
-
interface PortableTextTextBlock<TChild = PortableTextSpan | PortableTextObject> {
|
|
172
|
-
_type: string;
|
|
173
|
-
_key: string;
|
|
174
|
-
children: TChild[];
|
|
175
|
-
markDefs?: PortableTextObject[];
|
|
176
|
-
listItem?: string;
|
|
177
|
-
style?: string;
|
|
178
|
-
level?: number;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* @public
|
|
182
|
-
*/
|
|
183
|
-
declare function isTextBlock(context: {
|
|
184
|
-
schema: Schema;
|
|
185
|
-
}, block: unknown): block is PortableTextTextBlock;
|
|
186
|
-
/**
|
|
187
|
-
* @public
|
|
188
|
-
*/
|
|
189
|
-
interface PortableTextSpan {
|
|
190
|
-
_key: string;
|
|
191
|
-
_type: 'span';
|
|
192
|
-
text: string;
|
|
193
|
-
marks?: string[];
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* @public
|
|
197
|
-
*/
|
|
198
|
-
declare function isSpan(context: {
|
|
199
|
-
schema: Schema;
|
|
200
|
-
}, child: unknown): child is PortableTextSpan;
|
|
201
|
-
/**
|
|
202
|
-
* @public
|
|
203
|
-
*/
|
|
204
|
-
interface PortableTextObject {
|
|
205
|
-
_type: string;
|
|
206
|
-
_key: string;
|
|
207
|
-
[other: string]: unknown;
|
|
208
|
-
}
|
|
209
|
-
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 PortableTextObject, type PortableTextSpan, type PortableTextTextBlock, type Schema, type SchemaDefinition, type StyleDefinition, type StyleSchemaType, type TypedObject, compileSchema, defineSchema, isSpan, isTextBlock, isTypedObject };
|