@ones-editor/editor 0.0.7-beta.30 → 0.0.7-beta.32
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/index.js
CHANGED
|
@@ -48812,8 +48812,8 @@ ${codeText}
|
|
|
48812
48812
|
}
|
|
48813
48813
|
function applyPlaceholderToBlock(editor, block, placeholder2) {
|
|
48814
48814
|
var _a;
|
|
48815
|
+
removePlaceholderFromBlock(editor, block);
|
|
48815
48816
|
if (!isEmptyTextBlockWithoutCompositionText(editor, block)) {
|
|
48816
|
-
removePlaceholderFromBlock(editor, block);
|
|
48817
48817
|
return;
|
|
48818
48818
|
}
|
|
48819
48819
|
const contentElem = getBlockContent(block);
|
|
@@ -49076,6 +49076,29 @@ ${codeText}
|
|
|
49076
49076
|
return containerId === "root" && blockIndex === 0 && !this.options.hideTitle;
|
|
49077
49077
|
}
|
|
49078
49078
|
}
|
|
49079
|
+
function isImageBlock(block) {
|
|
49080
|
+
return getBlockType(block) === "embed" && getEmbedType(block) === "image";
|
|
49081
|
+
}
|
|
49082
|
+
async function getImageSizeFromDataUrl$1(url) {
|
|
49083
|
+
return new Promise((resolve, reject) => {
|
|
49084
|
+
const image = new Image();
|
|
49085
|
+
image.onload = () => {
|
|
49086
|
+
resolve({
|
|
49087
|
+
width: image.naturalWidth,
|
|
49088
|
+
height: image.naturalHeight
|
|
49089
|
+
});
|
|
49090
|
+
};
|
|
49091
|
+
image.onerror = reject;
|
|
49092
|
+
image.src = url;
|
|
49093
|
+
});
|
|
49094
|
+
}
|
|
49095
|
+
async function getImageSizeFromFile(file2) {
|
|
49096
|
+
const url = await fileToDataUrl(file2);
|
|
49097
|
+
return getImageSizeFromDataUrl$1(url);
|
|
49098
|
+
}
|
|
49099
|
+
function isValidSize(size) {
|
|
49100
|
+
return typeof size === "number";
|
|
49101
|
+
}
|
|
49079
49102
|
const logger$13 = getLogger("image-data");
|
|
49080
49103
|
const DEFAULT_WIDTH$1 = 1e3;
|
|
49081
49104
|
const DEFAULT_HEIGHT = 400;
|
|
@@ -49176,7 +49199,7 @@ ${codeText}
|
|
|
49176
49199
|
const parentWidth = getContainerContentWidth(parentContainerElement);
|
|
49177
49200
|
return `${Math.min(totalWidth * percent / 100, parentWidth)}px`;
|
|
49178
49201
|
}
|
|
49179
|
-
if (
|
|
49202
|
+
if (isValidSize(images[0].width)) {
|
|
49180
49203
|
return `${images[0].width}px`;
|
|
49181
49204
|
}
|
|
49182
49205
|
return "auto";
|
|
@@ -49190,11 +49213,11 @@ ${codeText}
|
|
|
49190
49213
|
images.forEach((image, index2) => {
|
|
49191
49214
|
const src2 = image.src || `empty:${index2}`;
|
|
49192
49215
|
const widthKey = getImageWidthKeyFromSrc(src2);
|
|
49193
|
-
if (widthKey &&
|
|
49216
|
+
if (widthKey && isValidSize(image.width)) {
|
|
49194
49217
|
result[widthKey] = image.width;
|
|
49195
49218
|
}
|
|
49196
49219
|
const heightKey = getImageHeightKeyFromSrc(src2);
|
|
49197
|
-
if (heightKey &&
|
|
49220
|
+
if (heightKey && isValidSize(image.height)) {
|
|
49198
49221
|
result[heightKey] = image.height;
|
|
49199
49222
|
}
|
|
49200
49223
|
assert(logger$13, image.flex, "no image flex");
|
|
@@ -49926,26 +49949,6 @@ ${codeText}
|
|
|
49926
49949
|
const imageData = imageObject.getImages()[index2];
|
|
49927
49950
|
updateImageItem(editor, block, imageData, index2, imageObject.getSelectedIndex(), imageObject.getImages());
|
|
49928
49951
|
}
|
|
49929
|
-
function isImageBlock(block) {
|
|
49930
|
-
return getBlockType(block) === "embed" && getEmbedType(block) === "image";
|
|
49931
|
-
}
|
|
49932
|
-
async function getImageSizeFromDataUrl$1(url) {
|
|
49933
|
-
return new Promise((resolve, reject) => {
|
|
49934
|
-
const image = new Image();
|
|
49935
|
-
image.onload = () => {
|
|
49936
|
-
resolve({
|
|
49937
|
-
width: image.naturalWidth,
|
|
49938
|
-
height: image.naturalHeight
|
|
49939
|
-
});
|
|
49940
|
-
};
|
|
49941
|
-
image.onerror = reject;
|
|
49942
|
-
image.src = url;
|
|
49943
|
-
});
|
|
49944
|
-
}
|
|
49945
|
-
async function getImageSizeFromFile(file2) {
|
|
49946
|
-
const url = await fileToDataUrl(file2);
|
|
49947
|
-
return getImageSizeFromDataUrl$1(url);
|
|
49948
|
-
}
|
|
49949
49952
|
function getAccepts$1(editor) {
|
|
49950
49953
|
var _a;
|
|
49951
49954
|
let accept = "image/*";
|
|
@@ -50175,14 +50178,14 @@ ${codeText}
|
|
|
50175
50178
|
if (isEmptyImage$1(imageData)) {
|
|
50176
50179
|
return;
|
|
50177
50180
|
}
|
|
50178
|
-
if (imageData.
|
|
50179
|
-
imageData.height = image.
|
|
50180
|
-
}
|
|
50181
|
-
|
|
50182
|
-
|
|
50181
|
+
if (isValidSize(imageData.width) && !isValidSize(imageData.height)) {
|
|
50182
|
+
imageData.height = imageData.width / image.naturalWidth * image.naturalHeight;
|
|
50183
|
+
} else if (isValidSize(imageData.height) && !isValidSize(imageData.width)) {
|
|
50184
|
+
imageData.width = imageData.height / image.naturalHeight * image.naturalWidth;
|
|
50185
|
+
} else {
|
|
50186
|
+
imageData.width = image.naturalWidth;
|
|
50187
|
+
imageData.height = image.naturalHeight;
|
|
50183
50188
|
}
|
|
50184
|
-
imageData.width = image.naturalWidth;
|
|
50185
|
-
imageData.height = image.naturalHeight;
|
|
50186
50189
|
imageData.virtualSize = false;
|
|
50187
50190
|
this.fixImageSizes();
|
|
50188
50191
|
}
|
|
@@ -51507,8 +51510,7 @@ ${codeText}
|
|
|
51507
51510
|
});
|
|
51508
51511
|
});
|
|
51509
51512
|
__publicField(this, "updatePlaceholder", (block) => {
|
|
51510
|
-
|
|
51511
|
-
contentElem.setAttribute("data-content-placeholder", i18n$1.t("blockMenu.button.searchPlaceholder"));
|
|
51513
|
+
applyPlaceholderToBlock(this.editor, block, i18n$1.t("blockMenu.button.searchPlaceholder"));
|
|
51512
51514
|
});
|
|
51513
51515
|
__publicField(this, "handleChanged", () => {
|
|
51514
51516
|
const block = this.emptyBlockMenu.currentBlock;
|
|
@@ -52977,11 +52979,9 @@ ${codeText}
|
|
|
52977
52979
|
if (Array.isArray(imageData.src)) {
|
|
52978
52980
|
return;
|
|
52979
52981
|
}
|
|
52980
|
-
|
|
52981
|
-
|
|
52982
|
-
|
|
52983
|
-
getImageObject(editor, blockId).setAutoFix(true);
|
|
52984
|
-
}
|
|
52982
|
+
const blockId = cloneDocResult.blockIdMap.get(blockData.id);
|
|
52983
|
+
if (blockId) {
|
|
52984
|
+
getImageObject(editor, blockId).setAutoFix(true);
|
|
52985
52985
|
}
|
|
52986
52986
|
}
|
|
52987
52987
|
});
|