@mdxeditor/editor
Advanced tools
Comparing version 3.9.2 to 3.9.3
@@ -54,3 +54,3 @@ import * as Dialog from "@radix-ui/react-dialog"; | ||
}, | ||
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") })), | ||
imageUploadHandler === null ? /* @__PURE__ */ React__default.createElement("input", { type: "hidden", accept: "image/*", ...register("file") }) : /* @__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") })), | ||
/* @__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( | ||
@@ -57,0 +57,0 @@ DownshiftAutoComplete, |
@@ -38,4 +38,4 @@ var __defProp = Object.defineProperty; | ||
this.__altText = altText; | ||
this.__width = width ?? "inherit"; | ||
this.__height = height ?? "inherit"; | ||
this.__width = width ? width : "inherit"; | ||
this.__height = height ? height : "inherit"; | ||
} | ||
@@ -42,0 +42,0 @@ /** @internal */ |
@@ -86,5 +86,2 @@ import { $wrapNodeInElement, mergeRegister } from "@lexical/utils"; | ||
(event) => { | ||
if (!theUploadHandler) { | ||
return false; | ||
} | ||
return onDragStart(event); | ||
@@ -97,3 +94,3 @@ }, | ||
(event) => { | ||
return onDragover(event); | ||
return onDragover(event, !!theUploadHandler); | ||
}, | ||
@@ -109,28 +106,34 @@ COMMAND_PRIORITY_LOW | ||
), | ||
...theUploadHandler !== null ? [ | ||
editor.registerCommand( | ||
PASTE_COMMAND, | ||
(event) => { | ||
var _a; | ||
let cbPayload = Array.from(((_a = event.clipboardData) == null ? void 0 : _a.items) ?? []); | ||
cbPayload = cbPayload.filter((i) => i.type.includes("image")); | ||
if (!cbPayload.length || cbPayload.length === 0) { | ||
return false; | ||
editor.registerCommand( | ||
PASTE_COMMAND, | ||
(event) => { | ||
var _a, _b; | ||
if (!theUploadHandler) { | ||
let fromWeb = Array.from(((_a = event.clipboardData) == null ? void 0 : _a.items) ?? []); | ||
fromWeb = fromWeb.filter((i) => i.type.includes("text")); | ||
if (!fromWeb.length || fromWeb.length === 0) { | ||
return true; | ||
} | ||
const imageUploadHandlerValue = r.getValue(imageUploadHandler$); | ||
Promise.all(cbPayload.map((file) => imageUploadHandlerValue(file.getAsFile()))).then((urls) => { | ||
urls.forEach((url) => { | ||
editor.dispatchCommand(INSERT_IMAGE_COMMAND, { | ||
src: url, | ||
altText: "" | ||
}); | ||
return false; | ||
} | ||
let cbPayload = Array.from(((_b = event.clipboardData) == null ? void 0 : _b.items) ?? []); | ||
cbPayload = cbPayload.filter((i) => i.type.includes("image")); | ||
if (!cbPayload.length || cbPayload.length === 0) { | ||
return false; | ||
} | ||
const imageUploadHandlerValue = r.getValue(imageUploadHandler$); | ||
Promise.all(cbPayload.map((file) => imageUploadHandlerValue(file.getAsFile()))).then((urls) => { | ||
urls.forEach((url) => { | ||
editor.dispatchCommand(INSERT_IMAGE_COMMAND, { | ||
src: url, | ||
altText: "" | ||
}); | ||
}).catch((e) => { | ||
throw e; | ||
}); | ||
return true; | ||
}, | ||
COMMAND_PRIORITY_CRITICAL | ||
) | ||
] : [] | ||
}).catch((e) => { | ||
throw e; | ||
}); | ||
return true; | ||
}, | ||
COMMAND_PRIORITY_CRITICAL | ||
) | ||
); | ||
@@ -210,9 +213,11 @@ }); | ||
} | ||
function onDragover(event) { | ||
function onDragover(event, hasUploadHandler) { | ||
var _a; | ||
let cbPayload = Array.from(((_a = event.dataTransfer) == null ? void 0 : _a.items) ?? []); | ||
cbPayload = cbPayload.filter((i) => i.type.includes("image")); | ||
if (cbPayload.length > 0) { | ||
event.preventDefault(); | ||
return true; | ||
if (hasUploadHandler) { | ||
let cbPayload = Array.from(((_a = event.dataTransfer) == null ? void 0 : _a.items) ?? []); | ||
cbPayload = cbPayload.filter((i) => i.type.includes("image")); | ||
if (cbPayload.length > 0) { | ||
event.preventDefault(); | ||
return true; | ||
} | ||
} | ||
@@ -219,0 +224,0 @@ const node = getImageNodeInSelection(); |
@@ -14,3 +14,3 @@ { | ||
"type": "module", | ||
"version": "3.9.2", | ||
"version": "3.9.3", | ||
"description": "React component for rich text markdown editing", | ||
@@ -17,0 +17,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
529598
13871