@ones-editor/editor 2.6.1-beta.2 → 2.7.1-beta.1
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/@ones-editor/core/src/core/blocks/common/block-dom.d.ts +2 -3
- package/@ones-editor/core/src/core/blocks/text-blocks/base/block-text.d.ts +1 -1
- package/@ones-editor/core/src/core/input-handler/actions.d.ts +0 -4
- package/@ones-editor/core/src/core/input-handler/handle-delete.d.ts +0 -4
- package/@ones-editor/core/src/core/selection/actions/index.d.ts +1 -3
- package/@ones-editor/core/src/utils/character.d.ts +0 -1
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/ui/src/index.d.ts +2 -2
- package/@ones-editor/ui/src/shortcuts/index.d.ts +2 -3
- package/@ones-editor/ui/src/shortcuts/text-style-shortcuts.d.ts +2 -1
- package/@ones-editor/ui-base/src/color-button/index.d.ts +2 -1
- package/@ones-editor/ui-base/src/color-button/text-color-item.d.ts +0 -2
- package/dist/index.js +481 -806
- package/package.json +1 -1
- package/@ones-editor/core/src/core/selection/actions/move-block-end.d.ts +0 -2
- package/@ones-editor/core/src/core/selection/actions/move-block-start.d.ts +0 -2
- package/@ones-editor/ui/src/shortcuts/align-shortcuts.d.ts +0 -2
- package/@ones-editor/ui/src/shortcuts/text-color-shortcuts.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -335,12 +335,12 @@ div.editor-root div.editor-content div[data-type=editor-container] div[data-type
|
|
|
335
335
|
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.hover .embed-hover-content {
|
|
336
336
|
outline: 1px solid #0064ff;
|
|
337
337
|
}
|
|
338
|
-
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected > div[data-type=block-content],
|
|
339
|
-
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected .embed-selected-content {
|
|
338
|
+
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected:not(.no-mask) > div[data-type=block-content],
|
|
339
|
+
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected:not(.no-mask) .embed-selected-content {
|
|
340
340
|
position: relative;
|
|
341
341
|
}
|
|
342
|
-
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected > div[data-type=block-content]::before,
|
|
343
|
-
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected .embed-selected-content::before {
|
|
342
|
+
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected:not(.no-mask) > div[data-type=block-content]::before,
|
|
343
|
+
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected:not(.no-mask) .embed-selected-content::before {
|
|
344
344
|
content: " ";
|
|
345
345
|
position: absolute;
|
|
346
346
|
left: 0;
|
|
@@ -8901,7 +8901,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8901
8901
|
imageExportFailed: "\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F"
|
|
8902
8902
|
}
|
|
8903
8903
|
};
|
|
8904
|
-
const logger$
|
|
8904
|
+
const logger$4R = getLogger("i18n");
|
|
8905
8905
|
const langs$3 = {
|
|
8906
8906
|
"en-US": enUS$x,
|
|
8907
8907
|
"zh-CN": zhCN$x,
|
|
@@ -8921,7 +8921,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8921
8921
|
function t$8(key, args) {
|
|
8922
8922
|
const ret = i18n.get(key, args);
|
|
8923
8923
|
if (ret === key) {
|
|
8924
|
-
logger$
|
|
8924
|
+
logger$4R.warn(`no locale value for key ${key}`);
|
|
8925
8925
|
}
|
|
8926
8926
|
return ret;
|
|
8927
8927
|
}
|
|
@@ -9534,7 +9534,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9534
9534
|
this._callbacks.clear();
|
|
9535
9535
|
}
|
|
9536
9536
|
}
|
|
9537
|
-
const logger$
|
|
9537
|
+
const logger$4Q = getLogger("await-locker");
|
|
9538
9538
|
class AwaitLock {
|
|
9539
9539
|
constructor() {
|
|
9540
9540
|
__publicField(this, "_acquired", false);
|
|
@@ -9576,7 +9576,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9576
9576
|
}
|
|
9577
9577
|
if (this._waitingResolvers.length > 0) {
|
|
9578
9578
|
const resolve = this._waitingResolvers.shift();
|
|
9579
|
-
assert(logger$
|
|
9579
|
+
assert(logger$4Q, resolve, "Resolver missing");
|
|
9580
9580
|
resolve(void 0);
|
|
9581
9581
|
} else {
|
|
9582
9582
|
this._acquired = false;
|
|
@@ -9659,7 +9659,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9659
9659
|
isMobileSafari: false
|
|
9660
9660
|
};
|
|
9661
9661
|
clientType.isMobileSafari = clientType.isMobile && clientType.isSafari;
|
|
9662
|
-
const logger$
|
|
9662
|
+
const logger$4P = getLogger("dom-utils");
|
|
9663
9663
|
function addClass(dom, ...className) {
|
|
9664
9664
|
if (dom && dom.nodeType === Node.ELEMENT_NODE) {
|
|
9665
9665
|
dom.classList.add(...className);
|
|
@@ -9713,7 +9713,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9713
9713
|
range.setStart(node, offset);
|
|
9714
9714
|
return range;
|
|
9715
9715
|
} catch (err) {
|
|
9716
|
-
assert(logger$
|
|
9716
|
+
assert(logger$4P, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
|
|
9717
9717
|
}
|
|
9718
9718
|
}
|
|
9719
9719
|
function createExpandedRange(startNode, startOffset, endNode, endOffset) {
|
|
@@ -9723,17 +9723,17 @@ var __publicField = (obj, key, value) => {
|
|
|
9723
9723
|
range.setEnd(endNode, endOffset);
|
|
9724
9724
|
return range;
|
|
9725
9725
|
} catch (err) {
|
|
9726
|
-
assert(logger$
|
|
9726
|
+
assert(logger$4P, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
|
|
9727
9727
|
}
|
|
9728
9728
|
}
|
|
9729
9729
|
function getFirstClientRect(elem) {
|
|
9730
9730
|
const rects = elem.getClientRects();
|
|
9731
|
-
assert(logger$
|
|
9731
|
+
assert(logger$4P, rects.length >= 1, "getFirstClientRect: no rects");
|
|
9732
9732
|
return rects[0];
|
|
9733
9733
|
}
|
|
9734
9734
|
function getLastClientRect(elem) {
|
|
9735
9735
|
const rects = elem.getClientRects();
|
|
9736
|
-
assert(logger$
|
|
9736
|
+
assert(logger$4P, rects.length >= 1, "getLastClientRect: no rects");
|
|
9737
9737
|
return rects[rects.length - 1];
|
|
9738
9738
|
}
|
|
9739
9739
|
function getDistanceSquare(rect, x, y) {
|
|
@@ -9780,7 +9780,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9780
9780
|
return 0;
|
|
9781
9781
|
}
|
|
9782
9782
|
if (!elem1.parentElement || !elem2.parentElement) {
|
|
9783
|
-
assert(logger$
|
|
9783
|
+
assert(logger$4P, false, "invalid dom node to compare");
|
|
9784
9784
|
}
|
|
9785
9785
|
if (elem1.parentElement === elem2.parentElement) {
|
|
9786
9786
|
const children = Array.from(elem1.parentElement.children);
|
|
@@ -9797,7 +9797,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9797
9797
|
const parents1 = getParents(elem1);
|
|
9798
9798
|
const parents2 = getParents(elem2);
|
|
9799
9799
|
if (parents1[0] !== parents2[0]) {
|
|
9800
|
-
assert(logger$
|
|
9800
|
+
assert(logger$4P, false, "invalid dom node to compare, different tree");
|
|
9801
9801
|
}
|
|
9802
9802
|
for (let i = 1; ; i++) {
|
|
9803
9803
|
const parent1 = parents1[i];
|
|
@@ -10397,7 +10397,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10397
10397
|
}
|
|
10398
10398
|
}
|
|
10399
10399
|
const MIN_DISTANCE_THRESHOLD$3 = 3;
|
|
10400
|
-
const logger$
|
|
10400
|
+
const logger$4O = getLogger("drag-drop");
|
|
10401
10401
|
class DragDrop {
|
|
10402
10402
|
constructor(options) {
|
|
10403
10403
|
__publicField(this, "dragStarted", false);
|
|
@@ -10418,7 +10418,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10418
10418
|
var _a;
|
|
10419
10419
|
event.preventDefault();
|
|
10420
10420
|
event.stopPropagation();
|
|
10421
|
-
assert(logger$
|
|
10421
|
+
assert(logger$4O, this.mouseDownEvent, "no mouse down event");
|
|
10422
10422
|
const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
|
|
10423
10423
|
const newPos = DragDrop.getEventPosition(event);
|
|
10424
10424
|
const deltaX = newPos.x - oldPos.x;
|
|
@@ -10434,7 +10434,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10434
10434
|
});
|
|
10435
10435
|
__publicField(this, "handleMouseUp", (event) => {
|
|
10436
10436
|
if (event instanceof MouseEvent && event.button === 0 || event instanceof TouchEvent) {
|
|
10437
|
-
assert(logger$
|
|
10437
|
+
assert(logger$4O, this.mouseDownEvent, "no mouse down event");
|
|
10438
10438
|
const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
|
|
10439
10439
|
const newPos = DragDrop.getEventPosition(event);
|
|
10440
10440
|
const deltaX = newPos.x - oldPos.x;
|
|
@@ -10543,7 +10543,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10543
10543
|
const dragDrop = new DragDrop(options);
|
|
10544
10544
|
return dragDrop;
|
|
10545
10545
|
}
|
|
10546
|
-
const logger$
|
|
10546
|
+
const logger$4N = getLogger("character");
|
|
10547
10547
|
function checkChar(charCode, rangeList) {
|
|
10548
10548
|
for (let i = 0; i < rangeList.length; i++) {
|
|
10549
10549
|
const start = rangeList[i][0];
|
|
@@ -10588,13 +10588,9 @@ var __publicField = (obj, key, value) => {
|
|
|
10588
10588
|
];
|
|
10589
10589
|
return checkChar(str.charCodeAt(0), CJKRange);
|
|
10590
10590
|
}
|
|
10591
|
-
function isCJKPunctuation(char) {
|
|
10592
|
-
const reg = /[\u3000-\u303F\uFF00-\uFFEF\u2000-\u206F\u2E00-\u2E7F]/;
|
|
10593
|
-
return reg.test(char);
|
|
10594
|
-
}
|
|
10595
10591
|
function trimChar(s, char) {
|
|
10596
10592
|
let c = char;
|
|
10597
|
-
assert(logger$
|
|
10593
|
+
assert(logger$4N, c.length === 1, "invalid char length");
|
|
10598
10594
|
if (c === "]")
|
|
10599
10595
|
c = "\\]";
|
|
10600
10596
|
if (c === "\\")
|
|
@@ -10928,7 +10924,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10928
10924
|
const metrics = context.measureText(text2);
|
|
10929
10925
|
return metrics.width + 4;
|
|
10930
10926
|
}
|
|
10931
|
-
const logger$
|
|
10927
|
+
const logger$4M = getLogger("editor-clipboard");
|
|
10932
10928
|
async function setClipboardDataByEvent(items, event) {
|
|
10933
10929
|
if (event.clipboardData) {
|
|
10934
10930
|
const data2 = event.clipboardData;
|
|
@@ -10986,7 +10982,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10986
10982
|
document.body.removeChild(textarea2);
|
|
10987
10983
|
return true;
|
|
10988
10984
|
} catch (ex) {
|
|
10989
|
-
logger$
|
|
10985
|
+
logger$4M.error(ex);
|
|
10990
10986
|
document.body.removeChild(textarea2);
|
|
10991
10987
|
return false;
|
|
10992
10988
|
}
|
|
@@ -11007,7 +11003,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11007
11003
|
document.body.removeChild(div);
|
|
11008
11004
|
return true;
|
|
11009
11005
|
} catch (ex) {
|
|
11010
|
-
logger$
|
|
11006
|
+
logger$4M.error(ex);
|
|
11011
11007
|
document.body.removeChild(div);
|
|
11012
11008
|
return false;
|
|
11013
11009
|
}
|
|
@@ -11034,7 +11030,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11034
11030
|
await navigator.clipboard.write([clipboardItems]);
|
|
11035
11031
|
return true;
|
|
11036
11032
|
} catch (err) {
|
|
11037
|
-
logger$
|
|
11033
|
+
logger$4M.error(err);
|
|
11038
11034
|
return await execCommandCopy(items);
|
|
11039
11035
|
}
|
|
11040
11036
|
}
|
|
@@ -11090,7 +11086,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11090
11086
|
a.click();
|
|
11091
11087
|
a.remove();
|
|
11092
11088
|
}
|
|
11093
|
-
const logger$
|
|
11089
|
+
const logger$4L = getLogger("auto-scroll");
|
|
11094
11090
|
function scrollable(scrollElement, direction) {
|
|
11095
11091
|
if (scrollElement.scrollHeight === scrollElement.clientHeight) {
|
|
11096
11092
|
return false;
|
|
@@ -11114,7 +11110,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11114
11110
|
const isHorizontal = direction === "left" || direction === "right";
|
|
11115
11111
|
const scroll = () => {
|
|
11116
11112
|
if (!scrollable(scrollElement, direction)) {
|
|
11117
|
-
logger$
|
|
11113
|
+
logger$4L.debug("No need for scroll");
|
|
11118
11114
|
return null;
|
|
11119
11115
|
}
|
|
11120
11116
|
if (isHorizontal) {
|
|
@@ -11171,7 +11167,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11171
11167
|
if (this.scrolling) {
|
|
11172
11168
|
return;
|
|
11173
11169
|
}
|
|
11174
|
-
logger$
|
|
11170
|
+
logger$4L.debug(`scroll direction: ${direction}`);
|
|
11175
11171
|
this.cancelScroll = continuousScroll(scrollElement, {
|
|
11176
11172
|
direction,
|
|
11177
11173
|
step
|
|
@@ -11421,7 +11417,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11421
11417
|
const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
|
|
11422
11418
|
return ColorNames[colorIndex];
|
|
11423
11419
|
}
|
|
11424
|
-
const logger$
|
|
11420
|
+
const logger$4K = getLogger("container");
|
|
11425
11421
|
function isContainer(elem) {
|
|
11426
11422
|
return elem.getAttribute("data-type") === "editor-container";
|
|
11427
11423
|
}
|
|
@@ -11433,9 +11429,9 @@ var __publicField = (obj, key, value) => {
|
|
|
11433
11429
|
}
|
|
11434
11430
|
function getContainerId(container) {
|
|
11435
11431
|
const id = container.getAttribute("data-container-id");
|
|
11436
|
-
assert(logger$
|
|
11432
|
+
assert(logger$4K, id, "no id for container");
|
|
11437
11433
|
if (isRootContainer(container)) {
|
|
11438
|
-
assert(logger$
|
|
11434
|
+
assert(logger$4K, id === "root", `invalid root container id, : ${id}`);
|
|
11439
11435
|
}
|
|
11440
11436
|
return id;
|
|
11441
11437
|
}
|
|
@@ -11446,7 +11442,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11446
11442
|
function generateEditorContainerId(containerId) {
|
|
11447
11443
|
return `ones-editor-container-${containerId}`;
|
|
11448
11444
|
}
|
|
11449
|
-
const logger$
|
|
11445
|
+
const logger$4J = getLogger("element");
|
|
11450
11446
|
function createContainerElement(parent, type, containerId) {
|
|
11451
11447
|
const container = createElement("div", [type], parent);
|
|
11452
11448
|
container.setAttribute("data-type", "editor-container");
|
|
@@ -11457,7 +11453,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11457
11453
|
}
|
|
11458
11454
|
function getContainerById(editor, containerId) {
|
|
11459
11455
|
const container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
|
|
11460
|
-
assert(logger$
|
|
11456
|
+
assert(logger$4J, container, `no container: ${containerId}`);
|
|
11461
11457
|
return container;
|
|
11462
11458
|
}
|
|
11463
11459
|
function getExistsContainerById(editor, containerId) {
|
|
@@ -11466,7 +11462,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11466
11462
|
}
|
|
11467
11463
|
function getContainerBlocksElement(container) {
|
|
11468
11464
|
const blocks = container.querySelector(":scope > .container-blocks");
|
|
11469
|
-
assert(logger$
|
|
11465
|
+
assert(logger$4J, blocks, "no container blocks element");
|
|
11470
11466
|
return blocks;
|
|
11471
11467
|
}
|
|
11472
11468
|
function getContainerToolsElement(container) {
|
|
@@ -11479,11 +11475,11 @@ var __publicField = (obj, key, value) => {
|
|
|
11479
11475
|
function isContainerBlocksElement(element) {
|
|
11480
11476
|
return element.classList.contains("container-blocks");
|
|
11481
11477
|
}
|
|
11482
|
-
const logger$
|
|
11478
|
+
const logger$4I = getLogger("container-children");
|
|
11483
11479
|
function getChildBlocks(container, traverseChild) {
|
|
11484
11480
|
const content = getContainerBlocksElement(container);
|
|
11485
11481
|
const blocks = Array.from(content.children);
|
|
11486
|
-
assert(logger$
|
|
11482
|
+
assert(logger$4I, blocks.length > 0, "container have not any child block");
|
|
11487
11483
|
if (traverseChild) {
|
|
11488
11484
|
const { condition, editor } = traverseChild;
|
|
11489
11485
|
return blocks.reduce((result, block) => {
|
|
@@ -11506,7 +11502,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11506
11502
|
}
|
|
11507
11503
|
function getFirstChildBlock(container) {
|
|
11508
11504
|
const block = container.querySelector(":scope > .container-blocks > div[data-type=editor-block]");
|
|
11509
|
-
assert(logger$
|
|
11505
|
+
assert(logger$4I, block, "container have not any child block");
|
|
11510
11506
|
return block;
|
|
11511
11507
|
}
|
|
11512
11508
|
function getLastChildBlock(container) {
|
|
@@ -11518,14 +11514,14 @@ var __publicField = (obj, key, value) => {
|
|
|
11518
11514
|
}
|
|
11519
11515
|
function getBlockByIndex(container, blockIndex) {
|
|
11520
11516
|
const block = getChildBlocks(container)[blockIndex];
|
|
11521
|
-
assert(logger$
|
|
11517
|
+
assert(logger$4I, block, `container have not block at index ${blockIndex}`);
|
|
11522
11518
|
return block;
|
|
11523
11519
|
}
|
|
11524
11520
|
function findBlockByIndex(container, blockIndex) {
|
|
11525
11521
|
var _a;
|
|
11526
11522
|
return (_a = getChildBlocks(container)[blockIndex]) != null ? _a : null;
|
|
11527
11523
|
}
|
|
11528
|
-
const logger$
|
|
11524
|
+
const logger$4H = getLogger("block-dom");
|
|
11529
11525
|
function isBlock$1(node) {
|
|
11530
11526
|
if (!(node instanceof HTMLDivElement)) {
|
|
11531
11527
|
return false;
|
|
@@ -11546,12 +11542,12 @@ var __publicField = (obj, key, value) => {
|
|
|
11546
11542
|
}
|
|
11547
11543
|
function getBlockId(block) {
|
|
11548
11544
|
const { id } = block;
|
|
11549
|
-
assert(logger$
|
|
11545
|
+
assert(logger$4H, id, "no block id");
|
|
11550
11546
|
return id;
|
|
11551
11547
|
}
|
|
11552
11548
|
function getBlockType(block) {
|
|
11553
11549
|
const type = block.getAttribute("data-block-type");
|
|
11554
|
-
assert(logger$
|
|
11550
|
+
assert(logger$4H, type, "invalid block dom, no data-type");
|
|
11555
11551
|
return type;
|
|
11556
11552
|
}
|
|
11557
11553
|
function getParentBlock(node) {
|
|
@@ -11574,12 +11570,12 @@ var __publicField = (obj, key, value) => {
|
|
|
11574
11570
|
}
|
|
11575
11571
|
function getParentContainer(block) {
|
|
11576
11572
|
const container = block.closest("div[data-type=editor-container]");
|
|
11577
|
-
assert(logger$
|
|
11573
|
+
assert(logger$4H, container, "failed to get block container");
|
|
11578
11574
|
return container;
|
|
11579
11575
|
}
|
|
11580
11576
|
function getBlockContent(block) {
|
|
11581
11577
|
const content = block.querySelector(":scope >div[data-type=block-content]");
|
|
11582
|
-
assert(logger$
|
|
11578
|
+
assert(logger$4H, content, "no block content");
|
|
11583
11579
|
return content;
|
|
11584
11580
|
}
|
|
11585
11581
|
function getBlockTools(block) {
|
|
@@ -11588,7 +11584,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11588
11584
|
tools = createElement("div", [], block);
|
|
11589
11585
|
tools.setAttribute("data-type", "block-tools");
|
|
11590
11586
|
}
|
|
11591
|
-
assert(logger$
|
|
11587
|
+
assert(logger$4H, tools, "no block tools");
|
|
11592
11588
|
return tools;
|
|
11593
11589
|
}
|
|
11594
11590
|
function getExistsBlockTools(block) {
|
|
@@ -11609,7 +11605,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11609
11605
|
function createBlockElement(editor, path, data2) {
|
|
11610
11606
|
const blockData = editor.editorDecorators.decorateBlock(path, data2);
|
|
11611
11607
|
const { id, type } = blockData;
|
|
11612
|
-
assert(logger$
|
|
11608
|
+
assert(logger$4H, id, "no block id");
|
|
11613
11609
|
const elem = createElement("div", [`${type}-block`], null);
|
|
11614
11610
|
elem.id = id;
|
|
11615
11611
|
elem.setAttribute("data-type", "editor-block");
|
|
@@ -11647,7 +11643,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11647
11643
|
}
|
|
11648
11644
|
function getBoxTypeFromElement(box) {
|
|
11649
11645
|
const type = box.getAttribute("data-box-type");
|
|
11650
|
-
assert(logger$
|
|
11646
|
+
assert(logger$4H, type, "not a valid box element, no type");
|
|
11651
11647
|
return type;
|
|
11652
11648
|
}
|
|
11653
11649
|
function isBox(node) {
|
|
@@ -11658,7 +11654,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11658
11654
|
}
|
|
11659
11655
|
function getBoxId(box) {
|
|
11660
11656
|
const { id } = box;
|
|
11661
|
-
assert(logger$
|
|
11657
|
+
assert(logger$4H, id, "no box id");
|
|
11662
11658
|
return id;
|
|
11663
11659
|
}
|
|
11664
11660
|
function getParentBox(node) {
|
|
@@ -11680,7 +11676,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11680
11676
|
}
|
|
11681
11677
|
function getBoxContent(box) {
|
|
11682
11678
|
const content = box.querySelector("span[data-type=box-content]");
|
|
11683
|
-
assert(logger$
|
|
11679
|
+
assert(logger$4H, content, "invalid box dom, no content");
|
|
11684
11680
|
return content;
|
|
11685
11681
|
}
|
|
11686
11682
|
function createInsertionElement(type, id, attributes) {
|
|
@@ -11702,7 +11698,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11702
11698
|
}
|
|
11703
11699
|
function getInsertionContent(insertion) {
|
|
11704
11700
|
const content = insertion.querySelector("span[data-type=insertion-content]");
|
|
11705
|
-
assert(logger$
|
|
11701
|
+
assert(logger$4H, content, "invalid insertion-child dom, no content");
|
|
11706
11702
|
return content;
|
|
11707
11703
|
}
|
|
11708
11704
|
function getPrevBlock(block) {
|
|
@@ -11725,44 +11721,31 @@ var __publicField = (obj, key, value) => {
|
|
|
11725
11721
|
}
|
|
11726
11722
|
return null;
|
|
11727
11723
|
}
|
|
11728
|
-
function getPrevVisibleBlock(block
|
|
11729
|
-
const mergedMatcher = matcher || (() => true);
|
|
11724
|
+
function getPrevVisibleBlock(block) {
|
|
11730
11725
|
let prev = block.previousElementSibling;
|
|
11731
11726
|
while (prev) {
|
|
11732
|
-
if (isBlock$1(prev) && isVisibleBlock(prev)
|
|
11727
|
+
if (isBlock$1(prev) && isVisibleBlock(prev)) {
|
|
11733
11728
|
return prev;
|
|
11734
11729
|
}
|
|
11735
11730
|
prev = prev.previousElementSibling;
|
|
11736
11731
|
}
|
|
11737
11732
|
return null;
|
|
11738
11733
|
}
|
|
11739
|
-
function getNextVisibleBlock(block
|
|
11740
|
-
const mergedMatcher = matcher || (() => true);
|
|
11734
|
+
function getNextVisibleBlock(block) {
|
|
11741
11735
|
let next2 = block.nextElementSibling;
|
|
11742
11736
|
while (next2) {
|
|
11743
|
-
if (isBlock$1(next2) && isVisibleBlock(next2)
|
|
11737
|
+
if (isBlock$1(next2) && isVisibleBlock(next2)) {
|
|
11744
11738
|
return next2;
|
|
11745
11739
|
}
|
|
11746
11740
|
next2 = next2.nextElementSibling;
|
|
11747
11741
|
}
|
|
11748
11742
|
return null;
|
|
11749
11743
|
}
|
|
11750
|
-
function getBlocksBetween(start, end, matcher) {
|
|
11751
|
-
const blocks = [];
|
|
11752
|
-
let cur = start;
|
|
11753
|
-
while (cur !== end) {
|
|
11754
|
-
if (isBlock$1(cur) && matcher(cur)) {
|
|
11755
|
-
blocks.push(cur);
|
|
11756
|
-
}
|
|
11757
|
-
cur = cur.nextElementSibling;
|
|
11758
|
-
}
|
|
11759
|
-
return blocks;
|
|
11760
|
-
}
|
|
11761
11744
|
function getBlockIndex(block) {
|
|
11762
11745
|
const container = getParentContainer(block);
|
|
11763
11746
|
const children = getChildBlocks(container);
|
|
11764
11747
|
const index2 = children.indexOf(block);
|
|
11765
|
-
assert(logger$
|
|
11748
|
+
assert(logger$4H, index2 !== -1, "invalid block & container dom, failed to get block index");
|
|
11766
11749
|
return index2;
|
|
11767
11750
|
}
|
|
11768
11751
|
function isInBlock(target) {
|
|
@@ -11787,18 +11770,18 @@ var __publicField = (obj, key, value) => {
|
|
|
11787
11770
|
function isTitleBlock$2(block) {
|
|
11788
11771
|
return block.hasAttribute("data-document-title");
|
|
11789
11772
|
}
|
|
11790
|
-
const logger$
|
|
11773
|
+
const logger$4G = getLogger("block-class");
|
|
11791
11774
|
function getBlockClass(editor, block) {
|
|
11792
11775
|
return editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
11793
11776
|
}
|
|
11794
11777
|
function getTextBlockClass(editor, block) {
|
|
11795
11778
|
const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
11796
|
-
assert(logger$
|
|
11779
|
+
assert(logger$4G, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
|
|
11797
11780
|
return text2;
|
|
11798
11781
|
}
|
|
11799
11782
|
function getComplexBlockClass(editor, block) {
|
|
11800
11783
|
const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
11801
|
-
assert(logger$
|
|
11784
|
+
assert(logger$4G, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
|
|
11802
11785
|
return complex;
|
|
11803
11786
|
}
|
|
11804
11787
|
function getBlockClassByType(editor, type) {
|
|
@@ -11819,7 +11802,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11819
11802
|
function getBlockKind(editor, block) {
|
|
11820
11803
|
return getBlockClass(editor, block).blockKind;
|
|
11821
11804
|
}
|
|
11822
|
-
const logger$
|
|
11805
|
+
const logger$4F = getLogger("text-block-child");
|
|
11823
11806
|
function isTextBlockContentChild(elem) {
|
|
11824
11807
|
if (elem.tagName !== "SPAN") {
|
|
11825
11808
|
return false;
|
|
@@ -11827,14 +11810,14 @@ var __publicField = (obj, key, value) => {
|
|
|
11827
11810
|
return true;
|
|
11828
11811
|
}
|
|
11829
11812
|
function isTextBlockContentBoxChild(elem) {
|
|
11830
|
-
assert(logger$
|
|
11813
|
+
assert(logger$4F, isTextBlockContentChild(elem), "not a valid text child");
|
|
11831
11814
|
if (elem.getAttribute("data-type") === "editor-box") {
|
|
11832
11815
|
return true;
|
|
11833
11816
|
}
|
|
11834
11817
|
return false;
|
|
11835
11818
|
}
|
|
11836
11819
|
function isTextBlockContentInsertionChild(elem) {
|
|
11837
|
-
assert(logger$
|
|
11820
|
+
assert(logger$4F, isTextBlockContentChild(elem), "not a valid text child");
|
|
11838
11821
|
if (elem.getAttribute("data-type") === "editor-insertion") {
|
|
11839
11822
|
return true;
|
|
11840
11823
|
}
|
|
@@ -11844,7 +11827,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11844
11827
|
return !isTextBlockContentBoxChild(elem) && !isTextBlockContentInsertionChild(elem);
|
|
11845
11828
|
}
|
|
11846
11829
|
function getTextBlockContentChildType(child) {
|
|
11847
|
-
assert(logger$
|
|
11830
|
+
assert(logger$4F, isTextBlockContentChild(child), "not a valid text child");
|
|
11848
11831
|
if (isTextBlockContentBoxChild(child)) {
|
|
11849
11832
|
return "box";
|
|
11850
11833
|
}
|
|
@@ -11859,15 +11842,15 @@ var __publicField = (obj, key, value) => {
|
|
|
11859
11842
|
return 0;
|
|
11860
11843
|
if (type === "box")
|
|
11861
11844
|
return 1;
|
|
11862
|
-
assert(logger$
|
|
11863
|
-
assert(logger$
|
|
11845
|
+
assert(logger$4F, child.textContent !== null, "text block content is undefined");
|
|
11846
|
+
assert(logger$4F, child.textContent.length >= 0, "text block content length is negative");
|
|
11864
11847
|
return child.textContent.length;
|
|
11865
11848
|
}
|
|
11866
11849
|
function getTextBlockContentChildren(block) {
|
|
11867
11850
|
const content = getBlockContent(block);
|
|
11868
11851
|
const children = Array.from(content.children);
|
|
11869
11852
|
children.forEach((child) => {
|
|
11870
|
-
assert(logger$
|
|
11853
|
+
assert(logger$4F, isTextBlockContentChild(child), "not a valid text child");
|
|
11871
11854
|
});
|
|
11872
11855
|
return children;
|
|
11873
11856
|
}
|
|
@@ -11896,17 +11879,17 @@ var __publicField = (obj, key, value) => {
|
|
|
11896
11879
|
};
|
|
11897
11880
|
}
|
|
11898
11881
|
const offset = blockOffset - start;
|
|
11899
|
-
assert(logger$
|
|
11900
|
-
assert(logger$
|
|
11882
|
+
assert(logger$4F, offset > 0, "invalid offset value");
|
|
11883
|
+
assert(logger$4F, !isTextBlockContentBoxChild(child), "invalid box child");
|
|
11901
11884
|
return {
|
|
11902
11885
|
prev: child,
|
|
11903
11886
|
next: child,
|
|
11904
11887
|
offset
|
|
11905
11888
|
};
|
|
11906
11889
|
}
|
|
11907
|
-
assert(logger$
|
|
11890
|
+
assert(logger$4F, false, `invalid block child at position: ${blockOffset}`);
|
|
11908
11891
|
}
|
|
11909
|
-
const logger$
|
|
11892
|
+
const logger$4E = getLogger("block-path");
|
|
11910
11893
|
function getBlockPath(block) {
|
|
11911
11894
|
const ret = [];
|
|
11912
11895
|
let current = block;
|
|
@@ -11920,26 +11903,26 @@ var __publicField = (obj, key, value) => {
|
|
|
11920
11903
|
return ret;
|
|
11921
11904
|
}
|
|
11922
11905
|
const parentBlock = getParentBlock(container);
|
|
11923
|
-
assert(logger$
|
|
11906
|
+
assert(logger$4E, parentBlock, "no parent block");
|
|
11924
11907
|
current = parentBlock;
|
|
11925
11908
|
}
|
|
11926
|
-
assert(logger$
|
|
11909
|
+
assert(logger$4E, false, "no parent block");
|
|
11927
11910
|
return [];
|
|
11928
11911
|
}
|
|
11929
|
-
const logger$
|
|
11912
|
+
const logger$4D = getLogger("child-container-path");
|
|
11930
11913
|
function getContainerBlockPath(container) {
|
|
11931
11914
|
if (isRootContainer(container)) {
|
|
11932
11915
|
return [];
|
|
11933
11916
|
}
|
|
11934
11917
|
const parentBlock = getParentBlock(container);
|
|
11935
|
-
assert(logger$
|
|
11918
|
+
assert(logger$4D, parentBlock, "no parent block");
|
|
11936
11919
|
return getBlockPath(parentBlock);
|
|
11937
11920
|
}
|
|
11938
|
-
const logger$
|
|
11921
|
+
const logger$4C = getLogger("load-blocks");
|
|
11939
11922
|
function loadBlocks(editor, container, path) {
|
|
11940
11923
|
const containerId = getContainerId(container);
|
|
11941
11924
|
const blocks = getContainerBlocks$1(container, editor.doc);
|
|
11942
|
-
assert(logger$
|
|
11925
|
+
assert(logger$4C, blocks.length > 0, "no blocks in container");
|
|
11943
11926
|
const fragment = document.createDocumentFragment();
|
|
11944
11927
|
blocks.forEach((b, index2) => {
|
|
11945
11928
|
const block = editor.editorBlocks.createBlock([...path, { containerId, blockIndex: index2 }], container, b);
|
|
@@ -11955,7 +11938,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11955
11938
|
return block;
|
|
11956
11939
|
}
|
|
11957
11940
|
const blocks = getChildBlocks(container);
|
|
11958
|
-
assert(logger$
|
|
11941
|
+
assert(logger$4C, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
|
|
11959
11942
|
if (blockIndex === blocks.length) {
|
|
11960
11943
|
containerBlocksElement.appendChild(block);
|
|
11961
11944
|
} else {
|
|
@@ -11973,7 +11956,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11973
11956
|
insertBlockAt(container, blockIndex, block);
|
|
11974
11957
|
return block;
|
|
11975
11958
|
}
|
|
11976
|
-
const logger$
|
|
11959
|
+
const logger$4B = getLogger("root-container");
|
|
11977
11960
|
const MIN_DISTANCE_THRESHOLD$2 = 3;
|
|
11978
11961
|
class RootContainer {
|
|
11979
11962
|
constructor(editor, rootContainer) {
|
|
@@ -12001,7 +11984,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12001
11984
|
this.editor.selection.updateSelection(null);
|
|
12002
11985
|
this.editor.emit("resize", this.editor);
|
|
12003
11986
|
} catch (err) {
|
|
12004
|
-
logger$
|
|
11987
|
+
logger$4B.warn(`failed to update selection while container resizing: ${err.message}`);
|
|
12005
11988
|
}
|
|
12006
11989
|
});
|
|
12007
11990
|
__publicField(this, "handleClick", (event) => {
|
|
@@ -12034,7 +12017,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12034
12017
|
const box = getParentBox(elem);
|
|
12035
12018
|
if (box) {
|
|
12036
12019
|
const block2 = getParentBlock(box);
|
|
12037
|
-
assert(logger$
|
|
12020
|
+
assert(logger$4B, block2, "no parent block");
|
|
12038
12021
|
(_b = (_a = this.editor.editorBoxes.getBoxClass(getBoxTypeFromElement(box))) == null ? void 0 : _a.handleClickBox) == null ? void 0 : _b.call(_a, this.editor, box, event);
|
|
12039
12022
|
return;
|
|
12040
12023
|
}
|
|
@@ -12089,7 +12072,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12089
12072
|
this.editor.input.focus({ preventScroll: true });
|
|
12090
12073
|
});
|
|
12091
12074
|
__publicField(this, "handleMouseMove", (event) => {
|
|
12092
|
-
assert(logger$
|
|
12075
|
+
assert(logger$4B, this.mouseDownEvent, "no mouse down event");
|
|
12093
12076
|
if (ensureIsMobileEvent(this.mouseDownEvent))
|
|
12094
12077
|
return;
|
|
12095
12078
|
const deltaX = event.x - this.mouseDownEvent.x;
|
|
@@ -12205,7 +12188,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12205
12188
|
loadBlocks(editor, container, path);
|
|
12206
12189
|
return container;
|
|
12207
12190
|
}
|
|
12208
|
-
const logger$
|
|
12191
|
+
const logger$4A = getLogger("block");
|
|
12209
12192
|
function getBlockTextLength$6(editor, block) {
|
|
12210
12193
|
return getBlockClass(editor, block).getBlockTextLength(block);
|
|
12211
12194
|
}
|
|
@@ -12224,7 +12207,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12224
12207
|
return block;
|
|
12225
12208
|
}
|
|
12226
12209
|
const parent = getParentBlock(container);
|
|
12227
|
-
assert(logger$
|
|
12210
|
+
assert(logger$4A, parent, "no parent block exists for child container");
|
|
12228
12211
|
block = parent;
|
|
12229
12212
|
}
|
|
12230
12213
|
}
|
|
@@ -12260,7 +12243,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12260
12243
|
}
|
|
12261
12244
|
return fun(editor, block, options);
|
|
12262
12245
|
} catch (err) {
|
|
12263
|
-
logger$
|
|
12246
|
+
logger$4A.debug(`unsupported block type: ${type}`);
|
|
12264
12247
|
return null;
|
|
12265
12248
|
}
|
|
12266
12249
|
}
|
|
@@ -12280,7 +12263,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12280
12263
|
const styles = Object.fromEntries(Object.entries(data2).filter(([key]) => key.startsWith("style-")));
|
|
12281
12264
|
Object.entries(styles).forEach(([, value]) => {
|
|
12282
12265
|
const type = typeof value;
|
|
12283
|
-
assert(logger$
|
|
12266
|
+
assert(logger$4A, type === "string" || type === "number" || type === "boolean", "invalid style value");
|
|
12284
12267
|
});
|
|
12285
12268
|
return styles;
|
|
12286
12269
|
}
|
|
@@ -12405,7 +12388,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12405
12388
|
}
|
|
12406
12389
|
return { element: null, blockCommands: [], boxCommands: [] };
|
|
12407
12390
|
}
|
|
12408
|
-
const logger$
|
|
12391
|
+
const logger$4z = getLogger("embed-block-common");
|
|
12409
12392
|
function isColumnsBlock(block) {
|
|
12410
12393
|
return getBlockType(block) === "layout";
|
|
12411
12394
|
}
|
|
@@ -12413,9 +12396,9 @@ var __publicField = (obj, key, value) => {
|
|
|
12413
12396
|
return getBlockType(block) === "embed";
|
|
12414
12397
|
}
|
|
12415
12398
|
function getEmbedType(block) {
|
|
12416
|
-
assert(logger$
|
|
12399
|
+
assert(logger$4z, isEmbedBlock(block), "not an embed block");
|
|
12417
12400
|
const type = block.getAttribute("data-embed-type");
|
|
12418
|
-
assert(logger$
|
|
12401
|
+
assert(logger$4z, type, "no embed data type");
|
|
12419
12402
|
return type;
|
|
12420
12403
|
}
|
|
12421
12404
|
function getEmbedClassFromBlock(editor, block) {
|
|
@@ -12481,10 +12464,10 @@ var __publicField = (obj, key, value) => {
|
|
|
12481
12464
|
data: (_c = overrideOptions == null ? void 0 : overrideOptions.data) != null ? _c : data2
|
|
12482
12465
|
});
|
|
12483
12466
|
}
|
|
12484
|
-
const logger$
|
|
12467
|
+
const logger$4y = getLogger("execute-block-command");
|
|
12485
12468
|
function executeEmbedBlockCommand(editor, block, commandGroup, item) {
|
|
12486
12469
|
var _a;
|
|
12487
|
-
assert(logger$
|
|
12470
|
+
assert(logger$4y, isEmbedBlock(block), "not a embed block");
|
|
12488
12471
|
const embedType = getEmbedType(block);
|
|
12489
12472
|
const embed = getEmbedClassByType(editor, embedType);
|
|
12490
12473
|
if (!embed.getOptions) {
|
|
@@ -12517,14 +12500,14 @@ var __publicField = (obj, key, value) => {
|
|
|
12517
12500
|
}
|
|
12518
12501
|
return void 0;
|
|
12519
12502
|
}
|
|
12520
|
-
const logger$
|
|
12503
|
+
const logger$4x = getLogger("block-class");
|
|
12521
12504
|
function isHeadingBlock$1(block) {
|
|
12522
12505
|
return !!block.getAttribute("data-style-heading");
|
|
12523
12506
|
}
|
|
12524
12507
|
function getBlockHeading(block) {
|
|
12525
12508
|
var _a;
|
|
12526
12509
|
const heading = Number.parseInt((_a = block.getAttribute("data-style-heading")) != null ? _a : "", 10);
|
|
12527
|
-
assert(logger$
|
|
12510
|
+
assert(logger$4x, heading, "not a heading block");
|
|
12528
12511
|
return heading;
|
|
12529
12512
|
}
|
|
12530
12513
|
function isExpandedHeadingBlock(block) {
|
|
@@ -12535,7 +12518,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12535
12518
|
}
|
|
12536
12519
|
function getHeadingBlockChildren(block, oldHeading) {
|
|
12537
12520
|
if (!oldHeading) {
|
|
12538
|
-
assert(logger$
|
|
12521
|
+
assert(logger$4x, isHeadingBlock$1(block), "not a heading block");
|
|
12539
12522
|
}
|
|
12540
12523
|
const children = [];
|
|
12541
12524
|
const heading = oldHeading != null ? oldHeading : getBlockHeading(block);
|
|
@@ -12565,7 +12548,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12565
12548
|
}
|
|
12566
12549
|
return children;
|
|
12567
12550
|
}
|
|
12568
|
-
const logger$
|
|
12551
|
+
const logger$4w = getLogger("complex-block-position");
|
|
12569
12552
|
class EditorComplexBlockPosition {
|
|
12570
12553
|
constructor(block, childContainerId, custom) {
|
|
12571
12554
|
__publicField(this, "blockId");
|
|
@@ -12574,7 +12557,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12574
12557
|
if (block instanceof HTMLElement) {
|
|
12575
12558
|
this.blockId = getBlockId(block);
|
|
12576
12559
|
} else {
|
|
12577
|
-
assert(logger$
|
|
12560
|
+
assert(logger$4w, typeof block === "string", `not a valid block id: ${block}`);
|
|
12578
12561
|
this.blockId = block;
|
|
12579
12562
|
}
|
|
12580
12563
|
this.childContainerId = childContainerId;
|
|
@@ -12586,7 +12569,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12586
12569
|
return false;
|
|
12587
12570
|
}
|
|
12588
12571
|
}
|
|
12589
|
-
const logger$
|
|
12572
|
+
const logger$4v = getLogger("simple-block-position");
|
|
12590
12573
|
class EditorSimpleBlockPosition {
|
|
12591
12574
|
constructor(block, offset, type) {
|
|
12592
12575
|
__publicField(this, "blockId");
|
|
@@ -12595,7 +12578,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12595
12578
|
if (block instanceof HTMLElement) {
|
|
12596
12579
|
this.blockId = getBlockId(block);
|
|
12597
12580
|
} else {
|
|
12598
|
-
assert(logger$
|
|
12581
|
+
assert(logger$4v, typeof block === "string", `not a valid block id: ${block}`);
|
|
12599
12582
|
this.blockId = block;
|
|
12600
12583
|
}
|
|
12601
12584
|
this.offset = offset;
|
|
@@ -12605,7 +12588,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12605
12588
|
return true;
|
|
12606
12589
|
}
|
|
12607
12590
|
}
|
|
12608
|
-
const logger$
|
|
12591
|
+
const logger$4u = getLogger("editor-position");
|
|
12609
12592
|
function createSimpleBlockPosition(block, offset, type) {
|
|
12610
12593
|
return new EditorSimpleBlockPosition(block, offset, type);
|
|
12611
12594
|
}
|
|
@@ -12627,7 +12610,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12627
12610
|
}
|
|
12628
12611
|
const block1 = editor.getBlockById(pos1.blockId);
|
|
12629
12612
|
const block2 = editor.getBlockById(pos2.blockId);
|
|
12630
|
-
assert(logger$
|
|
12613
|
+
assert(logger$4u, block1 !== block2, "comparePosition: blocks are the same");
|
|
12631
12614
|
return compareElement(block1, block2);
|
|
12632
12615
|
}
|
|
12633
12616
|
if (isComplexBlockPosition(pos1) && isComplexBlockPosition(pos2)) {
|
|
@@ -12638,13 +12621,13 @@ var __publicField = (obj, key, value) => {
|
|
|
12638
12621
|
}
|
|
12639
12622
|
const container1 = editor.getContainerById(p1.childContainerId);
|
|
12640
12623
|
const container2 = editor.getContainerById(p2.childContainerId);
|
|
12641
|
-
assert(logger$
|
|
12624
|
+
assert(logger$4u, container1 !== container2, "comparePosition: containers are the same");
|
|
12642
12625
|
return compareElement(container1, container2);
|
|
12643
12626
|
}
|
|
12644
|
-
assert(logger$
|
|
12627
|
+
assert(logger$4u, false, "invalid ");
|
|
12645
12628
|
return 0;
|
|
12646
12629
|
}
|
|
12647
|
-
const logger$
|
|
12630
|
+
const logger$4t = getLogger("simple-range");
|
|
12648
12631
|
class EditorSimpleSelectionRange {
|
|
12649
12632
|
constructor(editor, options) {
|
|
12650
12633
|
__publicField(this, "editor");
|
|
@@ -12693,11 +12676,11 @@ var __publicField = (obj, key, value) => {
|
|
|
12693
12676
|
const { editor } = this;
|
|
12694
12677
|
const startBlock = editor.getBlockById(this.start.blockId);
|
|
12695
12678
|
const endBlock = editor.getBlockById(this.end.blockId);
|
|
12696
|
-
assert(logger$
|
|
12697
|
-
assert(logger$
|
|
12679
|
+
assert(logger$4t, startBlock, "no start block");
|
|
12680
|
+
assert(logger$4t, endBlock, "no end block");
|
|
12698
12681
|
const startContainer = getParentContainer(startBlock);
|
|
12699
12682
|
const endContainer = getParentContainer(endBlock);
|
|
12700
|
-
assert(logger$
|
|
12683
|
+
assert(logger$4t, startContainer === endContainer, "invalid range");
|
|
12701
12684
|
const ret = [];
|
|
12702
12685
|
if (startBlock === endBlock) {
|
|
12703
12686
|
ret.push({
|
|
@@ -12708,7 +12691,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12708
12691
|
} else {
|
|
12709
12692
|
const startIndex = getBlockIndex(startBlock);
|
|
12710
12693
|
const endIndex = getBlockIndex(endBlock);
|
|
12711
|
-
assert(logger$
|
|
12694
|
+
assert(logger$4t, startIndex < endIndex, "invalid range, start > index");
|
|
12712
12695
|
ret.push({
|
|
12713
12696
|
block: startBlock,
|
|
12714
12697
|
start: this.start,
|
|
@@ -12808,7 +12791,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12808
12791
|
clearSelection: clearSelection$6,
|
|
12809
12792
|
convertTo: convertTo$m
|
|
12810
12793
|
};
|
|
12811
|
-
const logger$
|
|
12794
|
+
const logger$4s = getLogger("editor-blocks");
|
|
12812
12795
|
class EditorBlocks {
|
|
12813
12796
|
constructor(editor) {
|
|
12814
12797
|
__publicField(this, "blocks", /* @__PURE__ */ new Map());
|
|
@@ -12817,12 +12800,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12817
12800
|
registerBlockClass(blockClass) {
|
|
12818
12801
|
const type = blockClass.blockType;
|
|
12819
12802
|
const exists = this.blocks.get(type);
|
|
12820
|
-
assert(logger$
|
|
12803
|
+
assert(logger$4s, !exists, `duplicated block type: ${type}`);
|
|
12821
12804
|
this.blocks.set(type, blockClass);
|
|
12822
12805
|
}
|
|
12823
12806
|
getBlockClass(type) {
|
|
12824
12807
|
const exists = this.blocks.get(type);
|
|
12825
|
-
assert(logger$
|
|
12808
|
+
assert(logger$4s, exists, `unknown block type: ${type}`);
|
|
12826
12809
|
return exists;
|
|
12827
12810
|
}
|
|
12828
12811
|
hasBlock(type) {
|
|
@@ -12838,7 +12821,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12838
12821
|
}
|
|
12839
12822
|
const content = blockClass.createBlockContent(this.editor, path, container, blockElement, block);
|
|
12840
12823
|
if (content.parentElement !== blockElement) {
|
|
12841
|
-
logger$
|
|
12824
|
+
logger$4s.warn("content parent is not block");
|
|
12842
12825
|
blockElement.appendChild(content);
|
|
12843
12826
|
}
|
|
12844
12827
|
this.editor.blockHooks.forEach((hook) => {
|
|
@@ -12859,7 +12842,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12859
12842
|
return newBlock;
|
|
12860
12843
|
}
|
|
12861
12844
|
}
|
|
12862
|
-
const logger$
|
|
12845
|
+
const logger$4r = getLogger("editor-embeds");
|
|
12863
12846
|
class EditorEmbeds {
|
|
12864
12847
|
constructor(editor) {
|
|
12865
12848
|
__publicField(this, "objects", /* @__PURE__ */ new Map());
|
|
@@ -12868,12 +12851,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12868
12851
|
registerEmbedClass(embedClass) {
|
|
12869
12852
|
const type = embedClass.embedType;
|
|
12870
12853
|
const exists = this.objects.get(type);
|
|
12871
|
-
assert(logger$
|
|
12854
|
+
assert(logger$4r, !exists, `duplicated embed object type: ${type}`);
|
|
12872
12855
|
this.objects.set(type, embedClass);
|
|
12873
12856
|
}
|
|
12874
12857
|
getEmbedClass(type) {
|
|
12875
12858
|
const exists = this.objects.get(type);
|
|
12876
|
-
assert(logger$
|
|
12859
|
+
assert(logger$4r, exists, `unknown embed type: ${type}`);
|
|
12877
12860
|
return exists;
|
|
12878
12861
|
}
|
|
12879
12862
|
getEmbedClassFromBlock(block) {
|
|
@@ -12883,12 +12866,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12883
12866
|
this.objects.forEach(callback);
|
|
12884
12867
|
}
|
|
12885
12868
|
}
|
|
12886
|
-
const logger$
|
|
12869
|
+
const logger$4q = getLogger("embed-block");
|
|
12887
12870
|
function createBlockContent$6(editor, path, container, blockElement, blockData) {
|
|
12888
12871
|
const content = createBlockContentElement(blockElement, "div");
|
|
12889
|
-
assert(logger$
|
|
12872
|
+
assert(logger$4q, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
|
|
12890
12873
|
const embedBlockData = blockData;
|
|
12891
|
-
assert(logger$
|
|
12874
|
+
assert(logger$4q, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
|
|
12892
12875
|
const embedClass = editor.editorEmbeds.getEmbedClass(embedBlockData.embedType);
|
|
12893
12876
|
embedClass.createEmbedContent(editor, content, embedBlockData, path, container, blockElement);
|
|
12894
12877
|
blockElement.setAttribute("data-embed-type", embedBlockData.embedType);
|
|
@@ -12916,7 +12899,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12916
12899
|
function getCaretRect$4(block, pos) {
|
|
12917
12900
|
const content = getBlockContent(block);
|
|
12918
12901
|
const rect = content.getBoundingClientRect();
|
|
12919
|
-
assert(logger$
|
|
12902
|
+
assert(logger$4q, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
|
|
12920
12903
|
if (pos.offset === 1) {
|
|
12921
12904
|
return new DOMRect(rect.right, rect.top, 0, rect.height);
|
|
12922
12905
|
}
|
|
@@ -13056,18 +13039,18 @@ var __publicField = (obj, key, value) => {
|
|
|
13056
13039
|
toStandardDoc: toStandardDoc$2,
|
|
13057
13040
|
getResources: getResources$2
|
|
13058
13041
|
};
|
|
13059
|
-
const logger$
|
|
13042
|
+
const logger$4p = getLogger("complex-block-helper");
|
|
13060
13043
|
function complexBlockGetAllChildContainers(editor, block, options) {
|
|
13061
13044
|
const blockClass = getComplexBlockClass(editor, block);
|
|
13062
13045
|
return blockClass.getChildContainers(editor, block, options);
|
|
13063
13046
|
}
|
|
13064
13047
|
function complexBlockGetSelectedContainers(editor, block, start, end) {
|
|
13065
13048
|
if (start.isSimple()) {
|
|
13066
|
-
assert(logger$
|
|
13049
|
+
assert(logger$4p, end.isSimple(), "invalid start and end position");
|
|
13067
13050
|
return complexBlockGetAllChildContainers(editor, block);
|
|
13068
13051
|
}
|
|
13069
|
-
assert(logger$
|
|
13070
|
-
assert(logger$
|
|
13052
|
+
assert(logger$4p, !start.isSimple(), "invalid start pos");
|
|
13053
|
+
assert(logger$4p, !end.isSimple(), "invalid end pos");
|
|
13071
13054
|
const blockClass = getComplexBlockClass(editor, block);
|
|
13072
13055
|
return blockClass.getSelectedContainers(editor, block, start, end);
|
|
13073
13056
|
}
|
|
@@ -13078,11 +13061,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13078
13061
|
const parentComplexBlock = getParentBlock(getParentContainer(childBlock));
|
|
13079
13062
|
if (!parentComplexBlock)
|
|
13080
13063
|
return false;
|
|
13081
|
-
assert(logger$
|
|
13064
|
+
assert(logger$4p, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
|
|
13082
13065
|
const childContainer = getParentContainer(childBlock);
|
|
13083
13066
|
const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
|
|
13084
13067
|
const index2 = childContainers.indexOf(childContainer);
|
|
13085
|
-
assert(logger$
|
|
13068
|
+
assert(logger$4p, index2 >= 0, "not valid child container");
|
|
13086
13069
|
return index2 === 0;
|
|
13087
13070
|
}
|
|
13088
13071
|
function complexBlockGetFirstSimpleChild(editor, complexBlock, options) {
|
|
@@ -13135,13 +13118,13 @@ var __publicField = (obj, key, value) => {
|
|
|
13135
13118
|
return block;
|
|
13136
13119
|
}
|
|
13137
13120
|
function findPrevSimpleBlockBeforeChildContainer(editor, childContainer, options) {
|
|
13138
|
-
assert(logger$
|
|
13121
|
+
assert(logger$4p, isChildContainer(childContainer), "not a child container");
|
|
13139
13122
|
const parentComplexBlock = getParentBlock(childContainer);
|
|
13140
|
-
assert(logger$
|
|
13141
|
-
assert(logger$
|
|
13123
|
+
assert(logger$4p, parentComplexBlock, "no parent block");
|
|
13124
|
+
assert(logger$4p, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
|
|
13142
13125
|
const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock, options);
|
|
13143
13126
|
const containerIndex = childContainers.indexOf(childContainer);
|
|
13144
|
-
assert(logger$
|
|
13127
|
+
assert(logger$4p, containerIndex !== -1, "child container not found");
|
|
13145
13128
|
if (containerIndex === 0) {
|
|
13146
13129
|
const prevBlock = getPrevBlock(parentComplexBlock);
|
|
13147
13130
|
if (!prevBlock)
|
|
@@ -13159,9 +13142,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13159
13142
|
return lastBlock2;
|
|
13160
13143
|
}
|
|
13161
13144
|
function complexBlockGetTopChildContainers(editor, complexBlock) {
|
|
13162
|
-
assert(logger$
|
|
13145
|
+
assert(logger$4p, isComplexKindBlock(editor, complexBlock), "not a complex block");
|
|
13163
13146
|
const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
|
|
13164
|
-
assert(logger$
|
|
13147
|
+
assert(logger$4p, childContainers.length > 0, "no child container");
|
|
13165
13148
|
if (childContainers.length === 1) {
|
|
13166
13149
|
return childContainers;
|
|
13167
13150
|
}
|
|
@@ -13186,9 +13169,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13186
13169
|
return ret;
|
|
13187
13170
|
}
|
|
13188
13171
|
function complexBlockGetBottomChildContainers(editor, complexBlock) {
|
|
13189
|
-
assert(logger$
|
|
13172
|
+
assert(logger$4p, isComplexKindBlock(editor, complexBlock), "not a complex block");
|
|
13190
13173
|
const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
|
|
13191
|
-
assert(logger$
|
|
13174
|
+
assert(logger$4p, childContainers.length > 0, "no child container");
|
|
13192
13175
|
if (childContainers.length === 1) {
|
|
13193
13176
|
return childContainers;
|
|
13194
13177
|
}
|
|
@@ -13293,11 +13276,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13293
13276
|
return result;
|
|
13294
13277
|
}
|
|
13295
13278
|
const anchor = "";
|
|
13296
|
-
const logger$
|
|
13279
|
+
const logger$4o = getLogger("text-range");
|
|
13297
13280
|
function getBlockRangeInfo(block, blockOffset) {
|
|
13298
13281
|
const getChildRange = (child, offset) => {
|
|
13299
13282
|
if (isTextBlockContentInsertionChild(child)) {
|
|
13300
|
-
assert(logger$
|
|
13283
|
+
assert(logger$4o, offset === 0, `invalid offset for insertion child: ${offset}`);
|
|
13301
13284
|
const childOffset = 2;
|
|
13302
13285
|
return {
|
|
13303
13286
|
child,
|
|
@@ -13306,7 +13289,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13306
13289
|
};
|
|
13307
13290
|
}
|
|
13308
13291
|
if (isTextBlockContentBoxChild(child)) {
|
|
13309
|
-
assert(logger$
|
|
13292
|
+
assert(logger$4o, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
|
|
13310
13293
|
const childOffset = offset === 0 ? 1 : 2;
|
|
13311
13294
|
return {
|
|
13312
13295
|
child,
|
|
@@ -13315,17 +13298,17 @@ var __publicField = (obj, key, value) => {
|
|
|
13315
13298
|
};
|
|
13316
13299
|
}
|
|
13317
13300
|
const textNode = child.firstChild;
|
|
13318
|
-
assert(logger$
|
|
13319
|
-
assert(logger$
|
|
13301
|
+
assert(logger$4o, textNode, "no child node for text child");
|
|
13302
|
+
assert(logger$4o, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
|
|
13320
13303
|
if (textNode instanceof HTMLBRElement) {
|
|
13321
|
-
assert(logger$
|
|
13304
|
+
assert(logger$4o, offset >= 0 && offset <= 0, "invalid offset for text child");
|
|
13322
13305
|
return {
|
|
13323
13306
|
child,
|
|
13324
13307
|
container: textNode,
|
|
13325
13308
|
offset
|
|
13326
13309
|
};
|
|
13327
13310
|
}
|
|
13328
|
-
assert(logger$
|
|
13311
|
+
assert(logger$4o, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
|
|
13329
13312
|
return {
|
|
13330
13313
|
child,
|
|
13331
13314
|
container: textNode,
|
|
@@ -13354,38 +13337,38 @@ var __publicField = (obj, key, value) => {
|
|
|
13354
13337
|
}
|
|
13355
13338
|
start += childLength;
|
|
13356
13339
|
}
|
|
13357
|
-
assert(logger$
|
|
13340
|
+
assert(logger$4o, false, "failed to get range info");
|
|
13358
13341
|
}
|
|
13359
13342
|
function createChildRange(child, start, end) {
|
|
13360
13343
|
if (start === end) {
|
|
13361
|
-
assert(logger$
|
|
13344
|
+
assert(logger$4o, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
|
|
13362
13345
|
} else {
|
|
13363
|
-
assert(logger$
|
|
13346
|
+
assert(logger$4o, start < end, `invalid start & end: ${start}, ${end}`);
|
|
13364
13347
|
}
|
|
13365
13348
|
if (isTextBlockContentInsertionChild(child)) {
|
|
13366
|
-
assert(logger$
|
|
13367
|
-
assert(logger$
|
|
13349
|
+
assert(logger$4o, start === end, `invalid insertion child range offset: ${start}, ${end}`);
|
|
13350
|
+
assert(logger$4o, start === 0, `invalid insertion child range start: ${start}`);
|
|
13368
13351
|
const insertionElem = child;
|
|
13369
|
-
assert(logger$
|
|
13352
|
+
assert(logger$4o, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
|
|
13370
13353
|
const range = createExpandedRange(insertionElem, 1, insertionElem, 2);
|
|
13371
13354
|
return range;
|
|
13372
13355
|
}
|
|
13373
13356
|
if (isTextBlockContentBoxChild(child)) {
|
|
13374
|
-
assert(logger$
|
|
13375
|
-
assert(logger$
|
|
13357
|
+
assert(logger$4o, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
|
|
13358
|
+
assert(logger$4o, start === 0, `invalid box child range start: ${start}`);
|
|
13376
13359
|
const box = child;
|
|
13377
|
-
assert(logger$
|
|
13360
|
+
assert(logger$4o, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
|
|
13378
13361
|
const range = createExpandedRange(box, 1, box, 2);
|
|
13379
13362
|
return range;
|
|
13380
13363
|
}
|
|
13381
13364
|
const length = getTextBlockContentChildTextLength(child);
|
|
13382
|
-
assert(logger$
|
|
13365
|
+
assert(logger$4o, end <= length, `invalid child end: ${end}, ${length}`);
|
|
13383
13366
|
const textNode = child.firstChild;
|
|
13384
|
-
assert(logger$
|
|
13385
|
-
assert(logger$
|
|
13367
|
+
assert(logger$4o, textNode instanceof Text, "invalid block text child");
|
|
13368
|
+
assert(logger$4o, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
|
|
13386
13369
|
return createExpandedRange(textNode, start, textNode, end);
|
|
13387
13370
|
}
|
|
13388
|
-
const logger$
|
|
13371
|
+
const logger$4n = getLogger("caret-rect");
|
|
13389
13372
|
function getChildClientRects(block, child) {
|
|
13390
13373
|
if (isBox(child)) {
|
|
13391
13374
|
const box = child;
|
|
@@ -13394,7 +13377,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13394
13377
|
const blockContent = getBlockContent(block);
|
|
13395
13378
|
const lineHeight = Number.parseFloat(window.getComputedStyle(blockContent).lineHeight) || boxContent.getBoundingClientRect().height;
|
|
13396
13379
|
const rects = Array.from(boxContent.getClientRects());
|
|
13397
|
-
assert(logger$
|
|
13380
|
+
assert(logger$4n, rects.length > 0, "no box client rects");
|
|
13398
13381
|
const blockRect = blockContent.getBoundingClientRect();
|
|
13399
13382
|
const firstRect = rects[0];
|
|
13400
13383
|
const lastRect = new DOMRect(blockRect.left, firstRect.bottom, 1, lineHeight);
|
|
@@ -13414,22 +13397,22 @@ var __publicField = (obj, key, value) => {
|
|
|
13414
13397
|
const rect2 = getLastClientRect(ranges[0].child);
|
|
13415
13398
|
return new DOMRect(rect2.right, rect2.top, 1, rect2.height);
|
|
13416
13399
|
}
|
|
13417
|
-
assert(logger$
|
|
13400
|
+
assert(logger$4n, ranges[1], "invalid ranges");
|
|
13418
13401
|
const rect = getFirstClientRect(ranges[1].child);
|
|
13419
13402
|
return new DOMRect(rect.left, rect.top, 1, rect.height);
|
|
13420
13403
|
}
|
|
13421
13404
|
let rangeInfo = ranges[0];
|
|
13422
|
-
assert(logger$
|
|
13405
|
+
assert(logger$4n, ranges.length >= 1, "failed to get block range");
|
|
13423
13406
|
if (ranges.length === 1) {
|
|
13424
13407
|
rangeInfo = ranges[0];
|
|
13425
13408
|
} else {
|
|
13426
|
-
assert(logger$
|
|
13409
|
+
assert(logger$4n, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
|
|
13427
13410
|
if (isTextBlockContentInsertionChild(ranges[ranges.length - 1].child)) {
|
|
13428
13411
|
rangeInfo = ranges[ranges.length - 1];
|
|
13429
13412
|
const child = rangeInfo.child;
|
|
13430
13413
|
const content = getInsertionContent(child);
|
|
13431
13414
|
const rects2 = content.getClientRects();
|
|
13432
|
-
assert(logger$
|
|
13415
|
+
assert(logger$4n, rects2.length >= 1, "no client rects for box content");
|
|
13433
13416
|
const rect = rects2[rects2.length - 1];
|
|
13434
13417
|
return new DOMRect(rect.right, rect.y, 1, rect.height);
|
|
13435
13418
|
}
|
|
@@ -13446,9 +13429,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13446
13429
|
}
|
|
13447
13430
|
}
|
|
13448
13431
|
if (rangeInfo.container instanceof HTMLBRElement) {
|
|
13449
|
-
assert(logger$
|
|
13432
|
+
assert(logger$4n, pos.offset === 0, "invalid offset for empty block text");
|
|
13450
13433
|
const parent = rangeInfo.container.parentElement;
|
|
13451
|
-
assert(logger$
|
|
13434
|
+
assert(logger$4n, parent, "invalid br parent");
|
|
13452
13435
|
const rect = parent.getBoundingClientRect();
|
|
13453
13436
|
const ret = new DOMRect(rect.left, rect.top, 1, rect.height);
|
|
13454
13437
|
return ret;
|
|
@@ -13456,11 +13439,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13456
13439
|
const range = createRange(rangeInfo.container, rangeInfo.offset);
|
|
13457
13440
|
const rects = Array.from(range.getClientRects());
|
|
13458
13441
|
if (rects.length === 0) {
|
|
13459
|
-
assert(logger$
|
|
13460
|
-
assert(logger$
|
|
13442
|
+
assert(logger$4n, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
|
|
13443
|
+
assert(logger$4n, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
|
|
13461
13444
|
const child = rangeInfo.child;
|
|
13462
13445
|
const rects2 = getChildClientRects(block, child);
|
|
13463
|
-
assert(logger$
|
|
13446
|
+
assert(logger$4n, rects2.length >= 1, "no client rects for box content");
|
|
13464
13447
|
if (rangeInfo.offset === 1) {
|
|
13465
13448
|
const rect2 = rects2[0];
|
|
13466
13449
|
return new DOMRect(rect2.x, rect2.y, 1, rect2.height);
|
|
@@ -13506,7 +13489,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13506
13489
|
});
|
|
13507
13490
|
}
|
|
13508
13491
|
}
|
|
13509
|
-
assert(logger$
|
|
13492
|
+
assert(logger$4n, rects.length > 0, "no client rects for range");
|
|
13510
13493
|
if (pos.type === "home") {
|
|
13511
13494
|
return rects[rects.length - 1];
|
|
13512
13495
|
}
|
|
@@ -13586,13 +13569,13 @@ var __publicField = (obj, key, value) => {
|
|
|
13586
13569
|
};
|
|
13587
13570
|
}
|
|
13588
13571
|
}
|
|
13589
|
-
const logger$
|
|
13572
|
+
const logger$4m = getLogger("selection-range");
|
|
13590
13573
|
function createEditorSelectionRange(editor, options) {
|
|
13591
13574
|
const { anchor: anchor2, focus } = options;
|
|
13592
13575
|
if (anchor2 instanceof EditorSimpleBlockPosition && focus instanceof EditorSimpleBlockPosition) {
|
|
13593
13576
|
return new EditorSimpleSelectionRange(editor, { anchor: anchor2, focus });
|
|
13594
13577
|
}
|
|
13595
|
-
assert(logger$
|
|
13578
|
+
assert(logger$4m, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
|
|
13596
13579
|
return new EditorComplexSelectionRange(editor, { anchor: anchor2, focus });
|
|
13597
13580
|
}
|
|
13598
13581
|
function createBlockSimpleRange(editor, block, anchor2, focus) {
|
|
@@ -13614,7 +13597,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13614
13597
|
const focus = createSimpleBlockPosition(range.focus.blockId, range.focus.offset, "normal");
|
|
13615
13598
|
return createEditorSelectionRange(editor, { anchor: anchor2, focus });
|
|
13616
13599
|
}
|
|
13617
|
-
const logger$
|
|
13600
|
+
const logger$4l = getLogger("range-from-point");
|
|
13618
13601
|
function getBlockRangeFromPoint(editor, pointX, pointY, dragging) {
|
|
13619
13602
|
const yOffsets = [0, -12, 12];
|
|
13620
13603
|
let x = pointX;
|
|
@@ -13646,7 +13629,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13646
13629
|
const rect = elem.getBoundingClientRect();
|
|
13647
13630
|
if (rect.width && rect.top && i === 0) {
|
|
13648
13631
|
if (rect.left + rect.width < x || rect.top + rect.height < y) {
|
|
13649
|
-
logger$
|
|
13632
|
+
logger$4l.debug("click on scrollbar, out of element rect");
|
|
13650
13633
|
return null;
|
|
13651
13634
|
}
|
|
13652
13635
|
}
|
|
@@ -13684,7 +13667,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13684
13667
|
let block = getLastChildBlock(container);
|
|
13685
13668
|
if (!isVisibleBlock(block)) {
|
|
13686
13669
|
const preBlock = getPrevVisibleBlock(block);
|
|
13687
|
-
assert(logger$
|
|
13670
|
+
assert(logger$4l, preBlock, "container must have visible block");
|
|
13688
13671
|
block = preBlock;
|
|
13689
13672
|
}
|
|
13690
13673
|
const range = getBlockClass(editor, block).getRangeFromPoint(editor, block, x, block.getBoundingClientRect().bottom - 4);
|
|
@@ -13703,7 +13686,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13703
13686
|
if (range instanceof EditorSimpleSelectionRange) {
|
|
13704
13687
|
return range;
|
|
13705
13688
|
}
|
|
13706
|
-
assert(logger$
|
|
13689
|
+
assert(logger$4l, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
|
|
13707
13690
|
const complexRange = range;
|
|
13708
13691
|
const container2 = editor.getContainerById(complexRange.start.childContainerId);
|
|
13709
13692
|
return getRangeInContainer(editor, container2, x, y);
|
|
@@ -13726,7 +13709,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13726
13709
|
});
|
|
13727
13710
|
return getRangeInContainer(editor, container, x, y);
|
|
13728
13711
|
}
|
|
13729
|
-
const logger$
|
|
13712
|
+
const logger$4k = getLogger("adjust-selection-pos");
|
|
13730
13713
|
function getParentContainers(block) {
|
|
13731
13714
|
const containers = [];
|
|
13732
13715
|
while (block) {
|
|
@@ -13736,10 +13719,10 @@ var __publicField = (obj, key, value) => {
|
|
|
13736
13719
|
return containers;
|
|
13737
13720
|
}
|
|
13738
13721
|
const newBlock = getParentBlock(container);
|
|
13739
|
-
assert(logger$
|
|
13722
|
+
assert(logger$4k, newBlock, "child container has not parent container");
|
|
13740
13723
|
block = newBlock;
|
|
13741
13724
|
}
|
|
13742
|
-
assert(logger$
|
|
13725
|
+
assert(logger$4k, false, "should not come here: getParentContainers");
|
|
13743
13726
|
}
|
|
13744
13727
|
function getParentBlockInContainer(container, block) {
|
|
13745
13728
|
while (block) {
|
|
@@ -13748,16 +13731,16 @@ var __publicField = (obj, key, value) => {
|
|
|
13748
13731
|
return block;
|
|
13749
13732
|
}
|
|
13750
13733
|
const newBlock = getParentBlock(parent);
|
|
13751
|
-
assert(logger$
|
|
13734
|
+
assert(logger$4k, newBlock, "could not find parent block for a child container");
|
|
13752
13735
|
block = newBlock;
|
|
13753
13736
|
}
|
|
13754
|
-
assert(logger$
|
|
13737
|
+
assert(logger$4k, false, "no parent block in specified container");
|
|
13755
13738
|
}
|
|
13756
13739
|
function getClosestParentBlock(block1, block2) {
|
|
13757
13740
|
const containers1 = getParentContainers(block1);
|
|
13758
13741
|
const containers2 = getParentContainers(block2);
|
|
13759
|
-
assert(logger$
|
|
13760
|
-
assert(logger$
|
|
13742
|
+
assert(logger$4k, containers1.length > 0 && containers2.length > 0, "block has not parent container");
|
|
13743
|
+
assert(logger$4k, containers1[0] === containers2[0], "root container does not equal");
|
|
13761
13744
|
let parentContainer = containers1[0];
|
|
13762
13745
|
for (let i = 1; i < containers1.length || containers2.length; i++) {
|
|
13763
13746
|
if (containers1[i] === containers2[i]) {
|
|
@@ -13776,23 +13759,23 @@ var __publicField = (obj, key, value) => {
|
|
|
13776
13759
|
}
|
|
13777
13760
|
function getParentContainerInComplexBlock(parentComplexBlock, element) {
|
|
13778
13761
|
let block = getParentBlock(element);
|
|
13779
|
-
assert(logger$
|
|
13762
|
+
assert(logger$4k, block, "element is not in a block");
|
|
13780
13763
|
while (block) {
|
|
13781
13764
|
const container = getParentContainer(block);
|
|
13782
|
-
assert(logger$
|
|
13765
|
+
assert(logger$4k, isChildContainer(container), "not a child container");
|
|
13783
13766
|
const parentBlock = getParentBlock(container);
|
|
13784
|
-
assert(logger$
|
|
13767
|
+
assert(logger$4k, parentBlock, "child container has not parent block");
|
|
13785
13768
|
if (parentBlock === parentComplexBlock) {
|
|
13786
13769
|
return container;
|
|
13787
13770
|
}
|
|
13788
13771
|
block = parentBlock;
|
|
13789
13772
|
}
|
|
13790
|
-
assert(logger$
|
|
13773
|
+
assert(logger$4k, false, "failed to find parent container in complex block");
|
|
13791
13774
|
}
|
|
13792
13775
|
function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
|
|
13793
13776
|
const blockId = getBlockId(complexBlock);
|
|
13794
|
-
assert(logger$
|
|
13795
|
-
assert(logger$
|
|
13777
|
+
assert(logger$4k, blockId === anchor2.blockId, "invalid start pos");
|
|
13778
|
+
assert(logger$4k, blockId === focus.blockId, "invalid end pos");
|
|
13796
13779
|
const blockClass = getComplexBlockClass(editor, complexBlock);
|
|
13797
13780
|
if (blockClass.adjustSelectionPos) {
|
|
13798
13781
|
return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
|
|
@@ -13826,8 +13809,8 @@ var __publicField = (obj, key, value) => {
|
|
|
13826
13809
|
if (focus instanceof EditorComplexBlockPosition) {
|
|
13827
13810
|
focus = createSimpleBlockPosition(focusBlock, getBlockTextLength$6(editor, focusBlock), "end");
|
|
13828
13811
|
}
|
|
13829
|
-
assert(logger$
|
|
13830
|
-
assert(logger$
|
|
13812
|
+
assert(logger$4k, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
|
|
13813
|
+
assert(logger$4k, focus instanceof EditorSimpleBlockPosition, "not valid position type");
|
|
13831
13814
|
return {
|
|
13832
13815
|
anchor: anchor2,
|
|
13833
13816
|
focus
|
|
@@ -13881,7 +13864,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13881
13864
|
focus
|
|
13882
13865
|
};
|
|
13883
13866
|
}
|
|
13884
|
-
const logger$
|
|
13867
|
+
const logger$4j = getLogger("core");
|
|
13885
13868
|
function createBlockAnchor(editor, block, id, refClientRect) {
|
|
13886
13869
|
const tools = getBlockTools(block);
|
|
13887
13870
|
let elem = tools.querySelector(`.block-anchor[data-id=${id}]`);
|
|
@@ -13899,7 +13882,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13899
13882
|
return elem;
|
|
13900
13883
|
}
|
|
13901
13884
|
function createBlockCaretAnchor(editor, block, offset, id) {
|
|
13902
|
-
assert(logger$
|
|
13885
|
+
assert(logger$4j, isTextKindBlock(editor, block), "not a text kind block");
|
|
13903
13886
|
const caretRect = getTextCaretRect(block, createSimpleBlockPosition(block, offset, "normal"));
|
|
13904
13887
|
const blockRect = block.getBoundingClientRect();
|
|
13905
13888
|
const tools = getBlockTools(block);
|
|
@@ -14258,19 +14241,19 @@ var __publicField = (obj, key, value) => {
|
|
|
14258
14241
|
return result + (index2 ? "-" : "") + word.toLowerCase();
|
|
14259
14242
|
});
|
|
14260
14243
|
const kebabCase$1 = kebabCase;
|
|
14261
|
-
const logger$
|
|
14244
|
+
const logger$4i = getLogger("box");
|
|
14262
14245
|
function isBoxOp(op) {
|
|
14263
14246
|
if (!op.attributes)
|
|
14264
14247
|
return false;
|
|
14265
14248
|
if (!op.attributes.box)
|
|
14266
14249
|
return false;
|
|
14267
|
-
assert(logger$
|
|
14268
|
-
assert(logger$
|
|
14250
|
+
assert(logger$4i, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
|
|
14251
|
+
assert(logger$4i, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
|
|
14269
14252
|
return true;
|
|
14270
14253
|
}
|
|
14271
|
-
const logger$
|
|
14254
|
+
const logger$4h = getLogger("text-op");
|
|
14272
14255
|
function getOpLength(op) {
|
|
14273
|
-
assert(logger$
|
|
14256
|
+
assert(logger$4h, typeof op.insert === "string", "invalid op, no insert");
|
|
14274
14257
|
return op.insert.length;
|
|
14275
14258
|
}
|
|
14276
14259
|
function getOpAt(text2, offset) {
|
|
@@ -14278,7 +14261,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14278
14261
|
let pos = 0;
|
|
14279
14262
|
for (let i = 0; i < ops.length; i++) {
|
|
14280
14263
|
const op = ops[i];
|
|
14281
|
-
assert(logger$
|
|
14264
|
+
assert(logger$4h, typeof op.insert === "string", "invalid text op, no insert");
|
|
14282
14265
|
const end = pos + getOpLength(op);
|
|
14283
14266
|
if (end > offset) {
|
|
14284
14267
|
return [op];
|
|
@@ -14294,22 +14277,22 @@ var __publicField = (obj, key, value) => {
|
|
|
14294
14277
|
}
|
|
14295
14278
|
return [];
|
|
14296
14279
|
}
|
|
14297
|
-
const logger$
|
|
14280
|
+
const logger$4g = getLogger("rich-text-length");
|
|
14298
14281
|
function getTextOpLength(op) {
|
|
14299
|
-
assert(logger$
|
|
14282
|
+
assert(logger$4g, typeof op.insert === "string", "op.insert is not string");
|
|
14300
14283
|
return op.insert.length;
|
|
14301
14284
|
}
|
|
14302
14285
|
function getTextLength(ops) {
|
|
14303
14286
|
let count = 0;
|
|
14304
14287
|
ops.forEach((op) => {
|
|
14305
14288
|
if (op.insert) {
|
|
14306
|
-
assert(logger$
|
|
14289
|
+
assert(logger$4g, typeof op.insert === "string", "op.insert is not string");
|
|
14307
14290
|
count += getTextOpLength(op);
|
|
14308
14291
|
}
|
|
14309
14292
|
});
|
|
14310
14293
|
return count;
|
|
14311
14294
|
}
|
|
14312
|
-
const logger$
|
|
14295
|
+
const logger$4f = getLogger("split-text");
|
|
14313
14296
|
function splitText(ops, offset, splitResult) {
|
|
14314
14297
|
ops = cloneDeep__default.default(ops);
|
|
14315
14298
|
if (offset === 0) {
|
|
@@ -14327,8 +14310,8 @@ var __publicField = (obj, key, value) => {
|
|
|
14327
14310
|
let counted = 0;
|
|
14328
14311
|
for (let i = 0; i < ops.length; i++) {
|
|
14329
14312
|
const op = ops[i];
|
|
14330
|
-
assert(logger$
|
|
14331
|
-
assert(logger$
|
|
14313
|
+
assert(logger$4f, typeof op === "object", `invalid op type, ${typeof op}`);
|
|
14314
|
+
assert(logger$4f, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
|
|
14332
14315
|
const subLen = getTextOpLength(op);
|
|
14333
14316
|
if (counted + subLen < offset) {
|
|
14334
14317
|
counted += subLen;
|
|
@@ -14338,18 +14321,18 @@ var __publicField = (obj, key, value) => {
|
|
|
14338
14321
|
right: ops.slice(i + 1)
|
|
14339
14322
|
};
|
|
14340
14323
|
} else {
|
|
14341
|
-
assert(logger$
|
|
14324
|
+
assert(logger$4f, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
|
|
14342
14325
|
const splitIndex = offset - counted;
|
|
14343
14326
|
const copied = cloneDeep__default.default(op);
|
|
14344
|
-
assert(logger$
|
|
14345
|
-
assert(logger$
|
|
14327
|
+
assert(logger$4f, copied.insert, "no copied.insert");
|
|
14328
|
+
assert(logger$4f, typeof copied.insert === "string", "invalid copied.insert type");
|
|
14346
14329
|
copied.insert = copied.insert.substr(0, splitIndex);
|
|
14347
14330
|
op.insert = op.insert.substr(splitIndex);
|
|
14348
14331
|
if (copied.insert === "") {
|
|
14349
|
-
assert(logger$
|
|
14332
|
+
assert(logger$4f, false, "invalid copied.insert, is empty string");
|
|
14350
14333
|
}
|
|
14351
14334
|
if (op.insert === "") {
|
|
14352
|
-
assert(logger$
|
|
14335
|
+
assert(logger$4f, false, "invalid op.insert, is empty string");
|
|
14353
14336
|
}
|
|
14354
14337
|
const right = [
|
|
14355
14338
|
op,
|
|
@@ -14368,9 +14351,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14368
14351
|
throw new Error(`invalid split offset: ${offset}, ${JSON.stringify(ops)}`);
|
|
14369
14352
|
}
|
|
14370
14353
|
function splitToThree(text2, offset, length) {
|
|
14371
|
-
assert(logger$
|
|
14372
|
-
assert(logger$
|
|
14373
|
-
assert(logger$
|
|
14354
|
+
assert(logger$4f, offset >= 0, "invalid offset, < 0");
|
|
14355
|
+
assert(logger$4f, length > 0, "invalid length, <= 0");
|
|
14356
|
+
assert(logger$4f, offset + length <= getTextLength(text2), "invalid offset + length < text length");
|
|
14374
14357
|
const { left: temp, right } = splitText(text2, offset + length);
|
|
14375
14358
|
const { left, right: middle } = splitText(temp, offset);
|
|
14376
14359
|
return { left, middle, right };
|
|
@@ -14593,9 +14576,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14593
14576
|
}
|
|
14594
14577
|
return [color, backgroundColor];
|
|
14595
14578
|
}
|
|
14596
|
-
const logger$
|
|
14579
|
+
const logger$4e = getLogger("text-block-content");
|
|
14597
14580
|
function updateBlockContentCore(editor, blockPath, content, blockText, insertions) {
|
|
14598
|
-
assert(logger$
|
|
14581
|
+
assert(logger$4e, blockText, "no text for block");
|
|
14599
14582
|
if (blockText.length === 0 && (!insertions || insertions.size === 0)) {
|
|
14600
14583
|
content.innerHTML = "<span><br></span>";
|
|
14601
14584
|
return;
|
|
@@ -14627,9 +14610,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14627
14610
|
for (let i2 = 0; i2 < text2.length; i2++) {
|
|
14628
14611
|
const op = text2[i2];
|
|
14629
14612
|
if (isBoxOp(op)) {
|
|
14630
|
-
assert(logger$
|
|
14613
|
+
assert(logger$4e, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
|
|
14631
14614
|
const span2 = editor.editorBoxes.createBox(content, op.attributes);
|
|
14632
|
-
assert(logger$
|
|
14615
|
+
assert(logger$4e, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
|
|
14633
14616
|
const ret = editor.editorBlockRenders.renderBox(blockPath, op.attributes);
|
|
14634
14617
|
if (ret.classes) {
|
|
14635
14618
|
addClass(span2, ...ret.classes);
|
|
@@ -14647,7 +14630,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14647
14630
|
fragment.appendChild(span2);
|
|
14648
14631
|
continue;
|
|
14649
14632
|
}
|
|
14650
|
-
assert(logger$
|
|
14633
|
+
assert(logger$4e, op.insert, `no insert in op: ${JSON.stringify(op)}`);
|
|
14651
14634
|
const span = createElement("span", ["text"], fragment, op.insert);
|
|
14652
14635
|
if (op.attributes) {
|
|
14653
14636
|
const ret = editor.editorBlockRenders.renderText(blockPath, op.attributes);
|
|
@@ -14678,7 +14661,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14678
14661
|
const compositionText = editor.compositingText;
|
|
14679
14662
|
if (compositionText) {
|
|
14680
14663
|
const pos = editor.selection.range.start;
|
|
14681
|
-
assert(logger$
|
|
14664
|
+
assert(logger$4e, pos.isSimple(), "not an simple position while compositing");
|
|
14682
14665
|
if (pos.blockId === blockId) {
|
|
14683
14666
|
const attributes = getAttributesAt(text2, 0);
|
|
14684
14667
|
insertions.set(pos.offset, [{
|
|
@@ -14694,11 +14677,11 @@ var __publicField = (obj, key, value) => {
|
|
|
14694
14677
|
function clearAllTempCompositionText(editor) {
|
|
14695
14678
|
const children = editor.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');
|
|
14696
14679
|
if (children.length) {
|
|
14697
|
-
logger$
|
|
14680
|
+
logger$4e.debug(`remove ${children.length} temp composition span`);
|
|
14698
14681
|
}
|
|
14699
14682
|
Array.from(children).forEach((c) => c.remove());
|
|
14700
14683
|
}
|
|
14701
|
-
const logger$
|
|
14684
|
+
const logger$4d = getLogger("client-rects");
|
|
14702
14685
|
function getChildrenOffsets(block) {
|
|
14703
14686
|
const children = getTextBlockContentChildren(block);
|
|
14704
14687
|
let start = 0;
|
|
@@ -14716,15 +14699,15 @@ var __publicField = (obj, key, value) => {
|
|
|
14716
14699
|
return ret;
|
|
14717
14700
|
}
|
|
14718
14701
|
function getChildrenInRange(editor, block, from, to) {
|
|
14719
|
-
assert(logger$
|
|
14702
|
+
assert(logger$4d, from < to, `invalid from & to: ${from}, ${to}`);
|
|
14720
14703
|
const blockLength = getBlockTextLength$6(editor, block);
|
|
14721
|
-
assert(logger$
|
|
14704
|
+
assert(logger$4d, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
|
|
14722
14705
|
const offsets = getChildrenOffsets(block);
|
|
14723
14706
|
const startIndex = offsets.findIndex((c) => c.startBlockOffset <= from && from < c.endBlockOffset);
|
|
14724
14707
|
const endIndex = offsets.findIndex((c) => c.startBlockOffset < to && to <= c.endBlockOffset);
|
|
14725
|
-
assert(logger$
|
|
14726
|
-
assert(logger$
|
|
14727
|
-
assert(logger$
|
|
14708
|
+
assert(logger$4d, startIndex !== -1, "failed to find start child");
|
|
14709
|
+
assert(logger$4d, endIndex !== -1, "failed to find end child");
|
|
14710
|
+
assert(logger$4d, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
|
|
14728
14711
|
if (startIndex === endIndex) {
|
|
14729
14712
|
const child = offsets[startIndex];
|
|
14730
14713
|
return [{
|
|
@@ -14806,16 +14789,16 @@ var __publicField = (obj, key, value) => {
|
|
|
14806
14789
|
return rects;
|
|
14807
14790
|
}
|
|
14808
14791
|
function getRangeClientRects(editor, block, range) {
|
|
14809
|
-
assert(logger$
|
|
14792
|
+
assert(logger$4d, range instanceof EditorSimpleSelectionRange, "invalid range");
|
|
14810
14793
|
const start = range.start;
|
|
14811
14794
|
const end = range.end;
|
|
14812
|
-
assert(logger$
|
|
14813
|
-
assert(logger$
|
|
14814
|
-
assert(logger$
|
|
14815
|
-
assert(logger$
|
|
14795
|
+
assert(logger$4d, start.isSimple(), "text block only allow simple position");
|
|
14796
|
+
assert(logger$4d, end.isSimple(), "text block only allow simple position");
|
|
14797
|
+
assert(logger$4d, start.blockId === end.blockId, "only allow update one text block selection");
|
|
14798
|
+
assert(logger$4d, start.blockId === getBlockId(block), "only allow update one text block selection");
|
|
14816
14799
|
return getClientRects$2(editor, block, start, end);
|
|
14817
14800
|
}
|
|
14818
|
-
const logger$
|
|
14801
|
+
const logger$4c = getLogger("selection-background");
|
|
14819
14802
|
function getLineHeight(elem) {
|
|
14820
14803
|
const style2 = window.getComputedStyle(elem);
|
|
14821
14804
|
const lineHeightStyle = style2.getPropertyValue("line-height");
|
|
@@ -14835,9 +14818,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14835
14818
|
return lineHeight;
|
|
14836
14819
|
}
|
|
14837
14820
|
function updateSelection$4(editor, block, start, end) {
|
|
14838
|
-
assert(logger$
|
|
14839
|
-
assert(logger$
|
|
14840
|
-
assert(logger$
|
|
14821
|
+
assert(logger$4c, start.isSimple(), "text block only allow simple position");
|
|
14822
|
+
assert(logger$4c, end.isSimple(), "text block only allow simple position");
|
|
14823
|
+
assert(logger$4c, start.blockId === end.blockId, "only allow update one text block selection");
|
|
14841
14824
|
const from = start.offset;
|
|
14842
14825
|
const to = end.offset;
|
|
14843
14826
|
if (from === to) {
|
|
@@ -14896,7 +14879,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14896
14879
|
}
|
|
14897
14880
|
});
|
|
14898
14881
|
}
|
|
14899
|
-
const logger$
|
|
14882
|
+
const logger$4b = getLogger("line-breaker");
|
|
14900
14883
|
function mergeTextRects(rects) {
|
|
14901
14884
|
const result = [];
|
|
14902
14885
|
let lastRect = null;
|
|
@@ -15023,7 +15006,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15023
15006
|
}
|
|
15024
15007
|
const textChild = child;
|
|
15025
15008
|
const rects = mergeTextRects(textChild.getClientRects());
|
|
15026
|
-
assert(logger$
|
|
15009
|
+
assert(logger$4b, rects.length > 0, "invalid text child dom");
|
|
15027
15010
|
if (rects.length === 1) {
|
|
15028
15011
|
const nextChild = children[i + 1];
|
|
15029
15012
|
if (!nextChild) {
|
|
@@ -15048,10 +15031,10 @@ var __publicField = (obj, key, value) => {
|
|
|
15048
15031
|
continue;
|
|
15049
15032
|
}
|
|
15050
15033
|
const textNode = textChild.firstChild;
|
|
15051
|
-
assert(logger$
|
|
15052
|
-
assert(logger$
|
|
15034
|
+
assert(logger$4b, textNode, "invalid text child, no text node");
|
|
15035
|
+
assert(logger$4b, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
|
|
15053
15036
|
const textChildLength = getTextBlockContentChildTextLength(textChild);
|
|
15054
|
-
assert(logger$
|
|
15037
|
+
assert(logger$4b, textNode.data.length === textChildLength, "text node data length not equal child text length");
|
|
15055
15038
|
const textRects = getTextRects(textNode);
|
|
15056
15039
|
for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
|
|
15057
15040
|
const rect = textRects[rIndex];
|
|
@@ -15093,7 +15076,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15093
15076
|
}
|
|
15094
15077
|
}
|
|
15095
15078
|
}
|
|
15096
|
-
assert(logger$
|
|
15079
|
+
assert(logger$4b, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
|
|
15097
15080
|
return {
|
|
15098
15081
|
lineIndex: lineBreaks.length,
|
|
15099
15082
|
lineBreaks
|
|
@@ -23866,7 +23849,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23866
23849
|
const Graphemer_1 = __importDefault(Graphemer$1);
|
|
23867
23850
|
var _default = lib$1.default = Graphemer_1.default;
|
|
23868
23851
|
const splitter = new _default();
|
|
23869
|
-
const logger$
|
|
23852
|
+
const logger$4a = getLogger("text-offset");
|
|
23870
23853
|
function getChildOffset(block, child) {
|
|
23871
23854
|
const children = getTextBlockContentChildren(block);
|
|
23872
23855
|
let start = 0;
|
|
@@ -23882,26 +23865,26 @@ var __publicField = (obj, key, value) => {
|
|
|
23882
23865
|
}
|
|
23883
23866
|
start += testLength;
|
|
23884
23867
|
}
|
|
23885
|
-
assert(logger$
|
|
23868
|
+
assert(logger$4a, false, "can not find child in children");
|
|
23886
23869
|
}
|
|
23887
23870
|
function isValidOffset(block, blockOffset) {
|
|
23888
|
-
assert(logger$
|
|
23871
|
+
assert(logger$4a, blockOffset >= 0, `invalid offset: ${blockOffset}`);
|
|
23889
23872
|
const childInfo = getTextBlockChild(block, blockOffset);
|
|
23890
23873
|
const { prev, next: next2, offset } = childInfo;
|
|
23891
23874
|
if (!prev && !next2) {
|
|
23892
|
-
assert(logger$
|
|
23875
|
+
assert(logger$4a, false, "invalid offset, no prev & next child at offset");
|
|
23893
23876
|
}
|
|
23894
23877
|
if (prev !== next2) {
|
|
23895
23878
|
return true;
|
|
23896
23879
|
}
|
|
23897
23880
|
const child = prev;
|
|
23898
|
-
assert(logger$
|
|
23881
|
+
assert(logger$4a, child, "no child");
|
|
23899
23882
|
if (isTextBlockContentBoxChild(child)) {
|
|
23900
|
-
assert(logger$
|
|
23883
|
+
assert(logger$4a, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
|
|
23901
23884
|
return true;
|
|
23902
23885
|
}
|
|
23903
23886
|
const text2 = child.textContent;
|
|
23904
|
-
assert(logger$
|
|
23887
|
+
assert(logger$4a, text2, "no content for text child");
|
|
23905
23888
|
const chars = splitter.splitGraphemes(text2);
|
|
23906
23889
|
const validOffsets = /* @__PURE__ */ new Set();
|
|
23907
23890
|
let start = 0;
|
|
@@ -23931,7 +23914,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23931
23914
|
}
|
|
23932
23915
|
function getNextValidOffset(block, blockOffset) {
|
|
23933
23916
|
const length = getTextBlockLength(block);
|
|
23934
|
-
assert(logger$
|
|
23917
|
+
assert(logger$4a, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
|
|
23935
23918
|
if (blockOffset === length) {
|
|
23936
23919
|
return length;
|
|
23937
23920
|
}
|
|
@@ -23945,7 +23928,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23945
23928
|
}
|
|
23946
23929
|
return ret;
|
|
23947
23930
|
}
|
|
23948
|
-
const logger$
|
|
23931
|
+
const logger$49 = getLogger("line-offset");
|
|
23949
23932
|
function getLineOffsets(block) {
|
|
23950
23933
|
const lineBreaks = getLineBreaks(block);
|
|
23951
23934
|
const ret = [];
|
|
@@ -23966,7 +23949,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23966
23949
|
}
|
|
23967
23950
|
function getLineOffset(block, lineIndex) {
|
|
23968
23951
|
const lines = getLineOffsets(block);
|
|
23969
|
-
assert(logger$
|
|
23952
|
+
assert(logger$49, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
|
|
23970
23953
|
return lines[lineIndex];
|
|
23971
23954
|
}
|
|
23972
23955
|
function getLineOffsetByPos(block, pos) {
|
|
@@ -24023,7 +24006,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24023
24006
|
function getLineCount(block) {
|
|
24024
24007
|
return getLineOffsets(block).length;
|
|
24025
24008
|
}
|
|
24026
|
-
const logger$
|
|
24009
|
+
const logger$48 = getLogger("find-text-position");
|
|
24027
24010
|
function isWrappedLine(block, lineIndex) {
|
|
24028
24011
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24029
24012
|
const blockId = getBlockId(block);
|
|
@@ -24034,13 +24017,13 @@ var __publicField = (obj, key, value) => {
|
|
|
24034
24017
|
return false;
|
|
24035
24018
|
}
|
|
24036
24019
|
const childInfo = getTextBlockChild(block, start);
|
|
24037
|
-
assert(logger$
|
|
24038
|
-
assert(logger$
|
|
24020
|
+
assert(logger$48, childInfo.next, "no next child at offset");
|
|
24021
|
+
assert(logger$48, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
|
|
24039
24022
|
return true;
|
|
24040
24023
|
}
|
|
24041
24024
|
function getWrappedLineOffsets(block, lineIndex) {
|
|
24042
24025
|
const blockId = getBlockId(block);
|
|
24043
|
-
assert(logger$
|
|
24026
|
+
assert(logger$48, isWrappedLine(block, lineIndex), "line is not wrapped");
|
|
24044
24027
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24045
24028
|
const homePos = createSimpleBlockPosition(blockId, start, "home");
|
|
24046
24029
|
for (let offset = start + 1; offset <= end; offset += 1) {
|
|
@@ -24055,11 +24038,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24055
24038
|
return offset - 1;
|
|
24056
24039
|
}
|
|
24057
24040
|
}
|
|
24058
|
-
assert(logger$
|
|
24041
|
+
assert(logger$48, false, "failed to find wrapped offset");
|
|
24059
24042
|
return 0;
|
|
24060
24043
|
}
|
|
24061
24044
|
function findTextPositionInLine(editor, block, lineIndex, sourceBlock, pos, findDirection, suggestedX) {
|
|
24062
|
-
assert(logger$
|
|
24045
|
+
assert(logger$48, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
|
|
24063
24046
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24064
24047
|
let from = start;
|
|
24065
24048
|
const blockId = getBlockId(block);
|
|
@@ -24101,11 +24084,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24101
24084
|
return retPos;
|
|
24102
24085
|
}
|
|
24103
24086
|
function findPrevTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
|
|
24104
|
-
assert(logger$
|
|
24087
|
+
assert(logger$48, isTextKindBlock(editor, block), "not a text block");
|
|
24105
24088
|
return findTextPositionInLine(editor, block, getLineCount(block) - 1, sourceBlock, pos, "up", suggestedX);
|
|
24106
24089
|
}
|
|
24107
24090
|
function findNextTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
|
|
24108
|
-
assert(logger$
|
|
24091
|
+
assert(logger$48, isTextKindBlock(editor, block), "not a text block");
|
|
24109
24092
|
return findTextPositionInLine(editor, block, 0, sourceBlock, pos, "down", suggestedX);
|
|
24110
24093
|
}
|
|
24111
24094
|
function moveDown(editor, block, position, suggestedX) {
|
|
@@ -24213,7 +24196,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24213
24196
|
}
|
|
24214
24197
|
return pos;
|
|
24215
24198
|
}
|
|
24216
|
-
const logger$
|
|
24199
|
+
const logger$47 = getLogger("move-caret");
|
|
24217
24200
|
function moveTextCaret(editor, block, position, direction) {
|
|
24218
24201
|
if (direction === "ArrowLeft") {
|
|
24219
24202
|
const ret = moveLeft(block, position);
|
|
@@ -24243,9 +24226,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24243
24226
|
}
|
|
24244
24227
|
return createSimpleBlockPosition(getBlockId(block), ret.offset, ret.type);
|
|
24245
24228
|
}
|
|
24246
|
-
assert(logger$
|
|
24229
|
+
assert(logger$47, false, `invalid navigation direction: ${direction}`);
|
|
24247
24230
|
}
|
|
24248
|
-
const logger$
|
|
24231
|
+
const logger$46 = getLogger("text-range");
|
|
24249
24232
|
function getBlockRects(block) {
|
|
24250
24233
|
const ret = [];
|
|
24251
24234
|
const children = getTextBlockContentChildren(block);
|
|
@@ -24303,9 +24286,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24303
24286
|
return null;
|
|
24304
24287
|
}
|
|
24305
24288
|
const children = getTextBlockContentChildren(block);
|
|
24306
|
-
assert(logger$
|
|
24289
|
+
assert(logger$46, children.indexOf(child) !== -1, "failed to find child in children");
|
|
24307
24290
|
const offsetInfo = getChildOffset(block, child);
|
|
24308
|
-
assert(logger$
|
|
24291
|
+
assert(logger$46, offsetInfo, "failed to get child offset");
|
|
24309
24292
|
const { start } = offsetInfo;
|
|
24310
24293
|
let offset;
|
|
24311
24294
|
let length;
|
|
@@ -24321,7 +24304,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24321
24304
|
}
|
|
24322
24305
|
length = 0;
|
|
24323
24306
|
} else {
|
|
24324
|
-
assert(logger$
|
|
24307
|
+
assert(logger$46, child.firstChild instanceof Text, "child is not text");
|
|
24325
24308
|
offset = start + textNodeOffsetFromPoint(child.firstChild, x, y);
|
|
24326
24309
|
length = 0;
|
|
24327
24310
|
}
|
|
@@ -24345,9 +24328,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24345
24328
|
}
|
|
24346
24329
|
return new EditorSimpleSelectionRange(editor, { anchor: startPos, focus: endPos != null ? endPos : startPos });
|
|
24347
24330
|
}
|
|
24348
|
-
const logger$
|
|
24331
|
+
const logger$45 = getLogger("create-text-op");
|
|
24349
24332
|
function createTextOp(text2, attributes) {
|
|
24350
|
-
assert(logger$
|
|
24333
|
+
assert(logger$45, text2, "text is empty");
|
|
24351
24334
|
const ret = {
|
|
24352
24335
|
insert: text2
|
|
24353
24336
|
};
|
|
@@ -24370,7 +24353,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24370
24353
|
}
|
|
24371
24354
|
return result;
|
|
24372
24355
|
}
|
|
24373
|
-
const logger$
|
|
24356
|
+
const logger$44 = getLogger("merge-ops");
|
|
24374
24357
|
function mergeOps(text2) {
|
|
24375
24358
|
if (text2.length <= 1) {
|
|
24376
24359
|
return text2;
|
|
@@ -24392,10 +24375,10 @@ var __publicField = (obj, key, value) => {
|
|
|
24392
24375
|
return false;
|
|
24393
24376
|
}
|
|
24394
24377
|
if (op1.attributes === void 0) {
|
|
24395
|
-
assert(logger$
|
|
24378
|
+
assert(logger$44, op2.attributes === void 0, "op2.attributes is not undefined");
|
|
24396
24379
|
return true;
|
|
24397
24380
|
}
|
|
24398
|
-
assert(logger$
|
|
24381
|
+
assert(logger$44, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
|
|
24399
24382
|
return isEqual__default.default(op1.attributes, op2.attributes);
|
|
24400
24383
|
};
|
|
24401
24384
|
const newOps = [];
|
|
@@ -24404,8 +24387,8 @@ var __publicField = (obj, key, value) => {
|
|
|
24404
24387
|
for (let i = 1; i < text2.length; i += 1) {
|
|
24405
24388
|
const op = text2[i];
|
|
24406
24389
|
if (isSameTypeOp(before, op)) {
|
|
24407
|
-
assert(logger$
|
|
24408
|
-
assert(logger$
|
|
24390
|
+
assert(logger$44, typeof before.insert === "string", "before.insert is not string");
|
|
24391
|
+
assert(logger$44, typeof op.insert === "string", "op.insert is not string");
|
|
24409
24392
|
before.insert += op.insert;
|
|
24410
24393
|
} else {
|
|
24411
24394
|
newOps.push(op);
|
|
@@ -24433,15 +24416,15 @@ var __publicField = (obj, key, value) => {
|
|
|
24433
24416
|
}
|
|
24434
24417
|
return text2.slice(0, i + 1);
|
|
24435
24418
|
}
|
|
24436
|
-
const logger$
|
|
24419
|
+
const logger$43 = getLogger("delete-text");
|
|
24437
24420
|
function deleteText(richText2, offset, count) {
|
|
24438
24421
|
const { left, right } = splitToThree(richText2, offset, count);
|
|
24439
24422
|
const result = [...left, ...right];
|
|
24440
24423
|
return mergeOps(result);
|
|
24441
24424
|
}
|
|
24442
24425
|
function createDeleteOps(offset, count) {
|
|
24443
|
-
assert(logger$
|
|
24444
|
-
assert(logger$
|
|
24426
|
+
assert(logger$43, offset >= 0, `invalid offset: ${offset}`);
|
|
24427
|
+
assert(logger$43, count >= 1, `invalid delete count: ${count}`);
|
|
24445
24428
|
const ops = [];
|
|
24446
24429
|
if (offset !== 0) {
|
|
24447
24430
|
ops.push({
|
|
@@ -24453,7 +24436,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24453
24436
|
});
|
|
24454
24437
|
return ops;
|
|
24455
24438
|
}
|
|
24456
|
-
const logger$
|
|
24439
|
+
const logger$42 = getLogger("delta");
|
|
24457
24440
|
function diffRichText(oldText, newText) {
|
|
24458
24441
|
const delta1D = new Delta__default.default(oldText);
|
|
24459
24442
|
const delta2D = new Delta__default.default(newText);
|
|
@@ -24463,7 +24446,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24463
24446
|
return new Delta__default.default(ops).transformPosition(cursor, !isLocalOp);
|
|
24464
24447
|
}
|
|
24465
24448
|
function isValidDocText(text2) {
|
|
24466
|
-
assert(logger$
|
|
24449
|
+
assert(logger$42, text2, "ops is null or undefined");
|
|
24467
24450
|
for (let i = 0; i < text2.length; i++) {
|
|
24468
24451
|
const op = text2[i];
|
|
24469
24452
|
if (op.insert === null || op.insert === void 0) {
|
|
@@ -24483,7 +24466,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24483
24466
|
}
|
|
24484
24467
|
class RichText {
|
|
24485
24468
|
static ensureValidText(text2) {
|
|
24486
|
-
assert(logger$
|
|
24469
|
+
assert(logger$42, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
|
|
24487
24470
|
}
|
|
24488
24471
|
static diff(oldText, newText) {
|
|
24489
24472
|
this.ensureValidText(oldText);
|
|
@@ -24505,9 +24488,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24505
24488
|
return resultText;
|
|
24506
24489
|
}
|
|
24507
24490
|
}
|
|
24508
|
-
const logger$
|
|
24491
|
+
const logger$41 = getLogger("insert-text");
|
|
24509
24492
|
function insertText(richText2, offset, text2, attributes) {
|
|
24510
|
-
assert(logger$
|
|
24493
|
+
assert(logger$41, text2, `invalid text to insert: ${text2}`);
|
|
24511
24494
|
const { left, right } = splitText(richText2, offset);
|
|
24512
24495
|
const insertedText = typeof text2 === "string" ? [createTextOp(text2, attributes)] : text2;
|
|
24513
24496
|
const result = [...left, ...insertedText, ...right];
|
|
@@ -24520,7 +24503,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24520
24503
|
};
|
|
24521
24504
|
}
|
|
24522
24505
|
function createInsertOps(offset, text2, attributes) {
|
|
24523
|
-
assert(logger$
|
|
24506
|
+
assert(logger$41, offset >= 0, `invalid offset: ${offset}`);
|
|
24524
24507
|
if (text2.length === 0) {
|
|
24525
24508
|
return [];
|
|
24526
24509
|
}
|
|
@@ -24550,7 +24533,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24550
24533
|
function cloneText(text2) {
|
|
24551
24534
|
return cloneDeep__default.default(text2);
|
|
24552
24535
|
}
|
|
24553
|
-
const logger$
|
|
24536
|
+
const logger$40 = getLogger("update-op-attribute");
|
|
24554
24537
|
function updateOpAttributes(orgOps, key, value, newAttributes) {
|
|
24555
24538
|
const ops = cloneText(orgOps);
|
|
24556
24539
|
const index2 = ops.findIndex((op2) => {
|
|
@@ -24558,7 +24541,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24558
24541
|
return false;
|
|
24559
24542
|
return op2.attributes[key] === value;
|
|
24560
24543
|
});
|
|
24561
|
-
assert(logger$
|
|
24544
|
+
assert(logger$40, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
|
|
24562
24545
|
const op = ops[index2];
|
|
24563
24546
|
op.attributes = {
|
|
24564
24547
|
...op.attributes,
|
|
@@ -24640,11 +24623,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24640
24623
|
]);
|
|
24641
24624
|
}
|
|
24642
24625
|
const FILL_CHAR = "\u200B";
|
|
24643
|
-
const logger$
|
|
24626
|
+
const logger$3$ = getLogger("to-plain-text");
|
|
24644
24627
|
function toPlainText(ops, options) {
|
|
24645
24628
|
let text2 = "";
|
|
24646
24629
|
ops.forEach((op) => {
|
|
24647
|
-
assert(logger$
|
|
24630
|
+
assert(logger$3$, typeof op.insert === "string", "invalid op");
|
|
24648
24631
|
if (op.attributes && op.attributes.box === true) {
|
|
24649
24632
|
if (options == null ? void 0 : options.boxReplacement) {
|
|
24650
24633
|
text2 += options.boxReplacement;
|
|
@@ -24699,11 +24682,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24699
24682
|
focus: pos
|
|
24700
24683
|
};
|
|
24701
24684
|
}
|
|
24702
|
-
const logger$
|
|
24685
|
+
const logger$3_ = getLogger("block-to-text");
|
|
24703
24686
|
function textBlockToText$1(editor, ops, doc2) {
|
|
24704
24687
|
let text2 = "";
|
|
24705
24688
|
ops.forEach((op) => {
|
|
24706
|
-
assert(logger$
|
|
24689
|
+
assert(logger$3_, typeof op.insert === "string", "invalid op");
|
|
24707
24690
|
if (op.attributes && op.attributes.box === true) {
|
|
24708
24691
|
const box = op.attributes;
|
|
24709
24692
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -24721,11 +24704,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24721
24704
|
});
|
|
24722
24705
|
return text2;
|
|
24723
24706
|
}
|
|
24724
|
-
const logger$
|
|
24707
|
+
const logger$3Z = getLogger("block-to-text");
|
|
24725
24708
|
function textToMarkdownText(editor, ops, doc2) {
|
|
24726
24709
|
let text2 = "";
|
|
24727
24710
|
ops.forEach((op) => {
|
|
24728
|
-
assert(logger$
|
|
24711
|
+
assert(logger$3Z, typeof op.insert === "string", "invalid op");
|
|
24729
24712
|
if (op.attributes && op.attributes.box === true) {
|
|
24730
24713
|
const box = op.attributes;
|
|
24731
24714
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -24848,12 +24831,12 @@ var __publicField = (obj, key, value) => {
|
|
|
24848
24831
|
return void 0;
|
|
24849
24832
|
}
|
|
24850
24833
|
}
|
|
24851
|
-
const logger$
|
|
24834
|
+
const logger$3Y = getLogger("block-to-text");
|
|
24852
24835
|
function textBlockToHtml(editor, blockData, doc2) {
|
|
24853
24836
|
let html = "";
|
|
24854
24837
|
const ops = blockData.text || [];
|
|
24855
24838
|
ops.forEach((op) => {
|
|
24856
|
-
assert(logger$
|
|
24839
|
+
assert(logger$3Y, typeof op.insert === "string", "invalid op");
|
|
24857
24840
|
if (op.attributes && op.attributes.box === true) {
|
|
24858
24841
|
const box = op.attributes;
|
|
24859
24842
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -24929,16 +24912,16 @@ var __publicField = (obj, key, value) => {
|
|
|
24929
24912
|
}
|
|
24930
24913
|
return `<p>${html}</p>`;
|
|
24931
24914
|
}
|
|
24932
|
-
const logger$
|
|
24915
|
+
const logger$3X = getLogger("text-block");
|
|
24933
24916
|
function createBlockContent$5(editor, path, container, blockElement, blockData) {
|
|
24934
24917
|
const { text: text2 } = blockData;
|
|
24935
|
-
assert(logger$
|
|
24918
|
+
assert(logger$3X, text2, "no text for text block");
|
|
24936
24919
|
const content = createBlockContentElement(blockElement, "div");
|
|
24937
24920
|
updateBlockContent$1(editor, path, blockData.id, content, text2);
|
|
24938
24921
|
return content;
|
|
24939
24922
|
}
|
|
24940
24923
|
function updateBlockText$1(editor, block, text2) {
|
|
24941
|
-
assert(logger$
|
|
24924
|
+
assert(logger$3X, text2, "no text to update");
|
|
24942
24925
|
const newContent = createBlockContentElement(null, "div");
|
|
24943
24926
|
updateBlockContent$1(editor, getBlockPath(block), getBlockId(block), newContent, text2);
|
|
24944
24927
|
const oldContent = getBlockContent(block);
|
|
@@ -24948,7 +24931,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24948
24931
|
return getRangeClientRects(editor, block, range);
|
|
24949
24932
|
}
|
|
24950
24933
|
function convertTo$k(editor, blockData, doc2, type) {
|
|
24951
|
-
assert(logger$
|
|
24934
|
+
assert(logger$3X, blockData.text, "no text for text block");
|
|
24952
24935
|
if (type === "text") {
|
|
24953
24936
|
return textBlockToText$1(editor, blockData.text, doc2);
|
|
24954
24937
|
}
|
|
@@ -24962,7 +24945,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24962
24945
|
blockData.id = genId();
|
|
24963
24946
|
info == null ? void 0 : info.blockIdMap.set(srcBlockData.id, blockData.id);
|
|
24964
24947
|
const { text: text2 } = blockData;
|
|
24965
|
-
assert(logger$
|
|
24948
|
+
assert(logger$3X, text2, "no text for text block");
|
|
24966
24949
|
text2.forEach((op) => {
|
|
24967
24950
|
if (op.insert && op.attributes && op.attributes.box === true) {
|
|
24968
24951
|
const boxId = genId();
|
|
@@ -24994,7 +24977,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24994
24977
|
blockToDoc: blockToDoc$1
|
|
24995
24978
|
};
|
|
24996
24979
|
const updateTextBlockContent = updateBlockContent$1;
|
|
24997
|
-
const logger$
|
|
24980
|
+
const logger$3W = getLogger("action-helper");
|
|
24998
24981
|
function editorGetBlockData(editor, block) {
|
|
24999
24982
|
const container = getParentContainer(block);
|
|
25000
24983
|
const containerId = getContainerId(container);
|
|
@@ -25002,10 +24985,10 @@ var __publicField = (obj, key, value) => {
|
|
|
25002
24985
|
return editor.doc.getBlockData(containerId, blockIndex);
|
|
25003
24986
|
}
|
|
25004
24987
|
function editorGetBlockText(editor, block) {
|
|
25005
|
-
assert(logger$
|
|
24988
|
+
assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
|
|
25006
24989
|
const data2 = editorGetBlockData(editor, block);
|
|
25007
24990
|
const text2 = data2.text;
|
|
25008
|
-
assert(logger$
|
|
24991
|
+
assert(logger$3W, text2, "no text in block");
|
|
25009
24992
|
return text2;
|
|
25010
24993
|
}
|
|
25011
24994
|
function editorGetBlockTextEx(editor, block, length) {
|
|
@@ -25013,7 +24996,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25013
24996
|
}
|
|
25014
24997
|
function editorGetBoxData(editor, box) {
|
|
25015
24998
|
const block = getParentBlock(box);
|
|
25016
|
-
assert(logger$
|
|
24999
|
+
assert(logger$3W, block, "no parent block");
|
|
25017
25000
|
const text2 = editorGetBlockText(editor, block);
|
|
25018
25001
|
const id = getBoxId(box);
|
|
25019
25002
|
const op = text2.find((op2) => {
|
|
@@ -25023,60 +25006,60 @@ var __publicField = (obj, key, value) => {
|
|
|
25023
25006
|
}
|
|
25024
25007
|
return false;
|
|
25025
25008
|
});
|
|
25026
|
-
assert(logger$
|
|
25009
|
+
assert(logger$3W, op, "failed to find box");
|
|
25027
25010
|
return op.attributes;
|
|
25028
25011
|
}
|
|
25029
|
-
const logger$
|
|
25012
|
+
const logger$3V = getLogger("block-text");
|
|
25030
25013
|
function getTextAfterOffset(editor, block, offset) {
|
|
25031
|
-
assert(logger$
|
|
25032
|
-
assert(logger$
|
|
25033
|
-
assert(logger$
|
|
25014
|
+
assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
|
|
25015
|
+
assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
|
|
25016
|
+
assert(logger$3V, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25034
25017
|
const newOffset = getNextValidOffset(block, offset);
|
|
25035
25018
|
const length = newOffset - offset;
|
|
25036
25019
|
if (length === 0) {
|
|
25037
|
-
assert(logger$
|
|
25020
|
+
assert(logger$3V, false, `no text after offset: ${offset}`);
|
|
25038
25021
|
}
|
|
25039
25022
|
const text2 = editorGetBlockText(editor, block);
|
|
25040
25023
|
const { middle } = splitToThree(text2, offset, length);
|
|
25041
|
-
assert(logger$
|
|
25024
|
+
assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
|
|
25042
25025
|
const op = middle[0];
|
|
25043
25026
|
if (isBoxOp(op)) {
|
|
25044
25027
|
return " ";
|
|
25045
25028
|
}
|
|
25046
|
-
assert(logger$
|
|
25029
|
+
assert(logger$3V, op.insert.length === 1 || op.insert.length === 2, "invalid op");
|
|
25047
25030
|
return op.insert;
|
|
25048
25031
|
}
|
|
25049
25032
|
function getTextBeforeOffset(editor, block, offset) {
|
|
25050
|
-
assert(logger$
|
|
25051
|
-
assert(logger$
|
|
25052
|
-
assert(logger$
|
|
25033
|
+
assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
|
|
25034
|
+
assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
|
|
25035
|
+
assert(logger$3V, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25053
25036
|
const newOffset = getPrevValidOffset(block, offset);
|
|
25054
25037
|
const length = offset - newOffset;
|
|
25055
25038
|
if (length === 0) {
|
|
25056
|
-
assert(logger$
|
|
25039
|
+
assert(logger$3V, false, `no text before offset: ${offset}`);
|
|
25057
25040
|
}
|
|
25058
25041
|
const text2 = editorGetBlockText(editor, block);
|
|
25059
25042
|
const { middle } = splitToThree(text2, newOffset, length);
|
|
25060
|
-
assert(logger$
|
|
25043
|
+
assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
|
|
25061
25044
|
const op = middle[0];
|
|
25062
25045
|
if (isBoxOp(op)) {
|
|
25063
25046
|
return " ";
|
|
25064
25047
|
}
|
|
25065
|
-
assert(logger$
|
|
25048
|
+
assert(logger$3V, op.insert.length === 1 || op.insert.length === 2, "invalid op");
|
|
25066
25049
|
return op.insert;
|
|
25067
25050
|
}
|
|
25068
25051
|
function getOffsetInfoBefore(editor, block, offset) {
|
|
25069
|
-
assert(logger$
|
|
25070
|
-
assert(logger$
|
|
25071
|
-
assert(logger$
|
|
25052
|
+
assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
|
|
25053
|
+
assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
|
|
25054
|
+
assert(logger$3V, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25072
25055
|
const newOffset = getPrevValidOffset(block, offset);
|
|
25073
25056
|
const length = offset - newOffset;
|
|
25074
25057
|
if (length === 0) {
|
|
25075
|
-
assert(logger$
|
|
25058
|
+
assert(logger$3V, false, `no text before offset: ${offset}`);
|
|
25076
25059
|
}
|
|
25077
25060
|
const text2 = editorGetBlockText(editor, block);
|
|
25078
25061
|
const { middle } = splitToThree(text2, newOffset, length);
|
|
25079
|
-
assert(logger$
|
|
25062
|
+
assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
|
|
25080
25063
|
const op = middle[0];
|
|
25081
25064
|
if (isBoxOp(op)) {
|
|
25082
25065
|
return {
|
|
@@ -25086,33 +25069,25 @@ var __publicField = (obj, key, value) => {
|
|
|
25086
25069
|
length: 1
|
|
25087
25070
|
};
|
|
25088
25071
|
}
|
|
25089
|
-
let charType = "text";
|
|
25090
|
-
if (isSpace(op.insert)) {
|
|
25091
|
-
charType = "space";
|
|
25092
|
-
} else if (isCJKPunctuation(op.insert)) {
|
|
25093
|
-
charType = "cjk_punctuation";
|
|
25094
|
-
} else if (isCJK(op.insert)) {
|
|
25095
|
-
charType = "cjk";
|
|
25096
|
-
}
|
|
25097
25072
|
return {
|
|
25098
25073
|
op,
|
|
25099
|
-
charType,
|
|
25074
|
+
charType: isSpace(op.insert) ? "space" : "text",
|
|
25100
25075
|
offset: newOffset,
|
|
25101
25076
|
length: op.insert.length
|
|
25102
25077
|
};
|
|
25103
25078
|
}
|
|
25104
25079
|
function getOffsetInfoAfter(editor, block, offset) {
|
|
25105
|
-
assert(logger$
|
|
25106
|
-
assert(logger$
|
|
25107
|
-
assert(logger$
|
|
25080
|
+
assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
|
|
25081
|
+
assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
|
|
25082
|
+
assert(logger$3V, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25108
25083
|
const newOffset = getNextValidOffset(block, offset);
|
|
25109
25084
|
const length = newOffset - offset;
|
|
25110
25085
|
if (length === 0) {
|
|
25111
|
-
assert(logger$
|
|
25086
|
+
assert(logger$3V, false, `no text after offset: ${offset}`);
|
|
25112
25087
|
}
|
|
25113
25088
|
const text2 = editorGetBlockText(editor, block);
|
|
25114
25089
|
const { middle } = splitToThree(text2, offset, length);
|
|
25115
|
-
assert(logger$
|
|
25090
|
+
assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
|
|
25116
25091
|
const op = middle[0];
|
|
25117
25092
|
if (isBoxOp(op)) {
|
|
25118
25093
|
return {
|
|
@@ -25122,17 +25097,9 @@ var __publicField = (obj, key, value) => {
|
|
|
25122
25097
|
length: 1
|
|
25123
25098
|
};
|
|
25124
25099
|
}
|
|
25125
|
-
let charType = "text";
|
|
25126
|
-
if (isSpace(op.insert)) {
|
|
25127
|
-
charType = "space";
|
|
25128
|
-
} else if (isCJKPunctuation(op.insert)) {
|
|
25129
|
-
charType = "cjk_punctuation";
|
|
25130
|
-
} else if (isCJK(op.insert)) {
|
|
25131
|
-
charType = "cjk";
|
|
25132
|
-
}
|
|
25133
25100
|
return {
|
|
25134
25101
|
op,
|
|
25135
|
-
charType,
|
|
25102
|
+
charType: isSpace(op.insert) ? "space" : "text",
|
|
25136
25103
|
offset,
|
|
25137
25104
|
length: op.insert.length
|
|
25138
25105
|
};
|
|
@@ -25184,7 +25151,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25184
25151
|
return null;
|
|
25185
25152
|
}
|
|
25186
25153
|
function findWordLeft(editor, block, offset) {
|
|
25187
|
-
assert(logger$
|
|
25154
|
+
assert(logger$3V, isTextKindBlock(editor, block), "invalid blok type");
|
|
25188
25155
|
if (isEmptyTextBlock(editor, block)) {
|
|
25189
25156
|
return 0;
|
|
25190
25157
|
}
|
|
@@ -25193,7 +25160,6 @@ var __publicField = (obj, key, value) => {
|
|
|
25193
25160
|
return offset - 1;
|
|
25194
25161
|
}
|
|
25195
25162
|
let start = offset;
|
|
25196
|
-
let find = offsetInfo.charType;
|
|
25197
25163
|
if (offsetInfo.charType === "space") {
|
|
25198
25164
|
const startInfo2 = findPrevOffsetNotType(editor, block, start, "space");
|
|
25199
25165
|
if (!startInfo2) {
|
|
@@ -25206,15 +25172,14 @@ var __publicField = (obj, key, value) => {
|
|
|
25206
25172
|
return startInfo2.offset;
|
|
25207
25173
|
}
|
|
25208
25174
|
start = startInfo2.offset;
|
|
25209
|
-
find = getOffsetInfoBefore(editor, block, start).charType;
|
|
25210
25175
|
}
|
|
25211
|
-
const startInfo = findPrevOffsetNotType(editor, block, start,
|
|
25176
|
+
const startInfo = findPrevOffsetNotType(editor, block, start, "text");
|
|
25212
25177
|
if (!startInfo)
|
|
25213
25178
|
return 0;
|
|
25214
25179
|
return startInfo.offset + startInfo.length;
|
|
25215
25180
|
}
|
|
25216
25181
|
function findWordEnd(editor, block, offset) {
|
|
25217
|
-
assert(logger$
|
|
25182
|
+
assert(logger$3V, isTextKindBlock(editor, block), "invalid blok type");
|
|
25218
25183
|
if (isEmptyTextBlock(editor, block)) {
|
|
25219
25184
|
return 0;
|
|
25220
25185
|
}
|
|
@@ -25223,7 +25188,6 @@ var __publicField = (obj, key, value) => {
|
|
|
25223
25188
|
return offset + 1;
|
|
25224
25189
|
}
|
|
25225
25190
|
let start = offset;
|
|
25226
|
-
let find = offsetInfo.charType;
|
|
25227
25191
|
if (offsetInfo.charType === "space") {
|
|
25228
25192
|
const startInfo2 = findAfterOffsetNotType(editor, block, start, "space");
|
|
25229
25193
|
if (!startInfo2) {
|
|
@@ -25236,17 +25200,16 @@ var __publicField = (obj, key, value) => {
|
|
|
25236
25200
|
return startInfo2.offset;
|
|
25237
25201
|
}
|
|
25238
25202
|
start = startInfo2.offset;
|
|
25239
|
-
find = getOffsetInfoAfter(editor, block, start).charType;
|
|
25240
25203
|
}
|
|
25241
|
-
const startInfo = findAfterOffsetNotType(editor, block, start,
|
|
25204
|
+
const startInfo = findAfterOffsetNotType(editor, block, start, "text");
|
|
25242
25205
|
if (!startInfo)
|
|
25243
25206
|
return getBlockTextLength$6(editor, block);
|
|
25244
25207
|
return startInfo.offset;
|
|
25245
25208
|
}
|
|
25246
|
-
const logger$
|
|
25209
|
+
const logger$3U = getLogger("text-box");
|
|
25247
25210
|
function updateBoxContent$8(editor, boxElement, boxContent, boxData) {
|
|
25248
|
-
assert(logger$
|
|
25249
|
-
assert(logger$
|
|
25211
|
+
assert(logger$3U, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
|
|
25212
|
+
assert(logger$3U, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
|
|
25250
25213
|
createElement("span", [], boxContent, boxData.text);
|
|
25251
25214
|
}
|
|
25252
25215
|
function convertTo$j(editor, boxData, doc2, type) {
|
|
@@ -25280,7 +25243,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25280
25243
|
updateBoxContent: updateBoxContent$7,
|
|
25281
25244
|
convertTo: convertTo$i
|
|
25282
25245
|
};
|
|
25283
|
-
const logger$
|
|
25246
|
+
const logger$3T = getLogger("editor-boxes");
|
|
25284
25247
|
class EditorBoxes {
|
|
25285
25248
|
constructor(editor) {
|
|
25286
25249
|
__publicField(this, "boxes", /* @__PURE__ */ new Map());
|
|
@@ -25289,12 +25252,12 @@ var __publicField = (obj, key, value) => {
|
|
|
25289
25252
|
registerBoxClass(boxClass) {
|
|
25290
25253
|
const type = boxClass.boxType;
|
|
25291
25254
|
const exists = this.boxes.get(type);
|
|
25292
|
-
assert(logger$
|
|
25255
|
+
assert(logger$3T, !exists, `duplicated box type: ${type}`);
|
|
25293
25256
|
this.boxes.set(type, boxClass);
|
|
25294
25257
|
}
|
|
25295
25258
|
getBoxClass(type) {
|
|
25296
25259
|
const exists = this.boxes.get(type);
|
|
25297
|
-
assert(logger$
|
|
25260
|
+
assert(logger$3T, exists, `unknown box type: ${type}`);
|
|
25298
25261
|
return exists;
|
|
25299
25262
|
}
|
|
25300
25263
|
createBox(blockContent, box) {
|
|
@@ -25659,7 +25622,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25659
25622
|
return { classes, attributes: newAttributes, styles: newStyles };
|
|
25660
25623
|
}
|
|
25661
25624
|
}
|
|
25662
|
-
const logger$
|
|
25625
|
+
const logger$3S = getLogger("editor-insertion");
|
|
25663
25626
|
class EditorInsertions {
|
|
25664
25627
|
constructor(editor) {
|
|
25665
25628
|
__publicField(this, "insertions", /* @__PURE__ */ new Map());
|
|
@@ -25668,12 +25631,12 @@ var __publicField = (obj, key, value) => {
|
|
|
25668
25631
|
registerInsertionClass(insertionClass) {
|
|
25669
25632
|
const type = insertionClass.insertionType;
|
|
25670
25633
|
const exists = this.insertions.get(type);
|
|
25671
|
-
assert(logger$
|
|
25634
|
+
assert(logger$3S, !exists, `duplicated insertion type: ${type}`);
|
|
25672
25635
|
this.insertions.set(type, insertionClass);
|
|
25673
25636
|
}
|
|
25674
25637
|
getInsertionClass(type) {
|
|
25675
25638
|
const exists = this.insertions.get(type);
|
|
25676
|
-
assert(logger$
|
|
25639
|
+
assert(logger$3S, exists, `unknown insertion type: ${type}`);
|
|
25677
25640
|
return exists;
|
|
25678
25641
|
}
|
|
25679
25642
|
createInsertionElement(type, id, attributes) {
|
|
@@ -25793,7 +25756,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25793
25756
|
};
|
|
25794
25757
|
}
|
|
25795
25758
|
}
|
|
25796
|
-
const logger$
|
|
25759
|
+
const logger$3R = getLogger("editor-input");
|
|
25797
25760
|
class EditorInput$1 {
|
|
25798
25761
|
constructor(editor, callbacks) {
|
|
25799
25762
|
__publicField(this, "editor");
|
|
@@ -25915,7 +25878,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25915
25878
|
return;
|
|
25916
25879
|
}
|
|
25917
25880
|
this.callbacks.onCut(event);
|
|
25918
|
-
logger$
|
|
25881
|
+
logger$3R.debug("on cut");
|
|
25919
25882
|
});
|
|
25920
25883
|
__publicField(this, "handlePaste", (event) => {
|
|
25921
25884
|
if (event.isTrusted) {
|
|
@@ -26030,11 +25993,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26030
25993
|
this.callbacks.removeHandler(handler);
|
|
26031
25994
|
}
|
|
26032
25995
|
defaultInsertText(editor, containerId, blockIndex, offset, text2) {
|
|
26033
|
-
assert(logger$
|
|
25996
|
+
assert(logger$3R, editor === this.editor, "invalid editor");
|
|
26034
25997
|
this.callbacks.defaultInsertText(editor, containerId, blockIndex, offset, text2);
|
|
26035
25998
|
}
|
|
26036
25999
|
defaultHandleKeydown(editor, event) {
|
|
26037
|
-
assert(logger$
|
|
26000
|
+
assert(logger$3R, editor === this.editor, "invalid editor");
|
|
26038
26001
|
return this.callbacks.defaultHandleKeydown(editor, event);
|
|
26039
26002
|
}
|
|
26040
26003
|
forEach(callback) {
|
|
@@ -26059,7 +26022,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26059
26022
|
input2.style.left = `${x / scale}px`;
|
|
26060
26023
|
input2.style.top = `${y / scale}px`;
|
|
26061
26024
|
}
|
|
26062
|
-
const logger$
|
|
26025
|
+
const logger$3Q = getLogger("editor-caret");
|
|
26063
26026
|
function getFirefoxVersion() {
|
|
26064
26027
|
const userAgent = window.navigator.userAgent;
|
|
26065
26028
|
const match = userAgent.match(/Firefox\/(\d+)\./);
|
|
@@ -26122,11 +26085,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26122
26085
|
return;
|
|
26123
26086
|
}
|
|
26124
26087
|
const { range } = this.editor.selection;
|
|
26125
|
-
assert(logger$
|
|
26088
|
+
assert(logger$3Q, range.isCollapsed, "range is not collapsed");
|
|
26126
26089
|
const pos = range.start;
|
|
26127
|
-
assert(logger$
|
|
26090
|
+
assert(logger$3Q, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
|
|
26128
26091
|
const block = this.editor.getBlockById(pos.blockId);
|
|
26129
|
-
assert(logger$
|
|
26092
|
+
assert(logger$3Q, isTextKindBlock(this.editor, block), "only text kind block can has caret");
|
|
26130
26093
|
let rect;
|
|
26131
26094
|
const compositionSpan = block.querySelector("span.inputting-insertion");
|
|
26132
26095
|
if (compositionSpan) {
|
|
@@ -26164,7 +26127,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26164
26127
|
clearAllSelection(editor);
|
|
26165
26128
|
editor.selection.range.getSelectedBlocks().forEach((s) => updateBlockSelection(editor, s.block, s.start, s.end));
|
|
26166
26129
|
}
|
|
26167
|
-
const logger$
|
|
26130
|
+
const logger$3P = getLogger("editor-dom");
|
|
26168
26131
|
function editorGetClientHeight(editor) {
|
|
26169
26132
|
const scrollContainer = getScrollContainer$1(editor.rootContainer);
|
|
26170
26133
|
return scrollContainer.clientHeight;
|
|
@@ -26252,7 +26215,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26252
26215
|
}
|
|
26253
26216
|
function editorScrollIntoView(editor) {
|
|
26254
26217
|
if (!isElementVisible(editor.rootContainer)) {
|
|
26255
|
-
logger$
|
|
26218
|
+
logger$3P.warn("editorScrollIntoView: editor is not visible");
|
|
26256
26219
|
return;
|
|
26257
26220
|
}
|
|
26258
26221
|
const rootClientRect = editor.rootContainer.getBoundingClientRect();
|
|
@@ -26317,7 +26280,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26317
26280
|
const { start, end } = range;
|
|
26318
26281
|
return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
|
|
26319
26282
|
}
|
|
26320
|
-
const logger$
|
|
26283
|
+
const logger$3O = getLogger("range-in-block");
|
|
26321
26284
|
function rangeInBlock(block, range) {
|
|
26322
26285
|
const editor = range.getEditor();
|
|
26323
26286
|
const start = editor.getBlockById(range.start.blockId);
|
|
@@ -26338,16 +26301,16 @@ var __publicField = (obj, key, value) => {
|
|
|
26338
26301
|
while (prevBlock && !blocks.has(getBlockId(prevBlock))) {
|
|
26339
26302
|
prevBlock = getPrevVisibleBlock(prevBlock);
|
|
26340
26303
|
}
|
|
26341
|
-
assert(logger$
|
|
26304
|
+
assert(logger$3O, prevBlock, "no prev block while deleting a block");
|
|
26342
26305
|
newRange = createBlockSimpleRange(editor, prevBlock, getBlockTextLength$6(editor, prevBlock));
|
|
26343
26306
|
} else {
|
|
26344
26307
|
const nextBlock = getNextVisibleBlock(block);
|
|
26345
|
-
assert(logger$
|
|
26308
|
+
assert(logger$3O, nextBlock, "no prev and next block while deleting a block");
|
|
26346
26309
|
newRange = createBlockSimpleRange(editor, nextBlock, 0);
|
|
26347
26310
|
}
|
|
26348
26311
|
return newRange;
|
|
26349
26312
|
}
|
|
26350
|
-
const logger$
|
|
26313
|
+
const logger$3N = getLogger("block-to-html");
|
|
26351
26314
|
function blockToHtml(editor, blockData, doc2, path) {
|
|
26352
26315
|
const blockClass = getBlockClassByType(editor, blockData.type);
|
|
26353
26316
|
if (blockClass.convertTo) {
|
|
@@ -26356,15 +26319,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26356
26319
|
if (blockClass.blockKind !== "text") {
|
|
26357
26320
|
return `[${blockData.type}]`;
|
|
26358
26321
|
}
|
|
26359
|
-
assert(logger$
|
|
26322
|
+
assert(logger$3N, blockData.text, "no text");
|
|
26360
26323
|
const plainText = toPlainText(blockData.text);
|
|
26361
26324
|
return `<div>${escapeHtmlText(plainText)}</div>`;
|
|
26362
26325
|
}
|
|
26363
|
-
const logger$
|
|
26326
|
+
const logger$3M = getLogger("block-to-text");
|
|
26364
26327
|
function textBlockToText(editor, ops, doc2) {
|
|
26365
26328
|
let text2 = "";
|
|
26366
26329
|
ops.forEach((op) => {
|
|
26367
|
-
assert(logger$
|
|
26330
|
+
assert(logger$3M, typeof op.insert === "string", "invalid op");
|
|
26368
26331
|
if (op.attributes && op.attributes.box === true) {
|
|
26369
26332
|
const box = op.attributes;
|
|
26370
26333
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -26390,7 +26353,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26390
26353
|
if (blockClass.blockKind !== "text") {
|
|
26391
26354
|
return `[${blockData.type}]`;
|
|
26392
26355
|
}
|
|
26393
|
-
assert(logger$
|
|
26356
|
+
assert(logger$3M, blockData.text, "no text");
|
|
26394
26357
|
const plainText = textBlockToText(editor, blockData.text, doc2);
|
|
26395
26358
|
return plainText;
|
|
26396
26359
|
}
|
|
@@ -26423,11 +26386,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26423
26386
|
const markdown = lines.join("\n");
|
|
26424
26387
|
return markdown;
|
|
26425
26388
|
}
|
|
26426
|
-
const logger$
|
|
26389
|
+
const logger$3L = getLogger("get-text-position");
|
|
26427
26390
|
function editorGetTextPosition(editor, insertPos) {
|
|
26428
26391
|
const pos = insertPos != null ? insertPos : editor.selection.range.start;
|
|
26429
26392
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
26430
|
-
assert(logger$
|
|
26393
|
+
assert(logger$3L, false, `invalid insert pos type: ${typeof pos}`);
|
|
26431
26394
|
}
|
|
26432
26395
|
const { blockId } = pos;
|
|
26433
26396
|
const block = editor.getBlockById(blockId);
|
|
@@ -26515,14 +26478,14 @@ var __publicField = (obj, key, value) => {
|
|
|
26515
26478
|
return attributes;
|
|
26516
26479
|
}
|
|
26517
26480
|
}
|
|
26518
|
-
const logger$
|
|
26481
|
+
const logger$3K = getLogger("insert-text");
|
|
26519
26482
|
function getTextAttributes(editor, containerId, blockIndex, offset) {
|
|
26520
26483
|
var _a, _b;
|
|
26521
26484
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26522
|
-
assert(logger$
|
|
26523
|
-
assert(logger$
|
|
26485
|
+
assert(logger$3K, blockData, "no block data");
|
|
26486
|
+
assert(logger$3K, blockData.text, "no block text");
|
|
26524
26487
|
if (getTextLength(blockData.text) === 0) {
|
|
26525
|
-
assert(logger$
|
|
26488
|
+
assert(logger$3K, offset === 0, "invalid text offset");
|
|
26526
26489
|
return BlockAttributesHandler.get(editor).getEmptyBlockTextAttributes(blockData.id);
|
|
26527
26490
|
}
|
|
26528
26491
|
if (offset === 0) {
|
|
@@ -26569,7 +26532,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26569
26532
|
}
|
|
26570
26533
|
for (let i = 0; i < text2.length; i++) {
|
|
26571
26534
|
const op = text2[i];
|
|
26572
|
-
assert(logger$
|
|
26535
|
+
assert(logger$3K, typeof op.insert === "string", "invalid text op, no insert");
|
|
26573
26536
|
const endPos = pos + getOpLength(op);
|
|
26574
26537
|
if (endPos === start) {
|
|
26575
26538
|
return false;
|
|
@@ -26583,8 +26546,8 @@ var __publicField = (obj, key, value) => {
|
|
|
26583
26546
|
}
|
|
26584
26547
|
function editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset) {
|
|
26585
26548
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26586
|
-
assert(logger$
|
|
26587
|
-
assert(logger$
|
|
26549
|
+
assert(logger$3K, blockData, "no block data");
|
|
26550
|
+
assert(logger$3K, blockData.text, "no block text");
|
|
26588
26551
|
const attributes = getTextAttributes(editor, containerId, blockIndex, offset);
|
|
26589
26552
|
if (attributes && Object.keys(attributes).includes("link")) {
|
|
26590
26553
|
const inOp = checkRangeInOp(blockData.text, offset);
|
|
@@ -26603,21 +26566,21 @@ var __publicField = (obj, key, value) => {
|
|
|
26603
26566
|
const { containerId, blockIndex, offset } = editorGetTextPosition(editor);
|
|
26604
26567
|
editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset);
|
|
26605
26568
|
}
|
|
26606
|
-
const logger$
|
|
26569
|
+
const logger$3J = getLogger("update-composition-text");
|
|
26607
26570
|
function editorUpdateCompositionText(editor) {
|
|
26608
26571
|
const pos = editor.selection.range.start;
|
|
26609
26572
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
26610
|
-
assert(logger$
|
|
26573
|
+
assert(logger$3J, false, `invalid insert pos type: ${typeof pos}`);
|
|
26611
26574
|
}
|
|
26612
26575
|
const { blockId } = pos;
|
|
26613
26576
|
const block = editor.getBlockById(blockId);
|
|
26614
|
-
assert(logger$
|
|
26577
|
+
assert(logger$3J, isTextKindBlock(editor, block), "not a text kind block");
|
|
26615
26578
|
const container = getParentContainer(block);
|
|
26616
26579
|
const containerId = getContainerId(container);
|
|
26617
26580
|
const blockIndex = getBlockIndex(block);
|
|
26618
26581
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26619
|
-
assert(logger$
|
|
26620
|
-
assert(logger$
|
|
26582
|
+
assert(logger$3J, blockData, "no block data in doc");
|
|
26583
|
+
assert(logger$3J, blockData.text, "no text data in text block");
|
|
26621
26584
|
const blockContent = getBlockContent(block);
|
|
26622
26585
|
updateBlockContent$1(editor, getBlockPath(block), blockId, blockContent, blockData.text);
|
|
26623
26586
|
}
|
|
@@ -26629,25 +26592,25 @@ var __publicField = (obj, key, value) => {
|
|
|
26629
26592
|
const block = editor.getBlockById(blockData.id);
|
|
26630
26593
|
return block;
|
|
26631
26594
|
}
|
|
26632
|
-
const logger$
|
|
26595
|
+
const logger$3I = getLogger("delete-block-text");
|
|
26633
26596
|
function editorDeleteBlockText(editor, block, offset, count, options) {
|
|
26634
26597
|
if (!editor.isBlockWritable(block)) {
|
|
26635
|
-
logger$
|
|
26598
|
+
logger$3I.error("block is not writable");
|
|
26636
26599
|
return 0;
|
|
26637
26600
|
}
|
|
26638
|
-
assert(logger$
|
|
26601
|
+
assert(logger$3I, isTextKindBlock(editor, block), "block is not a text kind block");
|
|
26639
26602
|
const container = getParentContainer(block);
|
|
26640
26603
|
const containerId = getContainerId(container);
|
|
26641
26604
|
const blockIndex = getBlockIndex(block);
|
|
26642
26605
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26643
|
-
assert(logger$
|
|
26644
|
-
assert(logger$
|
|
26606
|
+
assert(logger$3I, blockData, "no block data in doc");
|
|
26607
|
+
assert(logger$3I, blockData.text, "no text data in text block");
|
|
26645
26608
|
let from = offset;
|
|
26646
26609
|
if (!isValidOffset(block, offset)) {
|
|
26647
26610
|
from = getPrevValidOffset(block, from);
|
|
26648
26611
|
}
|
|
26649
26612
|
let to = offset + count;
|
|
26650
|
-
assert(logger$
|
|
26613
|
+
assert(logger$3I, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
|
|
26651
26614
|
if (!isValidOffset(block, to)) {
|
|
26652
26615
|
to = getNextValidOffset(block, to);
|
|
26653
26616
|
}
|
|
@@ -26656,7 +26619,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26656
26619
|
editor.doc.localUpdateBlockText(containerId, blockIndex, actions2, options);
|
|
26657
26620
|
return deleteCount;
|
|
26658
26621
|
}
|
|
26659
|
-
const logger$
|
|
26622
|
+
const logger$3H = getLogger("break-text-block");
|
|
26660
26623
|
function copyBlockAttributes(editor, block) {
|
|
26661
26624
|
const blockData = editor.getBlockData(block);
|
|
26662
26625
|
const quoted = blockData.quoted;
|
|
@@ -26668,8 +26631,8 @@ var __publicField = (obj, key, value) => {
|
|
|
26668
26631
|
return {};
|
|
26669
26632
|
}
|
|
26670
26633
|
function editorBreakTextBlock(editor, block, offset, options) {
|
|
26671
|
-
assert(logger$
|
|
26672
|
-
assert(logger$
|
|
26634
|
+
assert(logger$3H, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
|
|
26635
|
+
assert(logger$3H, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
26673
26636
|
const container = getParentContainer(block);
|
|
26674
26637
|
const containerId = getContainerId(container);
|
|
26675
26638
|
const blockIndex = getBlockIndex(block);
|
|
@@ -26699,7 +26662,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26699
26662
|
};
|
|
26700
26663
|
}
|
|
26701
26664
|
}
|
|
26702
|
-
assert(logger$
|
|
26665
|
+
assert(logger$3H, isValidOffset(block, offset), "not a valid offset");
|
|
26703
26666
|
const text2 = editorGetBlockText(editor, block);
|
|
26704
26667
|
const { right } = splitText(text2, offset);
|
|
26705
26668
|
const rightLength = getTextLength(right);
|
|
@@ -26725,12 +26688,12 @@ var __publicField = (obj, key, value) => {
|
|
|
26725
26688
|
newBlock
|
|
26726
26689
|
};
|
|
26727
26690
|
}
|
|
26728
|
-
const logger$
|
|
26691
|
+
const logger$3G = getLogger("prepare-insert-new-block");
|
|
26729
26692
|
function editorPrepareInsertNewBlock(editor, containerId, blockIndex) {
|
|
26730
26693
|
if (containerId && blockIndex !== void 0 && blockIndex !== null) {
|
|
26731
26694
|
const container = editor.getContainerById(containerId);
|
|
26732
26695
|
const blocks = getChildBlocks(container);
|
|
26733
|
-
assert(logger$
|
|
26696
|
+
assert(logger$3G, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
|
|
26734
26697
|
return {
|
|
26735
26698
|
containerId,
|
|
26736
26699
|
blockIndex
|
|
@@ -26764,15 +26727,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26764
26727
|
blockIndex: getBlockIndex(newBlock)
|
|
26765
26728
|
};
|
|
26766
26729
|
}
|
|
26767
|
-
const logger$
|
|
26730
|
+
const logger$3F = getLogger("auto-insert-block");
|
|
26768
26731
|
function editorAutoInsertBlock(editor, blockData, containerId, blockIndex, newRange, insertBlockOptions) {
|
|
26769
26732
|
const result = editorPrepareInsertNewBlock(editor, containerId, blockIndex);
|
|
26770
|
-
assert(logger$
|
|
26733
|
+
assert(logger$3F, result, `not an valid insert position: ${editor.selection.range}`);
|
|
26771
26734
|
const defaultPos = { blockId: blockData.id, offset: 0 };
|
|
26772
26735
|
const defaultRange = { anchor: defaultPos, focus: defaultPos };
|
|
26773
26736
|
return editorInsertBlock(editor, result.containerId, result.blockIndex, blockData, newRange != null ? newRange : defaultRange, insertBlockOptions);
|
|
26774
26737
|
}
|
|
26775
|
-
const logger$
|
|
26738
|
+
const logger$3E = getLogger("delete-block");
|
|
26776
26739
|
function getAllChildContainers(editor, blockData, containerIds) {
|
|
26777
26740
|
if (blockData.children) {
|
|
26778
26741
|
containerIds.push(...blockData.children);
|
|
@@ -26789,7 +26752,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26789
26752
|
const containerId = getContainerId(container);
|
|
26790
26753
|
const blockIndex = getBlockIndex(block);
|
|
26791
26754
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26792
|
-
assert(logger$
|
|
26755
|
+
assert(logger$3E, blockData, "no block data in doc");
|
|
26793
26756
|
editor.doc.localDeleteBlock(containerId, blockIndex, createEditorSelectionRange(editor, { anchor: newRange.start, focus: newRange.end }));
|
|
26794
26757
|
return blockData;
|
|
26795
26758
|
}
|
|
@@ -26835,15 +26798,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26835
26798
|
});
|
|
26836
26799
|
editor.doc.localDeleteChildContainers(containerIds);
|
|
26837
26800
|
}
|
|
26838
|
-
const logger$
|
|
26801
|
+
const logger$3D = getLogger("merge-text-block");
|
|
26839
26802
|
function editorMergeTextBlock(editor, block1, block2) {
|
|
26840
|
-
assert(logger$
|
|
26841
|
-
assert(logger$
|
|
26803
|
+
assert(logger$3D, isTextKindBlock(editor, block1), "only text block can be merged");
|
|
26804
|
+
assert(logger$3D, isTextKindBlock(editor, block2), "only text block can be merged");
|
|
26842
26805
|
const data1 = editorGetBlockData(editor, block1);
|
|
26843
26806
|
const data2 = editorGetBlockData(editor, block2);
|
|
26844
26807
|
const text1 = data1.text;
|
|
26845
26808
|
const text2 = data2.text;
|
|
26846
|
-
assert(logger$
|
|
26809
|
+
assert(logger$3D, text1 && text2, "block data has no text");
|
|
26847
26810
|
const container = getParentContainer(block1);
|
|
26848
26811
|
const containerId = getContainerId(container);
|
|
26849
26812
|
const blockIndex = getBlockIndex(block1);
|
|
@@ -26853,15 +26816,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26853
26816
|
editorDeleteBlock(editor, block2, newRange);
|
|
26854
26817
|
return block;
|
|
26855
26818
|
}
|
|
26856
|
-
const logger$
|
|
26819
|
+
const logger$3C = getLogger("clear-selected-contents");
|
|
26857
26820
|
function deleteTextBlockSelection(editor, selectedBlock) {
|
|
26858
|
-
assert(logger$
|
|
26821
|
+
assert(logger$3C, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
|
|
26859
26822
|
const { start, end } = selectedBlock;
|
|
26860
|
-
assert(logger$
|
|
26861
|
-
assert(logger$
|
|
26823
|
+
assert(logger$3C, start.isSimple(), "not a simple block position");
|
|
26824
|
+
assert(logger$3C, end.isSimple(), "not a simple block position");
|
|
26862
26825
|
const startOffset = start.offset;
|
|
26863
26826
|
const endOffset = end.offset;
|
|
26864
|
-
assert(logger$
|
|
26827
|
+
assert(logger$3C, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
|
|
26865
26828
|
if (startOffset === endOffset) {
|
|
26866
26829
|
return;
|
|
26867
26830
|
}
|
|
@@ -26886,7 +26849,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26886
26849
|
return;
|
|
26887
26850
|
}
|
|
26888
26851
|
if (isEmbedBlock(block) || start.isSimple()) {
|
|
26889
|
-
assert(logger$
|
|
26852
|
+
assert(logger$3C, end.isSimple(), "invalid range");
|
|
26890
26853
|
const container = getParentContainer(block);
|
|
26891
26854
|
const blockIndex = getBlockIndex(block);
|
|
26892
26855
|
const newBlock = editor.insertTextBlock("", getContainerId(container), blockIndex);
|
|
@@ -26894,8 +26857,8 @@ var __publicField = (obj, key, value) => {
|
|
|
26894
26857
|
editor.deleteBlock(block);
|
|
26895
26858
|
return;
|
|
26896
26859
|
}
|
|
26897
|
-
assert(logger$
|
|
26898
|
-
assert(logger$
|
|
26860
|
+
assert(logger$3C, isComplexKindBlock(editor, block), "invalid block kind");
|
|
26861
|
+
assert(logger$3C, !start.isSimple() && !end.isSimple(), "invalid range");
|
|
26899
26862
|
complexBlockGetSelectedContainers(editor, block, start, end);
|
|
26900
26863
|
const containers = editor.selection.range.getSelectedContainers();
|
|
26901
26864
|
containers.forEach((container, index2) => {
|
|
@@ -26912,7 +26875,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26912
26875
|
return;
|
|
26913
26876
|
}
|
|
26914
26877
|
const selectedBlocks = range.getSelectedBlocks();
|
|
26915
|
-
assert(logger$
|
|
26878
|
+
assert(logger$3C, selectedBlocks.length > 0, "no selected block");
|
|
26916
26879
|
if (selectedBlocks.length === 1) {
|
|
26917
26880
|
clearOneBlock(editor, selectedBlocks[0]);
|
|
26918
26881
|
return;
|
|
@@ -26920,7 +26883,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26920
26883
|
const firstSelectedBlock = selectedBlocks[0];
|
|
26921
26884
|
const firstBlock = firstSelectedBlock.block;
|
|
26922
26885
|
const container = getParentContainer(firstBlock);
|
|
26923
|
-
assert(logger$
|
|
26886
|
+
assert(logger$3C, selectedBlocks.length > 1, "no selected block");
|
|
26924
26887
|
const lastSelectedBlock = selectedBlocks[selectedBlocks.length - 1];
|
|
26925
26888
|
const lastBlock2 = lastSelectedBlock.block;
|
|
26926
26889
|
if (isTextKindBlock(editor, firstBlock)) {
|
|
@@ -26950,7 +26913,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26950
26913
|
}
|
|
26951
26914
|
const prevBlock = getPrevBlock(firstBlock);
|
|
26952
26915
|
const nextBlock = getNextBlock(lastBlock2);
|
|
26953
|
-
assert(logger$
|
|
26916
|
+
assert(logger$3C, prevBlock || nextBlock, "no prev or next block");
|
|
26954
26917
|
selectedBlocks.forEach((selectedBlock) => editor.deleteBlock(selectedBlock.block));
|
|
26955
26918
|
}
|
|
26956
26919
|
function editorClearSelectedContents(editor, selectionRange) {
|
|
@@ -26969,7 +26932,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26969
26932
|
editor.emit("afterClearSelection", editor);
|
|
26970
26933
|
});
|
|
26971
26934
|
}
|
|
26972
|
-
const logger$
|
|
26935
|
+
const logger$3B = getLogger("core");
|
|
26973
26936
|
function editorUpdateBlockText(editor, block, ops, options) {
|
|
26974
26937
|
const container = getParentContainer(block);
|
|
26975
26938
|
const containerId = getContainerId(container);
|
|
@@ -26982,7 +26945,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26982
26945
|
}
|
|
26983
26946
|
function editorSetBlockText(editor, block, newText, options) {
|
|
26984
26947
|
if (!editor.isBlockWritable(block)) {
|
|
26985
|
-
logger$
|
|
26948
|
+
logger$3B.error("block is not writable");
|
|
26986
26949
|
return;
|
|
26987
26950
|
}
|
|
26988
26951
|
const oldText = editor.getBlockText(block);
|
|
@@ -26995,7 +26958,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26995
26958
|
const ops = RichText.diff(oldText, newText);
|
|
26996
26959
|
return editorUpdateBlockText(editor, block, ops);
|
|
26997
26960
|
}
|
|
26998
|
-
const logger$
|
|
26961
|
+
const logger$3A = getLogger("update-block-data");
|
|
26999
26962
|
function editorUpdateBlockData(editor, block, data2, newRange, options) {
|
|
27000
26963
|
const container = getParentContainer(block);
|
|
27001
26964
|
const containerId = getContainerId(container);
|
|
@@ -27012,17 +26975,17 @@ var __publicField = (obj, key, value) => {
|
|
|
27012
26975
|
if (oldKey === "id" || oldKey === "type" || oldKey === "text") {
|
|
27013
26976
|
return;
|
|
27014
26977
|
}
|
|
27015
|
-
logger$
|
|
26978
|
+
logger$3A.debug(`delete key: ${oldKey}`);
|
|
27016
26979
|
delta.delete.push(oldKey);
|
|
27017
26980
|
}
|
|
27018
26981
|
});
|
|
27019
26982
|
const entries = Object.entries(data2);
|
|
27020
26983
|
entries.forEach(([key, value]) => {
|
|
27021
|
-
assert(logger$
|
|
26984
|
+
assert(logger$3A, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
|
|
27022
26985
|
const oldValue = oldData[key];
|
|
27023
26986
|
if (value === null || value === void 0) {
|
|
27024
26987
|
if (oldValue !== null && oldValue !== void 0) {
|
|
27025
|
-
logger$
|
|
26988
|
+
logger$3A.debug(`delete key: ${key}`);
|
|
27026
26989
|
delta.delete.push(key);
|
|
27027
26990
|
}
|
|
27028
26991
|
return;
|
|
@@ -27040,10 +27003,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27040
27003
|
}
|
|
27041
27004
|
}
|
|
27042
27005
|
if (oldKeys.has(key)) {
|
|
27043
|
-
logger$
|
|
27006
|
+
logger$3A.debug(`replace key: ${key}`);
|
|
27044
27007
|
delta.delete.push(key);
|
|
27045
27008
|
} else {
|
|
27046
|
-
logger$
|
|
27009
|
+
logger$3A.debug(`insert key: ${key}`);
|
|
27047
27010
|
}
|
|
27048
27011
|
delta.insert[key] = value;
|
|
27049
27012
|
});
|
|
@@ -27088,13 +27051,13 @@ var __publicField = (obj, key, value) => {
|
|
|
27088
27051
|
comments: {}
|
|
27089
27052
|
};
|
|
27090
27053
|
}
|
|
27091
|
-
const logger$
|
|
27054
|
+
const logger$3z = getLogger("clone-block");
|
|
27092
27055
|
function cloneBlock(editorBlocks, oldDoc, data2, info) {
|
|
27093
27056
|
var _a;
|
|
27094
27057
|
const blockClass = editorBlocks.getBlockClass(data2.type);
|
|
27095
27058
|
if (blockClass.blockToDoc) {
|
|
27096
27059
|
return blockClass.blockToDoc(oldDoc, data2, (oldDoc2, childBlock) => {
|
|
27097
|
-
assert(logger$
|
|
27060
|
+
assert(logger$3z, data2 !== childBlock, "invalid child block");
|
|
27098
27061
|
return cloneBlock(editorBlocks, oldDoc2, data2, info);
|
|
27099
27062
|
}, info);
|
|
27100
27063
|
}
|
|
@@ -27107,7 +27070,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27107
27070
|
}
|
|
27108
27071
|
const newChildContainerId = genId();
|
|
27109
27072
|
const childBlocks = oldDoc.blocks[oldChildContainerId];
|
|
27110
|
-
assert(logger$
|
|
27073
|
+
assert(logger$3z, Array.isArray(childBlocks), "invalid child blocks");
|
|
27111
27074
|
const newDocs = childBlocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
|
|
27112
27075
|
const newDoc = mergeDocs(newDocs);
|
|
27113
27076
|
const { root: root2, ...childContainersData } = newDoc.blocks;
|
|
@@ -27136,7 +27099,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27136
27099
|
if (key.startsWith(prefix1)) {
|
|
27137
27100
|
const keyContent = key.substring(prefix1.length);
|
|
27138
27101
|
const newKey = `${newContainerId}/${keyContent}`;
|
|
27139
|
-
logger$
|
|
27102
|
+
logger$3z.debug(`replace key: ${key} -> ${newKey}`);
|
|
27140
27103
|
return newKey;
|
|
27141
27104
|
}
|
|
27142
27105
|
}
|
|
@@ -27145,7 +27108,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27145
27108
|
if (key.startsWith(prefix2)) {
|
|
27146
27109
|
const keyContent = key.substring(prefix2.length);
|
|
27147
27110
|
const newKey = `${newContainerId}_${keyContent}`;
|
|
27148
|
-
logger$
|
|
27111
|
+
logger$3z.debug(`replace key: ${key} -> ${newKey}`);
|
|
27149
27112
|
return newKey;
|
|
27150
27113
|
}
|
|
27151
27114
|
}
|
|
@@ -27175,7 +27138,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27175
27138
|
}
|
|
27176
27139
|
function cloneChildContainer(editorBlocks, oldDoc, containerId, info) {
|
|
27177
27140
|
const blocks = oldDoc.blocks[containerId];
|
|
27178
|
-
assert(logger$
|
|
27141
|
+
assert(logger$3z, Array.isArray(blocks), "invalid child blocks");
|
|
27179
27142
|
const newDocs = blocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
|
|
27180
27143
|
const newDoc = mergeDocs(newDocs);
|
|
27181
27144
|
return newDoc;
|
|
@@ -27184,10 +27147,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27184
27147
|
const docs = doc2.blocks.root.map((b) => cloneBlock(editor.editorBlocks, doc2, b, info));
|
|
27185
27148
|
return cloneDeep__default.default(mergeDocs(docs));
|
|
27186
27149
|
}
|
|
27187
|
-
const logger$
|
|
27150
|
+
const logger$3y = getLogger("insert-doc");
|
|
27188
27151
|
function editorInsertDoc(editor, block, offset, insertedDoc, cloneDocResult) {
|
|
27189
27152
|
if (isComplexKindBlock(editor, block)) {
|
|
27190
|
-
logger$
|
|
27153
|
+
logger$3y.warn("failed to insert doc into a complex block");
|
|
27191
27154
|
return;
|
|
27192
27155
|
}
|
|
27193
27156
|
const doc2 = cloneDoc(editor, insertedDoc, cloneDocResult);
|
|
@@ -27221,7 +27184,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27221
27184
|
}
|
|
27222
27185
|
return;
|
|
27223
27186
|
}
|
|
27224
|
-
assert(logger$
|
|
27187
|
+
assert(logger$3y, isTextKindBlock(editor, block), "not a text block");
|
|
27225
27188
|
if (isEmptyTextBlock(editor, block)) {
|
|
27226
27189
|
const blockIndex2 = getBlockIndex(block);
|
|
27227
27190
|
let lastBlock22;
|
|
@@ -27353,11 +27316,11 @@ var __publicField = (obj, key, value) => {
|
|
|
27353
27316
|
editor.deleteBlock(block);
|
|
27354
27317
|
}
|
|
27355
27318
|
}
|
|
27356
|
-
const logger$
|
|
27319
|
+
const logger$3x = getLogger("add-text-attribute");
|
|
27357
27320
|
function editorRemoveTextAttribute(editor, block, range, attributeName) {
|
|
27358
27321
|
const { start, end } = range;
|
|
27359
|
-
assert(logger$
|
|
27360
|
-
assert(logger$
|
|
27322
|
+
assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
27323
|
+
assert(logger$3x, attributeName, "invalid attribute name");
|
|
27361
27324
|
const oldText = editor.getBlockText(block);
|
|
27362
27325
|
const newText = rangeRemoveAttribute(start.offset, end.offset - start.offset, oldText, attributeName, void 0, { ignoreValue: true });
|
|
27363
27326
|
editor.setBlockText(block, newText);
|
|
@@ -27365,8 +27328,8 @@ var __publicField = (obj, key, value) => {
|
|
|
27365
27328
|
}
|
|
27366
27329
|
function editorAddTextAttribute(editor, block, range, attributeName, value) {
|
|
27367
27330
|
const { start, end } = range;
|
|
27368
|
-
assert(logger$
|
|
27369
|
-
assert(logger$
|
|
27331
|
+
assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
27332
|
+
assert(logger$3x, attributeName, "invalid attribute name");
|
|
27370
27333
|
const oldText = editor.getBlockText(block);
|
|
27371
27334
|
const newText = rangeAddAttribute(start.offset, end.offset - start.offset, oldText, attributeName, value);
|
|
27372
27335
|
editor.setBlockText(block, newText);
|
|
@@ -27374,7 +27337,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27374
27337
|
}
|
|
27375
27338
|
function editorSetTextColor(editor, block, range, type, value) {
|
|
27376
27339
|
const { start, end } = range;
|
|
27377
|
-
assert(logger$
|
|
27340
|
+
assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
27378
27341
|
const oldText = editor.getBlockText(block);
|
|
27379
27342
|
const newText = rangeSetTextColor(start.offset, end.offset - start.offset, oldText, type, value);
|
|
27380
27343
|
editor.setBlockText(block, newText);
|
|
@@ -27463,10 +27426,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27463
27426
|
});
|
|
27464
27427
|
return [color, backgroundColor];
|
|
27465
27428
|
}
|
|
27466
|
-
const logger$
|
|
27429
|
+
const logger$3w = getLogger("move-complex-block-position");
|
|
27467
27430
|
function moveComplexBlockPosition(editor, old, type) {
|
|
27468
27431
|
const block = editor.getBlockById(old.blockId);
|
|
27469
|
-
assert(logger$
|
|
27432
|
+
assert(logger$3w, isComplexKindBlock(editor, block), "is not a complex block");
|
|
27470
27433
|
const blockClass = getComplexBlockClass(editor, block);
|
|
27471
27434
|
const focusedContainer = editor.getContainerById(old.childContainerId);
|
|
27472
27435
|
const nextContainer = blockClass.getNextContainer(editor, block, focusedContainer, type, { noWrap: true });
|
|
@@ -27475,24 +27438,24 @@ var __publicField = (obj, key, value) => {
|
|
|
27475
27438
|
}
|
|
27476
27439
|
return createComplexBlockPosition(block, getContainerId(nextContainer));
|
|
27477
27440
|
}
|
|
27478
|
-
const logger$
|
|
27441
|
+
const logger$3v = getLogger("move-simple-block-position");
|
|
27479
27442
|
function getFirstChildBlockInComplexBlock(editor, complexBlock) {
|
|
27480
27443
|
const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
|
|
27481
27444
|
if (containers.length === 0) {
|
|
27482
|
-
logger$
|
|
27445
|
+
logger$3v.warn("complex block has not any child container, not loaded?");
|
|
27483
27446
|
return null;
|
|
27484
27447
|
}
|
|
27485
|
-
assert(logger$
|
|
27448
|
+
assert(logger$3v, containers.length > 0, "complex block has not any child container");
|
|
27486
27449
|
const container = containers[0];
|
|
27487
27450
|
return getFirstChildBlock(container);
|
|
27488
27451
|
}
|
|
27489
27452
|
function getLastChildBlockInComplexBlock(editor, complexBlock) {
|
|
27490
27453
|
const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
|
|
27491
27454
|
if (containers.length === 0) {
|
|
27492
|
-
logger$
|
|
27455
|
+
logger$3v.warn("complex block has not any child container, not loaded?");
|
|
27493
27456
|
return null;
|
|
27494
27457
|
}
|
|
27495
|
-
assert(logger$
|
|
27458
|
+
assert(logger$3v, containers.length > 0, "complex block has not any child container");
|
|
27496
27459
|
const container = containers[containers.length - 1];
|
|
27497
27460
|
return getLastChildBlock(container);
|
|
27498
27461
|
}
|
|
@@ -27537,8 +27500,8 @@ var __publicField = (obj, key, value) => {
|
|
|
27537
27500
|
return null;
|
|
27538
27501
|
}
|
|
27539
27502
|
const parentComplexBlock = getParentBlock(container);
|
|
27540
|
-
assert(logger$
|
|
27541
|
-
assert(logger$
|
|
27503
|
+
assert(logger$3v, parentComplexBlock, "child container has not parent block");
|
|
27504
|
+
assert(logger$3v, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
|
|
27542
27505
|
const nextContainer = getComplexBlockClass(editor, parentComplexBlock).getNextContainer(editor, parentComplexBlock, container, type);
|
|
27543
27506
|
if (nextContainer) {
|
|
27544
27507
|
if (isFindPrev(type)) {
|
|
@@ -27560,7 +27523,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27560
27523
|
return null;
|
|
27561
27524
|
}
|
|
27562
27525
|
const parentBlock = getParentBlock(container);
|
|
27563
|
-
assert(logger$
|
|
27526
|
+
assert(logger$3v, parentBlock, "child container has not parent block");
|
|
27564
27527
|
if (isFindPrev(type)) {
|
|
27565
27528
|
const prev = getPrevBlock(parentBlock);
|
|
27566
27529
|
if (prev) {
|
|
@@ -27615,7 +27578,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27615
27578
|
}
|
|
27616
27579
|
if (!targetBlock) {
|
|
27617
27580
|
if (isComplexKindBlock(editor, block) && complexBlockGetAllChildContainers(editor, block).length === 0) {
|
|
27618
|
-
logger$
|
|
27581
|
+
logger$3v.warn("complex block has not any child container, not loaded?");
|
|
27619
27582
|
targetBlock = direction === "ArrowDown" || direction === "ArrowRight" ? getNextVisibleBlock(block) : getPrevVisibleBlock(block);
|
|
27620
27583
|
}
|
|
27621
27584
|
}
|
|
@@ -27762,10 +27725,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27762
27725
|
editorAdjustSelection(editor, "ArrowUp", "select");
|
|
27763
27726
|
return true;
|
|
27764
27727
|
}
|
|
27765
|
-
const logger$
|
|
27728
|
+
const logger$3u = getLogger("word-offset");
|
|
27766
27729
|
function editorGetWordLeftPos(editor, type) {
|
|
27767
27730
|
const old = editor.selection.range.focus;
|
|
27768
|
-
assert(logger$
|
|
27731
|
+
assert(logger$3u, old.isSimple(), "invalid range type");
|
|
27769
27732
|
const block = editor.getBlockById(old.blockId);
|
|
27770
27733
|
if (isEmptyTextBlock(editor, block)) {
|
|
27771
27734
|
return createSimpleBlockPosition(block, 0, "home");
|
|
@@ -27790,7 +27753,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27790
27753
|
}
|
|
27791
27754
|
function editorGetWordRightPos(editor, type) {
|
|
27792
27755
|
const old = editor.selection.range.focus;
|
|
27793
|
-
assert(logger$
|
|
27756
|
+
assert(logger$3u, old.isSimple(), "invalid range type");
|
|
27794
27757
|
const block = editor.getBlockById(old.blockId);
|
|
27795
27758
|
if (isEmptyTextBlock(editor, block)) {
|
|
27796
27759
|
return createSimpleBlockPosition(block, 0, "end");
|
|
@@ -27902,10 +27865,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27902
27865
|
editor.selection.setSelection(editor.selection.getAnchorPos(), pos);
|
|
27903
27866
|
return true;
|
|
27904
27867
|
}
|
|
27905
|
-
const logger$
|
|
27868
|
+
const logger$3t = getLogger("line-offset");
|
|
27906
27869
|
function editorGetLineHomePos(editor) {
|
|
27907
27870
|
const old = editor.selection.range.focus;
|
|
27908
|
-
assert(logger$
|
|
27871
|
+
assert(logger$3t, old.isSimple(), "invalid range type");
|
|
27909
27872
|
const block = editor.getBlockById(old.blockId);
|
|
27910
27873
|
if (old.offset === 0 || !isTextKindBlock(editor, block)) {
|
|
27911
27874
|
const newPos2 = createSimpleBlockPosition(block, 0, "home");
|
|
@@ -27922,7 +27885,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27922
27885
|
}
|
|
27923
27886
|
function editorGetLineEndPos(editor) {
|
|
27924
27887
|
const old = editor.selection.range.focus;
|
|
27925
|
-
assert(logger$
|
|
27888
|
+
assert(logger$3t, old.isSimple(), "invalid range type");
|
|
27926
27889
|
const block = editor.getBlockById(old.blockId);
|
|
27927
27890
|
if (old.offset === getBlockTextLength$6(editor, block) || !isTextKindBlock(editor, block)) {
|
|
27928
27891
|
const newPos2 = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
|
|
@@ -28022,7 +27985,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28022
27985
|
editorPageDownScroll(editor);
|
|
28023
27986
|
return true;
|
|
28024
27987
|
}
|
|
28025
|
-
const logger$
|
|
27988
|
+
const logger$3s = getLogger("table-scroll");
|
|
28026
27989
|
class DomEventHandler {
|
|
28027
27990
|
constructor(editor, dom, name, handler, data2, options) {
|
|
28028
27991
|
__publicField(this, "handleEvent", (event) => {
|
|
@@ -28054,7 +28017,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28054
28017
|
const existsHandlers = this.handlers.get(element);
|
|
28055
28018
|
if (existsHandlers) {
|
|
28056
28019
|
if (existsHandlers.find((handler) => handler.handler === eventHandler && handler.name === eventName)) {
|
|
28057
|
-
logger$
|
|
28020
|
+
logger$3s.warn(`event has already registered: ${eventName}`);
|
|
28058
28021
|
return;
|
|
28059
28022
|
}
|
|
28060
28023
|
existsHandlers.push(new DomEventHandler(this.editor, element, eventName, eventHandler, data2, options));
|
|
@@ -28164,7 +28127,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28164
28127
|
});
|
|
28165
28128
|
return true;
|
|
28166
28129
|
}
|
|
28167
|
-
const logger$
|
|
28130
|
+
const logger$3r = getLogger("select-all");
|
|
28168
28131
|
function isContainerSelectedAllChildBlocks(container, range) {
|
|
28169
28132
|
const firstBlock = getFirstChildBlock(container);
|
|
28170
28133
|
const lastBlock2 = getLastChildBlock(container);
|
|
@@ -28179,8 +28142,8 @@ var __publicField = (obj, key, value) => {
|
|
|
28179
28142
|
return range.start.blockId === blockId && range.start.childContainerId === getContainerId(first) && range.end.blockId === blockId && range.end.childContainerId === getContainerId(last);
|
|
28180
28143
|
}
|
|
28181
28144
|
function selectComplexBlock(editor, block) {
|
|
28182
|
-
assert(logger$
|
|
28183
|
-
assert(logger$
|
|
28145
|
+
assert(logger$3r, block, "no parent block");
|
|
28146
|
+
assert(logger$3r, isComplexKindBlock(editor, block), "not a complex block");
|
|
28184
28147
|
const containers = getComplexBlockClass(editor, block).getChildContainers(editor, block);
|
|
28185
28148
|
const first = containers[0];
|
|
28186
28149
|
const last = containers[containers.length - 1];
|
|
@@ -28216,13 +28179,13 @@ var __publicField = (obj, key, value) => {
|
|
|
28216
28179
|
selectParentContainer(editor, getFirstChildBlock(editor.rootContainer));
|
|
28217
28180
|
return false;
|
|
28218
28181
|
}
|
|
28219
|
-
assert(logger$
|
|
28182
|
+
assert(logger$3r, !range.isSimple(), "invalid range type");
|
|
28220
28183
|
if (isComplexBlockSelectedAllChildContainer(focusedBlock, range)) {
|
|
28221
28184
|
selectParentContainer(editor, focusedBlock);
|
|
28222
28185
|
return false;
|
|
28223
28186
|
}
|
|
28224
|
-
assert(logger$
|
|
28225
|
-
assert(logger$
|
|
28187
|
+
assert(logger$3r, focusedBlock, "no parent block");
|
|
28188
|
+
assert(logger$3r, isComplexKindBlock(editor, focusedBlock), "not a complex block");
|
|
28226
28189
|
selectComplexBlock(editor, focusedBlock);
|
|
28227
28190
|
return true;
|
|
28228
28191
|
}
|
|
@@ -28258,30 +28221,6 @@ var __publicField = (obj, key, value) => {
|
|
|
28258
28221
|
}
|
|
28259
28222
|
editor.selection.setSelection(newStartPos, newEndPos);
|
|
28260
28223
|
}
|
|
28261
|
-
function editorMoveBlockStart(editor) {
|
|
28262
|
-
const focus = editor.selection.range.focus;
|
|
28263
|
-
const block = editor.getBlockById(focus.blockId);
|
|
28264
|
-
if (!block)
|
|
28265
|
-
return false;
|
|
28266
|
-
if (!isSimpleBlock(editor, block))
|
|
28267
|
-
return false;
|
|
28268
|
-
const newPos = createSimpleBlockPosition(block, 0, "home");
|
|
28269
|
-
editor.selection.setSelection(newPos);
|
|
28270
|
-
editor.selection.updateLastCaretRect();
|
|
28271
|
-
return true;
|
|
28272
|
-
}
|
|
28273
|
-
function editorMoveBlockEnd(editor) {
|
|
28274
|
-
const focus = editor.selection.range.focus;
|
|
28275
|
-
const block = editor.getBlockById(focus.blockId);
|
|
28276
|
-
if (!block)
|
|
28277
|
-
return false;
|
|
28278
|
-
if (!isSimpleBlock(editor, block))
|
|
28279
|
-
return false;
|
|
28280
|
-
const newPos = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
|
|
28281
|
-
editor.selection.setSelection(newPos);
|
|
28282
|
-
editor.selection.updateLastCaretRect();
|
|
28283
|
-
return true;
|
|
28284
|
-
}
|
|
28285
28224
|
function editorFocusToEnd(editor) {
|
|
28286
28225
|
editorSelectEnd(editor);
|
|
28287
28226
|
editor.focus();
|
|
@@ -28361,7 +28300,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28361
28300
|
}
|
|
28362
28301
|
return cloned;
|
|
28363
28302
|
}
|
|
28364
|
-
const logger$
|
|
28303
|
+
const logger$3q = getLogger("selected-block-to-doc");
|
|
28365
28304
|
function appendBlockChildren(editor, data2, doc2) {
|
|
28366
28305
|
if (!data2.children)
|
|
28367
28306
|
return;
|
|
@@ -28382,7 +28321,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28382
28321
|
if (isTextKindBlock(editor, selectedBlock.block)) {
|
|
28383
28322
|
const start = selectedBlock.start;
|
|
28384
28323
|
const end = selectedBlock.end;
|
|
28385
|
-
assert(logger$
|
|
28324
|
+
assert(logger$3q, data2.text, "no block text");
|
|
28386
28325
|
if (start.offset === end.offset) {
|
|
28387
28326
|
return {
|
|
28388
28327
|
blocks: {
|
|
@@ -28416,8 +28355,8 @@ var __publicField = (obj, key, value) => {
|
|
|
28416
28355
|
comments: {}
|
|
28417
28356
|
};
|
|
28418
28357
|
}
|
|
28419
|
-
assert(logger$
|
|
28420
|
-
assert(logger$
|
|
28358
|
+
assert(logger$3q, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
|
|
28359
|
+
assert(logger$3q, data2.children, "no children");
|
|
28421
28360
|
const ret = {
|
|
28422
28361
|
blocks: {
|
|
28423
28362
|
root: [
|
|
@@ -28435,9 +28374,9 @@ var __publicField = (obj, key, value) => {
|
|
|
28435
28374
|
const end = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
|
|
28436
28375
|
return selectedBlockToDoc(editor, { block, start, end });
|
|
28437
28376
|
}
|
|
28438
|
-
const logger$
|
|
28377
|
+
const logger$3p = getLogger("block-to-doc");
|
|
28439
28378
|
function blocksToDoc(editor, blocks) {
|
|
28440
|
-
assert(logger$
|
|
28379
|
+
assert(logger$3p, blocks.length > 0, "invalid params, no blocks");
|
|
28441
28380
|
const docs = blocks.map((b) => blockToDoc(editor, b));
|
|
28442
28381
|
return mergeDocs(docs);
|
|
28443
28382
|
}
|
|
@@ -28457,7 +28396,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28457
28396
|
const newDocs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s));
|
|
28458
28397
|
return mergeDocs(newDocs);
|
|
28459
28398
|
}
|
|
28460
|
-
const logger$
|
|
28399
|
+
const logger$3o = getLogger("ensure-block-visible");
|
|
28461
28400
|
function ensureBlockVisible(editor, block) {
|
|
28462
28401
|
var _a;
|
|
28463
28402
|
while (block) {
|
|
@@ -28467,16 +28406,16 @@ var __publicField = (obj, key, value) => {
|
|
|
28467
28406
|
return;
|
|
28468
28407
|
}
|
|
28469
28408
|
const parentComplexBlock = getParentBlock(container);
|
|
28470
|
-
assert(logger$
|
|
28409
|
+
assert(logger$3o, parentComplexBlock, "no parent block");
|
|
28471
28410
|
const parentComplexBlockClass = getBlockClass(editor, parentComplexBlock);
|
|
28472
28411
|
if (parentComplexBlockClass.isChildContainerVisible && !((_a = parentComplexBlockClass.isChildContainerVisible) == null ? void 0 : _a.call(parentComplexBlockClass, editor, parentComplexBlock, container))) {
|
|
28473
|
-
assert(logger$
|
|
28412
|
+
assert(logger$3o, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
|
|
28474
28413
|
parentComplexBlockClass.showChildContainer(editor, parentComplexBlock, container);
|
|
28475
28414
|
}
|
|
28476
28415
|
block = parentComplexBlock;
|
|
28477
28416
|
}
|
|
28478
28417
|
}
|
|
28479
|
-
const logger$
|
|
28418
|
+
const logger$3n = getLogger("editor-selection");
|
|
28480
28419
|
class EditorSelection {
|
|
28481
28420
|
constructor(editor) {
|
|
28482
28421
|
__publicField(this, "editor");
|
|
@@ -28489,7 +28428,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28489
28428
|
}
|
|
28490
28429
|
const range = this.range;
|
|
28491
28430
|
if (rangeInBlock(deletedBlock, range)) {
|
|
28492
|
-
logger$
|
|
28431
|
+
logger$3n.debug("adjust selection because remote deleted current block");
|
|
28493
28432
|
const newRange = moveSelectionBeforeDeleteBlock(editor, deletedBlock);
|
|
28494
28433
|
this.setRange(newRange, { noScroll: true });
|
|
28495
28434
|
}
|
|
@@ -28614,14 +28553,14 @@ var __publicField = (obj, key, value) => {
|
|
|
28614
28553
|
if (pos.isSimple()) {
|
|
28615
28554
|
const ok = pos.offset >= 0 && pos.offset <= getBlockTextLength$6(this.editor, block);
|
|
28616
28555
|
if (!ok) {
|
|
28617
|
-
assert(logger$
|
|
28556
|
+
assert(logger$3n, false, "invalid block position, out of range");
|
|
28618
28557
|
}
|
|
28619
28558
|
} else {
|
|
28620
28559
|
const childContainerId = pos.childContainerId;
|
|
28621
28560
|
const container = this.editor.getContainerById(childContainerId);
|
|
28622
28561
|
const ok = !!container;
|
|
28623
28562
|
if (!ok) {
|
|
28624
|
-
assert(logger$
|
|
28563
|
+
assert(logger$3n, false, "invalid complex block position, no container found");
|
|
28625
28564
|
}
|
|
28626
28565
|
}
|
|
28627
28566
|
}
|
|
@@ -28682,7 +28621,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28682
28621
|
let container = getParentContainer(block);
|
|
28683
28622
|
while (isChildContainer(container)) {
|
|
28684
28623
|
const parentBlock = getParentBlock(container);
|
|
28685
|
-
assert(logger$
|
|
28624
|
+
assert(logger$3n, parentBlock, "parent block not found");
|
|
28686
28625
|
addClass(parentBlock, "child-focused");
|
|
28687
28626
|
container = getParentContainer(parentBlock);
|
|
28688
28627
|
}
|
|
@@ -28792,15 +28731,15 @@ var __publicField = (obj, key, value) => {
|
|
|
28792
28731
|
editor.undoManager.redo();
|
|
28793
28732
|
return true;
|
|
28794
28733
|
}
|
|
28795
|
-
const logger$
|
|
28734
|
+
const logger$3m = getLogger("delete-text");
|
|
28796
28735
|
function editorDeleteText(editor, type, count, insertPos) {
|
|
28797
28736
|
const pos = insertPos != null ? insertPos : editor.selection.range.start;
|
|
28798
28737
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
28799
|
-
assert(logger$
|
|
28738
|
+
assert(logger$3m, false, `invalid insert pos type: ${typeof pos}`);
|
|
28800
28739
|
}
|
|
28801
28740
|
const { blockId } = pos;
|
|
28802
28741
|
const block = editor.getBlockById(blockId);
|
|
28803
|
-
assert(logger$
|
|
28742
|
+
assert(logger$3m, isTextKindBlock(editor, block), "block is not a text kind block");
|
|
28804
28743
|
let { offset } = pos;
|
|
28805
28744
|
if (type === "backward") {
|
|
28806
28745
|
if (offset - count < 0) {
|
|
@@ -28830,7 +28769,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28830
28769
|
}
|
|
28831
28770
|
return false;
|
|
28832
28771
|
}
|
|
28833
|
-
const logger$
|
|
28772
|
+
const logger$3l = getLogger("handle-backspace");
|
|
28834
28773
|
function tryDeleteEmptyBlock(editor, block) {
|
|
28835
28774
|
if (!isEmptyTextBlock(editor, block)) {
|
|
28836
28775
|
return;
|
|
@@ -28870,7 +28809,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28870
28809
|
}
|
|
28871
28810
|
} else {
|
|
28872
28811
|
tryDeleteEmptyBlock(editor, block);
|
|
28873
|
-
assert(logger$
|
|
28812
|
+
assert(logger$3l, isEmbedBlock(prevBlock), "prev block is not embed block");
|
|
28874
28813
|
editor.selection.selectBlock(prevBlock, 1);
|
|
28875
28814
|
}
|
|
28876
28815
|
} else {
|
|
@@ -28897,7 +28836,6 @@ var __publicField = (obj, key, value) => {
|
|
|
28897
28836
|
editor.deleteBlock(block);
|
|
28898
28837
|
}
|
|
28899
28838
|
}
|
|
28900
|
-
const logger$3l = getLogger("word-offset");
|
|
28901
28839
|
function handleEditorDelete(editor, event) {
|
|
28902
28840
|
if (!editor.selection.range.isCollapsed()) {
|
|
28903
28841
|
editor.clearSelectedContents();
|
|
@@ -28932,130 +28870,6 @@ var __publicField = (obj, key, value) => {
|
|
|
28932
28870
|
editor.deleteBlock(block);
|
|
28933
28871
|
}
|
|
28934
28872
|
}
|
|
28935
|
-
function handleEditorDeleteLeftWord(editor, event) {
|
|
28936
|
-
const old = editor.selection.range.focus;
|
|
28937
|
-
assert(logger$3l, old.isSimple(), "invalid range type");
|
|
28938
|
-
const block = editor.getBlockById(old.blockId);
|
|
28939
|
-
if (!isTextKindBlock(editor, block)) {
|
|
28940
|
-
editor.deleteBlock(block);
|
|
28941
|
-
return true;
|
|
28942
|
-
}
|
|
28943
|
-
if (old.offset === 0) {
|
|
28944
|
-
const matchNonEmptyTextBlockOrOtherBlock = (block2) => {
|
|
28945
|
-
if (!isTextKindBlock(editor, block2))
|
|
28946
|
-
return true;
|
|
28947
|
-
return !isEmptyTextBlock(editor, block2);
|
|
28948
|
-
};
|
|
28949
|
-
const prevBlock = getPrevVisibleBlock(block, matchNonEmptyTextBlockOrOtherBlock);
|
|
28950
|
-
if (!prevBlock)
|
|
28951
|
-
return false;
|
|
28952
|
-
const matchEmptyTextBlock = (block2) => isEmptyTextBlock(editor, block2);
|
|
28953
|
-
const emptyTextBlocks = getBlocksBetween(prevBlock, block, matchEmptyTextBlock);
|
|
28954
|
-
emptyTextBlocks.forEach((b) => {
|
|
28955
|
-
editor.deleteBlock(b);
|
|
28956
|
-
});
|
|
28957
|
-
if (!isTextKindBlock(editor, prevBlock)) {
|
|
28958
|
-
editor.deleteBlock(prevBlock);
|
|
28959
|
-
return true;
|
|
28960
|
-
}
|
|
28961
|
-
const textBlockLen = getBlockTextLength$6(editor, prevBlock);
|
|
28962
|
-
const newOffset2 = findWordLeft(editor, prevBlock, textBlockLen);
|
|
28963
|
-
editor.deleteTextFromBlock(prevBlock, newOffset2, textBlockLen - newOffset2);
|
|
28964
|
-
const currentBlockText = editor.getBlockText(block);
|
|
28965
|
-
editor.insertTextToBlock(prevBlock, newOffset2, currentBlockText);
|
|
28966
|
-
editor.deleteBlock(block);
|
|
28967
|
-
const pos = createSimpleBlockPosition(prevBlock, newOffset2, "normal");
|
|
28968
|
-
editor.selection.setSelection(pos);
|
|
28969
|
-
editor.selection.updateLastCaretRect();
|
|
28970
|
-
return true;
|
|
28971
|
-
}
|
|
28972
|
-
const newOffset = findWordLeft(editor, block, old.offset);
|
|
28973
|
-
const deletedCount = old.offset - newOffset;
|
|
28974
|
-
editor.deleteTextFromBlock(block, newOffset, deletedCount);
|
|
28975
|
-
return true;
|
|
28976
|
-
}
|
|
28977
|
-
function handleEditorDeleteRightWord(editor, event) {
|
|
28978
|
-
const old = editor.selection.range.focus;
|
|
28979
|
-
assert(logger$3l, old.isSimple(), "invalid range type");
|
|
28980
|
-
const block = editor.getBlockById(old.blockId);
|
|
28981
|
-
if (!isTextKindBlock(editor, block)) {
|
|
28982
|
-
editor.deleteBlock(block);
|
|
28983
|
-
return true;
|
|
28984
|
-
}
|
|
28985
|
-
if (old.offset === getTextBlockLength(block)) {
|
|
28986
|
-
const matchNonEmptyTextBlockOrOtherBlock = (block2) => {
|
|
28987
|
-
if (!isTextKindBlock(editor, block2))
|
|
28988
|
-
return true;
|
|
28989
|
-
return !isEmptyTextBlock(editor, block2);
|
|
28990
|
-
};
|
|
28991
|
-
const nextBlock = getNextVisibleBlock(block, matchNonEmptyTextBlockOrOtherBlock);
|
|
28992
|
-
if (!nextBlock)
|
|
28993
|
-
return false;
|
|
28994
|
-
const matchEmptyTextBlock = (block2) => isEmptyTextBlock(editor, block2);
|
|
28995
|
-
const emptyTextBlocks = getBlocksBetween(block, nextBlock, matchEmptyTextBlock);
|
|
28996
|
-
emptyTextBlocks.forEach((b) => {
|
|
28997
|
-
editor.deleteBlock(b);
|
|
28998
|
-
});
|
|
28999
|
-
if (!isTextKindBlock(editor, nextBlock)) {
|
|
29000
|
-
editor.deleteBlock(nextBlock);
|
|
29001
|
-
return true;
|
|
29002
|
-
}
|
|
29003
|
-
const newOffset = findWordEnd(editor, nextBlock, 0);
|
|
29004
|
-
editor.deleteTextFromBlock(nextBlock, 0, newOffset);
|
|
29005
|
-
const nextBlockText = editor.getBlockText(nextBlock);
|
|
29006
|
-
editor.insertTextToBlock(block, old.offset, nextBlockText);
|
|
29007
|
-
editor.deleteBlock(nextBlock);
|
|
29008
|
-
const pos = createSimpleBlockPosition(block, old.offset, "normal");
|
|
29009
|
-
editor.selection.setSelection(pos);
|
|
29010
|
-
editor.selection.updateLastCaretRect();
|
|
29011
|
-
return true;
|
|
29012
|
-
}
|
|
29013
|
-
const endOffset = findWordEnd(editor, block, old.offset);
|
|
29014
|
-
const deletedCount = endOffset - old.offset;
|
|
29015
|
-
editor.deleteTextFromBlock(block, old.offset, deletedCount);
|
|
29016
|
-
return true;
|
|
29017
|
-
}
|
|
29018
|
-
function handleEditorDeleteAfterWords(editor) {
|
|
29019
|
-
const old = editor.selection.range.focus;
|
|
29020
|
-
assert(logger$3l, old.isSimple(), "invalid range type");
|
|
29021
|
-
const block = editor.getBlockById(old.blockId);
|
|
29022
|
-
if (!isTextKindBlock(editor, block)) {
|
|
29023
|
-
editor.deleteBlock(block);
|
|
29024
|
-
return;
|
|
29025
|
-
}
|
|
29026
|
-
const needDeleteCount = getTextBlockLength(block) - old.offset;
|
|
29027
|
-
if (needDeleteCount === 0)
|
|
29028
|
-
return;
|
|
29029
|
-
editor.deleteTextFromBlock(block, old.offset, needDeleteCount);
|
|
29030
|
-
}
|
|
29031
|
-
function handleEditorDeleteRightChar(editor) {
|
|
29032
|
-
const old = editor.selection.range.focus;
|
|
29033
|
-
assert(logger$3l, old.isSimple(), "invalid range type");
|
|
29034
|
-
const block = editor.getBlockById(old.blockId);
|
|
29035
|
-
if (!isTextKindBlock(editor, block)) {
|
|
29036
|
-
editor.deleteBlock(block);
|
|
29037
|
-
return;
|
|
29038
|
-
}
|
|
29039
|
-
if (old.offset === getBlockTextLength$6(editor, block)) {
|
|
29040
|
-
const nextVisibleBlock = getNextVisibleBlock(block);
|
|
29041
|
-
if (!nextVisibleBlock)
|
|
29042
|
-
return;
|
|
29043
|
-
if (!isTextKindBlock(editor, nextVisibleBlock))
|
|
29044
|
-
return;
|
|
29045
|
-
if (isEmptyTextBlock(editor, nextVisibleBlock)) {
|
|
29046
|
-
editor.deleteBlock(nextVisibleBlock);
|
|
29047
|
-
return;
|
|
29048
|
-
}
|
|
29049
|
-
const nextBlockText = editor.getBlockText(nextVisibleBlock);
|
|
29050
|
-
editor.deleteBlock(nextVisibleBlock);
|
|
29051
|
-
editor.insertTextToBlock(block, old.offset, nextBlockText);
|
|
29052
|
-
const pos = createSimpleBlockPosition(block, old.offset, "normal");
|
|
29053
|
-
editor.selection.setSelection(pos);
|
|
29054
|
-
editor.selection.updateLastCaretRect();
|
|
29055
|
-
return;
|
|
29056
|
-
}
|
|
29057
|
-
editorDeleteText(editor, "forward", 1, null);
|
|
29058
|
-
}
|
|
29059
28873
|
function handleEditorEnterEvent$1(editor, event) {
|
|
29060
28874
|
if (isFullSelectedOneComplexBlock(editor)) {
|
|
29061
28875
|
const focusedBlock2 = editor.getFocusedBlock();
|
|
@@ -29277,42 +29091,6 @@ var __publicField = (obj, key, value) => {
|
|
|
29277
29091
|
return true;
|
|
29278
29092
|
});
|
|
29279
29093
|
}
|
|
29280
|
-
function editorHandleDeleteLeftWord(editor, event) {
|
|
29281
|
-
if (editor.readonly || !editor.isWritable()) {
|
|
29282
|
-
return false;
|
|
29283
|
-
}
|
|
29284
|
-
return editor.undoManager.runInGroup(() => {
|
|
29285
|
-
handleEditorDeleteLeftWord(editor);
|
|
29286
|
-
return true;
|
|
29287
|
-
});
|
|
29288
|
-
}
|
|
29289
|
-
function editorHandleDeleteRightWord(editor, event) {
|
|
29290
|
-
if (editor.readonly || !editor.isWritable()) {
|
|
29291
|
-
return false;
|
|
29292
|
-
}
|
|
29293
|
-
return editor.undoManager.runInGroup(() => {
|
|
29294
|
-
handleEditorDeleteRightWord(editor);
|
|
29295
|
-
return true;
|
|
29296
|
-
});
|
|
29297
|
-
}
|
|
29298
|
-
function editorHandleDeleteAfterWords(editor, event) {
|
|
29299
|
-
if (editor.readonly || !editor.isWritable()) {
|
|
29300
|
-
return false;
|
|
29301
|
-
}
|
|
29302
|
-
return editor.undoManager.runInGroup(() => {
|
|
29303
|
-
handleEditorDeleteAfterWords(editor);
|
|
29304
|
-
return true;
|
|
29305
|
-
});
|
|
29306
|
-
}
|
|
29307
|
-
function editorHandleDeleteRightChar(editor, event) {
|
|
29308
|
-
if (editor.readonly || !editor.isWritable()) {
|
|
29309
|
-
return false;
|
|
29310
|
-
}
|
|
29311
|
-
return editor.undoManager.runInGroup(() => {
|
|
29312
|
-
handleEditorDeleteRightChar(editor);
|
|
29313
|
-
return true;
|
|
29314
|
-
});
|
|
29315
|
-
}
|
|
29316
29094
|
function editorHandleBackspace(editor, event) {
|
|
29317
29095
|
if (editor.readonly || !editor.isWritable()) {
|
|
29318
29096
|
return false;
|
|
@@ -29406,10 +29184,6 @@ ${codeText}
|
|
|
29406
29184
|
__proto__: null,
|
|
29407
29185
|
editorHandleEnter,
|
|
29408
29186
|
editorHandleDelete,
|
|
29409
|
-
editorHandleDeleteLeftWord,
|
|
29410
|
-
editorHandleDeleteRightWord,
|
|
29411
|
-
editorHandleDeleteAfterWords,
|
|
29412
|
-
editorHandleDeleteRightChar,
|
|
29413
29187
|
editorHandleBackspace,
|
|
29414
29188
|
editorHandleInsertBr,
|
|
29415
29189
|
editorHandlePastePlainText,
|
|
@@ -29417,41 +29191,6 @@ ${codeText}
|
|
|
29417
29191
|
getSelectedCodeBlockMarkdown,
|
|
29418
29192
|
editorHandleCopyMarkdown
|
|
29419
29193
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
29420
|
-
const MacShortcuts = {
|
|
29421
|
-
"Cmd+ArrowLeft": editorMoveLineHome,
|
|
29422
|
-
"Cmd+ArrowRight": editorMoveLineEnd,
|
|
29423
|
-
"Option+ArrowLeft": editorMoveWordLeft,
|
|
29424
|
-
"Option+ArrowRight": editorMoveWordEnd,
|
|
29425
|
-
"Option+Shift+ArrowLeft": editorSelectWordLeft,
|
|
29426
|
-
"Option+Shift+ArrowRight": editorSelectWordEnd,
|
|
29427
|
-
"Cmd+Shift+ArrowLeft": editorSelectLineHome,
|
|
29428
|
-
"Cmd+Shift+ArrowRight": editorSelectLineEnd,
|
|
29429
|
-
"Ctrl+A": editorMoveBlockStart,
|
|
29430
|
-
"Ctrl+E": editorMoveBlockEnd,
|
|
29431
|
-
"Option+Delete": editorHandleDeleteRightWord,
|
|
29432
|
-
"Option+Backspace": editorHandleDeleteLeftWord,
|
|
29433
|
-
"Ctrl+B": editorMoveLeft,
|
|
29434
|
-
"Ctrl+F": editorMoveRight,
|
|
29435
|
-
"Ctrl+N": editorMoveDown,
|
|
29436
|
-
"Ctrl+P": editorMoveUp,
|
|
29437
|
-
"Ctrl+K": editorHandleDeleteAfterWords,
|
|
29438
|
-
"Ctrl+H": editorHandleBackspace,
|
|
29439
|
-
"Ctrl+D": editorHandleDeleteRightChar
|
|
29440
|
-
};
|
|
29441
|
-
const WinLinuxShortcuts = {
|
|
29442
|
-
"Home": editorMoveLineHome,
|
|
29443
|
-
"End": editorMoveLineEnd,
|
|
29444
|
-
"Shift+Home": editorSelectLineHome,
|
|
29445
|
-
"Shift+End": editorSelectLineEnd,
|
|
29446
|
-
"Ctrl+Delete": editorHandleDeleteRightWord,
|
|
29447
|
-
"Ctrl+Backspace": editorHandleDeleteLeftWord,
|
|
29448
|
-
"Ctrl+ArrowLeft": editorMoveWordLeft,
|
|
29449
|
-
"Ctrl+ArrowRight": editorMoveWordEnd,
|
|
29450
|
-
"Ctrl+Shift+ArrowLeft": editorSelectWordLeft,
|
|
29451
|
-
"Ctrl+Shift+ArrowRight": editorSelectWordEnd
|
|
29452
|
-
};
|
|
29453
|
-
const isMac = clientType.isMac;
|
|
29454
|
-
const CustomShortcuts = isMac ? MacShortcuts : WinLinuxShortcuts;
|
|
29455
29194
|
const DefaultShortcuts = {
|
|
29456
29195
|
"ArrowDown": editorMoveDown,
|
|
29457
29196
|
"ArrowUp": editorMoveUp,
|
|
@@ -29461,11 +29200,19 @@ ${codeText}
|
|
|
29461
29200
|
"Shift+ArrowUp": editorSelectUp,
|
|
29462
29201
|
"Shift+ArrowLeft": editorSelectLeft,
|
|
29463
29202
|
"Shift+ArrowRight": editorSelectRight,
|
|
29203
|
+
"CtrlOrCmd+ArrowLeft": editorMoveWordLeft,
|
|
29204
|
+
"CtrlOrCmd+ArrowRight": editorMoveWordEnd,
|
|
29205
|
+
"CtrlOrCmd+Shift+ArrowLeft": editorSelectWordLeft,
|
|
29206
|
+
"CtrlOrCmd+Shift+ArrowRight": editorSelectWordEnd,
|
|
29464
29207
|
"CtrlOrCmd+ArrowUp": editorMoveHome,
|
|
29465
29208
|
"CtrlOrCmd+ArrowDown": editorMoveEnd,
|
|
29466
29209
|
"CtrlOrCmd+Shift+ArrowUp": editorSelectHome,
|
|
29467
29210
|
"CtrlOrCmd+Shift+ArrowDown": editorSelectEnd,
|
|
29468
29211
|
"CtrlOrCmd+A": editorSelectAll,
|
|
29212
|
+
"Home": editorMoveLineHome,
|
|
29213
|
+
"End": editorMoveLineEnd,
|
|
29214
|
+
"Shift+Home": editorSelectLineHome,
|
|
29215
|
+
"Shift+End": editorSelectLineEnd,
|
|
29469
29216
|
"PageUp": editorMovePageUp,
|
|
29470
29217
|
"PageDown": editorMovePageDown,
|
|
29471
29218
|
"Shift+PageUp": editorSelectPageUp,
|
|
@@ -29477,8 +29224,7 @@ ${codeText}
|
|
|
29477
29224
|
"Backspace": editorHandleBackspace,
|
|
29478
29225
|
"Shift+Enter": editorHandleInsertBr,
|
|
29479
29226
|
"CtrlOrCmd+Shift+V": editorHandlePastePlainText,
|
|
29480
|
-
"CtrlOrCmd+Shift+C": editorHandleCopyMarkdown
|
|
29481
|
-
...CustomShortcuts
|
|
29227
|
+
"CtrlOrCmd+Shift+C": editorHandleCopyMarkdown
|
|
29482
29228
|
};
|
|
29483
29229
|
function editorHandleKeyboardEvent(editor, event) {
|
|
29484
29230
|
const result = editor.shortcuts.handleKeyboardEvents(editor, event);
|
|
@@ -43256,21 +43002,8 @@ ${codeText}
|
|
|
43256
43002
|
const textColorItem = "";
|
|
43257
43003
|
const DEFAULT_BG_COLOR = 2;
|
|
43258
43004
|
const NULLABLE_COLOR = -1;
|
|
43259
|
-
const STORAGE_NAME = "color-item";
|
|
43260
|
-
function getColorsFromLocalStorage(editor) {
|
|
43261
|
-
const colors = [null, null];
|
|
43262
|
-
const color = Number.parseInt(editor.settingsProvider.getItem(`${STORAGE_NAME}-color`) || "", 10);
|
|
43263
|
-
const backgroundColor = Number.parseInt(editor.settingsProvider.getItem(`${STORAGE_NAME}-backgroundColor`) || `${DEFAULT_BG_COLOR}`, 10);
|
|
43264
|
-
if (!Number.isNaN(color)) {
|
|
43265
|
-
colors[0] = color;
|
|
43266
|
-
}
|
|
43267
|
-
if (!Number.isNaN(backgroundColor)) {
|
|
43268
|
-
colors[1] = backgroundColor;
|
|
43269
|
-
}
|
|
43270
|
-
return colors;
|
|
43271
|
-
}
|
|
43272
43005
|
class TextColorItem extends tinyTypedEmitter.TypedEmitter {
|
|
43273
|
-
constructor(editor, storageName =
|
|
43006
|
+
constructor(editor, storageName = "color-item") {
|
|
43274
43007
|
super();
|
|
43275
43008
|
__publicField(this, "id", "text-color-item");
|
|
43276
43009
|
__publicField(this, "name", i18n$1.t("colorPalette.name"));
|
|
@@ -50965,7 +50698,7 @@ ${codeText}
|
|
|
50965
50698
|
}
|
|
50966
50699
|
return handleDragList(editor, draggedBlock, targetBlock, insertPos);
|
|
50967
50700
|
}
|
|
50968
|
-
function executeShortcut$
|
|
50701
|
+
function executeShortcut$1(editor, type) {
|
|
50969
50702
|
if (!editor.isWritable()) {
|
|
50970
50703
|
return false;
|
|
50971
50704
|
}
|
|
@@ -50979,8 +50712,8 @@ ${codeText}
|
|
|
50979
50712
|
return true;
|
|
50980
50713
|
}
|
|
50981
50714
|
const ListBlockShortcuts = {
|
|
50982
|
-
"Shift+CtrlOrCmd+L": (editor) => executeShortcut$
|
|
50983
|
-
"Shift+CtrlOrCmd+U": (editor) => executeShortcut$
|
|
50715
|
+
"Shift+CtrlOrCmd+L": (editor) => executeShortcut$1(editor, "ordered-list"),
|
|
50716
|
+
"Shift+CtrlOrCmd+U": (editor) => executeShortcut$1(editor, "unordered-list")
|
|
50984
50717
|
};
|
|
50985
50718
|
function getBlockPadding$1(block) {
|
|
50986
50719
|
const padding = block.getAttribute("block-padding-level");
|
|
@@ -61490,31 +61223,6 @@ $$${mathData.mathjaxText}$$
|
|
|
61490
61223
|
return editor.addCustom("overflow-tooltip-helper", () => new OverflowTooltipHelper(editor));
|
|
61491
61224
|
}
|
|
61492
61225
|
}
|
|
61493
|
-
function executeShortcut$2(editor, style2) {
|
|
61494
|
-
if (!editor.isWritable()) {
|
|
61495
|
-
return false;
|
|
61496
|
-
}
|
|
61497
|
-
const range = editor.selection.range;
|
|
61498
|
-
const allCommands = editor.editorCommandProviders.getCommands(range);
|
|
61499
|
-
const alignCommands = allCommands.flatMap((command2) => {
|
|
61500
|
-
if (command2.id === "align") {
|
|
61501
|
-
return command2.children;
|
|
61502
|
-
}
|
|
61503
|
-
return [];
|
|
61504
|
-
});
|
|
61505
|
-
const command = alignCommands.find((c) => c.id === `align-${style2}`);
|
|
61506
|
-
if (!command) {
|
|
61507
|
-
return false;
|
|
61508
|
-
}
|
|
61509
|
-
editor.editorCommandProviders.executeCommand(range, command, {});
|
|
61510
|
-
OnesEditorToolbar.get(editor).update("selectionChange");
|
|
61511
|
-
return true;
|
|
61512
|
-
}
|
|
61513
|
-
const AlignShortcuts = {
|
|
61514
|
-
"CtrlOrCmd+Shift+E": (editor) => executeShortcut$2(editor, "center"),
|
|
61515
|
-
"CtrlOrCmd+Shift+O": (editor) => executeShortcut$2(editor, "left"),
|
|
61516
|
-
"CtrlOrCmd+Shift+R": (editor) => executeShortcut$2(editor, "right")
|
|
61517
|
-
};
|
|
61518
61226
|
const TextCommands = {
|
|
61519
61227
|
"text/style-bold": "bold",
|
|
61520
61228
|
"text/style-italic": "italic",
|
|
@@ -61530,7 +61238,7 @@ $$${mathData.mathjaxText}$$
|
|
|
61530
61238
|
const styleCommands = blockCommands.filter((command) => styleCommandsSet.has(command.id));
|
|
61531
61239
|
return styleCommands;
|
|
61532
61240
|
}
|
|
61533
|
-
function executeShortcut
|
|
61241
|
+
function executeShortcut(editor, style2) {
|
|
61534
61242
|
if (!editor.isWritable()) {
|
|
61535
61243
|
return false;
|
|
61536
61244
|
}
|
|
@@ -61575,37 +61283,13 @@ $$${mathData.mathjaxText}$$
|
|
|
61575
61283
|
return shortcuts2;
|
|
61576
61284
|
};
|
|
61577
61285
|
const TextStyleShortcuts = {
|
|
61578
|
-
"CtrlOrCmd+B": (editor) => executeShortcut
|
|
61579
|
-
"CtrlOrCmd+I": (editor) => executeShortcut
|
|
61580
|
-
"CtrlOrCmd+U": (editor) => executeShortcut
|
|
61581
|
-
"CtrlOrCmd+D": (editor) => executeShortcut
|
|
61582
|
-
"CtrlOrCmd+K": (editor) => executeShortcut
|
|
61286
|
+
"CtrlOrCmd+B": (editor) => executeShortcut(editor, "style-bold"),
|
|
61287
|
+
"CtrlOrCmd+I": (editor) => executeShortcut(editor, "style-italic"),
|
|
61288
|
+
"CtrlOrCmd+U": (editor) => executeShortcut(editor, "style-underline"),
|
|
61289
|
+
"CtrlOrCmd+D": (editor) => executeShortcut(editor, "style-strikethrough"),
|
|
61290
|
+
"CtrlOrCmd+K": (editor) => executeShortcut(editor, "link"),
|
|
61583
61291
|
...headingShortcut()
|
|
61584
61292
|
};
|
|
61585
|
-
function executeShortcut(editor) {
|
|
61586
|
-
if (!editor.isWritable()) {
|
|
61587
|
-
return false;
|
|
61588
|
-
}
|
|
61589
|
-
const range = editor.selection.range;
|
|
61590
|
-
if (range.isCollapsed()) {
|
|
61591
|
-
return false;
|
|
61592
|
-
}
|
|
61593
|
-
editor.undoManager.runInGroup(() => {
|
|
61594
|
-
const colors = getColorsFromLocalStorage(editor);
|
|
61595
|
-
colors.forEach((color, idx) => {
|
|
61596
|
-
if (color === null) {
|
|
61597
|
-
return;
|
|
61598
|
-
}
|
|
61599
|
-
const type = idx === 0 ? "color" : "backgroundColor";
|
|
61600
|
-
editorRangeSetColor(editor, type, color, () => {
|
|
61601
|
-
});
|
|
61602
|
-
});
|
|
61603
|
-
});
|
|
61604
|
-
return true;
|
|
61605
|
-
}
|
|
61606
|
-
const TextColorShortcuts = {
|
|
61607
|
-
"CtrlOrCmd+Alt+KeyH": (editor) => executeShortcut(editor)
|
|
61608
|
-
};
|
|
61609
61293
|
const zhCN$p = {
|
|
61610
61294
|
quickMenu: {
|
|
61611
61295
|
basic: {
|
|
@@ -62364,7 +62048,7 @@ $$${mathData.mathjaxText}$$
|
|
|
62364
62048
|
__publicField(this, "updateButtonColor", (range) => {
|
|
62365
62049
|
const currentTextColor = editorRangeGetColor(this.editor, range, this.getEmptyTextBlockColor);
|
|
62366
62050
|
this.colorItem.setCurrentTextColors(currentTextColor);
|
|
62367
|
-
const lastButtonColor = getColorsFromLocalStorage(
|
|
62051
|
+
const lastButtonColor = this.colorItem.getColorsFromLocalStorage();
|
|
62368
62052
|
this.colorItem.setCurrentButtonColor(lastButtonColor);
|
|
62369
62053
|
});
|
|
62370
62054
|
__publicField(this, "setActiveAttribute", (type, value) => {
|
|
@@ -92219,11 +91903,9 @@ ${data2.plantumlText}
|
|
|
92219
91903
|
FindReplaceShortcuts,
|
|
92220
91904
|
BlockPaddingShortcuts,
|
|
92221
91905
|
TextStyleShortcuts,
|
|
92222
|
-
AlignShortcuts,
|
|
92223
91906
|
AutoLinkShortcuts,
|
|
92224
91907
|
DefaultShortcuts,
|
|
92225
91908
|
ListBlockShortcuts,
|
|
92226
|
-
TextColorShortcuts,
|
|
92227
91909
|
...options.shortcuts || []
|
|
92228
91910
|
],
|
|
92229
91911
|
colors: [
|
|
@@ -92432,7 +92114,7 @@ ${data2.plantumlText}
|
|
|
92432
92114
|
}
|
|
92433
92115
|
}
|
|
92434
92116
|
});
|
|
92435
|
-
editor.version = "2.
|
|
92117
|
+
editor.version = "2.7.1-beta.1";
|
|
92436
92118
|
return editor;
|
|
92437
92119
|
}
|
|
92438
92120
|
function isDoc(doc2) {
|
|
@@ -92545,7 +92227,7 @@ ${data2.plantumlText}
|
|
|
92545
92227
|
}
|
|
92546
92228
|
});
|
|
92547
92229
|
OnesEditorToolbar.register(editor);
|
|
92548
|
-
editor.version = "2.
|
|
92230
|
+
editor.version = "2.7.1-beta.1";
|
|
92549
92231
|
return editor;
|
|
92550
92232
|
}
|
|
92551
92233
|
async function showDocVersions(editor, options, serverUrl) {
|
|
@@ -138331,7 +138013,6 @@ ${data2.plantumlText}
|
|
|
138331
138013
|
exports2.AlignProvider = AlignProvider;
|
|
138332
138014
|
exports2.AlignRightIcon = AlignRightIcon;
|
|
138333
138015
|
exports2.AlignRightItem = AlignRightItem;
|
|
138334
|
-
exports2.AlignShortcuts = AlignShortcuts;
|
|
138335
138016
|
exports2.AnchorBox = AnchorBox;
|
|
138336
138017
|
exports2.ArrowDownIcon = ArrowDownIcon$1;
|
|
138337
138018
|
exports2.ArrowLeftIcon = arrowLeft;
|
|
@@ -138588,7 +138269,6 @@ ${data2.plantumlText}
|
|
|
138588
138269
|
exports2.TextBox = TextBox;
|
|
138589
138270
|
exports2.TextColorIcon = TextColorIcon;
|
|
138590
138271
|
exports2.TextColorItem = TextColorItem;
|
|
138591
|
-
exports2.TextColorShortcuts = TextColorShortcuts;
|
|
138592
138272
|
exports2.TextCommandProvider = TextCommandProvider;
|
|
138593
138273
|
exports2.TextGroupIcon = TextGroupIcon;
|
|
138594
138274
|
exports2.TextIcon = TextIcon;
|
|
@@ -138758,8 +138438,6 @@ ${data2.plantumlText}
|
|
|
138758
138438
|
exports2.editorInsertTextToBlock = editorInsertTextToBlock;
|
|
138759
138439
|
exports2.editorInsertTextToBlockEx = editorInsertTextToBlockEx;
|
|
138760
138440
|
exports2.editorMergeTextBlock = editorMergeTextBlock;
|
|
138761
|
-
exports2.editorMoveBlockEnd = editorMoveBlockEnd;
|
|
138762
|
-
exports2.editorMoveBlockStart = editorMoveBlockStart;
|
|
138763
138441
|
exports2.editorMoveDown = editorMoveDown;
|
|
138764
138442
|
exports2.editorMoveEnd = editorMoveEnd;
|
|
138765
138443
|
exports2.editorMoveHome = editorMoveHome;
|
|
@@ -138864,7 +138542,6 @@ ${data2.plantumlText}
|
|
|
138864
138542
|
exports2.getBlockTextLength = getBlockTextLength$6;
|
|
138865
138543
|
exports2.getBlockTools = getBlockTools;
|
|
138866
138544
|
exports2.getBlockType = getBlockType;
|
|
138867
|
-
exports2.getBlocksBetween = getBlocksBetween;
|
|
138868
138545
|
exports2.getBlocksWidth = getBlocksWidth;
|
|
138869
138546
|
exports2.getBoxContent = getBoxContent;
|
|
138870
138547
|
exports2.getBoxId = getBoxId;
|
|
@@ -138877,7 +138554,6 @@ ${data2.plantumlText}
|
|
|
138877
138554
|
exports2.getClosestContainerByCondition = getClosestContainerByCondition;
|
|
138878
138555
|
exports2.getColorFromAttributes = getColorFromAttributes;
|
|
138879
138556
|
exports2.getColorFromContent = getColorFromContent;
|
|
138880
|
-
exports2.getColorsFromLocalStorage = getColorsFromLocalStorage;
|
|
138881
138557
|
exports2.getComplexBlockClass = getComplexBlockClass;
|
|
138882
138558
|
exports2.getContainerBlockOverrideOptions = getContainerBlockOverrideOptions;
|
|
138883
138559
|
exports2.getContainerBlockPath = getContainerBlockPath;
|
|
@@ -138980,7 +138656,6 @@ ${data2.plantumlText}
|
|
|
138980
138656
|
exports2.isBox = isBox;
|
|
138981
138657
|
exports2.isBoxOp = isBoxOp;
|
|
138982
138658
|
exports2.isCJK = isCJK;
|
|
138983
|
-
exports2.isCJKPunctuation = isCJKPunctuation;
|
|
138984
138659
|
exports2.isChildContainer = isChildContainer;
|
|
138985
138660
|
exports2.isChildNode = isChildNode;
|
|
138986
138661
|
exports2.isClipboardEmpty = isClipboardEmpty$1;
|
|
@@ -139053,7 +138728,7 @@ ${data2.plantumlText}
|
|
|
139053
138728
|
exports2.loadJs = loadJs;
|
|
139054
138729
|
exports2.loadJsPromise = loadJsPromise;
|
|
139055
138730
|
exports2.lockers = lockers;
|
|
139056
|
-
exports2.logger = logger$
|
|
138731
|
+
exports2.logger = logger$4p;
|
|
139057
138732
|
exports2.markdownToDoc = markdownToDoc;
|
|
139058
138733
|
exports2.mergeCommands = mergeCommands;
|
|
139059
138734
|
exports2.mergeDocs = mergeDocs;
|