@mdxeditor/editor 3.45.1 → 3.46.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
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { usePublisher, useCellValue, useCellValues, useRealm } from "@mdxeditor/gurx";
|
|
2
2
|
import React__default from "react";
|
|
3
|
-
import { RealmWithPlugins } from "./RealmWithPlugins.js";
|
|
4
3
|
import { corePlugin, editorRootElementRef$, rootEditor$, useTranslation, contentEditableRef$, contentEditableClassName$, spellCheck$, composerChildren$, topAreaChildren$, editorWrappers$, placeholder$, bottomAreaChildren$, insertMarkdown$, setMarkdown$, viewMode$, markdownSourceEditorValue$, markdown$ } from "./plugins/core/index.js";
|
|
4
|
+
import { RealmWithPlugins } from "./RealmWithPlugins.js";
|
|
5
|
+
import { createLexicalComposerContext, LexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
5
6
|
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
7
|
+
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
6
8
|
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
7
9
|
import classNames from "classnames";
|
|
10
|
+
import { defaultSvgIcons } from "./defaultSvgIcons.js";
|
|
8
11
|
import { lexicalTheme } from "./styles/lexicalTheme.js";
|
|
9
12
|
import styles from "./styles/ui.module.css.js";
|
|
10
13
|
import { noop } from "./utils/fp.js";
|
|
11
|
-
import { createLexicalComposerContext, LexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
12
|
-
import { defaultSvgIcons } from "./defaultSvgIcons.js";
|
|
13
|
-
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
14
14
|
const LexicalProvider = ({ children }) => {
|
|
15
15
|
const rootEditor = useCellValue(rootEditor$);
|
|
16
16
|
const composerContextValue = React__default.useMemo(() => {
|
|
@@ -141,7 +141,9 @@ const MDXEditor = React__default.forwardRef((props, ref) => {
|
|
|
141
141
|
trim: props.trim ?? true,
|
|
142
142
|
lexicalTheme: props.lexicalTheme,
|
|
143
143
|
..."editorState" in props ? { editorState: props.editorState } : {},
|
|
144
|
-
suppressSharedHistory: props.suppressSharedHistory ?? false
|
|
144
|
+
suppressSharedHistory: props.suppressSharedHistory ?? false,
|
|
145
|
+
additionalLexicalNodes: props.additionalLexicalNodes ?? [],
|
|
146
|
+
lexicalEditorNamespace: props.lexicalEditorNamespace ?? "MDXEditor"
|
|
145
147
|
}),
|
|
146
148
|
...props.plugins ?? []
|
|
147
149
|
]
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ import * as lexical from 'lexical';
|
|
|
22
22
|
import { LexicalCommand } from 'lexical';
|
|
23
23
|
import { LexicalEditor } from 'lexical';
|
|
24
24
|
import { LexicalNode } from 'lexical';
|
|
25
|
+
import { LexicalNodeReplacement } from 'lexical';
|
|
25
26
|
import { LinkNode } from '@lexical/link';
|
|
26
27
|
import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
|
|
27
28
|
import { ListType } from '@lexical/list';
|
|
@@ -202,11 +203,13 @@ export declare const addExportVisitor$: NodeRef< LexicalVisitor | LexicalVisitor
|
|
|
202
203
|
*/
|
|
203
204
|
export declare const addImportVisitor$: NodeRef<MdastImportVisitor<Mdast.Nodes> | MdastImportVisitor<Mdast.Nodes>[]>;
|
|
204
205
|
|
|
206
|
+
export declare type AdditionalLexicalNode = KlassConstructor<typeof LexicalNode> | LexicalNodeReplacement;
|
|
207
|
+
|
|
205
208
|
/**
|
|
206
209
|
* Registers a lexical node to be used in the editor.
|
|
207
210
|
* @group Core
|
|
208
211
|
*/
|
|
209
|
-
export declare const addLexicalNode$: NodeRef<
|
|
212
|
+
export declare const addLexicalNode$: NodeRef<KlassConstructor<typeof LexicalNode> | KlassConstructor<typeof LexicalNode>[]>;
|
|
210
213
|
|
|
211
214
|
/**
|
|
212
215
|
* Adds a mdast extension to the markdown parser.
|
|
@@ -2311,6 +2314,14 @@ export declare interface MDXEditorProps {
|
|
|
2311
2314
|
* The initial state of the lexical editor. Pass null to disable any initiation.
|
|
2312
2315
|
*/
|
|
2313
2316
|
editorState?: EditorState | undefined | null;
|
|
2317
|
+
/**
|
|
2318
|
+
* Additional lexical nodes to include in the editor.
|
|
2319
|
+
*/
|
|
2320
|
+
additionalLexicalNodes?: AdditionalLexicalNode[];
|
|
2321
|
+
/**
|
|
2322
|
+
* The lexical editor namespace.
|
|
2323
|
+
*/
|
|
2324
|
+
lexicalEditorNamespace?: string;
|
|
2314
2325
|
}
|
|
2315
2326
|
|
|
2316
2327
|
/**
|
|
@@ -2344,7 +2355,11 @@ export declare const muteChange$: NodeRef<boolean>;
|
|
|
2344
2355
|
|
|
2345
2356
|
export declare const NESTED_EDITOR_UPDATED_COMMAND: LexicalCommand<undefined>;
|
|
2346
2357
|
|
|
2347
|
-
|
|
2358
|
+
/**
|
|
2359
|
+
* React Components registered to be rendered inside `LexicalNestedComposer`. Useful if you're using lexical editor plugins that are wrapped as react components.
|
|
2360
|
+
* @group Core
|
|
2361
|
+
*/
|
|
2362
|
+
export declare const nestedEditorChildren$: NodeRef<default_2.ComponentType<{}>[]>;
|
|
2348
2363
|
|
|
2349
2364
|
/**
|
|
2350
2365
|
* Use this context to provide the necessary values to the {@link NestedLexicalEditor} React component.
|
|
@@ -3041,7 +3056,7 @@ export declare function useCodeBlockEditorContext(): CodeBlockEditorContextValue
|
|
|
3041
3056
|
* Contains the currently registered lexical nodes.
|
|
3042
3057
|
* @group Core
|
|
3043
3058
|
*/
|
|
3044
|
-
export declare const usedLexicalNodes$: NodeRef<
|
|
3059
|
+
export declare const usedLexicalNodes$: NodeRef<KlassConstructor<typeof LexicalNode>[]>;
|
|
3045
3060
|
|
|
3046
3061
|
export declare function useEditorSearch(): {
|
|
3047
3062
|
next: () => void;
|
|
@@ -545,8 +545,8 @@ const corePlugin = realmPlugin({
|
|
|
545
545
|
const newEditor = createEditor({
|
|
546
546
|
// ...(params?.editorState ? { editorState: params.editorState } : {}),
|
|
547
547
|
editable: (params == null ? void 0 : params.readOnly) !== true,
|
|
548
|
-
namespace: "MDXEditor",
|
|
549
|
-
nodes: r.getValue(usedLexicalNodes$),
|
|
548
|
+
namespace: (params == null ? void 0 : params.lexicalEditorNamespace) ?? "MDXEditor",
|
|
549
|
+
nodes: [...r.getValue(usedLexicalNodes$), ...(params == null ? void 0 : params.additionalLexicalNodes) ?? []],
|
|
550
550
|
onError: (error) => {
|
|
551
551
|
throw error;
|
|
552
552
|
},
|
|
@@ -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
|
-
[
|
|
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,
|