@mdxeditor/editor 3.9.0 → 3.9.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.
@@ -4,14 +4,15 @@ import React__default from "react";
4
4
  import { useForm } from "react-hook-form";
5
5
  import styles from "../../styles/ui.module.css.js";
6
6
  import { editorRootElementRef$, useTranslation } from "../core/index.js";
7
- import { imageAutocompleteSuggestions$, imageDialogState$, saveImage$, closeImageDialog$ } from "./index.js";
7
+ import { imageAutocompleteSuggestions$, imageDialogState$, imageUploadHandler$, saveImage$, closeImageDialog$ } from "./index.js";
8
8
  import { DownshiftAutoComplete } from "../core/ui/DownshiftAutoComplete.js";
9
9
  import { useCellValues, usePublisher } from "@mdxeditor/gurx";
10
10
  const ImageDialog = () => {
11
- const [imageAutocompleteSuggestions, state, editorRootElementRef] = useCellValues(
11
+ const [imageAutocompleteSuggestions, state, editorRootElementRef, imageUploadHandler] = useCellValues(
12
12
  imageAutocompleteSuggestions$,
13
13
  imageDialogState$,
14
- editorRootElementRef$
14
+ editorRootElementRef$,
15
+ imageUploadHandler$
15
16
  );
16
17
  const saveImage = usePublisher(saveImage$);
17
18
  const closeImageDialog = usePublisher(closeImageDialog$);
@@ -50,8 +51,8 @@ const ImageDialog = () => {
50
51
  },
51
52
  className: styles.multiFieldForm
52
53
  },
53
- /* @__PURE__ */ React__default.createElement("div", { className: styles.formField }, /* @__PURE__ */ React__default.createElement("label", { htmlFor: "file" }, t("uploadImage.uploadInstructions", "Upload an image from your device:")), /* @__PURE__ */ React__default.createElement("input", { type: "file", accept: "image/*", ...register("file") })),
54
- /* @__PURE__ */ React__default.createElement("div", { className: styles.formField }, /* @__PURE__ */ React__default.createElement("label", { htmlFor: "src" }, t("uploadImage.addViaUrlInstructions", "Or add an image from an URL:")), /* @__PURE__ */ React__default.createElement(
54
+ imageUploadHandler !== null && /* @__PURE__ */ React__default.createElement("div", { className: styles.formField }, /* @__PURE__ */ React__default.createElement("label", { htmlFor: "file" }, t("uploadImage.uploadInstructions", "Upload an image from your device:")), /* @__PURE__ */ React__default.createElement("input", { type: "file", accept: "image/*", ...register("file") })),
55
+ /* @__PURE__ */ React__default.createElement("div", { className: styles.formField }, /* @__PURE__ */ React__default.createElement("label", { htmlFor: "src" }, imageUploadHandler !== null ? t("uploadImage.addViaUrlInstructions", "Or add an image from an URL:") : t("uploadImage.addViaUrlInstructionsNoUpload", "Add an image from an URL:")), /* @__PURE__ */ React__default.createElement(
55
56
  DownshiftAutoComplete,
56
57
  {
57
58
  register,
@@ -219,6 +219,7 @@ function ImageEditor({ src, title, alt, nodeKey, width, height }) {
219
219
  className: styles.iconButton,
220
220
  type: "button",
221
221
  title: t("image.delete", "Delete image"),
222
+ disabled: readOnly,
222
223
  onClick: (e) => {
223
224
  e.preventDefault();
224
225
  editor.update(() => {
@@ -83,6 +83,9 @@ const imageDialogState$ = Cell(
83
83
  editor.registerCommand(
84
84
  DRAGSTART_COMMAND,
85
85
  (event) => {
86
+ if (!theUploadHandler) {
87
+ return false;
88
+ }
86
89
  return onDragStart(event);
87
90
  },
88
91
  COMMAND_PRIORITY_HIGH
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "*.css"
12
12
  ],
13
13
  "type": "module",
14
- "version": "3.9.0",
14
+ "version": "3.9.2",
15
15
  "description": "React component for rich text markdown editing",
16
16
  "scripts": {
17
17
  "build": "vite build",