@mdxeditor/editor 3.46.0 → 3.47.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/MDXEditor.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { usePublisher, useCellValue, useCellValues, useRealm } from "@mdxeditor/gurx";
2
2
  import React__default from "react";
3
- import { corePlugin, editorRootElementRef$, rootEditor$, useTranslation, contentEditableRef$, contentEditableClassName$, spellCheck$, composerChildren$, topAreaChildren$, editorWrappers$, placeholder$, bottomAreaChildren$, insertMarkdown$, setMarkdown$, viewMode$, markdownSourceEditorValue$, markdown$ } from "./plugins/core/index.js";
3
+ import { corePlugin, editorRootElementRef$, rootEditor$, useTranslation, contentEditableRef$, contentEditableWrapperElement$, contentEditableClassName$, spellCheck$, composerChildren$, topAreaChildren$, editorWrappers$, placeholder$, bottomAreaChildren$, insertMarkdown$, setMarkdown$, viewMode$, markdownSourceEditorValue$, markdown$ } from "./plugins/core/index.js";
4
4
  import { RealmWithPlugins } from "./RealmWithPlugins.js";
5
5
  import { createLexicalComposerContext, LexicalComposerContext } from "@lexical/react/LexicalComposerContext";
6
6
  import { ContentEditable } from "@lexical/react/LexicalContentEditable";
