@mdxeditor/editor 3.17.3 → 3.18.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 +6 -3
- package/dist/index.d.ts +11 -0
- package/dist/index.js +2 -1
- package/dist/plugins/core/index.js +4 -0
- package/dist/plugins/frontmatter/index.js +4 -1
- package/package.json +1 -1
package/dist/MDXEditor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCellValue, useCellValues, usePublisher, 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, 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,9 @@ const LexicalProvider = ({ children }) => {
|
|
|
20
20
|
};
|
|
21
21
|
const RichTextEditor = () => {
|
|
22
22
|
const t = useTranslation();
|
|
23
|
-
const [contentEditableClassName, composerChildren, topAreaChildren, editorWrappers, placeholder] = useCellValues(
|
|
23
|
+
const [contentEditableClassName, spellCheck, composerChildren, topAreaChildren, editorWrappers, placeholder] = useCellValues(
|
|
24
24
|
contentEditableClassName$,
|
|
25
|
+
spellCheck$,
|
|
25
26
|
composerChildren$,
|
|
26
27
|
topAreaChildren$,
|
|
27
28
|
editorWrappers$,
|
|
@@ -34,7 +35,8 @@ const RichTextEditor = () => {
|
|
|
34
35
|
ContentEditable,
|
|
35
36
|
{
|
|
36
37
|
className: classNames(styles.contentEditable, contentEditableClassName),
|
|
37
|
-
ariaLabel: t("contentArea.editableMarkdown", "editable markdown")
|
|
38
|
+
ariaLabel: t("contentArea.editableMarkdown", "editable markdown"),
|
|
39
|
+
spellCheck
|
|
38
40
|
}
|
|
39
41
|
),
|
|
40
42
|
placeholder: /* @__PURE__ */ React__default.createElement("div", { className: classNames(styles.contentEditable, styles.placeholder, contentEditableClassName) }, /* @__PURE__ */ React__default.createElement("p", null, placeholder)),
|
|
@@ -117,6 +119,7 @@ const MDXEditor = React__default.forwardRef((props, ref) => {
|
|
|
117
119
|
plugins: [
|
|
118
120
|
corePlugin({
|
|
119
121
|
contentEditableClassName: props.contentEditableClassName ?? "",
|
|
122
|
+
spellCheck: props.spellCheck ?? true,
|
|
120
123
|
initialMarkdown: props.markdown,
|
|
121
124
|
onChange: props.onChange ?? noop,
|
|
122
125
|
onBlur: props.onBlur ?? noop,
|
package/dist/index.d.ts
CHANGED
|
@@ -2057,6 +2057,11 @@ export declare interface MDXEditorProps {
|
|
|
2057
2057
|
* Use this to style the various content elements like lists and blockquotes.
|
|
2058
2058
|
*/
|
|
2059
2059
|
contentEditableClassName?: string;
|
|
2060
|
+
/**
|
|
2061
|
+
* Controls the spellCheck value for the content editable element of the eitor.
|
|
2062
|
+
* Defaults to true, use false to disable spell checking.
|
|
2063
|
+
*/
|
|
2064
|
+
spellCheck?: boolean;
|
|
2060
2065
|
/**
|
|
2061
2066
|
* The markdown to edit. Notice that this is read only when the component is mounted.
|
|
2062
2067
|
* To change the component content dynamically, use the `MDXEditorMethods.setMarkdown` method.
|
|
@@ -2607,6 +2612,12 @@ export declare const SingleChoiceToggleGroup: <T extends string>({ value, onChan
|
|
|
2607
2612
|
|
|
2608
2613
|
/* Excluded from this release type: SingleToggleGroup */
|
|
2609
2614
|
|
|
2615
|
+
/**
|
|
2616
|
+
* Holds the spellcheck value of the content editable element.
|
|
2617
|
+
* @group Core
|
|
2618
|
+
*/
|
|
2619
|
+
export declare const spellCheck$: NodeRef<boolean>;
|
|
2620
|
+
|
|
2610
2621
|
/**
|
|
2611
2622
|
* @group Image
|
|
2612
2623
|
*/
|
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$, 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";
|
|
@@ -292,6 +292,7 @@ export {
|
|
|
292
292
|
sandpackPlugin,
|
|
293
293
|
saveImage$,
|
|
294
294
|
setMarkdown$,
|
|
295
|
+
spellCheck$,
|
|
295
296
|
switchFromPreviewToLinkEdit$,
|
|
296
297
|
syntaxExtensions$,
|
|
297
298
|
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);
|
|
@@ -494,6 +495,7 @@ const corePlugin = realmPlugin({
|
|
|
494
495
|
],
|
|
495
496
|
[addComposerChild$]: SharedHistoryPlugin,
|
|
496
497
|
[contentEditableClassName$]: params == null ? void 0 : params.contentEditableClassName,
|
|
498
|
+
[spellCheck$]: params == null ? void 0 : params.spellCheck,
|
|
497
499
|
[toMarkdownOptions$]: params == null ? void 0 : params.toMarkdownOptions,
|
|
498
500
|
[autoFocus$]: params == null ? void 0 : params.autoFocus,
|
|
499
501
|
[placeholder$]: params == null ? void 0 : params.placeholder,
|
|
@@ -549,6 +551,7 @@ const corePlugin = realmPlugin({
|
|
|
549
551
|
update(realm, params) {
|
|
550
552
|
realm.pubIn({
|
|
551
553
|
[contentEditableClassName$]: params == null ? void 0 : params.contentEditableClassName,
|
|
554
|
+
[spellCheck$]: params == null ? void 0 : params.spellCheck,
|
|
552
555
|
[toMarkdownOptions$]: params == null ? void 0 : params.toMarkdownOptions,
|
|
553
556
|
[autoFocus$]: params == null ? void 0 : params.autoFocus,
|
|
554
557
|
[placeholder$]: params == null ? void 0 : params.placeholder,
|
|
@@ -624,6 +627,7 @@ export {
|
|
|
624
627
|
rootEditor$,
|
|
625
628
|
rootEditorSubscriptions$,
|
|
626
629
|
setMarkdown$,
|
|
630
|
+
spellCheck$,
|
|
627
631
|
syntaxExtensions$,
|
|
628
632
|
toMarkdownExtensions$,
|
|
629
633
|
toMarkdownOptions$,
|
|
@@ -78,7 +78,10 @@ const frontmatterPlugin = realmPlugin({
|
|
|
78
78
|
setTimeout(() => {
|
|
79
79
|
editor.update(
|
|
80
80
|
() => {
|
|
81
|
-
$getRoot().
|
|
81
|
+
const firstItem = $getRoot().getFirstChild();
|
|
82
|
+
if (!$isFrontmatterNode(firstItem)) {
|
|
83
|
+
$getRoot().splice(0, 0, [$createFrontmatterNode(yaml)]);
|
|
84
|
+
}
|
|
82
85
|
},
|
|
83
86
|
{ discrete: true }
|
|
84
87
|
);
|