@ones-editor/editor 0.0.7-beta.50 → 0.0.7-beta.52
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
|
@@ -22454,6 +22454,18 @@ var __publicField = (obj, key, value) => {
|
|
|
22454
22454
|
}
|
|
22455
22455
|
return false;
|
|
22456
22456
|
}
|
|
22457
|
+
function getBlockPartialVisiblePercent(editor, block) {
|
|
22458
|
+
const visibleRect = editorGetVisibleRect(editor);
|
|
22459
|
+
const rect = block.getBoundingClientRect();
|
|
22460
|
+
if (rect.top >= visibleRect.top && rect.top <= visibleRect.bottom && rect.bottom <= visibleRect.bottom && rect.bottom >= visibleRect.top) {
|
|
22461
|
+
return 100;
|
|
22462
|
+
}
|
|
22463
|
+
const intersectionX = Math.max(0, Math.min(rect.right, visibleRect.right) - Math.max(rect.left, visibleRect.left));
|
|
22464
|
+
const intersectionY = Math.max(0, Math.min(rect.bottom, visibleRect.bottom) - Math.max(rect.top, visibleRect.top));
|
|
22465
|
+
const intersectionArea = intersectionX * intersectionY;
|
|
22466
|
+
const elementAArea = rect.width * rect.height;
|
|
22467
|
+
return intersectionArea / elementAArea * 100;
|
|
22468
|
+
}
|
|
22457
22469
|
function isChildContainerVisible(editor, container) {
|
|
22458
22470
|
const visibleRect = editorGetVisibleRect(editor);
|
|
22459
22471
|
const rect = container.getBoundingClientRect();
|
|
@@ -22480,7 +22492,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22480
22492
|
}
|
|
22481
22493
|
if (selection.range.start.blockId === selection.range.end.blockId) {
|
|
22482
22494
|
const block2 = editor.getBlockById(selection.range.start.blockId);
|
|
22483
|
-
if (isEmbedBlock(block2) && isBlockPartialVisible(editor, block2)) {
|
|
22495
|
+
if (isEmbedBlock(block2) && isBlockPartialVisible(editor, block2) && getBlockPartialVisiblePercent(editor, block2) >= 50) {
|
|
22484
22496
|
return;
|
|
22485
22497
|
}
|
|
22486
22498
|
if (isComplexKindBlock(editor, block2) && isBlockPartialVisible(editor, block2)) {
|
|
@@ -22492,6 +22504,15 @@ var __publicField = (obj, key, value) => {
|
|
|
22492
22504
|
if (isBlockPositionVisible(editor, simplePos)) {
|
|
22493
22505
|
return;
|
|
22494
22506
|
}
|
|
22507
|
+
if (isEmbedBlock(block)) {
|
|
22508
|
+
const next = getNextBlock(block);
|
|
22509
|
+
if (next) {
|
|
22510
|
+
animateScrollTo(next, {
|
|
22511
|
+
elementToScroll: getScrollContainer$1(editor.rootContainer)
|
|
22512
|
+
});
|
|
22513
|
+
return;
|
|
22514
|
+
}
|
|
22515
|
+
}
|
|
22495
22516
|
const rect = getBlockCaretRect(editor, block, simplePos);
|
|
22496
22517
|
const blockRect = block.getBoundingClientRect();
|
|
22497
22518
|
const tools = getBlockTools(block);
|
|
@@ -70651,7 +70672,7 @@ ${data.flowchartText}
|
|
|
70651
70672
|
media: {
|
|
70652
70673
|
upload: {
|
|
70653
70674
|
failed: '<div class="line-1">{name}\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <span class="retry-upload">\u91CD\u8BD5</span></div>',
|
|
70654
|
-
maxSizeFailed: '<div class="line-1">{name}\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u6587\u4EF6\u5927\u5C0F\u8D85\u8FC7\
|
|
70675
|
+
maxSizeFailed: '<div class="line-1">{name}\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u6587\u4EF6\u5927\u5C0F\u8D85\u8FC7\u9650\u5236\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6</div>'
|
|
70655
70676
|
},
|
|
70656
70677
|
load: {
|
|
70657
70678
|
failed: '<div class="line-1">{name}\u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <span class="retry-upload">\u91CD\u8BD5</span></div>'
|
|
@@ -70670,7 +70691,7 @@ ${data.flowchartText}
|
|
|
70670
70691
|
media: {
|
|
70671
70692
|
upload: {
|
|
70672
70693
|
failed: '<div class="line-1">{name} upload failed</div><div class="line-2">Network error, you can <span class="retry-upload">Retry</span></div>',
|
|
70673
|
-
maxSizeFailed: '<div class="line-1">{name} upload failed</div><div class="line-2">The file size exceeds
|
|
70694
|
+
maxSizeFailed: '<div class="line-1">{name} upload failed</div><div class="line-2">The file size exceeds limit. Please choose another file.</div>'
|
|
70674
70695
|
},
|
|
70675
70696
|
load: {
|
|
70676
70697
|
failed: '<div class="line-1">{name} loading failed</div><div class="line-2">Network error, you can <span class="retry-upload">Retry</span></div>'
|
|
@@ -70689,7 +70710,7 @@ ${data.flowchartText}
|
|
|
70689
70710
|
media: {
|
|
70690
70711
|
upload: {
|
|
70691
70712
|
failed: '<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>',
|
|
70692
|
-
maxSizeFailed: '<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u30D5\u30A1\u30A4\u30EB\u306E\u30B5\u30A4\u30BA\u304C\
|
|
70713
|
+
maxSizeFailed: '<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u30D5\u30A1\u30A4\u30EB\u306E\u30B5\u30A4\u30BA\u304C\u4E0A\u9650\u3092\u8D85\u3048\u3066\u3044\u308B\u305F\u3081\u3001\u4ED6\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044</div>'
|
|
70693
70714
|
},
|
|
70694
70715
|
load: {
|
|
70695
70716
|
failed: '<div class="line-1">{name}\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>'
|
|
@@ -70783,18 +70804,6 @@ ${data.flowchartText}
|
|
|
70783
70804
|
return src === ReservedMediaSrcType.Empty || src === ReservedMediaSrcType.Error;
|
|
70784
70805
|
}
|
|
70785
70806
|
const logger$5 = getLogger("media");
|
|
70786
|
-
function formatFileSize(num, digits = 2) {
|
|
70787
|
-
if (num < 1024) {
|
|
70788
|
-
return `${num}B`;
|
|
70789
|
-
}
|
|
70790
|
-
if (num < 1024 * 1024) {
|
|
70791
|
-
return `${(num / 1024).toFixed(digits)}KB`;
|
|
70792
|
-
}
|
|
70793
|
-
if (num < 1024 * 1024 * 1024) {
|
|
70794
|
-
return `${(num / (1024 * 1024)).toFixed(digits)}MB`;
|
|
70795
|
-
}
|
|
70796
|
-
return `${(num / (1024 * 1024 * 1024)).toFixed(digits)}GB`;
|
|
70797
|
-
}
|
|
70798
70807
|
class Media extends tinyTypedEmitter.TypedEmitter {
|
|
70799
70808
|
constructor(options) {
|
|
70800
70809
|
super();
|
|
@@ -70904,7 +70913,7 @@ ${data.flowchartText}
|
|
|
70904
70913
|
return errorContainer;
|
|
70905
70914
|
}
|
|
70906
70915
|
renderRetry(file2, error2) {
|
|
70907
|
-
var _a, _b
|
|
70916
|
+
var _a, _b;
|
|
70908
70917
|
assert(logger$5, this.abstract, "no abstract");
|
|
70909
70918
|
const { editor } = this.options;
|
|
70910
70919
|
const { mediaIcon, mediaName } = this.abstract;
|
|
@@ -70914,15 +70923,7 @@ ${data.flowchartText}
|
|
|
70914
70923
|
const errorDetail = createElement("div", [], retry);
|
|
70915
70924
|
let html = i18n$1.t("media.upload.failed", { name: mediaName });
|
|
70916
70925
|
if (((_a = error2.response) == null ? void 0 : _a.status) === 420 || ((_b = error2.response) == null ? void 0 : _b.status) === 413) {
|
|
70917
|
-
|
|
70918
|
-
const fileSizeMatch = message.match(/(\d+)/);
|
|
70919
|
-
if (fileSizeMatch) {
|
|
70920
|
-
const fileSize = Number.parseInt(fileSizeMatch[1], 10);
|
|
70921
|
-
const formattedSize = formatFileSize(fileSize, 0);
|
|
70922
|
-
html = i18n$1.t("media.upload.maxSizeFailed", { name: mediaName, size: formattedSize });
|
|
70923
|
-
} else {
|
|
70924
|
-
html = i18n$1.t("media.upload.maxSizeFailed", { name: mediaName, size: "maxRequestBodySize" });
|
|
70925
|
-
}
|
|
70926
|
+
html = i18n$1.t("media.upload.maxSizeFailed", { name: mediaName });
|
|
70926
70927
|
}
|
|
70927
70928
|
errorDetail.innerHTML = html;
|
|
70928
70929
|
retry.appendChild(errorDetail);
|