@mdxeditor/editor 3.16.0 → 3.17.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.
package/dist/MDXEditor.js CHANGED
@@ -128,7 +128,8 @@ const MDXEditor = React__default.forwardRef((props, ref) => {
128
128
  suppressHtmlProcessing: props.suppressHtmlProcessing ?? false,
129
129
  onError: props.onError ?? noop,
130
130
  translation: props.translation ?? defaultTranslation,
131
- trim: props.trim ?? true
131
+ trim: props.trim ?? true,
132
+ lexicalTheme: props.lexicalTheme
132
133
  }),
133
134
  ...props.plugins ?? []
134
135
  ]
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import { Directives } from 'mdast-util-directive';
6
6
  import { DOMConversionMap } from 'lexical';
7
7
  import { DOMExportOutput } from 'lexical';
8
8
  import { EditorConfig } from 'lexical';
9
+ import { EditorThemeClasses } from 'lexical';
9
10
  import { ElementNode } from 'lexical';
10
11
  import { Extension } from 'micromark-util-types';
11
12
  import { Extension as Extension_2 } from '@codemirror/state';
@@ -1787,6 +1788,10 @@ export declare interface LexicalExportVisitor<LN extends LexicalNode, UN extends
1787
1788
  priority?: number;
1788
1789
  }
1789
1790
 
1791
+ export declare const lexicalTheme$: NodeRef<EditorThemeClasses>;
1792
+
1793
+ export declare const lexicalTheme: EditorThemeClasses;
1794
+
1790
1795
  /**
1791
1796
  * A generic visitor that can be used to process any lexical node.
1792
1797
  * @group Markdown Processing
@@ -2114,6 +2119,10 @@ export declare interface MDXEditorProps {
2114
2119
  * Whether to apply trim() to the initial markdown input (default: true)
2115
2120
  */
2116
2121
  trim?: boolean;
2122
+ /**
2123
+ * A custom lexical theme to use for the editor.
2124
+ */
2125
+ lexicalTheme?: EditorThemeClasses;
2117
2126
  }
2118
2127
 
