@tinacms/mdx 1.0.1 → 1.0.3
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/dist/index.d.ts +1 -0
- package/dist/parse/plate.d.ts +127 -23
- package/dist/parse/remarkToPlate.d.ts +3 -13
- package/package.json +6 -3
package/dist/index.d.ts
CHANGED
package/dist/parse/plate.d.ts
CHANGED
|
@@ -15,39 +15,62 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* @group _MiscellaneousElement
|
|
20
|
+
*/
|
|
19
21
|
export declare type RootElement = {
|
|
20
22
|
type: 'root';
|
|
21
23
|
children: BlockElement[];
|
|
22
24
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
type: 'p';
|
|
25
|
+
/**
|
|
26
|
+
* @group BlockElement
|
|
27
|
+
*/
|
|
28
|
+
export declare type BlockquoteElement = {
|
|
29
|
+
type: 'blockquote';
|
|
29
30
|
children: InlineElement[];
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
/**
|
|
33
|
+
* @group BlockElement
|
|
34
|
+
*/
|
|
35
|
+
export declare type CodeBlockElement = {
|
|
36
|
+
type: 'code_block';
|
|
37
|
+
lang?: string;
|
|
38
|
+
value: string;
|
|
35
39
|
children: [EmptyTextElement];
|
|
36
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* @group BlockElement
|
|
43
|
+
*/
|
|
44
|
+
export declare type HeadingElement = {
|
|
45
|
+
type: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
46
|
+
children: InlineElement[];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* @group BlockElement
|
|
50
|
+
*/
|
|
37
51
|
export declare type HrElement = {
|
|
38
52
|
type: 'hr';
|
|
39
53
|
children: [EmptyTextElement];
|
|
40
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* @group BlockElement
|
|
57
|
+
*/
|
|
41
58
|
export declare type HTMLElement = {
|
|
42
59
|
type: 'html';
|
|
43
60
|
value: string;
|
|
44
61
|
children: [EmptyTextElement];
|
|
45
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* @group InlineElement
|
|
65
|
+
*/
|
|
46
66
|
export declare type HTMLInlineElement = {
|
|
47
67
|
type: 'html_inline';
|
|
48
68
|
value: string;
|
|
49
69
|
children: [EmptyTextElement];
|
|
50
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* @group BlockElement
|
|
73
|
+
*/
|
|
51
74
|
export declare type InvalidMarkdownElement = {
|
|
52
75
|
type: 'invalid_markdown';
|
|
53
76
|
value: string;
|
|
@@ -55,45 +78,85 @@ export declare type InvalidMarkdownElement = {
|
|
|
55
78
|
position?: Position;
|
|
56
79
|
children: [EmptyTextElement];
|
|
57
80
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
type: 'blockquote';
|
|
66
|
-
children: InlineElement[];
|
|
67
|
-
};
|
|
81
|
+
/**
|
|
82
|
+
* @group ListElements
|
|
83
|
+
*/
|
|
84
|
+
export declare type List = OrderedListElement | UnorderedListElement;
|
|
85
|
+
/**
|
|
86
|
+
* @group ListElements
|
|
87
|
+
*/
|
|
68
88
|
export declare type ListItemContentElement = {
|
|
69
89
|
type: 'lic';
|
|
70
90
|
children: LicElement[];
|
|
71
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* @group ListElements
|
|
94
|
+
*/
|
|
72
95
|
export declare type ListItemChildrenElement = ListItemContentElement | UnorderedListElement | OrderedListElement;
|
|
96
|
+
/**
|
|
97
|
+
* @group BlockElement
|
|
98
|
+
*/
|
|
73
99
|
export declare type ListItemElement = {
|
|
74
100
|
type: 'li';
|
|
75
101
|
children: ListItemChildrenElement[];
|
|
76
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* @group BlockElement
|
|
105
|
+
*/
|
|
77
106
|
export declare type UnorderedListElement = {
|
|
78
107
|
type: 'ul';
|
|
79
108
|
children: ListItemElement[];
|
|
80
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* @group BlockElement
|
|
112
|
+
*/
|
|
113
|
+
export declare type MdxBlockElement = {
|
|
114
|
+
type: 'mdxJsxFlowElement';
|
|
115
|
+
name: string | null;
|
|
116
|
+
props: Record<string, unknown>;
|
|
117
|
+
children: [EmptyTextElement];
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* @group BlockElement
|
|
121
|
+
*/
|
|
81
122
|
export declare type OrderedListElement = {
|
|
82
123
|
type: 'ol';
|
|
83
124
|
children: ListItemElement[];
|
|
84
125
|
};
|
|
85
|
-
|
|
86
|
-
|
|
126
|
+
/**
|
|
127
|
+
* @group BlockElement
|
|
128
|
+
*/
|
|
129
|
+
export declare type ParagraphElement = {
|
|
130
|
+
type: 'p';
|
|
131
|
+
children: InlineElement[];
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* @group BlockElement
|
|
135
|
+
*/
|
|
136
|
+
export declare type BlockElement = BlockquoteElement | CodeBlockElement | HeadingElement | HrElement | HTMLElement | ImageElement | InvalidMarkdownElement | ListItemElement | MdxBlockElement | ParagraphElement | OrderedListElement | UnorderedListElement;
|
|
137
|
+
/**
|
|
138
|
+
* @group InlineElement
|
|
139
|
+
*/
|
|
87
140
|
export declare type MdxInlineElement = {
|
|
88
141
|
type: 'mdxJsxTextElement';
|
|
89
142
|
name: string | null;
|
|
90
143
|
props: Record<string, unknown>;
|
|
91
144
|
children: [EmptyTextElement];
|
|
92
145
|
};
|
|
146
|
+
/**
|
|
147
|
+
* @remarks
|
|
148
|
+
* Used specifically to denote no children, used by
|
|
149
|
+
* the frontend rich-text editor for void nodes
|
|
150
|
+
*
|
|
151
|
+
* @group MiscellaneousElement
|
|
152
|
+
*/
|
|
93
153
|
export declare type EmptyTextElement = {
|
|
94
154
|
type: 'text';
|
|
95
155
|
text: '';
|
|
96
156
|
};
|
|
157
|
+
/**
|
|
158
|
+
* @group InlineElement
|
|
159
|
+
*/
|
|
97
160
|
export declare type TextElement = {
|
|
98
161
|
type: 'text';
|
|
99
162
|
text: string;
|
|
@@ -101,6 +164,12 @@ export declare type TextElement = {
|
|
|
101
164
|
italic?: boolean;
|
|
102
165
|
code?: boolean;
|
|
103
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* @remarks
|
|
169
|
+
* It may be beneficial to treat this as a block element
|
|
170
|
+
*
|
|
171
|
+
* @group InlineElement
|
|
172
|
+
*/
|
|
104
173
|
export declare type ImageElement = {
|
|
105
174
|
type: 'img';
|
|
106
175
|
url: string;
|
|
@@ -108,15 +177,50 @@ export declare type ImageElement = {
|
|
|
108
177
|
caption?: string | null;
|
|
109
178
|
children: [EmptyTextElement];
|
|
110
179
|
};
|
|
180
|
+
/**
|
|
181
|
+
* @group InlineElement
|
|
182
|
+
*/
|
|
111
183
|
export declare type LinkElement = {
|
|
112
184
|
type: 'a';
|
|
113
185
|
url: string;
|
|
114
186
|
title?: string | null;
|
|
115
187
|
children: InlineElement[];
|
|
116
188
|
};
|
|
189
|
+
/**
|
|
190
|
+
* @group InlineElement
|
|
191
|
+
*/
|
|
117
192
|
export declare type BreakElement = {
|
|
118
193
|
type: 'break';
|
|
119
194
|
children: [EmptyTextElement];
|
|
120
195
|
};
|
|
196
|
+
/**
|
|
197
|
+
* @group ListElements
|
|
198
|
+
*/
|
|
121
199
|
export declare type LicElement = InlineElement;
|
|
200
|
+
/**
|
|
201
|
+
* @group InlineElement
|
|
202
|
+
*/
|
|
122
203
|
export declare type InlineElement = TextElement | MdxInlineElement | BreakElement | LinkElement | ImageElement | HTMLInlineElement;
|
|
204
|
+
/**
|
|
205
|
+
* @remarks
|
|
206
|
+
* Positional information for error reporting
|
|
207
|
+
*
|
|
208
|
+
* @group _MiscellaneousElement
|
|
209
|
+
*/
|
|
210
|
+
export declare type Position = {
|
|
211
|
+
start: PositionItem;
|
|
212
|
+
end: PositionItem;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* @remarks
|
|
216
|
+
* Positional information for error reporting
|
|
217
|
+
*
|
|
218
|
+
* @group _MiscellaneousElement
|
|
219
|
+
*/
|
|
220
|
+
export declare type PositionItem = {
|
|
221
|
+
line?: number | null;
|
|
222
|
+
column?: number | null;
|
|
223
|
+
offset?: number | null;
|
|
224
|
+
_index?: number | null;
|
|
225
|
+
_bufferIndex?: number | null;
|
|
226
|
+
};
|
|
@@ -19,6 +19,7 @@ import type * as Md from 'mdast';
|
|
|
19
19
|
import type * as Plate from './plate';
|
|
20
20
|
import type { RichTypeInner } from '@tinacms/schema-tools';
|
|
21
21
|
import type { MdxJsxTextElement, MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
|
|
22
|
+
export type { Position, PositionItem } from './plate';
|
|
22
23
|
declare module 'mdast' {
|
|
23
24
|
interface StaticPhrasingContentMap {
|
|
24
25
|
mdxJsxTextElement: MdxJsxTextElement;
|
|
@@ -34,18 +35,7 @@ declare module 'mdast' {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
export declare const remarkToSlate: (root: Md.Root | MdxJsxFlowElement | MdxJsxTextElement, field: RichTypeInner, imageCallback: (url: string) => string) => Plate.RootElement;
|
|
37
|
-
export declare type PositionItem = {
|
|
38
|
-
line?: number | null;
|
|
39
|
-
column?: number | null;
|
|
40
|
-
offset?: number | null;
|
|
41
|
-
_index?: number | null;
|
|
42
|
-
_bufferIndex?: number | null;
|
|
43
|
-
};
|
|
44
|
-
export declare type Position = {
|
|
45
|
-
start: PositionItem;
|
|
46
|
-
end: PositionItem;
|
|
47
|
-
};
|
|
48
38
|
export declare class RichTextParseError extends Error {
|
|
49
|
-
position?: Position;
|
|
50
|
-
constructor(message: string, position?: Position);
|
|
39
|
+
position?: Plate.Position;
|
|
40
|
+
constructor(message: string, position?: Plate.Position);
|
|
51
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/mdx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"typings": "dist/index.d.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -19,14 +19,17 @@
|
|
|
19
19
|
]
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@tinacms/schema-tools": "1.0.
|
|
22
|
+
"@tinacms/schema-tools": "1.0.3",
|
|
23
23
|
"acorn": "^8.7.1",
|
|
24
|
+
"concat-md": "^0.5.0",
|
|
24
25
|
"lodash-es": "^4.17.21",
|
|
25
26
|
"mdast-util-mdx-jsx": "^2.0.1",
|
|
26
27
|
"mdast-util-to-markdown": "^1.3.0",
|
|
27
28
|
"prettier": "^2.7.1",
|
|
28
29
|
"remark": "^14.0.2",
|
|
29
30
|
"remark-mdx": "^2.1.2",
|
|
31
|
+
"typedoc": "^0.23.21",
|
|
32
|
+
"typedoc-plugin-markdown": "^3.13.6",
|
|
30
33
|
"unist-util-visit": "^4.1.0",
|
|
31
34
|
"vfile": "^4.2.0"
|
|
32
35
|
},
|
|
@@ -71,7 +74,7 @@
|
|
|
71
74
|
"scripts": {
|
|
72
75
|
"types": "yarn tsc",
|
|
73
76
|
"build": "tinacms-scripts build",
|
|
74
|
-
"docs": "
|
|
77
|
+
"docs": "typedoc --plugin typedoc-plugin-markdown src/parse/plate.ts --theme markdown && concat-md --decrease-title-levels --dir-name-as-title docs > spec.md",
|
|
75
78
|
"serve": "yarn nodemon dist/server.js",
|
|
76
79
|
"test": "vitest",
|
|
77
80
|
"coverage": "vitest run --coverage",
|