@mdxeditor/editor 3.0.6 → 3.0.8

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 CHANGED
@@ -1,38 +1,7 @@
1
- /**
2
- * The `@mdxeditor/editor` package exports the MDXEditor React component and a set of plugins and
3
- * pre-made components for editing/editor UI.
4
- *
5
- * The API Reference is organized around the various features of the editor. Usually, each feature is implemented as a plugin.
6
- *
7
- * Several note-worthy types of exports are available:
8
- *
9
- * **dollar-suffixed variables** (e.g. `markdown$`, `applyBlockType$`, etc.). These are [reactive Gurx primitives (Cells and Signals)](https://mdx-editor.github.io/gurx/)
10
- * which let you interact with the editor state and extend it with your own custom logic.
11
- *
12
- * The MDXEditor package re-exports Gurx's React hooks, so you can use them like this for example:
13
- * ```tsx
14
- * // use the markdown$ cell to get the current markdown value,
15
- * // and the rootEditor$ cell to get the Lexical editor instance.
16
- * const [markdown, rootEditor] = useCellValues([markdown$, rootEditor$])
17
- * // use the applyBlockType$ signal to apply a block type to the current selection
18
- * const applyBlockType = usePublisher(applyBlockType$)
19
- * ```
20
- *
21
- * **dollar-prefixed functions** (e.g. `$isCodeBlockNode`, etc.). These are following the conventions of the Lexical API, and are usually usable within the Lexical editor read/update cycles.
22
- *
23
- * **`plugin` functions** - these are functions that return a plugin object that can be passed to the `plugins` prop of the MDXEditor component. They usually accept a set of configuration options specific to the features they provide.
24
- *
25
- * **MDAST Nodes, Lexical Nodes and Import/Export visitors** - these are part of the bi-directional Markdown to/from Lexical state conversion API.
26
- *
27
- * **Toolbar plugins and primitives** - React components that can be used in the Editor toolbar. The primitives are meant to be used to build your own toolbar items.
28
- *
29
- * @packageDocumentation
30
- */
31
-
32
- /// <reference types="react" />
33
-
34
1
  import { Config } from 'mdast-util-from-markdown/lib';
2
+ import { ContentEditable } from '@lexical/react/LexicalContentEditable.js';
35
3
  import { DecoratorNode } from 'lexical';
4
+ import { default as default_2 } from 'react';
36
5
  import { Directives } from 'mdast-util-directive';
37
6
  import { DOMConversionMap } from 'lexical';
38
7
  import { DOMExportOutput } from 'lexical';
@@ -61,7 +30,6 @@ import { Options as Options_2 } from 'mdast-util-to-markdown/lib/types';
61
30
  import { ParseOptions } from 'micromark-util-types';
62
31
  import * as RadixToolbar from '@radix-ui/react-toolbar';
63
32
  import { RangeSelection } from 'lexical';
64
- import { default as React_2 } from 'react';
65
33
  import { ReactNode } from 'react';
66
34
  import { Realm } from '@mdxeditor/gurx';
67
35
  import { RootNode } from 'lexical';
