@mdxeditor/editor 3.21.4 → 3.22.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/index.d.ts
CHANGED
|
@@ -1393,6 +1393,8 @@ export declare const inFocus$: NodeRef<boolean>;
|
|
|
1393
1393
|
|
|
1394
1394
|
/* Excluded from this release type: initialMarkdown$ */
|
|
1395
1395
|
|
|
1396
|
+
export declare const initialMarkdownNormalize$: NodeRef<boolean>;
|
|
1397
|
+
|
|
1396
1398
|
/* Excluded from this release type: INSERT_IMAGE_COMMAND */
|
|
1397
1399
|
|
|
1398
1400
|
/**
|
|
@@ -2073,7 +2075,7 @@ export declare interface MDXEditorProps {
|
|
|
2073
2075
|
*/
|
|
2074
2076
|
contentEditableClassName?: string;
|
|
2075
2077
|
/**
|
|
2076
|
-
* Controls the spellCheck value for the content editable element of the
|
|
2078
|
+
* Controls the spellCheck value for the content editable element of the editor.
|
|
2077
2079
|
* Defaults to true, use false to disable spell checking.
|
|
2078
2080
|
*/
|
|
2079
2081
|
spellCheck?: boolean;
|
|
@@ -2085,8 +2087,9 @@ export declare interface MDXEditorProps {
|
|
|
2085
2087
|
/**
|
|
2086
2088
|
* Triggered when the editor value changes. The callback is not throttled, you can use any throttling mechanism
|
|
2087
2089
|
* if you intend to do auto-saving.
|
|
2090
|
+
* @param initialMarkdownNormalize - set to true if the change is triggered when the initial markdown is set. This can happen due to variety of reasons - for example, additional whitespace, bullet symbols different than the configured ones, etc.
|
|
2088
2091
|
*/
|
|
2089
|
-
onChange?: (markdown: string) => void;
|
|
2092
|
+
onChange?: (markdown: string, initialMarkdownNormalize: boolean) => void;
|
|
2090
2093
|
/**
|
|
2091
2094
|
* Triggered when the markdown parser encounters an error. The payload includes the invalid source and the error message.
|
|
2092
2095
|
*/
|
|
@@ -2133,7 +2136,7 @@ export declare interface MDXEditorProps {
|
|
|
2133
2136
|
*/
|
|
2134
2137
|
iconComponentFor?: (name: IconKey) => JSX.Element;
|
|
2135
2138
|
/**
|
|
2136
|
-
* Set to
|
|
2139
|
+
* Set to true if you want to suppress the processing of HTML tags.
|
|
2137
2140
|
*/
|
|
2138
2141
|
suppressHtmlProcessing?: boolean;
|
|
2139
2142
|
/**
|
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$, contentEditableRef$, 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$, spellCheck$, 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$, contentEditableRef$, convertSelectionToNode$, corePlugin, createActiveEditorSubscription$, createRootEditorSubscription$, currentBlockType$, currentFormat$, currentSelection$, directiveDescriptors$, editorInFocus$, editorRootElementRef$, editorWrappers$, exportVisitors$, historyState$, iconComponentFor$, importVisitors$, inFocus$, initialMarkdown$, initialMarkdownNormalize$, insertDecoratorNode$, insertMarkdown$, jsxComponentDescriptors$, jsxIsAvailable$, lexicalTheme$, markdown$, markdownErrorSignal$, markdownProcessingError$, markdownSourceEditorValue$, mdastExtensions$, muteChange$, nestedEditorChildren$, onBlur$, placeholder$, readOnly$, rootEditor$, rootEditorSubscriptions$, setMarkdown$, spellCheck$, 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";
|
|
@@ -237,6 +237,7 @@ export {
|
|
|
237
237
|
importVisitors$,
|
|
238
238
|
inFocus$,
|
|
239
239
|
initialMarkdown$,
|
|
240
|
+
initialMarkdownNormalize$,
|
|
240
241
|
insertCodeBlock$,
|
|
241
242
|
insertCodeMirror$,
|
|
242
243
|
insertDecoratorNode$,
|
|
@@ -81,9 +81,15 @@ const currentSelection$ = Cell(null, (r) => {
|
|
|
81
81
|
});
|
|
82
82
|
const initialMarkdown$ = Cell("");
|
|
83
83
|
const markdown$ = Cell("");
|
|
84
|
+
const initialMarkdownNormalize$ = Cell(false);
|
|
84
85
|
const markdownSignal$ = Signal((r) => {
|
|
85
86
|
r.link(markdown$, markdownSignal$);
|
|
86
|
-
r.
|
|
87
|
+
r.sub(initialMarkdown$, (md) => {
|
|
88
|
+
r.pubIn({
|
|
89
|
+
[initialMarkdownNormalize$]: true,
|
|
90
|
+
[markdown$]: md
|
|
91
|
+
});
|
|
92
|
+
});
|
|
87
93
|
});
|
|
88
94
|
const mutableMarkdownSignal$ = Signal((r) => {
|
|
89
95
|
r.link(
|
|
@@ -274,6 +280,7 @@ const createRootEditorSubscription$ = Appender(rootEditorSubscriptions$, (r, sig
|
|
|
274
280
|
});
|
|
275
281
|
});
|
|
276
282
|
r.pub(markdown$, theNewMarkdownValue.trim());
|
|
283
|
+
r.pub(initialMarkdownNormalize$, false);
|
|
277
284
|
});
|
|
278
285
|
},
|
|
279
286
|
(rootEditor) => {
|
|
@@ -508,7 +515,9 @@ const corePlugin = realmPlugin({
|
|
|
508
515
|
[lexicalTheme$]: (params == null ? void 0 : params.lexicalTheme) ?? lexicalTheme
|
|
509
516
|
});
|
|
510
517
|
r.singletonSub(markdownErrorSignal$, params == null ? void 0 : params.onError);
|
|
511
|
-
r.singletonSub(mutableMarkdownSignal$,
|
|
518
|
+
r.singletonSub(mutableMarkdownSignal$, (value) => {
|
|
519
|
+
params == null ? void 0 : params.onChange(value, r.getValue(initialMarkdownNormalize$));
|
|
520
|
+
});
|
|
512
521
|
r.singletonSub(onBlur$, params == null ? void 0 : params.onBlur);
|
|
513
522
|
if (!(params == null ? void 0 : params.suppressHtmlProcessing)) {
|
|
514
523
|
r.pubIn({
|
|
@@ -558,7 +567,9 @@ const corePlugin = realmPlugin({
|
|
|
558
567
|
[placeholder$]: params == null ? void 0 : params.placeholder,
|
|
559
568
|
[readOnly$]: params == null ? void 0 : params.readOnly
|
|
560
569
|
});
|
|
561
|
-
realm.singletonSub(mutableMarkdownSignal$,
|
|
570
|
+
realm.singletonSub(mutableMarkdownSignal$, (value) => {
|
|
571
|
+
params == null ? void 0 : params.onChange(value, realm.getValue(initialMarkdownNormalize$));
|
|
572
|
+
});
|
|
562
573
|
realm.singletonSub(onBlur$, params == null ? void 0 : params.onBlur);
|
|
563
574
|
realm.singletonSub(markdownErrorSignal$, params == null ? void 0 : params.onError);
|
|
564
575
|
}
|
|
@@ -611,6 +622,7 @@ export {
|
|
|
611
622
|
importVisitors$,
|
|
612
623
|
inFocus$,
|
|
613
624
|
initialMarkdown$,
|
|
625
|
+
initialMarkdownNormalize$,
|
|
614
626
|
insertDecoratorNode$,
|
|
615
627
|
insertMarkdown$,
|
|
616
628
|
jsxComponentDescriptors$,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $isListItemNode, $isListNode } from "@lexical/list";
|
|
2
|
-
import { $isTextNode } from "lexical";
|
|
2
|
+
import { $isTextNode, $isElementNode } from "lexical";
|
|
3
3
|
const LexicalListItemVisitor = {
|
|
4
4
|
testLexicalNode: $isListItemNode,
|
|
5
5
|
visitLexicalNode: ({ lexicalNode, mdastParent, actions }) => {
|
|
@@ -22,7 +22,7 @@ const LexicalListItemVisitor = {
|
|
|
22
22
|
});
|
|
23
23
|
let surroundingParagraph = null;
|
|
24
24
|
for (const child of lexicalNode.getChildren()) {
|
|
25
|
-
if ($isTextNode(child)) {
|
|
25
|
+
if ($isTextNode(child) || $isElementNode(child) && child.isInline()) {
|
|
26
26
|
if (!surroundingParagraph) {
|
|
27
27
|
surroundingParagraph = actions.appendToParent(listItem, {
|
|
28
28
|
type: "paragraph",
|