@mdxeditor/editor 2.8.0 → 2.8.2
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/index.d.ts
CHANGED
|
@@ -2006,6 +2006,8 @@ export declare const MultipleChoiceToggleGroup: React_2.FC<{
|
|
|
2006
2006
|
}[];
|
|
2007
2007
|
}>;
|
|
2008
2008
|
|
|
2009
|
+
export declare const muteChange$: NodeRef<boolean>;
|
|
2010
|
+
|
|
2009
2011
|
/* Excluded from this release type: NESTED_EDITOR_UPDATED_COMMAND */
|
|
2010
2012
|
|
|
2011
2013
|
/* Excluded from this release type: nestedEditorChildren$ */
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export * from "@mdxeditor/gurx";
|
|
|
3
3
|
import { MDXEditor } from "./MDXEditor.js";
|
|
4
4
|
import { MarkdownParseError, UnrecognizedMarkdownConstructError, importMarkdownToLexical, importMdastTreeToLexical } from "./importMarkdownToLexical.js";
|
|
5
5
|
import { exportLexicalTreeToMdast, exportMarkdownFromLexical } from "./exportMarkdownFromLexical.js";
|
|
6
|
-
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$, initialRootEditorState$, insertDecoratorNode$, insertMarkdown$, jsxComponentDescriptors$, jsxIsAvailable$, markdown$, markdownErrorSignal$, markdownProcessingError$, markdownSourceEditorValue$, mdastExtensions$, nestedEditorChildren$, onBlur$, placeholder$, readOnly$, rootEditor$, rootEditorSubscriptions$, setMarkdown$, syntaxExtensions$, toMarkdownExtensions$, toMarkdownOptions$, topAreaChildren$, usedLexicalNodes$, viewMode$ } from "./plugins/core/index.js";
|
|
6
|
+
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$, initialRootEditorState$, insertDecoratorNode$, insertMarkdown$, jsxComponentDescriptors$, jsxIsAvailable$, markdown$, markdownErrorSignal$, markdownProcessingError$, markdownSourceEditorValue$, mdastExtensions$, muteChange$, nestedEditorChildren$, onBlur$, placeholder$, readOnly$, rootEditor$, rootEditorSubscriptions$, setMarkdown$, syntaxExtensions$, toMarkdownExtensions$, toMarkdownOptions$, topAreaChildren$, usedLexicalNodes$, viewMode$ } from "./plugins/core/index.js";
|
|
7
7
|
import { ALL_HEADING_LEVELS, allowedHeadingLevels$, headingsPlugin } from "./plugins/headings/index.js";
|
|
8
8
|
import { insertThematicBreak$, thematicBreakPlugin } from "./plugins/thematic-break/index.js";
|
|
9
9
|
import { applyListType$, currentListType$, listsPlugin } from "./plugins/lists/index.js";
|
|
@@ -246,6 +246,7 @@ export {
|
|
|
246
246
|
markdownSourceEditorValue$,
|
|
247
247
|
maxLengthPlugin,
|
|
248
248
|
mdastExtensions$,
|
|
249
|
+
muteChange$,
|
|
249
250
|
nestedEditorChildren$,
|
|
250
251
|
noop,
|
|
251
252
|
onBlur$,
|
|
@@ -3,7 +3,7 @@ import { createEmptyHistoryState } from "@lexical/react/LexicalHistoryPlugin.js"
|
|
|
3
3
|
import { $isHeadingNode } from "@lexical/rich-text";
|
|
4
4
|
import { $setBlocksType } from "@lexical/selection";
|
|
5
5
|
import { $findMatchingParent, $wrapNodeInElement, $insertNodeToNearestRoot } from "@lexical/utils";
|
|
6
|
-
import { Cell, withLatestFrom, Signal, filter, scan } from "@mdxeditor/gurx";
|
|
6
|
+
import { Cell, withLatestFrom, Signal, filter, map, scan } from "@mdxeditor/gurx";
|
|
7
7
|
import { createCommand, FORMAT_TEXT_COMMAND, $isRootOrShadowRoot, $getRoot, $setSelection, $getSelection, $insertNodes, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_CRITICAL, FOCUS_COMMAND, KEY_DOWN_COMMAND, $isDecoratorNode, BLUR_COMMAND, $isRangeSelection, $createParagraphNode, ParagraphNode, TextNode } from "lexical";
|
|
8
8
|
import { mdxJsxFromMarkdown, mdxJsxToMarkdown } from "mdast-util-mdx-jsx";
|
|
9
9
|
import { mdxJsx } from "micromark-extension-mdx-jsx";
|
|
@@ -83,6 +83,17 @@ const markdownSignal$ = Signal((r) => {
|
|
|
83
83
|
r.link(markdown$, markdownSignal$);
|
|
84
84
|
r.link(initialMarkdown$, markdown$);
|
|
85
85
|
});
|
|
86
|
+
const mutableMarkdownSignal$ = Signal((r) => {
|
|
87
|
+
r.link(
|
|
88
|
+
r.pipe(
|
|
89
|
+
markdownSignal$,
|
|
90
|
+
withLatestFrom(muteChange$),
|
|
91
|
+
filter(([, muted]) => !muted),
|
|
92
|
+
map(([value]) => value)
|
|
93
|
+
),
|
|
94
|
+
mutableMarkdownSignal$
|
|
95
|
+
);
|
|
96
|
+
});
|
|
86
97
|
const importVisitors$ = Cell([]);
|
|
87
98
|
const syntaxExtensions$ = Cell([]);
|
|
88
99
|
const mdastExtensions$ = Cell([]);
|
|
@@ -101,6 +112,7 @@ const addSyntaxExtension$ = Appender(syntaxExtensions$);
|
|
|
101
112
|
const addMdastExtension$ = Appender(mdastExtensions$);
|
|
102
113
|
const addExportVisitor$ = Appender(exportVisitors$);
|
|
103
114
|
const addToMarkdownExtension$ = Appender(toMarkdownExtensions$);
|
|
115
|
+
const muteChange$ = Cell(false);
|
|
104
116
|
const setMarkdown$ = Signal((r) => {
|
|
105
117
|
r.sub(
|
|
106
118
|
r.pipe(
|
|
@@ -111,15 +123,21 @@ const setMarkdown$ = Signal((r) => {
|
|
|
111
123
|
})
|
|
112
124
|
),
|
|
113
125
|
([theNewMarkdownValue, , editor, inFocus]) => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
$
|
|
119
|
-
|
|
120
|
-
|
|
126
|
+
r.pub(muteChange$, true);
|
|
127
|
+
editor == null ? void 0 : editor.update(
|
|
128
|
+
() => {
|
|
129
|
+
$getRoot().clear();
|
|
130
|
+
tryImportingMarkdown(r, $getRoot(), theNewMarkdownValue);
|
|
131
|
+
if (!inFocus) {
|
|
132
|
+
$setSelection(null);
|
|
133
|
+
} else {
|
|
134
|
+
editor.focus();
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
onUpdate: () => r.pub(muteChange$, false)
|
|
121
139
|
}
|
|
122
|
-
|
|
140
|
+
);
|
|
123
141
|
}
|
|
124
142
|
);
|
|
125
143
|
});
|
|
@@ -504,7 +522,7 @@ const corePlugin = realmPlugin({
|
|
|
504
522
|
[placeholder$]: params == null ? void 0 : params.placeholder,
|
|
505
523
|
[readOnly$]: params == null ? void 0 : params.readOnly
|
|
506
524
|
});
|
|
507
|
-
realm.singletonSub(
|
|
525
|
+
realm.singletonSub(mutableMarkdownSignal$, params == null ? void 0 : params.onChange);
|
|
508
526
|
realm.singletonSub(onBlur$, params == null ? void 0 : params.onBlur);
|
|
509
527
|
realm.singletonSub(markdownErrorSignal$, params == null ? void 0 : params.onError);
|
|
510
528
|
}
|
|
@@ -563,6 +581,7 @@ export {
|
|
|
563
581
|
markdownProcessingError$,
|
|
564
582
|
markdownSourceEditorValue$,
|
|
565
583
|
mdastExtensions$,
|
|
584
|
+
muteChange$,
|
|
566
585
|
nestedEditorChildren$,
|
|
567
586
|
onBlur$,
|
|
568
587
|
placeholder$,
|
|
@@ -4,16 +4,21 @@ import styles from "../../../styles/ui.module.css.js";
|
|
|
4
4
|
import { codeBlockLanguages$ } from "../../codemirror/index.js";
|
|
5
5
|
import { editorInFocus$, activeEditor$ } from "../../core/index.js";
|
|
6
6
|
import { Select } from "../primitives/select.js";
|
|
7
|
+
const EMPTY_VALUE = "__EMPTY_VALUE__";
|
|
7
8
|
const ChangeCodeMirrorLanguage = () => {
|
|
8
9
|
const [editorInFocus, theEditor, codeBlockLanguages] = useCellValues(editorInFocus$, activeEditor$, codeBlockLanguages$);
|
|
9
10
|
const codeBlockNode = editorInFocus.rootNode;
|
|
11
|
+
let currentLanguage = codeBlockNode.getLanguage();
|
|
12
|
+
if (currentLanguage === "") {
|
|
13
|
+
currentLanguage = EMPTY_VALUE;
|
|
14
|
+
}
|
|
10
15
|
return /* @__PURE__ */ React__default.createElement("div", { className: styles.selectWithLabel }, /* @__PURE__ */ React__default.createElement("label", null, "Code block language:"), /* @__PURE__ */ React__default.createElement(
|
|
11
16
|
Select,
|
|
12
17
|
{
|
|
13
|
-
value:
|
|
18
|
+
value: currentLanguage,
|
|
14
19
|
onChange: (language) => {
|
|
15
20
|
theEditor == null ? void 0 : theEditor.update(() => {
|
|
16
|
-
codeBlockNode.setLanguage(language);
|
|
21
|
+
codeBlockNode.setLanguage(language === EMPTY_VALUE ? "" : language);
|
|
17
22
|
setTimeout(() => {
|
|
18
23
|
theEditor == null ? void 0 : theEditor.update(() => {
|
|
19
24
|
codeBlockNode.getLatest().select();
|
|
@@ -23,7 +28,7 @@ const ChangeCodeMirrorLanguage = () => {
|
|
|
23
28
|
},
|
|
24
29
|
triggerTitle: "Select code block language",
|
|
25
30
|
placeholder: "Code block language",
|
|
26
|
-
items: Object.entries(codeBlockLanguages).map(([value, label]) => ({ value, label }))
|
|
31
|
+
items: Object.entries(codeBlockLanguages).map(([value, label]) => ({ value: value ? value : EMPTY_VALUE, label }))
|
|
27
32
|
}
|
|
28
33
|
));
|
|
29
34
|
};
|