@@ -21,8 +21,10 @@ const LexicalProvider = ({ children }) => {
21
21
  const RichTextEditor = () => {
22
22
  const t = useTranslation();
23
23
  const setContentEditableRef = usePublisher(contentEditableRef$);
24
- const onRef = (_contentEditableRef) => {
25
- setContentEditableRef({ current: _contentEditableRef });
24
+ const setEditorRootWrapperElement = usePublisher(contentEditableWrapperElement$);
25
+ const onRef = (el) => {
26
+ setEditorRootWrapperElement(el);
27
+ setContentEditableRef({ current: el });
26
28
  };
27
29
  const [contentEditableClassName, spellCheck, composerChildren, topAreaChildren, editorWrappers, placeholder, bottomAreaChildren] = useCellValues(
28
30
  contentEditableClassName$,
package/dist/index.d.ts CHANGED
@@ -689,6 +689,8 @@ export declare const contentEditableClassName$: NodeRef<string>;
689
689
  */
690
690
  export declare const contentEditableRef$: NodeRef<default_2.RefObject<HTMLDivElement> | null>;
691
691
 
692
+ export declare const contentEditableWrapperElement$: NodeRef<HTMLDivElement | null>;
693
+
692
694
  /**
693
695
  * Returns true if the user is pressing the control key on Windows or the meta key on Mac.
694
696
  * @group Utils
@@ -2355,7 +2357,11 @@ export declare const muteChange$: NodeRef<boolean>;
2355
2357
 
2356
2358
  export declare const NESTED_EDITOR_UPDATED_COMMAND: LexicalCommand<undefined>;
2357
2359
 
2358
- /* Excluded from this release type: nestedEditorChildren$ */
2360
+ /**
2361
+ * React Components registered to be rendered inside `LexicalNestedComposer`. Useful if you're using lexical editor plugins that are wrapped as react components.
2362
+ * @group Core
2363
+ */
2364
+ export declare const nestedEditorChildren$: NodeRef<default_2.ComponentType<{}>[]>;
2359
2365
 
2360
2366
  /**
2361
2367
  * Use this context to provide the necessary values to the {@link NestedLexicalEditor} React component.
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { MDXEditor } from "./MDXEditor.js";
4
4
  import { defaultSvgIcons } from "./defaultSvgIcons.js";
5
5
  import { MarkdownParseError, UnrecognizedMarkdownConstructError, importMarkdownToLexical, importMdastTreeToLexical } from "./importMarkdownToLexical.js";
6
6
  import { exportLexicalTreeToMdast, exportMarkdownFromLexical } from "./exportMarkdownFromLexical.js";
7
- import { Appender, NESTED_EDITOR_UPDATED_COMMAND, activeEditor$, activeEditorSubscriptions$, activePlugins$, addActivePlugin$, addBottomAreaChild$, addComposerChild$, addEditorWrapper$, addExportVisitor$, addImportVisitor$, addLexicalNode$, addMdastExtension$, addNestedEditorChild$, addSyntaxExtension$, addToMarkdownExtension$, addTopAreaChild$, applyBlockType$, applyFormat$, autoFocus$, bottomAreaChildren$, codeBlockEditorDescriptors$, composerChildren$, contentEditableClassName$, contentEditableRef$, convertSelectionToNode$, corePlugin, createActiveEditorSubscription$, createRootEditorSubscription$, currentBlockType$, currentFormat$, currentSelection$, directiveDescriptors$, editorInFocus$, editorRootElementRef$, editorWrappers$, exportVisitors$, historyState$, iconComponentFor$, importVisitors$, inFocus$, initialMarkdown$, initialMarkdownNormalize$, insertDecoratorNode$, insertMarkdown$, jsxComponentDescriptors$, jsxIsAvailable$, lexicalTheme$, markdown$, markdownErrorSignal$, markdownProcessingError$, markdownSourceEditorValue$, mdastExtensions$, muteChange$, nestedEditorChildren$, onBlur$, placeholder$, readOnly$, rootEditor$, rootEditorSubscriptions$, setMarkdown$, spellCheck$, syntaxExtensions$, toMarkdownExtensions$, toMarkdownOptions$, topAreaChildren$, translation$, useTranslation, usedLexicalNodes$, viewMode$ } from "./plugins/core/index.js";
7
+ import { Appender, NESTED_EDITOR_UPDATED_COMMAND, activeEditor$, activeEditorSubscriptions$, activePlugins$, addActivePlugin$, addBottomAreaChild$, addComposerChild$, addEditorWrapper$, addExportVisitor$, addImportVisitor$, addLexicalNode$, addMdastExtension$, addNestedEditorChild$, addSyntaxExtension$, addToMarkdownExtension$, addTopAreaChild$, applyBlockType$, applyFormat$, autoFocus$, bottomAreaChildren$, codeBlockEditorDescriptors$, composerChildren$, contentEditableClassName$, contentEditableRef$, contentEditableWrapperElement$, convertSelectionToNode$, corePlugin, createActiveEditorSubscription$, createRootEditorSubscription$, currentBlockType$, currentFormat$, currentSelection$, directiveDescriptors$, editorInFocus$, editorRootElementRef$, editorWrappers$, exportVisitors$, historyState$, iconComponentFor$, importVisitors$, inFocus$, initialMarkdown$, initialMarkdownNormalize$, insertDecoratorNode$, insertMarkdown$, jsxComponentDescriptors$, jsxIsAvailable$, lexicalTheme$, markdown$, markdownErrorSignal$, markdownProcessingError$, markdownSourceEditorValue$, mdastExtensions$, muteChange$, nestedEditorChildren$, onBlur$, placeholder$, readOnly$, rootEditor$, rootEditorSubscriptions$, setMarkdown$, spellCheck$, syntaxExtensions$, toMarkdownExtensions$, toMarkdownOptions$, topAreaChildren$, translation$, useTranslation, usedLexicalNodes$, viewMode$ } from "./plugins/core/index.js";
8
8
  import { ALL_HEADING_LEVELS, allowedHeadingLevels$, headingsPlugin } from "./plugins/headings/index.js";
9
9
  import { insertThematicBreak$, thematicBreakPlugin } from "./plugins/thematic-break/index.js";
10
10
  import { applyListType$, currentListType$, listsPlugin } from "./plugins/lists/index.js";
@@ -206,6 +206,7 @@ export {
206
206
  composerChildren$,
207
207
  contentEditableClassName$,
208
208
  contentEditableRef$,
209
+ contentEditableWrapperElement$,
209
210
  controlOrMeta,
210
211
  convertSelectionToNode$,
211
212
  corePlugin,
@@ -190,6 +190,7 @@ function rebind() {
190
190
  return activeEditorValue ? subs.map((s) => s(activeEditorValue)) : [];
191
191
  }, []);
192
192
  }
193
+ const contentEditableWrapperElement$ = Cell(null);
193
194
  const activeEditorSubscriptions$ = Cell([], (r) => {
194
195
  r.pipe(r.combine(activeEditorSubscriptions$, activeEditor$), rebind());
195
196
  });
@@ -624,6 +625,7 @@ export {
624
625
  composerChildren$,
625
626
  contentEditableClassName$,
626
627
  contentEditableRef$,
628
+ contentEditableWrapperElement$,
627
629
  convertSelectionToNode$,
628
630
  corePlugin,
629
631
  createActiveEditorSubscription$,
@@ -6,19 +6,21 @@ import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
6
6
  import { LexicalAutoLinkPlugin } from "./AutoLinkPlugin.js";
7
7
  import { Cell } from "@mdxeditor/gurx";
8
8
  import { realmPlugin } from "../../RealmWithPlugins.js";
9
- import { addComposerChild$, addExportVisitor$, addLexicalNode$, addImportVisitor$, addActivePlugin$ } from "../core/index.js";
9
+ import { addComposerChild$, addNestedEditorChild$, addExportVisitor$, addLexicalNode$, addImportVisitor$, addActivePlugin$ } from "../core/index.js";
10
10
  const disableAutoLink$ = Cell(false);
11
11
  const linkPlugin = realmPlugin({
12
12
  init(realm, params) {
13
13
  const disableAutoLink = Boolean(params == null ? void 0 : params.disableAutoLink);
14
14
  const linkPluginProps = (params == null ? void 0 : params.validateUrl) ? { validateUrl: params.validateUrl } : {};
15
+ const EditorChild = () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(LinkPlugin, { ...linkPluginProps }), disableAutoLink ? null : /* @__PURE__ */ React__default.createElement(LexicalAutoLinkPlugin, null));
15
16
  realm.pubIn({
16
17
  [addActivePlugin$]: "link",
17
18
  [addImportVisitor$]: MdastLinkVisitor,
18
19
  [addLexicalNode$]: [LinkNode, AutoLinkNode],
19
20
  [addExportVisitor$]: LexicalLinkVisitor,
20
21
  [disableAutoLink$]: disableAutoLink,
21
- [addComposerChild$]: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(LinkPlugin, { ...linkPluginProps }), disableAutoLink ? null : /* @__PURE__ */ React__default.createElement(LexicalAutoLinkPlugin, null))
22
+ [addNestedEditorChild$]: EditorChild,
23
+ [addComposerChild$]: EditorChild
22
24
  });
23
25
  }
24
26
  });