@@ -160,23 +128,23 @@ export declare const addActivePlugin$: NodeRef<string | string[]>;
160
128
  * Lets you add React components to the {@link https://lexical.dev/docs/react/plugins | Lexical Composer} element.
161
129
  * @group Core
162
130
  */
163
- export declare const addComposerChild$: NodeRef<React_2.ComponentType<{}> | React_2.ComponentType<{}>[]>;
131
+ export declare const addComposerChild$: NodeRef<default_2.ComponentType<{}> | default_2.ComponentType<{}>[]>;
164
132
 
165
133
  /**
166
134
  * Lets you add React components as wrappers around the editor.
167
135
  * @group Core
168
136
  */
169
- export declare const addEditorWrapper$: NodeRef<React_2.ComponentType<{
170
- children: React_2.ReactNode;
171
- }> | React_2.ComponentType<{
172
- children: React_2.ReactNode;
137
+ export declare const addEditorWrapper$: NodeRef<default_2.ComponentType<{
138
+ children: default_2.ReactNode;
139
+ }> | default_2.ComponentType<{
140
+ children: default_2.ReactNode;
173
141
  }>[]>;
174
142
 
175
143
  /**
176
144
  * Adds an export visitor to be used when exporting markdown from the Lexical tree.
177
145
  * @group Markdown Processing
178
146
  */
179
- export declare const addExportVisitor$: NodeRef<LexicalVisitor | LexicalVisitor[]>;
147
+ export declare const addExportVisitor$: NodeRef< LexicalVisitor | LexicalVisitor[]>;
180
148
 
181
149
  /**
182
150
  * Registers a visitor to be used when importing markdown.
@@ -188,37 +156,37 @@ export declare const addImportVisitor$: NodeRef<MdastImportVisitor<Mdast.Nodes>
188
156
  * Registers a lexical node to be used in the editor.
189
157
  * @group Core
190
158
  */
191
- export declare const addLexicalNode$: NodeRef<KlassConstructor<typeof LexicalNode> | KlassConstructor<typeof LexicalNode>[]>;
159
+ export declare const addLexicalNode$: NodeRef< KlassConstructor<typeof LexicalNode> | KlassConstructor<typeof LexicalNode>[]>;
192
160
 
193
161
  /**
194
162
  * Adds a mdast extension to the markdown parser.
195
163
  * @group Markdown Processing
196
164
  */
197
- export declare const addMdastExtension$: NodeRef<Partial<Config> | Partial<Config>[] | (Partial<Config> | Partial<Config>[])[]>;
165
+ export declare const addMdastExtension$: NodeRef<Partial< Config> | Partial< Config>[] | (Partial< Config> | Partial< Config>[])[]>;
198
166
 
199
167
  /**
200
168
  * Lets you add React components as children of any registered nested editor (useful for Lexical plugins).
201
169
  * @group Core
202
170
  */
203
- export declare const addNestedEditorChild$: NodeRef<React_2.ComponentType<{}> | React_2.ComponentType<{}>[]>;
171
+ export declare const addNestedEditorChild$: NodeRef<default_2.ComponentType<{}> | default_2.ComponentType<{}>[]>;
204
172
 
205
173
  /**
206
174
  * Adds a syntax extension to the markdown parser.
207
175
  * @group Markdown Processing
208
176
  */
209
- export declare const addSyntaxExtension$: NodeRef<Extension | Extension[]>;
177
+ export declare const addSyntaxExtension$: NodeRef< Extension | Extension[]>;
210
178
 
211
179
  /**
212
180
  * Adds a markdown to string extension to be used when exporting markdown from the Lexical tree.
213
181
  * @group Markdown Processing
214
182
  */
215
- export declare const addToMarkdownExtension$: NodeRef<Options_2 | Options_2[]>;
183
+ export declare const addToMarkdownExtension$: NodeRef< Options_2 | Options_2[]>;
216
184
 
217
185
  /**
218
186
  * Lets you add React components on top of the editor (like the toolbar).
219
187
  * @group Core
220
188
  */
221
- export declare const addTopAreaChild$: NodeRef<React_2.ComponentType<{}> | React_2.ComponentType<{}>[]>;
189
+ export declare const addTopAreaChild$: NodeRef<default_2.ComponentType<{}> | default_2.ComponentType<{}>[]>;
222
190
 
223
191
  /* Excluded from this release type: ADMONITION_TYPES */
224
192
 
@@ -307,19 +275,19 @@ export declare type BlockType = 'paragraph' | 'quote' | HeadingTagType | '';
307
275
  * Supports paragraphs, headings and block quotes.
308
276
  * @group Toolbar Components
309
277
  */
310
- export declare const BlockTypeSelect: () => React_2.JSX.Element | null;
278
+ export declare const BlockTypeSelect: () => default_2.JSX.Element | null;
311
279
 
312
280
  /**
313
281
  * A toolbar component that lets the user toggle bold, italic and underline formatting.
314
282
  * @group Toolbar Components
315
283
  */
316
- export declare const BoldItalicUnderlineToggles: React_2.FC;
284
+ export declare const BoldItalicUnderlineToggles: default_2.FC;
317
285
 
318
286
  /**
319
287
  * A toolbar button primitive.
320
288
  * @group Toolbar Primitives
321
289
  */
322
- export declare const Button: React_2.ForwardRefExoticComponent<Omit<RadixToolbar.ToolbarButtonProps & React_2.RefAttributes<HTMLButtonElement>, "ref"> & React_2.RefAttributes<object>>;
290
+ export declare const Button: default_2.ForwardRefExoticComponent<Omit<RadixToolbar.ToolbarButtonProps & default_2.RefAttributes<HTMLButtonElement>, "ref"> & default_2.RefAttributes<object>>;
323
291
 
324
292
  /**
325
293
  * Use this primitive to create a toolbar button that can be either a button or a dropdown, depending on the number of items passed.
@@ -329,7 +297,7 @@ export declare const ButtonOrDropdownButton: <T extends string>(props: {
329
297
  /**
330
298
  * The contents of the button - usually an icon.
331
299
  */
332
- children: React_2.ReactNode;
300
+ children: default_2.ReactNode;
333
301
  /**
334
302
  * The title used for the tooltip.
335
303
  */
@@ -352,15 +320,15 @@ export declare const ButtonOrDropdownButton: <T extends string>(props: {
352
320
  */
353
321
  label: string | JSX.Element;
354
322
  }[];
355
- }) => React_2.JSX.Element;
323
+ }) => default_2.JSX.Element;
356
324
 
357
325
  /**
358
326
  * A toolbar button with tooltip primitive.
359
327
  * @group Toolbar Primitives
360
328
  */
361
- export declare const ButtonWithTooltip: ({ title, children, ...props }: Omit<RadixToolbar.ToolbarButtonProps & React_2.RefAttributes<HTMLButtonElement>, "ref"> & React_2.RefAttributes<object> & {
329
+ export declare const ButtonWithTooltip: ({ title, children, ...props }: Omit<RadixToolbar.ToolbarButtonProps & default_2.RefAttributes<HTMLButtonElement>, "ref"> & default_2.RefAttributes<object> & {
362
330
  title: string;
363
- }) => React_2.JSX.Element;
331
+ }) => default_2.JSX.Element;
364
332
 
365
333
  /**
366
334
  * Calls the passed function.
@@ -381,7 +349,7 @@ export declare const cancelLinkEdit$: NodeRef<void>;
381
349
  * For this component to work, you must pass the {@link AdmonitionDirectiveDescriptor} to the `directivesPlugin` `directiveDescriptors` parameter.
382
350
  * @group Toolbar Components
383
351
  */
384
- export declare const ChangeAdmonitionType: () => React_2.JSX.Element;
352
+ export declare const ChangeAdmonitionType: () => default_2.JSX.Element;
385
353
 
386
354
  /**
387
355
  * A component that allows the user to change the code block language of the current selection.
@@ -389,7 +357,7 @@ export declare const ChangeAdmonitionType: () => React_2.JSX.Element;
389
357
  * See {@link ConditionalContents} for an example on how to display the dropdown only when a code block is in focus.
390
358
  * @group Toolbar Components
391
359
  */
392
- export declare const ChangeCodeMirrorLanguage: () => React_2.JSX.Element;
360
+ export declare const ChangeCodeMirrorLanguage: () => default_2.JSX.Element;
393
361
 
394
362
  export declare type ClickLinkCallback = (url: string) => void;
395
363
 
