@ones-editor/editor 2.8.18 → 2.8.20
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);
|
|
@@ -53425,6 +53442,11 @@ ${codeText}
|
|
|
53425
53442
|
linkElement.href = getLinkHref(child);
|
|
53426
53443
|
linkElement.target = "_blank";
|
|
53427
53444
|
linkElement.rel = "noopener noreferrer";
|
|
53445
|
+
linkElement.onclick = (event) => {
|
|
53446
|
+
event.preventDefault();
|
|
53447
|
+
event.stopPropagation();
|
|
53448
|
+
editor.emit("clickLink", editor, event, linkElement);
|
|
53449
|
+
};
|
|
53428
53450
|
commands = [{
|
|
53429
53451
|
id: "link-text",
|
|
53430
53452
|
name: getLinkHref(child),
|
|
@@ -68146,6 +68168,33 @@ ${codeText}
|
|
|
68146
68168
|
this.editor.input.addHandler(this);
|
|
68147
68169
|
});
|
|
68148
68170
|
}
|
|
68171
|
+
async handleBeforePasteDoc(editor, doc2) {
|
|
68172
|
+
for (const blocks of Object.values(doc2.blocks)) {
|
|
68173
|
+
for (const blockData of blocks) {
|
|
68174
|
+
if (blockData.type === "embed" && blockData.embedType === "image") {
|
|
68175
|
+
const imageData = blockData.embedData;
|
|
68176
|
+
const resources = Array.isArray(imageData.src) ? imageData.src : [imageData.src];
|
|
68177
|
+
const uploadedResources = resources.map(async (src) => {
|
|
68178
|
+
if (src.startsWith("data:")) {
|
|
68179
|
+
const { blob, mimeString } = dataURLToBlob(src);
|
|
68180
|
+
let ext = mimeString.split("/")[1] || "png";
|
|
68181
|
+
if (ext.indexOf("+") > 0) {
|
|
68182
|
+
ext = ext.split("+")[0];
|
|
68183
|
+
}
|
|
68184
|
+
const fileName = `image.${ext}`;
|
|
68185
|
+
const file2 = new File([blob], fileName, { type: mimeString });
|
|
68186
|
+
const ret = await editor.doc.uploadResource(file2);
|
|
68187
|
+
return ret.resourceId;
|
|
68188
|
+
}
|
|
68189
|
+
return src;
|
|
68190
|
+
});
|
|
68191
|
+
const newSrc = await Promise.all(uploadedResources);
|
|
68192
|
+
imageData.src = Array.isArray(imageData.src) ? newSrc : newSrc[0];
|
|
68193
|
+
}
|
|
68194
|
+
}
|
|
68195
|
+
}
|
|
68196
|
+
return false;
|
|
68197
|
+
}
|
|
68149
68198
|
async handleAfterPasteDoc(editor, doc2, cloneDocResult) {
|
|
68150
68199
|
Object.values(doc2.blocks).forEach((blocks) => {
|
|
68151
68200
|
blocks.forEach((blockData) => {
|
|
@@ -76082,6 +76131,23 @@ ${content}
|
|
|
76082
76131
|
}
|
|
76083
76132
|
Array.from(element.children).forEach(removeHiddenElements);
|
|
76084
76133
|
}
|
|
76134
|
+
function processDataUrl(fragment) {
|
|
76135
|
+
const images = fragment.querySelectorAll("img");
|
|
76136
|
+
images.forEach((img) => {
|
|
76137
|
+
var _a;
|
|
76138
|
+
const src = img.getAttribute("src");
|
|
76139
|
+
if (src && src.startsWith("data:")) {
|
|
76140
|
+
const [header, data2] = src.split(",");
|
|
76141
|
+
const mimeString = ((_a = header.split(":")[1]) == null ? void 0 : _a.split(";")[0]) || "image/png";
|
|
76142
|
+
const isBase642 = header.includes("base64");
|
|
76143
|
+
if (!isBase642) {
|
|
76144
|
+
const byteString = decodeURIComponent(data2);
|
|
76145
|
+
const url = stringToBase64DataUrl(byteString, mimeString);
|
|
76146
|
+
img.setAttribute("src", url);
|
|
76147
|
+
}
|
|
76148
|
+
}
|
|
76149
|
+
});
|
|
76150
|
+
}
|
|
76085
76151
|
function processHtml(html, options) {
|
|
76086
76152
|
const fragment = htmlToFragment(html);
|
|
76087
76153
|
fragment.querySelectorAll("td.js-line-number").forEach((cell) => cell.remove());
|
|
@@ -76092,6 +76158,7 @@ ${content}
|
|
|
76092
76158
|
Array.from(fragment.children).forEach((node) => convertAllTables(node, options));
|
|
76093
76159
|
Array.from(fragment.children).forEach(removeStyleElement);
|
|
76094
76160
|
replaceHljsFragmentToCode(fragment);
|
|
76161
|
+
processDataUrl(fragment);
|
|
76095
76162
|
const newHtml = fragmentToHtml(fragment);
|
|
76096
76163
|
return newHtml;
|
|
76097
76164
|
}
|
|
@@ -93002,7 +93069,7 @@ ${data2.plantumlText}
|
|
|
93002
93069
|
}
|
|
93003
93070
|
}
|
|
93004
93071
|
});
|
|
93005
|
-
editor.version = "2.8.
|
|
93072
|
+
editor.version = "2.8.20";
|
|
93006
93073
|
return editor;
|
|
93007
93074
|
}
|
|
93008
93075
|
function isDoc(doc2) {
|
|
@@ -93115,7 +93182,7 @@ ${data2.plantumlText}
|
|
|
93115
93182
|
}
|
|
93116
93183
|
});
|
|
93117
93184
|
OnesEditorToolbar.register(editor);
|
|
93118
|
-
editor.version = "2.8.
|
|
93185
|
+
editor.version = "2.8.20";
|
|
93119
93186
|
return editor;
|
|
93120
93187
|
}
|
|
93121
93188
|
async function showDocVersions(editor, options, serverUrl) {
|
|
@@ -139284,6 +139351,7 @@ ${data2.plantumlText}
|
|
|
139284
139351
|
exports2.createTextButton = createTextButton;
|
|
139285
139352
|
exports2.createTextOp = createTextOp;
|
|
139286
139353
|
exports2.createTextWithReplaceSoftReturn = createTextWithReplaceSoftReturn;
|
|
139354
|
+
exports2.dataURLToBlob = dataURLToBlob;
|
|
139287
139355
|
exports2.daysAfter = daysAfter;
|
|
139288
139356
|
exports2.deleteColor = deleteColor;
|
|
139289
139357
|
exports2.deleteText = deleteText;
|
|
@@ -139680,6 +139748,7 @@ ${data2.plantumlText}
|
|
|
139680
139748
|
exports2.showToast = showToast;
|
|
139681
139749
|
exports2.splitText = splitText;
|
|
139682
139750
|
exports2.splitToThree = splitToThree;
|
|
139751
|
+
exports2.stringToBase64DataUrl = stringToBase64DataUrl;
|
|
139683
139752
|
exports2.stringToDataUrl = stringToDataUrl;
|
|
139684
139753
|
exports2.stringToObjectUrl = stringToObjectUrl;
|
|
139685
139754
|
exports2.subText = subText;
|