@mdxeditor/editor 0.22.3 → 0.22.5

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.
@@ -48,7 +48,7 @@ export interface MDXEditorProps {
48
48
  placeholder?: React.ReactNode;
49
49
  /**
50
50
  * pass if you would like to have the editor in read-only mode.
51
- * Note: Don't use this mode to render content for consumption - reander the markdown using a library of your choice instead.
51
+ * Note: Don't use this mode to render content for consumption - render the markdown using a library of your choice instead.
52
52
  */
53
53
  readOnly?: boolean;
54
54
  }
package/dist/MDXEditor.js CHANGED
@@ -8,7 +8,7 @@ import { ContentEditable } from "@lexical/react/LexicalContentEditable.js";
8
8
  import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary.js";
9
9
  import classNames from "classnames";
10
10
  import { noop } from "./utils/fp.js";
11
- import { RealmPluginInitializer } from "./gurx/react.js";
11
+ import { RealmPluginInitializer, useHasPlugin } from "./gurx/react.js";
12
12
  const LexicalProvider = ({ children }) => {
13
13
  const [initialRootEditorState, nodes, readOnly] = corePluginHooks.useEmitterValues(
14
14
  "initialRootEditorState",
@@ -79,11 +79,17 @@ const EditorRootElement = ({ children, className }) => {
79
79
  };
80
80
  const Methods = ({ mdxRef }) => {
81
81
  const realm = corePluginHooks.useRealmContext();
82
+ const hasDiffSourcePlugin = useHasPlugin("diff-source");
82
83
  React__default.useImperativeHandle(
83
84
  mdxRef,
84
85
  () => {
85
86
  return {
86
87
  getMarkdown: () => {
88
+ if (hasDiffSourcePlugin) {
89
+ if (realm.getKeyValue("viewMode") === "source") {
90
+ return realm.getKeyValue("markdownSourceEditorValue");
91
+ }
92
+ }
87
93
  return realm.getKeyValue("markdown");
88
94
  },
89
95
  setMarkdown: (markdown) => {
@@ -95,7 +101,7 @@ const Methods = ({ mdxRef }) => {
95
101
  }
96
102
  };
97
103
  },
98
- [realm]
104
+ [realm, hasDiffSourcePlugin]
99
105
  );
100
106
  return null;
101
107
  };
@@ -296,7 +296,7 @@ diffSourcePluginHooks: {
296
296
  insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
297
297
  onBlur: RealmNode<FocusEvent>;
298
298
  }>;
299
- useEmitter: <K extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "placeholder" | "autoFocus" | "readOnly" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "onBlur" | "viewMode" | "diffMarkdown" | "markdownSourceEditorValue">(key: K, callback: (value: ValueForKey<{
299
+ useEmitter: <K extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "placeholder" | "autoFocus" | "readOnly" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "onBlur" | "markdownSourceEditorValue" | "viewMode" | "diffMarkdown">(key: K, callback: (value: ValueForKey<{
300
300
  viewMode: RealmNode<ViewMode>;
301
301
  diffMarkdown: RealmNode<string>;
302
302
  markdownSourceEditorValue: RealmNode<string>;
@@ -523,7 +523,7 @@ diffSourcePluginHooks: {
523
523
  insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
524
524
  onBlur: RealmNode<FocusEvent>;
525
525
  }>) => void;
526
- usePublisher: <K_2 extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "placeholder" | "autoFocus" | "readOnly" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "onBlur" | "viewMode" | "diffMarkdown" | "markdownSourceEditorValue">(key: K_2) => (value: ValueForKey<{
526
+ usePublisher: <K_2 extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "placeholder" | "autoFocus" | "readOnly" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "onBlur" | "markdownSourceEditorValue" | "viewMode" | "diffMarkdown">(key: K_2) => (value: ValueForKey<{
527
527
  viewMode: RealmNode<ViewMode>;
528
528
  diffMarkdown: RealmNode<string>;
529
529
  markdownSourceEditorValue: RealmNode<string>;
@@ -54,6 +54,9 @@ function LinkEditForm({ initialUrl, initialTitle, onSubmit, onCancel, linkAutoco
54
54
  },
55
55
  [isOpen, items, onSubmit, title]
56
56
  );
57
+ const handleSaveClick = (event) => {
58
+ event.stopPropagation();
59
+ };
57
60
  const downshiftInputProps = getInputProps();
58
61
  const inputProps = {
59
62
  ...downshiftInputProps,
@@ -72,7 +75,7 @@ function LinkEditForm({ initialUrl, initialTitle, onSubmit, onCancel, linkAutoco
72
75
  ...getItemProps({ item, index })
73
76
  },
74
77
  item
75
- ))))), /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("label", { htmlFor: "link-title" }, "Title")), /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("div", { className: styles.linkDialogInputWrapper }, /* @__PURE__ */ React__default.createElement("input", { id: "link-title", className: styles.linkDialogInput, size: 40, value: title, onChange: (e) => setTitle(e.target.value) }))), /* @__PURE__ */ React__default.createElement("div", { style: { display: "flex", justifyContent: "flex-end", gap: "var(--spacing-2)" } }, /* @__PURE__ */ React__default.createElement("button", { type: "reset", title: "Cancel change", "aria-label": "Cancel change", className: classNames(styles.secondaryButton) }, "Cancel"), /* @__PURE__ */ React__default.createElement("button", { type: "submit", title: "Set URL", "aria-label": "Set URL", className: classNames(styles.primaryButton) }, "Save")));
78
+ ))))), /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("label", { htmlFor: "link-title" }, "Title")), /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("div", { className: styles.linkDialogInputWrapper }, /* @__PURE__ */ React__default.createElement("input", { id: "link-title", className: styles.linkDialogInput, size: 40, value: title, onChange: (e) => setTitle(e.target.value) }))), /* @__PURE__ */ React__default.createElement("div", { style: { display: "flex", justifyContent: "flex-end", gap: "var(--spacing-2)" } }, /* @__PURE__ */ React__default.createElement("button", { type: "reset", title: "Cancel change", "aria-label": "Cancel change", className: classNames(styles.secondaryButton) }, "Cancel"), /* @__PURE__ */ React__default.createElement("button", { type: "submit", title: "Set URL", "aria-label": "Set URL", className: classNames(styles.primaryButton), onClick: handleSaveClick }, "Save")));
76
79
  }
77
80
  const LinkDialog = () => {
78
81
  const [editorRootElementRef] = corePluginHooks.useEmitterValues("editorRootElementRef");
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "private": false,
10
10
  "sideEffects": false,
11
11
  "type": "module",
12
- "version": "0.22.3",
12
+ "version": "0.22.5",
13
13
  "description": "React component for rich text markdown editing",
14
14
  "scripts": {
15
15
  "build": "vite build",