@mdxeditor/editor 2.5.0 → 2.5.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/README.md +6 -1
- package/dist/index.d.ts +14 -18
- package/dist/index.js +3 -3
- package/dist/plugins/codeblock/CodeBlockNode.js +1 -4
- package/dist/plugins/codeblock/index.js +0 -3
- package/dist/plugins/codemirror/CodeMirrorEditor.js +4 -3
- package/dist/plugins/codemirror/index.js +7 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ The component supports the core markdown syntax and certain extensions, includin
|
|
|
10
10
|
|
|
11
11
|
```jsx
|
|
12
12
|
import {MDXEditor, headingsPlugin} from '@mdxeditor/editor';
|
|
13
|
+
import '@mdxeditor/editor/style.css';
|
|
13
14
|
|
|
14
15
|
export default function App() {
|
|
15
16
|
return <MDXEditor markdown={'# Hello World'} plugins={[headingsPlugin()]} />;
|
|
@@ -21,7 +22,11 @@ The best place to get started using the component is the [documentation](https:/
|
|
|
21
22
|
|
|
22
23
|
## Help and support
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
If you find a bug, check if something similar is not reported already in the [issues](https://github.com/mdx-editor/editor/issues). If not, [create a new issue](https://github.com/mdx-editor/editor/issues/new?assignees=&labels=bug&projects=&template=1.bug.md&title=%5BBUG%5D).
|
|
26
|
+
|
|
27
|
+
If you're integrating the component in your commercial project and need dedicated assistance with your issues in exchange of sponsorship, [contact me over email](mailto:petyo@mdxeditor.dev).
|
|
28
|
+
|
|
29
|
+
If you want to discuss ideas [join the Discord server](https://discord.gg/4q7U2Hc) or start a discussion in the [Discussions](https://github.com/mdx-editor/editor/discussions) section.
|
|
25
30
|
|
|
26
31
|
## License
|
|
27
32
|
|
package/dist/index.d.ts
CHANGED
|
@@ -476,10 +476,6 @@ export declare interface CodeBlockEditorProps {
|
|
|
476
476
|
* Note: you don't need to unsubscribe, the emiter has a single subscription model.
|
|
477
477
|
*/
|
|
478
478
|
focusEmitter: VoidEmitter;
|
|
479
|
-
/**
|
|
480
|
-
* The theme CodeMirrorEditor used.
|
|
481
|
-
*/
|
|
482
|
-
theme: SandpackThemeProp;
|
|
483
479
|
}
|
|
484
480
|
|
|
485
481
|
/**
|
|
@@ -537,13 +533,9 @@ export declare const codeBlockPlugin: (params?: {
|
|
|
537
533
|
* The default language to use when creating a new code block if no language is passed.
|
|
538
534
|
*/
|
|
539
535
|
defaultCodeBlockLanguage?: string | undefined;
|
|
540
|
-
/**
|
|
541
|
-
* The theme of CodeMirrorEditor
|
|
542
|
-
*/
|
|
543
|
-
theme?: SandpackThemeProp | undefined;
|
|
544
536
|
} | undefined) => RealmPlugin;
|
|
545
537
|
|
|
546
|
-
export declare const CodeMirrorEditor: ({ language, nodeKey, code, focusEmitter
|
|
538
|
+
export declare const CodeMirrorEditor: ({ language, nodeKey, code, focusEmitter }: CodeBlockEditorProps) => React_2.JSX.Element;
|
|
547
539
|
|
|
548
540
|
/**
|
|
549
541
|
* A plugin that adds lets users edit code blocks with CodeMirror.
|
|
@@ -551,8 +543,21 @@ export declare const CodeMirrorEditor: ({ language, nodeKey, code, focusEmitter,
|
|
|
551
543
|
*/
|
|
552
544
|
export declare const codeMirrorPlugin: (params?: {
|
|
553
545
|
codeBlockLanguages: Record<string, string>;
|
|
546
|
+
/**
|
|
547
|
+
* The theme of CodeMirrorEditor
|
|
548
|
+
*/
|
|
549
|
+
theme?: SandpackThemeProp | undefined;
|
|
554
550
|
} | undefined) => RealmPlugin;
|
|
555
551
|
|
|
552
|
+
/**
|
|
553
|
+
* The theme CodeMirrorEditor used.
|
|
554
|
+
* It can be "light" | "dark" | "auto",
|
|
555
|
+
* or the theme in "@codesandbox/sandpack-themes" package,
|
|
556
|
+
* or you can also custom one,
|
|
557
|
+
* learn more https://sandpack.codesandbox.io/docs/getting-started/themes#custom-theme
|
|
558
|
+
*/
|
|
559
|
+
export declare const codeMirrorTheme$: NodeRef<SandpackThemeProp>;
|
|
560
|
+
|
|
556
561
|
/**
|
|
557
562
|
* A toolbar component that lets the user toggle code formatting.
|
|
558
563
|
* Use for inline `code` elements (like variables, methods, etc).
|
|
@@ -2506,15 +2511,6 @@ export declare function tap<T>(arg: T, proc: (arg: T) => unknown): T;
|
|
|
2506
2511
|
*/
|
|
2507
2512
|
export declare const thematicBreakPlugin: (params?: unknown) => RealmPlugin;
|
|
2508
2513
|
|
|
2509
|
-
/**
|
|
2510
|
-
* The theme CodeMirrorEditor used.
|
|
2511
|
-
* It can be "light" | "dark" | "auto",
|
|
2512
|
-
* or the theme in "@codesandbox/sandpack-themes" package,
|
|
2513
|
-
* or you can also custom one,
|
|
2514
|
-
* learn more https://sandpack.codesandbox.io/docs/getting-started/themes#custom-theme
|
|
2515
|
-
*/
|
|
2516
|
-
export declare const theme$: NodeRef<SandpackThemeProp>;
|
|
2517
|
-
|
|
2518
2514
|
/**
|
|
2519
2515
|
* Takes a value and applies a function to it.
|
|
2520
2516
|
* @group Utils
|
package/dist/index.js
CHANGED
|
@@ -15,9 +15,9 @@ import { quotePlugin } from "./plugins/quote/index.js";
|
|
|
15
15
|
import { insertJsx$, isMdastJsxNode, jsxPlugin } from "./plugins/jsx/index.js";
|
|
16
16
|
import { GenericJsxEditor } from "./jsx-editors/GenericJsxEditor.js";
|
|
17
17
|
import { insertSandpack$, sandpackConfig$, sandpackPlugin } from "./plugins/sandpack/index.js";
|
|
18
|
-
import { codeBlockLanguages$, codeMirrorPlugin, insertCodeMirror$ } from "./plugins/codemirror/index.js";
|
|
18
|
+
import { codeBlockLanguages$, codeMirrorPlugin, codeMirrorTheme$, insertCodeMirror$ } from "./plugins/codemirror/index.js";
|
|
19
19
|
import { CodeMirrorEditor } from "./plugins/codemirror/CodeMirrorEditor.js";
|
|
20
|
-
import { appendCodeBlockEditorDescriptor$, codeBlockPlugin, defaultCodeBlockLanguage$, insertCodeBlock
|
|
20
|
+
import { appendCodeBlockEditorDescriptor$, codeBlockPlugin, defaultCodeBlockLanguage$, insertCodeBlock$ } 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";
|
|
@@ -164,6 +164,7 @@ export {
|
|
|
164
164
|
codeBlockLanguages$,
|
|
165
165
|
codeBlockPlugin,
|
|
166
166
|
codeMirrorPlugin,
|
|
167
|
+
codeMirrorTheme$,
|
|
167
168
|
compose,
|
|
168
169
|
composerChildren$,
|
|
169
170
|
contentEditableClassName$,
|
|
@@ -269,7 +270,6 @@ export {
|
|
|
269
270
|
tablePlugin,
|
|
270
271
|
tap,
|
|
271
272
|
thematicBreakPlugin,
|
|
272
|
-
theme$,
|
|
273
273
|
thrush,
|
|
274
274
|
toMarkdownExtensions$,
|
|
275
275
|
toMarkdownOptions$,
|
|
@@ -7,7 +7,6 @@ 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";
|
|
11
10
|
import { voidEmitter } from "../../utils/voidEmitter.js";
|
|
12
11
|
import { codeBlockEditorDescriptors$, NESTED_EDITOR_UPDATED_COMMAND } from "../core/index.js";
|
|
13
12
|
class CodeBlockNode extends DecoratorNode {
|
|
@@ -88,8 +87,7 @@ class CodeBlockNode extends DecoratorNode {
|
|
|
88
87
|
language: this.getLanguage(),
|
|
89
88
|
codeBlockNode: this,
|
|
90
89
|
nodeKey: this.getKey(),
|
|
91
|
-
focusEmitter: this.__focusEmitter
|
|
92
|
-
theme: "auto"
|
|
90
|
+
focusEmitter: this.__focusEmitter
|
|
93
91
|
}
|
|
94
92
|
);
|
|
95
93
|
}
|
|
@@ -142,7 +140,6 @@ const CodeBlockEditorContainer = (props) => {
|
|
|
142
140
|
}
|
|
143
141
|
const Editor = descriptor.Editor;
|
|
144
142
|
const { codeBlockNode: _, parentEditor: __, ...restProps } = props;
|
|
145
|
-
restProps.theme = useCellValue(theme$);
|
|
146
143
|
return /* @__PURE__ */ React__default.createElement(CodeBlockEditorContextProvider, { parentEditor: props.parentEditor, lexicalNode: props.codeBlockNode }, /* @__PURE__ */ React__default.createElement(Editor, { ...restProps }));
|
|
147
144
|
};
|
|
148
145
|
function $createCodeBlockNode(options) {
|
|
@@ -6,7 +6,6 @@ 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");
|
|
10
9
|
const insertCodeBlock$ = Signal((r) => {
|
|
11
10
|
r.link(
|
|
12
11
|
r.pipe(
|
|
@@ -23,7 +22,6 @@ const appendCodeBlockEditorDescriptor$ = Appender(codeBlockEditorDescriptors$);
|
|
|
23
22
|
const codeBlockPlugin = realmPlugin({
|
|
24
23
|
update(realm, params) {
|
|
25
24
|
realm.pub(defaultCodeBlockLanguage$, (params == null ? void 0 : params.defaultCodeBlockLanguage) || "");
|
|
26
|
-
realm.pub(theme$, (params == null ? void 0 : params.theme) || "auto");
|
|
27
25
|
},
|
|
28
26
|
init(realm, params) {
|
|
29
27
|
realm.pubIn({
|
|
@@ -43,6 +41,5 @@ export {
|
|
|
43
41
|
codeBlockPlugin,
|
|
44
42
|
defaultCodeBlockLanguage$,
|
|
45
43
|
insertCodeBlock$,
|
|
46
|
-
theme$,
|
|
47
44
|
useCodeBlockEditorContext
|
|
48
45
|
};
|
|
@@ -4,10 +4,11 @@ import styles from "../../styles/ui.module.css.js";
|
|
|
4
4
|
import { useCodeBlockEditorContext } from "../codeblock/CodeBlockNode.js";
|
|
5
5
|
import { readOnly$ } from "../core/index.js";
|
|
6
6
|
import { useCodeMirrorRef } from "../sandpack/useCodeMirrorRef.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import { useCellValues } from "@mdxeditor/gurx";
|
|
8
|
+
import { codeMirrorTheme$ } from "./index.js";
|
|
9
|
+
const CodeMirrorEditor = ({ language, nodeKey, code, focusEmitter }) => {
|
|
9
10
|
const codeMirrorRef = useCodeMirrorRef(nodeKey, "codeblock", "jsx", focusEmitter);
|
|
10
|
-
const readOnly =
|
|
11
|
+
const [readOnly, theme] = useCellValues(readOnly$, codeMirrorTheme$);
|
|
11
12
|
const { setCode } = useCodeBlockEditorContext();
|
|
12
13
|
React__default.useEffect(() => {
|
|
13
14
|
var _a, _b;
|
|
@@ -24,13 +24,18 @@ const insertCodeMirror$ = Signal((r) => {
|
|
|
24
24
|
insertCodeBlock$
|
|
25
25
|
);
|
|
26
26
|
});
|
|
27
|
+
const codeMirrorTheme$ = Cell("auto");
|
|
27
28
|
const codeMirrorPlugin = realmPlugin({
|
|
28
29
|
update(r, params) {
|
|
29
|
-
r.
|
|
30
|
+
r.pubIn({
|
|
31
|
+
[codeBlockLanguages$]: params == null ? void 0 : params.codeBlockLanguages,
|
|
32
|
+
[codeMirrorTheme$]: (params == null ? void 0 : params.theme) || "auto"
|
|
33
|
+
});
|
|
30
34
|
},
|
|
31
35
|
init(r, params) {
|
|
32
36
|
r.pubIn({
|
|
33
37
|
[codeBlockLanguages$]: params == null ? void 0 : params.codeBlockLanguages,
|
|
38
|
+
[codeMirrorTheme$]: (params == null ? void 0 : params.theme) || "auto",
|
|
34
39
|
[appendCodeBlockEditorDescriptor$]: buildCodeBlockDescriptor((params == null ? void 0 : params.codeBlockLanguages) || {})
|
|
35
40
|
});
|
|
36
41
|
}
|
|
@@ -47,5 +52,6 @@ function buildCodeBlockDescriptor(codeBlockLanguages) {
|
|
|
47
52
|
export {
|
|
48
53
|
codeBlockLanguages$,
|
|
49
54
|
codeMirrorPlugin,
|
|
55
|
+
codeMirrorTheme$,
|
|
50
56
|
insertCodeMirror$
|
|
51
57
|
};
|