@@ -15,7 +15,7 @@ import classNames from "classnames";
15
15
  import styles from "../../styles/ui.module.css.js";
16
16
  import { isPartOftheEditorUI } from "../../utils/isPartOftheEditorUI.js";
17
17
  import { uuidv4 } from "../../utils/uuid4.js";
18
- import { iconComponentFor$, readOnly$, useTranslation, editorRootElementRef$, importVisitors$, exportVisitors$, usedLexicalNodes$, jsxComponentDescriptors$, directiveDescriptors$, codeBlockEditorDescriptors$, jsxIsAvailable$, rootEditor$, NESTED_EDITOR_UPDATED_COMMAND } from "../core/index.js";
18
+ import { iconComponentFor$, readOnly$, useTranslation, editorRootElementRef$, importVisitors$, exportVisitors$, usedLexicalNodes$, jsxComponentDescriptors$, directiveDescriptors$, codeBlockEditorDescriptors$, jsxIsAvailable$, rootEditor$, nestedEditorChildren$, NESTED_EDITOR_UPDATED_COMMAND } from "../core/index.js";
19
19
  import { useCellValues } from "@mdxeditor/gurx";
20
20
  const getCellType = (rowIndex) => {
21
21
  if (rowIndex === 0) {
@@ -218,7 +218,8 @@ const CellEditor = ({ focus, setActiveCell, parentEditor, lexicalTable, contents
218
218
  directiveDescriptors,
219
219
  codeBlockEditorDescriptors,
220
220
  jsxIsAvailable,
221
- rootEditor
221
+ rootEditor,
222
+ nestedEditorChildren
222
223
  ] = useCellValues(
223
224
  importVisitors$,
224
225
  exportVisitors$,
@@ -227,7 +228,8 @@ const CellEditor = ({ focus, setActiveCell, parentEditor, lexicalTable, contents
227
228
  directiveDescriptors$,
228
229
  codeBlockEditorDescriptors$,
229
230
  jsxIsAvailable$,
230
- rootEditor$
231
+ rootEditor$,
232
+ nestedEditorChildren$
231
233
  );
232
234
  const [editor] = React__default.useState(() => {
233
235
  const editor2 = createEditor({
@@ -323,7 +325,7 @@ const CellEditor = ({ focus, setActiveCell, parentEditor, lexicalTable, contents
323
325
  React__default.useEffect(() => {
324
326
  focus && editor.focus();
325
327
  }, [focus, editor]);
326
- return /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor }, /* @__PURE__ */ React__default.createElement(RichTextPlugin, { contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, null), placeholder: /* @__PURE__ */ React__default.createElement("div", null), ErrorBoundary: LexicalErrorBoundary }), /* @__PURE__ */ React__default.createElement(HistoryPlugin, null));
328
+ return /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor }, /* @__PURE__ */ React__default.createElement(RichTextPlugin, { contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, null), placeholder: /* @__PURE__ */ React__default.createElement("div", null), ErrorBoundary: LexicalErrorBoundary }), nestedEditorChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })), /* @__PURE__ */ React__default.createElement(HistoryPlugin, null));
327
329
  };
328
330
  const ColumnEditor = ({
329
331
  parentEditor,
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "*.css"
12
12
  ],
13
13
  "type": "module",
14
- "version": "3.46.0",
14
+ "version": "3.47.0",
15
15
  "description": "React component for rich text markdown editing",
16
16
  "scripts": {
17
17
  "build": "vite build",