@ones-editor/editor 2.8.18 → 2.8.19
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
|
@@ -10797,6 +10797,23 @@ var __publicField = (obj, key, value) => {
|
|
|
10797
10797
|
function fromBase64ToBlob(data2) {
|
|
10798
10798
|
return new Blob([jsBase64.Base64.toUint8Array(data2)]);
|
|
10799
10799
|
}
|
|
10800
|
+
function dataURLToBlob(dataURL) {
|
|
10801
|
+
var _a;
|
|
10802
|
+
const [header, data2] = dataURL.split(",");
|
|
10803
|
+
const mimeString = ((_a = header.match(/:(.*?);/)) == null ? void 0 : _a[1]) || "";
|
|
10804
|
+
const isBase642 = header.includes("base64");
|
|
10805
|
+
let blob;
|
|
10806
|
+
if (isBase642) {
|
|
10807
|
+
blob = fromBase64ToBlob(data2);
|
|
10808
|
+
} else {
|
|
10809
|
+
const byteString = decodeURIComponent(data2);
|
|
10810
|
+
blob = new Blob([byteString], { type: mimeString });
|
|
10811
|
+
}
|
|
10812
|
+
return { blob, mimeString };
|
|
10813
|
+
}
|
|
10814
|
+
function stringToBase64DataUrl(data2, type) {
|
|
10815
|
+
return `data:${type};base64,${toBase64URL(data2)}`;
|
|
10816
|
+
}
|
|
10800
10817
|
const patch = snabbdom.init([snabbdom.classModule, snabbdom.styleModule, snabbdom.datasetModule, snabbdom.attributesModule, snabbdom.propsModule]);
|
|
10801
10818
|
function patchNode(oldContent, newContent) {
|
|
10802
10819
|
const oldVNode = snabbdom.toVNode(oldContent);
|
|
@@ -68146,6 +68163,33 @@ ${codeText}
|
|
|
68146
68163
|
this.editor.input.addHandler(this);
|
|
68147
68164
|
});
|
|
68148
68165
|
}
|
|
68166
|
+
async handleBeforePasteDoc(editor, doc2) {
|
|
68167
|
+
for (const blocks of Object.values(doc2.blocks)) {
|
|
68168
|
+
for (const blockData of blocks) {
|
|
68169
|
+
if (blockData.type === "embed" && blockData.embedType === "image") {
|
|
68170
|
+
const imageData = blockData.embedData;
|
|
68171
|
+
const resources = Array.isArray(imageData.src) ? imageData.src : [imageData.src];
|
|
68172
|
+
const uploadedResources = resources.map(async (src) => {
|
|
68173
|
+
if (src.startsWith("data:")) {
|
|
68174
|
+
const { blob, mimeString } = dataURLToBlob(src);
|
|
68175
|
+
let ext = mimeString.split("/")[1] || "png";
|
|
68176
|
+
if (ext.indexOf("+") > 0) {
|
|
68177
|
+
ext = ext.split("+")[0];
|
|
68178
|
+
}
|
|
68179
|
+
const fileName = `image.${ext}`;
|
|
68180
|
+
const file2 = new File([blob], fileName, { type: mimeString });
|
|
68181
|
+
const ret = await editor.doc.uploadResource(file2);
|
|
68182
|
+
return ret.resourceId;
|
|
68183
|
+
}
|
|
68184
|
+
return src;
|
|
68185
|
+
});
|
|
68186
|
+
const newSrc = await Promise.all(uploadedResources);
|
|
68187
|
+
imageData.src = Array.isArray(imageData.src) ? newSrc : newSrc[0];
|
|
68188
|
+
}
|
|
68189
|
+
}
|
|
68190
|
+
}
|
|
68191
|
+
return false;
|
|
68192
|
+
}
|
|
68149
68193
|
async handleAfterPasteDoc(editor, doc2, cloneDocResult) {
|
|
68150
68194
|
Object.values(doc2.blocks).forEach((blocks) => {
|
|
68151
68195
|
blocks.forEach((blockData) => {
|
|
@@ -76082,6 +76126,23 @@ ${content}
|
|
|
76082
76126
|
}
|
|
76083
76127
|
Array.from(element.children).forEach(removeHiddenElements);
|
|
76084
76128
|
}
|
|
76129
|
+
function processDataUrl(fragment) {
|
|
76130
|
+
const images = fragment.querySelectorAll("img");
|
|
76131
|
+
images.forEach((img) => {
|
|
76132
|
+
var _a;
|
|
76133
|
+
const src = img.getAttribute("src");
|
|
76134
|
+
if (src && src.startsWith("data:")) {
|
|
76135
|
+
const [header, data2] = src.split(",");
|
|
76136
|
+
const mimeString = ((_a = header.split(":")[1]) == null ? void 0 : _a.split(";")[0]) || "image/png";
|
|
76137
|
+
const isBase642 = header.includes("base64");
|
|
76138
|
+
if (!isBase642) {
|
|
76139
|
+
const byteString = decodeURIComponent(data2);
|
|
76140
|
+
const url = stringToBase64DataUrl(byteString, mimeString);
|
|
76141
|
+
img.setAttribute("src", url);
|
|
76142
|
+
}
|
|
76143
|
+
}
|
|
76144
|
+
});
|
|
76145
|
+
}
|
|
76085
76146
|
function processHtml(html, options) {
|
|
76086
76147
|
const fragment = htmlToFragment(html);
|
|
76087
76148
|
fragment.querySelectorAll("td.js-line-number").forEach((cell) => cell.remove());
|
|
@@ -76092,6 +76153,7 @@ ${content}
|
|
|
76092
76153
|
Array.from(fragment.children).forEach((node) => convertAllTables(node, options));
|
|
76093
76154
|
Array.from(fragment.children).forEach(removeStyleElement);
|
|
76094
76155
|
replaceHljsFragmentToCode(fragment);
|
|
76156
|
+
processDataUrl(fragment);
|
|
76095
76157
|
const newHtml = fragmentToHtml(fragment);
|
|
76096
76158
|
return newHtml;
|
|
76097
76159
|
}
|
|
@@ -93002,7 +93064,7 @@ ${data2.plantumlText}
|
|
|
93002
93064
|
}
|
|
93003
93065
|
}
|
|
93004
93066
|
});
|
|
93005
|
-
editor.version = "2.8.
|
|
93067
|
+
editor.version = "2.8.19";
|
|
93006
93068
|
return editor;
|
|
93007
93069
|
}
|
|
93008
93070
|
function isDoc(doc2) {
|
|
@@ -93115,7 +93177,7 @@ ${data2.plantumlText}
|
|
|
93115
93177
|
}
|
|
93116
93178
|
});
|
|
93117
93179
|
OnesEditorToolbar.register(editor);
|
|
93118
|
-
editor.version = "2.8.
|
|
93180
|
+
editor.version = "2.8.19";
|
|
93119
93181
|
return editor;
|
|
93120
93182
|
}
|
|
93121
93183
|
async function showDocVersions(editor, options, serverUrl) {
|
|
@@ -139284,6 +139346,7 @@ ${data2.plantumlText}
|
|
|
139284
139346
|
exports2.createTextButton = createTextButton;
|
|
139285
139347
|
exports2.createTextOp = createTextOp;
|
|
139286
139348
|
exports2.createTextWithReplaceSoftReturn = createTextWithReplaceSoftReturn;
|
|
139349
|
+
exports2.dataURLToBlob = dataURLToBlob;
|
|
139287
139350
|
exports2.daysAfter = daysAfter;
|
|
139288
139351
|
exports2.deleteColor = deleteColor;
|
|
139289
139352
|
exports2.deleteText = deleteText;
|
|
@@ -139680,6 +139743,7 @@ ${data2.plantumlText}
|
|
|
139680
139743
|
exports2.showToast = showToast;
|
|
139681
139744
|
exports2.splitText = splitText;
|
|
139682
139745
|
exports2.splitToThree = splitToThree;
|
|
139746
|
+
exports2.stringToBase64DataUrl = stringToBase64DataUrl;
|
|
139683
139747
|
exports2.stringToDataUrl = stringToDataUrl;
|
|
139684
139748
|
exports2.stringToObjectUrl = stringToObjectUrl;
|
|
139685
139749
|
exports2.subText = subText;
|