/
types.ts
122 lines (109 loc) · 2.2 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import type {ComponentType} from 'react'
import type {
ArraySchemaType,
ObjectSchemaType,
PortableTextObject,
SpanSchemaType,
TitledListValue,
} from '@sanity/types'
/**
* @public
*/
export interface BlockContentFeatures {
styles: TitledListValue<string>[]
decorators: TitledListValue<string>[]
annotations: ResolvedAnnotationType[]
lists: TitledListValue<string>[]
types: {
block: ArraySchemaType
span: SpanSchemaType
inlineObjects: ObjectSchemaType[]
blockObjects: ObjectSchemaType[]
}
}
/**
* @beta
*/
export interface BlockEditorSchemaProps {
icon?: string | ComponentType
render?: ComponentType
}
/**
* @public
*/
export interface ResolvedAnnotationType {
blockEditor?: BlockEditorSchemaProps
title: string | undefined
value: string
type: ObjectSchemaType
icon: ComponentType | undefined
}
/**
* @public
*/
export interface TypedObject {
_type: string
_key?: string
}
/**
* @public
*/
export interface ArbitraryTypedObject extends TypedObject {
[key: string]: unknown
}
export interface MinimalSpan {
_type: 'span'
_key?: string
text: string
marks?: string[]
}
export interface MinimalBlock extends TypedObject {
_type: 'block'
children: TypedObject[]
markDefs?: TypedObject[]
style?: string
level?: number
listItem?: string
}
export interface PlaceholderDecorator {
_type: '__decorator'
name: string
children: TypedObject[]
}
export interface PlaceholderAnnotation {
_type: '__annotation'
markDef: PortableTextObject
children: TypedObject[]
}
/**
* @public
*/
export type HtmlParser = (html: string) => Document
/**
* @public
*/
export interface HtmlDeserializerOptions {
rules?: DeserializerRule[]
parseHtml?: HtmlParser
}
/**
* @public
*/
export interface DeserializerRule {
deserialize: (
el: Node,
next: (elements: Node | Node[] | NodeList) => TypedObject | TypedObject[] | undefined,
createBlock: (props: ArbitraryTypedObject) => {
_type: string
block: ArbitraryTypedObject
}
) => TypedObject | TypedObject[] | undefined
}
/**
* @public
*/
export interface BlockEnabledFeatures {
enabledBlockStyles: string[]
enabledSpanDecorators: string[]
enabledBlockAnnotations: string[]
}