@ones-editor/editor 0.0.7-beta.26 → 0.0.7-beta.28
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
|
@@ -2365,7 +2365,6 @@ div[data-type=editor-block].table-block div[data-type=table-content] > .error {
|
|
|
2365
2365
|
}
|
|
2366
2366
|
div[data-type=editor-block].table-block div[data-type=table-content] > table {
|
|
2367
2367
|
border-collapse: collapse;
|
|
2368
|
-
width: max-content;
|
|
2369
2368
|
border-spacing: 0;
|
|
2370
2369
|
}
|
|
2371
2370
|
div[data-type=editor-block].table-block div[data-type=table-content] > table colgroup col {
|
|
@@ -3761,7 +3760,7 @@ div.editor-root.readonly div.editor-content div[data-type=editor-block] > [data-
|
|
|
3761
3760
|
justify-content: center;
|
|
3762
3761
|
}
|
|
3763
3762
|
.comment-editor-root:not(.comment-editor-readonly) .editor-root .editor-content [data-type=editor-block]:not([data-block-type=text]) {
|
|
3764
|
-
width:
|
|
3763
|
+
width: 224px;
|
|
3765
3764
|
}
|
|
3766
3765
|
.comment-editor-editing {
|
|
3767
3766
|
border: 1px solid #0064ff;
|
|
@@ -3850,6 +3849,7 @@ div.editor-root.readonly div.editor-content div[data-type=editor-block] > [data-
|
|
|
3850
3849
|
}
|
|
3851
3850
|
.comment-item-root .item-actions .editor-button {
|
|
3852
3851
|
padding: 4px 10px;
|
|
3852
|
+
line-height: 1;
|
|
3853
3853
|
}
|
|
3854
3854
|
.comment-item-root .item-actions.hidden {
|
|
3855
3855
|
display: none;
|
|
@@ -3908,10 +3908,6 @@ div.editor-root.readonly div.editor-content div[data-type=editor-block] > [data-
|
|
|
3908
3908
|
transform: matrix(0.71, 0.61, 0.82, -0.71, 0, 0) translateX(-50%);
|
|
3909
3909
|
z-index: -1;
|
|
3910
3910
|
}.comment-quick-reply .quick-reply-button {
|
|
3911
|
-
position: absolute;
|
|
3912
|
-
left: 8px;
|
|
3913
|
-
bottom: 10px;
|
|
3914
|
-
z-index: 2;
|
|
3915
3911
|
color: #575859;
|
|
3916
3912
|
font-size: 12px;
|
|
3917
3913
|
}
|
|
@@ -3934,6 +3930,7 @@ div.editor-root.readonly div.editor-content div[data-type=editor-block] > [data-
|
|
|
3934
3930
|
}
|
|
3935
3931
|
.comment-quick-reply .quick-reply-editor .reply-editor-actions .editor-button {
|
|
3936
3932
|
padding: 4px 10px;
|
|
3933
|
+
line-height: 1;
|
|
3937
3934
|
}
|
|
3938
3935
|
.comment-quick-reply.hidden {
|
|
3939
3936
|
display: none;
|
|
@@ -4029,7 +4026,7 @@ div.editor-root.readonly div.editor-content div[data-type=editor-block] > [data-
|
|
|
4029
4026
|
border-radius: 2px;
|
|
4030
4027
|
border-color: var(--editor-comment-layer-active-border-color);
|
|
4031
4028
|
box-shadow: var(--editor-box-shadow);
|
|
4032
|
-
padding-bottom:
|
|
4029
|
+
padding-bottom: 10px;
|
|
4033
4030
|
}
|
|
4034
4031
|
.editor-web-comment-root .comment-groups-container .comment-group-item-root:not(.no-animation) {
|
|
4035
4032
|
transition: top 0.2s ease-in, opacity 0.35s ease-in;
|
|
@@ -6767,44 +6764,6 @@ var __publicField = (obj, key, value) => {
|
|
|
6767
6764
|
}
|
|
6768
6765
|
}
|
|
6769
6766
|
const lockers = new Lockers();
|
|
6770
|
-
/**
|
|
6771
|
-
* @name string-character-is-astral-surrogate
|
|
6772
|
-
* @fileoverview Tells, is given character a part of astral character, specifically, a high and low surrogate
|
|
6773
|
-
* @version 2.1.6
|
|
6774
|
-
* @author Roy Revelt, Codsen Ltd
|
|
6775
|
-
* @license MIT
|
|
6776
|
-
* {@link https://codsen.com/os/string-character-is-astral-surrogate/}
|
|
6777
|
-
*/
|
|
6778
|
-
function t$7(r) {
|
|
6779
|
-
if (typeof r == "string")
|
|
6780
|
-
return r.length === 0 ? false : r.charCodeAt(0) >= 55296 && r.charCodeAt(0) <= 56319;
|
|
6781
|
-
if (r === void 0)
|
|
6782
|
-
return false;
|
|
6783
|
-
throw new TypeError(`string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but ${typeof r}`);
|
|
6784
|
-
}
|
|
6785
|
-
function e(r) {
|
|
6786
|
-
if (typeof r == "string")
|
|
6787
|
-
return r.length === 0 ? false : r.charCodeAt(0) >= 56320 && r.charCodeAt(0) <= 57343;
|
|
6788
|
-
if (r === void 0)
|
|
6789
|
-
return false;
|
|
6790
|
-
throw new TypeError(`string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but ${typeof r}`);
|
|
6791
|
-
}
|
|
6792
|
-
const ZERO_WIDTH_SPACE_CHAR = "\u200B";
|
|
6793
|
-
function unicodeLength(str) {
|
|
6794
|
-
const s = str;
|
|
6795
|
-
return [...s].length;
|
|
6796
|
-
}
|
|
6797
|
-
function unicodeSubstr(str, start, count) {
|
|
6798
|
-
const s = str;
|
|
6799
|
-
const arr = [...s];
|
|
6800
|
-
let end;
|
|
6801
|
-
if (count === void 0) {
|
|
6802
|
-
end = arr.length;
|
|
6803
|
-
} else {
|
|
6804
|
-
end = start + count;
|
|
6805
|
-
}
|
|
6806
|
-
return arr.slice(start, end).join("");
|
|
6807
|
-
}
|
|
6808
6767
|
const logger$46 = getLogger("dom-utils");
|
|
6809
6768
|
function addClass(dom, ...className) {
|
|
6810
6769
|
if (dom && dom.nodeType === Node.ELEMENT_NODE) {
|
|
@@ -6888,28 +6847,31 @@ var __publicField = (obj, key, value) => {
|
|
|
6888
6847
|
const dist = (x1 - x) ** 2 + (y1 - y) ** 2;
|
|
6889
6848
|
return dist;
|
|
6890
6849
|
}
|
|
6891
|
-
function
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
let
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6850
|
+
function getOffsetFromPoint(x, y) {
|
|
6851
|
+
let range;
|
|
6852
|
+
let textNode = null;
|
|
6853
|
+
let offset = -1;
|
|
6854
|
+
if (document.caretPositionFromPoint) {
|
|
6855
|
+
range = document.caretPositionFromPoint(x, y);
|
|
6856
|
+
if (range) {
|
|
6857
|
+
textNode = range.offsetNode;
|
|
6858
|
+
offset = range.offset;
|
|
6900
6859
|
}
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
if (dist < minDist) {
|
|
6907
|
-
minDist = dist;
|
|
6908
|
-
offset = i;
|
|
6909
|
-
}
|
|
6860
|
+
} else if (document.caretRangeFromPoint) {
|
|
6861
|
+
range = document.caretRangeFromPoint(x, y);
|
|
6862
|
+
if (range) {
|
|
6863
|
+
textNode = range.startContainer;
|
|
6864
|
+
offset = range.startOffset;
|
|
6910
6865
|
}
|
|
6911
6866
|
}
|
|
6912
|
-
return offset;
|
|
6867
|
+
return { textNode, offset };
|
|
6868
|
+
}
|
|
6869
|
+
function textNodeOffsetFromPoint(node, x, y) {
|
|
6870
|
+
const offsetInfo = getOffsetFromPoint(x, y);
|
|
6871
|
+
if (offsetInfo.textNode === node) {
|
|
6872
|
+
return offsetInfo.offset;
|
|
6873
|
+
}
|
|
6874
|
+
return 0;
|
|
6913
6875
|
}
|
|
6914
6876
|
function compareElement(elem1, elem2) {
|
|
6915
6877
|
if (elem1 === elem2) {
|
|
@@ -7331,6 +7293,44 @@ var __publicField = (obj, key, value) => {
|
|
|
7331
7293
|
function pointInRect(rect, x, y) {
|
|
7332
7294
|
return rect.left <= x && x <= rect.right && rect.top <= y && y <= rect.bottom;
|
|
7333
7295
|
}
|
|
7296
|
+
/**
|
|
7297
|
+
* @name string-character-is-astral-surrogate
|
|
7298
|
+
* @fileoverview Tells, is given character a part of astral character, specifically, a high and low surrogate
|
|
7299
|
+
* @version 2.1.6
|
|
7300
|
+
* @author Roy Revelt, Codsen Ltd
|
|
7301
|
+
* @license MIT
|
|
7302
|
+
* {@link https://codsen.com/os/string-character-is-astral-surrogate/}
|
|
7303
|
+
*/
|
|
7304
|
+
function t$7(r) {
|
|
7305
|
+
if (typeof r == "string")
|
|
7306
|
+
return r.length === 0 ? false : r.charCodeAt(0) >= 55296 && r.charCodeAt(0) <= 56319;
|
|
7307
|
+
if (r === void 0)
|
|
7308
|
+
return false;
|
|
7309
|
+
throw new TypeError(`string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but ${typeof r}`);
|
|
7310
|
+
}
|
|
7311
|
+
function e(r) {
|
|
7312
|
+
if (typeof r == "string")
|
|
7313
|
+
return r.length === 0 ? false : r.charCodeAt(0) >= 56320 && r.charCodeAt(0) <= 57343;
|
|
7314
|
+
if (r === void 0)
|
|
7315
|
+
return false;
|
|
7316
|
+
throw new TypeError(`string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but ${typeof r}`);
|
|
7317
|
+
}
|
|
7318
|
+
const ZERO_WIDTH_SPACE_CHAR = "\u200B";
|
|
7319
|
+
function unicodeLength(str) {
|
|
7320
|
+
const s = str;
|
|
7321
|
+
return [...s].length;
|
|
7322
|
+
}
|
|
7323
|
+
function unicodeSubstr(str, start, count) {
|
|
7324
|
+
const s = str;
|
|
7325
|
+
const arr = [...s];
|
|
7326
|
+
let end;
|
|
7327
|
+
if (count === void 0) {
|
|
7328
|
+
end = arr.length;
|
|
7329
|
+
} else {
|
|
7330
|
+
end = start + count;
|
|
7331
|
+
}
|
|
7332
|
+
return arr.slice(start, end).join("");
|
|
7333
|
+
}
|
|
7334
7334
|
function escapeSpace(text2) {
|
|
7335
7335
|
const nbsp = "\xA0";
|
|
7336
7336
|
if (!text2)
|
|
@@ -10260,8 +10260,21 @@ var __publicField = (obj, key, value) => {
|
|
|
10260
10260
|
}
|
|
10261
10261
|
return null;
|
|
10262
10262
|
}
|
|
10263
|
-
function getBlockRangeFromPoint(editor,
|
|
10263
|
+
function getBlockRangeFromPoint(editor, pointX, pointY) {
|
|
10264
10264
|
const yOffsets = [0, -8, 8];
|
|
10265
|
+
let x = pointX;
|
|
10266
|
+
const y = pointY;
|
|
10267
|
+
let target = document.elementsFromPoint(x, y)[0];
|
|
10268
|
+
if (target === editor.contentElement) {
|
|
10269
|
+
const contentRect = editor.contentElement.getBoundingClientRect();
|
|
10270
|
+
const editorCenterX = contentRect.left + contentRect.width / 2;
|
|
10271
|
+
target = document.elementsFromPoint(editorCenterX, y)[0];
|
|
10272
|
+
const targetBlock = getParentBlock(target);
|
|
10273
|
+
if (targetBlock) {
|
|
10274
|
+
const blockRect = targetBlock.getBoundingClientRect();
|
|
10275
|
+
x = pointX > editorCenterX ? blockRect.right - 5 : blockRect.left;
|
|
10276
|
+
}
|
|
10277
|
+
}
|
|
10265
10278
|
for (let i = 0; i < yOffsets.length; i++) {
|
|
10266
10279
|
const elem = document.elementsFromPoint(x, y + yOffsets[i])[0];
|
|
10267
10280
|
if (!elem) {
|
|
@@ -11210,6 +11223,191 @@ var __publicField = (obj, key, value) => {
|
|
|
11210
11223
|
background.remove();
|
|
11211
11224
|
});
|
|
11212
11225
|
}
|
|
11226
|
+
const logger$3w = getLogger("line-breaker");
|
|
11227
|
+
function getRects(textNode) {
|
|
11228
|
+
const range = document.createRange();
|
|
11229
|
+
range.setStart(textNode, 0);
|
|
11230
|
+
range.setEnd(textNode, textNode.data.length);
|
|
11231
|
+
return range.getClientRects();
|
|
11232
|
+
}
|
|
11233
|
+
function getLineBreaks(block) {
|
|
11234
|
+
const isWrappedChild = (child) => {
|
|
11235
|
+
const first = getFirstClientRect(child);
|
|
11236
|
+
const last = getLastClientRect(child);
|
|
11237
|
+
return last.top > first.top + first.height / 2;
|
|
11238
|
+
};
|
|
11239
|
+
const nextChildStartsNewLine = (child, nextChild) => {
|
|
11240
|
+
const currRect = getLastClientRect(child);
|
|
11241
|
+
const nextRect = getFirstClientRect(nextChild);
|
|
11242
|
+
const ret = Math.floor(nextRect.left) < Math.floor(currRect.right);
|
|
11243
|
+
return ret;
|
|
11244
|
+
};
|
|
11245
|
+
const endAtNewLine = (prev, box) => {
|
|
11246
|
+
const currRect = getLastClientRect(prev);
|
|
11247
|
+
const endRect = getLastClientRect(box);
|
|
11248
|
+
return endRect.top + endRect.height / 2 > currRect.bottom;
|
|
11249
|
+
};
|
|
11250
|
+
const lineBreaks = [];
|
|
11251
|
+
let offset = 0;
|
|
11252
|
+
const children = getTextBlockContentChildren(block);
|
|
11253
|
+
for (let i = 0; i < children.length; i++) {
|
|
11254
|
+
const child = children[i];
|
|
11255
|
+
if (isTextBlockContentInsertionChild(child)) {
|
|
11256
|
+
const insertion = child;
|
|
11257
|
+
const nextChild = children[i + 1];
|
|
11258
|
+
if (!nextChild) {
|
|
11259
|
+
break;
|
|
11260
|
+
}
|
|
11261
|
+
const prevChild = children[i - 1];
|
|
11262
|
+
if (prevChild) {
|
|
11263
|
+
if (endAtNewLine(prevChild, insertion)) {
|
|
11264
|
+
lineBreaks.push({
|
|
11265
|
+
offset,
|
|
11266
|
+
type: "betweenChild",
|
|
11267
|
+
childInfo: {
|
|
11268
|
+
prevChild,
|
|
11269
|
+
nextChild: insertion,
|
|
11270
|
+
wrap: "nextWrapped",
|
|
11271
|
+
prevWrapped: isWrappedChild(prevChild),
|
|
11272
|
+
nextWrapped: isWrappedChild(insertion)
|
|
11273
|
+
}
|
|
11274
|
+
});
|
|
11275
|
+
}
|
|
11276
|
+
}
|
|
11277
|
+
if (nextChildStartsNewLine(insertion, nextChild)) {
|
|
11278
|
+
lineBreaks.push({
|
|
11279
|
+
offset,
|
|
11280
|
+
type: "betweenChild",
|
|
11281
|
+
childInfo: {
|
|
11282
|
+
prevChild,
|
|
11283
|
+
nextChild: insertion,
|
|
11284
|
+
wrap: "nowrap",
|
|
11285
|
+
prevWrapped: isWrappedChild(prevChild),
|
|
11286
|
+
nextWrapped: isWrappedChild(insertion)
|
|
11287
|
+
}
|
|
11288
|
+
});
|
|
11289
|
+
continue;
|
|
11290
|
+
}
|
|
11291
|
+
continue;
|
|
11292
|
+
}
|
|
11293
|
+
if (isTextBlockContentBoxChild(child)) {
|
|
11294
|
+
const boxChild = child;
|
|
11295
|
+
const nextChild = children[i + 1];
|
|
11296
|
+
if (!nextChild) {
|
|
11297
|
+
break;
|
|
11298
|
+
}
|
|
11299
|
+
const prevChild = children[i - 1];
|
|
11300
|
+
if (prevChild) {
|
|
11301
|
+
if (endAtNewLine(prevChild, boxChild)) {
|
|
11302
|
+
lineBreaks.push({
|
|
11303
|
+
offset,
|
|
11304
|
+
type: "betweenChild",
|
|
11305
|
+
childInfo: {
|
|
11306
|
+
prevChild,
|
|
11307
|
+
nextChild: boxChild,
|
|
11308
|
+
wrap: "nextWrapped",
|
|
11309
|
+
prevWrapped: isWrappedChild(prevChild),
|
|
11310
|
+
nextWrapped: isWrappedChild(boxChild)
|
|
11311
|
+
}
|
|
11312
|
+
});
|
|
11313
|
+
}
|
|
11314
|
+
}
|
|
11315
|
+
if (nextChildStartsNewLine(boxChild, nextChild)) {
|
|
11316
|
+
offset += 1;
|
|
11317
|
+
lineBreaks.push({
|
|
11318
|
+
offset,
|
|
11319
|
+
type: "betweenChild",
|
|
11320
|
+
childInfo: {
|
|
11321
|
+
prevChild,
|
|
11322
|
+
nextChild: child,
|
|
11323
|
+
wrap: "nowrap",
|
|
11324
|
+
prevWrapped: isWrappedChild(prevChild),
|
|
11325
|
+
nextWrapped: isWrappedChild(child)
|
|
11326
|
+
}
|
|
11327
|
+
});
|
|
11328
|
+
continue;
|
|
11329
|
+
}
|
|
11330
|
+
offset += 1;
|
|
11331
|
+
continue;
|
|
11332
|
+
}
|
|
11333
|
+
const textChild = child;
|
|
11334
|
+
const rects = textChild.getClientRects();
|
|
11335
|
+
assert(logger$3w, rects.length > 0, "invalid text child dom");
|
|
11336
|
+
if (rects.length === 1) {
|
|
11337
|
+
const nextChild = children[i + 1];
|
|
11338
|
+
if (!nextChild) {
|
|
11339
|
+
break;
|
|
11340
|
+
}
|
|
11341
|
+
if (nextChildStartsNewLine(textChild, nextChild)) {
|
|
11342
|
+
offset += getTextBlockContentChildTextLength(textChild);
|
|
11343
|
+
lineBreaks.push({
|
|
11344
|
+
offset,
|
|
11345
|
+
type: "betweenChild",
|
|
11346
|
+
childInfo: {
|
|
11347
|
+
prevChild: textChild,
|
|
11348
|
+
nextChild,
|
|
11349
|
+
wrap: "nowrap",
|
|
11350
|
+
prevWrapped: isWrappedChild(textChild),
|
|
11351
|
+
nextWrapped: isWrappedChild(nextChild)
|
|
11352
|
+
}
|
|
11353
|
+
});
|
|
11354
|
+
continue;
|
|
11355
|
+
}
|
|
11356
|
+
offset += getTextBlockContentChildTextLength(textChild);
|
|
11357
|
+
continue;
|
|
11358
|
+
}
|
|
11359
|
+
const textNode = textChild.firstChild;
|
|
11360
|
+
assert(logger$3w, textNode, "invalid text child, no text node");
|
|
11361
|
+
assert(logger$3w, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
|
|
11362
|
+
const textChildLength = getTextBlockContentChildTextLength(textChild);
|
|
11363
|
+
assert(logger$3w, textNode.data.length === textChildLength, "text node data length not equal child text length");
|
|
11364
|
+
const textRects = getRects(textNode);
|
|
11365
|
+
for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
|
|
11366
|
+
const rect = textRects[rIndex];
|
|
11367
|
+
const offsetInfo = getOffsetFromPoint(rect.right, rect.top);
|
|
11368
|
+
if (offsetInfo.offset > -1 && offsetInfo.textNode === textNode) {
|
|
11369
|
+
lineBreaks.push({
|
|
11370
|
+
offset: offset + offsetInfo.offset,
|
|
11371
|
+
type: "textBreakWord",
|
|
11372
|
+
childInfo: {
|
|
11373
|
+
prevChild: child,
|
|
11374
|
+
nextChild: child,
|
|
11375
|
+
wrap: "nowrap",
|
|
11376
|
+
prevWrapped: isWrappedChild(child),
|
|
11377
|
+
nextWrapped: isWrappedChild(child)
|
|
11378
|
+
}
|
|
11379
|
+
});
|
|
11380
|
+
}
|
|
11381
|
+
}
|
|
11382
|
+
offset += textChildLength;
|
|
11383
|
+
}
|
|
11384
|
+
return lineBreaks;
|
|
11385
|
+
}
|
|
11386
|
+
function getLineIndex(block, position) {
|
|
11387
|
+
const lineBreaks = getLineBreaks(block);
|
|
11388
|
+
for (let i = 0; i < lineBreaks.length; i++) {
|
|
11389
|
+
const { offset } = lineBreaks[i];
|
|
11390
|
+
if (position.offset < offset) {
|
|
11391
|
+
return {
|
|
11392
|
+
lineIndex: i,
|
|
11393
|
+
lineBreaks
|
|
11394
|
+
};
|
|
11395
|
+
}
|
|
11396
|
+
if (position.offset === offset) {
|
|
11397
|
+
if (position.type === "end") {
|
|
11398
|
+
return {
|
|
11399
|
+
lineIndex: i,
|
|
11400
|
+
lineBreaks
|
|
11401
|
+
};
|
|
11402
|
+
}
|
|
11403
|
+
}
|
|
11404
|
+
}
|
|
11405
|
+
assert(logger$3w, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
|
|
11406
|
+
return {
|
|
11407
|
+
lineIndex: lineBreaks.length,
|
|
11408
|
+
lineBreaks
|
|
11409
|
+
};
|
|
11410
|
+
}
|
|
11213
11411
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
11214
11412
|
var lib$1 = {};
|
|
11215
11413
|
var Graphemer$1 = {};
|
|
@@ -19977,7 +20175,7 @@ var __publicField = (obj, key, value) => {
|
|
|
19977
20175
|
const Graphemer_1 = __importDefault(Graphemer$1);
|
|
19978
20176
|
var _default = lib$1.default = Graphemer_1.default;
|
|
19979
20177
|
const splitter = new _default();
|
|
19980
|
-
const logger$
|
|
20178
|
+
const logger$3v = getLogger("text-offset");
|
|
19981
20179
|
function getChildOffset(block, child) {
|
|
19982
20180
|
const children = getTextBlockContentChildren(block);
|
|
19983
20181
|
let start = 0;
|
|
@@ -19993,26 +20191,26 @@ var __publicField = (obj, key, value) => {
|
|
|
19993
20191
|
}
|
|
19994
20192
|
start += testLength;
|
|
19995
20193
|
}
|
|
19996
|
-
assert(logger$
|
|
20194
|
+
assert(logger$3v, false, "can not find child in children");
|
|
19997
20195
|
}
|
|
19998
20196
|
function isValidOffset(block, blockOffset) {
|
|
19999
|
-
assert(logger$
|
|
20197
|
+
assert(logger$3v, blockOffset >= 0, `invalid offset: ${blockOffset}`);
|
|
20000
20198
|
const childInfo = getTextBlockChild(block, blockOffset);
|
|
20001
20199
|
const { prev, next, offset } = childInfo;
|
|
20002
20200
|
if (!prev && !next) {
|
|
20003
|
-
assert(logger$
|
|
20201
|
+
assert(logger$3v, false, "invalid offset, no prev & next child at offset");
|
|
20004
20202
|
}
|
|
20005
20203
|
if (prev !== next) {
|
|
20006
20204
|
return true;
|
|
20007
20205
|
}
|
|
20008
20206
|
const child = prev;
|
|
20009
|
-
assert(logger$
|
|
20207
|
+
assert(logger$3v, child, "no child");
|
|
20010
20208
|
if (isTextBlockContentBoxChild(child)) {
|
|
20011
|
-
assert(logger$
|
|
20209
|
+
assert(logger$3v, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
|
|
20012
20210
|
return true;
|
|
20013
20211
|
}
|
|
20014
20212
|
const text2 = child.textContent;
|
|
20015
|
-
assert(logger$
|
|
20213
|
+
assert(logger$3v, text2, "no content for text child");
|
|
20016
20214
|
const chars = splitter.splitGraphemes(text2);
|
|
20017
20215
|
const validOffsets = /* @__PURE__ */ new Set();
|
|
20018
20216
|
let start = 0;
|
|
@@ -20042,7 +20240,7 @@ var __publicField = (obj, key, value) => {
|
|
|
20042
20240
|
}
|
|
20043
20241
|
function getNextValidOffset(block, blockOffset) {
|
|
20044
20242
|
const length = getTextBlockLength(block);
|
|
20045
|
-
assert(logger$
|
|
20243
|
+
assert(logger$3v, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
|
|
20046
20244
|
if (blockOffset === length) {
|
|
20047
20245
|
return length;
|
|
20048
20246
|
}
|
|
@@ -20056,229 +20254,6 @@ var __publicField = (obj, key, value) => {
|
|
|
20056
20254
|
}
|
|
20057
20255
|
return ret;
|
|
20058
20256
|
}
|
|
20059
|
-
const logger$3v = getLogger("line-breaker");
|
|
20060
|
-
function getLineBreaks(block) {
|
|
20061
|
-
const isWrappedChild = (child) => {
|
|
20062
|
-
const first = getFirstClientRect(child);
|
|
20063
|
-
const last = getLastClientRect(child);
|
|
20064
|
-
return last.top > first.top + first.height / 2;
|
|
20065
|
-
};
|
|
20066
|
-
const nextChildStartsNewLine = (child, nextChild) => {
|
|
20067
|
-
const currRect = getLastClientRect(child);
|
|
20068
|
-
const nextRect = getFirstClientRect(nextChild);
|
|
20069
|
-
const ret = Math.floor(nextRect.left) < Math.floor(currRect.right);
|
|
20070
|
-
return ret;
|
|
20071
|
-
};
|
|
20072
|
-
const endAtNewLine = (prev, box) => {
|
|
20073
|
-
const currRect = getLastClientRect(prev);
|
|
20074
|
-
const endRect = getLastClientRect(box);
|
|
20075
|
-
return endRect.top + endRect.height / 2 > currRect.bottom;
|
|
20076
|
-
};
|
|
20077
|
-
const isBreakWordRects = (rects) => {
|
|
20078
|
-
if (rects.length === 0) {
|
|
20079
|
-
return false;
|
|
20080
|
-
}
|
|
20081
|
-
if (rects.length === 1) {
|
|
20082
|
-
return false;
|
|
20083
|
-
}
|
|
20084
|
-
const first = rects[0];
|
|
20085
|
-
const last = rects[rects.length - 1];
|
|
20086
|
-
return Math.floor(first.right) - Math.floor(last.left) > 10;
|
|
20087
|
-
};
|
|
20088
|
-
const lineBreaks = [];
|
|
20089
|
-
let offset = 0;
|
|
20090
|
-
const children = getTextBlockContentChildren(block);
|
|
20091
|
-
for (let i = 0; i < children.length; i++) {
|
|
20092
|
-
const child = children[i];
|
|
20093
|
-
if (isTextBlockContentInsertionChild(child)) {
|
|
20094
|
-
const insertion = child;
|
|
20095
|
-
const nextChild = children[i + 1];
|
|
20096
|
-
if (!nextChild) {
|
|
20097
|
-
break;
|
|
20098
|
-
}
|
|
20099
|
-
const prevChild = children[i - 1];
|
|
20100
|
-
if (prevChild) {
|
|
20101
|
-
if (endAtNewLine(prevChild, insertion)) {
|
|
20102
|
-
lineBreaks.push({
|
|
20103
|
-
offset,
|
|
20104
|
-
type: "betweenChild",
|
|
20105
|
-
childInfo: {
|
|
20106
|
-
prevChild,
|
|
20107
|
-
nextChild: insertion,
|
|
20108
|
-
wrap: "nextWrapped",
|
|
20109
|
-
prevWrapped: isWrappedChild(prevChild),
|
|
20110
|
-
nextWrapped: isWrappedChild(insertion)
|
|
20111
|
-
}
|
|
20112
|
-
});
|
|
20113
|
-
}
|
|
20114
|
-
}
|
|
20115
|
-
if (nextChildStartsNewLine(insertion, nextChild)) {
|
|
20116
|
-
lineBreaks.push({
|
|
20117
|
-
offset,
|
|
20118
|
-
type: "betweenChild",
|
|
20119
|
-
childInfo: {
|
|
20120
|
-
prevChild,
|
|
20121
|
-
nextChild: insertion,
|
|
20122
|
-
wrap: "nowrap",
|
|
20123
|
-
prevWrapped: isWrappedChild(prevChild),
|
|
20124
|
-
nextWrapped: isWrappedChild(insertion)
|
|
20125
|
-
}
|
|
20126
|
-
});
|
|
20127
|
-
continue;
|
|
20128
|
-
}
|
|
20129
|
-
continue;
|
|
20130
|
-
}
|
|
20131
|
-
if (isTextBlockContentBoxChild(child)) {
|
|
20132
|
-
const boxChild = child;
|
|
20133
|
-
const nextChild = children[i + 1];
|
|
20134
|
-
if (!nextChild) {
|
|
20135
|
-
break;
|
|
20136
|
-
}
|
|
20137
|
-
const prevChild = children[i - 1];
|
|
20138
|
-
if (prevChild) {
|
|
20139
|
-
if (endAtNewLine(prevChild, boxChild)) {
|
|
20140
|
-
lineBreaks.push({
|
|
20141
|
-
offset,
|
|
20142
|
-
type: "betweenChild",
|
|
20143
|
-
childInfo: {
|
|
20144
|
-
prevChild,
|
|
20145
|
-
nextChild: boxChild,
|
|
20146
|
-
wrap: "nextWrapped",
|
|
20147
|
-
prevWrapped: isWrappedChild(prevChild),
|
|
20148
|
-
nextWrapped: isWrappedChild(boxChild)
|
|
20149
|
-
}
|
|
20150
|
-
});
|
|
20151
|
-
}
|
|
20152
|
-
}
|
|
20153
|
-
if (nextChildStartsNewLine(boxChild, nextChild)) {
|
|
20154
|
-
offset += 1;
|
|
20155
|
-
lineBreaks.push({
|
|
20156
|
-
offset,
|
|
20157
|
-
type: "betweenChild",
|
|
20158
|
-
childInfo: {
|
|
20159
|
-
prevChild,
|
|
20160
|
-
nextChild: child,
|
|
20161
|
-
wrap: "nowrap",
|
|
20162
|
-
prevWrapped: isWrappedChild(prevChild),
|
|
20163
|
-
nextWrapped: isWrappedChild(child)
|
|
20164
|
-
}
|
|
20165
|
-
});
|
|
20166
|
-
continue;
|
|
20167
|
-
}
|
|
20168
|
-
offset += 1;
|
|
20169
|
-
continue;
|
|
20170
|
-
}
|
|
20171
|
-
const textChild = child;
|
|
20172
|
-
const rects = textChild.getClientRects();
|
|
20173
|
-
assert(logger$3v, rects.length > 0, "invalid text child dom");
|
|
20174
|
-
if (rects.length === 1) {
|
|
20175
|
-
const nextChild = children[i + 1];
|
|
20176
|
-
if (!nextChild) {
|
|
20177
|
-
break;
|
|
20178
|
-
}
|
|
20179
|
-
if (nextChildStartsNewLine(textChild, nextChild)) {
|
|
20180
|
-
offset += getTextBlockContentChildTextLength(textChild);
|
|
20181
|
-
lineBreaks.push({
|
|
20182
|
-
offset,
|
|
20183
|
-
type: "betweenChild",
|
|
20184
|
-
childInfo: {
|
|
20185
|
-
prevChild: textChild,
|
|
20186
|
-
nextChild,
|
|
20187
|
-
wrap: "nowrap",
|
|
20188
|
-
prevWrapped: isWrappedChild(textChild),
|
|
20189
|
-
nextWrapped: isWrappedChild(nextChild)
|
|
20190
|
-
}
|
|
20191
|
-
});
|
|
20192
|
-
continue;
|
|
20193
|
-
}
|
|
20194
|
-
offset += getTextBlockContentChildTextLength(textChild);
|
|
20195
|
-
continue;
|
|
20196
|
-
}
|
|
20197
|
-
const textNode = textChild.firstChild;
|
|
20198
|
-
assert(logger$3v, textNode, "invalid text child, no text node");
|
|
20199
|
-
assert(logger$3v, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
|
|
20200
|
-
const range = document.createRange();
|
|
20201
|
-
const rangeNext = document.createRange();
|
|
20202
|
-
const textChildLength = getTextBlockContentChildTextLength(textChild);
|
|
20203
|
-
assert(logger$3v, textNode.data.length === textChildLength, "text node data length not equal child text length");
|
|
20204
|
-
for (let subOffset = 0; subOffset < textNode.data.length; subOffset++) {
|
|
20205
|
-
if (!isValidOffset(block, offset + subOffset)) {
|
|
20206
|
-
continue;
|
|
20207
|
-
}
|
|
20208
|
-
range.setStart(textNode, subOffset);
|
|
20209
|
-
const currRects = range.getClientRects();
|
|
20210
|
-
assert(logger$3v, currRects.length >= 1, "invalid text node, no client rects");
|
|
20211
|
-
if (isBreakWordRects(currRects)) {
|
|
20212
|
-
const newOffset = offset + subOffset;
|
|
20213
|
-
lineBreaks.push({
|
|
20214
|
-
offset: newOffset,
|
|
20215
|
-
type: "textBreakWord",
|
|
20216
|
-
childInfo: {
|
|
20217
|
-
prevChild: child,
|
|
20218
|
-
nextChild: child,
|
|
20219
|
-
wrap: "nowrap",
|
|
20220
|
-
prevWrapped: isWrappedChild(child),
|
|
20221
|
-
nextWrapped: isWrappedChild(child)
|
|
20222
|
-
}
|
|
20223
|
-
});
|
|
20224
|
-
continue;
|
|
20225
|
-
}
|
|
20226
|
-
let nextSubOffset = subOffset + 1;
|
|
20227
|
-
if (!isValidOffset(block, offset + nextSubOffset)) {
|
|
20228
|
-
nextSubOffset = subOffset + 2;
|
|
20229
|
-
}
|
|
20230
|
-
rangeNext.setStart(textNode, nextSubOffset);
|
|
20231
|
-
const nextRects = rangeNext.getClientRects();
|
|
20232
|
-
const currRect = currRects[0];
|
|
20233
|
-
const nextRect = nextRects[0];
|
|
20234
|
-
if (Math.floor(nextRect.left) < Math.floor(currRect.right)) {
|
|
20235
|
-
if (isFirefox() || isSafari()) {
|
|
20236
|
-
lineBreaks.push({
|
|
20237
|
-
offset: isSafari() ? offset + nextSubOffset : offset + subOffset,
|
|
20238
|
-
type: "textBreakWord",
|
|
20239
|
-
childInfo: {
|
|
20240
|
-
prevChild: child,
|
|
20241
|
-
nextChild: child,
|
|
20242
|
-
wrap: "nowrap",
|
|
20243
|
-
prevWrapped: isWrappedChild(child),
|
|
20244
|
-
nextWrapped: isWrappedChild(child)
|
|
20245
|
-
}
|
|
20246
|
-
});
|
|
20247
|
-
continue;
|
|
20248
|
-
} else {
|
|
20249
|
-
assert(logger$3v, false, "span pre-wrap should not has a line-wrap by white space");
|
|
20250
|
-
}
|
|
20251
|
-
}
|
|
20252
|
-
}
|
|
20253
|
-
offset += textChildLength;
|
|
20254
|
-
}
|
|
20255
|
-
return lineBreaks;
|
|
20256
|
-
}
|
|
20257
|
-
function getLineIndex(block, position) {
|
|
20258
|
-
const lineBreaks = getLineBreaks(block);
|
|
20259
|
-
for (let i = 0; i < lineBreaks.length; i++) {
|
|
20260
|
-
const { offset, type } = lineBreaks[i];
|
|
20261
|
-
if (position.offset < offset) {
|
|
20262
|
-
return {
|
|
20263
|
-
lineIndex: i,
|
|
20264
|
-
lineBreaks
|
|
20265
|
-
};
|
|
20266
|
-
}
|
|
20267
|
-
if (position.offset === offset) {
|
|
20268
|
-
if (position.type === "end") {
|
|
20269
|
-
return {
|
|
20270
|
-
lineIndex: i,
|
|
20271
|
-
lineBreaks
|
|
20272
|
-
};
|
|
20273
|
-
}
|
|
20274
|
-
}
|
|
20275
|
-
}
|
|
20276
|
-
assert(logger$3v, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
|
|
20277
|
-
return {
|
|
20278
|
-
lineIndex: lineBreaks.length,
|
|
20279
|
-
lineBreaks
|
|
20280
|
-
};
|
|
20281
|
-
}
|
|
20282
20257
|
const logger$3u = getLogger("line-offset");
|
|
20283
20258
|
function getLineOffsets(block) {
|
|
20284
20259
|
const lineBreaks = getLineBreaks(block);
|
|
@@ -39653,6 +39628,10 @@ var __publicField = (obj, key, value) => {
|
|
|
39653
39628
|
const leftWidths = widths.slice(0, colIndex).reduce((a, b) => a + b, 0);
|
|
39654
39629
|
const colWidth = totalWidth - leftWidths;
|
|
39655
39630
|
setColumnWidth(table, colIndex, colWidth);
|
|
39631
|
+
if (colWidth) {
|
|
39632
|
+
const tableWidth = parseFloat(table.style.minWidth);
|
|
39633
|
+
table.style.minWidth = `${tableWidth + (colWidth - widths[colIndex])}px`;
|
|
39634
|
+
}
|
|
39656
39635
|
updateResizeGripper(this.editor, block, draggingRefCell);
|
|
39657
39636
|
this.editor.selection.caret.update();
|
|
39658
39637
|
}
|
|
@@ -46176,6 +46155,7 @@ $$${mathData.mathjaxText}$$
|
|
|
46176
46155
|
}
|
|
46177
46156
|
}
|
|
46178
46157
|
assert(logger$1k, containerIndex === tableData.children.length, "container count mismatch");
|
|
46158
|
+
table.style.minWidth = `${colsWidth.reduce((pre, cur) => cur + pre, 0)}px`;
|
|
46179
46159
|
if (tableData.noBorder) {
|
|
46180
46160
|
addClass(table, "no-border");
|
|
46181
46161
|
}
|
|
@@ -48174,8 +48154,8 @@ ${codeText}
|
|
|
48174
48154
|
\`\`\`
|
|
48175
48155
|
${captionText}`;
|
|
48176
48156
|
}
|
|
48177
|
-
return `<p><pre><code>${codeText}</code></pre></p>
|
|
48178
|
-
<p>${captionText}</p>`;
|
|
48157
|
+
return `<p><pre><code>${escapeHtmlText(codeText)}</code></pre></p>
|
|
48158
|
+
<p>${escapeHtmlText(captionText)}</p>`;
|
|
48179
48159
|
}
|
|
48180
48160
|
const CodeBlock = {
|
|
48181
48161
|
blockType: "code",
|
|
@@ -60781,9 +60761,16 @@ ${codeText}
|
|
|
60781
60761
|
assert(logger$l, data.text, `no text for text box data: ${JSON.stringify(boxData)}`);
|
|
60782
60762
|
assert(logger$l, typeof data.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
|
|
60783
60763
|
const oldBoxData = data.oldAttr;
|
|
60784
|
-
|
|
60785
|
-
|
|
60786
|
-
|
|
60764
|
+
if (oldBoxData && oldBoxData.box) {
|
|
60765
|
+
const childBoxElement = createBoxElement(oldBoxData);
|
|
60766
|
+
const childBoxContent = createBoxContentElement(childBoxElement);
|
|
60767
|
+
const boxClass = editor.editorBoxes.getBoxClass(oldBoxData.type);
|
|
60768
|
+
if (boxClass) {
|
|
60769
|
+
boxClass.updateBoxContent(editor, childBoxElement, childBoxContent, oldBoxData);
|
|
60770
|
+
}
|
|
60771
|
+
boxContent.appendChild(childBoxElement);
|
|
60772
|
+
} else {
|
|
60773
|
+
createElement("span", [], boxContent, data.text);
|
|
60787
60774
|
}
|
|
60788
60775
|
addClass(boxContent, "history-deleted-box");
|
|
60789
60776
|
const user = data.user;
|
|
@@ -72993,6 +72980,7 @@ ${data.flowchartText}
|
|
|
72993
72980
|
exports2.getNextBlock = getNextBlock;
|
|
72994
72981
|
exports2.getNextValidOffset = getNextValidOffset;
|
|
72995
72982
|
exports2.getNextVisibleBlock = getNextVisibleBlock;
|
|
72983
|
+
exports2.getOffsetFromPoint = getOffsetFromPoint;
|
|
72996
72984
|
exports2.getOffsetInfoAfter = getOffsetInfoAfter;
|
|
72997
72985
|
exports2.getOffsetInfoBefore = getOffsetInfoBefore;
|
|
72998
72986
|
exports2.getOpAt = getOpAt;
|