-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.ts
153 lines (122 loc) · 2.54 KB
/
index.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* Markers */
export enum MarkerTypeIdentifier {
TEXT = 0,
ATOM = 1
}
// [typeIdentifier, openMarkupsIndexes, numberOfClosedMarkups, text]
export interface TextMarker extends Array<any> {
0: MarkerTypeIdentifier.TEXT
1: number[]
2: number
3: string
}
// [typeIdentifier, openMarkupsIndexes, numberOfClosedMarkups, atomIndex]
export interface AtomMarker extends Array<any> {
0: MarkerTypeIdentifier.ATOM
1: number[]
2: number
3: number
}
export type Marker = TextMarker | AtomMarker
/* Markups */
export enum MarkupTagName {
a = 'a',
b = 'b',
code = 'code',
em = 'em',
i = 'i',
s = 's',
strong = 'strong',
sub = 'sub',
sup = 'sup',
u = 'u'
}
// [tagName, optionalAttributesArray]
export interface Markup extends Array<any> {
0: MarkupTagName
1?: string[]
}
/* Cards */
// [type, payload]
export interface Card extends Array<any> {
0: string
1: object
}
/* Atoms */
// [type, text, payload]}
export interface Atom extends Array<any> {
0: string
1: string
2: object
}
/* Sections */
export enum SectionTypeIdentifier {
MARKUP = 1,
IMAGE = 2,
LIST = 3,
CARD = 10
}
/* Markup sections */
export enum MarkupSectionTagName {
aside = 'aside',
blockquote = 'blockquote',
h1 = 'h1',
h2 = 'h2',
h3 = 'h3',
h4 = 'h4',
h5 = 'h5',
h6 = 'h6',
p = 'p',
'pull-quote' = 'aside' // Mobiledoc 0.3.0
}
// [typeIdentifier, tagName, markers]
export interface MarkupSection extends Array<any> {
0: SectionTypeIdentifier.MARKUP
1: MarkupSectionTagName
2: Marker[]
3?: Attributes
}
export interface Attributes extends Array<any> {
0: 'data-md-text-align'
1: 'left' | 'right' | 'center'
}
/* Image sections */
export enum ImageSectionTagName {
img = 'img'
}
// [typeIdentifier, imageSrc]
export interface ImageSection extends Array<any> {
0: SectionTypeIdentifier.IMAGE
1: string
}
/* List Section */
export enum ListSectionTagName {
ul = 'ul',
ol = 'ol'
}
export enum ListItemTagName {
li = 'li'
}
export type ListItem = Marker[]
// [typeIdentifier, tagName, itemMarkers]
export interface ListSection extends Array<any> {
0: SectionTypeIdentifier.LIST
1: ListSectionTagName
2: ListItem[]
}
/* Card section */
// [typeIdentifier, index]
export interface CardSection extends Array<any> {
0: SectionTypeIdentifier.CARD
1: number
}
/* Sections */
export type Section = MarkupSection | ImageSection | ListSection | CardSection
/* Mobiledoc (0.3.x) */
export default interface Mobiledoc {
version: string
sections: Section[]
markups: Markup[]
cards: Card[]
atoms: Atom[]
}