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