@lofcz/platejs-markdown 52.3.5
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/LICENSE +21 -0
- package/README.md +12 -0
- package/dist/index.d.ts +425 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1935 -0
- package/dist/index.js.map +1 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Ziad Beyens, Dylan Schiemann, Joe Anderson, Jack Hanford
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import { Descendant as Descendant$1, NodeKey, Nullable, OmitFirst, PluginConfig, SlateEditor, TElement, TListElement, TNodeMap, TText, Value } from "platejs";
|
|
2
|
+
import { MdxJsxFlowElement, MdxJsxFlowElement as MdMdxJsxFlowElement, MdxJsxTextElement, MdxJsxTextElement as MdMdxJsxTextElement } from "mdast-util-mdx";
|
|
3
|
+
import { Options } from "remark-stringify";
|
|
4
|
+
import { Plugin } from "unified";
|
|
5
|
+
import { Token } from "marked";
|
|
6
|
+
import baseRemarkMdx from "remark-mdx";
|
|
7
|
+
import * as unistLib from "unist";
|
|
8
|
+
import { StrictExtract } from "ts-essentials";
|
|
9
|
+
import { Blockquote as MdBlockquote, Break as MdBreak, Code as MdCode, Content as MdContent, Definition as MdDefinition, Delete as MdDelete, Emphasis as MdEmphasis, FootnoteDefinition as MdFootnoteDefinition, FootnoteReference as MdFootnoteReference, Heading as MdHeading, Html as MdHtml, Image as MdImage, ImageReference as MdImageReference, InlineCode as MdInlineCode, Link as MdLink, LinkReference as MdLinkReference, List as MdList, ListItem as MdListItem, Paragraph as MdParagraph, PhrasingContent as MDPhrasingContent, Root, Root as MdRoot, RootContent as MdRootContent, Strong as MdStrong, Table as MdTable, TableCell as MdTableCell, TableRow as MdTableRow, Text as MdText, ThematicBreak as MdThematicBreak, Yaml as MdYaml } from "mdast";
|
|
10
|
+
import { InlineMath as MdInlineMath, Math as MdMath } from "mdast-util-math";
|
|
11
|
+
|
|
12
|
+
//#region src/lib/deserializer/utils/customMdxDeserialize.d.ts
|
|
13
|
+
declare const customMdxDeserialize: (mdastNode: MdxJsxFlowElement | MdxJsxTextElement, deco: MdDecoration, options: DeserializeMdOptions) => any;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/lib/deserializer/utils/deserializeInlineMd.d.ts
|
|
16
|
+
declare const deserializeInlineMd: (editor: SlateEditor, text: string, options?: DeserializeMdOptions) => Descendant[];
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/lib/deserializer/utils/getDeserializerByKey.d.ts
|
|
19
|
+
declare const getDeserializerByKey: (key: string, options: DeserializeMdOptions) => any;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/lib/deserializer/utils/getMergedOptionsDeserialize.d.ts
|
|
22
|
+
/**
|
|
23
|
+
* Merges Markdown configurations, following the principle that options take
|
|
24
|
+
* precedence
|
|
25
|
+
*
|
|
26
|
+
* @param editor Editor instance used to get plugin default configurations
|
|
27
|
+
* @param options User-provided options (higher priority)
|
|
28
|
+
* @returns The final merged configuration
|
|
29
|
+
*/
|
|
30
|
+
declare const getMergedOptionsDeserialize: (editor: SlateEditor, options?: DeserializeMdOptions) => DeserializeMdOptions;
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/lib/deserializer/utils/getStyleValue.d.ts
|
|
33
|
+
declare const getStyleValue: (mdastNode: MdMdxJsxTextElement, styleName: string) => string | undefined;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/lib/deserializer/utils/htmlToJsx.d.ts
|
|
36
|
+
declare const htmlToJsx: (html: string) => string;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/lib/deserializer/utils/markdownToSlateNodesSafely.d.ts
|
|
39
|
+
declare const markdownToSlateNodesSafely: (editor: SlateEditor, data: string, options?: Omit<DeserializeMdOptions, "editor">) => Descendant[];
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/lib/deserializer/utils/parseMarkdownBlocks.d.ts
|
|
42
|
+
type ParseMarkdownBlocksOptions = {
|
|
43
|
+
/**
|
|
44
|
+
* Token types to exclude from the output.
|
|
45
|
+
*
|
|
46
|
+
* @default ['space']
|
|
47
|
+
*/
|
|
48
|
+
exclude?: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Whether to trim the content.
|
|
51
|
+
*
|
|
52
|
+
* @default true
|
|
53
|
+
*/
|
|
54
|
+
trim?: boolean;
|
|
55
|
+
};
|
|
56
|
+
declare const parseMarkdownBlocks: (content: string, {
|
|
57
|
+
exclude,
|
|
58
|
+
trim
|
|
59
|
+
}?: ParseMarkdownBlocksOptions) => Token[];
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/lib/deserializer/utils/splitIncompleteMdx.d.ts
|
|
62
|
+
declare const splitIncompleteMdx: (data: string) => string[] | string;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/lib/deserializer/utils/stripMarkdown.d.ts
|
|
65
|
+
declare const stripMarkdownBlocks: (text: string) => string;
|
|
66
|
+
declare const stripMarkdownInline: (text: string) => string;
|
|
67
|
+
declare const stripMarkdown: (text: string) => string;
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/lib/deserializer/deserializeMd.d.ts
|
|
70
|
+
type DeserializeMdOptions = {
|
|
71
|
+
allowedNodes?: PlateType[] | null;
|
|
72
|
+
allowNode?: AllowNodeConfig;
|
|
73
|
+
disallowedNodes?: PlateType[] | null;
|
|
74
|
+
editor?: SlateEditor;
|
|
75
|
+
memoize?: boolean;
|
|
76
|
+
parser?: ParseMarkdownBlocksOptions;
|
|
77
|
+
preserveEmptyParagraphs?: boolean;
|
|
78
|
+
remarkPlugins?: Plugin[];
|
|
79
|
+
rules?: MdRules | null;
|
|
80
|
+
splitLineBreaks?: boolean;
|
|
81
|
+
withoutMdx?: boolean;
|
|
82
|
+
onError?: (error: Error) => void;
|
|
83
|
+
};
|
|
84
|
+
declare const markdownToAstProcessor: (editor: SlateEditor, data: string, options?: DeserializeMdOptions) => Root;
|
|
85
|
+
declare const markdownToSlateNodes: (editor: SlateEditor, data: string, options?: Omit<DeserializeMdOptions, "editor">) => Descendant$1[];
|
|
86
|
+
declare const deserializeMd: (editor: SlateEditor, data: string, options?: Omit<DeserializeMdOptions, "editor">) => Value;
|
|
87
|
+
declare module 'unified' {
|
|
88
|
+
interface CompileResultMap {
|
|
89
|
+
remarkToSlateNode: Descendant$1[];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=deserializeMd.d.ts.map
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/lib/deserializer/convertChildrenDeserialize.d.ts
|
|
95
|
+
declare const convertChildrenDeserialize: (children: MdRootContent[], deco: MdDecoration, options: DeserializeMdOptions) => Descendant$1[];
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/lib/deserializer/convertNodesDeserialize.d.ts
|
|
98
|
+
declare const convertNodesDeserialize: (nodes: MdRootContent[], deco: MdDecoration, options: DeserializeMdOptions) => Descendant$1[];
|
|
99
|
+
declare const buildSlateNode: (mdastNode: MdRootContent, deco: MdDecoration, options: DeserializeMdOptions) => Descendant$1[];
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/lib/deserializer/convertTextsDeserialize.d.ts
|
|
102
|
+
declare const convertTextsDeserialize: (mdastNode: MdDelete | MdEmphasis | MdStrong, deco: MdDecoration, options: DeserializeMdOptions) => any;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/lib/deserializer/mdastToSlate.d.ts
|
|
105
|
+
declare const mdastToSlate: (node: Root, options: DeserializeMdOptions) => Descendant$1[];
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/lib/serializer/serializeMd.d.ts
|
|
108
|
+
type SerializeMdOptions = {
|
|
109
|
+
allowedNodes?: PlateType[] | null;
|
|
110
|
+
allowNode?: AllowNodeConfig;
|
|
111
|
+
disallowedNodes?: PlateType[] | null;
|
|
112
|
+
editor?: SlateEditor;
|
|
113
|
+
/** Marks to treat as plain text without applying markdown formatting. */
|
|
114
|
+
plainMarks?: PlateType[] | null;
|
|
115
|
+
preserveEmptyParagraphs?: boolean;
|
|
116
|
+
remarkPlugins?: Plugin[];
|
|
117
|
+
remarkStringifyOptions?: Options | null;
|
|
118
|
+
rules?: MdRules;
|
|
119
|
+
spread?: boolean;
|
|
120
|
+
value?: Descendant$1[];
|
|
121
|
+
withBlockId?: boolean;
|
|
122
|
+
};
|
|
123
|
+
/** Serialize the editor value to Markdown. */
|
|
124
|
+
declare const serializeMd: (editor: SlateEditor, options?: Omit<SerializeMdOptions, "editor">) => string;
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/lib/serializer/convertNodesSerialize.d.ts
|
|
127
|
+
declare const convertNodesSerialize: (nodes: Descendant$1[], options: SerializeMdOptions, isBlock?: boolean) => unistLib.Node[];
|
|
128
|
+
declare const buildMdastNode: (node: any, options: SerializeMdOptions, isBlock?: boolean) => any;
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/lib/serializer/convertTextsSerialize.d.ts
|
|
131
|
+
declare const basicMarkdownMarks: string[];
|
|
132
|
+
declare const convertTextsSerialize: (slateTexts: readonly TText[], options: SerializeMdOptions, _key?: string) => MdMark[];
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/lib/serializer/listToMdastTree.d.ts
|
|
135
|
+
declare function listToMdastTree(nodes: TListElement[], options: SerializeMdOptions, isBlock?: boolean): any;
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/lib/serializer/serializeInlineMd.d.ts
|
|
138
|
+
declare const serializeInlineMd: (editor: SlateEditor, options?: SerializeMdOptions) => string;
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/lib/serializer/wrapWithBlockId.d.ts
|
|
141
|
+
/**
|
|
142
|
+
* Wraps an mdast node with a block element containing an ID attribute. Used for
|
|
143
|
+
* preserving block IDs when serializing to markdown.
|
|
144
|
+
*
|
|
145
|
+
* @param mdastNode - The mdast node to wrap
|
|
146
|
+
* @param nodeId - The ID to attach to the block element
|
|
147
|
+
* @returns The wrapped mdast node with block element and ID attribute
|
|
148
|
+
*/
|
|
149
|
+
declare const wrapWithBlockId: (mdastNode: unistLib.Node, nodeId: string) => unistLib.Node;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/lib/serializer/utils/getCustomMark.d.ts
|
|
152
|
+
declare const getCustomMark: (options?: SerializeMdOptions) => string[];
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/lib/serializer/utils/getMergedOptionsSerialize.d.ts
|
|
155
|
+
/**
|
|
156
|
+
* Merges Markdown configurations, following the principle that options take
|
|
157
|
+
* precedence
|
|
158
|
+
*
|
|
159
|
+
* @param editor Editor instance used to get plugin default configurations
|
|
160
|
+
* @param options User-provided options (higher priority)
|
|
161
|
+
* @returns The final merged configuration
|
|
162
|
+
*/
|
|
163
|
+
declare const getMergedOptionsSerialize: (editor: SlateEditor, options?: SerializeMdOptions) => SerializeMdOptions;
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/lib/serializer/utils/getSerializerByKey.d.ts
|
|
166
|
+
declare const getSerializerByKey: (key: string, options: SerializeMdOptions) => any;
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/lib/serializer/utils/unreachable.d.ts
|
|
169
|
+
declare const unreachable: (value: any) => void;
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/lib/types.d.ts
|
|
172
|
+
type MdRules = Partial<{ [K in keyof PlateNodeMap]: Nullable<MdNodeParser<K>> }> & Record<string, Nullable<AnyNodeParser>>;
|
|
173
|
+
type MdNodeParser<K$1 extends keyof PlateNodeMap> = {
|
|
174
|
+
mark?: boolean;
|
|
175
|
+
deserialize?: (mdastNode: MdNodeMap[K$1], deco: MdDecoration, options: DeserializeMdOptions) => PlateNodeMap[K$1];
|
|
176
|
+
serialize?: (slateNode: PlateNodeMap[K$1], options: SerializeMdOptions) => MdNodeMap[K$1];
|
|
177
|
+
};
|
|
178
|
+
type AnyNodeParser = {
|
|
179
|
+
mark?: boolean;
|
|
180
|
+
deserialize?: (mdastNode: any, deco: MdDecoration, options: DeserializeMdOptions) => any;
|
|
181
|
+
serialize?: (slateNode: any, options: SerializeMdOptions) => any;
|
|
182
|
+
};
|
|
183
|
+
type StrictMdType = MdGFM | MdRootContent['type'] | MdStyle;
|
|
184
|
+
type MdType = (string & {}) | StrictMdType;
|
|
185
|
+
type MdGFM = 'del' | 'mark' | 'sub' | 'sup' | 'u';
|
|
186
|
+
type MdStyle = 'backgroundColor' | 'color' | 'fontFamily' | 'fontSize' | 'fontWeight';
|
|
187
|
+
type MdMark = MdDelete | MdEmphasis | MdInlineCode | MdStrong | MdText;
|
|
188
|
+
type MdDecoration = Readonly<Partial<Record<(string & {}) | (MdDelete | MdEmphasis | MdInlineCode | MdStrong)['type'] | MdStyle | 'underline', boolean | string>>>;
|
|
189
|
+
type StrictPlateType = StrictExtract<NodeKey, 'a' | 'blockquote' | 'bold' | 'callout' | 'code' | 'code_block' | 'code_line' | 'column' | 'column_group' | 'comment' | 'date' | 'equation' | 'hr' | 'img' | 'inline_equation' | 'italic' | 'li' | 'mention' | 'p' | 'strikethrough' | 'subscript' | 'suggestion' | 'superscript' | 'table' | 'td' | 'th' | 'toc' | 'toggle' | 'tr' | 'underline'> | 'heading' | 'list' | 'text';
|
|
190
|
+
type PlateType = (string & {}) | StrictPlateType;
|
|
191
|
+
type PlateNodeMap = Pick<TNodeMap, 'a' | 'audio' | 'blockquote' | 'bold' | 'callout' | 'code' | 'code_block' | 'column' | 'column_group' | 'comment' | 'date' | 'equation' | 'file' | 'hr' | 'img' | 'inline_equation' | 'italic' | 'mention' | 'p' | 'strikethrough' | 'subscript' | 'suggestion' | 'superscript' | 'table' | 'td' | 'th' | 'toc' | 'toggle' | 'tr' | 'underline' | 'video'> & {
|
|
192
|
+
/** Markdown only */
|
|
193
|
+
text: TText;
|
|
194
|
+
list: any;
|
|
195
|
+
heading: TElement;
|
|
196
|
+
footnoteReference: any;
|
|
197
|
+
definition: any;
|
|
198
|
+
footnoteDefinition: any;
|
|
199
|
+
break: any;
|
|
200
|
+
yaml: any;
|
|
201
|
+
imageReference: any;
|
|
202
|
+
linkReference: any;
|
|
203
|
+
html: any;
|
|
204
|
+
};
|
|
205
|
+
type MdNodeMap = {
|
|
206
|
+
/** Common Elements */
|
|
207
|
+
a: MdLink;
|
|
208
|
+
blockquote: MdBlockquote;
|
|
209
|
+
code_block: MdCode;
|
|
210
|
+
equation: MdMath;
|
|
211
|
+
heading: MdHeading;
|
|
212
|
+
hr: MdThematicBreak;
|
|
213
|
+
img: MdImage;
|
|
214
|
+
inline_equation: MdInlineMath;
|
|
215
|
+
p: MdParagraph;
|
|
216
|
+
table: MdTable;
|
|
217
|
+
td: MdTableCell;
|
|
218
|
+
th: MdTableCell;
|
|
219
|
+
tr: MdTableRow;
|
|
220
|
+
list: MdList;
|
|
221
|
+
/** Common Marks */
|
|
222
|
+
bold: MdStrong;
|
|
223
|
+
italic: MdEmphasis;
|
|
224
|
+
code: MdInlineCode;
|
|
225
|
+
text: MdText;
|
|
226
|
+
strikethrough: MdDelete;
|
|
227
|
+
/** Markdown only */
|
|
228
|
+
footnoteReference: MdFootnoteReference;
|
|
229
|
+
definition: MdDefinition;
|
|
230
|
+
footnoteDefinition: MdFootnoteDefinition;
|
|
231
|
+
break: MdBreak;
|
|
232
|
+
yaml: MdYaml;
|
|
233
|
+
imageReference: MdImageReference;
|
|
234
|
+
linkReference: MdLinkReference;
|
|
235
|
+
html: MdHtml;
|
|
236
|
+
/** Plate only */
|
|
237
|
+
column_group: any;
|
|
238
|
+
column: any;
|
|
239
|
+
toc: any;
|
|
240
|
+
callout: any;
|
|
241
|
+
toggle: any;
|
|
242
|
+
mention: any;
|
|
243
|
+
date: any;
|
|
244
|
+
underline: any;
|
|
245
|
+
comment: any;
|
|
246
|
+
superscript: any;
|
|
247
|
+
subscript: any;
|
|
248
|
+
suggestion: any;
|
|
249
|
+
file: any;
|
|
250
|
+
video: any;
|
|
251
|
+
audio: any;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Get plate node type from mdast node type if the mdast is mdast only return
|
|
255
|
+
* the mdast type itself.
|
|
256
|
+
*/
|
|
257
|
+
declare const mdastToPlate: <T extends StrictMdType>(editor: SlateEditor, mdastType: T) => any;
|
|
258
|
+
/**
|
|
259
|
+
* Get mdast node type from plate element type if the plateType is plate only
|
|
260
|
+
* return the plateType itself.
|
|
261
|
+
*/
|
|
262
|
+
declare const plateToMdast: <T extends StrictPlateType>(plateType: T) => T | NonNullable<{
|
|
263
|
+
readonly a: "link";
|
|
264
|
+
readonly blockquote: "blockquote";
|
|
265
|
+
readonly bold: "strong";
|
|
266
|
+
readonly callout: "callout";
|
|
267
|
+
readonly code: "inlineCode";
|
|
268
|
+
readonly code_block: "code";
|
|
269
|
+
readonly code_line: "code_line";
|
|
270
|
+
readonly column: "column";
|
|
271
|
+
readonly column_group: "column_group";
|
|
272
|
+
readonly comment: "comment";
|
|
273
|
+
readonly date: "date";
|
|
274
|
+
readonly equation: "math";
|
|
275
|
+
readonly heading: "heading";
|
|
276
|
+
readonly hr: "thematicBreak";
|
|
277
|
+
readonly img: "image";
|
|
278
|
+
readonly inline_equation: "inlineMath";
|
|
279
|
+
readonly italic: "emphasis";
|
|
280
|
+
readonly li: "listItem";
|
|
281
|
+
readonly list: "list";
|
|
282
|
+
readonly mention: "mention";
|
|
283
|
+
readonly p: "paragraph";
|
|
284
|
+
readonly strikethrough: "delete";
|
|
285
|
+
readonly subscript: "sub";
|
|
286
|
+
readonly suggestion: "suggestion";
|
|
287
|
+
readonly superscript: "sup";
|
|
288
|
+
readonly table: "table";
|
|
289
|
+
readonly td: "tableCell";
|
|
290
|
+
readonly text: "text";
|
|
291
|
+
readonly th: "tableCell";
|
|
292
|
+
readonly toc: "toc";
|
|
293
|
+
readonly toggle: "toggle";
|
|
294
|
+
readonly tr: "tableRow";
|
|
295
|
+
readonly underline: "u";
|
|
296
|
+
}[T]>;
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/lib/MarkdownPlugin.d.ts
|
|
299
|
+
type AllowNodeConfig = {
|
|
300
|
+
/** Custom filter function for nodes during deserialization */
|
|
301
|
+
deserialize?: (node: any) => boolean;
|
|
302
|
+
/** Custom filter function for nodes during serialization */
|
|
303
|
+
serialize?: (node: any) => boolean;
|
|
304
|
+
};
|
|
305
|
+
type MarkdownConfig = PluginConfig<'markdown', {
|
|
306
|
+
/**
|
|
307
|
+
* Configuration for allowed node types. Cannot be combined with
|
|
308
|
+
* disallowedNodes.
|
|
309
|
+
*/
|
|
310
|
+
allowedNodes: PlateType[] | null;
|
|
311
|
+
/**
|
|
312
|
+
* Configuration for disallowed node types. Cannot be combined with
|
|
313
|
+
* allowedNodes.
|
|
314
|
+
*
|
|
315
|
+
* @default null
|
|
316
|
+
*/
|
|
317
|
+
disallowedNodes: PlateType[] | null;
|
|
318
|
+
/**
|
|
319
|
+
* Array of remark plugins to extend Markdown parsing and serialization
|
|
320
|
+
* functionality. For example, you can add remark-gfm to support GFM syntax,
|
|
321
|
+
* remark-math to support mathematical formulas, etc. These plugins will be
|
|
322
|
+
* used during the parsing and generation of Markdown text.
|
|
323
|
+
*
|
|
324
|
+
* @default undefined
|
|
325
|
+
*/
|
|
326
|
+
remarkPlugins: Plugin[];
|
|
327
|
+
/**
|
|
328
|
+
* Custom options passed to remark-stringify.
|
|
329
|
+
*
|
|
330
|
+
* @default null
|
|
331
|
+
*/
|
|
332
|
+
remarkStringifyOptions: Options | null;
|
|
333
|
+
/**
|
|
334
|
+
* Rules that define how to convert Markdown syntax elements to Slate editor
|
|
335
|
+
* elements. Or rules that how to convert Slate editor elements to Markdown
|
|
336
|
+
* syntax elements. Includes conversion rules for elements such as
|
|
337
|
+
* paragraphs, headings, lists, links, images, etc.
|
|
338
|
+
*
|
|
339
|
+
* You can pass null disable default node parser.
|
|
340
|
+
*
|
|
341
|
+
* NOTE: don't forget pass `mark:true` when you custom inline nodes.
|
|
342
|
+
*
|
|
343
|
+
* @default null
|
|
344
|
+
*/
|
|
345
|
+
rules: MdRules | null;
|
|
346
|
+
/**
|
|
347
|
+
* Custom filter function for nodes during deserialization and
|
|
348
|
+
* serialization.
|
|
349
|
+
*
|
|
350
|
+
* @default null
|
|
351
|
+
*/
|
|
352
|
+
allowNode?: AllowNodeConfig;
|
|
353
|
+
/**
|
|
354
|
+
* Marks to treat as plain text without applying markdown formatting.
|
|
355
|
+
*
|
|
356
|
+
* @default null
|
|
357
|
+
*/
|
|
358
|
+
plainMarks?: PlateType[] | null;
|
|
359
|
+
}, {
|
|
360
|
+
markdown: {
|
|
361
|
+
deserialize: OmitFirst<typeof deserializeMd>;
|
|
362
|
+
deserializeInline: OmitFirst<typeof deserializeInlineMd>;
|
|
363
|
+
serialize: OmitFirst<typeof serializeMd>;
|
|
364
|
+
};
|
|
365
|
+
}>;
|
|
366
|
+
declare const MarkdownPlugin: any;
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/lib/plugins/remarkMdx.d.ts
|
|
369
|
+
declare const remarkMdx: typeof baseRemarkMdx;
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region src/lib/plugins/remarkMention.d.ts
|
|
372
|
+
type MentionNode = {
|
|
373
|
+
children: {
|
|
374
|
+
type: 'text';
|
|
375
|
+
value: string;
|
|
376
|
+
}[];
|
|
377
|
+
type: 'mention';
|
|
378
|
+
username: string;
|
|
379
|
+
displayText?: string;
|
|
380
|
+
};
|
|
381
|
+
declare module 'mdast' {
|
|
382
|
+
interface StaticPhrasingContentMap {
|
|
383
|
+
mention: MentionNode;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* A remark plugin that converts @username patterns and [display
|
|
388
|
+
* text](mention:id) patterns in text nodes into mention nodes. This plugin runs
|
|
389
|
+
* after remark-gfm and transforms mention patterns into special mention nodes
|
|
390
|
+
* that can be later converted into Plate mention elements.
|
|
391
|
+
*
|
|
392
|
+
* Supports two formats:
|
|
393
|
+
*
|
|
394
|
+
* - @username - Simple mention format (no spaces allowed)
|
|
395
|
+
* - [display text](mention:id) - Markdown link-style format (supports spaces)
|
|
396
|
+
*/
|
|
397
|
+
declare const remarkMention: Plugin;
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/lib/rules/columnRules.d.ts
|
|
400
|
+
declare const columnRules: MdRules;
|
|
401
|
+
//#endregion
|
|
402
|
+
//#region src/lib/rules/defaultRules.d.ts
|
|
403
|
+
declare const defaultRules: MdRules;
|
|
404
|
+
declare const buildRules: (editor: SlateEditor) => Record<string, any>;
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region src/lib/rules/fontRules.d.ts
|
|
407
|
+
declare const fontRules: MdRules;
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/lib/rules/mediaRules.d.ts
|
|
410
|
+
declare const mediaRules: MdRules;
|
|
411
|
+
//#endregion
|
|
412
|
+
//#region src/lib/rules/utils/parseAttributes.d.ts
|
|
413
|
+
declare function parseAttributes(attributes: any[]): Record<string, any>;
|
|
414
|
+
declare function propsToAttributes(props: Record<string, any>): any[];
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region src/lib/utils/getRemarkPluginsWithoutMdx.d.ts
|
|
417
|
+
declare const REMARK_MDX_TAG = "remarkMdx";
|
|
418
|
+
declare const tagRemarkPlugin: (pluginFn: any, tag: string) => {
|
|
419
|
+
(this: any, ...args: any[]): any;
|
|
420
|
+
__pluginTag: string;
|
|
421
|
+
};
|
|
422
|
+
declare const getRemarkPluginsWithoutMdx: (plugins: Plugin[]) => Plugin[];
|
|
423
|
+
//#endregion
|
|
424
|
+
export { AllowNodeConfig, DeserializeMdOptions, type MDPhrasingContent, MarkdownConfig, MarkdownPlugin, type MdBlockquote, type MdBreak, type MdCode, type MdContent, MdDecoration, type MdDefinition, type MdDelete, type MdEmphasis, type MdFootnoteDefinition, type MdFootnoteReference, type MdHeading, type MdHtml, type MdImage, type MdImageReference, type MdInlineCode, type MdInlineMath, type MdLink, type MdLinkReference, type MdList, type MdListItem, MdMark, type MdMath, type MdMdxJsxFlowElement, type MdMdxJsxTextElement, MdNodeParser, type MdParagraph, type MdRoot, type MdRootContent, MdRules, type MdStrong, type MdTable, type MdTableCell, type MdTableRow, type MdText, type MdThematicBreak, MdType, type MdYaml, MentionNode, ParseMarkdownBlocksOptions, PlateType, REMARK_MDX_TAG, SerializeMdOptions, StrictPlateType, basicMarkdownMarks, buildMdastNode, buildRules, buildSlateNode, columnRules, convertChildrenDeserialize, convertNodesDeserialize, convertNodesSerialize, convertTextsDeserialize, convertTextsSerialize, customMdxDeserialize, defaultRules, deserializeInlineMd, deserializeMd, fontRules, getCustomMark, getDeserializerByKey, getMergedOptionsDeserialize, getMergedOptionsSerialize, getRemarkPluginsWithoutMdx, getSerializerByKey, getStyleValue, htmlToJsx, listToMdastTree, markdownToAstProcessor, markdownToSlateNodes, markdownToSlateNodesSafely, mdastToPlate, mdastToSlate, mediaRules, parseAttributes, parseMarkdownBlocks, plateToMdast, propsToAttributes, remarkMdx, remarkMention, serializeInlineMd, serializeMd, splitIncompleteMdx, stripMarkdown, stripMarkdownBlocks, stripMarkdownInline, tagRemarkPlugin, type unistLib, unreachable, wrapWithBlockId };
|
|
425
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/lib/deserializer/utils/customMdxDeserialize.ts","../src/lib/deserializer/utils/deserializeInlineMd.ts","../src/lib/deserializer/utils/getDeserializerByKey.ts","../src/lib/deserializer/utils/getMergedOptionsDeserialize.ts","../src/lib/deserializer/utils/getStyleValue.ts","../src/lib/deserializer/utils/htmlToJsx.ts","../src/lib/deserializer/utils/markdownToSlateNodesSafely.ts","../src/lib/deserializer/utils/parseMarkdownBlocks.ts","../src/lib/deserializer/utils/splitIncompleteMdx.ts","../src/lib/deserializer/utils/stripMarkdown.ts","../src/lib/deserializer/deserializeMd.ts","../src/lib/deserializer/convertChildrenDeserialize.ts","../src/lib/deserializer/convertNodesDeserialize.ts","../src/lib/deserializer/convertTextsDeserialize.ts","../src/lib/deserializer/mdastToSlate.ts","../src/lib/serializer/serializeMd.ts","../src/lib/serializer/convertNodesSerialize.ts","../src/lib/serializer/convertTextsSerialize.ts","../src/lib/serializer/listToMdastTree.ts","../src/lib/serializer/serializeInlineMd.ts","../src/lib/serializer/wrapWithBlockId.ts","../src/lib/serializer/utils/getCustomMark.ts","../src/lib/serializer/utils/getMergedOptionsSerialize.ts","../src/lib/serializer/utils/getSerializerByKey.ts","../src/lib/serializer/utils/unreachable.ts","../src/lib/types.ts","../src/lib/MarkdownPlugin.ts","../src/lib/plugins/remarkMdx.ts","../src/lib/plugins/remarkMention.ts","../src/lib/rules/columnRules.ts","../src/lib/rules/defaultRules.ts","../src/lib/rules/fontRules.ts","../src/lib/rules/mediaRules.ts","../src/lib/rules/utils/parseAttributes.ts","../src/lib/utils/getRemarkPluginsWithoutMdx.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;cAWa,kCACA,oBAAoB,yBACzB,uBACG;;;cCJE,8BACH,qCAEE,yBAAoB;;;cCTnB,6CAEF;;;;;;;;;;;cCUE,sCACH,uBACE,yBACT;;;cCjBU,2BACA;;;cCmCA;;;cC7BA,qCACH,qCAEE,KAAK,oCAA+B;;;KCVpC,0BAAA;;;;;;;;;;;APSZ;EACa,IAAA,CAAA,EAAA,OAAA;CAAoB;AACzB,cOIK,mBPJL,EAAA,CAAA,OAAA,EAAA,MAAA,EAAA;EAAA,OAAA;EAAA;AAAA,CAAA,CAAA,EOMgC,0BPNhC,EAAA,GOOL,KPPK,EAAA;;;cQJK;;;cCTA;cAwBA;cAsBA;;;KCjBD,oBAAA;iBACK;cACH;oBACM;WACT;;EVtBE,MAAA,CAAA,EUwBF,0BVyCV;EAhEY,uBAAA,CAAA,EAAA,OAAA;EAAoB,aAAA,CAAA,EUyBf,MVzBe,EAAA;EACzB,KAAA,CAAA,EUyBE,OVzBF,GAAA,IAAA;EACG,eAAA,CAAA,EAAA,OAAA;EAAoB,UAAA,CAAA,EAAA,OAAA;oBU2BX;;cAGP,iCACH,qCAEE,yBAAoB;ATrCnB,cS+CA,oBThBZ,EAAA,CAAA,MAAA,ESiBS,WTjBT,EAAA,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,ESmBW,ITnBX,CSmBgB,oBTnBhB,EAAA,QAAA,CAAA,EAAA,GSoBE,YTpBF,EAAA;AA9BS,cSmFG,aTnFH,EAAA,CAAA,MAAA,ESoFA,WTpFA,EAAA,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,ESs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