@mdxeditor/editor 1.13.5 → 1.14.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.
|
@@ -57,6 +57,7 @@ function ImageEditor({ src, title, alt, nodeKey, width, height }) {
|
|
|
57
57
|
const [disableImageResize] = imagePluginHooks.useEmitterValues("disableImageResize");
|
|
58
58
|
const [imagePreviewHandler] = imagePluginHooks.useEmitterValues("imagePreviewHandler");
|
|
59
59
|
const [imageSource, setImageSource] = React__default.useState(null);
|
|
60
|
+
const [initialImagePath, setInitialImagePath] = React__default.useState(null);
|
|
60
61
|
const openEditImageDialog = imagePluginHooks.usePublisher("openEditImageDialog");
|
|
61
62
|
const [iconComponentFor] = corePluginHooks.useEmitterValues("iconComponentFor");
|
|
62
63
|
const onDelete = React__default.useCallback(
|
|
@@ -108,6 +109,8 @@ function ImageEditor({ src, title, alt, nodeKey, width, height }) {
|
|
|
108
109
|
React__default.useEffect(() => {
|
|
109
110
|
if (imagePreviewHandler) {
|
|
110
111
|
const callPreviewHandler = async () => {
|
|
112
|
+
if (!initialImagePath)
|
|
113
|
+
setInitialImagePath(src);
|
|
111
114
|
const updatedSrc = await imagePreviewHandler(src);
|
|
112
115
|
setImageSource(updatedSrc);
|
|
113
116
|
};
|
|
@@ -212,7 +215,7 @@ function ImageEditor({ src, title, alt, nodeKey, width, height }) {
|
|
|
212
215
|
openEditImageDialog({
|
|
213
216
|
nodeKey,
|
|
214
217
|
initialValues: {
|
|
215
|
-
src: imageSource,
|
|
218
|
+
src: !initialImagePath ? imageSource : initialImagePath,
|
|
216
219
|
title: title || "",
|
|
217
220
|
altText: alt || ""
|
|
218
221
|
}
|