@intlayer/design-system 6.1.3 → 6.1.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/dist/.vite/manifest.json +63 -7
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +2 -2
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.cjs +2 -1
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.cjs.map +1 -1
- package/dist/components/ExpandCollapse/expandCollapse.content.cjs +2 -1
- package/dist/components/ExpandCollapse/expandCollapse.content.cjs.map +1 -1
- package/dist/components/Headers/index.cjs +12 -0
- package/dist/components/Headers/index.cjs.map +1 -1
- package/dist/components/Headers/index.d.ts +1 -0
- package/dist/components/Headers/index.d.ts.map +1 -1
- package/dist/components/Headers/index.mjs +13 -1
- package/dist/components/Headers/index.mjs.map +1 -1
- package/dist/components/IDE/Code.cjs +1 -1
- package/dist/components/IDE/Code.cjs.map +1 -1
- package/dist/components/IDE/Code.mjs +1 -1
- package/dist/components/IDE/Code.mjs.map +1 -1
- package/dist/components/IDE/MarkDownRender.cjs +2 -2
- package/dist/components/IDE/MarkDownRender.cjs.map +1 -1
- package/dist/components/IDE/MarkDownRender.d.ts.map +1 -1
- package/dist/components/IDE/MarkDownRender.mjs +2 -2
- package/dist/components/IDE/MarkDownRender.mjs.map +1 -1
- package/dist/components/IDE/code.content.cjs +2 -1
- package/dist/components/IDE/code.content.cjs.map +1 -1
- package/dist/components/IDE/copyCode.content.cjs +2 -1
- package/dist/components/IDE/copyCode.content.cjs.map +1 -1
- package/dist/components/LocaleSwitcherContentDropDown/localeSwitcher.content.cjs +2 -1
- package/dist/components/LocaleSwitcherContentDropDown/localeSwitcher.content.cjs.map +1 -1
- package/dist/components/LocaleSwitcherDropDown/localeSwitcher.content.cjs +2 -1
- package/dist/components/LocaleSwitcherDropDown/localeSwitcher.content.cjs.map +1 -1
- package/dist/components/MarkDownRender/MarkDownRender.cjs +189 -0
- package/dist/components/MarkDownRender/MarkDownRender.cjs.map +1 -0
- package/dist/components/MarkDownRender/MarkDownRender.d.ts +12 -0
- package/dist/components/MarkDownRender/MarkDownRender.d.ts.map +1 -0
- package/dist/components/MarkDownRender/MarkDownRender.mjs +189 -0
- package/dist/components/MarkDownRender/MarkDownRender.mjs.map +1 -0
- package/dist/components/MarkDownRender/index.cjs +2 -150
- package/dist/components/MarkDownRender/index.cjs.map +1 -1
- package/dist/components/MarkDownRender/index.d.ts +1 -11
- package/dist/components/MarkDownRender/index.d.ts.map +1 -1
- package/dist/components/MarkDownRender/index.mjs +1 -149
- package/dist/components/MarkDownRender/index.mjs.map +1 -1
- package/dist/components/MarkDownRender/processor.cjs +1819 -0
- package/dist/components/MarkDownRender/processor.cjs.map +1 -0
- package/dist/components/MarkDownRender/processor.d.ts +368 -0
- package/dist/components/MarkDownRender/processor.d.ts.map +1 -0
- package/dist/components/MarkDownRender/processor.mjs +1819 -0
- package/dist/components/MarkDownRender/processor.mjs.map +1 -0
- package/dist/components/Tab/Tab.cjs +171 -0
- package/dist/components/Tab/Tab.cjs.map +1 -0
- package/dist/components/Tab/Tab.d.ts +24 -0
- package/dist/components/Tab/Tab.d.ts.map +1 -0
- package/dist/components/Tab/Tab.mjs +171 -0
- package/dist/components/Tab/Tab.mjs.map +1 -0
- package/dist/components/Tab/TabContext.cjs +28 -0
- package/dist/components/Tab/TabContext.cjs.map +1 -0
- package/dist/components/Tab/TabContext.d.ts +19 -0
- package/dist/components/Tab/TabContext.d.ts.map +1 -0
- package/dist/components/Tab/TabContext.mjs +28 -0
- package/dist/components/Tab/TabContext.mjs.map +1 -0
- package/dist/components/Tab/index.cjs +5 -0
- package/dist/components/Tab/index.cjs.map +1 -0
- package/dist/components/Tab/index.d.ts +2 -0
- package/dist/components/Tab/index.d.ts.map +1 -0
- package/dist/components/Tab/index.mjs +5 -0
- package/dist/components/Tab/index.mjs.map +1 -0
- package/dist/components/TabSelector/TabSelector.cjs +6 -1
- package/dist/components/TabSelector/TabSelector.cjs.map +1 -1
- package/dist/components/TabSelector/TabSelector.d.ts +1 -1
- package/dist/components/TabSelector/TabSelector.d.ts.map +1 -1
- package/dist/components/TabSelector/TabSelector.mjs +6 -1
- package/dist/components/TabSelector/TabSelector.mjs.map +1 -1
- package/dist/components/Table/Table.cjs +15 -8
- package/dist/components/Table/Table.cjs.map +1 -1
- package/dist/components/Table/Table.d.ts.map +1 -1
- package/dist/components/Table/Table.mjs +15 -8
- package/dist/components/Table/Table.mjs.map +1 -1
- package/dist/components/Table/table.content.cjs +2 -1
- package/dist/components/Table/table.content.cjs.map +1 -1
- package/dist/components/index.cjs +5 -2
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.mjs +5 -2
- package/dist/components/index.mjs.map +1 -1
- package/dist/hooks/index.cjs +2 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.mjs +2 -0
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/useHorizontalSwipe.cjs +144 -0
- package/dist/hooks/useHorizontalSwipe.cjs.map +1 -0
- package/dist/hooks/useHorizontalSwipe.d.ts +26 -0
- package/dist/hooks/useHorizontalSwipe.d.ts.map +1 -0
- package/dist/hooks/useHorizontalSwipe.mjs +144 -0
- package/dist/hooks/useHorizontalSwipe.mjs.map +1 -0
- package/package.json +44 -20
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { createElement, FC, HTMLAttributes, JSX, Key, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Analogous to `node.type`. Please note that the values here may change at any time,
|
|
4
|
+
* so do not hard code against the value directly.
|
|
5
|
+
*/
|
|
6
|
+
export declare const RuleType: {
|
|
7
|
+
readonly blockQuote: "0";
|
|
8
|
+
readonly breakLine: "1";
|
|
9
|
+
readonly breakThematic: "2";
|
|
10
|
+
readonly codeBlock: "3";
|
|
11
|
+
readonly codeFenced: "4";
|
|
12
|
+
readonly codeInline: "5";
|
|
13
|
+
readonly footnote: "6";
|
|
14
|
+
readonly footnoteReference: "7";
|
|
15
|
+
readonly gfmTask: "8";
|
|
16
|
+
readonly heading: "9";
|
|
17
|
+
readonly headingSetext: "10";
|
|
18
|
+
/** only available if not `disableHTMLParsing` */
|
|
19
|
+
readonly htmlBlock: "11";
|
|
20
|
+
readonly htmlComment: "12";
|
|
21
|
+
/** only available if not `disableHTMLParsing` */
|
|
22
|
+
readonly htmlSelfClosing: "13";
|
|
23
|
+
/** Custom components like <Tabs>, <TabItem> */
|
|
24
|
+
readonly customComponent: "34";
|
|
25
|
+
readonly image: "14";
|
|
26
|
+
readonly link: "15";
|
|
27
|
+
/** emits a `link` 'node', does not render directly */
|
|
28
|
+
readonly linkAngleBraceStyleDetector: "16";
|
|
29
|
+
/** emits a `link` 'node', does not render directly */
|
|
30
|
+
readonly linkBareUrlDetector: "17";
|
|
31
|
+
/** emits a `link` 'node', does not render directly */
|
|
32
|
+
readonly linkMailtoDetector: "18";
|
|
33
|
+
readonly newlineCoalescer: "19";
|
|
34
|
+
readonly orderedList: "20";
|
|
35
|
+
readonly paragraph: "21";
|
|
36
|
+
readonly ref: "22";
|
|
37
|
+
readonly refImage: "23";
|
|
38
|
+
readonly refLink: "24";
|
|
39
|
+
readonly table: "25";
|
|
40
|
+
readonly tableSeparator: "26";
|
|
41
|
+
readonly text: "27";
|
|
42
|
+
readonly textBolded: "28";
|
|
43
|
+
readonly textEmphasized: "29";
|
|
44
|
+
readonly textEscaped: "30";
|
|
45
|
+
readonly textMarked: "31";
|
|
46
|
+
readonly textStrikethroughed: "32";
|
|
47
|
+
readonly unorderedList: "33";
|
|
48
|
+
};
|
|
49
|
+
type RuleType = (typeof RuleType)[keyof typeof RuleType];
|
|
50
|
+
export declare const slugify: (str: string) => string;
|
|
51
|
+
export declare const sanitizer: (input: string) => string | null;
|
|
52
|
+
export declare const compiler: (markdown?: string, options?: MarkdownProcessorOptions) => JSX.Element;
|
|
53
|
+
/**
|
|
54
|
+
* A simple HOC for easy React use. Feed the markdown content as a direct child
|
|
55
|
+
* and the rest is taken care of automatically.
|
|
56
|
+
*/
|
|
57
|
+
export declare const MarkdownProcessor: FC<Omit<HTMLAttributes<Element>, 'children'> & {
|
|
58
|
+
children: string;
|
|
59
|
+
options?: MarkdownProcessorOptions;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* RequireAtLeastOne<{ ... }> <- only requires at least one key
|
|
63
|
+
*/
|
|
64
|
+
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
|
|
65
|
+
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
|
66
|
+
}[Keys];
|
|
67
|
+
type CreateElement = typeof createElement;
|
|
68
|
+
type HTMLTags = keyof JSX.IntrinsicElements;
|
|
69
|
+
type State = {
|
|
70
|
+
/** true if the current content is inside anchor link grammar */
|
|
71
|
+
inAnchor?: boolean;
|
|
72
|
+
/** true if parsing in an HTML context */
|
|
73
|
+
inHTML?: boolean;
|
|
74
|
+
/** true if parsing in an inline context (subset of rules around formatting and links) */
|
|
75
|
+
inline?: boolean;
|
|
76
|
+
/** true if in a table */
|
|
77
|
+
inTable?: boolean;
|
|
78
|
+
/** use this for the `key` prop */
|
|
79
|
+
key?: Key;
|
|
80
|
+
/** true if in a list */
|
|
81
|
+
list?: boolean;
|
|
82
|
+
/** used for lookbacks */
|
|
83
|
+
prevCapture?: string;
|
|
84
|
+
/** true if parsing in inline context w/o links */
|
|
85
|
+
simple?: boolean;
|
|
86
|
+
};
|
|
87
|
+
type BlockQuoteNode = {
|
|
88
|
+
alert?: string;
|
|
89
|
+
children: ParserResult[];
|
|
90
|
+
type: typeof RuleType.blockQuote;
|
|
91
|
+
};
|
|
92
|
+
type BreakLineNode = {
|
|
93
|
+
type: typeof RuleType.breakLine;
|
|
94
|
+
};
|
|
95
|
+
type BreakThematicNode = {
|
|
96
|
+
type: typeof RuleType.breakThematic;
|
|
97
|
+
};
|
|
98
|
+
type CodeBlockNode = {
|
|
99
|
+
type: typeof RuleType.codeBlock;
|
|
100
|
+
attrs?: JSX.IntrinsicAttributes;
|
|
101
|
+
lang?: string;
|
|
102
|
+
text: string;
|
|
103
|
+
};
|
|
104
|
+
type CodeFencedNode = {
|
|
105
|
+
type: typeof RuleType.codeFenced;
|
|
106
|
+
};
|
|
107
|
+
type CodeInlineNode = {
|
|
108
|
+
type: typeof RuleType.codeInline;
|
|
109
|
+
text: string;
|
|
110
|
+
};
|
|
111
|
+
type FootnoteNode = {
|
|
112
|
+
type: typeof RuleType.footnote;
|
|
113
|
+
};
|
|
114
|
+
type FootnoteReferenceNode = {
|
|
115
|
+
type: typeof RuleType.footnoteReference;
|
|
116
|
+
target: string;
|
|
117
|
+
text: string;
|
|
118
|
+
};
|
|
119
|
+
type GFMTaskNode = {
|
|
120
|
+
type: typeof RuleType.gfmTask;
|
|
121
|
+
completed: boolean;
|
|
122
|
+
};
|
|
123
|
+
type HeadingNode = {
|
|
124
|
+
type: typeof RuleType.heading;
|
|
125
|
+
children: ParserResult[];
|
|
126
|
+
id: string;
|
|
127
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
128
|
+
};
|
|
129
|
+
type HeadingSetextNode = {
|
|
130
|
+
type: typeof RuleType.headingSetext;
|
|
131
|
+
};
|
|
132
|
+
type HTMLCommentNode = {
|
|
133
|
+
type: typeof RuleType.htmlComment;
|
|
134
|
+
};
|
|
135
|
+
type ImageNode = {
|
|
136
|
+
type: typeof RuleType.image;
|
|
137
|
+
alt?: string;
|
|
138
|
+
target: string;
|
|
139
|
+
title?: string;
|
|
140
|
+
};
|
|
141
|
+
type LinkNode = {
|
|
142
|
+
type: typeof RuleType.link;
|
|
143
|
+
children: ParserResult[];
|
|
144
|
+
target: string;
|
|
145
|
+
title?: string;
|
|
146
|
+
};
|
|
147
|
+
type LinkAngleBraceNode = {
|
|
148
|
+
type: typeof RuleType.linkAngleBraceStyleDetector;
|
|
149
|
+
};
|
|
150
|
+
type LinkBareURLNode = {
|
|
151
|
+
type: typeof RuleType.linkBareUrlDetector;
|
|
152
|
+
};
|
|
153
|
+
type LinkMailtoNode = {
|
|
154
|
+
type: typeof RuleType.linkMailtoDetector;
|
|
155
|
+
};
|
|
156
|
+
type OrderedListNode = {
|
|
157
|
+
type: typeof RuleType.orderedList;
|
|
158
|
+
items: ParserResult[][];
|
|
159
|
+
ordered: true;
|
|
160
|
+
start?: number;
|
|
161
|
+
};
|
|
162
|
+
type UnorderedListNode = {
|
|
163
|
+
type: typeof RuleType.unorderedList;
|
|
164
|
+
items: ParserResult[][];
|
|
165
|
+
ordered: false;
|
|
166
|
+
};
|
|
167
|
+
type NewlineNode = {
|
|
168
|
+
type: typeof RuleType.newlineCoalescer;
|
|
169
|
+
};
|
|
170
|
+
type ParagraphNode = {
|
|
171
|
+
type: typeof RuleType.paragraph;
|
|
172
|
+
children: ParserResult[];
|
|
173
|
+
};
|
|
174
|
+
type ReferenceNode = {
|
|
175
|
+
type: typeof RuleType.ref;
|
|
176
|
+
};
|
|
177
|
+
type ReferenceImageNode = {
|
|
178
|
+
type: typeof RuleType.refImage;
|
|
179
|
+
alt?: string;
|
|
180
|
+
ref: string;
|
|
181
|
+
};
|
|
182
|
+
type ReferenceLinkNode = {
|
|
183
|
+
type: typeof RuleType.refLink;
|
|
184
|
+
children: ParserResult[];
|
|
185
|
+
fallbackChildren: string;
|
|
186
|
+
ref: string;
|
|
187
|
+
};
|
|
188
|
+
type TableNode = {
|
|
189
|
+
type: typeof RuleType.table;
|
|
190
|
+
/**
|
|
191
|
+
* alignment for each table column
|
|
192
|
+
*/
|
|
193
|
+
align: ('left' | 'right' | 'center')[];
|
|
194
|
+
cells: ParserResult[][][];
|
|
195
|
+
header: ParserResult[][];
|
|
196
|
+
};
|
|
197
|
+
type TableSeparatorNode = {
|
|
198
|
+
type: typeof RuleType.tableSeparator;
|
|
199
|
+
};
|
|
200
|
+
type TextNode = {
|
|
201
|
+
type: typeof RuleType.text;
|
|
202
|
+
text: string;
|
|
203
|
+
};
|
|
204
|
+
type BoldTextNode = {
|
|
205
|
+
type: typeof RuleType.textBolded;
|
|
206
|
+
children: ParserResult[];
|
|
207
|
+
};
|
|
208
|
+
type ItalicTextNode = {
|
|
209
|
+
type: typeof RuleType.textEmphasized;
|
|
210
|
+
children: ParserResult[];
|
|
211
|
+
};
|
|
212
|
+
type EscapedTextNode = {
|
|
213
|
+
type: typeof RuleType.textEscaped;
|
|
214
|
+
};
|
|
215
|
+
type MarkedTextNode = {
|
|
216
|
+
type: typeof RuleType.textMarked;
|
|
217
|
+
children: ParserResult[];
|
|
218
|
+
};
|
|
219
|
+
type StrikethroughTextNode = {
|
|
220
|
+
type: typeof RuleType.textStrikethroughed;
|
|
221
|
+
children: ParserResult[];
|
|
222
|
+
};
|
|
223
|
+
type HTMLNode = {
|
|
224
|
+
type: typeof RuleType.htmlBlock;
|
|
225
|
+
attrs: JSX.IntrinsicAttributes | null;
|
|
226
|
+
children?: ReturnType<NestedParser> | undefined;
|
|
227
|
+
noInnerParse: boolean;
|
|
228
|
+
tag: HTMLTags;
|
|
229
|
+
text?: string | undefined;
|
|
230
|
+
};
|
|
231
|
+
type HTMLSelfClosingNode = {
|
|
232
|
+
type: typeof RuleType.htmlSelfClosing;
|
|
233
|
+
attrs: JSX.IntrinsicAttributes | null;
|
|
234
|
+
tag: string;
|
|
235
|
+
};
|
|
236
|
+
type CustomComponentNode = {
|
|
237
|
+
type: typeof RuleType.customComponent;
|
|
238
|
+
attrs: JSX.IntrinsicAttributes | null;
|
|
239
|
+
children?: ReturnType<NestedParser> | undefined;
|
|
240
|
+
noInnerParse: boolean;
|
|
241
|
+
tag: string;
|
|
242
|
+
text?: string | undefined;
|
|
243
|
+
};
|
|
244
|
+
type ParserResult = BlockQuoteNode | BreakLineNode | BreakThematicNode | CodeBlockNode | CodeFencedNode | CodeInlineNode | CustomComponentNode | FootnoteNode | FootnoteReferenceNode | GFMTaskNode | HeadingNode | HeadingSetextNode | HTMLCommentNode | ImageNode | LinkNode | LinkAngleBraceNode | LinkBareURLNode | LinkMailtoNode | OrderedListNode | UnorderedListNode | NewlineNode | ParagraphNode | ReferenceNode | ReferenceImageNode | ReferenceLinkNode | TableNode | TableSeparatorNode | TextNode | BoldTextNode | ItalicTextNode | EscapedTextNode | MarkedTextNode | StrikethroughTextNode | HTMLNode | HTMLSelfClosingNode;
|
|
245
|
+
type NestedParser = (input: string, state: State) => ParserResult[];
|
|
246
|
+
type RuleOutput = (ast: ParserResult | ParserResult[], state: State) => ReactNode;
|
|
247
|
+
type Override = RequireAtLeastOne<{
|
|
248
|
+
component: any;
|
|
249
|
+
props: Object;
|
|
250
|
+
}> | any;
|
|
251
|
+
type Overrides = {
|
|
252
|
+
[tag in HTMLTags]?: Override;
|
|
253
|
+
} & {
|
|
254
|
+
[customComponent: string]: Override;
|
|
255
|
+
};
|
|
256
|
+
export type MarkdownProcessorOptions = Partial<{
|
|
257
|
+
/**
|
|
258
|
+
* Ultimate control over the output of all rendered JSX.
|
|
259
|
+
*/
|
|
260
|
+
createElement: (tag: Parameters<CreateElement>[0], props: JSX.IntrinsicAttributes, ...children: ReactNode[]) => ReactNode;
|
|
261
|
+
/**
|
|
262
|
+
* The library automatically generates an anchor tag for bare URLs included in the markdown
|
|
263
|
+
* document, but this behavior can be disabled if desired.
|
|
264
|
+
*/
|
|
265
|
+
disableAutoLink: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Disable the compiler's best-effort transcription of provided raw HTML
|
|
268
|
+
* into JSX-equivalent. This is the functionality that prevents the need to
|
|
269
|
+
* use `dangerouslySetInnerHTML` in
|
|
270
|
+
*/
|
|
271
|
+
disableParsingRawHTML: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Forces the compiler to have space between hash sign and the header text which
|
|
274
|
+
* is explicitly stated in the most of the markdown specs.
|
|
275
|
+
* https://github.github.com/gfm/#atx-heading
|
|
276
|
+
* `The opening sequence of # characters must be followed by a space or by the end of line.`
|
|
277
|
+
*/
|
|
278
|
+
enforceAtxHeadings: boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Forces the compiler to always output content with a block-level wrapper
|
|
281
|
+
* (`<p>` or any block-level syntax your markdown already contains.)
|
|
282
|
+
*/
|
|
283
|
+
forceBlock: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Forces the compiler to always output content with an inline wrapper (`<span>`)
|
|
286
|
+
*/
|
|
287
|
+
forceInline: boolean;
|
|
288
|
+
/**
|
|
289
|
+
* Forces the compiler to wrap results, even if there is only a single
|
|
290
|
+
* child or no children.
|
|
291
|
+
*/
|
|
292
|
+
forceWrapper: boolean;
|
|
293
|
+
/**
|
|
294
|
+
* Supply additional HTML entity: unicode replacement mappings.
|
|
295
|
+
*
|
|
296
|
+
* Pass only the inner part of the entity as the key,
|
|
297
|
+
* e.g. `≤` -> `{ "le": "\u2264" }`
|
|
298
|
+
*
|
|
299
|
+
* By default
|
|
300
|
+
* the following entities are replaced with their unicode equivalents:
|
|
301
|
+
*
|
|
302
|
+
* ```
|
|
303
|
+
* &
|
|
304
|
+
* '
|
|
305
|
+
* >
|
|
306
|
+
* <
|
|
307
|
+
*
|
|
308
|
+
* "
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
namedCodesToUnicode: {
|
|
312
|
+
[key: string]: string;
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* Selectively control the output of particular HTML tags as they would be
|
|
316
|
+
* emitted by the compiler.
|
|
317
|
+
*/
|
|
318
|
+
overrides: Overrides;
|
|
319
|
+
/**
|
|
320
|
+
* Allows for full control over rendering of particular rules.
|
|
321
|
+
* For example, to implement a LaTeX renderer such as `react-katex`:
|
|
322
|
+
*
|
|
323
|
+
* ```
|
|
324
|
+
* renderRule(next, node, renderChildren, state) {
|
|
325
|
+
* if (node.type === RuleType.codeBlock && node.lang === 'latex') {
|
|
326
|
+
* return (
|
|
327
|
+
* <TeX as="div" key={state.key}>
|
|
328
|
+
* {String.raw`${node.text}`}
|
|
329
|
+
* </TeX>
|
|
330
|
+
* )
|
|
331
|
+
* }
|
|
332
|
+
*
|
|
333
|
+
* return next();
|
|
334
|
+
* }
|
|
335
|
+
* ```
|
|
336
|
+
*
|
|
337
|
+
* Thar be dragons obviously, but you can do a lot with this
|
|
338
|
+
* (have fun!) To see how things work internally, check the `render`
|
|
339
|
+
* method in source for a particular rule.
|
|
340
|
+
*/
|
|
341
|
+
renderRule: (
|
|
342
|
+
/** Resume normal processing, call this function as a fallback if you are not returning custom JSX. */
|
|
343
|
+
next: () => ReactNode,
|
|
344
|
+
/** the current AST node, use `RuleType` against `node.type` for identification */
|
|
345
|
+
node: ParserResult,
|
|
346
|
+
/** use as `renderChildren(node.children)` for block nodes */
|
|
347
|
+
renderChildren: RuleOutput,
|
|
348
|
+
/** contains `key` which should be supplied to the topmost JSX element */
|
|
349
|
+
state: State) => ReactNode;
|
|
350
|
+
/**
|
|
351
|
+
* Override the built-in sanitizer function for URLs, etc if desired. The built-in version is available as a library export called `sanitizer`.
|
|
352
|
+
*/
|
|
353
|
+
sanitizer: (value: string, tag: HTMLTags, attribute: string) => string | null;
|
|
354
|
+
/**
|
|
355
|
+
* Override normalization of non-URI-safe characters for use in generating
|
|
356
|
+
* HTML IDs for anchor linking purposes.
|
|
357
|
+
*/
|
|
358
|
+
slugify: (input: string, defaultFn: (input: string) => string) => string;
|
|
359
|
+
/**
|
|
360
|
+
* Declare the type of the wrapper to be used when there are multiple
|
|
361
|
+
* children to render. Set to `null` to get an array of children back
|
|
362
|
+
* without any wrapper, or use `Fragment` to get a React element
|
|
363
|
+
* that won't show up in the DOM.
|
|
364
|
+
*/
|
|
365
|
+
wrapper: any | null;
|
|
366
|
+
}>;
|
|
367
|
+
export {};
|
|
368
|
+
//# sourceMappingURL=processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor.d.ts","sourceRoot":"","sources":["../../../src/components/MarkDownRender/processor.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAEL,aAAa,EAEb,EAAE,EACF,cAAc,EACd,GAAG,EACH,GAAG,EACH,SAAS,EACV,MAAM,OAAO,CAAC;AAEf;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;IAYnB,iDAAiD;;;IAGjD,iDAAiD;;IAEjD,+CAA+C;;;;IAI/C,sDAAsD;;IAEtD,sDAAsD;;IAEtD,sDAAsD;;;;;;;;;;;;;;;;;CAiB9C,CAAC;AAMX,KAAK,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AA2kBzD,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAapB,CAAC;AAogBnB,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,MAAM,GAAG,IA6BlD,CAAC;AAwMF,eAAO,MAAM,QAAQ,GACnB,WAAU,MAAW,EACrB,UAAS,wBAA6B,KACrC,GAAG,CAAC,OAyuCN,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAChC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,GAAG;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC,CAaF,CAAC;AAEF;;GAEG;AACH,KAAK,iBAAiB,CAAC,CAAC,EAAE,IAAI,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,IAAI,CAC9D,CAAC,EACD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI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