@mdxeditor/editor 2.3.9 → 2.4.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
|
@@ -37,7 +37,7 @@ const RichTextEditor = () => {
|
|
|
37
37
|
editorWrappers$,
|
|
38
38
|
placeholder$
|
|
39
39
|
);
|
|
40
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, topAreaChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })), /* @__PURE__ */ React__default.createElement(
|
|
40
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, topAreaChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })), /* @__PURE__ */ React__default.createElement(RenderRecursiveWrappers, { wrappers: editorWrappers }, /* @__PURE__ */ React__default.createElement("div", { className: classNames(styles.rootContentEditableWrapper) }, /* @__PURE__ */ React__default.createElement(
|
|
41
41
|
RichTextPlugin,
|
|
42
42
|
{
|
|
43
43
|
contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, { className: classNames(styles.contentEditable, contentEditableClassName) }),
|
|
@@ -56,7 +56,7 @@ const IconFallback = () => {
|
|
|
56
56
|
const defaultIconComponentFor = (name) => {
|
|
57
57
|
return /* @__PURE__ */ React__default.createElement(React__default.Suspense, { fallback: /* @__PURE__ */ React__default.createElement(IconFallback, null) }, /* @__PURE__ */ React__default.createElement(DefaultIcon, { name }));
|
|
58
58
|
};
|
|
59
|
-
const
|
|
59
|
+
const RenderRecursiveWrappers = ({
|
|
60
60
|
wrappers,
|
|
61
61
|
children
|
|
62
62
|
}) => {
|
|
@@ -64,7 +64,7 @@ const RenderRecurisveWrappers = ({
|
|
|
64
64
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children);
|
|
65
65
|
}
|
|
66
66
|
const Wrapper = wrappers[0];
|
|
67
|
-
return /* @__PURE__ */ React__default.createElement(Wrapper, null, /* @__PURE__ */ React__default.createElement(
|
|
67
|
+
return /* @__PURE__ */ React__default.createElement(Wrapper, null, /* @__PURE__ */ React__default.createElement(RenderRecursiveWrappers, { wrappers: wrappers.slice(1) }, children));
|
|
68
68
|
};
|
|
69
69
|
const EditorRootElement = ({ children, className }) => {
|
|
70
70
|
const editorRootElementRef = React__default.useRef(null);
|
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ import { ReactNode } from 'react';
|
|
|
67
67
|
import { Realm } from '@mdxeditor/gurx';
|
|
68
68
|
import { RootNode } from 'lexical';
|
|
69
69
|
import { SandpackProvider } from '@codesandbox/sandpack-react';
|
|
70
|
+
import { SandpackThemeProp } from '@codesandbox/sandpack-react/types';
|
|
70
71
|
import { SerializedElementNode } from 'lexical';
|
|
71
72
|
import { SerializedLexicalNode } from 'lexical';
|
|
72
73
|
import { Spread } from 'lexical';
|
|
@@ -473,6 +474,10 @@ export declare interface CodeBlockEditorProps {
|
|
|
473
474
|
* Note: you don't need to unsubscribe, the emiter has a single subscription model.
|
|
474
475
|
*/
|
|
475
476
|
focusEmitter: VoidEmitter;
|
|
477
|
+
/**
|
|
478
|
+
* The theme CodeMirrorEditor used.
|
|
479
|
+
*/
|
|
480
|
+
theme: SandpackThemeProp;
|
|
476
481
|
}
|
|
477
482
|
|
|
478
483
|
/**
|
|
@@ -530,9 +535,13 @@ export declare const codeBlockPlugin: (params?: {
|
|
|
530
535
|
* The default language to use when creating a new code block if no language is passed.
|
|
531
536
|
*/
|
|
532
537
|
defaultCodeBlockLanguage?: string | undefined;
|
|
538
|
+
/**
|
|
539
|
+
* The theme of CodeMirrorEditor
|
|
540
|
+
*/
|
|
541
|
+
theme?: SandpackThemeProp | undefined;
|
|
533
542
|
} | undefined) => RealmPlugin;
|
|
534
543
|
|
|
535
|
-
|
|
544
|
+
export declare const CodeMirrorEditor: ({ language, nodeKey, code, focusEmitter, theme }: CodeBlockEditorProps) => React_2.JSX.Element;
|
|
536
545
|
|
|
537
546
|
/**
|
|
538
547
|
* A plugin that adds lets users edit code blocks with CodeMirror.
|
|
@@ -2483,6 +2492,15 @@ export declare function tap<T>(arg: T, proc: (arg: T) => unknown): T;
|
|
|
2483
2492
|
*/
|
|
2484
2493
|
export declare const thematicBreakPlugin: (params?: unknown) => RealmPlugin;
|
|
2485
2494
|
|
|
2495
|
+
/**
|
|
2496
|
+
* The theme CodeMirrorEditor used.
|
|
2497
|
+
* It can be "light" | "dark" | "auto",
|
|
2498
|
+
* or the theme in "@codesandbox/sandpack-themes" package,
|
|
2499
|
+
* or you can also custom one,
|
|
2500
|
+
* learn more https://sandpack.codesandbox.io/docs/getting-started/themes#custom-theme
|
|
2501
|
+
*/
|
|
2502
|
+
export declare const theme$: NodeRef<SandpackThemeProp>;
|
|
2503
|
+
|
|
2486
2504
|
/**
|
|
2487
2505
|
* Takes a value and applies a function to it.
|
|
2488
2506
|
* @group Utils
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { GenericJsxEditor } from "./jsx-editors/GenericJsxEditor.js";
|
|
|
17
17
|
import { insertSandpack$, sandpackConfig$, sandpackPlugin } from "./plugins/sandpack/index.js";
|
|
18
18
|
import { codeBlockLanguages$, codeMirrorPlugin, insertCodeMirror$ } from "./plugins/codemirror/index.js";
|
|
19
19
|
import { CodeMirrorEditor } from "./plugins/codemirror/CodeMirrorEditor.js";
|
|
20
|
-
import { appendCodeBlockEditorDescriptor$, codeBlockPlugin, defaultCodeBlockLanguage$, insertCodeBlock$ } from "./plugins/codeblock/index.js";
|
|
20
|
+
import { appendCodeBlockEditorDescriptor$, codeBlockPlugin, defaultCodeBlockLanguage$, insertCodeBlock$, theme$ } from "./plugins/codeblock/index.js";
|
|
21
21
|
import { directivesPlugin, insertDirective$ } from "./plugins/directives/index.js";
|
|
22
22
|
import { ADMONITION_TYPES, AdmonitionDirectiveDescriptor } from "./directive-editors/AdmonitionDirectiveDescriptor.js";
|
|
23
23
|
import { GenericDirectiveEditor } from "./directive-editors/GenericDirectiveEditor.js";
|
|
@@ -268,6 +268,7 @@ export {
|
|
|
268
268
|
tablePlugin,
|
|
269
269
|
tap,
|
|
270
270
|
thematicBreakPlugin,
|
|
271
|
+
theme$,
|
|
271
272
|
thrush,
|
|
272
273
|
toMarkdownExtensions$,
|
|
273
274
|
toMarkdownOptions$,
|
|
@@ -7,6 +7,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
import { useCellValue } from "@mdxeditor/gurx";
|
|
8
8
|
import { DecoratorNode } from "lexical";
|
|
9
9
|
import React__default from "react";
|
|
10
|
+
import { theme$ } from "./index.js";
|
|
10
11
|
import { voidEmitter } from "../../utils/voidEmitter.js";
|
|
11
12
|
import { codeBlockEditorDescriptors$, NESTED_EDITOR_UPDATED_COMMAND } from "../core/index.js";
|
|
12
13
|
class CodeBlockNode extends DecoratorNode {
|
|
@@ -87,7 +88,8 @@ class CodeBlockNode extends DecoratorNode {
|
|
|
87
88
|
language: this.getLanguage(),
|
|
88
89
|
codeBlockNode: this,
|
|
89
90
|
nodeKey: this.getKey(),
|
|
90
|
-
focusEmitter: this.__focusEmitter
|
|
91
|
+
focusEmitter: this.__focusEmitter,
|
|
92
|
+
theme: "auto"
|
|
91
93
|
}
|
|
92
94
|
);
|
|
93
95
|
}
|
|
@@ -140,6 +142,7 @@ const CodeBlockEditorContainer = (props) => {
|
|
|
140
142
|
}
|
|
141
143
|
const Editor = descriptor.Editor;
|
|
142
144
|
const { codeBlockNode: _, parentEditor: __, ...restProps } = props;
|
|
145
|
+
restProps.theme = useCellValue(theme$);
|
|
143
146
|
return /* @__PURE__ */ React__default.createElement(CodeBlockEditorContextProvider, { parentEditor: props.parentEditor, lexicalNode: props.codeBlockNode }, /* @__PURE__ */ React__default.createElement(Editor, { ...restProps }));
|
|
144
147
|
};
|
|
145
148
|
function $createCodeBlockNode(options) {
|
|
@@ -6,6 +6,7 @@ import { $isCodeBlockNode, useCodeBlockEditorContext } from "./CodeBlockNode.js"
|
|
|
6
6
|
import { Cell, Signal, withLatestFrom, map } from "@mdxeditor/gurx";
|
|
7
7
|
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
8
8
|
const defaultCodeBlockLanguage$ = Cell("");
|
|
9
|
+
const theme$ = Cell("auto");
|
|
9
10
|
const insertCodeBlock$ = Signal((r) => {
|
|
10
11
|
r.link(
|
|
11
12
|
r.pipe(
|
|
@@ -22,6 +23,7 @@ const appendCodeBlockEditorDescriptor$ = Appender(codeBlockEditorDescriptors$);
|
|
|
22
23
|
const codeBlockPlugin = realmPlugin({
|
|
23
24
|
update(realm, params) {
|
|
24
25
|
realm.pub(defaultCodeBlockLanguage$, (params == null ? void 0 : params.defaultCodeBlockLanguage) || "");
|
|
26
|
+
realm.pub(theme$, (params == null ? void 0 : params.theme) || "auto");
|
|
25
27
|
},
|
|
26
28
|
init(realm, params) {
|
|
27
29
|
realm.pubIn({
|
|
@@ -41,5 +43,6 @@ export {
|
|
|
41
43
|
codeBlockPlugin,
|
|
42
44
|
defaultCodeBlockLanguage$,
|
|
43
45
|
insertCodeBlock$,
|
|
46
|
+
theme$,
|
|
44
47
|
useCodeBlockEditorContext
|
|
45
48
|
};
|
|
@@ -5,7 +5,7 @@ import { useCodeBlockEditorContext } from "../codeblock/CodeBlockNode.js";
|
|
|
5
5
|
import { readOnly$ } from "../core/index.js";
|
|
6
6
|
import { useCodeMirrorRef } from "../sandpack/useCodeMirrorRef.js";
|
|
7
7
|
import { useCellValue } from "@mdxeditor/gurx";
|
|
8
|
-
const CodeMirrorEditor = ({ language, nodeKey, code, focusEmitter }) => {
|
|
8
|
+
const CodeMirrorEditor = ({ language, nodeKey, code, focusEmitter, theme }) => {
|
|
9
9
|
const codeMirrorRef = useCodeMirrorRef(nodeKey, "codeblock", "jsx", focusEmitter);
|
|
10
10
|
const readOnly = useCellValue(readOnly$);
|
|
11
11
|
const { setCode } = useCodeBlockEditorContext();
|
|
@@ -23,7 +23,7 @@ const CodeMirrorEditor = ({ language, nodeKey, code, focusEmitter }) => {
|
|
|
23
23
|
e.stopPropagation();
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
|
-
/* @__PURE__ */ React__default.createElement(SandpackProvider,
|
|
26
|
+
/* @__PURE__ */ React__default.createElement(SandpackProvider, { theme }, /* @__PURE__ */ React__default.createElement(
|
|
27
27
|
CodeEditor,
|
|
28
28
|
{
|
|
29
29
|
readOnly,
|