@mdxeditor/editor 0.1.0 → 0.1.1

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.
@@ -0,0 +1,722 @@
1
+ /**
2
+ * The `@mdxeditor/editor` package exports the MDXEditor React component, along with some utilities and default option values that id the customization of the widget.
3
+ * In addition to that, the package exports the LexicalNodes used to represent the MDX AST, as well as the NodeDecorators used to render the nodes in the editor.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+
8
+ /// <reference types="react" />
9
+
10
+ import { AdmonitionKind } from 'lexical';
11
+ import type { ComponentType } from 'react';
12
+ import { ContainerDirective } from 'mdast-util-directive';
13
+ import { DecoratorNode } from 'lexical';
14
+ import type { DOMConversionMap } from 'lexical';
15
+ import type { DOMExportOutput } from 'lexical';
16
+ import { EditorConfig } from 'lexical';
17
+ import { EditorThemeClasses } from 'lexical';
18
+ import { ElementNode } from 'lexical';
19
+ import { FromMarkdownOptions } from 'mdast-util-from-markdown/lib';
20
+ import { HeadingNode } from '@lexical/rich-text';
21
+ import { HorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode';
22
+ import { Klass } from 'lexical';
23
+ import { LexicalEditor } from 'lexical';
24
+ import { LexicalNode } from 'lexical';
25
+ import { LineBreakNode } from 'lexical';
26
+ import { LinkNode } from '@lexical/link';
27
+ import { ListItemNode } from '@lexical/list';
28
+ import { ListNode } from '@lexical/list';
29
+ import * as Mdast from 'mdast';
30
+ import { MdxjsEsm } from 'mdast-util-mdx';
31
+ import { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
32
+ import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
33
+ import type { MdxJsxTextElement } from 'mdast-util-mdx-jsx';
34
+ import { MdxJsxTextElement as MdxJsxTextElement_2 } from 'mdast-util-mdx';
35
+ import { NodeKey } from 'lexical';
36
+ import { ParagraphNode } from 'lexical';
37
+ import { ParseOptions } from 'mdast-util-from-markdown/lib';
38
+ import { QuoteNode } from '@lexical/rich-text';
39
+ import * as RadixToolbar from '@radix-ui/react-toolbar';
40
+ import { RangeSelection } from 'lexical';
41
+ import { default as React_2 } from 'react';
42
+ import { RootNode } from 'lexical';
43
+ import { SandpackProvider } from '@codesandbox/sandpack-react';
44
+ import { SerializedEditorState } from 'lexical';
45
+ import { SerializedElementNode } from 'lexical';
46
+ import { SerializedLexicalNode } from 'lexical';
47
+ import { Spread } from 'lexical';
48
+ import { TextNode } from 'lexical';
49
+ import { Options as ToMarkdownOptions } from 'mdast-util-to-markdown';
50
+
51
+ export declare function $createAdmonitionNode(kind?: AdmonitionKind): AdmonitionNode;
52
+
53
+ export declare function $createCodeBlockNode({ code, language, meta }: CodeBlockPayload): CodeBlockNode;
54
+
55
+ export declare function $createFrontmatterNode({ yaml }: FrontmatterPayload): FrontmatterNode;
56
+
57
+ export declare function $createImageNode({ altText, title, src, key }: ImagePayload): ImageNode;
58
+
59
+ export declare function $createJsxNode(payload: JsxPayload): JsxNode;
60
+
61
+ export declare function $createSandpackNode({ code, language, meta }: SandpackPayload): SandpackNode;
62
+
63
+ export declare function $createTableNode(mdastNode: Mdast.Table): TableNode;
64
+
65
+ export declare function $isAdmonitionNode(node: LexicalNode | null | undefined): node is AdmonitionNode;
66
+
67
+ export declare function $isCodeBlockNode(node: LexicalNode | null | undefined): node is CodeBlockNode;
68
+
69
+ export declare function $isFrontmatterNode(node: LexicalNode | null | undefined): node is FrontmatterNode;
70
+
71
+ export declare function $isImageNode(node: LexicalNode | null | undefined): node is ImageNode;
72
+
73
+ export declare function $isJsxNode(node: LexicalNode | null | undefined): node is JsxNode;
74
+
75
+ export declare function $isSandpackNode(node: LexicalNode | null | undefined): node is SandpackNode;
76
+
77
+ export declare function $isTableNode(node: LexicalNode | null | undefined): node is TableNode;
78
+
79
+ export declare type ActiveEditorType = LexicalEditorType | CodeBlockEditorType | SandpackEditorType;
80
+
81
+ export { AdmonitionKind }
82
+
83
+ export declare class AdmonitionNode extends ElementNode {
84
+ __kind: AdmonitionKind;
85
+ static getType(): string;
86
+ getKind(): AdmonitionKind;
87
+ setKind(kind: AdmonitionKind): void;
88
+ static clone(node: AdmonitionNode): AdmonitionNode;
89
+ constructor(kind?: AdmonitionKind, key?: NodeKey);
90
+ createDOM(config: EditorConfig): HTMLElement;
91
+ updateDOM(_prevNode: AdmonitionNode, _dom: HTMLElement): boolean;
92
+ static importJSON(serializedNode: SerializedAdmonitionNode): AdmonitionNode;
93
+ exportJSON(): SerializedElementNode;
94
+ insertNewAfter(_: RangeSelection, restoreSelection?: boolean): AdmonitionNode;
95
+ collapseAtStart(): true;
96
+ }
97
+
98
+ export declare interface CodeBlockEditorProps extends SandpackEditorProps {
99
+ language: string;
100
+ }
101
+
102
+ export declare type CodeBlockEditorType = {
103
+ type: 'codeblock';
104
+ nodeKey: string;
105
+ };
106
+
107
+ export declare class CodeBlockNode extends DecoratorNode<JSX.Element> {
108
+ __code: string;
109
+ __meta: string;
110
+ __language: string;
111
+ __focusEmitter: {
112
+ publish: () => void;
113
+ subscribe: (cb: () => void) => void;
114
+ };
115
+ static getType(): string;
116
+ static clone(node: CodeBlockNode): CodeBlockNode;
117
+ static importJSON(serializedNode: SerializedCodeBlockNode): CodeBlockNode;
118
+ constructor(code: string, language: string, meta: string, key?: NodeKey);
119
+ exportJSON(): SerializedCodeBlockNode;
120
+ createDOM(_config: EditorConfig): HTMLDivElement;
121
+ updateDOM(): false;
122
+ getCode(): string;
123
+ getMeta(): string;
124
+ getLanguage(): string;
125
+ setCode(code: string): void;
126
+ setMeta(meta: string): void;
127
+ setLanguage(language: string): void;
128
+ select(): void;
129
+ decorate(_editor: LexicalEditor, { theme: { nodeDecoratorComponents: { CodeBlockEditor } } }: ExtendedEditorConfig): JSX.Element;
130
+ }
131
+
132
+ export declare interface CodeBlockPayload {
133
+ code: string;
134
+ meta: string;
135
+ language: string;
136
+ }
137
+
138
+ export declare type CoordinatesSubscription = (coords: [colIndex: number, rowIndex: number]) => void;
139
+
140
+ export declare const defaultExtensions: {
141
+ mdxToMarkdown: ToMarkdownOptions;
142
+ frontmatterToMarkdown: ToMarkdownOptions;
143
+ directiveToMarkdown: ToMarkdownOptions;
144
+ gfmTableToMarkdown: ToMarkdownOptions;
145
+ };
146
+
147
+ export declare const defaultLexicalNodes: Record<string, Klass<LexicalNode>>;
148
+
149
+ export declare const defaultLexicalVisitors: {
150
+ LexicalRootVisitor: LexicalExportVisitor<RootNode, Mdast.Content>;
151
+ LexicalParagraphVisitor: LexicalExportVisitor<ParagraphNode, Mdast.Paragraph>;
152
+ LexicalFrontmatterVisitor: LexicalExportVisitor<FrontmatterNode, Mdast.YAML>;
153
+ LexicalTextVisitor: LexicalExportVisitor<TextNode, Mdast.Text>;
154
+ LexicalLinebreakVisitor: LexicalExportVisitor<LineBreakNode, Mdast.Text>;
155
+ LexicalLinkVisitor: LexicalExportVisitor<LinkNode, Mdast.Link>;
156
+ LexicalHeadingVisitor: LexicalExportVisitor<HeadingNode, Mdast.Heading>;
157
+ LexicalListVisitor: LexicalExportVisitor<ListNode, Mdast.List>;
158
+ LexicalListItemVisitor: LexicalExportVisitor<ListItemNode, Mdast.ListItem>;
159
+ LexicalQuoteVisitor: LexicalExportVisitor<QuoteNode, Mdast.Blockquote>;
160
+ SandpackNodeVisitor: LexicalExportVisitor<SandpackNode, Mdast.Code>;
161
+ CodeBlockVisitor: LexicalExportVisitor<CodeBlockNode, Mdast.Code>;
162
+ LexicalThematicBreakVisitor: LexicalExportVisitor<HorizontalRuleNode, Mdast.ThematicBreak>;
163
+ AdmonitionVisitor: LexicalExportVisitor<AdmonitionNode, ContainerDirective>;
164
+ LexicalImageVisitor: LexicalExportVisitor<ImageNode, Mdast.Image>;
165
+ JsxVisitor: LexicalExportVisitor<JsxNode, MdxJsxFlowElement | MdxJsxTextElement>;
166
+ LexicalTableVisitor: LexicalExportVisitor<TableNode, Mdast.Table>;
167
+ };
168
+
169
+ export declare const defaultMdastExtensions: Record<string, MarkdownParseOptions['mdastExtensions'][number]>;
170
+
171
+ export declare const defaultMdastVisitors: Record<string, MdastImportVisitor<Mdast.Content>>;
172
+
173
+ export declare interface DefaultMdxOptionValues {
174
+ markdownParse: {
175
+ defaultVisitors: typeof defaultMdastVisitors;
176
+ defaultSyntaxExtensions: typeof defaultSyntaxExtensions;
177
+ defaultMdastExtensions: typeof defaultMdastExtensions;
178
+ };
179
+ lexicalConvert: {
180
+ defaultVisitors: typeof defaultLexicalVisitors;
181
+ defaultExtensions: typeof defaultExtensions;
182
+ defaultMarkdownOptions: typeof defaultToMarkdownOptions;
183
+ };
184
+ defaultLexicalNodes: typeof defaultLexicalNodes;
185
+ }
186
+
187
+ export declare const defaultMdxOptionValues: DefaultMdxOptionValues;
188
+
189
+ export declare const defaultSyntaxExtensions: Record<string, MarkdownParseOptions['syntaxExtensions'][number]>;
190
+
191
+ export declare const defaultToMarkdownOptions: ToMarkdownOptions;
192
+
193
+ export declare interface ExportLexicalTreeOptions {
194
+ root: RootNode;
195
+ visitors: LexicalVisitor[];
196
+ jsxComponentDescriptors: JsxComponentDescriptors;
197
+ }
198
+
199
+ export declare function exportLexicalTreeToMdast({ root, visitors, jsxComponentDescriptors }: ExportLexicalTreeOptions): Mdast.Root;
200
+
201
+ export declare function exportMarkdownFromLexical({ root, toMarkdownOptions, toMarkdownExtensions, visitors, jsxComponentDescriptors }: ExportMarkdownFromLexicalOptions): string;
202
+
203
+ export declare interface ExportMarkdownFromLexicalOptions extends ExportLexicalTreeOptions {
204
+ toMarkdownExtensions: ToMarkdownOptions['extensions'];
205
+ toMarkdownOptions: ToMarkdownOptions;
206
+ }
207
+
208
+ declare type ExtendedEditorConfig = EditorConfig & {
209
+ theme: EditorConfig['theme'] & {
210
+ nodeDecoratorComponents: NodeDecoratorComponents;
211
+ };
212
+ };
213
+
214
+ export declare interface FrontmatterEditorProps {
215
+ yaml: string;
216
+ onChange: (yaml: string) => void;
217
+ }
218
+
219
+ export declare class FrontmatterNode extends DecoratorNode<JSX.Element> {
220
+ __yaml: string;
221
+ static getType(): string;
222
+ static clone(node: FrontmatterNode): FrontmatterNode;
223
+ static importJSON(serializedNode: SerializedFrontmatterNode): FrontmatterNode;
224
+ constructor(code: string, key?: NodeKey);
225
+ exportJSON(): SerializedFrontmatterNode;
226
+ createDOM(_config: EditorConfig): HTMLDivElement;
227
+ updateDOM(): false;
228
+ getYaml(): string;
229
+ setYaml(yaml: string): void;
230
+ decorate(editor: LexicalEditor, { theme: { nodeDecoratorComponents: { FrontmatterEditor } } }: ExtendedEditorConfig): JSX.Element;
231
+ }
232
+
233
+ export declare interface FrontmatterPayload {
234
+ yaml: string;
235
+ }
236
+
237
+ export declare class ImageNode extends DecoratorNode<JSX.Element> {
238
+ __src: string;
239
+ __altText: string;
240
+ __title: string | undefined;
241
+ static getType(): string;
242
+ static clone(node: ImageNode): ImageNode;
243
+ static importJSON(serializedNode: SerializedImageNode): ImageNode;
244
+ exportDOM(): DOMExportOutput;
245
+ static importDOM(): DOMConversionMap | null;
246
+ constructor(src: string, altText: string, title: string | undefined, key?: NodeKey);
247
+ exportJSON(): SerializedImageNode;
248
+ createDOM(config: EditorConfig): HTMLElement;
249
+ updateDOM(): false;
250
+ getSrc(): string;
251
+ getAltText(): string;
252
+ getTitle(): string | undefined;
253
+ setTitle(title: string | undefined): void;
254
+ decorate(): JSX.Element;
255
+ }
256
+
257
+ export declare interface ImagePayload {
258
+ altText: string;
259
+ title?: string;
260
+ key?: NodeKey;
261
+ src: string;
262
+ }
263
+
264
+ export declare function importMarkdownToLexical({ root, markdown, visitors, syntaxExtensions, mdastExtensions }: MarkdownParseOptions): void;
265
+
266
+ export declare function importMdastTreeToLexical({ root, mdastRoot, visitors }: MdastTreeImportOptions): void;
267
+
268
+ export declare type ImportVisitors = Array<MdastImportVisitor<Mdast.Content>>;
269
+
270
+ declare const IS_BOLD: 1;
271
+
272
+ declare const IS_ITALIC: 2;
273
+
274
+ declare const IS_UNDERLINE: 8;
275
+
276
+ export declare interface JsxComponentDescriptor {
277
+ name: string;
278
+ kind: 'flow' | 'text';
279
+ source: string;
280
+ defaultExport?: boolean;
281
+ props: Array<JsxPropertyDescriptor>;
282
+ }
283
+
284
+ export declare type JsxComponentDescriptors = Array<JsxComponentDescriptor>;
285
+
286
+ export declare interface JsxEditorProps {
287
+ kind: JsxKind;
288
+ attributes: MdxJsxAttribute[];
289
+ componentName: string;
290
+ onSubmit: (values: Record<string, string>) => void;
291
+ theme: EditorThemeClasses;
292
+ editor: LexicalEditor;
293
+ }
294
+
295
+ export declare type JsxKind = 'text' | 'flow';
296
+
297
+ export declare class JsxNode extends DecoratorNode<JSX.Element> {
298
+ __kind: JsxKind;
299
+ __name: string;
300
+ __attributes: Array<MdxJsxAttribute>;
301
+ __editor: LexicalEditor;
302
+ static getType(): string;
303
+ static clone(node: JsxNode): JsxNode;
304
+ static importJSON(serializedNode: SerializedJsxNode): JsxNode;
305
+ constructor({ name, kind, attributes, state, updateFn, key }: JsxNodeConstructorParams);
306
+ exportJSON(): SerializedJsxNode;
307
+ inNestedEditor(callback: () => void): void;
308
+ getChildren(): Array<LexicalNode>;
309
+ createDOM(): HTMLElement;
310
+ updateDOM(): false;
311
+ getName(): string;
312
+ getKind(): JsxKind;
313
+ getAttributes(): MdxJsxAttribute[];
314
+ updateAttributes(attributeValues: Record<string, string>): void;
315
+ decorate(_parentEditor: LexicalEditor, { theme: { nodeDecoratorComponents: { JsxEditor } } }: ExtendedEditorConfig): JSX.Element;
316
+ }
317
+
318
+ export declare interface JsxNodeConstructorParams extends JsxPayload {
319
+ key?: NodeKey;
320
+ }
321
+
322
+ export declare interface JsxPayload {
323
+ name: string;
324
+ kind: JsxKind;
325
+ attributes: Array<MdxJsxAttribute>;
326
+ state?: SerializedEditorState;
327
+ updateFn?: updateFn;
328
+ }
329
+
330
+ export declare interface JsxPropertyDescriptor {
331
+ name: string;
332
+ type: 'string' | 'number';
333
+ required?: boolean;
334
+ }
335
+
336
+ export declare type LexicalEditorType = {
337
+ type: 'lexical';
338
+ };
339
+
340
+ export declare interface LexicalExportVisitor<LN extends LexicalNode, UN extends Mdast.Content> {
341
+ testLexicalNode?(lexicalNode: LexicalNode): lexicalNode is LN;
342
+ visitLexicalNode?(params: LexicalNodeVisitParams<LN>): void;
343
+ shouldJoin?(prevNode: Mdast.Content, currentNode: UN): boolean;
344
+ join?<T extends Mdast.Content>(prevNode: T, currentNode: T): T;
345
+ }
346
+
347
+ export declare interface LexicalNodeVisitParams<T extends LexicalNode> {
348
+ lexicalNode: T;
349
+ mdastParent: Mdast.Parent;
350
+ actions: LexicalVisitActions<T>;
351
+ }
352
+
353
+ export declare interface LexicalVisitActions<T extends LexicalNode> {
354
+ visitChildren(node: T, mdastParent: Mdast.Parent): void;
355
+ addAndStepInto(type: string, props?: Record<string, unknown>, hasChildren?: boolean): void;
356
+ appendToParent<T extends Mdast.Parent>(parentNode: T, node: T['children'][number]): T['children'][number] | Mdast.Root;
357
+ registerReferredComponent(componentName: string): void;
358
+ }
359
+
360
+ export declare type LexicalVisitor = LexicalExportVisitor<LexicalNode, Mdast.Content>;
361
+
362
+ export declare interface MarkdownParseOptions extends Omit<MdastTreeImportOptions, 'mdastRoot'> {
363
+ markdown: string;
364
+ syntaxExtensions: NonNullable<ParseOptions['extensions']>;
365
+ mdastExtensions: NonNullable<FromMarkdownOptions['mdastExtensions']>;
366
+ }
367
+
368
+ export declare const MdastAdmonitionVisitor: MdastImportVisitor<ContainerDirective>;
369
+
370
+ export declare const MdastBlockQuoteVisitor: MdastImportVisitor<Mdast.Blockquote>;
371
+
372
+ export declare const MdastCodeVisitor: MdastImportVisitor<Mdast.Code>;
373
+
374
+ export declare const MdastFormattingVisitor: MdastImportVisitor<Mdast.Emphasis | Mdast.Strong | MdxJsxTextElement_2>;
375
+
376
+ export declare const MdastFrontmatterVisitor: MdastImportVisitor<Mdast.YAML>;
377
+
378
+ export declare const MdastHeadingVisitor: MdastImportVisitor<Mdast.Heading>;
379
+
380
+ export declare const MdastImageVisitor: MdastImportVisitor<Mdast.Image>;
381
+
382
+ export declare interface MdastImportVisitor<UN extends Mdast.Content> {
383
+ testNode: ((mdastNode: Mdast.Content | Mdast.Root) => boolean) | string;
384
+ visitNode(params: MdastVisitParams<UN>): void;
385
+ }
386
+
387
+ export declare const MdastInlineCodeVisitor: MdastImportVisitor<Mdast.InlineCode>;
388
+
389
+ export declare const MdastLinkVisitor: MdastImportVisitor<Mdast.Link>;
390
+
391
+ export declare const MdastListItemVisitor: MdastImportVisitor<Mdast.ListItem>;
392
+
393
+ export declare const MdastListVisitor: MdastImportVisitor<Mdast.List>;
394
+
395
+ export declare const MdastMdxJsEsmVisitor: MdastImportVisitor<MdxjsEsm>;
396
+
397
+ export declare const MdastMdxJsxElementVisitor: MdastImportVisitor<MdxJsxTextElement_2>;
398
+
399
+ export declare const MdastParagraphVisitor: MdastImportVisitor<Mdast.Paragraph>;
400
+
401
+ export declare const MdastRootVisitor: MdastImportVisitor<Mdast.Content>;
402
+
403
+ export declare const MdastTableVisitor: MdastImportVisitor<Mdast.Table>;
404
+
405
+ export declare const MdastTextVisitor: MdastImportVisitor<Mdast.Text>;
406
+
407
+ export declare const MdastThematicBreakVisitor: MdastImportVisitor<Mdast.ThematicBreak>;
408
+
409
+ export declare interface MdastTreeImportOptions {
410
+ root: RootNode;
411
+ visitors: Array<MdastImportVisitor<Mdast.Content>>;
412
+ mdastRoot: Mdast.Root;
413
+ }
414
+
415
+ export declare interface MdastVisitActions {
416
+ visitChildren(node: Mdast.Parent, lexicalParent: LexicalNode): void;
417
+ addAndStepInto(lexicalNode: LexicalNode): void;
418
+ addFormatting(format: typeof IS_BOLD | typeof IS_ITALIC | typeof IS_UNDERLINE): void;
419
+ getParentFormatting(): number;
420
+ }
421
+
422
+ export declare interface MdastVisitParams<T extends Mdast.Content> {
423
+ mdastNode: T;
424
+ lexicalParent: LexicalNode;
425
+ actions: MdastVisitActions;
426
+ }
427
+
428
+ /**
429
+ * The MDXEditor React component
430
+ */
431
+ export declare const MDXEditor: React_2.ForwardRefExoticComponent<MDXEditorProps & React_2.RefAttributes<MDXEditorMethods>>;
432
+
433
+ /**
434
+ * The interface for the {@link MDXEditor} object reference.
435
+ *
436
+ * @example
437
+ * ```tsx
438
+ * const mdxEditorRef = React.useRef<MDXEditorMethods>(null)
439
+ * <MDXEditor ref={mdxEditorRef} />
440
+ * ```
441
+ */
442
+ export declare interface MDXEditorMethods {
443
+ getMarkdown: () => string;
444
+ }
445
+
446
+ /**
447
+ * The properties of the {@link MDXEditor} react component
448
+ */
449
+ export declare interface MDXEditorProps {
450
+ /**
451
+ * The markdown content to be edited.
452
+ */
453
+ markdown: string;
454
+ /**
455
+ * The configuration for the sandpack editor that's used for the fenced code blocks.
456
+ * @see the {@link SandpackConfig} interface for more details.
457
+ */
458
+ sandpackConfig?: SandpackConfig;
459
+ /**
460
+ * The markdown content to use for the diff view mode. If not provided, the contents of the `markdown` prop will be used.
461
+ */
462
+ headMarkdown?: string;
463
+ /**
464
+ * The configuration for the JSX components used in the markdown content.
465
+ * @see the {@link JsxComponentDescriptors} interface for more details.
466
+ */
467
+ jsxComponentDescriptors?: JsxComponentDescriptors;
468
+ /**
469
+ * The list of suggestions to be shown in the link autocomplete dialog dropdown.
470
+ */
471
+ linkAutocompleteSuggestions?: string[];
472
+ /**
473
+ * The list of suggestions to be shown in the image autocomplete dialog dropdown.
474
+ */
475
+ imageAutoCompleteSuggestions?: string[];
476
+ /**
477
+ * The set of components to be rendered in the toolbar.
478
+ */
479
+ toolbarComponents?: ComponentType[];
480
+ /**
481
+ * The initial view mode for the editor. Defaults to `ViewMode.editor`.
482
+ */
483
+ viewMode?: ViewMode;
484
+ onChange?: (markdown: string) => void;
485
+ className?: string;
486
+ contentEditableClassName?: string;
487
+ markdownParseOptions?: Partial<MarkdownParseOptions>;
488
+ lexicalNodes?: Klass<LexicalNode>[];
489
+ lexicalConvertOptions?: Partial<ExportMarkdownFromLexicalOptions>;
490
+ }
491
+
492
+ declare interface NodeDecoratorComponents {
493
+ FrontmatterEditor: React.FC<FrontmatterEditorProps>;
494
+ JsxEditor: React.FC<JsxEditorProps>;
495
+ SandpackEditor: React.FC<SandpackEditorProps>;
496
+ CodeBlockEditor: React.FC<CodeBlockEditorProps>;
497
+ TableEditor: React.FC<TableEditorProps>;
498
+ }
499
+
500
+ /**
501
+ * The configuration for the available sandpack presets
502
+ */
503
+ export declare interface SandpackConfig {
504
+ /**
505
+ * The name of the default preset that will be used if no meta (other than live) is set
506
+ */
507
+ defaultPreset: string;
508
+ /**
509
+ * The list of sandpack presets that can be used
510
+ */
511
+ presets: Array<SandpackPreset>;
512
+ }
513
+
514
+ export declare interface SandpackEditorProps {
515
+ code: string;
516
+ nodeKey: string;
517
+ meta: string;
518
+ onChange: (code: string) => void;
519
+ focusEmitter: VoidEmitter;
520
+ }
521
+
522
+ export declare type SandpackEditorType = {
523
+ type: 'sandpack';
524
+ nodeKey: string;
525
+ };
526
+
527
+ export declare class SandpackNode extends DecoratorNode<JSX.Element> {
528
+ __code: string;
529
+ __meta: string;
530
+ __language: string;
531
+ __focusEmitter: {
532
+ publish: () => void;
533
+ subscribe: (cb: () => void) => void;
534
+ };
535
+ static getType(): string;
536
+ static clone(node: SandpackNode): SandpackNode;
537
+ static importJSON(serializedNode: SerializedSandpackNode): SandpackNode;
538
+ constructor(code: string, language: string, meta: string, key?: NodeKey);
539
+ exportJSON(): SerializedSandpackNode;
540
+ createDOM(_config: EditorConfig): HTMLDivElement;
541
+ updateDOM(): false;
542
+ getCode(): string;
543
+ getMeta(): string;
544
+ getLanguage(): string;
545
+ setCode(code: string): void;
546
+ setMeta(meta: string): void;
547
+ setLanguage(language: string): void;
548
+ select(): void;
549
+ decorate(_parentEditor: LexicalEditor, { theme: { nodeDecoratorComponents: { SandpackEditor } } }: ExtendedEditorConfig): JSX.Element;
550
+ }
551
+
552
+ export declare interface SandpackPayload {
553
+ code: string;
554
+ meta: string;
555
+ language: string;
556
+ }
557
+
558
+ /**
559
+ * Defines a single preset that can be used to create a sandbox.
560
+ */
561
+ export declare interface SandpackPreset {
562
+ /**
563
+ * The name of the preset - use this to reference the preset from the defaultPreset field
564
+ */
565
+ name: string;
566
+ /**
567
+ * The label of th preset, displayed in the sandpack button dropdown
568
+ */
569
+ label: string;
570
+ /**
571
+ * The meta string that will be used to identify the preset from the fenced code block. e.g. "live react"
572
+ */
573
+ meta: string;
574
+ /**
575
+ * The sandpack template that will be used to create the sandbox. e.g. "react", "react-ts", "vanilla".
576
+ */
577
+ sandpackTemplate: SandpackProviderProps['template'];
578
+ /**
579
+ * The sandpack theme that will be used to create the sandbox. e.g. "light", "dark".
580
+ */
581
+ sandpackTheme: SandpackProviderProps['theme'];
582
+ /**
583
+ * The name of the file that will be created in the sandbox. e.g. "/App.js"
584
+ */
585
+ snippetFileName: string;
586
+ /**
587
+ * The dependencies that will be added to the sandbox, just like in package.json
588
+ */
589
+ dependencies?: Record<string, string>;
590
+ /**
591
+ * The files that will be added to the sandbox (read-only).
592
+ * The key is the name of the file, and the value is the contents of the file.
593
+ */
594
+ files?: Record<string, string>;
595
+ /**
596
+ * The language used in the editable snippet. e.g. "jsx", "tsx", etc
597
+ */
598
+ snippetLanguage?: string;
599
+ /**
600
+ * The initial content of the editable snippet.
601
+ */
602
+ initialSnippetContent?: string;
603
+ }
604
+
605
+ declare type SandpackProviderProps = React_2.ComponentProps<typeof SandpackProvider>;
606
+
607
+ export declare type SerializedAdmonitionNode = Spread<{
608
+ type: 'admonition';
609
+ kind: AdmonitionKind;
610
+ version: 1;
611
+ }, SerializedElementNode>;
612
+
613
+ export declare type SerializedCodeBlockNode = Spread<CodeBlockPayload & {
614
+ type: 'codeblock';
615
+ version: 1;
616
+ }, SerializedLexicalNode>;
617
+
618
+ export declare type SerializedFrontmatterNode = Spread<{
619
+ yaml: string;
620
+ version: 1;
621
+ }, SerializedLexicalNode>;
622
+
623
+ export declare type SerializedImageNode = Spread<{
624
+ altText: string;
625
+ title?: string;
626
+ src: string;
627
+ type: 'image';
628
+ version: 1;
629
+ }, SerializedLexicalNode>;
630
+
631
+ export declare type SerializedJsxNode = Spread<Omit<JsxPayload, 'updateFn'> & {
632
+ version: 1;
633
+ type: 'jsx';
634
+ }, SerializedLexicalNode>;
635
+
636
+ export declare type SerializedSandpackNode = Spread<SandpackPayload & {
637
+ type: 'sandpack';
638
+ version: 1;
639
+ }, SerializedLexicalNode>;
640
+
641
+ export declare type SerializedTableNode = Spread<{
642
+ mdastNode: Mdast.Table;
643
+ }, SerializedLexicalNode>;
644
+
645
+ export declare interface TableEditorProps {
646
+ parentEditor: LexicalEditor;
647
+ lexicalTable: TableNode;
648
+ mdastNode: Mdast.Table;
649
+ }
650
+
651
+ export declare class TableNode extends DecoratorNode<JSX.Element> {
652
+ __mdastNode: Mdast.Table;
653
+ focusEmitter: {
654
+ publish: (coords: [colIndex: number, rowIndex: number]) => void;
655
+ subscribe: (cb: CoordinatesSubscription) => void;
656
+ };
657
+ static getType(): string;
658
+ static clone(node: TableNode): TableNode;
659
+ static importJSON(serializedNode: SerializedTableNode): TableNode;
660
+ exportJSON(): SerializedTableNode;
661
+ getMdastNode(): Mdast.Table;
662
+ getRowCount(): number;
663
+ getColCount(): number;
664
+ constructor(mdastNode?: Mdast.Table, key?: NodeKey);
665
+ createDOM(): HTMLElement;
666
+ updateDOM(): false;
667
+ updateCellContents(colIndex: number, rowIndex: number, children: Mdast.PhrasingContent[]): void;
668
+ insertColumnAt(colIndex: number): void;
669
+ deleteColumnAt(colIndex: number): void;
670
+ insertRowAt(y: number): void;
671
+ deleteRowAt(rowIndex: number): void;
672
+ addRowToBottom(): void;
673
+ addColumnToRight(): void;
674
+ setColumnAlign(colIndex: number, align: Mdast.AlignType): void;
675
+ decorate(parentEditor: LexicalEditor, { theme: { nodeDecoratorComponents: { TableEditor } } }: ExtendedEditorConfig): JSX.Element;
676
+ select(coords: [colIndex: number, rowIndex: number]): void;
677
+ isInline(): false;
678
+ }
679
+
680
+ export { ToMarkdownOptions }
681
+
682
+ export declare const ToolbarComponents: {
683
+ BlockTypeSelect: () => React_2.JSX.Element;
684
+ BoldItalicUnderlineButtons: React_2.FC<{}>;
685
+ CodeBlockButton: React_2.FC<{}>;
686
+ FrontmatterButton: React_2.FC<{}>;
687
+ GroupGroup: React_2.FC<{
688
+ children: React_2.ReactNode;
689
+ }>;
690
+ HorizontalRuleIcon: React_2.FC<React_2.SVGProps<SVGSVGElement> & {
691
+ title?: string | undefined;
692
+ }>;
693
+ LinkButton: React_2.FC<{}>;
694
+ ListButtons: React_2.FC<{}>;
695
+ SandpackButton: React_2.FC<{}>;
696
+ TableButton: React_2.FC<{}>;
697
+ ToggleItem: React_2.ForwardRefExoticComponent<RadixToolbar.ToolbarToggleItemProps & React_2.RefAttributes<HTMLButtonElement>>;
698
+ ToggleSingleGroup: React_2.ForwardRefExoticComponent<Omit<RadixToolbar.ToolbarToggleGroupSingleProps, "type"> & React_2.RefAttributes<HTMLDivElement>>;
699
+ ToggleSingleGroupWithItem: React_2.ForwardRefExoticComponent<Omit<RadixToolbar.ToolbarToggleGroupSingleProps, "type"> & {
700
+ on: boolean;
701
+ } & React_2.RefAttributes<HTMLDivElement>>;
702
+ ToolbarButton: React_2.ForwardRefExoticComponent<RadixToolbar.ToolbarButtonProps & React_2.RefAttributes<HTMLButtonElement>>;
703
+ ToolbarSeparator: React_2.ForwardRefExoticComponent<RadixToolbar.ToolbarSeparatorProps & React_2.RefAttributes<HTMLDivElement>>;
704
+ ImageButton: React_2.ForwardRefExoticComponent<RadixToolbar.ToolbarButtonProps & React_2.RefAttributes<HTMLButtonElement>>;
705
+ };
706
+
707
+ export declare type updateFn = (node: LexicalNode) => void;
708
+
709
+ /**
710
+ * The editor view mode.
711
+ * editor - The default rich text view mode.
712
+ * markdown - plain text markdown edit mode.
713
+ * diff - side by side comparison with the original markdown (passed as `headMarkdown`).
714
+ */
715
+ export declare type ViewMode = 'editor' | 'markdown' | 'diff';
716
+
717
+ export declare interface VoidEmitter {
718
+ publish: () => void;
719
+ subscribe: (callback: () => void) => void;
720
+ }
721
+
722
+ export { }