@mdxeditor/editor 3.44.2 → 3.45.0

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
@@ -1170,7 +1170,7 @@ export declare const EmptyTextNodeIndex: TextNodeIndex;
1170
1170
 
1171
1171
  /* Excluded from this release type: ExportLexicalTreeOptions */
1172
1172
 
1173
- /* Excluded from this release type: exportLexicalTreeToMdast */
1173
+ export declare function exportLexicalTreeToMdast({ root, visitors, jsxComponentDescriptors, jsxIsAvailable, addImportStatements }: ExportLexicalTreeOptions): Mdast.Root;
1174
1174
 
1175
1175
  /* Excluded from this release type: exportMarkdownFromLexical */
1176
1176
 
@@ -1466,7 +1466,7 @@ export declare type ImageUploadHandler = ((image: File) => Promise<string>) | nu
1466
1466
 
1467
1467
  /* Excluded from this release type: importMarkdownToLexical */
1468
1468
 
1469
- /* Excluded from this release type: importMdastTreeToLexical */
1469
+ export declare function importMdastTreeToLexical({ root, mdastRoot, visitors, ...descriptors }: MdastTreeImportOptions): void;
1470
1470
 
1471
1471
  export declare interface ImportPoint {
1472
1472
  append(node: LexicalNode): void;
@@ -1707,7 +1707,7 @@ export declare function isMdastHTMLNode(node: Mdast.Nodes): node is MdastHTMLNod
1707
1707
  */
1708
1708
  export declare function isMdastJsxNode(node: Mdast.Nodes): node is MdastJsx;
1709
1709
 
1710
- /* Excluded from this release type: isPartOftheEditorUI */
1710
+ export declare function isPartOftheEditorUI(element: HTMLElement | null, editorRoot: HTMLElement): boolean;
1711
1711
 
1712
1712
  /**
1713
1713
  * returns a function which calls all passed functions in the passed order.
@@ -2308,9 +2308,9 @@ export declare interface MDXEditorProps {
2308
2308
  */
2309
2309
  suppressSharedHistory?: boolean;
2310
2310
  /**
2311
- * The initial state of the lexical editor.
2311
+ * The initial state of the lexical editor. Pass null to disable any initiation.
2312
2312
  */
2313
- editorState?: EditorState | undefined;
2313
+ editorState?: EditorState | undefined | null;
2314
2314
  }
2315
2315
 
2316
2316
  /**
@@ -2342,7 +2342,7 @@ export declare const MultipleChoiceToggleGroup: default_2.FC<{
2342
2342
 
2343
2343
  export declare const muteChange$: NodeRef<boolean>;
2344
2344
 
2345
- /* Excluded from this release type: NESTED_EDITOR_UPDATED_COMMAND */
2345
+ export declare const NESTED_EDITOR_UPDATED_COMMAND: LexicalCommand<undefined>;
2346
2346
 
2347
2347
  /* Excluded from this release type: nestedEditorChildren$ */
2348
2348
 
@@ -543,7 +543,7 @@ const corePlugin = realmPlugin({
543
543
  },
544
544
  postInit(r, params) {
545
545
  const newEditor = createEditor({
546
- ...(params == null ? void 0 : params.editorState) ? { editorState: params.editorState } : {},
546
+ // ...(params?.editorState ? { editorState: params.editorState } : {}),
547
547
  editable: (params == null ? void 0 : params.readOnly) !== true,
548
548
  namespace: "MDXEditor",
549
549
  nodes: r.getValue(usedLexicalNodes$),
@@ -552,24 +552,26 @@ const corePlugin = realmPlugin({
552
552
  },
553
553
  theme: r.getValue(lexicalTheme$)
554
554
  });
555
- newEditor.update(() => {
556
- const markdown = (params == null ? void 0 : params.initialMarkdown.trim()) ?? "";
557
- tryImportingMarkdown(r, $getRoot(), markdown);
558
- const autoFocusValue = params == null ? void 0 : params.autoFocus;
559
- if (autoFocusValue) {
560
- if (autoFocusValue === true) {
555
+ if ((params == null ? void 0 : params.editorState) !== null) {
556
+ newEditor.update(() => {
557
+ const markdown = (params == null ? void 0 : params.initialMarkdown.trim()) ?? "";
558
+ tryImportingMarkdown(r, $getRoot(), markdown);
559
+ const autoFocusValue = params == null ? void 0 : params.autoFocus;
560
+ if (autoFocusValue) {
561
+ if (autoFocusValue === true) {
562
+ setTimeout(() => {
563
+ newEditor.focus(noop, { defaultSelection: "rootStart" });
564
+ });
565
+ return;
566
+ }
561
567
  setTimeout(() => {
562
- newEditor.focus(noop, { defaultSelection: "rootStart" });
568
+ newEditor.focus(noop, {
569
+ defaultSelection: autoFocusValue.defaultSelection ?? "rootStart"
570
+ });
563
571
  });
564
- return;
565
572
  }
566
- setTimeout(() => {
567
- newEditor.focus(noop, {
568
- defaultSelection: autoFocusValue.defaultSelection ?? "rootStart"
569
- });
570
- });
571
- }
572
- });
573
+ });
574
+ }
573
575
  r.pub(rootEditor$, newEditor);
574
576
  r.pub(activeEditor$, newEditor);
575
577
  },
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "*.css"
12
12
  ],
13
13
  "type": "module",
14
- "version": "3.44.2",
14
+ "version": "3.45.0",
15
15
  "description": "React component for rich text markdown editing",
16
16
  "scripts": {
17
17
  "build": "vite build",