@mdxeditor/editor 3.17.4 → 3.19.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 +13 -6
- package/dist/index.d.ts +17 -0
- package/dist/index.js +3 -1
- package/dist/plugins/core/index.js +6 -0
- package/package.json +1 -1
package/dist/MDXEditor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useCellValue,
|
|
1
|
+
import { useCellValue, usePublisher, useCellValues, useRealm } from "@mdxeditor/gurx";
|
|
2
2
|
import React__default from "react";
|
|
3
3
|
import { RealmWithPlugins } from "./RealmWithPlugins.js";
|
|
4
|
-
import { corePlugin, rootEditor$, useTranslation, contentEditableClassName$, composerChildren$, topAreaChildren$, editorWrappers$, placeholder$, editorRootElementRef$, viewMode$, markdownSourceEditorValue$, markdown$, setMarkdown$, insertMarkdown$ } from "./plugins/core/index.js";
|
|
4
|
+
import { corePlugin, rootEditor$, useTranslation, contentEditableRef$, contentEditableClassName$, spellCheck$, composerChildren$, topAreaChildren$, editorWrappers$, placeholder$, editorRootElementRef$, viewMode$, markdownSourceEditorValue$, markdown$, setMarkdown$, insertMarkdown$ } from "./plugins/core/index.js";
|
|
5
5
|
import { ContentEditable } from "@lexical/react/LexicalContentEditable.js";
|
|
6
6
|
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary.js";
|
|
7
7
|
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin.js";
|
|
@@ -20,8 +20,13 @@ const LexicalProvider = ({ children }) => {
|
|
|
20
20
|
};
|
|
21
21
|
const RichTextEditor = () => {
|
|
22
22
|
const t = useTranslation();
|
|
23
|
-
const
|
|
23
|
+
const setContentEditableRef = usePublisher(contentEditableRef$);
|
|
24
|
+
const onRef = (_contentEditableRef) => {
|
|
25
|
+
setContentEditableRef({ current: _contentEditableRef });
|
|
26
|
+
};
|
|
27
|
+
const [contentEditableClassName, spellCheck, composerChildren, topAreaChildren, editorWrappers, placeholder] = useCellValues(
|
|
24
28
|
contentEditableClassName$,
|
|
29
|
+
spellCheck$,
|
|
25
30
|
composerChildren$,
|
|
26
31
|
topAreaChildren$,
|
|
27
32
|
editorWrappers$,
|
|
@@ -30,13 +35,14 @@ const RichTextEditor = () => {
|
|
|
30
35
|
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, "mdxeditor-root-contenteditable") }, /* @__PURE__ */ React__default.createElement(
|
|
31
36
|
RichTextPlugin,
|
|
32
37
|
{
|
|
33
|
-
contentEditable: /* @__PURE__ */ React__default.createElement(
|
|
38
|
+
contentEditable: /* @__PURE__ */ React__default.createElement("div", { ref: onRef }, /* @__PURE__ */ React__default.createElement(
|
|
34
39
|
ContentEditable,
|
|
35
40
|
{
|
|
36
41
|
className: classNames(styles.contentEditable, contentEditableClassName),
|
|
37
|
-
ariaLabel: t("contentArea.editableMarkdown", "editable markdown")
|
|
42
|
+
ariaLabel: t("contentArea.editableMarkdown", "editable markdown"),
|
|
43
|
+
spellCheck
|
|
38
44
|
}
|
|
39
|
-
),
|
|
45
|
+
)),
|
|
40
46
|
placeholder: /* @__PURE__ */ React__default.createElement("div", { className: classNames(styles.contentEditable, styles.placeholder, contentEditableClassName) }, /* @__PURE__ */ React__default.createElement("p", null, placeholder)),
|
|
41
47
|
ErrorBoundary: LexicalErrorBoundary
|
|
42
48
|
}
|
|
@@ -117,6 +123,7 @@ const MDXEditor = React__default.forwardRef((props, ref) => {
|
|
|
117
123
|
plugins: [
|
|
118
124
|
corePlugin({
|
|
119
125
|
contentEditableClassName: props.contentEditableClassName ?? "",
|
|
126
|
+
spellCheck: props.spellCheck ?? true,
|
|
120
127
|
initialMarkdown: props.markdown,
|
|
121
128
|
onChange: props.onChange ?? noop,
|
|
122
129
|
onBlur: props.onBlur ?? noop,
|
package/dist/index.d.ts
CHANGED
|
@@ -632,6 +632,12 @@ export declare interface ConditionalContentsOption {
|
|
|
632
632
|
*/
|
|
633
633
|
export declare const contentEditableClassName$: NodeRef<string>;
|
|
634
634
|
|
|
635
|
+
/**
|
|
636
|
+
* A reference to the content editable element.
|
|
637
|
+
* @group Core
|
|
638
|
+
*/
|
|
639
|
+
export declare const contentEditableRef$: NodeRef<default_2.RefObject<HTMLDivElement> | null>;
|
|
640
|
+
|
|
635
641
|
/**
|
|
636
642
|
* Returns true if the user is pressing the control key on Windows or the meta key on Mac.
|
|
637
643
|
* @group Utils
|
|
@@ -2057,6 +2063,11 @@ export declare interface MDXEditorProps {
|
|
|
2057
2063
|
* Use this to style the various content elements like lists and blockquotes.
|
|
2058
2064
|
*/
|
|
2059
2065
|
contentEditableClassName?: string;
|
|
2066
|
+
/**
|
|
2067
|
+
* Controls the spellCheck value for the content editable element of the eitor.
|
|
2068
|
+
* Defaults to true, use false to disable spell checking.
|
|
2069
|
+
*/
|
|
2070
|
+
spellCheck?: boolean;
|
|
2060
2071
|
/**
|
|
2061
2072
|
* The markdown to edit. Notice that this is read only when the component is mounted.
|
|
2062
2073
|
* To change the component content dynamically, use the `MDXEditorMethods.setMarkdown` method.
|
|
@@ -2607,6 +2618,12 @@ export declare const SingleChoiceToggleGroup: <T extends string>({ value, onChan
|
|
|
2607
2618
|
|
|
2608
2619
|
/* Excluded from this release type: SingleToggleGroup */
|
|
2609
2620
|
|
|
2621
|
+
/**
|
|
2622
|
+
* Holds the spellcheck value of the content editable element.
|
|
2623
|
+
* @group Core
|
|
2624
|
+
*/
|
|
2625
|
+
export declare const spellCheck$: NodeRef<boolean>;
|
|
2626
|
+
|
|
2610
2627
|
/**
|
|
2611
2628
|
* @group Image
|
|
2612
2629
|
*/
|
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$, 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$, 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$, 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";
|
|
@@ -189,6 +189,7 @@ export {
|
|
|
189
189
|
compose,
|
|
190
190
|
composerChildren$,
|
|
191
191
|
contentEditableClassName$,
|
|
192
|
+
contentEditableRef$,
|
|
192
193
|
controlOrMeta,
|
|
193
194
|
convertSelectionToNode$,
|
|
194
195
|
corePlugin,
|
|
@@ -292,6 +293,7 @@ export {
|
|
|
292
293
|
sandpackPlugin,
|
|
293
294
|
saveImage$,
|
|
294
295
|
setMarkdown$,
|
|
296
|
+
spellCheck$,
|
|
295
297
|
switchFromPreviewToLinkEdit$,
|
|
296
298
|
syntaxExtensions$,
|
|
297
299
|
tablePlugin,
|
|
@@ -33,6 +33,7 @@ const NESTED_EDITOR_UPDATED_COMMAND = createCommand("NESTED_EDITOR_UPDATED_COMMA
|
|
|
33
33
|
const rootEditor$ = Cell(null);
|
|
34
34
|
const activeEditor$ = Cell(null);
|
|
35
35
|
const contentEditableClassName$ = Cell("");
|
|
36
|
+
const spellCheck$ = Cell(true);
|
|
36
37
|
const readOnly$ = Cell(false, (r) => {
|
|
37
38
|
r.sub(r.pipe(readOnly$, withLatestFrom(rootEditor$)), ([readOnly, rootEditor]) => {
|
|
38
39
|
rootEditor == null ? void 0 : rootEditor.setEditable(!readOnly);
|
|
@@ -107,6 +108,7 @@ const jsxComponentDescriptors$ = Cell([]);
|
|
|
107
108
|
const directiveDescriptors$ = Cell([]);
|
|
108
109
|
const codeBlockEditorDescriptors$ = Cell([]);
|
|
109
110
|
const editorRootElementRef$ = Cell(null);
|
|
111
|
+
const contentEditableRef$ = Cell(null);
|
|
110
112
|
const addLexicalNode$ = Appender(usedLexicalNodes$);
|
|
111
113
|
const addImportVisitor$ = Appender(importVisitors$);
|
|
112
114
|
const addSyntaxExtension$ = Appender(syntaxExtensions$);
|
|
@@ -494,6 +496,7 @@ const corePlugin = realmPlugin({
|
|
|
494
496
|
],
|
|
495
497
|
[addComposerChild$]: SharedHistoryPlugin,
|
|
496
498
|
[contentEditableClassName$]: params == null ? void 0 : params.contentEditableClassName,
|
|
499
|
+
[spellCheck$]: params == null ? void 0 : params.spellCheck,
|
|
497
500
|
[toMarkdownOptions$]: params == null ? void 0 : params.toMarkdownOptions,
|
|
498
501
|
[autoFocus$]: params == null ? void 0 : params.autoFocus,
|
|
499
502
|
[placeholder$]: params == null ? void 0 : params.placeholder,
|
|
@@ -549,6 +552,7 @@ const corePlugin = realmPlugin({
|
|
|
549
552
|
update(realm, params) {
|
|
550
553
|
realm.pubIn({
|
|
551
554
|
[contentEditableClassName$]: params == null ? void 0 : params.contentEditableClassName,
|
|
555
|
+
[spellCheck$]: params == null ? void 0 : params.spellCheck,
|
|
552
556
|
[toMarkdownOptions$]: params == null ? void 0 : params.toMarkdownOptions,
|
|
553
557
|
[autoFocus$]: params == null ? void 0 : params.autoFocus,
|
|
554
558
|
[placeholder$]: params == null ? void 0 : params.placeholder,
|
|
@@ -589,6 +593,7 @@ export {
|
|
|
589
593
|
codeBlockEditorDescriptors$,
|
|
590
594
|
composerChildren$,
|
|
591
595
|
contentEditableClassName$,
|
|
596
|
+
contentEditableRef$,
|
|
592
597
|
convertSelectionToNode$,
|
|
593
598
|
corePlugin,
|
|
594
599
|
createActiveEditorSubscription$,
|
|
@@ -624,6 +629,7 @@ export {
|
|
|
624
629
|
rootEditor$,
|
|
625
630
|
rootEditorSubscriptions$,
|
|
626
631
|
setMarkdown$,
|
|
632
|
+
spellCheck$,
|
|
627
633
|
syntaxExtensions$,
|
|
628
634
|
toMarkdownExtensions$,
|
|
629
635
|
toMarkdownOptions$,
|