2119
2128
  /**
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$, addComposerChild$, addEditorWrapper$, addExportVisitor$, addImportVisitor$, addLexicalNode$, addMdastExtension$, addNestedEditorChild$, addSyntaxExtension$, addToMarkdownExtension$, addTopAreaChild$, applyBlockType$, applyFormat$, autoFocus$, codeBlockEditorDescriptors$, composerChildren$, contentEditableClassName$, convertSelectionToNode$, corePlugin, createActiveEditorSubscription$, createRootEditorSubscription$, currentBlockType$, currentFormat$, currentSelection$, directiveDescriptors$, editorInFocus$, editorRootElementRef$, editorWrappers$, exportVisitors$, historyState$, iconComponentFor$, importVisitors$, inFocus$, initialMarkdown$, insertDecoratorNode$, insertMarkdown$, jsxComponentDescriptors$, jsxIsAvailable$, markdown$, markdownErrorSignal$, markdownProcessingError$, markdownSourceEditorValue$, mdastExtensions$, muteChange$, nestedEditorChildren$, onBlur$, placeholder$, readOnly$, rootEditor$, rootEditorSubscriptions$, setMarkdown$, syntaxExtensions$, toMarkdownExtensions$, toMarkdownOptions$, topAreaChildren$, translation$, useTranslation, usedLexicalNodes$, viewMode$ } from "./plugins/core/index.js";
7
+ import { Appender, NESTED_EDITOR_UPDATED_COMMAND, activeEditor$, activeEditorSubscriptions$, activePlugins$, addActivePlugin$, addComposerChild$, addEditorWrapper$, addExportVisitor$, addImportVisitor$, addLexicalNode$, addMdastExtension$, addNestedEditorChild$, addSyntaxExtension$, addToMarkdownExtension$, addTopAreaChild$, applyBlockType$, applyFormat$, autoFocus$, codeBlockEditorDescriptors$, composerChildren$, contentEditableClassName$, convertSelectionToNode$, corePlugin, createActiveEditorSubscription$, createRootEditorSubscription$, currentBlockType$, currentFormat$, currentSelection$, directiveDescriptors$, editorInFocus$, editorRootElementRef$, editorWrappers$, exportVisitors$, historyState$, iconComponentFor$, importVisitors$, inFocus$, initialMarkdown$, insertDecoratorNode$, insertMarkdown$, jsxComponentDescriptors$, jsxIsAvailable$, lexicalTheme$, markdown$, markdownErrorSignal$, markdownProcessingError$, markdownSourceEditorValue$, mdastExtensions$, muteChange$, nestedEditorChildren$, onBlur$, placeholder$, readOnly$, rootEditor$, rootEditorSubscriptions$, setMarkdown$, 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";
@@ -60,6 +60,7 @@ import { uuidv4 } from "./utils/uuid4.js";
60
60
  import { voidEmitter } from "./utils/voidEmitter.js";
61
61
  import { RealmWithPlugins, realmPlugin } from "./RealmWithPlugins.js";
62
62
  import { DEFAULT_FORMAT, IS_BOLD, IS_CODE, IS_HIGHLIGHT, IS_ITALIC, IS_STRIKETHROUGH, IS_SUBSCRIPT, IS_SUPERSCRIPT, IS_UNDERLINE } from "./FormatConstants.js";
63
+ import { lexicalTheme } from "./styles/lexicalTheme.js";
63
64
  import { htmlTags, isMdastHTMLNode } from "./plugins/core/MdastHTMLNode.js";
64
65
  import { $createGenericHTMLNode, $isGenericHTMLNode, GenericHTMLNode, TYPE_NAME } from "./plugins/core/GenericHTMLNode.js";
65
66
  import { $createTableNode, $isTableNode, TableNode } from "./plugins/table/TableNode.js";
@@ -253,6 +254,8 @@ export {
253
254
  jsxComponentDescriptors$,
254
255
  jsxIsAvailable$,
255
256
  jsxPlugin,
257
+ lexicalTheme,
258
+ lexicalTheme$,
256
259
  linkAutocompleteSuggestions$,
257
260
  linkDialogPlugin,
258
261
  linkDialogState$,
@@ -1,19 +1,18 @@
1
1
  import { $addUpdateTag, $getNodeByKey, createEditor, $getRoot, FOCUS_COMMAND, COMMAND_PRIORITY_LOW, BLUR_COMMAND, COMMAND_PRIORITY_EDITOR, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_HIGH, KEY_BACKSPACE_COMMAND, COMMAND_PRIORITY_CRITICAL } from "lexical";
2
2
  import React__default from "react";
3
- import { NESTED_EDITOR_UPDATED_COMMAND, rootEditor$, importVisitors$, exportVisitors$, usedLexicalNodes$, jsxComponentDescriptors$, directiveDescriptors$, codeBlockEditorDescriptors$, jsxIsAvailable$, nestedEditorChildren$, editorInFocus$ } from "./index.js";
3
+ import { NESTED_EDITOR_UPDATED_COMMAND, rootEditor$, importVisitors$, exportVisitors$, usedLexicalNodes$, jsxComponentDescriptors$, directiveDescriptors$, codeBlockEditorDescriptors$, jsxIsAvailable$, nestedEditorChildren$, lexicalTheme$, editorInFocus$ } from "./index.js";
4
4
  import { ContentEditable } from "@lexical/react/LexicalContentEditable.js";
5
5
  import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary.js";
6
6
  import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer.js";
7
7
  import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin.js";
8
8
  import classNames from "classnames";
9
- import { lexicalTheme } from "../../styles/lexicalTheme.js";
10
9
  import { exportLexicalTreeToMdast } from "../../exportMarkdownFromLexical.js";
11
10
  import { importMdastTreeToLexical } from "../../importMarkdownToLexical.js";
12
11
  import styles from "../../styles/ui.module.css.js";
13
12
  import { SharedHistoryPlugin } from "./SharedHistoryPlugin.js";
14
13
  import { mergeRegister } from "@lexical/utils";
15
14
  import { isPartOftheEditorUI } from "../../utils/isPartOftheEditorUI.js";
16
- import { useCellValues, usePublisher } from "@mdxeditor/gurx";
15
+ import { useRealm, useCellValues, usePublisher } from "@mdxeditor/gurx";
17
16
  const NestedEditorsContext = React__default.createContext(void 0);
18
17
  function useNestedEditorContext() {
19
18
  const context = React__default.useContext(NestedEditorsContext);
@@ -54,6 +53,7 @@ const NestedLexicalEditor = function(props) {
54
53
  const updateMdastNode = useMdastNodeUpdater();
55
54
  const removeNode = useLexicalNodeRemove();
56
55
  const content = getContent(mdastNode);
56
+ const realm = useRealm();
57
57
  const [
58
58
  rootEditor,
59
59
  importVisitors,
@@ -63,7 +63,8 @@ const NestedLexicalEditor = function(props) {
63
63
  directiveDescriptors,
64
64
  codeBlockEditorDescriptors,
65
65
  jsxIsAvailable,
66
- nestedEditorChildren
66
+ nestedEditorChildren,
67
+ lexicalTheme
67
68
  ] = useCellValues(
68
69
  rootEditor$,
69
70
  importVisitors$,
@@ -73,13 +74,14 @@ const NestedLexicalEditor = function(props) {
73
74
  directiveDescriptors$,
74
75
  codeBlockEditorDescriptors$,
75
76
  jsxIsAvailable$,
76
- nestedEditorChildren$
77
+ nestedEditorChildren$,
78
+ lexicalTheme$
77
79
  );
78
80
  const setEditorInFocus = usePublisher(editorInFocus$);
79
81
  const [editor] = React__default.useState(() => {
80
82
  const editor2 = createEditor({
81
83
  nodes: usedLexicalNodes,
82
- theme: lexicalTheme
84
+ theme: realm.getValue(lexicalTheme$)
83
85
  });
84
86
  return editor2;
85
87
  });
@@ -192,7 +194,7 @@ const NestedLexicalEditor = function(props) {
192
194
  updateMdastNode,
193
195
  rootEditor
194
196
  ]);
195
- return /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor }, /* @__PURE__ */ React__default.createElement(
197
+ return /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor, initialTheme: lexicalTheme }, /* @__PURE__ */ React__default.createElement(
196
198
  RichTextPlugin,
197
199
  {
198
200
  contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, { ...contentEditableProps, className: classNames(styles.nestedEditor, contentEditableProps == null ? void 0 : contentEditableProps.className) }),
@@ -470,6 +470,7 @@ const addActivePlugin$ = Appender(activePlugins$);
470
470
  const translation$ = Cell(() => {
471
471
  throw new Error("No translation function provided");
472
472
  });
473
+ const lexicalTheme$ = Cell(lexicalTheme);
473
474
  const corePlugin = realmPlugin({
474
475
  init(r, params) {
475
476
  const initialMarkdown = (params == null ? void 0 : params.initialMarkdown) ?? "";
@@ -497,7 +498,8 @@ const corePlugin = realmPlugin({
497
498
  [translation$]: params == null ? void 0 : params.translation,
498
499
  [addMdastExtension$]: gfmStrikethroughFromMarkdown(),
499
500
  [addSyntaxExtension$]: gfmStrikethrough(),
500
- [addToMarkdownExtension$]: [mdxJsxToMarkdown(), gfmStrikethroughToMarkdown()]
501
+ [addToMarkdownExtension$]: [mdxJsxToMarkdown(), gfmStrikethroughToMarkdown()],
502
+ [lexicalTheme$]: (params == null ? void 0 : params.lexicalTheme) ?? lexicalTheme
501
503
  });
502
504
  r.singletonSub(markdownErrorSignal$, params == null ? void 0 : params.onError);
503
505
  r.singletonSub(mutableMarkdownSignal$, params == null ? void 0 : params.onChange);
@@ -518,7 +520,7 @@ const corePlugin = realmPlugin({
518
520
  onError: (error) => {
519
521
  throw error;
520
522
  },
521
- theme: lexicalTheme
523
+ theme: r.getValue(lexicalTheme$)
522
524
  });
523
525
  newEditor.update(() => {
524
526
  const markdown = (params == null ? void 0 : params.initialMarkdown.trim()) ?? "";
@@ -605,6 +607,7 @@ export {
605
607
  insertMarkdown$,
606
608
  jsxComponentDescriptors$,
607
609
  jsxIsAvailable$,
610
+ lexicalTheme$,
608
611
  markdown$,
609
612
  markdownErrorSignal$,
610
613
  markdownProcessingError$,
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "*.css"
12
12
  ],
13
13
  "type": "module",
14
- "version": "3.16.0",
14
+ "version": "3.17.1",
15
15
  "description": "React component for rich text markdown editing",
16
16
  "scripts": {
17
17
  "build": "vite build",