aden-editor-vue 0.1.2 → 0.1.3
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.cjs +44 -38
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +44 -38
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6595,6 +6595,42 @@ function renderTextChildren(block) {
|
|
|
6595
6595
|
return frag;
|
|
6596
6596
|
}
|
|
6597
6597
|
init_src();
|
|
6598
|
+
var toastEl = null;
|
|
6599
|
+
var hideTimer = null;
|
|
6600
|
+
var toastUsers = 0;
|
|
6601
|
+
function retainToast() {
|
|
6602
|
+
toastUsers += 1;
|
|
6603
|
+
}
|
|
6604
|
+
function releaseToast() {
|
|
6605
|
+
toastUsers = Math.max(0, toastUsers - 1);
|
|
6606
|
+
if (toastUsers === 0) destroyToast();
|
|
6607
|
+
}
|
|
6608
|
+
function showToast(message, duration = 2600) {
|
|
6609
|
+
if (typeof document === "undefined") return;
|
|
6610
|
+
if (!toastEl || !document.body.contains(toastEl)) {
|
|
6611
|
+
toastEl = document.createElement("div");
|
|
6612
|
+
toastEl.className = "aden-toast";
|
|
6613
|
+
toastEl.setAttribute("role", "status");
|
|
6614
|
+
toastEl.setAttribute("aria-live", "polite");
|
|
6615
|
+
document.body.appendChild(toastEl);
|
|
6616
|
+
}
|
|
6617
|
+
toastEl.textContent = message;
|
|
6618
|
+
void toastEl.offsetWidth;
|
|
6619
|
+
toastEl.classList.add("show");
|
|
6620
|
+
if (hideTimer !== null) window.clearTimeout(hideTimer);
|
|
6621
|
+
hideTimer = window.setTimeout(() => {
|
|
6622
|
+
toastEl == null ? void 0 : toastEl.classList.remove("show");
|
|
6623
|
+
hideTimer = null;
|
|
6624
|
+
}, duration);
|
|
6625
|
+
}
|
|
6626
|
+
function destroyToast() {
|
|
6627
|
+
if (hideTimer !== null) {
|
|
6628
|
+
window.clearTimeout(hideTimer);
|
|
6629
|
+
hideTimer = null;
|
|
6630
|
+
}
|
|
6631
|
+
toastEl == null ? void 0 : toastEl.remove();
|
|
6632
|
+
toastEl = null;
|
|
6633
|
+
}
|
|
6598
6634
|
function escapeText(s) {
|
|
6599
6635
|
return s.replace(/[<>&"]/g, (c) => ({ "<": "<", ">": ">", "&": "&", '"': """ })[c]);
|
|
6600
6636
|
}
|
|
@@ -6657,7 +6693,10 @@ function renderImage(block, handlers) {
|
|
|
6657
6693
|
img.style.width = "auto";
|
|
6658
6694
|
img.style.maxWidth = "100%";
|
|
6659
6695
|
}
|
|
6660
|
-
img.addEventListener("error", () =>
|
|
6696
|
+
img.addEventListener("error", () => {
|
|
6697
|
+
wrap.classList.add("is-broken");
|
|
6698
|
+
showToast("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u56FE\u7247\u5730\u5740\u6216\u914D\u7F6E uploadImage \u4E0A\u4F20\u5230\u53EF\u8BBF\u95EE\u7684\u5B58\u50A8\u670D\u52A1", 5200);
|
|
6699
|
+
});
|
|
6661
6700
|
if (handlers.isSelected(block.id)) wrap.classList.add("is-selected");
|
|
6662
6701
|
wrap.appendChild(img);
|
|
6663
6702
|
return wrap;
|
|
@@ -7310,42 +7349,6 @@ function injectAttachmentStyles() {
|
|
|
7310
7349
|
injected7 = true;
|
|
7311
7350
|
}
|
|
7312
7351
|
init_src();
|
|
7313
|
-
var toastEl = null;
|
|
7314
|
-
var hideTimer = null;
|
|
7315
|
-
var toastUsers = 0;
|
|
7316
|
-
function retainToast() {
|
|
7317
|
-
toastUsers += 1;
|
|
7318
|
-
}
|
|
7319
|
-
function releaseToast() {
|
|
7320
|
-
toastUsers = Math.max(0, toastUsers - 1);
|
|
7321
|
-
if (toastUsers === 0) destroyToast();
|
|
7322
|
-
}
|
|
7323
|
-
function showToast(message, duration = 2600) {
|
|
7324
|
-
if (typeof document === "undefined") return;
|
|
7325
|
-
if (!toastEl || !document.body.contains(toastEl)) {
|
|
7326
|
-
toastEl = document.createElement("div");
|
|
7327
|
-
toastEl.className = "aden-toast";
|
|
7328
|
-
toastEl.setAttribute("role", "status");
|
|
7329
|
-
toastEl.setAttribute("aria-live", "polite");
|
|
7330
|
-
document.body.appendChild(toastEl);
|
|
7331
|
-
}
|
|
7332
|
-
toastEl.textContent = message;
|
|
7333
|
-
void toastEl.offsetWidth;
|
|
7334
|
-
toastEl.classList.add("show");
|
|
7335
|
-
if (hideTimer !== null) window.clearTimeout(hideTimer);
|
|
7336
|
-
hideTimer = window.setTimeout(() => {
|
|
7337
|
-
toastEl == null ? void 0 : toastEl.classList.remove("show");
|
|
7338
|
-
hideTimer = null;
|
|
7339
|
-
}, duration);
|
|
7340
|
-
}
|
|
7341
|
-
function destroyToast() {
|
|
7342
|
-
if (hideTimer !== null) {
|
|
7343
|
-
window.clearTimeout(hideTimer);
|
|
7344
|
-
hideTimer = null;
|
|
7345
|
-
}
|
|
7346
|
-
toastEl == null ? void 0 : toastEl.remove();
|
|
7347
|
-
toastEl = null;
|
|
7348
|
-
}
|
|
7349
7352
|
var DEFAULT_ACCEPT = [
|
|
7350
7353
|
"image/png",
|
|
7351
7354
|
"image/jpeg",
|
|
@@ -7439,7 +7442,9 @@ var ImageController = class {
|
|
|
7439
7442
|
try {
|
|
7440
7443
|
const rawUrl = await uploader(file);
|
|
7441
7444
|
const url = this.opts.upload ? sanitizePersistentMediaUrl(rawUrl) : sanitizeUrl(rawUrl, "media");
|
|
7442
|
-
if (!url)
|
|
7445
|
+
if (!url) {
|
|
7446
|
+
throw new Error(this.opts.upload ? "\u4E0A\u4F20\u63A5\u53E3\u672A\u8FD4\u56DE\u53EF\u6301\u4E45\u8BBF\u95EE\u7684\u56FE\u7247 URL\uFF0C\u8BF7\u68C0\u67E5\u63A5\u53E3\u54CD\u5E94\u548C\u56FE\u7247\u5730\u5740" : "\u672C\u5730\u56FE\u7247\u8BFB\u53D6\u5931\u8D25");
|
|
7447
|
+
}
|
|
7443
7448
|
resolveImageUpload(this.opts.editor, uploadId, { src: url });
|
|
7444
7449
|
this.pending.delete(uploadId);
|
|
7445
7450
|
this.uploadToBlock.delete(uploadId);
|
|
@@ -7454,6 +7459,7 @@ var ImageController = class {
|
|
|
7454
7459
|
return;
|
|
7455
7460
|
}
|
|
7456
7461
|
const msg = (e == null ? void 0 : e.message) || "\u672A\u77E5\u9519\u8BEF";
|
|
7462
|
+
showToast(this.opts.upload ? `\u56FE\u7247\u4E0A\u4F20\u5931\u8D25\uFF1A${msg}` : `\u56FE\u7247\u5904\u7406\u5931\u8D25\uFF1A${msg}\u3002\u8BF7\u914D\u7F6E uploadImage \u56FE\u7247\u4E0A\u4F20\u63A5\u53E3\u540E\u91CD\u8BD5`, 5200);
|
|
7457
7463
|
const blockId = this.uploadToBlock.get(uploadId);
|
|
7458
7464
|
const blockStillExists = !!blockId && this.opts.editor.getDoc().blocks.some((block) => block.id === blockId);
|
|
7459
7465
|
resolveImageUpload(this.opts.editor, uploadId, { error: msg });
|