@@ -547,7 +515,7 @@ export declare const codeBlockPlugin: (params?: {
547
515
  */
548
516
  export declare const codeMirrorAutoLoadLanguageSupport$: NodeRef<boolean>;
549
517
 
550
- export declare const CodeMirrorEditor: ({ language, nodeKey, code, focusEmitter }: CodeBlockEditorProps) => React_2.JSX.Element;
518
+ export declare const CodeMirrorEditor: ({ language, nodeKey, code, focusEmitter }: CodeBlockEditorProps) => default_2.JSX.Element;
551
519
 
552
520
  /**
553
521
  * The code mirror extensions for the coemirror code block editor.
@@ -578,7 +546,7 @@ export declare const codeMirrorPlugin: (params?: {
578
546
  * Use for inline `code` elements (like variables, methods, etc).
579
547
  * @group Toolbar Components
580
548
  */
581
- export declare const CodeToggle: React_2.FC;
549
+ export declare const CodeToggle: default_2.FC;
582
550
 
583
551
  export declare const COMMON_STATE_CONFIG_EXTENSIONS: Extension_2[];
584
552
 
@@ -613,7 +581,7 @@ export declare function compose<I, A, R>(a: (arg: A) => R, b: (arg: I) => A): (a
613
581
  * ```
614
582
  * @group Toolbar Primitives
615
583
  */
616
- export declare const ConditionalContents: React_2.FC<{
584
+ export declare const ConditionalContents: default_2.FC<{
617
585
  /**
618
586
  * A set of options that define the contents to show based on the editor that is in focus.
619
587
  * Can be either a {@link ConditionalContentsOption} or a {@link FallbackOption}.
@@ -634,7 +602,7 @@ export declare type ConditionalContentsOption = {
634
602
  /**
635
603
  * The contents to display if the `when` function returns `true`.
636
604
  */
637
- contents: () => React_2.ReactNode;
605
+ contents: () => default_2.ReactNode;
638
606
  };
639
607
 
640
608
  /**
@@ -711,7 +679,7 @@ export declare interface CreateImageNodeParameters {
711
679
  * For this component to work, you must include the `linkDialogPlugin`.
712
680
  * @group Toolbar Components
713
681
  */
714
- export declare const CreateLink: () => React_2.JSX.Element;
682
+ export declare const CreateLink: () => default_2.JSX.Element;
715
683
 
716
684
  /**
717
685
  * An input signal that lets you register a new {@link EditorSubscription} for the root editor.
@@ -782,7 +750,7 @@ export declare interface Descriptors {
782
750
  * Use this primitive to create a toolbar button that opens a dialog with a text input, autocomplete suggestions, and a submit button.
783
751
  * @group Toolbar Primitives
784
752
  */
785
- export declare const DialogButton: React_2.ForwardRefExoticComponent<{
753
+ export declare const DialogButton: default_2.ForwardRefExoticComponent<{
786
754
  /**
787
755
  * The autocomplete suggestions to show in the dialog input.
788
756
  */
@@ -802,7 +770,7 @@ export declare const DialogButton: React_2.ForwardRefExoticComponent<{
802
770
  * <DialogButton buttonContent={<CustomIcon />} />
803
771
  * ```
804
772
  */
805
- buttonContent?: React_2.ReactNode;
773
+ buttonContent?: default_2.ReactNode;
806
774
  /**
807
775
  * The placeholder text to show in the dialog input.
808
776
  */
@@ -811,7 +779,7 @@ export declare const DialogButton: React_2.ForwardRefExoticComponent<{
811
779
  * The title of the submit button.
812
780
  */
813
781
  submitButtonTitle: string;
814
- } & React_2.RefAttributes<HTMLButtonElement>>;
782
+ } & default_2.RefAttributes<HTMLButtonElement>>;
815
783
 
816
784
  /* Excluded from this release type: diffMarkdown$ */
817
785
 
@@ -856,8 +824,8 @@ export declare const diffSourcePlugin: (params?: {
856
824
  *
857
825
  * @group Toolbar Components
858
826
  */
859
- export declare const DiffSourceToggleWrapper: React_2.FC<{
860
- children: React_2.ReactNode;
827
+ export declare const DiffSourceToggleWrapper: default_2.FC<{
828
+ children: default_2.ReactNode;
861
829
  options?: ViewMode[];
862
830
  }>;
863
831
 
@@ -927,7 +895,7 @@ export declare interface DirectiveEditorProps<T extends Directives = Directives>
927
895
  * A lexical node that represents an image. Use {@link "$createDirectiveNode"} to construct one.
928
896
  * @group Directive
929
897
  */
930
- export declare class DirectiveNode extends DecoratorNode<React_2.JSX.Element> {
898
+ export declare class DirectiveNode extends DecoratorNode<default_2.JSX.Element> {
931
899
  /* Excluded from this release type: __mdastNode */
932
900
  /* Excluded from this release type: __focusEmitter */
933
901
  /* Excluded from this release type: getType */
@@ -1025,7 +993,7 @@ export declare interface EditorInFocus {
1025
993
  * A reference to a DOM element. used for the various popups, dialogs, and tooltips
1026
994
  * @group Core
1027
995
  */
1028
- export declare const editorRootElementRef$: NodeRef<React_2.RefObject<HTMLDivElement> | null>;
996
+ export declare const editorRootElementRef$: NodeRef<default_2.RefObject<HTMLDivElement> | null>;
1029
997
 
1030
998
  /**
1031
999
  * A function that subscribes to Lexical editor updates or events, and retursns an unsubscribe function.
@@ -1058,7 +1026,7 @@ export declare type FallbackOption = {
1058
1026
  /**
1059
1027
  * The contents to display
1060
1028
  */
1061
- fallback: () => React_2.ReactNode;
1029
+ fallback: () => default_2.ReactNode;
1062
1030
  };
1063
1031
 
1064
1032
  declare interface FileImageParameters extends BaseImageParameters {
@@ -1089,7 +1057,7 @@ export declare const frontmatterPlugin: (params?: unknown) => RealmPlugin;
1089
1057
  * Use this editor for the {@link DirectiveDescriptor} Editor option.
1090
1058
  * @group Directive
1091
1059
  */
1092
- export declare const GenericDirectiveEditor: React_2.FC<DirectiveEditorProps>;
1060
+ export declare const GenericDirectiveEditor: default_2.FC<DirectiveEditorProps>;
1093
1061
 
1094
1062
  /**
1095
1063
  * A Lexical node that represents a generic HTML element. Use {@link $createGenericHTMLNode} to construct one.
@@ -1127,7 +1095,7 @@ export declare class GenericHTMLNode extends ElementNode {
1127
1095
  * Use this editor for the {@link JsxComponentDescriptor} Editor option.
1128
1096
  * @group JSX
1129
1097
  */
1130
- export declare const GenericJsxEditor: React_2.FC<JsxEditorProps>;
1098
+ export declare const GenericJsxEditor: default_2.FC<JsxEditorProps>;
1131
1099
 
1132
1100
  /**
1133
1101
  * Gets the selected node from the Lexical editor.
@@ -1183,7 +1151,7 @@ export declare const htmlTags: readonly ["a", "abbr", "address", "area", "articl
1183
1151
  * A callback that returns the icon component for the given name.
1184
1152
  * @group Core
1185
1153
  */
1186
- export declare const iconComponentFor$: NodeRef<(name: IconKey) => React_2.ReactNode>;
1154
+ export declare const iconComponentFor$: NodeRef<(name: IconKey) => default_2.ReactNode>;
1187
1155
 
1188
1156
  /**
1189
1157
  * A type that represents the possible icon names that can be used with the {@link iconComponentFor$} cell.
@@ -1322,7 +1290,7 @@ export declare const inFocus$: NodeRef<boolean>;
1322
1290
  *
1323
1291
  * @group Toolbar Components
1324
1292
  */
1325
- export declare const InsertAdmonition: () => React_2.JSX.Element;
1293
+ export declare const InsertAdmonition: () => default_2.JSX.Element;
1326
1294
 
1327
1295
  /**
1328
1296
  * A signal that inserts a new code block into the editor with the published options.
@@ -1337,7 +1305,7 @@ export declare const insertCodeBlock$: NodeRef<Partial<CreateCodeBlockNodeOption
1337
1305
  *
1338
1306
  * @group Toolbar Components
1339
1307
  */
1340
- export declare const InsertCodeBlock: React_2.FC;
1308
+ export declare const InsertCodeBlock: default_2.FC;
1341
1309
 
1342
1310
  /**
1343
1311
  * Inserts a new code mirror code block with the specified parameters.
@@ -1375,7 +1343,7 @@ export declare const insertFrontmatter$: NodeRef<void>;
1375
1343
  * For this to work, you need to have the `frontmatterPlugin` plugin enabled.
1376
1344
  * @group Toolbar Components
1377
1345
  */
1378
- export declare const InsertFrontmatter: React_2.FC;
1346
+ export declare const InsertFrontmatter: default_2.FC;
1379
1347
 
1380
1348
  /**
1381
1349
  * A signal that inserts a new image node with the published payload.
@@ -1388,7 +1356,7 @@ export declare const insertImage$: NodeRef<InsertImageParameters>;
1388
1356
  * For the button to work, you need to have the `imagePlugin` plugin enabled.
1389
1357
  * @group Toolbar Components
1390
1358
  */
1391
- export declare const InsertImage: React_2.ForwardRefExoticComponent<Omit<Record<string, never>, "ref"> & React_2.RefAttributes<HTMLButtonElement>>;
1359
+ export declare const InsertImage: default_2.ForwardRefExoticComponent<Omit<Record<string, never>, "ref"> & default_2.RefAttributes<HTMLButtonElement>>;
1392
1360
 
1393
1361
  /**
1394
1362
  * @group Image
@@ -1431,7 +1399,7 @@ export declare const insertSandpack$: NodeRef<string>;
1431
1399
  * For this to work, you need to have the `sandpackPlugin` installed.
1432
1400
  * @group Toolbar Components
1433
1401
  */
1434
- export declare const InsertSandpack: () => React_2.JSX.Element;
1402
+ export declare const InsertSandpack: () => default_2.JSX.Element;
1435
1403
 
1436
1404
  /**
1437
1405
  * A signal that will insert a table with the published amount of rows and columns into the active editor.
@@ -1460,7 +1428,7 @@ export declare const insertTable$: NodeRef<{
1460
1428
  * For this button to work, you need to have the `tablePlugin` plugin enabled.
1461
1429
  * @group Toolbar Components
1462
1430
  */
1463
- export declare const InsertTable: React_2.FC;
1431
+ export declare const InsertTable: default_2.FC;
1464
1432
 
1465
1433
  /**
1466
1434
  * Inserts a thematic break at the current selection.
@@ -1473,7 +1441,7 @@ export declare const insertThematicBreak$: NodeRef<void>;
1473
1441
  * For this button to work, you need to have the `thematicBreakPlugin` plugin enabled.
1474
1442
  * @group Toolbar Components
1475
1443
  */
1476
- export declare const InsertThematicBreak: React_2.FC;
1444
+ export declare const InsertThematicBreak: default_2.FC;
1477
1445
 
1478
1446
  /**
1479
1447
  * Used to detect if the current platform is Apple based, mostly for keyboard shortcuts.
@@ -1544,7 +1512,7 @@ export declare interface JsxComponentDescriptor {
1544
1512
  /**
1545
1513
  * The editor to use for editing the component
1546
1514
  */
1547
- Editor: React_2.ComponentType<JsxEditorProps>;
1515
+ Editor: default_2.ComponentType<JsxEditorProps>;
1548
1516
  }
1549
1517
 
1550
1518
  /**
@@ -1614,7 +1582,7 @@ export declare interface JsxPropertyDescriptor {
1614
1582
  * You'll probably want to create your own toolbar component that includes only the buttons that you need.
1615
1583
  * @group Toolbar Components
1616
1584
  */
1617
- export declare const KitchenSinkToolbar: React_2.FC;
1585
+ export declare const KitchenSinkToolbar: default_2.FC;
1618
1586
 
1619
1587
  /**
1620
1588
  * All recognized HTML tags.
@@ -1750,7 +1718,7 @@ export declare const linkPlugin: (params?: {
1750
1718
  * An optional function to validate the URL of a link.
1751
1719
  * By default, no validation is performed.
1752
1720
  */
1753
- validateUrl?: React_2.ComponentProps<typeof LinkPlugin>['validateUrl'];
1721
+ validateUrl?: default_2.ComponentProps<typeof LinkPlugin>['validateUrl'];
1754
1722
  /**
1755
1723
  * Whether to disable the auto-linking of URLs and email addresses.
1756
1724
  * @default false
@@ -1771,7 +1739,7 @@ export declare const listsPlugin: (params?: unknown) => RealmPlugin;
1771
1739
  * @group Toolbar Components
1772
1740
  * @param options - The list types that the user can toggle between. Defaults to `['bullet', 'number', 'check']`.
1773
1741
  */
1774
- export declare const ListsToggle: React_2.FC<{
1742
+ export declare const ListsToggle: default_2.FC<{
1775
1743
  options?: Array<'bullet' | 'number' | 'check'>;
1776
1744
  }>;
1777
1745
 
@@ -1925,7 +1893,7 @@ export declare type MdastJsx = MdxJsxTextElement | MdxJsxFlowElement;
1925
1893
  * The MDXEditor React component.
1926
1894
  * @group MDXEditor
1927
1895
  */
1928
- export declare const MDXEditor: React_2.ForwardRefExoticComponent<MDXEditorProps & React_2.RefAttributes<MDXEditorMethods>>;
1896
+ export declare const MDXEditor: default_2.ForwardRefExoticComponent<MDXEditorProps & default_2.RefAttributes<MDXEditorMethods>>;
1929
1897
 
1930
1898
  /**
1931
1899
  * The interface for the {@link MDXEditor} object reference.
@@ -2014,7 +1982,7 @@ export declare interface MDXEditorProps {
2014
1982
  /**
2015
1983
  * The placeholder contents, displayed when the editor is empty.
2016
1984
  */
2017
- placeholder?: React_2.ReactNode;
1985
+ placeholder?: default_2.ReactNode;
2018
1986
  /**
2019
1987
  * pass if you would like to have the editor in read-only mode.
2020
1988
  * Note: Don't use this mode to render content for consumption - render the markdown using a library of your choice instead.
@@ -2044,10 +2012,10 @@ export declare type MdxNodeType = MdastHTMLNode['type'];
2044
2012
  * A toolbar primitive that allows you to build an UI with multiple non-exclusive toggle groups, like the bold/italic/underline toggle.
2045
2013
  * @group Toolbar Primitives
2046
2014
  */
2047
- export declare const MultipleChoiceToggleGroup: React_2.FC<{
2015
+ export declare const MultipleChoiceToggleGroup: default_2.FC<{
2048
2016
  items: {
2049
2017
  title: string;
2050
- contents: React_2.ReactNode;
2018
+ contents: default_2.ReactNode;
2051
2019
  active: boolean;
2052
2020
  onChange: (active: boolean) => void;
2053
2021
  disabled?: boolean;
@@ -2065,7 +2033,7 @@ export declare const muteChange$: NodeRef<boolean>;
2065
2033
  * Place it as a wrapper in your custom lexical node decorators.
2066
2034
  * @group Custom Editor Primitives
2067
2035
  */
2068
- export declare const NestedEditorsContext: React_2.Context<NestedEditorsContextValue<Node_2> | undefined>;
2036
+ export declare const NestedEditorsContext: default_2.Context<NestedEditorsContextValue<Node_2> | undefined>;
2069
2037
 
2070
2038
  /**
2071
2039
  * The value of the {@link NestedEditorsContext} React context.
@@ -2128,25 +2096,12 @@ export declare const NestedLexicalEditor: <T extends Mdast.RootContent>(props: {
2128
2096
  /**
2129
2097
  * Props passed to the {@link https://github.com/facebook/lexical/blob/main/packages/lexical-react/src/LexicalContentEditable.tsx | ContentEditable} component.
2130
2098
  */
2131
- contentEditableProps?: ({
2132
- ariaActiveDescendant?: string | undefined;
2133
- ariaAutoComplete?: "list" | "none" | "inline" | "both" | undefined;
2134
- ariaControls?: string | undefined;
2135
- ariaDescribedBy?: string | undefined;
2136
- ariaExpanded?: (boolean | "true" | "false") | undefined;
2137
- ariaLabel?: string | undefined;
2138
- ariaLabelledBy?: string | undefined;
2139
- ariaMultiline?: (boolean | "true" | "false") | undefined;
2140
- ariaOwns?: string | undefined;
2141
- ariaRequired?: (boolean | "true" | "false") | undefined;
2142
- autoCapitalize?: string | undefined;
2143
- 'data-testid'?: string | null | undefined;
2144
- } & React_2.AllHTMLAttributes<HTMLDivElement>) | undefined;
2099
+ contentEditableProps?: default_2.ComponentProps<typeof ContentEditable>;
2145
2100
  /**
2146
2101
  * Whether or not the editor edits blocks (multiple paragraphs)
2147
2102
  */
2148
- block?: boolean | undefined;
2149
- }) => React_2.JSX.Element;
2103
+ block?: boolean;
2104
+ }) => default_2.JSX.Element;
2150
2105
 
2151
2106
  /**
2152
2107
  * The state of the image dialog when it is in new mode.
@@ -2219,7 +2174,7 @@ export declare function prop<T extends Record<string, unknown>>(property: keyof
2219
2174
  * Displays a simple, static key/value editing UI in a popover.
2220
2175
  * @group Custom Editor Primitives
2221
2176
  */
2222
- export declare const PropertyPopover: React_2.FC<{
2177
+ export declare const PropertyPopover: default_2.FC<{
2223
2178
  /**
2224
2179
  * The properties to edit. The key is the name of the property, and the value is the initial value.
2225
2180
  */
@@ -2385,7 +2340,7 @@ export declare interface SandpackPreset {
2385
2340
  initialSnippetContent?: string;
2386
2341
  }
2387
2342
 
2388
- declare type SandpackProviderProps = React_2.ComponentProps<typeof SandpackProvider>;
2343
+ declare type SandpackProviderProps = default_2.ComponentProps<typeof SandpackProvider>;
2389
2344
 
2390
2345
  /**
2391
2346
  * Saves the data from the image dialog
@@ -2410,11 +2365,11 @@ export declare const Select: <T extends string>(props: {
2410
2365
  onChange: (value: T) => void;
2411
2366
  triggerTitle: string;
2412
2367
  placeholder: string;
2413
- items: ("separator" | {
2368
+ items: ({
2414
2369
  label: string | JSX.Element;
2415
2370
  value: T;
2416
- })[];
2417
- }) => React_2.JSX.Element;
2371
+ } | 'separator')[];
2372
+ }) => default_2.JSX.Element;
2418
2373
 
2419
2374
  /* Excluded from this release type: SelectButtonTrigger */
2420
2375
 
@@ -2429,7 +2384,7 @@ export declare const Select: <T extends string>(props: {
2429
2384
  * By default, the separator is styled as vertical line.
2430
2385
  * @group Toolbar Primitives
2431
2386
  */
2432
- export declare const Separator: React_2.ForwardRefExoticComponent<RadixToolbar.ToolbarSeparatorProps & React_2.RefAttributes<HTMLDivElement>>;
2387
+ export declare const Separator: default_2.ForwardRefExoticComponent<RadixToolbar.ToolbarSeparatorProps & default_2.RefAttributes<HTMLDivElement>>;
2433
2388
 
2434
2389
  /**
2435
2390
  * A serialized representation of an {@link CodeBlockNode}.
@@ -2496,7 +2451,7 @@ export declare const setMarkdown$: NodeRef<string>;
2496
2451
  * See {@link ConditionalContents} for an example on how to display the dropdown only when a sandpack editor is in focus.
2497
2452
  * @group Toolbar Components
2498
2453
  */
2499
- export declare const ShowSandpackInfo: () => React_2.JSX.Element;
2454
+ export declare const ShowSandpackInfo: () => default_2.JSX.Element;
2500
2455
 
2501
2456
  /**
2502
2457
  * A toolbar primitive that allows you to build an UI with multiple exclusive toggle groups, like the list type toggle.
@@ -2506,12 +2461,12 @@ export declare const SingleChoiceToggleGroup: <T extends string>({ value, onChan
2506
2461
  items: {
2507
2462
  title: string;
2508
2463
  value: T;
2509
- contents: React_2.ReactNode;
2464
+ contents: default_2.ReactNode;
2510
2465
  }[];
2511
2466
  onChange: (value: T) => void;
2512
2467
  value: T;
2513
- className?: string | undefined;
2514
- }) => React_2.JSX.Element;
2468
+ className?: string;
2469
+ }) => default_2.JSX.Element;
2515
2470
 
2516
2471
  /* Excluded from this release type: SingleToggleGroup */
2517
2472
 
@@ -2614,14 +2569,14 @@ export { ToMarkdownOptions }
2614
2569
  * The factory function that returns the contents of the toolbar.
2615
2570
  * @group Toolbar
2616
2571
  */
2617
- export declare const toolbarContents$: NodeRef<() => React_2.ReactNode>;
2572
+ export declare const toolbarContents$: NodeRef<() => default_2.ReactNode>;
2618
2573
 
2619
2574
  /**
2620
2575
  * A plugin that adds a toolbar to the editor.
2621
2576
  * @group Toolbar
2622
2577
  */
2623
2578
  export declare const toolbarPlugin: (params?: {
2624
- toolbarContents: () => React_2.ReactNode;
2579
+ toolbarContents: () => default_2.ReactNode;
2625
2580
  } | undefined) => RealmPlugin;
2626
2581
 
2627
2582
  /* Excluded from this release type: ToolbarToggleItem */
@@ -2630,10 +2585,10 @@ export declare const toolbarPlugin: (params?: {
2630
2585
  * A styled wrapper around the radix-ui tooltip, that lets you display an instant tooltip on hover.
2631
2586
  * @group Toolbar Primitives
2632
2587
  */
2633
- export declare const TooltipWrap: React_2.ForwardRefExoticComponent<{
2588
+ export declare const TooltipWrap: default_2.ForwardRefExoticComponent<{
2634
2589
  title: string;
2635
2590
  children: ReactNode;
2636
- } & React_2.RefAttributes<HTMLButtonElement>>;
2591
+ } & default_2.RefAttributes<HTMLButtonElement>>;
2637
2592
 
2638
2593
  /* Excluded from this release type: topAreaChildren$ */
2639
2594
 
@@ -2647,7 +2602,7 @@ export declare type Translation = (key: string, defaultValue: string, interpolat
2647
2602
  * A toolbar component that lets the user undo and redo changes in the editor.
2648
2603
  * @group Toolbar Components
2649
2604
  */
2650
- export declare const UndoRedo: React_2.FC;
2605
+ export declare const UndoRedo: default_2.FC;
2651
2606
 
2652
2607
  /**
2653
2608
  * An error that gets thrown when the Markdown parsing encounters an node that has no corresponding {@link MdastImportVisitor}.
@@ -2733,3 +2688,21 @@ export declare function voidEmitter(): {
2733
2688
  export * from "@mdxeditor/gurx";
2734
2689
 
2735
2690
  export { }
2691
+
2692
+
2693
+ declare global {
2694
+ interface DragEvent {
2695
+ rangeOffset?: number;
2696
+ rangeParent?: Node;
2697
+ }
2698
+ }
2699
+
2700
+
2701
+ declare module 'micromark-util-types' {
2702
+ interface TokenTypeMap {
2703
+ comment: 'comment';
2704
+ commentEnd: 'commentEnd';
2705
+ data: 'data';
2706
+ }
2707
+ }
2708
+
@@ -1,5 +1,5 @@
1
1
  import { $isTextNode } from "lexical";
2
- import { IS_CODE, IS_ITALIC, IS_BOLD, IS_UNDERLINE } from "../../FormatConstants.js";
2
+ import { IS_ITALIC, IS_BOLD, IS_UNDERLINE, IS_CODE } from "../../FormatConstants.js";
3
3
  function isMdastText(mdastNode) {
4
4
  return mdastNode.type === "text";
5
5
  }
@@ -35,12 +35,6 @@ const LexicalTextVisitor = {
35
35
  const textContent = lexicalNode.getTextContent();
36
36
  const format = lexicalNode.getFormat() ?? 0;
37
37
  const style = lexicalNode.getStyle();
38
- if (format & IS_CODE) {
39
- actions.addAndStepInto("inlineCode", {
40
- value: textContent
41
- });
42
- return;
43
- }
44
38
  let localParentNode = mdastParent;
45
39
  if (style) {
46
40
  localParentNode = actions.appendToParent(localParentNode, {
@@ -90,6 +84,13 @@ const LexicalTextVisitor = {
90
84
  attributes: []
91
85
  });
92
86
  }
87
+ if (format & IS_CODE) {
88
+ actions.appendToParent(localParentNode, {
89
+ type: "inlineCode",
90
+ value: textContent
91
+ });
92
+ return;
93
+ }
93
94
  actions.appendToParent(localParentNode, {
94
95
  type: "text",
95
96
  value: textContent
@@ -1,4 +1,5 @@
1
- import { IS_UNDERLINE, IS_ITALIC, IS_BOLD } from "../../FormatConstants.js";
1
+ import { IS_CODE, IS_ITALIC, IS_BOLD, IS_UNDERLINE } from "../../FormatConstants.js";
2
+ import { $createTextNode } from "lexical";
2
3
  function isOpeningUnderlineNode(node) {
3
4
  return node.type === "html" && node.value === "<u>";
4
5
  }
@@ -8,29 +9,88 @@ function isClosingUnderlineNode(node) {
8
9
  function isJsxUnderlineNode(node) {
9
10
  return node.type === "mdxJsxTextElement" && node.name === "u";
10
11
  }
11
- const MdastFormattingVisitor = {
12
- testNode(mdastNode) {
13
- return mdastNode.type === "emphasis" || mdastNode.type === "strong" || isJsxUnderlineNode(mdastNode) || isOpeningUnderlineNode(mdastNode) || isClosingUnderlineNode(mdastNode);
14
- },
15
- visitNode({ mdastNode, lexicalParent, actions, mdastParent }) {
16
- if (isOpeningUnderlineNode(mdastNode)) {
17
- actions.removeFormatting(IS_UNDERLINE, mdastParent);
18
- return;
19
- }
20
- if (isClosingUnderlineNode(mdastNode)) {
21
- actions.removeFormatting(IS_UNDERLINE, mdastParent);
22
- return;
23
- }
24
- if (mdastNode.type === "emphasis") {
25
- actions.addFormatting(IS_ITALIC);
26
- } else if (mdastNode.type === "strong") {
27
- actions.addFormatting(IS_BOLD);
28
- } else if (isJsxUnderlineNode(mdastNode)) {
29
- actions.addFormatting(IS_UNDERLINE);
30
- }
12
+ function isJsxCodeNode(node) {
13
+ return node.type === "mdxJsxTextElement" && node.name === "code";
14
+ }
15
+ function isOpeningCodeNode(node) {
16
+ return node.type === "html" && node.value === "<code>";
17
+ }
18
+ function isClosingCodeNode(node) {
19
+ return node.type === "html" && node.value === "</code>";
20
+ }
21
+ const JsxCodeVisitor = {
22
+ testNode: isJsxCodeNode,
23
+ visitNode({ mdastNode, actions, lexicalParent }) {
24
+ actions.addFormatting(IS_CODE);
25
+ actions.visitChildren(mdastNode, lexicalParent);
26
+ }
27
+ };
28
+ const OpeningCodeVisitor = {
29
+ testNode: isOpeningCodeNode,
30
+ visitNode({ actions, mdastParent }) {
31
+ actions.addFormatting(IS_CODE, mdastParent);
32
+ }
33
+ };
34
+ const ClosingCodeVisitor = {
35
+ testNode: isClosingCodeNode,
36
+ visitNode({ actions, mdastParent }) {
37
+ actions.removeFormatting(IS_CODE, mdastParent);
38
+ }
39
+ };
40
+ const MdCodeVisitor = {
41
+ testNode: "inlineCode",
42
+ visitNode({ mdastNode, actions }) {
43
+ actions.addAndStepInto($createTextNode(mdastNode.value).setFormat(actions.getParentFormatting() | IS_CODE));
44
+ }
45
+ };
46
+ const MdEmphasisVisitor = {
47
+ testNode: "emphasis",
48
+ visitNode({ mdastNode, actions, lexicalParent }) {
49
+ actions.addFormatting(IS_ITALIC);
50
+ actions.visitChildren(mdastNode, lexicalParent);
51
+ }
52
+ };
53
+ const MdStrongVisitor = {
54
+ testNode: "strong",
55
+ visitNode({ mdastNode, actions, lexicalParent }) {
56
+ actions.addFormatting(IS_BOLD);
31
57
  actions.visitChildren(mdastNode, lexicalParent);
32
58
  }
33
59
  };
60
+ const JsxUnderlineVisitor = {
61
+ testNode: isJsxUnderlineNode,
62
+ visitNode({ mdastNode, actions, lexicalParent }) {
63
+ actions.addFormatting(IS_UNDERLINE);
64
+ actions.visitChildren(mdastNode, lexicalParent);
65
+ }
66
+ };
67
+ const OpeningUnderlineVisitor = {
68
+ testNode: isOpeningUnderlineNode,
69
+ visitNode({ actions, mdastParent }) {
70
+ actions.addFormatting(IS_UNDERLINE, mdastParent);
71
+ }
72
+ };
73
+ const ClosingUnderlineVisitor = {
74
+ testNode: isClosingUnderlineNode,
75
+ visitNode({ actions, mdastParent }) {
76
+ actions.removeFormatting(IS_UNDERLINE, mdastParent);
77
+ }
78
+ };
79
+ const formattingVisitors = [
80
+ // emphasis
81
+ MdEmphasisVisitor,
82
+ // strong
83
+ MdStrongVisitor,
84
+ // underline
85
+ JsxUnderlineVisitor,
86
+ OpeningUnderlineVisitor,
87
+ ClosingUnderlineVisitor,
88
+ // code
89
+ JsxCodeVisitor,
90
+ OpeningCodeVisitor,
91
+ ClosingCodeVisitor,
92
+ MdCodeVisitor
93
+ ];
34
94
  export {
35
- MdastFormattingVisitor
95
+ formattingVisitors
36
96
  };
@@ -20,9 +20,8 @@ import { LexicalParagraphVisitor } from "./LexicalParagraphVisitor.js";
20
20
  import { LexicalRootVisitor } from "./LexicalRootVisitor.js";
21
21
  import { LexicalTextVisitor } from "./LexicalTextVisitor.js";
22
22
  import { MdastBreakVisitor } from "./MdastBreakVisitor.js";
23
- import { MdastFormattingVisitor } from "./MdastFormattingVisitor.js";
23
+ import { formattingVisitors } from "./MdastFormattingVisitor.js";
24
24
  import { MdastHTMLVisitor } from "./MdastHTMLVisitor.js";
25
- import { MdastInlineCodeVisitor } from "./MdastInlineCodeVisitor.js";
26
25
  import { MdastParagraphVisitor } from "./MdastParagraphVisitor.js";
27
26
  import { MdastRootVisitor } from "./MdastRootVisitor.js";
28
27
  import { MdastTextVisitor } from "./MdastTextVisitor.js";
@@ -478,14 +477,7 @@ const corePlugin = realmPlugin({
478
477
  r.pubIn({
479
478
  [initialMarkdown$]: params == null ? void 0 : params.initialMarkdown.trim(),
480
479
  [iconComponentFor$]: params == null ? void 0 : params.iconComponentFor,
481
- [addImportVisitor$]: [
482
- MdastRootVisitor,
483
- MdastParagraphVisitor,
484
- MdastTextVisitor,
485
- MdastFormattingVisitor,
486
- MdastInlineCodeVisitor,
487
- MdastBreakVisitor
488
- ],
480
+ [addImportVisitor$]: [MdastRootVisitor, MdastParagraphVisitor, MdastTextVisitor, MdastBreakVisitor, ...formattingVisitors],
489
481
  [addLexicalNode$]: [ParagraphNode, TextNode, GenericHTMLNode],
490
482
  [addExportVisitor$]: [
491
483
  LexicalRootVisitor,
@@ -242,9 +242,13 @@ const CellEditor = ({ focus, setActiveCell, parentEditor, lexicalTable, contents
242
242
  visitors: exportVisitors,
243
243
  jsxIsAvailable
244
244
  });
245
- parentEditor.update(() => {
246
- lexicalTable.updateCellContents(colIndex, rowIndex, mdast.children[0].children);
247
- });
245
+ parentEditor.update(
246
+ () => {
247
+ lexicalTable.updateCellContents(colIndex, rowIndex, mdast.children[0].children);
248
+ },
249
+ { discrete: true }
250
+ );
251
+ parentEditor.dispatchCommand(NESTED_EDITOR_UPDATED_COMMAND, void 0);
248
252
  });
249
253
  setActiveCell(nextCell);
250
254
  },
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "*.css"
12
12
  ],
13
13
  "type": "module",
14
- "version": "3.0.6",
14
+ "version": "3.0.8",
15
15
  "description": "React component for rich text markdown editing",
16
16
  "scripts": {
17
17
  "build": "vite build",
@@ -109,8 +109,8 @@
109
109
  "@types/react": "^18.2.7",
110
110
  "@types/react-dom": "^18.2.4",
111
111
  "@types/unist": "^3.0.2",
112
- "@typescript-eslint/eslint-plugin": "^6.17.0",
113
- "@typescript-eslint/parser": "^6.17.0",
112
+ "@typescript-eslint/eslint-plugin": "^7.9.0",
113
+ "@typescript-eslint/parser": "^7.9.0",
114
114
  "@vitejs/plugin-react": "^4.0.0",
115
115
  "@vitejs/plugin-react-swc": "^3.5.0",
116
116
  "autoprefixer": "^10.4.14",
@@ -141,13 +141,13 @@
141
141
  "semantic-release": "^21.0.5",
142
142
  "svgo": "^3.0.2",
143
143
  "terser": "^5.26.0",
144
- "typedoc": "^0.25.6",
145
- "typedoc-plugin-markdown": "^3.17.1",
144
+ "typedoc": "^0.25.13",
145
+ "typedoc-plugin-markdown": "^4.0.2",
146
146
  "typedoc-plugin-no-inherit": "^1.4.0",
147
- "typescript": "^5.3.3",
147
+ "typescript": "^5.4.5",
148
148
  "typescript-plugin-css-modules": "^5.0.2",
149
149
  "vite": "^5.0.10",
150
- "vite-plugin-dts": "^3.7.0",
150
+ "vite-plugin-dts": "^3.9.1",
151
151
  "vite-plugin-svgr": "^4.2.0",
152
152
  "vite-tsconfig-paths": "^4.2.3",
153
153
  "vitest": "^1.1.1"
@@ -1,27 +0,0 @@
1
- import { $createTextNode } from "lexical";
2
- import { IS_CODE } from "../../FormatConstants.js";
3
- function isOpeningCodeNode(node) {
4
- return node.type === "html" && node.value === "<code>";
5
- }
6
- function isClosingCodeNode(node) {
7
- return node.type === "html" && node.value === "</code>";
8
- }
9
- const MdastInlineCodeVisitor = {
10
- testNode: (node) => {
11
- return node.type === "inlineCode" || isOpeningCodeNode(node) || isClosingCodeNode(node);
12
- },
13
- visitNode({ mdastNode, actions, mdastParent }) {
14
- if (isOpeningCodeNode(mdastNode)) {
15
- actions.addFormatting(IS_CODE, mdastParent);
16
- return;
17
- }
18
- if (isClosingCodeNode(mdastNode)) {
19
- actions.removeFormatting(IS_CODE, mdastParent);
20
- return;
21
- }
22
- actions.addAndStepInto($createTextNode(mdastNode.value).setFormat(IS_CODE));
23
- }
24
- };
25
- export {
26
- MdastInlineCodeVisitor
27
- };