@ones-editor/editor 2.8.26 → 2.8.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -8916,7 +8916,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8916
8916
|
imageExportFailed: "\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F"
|
|
8917
8917
|
}
|
|
8918
8918
|
};
|
|
8919
|
-
const logger$
|
|
8919
|
+
const logger$4T = getLogger("i18n");
|
|
8920
8920
|
const langs$3 = {
|
|
8921
8921
|
"en-US": enUS$x,
|
|
8922
8922
|
"zh-CN": zhCN$x,
|
|
@@ -8936,7 +8936,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8936
8936
|
function t$8(key, args) {
|
|
8937
8937
|
const ret = i18n.get(key, args);
|
|
8938
8938
|
if (ret === key) {
|
|
8939
|
-
logger$
|
|
8939
|
+
logger$4T.warn(`no locale value for key ${key}`);
|
|
8940
8940
|
}
|
|
8941
8941
|
return ret;
|
|
8942
8942
|
}
|
|
@@ -9554,7 +9554,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9554
9554
|
this._callbacks.clear();
|
|
9555
9555
|
}
|
|
9556
9556
|
}
|
|
9557
|
-
const logger$
|
|
9557
|
+
const logger$4S = getLogger("await-locker");
|
|
9558
9558
|
class AwaitLock {
|
|
9559
9559
|
constructor() {
|
|
9560
9560
|
__publicField(this, "_acquired", false);
|
|
@@ -9596,7 +9596,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9596
9596
|
}
|
|
9597
9597
|
if (this._waitingResolvers.length > 0) {
|
|
9598
9598
|
const resolve = this._waitingResolvers.shift();
|
|
9599
|
-
assert(logger$
|
|
9599
|
+
assert(logger$4S, resolve, "Resolver missing");
|
|
9600
9600
|
resolve(void 0);
|
|
9601
9601
|
} else {
|
|
9602
9602
|
this._acquired = false;
|
|
@@ -9679,7 +9679,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9679
9679
|
isMobileSafari: false
|
|
9680
9680
|
};
|
|
9681
9681
|
clientType.isMobileSafari = clientType.isMobile && clientType.isSafari;
|
|
9682
|
-
const logger$
|
|
9682
|
+
const logger$4R = getLogger("dom-utils");
|
|
9683
9683
|
function addClass(dom, ...className) {
|
|
9684
9684
|
if (dom && dom.nodeType === Node.ELEMENT_NODE) {
|
|
9685
9685
|
dom.classList.add(...className);
|
|
@@ -9733,7 +9733,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9733
9733
|
range.setStart(node, offset);
|
|
9734
9734
|
return range;
|
|
9735
9735
|
} catch (err) {
|
|
9736
|
-
assert(logger$
|
|
9736
|
+
assert(logger$4R, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
|
|
9737
9737
|
}
|
|
9738
9738
|
}
|
|
9739
9739
|
function createExpandedRange(startNode, startOffset, endNode, endOffset) {
|
|
@@ -9743,17 +9743,17 @@ var __publicField = (obj, key, value) => {
|
|
|
9743
9743
|
range.setEnd(endNode, endOffset);
|
|
9744
9744
|
return range;
|
|
9745
9745
|
} catch (err) {
|
|
9746
|
-
assert(logger$
|
|
9746
|
+
assert(logger$4R, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
|
|
9747
9747
|
}
|
|
9748
9748
|
}
|
|
9749
9749
|
function getFirstClientRect(elem) {
|
|
9750
9750
|
const rects = elem.getClientRects();
|
|
9751
|
-
assert(logger$
|
|
9751
|
+
assert(logger$4R, rects.length >= 1, "getFirstClientRect: no rects");
|
|
9752
9752
|
return rects[0];
|
|
9753
9753
|
}
|
|
9754
9754
|
function getLastClientRect(elem) {
|
|
9755
9755
|
const rects = elem.getClientRects();
|
|
9756
|
-
assert(logger$
|
|
9756
|
+
assert(logger$4R, rects.length >= 1, "getLastClientRect: no rects");
|
|
9757
9757
|
return rects[rects.length - 1];
|
|
9758
9758
|
}
|
|
9759
9759
|
function getDistanceSquare(rect, x, y) {
|
|
@@ -9800,7 +9800,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9800
9800
|
return 0;
|
|
9801
9801
|
}
|
|
9802
9802
|
if (!elem1.parentElement || !elem2.parentElement) {
|
|
9803
|
-
assert(logger$
|
|
9803
|
+
assert(logger$4R, false, "invalid dom node to compare");
|
|
9804
9804
|
}
|
|
9805
9805
|
if (elem1.parentElement === elem2.parentElement) {
|
|
9806
9806
|
const children = Array.from(elem1.parentElement.children);
|
|
@@ -9817,7 +9817,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9817
9817
|
const parents1 = getParents(elem1);
|
|
9818
9818
|
const parents2 = getParents(elem2);
|
|
9819
9819
|
if (parents1[0] !== parents2[0]) {
|
|
9820
|
-
assert(logger$
|
|
9820
|
+
assert(logger$4R, false, "invalid dom node to compare, different tree");
|
|
9821
9821
|
}
|
|
9822
9822
|
for (let i = 1; ; i++) {
|
|
9823
9823
|
const parent1 = parents1[i];
|
|
@@ -10417,7 +10417,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10417
10417
|
}
|
|
10418
10418
|
}
|
|
10419
10419
|
const MIN_DISTANCE_THRESHOLD$3 = 3;
|
|
10420
|
-
const logger$
|
|
10420
|
+
const logger$4Q = getLogger("drag-drop");
|
|
10421
10421
|
class DragDrop {
|
|
10422
10422
|
constructor(options) {
|
|
10423
10423
|
__publicField(this, "dragStarted", false);
|
|
@@ -10438,7 +10438,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10438
10438
|
var _a;
|
|
10439
10439
|
event.preventDefault();
|
|
10440
10440
|
event.stopPropagation();
|
|
10441
|
-
assert(logger$
|
|
10441
|
+
assert(logger$4Q, this.mouseDownEvent, "no mouse down event");
|
|
10442
10442
|
const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
|
|
10443
10443
|
const newPos = DragDrop.getEventPosition(event);
|
|
10444
10444
|
const deltaX = newPos.x - oldPos.x;
|
|
@@ -10454,7 +10454,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10454
10454
|
});
|
|
10455
10455
|
__publicField(this, "handleMouseUp", (event) => {
|
|
10456
10456
|
if (event instanceof MouseEvent && event.button === 0 || event instanceof TouchEvent) {
|
|
10457
|
-
assert(logger$
|
|
10457
|
+
assert(logger$4Q, this.mouseDownEvent, "no mouse down event");
|
|
10458
10458
|
const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
|
|
10459
10459
|
const newPos = DragDrop.getEventPosition(event);
|
|
10460
10460
|
const deltaX = newPos.x - oldPos.x;
|
|
@@ -10563,7 +10563,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10563
10563
|
const dragDrop = new DragDrop(options);
|
|
10564
10564
|
return dragDrop;
|
|
10565
10565
|
}
|
|
10566
|
-
const logger$
|
|
10566
|
+
const logger$4P = getLogger("character");
|
|
10567
10567
|
function checkChar(charCode, rangeList) {
|
|
10568
10568
|
for (let i = 0; i < rangeList.length; i++) {
|
|
10569
10569
|
const start = rangeList[i][0];
|
|
@@ -10614,7 +10614,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10614
10614
|
}
|
|
10615
10615
|
function trimChar(s, char) {
|
|
10616
10616
|
let c = char;
|
|
10617
|
-
assert(logger$
|
|
10617
|
+
assert(logger$4P, c.length === 1, "invalid char length");
|
|
10618
10618
|
if (c === "]")
|
|
10619
10619
|
c = "\\]";
|
|
10620
10620
|
if (c === "\\")
|
|
@@ -10972,7 +10972,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10972
10972
|
return 200;
|
|
10973
10973
|
}
|
|
10974
10974
|
}
|
|
10975
|
-
const logger$
|
|
10975
|
+
const logger$4O = getLogger("editor-clipboard");
|
|
10976
10976
|
async function setClipboardDataByEvent(items, event) {
|
|
10977
10977
|
if (event.clipboardData) {
|
|
10978
10978
|
const data2 = event.clipboardData;
|
|
@@ -11030,7 +11030,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11030
11030
|
document.body.removeChild(textarea2);
|
|
11031
11031
|
return true;
|
|
11032
11032
|
} catch (ex) {
|
|
11033
|
-
logger$
|
|
11033
|
+
logger$4O.error(ex);
|
|
11034
11034
|
document.body.removeChild(textarea2);
|
|
11035
11035
|
return false;
|
|
11036
11036
|
}
|
|
@@ -11051,7 +11051,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11051
11051
|
document.body.removeChild(div);
|
|
11052
11052
|
return true;
|
|
11053
11053
|
} catch (ex) {
|
|
11054
|
-
logger$
|
|
11054
|
+
logger$4O.error(ex);
|
|
11055
11055
|
document.body.removeChild(div);
|
|
11056
11056
|
return false;
|
|
11057
11057
|
}
|
|
@@ -11078,7 +11078,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11078
11078
|
await navigator.clipboard.write([clipboardItems]);
|
|
11079
11079
|
return true;
|
|
11080
11080
|
} catch (err) {
|
|
11081
|
-
logger$
|
|
11081
|
+
logger$4O.error(err);
|
|
11082
11082
|
return await execCommandCopy(items);
|
|
11083
11083
|
}
|
|
11084
11084
|
}
|
|
@@ -11134,7 +11134,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11134
11134
|
a.click();
|
|
11135
11135
|
a.remove();
|
|
11136
11136
|
}
|
|
11137
|
-
const logger$
|
|
11137
|
+
const logger$4N = getLogger("auto-scroll");
|
|
11138
11138
|
function scrollable(scrollElement, direction) {
|
|
11139
11139
|
if (scrollElement.scrollHeight === scrollElement.clientHeight) {
|
|
11140
11140
|
return false;
|
|
@@ -11158,7 +11158,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11158
11158
|
const isHorizontal = direction === "left" || direction === "right";
|
|
11159
11159
|
const scroll = () => {
|
|
11160
11160
|
if (!scrollable(scrollElement, direction)) {
|
|
11161
|
-
logger$
|
|
11161
|
+
logger$4N.debug("No need for scroll");
|
|
11162
11162
|
return null;
|
|
11163
11163
|
}
|
|
11164
11164
|
if (isHorizontal) {
|
|
@@ -11215,7 +11215,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11215
11215
|
if (this.scrolling) {
|
|
11216
11216
|
return;
|
|
11217
11217
|
}
|
|
11218
|
-
logger$
|
|
11218
|
+
logger$4N.debug(`scroll direction: ${direction}`);
|
|
11219
11219
|
this.cancelScroll = continuousScroll(scrollElement, {
|
|
11220
11220
|
direction,
|
|
11221
11221
|
step
|
|
@@ -11465,7 +11465,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11465
11465
|
const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
|
|
11466
11466
|
return ColorNames[colorIndex];
|
|
11467
11467
|
}
|
|
11468
|
-
const logger$
|
|
11468
|
+
const logger$4M = getLogger("container");
|
|
11469
11469
|
function isContainer(elem) {
|
|
11470
11470
|
return elem.getAttribute("data-type") === "editor-container";
|
|
11471
11471
|
}
|
|
@@ -11477,9 +11477,9 @@ var __publicField = (obj, key, value) => {
|
|
|
11477
11477
|
}
|
|
11478
11478
|
function getContainerId(container) {
|
|
11479
11479
|
const id = container.getAttribute("data-container-id");
|
|
11480
|
-
assert(logger$
|
|
11480
|
+
assert(logger$4M, id, "no id for container");
|
|
11481
11481
|
if (isRootContainer(container)) {
|
|
11482
|
-
assert(logger$
|
|
11482
|
+
assert(logger$4M, id === "root", `invalid root container id, : ${id}`);
|
|
11483
11483
|
}
|
|
11484
11484
|
return id;
|
|
11485
11485
|
}
|
|
@@ -11490,7 +11490,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11490
11490
|
function generateEditorContainerId(containerId) {
|
|
11491
11491
|
return `ones-editor-container-${containerId}`;
|
|
11492
11492
|
}
|
|
11493
|
-
const logger$
|
|
11493
|
+
const logger$4L = getLogger("element");
|
|
11494
11494
|
function createContainerElement(parent, type, containerId) {
|
|
11495
11495
|
const container = createElement("div", [type], parent);
|
|
11496
11496
|
container.setAttribute("data-type", "editor-container");
|
|
@@ -11501,7 +11501,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11501
11501
|
}
|
|
11502
11502
|
function getContainerById(editor, containerId) {
|
|
11503
11503
|
const container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
|
|
11504
|
-
assert(logger$
|
|
11504
|
+
assert(logger$4L, container, `no container: ${containerId}`);
|
|
11505
11505
|
return container;
|
|
11506
11506
|
}
|
|
11507
11507
|
function getExistsContainerById(editor, containerId) {
|
|
@@ -11510,7 +11510,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11510
11510
|
}
|
|
11511
11511
|
function getContainerBlocksElement(container) {
|
|
11512
11512
|
const blocks = container.querySelector(":scope > .container-blocks");
|
|
11513
|
-
assert(logger$
|
|
11513
|
+
assert(logger$4L, blocks, "no container blocks element");
|
|
11514
11514
|
return blocks;
|
|
11515
11515
|
}
|
|
11516
11516
|
function getContainerToolsElement(container) {
|
|
@@ -11523,11 +11523,11 @@ var __publicField = (obj, key, value) => {
|
|
|
11523
11523
|
function isContainerBlocksElement(element) {
|
|
11524
11524
|
return element.classList.contains("container-blocks");
|
|
11525
11525
|
}
|
|
11526
|
-
const logger$
|
|
11526
|
+
const logger$4K = getLogger("container-children");
|
|
11527
11527
|
function getChildBlocks(container, traverseChild) {
|
|
11528
11528
|
const content = getContainerBlocksElement(container);
|
|
11529
11529
|
const blocks = Array.from(content.children);
|
|
11530
|
-
assert(logger$
|
|
11530
|
+
assert(logger$4K, blocks.length > 0, "container have not any child block");
|
|
11531
11531
|
if (traverseChild) {
|
|
11532
11532
|
const { condition, editor } = traverseChild;
|
|
11533
11533
|
return blocks.reduce((result, block) => {
|
|
@@ -11550,7 +11550,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11550
11550
|
}
|
|
11551
11551
|
function getFirstChildBlock(container) {
|
|
11552
11552
|
const block = container.querySelector(":scope > .container-blocks > div[data-type=editor-block]");
|
|
11553
|
-
assert(logger$
|
|
11553
|
+
assert(logger$4K, block, "container have not any child block");
|
|
11554
11554
|
return block;
|
|
11555
11555
|
}
|
|
11556
11556
|
function getLastChildBlock(container) {
|
|
@@ -11562,14 +11562,14 @@ var __publicField = (obj, key, value) => {
|
|
|
11562
11562
|
}
|
|
11563
11563
|
function getBlockByIndex(container, blockIndex) {
|
|
11564
11564
|
const block = getChildBlocks(container)[blockIndex];
|
|
11565
|
-
assert(logger$
|
|
11565
|
+
assert(logger$4K, block, `container have not block at index ${blockIndex}`);
|
|
11566
11566
|
return block;
|
|
11567
11567
|
}
|
|
11568
11568
|
function findBlockByIndex(container, blockIndex) {
|
|
11569
11569
|
var _a;
|
|
11570
11570
|
return (_a = getChildBlocks(container)[blockIndex]) != null ? _a : null;
|
|
11571
11571
|
}
|
|
11572
|
-
const logger$
|
|
11572
|
+
const logger$4J = getLogger("block-dom");
|
|
11573
11573
|
function isBlock$1(node) {
|
|
11574
11574
|
if (!(node instanceof HTMLDivElement)) {
|
|
11575
11575
|
return false;
|
|
@@ -11590,12 +11590,12 @@ var __publicField = (obj, key, value) => {
|
|
|
11590
11590
|
}
|
|
11591
11591
|
function getBlockId(block) {
|
|
11592
11592
|
const { id } = block;
|
|
11593
|
-
assert(logger$
|
|
11593
|
+
assert(logger$4J, id, "no block id");
|
|
11594
11594
|
return id;
|
|
11595
11595
|
}
|
|
11596
11596
|
function getBlockType(block) {
|
|
11597
11597
|
const type = block.getAttribute("data-block-type");
|
|
11598
|
-
assert(logger$
|
|
11598
|
+
assert(logger$4J, type, "invalid block dom, no data-type");
|
|
11599
11599
|
return type;
|
|
11600
11600
|
}
|
|
11601
11601
|
function getParentBlock(node) {
|
|
@@ -11618,12 +11618,12 @@ var __publicField = (obj, key, value) => {
|
|
|
11618
11618
|
}
|
|
11619
11619
|
function getParentContainer(block) {
|
|
11620
11620
|
const container = block.closest("div[data-type=editor-container]");
|
|
11621
|
-
assert(logger$
|
|
11621
|
+
assert(logger$4J, container, "failed to get block container");
|
|
11622
11622
|
return container;
|
|
11623
11623
|
}
|
|
11624
11624
|
function getBlockContent(block) {
|
|
11625
11625
|
const content = block.querySelector(":scope >div[data-type=block-content]");
|
|
11626
|
-
assert(logger$
|
|
11626
|
+
assert(logger$4J, content, "no block content");
|
|
11627
11627
|
return content;
|
|
11628
11628
|
}
|
|
11629
11629
|
function getBlockTools(block) {
|
|
@@ -11632,7 +11632,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11632
11632
|
tools = createElement("div", [], block);
|
|
11633
11633
|
tools.setAttribute("data-type", "block-tools");
|
|
11634
11634
|
}
|
|
11635
|
-
assert(logger$
|
|
11635
|
+
assert(logger$4J, tools, "no block tools");
|
|
11636
11636
|
return tools;
|
|
11637
11637
|
}
|
|
11638
11638
|
function getExistsBlockTools(block) {
|
|
@@ -11653,7 +11653,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11653
11653
|
function createBlockElement(editor, path, data2) {
|
|
11654
11654
|
const blockData = editor.editorDecorators.decorateBlock(path, data2);
|
|
11655
11655
|
const { id, type } = blockData;
|
|
11656
|
-
assert(logger$
|
|
11656
|
+
assert(logger$4J, id, "no block id");
|
|
11657
11657
|
const elem = createElement("div", [`${type}-block`], null);
|
|
11658
11658
|
elem.id = id;
|
|
11659
11659
|
elem.setAttribute("data-type", "editor-block");
|
|
@@ -11691,7 +11691,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11691
11691
|
}
|
|
11692
11692
|
function getBoxTypeFromElement(box) {
|
|
11693
11693
|
const type = box.getAttribute("data-box-type");
|
|
11694
|
-
assert(logger$
|
|
11694
|
+
assert(logger$4J, type, "not a valid box element, no type");
|
|
11695
11695
|
return type;
|
|
11696
11696
|
}
|
|
11697
11697
|
function isBox(node) {
|
|
@@ -11702,7 +11702,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11702
11702
|
}
|
|
11703
11703
|
function getBoxId(box) {
|
|
11704
11704
|
const { id } = box;
|
|
11705
|
-
assert(logger$
|
|
11705
|
+
assert(logger$4J, id, "no box id");
|
|
11706
11706
|
return id;
|
|
11707
11707
|
}
|
|
11708
11708
|
function getParentBox(node) {
|
|
@@ -11724,7 +11724,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11724
11724
|
}
|
|
11725
11725
|
function getBoxContent(box) {
|
|
11726
11726
|
const content = box.querySelector("span[data-type=box-content]");
|
|
11727
|
-
assert(logger$
|
|
11727
|
+
assert(logger$4J, content, "invalid box dom, no content");
|
|
11728
11728
|
return content;
|
|
11729
11729
|
}
|
|
11730
11730
|
function createInsertionElement(type, id, attributes) {
|
|
@@ -11746,7 +11746,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11746
11746
|
}
|
|
11747
11747
|
function getInsertionContent(insertion) {
|
|
11748
11748
|
const content = insertion.querySelector("span[data-type=insertion-content]");
|
|
11749
|
-
assert(logger$
|
|
11749
|
+
assert(logger$4J, content, "invalid insertion-child dom, no content");
|
|
11750
11750
|
return content;
|
|
11751
11751
|
}
|
|
11752
11752
|
function getPrevBlock(block) {
|
|
@@ -11806,7 +11806,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11806
11806
|
const container = getParentContainer(block);
|
|
11807
11807
|
const children = getChildBlocks(container);
|
|
11808
11808
|
const index2 = children.indexOf(block);
|
|
11809
|
-
assert(logger$
|
|
11809
|
+
assert(logger$4J, index2 !== -1, "invalid block & container dom, failed to get block index");
|
|
11810
11810
|
return index2;
|
|
11811
11811
|
}
|
|
11812
11812
|
function isInBlock(target) {
|
|
@@ -11831,18 +11831,18 @@ var __publicField = (obj, key, value) => {
|
|
|
11831
11831
|
function isTitleBlock$2(block) {
|
|
11832
11832
|
return block.hasAttribute("data-document-title");
|
|
11833
11833
|
}
|
|
11834
|
-
const logger$
|
|
11834
|
+
const logger$4I = getLogger("block-class");
|
|
11835
11835
|
function getBlockClass(editor, block) {
|
|
11836
11836
|
return editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
11837
11837
|
}
|
|
11838
11838
|
function getTextBlockClass(editor, block) {
|
|
11839
11839
|
const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
11840
|
-
assert(logger$
|
|
11840
|
+
assert(logger$4I, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
|
|
11841
11841
|
return text2;
|
|
11842
11842
|
}
|
|
11843
11843
|
function getComplexBlockClass(editor, block) {
|
|
11844
11844
|
const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
11845
|
-
assert(logger$
|
|
11845
|
+
assert(logger$4I, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
|
|
11846
11846
|
return complex;
|
|
11847
11847
|
}
|
|
11848
11848
|
function getBlockClassByType(editor, type) {
|
|
@@ -11863,7 +11863,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11863
11863
|
function getBlockKind(editor, block) {
|
|
11864
11864
|
return getBlockClass(editor, block).blockKind;
|
|
11865
11865
|
}
|
|
11866
|
-
const logger$
|
|
11866
|
+
const logger$4H = getLogger("text-block-child");
|
|
11867
11867
|
function isTextBlockContentChild(elem) {
|
|
11868
11868
|
if (elem.tagName !== "SPAN") {
|
|
11869
11869
|
return false;
|
|
@@ -11871,14 +11871,14 @@ var __publicField = (obj, key, value) => {
|
|
|
11871
11871
|
return true;
|
|
11872
11872
|
}
|
|
11873
11873
|
function isTextBlockContentBoxChild(elem) {
|
|
11874
|
-
assert(logger$
|
|
11874
|
+
assert(logger$4H, isTextBlockContentChild(elem), "not a valid text child");
|
|
11875
11875
|
if (elem.getAttribute("data-type") === "editor-box") {
|
|
11876
11876
|
return true;
|
|
11877
11877
|
}
|
|
11878
11878
|
return false;
|
|
11879
11879
|
}
|
|
11880
11880
|
function isTextBlockContentInsertionChild(elem) {
|
|
11881
|
-
assert(logger$
|
|
11881
|
+
assert(logger$4H, isTextBlockContentChild(elem), "not a valid text child");
|
|
11882
11882
|
if (elem.getAttribute("data-type") === "editor-insertion") {
|
|
11883
11883
|
return true;
|
|
11884
11884
|
}
|
|
@@ -11888,7 +11888,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11888
11888
|
return !isTextBlockContentBoxChild(elem) && !isTextBlockContentInsertionChild(elem);
|
|
11889
11889
|
}
|
|
11890
11890
|
function getTextBlockContentChildType(child) {
|
|
11891
|
-
assert(logger$
|
|
11891
|
+
assert(logger$4H, isTextBlockContentChild(child), "not a valid text child");
|
|
11892
11892
|
if (isTextBlockContentBoxChild(child)) {
|
|
11893
11893
|
return "box";
|
|
11894
11894
|
}
|
|
@@ -11903,15 +11903,15 @@ var __publicField = (obj, key, value) => {
|
|
|
11903
11903
|
return 0;
|
|
11904
11904
|
if (type === "box")
|
|
11905
11905
|
return 1;
|
|
11906
|
-
assert(logger$
|
|
11907
|
-
assert(logger$
|
|
11906
|
+
assert(logger$4H, child.textContent !== null, "text block content is undefined");
|
|
11907
|
+
assert(logger$4H, child.textContent.length >= 0, "text block content length is negative");
|
|
11908
11908
|
return child.textContent.length;
|
|
11909
11909
|
}
|
|
11910
11910
|
function getTextBlockContentChildren(block) {
|
|
11911
11911
|
const content = getBlockContent(block);
|
|
11912
11912
|
const children = Array.from(content.children);
|
|
11913
11913
|
children.forEach((child) => {
|
|
11914
|
-
assert(logger$
|
|
11914
|
+
assert(logger$4H, isTextBlockContentChild(child), "not a valid text child");
|
|
11915
11915
|
});
|
|
11916
11916
|
return children;
|
|
11917
11917
|
}
|
|
@@ -11940,17 +11940,17 @@ var __publicField = (obj, key, value) => {
|
|
|
11940
11940
|
};
|
|
11941
11941
|
}
|
|
11942
11942
|
const offset = blockOffset - start;
|
|
11943
|
-
assert(logger$
|
|
11944
|
-
assert(logger$
|
|
11943
|
+
assert(logger$4H, offset > 0, "invalid offset value");
|
|
11944
|
+
assert(logger$4H, !isTextBlockContentBoxChild(child), "invalid box child");
|
|
11945
11945
|
return {
|
|
11946
11946
|
prev: child,
|
|
11947
11947
|
next: child,
|
|
11948
11948
|
offset
|
|
11949
11949
|
};
|
|
11950
11950
|
}
|
|
11951
|
-
assert(logger$
|
|
11951
|
+
assert(logger$4H, false, `invalid block child at position: ${blockOffset}`);
|
|
11952
11952
|
}
|
|
11953
|
-
const logger$
|
|
11953
|
+
const logger$4G = getLogger("block-path");
|
|
11954
11954
|
function getBlockPath(block) {
|
|
11955
11955
|
const ret = [];
|
|
11956
11956
|
let current = block;
|
|
@@ -11964,26 +11964,26 @@ var __publicField = (obj, key, value) => {
|
|
|
11964
11964
|
return ret;
|
|
11965
11965
|
}
|
|
11966
11966
|
const parentBlock = getParentBlock(container);
|
|
11967
|
-
assert(logger$
|
|
11967
|
+
assert(logger$4G, parentBlock, "no parent block");
|
|
11968
11968
|
current = parentBlock;
|
|
11969
11969
|
}
|
|
11970
|
-
assert(logger$
|
|
11970
|
+
assert(logger$4G, false, "no parent block");
|
|
11971
11971
|
return [];
|
|
11972
11972
|
}
|
|
11973
|
-
const logger$
|
|
11973
|
+
const logger$4F = getLogger("child-container-path");
|
|
11974
11974
|
function getContainerBlockPath(container) {
|
|
11975
11975
|
if (isRootContainer(container)) {
|
|
11976
11976
|
return [];
|
|
11977
11977
|
}
|
|
11978
11978
|
const parentBlock = getParentBlock(container);
|
|
11979
|
-
assert(logger$
|
|
11979
|
+
assert(logger$4F, parentBlock, "no parent block");
|
|
11980
11980
|
return getBlockPath(parentBlock);
|
|
11981
11981
|
}
|
|
11982
|
-
const logger$
|
|
11982
|
+
const logger$4E = getLogger("load-blocks");
|
|
11983
11983
|
function loadBlocks(editor, container, path) {
|
|
11984
11984
|
const containerId = getContainerId(container);
|
|
11985
11985
|
const blocks = getContainerBlocks$1(container, editor.doc);
|
|
11986
|
-
assert(logger$
|
|
11986
|
+
assert(logger$4E, blocks.length > 0, "no blocks in container");
|
|
11987
11987
|
const fragment = document.createDocumentFragment();
|
|
11988
11988
|
blocks.forEach((b, index2) => {
|
|
11989
11989
|
const block = editor.editorBlocks.createBlock([...path, { containerId, blockIndex: index2 }], container, b);
|
|
@@ -11999,7 +11999,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11999
11999
|
return block;
|
|
12000
12000
|
}
|
|
12001
12001
|
const blocks = getChildBlocks(container);
|
|
12002
|
-
assert(logger$
|
|
12002
|
+
assert(logger$4E, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
|
|
12003
12003
|
if (blockIndex === blocks.length) {
|
|
12004
12004
|
containerBlocksElement.appendChild(block);
|
|
12005
12005
|
} else {
|
|
@@ -12017,7 +12017,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12017
12017
|
insertBlockAt(container, blockIndex, block);
|
|
12018
12018
|
return block;
|
|
12019
12019
|
}
|
|
12020
|
-
const logger$
|
|
12020
|
+
const logger$4D = getLogger("root-container");
|
|
12021
12021
|
const MIN_DISTANCE_THRESHOLD$2 = 3;
|
|
12022
12022
|
class RootContainer {
|
|
12023
12023
|
constructor(editor, rootContainer) {
|
|
@@ -12045,7 +12045,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12045
12045
|
this.editor.selection.updateSelection(null);
|
|
12046
12046
|
this.editor.emit("resize", this.editor);
|
|
12047
12047
|
} catch (err) {
|
|
12048
|
-
logger$
|
|
12048
|
+
logger$4D.warn(`failed to update selection while container resizing: ${err.message}`);
|
|
12049
12049
|
}
|
|
12050
12050
|
});
|
|
12051
12051
|
__publicField(this, "handleClick", (event) => {
|
|
@@ -12079,7 +12079,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12079
12079
|
const box = getParentBox(elem);
|
|
12080
12080
|
if (box && isChildNode(box, eTarget)) {
|
|
12081
12081
|
const block2 = getParentBlock(box);
|
|
12082
|
-
assert(logger$
|
|
12082
|
+
assert(logger$4D, block2, "no parent block");
|
|
12083
12083
|
(_b = (_a = this.editor.editorBoxes.getBoxClass(getBoxTypeFromElement(box))) == null ? void 0 : _a.handleClickBox) == null ? void 0 : _b.call(_a, this.editor, box, event);
|
|
12084
12084
|
return;
|
|
12085
12085
|
}
|
|
@@ -12134,7 +12134,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12134
12134
|
this.editor.input.focus({ preventScroll: true });
|
|
12135
12135
|
});
|
|
12136
12136
|
__publicField(this, "handleMouseMove", (event) => {
|
|
12137
|
-
assert(logger$
|
|
12137
|
+
assert(logger$4D, this.mouseDownEvent, "no mouse down event");
|
|
12138
12138
|
if (ensureIsMobileEvent(this.mouseDownEvent))
|
|
12139
12139
|
return;
|
|
12140
12140
|
const deltaX = event.x - this.mouseDownEvent.x;
|
|
@@ -12250,7 +12250,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12250
12250
|
loadBlocks(editor, container, path);
|
|
12251
12251
|
return container;
|
|
12252
12252
|
}
|
|
12253
|
-
const logger$
|
|
12253
|
+
const logger$4C = getLogger("block");
|
|
12254
12254
|
function getBlockTextLength$6(editor, block) {
|
|
12255
12255
|
return getBlockClass(editor, block).getBlockTextLength(block);
|
|
12256
12256
|
}
|
|
@@ -12269,7 +12269,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12269
12269
|
return block;
|
|
12270
12270
|
}
|
|
12271
12271
|
const parent = getParentBlock(container);
|
|
12272
|
-
assert(logger$
|
|
12272
|
+
assert(logger$4C, parent, "no parent block exists for child container");
|
|
12273
12273
|
block = parent;
|
|
12274
12274
|
}
|
|
12275
12275
|
}
|
|
@@ -12305,7 +12305,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12305
12305
|
}
|
|
12306
12306
|
return fun(editor, block, options);
|
|
12307
12307
|
} catch (err) {
|
|
12308
|
-
logger$
|
|
12308
|
+
logger$4C.debug(`unsupported block type: ${type}`);
|
|
12309
12309
|
return null;
|
|
12310
12310
|
}
|
|
12311
12311
|
}
|
|
@@ -12325,7 +12325,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12325
12325
|
const styles = Object.fromEntries(Object.entries(data2).filter(([key]) => key.startsWith("style-")));
|
|
12326
12326
|
Object.entries(styles).forEach(([, value]) => {
|
|
12327
12327
|
const type = typeof value;
|
|
12328
|
-
assert(logger$
|
|
12328
|
+
assert(logger$4C, type === "string" || type === "number" || type === "boolean", "invalid style value");
|
|
12329
12329
|
});
|
|
12330
12330
|
return styles;
|
|
12331
12331
|
}
|
|
@@ -12450,7 +12450,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12450
12450
|
}
|
|
12451
12451
|
return { element: null, blockCommands: [], boxCommands: [] };
|
|
12452
12452
|
}
|
|
12453
|
-
const logger$
|
|
12453
|
+
const logger$4B = getLogger("embed-block-common");
|
|
12454
12454
|
function isColumnsBlock(block) {
|
|
12455
12455
|
return getBlockType(block) === "layout";
|
|
12456
12456
|
}
|
|
@@ -12458,9 +12458,9 @@ var __publicField = (obj, key, value) => {
|
|
|
12458
12458
|
return getBlockType(block) === "embed";
|
|
12459
12459
|
}
|
|
12460
12460
|
function getEmbedType(block) {
|
|
12461
|
-
assert(logger$
|
|
12461
|
+
assert(logger$4B, isEmbedBlock(block), "not an embed block");
|
|
12462
12462
|
const type = block.getAttribute("data-embed-type");
|
|
12463
|
-
assert(logger$
|
|
12463
|
+
assert(logger$4B, type, "no embed data type");
|
|
12464
12464
|
return type;
|
|
12465
12465
|
}
|
|
12466
12466
|
function getEmbedClassFromBlock(editor, block) {
|
|
@@ -12526,10 +12526,10 @@ var __publicField = (obj, key, value) => {
|
|
|
12526
12526
|
data: (_c = overrideOptions == null ? void 0 : overrideOptions.data) != null ? _c : data2
|
|
12527
12527
|
});
|
|
12528
12528
|
}
|
|
12529
|
-
const logger$
|
|
12529
|
+
const logger$4A = getLogger("execute-block-command");
|
|
12530
12530
|
function executeEmbedBlockCommand(editor, block, commandGroup, item) {
|
|
12531
12531
|
var _a;
|
|
12532
|
-
assert(logger$
|
|
12532
|
+
assert(logger$4A, isEmbedBlock(block), "not a embed block");
|
|
12533
12533
|
const embedType = getEmbedType(block);
|
|
12534
12534
|
const embed = getEmbedClassByType(editor, embedType);
|
|
12535
12535
|
if (!embed.getOptions) {
|
|
@@ -12562,14 +12562,14 @@ var __publicField = (obj, key, value) => {
|
|
|
12562
12562
|
}
|
|
12563
12563
|
return void 0;
|
|
12564
12564
|
}
|
|
12565
|
-
const logger$
|
|
12565
|
+
const logger$4z = getLogger("block-class");
|
|
12566
12566
|
function isHeadingBlock$1(block) {
|
|
12567
12567
|
return !!block.getAttribute("data-style-heading");
|
|
12568
12568
|
}
|
|
12569
12569
|
function getBlockHeading(block) {
|
|
12570
12570
|
var _a;
|
|
12571
12571
|
const heading = Number.parseInt((_a = block.getAttribute("data-style-heading")) != null ? _a : "", 10);
|
|
12572
|
-
assert(logger$
|
|
12572
|
+
assert(logger$4z, heading, "not a heading block");
|
|
12573
12573
|
return heading;
|
|
12574
12574
|
}
|
|
12575
12575
|
function isExpandedHeadingBlock(block) {
|
|
@@ -12580,7 +12580,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12580
12580
|
}
|
|
12581
12581
|
function getHeadingBlockChildren(block, oldHeading) {
|
|
12582
12582
|
if (!oldHeading) {
|
|
12583
|
-
assert(logger$
|
|
12583
|
+
assert(logger$4z, isHeadingBlock$1(block), "not a heading block");
|
|
12584
12584
|
}
|
|
12585
12585
|
const children = [];
|
|
12586
12586
|
const heading = oldHeading != null ? oldHeading : getBlockHeading(block);
|
|
@@ -12610,7 +12610,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12610
12610
|
}
|
|
12611
12611
|
return children;
|
|
12612
12612
|
}
|
|
12613
|
-
const logger$
|
|
12613
|
+
const logger$4y = getLogger("complex-block-position");
|
|
12614
12614
|
class EditorComplexBlockPosition {
|
|
12615
12615
|
constructor(block, childContainerId, custom) {
|
|
12616
12616
|
__publicField(this, "blockId");
|
|
@@ -12619,7 +12619,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12619
12619
|
if (block instanceof HTMLElement) {
|
|
12620
12620
|
this.blockId = getBlockId(block);
|
|
12621
12621
|
} else {
|
|
12622
|
-
assert(logger$
|
|
12622
|
+
assert(logger$4y, typeof block === "string", `not a valid block id: ${block}`);
|
|
12623
12623
|
this.blockId = block;
|
|
12624
12624
|
}
|
|
12625
12625
|
this.childContainerId = childContainerId;
|
|
@@ -12631,7 +12631,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12631
12631
|
return false;
|
|
12632
12632
|
}
|
|
12633
12633
|
}
|
|
12634
|
-
const logger$
|
|
12634
|
+
const logger$4x = getLogger("simple-block-position");
|
|
12635
12635
|
class EditorSimpleBlockPosition {
|
|
12636
12636
|
constructor(block, offset, type) {
|
|
12637
12637
|
__publicField(this, "blockId");
|
|
@@ -12640,7 +12640,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12640
12640
|
if (block instanceof HTMLElement) {
|
|
12641
12641
|
this.blockId = getBlockId(block);
|
|
12642
12642
|
} else {
|
|
12643
|
-
assert(logger$
|
|
12643
|
+
assert(logger$4x, typeof block === "string", `not a valid block id: ${block}`);
|
|
12644
12644
|
this.blockId = block;
|
|
12645
12645
|
}
|
|
12646
12646
|
this.offset = offset;
|
|
@@ -12650,7 +12650,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12650
12650
|
return true;
|
|
12651
12651
|
}
|
|
12652
12652
|
}
|
|
12653
|
-
const logger$
|
|
12653
|
+
const logger$4w = getLogger("editor-position");
|
|
12654
12654
|
function createSimpleBlockPosition(block, offset, type) {
|
|
12655
12655
|
return new EditorSimpleBlockPosition(block, offset, type);
|
|
12656
12656
|
}
|
|
@@ -12672,7 +12672,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12672
12672
|
}
|
|
12673
12673
|
const block1 = editor.getBlockById(pos1.blockId);
|
|
12674
12674
|
const block2 = editor.getBlockById(pos2.blockId);
|
|
12675
|
-
assert(logger$
|
|
12675
|
+
assert(logger$4w, block1 !== block2, "comparePosition: blocks are the same");
|
|
12676
12676
|
return compareElement(block1, block2);
|
|
12677
12677
|
}
|
|
12678
12678
|
if (isComplexBlockPosition(pos1) && isComplexBlockPosition(pos2)) {
|
|
@@ -12683,13 +12683,13 @@ var __publicField = (obj, key, value) => {
|
|
|
12683
12683
|
}
|
|
12684
12684
|
const container1 = editor.getContainerById(p1.childContainerId);
|
|
12685
12685
|
const container2 = editor.getContainerById(p2.childContainerId);
|
|
12686
|
-
assert(logger$
|
|
12686
|
+
assert(logger$4w, container1 !== container2, "comparePosition: containers are the same");
|
|
12687
12687
|
return compareElement(container1, container2);
|
|
12688
12688
|
}
|
|
12689
|
-
assert(logger$
|
|
12689
|
+
assert(logger$4w, false, "invalid ");
|
|
12690
12690
|
return 0;
|
|
12691
12691
|
}
|
|
12692
|
-
const logger$
|
|
12692
|
+
const logger$4v = getLogger("simple-range");
|
|
12693
12693
|
class EditorSimpleSelectionRange {
|
|
12694
12694
|
constructor(editor, options) {
|
|
12695
12695
|
__publicField(this, "editor");
|
|
@@ -12738,11 +12738,11 @@ var __publicField = (obj, key, value) => {
|
|
|
12738
12738
|
const { editor } = this;
|
|
12739
12739
|
const startBlock = editor.getBlockById(this.start.blockId);
|
|
12740
12740
|
const endBlock = editor.getBlockById(this.end.blockId);
|
|
12741
|
-
assert(logger$
|
|
12742
|
-
assert(logger$
|
|
12741
|
+
assert(logger$4v, startBlock, "no start block");
|
|
12742
|
+
assert(logger$4v, endBlock, "no end block");
|
|
12743
12743
|
const startContainer = getParentContainer(startBlock);
|
|
12744
12744
|
const endContainer = getParentContainer(endBlock);
|
|
12745
|
-
assert(logger$
|
|
12745
|
+
assert(logger$4v, startContainer === endContainer, "invalid range");
|
|
12746
12746
|
const ret = [];
|
|
12747
12747
|
if (startBlock === endBlock) {
|
|
12748
12748
|
ret.push({
|
|
@@ -12753,7 +12753,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12753
12753
|
} else {
|
|
12754
12754
|
const startIndex = getBlockIndex(startBlock);
|
|
12755
12755
|
const endIndex = getBlockIndex(endBlock);
|
|
12756
|
-
assert(logger$
|
|
12756
|
+
assert(logger$4v, startIndex < endIndex, "invalid range, start > index");
|
|
12757
12757
|
ret.push({
|
|
12758
12758
|
block: startBlock,
|
|
12759
12759
|
start: this.start,
|
|
@@ -12853,7 +12853,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12853
12853
|
clearSelection: clearSelection$6,
|
|
12854
12854
|
convertTo: convertTo$m
|
|
12855
12855
|
};
|
|
12856
|
-
const logger$
|
|
12856
|
+
const logger$4u = getLogger("editor-blocks");
|
|
12857
12857
|
class EditorBlocks {
|
|
12858
12858
|
constructor(editor) {
|
|
12859
12859
|
__publicField(this, "blocks", /* @__PURE__ */ new Map());
|
|
@@ -12862,12 +12862,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12862
12862
|
registerBlockClass(blockClass) {
|
|
12863
12863
|
const type = blockClass.blockType;
|
|
12864
12864
|
const exists = this.blocks.get(type);
|
|
12865
|
-
assert(logger$
|
|
12865
|
+
assert(logger$4u, !exists, `duplicated block type: ${type}`);
|
|
12866
12866
|
this.blocks.set(type, blockClass);
|
|
12867
12867
|
}
|
|
12868
12868
|
getBlockClass(type) {
|
|
12869
12869
|
const exists = this.blocks.get(type);
|
|
12870
|
-
assert(logger$
|
|
12870
|
+
assert(logger$4u, exists, `unknown block type: ${type}`);
|
|
12871
12871
|
return exists;
|
|
12872
12872
|
}
|
|
12873
12873
|
hasBlock(type) {
|
|
@@ -12883,7 +12883,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12883
12883
|
}
|
|
12884
12884
|
const content = blockClass.createBlockContent(this.editor, path, container, blockElement, block);
|
|
12885
12885
|
if (content.parentElement !== blockElement) {
|
|
12886
|
-
logger$
|
|
12886
|
+
logger$4u.warn("content parent is not block");
|
|
12887
12887
|
blockElement.appendChild(content);
|
|
12888
12888
|
}
|
|
12889
12889
|
this.editor.blockHooks.forEach((hook) => {
|
|
@@ -12904,7 +12904,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12904
12904
|
return newBlock;
|
|
12905
12905
|
}
|
|
12906
12906
|
}
|
|
12907
|
-
const logger$
|
|
12907
|
+
const logger$4t = getLogger("editor-embeds");
|
|
12908
12908
|
class EditorEmbeds {
|
|
12909
12909
|
constructor(editor) {
|
|
12910
12910
|
__publicField(this, "objects", /* @__PURE__ */ new Map());
|
|
@@ -12913,12 +12913,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12913
12913
|
registerEmbedClass(embedClass) {
|
|
12914
12914
|
const type = embedClass.embedType;
|
|
12915
12915
|
const exists = this.objects.get(type);
|
|
12916
|
-
assert(logger$
|
|
12916
|
+
assert(logger$4t, !exists, `duplicated embed object type: ${type}`);
|
|
12917
12917
|
this.objects.set(type, embedClass);
|
|
12918
12918
|
}
|
|
12919
12919
|
getEmbedClass(type) {
|
|
12920
12920
|
const exists = this.objects.get(type);
|
|
12921
|
-
assert(logger$
|
|
12921
|
+
assert(logger$4t, exists, `unknown embed type: ${type}`);
|
|
12922
12922
|
return exists;
|
|
12923
12923
|
}
|
|
12924
12924
|
getEmbedClassFromBlock(block) {
|
|
@@ -12928,12 +12928,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12928
12928
|
this.objects.forEach(callback);
|
|
12929
12929
|
}
|
|
12930
12930
|
}
|
|
12931
|
-
const logger$
|
|
12931
|
+
const logger$4s = getLogger("embed-block");
|
|
12932
12932
|
function createBlockContent$6(editor, path, container, blockElement, blockData) {
|
|
12933
12933
|
const content = createBlockContentElement(blockElement, "div");
|
|
12934
|
-
assert(logger$
|
|
12934
|
+
assert(logger$4s, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
|
|
12935
12935
|
const embedBlockData = blockData;
|
|
12936
|
-
assert(logger$
|
|
12936
|
+
assert(logger$4s, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
|
|
12937
12937
|
const embedClass = editor.editorEmbeds.getEmbedClass(embedBlockData.embedType);
|
|
12938
12938
|
embedClass.createEmbedContent(editor, content, embedBlockData, path, container, blockElement);
|
|
12939
12939
|
blockElement.setAttribute("data-embed-type", embedBlockData.embedType);
|
|
@@ -12961,7 +12961,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12961
12961
|
function getCaretRect$4(block, pos) {
|
|
12962
12962
|
const content = getBlockContent(block);
|
|
12963
12963
|
const rect = content.getBoundingClientRect();
|
|
12964
|
-
assert(logger$
|
|
12964
|
+
assert(logger$4s, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
|
|
12965
12965
|
if (pos.offset === 1) {
|
|
12966
12966
|
return new DOMRect(rect.right, rect.top, 0, rect.height);
|
|
12967
12967
|
}
|
|
@@ -13101,18 +13101,18 @@ var __publicField = (obj, key, value) => {
|
|
|
13101
13101
|
toStandardDoc: toStandardDoc$2,
|
|
13102
13102
|
getResources: getResources$2
|
|
13103
13103
|
};
|
|
13104
|
-
const logger$
|
|
13104
|
+
const logger$4r = getLogger("complex-block-helper");
|
|
13105
13105
|
function complexBlockGetAllChildContainers(editor, block, options) {
|
|
13106
13106
|
const blockClass = getComplexBlockClass(editor, block);
|
|
13107
13107
|
return blockClass.getChildContainers(editor, block, options);
|
|
13108
13108
|
}
|
|
13109
13109
|
function complexBlockGetSelectedContainers(editor, block, start, end) {
|
|
13110
13110
|
if (start.isSimple()) {
|
|
13111
|
-
assert(logger$
|
|
13111
|
+
assert(logger$4r, end.isSimple(), "invalid start and end position");
|
|
13112
13112
|
return complexBlockGetAllChildContainers(editor, block);
|
|
13113
13113
|
}
|
|
13114
|
-
assert(logger$
|
|
13115
|
-
assert(logger$
|
|
13114
|
+
assert(logger$4r, !start.isSimple(), "invalid start pos");
|
|
13115
|
+
assert(logger$4r, !end.isSimple(), "invalid end pos");
|
|
13116
13116
|
const blockClass = getComplexBlockClass(editor, block);
|
|
13117
13117
|
return blockClass.getSelectedContainers(editor, block, start, end);
|
|
13118
13118
|
}
|
|
@@ -13123,11 +13123,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13123
13123
|
const parentComplexBlock = getParentBlock(getParentContainer(childBlock));
|
|
13124
13124
|
if (!parentComplexBlock)
|
|
13125
13125
|
return false;
|
|
13126
|
-
assert(logger$
|
|
13126
|
+
assert(logger$4r, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
|
|
13127
13127
|
const childContainer = getParentContainer(childBlock);
|
|
13128
13128
|
const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
|
|
13129
13129
|
const index2 = childContainers.indexOf(childContainer);
|
|
13130
|
-
assert(logger$
|
|
13130
|
+
assert(logger$4r, index2 >= 0, "not valid child container");
|
|
13131
13131
|
return index2 === 0;
|
|
13132
13132
|
}
|
|
13133
13133
|
function complexBlockGetFirstSimpleChild(editor, complexBlock, options) {
|
|
@@ -13180,13 +13180,13 @@ var __publicField = (obj, key, value) => {
|
|
|
13180
13180
|
return block;
|
|
13181
13181
|
}
|
|
13182
13182
|
function findPrevSimpleBlockBeforeChildContainer(editor, childContainer, options) {
|
|
13183
|
-
assert(logger$
|
|
13183
|
+
assert(logger$4r, isChildContainer(childContainer), "not a child container");
|
|
13184
13184
|
const parentComplexBlock = getParentBlock(childContainer);
|
|
13185
|
-
assert(logger$
|
|
13186
|
-
assert(logger$
|
|
13185
|
+
assert(logger$4r, parentComplexBlock, "no parent block");
|
|
13186
|
+
assert(logger$4r, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
|
|
13187
13187
|
const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock, options);
|
|
13188
13188
|
const containerIndex = childContainers.indexOf(childContainer);
|
|
13189
|
-
assert(logger$
|
|
13189
|
+
assert(logger$4r, containerIndex !== -1, "child container not found");
|
|
13190
13190
|
if (containerIndex === 0) {
|
|
13191
13191
|
const prevBlock = getPrevBlock(parentComplexBlock);
|
|
13192
13192
|
if (!prevBlock)
|
|
@@ -13204,9 +13204,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13204
13204
|
return lastBlock2;
|
|
13205
13205
|
}
|
|
13206
13206
|
function complexBlockGetTopChildContainers(editor, complexBlock) {
|
|
13207
|
-
assert(logger$
|
|
13207
|
+
assert(logger$4r, isComplexKindBlock(editor, complexBlock), "not a complex block");
|
|
13208
13208
|
const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
|
|
13209
|
-
assert(logger$
|
|
13209
|
+
assert(logger$4r, childContainers.length > 0, "no child container");
|
|
13210
13210
|
if (childContainers.length === 1) {
|
|
13211
13211
|
return childContainers;
|
|
13212
13212
|
}
|
|
@@ -13231,9 +13231,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13231
13231
|
return ret;
|
|
13232
13232
|
}
|
|
13233
13233
|
function complexBlockGetBottomChildContainers(editor, complexBlock) {
|
|
13234
|
-
assert(logger$
|
|
13234
|
+
assert(logger$4r, isComplexKindBlock(editor, complexBlock), "not a complex block");
|
|
13235
13235
|
const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
|
|
13236
|
-
assert(logger$
|
|
13236
|
+
assert(logger$4r, childContainers.length > 0, "no child container");
|
|
13237
13237
|
if (childContainers.length === 1) {
|
|
13238
13238
|
return childContainers;
|
|
13239
13239
|
}
|
|
@@ -13338,11 +13338,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13338
13338
|
return result;
|
|
13339
13339
|
}
|
|
13340
13340
|
const anchor = "";
|
|
13341
|
-
const logger$
|
|
13341
|
+
const logger$4q = getLogger("text-range");
|
|
13342
13342
|
function getBlockRangeInfo(block, blockOffset) {
|
|
13343
13343
|
const getChildRange = (child, offset) => {
|
|
13344
13344
|
if (isTextBlockContentInsertionChild(child)) {
|
|
13345
|
-
assert(logger$
|
|
13345
|
+
assert(logger$4q, offset === 0, `invalid offset for insertion child: ${offset}`);
|
|
13346
13346
|
const childOffset = 2;
|
|
13347
13347
|
return {
|
|
13348
13348
|
child,
|
|
@@ -13351,7 +13351,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13351
13351
|
};
|
|
13352
13352
|
}
|
|
13353
13353
|
if (isTextBlockContentBoxChild(child)) {
|
|
13354
|
-
assert(logger$
|
|
13354
|
+
assert(logger$4q, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
|
|
13355
13355
|
const childOffset = offset === 0 ? 1 : 2;
|
|
13356
13356
|
return {
|
|
13357
13357
|
child,
|
|
@@ -13360,17 +13360,17 @@ var __publicField = (obj, key, value) => {
|
|
|
13360
13360
|
};
|
|
13361
13361
|
}
|
|
13362
13362
|
const textNode = child.firstChild;
|
|
13363
|
-
assert(logger$
|
|
13364
|
-
assert(logger$
|
|
13363
|
+
assert(logger$4q, textNode, "no child node for text child");
|
|
13364
|
+
assert(logger$4q, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
|
|
13365
13365
|
if (textNode instanceof HTMLBRElement) {
|
|
13366
|
-
assert(logger$
|
|
13366
|
+
assert(logger$4q, offset >= 0 && offset <= 0, "invalid offset for text child");
|
|
13367
13367
|
return {
|
|
13368
13368
|
child,
|
|
13369
13369
|
container: textNode,
|
|
13370
13370
|
offset
|
|
13371
13371
|
};
|
|
13372
13372
|
}
|
|
13373
|
-
assert(logger$
|
|
13373
|
+
assert(logger$4q, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
|
|
13374
13374
|
return {
|
|
13375
13375
|
child,
|
|
13376
13376
|
container: textNode,
|
|
@@ -13399,38 +13399,38 @@ var __publicField = (obj, key, value) => {
|
|
|
13399
13399
|
}
|
|
13400
13400
|
start += childLength;
|
|
13401
13401
|
}
|
|
13402
|
-
assert(logger$
|
|
13402
|
+
assert(logger$4q, false, "failed to get range info");
|
|
13403
13403
|
}
|
|
13404
13404
|
function createChildRange(child, start, end) {
|
|
13405
13405
|
if (start === end) {
|
|
13406
|
-
assert(logger$
|
|
13406
|
+
assert(logger$4q, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
|
|
13407
13407
|
} else {
|
|
13408
|
-
assert(logger$
|
|
13408
|
+
assert(logger$4q, start < end, `invalid start & end: ${start}, ${end}`);
|
|
13409
13409
|
}
|
|
13410
13410
|
if (isTextBlockContentInsertionChild(child)) {
|
|
13411
|
-
assert(logger$
|
|
13412
|
-
assert(logger$
|
|
13411
|
+
assert(logger$4q, start === end, `invalid insertion child range offset: ${start}, ${end}`);
|
|
13412
|
+
assert(logger$4q, start === 0, `invalid insertion child range start: ${start}`);
|
|
13413
13413
|
const insertionElem = child;
|
|
13414
|
-
assert(logger$
|
|
13414
|
+
assert(logger$4q, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
|
|
13415
13415
|
const range = createExpandedRange(insertionElem, 1, insertionElem, 2);
|
|
13416
13416
|
return range;
|
|
13417
13417
|
}
|
|
13418
13418
|
if (isTextBlockContentBoxChild(child)) {
|
|
13419
|
-
assert(logger$
|
|
13420
|
-
assert(logger$
|
|
13419
|
+
assert(logger$4q, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
|
|
13420
|
+
assert(logger$4q, start === 0, `invalid box child range start: ${start}`);
|
|
13421
13421
|
const box = child;
|
|
13422
|
-
assert(logger$
|
|
13422
|
+
assert(logger$4q, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
|
|
13423
13423
|
const range = createExpandedRange(box, 1, box, 2);
|
|
13424
13424
|
return range;
|
|
13425
13425
|
}
|
|
13426
13426
|
const length = getTextBlockContentChildTextLength(child);
|
|
13427
|
-
assert(logger$
|
|
13427
|
+
assert(logger$4q, end <= length, `invalid child end: ${end}, ${length}`);
|
|
13428
13428
|
const textNode = child.firstChild;
|
|
13429
|
-
assert(logger$
|
|
13430
|
-
assert(logger$
|
|
13429
|
+
assert(logger$4q, textNode instanceof Text, "invalid block text child");
|
|
13430
|
+
assert(logger$4q, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
|
|
13431
13431
|
return createExpandedRange(textNode, start, textNode, end);
|
|
13432
13432
|
}
|
|
13433
|
-
const logger$
|
|
13433
|
+
const logger$4p = getLogger("caret-rect");
|
|
13434
13434
|
function getChildClientRects(block, child) {
|
|
13435
13435
|
if (isBox(child)) {
|
|
13436
13436
|
const box = child;
|
|
@@ -13439,7 +13439,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13439
13439
|
const blockContent = getBlockContent(block);
|
|
13440
13440
|
const lineHeight = Number.parseFloat(window.getComputedStyle(blockContent).lineHeight) || boxContent.getBoundingClientRect().height;
|
|
13441
13441
|
const rects = Array.from(boxContent.getClientRects());
|
|
13442
|
-
assert(logger$
|
|
13442
|
+
assert(logger$4p, rects.length > 0, "no box client rects");
|
|
13443
13443
|
const blockRect = blockContent.getBoundingClientRect();
|
|
13444
13444
|
const firstRect = rects[0];
|
|
13445
13445
|
const lastRect = new DOMRect(blockRect.left, firstRect.bottom, 1, lineHeight);
|
|
@@ -13459,22 +13459,22 @@ var __publicField = (obj, key, value) => {
|
|
|
13459
13459
|
const rect2 = getLastClientRect(ranges[0].child);
|
|
13460
13460
|
return new DOMRect(rect2.right, rect2.top, 1, rect2.height);
|
|
13461
13461
|
}
|
|
13462
|
-
assert(logger$
|
|
13462
|
+
assert(logger$4p, ranges[1], "invalid ranges");
|
|
13463
13463
|
const rect = getFirstClientRect(ranges[1].child);
|
|
13464
13464
|
return new DOMRect(rect.left, rect.top, 1, rect.height);
|
|
13465
13465
|
}
|
|
13466
13466
|
let rangeInfo = ranges[0];
|
|
13467
|
-
assert(logger$
|
|
13467
|
+
assert(logger$4p, ranges.length >= 1, "failed to get block range");
|
|
13468
13468
|
if (ranges.length === 1) {
|
|
13469
13469
|
rangeInfo = ranges[0];
|
|
13470
13470
|
} else {
|
|
13471
|
-
assert(logger$
|
|
13471
|
+
assert(logger$4p, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
|
|
13472
13472
|
if (isTextBlockContentInsertionChild(ranges[ranges.length - 1].child)) {
|
|
13473
13473
|
rangeInfo = ranges[ranges.length - 1];
|
|
13474
13474
|
const child = rangeInfo.child;
|
|
13475
13475
|
const content = getInsertionContent(child);
|
|
13476
13476
|
const rects2 = content.getClientRects();
|
|
13477
|
-
assert(logger$
|
|
13477
|
+
assert(logger$4p, rects2.length >= 1, "no client rects for box content");
|
|
13478
13478
|
const rect = rects2[rects2.length - 1];
|
|
13479
13479
|
return new DOMRect(rect.right, rect.y, 1, rect.height);
|
|
13480
13480
|
}
|
|
@@ -13491,9 +13491,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13491
13491
|
}
|
|
13492
13492
|
}
|
|
13493
13493
|
if (rangeInfo.container instanceof HTMLBRElement) {
|
|
13494
|
-
assert(logger$
|
|
13494
|
+
assert(logger$4p, pos.offset === 0, "invalid offset for empty block text");
|
|
13495
13495
|
const parent = rangeInfo.container.parentElement;
|
|
13496
|
-
assert(logger$
|
|
13496
|
+
assert(logger$4p, parent, "invalid br parent");
|
|
13497
13497
|
const rect = parent.getBoundingClientRect();
|
|
13498
13498
|
const ret = new DOMRect(rect.left, rect.top, 1, rect.height);
|
|
13499
13499
|
return ret;
|
|
@@ -13501,11 +13501,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13501
13501
|
const range = createRange(rangeInfo.container, rangeInfo.offset);
|
|
13502
13502
|
const rects = Array.from(range.getClientRects());
|
|
13503
13503
|
if (rects.length === 0) {
|
|
13504
|
-
assert(logger$
|
|
13505
|
-
assert(logger$
|
|
13504
|
+
assert(logger$4p, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
|
|
13505
|
+
assert(logger$4p, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
|
|
13506
13506
|
const child = rangeInfo.child;
|
|
13507
13507
|
const rects2 = getChildClientRects(block, child);
|
|
13508
|
-
assert(logger$
|
|
13508
|
+
assert(logger$4p, rects2.length >= 1, "no client rects for box content");
|
|
13509
13509
|
if (rangeInfo.offset === 1) {
|
|
13510
13510
|
const rect2 = rects2[0];
|
|
13511
13511
|
return new DOMRect(rect2.x, rect2.y, 1, rect2.height);
|
|
@@ -13551,7 +13551,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13551
13551
|
});
|
|
13552
13552
|
}
|
|
13553
13553
|
}
|
|
13554
|
-
assert(logger$
|
|
13554
|
+
assert(logger$4p, rects.length > 0, "no client rects for range");
|
|
13555
13555
|
if (pos.type === "home") {
|
|
13556
13556
|
return rects[rects.length - 1];
|
|
13557
13557
|
}
|
|
@@ -13631,13 +13631,13 @@ var __publicField = (obj, key, value) => {
|
|
|
13631
13631
|
};
|
|
13632
13632
|
}
|
|
13633
13633
|
}
|
|
13634
|
-
const logger$
|
|
13634
|
+
const logger$4o = getLogger("selection-range");
|
|
13635
13635
|
function createEditorSelectionRange(editor, options) {
|
|
13636
13636
|
const { anchor: anchor2, focus } = options;
|
|
13637
13637
|
if (anchor2 instanceof EditorSimpleBlockPosition && focus instanceof EditorSimpleBlockPosition) {
|
|
13638
13638
|
return new EditorSimpleSelectionRange(editor, { anchor: anchor2, focus });
|
|
13639
13639
|
}
|
|
13640
|
-
assert(logger$
|
|
13640
|
+
assert(logger$4o, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
|
|
13641
13641
|
return new EditorComplexSelectionRange(editor, { anchor: anchor2, focus });
|
|
13642
13642
|
}
|
|
13643
13643
|
function createBlockSimpleRange(editor, block, anchor2, focus) {
|
|
@@ -13659,7 +13659,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13659
13659
|
const focus = createSimpleBlockPosition(range.focus.blockId, range.focus.offset, "normal");
|
|
13660
13660
|
return createEditorSelectionRange(editor, { anchor: anchor2, focus });
|
|
13661
13661
|
}
|
|
13662
|
-
const logger$
|
|
13662
|
+
const logger$4n = getLogger("range-from-point");
|
|
13663
13663
|
function getBlockRangeFromPoint(editor, pointX, pointY, dragging) {
|
|
13664
13664
|
const yOffsets = [0, -12, 12];
|
|
13665
13665
|
let x = pointX;
|
|
@@ -13691,7 +13691,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13691
13691
|
const rect = elem.getBoundingClientRect();
|
|
13692
13692
|
if (rect.width && rect.top && i === 0) {
|
|
13693
13693
|
if (rect.left + rect.width < x || rect.top + rect.height < y) {
|
|
13694
|
-
logger$
|
|
13694
|
+
logger$4n.debug("click on scrollbar, out of element rect");
|
|
13695
13695
|
return null;
|
|
13696
13696
|
}
|
|
13697
13697
|
}
|
|
@@ -13729,7 +13729,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13729
13729
|
let block = getLastChildBlock(container);
|
|
13730
13730
|
if (!isVisibleBlock(block)) {
|
|
13731
13731
|
const preBlock = getPrevVisibleBlock(block);
|
|
13732
|
-
assert(logger$
|
|
13732
|
+
assert(logger$4n, preBlock, "container must have visible block");
|
|
13733
13733
|
block = preBlock;
|
|
13734
13734
|
}
|
|
13735
13735
|
const range = getBlockClass(editor, block).getRangeFromPoint(editor, block, x, block.getBoundingClientRect().bottom - 4);
|
|
@@ -13748,7 +13748,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13748
13748
|
if (range instanceof EditorSimpleSelectionRange) {
|
|
13749
13749
|
return range;
|
|
13750
13750
|
}
|
|
13751
|
-
assert(logger$
|
|
13751
|
+
assert(logger$4n, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
|
|
13752
13752
|
const complexRange = range;
|
|
13753
13753
|
const container2 = editor.getContainerById(complexRange.start.childContainerId);
|
|
13754
13754
|
return getRangeInContainer(editor, container2, x, y);
|
|
@@ -13771,7 +13771,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13771
13771
|
});
|
|
13772
13772
|
return getRangeInContainer(editor, container, x, y);
|
|
13773
13773
|
}
|
|
13774
|
-
const logger$
|
|
13774
|
+
const logger$4m = getLogger("adjust-selection-pos");
|
|
13775
13775
|
function getParentContainers(block) {
|
|
13776
13776
|
const containers = [];
|
|
13777
13777
|
while (block) {
|
|
@@ -13781,10 +13781,10 @@ var __publicField = (obj, key, value) => {
|
|
|
13781
13781
|
return containers;
|
|
13782
13782
|
}
|
|
13783
13783
|
const newBlock = getParentBlock(container);
|
|
13784
|
-
assert(logger$
|
|
13784
|
+
assert(logger$4m, newBlock, "child container has not parent container");
|
|
13785
13785
|
block = newBlock;
|
|
13786
13786
|
}
|
|
13787
|
-
assert(logger$
|
|
13787
|
+
assert(logger$4m, false, "should not come here: getParentContainers");
|
|
13788
13788
|
}
|
|
13789
13789
|
function getParentBlockInContainer(container, block) {
|
|
13790
13790
|
while (block) {
|
|
@@ -13793,16 +13793,16 @@ var __publicField = (obj, key, value) => {
|
|
|
13793
13793
|
return block;
|
|
13794
13794
|
}
|
|
13795
13795
|
const newBlock = getParentBlock(parent);
|
|
13796
|
-
assert(logger$
|
|
13796
|
+
assert(logger$4m, newBlock, "could not find parent block for a child container");
|
|
13797
13797
|
block = newBlock;
|
|
13798
13798
|
}
|
|
13799
|
-
assert(logger$
|
|
13799
|
+
assert(logger$4m, false, "no parent block in specified container");
|
|
13800
13800
|
}
|
|
13801
13801
|
function getClosestParentBlock(block1, block2) {
|
|
13802
13802
|
const containers1 = getParentContainers(block1);
|
|
13803
13803
|
const containers2 = getParentContainers(block2);
|
|
13804
|
-
assert(logger$
|
|
13805
|
-
assert(logger$
|
|
13804
|
+
assert(logger$4m, containers1.length > 0 && containers2.length > 0, "block has not parent container");
|
|
13805
|
+
assert(logger$4m, containers1[0] === containers2[0], "root container does not equal");
|
|
13806
13806
|
let parentContainer = containers1[0];
|
|
13807
13807
|
for (let i = 1; i < containers1.length || containers2.length; i++) {
|
|
13808
13808
|
if (containers1[i] === containers2[i]) {
|
|
@@ -13821,23 +13821,23 @@ var __publicField = (obj, key, value) => {
|
|
|
13821
13821
|
}
|
|
13822
13822
|
function getParentContainerInComplexBlock(parentComplexBlock, element) {
|
|
13823
13823
|
let block = getParentBlock(element);
|
|
13824
|
-
assert(logger$
|
|
13824
|
+
assert(logger$4m, block, "element is not in a block");
|
|
13825
13825
|
while (block) {
|
|
13826
13826
|
const container = getParentContainer(block);
|
|
13827
|
-
assert(logger$
|
|
13827
|
+
assert(logger$4m, isChildContainer(container), "not a child container");
|
|
13828
13828
|
const parentBlock = getParentBlock(container);
|
|
13829
|
-
assert(logger$
|
|
13829
|
+
assert(logger$4m, parentBlock, "child container has not parent block");
|
|
13830
13830
|
if (parentBlock === parentComplexBlock) {
|
|
13831
13831
|
return container;
|
|
13832
13832
|
}
|
|
13833
13833
|
block = parentBlock;
|
|
13834
13834
|
}
|
|
13835
|
-
assert(logger$
|
|
13835
|
+
assert(logger$4m, false, "failed to find parent container in complex block");
|
|
13836
13836
|
}
|
|
13837
13837
|
function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
|
|
13838
13838
|
const blockId = getBlockId(complexBlock);
|
|
13839
|
-
assert(logger$
|
|
13840
|
-
assert(logger$
|
|
13839
|
+
assert(logger$4m, blockId === anchor2.blockId, "invalid start pos");
|
|
13840
|
+
assert(logger$4m, blockId === focus.blockId, "invalid end pos");
|
|
13841
13841
|
const blockClass = getComplexBlockClass(editor, complexBlock);
|
|
13842
13842
|
if (blockClass.adjustSelectionPos) {
|
|
13843
13843
|
return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
|
|
@@ -13871,8 +13871,8 @@ var __publicField = (obj, key, value) => {
|
|
|
13871
13871
|
if (focus instanceof EditorComplexBlockPosition) {
|
|
13872
13872
|
focus = createSimpleBlockPosition(focusBlock, getBlockTextLength$6(editor, focusBlock), "end");
|
|
13873
13873
|
}
|
|
13874
|
-
assert(logger$
|
|
13875
|
-
assert(logger$
|
|
13874
|
+
assert(logger$4m, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
|
|
13875
|
+
assert(logger$4m, focus instanceof EditorSimpleBlockPosition, "not valid position type");
|
|
13876
13876
|
return {
|
|
13877
13877
|
anchor: anchor2,
|
|
13878
13878
|
focus
|
|
@@ -13926,7 +13926,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13926
13926
|
focus
|
|
13927
13927
|
};
|
|
13928
13928
|
}
|
|
13929
|
-
const logger$
|
|
13929
|
+
const logger$4l = getLogger("core");
|
|
13930
13930
|
function createBlockAnchor(editor, block, id, refClientRect) {
|
|
13931
13931
|
const tools = getBlockTools(block);
|
|
13932
13932
|
let elem = tools.querySelector(`.block-anchor[data-id=${id}]`);
|
|
@@ -13944,7 +13944,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13944
13944
|
return elem;
|
|
13945
13945
|
}
|
|
13946
13946
|
function createBlockCaretAnchor(editor, block, offset, id) {
|
|
13947
|
-
assert(logger$
|
|
13947
|
+
assert(logger$4l, isTextKindBlock(editor, block), "not a text kind block");
|
|
13948
13948
|
const caretRect = getTextCaretRect(block, createSimpleBlockPosition(block, offset, "normal"));
|
|
13949
13949
|
const blockRect = block.getBoundingClientRect();
|
|
13950
13950
|
const tools = getBlockTools(block);
|
|
@@ -14303,19 +14303,19 @@ var __publicField = (obj, key, value) => {
|
|
|
14303
14303
|
return result + (index2 ? "-" : "") + word.toLowerCase();
|
|
14304
14304
|
});
|
|
14305
14305
|
const kebabCase$1 = kebabCase;
|
|
14306
|
-
const logger$
|
|
14306
|
+
const logger$4k = getLogger("box");
|
|
14307
14307
|
function isBoxOp(op) {
|
|
14308
14308
|
if (!op.attributes)
|
|
14309
14309
|
return false;
|
|
14310
14310
|
if (!op.attributes.box)
|
|
14311
14311
|
return false;
|
|
14312
|
-
assert(logger$
|
|
14313
|
-
assert(logger$
|
|
14312
|
+
assert(logger$4k, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
|
|
14313
|
+
assert(logger$4k, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
|
|
14314
14314
|
return true;
|
|
14315
14315
|
}
|
|
14316
|
-
const logger$
|
|
14316
|
+
const logger$4j = getLogger("text-op");
|
|
14317
14317
|
function getOpLength(op) {
|
|
14318
|
-
assert(logger$
|
|
14318
|
+
assert(logger$4j, typeof op.insert === "string", "invalid op, no insert");
|
|
14319
14319
|
return op.insert.length;
|
|
14320
14320
|
}
|
|
14321
14321
|
function getOpAt(text2, offset) {
|
|
@@ -14323,7 +14323,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14323
14323
|
let pos = 0;
|
|
14324
14324
|
for (let i = 0; i < ops.length; i++) {
|
|
14325
14325
|
const op = ops[i];
|
|
14326
|
-
assert(logger$
|
|
14326
|
+
assert(logger$4j, typeof op.insert === "string", "invalid text op, no insert");
|
|
14327
14327
|
const end = pos + getOpLength(op);
|
|
14328
14328
|
if (end > offset) {
|
|
14329
14329
|
return [op];
|
|
@@ -14339,22 +14339,22 @@ var __publicField = (obj, key, value) => {
|
|
|
14339
14339
|
}
|
|
14340
14340
|
return [];
|
|
14341
14341
|
}
|
|
14342
|
-
const logger$
|
|
14342
|
+
const logger$4i = getLogger("rich-text-length");
|
|
14343
14343
|
function getTextOpLength(op) {
|
|
14344
|
-
assert(logger$
|
|
14344
|
+
assert(logger$4i, typeof op.insert === "string", "op.insert is not string");
|
|
14345
14345
|
return op.insert.length;
|
|
14346
14346
|
}
|
|
14347
14347
|
function getTextLength(ops) {
|
|
14348
14348
|
let count = 0;
|
|
14349
14349
|
ops.forEach((op) => {
|
|
14350
14350
|
if (op.insert) {
|
|
14351
|
-
assert(logger$
|
|
14351
|
+
assert(logger$4i, typeof op.insert === "string", "op.insert is not string");
|
|
14352
14352
|
count += getTextOpLength(op);
|
|
14353
14353
|
}
|
|
14354
14354
|
});
|
|
14355
14355
|
return count;
|
|
14356
14356
|
}
|
|
14357
|
-
const logger$
|
|
14357
|
+
const logger$4h = getLogger("split-text");
|
|
14358
14358
|
function splitText(ops, offset, splitResult) {
|
|
14359
14359
|
ops = cloneDeep__default.default(ops);
|
|
14360
14360
|
if (offset === 0) {
|
|
@@ -14372,8 +14372,8 @@ var __publicField = (obj, key, value) => {
|
|
|
14372
14372
|
let counted = 0;
|
|
14373
14373
|
for (let i = 0; i < ops.length; i++) {
|
|
14374
14374
|
const op = ops[i];
|
|
14375
|
-
assert(logger$
|
|
14376
|
-
assert(logger$
|
|
14375
|
+
assert(logger$4h, typeof op === "object", `invalid op type, ${typeof op}`);
|
|
14376
|
+
assert(logger$4h, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
|
|
14377
14377
|
const subLen = getTextOpLength(op);
|
|
14378
14378
|
if (counted + subLen < offset) {
|
|
14379
14379
|
counted += subLen;
|
|
@@ -14383,18 +14383,18 @@ var __publicField = (obj, key, value) => {
|
|
|
14383
14383
|
right: ops.slice(i + 1)
|
|
14384
14384
|
};
|
|
14385
14385
|
} else {
|
|
14386
|
-
assert(logger$
|
|
14386
|
+
assert(logger$4h, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
|
|
14387
14387
|
const splitIndex = offset - counted;
|
|
14388
14388
|
const copied = cloneDeep__default.default(op);
|
|
14389
|
-
assert(logger$
|
|
14390
|
-
assert(logger$
|
|
14389
|
+
assert(logger$4h, copied.insert, "no copied.insert");
|
|
14390
|
+
assert(logger$4h, typeof copied.insert === "string", "invalid copied.insert type");
|
|
14391
14391
|
copied.insert = copied.insert.substr(0, splitIndex);
|
|
14392
14392
|
op.insert = op.insert.substr(splitIndex);
|
|
14393
14393
|
if (copied.insert === "") {
|
|
14394
|
-
assert(logger$
|
|
14394
|
+
assert(logger$4h, false, "invalid copied.insert, is empty string");
|
|
14395
14395
|
}
|
|
14396
14396
|
if (op.insert === "") {
|
|
14397
|
-
assert(logger$
|
|
14397
|
+
assert(logger$4h, false, "invalid op.insert, is empty string");
|
|
14398
14398
|
}
|
|
14399
14399
|
const right = [
|
|
14400
14400
|
op,
|
|
@@ -14413,9 +14413,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14413
14413
|
throw new Error(`invalid split offset: ${offset}, ${JSON.stringify(ops)}`);
|
|
14414
14414
|
}
|
|
14415
14415
|
function splitToThree(text2, offset, length) {
|
|
14416
|
-
assert(logger$
|
|
14417
|
-
assert(logger$
|
|
14418
|
-
assert(logger$
|
|
14416
|
+
assert(logger$4h, offset >= 0, "invalid offset, < 0");
|
|
14417
|
+
assert(logger$4h, length > 0, "invalid length, <= 0");
|
|
14418
|
+
assert(logger$4h, offset + length <= getTextLength(text2), "invalid offset + length < text length");
|
|
14419
14419
|
const { left: temp, right } = splitText(text2, offset + length);
|
|
14420
14420
|
const { left, right: middle } = splitText(temp, offset);
|
|
14421
14421
|
return { left, middle, right };
|
|
@@ -14638,9 +14638,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14638
14638
|
}
|
|
14639
14639
|
return [color, backgroundColor];
|
|
14640
14640
|
}
|
|
14641
|
-
const logger$
|
|
14641
|
+
const logger$4g = getLogger("text-block-content");
|
|
14642
14642
|
function updateBlockContentCore(editor, blockPath, content, blockText, insertions) {
|
|
14643
|
-
assert(logger$
|
|
14643
|
+
assert(logger$4g, blockText, "no text for block");
|
|
14644
14644
|
if (blockText.length === 0 && (!insertions || insertions.size === 0)) {
|
|
14645
14645
|
content.innerHTML = "<span><br></span>";
|
|
14646
14646
|
return;
|
|
@@ -14672,9 +14672,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14672
14672
|
for (let i2 = 0; i2 < text2.length; i2++) {
|
|
14673
14673
|
const op = text2[i2];
|
|
14674
14674
|
if (isBoxOp(op)) {
|
|
14675
|
-
assert(logger$
|
|
14675
|
+
assert(logger$4g, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
|
|
14676
14676
|
const span2 = editor.editorBoxes.createBox(content, op.attributes);
|
|
14677
|
-
assert(logger$
|
|
14677
|
+
assert(logger$4g, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
|
|
14678
14678
|
const ret = editor.editorBlockRenders.renderBox(blockPath, op.attributes);
|
|
14679
14679
|
if (ret.classes) {
|
|
14680
14680
|
addClass(span2, ...ret.classes);
|
|
@@ -14692,7 +14692,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14692
14692
|
fragment.appendChild(span2);
|
|
14693
14693
|
continue;
|
|
14694
14694
|
}
|
|
14695
|
-
assert(logger$
|
|
14695
|
+
assert(logger$4g, op.insert, `no insert in op: ${JSON.stringify(op)}`);
|
|
14696
14696
|
const span = createElement("span", ["text"], fragment, op.insert);
|
|
14697
14697
|
if (op.attributes) {
|
|
14698
14698
|
const ret = editor.editorBlockRenders.renderText(blockPath, op.attributes);
|
|
@@ -14723,7 +14723,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14723
14723
|
const compositionText = editor.compositingText;
|
|
14724
14724
|
if (compositionText) {
|
|
14725
14725
|
const pos = editor.selection.range.start;
|
|
14726
|
-
assert(logger$
|
|
14726
|
+
assert(logger$4g, pos.isSimple(), "not an simple position while compositing");
|
|
14727
14727
|
if (pos.blockId === blockId) {
|
|
14728
14728
|
const attributes = getAttributesAt(text2, 0);
|
|
14729
14729
|
insertions.set(pos.offset, [{
|
|
@@ -14739,11 +14739,11 @@ var __publicField = (obj, key, value) => {
|
|
|
14739
14739
|
function clearAllTempCompositionText(editor) {
|
|
14740
14740
|
const children = editor.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');
|
|
14741
14741
|
if (children.length) {
|
|
14742
|
-
logger$
|
|
14742
|
+
logger$4g.debug(`remove ${children.length} temp composition span`);
|
|
14743
14743
|
}
|
|
14744
14744
|
Array.from(children).forEach((c) => c.remove());
|
|
14745
14745
|
}
|
|
14746
|
-
const logger$
|
|
14746
|
+
const logger$4f = getLogger("client-rects");
|
|
14747
14747
|
function getChildrenOffsets(block) {
|
|
14748
14748
|
const children = getTextBlockContentChildren(block);
|
|
14749
14749
|
let start = 0;
|
|
@@ -14761,15 +14761,15 @@ var __publicField = (obj, key, value) => {
|
|
|
14761
14761
|
return ret;
|
|
14762
14762
|
}
|
|
14763
14763
|
function getChildrenInRange(editor, block, from, to) {
|
|
14764
|
-
assert(logger$
|
|
14764
|
+
assert(logger$4f, from < to, `invalid from & to: ${from}, ${to}`);
|
|
14765
14765
|
const blockLength = getBlockTextLength$6(editor, block);
|
|
14766
|
-
assert(logger$
|
|
14766
|
+
assert(logger$4f, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
|
|
14767
14767
|
const offsets = getChildrenOffsets(block);
|
|
14768
14768
|
const startIndex = offsets.findIndex((c) => c.startBlockOffset <= from && from < c.endBlockOffset);
|
|
14769
14769
|
const endIndex = offsets.findIndex((c) => c.startBlockOffset < to && to <= c.endBlockOffset);
|
|
14770
|
-
assert(logger$
|
|
14771
|
-
assert(logger$
|
|
14772
|
-
assert(logger$
|
|
14770
|
+
assert(logger$4f, startIndex !== -1, "failed to find start child");
|
|
14771
|
+
assert(logger$4f, endIndex !== -1, "failed to find end child");
|
|
14772
|
+
assert(logger$4f, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
|
|
14773
14773
|
if (startIndex === endIndex) {
|
|
14774
14774
|
const child = offsets[startIndex];
|
|
14775
14775
|
return [{
|
|
@@ -14851,16 +14851,16 @@ var __publicField = (obj, key, value) => {
|
|
|
14851
14851
|
return rects;
|
|
14852
14852
|
}
|
|
14853
14853
|
function getRangeClientRects(editor, block, range) {
|
|
14854
|
-
assert(logger$
|
|
14854
|
+
assert(logger$4f, range instanceof EditorSimpleSelectionRange, "invalid range");
|
|
14855
14855
|
const start = range.start;
|
|
14856
14856
|
const end = range.end;
|
|
14857
|
-
assert(logger$
|
|
14858
|
-
assert(logger$
|
|
14859
|
-
assert(logger$
|
|
14860
|
-
assert(logger$
|
|
14857
|
+
assert(logger$4f, start.isSimple(), "text block only allow simple position");
|
|
14858
|
+
assert(logger$4f, end.isSimple(), "text block only allow simple position");
|
|
14859
|
+
assert(logger$4f, start.blockId === end.blockId, "only allow update one text block selection");
|
|
14860
|
+
assert(logger$4f, start.blockId === getBlockId(block), "only allow update one text block selection");
|
|
14861
14861
|
return getClientRects$2(editor, block, start, end);
|
|
14862
14862
|
}
|
|
14863
|
-
const logger$
|
|
14863
|
+
const logger$4e = getLogger("selection-background");
|
|
14864
14864
|
function getLineHeight(elem) {
|
|
14865
14865
|
const style2 = window.getComputedStyle(elem);
|
|
14866
14866
|
const lineHeightStyle = style2.getPropertyValue("line-height");
|
|
@@ -14880,9 +14880,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14880
14880
|
return lineHeight;
|
|
14881
14881
|
}
|
|
14882
14882
|
function updateSelection$4(editor, block, start, end) {
|
|
14883
|
-
assert(logger$
|
|
14884
|
-
assert(logger$
|
|
14885
|
-
assert(logger$
|
|
14883
|
+
assert(logger$4e, start.isSimple(), "text block only allow simple position");
|
|
14884
|
+
assert(logger$4e, end.isSimple(), "text block only allow simple position");
|
|
14885
|
+
assert(logger$4e, start.blockId === end.blockId, "only allow update one text block selection");
|
|
14886
14886
|
const from = start.offset;
|
|
14887
14887
|
const to = end.offset;
|
|
14888
14888
|
if (from === to) {
|
|
@@ -14941,7 +14941,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14941
14941
|
}
|
|
14942
14942
|
});
|
|
14943
14943
|
}
|
|
14944
|
-
const logger$
|
|
14944
|
+
const logger$4d = getLogger("line-breaker");
|
|
14945
14945
|
function mergeTextRects(rects) {
|
|
14946
14946
|
const result = [];
|
|
14947
14947
|
let lastRect = null;
|
|
@@ -15068,7 +15068,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15068
15068
|
}
|
|
15069
15069
|
const textChild = child;
|
|
15070
15070
|
const rects = mergeTextRects(textChild.getClientRects());
|
|
15071
|
-
assert(logger$
|
|
15071
|
+
assert(logger$4d, rects.length > 0, "invalid text child dom");
|
|
15072
15072
|
if (rects.length === 1) {
|
|
15073
15073
|
const nextChild = children[i + 1];
|
|
15074
15074
|
if (!nextChild) {
|
|
@@ -15093,10 +15093,10 @@ var __publicField = (obj, key, value) => {
|
|
|
15093
15093
|
continue;
|
|
15094
15094
|
}
|
|
15095
15095
|
const textNode = textChild.firstChild;
|
|
15096
|
-
assert(logger$
|
|
15097
|
-
assert(logger$
|
|
15096
|
+
assert(logger$4d, textNode, "invalid text child, no text node");
|
|
15097
|
+
assert(logger$4d, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
|
|
15098
15098
|
const textChildLength = getTextBlockContentChildTextLength(textChild);
|
|
15099
|
-
assert(logger$
|
|
15099
|
+
assert(logger$4d, textNode.data.length === textChildLength, "text node data length not equal child text length");
|
|
15100
15100
|
const textRects = getTextRects(textNode);
|
|
15101
15101
|
for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
|
|
15102
15102
|
const rect = textRects[rIndex];
|
|
@@ -15138,7 +15138,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15138
15138
|
}
|
|
15139
15139
|
}
|
|
15140
15140
|
}
|
|
15141
|
-
assert(logger$
|
|
15141
|
+
assert(logger$4d, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
|
|
15142
15142
|
return {
|
|
15143
15143
|
lineIndex: lineBreaks.length,
|
|
15144
15144
|
lineBreaks
|
|
@@ -23911,7 +23911,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23911
23911
|
const Graphemer_1 = __importDefault(Graphemer$1);
|
|
23912
23912
|
var _default = lib$1.default = Graphemer_1.default;
|
|
23913
23913
|
const splitter = new _default();
|
|
23914
|
-
const logger$
|
|
23914
|
+
const logger$4c = getLogger("text-offset");
|
|
23915
23915
|
function getChildOffset(block, child) {
|
|
23916
23916
|
const children = getTextBlockContentChildren(block);
|
|
23917
23917
|
let start = 0;
|
|
@@ -23927,26 +23927,26 @@ var __publicField = (obj, key, value) => {
|
|
|
23927
23927
|
}
|
|
23928
23928
|
start += testLength;
|
|
23929
23929
|
}
|
|
23930
|
-
assert(logger$
|
|
23930
|
+
assert(logger$4c, false, "can not find child in children");
|
|
23931
23931
|
}
|
|
23932
23932
|
function isValidOffset(block, blockOffset) {
|
|
23933
|
-
assert(logger$
|
|
23933
|
+
assert(logger$4c, blockOffset >= 0, `invalid offset: ${blockOffset}`);
|
|
23934
23934
|
const childInfo = getTextBlockChild(block, blockOffset);
|
|
23935
23935
|
const { prev, next: next2, offset } = childInfo;
|
|
23936
23936
|
if (!prev && !next2) {
|
|
23937
|
-
assert(logger$
|
|
23937
|
+
assert(logger$4c, false, "invalid offset, no prev & next child at offset");
|
|
23938
23938
|
}
|
|
23939
23939
|
if (prev !== next2) {
|
|
23940
23940
|
return true;
|
|
23941
23941
|
}
|
|
23942
23942
|
const child = prev;
|
|
23943
|
-
assert(logger$
|
|
23943
|
+
assert(logger$4c, child, "no child");
|
|
23944
23944
|
if (isTextBlockContentBoxChild(child)) {
|
|
23945
|
-
assert(logger$
|
|
23945
|
+
assert(logger$4c, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
|
|
23946
23946
|
return true;
|
|
23947
23947
|
}
|
|
23948
23948
|
const text2 = child.textContent;
|
|
23949
|
-
assert(logger$
|
|
23949
|
+
assert(logger$4c, text2, "no content for text child");
|
|
23950
23950
|
const chars = splitter.splitGraphemes(text2);
|
|
23951
23951
|
const validOffsets = /* @__PURE__ */ new Set();
|
|
23952
23952
|
let start = 0;
|
|
@@ -23976,7 +23976,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23976
23976
|
}
|
|
23977
23977
|
function getNextValidOffset(block, blockOffset) {
|
|
23978
23978
|
const length = getTextBlockLength(block);
|
|
23979
|
-
assert(logger$
|
|
23979
|
+
assert(logger$4c, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
|
|
23980
23980
|
if (blockOffset === length) {
|
|
23981
23981
|
return length;
|
|
23982
23982
|
}
|
|
@@ -23990,7 +23990,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23990
23990
|
}
|
|
23991
23991
|
return ret;
|
|
23992
23992
|
}
|
|
23993
|
-
const logger$
|
|
23993
|
+
const logger$4b = getLogger("line-offset");
|
|
23994
23994
|
function getLineOffsets(block) {
|
|
23995
23995
|
const lineBreaks = getLineBreaks(block);
|
|
23996
23996
|
const ret = [];
|
|
@@ -24011,7 +24011,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24011
24011
|
}
|
|
24012
24012
|
function getLineOffset(block, lineIndex) {
|
|
24013
24013
|
const lines = getLineOffsets(block);
|
|
24014
|
-
assert(logger$
|
|
24014
|
+
assert(logger$4b, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
|
|
24015
24015
|
return lines[lineIndex];
|
|
24016
24016
|
}
|
|
24017
24017
|
function getLineOffsetByPos(block, pos) {
|
|
@@ -24068,7 +24068,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24068
24068
|
function getLineCount(block) {
|
|
24069
24069
|
return getLineOffsets(block).length;
|
|
24070
24070
|
}
|
|
24071
|
-
const logger$
|
|
24071
|
+
const logger$4a = getLogger("find-text-position");
|
|
24072
24072
|
function isWrappedLine(block, lineIndex) {
|
|
24073
24073
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24074
24074
|
const blockId = getBlockId(block);
|
|
@@ -24079,13 +24079,13 @@ var __publicField = (obj, key, value) => {
|
|
|
24079
24079
|
return false;
|
|
24080
24080
|
}
|
|
24081
24081
|
const childInfo = getTextBlockChild(block, start);
|
|
24082
|
-
assert(logger$
|
|
24083
|
-
assert(logger$
|
|
24082
|
+
assert(logger$4a, childInfo.next, "no next child at offset");
|
|
24083
|
+
assert(logger$4a, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
|
|
24084
24084
|
return true;
|
|
24085
24085
|
}
|
|
24086
24086
|
function getWrappedLineOffsets(block, lineIndex) {
|
|
24087
24087
|
const blockId = getBlockId(block);
|
|
24088
|
-
assert(logger$
|
|
24088
|
+
assert(logger$4a, isWrappedLine(block, lineIndex), "line is not wrapped");
|
|
24089
24089
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24090
24090
|
const homePos = createSimpleBlockPosition(blockId, start, "home");
|
|
24091
24091
|
for (let offset = start + 1; offset <= end; offset += 1) {
|
|
@@ -24100,11 +24100,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24100
24100
|
return offset - 1;
|
|
24101
24101
|
}
|
|
24102
24102
|
}
|
|
24103
|
-
assert(logger$
|
|
24103
|
+
assert(logger$4a, false, "failed to find wrapped offset");
|
|
24104
24104
|
return 0;
|
|
24105
24105
|
}
|
|
24106
24106
|
function findTextPositionInLine(editor, block, lineIndex, sourceBlock, pos, findDirection, suggestedX) {
|
|
24107
|
-
assert(logger$
|
|
24107
|
+
assert(logger$4a, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
|
|
24108
24108
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24109
24109
|
let from = start;
|
|
24110
24110
|
const blockId = getBlockId(block);
|
|
@@ -24146,11 +24146,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24146
24146
|
return retPos;
|
|
24147
24147
|
}
|
|
24148
24148
|
function findPrevTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
|
|
24149
|
-
assert(logger$
|
|
24149
|
+
assert(logger$4a, isTextKindBlock(editor, block), "not a text block");
|
|
24150
24150
|
return findTextPositionInLine(editor, block, getLineCount(block) - 1, sourceBlock, pos, "up", suggestedX);
|
|
24151
24151
|
}
|
|
24152
24152
|
function findNextTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
|
|
24153
|
-
assert(logger$
|
|
24153
|
+
assert(logger$4a, isTextKindBlock(editor, block), "not a text block");
|
|
24154
24154
|
return findTextPositionInLine(editor, block, 0, sourceBlock, pos, "down", suggestedX);
|
|
24155
24155
|
}
|
|
24156
24156
|
function moveDown(editor, block, position, suggestedX) {
|
|
@@ -24258,7 +24258,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24258
24258
|
}
|
|
24259
24259
|
return pos;
|
|
24260
24260
|
}
|
|
24261
|
-
const logger$
|
|
24261
|
+
const logger$49 = getLogger("move-caret");
|
|
24262
24262
|
function moveTextCaret(editor, block, position, direction) {
|
|
24263
24263
|
if (direction === "ArrowLeft") {
|
|
24264
24264
|
const ret = moveLeft(block, position);
|
|
@@ -24288,9 +24288,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24288
24288
|
}
|
|
24289
24289
|
return createSimpleBlockPosition(getBlockId(block), ret.offset, ret.type);
|
|
24290
24290
|
}
|
|
24291
|
-
assert(logger$
|
|
24291
|
+
assert(logger$49, false, `invalid navigation direction: ${direction}`);
|
|
24292
24292
|
}
|
|
24293
|
-
const logger$
|
|
24293
|
+
const logger$48 = getLogger("text-range");
|
|
24294
24294
|
function getBlockRects(block) {
|
|
24295
24295
|
const ret = [];
|
|
24296
24296
|
const children = getTextBlockContentChildren(block);
|
|
@@ -24348,9 +24348,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24348
24348
|
return null;
|
|
24349
24349
|
}
|
|
24350
24350
|
const children = getTextBlockContentChildren(block);
|
|
24351
|
-
assert(logger$
|
|
24351
|
+
assert(logger$48, children.indexOf(child) !== -1, "failed to find child in children");
|
|
24352
24352
|
const offsetInfo = getChildOffset(block, child);
|
|
24353
|
-
assert(logger$
|
|
24353
|
+
assert(logger$48, offsetInfo, "failed to get child offset");
|
|
24354
24354
|
const { start } = offsetInfo;
|
|
24355
24355
|
let offset;
|
|
24356
24356
|
let length;
|
|
@@ -24366,7 +24366,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24366
24366
|
}
|
|
24367
24367
|
length = 0;
|
|
24368
24368
|
} else {
|
|
24369
|
-
assert(logger$
|
|
24369
|
+
assert(logger$48, child.firstChild instanceof Text, "child is not text");
|
|
24370
24370
|
offset = start + textNodeOffsetFromPoint(child.firstChild, x, y);
|
|
24371
24371
|
length = 0;
|
|
24372
24372
|
}
|
|
@@ -24390,9 +24390,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24390
24390
|
}
|
|
24391
24391
|
return new EditorSimpleSelectionRange(editor, { anchor: startPos, focus: endPos != null ? endPos : startPos });
|
|
24392
24392
|
}
|
|
24393
|
-
const logger$
|
|
24393
|
+
const logger$47 = getLogger("create-text-op");
|
|
24394
24394
|
function createTextOp(text2, attributes) {
|
|
24395
|
-
assert(logger$
|
|
24395
|
+
assert(logger$47, text2, "text is empty");
|
|
24396
24396
|
const ret = {
|
|
24397
24397
|
insert: text2
|
|
24398
24398
|
};
|
|
@@ -24415,7 +24415,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24415
24415
|
}
|
|
24416
24416
|
return result;
|
|
24417
24417
|
}
|
|
24418
|
-
const logger$
|
|
24418
|
+
const logger$46 = getLogger("merge-ops");
|
|
24419
24419
|
function mergeOps(text2) {
|
|
24420
24420
|
if (text2.length <= 1) {
|
|
24421
24421
|
return text2;
|
|
@@ -24437,10 +24437,10 @@ var __publicField = (obj, key, value) => {
|
|
|
24437
24437
|
return false;
|
|
24438
24438
|
}
|
|
24439
24439
|
if (op1.attributes === void 0) {
|
|
24440
|
-
assert(logger$
|
|
24440
|
+
assert(logger$46, op2.attributes === void 0, "op2.attributes is not undefined");
|
|
24441
24441
|
return true;
|
|
24442
24442
|
}
|
|
24443
|
-
assert(logger$
|
|
24443
|
+
assert(logger$46, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
|
|
24444
24444
|
return isEqual__default.default(op1.attributes, op2.attributes);
|
|
24445
24445
|
};
|
|
24446
24446
|
const newOps = [];
|
|
@@ -24449,8 +24449,8 @@ var __publicField = (obj, key, value) => {
|
|
|
24449
24449
|
for (let i = 1; i < text2.length; i += 1) {
|
|
24450
24450
|
const op = text2[i];
|
|
24451
24451
|
if (isSameTypeOp(before, op)) {
|
|
24452
|
-
assert(logger$
|
|
24453
|
-
assert(logger$
|
|
24452
|
+
assert(logger$46, typeof before.insert === "string", "before.insert is not string");
|
|
24453
|
+
assert(logger$46, typeof op.insert === "string", "op.insert is not string");
|
|
24454
24454
|
before.insert += op.insert;
|
|
24455
24455
|
} else {
|
|
24456
24456
|
newOps.push(op);
|
|
@@ -24478,15 +24478,15 @@ var __publicField = (obj, key, value) => {
|
|
|
24478
24478
|
}
|
|
24479
24479
|
return text2.slice(0, i + 1);
|
|
24480
24480
|
}
|
|
24481
|
-
const logger$
|
|
24481
|
+
const logger$45 = getLogger("delete-text");
|
|
24482
24482
|
function deleteText(richText2, offset, count) {
|
|
24483
24483
|
const { left, right } = splitToThree(richText2, offset, count);
|
|
24484
24484
|
const result = [...left, ...right];
|
|
24485
24485
|
return mergeOps(result);
|
|
24486
24486
|
}
|
|
24487
24487
|
function createDeleteOps(offset, count) {
|
|
24488
|
-
assert(logger$
|
|
24489
|
-
assert(logger$
|
|
24488
|
+
assert(logger$45, offset >= 0, `invalid offset: ${offset}`);
|
|
24489
|
+
assert(logger$45, count >= 1, `invalid delete count: ${count}`);
|
|
24490
24490
|
const ops = [];
|
|
24491
24491
|
if (offset !== 0) {
|
|
24492
24492
|
ops.push({
|
|
@@ -24498,7 +24498,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24498
24498
|
});
|
|
24499
24499
|
return ops;
|
|
24500
24500
|
}
|
|
24501
|
-
const logger$
|
|
24501
|
+
const logger$44 = getLogger("delta");
|
|
24502
24502
|
function diffRichText(oldText, newText) {
|
|
24503
24503
|
const delta1D = new Delta__default.default(oldText);
|
|
24504
24504
|
const delta2D = new Delta__default.default(newText);
|
|
@@ -24508,7 +24508,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24508
24508
|
return new Delta__default.default(ops).transformPosition(cursor, !isLocalOp);
|
|
24509
24509
|
}
|
|
24510
24510
|
function isValidDocText(text2) {
|
|
24511
|
-
assert(logger$
|
|
24511
|
+
assert(logger$44, text2, "ops is null or undefined");
|
|
24512
24512
|
for (let i = 0; i < text2.length; i++) {
|
|
24513
24513
|
const op = text2[i];
|
|
24514
24514
|
if (op.insert === null || op.insert === void 0) {
|
|
@@ -24528,7 +24528,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24528
24528
|
}
|
|
24529
24529
|
class RichText {
|
|
24530
24530
|
static ensureValidText(text2) {
|
|
24531
|
-
assert(logger$
|
|
24531
|
+
assert(logger$44, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
|
|
24532
24532
|
}
|
|
24533
24533
|
static diff(oldText, newText) {
|
|
24534
24534
|
this.ensureValidText(oldText);
|
|
@@ -24550,9 +24550,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24550
24550
|
return resultText;
|
|
24551
24551
|
}
|
|
24552
24552
|
}
|
|
24553
|
-
const logger$
|
|
24553
|
+
const logger$43 = getLogger("insert-text");
|
|
24554
24554
|
function insertText(richText2, offset, text2, attributes) {
|
|
24555
|
-
assert(logger$
|
|
24555
|
+
assert(logger$43, text2, `invalid text to insert: ${text2}`);
|
|
24556
24556
|
const { left, right } = splitText(richText2, offset);
|
|
24557
24557
|
const insertedText = typeof text2 === "string" ? [createTextOp(text2, attributes)] : text2;
|
|
24558
24558
|
const result = [...left, ...insertedText, ...right];
|
|
@@ -24565,7 +24565,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24565
24565
|
};
|
|
24566
24566
|
}
|
|
24567
24567
|
function createInsertOps(offset, text2, attributes) {
|
|
24568
|
-
assert(logger$
|
|
24568
|
+
assert(logger$43, offset >= 0, `invalid offset: ${offset}`);
|
|
24569
24569
|
if (text2.length === 0) {
|
|
24570
24570
|
return [];
|
|
24571
24571
|
}
|
|
@@ -24595,7 +24595,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24595
24595
|
function cloneText(text2) {
|
|
24596
24596
|
return cloneDeep__default.default(text2);
|
|
24597
24597
|
}
|
|
24598
|
-
const logger$
|
|
24598
|
+
const logger$42 = getLogger("update-op-attribute");
|
|
24599
24599
|
function updateOpAttributes(orgOps, key, value, newAttributes) {
|
|
24600
24600
|
const ops = cloneText(orgOps);
|
|
24601
24601
|
const index2 = ops.findIndex((op2) => {
|
|
@@ -24603,7 +24603,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24603
24603
|
return false;
|
|
24604
24604
|
return op2.attributes[key] === value;
|
|
24605
24605
|
});
|
|
24606
|
-
assert(logger$
|
|
24606
|
+
assert(logger$42, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
|
|
24607
24607
|
const op = ops[index2];
|
|
24608
24608
|
op.attributes = {
|
|
24609
24609
|
...op.attributes,
|
|
@@ -24685,11 +24685,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24685
24685
|
]);
|
|
24686
24686
|
}
|
|
24687
24687
|
const FILL_CHAR = "\u200B";
|
|
24688
|
-
const logger$
|
|
24688
|
+
const logger$41 = getLogger("to-plain-text");
|
|
24689
24689
|
function toPlainText(ops, options) {
|
|
24690
24690
|
let text2 = "";
|
|
24691
24691
|
ops.forEach((op) => {
|
|
24692
|
-
assert(logger$
|
|
24692
|
+
assert(logger$41, typeof op.insert === "string", "invalid op");
|
|
24693
24693
|
if (op.attributes && op.attributes.box === true) {
|
|
24694
24694
|
if (options == null ? void 0 : options.boxReplacement) {
|
|
24695
24695
|
text2 += options.boxReplacement;
|
|
@@ -24744,11 +24744,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24744
24744
|
focus: pos
|
|
24745
24745
|
};
|
|
24746
24746
|
}
|
|
24747
|
-
const logger$
|
|
24747
|
+
const logger$40 = getLogger("block-to-text");
|
|
24748
24748
|
function textBlockToText$1(editor, ops, doc2) {
|
|
24749
24749
|
let text2 = "";
|
|
24750
24750
|
ops.forEach((op) => {
|
|
24751
|
-
assert(logger$
|
|
24751
|
+
assert(logger$40, typeof op.insert === "string", "invalid op");
|
|
24752
24752
|
if (op.attributes && op.attributes.box === true) {
|
|
24753
24753
|
const box = op.attributes;
|
|
24754
24754
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -24766,11 +24766,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24766
24766
|
});
|
|
24767
24767
|
return text2;
|
|
24768
24768
|
}
|
|
24769
|
-
const logger$
|
|
24769
|
+
const logger$3$ = getLogger("block-to-text");
|
|
24770
24770
|
function textToMarkdownText(editor, ops, doc2) {
|
|
24771
24771
|
let text2 = "";
|
|
24772
24772
|
ops.forEach((op) => {
|
|
24773
|
-
assert(logger$
|
|
24773
|
+
assert(logger$3$, typeof op.insert === "string", "invalid op");
|
|
24774
24774
|
if (op.attributes && op.attributes.box === true) {
|
|
24775
24775
|
const box = op.attributes;
|
|
24776
24776
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -24893,12 +24893,12 @@ var __publicField = (obj, key, value) => {
|
|
|
24893
24893
|
return void 0;
|
|
24894
24894
|
}
|
|
24895
24895
|
}
|
|
24896
|
-
const logger$
|
|
24896
|
+
const logger$3_ = getLogger("block-to-text");
|
|
24897
24897
|
function textBlockToHtml(editor, blockData, doc2) {
|
|
24898
24898
|
let html = "";
|
|
24899
24899
|
const ops = blockData.text || [];
|
|
24900
24900
|
ops.forEach((op) => {
|
|
24901
|
-
assert(logger$
|
|
24901
|
+
assert(logger$3_, typeof op.insert === "string", "invalid op");
|
|
24902
24902
|
if (op.attributes && op.attributes.box === true) {
|
|
24903
24903
|
const box = op.attributes;
|
|
24904
24904
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -24974,16 +24974,16 @@ var __publicField = (obj, key, value) => {
|
|
|
24974
24974
|
}
|
|
24975
24975
|
return `<p>${html}</p>`;
|
|
24976
24976
|
}
|
|
24977
|
-
const logger$
|
|
24977
|
+
const logger$3Z = getLogger("text-block");
|
|
24978
24978
|
function createBlockContent$5(editor, path, container, blockElement, blockData) {
|
|
24979
24979
|
const { text: text2 } = blockData;
|
|
24980
|
-
assert(logger$
|
|
24980
|
+
assert(logger$3Z, text2, "no text for text block");
|
|
24981
24981
|
const content = createBlockContentElement(blockElement, "div");
|
|
24982
24982
|
updateBlockContent$1(editor, path, blockData.id, content, text2);
|
|
24983
24983
|
return content;
|
|
24984
24984
|
}
|
|
24985
24985
|
function updateBlockText$1(editor, block, text2) {
|
|
24986
|
-
assert(logger$
|
|
24986
|
+
assert(logger$3Z, text2, "no text to update");
|
|
24987
24987
|
const newContent = createBlockContentElement(null, "div");
|
|
24988
24988
|
updateBlockContent$1(editor, getBlockPath(block), getBlockId(block), newContent, text2);
|
|
24989
24989
|
const oldContent = getBlockContent(block);
|
|
@@ -24993,7 +24993,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24993
24993
|
return getRangeClientRects(editor, block, range);
|
|
24994
24994
|
}
|
|
24995
24995
|
function convertTo$k(editor, blockData, doc2, type) {
|
|
24996
|
-
assert(logger$
|
|
24996
|
+
assert(logger$3Z, blockData.text, "no text for text block");
|
|
24997
24997
|
if (type === "text") {
|
|
24998
24998
|
return textBlockToText$1(editor, blockData.text, doc2);
|
|
24999
24999
|
}
|
|
@@ -25007,7 +25007,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25007
25007
|
blockData.id = genId();
|
|
25008
25008
|
info == null ? void 0 : info.blockIdMap.set(srcBlockData.id, blockData.id);
|
|
25009
25009
|
const { text: text2 } = blockData;
|
|
25010
|
-
assert(logger$
|
|
25010
|
+
assert(logger$3Z, text2, "no text for text block");
|
|
25011
25011
|
text2.forEach((op) => {
|
|
25012
25012
|
if (op.insert && op.attributes && op.attributes.box === true) {
|
|
25013
25013
|
const boxId = genId();
|
|
@@ -25039,7 +25039,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25039
25039
|
blockToDoc: blockToDoc$1
|
|
25040
25040
|
};
|
|
25041
25041
|
const updateTextBlockContent = updateBlockContent$1;
|
|
25042
|
-
const logger$
|
|
25042
|
+
const logger$3Y = getLogger("action-helper");
|
|
25043
25043
|
function editorGetBlockData(editor, block) {
|
|
25044
25044
|
const container = getParentContainer(block);
|
|
25045
25045
|
const containerId = getContainerId(container);
|
|
@@ -25047,10 +25047,10 @@ var __publicField = (obj, key, value) => {
|
|
|
25047
25047
|
return editor.doc.getBlockData(containerId, blockIndex);
|
|
25048
25048
|
}
|
|
25049
25049
|
function editorGetBlockText(editor, block) {
|
|
25050
|
-
assert(logger$
|
|
25050
|
+
assert(logger$3Y, isTextKindBlock(editor, block), "not a text kind block");
|
|
25051
25051
|
const data2 = editorGetBlockData(editor, block);
|
|
25052
25052
|
const text2 = data2.text;
|
|
25053
|
-
assert(logger$
|
|
25053
|
+
assert(logger$3Y, text2, "no text in block");
|
|
25054
25054
|
return text2;
|
|
25055
25055
|
}
|
|
25056
25056
|
function editorGetBlockTextEx(editor, block, length) {
|
|
@@ -25058,7 +25058,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25058
25058
|
}
|
|
25059
25059
|
function editorGetBoxData(editor, box) {
|
|
25060
25060
|
const block = getParentBlock(box);
|
|
25061
|
-
assert(logger$
|
|
25061
|
+
assert(logger$3Y, block, "no parent block");
|
|
25062
25062
|
const text2 = editorGetBlockText(editor, block);
|
|
25063
25063
|
const id = getBoxId(box);
|
|
25064
25064
|
const op = text2.find((op2) => {
|
|
@@ -25068,60 +25068,60 @@ var __publicField = (obj, key, value) => {
|
|
|
25068
25068
|
}
|
|
25069
25069
|
return false;
|
|
25070
25070
|
});
|
|
25071
|
-
assert(logger$
|
|
25071
|
+
assert(logger$3Y, op, "failed to find box");
|
|
25072
25072
|
return op.attributes;
|
|
25073
25073
|
}
|
|
25074
|
-
const logger$
|
|
25074
|
+
const logger$3X = getLogger("block-text");
|
|
25075
25075
|
function getTextAfterOffset(editor, block, offset) {
|
|
25076
|
-
assert(logger$
|
|
25077
|
-
assert(logger$
|
|
25078
|
-
assert(logger$
|
|
25076
|
+
assert(logger$3X, isTextKindBlock(editor, block), "not a text kind block");
|
|
25077
|
+
assert(logger$3X, isValidOffset(block, offset), "not a valid offset");
|
|
25078
|
+
assert(logger$3X, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25079
25079
|
const newOffset = getNextValidOffset(block, offset);
|
|
25080
25080
|
const length = newOffset - offset;
|
|
25081
25081
|
if (length === 0) {
|
|
25082
|
-
assert(logger$
|
|
25082
|
+
assert(logger$3X, false, `no text after offset: ${offset}`);
|
|
25083
25083
|
}
|
|
25084
25084
|
const text2 = editorGetBlockText(editor, block);
|
|
25085
25085
|
const { middle } = splitToThree(text2, offset, length);
|
|
25086
|
-
assert(logger$
|
|
25086
|
+
assert(logger$3X, middle.length === 1, "failed to split text to 3 parts");
|
|
25087
25087
|
const op = middle[0];
|
|
25088
25088
|
if (isBoxOp(op)) {
|
|
25089
25089
|
return " ";
|
|
25090
25090
|
}
|
|
25091
|
-
assert(logger$
|
|
25091
|
+
assert(logger$3X, op.insert.length === 1 || op.insert.length === 2, "invalid op");
|
|
25092
25092
|
return op.insert;
|
|
25093
25093
|
}
|
|
25094
25094
|
function getTextBeforeOffset(editor, block, offset) {
|
|
25095
|
-
assert(logger$
|
|
25096
|
-
assert(logger$
|
|
25097
|
-
assert(logger$
|
|
25095
|
+
assert(logger$3X, isTextKindBlock(editor, block), "not a text kind block");
|
|
25096
|
+
assert(logger$3X, isValidOffset(block, offset), "not a valid offset");
|
|
25097
|
+
assert(logger$3X, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25098
25098
|
const newOffset = getPrevValidOffset(block, offset);
|
|
25099
25099
|
const length = offset - newOffset;
|
|
25100
25100
|
if (length === 0) {
|
|
25101
|
-
assert(logger$
|
|
25101
|
+
assert(logger$3X, false, `no text before offset: ${offset}`);
|
|
25102
25102
|
}
|
|
25103
25103
|
const text2 = editorGetBlockText(editor, block);
|
|
25104
25104
|
const { middle } = splitToThree(text2, newOffset, length);
|
|
25105
|
-
assert(logger$
|
|
25105
|
+
assert(logger$3X, middle.length === 1, "failed to split text to 3 parts");
|
|
25106
25106
|
const op = middle[0];
|
|
25107
25107
|
if (isBoxOp(op)) {
|
|
25108
25108
|
return " ";
|
|
25109
25109
|
}
|
|
25110
|
-
assert(logger$
|
|
25110
|
+
assert(logger$3X, op.insert.length === 1 || op.insert.length === 2, "invalid op");
|
|
25111
25111
|
return op.insert;
|
|
25112
25112
|
}
|
|
25113
25113
|
function getOffsetInfoBefore(editor, block, offset) {
|
|
25114
|
-
assert(logger$
|
|
25115
|
-
assert(logger$
|
|
25116
|
-
assert(logger$
|
|
25114
|
+
assert(logger$3X, isTextKindBlock(editor, block), "not a text kind block");
|
|
25115
|
+
assert(logger$3X, isValidOffset(block, offset), "not a valid offset");
|
|
25116
|
+
assert(logger$3X, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25117
25117
|
const newOffset = getPrevValidOffset(block, offset);
|
|
25118
25118
|
const length = offset - newOffset;
|
|
25119
25119
|
if (length === 0) {
|
|
25120
|
-
assert(logger$
|
|
25120
|
+
assert(logger$3X, false, `no text before offset: ${offset}`);
|
|
25121
25121
|
}
|
|
25122
25122
|
const text2 = editorGetBlockText(editor, block);
|
|
25123
25123
|
const { middle } = splitToThree(text2, newOffset, length);
|
|
25124
|
-
assert(logger$
|
|
25124
|
+
assert(logger$3X, middle.length === 1, "failed to split text to 3 parts");
|
|
25125
25125
|
const op = middle[0];
|
|
25126
25126
|
if (isBoxOp(op)) {
|
|
25127
25127
|
return {
|
|
@@ -25147,17 +25147,17 @@ var __publicField = (obj, key, value) => {
|
|
|
25147
25147
|
};
|
|
25148
25148
|
}
|
|
25149
25149
|
function getOffsetInfoAfter(editor, block, offset) {
|
|
25150
|
-
assert(logger$
|
|
25151
|
-
assert(logger$
|
|
25152
|
-
assert(logger$
|
|
25150
|
+
assert(logger$3X, isTextKindBlock(editor, block), "not a text kind block");
|
|
25151
|
+
assert(logger$3X, isValidOffset(block, offset), "not a valid offset");
|
|
25152
|
+
assert(logger$3X, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25153
25153
|
const newOffset = getNextValidOffset(block, offset);
|
|
25154
25154
|
const length = newOffset - offset;
|
|
25155
25155
|
if (length === 0) {
|
|
25156
|
-
assert(logger$
|
|
25156
|
+
assert(logger$3X, false, `no text after offset: ${offset}`);
|
|
25157
25157
|
}
|
|
25158
25158
|
const text2 = editorGetBlockText(editor, block);
|
|
25159
25159
|
const { middle } = splitToThree(text2, offset, length);
|
|
25160
|
-
assert(logger$
|
|
25160
|
+
assert(logger$3X, middle.length === 1, "failed to split text to 3 parts");
|
|
25161
25161
|
const op = middle[0];
|
|
25162
25162
|
if (isBoxOp(op)) {
|
|
25163
25163
|
return {
|
|
@@ -25229,7 +25229,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25229
25229
|
return null;
|
|
25230
25230
|
}
|
|
25231
25231
|
function findWordLeft(editor, block, offset) {
|
|
25232
|
-
assert(logger$
|
|
25232
|
+
assert(logger$3X, isTextKindBlock(editor, block), "invalid blok type");
|
|
25233
25233
|
if (isEmptyTextBlock(editor, block)) {
|
|
25234
25234
|
return 0;
|
|
25235
25235
|
}
|
|
@@ -25259,7 +25259,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25259
25259
|
return startInfo.offset + startInfo.length;
|
|
25260
25260
|
}
|
|
25261
25261
|
function findWordEnd(editor, block, offset) {
|
|
25262
|
-
assert(logger$
|
|
25262
|
+
assert(logger$3X, isTextKindBlock(editor, block), "invalid blok type");
|
|
25263
25263
|
if (isEmptyTextBlock(editor, block)) {
|
|
25264
25264
|
return 0;
|
|
25265
25265
|
}
|
|
@@ -25288,10 +25288,10 @@ var __publicField = (obj, key, value) => {
|
|
|
25288
25288
|
return getBlockTextLength$6(editor, block);
|
|
25289
25289
|
return startInfo.offset;
|
|
25290
25290
|
}
|
|
25291
|
-
const logger$
|
|
25291
|
+
const logger$3W = getLogger("text-box");
|
|
25292
25292
|
function updateBoxContent$8(editor, boxElement, boxContent, boxData) {
|
|
25293
|
-
assert(logger$
|
|
25294
|
-
assert(logger$
|
|
25293
|
+
assert(logger$3W, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
|
|
25294
|
+
assert(logger$3W, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
|
|
25295
25295
|
createElement("span", [], boxContent, boxData.text);
|
|
25296
25296
|
}
|
|
25297
25297
|
function convertTo$j(editor, boxData, doc2, type) {
|
|
@@ -25325,7 +25325,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25325
25325
|
updateBoxContent: updateBoxContent$7,
|
|
25326
25326
|
convertTo: convertTo$i
|
|
25327
25327
|
};
|
|
25328
|
-
const logger$
|
|
25328
|
+
const logger$3V = getLogger("editor-boxes");
|
|
25329
25329
|
class EditorBoxes {
|
|
25330
25330
|
constructor(editor) {
|
|
25331
25331
|
__publicField(this, "boxes", /* @__PURE__ */ new Map());
|
|
@@ -25334,12 +25334,12 @@ var __publicField = (obj, key, value) => {
|
|
|
25334
25334
|
registerBoxClass(boxClass) {
|
|
25335
25335
|
const type = boxClass.boxType;
|
|
25336
25336
|
const exists = this.boxes.get(type);
|
|
25337
|
-
assert(logger$
|
|
25337
|
+
assert(logger$3V, !exists, `duplicated box type: ${type}`);
|
|
25338
25338
|
this.boxes.set(type, boxClass);
|
|
25339
25339
|
}
|
|
25340
25340
|
getBoxClass(type) {
|
|
25341
25341
|
const exists = this.boxes.get(type);
|
|
25342
|
-
assert(logger$
|
|
25342
|
+
assert(logger$3V, exists, `unknown box type: ${type}`);
|
|
25343
25343
|
return exists;
|
|
25344
25344
|
}
|
|
25345
25345
|
createBox(blockContent, box) {
|
|
@@ -25701,7 +25701,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25701
25701
|
return { classes, attributes: newAttributes, styles: newStyles };
|
|
25702
25702
|
}
|
|
25703
25703
|
}
|
|
25704
|
-
const logger$
|
|
25704
|
+
const logger$3U = getLogger("editor-insertion");
|
|
25705
25705
|
class EditorInsertions {
|
|
25706
25706
|
constructor(editor) {
|
|
25707
25707
|
__publicField(this, "insertions", /* @__PURE__ */ new Map());
|
|
@@ -25710,12 +25710,12 @@ var __publicField = (obj, key, value) => {
|
|
|
25710
25710
|
registerInsertionClass(insertionClass) {
|
|
25711
25711
|
const type = insertionClass.insertionType;
|
|
25712
25712
|
const exists = this.insertions.get(type);
|
|
25713
|
-
assert(logger$
|
|
25713
|
+
assert(logger$3U, !exists, `duplicated insertion type: ${type}`);
|
|
25714
25714
|
this.insertions.set(type, insertionClass);
|
|
25715
25715
|
}
|
|
25716
25716
|
getInsertionClass(type) {
|
|
25717
25717
|
const exists = this.insertions.get(type);
|
|
25718
|
-
assert(logger$
|
|
25718
|
+
assert(logger$3U, exists, `unknown insertion type: ${type}`);
|
|
25719
25719
|
return exists;
|
|
25720
25720
|
}
|
|
25721
25721
|
createInsertionElement(type, id, attributes) {
|
|
@@ -25835,7 +25835,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25835
25835
|
};
|
|
25836
25836
|
}
|
|
25837
25837
|
}
|
|
25838
|
-
const logger$
|
|
25838
|
+
const logger$3T = getLogger("editor-input");
|
|
25839
25839
|
class EditorInput$1 {
|
|
25840
25840
|
constructor(editor, callbacks) {
|
|
25841
25841
|
__publicField(this, "editor");
|
|
@@ -25957,7 +25957,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25957
25957
|
return;
|
|
25958
25958
|
}
|
|
25959
25959
|
this.callbacks.onCut(event);
|
|
25960
|
-
logger$
|
|
25960
|
+
logger$3T.debug("on cut");
|
|
25961
25961
|
});
|
|
25962
25962
|
__publicField(this, "handlePaste", (event) => {
|
|
25963
25963
|
if (event.isTrusted) {
|
|
@@ -26072,11 +26072,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26072
26072
|
this.callbacks.removeHandler(handler);
|
|
26073
26073
|
}
|
|
26074
26074
|
defaultInsertText(editor, containerId, blockIndex, offset, text2) {
|
|
26075
|
-
assert(logger$
|
|
26075
|
+
assert(logger$3T, editor === this.editor, "invalid editor");
|
|
26076
26076
|
this.callbacks.defaultInsertText(editor, containerId, blockIndex, offset, text2);
|
|
26077
26077
|
}
|
|
26078
26078
|
defaultHandleKeydown(editor, event) {
|
|
26079
|
-
assert(logger$
|
|
26079
|
+
assert(logger$3T, editor === this.editor, "invalid editor");
|
|
26080
26080
|
return this.callbacks.defaultHandleKeydown(editor, event);
|
|
26081
26081
|
}
|
|
26082
26082
|
forEach(callback) {
|
|
@@ -26101,7 +26101,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26101
26101
|
input2.style.left = `${x / scale}px`;
|
|
26102
26102
|
input2.style.top = `${y / scale}px`;
|
|
26103
26103
|
}
|
|
26104
|
-
const logger$
|
|
26104
|
+
const logger$3S = getLogger("editor-caret");
|
|
26105
26105
|
function getFirefoxVersion() {
|
|
26106
26106
|
const userAgent = window.navigator.userAgent;
|
|
26107
26107
|
const match = userAgent.match(/Firefox\/(\d+)\./);
|
|
@@ -26164,11 +26164,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26164
26164
|
return;
|
|
26165
26165
|
}
|
|
26166
26166
|
const { range } = this.editor.selection;
|
|
26167
|
-
assert(logger$
|
|
26167
|
+
assert(logger$3S, range.isCollapsed, "range is not collapsed");
|
|
26168
26168
|
const pos = range.start;
|
|
26169
|
-
assert(logger$
|
|
26169
|
+
assert(logger$3S, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
|
|
26170
26170
|
const block = this.editor.getBlockById(pos.blockId);
|
|
26171
|
-
assert(logger$
|
|
26171
|
+
assert(logger$3S, isTextKindBlock(this.editor, block), "only text kind block can has caret");
|
|
26172
26172
|
let rect;
|
|
26173
26173
|
const compositionSpan = block.querySelector("span.inputting-insertion");
|
|
26174
26174
|
if (compositionSpan) {
|
|
@@ -26206,7 +26206,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26206
26206
|
clearAllSelection(editor);
|
|
26207
26207
|
editor.selection.range.getSelectedBlocks().forEach((s) => updateBlockSelection(editor, s.block, s.start, s.end));
|
|
26208
26208
|
}
|
|
26209
|
-
const logger$
|
|
26209
|
+
const logger$3R = getLogger("editor-dom");
|
|
26210
26210
|
function editorGetClientHeight(editor) {
|
|
26211
26211
|
const scrollContainer = getScrollContainer$1(editor.rootContainer);
|
|
26212
26212
|
return scrollContainer.clientHeight;
|
|
@@ -26294,7 +26294,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26294
26294
|
}
|
|
26295
26295
|
function editorScrollIntoView(editor) {
|
|
26296
26296
|
if (!isElementVisible(editor.rootContainer)) {
|
|
26297
|
-
logger$
|
|
26297
|
+
logger$3R.warn("editorScrollIntoView: editor is not visible");
|
|
26298
26298
|
return;
|
|
26299
26299
|
}
|
|
26300
26300
|
const rootClientRect = editor.rootContainer.getBoundingClientRect();
|
|
@@ -26359,7 +26359,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26359
26359
|
const { start, end } = range;
|
|
26360
26360
|
return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
|
|
26361
26361
|
}
|
|
26362
|
-
const logger$
|
|
26362
|
+
const logger$3Q = getLogger("range-in-block");
|
|
26363
26363
|
function rangeInBlock(block, range) {
|
|
26364
26364
|
const editor = range.getEditor();
|
|
26365
26365
|
const start = editor.getBlockById(range.start.blockId);
|
|
@@ -26380,16 +26380,16 @@ var __publicField = (obj, key, value) => {
|
|
|
26380
26380
|
while (prevBlock && !blocks.has(getBlockId(prevBlock))) {
|
|
26381
26381
|
prevBlock = getPrevVisibleBlock(prevBlock);
|
|
26382
26382
|
}
|
|
26383
|
-
assert(logger$
|
|
26383
|
+
assert(logger$3Q, prevBlock, "no prev block while deleting a block");
|
|
26384
26384
|
newRange = createBlockSimpleRange(editor, prevBlock, getBlockTextLength$6(editor, prevBlock));
|
|
26385
26385
|
} else {
|
|
26386
26386
|
const nextBlock = getNextVisibleBlock(block);
|
|
26387
|
-
assert(logger$
|
|
26387
|
+
assert(logger$3Q, nextBlock, "no prev and next block while deleting a block");
|
|
26388
26388
|
newRange = createBlockSimpleRange(editor, nextBlock, 0);
|
|
26389
26389
|
}
|
|
26390
26390
|
return newRange;
|
|
26391
26391
|
}
|
|
26392
|
-
const logger$
|
|
26392
|
+
const logger$3P = getLogger("block-to-html");
|
|
26393
26393
|
function blockToHtml(editor, blockData, doc2, path) {
|
|
26394
26394
|
const blockClass = getBlockClassByType(editor, blockData.type);
|
|
26395
26395
|
if (blockClass.convertTo) {
|
|
@@ -26398,15 +26398,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26398
26398
|
if (blockClass.blockKind !== "text") {
|
|
26399
26399
|
return `[${blockData.type}]`;
|
|
26400
26400
|
}
|
|
26401
|
-
assert(logger$
|
|
26401
|
+
assert(logger$3P, blockData.text, "no text");
|
|
26402
26402
|
const plainText = toPlainText(blockData.text);
|
|
26403
26403
|
return `<div>${escapeHtmlText(plainText)}</div>`;
|
|
26404
26404
|
}
|
|
26405
|
-
const logger$
|
|
26405
|
+
const logger$3O = getLogger("block-to-text");
|
|
26406
26406
|
function textBlockToText(editor, ops, doc2) {
|
|
26407
26407
|
let text2 = "";
|
|
26408
26408
|
ops.forEach((op) => {
|
|
26409
|
-
assert(logger$
|
|
26409
|
+
assert(logger$3O, typeof op.insert === "string", "invalid op");
|
|
26410
26410
|
if (op.attributes && op.attributes.box === true) {
|
|
26411
26411
|
const box = op.attributes;
|
|
26412
26412
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -26432,7 +26432,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26432
26432
|
if (blockClass.blockKind !== "text") {
|
|
26433
26433
|
return `[${blockData.type}]`;
|
|
26434
26434
|
}
|
|
26435
|
-
assert(logger$
|
|
26435
|
+
assert(logger$3O, blockData.text, "no text");
|
|
26436
26436
|
const plainText = textBlockToText(editor, blockData.text, doc2);
|
|
26437
26437
|
return plainText;
|
|
26438
26438
|
}
|
|
@@ -26465,11 +26465,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26465
26465
|
const markdown = lines.join("\n");
|
|
26466
26466
|
return markdown;
|
|
26467
26467
|
}
|
|
26468
|
-
const logger$
|
|
26468
|
+
const logger$3N = getLogger("get-text-position");
|
|
26469
26469
|
function editorGetTextPosition(editor, insertPos) {
|
|
26470
26470
|
const pos = insertPos != null ? insertPos : editor.selection.range.start;
|
|
26471
26471
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
26472
|
-
assert(logger$
|
|
26472
|
+
assert(logger$3N, false, `invalid insert pos type: ${typeof pos}`);
|
|
26473
26473
|
}
|
|
26474
26474
|
const { blockId } = pos;
|
|
26475
26475
|
const block = editor.getBlockById(blockId);
|
|
@@ -26557,14 +26557,14 @@ var __publicField = (obj, key, value) => {
|
|
|
26557
26557
|
return attributes;
|
|
26558
26558
|
}
|
|
26559
26559
|
}
|
|
26560
|
-
const logger$
|
|
26560
|
+
const logger$3M = getLogger("insert-text");
|
|
26561
26561
|
function getTextAttributes(editor, containerId, blockIndex, offset) {
|
|
26562
26562
|
var _a, _b;
|
|
26563
26563
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26564
|
-
assert(logger$
|
|
26565
|
-
assert(logger$
|
|
26564
|
+
assert(logger$3M, blockData, "no block data");
|
|
26565
|
+
assert(logger$3M, blockData.text, "no block text");
|
|
26566
26566
|
if (getTextLength(blockData.text) === 0) {
|
|
26567
|
-
assert(logger$
|
|
26567
|
+
assert(logger$3M, offset === 0, "invalid text offset");
|
|
26568
26568
|
return BlockAttributesHandler.get(editor).getEmptyBlockTextAttributes(blockData.id);
|
|
26569
26569
|
}
|
|
26570
26570
|
if (offset === 0) {
|
|
@@ -26611,7 +26611,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26611
26611
|
}
|
|
26612
26612
|
for (let i = 0; i < text2.length; i++) {
|
|
26613
26613
|
const op = text2[i];
|
|
26614
|
-
assert(logger$
|
|
26614
|
+
assert(logger$3M, typeof op.insert === "string", "invalid text op, no insert");
|
|
26615
26615
|
const endPos = pos + getOpLength(op);
|
|
26616
26616
|
if (endPos === start) {
|
|
26617
26617
|
return false;
|
|
@@ -26625,8 +26625,8 @@ var __publicField = (obj, key, value) => {
|
|
|
26625
26625
|
}
|
|
26626
26626
|
function editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset) {
|
|
26627
26627
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26628
|
-
assert(logger$
|
|
26629
|
-
assert(logger$
|
|
26628
|
+
assert(logger$3M, blockData, "no block data");
|
|
26629
|
+
assert(logger$3M, blockData.text, "no block text");
|
|
26630
26630
|
const attributes = getTextAttributes(editor, containerId, blockIndex, offset);
|
|
26631
26631
|
if (attributes && Object.keys(attributes).includes("link")) {
|
|
26632
26632
|
const inOp = checkRangeInOp(blockData.text, offset);
|
|
@@ -26645,21 +26645,21 @@ var __publicField = (obj, key, value) => {
|
|
|
26645
26645
|
const { containerId, blockIndex, offset } = editorGetTextPosition(editor);
|
|
26646
26646
|
editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset);
|
|
26647
26647
|
}
|
|
26648
|
-
const logger$
|
|
26648
|
+
const logger$3L = getLogger("update-composition-text");
|
|
26649
26649
|
function editorUpdateCompositionText(editor) {
|
|
26650
26650
|
const pos = editor.selection.range.start;
|
|
26651
26651
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
26652
|
-
assert(logger$
|
|
26652
|
+
assert(logger$3L, false, `invalid insert pos type: ${typeof pos}`);
|
|
26653
26653
|
}
|
|
26654
26654
|
const { blockId } = pos;
|
|
26655
26655
|
const block = editor.getBlockById(blockId);
|
|
26656
|
-
assert(logger$
|
|
26656
|
+
assert(logger$3L, isTextKindBlock(editor, block), "not a text kind block");
|
|
26657
26657
|
const container = getParentContainer(block);
|
|
26658
26658
|
const containerId = getContainerId(container);
|
|
26659
26659
|
const blockIndex = getBlockIndex(block);
|
|
26660
26660
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26661
|
-
assert(logger$
|
|
26662
|
-
assert(logger$
|
|
26661
|
+
assert(logger$3L, blockData, "no block data in doc");
|
|
26662
|
+
assert(logger$3L, blockData.text, "no text data in text block");
|
|
26663
26663
|
const blockContent = getBlockContent(block);
|
|
26664
26664
|
updateBlockContent$1(editor, getBlockPath(block), blockId, blockContent, blockData.text);
|
|
26665
26665
|
}
|
|
@@ -26671,25 +26671,25 @@ var __publicField = (obj, key, value) => {
|
|
|
26671
26671
|
const block = editor.getBlockById(blockData.id);
|
|
26672
26672
|
return block;
|
|
26673
26673
|
}
|
|
26674
|
-
const logger$
|
|
26674
|
+
const logger$3K = getLogger("delete-block-text");
|
|
26675
26675
|
function editorDeleteBlockText(editor, block, offset, count, options) {
|
|
26676
26676
|
if (!editor.isBlockWritable(block)) {
|
|
26677
|
-
logger$
|
|
26677
|
+
logger$3K.error("block is not writable");
|
|
26678
26678
|
return 0;
|
|
26679
26679
|
}
|
|
26680
|
-
assert(logger$
|
|
26680
|
+
assert(logger$3K, isTextKindBlock(editor, block), "block is not a text kind block");
|
|
26681
26681
|
const container = getParentContainer(block);
|
|
26682
26682
|
const containerId = getContainerId(container);
|
|
26683
26683
|
const blockIndex = getBlockIndex(block);
|
|
26684
26684
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26685
|
-
assert(logger$
|
|
26686
|
-
assert(logger$
|
|
26685
|
+
assert(logger$3K, blockData, "no block data in doc");
|
|
26686
|
+
assert(logger$3K, blockData.text, "no text data in text block");
|
|
26687
26687
|
let from = offset;
|
|
26688
26688
|
if (!isValidOffset(block, offset)) {
|
|
26689
26689
|
from = getPrevValidOffset(block, from);
|
|
26690
26690
|
}
|
|
26691
26691
|
let to = offset + count;
|
|
26692
|
-
assert(logger$
|
|
26692
|
+
assert(logger$3K, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
|
|
26693
26693
|
if (!isValidOffset(block, to)) {
|
|
26694
26694
|
to = getNextValidOffset(block, to);
|
|
26695
26695
|
}
|
|
@@ -26698,7 +26698,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26698
26698
|
editor.doc.localUpdateBlockText(containerId, blockIndex, actions2, options);
|
|
26699
26699
|
return deleteCount;
|
|
26700
26700
|
}
|
|
26701
|
-
const logger$
|
|
26701
|
+
const logger$3J = getLogger("break-text-block");
|
|
26702
26702
|
function copyBlockAttributes(editor, block, options) {
|
|
26703
26703
|
const blockData = editor.getBlockData(block);
|
|
26704
26704
|
const quoted = blockData.quoted;
|
|
@@ -26715,8 +26715,8 @@ var __publicField = (obj, key, value) => {
|
|
|
26715
26715
|
return ret;
|
|
26716
26716
|
}
|
|
26717
26717
|
function editorBreakTextBlock(editor, block, offset, options) {
|
|
26718
|
-
assert(logger$
|
|
26719
|
-
assert(logger$
|
|
26718
|
+
assert(logger$3J, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
|
|
26719
|
+
assert(logger$3J, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
26720
26720
|
const container = getParentContainer(block);
|
|
26721
26721
|
const containerId = getContainerId(container);
|
|
26722
26722
|
const blockIndex = getBlockIndex(block);
|
|
@@ -26746,7 +26746,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26746
26746
|
};
|
|
26747
26747
|
}
|
|
26748
26748
|
}
|
|
26749
|
-
assert(logger$
|
|
26749
|
+
assert(logger$3J, isValidOffset(block, offset), "not a valid offset");
|
|
26750
26750
|
const text2 = editorGetBlockText(editor, block);
|
|
26751
26751
|
const { right } = splitText(text2, offset);
|
|
26752
26752
|
const rightLength = getTextLength(right);
|
|
@@ -26772,12 +26772,12 @@ var __publicField = (obj, key, value) => {
|
|
|
26772
26772
|
newBlock
|
|
26773
26773
|
};
|
|
26774
26774
|
}
|
|
26775
|
-
const logger$
|
|
26775
|
+
const logger$3I = getLogger("prepare-insert-new-block");
|
|
26776
26776
|
function editorPrepareInsertNewBlock(editor, containerId, blockIndex) {
|
|
26777
26777
|
if (containerId && blockIndex !== void 0 && blockIndex !== null) {
|
|
26778
26778
|
const container = editor.getContainerById(containerId);
|
|
26779
26779
|
const blocks = getChildBlocks(container);
|
|
26780
|
-
assert(logger$
|
|
26780
|
+
assert(logger$3I, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
|
|
26781
26781
|
return {
|
|
26782
26782
|
containerId,
|
|
26783
26783
|
blockIndex
|
|
@@ -26811,15 +26811,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26811
26811
|
blockIndex: getBlockIndex(newBlock)
|
|
26812
26812
|
};
|
|
26813
26813
|
}
|
|
26814
|
-
const logger$
|
|
26814
|
+
const logger$3H = getLogger("auto-insert-block");
|
|
26815
26815
|
function editorAutoInsertBlock(editor, blockData, containerId, blockIndex, newRange, insertBlockOptions) {
|
|
26816
26816
|
const result = editorPrepareInsertNewBlock(editor, containerId, blockIndex);
|
|
26817
|
-
assert(logger$
|
|
26817
|
+
assert(logger$3H, result, `not an valid insert position: ${editor.selection.range}`);
|
|
26818
26818
|
const defaultPos = { blockId: blockData.id, offset: 0 };
|
|
26819
26819
|
const defaultRange = { anchor: defaultPos, focus: defaultPos };
|
|
26820
26820
|
return editorInsertBlock(editor, result.containerId, result.blockIndex, blockData, newRange != null ? newRange : defaultRange, insertBlockOptions);
|
|
26821
26821
|
}
|
|
26822
|
-
const logger$
|
|
26822
|
+
const logger$3G = getLogger("delete-block");
|
|
26823
26823
|
function getAllChildContainers(editor, blockData, containerIds) {
|
|
26824
26824
|
if (blockData.children) {
|
|
26825
26825
|
containerIds.push(...blockData.children);
|
|
@@ -26836,7 +26836,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26836
26836
|
const containerId = getContainerId(container);
|
|
26837
26837
|
const blockIndex = getBlockIndex(block);
|
|
26838
26838
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26839
|
-
assert(logger$
|
|
26839
|
+
assert(logger$3G, blockData, "no block data in doc");
|
|
26840
26840
|
editor.doc.localDeleteBlock(containerId, blockIndex, createEditorSelectionRange(editor, { anchor: newRange.start, focus: newRange.end }));
|
|
26841
26841
|
return blockData;
|
|
26842
26842
|
}
|
|
@@ -26882,15 +26882,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26882
26882
|
});
|
|
26883
26883
|
editor.doc.localDeleteChildContainers(containerIds);
|
|
26884
26884
|
}
|
|
26885
|
-
const logger$
|
|
26885
|
+
const logger$3F = getLogger("merge-text-block");
|
|
26886
26886
|
function editorMergeTextBlock(editor, block1, block2) {
|
|
26887
|
-
assert(logger$
|
|
26888
|
-
assert(logger$
|
|
26887
|
+
assert(logger$3F, isTextKindBlock(editor, block1), "only text block can be merged");
|
|
26888
|
+
assert(logger$3F, isTextKindBlock(editor, block2), "only text block can be merged");
|
|
26889
26889
|
const data1 = editorGetBlockData(editor, block1);
|
|
26890
26890
|
const data2 = editorGetBlockData(editor, block2);
|
|
26891
26891
|
const text1 = data1.text;
|
|
26892
26892
|
const text2 = data2.text;
|
|
26893
|
-
assert(logger$
|
|
26893
|
+
assert(logger$3F, text1 && text2, "block data has no text");
|
|
26894
26894
|
const container = getParentContainer(block1);
|
|
26895
26895
|
const containerId = getContainerId(container);
|
|
26896
26896
|
const blockIndex = getBlockIndex(block1);
|
|
@@ -26900,15 +26900,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26900
26900
|
editorDeleteBlock(editor, block2, newRange);
|
|
26901
26901
|
return block;
|
|
26902
26902
|
}
|
|
26903
|
-
const logger$
|
|
26903
|
+
const logger$3E = getLogger("clear-selected-contents");
|
|
26904
26904
|
function deleteTextBlockSelection(editor, selectedBlock) {
|
|
26905
|
-
assert(logger$
|
|
26905
|
+
assert(logger$3E, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
|
|
26906
26906
|
const { start, end } = selectedBlock;
|
|
26907
|
-
assert(logger$
|
|
26908
|
-
assert(logger$
|
|
26907
|
+
assert(logger$3E, start.isSimple(), "not a simple block position");
|
|
26908
|
+
assert(logger$3E, end.isSimple(), "not a simple block position");
|
|
26909
26909
|
const startOffset = start.offset;
|
|
26910
26910
|
const endOffset = end.offset;
|
|
26911
|
-
assert(logger$
|
|
26911
|
+
assert(logger$3E, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
|
|
26912
26912
|
if (startOffset === endOffset) {
|
|
26913
26913
|
return;
|
|
26914
26914
|
}
|
|
@@ -26933,7 +26933,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26933
26933
|
return;
|
|
26934
26934
|
}
|
|
26935
26935
|
if (isEmbedBlock(block) || start.isSimple()) {
|
|
26936
|
-
assert(logger$
|
|
26936
|
+
assert(logger$3E, end.isSimple(), "invalid range");
|
|
26937
26937
|
const container = getParentContainer(block);
|
|
26938
26938
|
const blockIndex = getBlockIndex(block);
|
|
26939
26939
|
const newBlock = editor.insertTextBlock("", getContainerId(container), blockIndex);
|
|
@@ -26941,8 +26941,8 @@ var __publicField = (obj, key, value) => {
|
|
|
26941
26941
|
editor.deleteBlock(block);
|
|
26942
26942
|
return;
|
|
26943
26943
|
}
|
|
26944
|
-
assert(logger$
|
|
26945
|
-
assert(logger$
|
|
26944
|
+
assert(logger$3E, isComplexKindBlock(editor, block), "invalid block kind");
|
|
26945
|
+
assert(logger$3E, !start.isSimple() && !end.isSimple(), "invalid range");
|
|
26946
26946
|
complexBlockGetSelectedContainers(editor, block, start, end);
|
|
26947
26947
|
const containers = editor.selection.range.getSelectedContainers();
|
|
26948
26948
|
containers.forEach((container, index2) => {
|
|
@@ -26959,7 +26959,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26959
26959
|
return;
|
|
26960
26960
|
}
|
|
26961
26961
|
const selectedBlocks = range.getSelectedBlocks();
|
|
26962
|
-
assert(logger$
|
|
26962
|
+
assert(logger$3E, selectedBlocks.length > 0, "no selected block");
|
|
26963
26963
|
if (selectedBlocks.length === 1) {
|
|
26964
26964
|
clearOneBlock(editor, selectedBlocks[0]);
|
|
26965
26965
|
return;
|
|
@@ -26967,7 +26967,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26967
26967
|
const firstSelectedBlock = selectedBlocks[0];
|
|
26968
26968
|
const firstBlock = firstSelectedBlock.block;
|
|
26969
26969
|
const container = getParentContainer(firstBlock);
|
|
26970
|
-
assert(logger$
|
|
26970
|
+
assert(logger$3E, selectedBlocks.length > 1, "no selected block");
|
|
26971
26971
|
const lastSelectedBlock = selectedBlocks[selectedBlocks.length - 1];
|
|
26972
26972
|
const lastBlock2 = lastSelectedBlock.block;
|
|
26973
26973
|
if (isTextKindBlock(editor, firstBlock)) {
|
|
@@ -26997,7 +26997,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26997
26997
|
}
|
|
26998
26998
|
const prevBlock = getPrevBlock(firstBlock);
|
|
26999
26999
|
const nextBlock = getNextBlock(lastBlock2);
|
|
27000
|
-
assert(logger$
|
|
27000
|
+
assert(logger$3E, prevBlock || nextBlock, "no prev or next block");
|
|
27001
27001
|
selectedBlocks.forEach((selectedBlock) => editor.deleteBlock(selectedBlock.block));
|
|
27002
27002
|
}
|
|
27003
27003
|
function editorClearSelectedContents(editor, selectionRange) {
|
|
@@ -27016,7 +27016,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27016
27016
|
editor.emit("afterClearSelection", editor);
|
|
27017
27017
|
});
|
|
27018
27018
|
}
|
|
27019
|
-
const logger$
|
|
27019
|
+
const logger$3D = getLogger("core");
|
|
27020
27020
|
function editorUpdateBlockText(editor, block, ops, options) {
|
|
27021
27021
|
const container = getParentContainer(block);
|
|
27022
27022
|
const containerId = getContainerId(container);
|
|
@@ -27029,7 +27029,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27029
27029
|
}
|
|
27030
27030
|
function editorSetBlockText(editor, block, newText, options) {
|
|
27031
27031
|
if (!editor.isBlockWritable(block)) {
|
|
27032
|
-
logger$
|
|
27032
|
+
logger$3D.error("block is not writable");
|
|
27033
27033
|
return;
|
|
27034
27034
|
}
|
|
27035
27035
|
const oldText = editor.getBlockText(block);
|
|
@@ -27042,7 +27042,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27042
27042
|
const ops = RichText.diff(oldText, newText);
|
|
27043
27043
|
return editorUpdateBlockText(editor, block, ops);
|
|
27044
27044
|
}
|
|
27045
|
-
const logger$
|
|
27045
|
+
const logger$3C = getLogger("update-block-data");
|
|
27046
27046
|
function editorUpdateBlockData(editor, block, data2, newRange, options) {
|
|
27047
27047
|
const container = getParentContainer(block);
|
|
27048
27048
|
const containerId = getContainerId(container);
|
|
@@ -27059,17 +27059,17 @@ var __publicField = (obj, key, value) => {
|
|
|
27059
27059
|
if (oldKey === "id" || oldKey === "type" || oldKey === "text") {
|
|
27060
27060
|
return;
|
|
27061
27061
|
}
|
|
27062
|
-
logger$
|
|
27062
|
+
logger$3C.debug(`delete key: ${oldKey}`);
|
|
27063
27063
|
delta.delete.push(oldKey);
|
|
27064
27064
|
}
|
|
27065
27065
|
});
|
|
27066
27066
|
const entries = Object.entries(data2);
|
|
27067
27067
|
entries.forEach(([key, value]) => {
|
|
27068
|
-
assert(logger$
|
|
27068
|
+
assert(logger$3C, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
|
|
27069
27069
|
const oldValue = oldData[key];
|
|
27070
27070
|
if (value === null || value === void 0) {
|
|
27071
27071
|
if (oldValue !== null && oldValue !== void 0) {
|
|
27072
|
-
logger$
|
|
27072
|
+
logger$3C.debug(`delete key: ${key}`);
|
|
27073
27073
|
delta.delete.push(key);
|
|
27074
27074
|
}
|
|
27075
27075
|
return;
|
|
@@ -27087,10 +27087,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27087
27087
|
}
|
|
27088
27088
|
}
|
|
27089
27089
|
if (oldKeys.has(key)) {
|
|
27090
|
-
logger$
|
|
27090
|
+
logger$3C.debug(`replace key: ${key}`);
|
|
27091
27091
|
delta.delete.push(key);
|
|
27092
27092
|
} else {
|
|
27093
|
-
logger$
|
|
27093
|
+
logger$3C.debug(`insert key: ${key}`);
|
|
27094
27094
|
}
|
|
27095
27095
|
delta.insert[key] = value;
|
|
27096
27096
|
});
|
|
@@ -27135,13 +27135,13 @@ var __publicField = (obj, key, value) => {
|
|
|
27135
27135
|
comments: {}
|
|
27136
27136
|
};
|
|
27137
27137
|
}
|
|
27138
|
-
const logger$
|
|
27138
|
+
const logger$3B = getLogger("clone-block");
|
|
27139
27139
|
function cloneBlock(editorBlocks, oldDoc, data2, info) {
|
|
27140
27140
|
var _a;
|
|
27141
27141
|
const blockClass = editorBlocks.getBlockClass(data2.type);
|
|
27142
27142
|
if (blockClass.blockToDoc) {
|
|
27143
27143
|
return blockClass.blockToDoc(oldDoc, data2, (oldDoc2, childBlock) => {
|
|
27144
|
-
assert(logger$
|
|
27144
|
+
assert(logger$3B, data2 !== childBlock, "invalid child block");
|
|
27145
27145
|
return cloneBlock(editorBlocks, oldDoc2, data2, info);
|
|
27146
27146
|
}, info);
|
|
27147
27147
|
}
|
|
@@ -27154,7 +27154,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27154
27154
|
}
|
|
27155
27155
|
const newChildContainerId = genId();
|
|
27156
27156
|
const childBlocks = oldDoc.blocks[oldChildContainerId];
|
|
27157
|
-
assert(logger$
|
|
27157
|
+
assert(logger$3B, Array.isArray(childBlocks), "invalid child blocks");
|
|
27158
27158
|
const newDocs = childBlocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
|
|
27159
27159
|
const newDoc = mergeDocs(newDocs);
|
|
27160
27160
|
const { root: root2, ...childContainersData } = newDoc.blocks;
|
|
@@ -27183,7 +27183,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27183
27183
|
if (key.startsWith(prefix1)) {
|
|
27184
27184
|
const keyContent = key.substring(prefix1.length);
|
|
27185
27185
|
const newKey = `${newContainerId}/${keyContent}`;
|
|
27186
|
-
logger$
|
|
27186
|
+
logger$3B.debug(`replace key: ${key} -> ${newKey}`);
|
|
27187
27187
|
return newKey;
|
|
27188
27188
|
}
|
|
27189
27189
|
}
|
|
@@ -27192,7 +27192,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27192
27192
|
if (key.startsWith(prefix2)) {
|
|
27193
27193
|
const keyContent = key.substring(prefix2.length);
|
|
27194
27194
|
const newKey = `${newContainerId}_${keyContent}`;
|
|
27195
|
-
logger$
|
|
27195
|
+
logger$3B.debug(`replace key: ${key} -> ${newKey}`);
|
|
27196
27196
|
return newKey;
|
|
27197
27197
|
}
|
|
27198
27198
|
}
|
|
@@ -27222,7 +27222,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27222
27222
|
}
|
|
27223
27223
|
function cloneChildContainer(editorBlocks, oldDoc, containerId, info) {
|
|
27224
27224
|
const blocks = oldDoc.blocks[containerId];
|
|
27225
|
-
assert(logger$
|
|
27225
|
+
assert(logger$3B, Array.isArray(blocks), "invalid child blocks");
|
|
27226
27226
|
const newDocs = blocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
|
|
27227
27227
|
const newDoc = mergeDocs(newDocs);
|
|
27228
27228
|
return newDoc;
|
|
@@ -27231,11 +27231,11 @@ var __publicField = (obj, key, value) => {
|
|
|
27231
27231
|
const docs = doc2.blocks.root.map((b) => cloneBlock(editor.editorBlocks, doc2, b, info));
|
|
27232
27232
|
return cloneDeep__default.default(mergeDocs(docs));
|
|
27233
27233
|
}
|
|
27234
|
-
const logger$
|
|
27234
|
+
const logger$3A = getLogger("insert-doc");
|
|
27235
27235
|
function editorInsertDoc(editor, block, offset, insertedDoc, cloneDocResult) {
|
|
27236
27236
|
var _a;
|
|
27237
27237
|
if (isComplexKindBlock(editor, block)) {
|
|
27238
|
-
logger$
|
|
27238
|
+
logger$3A.warn("failed to insert doc into a complex block");
|
|
27239
27239
|
return;
|
|
27240
27240
|
}
|
|
27241
27241
|
const doc2 = cloneDoc(editor, insertedDoc, cloneDocResult);
|
|
@@ -27273,7 +27273,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27273
27273
|
}
|
|
27274
27274
|
return;
|
|
27275
27275
|
}
|
|
27276
|
-
assert(logger$
|
|
27276
|
+
assert(logger$3A, isTextKindBlock(editor, block), "not a text block");
|
|
27277
27277
|
if (isEmptyTextBlock(editor, block)) {
|
|
27278
27278
|
const blockIndex2 = getBlockIndex(block);
|
|
27279
27279
|
let lastBlock22;
|
|
@@ -27405,11 +27405,11 @@ var __publicField = (obj, key, value) => {
|
|
|
27405
27405
|
editor.deleteBlock(block);
|
|
27406
27406
|
}
|
|
27407
27407
|
}
|
|
27408
|
-
const logger$
|
|
27408
|
+
const logger$3z = getLogger("add-text-attribute");
|
|
27409
27409
|
function editorRemoveTextAttribute(editor, block, range, attributeName) {
|
|
27410
27410
|
const { start, end } = range;
|
|
27411
|
-
assert(logger$
|
|
27412
|
-
assert(logger$
|
|
27411
|
+
assert(logger$3z, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
27412
|
+
assert(logger$3z, attributeName, "invalid attribute name");
|
|
27413
27413
|
const oldText = editor.getBlockText(block);
|
|
27414
27414
|
const newText = rangeRemoveAttribute(start.offset, end.offset - start.offset, oldText, attributeName, void 0, { ignoreValue: true });
|
|
27415
27415
|
editor.setBlockText(block, newText);
|
|
@@ -27417,8 +27417,8 @@ var __publicField = (obj, key, value) => {
|
|
|
27417
27417
|
}
|
|
27418
27418
|
function editorAddTextAttribute(editor, block, range, attributeName, value) {
|
|
27419
27419
|
const { start, end } = range;
|
|
27420
|
-
assert(logger$
|
|
27421
|
-
assert(logger$
|
|
27420
|
+
assert(logger$3z, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
27421
|
+
assert(logger$3z, attributeName, "invalid attribute name");
|
|
27422
27422
|
const oldText = editor.getBlockText(block);
|
|
27423
27423
|
const newText = rangeAddAttribute(start.offset, end.offset - start.offset, oldText, attributeName, value);
|
|
27424
27424
|
editor.setBlockText(block, newText);
|
|
@@ -27426,7 +27426,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27426
27426
|
}
|
|
27427
27427
|
function editorSetTextColor(editor, block, range, type, value) {
|
|
27428
27428
|
const { start, end } = range;
|
|
27429
|
-
assert(logger$
|
|
27429
|
+
assert(logger$3z, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
27430
27430
|
const oldText = editor.getBlockText(block);
|
|
27431
27431
|
const newText = rangeSetTextColor(start.offset, end.offset - start.offset, oldText, type, value);
|
|
27432
27432
|
editor.setBlockText(block, newText);
|
|
@@ -27515,10 +27515,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27515
27515
|
});
|
|
27516
27516
|
return [color, backgroundColor];
|
|
27517
27517
|
}
|
|
27518
|
-
const logger$
|
|
27518
|
+
const logger$3y = getLogger("move-complex-block-position");
|
|
27519
27519
|
function moveComplexBlockPosition(editor, old, type) {
|
|
27520
27520
|
const block = editor.getBlockById(old.blockId);
|
|
27521
|
-
assert(logger$
|
|
27521
|
+
assert(logger$3y, isComplexKindBlock(editor, block), "is not a complex block");
|
|
27522
27522
|
const blockClass = getComplexBlockClass(editor, block);
|
|
27523
27523
|
const focusedContainer = editor.getContainerById(old.childContainerId);
|
|
27524
27524
|
const nextContainer = blockClass.getNextContainer(editor, block, focusedContainer, type, { noWrap: true });
|
|
@@ -27527,24 +27527,24 @@ var __publicField = (obj, key, value) => {
|
|
|
27527
27527
|
}
|
|
27528
27528
|
return createComplexBlockPosition(block, getContainerId(nextContainer));
|
|
27529
27529
|
}
|
|
27530
|
-
const logger$
|
|
27530
|
+
const logger$3x = getLogger("move-simple-block-position");
|
|
27531
27531
|
function getFirstChildBlockInComplexBlock(editor, complexBlock) {
|
|
27532
27532
|
const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
|
|
27533
27533
|
if (containers.length === 0) {
|
|
27534
|
-
logger$
|
|
27534
|
+
logger$3x.warn("complex block has not any child container, not loaded?");
|
|
27535
27535
|
return null;
|
|
27536
27536
|
}
|
|
27537
|
-
assert(logger$
|
|
27537
|
+
assert(logger$3x, containers.length > 0, "complex block has not any child container");
|
|
27538
27538
|
const container = containers[0];
|
|
27539
27539
|
return getFirstChildBlock(container);
|
|
27540
27540
|
}
|
|
27541
27541
|
function getLastChildBlockInComplexBlock(editor, complexBlock) {
|
|
27542
27542
|
const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
|
|
27543
27543
|
if (containers.length === 0) {
|
|
27544
|
-
logger$
|
|
27544
|
+
logger$3x.warn("complex block has not any child container, not loaded?");
|
|
27545
27545
|
return null;
|
|
27546
27546
|
}
|
|
27547
|
-
assert(logger$
|
|
27547
|
+
assert(logger$3x, containers.length > 0, "complex block has not any child container");
|
|
27548
27548
|
const container = containers[containers.length - 1];
|
|
27549
27549
|
return getLastChildBlock(container);
|
|
27550
27550
|
}
|
|
@@ -27589,8 +27589,8 @@ var __publicField = (obj, key, value) => {
|
|
|
27589
27589
|
return null;
|
|
27590
27590
|
}
|
|
27591
27591
|
const parentComplexBlock = getParentBlock(container);
|
|
27592
|
-
assert(logger$
|
|
27593
|
-
assert(logger$
|
|
27592
|
+
assert(logger$3x, parentComplexBlock, "child container has not parent block");
|
|
27593
|
+
assert(logger$3x, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
|
|
27594
27594
|
const nextContainer = getComplexBlockClass(editor, parentComplexBlock).getNextContainer(editor, parentComplexBlock, container, type);
|
|
27595
27595
|
if (nextContainer) {
|
|
27596
27596
|
if (isFindPrev(type)) {
|
|
@@ -27612,7 +27612,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27612
27612
|
return null;
|
|
27613
27613
|
}
|
|
27614
27614
|
const parentBlock = getParentBlock(container);
|
|
27615
|
-
assert(logger$
|
|
27615
|
+
assert(logger$3x, parentBlock, "child container has not parent block");
|
|
27616
27616
|
if (isFindPrev(type)) {
|
|
27617
27617
|
const prev = getPrevBlock(parentBlock);
|
|
27618
27618
|
if (prev) {
|
|
@@ -27667,7 +27667,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27667
27667
|
}
|
|
27668
27668
|
if (!targetBlock) {
|
|
27669
27669
|
if (isComplexKindBlock(editor, block) && complexBlockGetAllChildContainers(editor, block).length === 0) {
|
|
27670
|
-
logger$
|
|
27670
|
+
logger$3x.warn("complex block has not any child container, not loaded?");
|
|
27671
27671
|
targetBlock = direction === "ArrowDown" || direction === "ArrowRight" ? getNextVisibleBlock(block) : getPrevVisibleBlock(block);
|
|
27672
27672
|
}
|
|
27673
27673
|
}
|
|
@@ -27814,10 +27814,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27814
27814
|
editorAdjustSelection(editor, "ArrowUp", "select");
|
|
27815
27815
|
return true;
|
|
27816
27816
|
}
|
|
27817
|
-
const logger$
|
|
27817
|
+
const logger$3w = getLogger("word-offset");
|
|
27818
27818
|
function editorGetWordLeftPos(editor, type) {
|
|
27819
27819
|
const old = editor.selection.range.focus;
|
|
27820
|
-
assert(logger$
|
|
27820
|
+
assert(logger$3w, old.isSimple(), "invalid range type");
|
|
27821
27821
|
const block = editor.getBlockById(old.blockId);
|
|
27822
27822
|
if (isEmptyTextBlock(editor, block)) {
|
|
27823
27823
|
return createSimpleBlockPosition(block, 0, "home");
|
|
@@ -27842,7 +27842,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27842
27842
|
}
|
|
27843
27843
|
function editorGetWordRightPos(editor, type) {
|
|
27844
27844
|
const old = editor.selection.range.focus;
|
|
27845
|
-
assert(logger$
|
|
27845
|
+
assert(logger$3w, old.isSimple(), "invalid range type");
|
|
27846
27846
|
const block = editor.getBlockById(old.blockId);
|
|
27847
27847
|
if (isEmptyTextBlock(editor, block)) {
|
|
27848
27848
|
return createSimpleBlockPosition(block, 0, "end");
|
|
@@ -27954,10 +27954,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27954
27954
|
editor.selection.setSelection(editor.selection.getAnchorPos(), pos);
|
|
27955
27955
|
return true;
|
|
27956
27956
|
}
|
|
27957
|
-
const logger$
|
|
27957
|
+
const logger$3v = getLogger("line-offset");
|
|
27958
27958
|
function editorGetLineHomePos(editor) {
|
|
27959
27959
|
const old = editor.selection.range.focus;
|
|
27960
|
-
assert(logger$
|
|
27960
|
+
assert(logger$3v, old.isSimple(), "invalid range type");
|
|
27961
27961
|
const block = editor.getBlockById(old.blockId);
|
|
27962
27962
|
if (old.offset === 0 || !isTextKindBlock(editor, block)) {
|
|
27963
27963
|
const newPos2 = createSimpleBlockPosition(block, 0, "home");
|
|
@@ -27974,7 +27974,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27974
27974
|
}
|
|
27975
27975
|
function editorGetLineEndPos(editor) {
|
|
27976
27976
|
const old = editor.selection.range.focus;
|
|
27977
|
-
assert(logger$
|
|
27977
|
+
assert(logger$3v, old.isSimple(), "invalid range type");
|
|
27978
27978
|
const block = editor.getBlockById(old.blockId);
|
|
27979
27979
|
if (old.offset === getBlockTextLength$6(editor, block) || !isTextKindBlock(editor, block)) {
|
|
27980
27980
|
const newPos2 = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
|
|
@@ -28074,7 +28074,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28074
28074
|
editorPageDownScroll(editor);
|
|
28075
28075
|
return true;
|
|
28076
28076
|
}
|
|
28077
|
-
const logger$
|
|
28077
|
+
const logger$3u = getLogger("table-scroll");
|
|
28078
28078
|
class DomEventHandler {
|
|
28079
28079
|
constructor(editor, dom, name, handler, data2, options) {
|
|
28080
28080
|
__publicField(this, "handleEvent", (event) => {
|
|
@@ -28106,7 +28106,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28106
28106
|
const existsHandlers = this.handlers.get(element);
|
|
28107
28107
|
if (existsHandlers) {
|
|
28108
28108
|
if (existsHandlers.find((handler) => handler.handler === eventHandler && handler.name === eventName)) {
|
|
28109
|
-
logger$
|
|
28109
|
+
logger$3u.warn(`event has already registered: ${eventName}`);
|
|
28110
28110
|
return;
|
|
28111
28111
|
}
|
|
28112
28112
|
existsHandlers.push(new DomEventHandler(this.editor, element, eventName, eventHandler, data2, options));
|
|
@@ -28216,7 +28216,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28216
28216
|
});
|
|
28217
28217
|
return true;
|
|
28218
28218
|
}
|
|
28219
|
-
const logger$
|
|
28219
|
+
const logger$3t = getLogger("select-all");
|
|
28220
28220
|
function isContainerSelectedAllChildBlocks(container, range) {
|
|
28221
28221
|
const firstBlock = getFirstChildBlock(container);
|
|
28222
28222
|
const lastBlock2 = getLastChildBlock(container);
|
|
@@ -28231,8 +28231,8 @@ var __publicField = (obj, key, value) => {
|
|
|
28231
28231
|
return range.start.blockId === blockId && range.start.childContainerId === getContainerId(first) && range.end.blockId === blockId && range.end.childContainerId === getContainerId(last);
|
|
28232
28232
|
}
|
|
28233
28233
|
function selectComplexBlock(editor, block) {
|
|
28234
|
-
assert(logger$
|
|
28235
|
-
assert(logger$
|
|
28234
|
+
assert(logger$3t, block, "no parent block");
|
|
28235
|
+
assert(logger$3t, isComplexKindBlock(editor, block), "not a complex block");
|
|
28236
28236
|
const containers = getComplexBlockClass(editor, block).getChildContainers(editor, block);
|
|
28237
28237
|
const first = containers[0];
|
|
28238
28238
|
const last = containers[containers.length - 1];
|
|
@@ -28268,13 +28268,13 @@ var __publicField = (obj, key, value) => {
|
|
|
28268
28268
|
selectParentContainer(editor, getFirstChildBlock(editor.rootContainer));
|
|
28269
28269
|
return false;
|
|
28270
28270
|
}
|
|
28271
|
-
assert(logger$
|
|
28271
|
+
assert(logger$3t, !range.isSimple(), "invalid range type");
|
|
28272
28272
|
if (isComplexBlockSelectedAllChildContainer(focusedBlock, range)) {
|
|
28273
28273
|
selectParentContainer(editor, focusedBlock);
|
|
28274
28274
|
return false;
|
|
28275
28275
|
}
|
|
28276
|
-
assert(logger$
|
|
28277
|
-
assert(logger$
|
|
28276
|
+
assert(logger$3t, focusedBlock, "no parent block");
|
|
28277
|
+
assert(logger$3t, isComplexKindBlock(editor, focusedBlock), "not a complex block");
|
|
28278
28278
|
selectComplexBlock(editor, focusedBlock);
|
|
28279
28279
|
return true;
|
|
28280
28280
|
}
|
|
@@ -28413,7 +28413,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28413
28413
|
}
|
|
28414
28414
|
return cloned;
|
|
28415
28415
|
}
|
|
28416
|
-
const logger$
|
|
28416
|
+
const logger$3s = getLogger("selected-block-to-doc");
|
|
28417
28417
|
function appendBlockChildren(editor, data2, doc2) {
|
|
28418
28418
|
if (!data2.children)
|
|
28419
28419
|
return;
|
|
@@ -28434,7 +28434,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28434
28434
|
if (isTextKindBlock(editor, selectedBlock.block)) {
|
|
28435
28435
|
const start = selectedBlock.start;
|
|
28436
28436
|
const end = selectedBlock.end;
|
|
28437
|
-
assert(logger$
|
|
28437
|
+
assert(logger$3s, data2.text, "no block text");
|
|
28438
28438
|
if (start.offset === end.offset) {
|
|
28439
28439
|
return {
|
|
28440
28440
|
blocks: {
|
|
@@ -28468,8 +28468,8 @@ var __publicField = (obj, key, value) => {
|
|
|
28468
28468
|
comments: {}
|
|
28469
28469
|
};
|
|
28470
28470
|
}
|
|
28471
|
-
assert(logger$
|
|
28472
|
-
assert(logger$
|
|
28471
|
+
assert(logger$3s, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
|
|
28472
|
+
assert(logger$3s, data2.children, "no children");
|
|
28473
28473
|
const ret = {
|
|
28474
28474
|
blocks: {
|
|
28475
28475
|
root: [
|
|
@@ -28487,9 +28487,9 @@ var __publicField = (obj, key, value) => {
|
|
|
28487
28487
|
const end = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
|
|
28488
28488
|
return selectedBlockToDoc(editor, { block, start, end });
|
|
28489
28489
|
}
|
|
28490
|
-
const logger$
|
|
28490
|
+
const logger$3r = getLogger("block-to-doc");
|
|
28491
28491
|
function blocksToDoc(editor, blocks) {
|
|
28492
|
-
assert(logger$
|
|
28492
|
+
assert(logger$3r, blocks.length > 0, "invalid params, no blocks");
|
|
28493
28493
|
const docs = blocks.map((b) => blockToDoc(editor, b));
|
|
28494
28494
|
return mergeDocs(docs);
|
|
28495
28495
|
}
|
|
@@ -28509,7 +28509,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28509
28509
|
const newDocs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s));
|
|
28510
28510
|
return mergeDocs(newDocs);
|
|
28511
28511
|
}
|
|
28512
|
-
const logger$
|
|
28512
|
+
const logger$3q = getLogger("ensure-block-visible");
|
|
28513
28513
|
function ensureBlockVisible(editor, block) {
|
|
28514
28514
|
var _a;
|
|
28515
28515
|
while (block) {
|
|
@@ -28519,16 +28519,16 @@ var __publicField = (obj, key, value) => {
|
|
|
28519
28519
|
return;
|
|
28520
28520
|
}
|
|
28521
28521
|
const parentComplexBlock = getParentBlock(container);
|
|
28522
|
-
assert(logger$
|
|
28522
|
+
assert(logger$3q, parentComplexBlock, "no parent block");
|
|
28523
28523
|
const parentComplexBlockClass = getBlockClass(editor, parentComplexBlock);
|
|
28524
28524
|
if (parentComplexBlockClass.isChildContainerVisible && !((_a = parentComplexBlockClass.isChildContainerVisible) == null ? void 0 : _a.call(parentComplexBlockClass, editor, parentComplexBlock, container))) {
|
|
28525
|
-
assert(logger$
|
|
28525
|
+
assert(logger$3q, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
|
|
28526
28526
|
parentComplexBlockClass.showChildContainer(editor, parentComplexBlock, container);
|
|
28527
28527
|
}
|
|
28528
28528
|
block = parentComplexBlock;
|
|
28529
28529
|
}
|
|
28530
28530
|
}
|
|
28531
|
-
const logger$
|
|
28531
|
+
const logger$3p = getLogger("editor-selection");
|
|
28532
28532
|
class EditorSelection {
|
|
28533
28533
|
constructor(editor) {
|
|
28534
28534
|
__publicField(this, "editor");
|
|
@@ -28541,7 +28541,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28541
28541
|
}
|
|
28542
28542
|
const range = this.range;
|
|
28543
28543
|
if (rangeInBlock(deletedBlock, range)) {
|
|
28544
|
-
logger$
|
|
28544
|
+
logger$3p.debug("adjust selection because remote deleted current block");
|
|
28545
28545
|
const newRange = moveSelectionBeforeDeleteBlock(editor, deletedBlock);
|
|
28546
28546
|
this.setRange(newRange, { noScroll: true });
|
|
28547
28547
|
}
|
|
@@ -28666,14 +28666,14 @@ var __publicField = (obj, key, value) => {
|
|
|
28666
28666
|
if (pos.isSimple()) {
|
|
28667
28667
|
const ok = pos.offset >= 0 && pos.offset <= getBlockTextLength$6(this.editor, block);
|
|
28668
28668
|
if (!ok) {
|
|
28669
|
-
assert(logger$
|
|
28669
|
+
assert(logger$3p, false, "invalid block position, out of range");
|
|
28670
28670
|
}
|
|
28671
28671
|
} else {
|
|
28672
28672
|
const childContainerId = pos.childContainerId;
|
|
28673
28673
|
const container = this.editor.getContainerById(childContainerId);
|
|
28674
28674
|
const ok = !!container;
|
|
28675
28675
|
if (!ok) {
|
|
28676
|
-
assert(logger$
|
|
28676
|
+
assert(logger$3p, false, "invalid complex block position, no container found");
|
|
28677
28677
|
}
|
|
28678
28678
|
}
|
|
28679
28679
|
}
|
|
@@ -28734,7 +28734,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28734
28734
|
let container = getParentContainer(block);
|
|
28735
28735
|
while (isChildContainer(container)) {
|
|
28736
28736
|
const parentBlock = getParentBlock(container);
|
|
28737
|
-
assert(logger$
|
|
28737
|
+
assert(logger$3p, parentBlock, "parent block not found");
|
|
28738
28738
|
addClass(parentBlock, "child-focused");
|
|
28739
28739
|
container = getParentContainer(parentBlock);
|
|
28740
28740
|
}
|
|
@@ -28844,15 +28844,15 @@ var __publicField = (obj, key, value) => {
|
|
|
28844
28844
|
editor.undoManager.redo();
|
|
28845
28845
|
return true;
|
|
28846
28846
|
}
|
|
28847
|
-
const logger$
|
|
28847
|
+
const logger$3o = getLogger("delete-text");
|
|
28848
28848
|
function editorDeleteText(editor, type, count, insertPos) {
|
|
28849
28849
|
const pos = insertPos != null ? insertPos : editor.selection.range.start;
|
|
28850
28850
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
28851
|
-
assert(logger$
|
|
28851
|
+
assert(logger$3o, false, `invalid insert pos type: ${typeof pos}`);
|
|
28852
28852
|
}
|
|
28853
28853
|
const { blockId } = pos;
|
|
28854
28854
|
const block = editor.getBlockById(blockId);
|
|
28855
|
-
assert(logger$
|
|
28855
|
+
assert(logger$3o, isTextKindBlock(editor, block), "block is not a text kind block");
|
|
28856
28856
|
let { offset } = pos;
|
|
28857
28857
|
if (type === "backward") {
|
|
28858
28858
|
if (offset - count < 0) {
|
|
@@ -28882,7 +28882,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28882
28882
|
}
|
|
28883
28883
|
return false;
|
|
28884
28884
|
}
|
|
28885
|
-
const logger$
|
|
28885
|
+
const logger$3n = getLogger("handle-backspace");
|
|
28886
28886
|
function tryDeleteEmptyBlock(editor, block) {
|
|
28887
28887
|
if (!isEmptyTextBlock(editor, block)) {
|
|
28888
28888
|
return;
|
|
@@ -28922,7 +28922,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28922
28922
|
}
|
|
28923
28923
|
} else {
|
|
28924
28924
|
tryDeleteEmptyBlock(editor, block);
|
|
28925
|
-
assert(logger$
|
|
28925
|
+
assert(logger$3n, isEmbedBlock(prevBlock), "prev block is not embed block");
|
|
28926
28926
|
editor.selection.selectBlock(prevBlock, 1);
|
|
28927
28927
|
}
|
|
28928
28928
|
} else {
|
|
@@ -28949,7 +28949,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28949
28949
|
editor.deleteBlock(block);
|
|
28950
28950
|
}
|
|
28951
28951
|
}
|
|
28952
|
-
const logger$
|
|
28952
|
+
const logger$3m = getLogger("word-offset");
|
|
28953
28953
|
function handleEditorDelete(editor, event) {
|
|
28954
28954
|
if (!editor.selection.range.isCollapsed()) {
|
|
28955
28955
|
editor.clearSelectedContents();
|
|
@@ -28986,7 +28986,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28986
28986
|
}
|
|
28987
28987
|
function handleEditorDeleteLeftWord(editor, event) {
|
|
28988
28988
|
const old = editor.selection.range.focus;
|
|
28989
|
-
assert(logger$
|
|
28989
|
+
assert(logger$3m, old.isSimple(), "invalid range type");
|
|
28990
28990
|
const block = editor.getBlockById(old.blockId);
|
|
28991
28991
|
if (!isTextKindBlock(editor, block)) {
|
|
28992
28992
|
editor.deleteBlock(block);
|
|
@@ -29028,7 +29028,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29028
29028
|
}
|
|
29029
29029
|
function handleEditorDeleteRightWord(editor, event) {
|
|
29030
29030
|
const old = editor.selection.range.focus;
|
|
29031
|
-
assert(logger$
|
|
29031
|
+
assert(logger$3m, old.isSimple(), "invalid range type");
|
|
29032
29032
|
const block = editor.getBlockById(old.blockId);
|
|
29033
29033
|
if (!isTextKindBlock(editor, block)) {
|
|
29034
29034
|
editor.deleteBlock(block);
|
|
@@ -29069,7 +29069,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29069
29069
|
}
|
|
29070
29070
|
function handleEditorDeleteAfterWords(editor) {
|
|
29071
29071
|
const old = editor.selection.range.focus;
|
|
29072
|
-
assert(logger$
|
|
29072
|
+
assert(logger$3m, old.isSimple(), "invalid range type");
|
|
29073
29073
|
const block = editor.getBlockById(old.blockId);
|
|
29074
29074
|
if (!isTextKindBlock(editor, block)) {
|
|
29075
29075
|
editor.deleteBlock(block);
|
|
@@ -29082,7 +29082,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29082
29082
|
}
|
|
29083
29083
|
function handleEditorDeleteRightChar(editor) {
|
|
29084
29084
|
const old = editor.selection.range.focus;
|
|
29085
|
-
assert(logger$
|
|
29085
|
+
assert(logger$3m, old.isSimple(), "invalid range type");
|
|
29086
29086
|
const block = editor.getBlockById(old.blockId);
|
|
29087
29087
|
if (!isTextKindBlock(editor, block)) {
|
|
29088
29088
|
editor.deleteBlock(block);
|
|
@@ -29310,7 +29310,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29310
29310
|
const doc2 = blockToDoc(editor, block);
|
|
29311
29311
|
editorCopyDoc(editor, doc2);
|
|
29312
29312
|
}
|
|
29313
|
-
const logger$
|
|
29313
|
+
const logger$3l = getLogger("input-handler-actions");
|
|
29314
29314
|
function editorHandleEnter(editor, event) {
|
|
29315
29315
|
if (editor.readonly || !editor.isWritable()) {
|
|
29316
29316
|
return false;
|
|
@@ -29392,7 +29392,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29392
29392
|
toPlainText: true
|
|
29393
29393
|
});
|
|
29394
29394
|
}).catch((err) => {
|
|
29395
|
-
logger$
|
|
29395
|
+
logger$3l.error(err);
|
|
29396
29396
|
});
|
|
29397
29397
|
return true;
|
|
29398
29398
|
}
|
|
@@ -30178,14 +30178,14 @@ ${codeText}
|
|
|
30178
30178
|
editor.selection.updateSelection(null, { focusBlockChanged: true });
|
|
30179
30179
|
});
|
|
30180
30180
|
}
|
|
30181
|
-
const logger$
|
|
30181
|
+
const logger$3k = getLogger("transform-selection");
|
|
30182
30182
|
function transformSelection(editor, blockId, delta, local) {
|
|
30183
30183
|
const { range } = editor.selection;
|
|
30184
30184
|
const { anchor: anchor2, focus } = range;
|
|
30185
30185
|
if (anchor2.blockId !== blockId && focus.blockId !== blockId) {
|
|
30186
30186
|
return range;
|
|
30187
30187
|
}
|
|
30188
|
-
assert(logger$
|
|
30188
|
+
assert(logger$3k, anchor2.isSimple() && focus.isSimple(), "invalid text pos type");
|
|
30189
30189
|
let newAnchor = anchor2;
|
|
30190
30190
|
if (anchor2.blockId === blockId) {
|
|
30191
30191
|
const newOffset = RichText.transformCursor(anchor2.offset, delta, local);
|
|
@@ -30198,12 +30198,12 @@ ${codeText}
|
|
|
30198
30198
|
}
|
|
30199
30199
|
return createEditorSelectionRange(editor, { anchor: newAnchor, focus: newFocus });
|
|
30200
30200
|
}
|
|
30201
|
-
const logger$
|
|
30201
|
+
const logger$3j = getLogger("handle-block-text-changed");
|
|
30202
30202
|
function onBlockTextChanged(editor, containerId, blockIndex, actions2, local) {
|
|
30203
30203
|
const container = editor.getContainerById(containerId);
|
|
30204
30204
|
const block = getBlockByIndex(container, blockIndex);
|
|
30205
30205
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
30206
|
-
assert(logger$
|
|
30206
|
+
assert(logger$3j, blockData.text, "no block text");
|
|
30207
30207
|
getTextBlockClass(editor, block).setBlockText(editor, block, blockData.text);
|
|
30208
30208
|
if (!local) {
|
|
30209
30209
|
const newRange = transformSelection(editor, blockData.id, actions2, local);
|
|
@@ -30235,7 +30235,7 @@ ${codeText}
|
|
|
30235
30235
|
});
|
|
30236
30236
|
handleDeleteBlock$8(editor, block, local, { child: false });
|
|
30237
30237
|
}
|
|
30238
|
-
const logger$
|
|
30238
|
+
const logger$3i = getLogger("editor-doc");
|
|
30239
30239
|
class EditorDoc extends EventCallbacks {
|
|
30240
30240
|
constructor(editor, externalDoc, localEvents) {
|
|
30241
30241
|
super();
|
|
@@ -30274,12 +30274,12 @@ ${codeText}
|
|
|
30274
30274
|
}
|
|
30275
30275
|
verifyBlockWritable(containerId, blockIndex) {
|
|
30276
30276
|
const block = this.editor.getBlockByIndex(containerId, blockIndex);
|
|
30277
|
-
assert(logger$
|
|
30277
|
+
assert(logger$3i, this.editor.isBlockWritable(block), `block is not writable, ${containerId}, ${blockIndex}`);
|
|
30278
30278
|
}
|
|
30279
30279
|
localUpdateBlockText(containerId, blockIndex, actions2, options) {
|
|
30280
30280
|
const blockData = this.getBlockData(containerId, blockIndex);
|
|
30281
30281
|
const oldText = blockData.text;
|
|
30282
|
-
assert(logger$
|
|
30282
|
+
assert(logger$3i, oldText, `no text, ${containerId}, ${blockIndex}`);
|
|
30283
30283
|
const newRange = transformSelection(this.editor, blockData.id, actions2, true);
|
|
30284
30284
|
const newText = RichText.apply(oldText, actions2);
|
|
30285
30285
|
this.localEvents.forEach((event) => event.onBeforeUpdateBlockText(containerId, blockData.id, oldText, newText, newRange.toDocRange()));
|
|
@@ -30293,7 +30293,7 @@ ${codeText}
|
|
|
30293
30293
|
const deletedKeys = Array.from(delta.delete).filter((key) => key !== "comments");
|
|
30294
30294
|
const insertedKeys = Object.keys(delta.insert).filter((key) => key !== "comments");
|
|
30295
30295
|
if (deletedKeys.length > 0 || insertedKeys.length > 0) {
|
|
30296
|
-
assert(logger$
|
|
30296
|
+
assert(logger$3i, false, `block is not writable, comment supported only, ${JSON.stringify(delta)}}`);
|
|
30297
30297
|
}
|
|
30298
30298
|
}
|
|
30299
30299
|
const oldData = cloneDeep__default.default(this.getBlockData(containerId, blockIndex));
|
|
@@ -30304,7 +30304,7 @@ ${codeText}
|
|
|
30304
30304
|
return ret;
|
|
30305
30305
|
}
|
|
30306
30306
|
localInsertBlock(containerId, blockIndex, data2, newRange, options) {
|
|
30307
|
-
assert(logger$
|
|
30307
|
+
assert(logger$3i, !this.editor.readonly, "editor is readonly");
|
|
30308
30308
|
this.localEvents.forEach((event) => event.onBeforeInsertBlock(containerId, blockIndex, data2, newRange));
|
|
30309
30309
|
const ret = this.externalDoc.localInsertBlock(containerId, blockIndex, data2, newRange);
|
|
30310
30310
|
if (!(options == null ? void 0 : options.noFocus)) {
|
|
@@ -30313,7 +30313,7 @@ ${codeText}
|
|
|
30313
30313
|
return ret;
|
|
30314
30314
|
}
|
|
30315
30315
|
localDeleteBlock(containerId, blockIndex, newRange) {
|
|
30316
|
-
assert(logger$
|
|
30316
|
+
assert(logger$3i, !this.editor.readonly, "editor is readonly");
|
|
30317
30317
|
this.verifyBlockWritable(containerId, blockIndex);
|
|
30318
30318
|
const blockData = cloneDeep__default.default(this.getBlockData(containerId, blockIndex));
|
|
30319
30319
|
this.localEvents.forEach((event) => event.onBeforeDeleteBlock(containerId, blockIndex, blockData, newRange));
|
|
@@ -30322,7 +30322,7 @@ ${codeText}
|
|
|
30322
30322
|
return ret;
|
|
30323
30323
|
}
|
|
30324
30324
|
localDeleteChildContainers(containerIds) {
|
|
30325
|
-
assert(logger$
|
|
30325
|
+
assert(logger$3i, !this.editor.readonly, "editor is readonly");
|
|
30326
30326
|
containerIds.forEach((containerId) => {
|
|
30327
30327
|
const blocks = cloneDeep__default.default(this.getContainerBlocks(containerId));
|
|
30328
30328
|
this.localEvents.forEach((event) => event.onBeforeDeleteChildContainer(containerId, blocks));
|
|
@@ -30330,7 +30330,7 @@ ${codeText}
|
|
|
30330
30330
|
return this.externalDoc.localDeleteChildContainers(containerIds);
|
|
30331
30331
|
}
|
|
30332
30332
|
localInsertChildContainers(containers) {
|
|
30333
|
-
assert(logger$
|
|
30333
|
+
assert(logger$3i, !this.editor.readonly, "editor is readonly");
|
|
30334
30334
|
const data2 = cloneDeep__default.default(containers);
|
|
30335
30335
|
data2.forEach((item) => {
|
|
30336
30336
|
this.localEvents.forEach((event) => event.onBeforeInsertChildContainer(item.containerId, item.blocks));
|
|
@@ -30338,7 +30338,7 @@ ${codeText}
|
|
|
30338
30338
|
this.externalDoc.localInsertChildContainers(data2);
|
|
30339
30339
|
}
|
|
30340
30340
|
onRequestReload(reason) {
|
|
30341
|
-
logger$
|
|
30341
|
+
logger$3i.debug(`reload doc: ${reason}`);
|
|
30342
30342
|
this.editor.reload();
|
|
30343
30343
|
this.callbacks.forEach((c) => {
|
|
30344
30344
|
var _a;
|
|
@@ -30446,7 +30446,7 @@ ${codeText}
|
|
|
30446
30446
|
return (_c = (_b = (_a = this.externalDoc).getServerMeta) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
30447
30447
|
}
|
|
30448
30448
|
reset(doc2) {
|
|
30449
|
-
logger$
|
|
30449
|
+
logger$3i.log("reset doc");
|
|
30450
30450
|
this.externalDoc = doc2;
|
|
30451
30451
|
this.externalDoc.registerCallback(this);
|
|
30452
30452
|
this.editor.reload();
|
|
@@ -30464,7 +30464,7 @@ ${codeText}
|
|
|
30464
30464
|
}
|
|
30465
30465
|
last.combine(action);
|
|
30466
30466
|
}
|
|
30467
|
-
const logger$
|
|
30467
|
+
const logger$3h = getLogger("undo-action");
|
|
30468
30468
|
class Action {
|
|
30469
30469
|
constructor(editor, containerId, afterRange, batchActionId) {
|
|
30470
30470
|
__publicField(this, "beforeRange");
|
|
@@ -30486,18 +30486,18 @@ ${codeText}
|
|
|
30486
30486
|
return false;
|
|
30487
30487
|
}
|
|
30488
30488
|
combinable(other) {
|
|
30489
|
-
assert(logger$
|
|
30489
|
+
assert(logger$3h, other, "no other action");
|
|
30490
30490
|
return false;
|
|
30491
30491
|
}
|
|
30492
30492
|
combine(other) {
|
|
30493
|
-
assert(logger$
|
|
30493
|
+
assert(logger$3h, false, "no other");
|
|
30494
30494
|
}
|
|
30495
30495
|
getBatchActionId() {
|
|
30496
30496
|
return this.batchActionId;
|
|
30497
30497
|
}
|
|
30498
30498
|
setAfterRange(range) {
|
|
30499
30499
|
if (this.afterRange) {
|
|
30500
|
-
logger$
|
|
30500
|
+
logger$3h.warn("after range has already set");
|
|
30501
30501
|
}
|
|
30502
30502
|
this.afterRange = range;
|
|
30503
30503
|
}
|
|
@@ -30519,7 +30519,7 @@ ${codeText}
|
|
|
30519
30519
|
const containerId = blockData.children[i];
|
|
30520
30520
|
const container = doc2.blocks[containerId];
|
|
30521
30521
|
if (!container) {
|
|
30522
|
-
logger$
|
|
30522
|
+
logger$3h.warn(`container (${containerId}) not found, deleted by others?`);
|
|
30523
30523
|
return false;
|
|
30524
30524
|
}
|
|
30525
30525
|
}
|
|
@@ -30527,7 +30527,7 @@ ${codeText}
|
|
|
30527
30527
|
return true;
|
|
30528
30528
|
}
|
|
30529
30529
|
}
|
|
30530
|
-
const logger$
|
|
30530
|
+
const logger$3g = getLogger("block-action");
|
|
30531
30531
|
class BlockAction extends Action {
|
|
30532
30532
|
constructor(editor, containerId, blockIndex, data2, afterRange) {
|
|
30533
30533
|
super(editor, containerId, afterRange);
|
|
@@ -30538,7 +30538,7 @@ ${codeText}
|
|
|
30538
30538
|
}
|
|
30539
30539
|
deleteBlock(editor, newRange) {
|
|
30540
30540
|
if (!this.hasDocContainerId(editor, this.containerId)) {
|
|
30541
|
-
logger$
|
|
30541
|
+
logger$3g.warn(`container (${this.containerId}) not found, deleted by others?`);
|
|
30542
30542
|
return false;
|
|
30543
30543
|
}
|
|
30544
30544
|
const container = editor.getContainerById(this.containerId);
|
|
@@ -30552,18 +30552,18 @@ ${codeText}
|
|
|
30552
30552
|
}
|
|
30553
30553
|
insertBlock(editor, newRange) {
|
|
30554
30554
|
if (!this.hasDocContainerId(editor, this.containerId)) {
|
|
30555
|
-
logger$
|
|
30555
|
+
logger$3g.warn(`container (${this.containerId}) not found, deleted by others?`);
|
|
30556
30556
|
return false;
|
|
30557
30557
|
}
|
|
30558
30558
|
if (!this.checkBlockData(editor, this.blockData)) {
|
|
30559
30559
|
return false;
|
|
30560
30560
|
}
|
|
30561
30561
|
if (!editor.findBlockByIndex(this.containerId, Math.max(0, this.blockIndex - 1))) {
|
|
30562
|
-
logger$
|
|
30562
|
+
logger$3g.warn(`block (${Math.max(0, this.blockIndex - 1)}) not found, deleted by others?`);
|
|
30563
30563
|
return false;
|
|
30564
30564
|
}
|
|
30565
30565
|
if (editor.findBlockById(this.blockData.id)) {
|
|
30566
|
-
logger$
|
|
30566
|
+
logger$3g.warn(`block (${this.blockData.id}) already exists, inserted by others?`);
|
|
30567
30567
|
return false;
|
|
30568
30568
|
}
|
|
30569
30569
|
editorInsertBlock(editor, this.containerId, this.blockIndex, cloneDeep__default.default(this.blockData), newRange);
|
|
@@ -30633,7 +30633,7 @@ ${codeText}
|
|
|
30633
30633
|
}
|
|
30634
30634
|
}
|
|
30635
30635
|
}
|
|
30636
|
-
const logger$
|
|
30636
|
+
const logger$3f = getLogger("update-block-data-action");
|
|
30637
30637
|
class UpdateBlockDataAction extends Action {
|
|
30638
30638
|
constructor(editor, containerId, blockId, oldData, newData, newRange) {
|
|
30639
30639
|
super(editor, containerId, newRange);
|
|
@@ -30641,15 +30641,15 @@ ${codeText}
|
|
|
30641
30641
|
__publicField(this, "afterBlockData");
|
|
30642
30642
|
__publicField(this, "blockId");
|
|
30643
30643
|
this.blockId = blockId;
|
|
30644
|
-
assert(logger$
|
|
30645
|
-
assert(logger$
|
|
30644
|
+
assert(logger$3f, this.blockId === oldData.id, "invalid block id");
|
|
30645
|
+
assert(logger$3f, this.blockId === newData.id, "invalid block id");
|
|
30646
30646
|
this.beforeBlockData = cloneDeep__default.default(oldData);
|
|
30647
30647
|
this.afterBlockData = cloneDeep__default.default(newData);
|
|
30648
|
-
assert(logger$
|
|
30648
|
+
assert(logger$3f, this.beforeBlockData.type === this.afterBlockData.type, "invalid block type");
|
|
30649
30649
|
}
|
|
30650
30650
|
undo(editor) {
|
|
30651
30651
|
if (!editor.findBlockById(this.blockId)) {
|
|
30652
|
-
logger$
|
|
30652
|
+
logger$3f.warn(`block (${this.blockId}) not found, deleted by others?`);
|
|
30653
30653
|
return false;
|
|
30654
30654
|
}
|
|
30655
30655
|
const block = editor.getBlockById(this.blockId);
|
|
@@ -30659,16 +30659,16 @@ ${codeText}
|
|
|
30659
30659
|
return false;
|
|
30660
30660
|
}
|
|
30661
30661
|
const container = editor.getContainerById(this.containerId);
|
|
30662
|
-
assert(logger$
|
|
30662
|
+
assert(logger$3f, container, "no container");
|
|
30663
30663
|
editorUpdateBlockData(editor, block, UpdateBlockDataAction.toAttributes(this.beforeBlockData), this.beforeRange);
|
|
30664
30664
|
return true;
|
|
30665
30665
|
}
|
|
30666
30666
|
redo(editor) {
|
|
30667
30667
|
if (!editor.findBlockById(this.blockId)) {
|
|
30668
|
-
logger$
|
|
30668
|
+
logger$3f.warn(`block (${this.blockId}) not found, deleted by others?`);
|
|
30669
30669
|
return false;
|
|
30670
30670
|
}
|
|
30671
|
-
assert(logger$
|
|
30671
|
+
assert(logger$3f, editor, "no editor");
|
|
30672
30672
|
const block = editor.getBlockById(this.blockId);
|
|
30673
30673
|
if (!block)
|
|
30674
30674
|
return false;
|
|
@@ -30676,7 +30676,7 @@ ${codeText}
|
|
|
30676
30676
|
return false;
|
|
30677
30677
|
}
|
|
30678
30678
|
const container = editor.getContainerById(this.containerId);
|
|
30679
|
-
assert(logger$
|
|
30679
|
+
assert(logger$3f, container, "no container");
|
|
30680
30680
|
editorUpdateBlockData(editor, block, UpdateBlockDataAction.toAttributes(this.afterBlockData), this.afterRange);
|
|
30681
30681
|
return true;
|
|
30682
30682
|
}
|
|
@@ -30690,7 +30690,7 @@ ${codeText}
|
|
|
30690
30690
|
return `block-${this.blockId}`;
|
|
30691
30691
|
}
|
|
30692
30692
|
}
|
|
30693
|
-
const logger$
|
|
30693
|
+
const logger$3e = getLogger("update-block-text-action");
|
|
30694
30694
|
class UpdateBlockTextAction extends Action {
|
|
30695
30695
|
constructor(editor, container, blockId, oldData, newData, newRange) {
|
|
30696
30696
|
super(editor, container, newRange);
|
|
@@ -30704,8 +30704,8 @@ ${codeText}
|
|
|
30704
30704
|
this.type = UpdateBlockTextAction.calType(oldData, newData);
|
|
30705
30705
|
}
|
|
30706
30706
|
static calType(oldData, newData) {
|
|
30707
|
-
assert(logger$
|
|
30708
|
-
assert(logger$
|
|
30707
|
+
assert(logger$3e, oldData, "no old data");
|
|
30708
|
+
assert(logger$3e, newData, "no new data");
|
|
30709
30709
|
const diff = RichText.diff(oldData, newData);
|
|
30710
30710
|
const ops = diff;
|
|
30711
30711
|
const type = /* @__PURE__ */ new Set();
|
|
@@ -30748,11 +30748,11 @@ ${codeText}
|
|
|
30748
30748
|
}
|
|
30749
30749
|
undo(editor) {
|
|
30750
30750
|
if (!this.hasDocContainerId(editor, this.containerId)) {
|
|
30751
|
-
logger$
|
|
30751
|
+
logger$3e.warn(`container (${this.containerId}) not found, deleted by others?`);
|
|
30752
30752
|
return false;
|
|
30753
30753
|
}
|
|
30754
30754
|
if (!this.findDocBlockById(editor, this.blockId)) {
|
|
30755
|
-
logger$
|
|
30755
|
+
logger$3e.warn(`block (${this.blockId}) not found, deleted by others?`);
|
|
30756
30756
|
return false;
|
|
30757
30757
|
}
|
|
30758
30758
|
const container = editor.getContainerById(this.containerId);
|
|
@@ -30766,11 +30766,11 @@ ${codeText}
|
|
|
30766
30766
|
}
|
|
30767
30767
|
redo(editor) {
|
|
30768
30768
|
if (!this.hasDocContainerId(editor, this.containerId)) {
|
|
30769
|
-
logger$
|
|
30769
|
+
logger$3e.warn(`container (${this.containerId}) not found, deleted by others?`);
|
|
30770
30770
|
return false;
|
|
30771
30771
|
}
|
|
30772
30772
|
if (!this.findDocBlockById(editor, this.blockId)) {
|
|
30773
|
-
logger$
|
|
30773
|
+
logger$3e.warn(`block (${this.blockId}) not found, deleted by others?`);
|
|
30774
30774
|
return false;
|
|
30775
30775
|
}
|
|
30776
30776
|
const container = editor.getContainerById(this.containerId);
|
|
@@ -30809,13 +30809,13 @@ ${codeText}
|
|
|
30809
30809
|
return true;
|
|
30810
30810
|
}
|
|
30811
30811
|
combine(other) {
|
|
30812
|
-
assert(logger$
|
|
30812
|
+
assert(logger$3e, other instanceof UpdateBlockTextAction, "invalid action type");
|
|
30813
30813
|
const last = other;
|
|
30814
30814
|
this.afterRichTextData = last.afterRichTextData;
|
|
30815
30815
|
this.afterRange = other.afterRange;
|
|
30816
30816
|
}
|
|
30817
30817
|
}
|
|
30818
|
-
const logger$
|
|
30818
|
+
const logger$3d = getLogger("child-container-action");
|
|
30819
30819
|
class ChildContainerAction extends Action {
|
|
30820
30820
|
constructor(editor, containerId, blocks) {
|
|
30821
30821
|
super(editor, containerId, editor.selection.range.toDocRange());
|
|
@@ -30823,7 +30823,7 @@ ${codeText}
|
|
|
30823
30823
|
}
|
|
30824
30824
|
deleteChildContainer(editor) {
|
|
30825
30825
|
if (!this.hasDocContainerId(editor, this.containerId)) {
|
|
30826
|
-
logger$
|
|
30826
|
+
logger$3d.warn(`container (${this.containerId}) not found, deleted by others?`);
|
|
30827
30827
|
return false;
|
|
30828
30828
|
}
|
|
30829
30829
|
editor.doc.localDeleteChildContainers([this.containerId]);
|
|
@@ -30831,7 +30831,7 @@ ${codeText}
|
|
|
30831
30831
|
}
|
|
30832
30832
|
insertChildContainer(editor) {
|
|
30833
30833
|
if (this.hasDocContainerId(editor, this.containerId)) {
|
|
30834
|
-
logger$
|
|
30834
|
+
logger$3d.warn(`container (${this.containerId}) already exists`);
|
|
30835
30835
|
return false;
|
|
30836
30836
|
}
|
|
30837
30837
|
editor.doc.localInsertChildContainers([{ containerId: this.containerId, blocks: cloneDeep__default.default(this.blocks) }]);
|
|
@@ -30855,7 +30855,7 @@ ${codeText}
|
|
|
30855
30855
|
}
|
|
30856
30856
|
}
|
|
30857
30857
|
const BATCH_ACTION_TS = 1e3 * 3;
|
|
30858
|
-
const logger$
|
|
30858
|
+
const logger$3c = getLogger("undo");
|
|
30859
30859
|
class UndoManager {
|
|
30860
30860
|
constructor(editor) {
|
|
30861
30861
|
__publicField(this, "editor");
|
|
@@ -30902,21 +30902,21 @@ ${codeText}
|
|
|
30902
30902
|
}
|
|
30903
30903
|
beginGroup() {
|
|
30904
30904
|
if (this.groupCounter === 0) {
|
|
30905
|
-
assert(logger$
|
|
30905
|
+
assert(logger$3c, !this.currentGroup, "current group already exists");
|
|
30906
30906
|
this.currentGroup = new GroupAction(this.editor);
|
|
30907
30907
|
this.groupCounter = 1;
|
|
30908
30908
|
} else {
|
|
30909
|
-
assert(logger$
|
|
30909
|
+
assert(logger$3c, this.currentGroup, "current group not exists");
|
|
30910
30910
|
this.groupCounter += 1;
|
|
30911
30911
|
}
|
|
30912
30912
|
}
|
|
30913
30913
|
endGroup() {
|
|
30914
|
-
assert(logger$
|
|
30915
|
-
assert(logger$
|
|
30914
|
+
assert(logger$3c, this.currentGroup, "current group not exists");
|
|
30915
|
+
assert(logger$3c, this.groupCounter > 0, "group counter === 0");
|
|
30916
30916
|
this.groupCounter -= 1;
|
|
30917
30917
|
if (this.groupCounter === 0) {
|
|
30918
30918
|
if (this.currentGroup.actions.length === 0) {
|
|
30919
|
-
logger$
|
|
30919
|
+
logger$3c.warn("empty undo group, skip it");
|
|
30920
30920
|
} else {
|
|
30921
30921
|
this.actions.push(this.currentGroup);
|
|
30922
30922
|
this.editor.input.handleChanged(this.currentGroup);
|
|
@@ -30934,7 +30934,7 @@ ${codeText}
|
|
|
30934
30934
|
setTimeout(() => this.editor.selection.caret.update());
|
|
30935
30935
|
return ret;
|
|
30936
30936
|
} catch (err) {
|
|
30937
|
-
logger$
|
|
30937
|
+
logger$3c.error(`failed to run action: ${err.message}`);
|
|
30938
30938
|
throw err;
|
|
30939
30939
|
} finally {
|
|
30940
30940
|
this.endGroup();
|
|
@@ -30945,14 +30945,14 @@ ${codeText}
|
|
|
30945
30945
|
if (pos.isSimple()) {
|
|
30946
30946
|
const ok = pos.offset >= 0 && pos.offset <= getBlockTextLength$6(this.editor, block);
|
|
30947
30947
|
if (!ok) {
|
|
30948
|
-
assert(logger$
|
|
30948
|
+
assert(logger$3c, false, "invalid block position, out of range");
|
|
30949
30949
|
}
|
|
30950
30950
|
} else {
|
|
30951
30951
|
const childContainerId = pos.childContainerId;
|
|
30952
30952
|
const container = this.editor.getContainerById(childContainerId);
|
|
30953
30953
|
const ok = !!container;
|
|
30954
30954
|
if (!ok) {
|
|
30955
|
-
assert(logger$
|
|
30955
|
+
assert(logger$3c, false, "invalid complex block position, no container found");
|
|
30956
30956
|
}
|
|
30957
30957
|
}
|
|
30958
30958
|
}
|
|
@@ -30962,7 +30962,7 @@ ${codeText}
|
|
|
30962
30962
|
this.verifyPos(start);
|
|
30963
30963
|
this.verifyPos(end);
|
|
30964
30964
|
} catch (err) {
|
|
30965
|
-
logger$
|
|
30965
|
+
logger$3c.error(`undo: failed to restore caret pos: ${err.message}`);
|
|
30966
30966
|
const firstBlock = this.editor.getFirstBlock();
|
|
30967
30967
|
this.editor.selection.setRange(createBlockSimpleRange(this.editor, firstBlock, 0), { noScroll: true });
|
|
30968
30968
|
}
|
|
@@ -30980,7 +30980,7 @@ ${codeText}
|
|
|
30980
30980
|
try {
|
|
30981
30981
|
this.editor.selection.setRange(fromDocRange(this.editor, action.beforeRange));
|
|
30982
30982
|
} catch (err) {
|
|
30983
|
-
logger$
|
|
30983
|
+
logger$3c.error(`undo: failed to restore caret pos: ${err.message}`);
|
|
30984
30984
|
}
|
|
30985
30985
|
this.editor.input.handleChanged(action);
|
|
30986
30986
|
const batchActionId = action.getBatchActionId();
|
|
@@ -30993,7 +30993,7 @@ ${codeText}
|
|
|
30993
30993
|
}
|
|
30994
30994
|
return false;
|
|
30995
30995
|
} catch (error2) {
|
|
30996
|
-
logger$
|
|
30996
|
+
logger$3c.error(`failed to undo: ${error2.message}`);
|
|
30997
30997
|
return false;
|
|
30998
30998
|
} finally {
|
|
30999
30999
|
this.undoRedoing = false;
|
|
@@ -31015,10 +31015,10 @@ ${codeText}
|
|
|
31015
31015
|
if (afterRange) {
|
|
31016
31016
|
this.editor.selection.setRange(fromDocRange(this.editor, afterRange));
|
|
31017
31017
|
} else {
|
|
31018
|
-
logger$
|
|
31018
|
+
logger$3c.warn("no after range");
|
|
31019
31019
|
}
|
|
31020
31020
|
} catch (err) {
|
|
31021
|
-
logger$
|
|
31021
|
+
logger$3c.error(`redo: failed to set caret pos after redo: ${err.message}`);
|
|
31022
31022
|
}
|
|
31023
31023
|
const batchActionId = action.getBatchActionId();
|
|
31024
31024
|
const nextAction = this.actions[this.undoCursor];
|
|
@@ -31098,8 +31098,8 @@ ${codeText}
|
|
|
31098
31098
|
return;
|
|
31099
31099
|
}
|
|
31100
31100
|
this.prepareSaveUndoState();
|
|
31101
|
-
assert(logger$
|
|
31102
|
-
assert(logger$
|
|
31101
|
+
assert(logger$3c, blockIndex >= 0, "invalid block index");
|
|
31102
|
+
assert(logger$3c, blockData, "no block data");
|
|
31103
31103
|
this.addAction(new InsertBlockAction(this.editor, containerId, blockIndex, blockData, newRange));
|
|
31104
31104
|
}
|
|
31105
31105
|
onBeforeDeleteBlock(containerId, blockIndex, blockData, newRange) {
|
|
@@ -31353,7 +31353,7 @@ ${codeText}
|
|
|
31353
31353
|
}
|
|
31354
31354
|
return commands;
|
|
31355
31355
|
};
|
|
31356
|
-
const logger$
|
|
31356
|
+
const logger$3b = getLogger("range-commands");
|
|
31357
31357
|
const injectGroup$1 = (commands, group) => {
|
|
31358
31358
|
commands.forEach((command) => {
|
|
31359
31359
|
command.group = group;
|
|
@@ -31365,8 +31365,8 @@ ${codeText}
|
|
|
31365
31365
|
function setBlockCommandsMap(providers, editor, block, range, commandsMap) {
|
|
31366
31366
|
var _a, _b, _c;
|
|
31367
31367
|
const blockId = getBlockId(block);
|
|
31368
|
-
assert(logger$
|
|
31369
|
-
assert(logger$
|
|
31368
|
+
assert(logger$3b, blockId === range.start.blockId, "invalid start range");
|
|
31369
|
+
assert(logger$3b, blockId === range.end.blockId, "invalid end range");
|
|
31370
31370
|
let index2 = 0;
|
|
31371
31371
|
for (const provider of providers) {
|
|
31372
31372
|
const commands = provider.getAvailableCommands(editor, block, range);
|
|
@@ -31381,8 +31381,8 @@ ${codeText}
|
|
|
31381
31381
|
}
|
|
31382
31382
|
if (isComplexKindBlock(editor, block)) {
|
|
31383
31383
|
if (isComplexBlockPosition(range.start)) {
|
|
31384
|
-
assert(logger$
|
|
31385
|
-
assert(logger$
|
|
31384
|
+
assert(logger$3b, !range.start.isSimple(), "invalid start pos");
|
|
31385
|
+
assert(logger$3b, !range.end.isSimple(), "invalid end pos");
|
|
31386
31386
|
const focusedContainerId = range.start.childContainerId;
|
|
31387
31387
|
const focusedContainer = getContainerById(editor, focusedContainerId);
|
|
31388
31388
|
const blocks = getChildBlocks(focusedContainer);
|
|
@@ -31410,7 +31410,7 @@ ${codeText}
|
|
|
31410
31410
|
});
|
|
31411
31411
|
return commands;
|
|
31412
31412
|
}
|
|
31413
|
-
const logger$
|
|
31413
|
+
const logger$3a = getLogger("abstract-command-providers");
|
|
31414
31414
|
class AbstractProvider {
|
|
31415
31415
|
constructor(editor) {
|
|
31416
31416
|
__publicField(this, "commandProviders", []);
|
|
@@ -31421,7 +31421,7 @@ ${codeText}
|
|
|
31421
31421
|
__publicField(this, "getCommandProviders", () => this.commandProviders);
|
|
31422
31422
|
__publicField(this, "getCommandProvider", (id) => {
|
|
31423
31423
|
const provider = this.commandProviders.find((provider2) => provider2.id === id);
|
|
31424
|
-
assert(logger$
|
|
31424
|
+
assert(logger$3a, provider, `no command provider found for ${id}`);
|
|
31425
31425
|
return provider;
|
|
31426
31426
|
});
|
|
31427
31427
|
__publicField(this, "filterItems", (range, items) => {
|
|
@@ -31529,12 +31529,12 @@ ${codeText}
|
|
|
31529
31529
|
const blockIndex = getBlockIndex(block);
|
|
31530
31530
|
onBlockDataChanged(editor, containerId, blockIndex);
|
|
31531
31531
|
}
|
|
31532
|
-
const logger$
|
|
31532
|
+
const logger$39 = getLogger("update-block-text");
|
|
31533
31533
|
function editorUpdateBoxData(editor, boxData, options) {
|
|
31534
31534
|
const boxElem = editor.getBoxById(boxData.id);
|
|
31535
31535
|
const block = getParentBlock(boxElem);
|
|
31536
|
-
assert(logger$
|
|
31537
|
-
assert(logger$
|
|
31536
|
+
assert(logger$39, block, "no parent block");
|
|
31537
|
+
assert(logger$39, isTextKindBlock(editor, block), "not a text block");
|
|
31538
31538
|
const text2 = editor.getBlockText(block);
|
|
31539
31539
|
const newText = updateOpAttributes(text2, "id", boxData.id, boxData);
|
|
31540
31540
|
editorSetBlockText(editor, block, newText, options);
|
|
@@ -31601,7 +31601,7 @@ ${codeText}
|
|
|
31601
31601
|
return void 0;
|
|
31602
31602
|
}
|
|
31603
31603
|
}
|
|
31604
|
-
const logger$
|
|
31604
|
+
const logger$38 = getLogger("editor");
|
|
31605
31605
|
class Editor extends tinyTypedEmitter.TypedEmitter {
|
|
31606
31606
|
constructor(parent, doc2, optionalOptions) {
|
|
31607
31607
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
@@ -31643,7 +31643,7 @@ ${codeText}
|
|
|
31643
31643
|
}
|
|
31644
31644
|
return colors[index2 % colors.length];
|
|
31645
31645
|
});
|
|
31646
|
-
logger$
|
|
31646
|
+
logger$38.debug("create editor");
|
|
31647
31647
|
this.setMaxListeners(100);
|
|
31648
31648
|
this.options = {
|
|
31649
31649
|
colors: (_a = optionalOptions == null ? void 0 : optionalOptions.colors) != null ? _a : ["#B21B57", "#008796", "#7241CC", "#CC4C08", "#5D8F00", "#BD2C1C", "#D17D00"],
|
|
@@ -31711,7 +31711,7 @@ ${codeText}
|
|
|
31711
31711
|
}
|
|
31712
31712
|
getCustom(name) {
|
|
31713
31713
|
const exists = this.customs.get(name);
|
|
31714
|
-
assert(logger$
|
|
31714
|
+
assert(logger$38, exists, `${name} does not exists`);
|
|
31715
31715
|
return exists;
|
|
31716
31716
|
}
|
|
31717
31717
|
replaceCustom(name, newCustom) {
|
|
@@ -31762,7 +31762,7 @@ ${codeText}
|
|
|
31762
31762
|
return this.editorInsertions.createInsertion(blockContent, insertion);
|
|
31763
31763
|
}
|
|
31764
31764
|
destroy() {
|
|
31765
|
-
logger$
|
|
31765
|
+
logger$38.debug("destroy editor");
|
|
31766
31766
|
this.emit("destroy", this);
|
|
31767
31767
|
this.input.destroy();
|
|
31768
31768
|
this.rootContainerObject.destroy();
|
|
@@ -31790,8 +31790,8 @@ ${codeText}
|
|
|
31790
31790
|
getChildContainerData(childContainerId) {
|
|
31791
31791
|
const blocks = this.doc.getContainerBlocks(childContainerId);
|
|
31792
31792
|
if (!blocks || !Array.isArray(blocks)) {
|
|
31793
|
-
assert(logger$
|
|
31794
|
-
assert(logger$
|
|
31793
|
+
assert(logger$38, blocks, `no child container data: ${childContainerId}, ${JSON.stringify(this.doc)}`);
|
|
31794
|
+
assert(logger$38, Array.isArray(blocks), `container data is not an array: ${JSON.stringify(blocks)}`);
|
|
31795
31795
|
}
|
|
31796
31796
|
return blocks;
|
|
31797
31797
|
}
|
|
@@ -31812,25 +31812,25 @@ ${codeText}
|
|
|
31812
31812
|
findBlockById(id) {
|
|
31813
31813
|
const block = this.rootContainer.querySelector(`#${id}`);
|
|
31814
31814
|
if (block) {
|
|
31815
|
-
assert(logger$
|
|
31815
|
+
assert(logger$38, isBlock$1(block), "not an valid block element");
|
|
31816
31816
|
}
|
|
31817
31817
|
return block != null ? block : null;
|
|
31818
31818
|
}
|
|
31819
31819
|
findBoxById(id) {
|
|
31820
31820
|
const box = this.rootContainer.querySelector(`#${id}`);
|
|
31821
31821
|
if (box) {
|
|
31822
|
-
assert(logger$
|
|
31822
|
+
assert(logger$38, isBox(box), "not an valid box element");
|
|
31823
31823
|
}
|
|
31824
31824
|
return box != null ? box : null;
|
|
31825
31825
|
}
|
|
31826
31826
|
getBlockById(id) {
|
|
31827
31827
|
const block = this.findBlockById(id);
|
|
31828
|
-
assert(logger$
|
|
31828
|
+
assert(logger$38, block, `no block, id=${id}`);
|
|
31829
31829
|
return block;
|
|
31830
31830
|
}
|
|
31831
31831
|
getBoxById(id) {
|
|
31832
31832
|
const box = this.findBoxById(id);
|
|
31833
|
-
assert(logger$
|
|
31833
|
+
assert(logger$38, box, `no box, id=${id}`);
|
|
31834
31834
|
return box;
|
|
31835
31835
|
}
|
|
31836
31836
|
getBlockByIndex(containerId, blockIndex) {
|
|
@@ -32111,7 +32111,7 @@ ${codeText}
|
|
|
32111
32111
|
this.removeAllListeners();
|
|
32112
32112
|
}
|
|
32113
32113
|
}
|
|
32114
|
-
const logger$
|
|
32114
|
+
const logger$37 = getLogger("local-doc");
|
|
32115
32115
|
class LocalDoc extends EventCallbacks {
|
|
32116
32116
|
constructor(doc2, options) {
|
|
32117
32117
|
super();
|
|
@@ -32151,17 +32151,17 @@ ${codeText}
|
|
|
32151
32151
|
}
|
|
32152
32152
|
getBlockData(containerId, blockIndex) {
|
|
32153
32153
|
const blocks = this.getContainerBlocks(containerId);
|
|
32154
|
-
assert(logger$
|
|
32154
|
+
assert(logger$37, blocks, `no container data: ${containerId}`);
|
|
32155
32155
|
const blockData = blocks[blockIndex];
|
|
32156
|
-
assert(logger$
|
|
32156
|
+
assert(logger$37, blockData, `no block data: ${blockIndex}`);
|
|
32157
32157
|
return blockData;
|
|
32158
32158
|
}
|
|
32159
32159
|
localUpdateBlockText(containerId, blockIndex, actions2) {
|
|
32160
32160
|
const blockData = this.getBlockData(containerId, blockIndex);
|
|
32161
|
-
assert(logger$
|
|
32161
|
+
assert(logger$37, blockData.text, "no text for data");
|
|
32162
32162
|
const newText = RichText.apply(blockData.text, actions2);
|
|
32163
32163
|
blockData.text = newText;
|
|
32164
|
-
assert(logger$
|
|
32164
|
+
assert(logger$37, this.callbacks.length > 0, "no callbacks");
|
|
32165
32165
|
this.callbacks.forEach((cb) => {
|
|
32166
32166
|
var _a;
|
|
32167
32167
|
return (_a = cb.onUpdateBlockText) == null ? void 0 : _a.call(cb, containerId, blockIndex, actions2, true);
|
|
@@ -32174,7 +32174,7 @@ ${codeText}
|
|
|
32174
32174
|
Object.entries(delta.insert).forEach(([key, value]) => {
|
|
32175
32175
|
blockData[key] = value;
|
|
32176
32176
|
});
|
|
32177
|
-
assert(logger$
|
|
32177
|
+
assert(logger$37, this.callbacks.length > 0, "no callbacks");
|
|
32178
32178
|
this.callbacks.forEach((cb) => {
|
|
32179
32179
|
var _a;
|
|
32180
32180
|
return (_a = cb.onUpdateBlockData) == null ? void 0 : _a.call(cb, containerId, blockIndex, delta, true);
|
|
@@ -32183,10 +32183,10 @@ ${codeText}
|
|
|
32183
32183
|
}
|
|
32184
32184
|
localInsertBlock(containerId, blockIndex, data2) {
|
|
32185
32185
|
const blocks = this.getContainerBlocks(containerId);
|
|
32186
|
-
assert(logger$
|
|
32187
|
-
assert(logger$
|
|
32186
|
+
assert(logger$37, blocks, `no container data: ${containerId}`);
|
|
32187
|
+
assert(logger$37, blockIndex >= 0 && blockIndex <= blocks.length, `invalid block index: ${blockIndex}, ${blocks.length}`);
|
|
32188
32188
|
blocks.splice(blockIndex, 0, data2);
|
|
32189
|
-
assert(logger$
|
|
32189
|
+
assert(logger$37, this.callbacks.length > 0, "no callbacks");
|
|
32190
32190
|
this.callbacks.forEach((cb) => {
|
|
32191
32191
|
var _a;
|
|
32192
32192
|
return (_a = cb.onInsertBlock) == null ? void 0 : _a.call(cb, containerId, blockIndex, data2, true);
|
|
@@ -32195,11 +32195,11 @@ ${codeText}
|
|
|
32195
32195
|
}
|
|
32196
32196
|
localDeleteBlock(containerId, blockIndex) {
|
|
32197
32197
|
const blocks = this.getContainerBlocks(containerId);
|
|
32198
|
-
assert(logger$
|
|
32199
|
-
assert(logger$
|
|
32198
|
+
assert(logger$37, blocks, `no container data: ${containerId}`);
|
|
32199
|
+
assert(logger$37, blockIndex >= 0 && blockIndex <= blocks.length, `invalid block index: ${blockIndex}, ${blocks.length}`);
|
|
32200
32200
|
const data2 = blocks[blockIndex];
|
|
32201
32201
|
blocks.splice(blockIndex, 1);
|
|
32202
|
-
assert(logger$
|
|
32202
|
+
assert(logger$37, this.callbacks.length > 0, "no callbacks");
|
|
32203
32203
|
this.callbacks.forEach((cb) => {
|
|
32204
32204
|
var _a;
|
|
32205
32205
|
return (_a = cb.onDeleteBlock) == null ? void 0 : _a.call(cb, containerId, blockIndex, true);
|
|
@@ -32209,7 +32209,7 @@ ${codeText}
|
|
|
32209
32209
|
localInsertChildContainers(containers) {
|
|
32210
32210
|
containers.forEach(({ containerId, blocks }) => {
|
|
32211
32211
|
this.doc.blocks[containerId] = blocks;
|
|
32212
|
-
assert(logger$
|
|
32212
|
+
assert(logger$37, this.callbacks.length > 0, "no callbacks");
|
|
32213
32213
|
this.callbacks.forEach((cb) => {
|
|
32214
32214
|
var _a;
|
|
32215
32215
|
return (_a = cb.onInsertChildContainer) == null ? void 0 : _a.call(cb, containerId, blocks, true);
|
|
@@ -32217,13 +32217,13 @@ ${codeText}
|
|
|
32217
32217
|
});
|
|
32218
32218
|
}
|
|
32219
32219
|
localDeleteChildContainers(containerIds) {
|
|
32220
|
-
logger$
|
|
32220
|
+
logger$37.debug(`delete child containers: ${containerIds}`);
|
|
32221
32221
|
containerIds.forEach((id) => {
|
|
32222
|
-
assert(logger$
|
|
32222
|
+
assert(logger$37, this.doc.blocks[id], `no child container: ${id}`);
|
|
32223
32223
|
delete this.doc.blocks[id];
|
|
32224
32224
|
});
|
|
32225
32225
|
containerIds.forEach((id) => {
|
|
32226
|
-
assert(logger$
|
|
32226
|
+
assert(logger$37, this.callbacks.length > 0, "no callbacks");
|
|
32227
32227
|
this.callbacks.forEach((cb) => {
|
|
32228
32228
|
var _a;
|
|
32229
32229
|
return (_a = cb.onDeleteChildContainer) == null ? void 0 : _a.call(cb, id, true);
|
|
@@ -32231,7 +32231,7 @@ ${codeText}
|
|
|
32231
32231
|
});
|
|
32232
32232
|
}
|
|
32233
32233
|
uploadResource(file2, options) {
|
|
32234
|
-
assert(logger$
|
|
32234
|
+
assert(logger$37, false, "not implemented");
|
|
32235
32235
|
}
|
|
32236
32236
|
async addResources(resourceIds) {
|
|
32237
32237
|
return resourceIds;
|
|
@@ -32240,7 +32240,7 @@ ${codeText}
|
|
|
32240
32240
|
return src;
|
|
32241
32241
|
}
|
|
32242
32242
|
request(url, opt) {
|
|
32243
|
-
assert(logger$
|
|
32243
|
+
assert(logger$37, false, "not implemented");
|
|
32244
32244
|
}
|
|
32245
32245
|
broadcastMessage(data2) {
|
|
32246
32246
|
}
|
|
@@ -32291,7 +32291,7 @@ ${codeText}
|
|
|
32291
32291
|
return custom;
|
|
32292
32292
|
});
|
|
32293
32293
|
}
|
|
32294
|
-
const logger$
|
|
32294
|
+
const logger$36 = getLogger("find-block");
|
|
32295
32295
|
function findPrevVisibleSimpleBlock(editor, block) {
|
|
32296
32296
|
const prevVisibleBlock = getPrevVisibleBlock(block);
|
|
32297
32297
|
if (!prevVisibleBlock) {
|
|
@@ -32299,7 +32299,7 @@ ${codeText}
|
|
|
32299
32299
|
return null;
|
|
32300
32300
|
}
|
|
32301
32301
|
const parent = getParentBlockExcludeSelf(block);
|
|
32302
|
-
assert(logger$
|
|
32302
|
+
assert(logger$36, parent, "no parent block");
|
|
32303
32303
|
return findPrevVisibleSimpleBlock(editor, parent);
|
|
32304
32304
|
}
|
|
32305
32305
|
if (!isComplexKindBlock(editor, prevVisibleBlock)) {
|
|
@@ -32314,7 +32314,7 @@ ${codeText}
|
|
|
32314
32314
|
return null;
|
|
32315
32315
|
}
|
|
32316
32316
|
const parent = getParentBlockExcludeSelf(block);
|
|
32317
|
-
assert(logger$
|
|
32317
|
+
assert(logger$36, parent, "no parent block");
|
|
32318
32318
|
return findNextVisibleSimpleBlock(editor, parent);
|
|
32319
32319
|
}
|
|
32320
32320
|
if (!isComplexKindBlock(editor, nextVisibleBlock)) {
|
|
@@ -32322,7 +32322,7 @@ ${codeText}
|
|
|
32322
32322
|
}
|
|
32323
32323
|
return complexBlockGetFirstSimpleChild(editor, nextVisibleBlock, { visibleOnly: true });
|
|
32324
32324
|
}
|
|
32325
|
-
const logger$
|
|
32325
|
+
const logger$35 = getLogger("remote-cursor");
|
|
32326
32326
|
class RemoteCaretsHandler {
|
|
32327
32327
|
constructor() {
|
|
32328
32328
|
__publicField(this, "remoteUsers", new RemoteUsers());
|
|
@@ -32335,7 +32335,7 @@ ${codeText}
|
|
|
32335
32335
|
} else if (message.type === "caret") {
|
|
32336
32336
|
this.handleUpdateCaret(message);
|
|
32337
32337
|
} else {
|
|
32338
|
-
logger$
|
|
32338
|
+
logger$35.debug(`unknown remote message received: ${msg}`);
|
|
32339
32339
|
}
|
|
32340
32340
|
}
|
|
32341
32341
|
handleUpdateUsers(users) {
|
|
@@ -32462,7 +32462,7 @@ ${codeText}
|
|
|
32462
32462
|
});
|
|
32463
32463
|
this.setMethods(defaultMethods);
|
|
32464
32464
|
}
|
|
32465
|
-
var logger$
|
|
32465
|
+
var logger$34 = Logger$1;
|
|
32466
32466
|
Logger$1.prototype.setMethods = function(overrides) {
|
|
32467
32467
|
overrides = overrides || {};
|
|
32468
32468
|
var logger2 = this;
|
|
@@ -32472,9 +32472,9 @@ ${codeText}
|
|
|
32472
32472
|
}
|
|
32473
32473
|
});
|
|
32474
32474
|
};
|
|
32475
|
-
var Logger = logger$
|
|
32476
|
-
var logger$
|
|
32477
|
-
var logger_1 = logger$
|
|
32475
|
+
var Logger = logger$34;
|
|
32476
|
+
var logger$33 = new Logger();
|
|
32477
|
+
var logger_1 = logger$33;
|
|
32478
32478
|
function ShareDBError$3(code, message) {
|
|
32479
32479
|
this.code = code;
|
|
32480
32480
|
this.message = message || "";
|
|
@@ -33393,7 +33393,7 @@ ${codeText}
|
|
|
33393
33393
|
presenceRequest: "pr"
|
|
33394
33394
|
};
|
|
33395
33395
|
var emitter$5 = emitter$6;
|
|
33396
|
-
var logger$
|
|
33396
|
+
var logger$32 = logger_1;
|
|
33397
33397
|
var ShareDBError$2 = error;
|
|
33398
33398
|
var types$2 = types$3;
|
|
33399
33399
|
var util$9 = util$a;
|
|
@@ -33995,7 +33995,7 @@ ${codeText}
|
|
|
33995
33995
|
if (this.inflightOp.create) {
|
|
33996
33996
|
this.version = message.v;
|
|
33997
33997
|
} else if (message.v !== this.version) {
|
|
33998
|
-
logger$
|
|
33998
|
+
logger$32.warn("Invalid version from server. Expected: " + this.version + " Received: " + message.v, message);
|
|
33999
33999
|
return this.fetch();
|
|
34000
34000
|
}
|
|
34001
34001
|
if (message[ACTIONS$6.fixup]) {
|
|
@@ -37087,7 +37087,7 @@ ${codeText}
|
|
|
37087
37087
|
var ACTIONS = messageActions.ACTIONS;
|
|
37088
37088
|
var types$1 = types$3;
|
|
37089
37089
|
var util = util$a;
|
|
37090
|
-
var logger$
|
|
37090
|
+
var logger$31 = logger_1;
|
|
37091
37091
|
var DocPresenceEmitter = docPresenceEmitter;
|
|
37092
37092
|
var ERROR_CODE = ShareDBError.CODES;
|
|
37093
37093
|
function connectionState(socket) {
|
|
@@ -37131,11 +37131,11 @@ ${codeText}
|
|
|
37131
37131
|
try {
|
|
37132
37132
|
var data2 = typeof event.data === "string" ? JSON.parse(event.data) : event.data;
|
|
37133
37133
|
} catch (err) {
|
|
37134
|
-
logger$
|
|
37134
|
+
logger$31.warn("Failed to parse message", event);
|
|
37135
37135
|
return;
|
|
37136
37136
|
}
|
|
37137
37137
|
if (connection2.debug)
|
|
37138
|
-
logger$
|
|
37138
|
+
logger$31.info("RECV", JSON.stringify(data2));
|
|
37139
37139
|
var request = { data: data2 };
|
|
37140
37140
|
connection2.emit("receive", request);
|
|
37141
37141
|
if (!request.data)
|
|
@@ -37237,7 +37237,7 @@ ${codeText}
|
|
|
37237
37237
|
case ACTIONS.pingPong:
|
|
37238
37238
|
return this._handlePingPong(err);
|
|
37239
37239
|
default:
|
|
37240
|
-
logger$
|
|
37240
|
+
logger$31.warn("Ignoring unrecognized message", message);
|
|
37241
37241
|
}
|
|
37242
37242
|
};
|
|
37243
37243
|
function wrapErrorData(errorData, fullMessage) {
|
|
@@ -37277,7 +37277,7 @@ ${codeText}
|
|
|
37277
37277
|
doc2[method](err);
|
|
37278
37278
|
}
|
|
37279
37279
|
} else {
|
|
37280
|
-
logger$
|
|
37280
|
+
logger$31.error("Invalid bulk message", message);
|
|
37281
37281
|
}
|
|
37282
37282
|
};
|
|
37283
37283
|
Connection$1.prototype._reset = function() {
|
|
@@ -37410,7 +37410,7 @@ ${codeText}
|
|
|
37410
37410
|
};
|
|
37411
37411
|
Connection$1.prototype.send = function(message) {
|
|
37412
37412
|
if (this.debug)
|
|
37413
|
-
logger$
|
|
37413
|
+
logger$31.info("SEND", JSON.stringify(message));
|
|
37414
37414
|
this.emit("send", message);
|
|
37415
37415
|
this.socket.send(JSON.stringify(message));
|
|
37416
37416
|
};
|
|
@@ -37687,7 +37687,7 @@ ${codeText}
|
|
|
37687
37687
|
};
|
|
37688
37688
|
const AuthHeader = "x-live-editor-token";
|
|
37689
37689
|
const BaseURLHeader = "x-live-editor-base-url";
|
|
37690
|
-
const logger$
|
|
37690
|
+
const logger$30 = getLogger("auto-renew-token");
|
|
37691
37691
|
function sleep(ms) {
|
|
37692
37692
|
return new Promise((resolve) => {
|
|
37693
37693
|
setTimeout(resolve, ms);
|
|
@@ -37712,13 +37712,13 @@ ${codeText}
|
|
|
37712
37712
|
return;
|
|
37713
37713
|
}
|
|
37714
37714
|
try {
|
|
37715
|
-
logger$
|
|
37715
|
+
logger$30.info("renewing token");
|
|
37716
37716
|
this.emit("renewingToken", this.retryCount);
|
|
37717
37717
|
const ret = await this.renewToken();
|
|
37718
37718
|
if (this.stop) {
|
|
37719
37719
|
return;
|
|
37720
37720
|
}
|
|
37721
|
-
logger$
|
|
37721
|
+
logger$30.info("renewed token");
|
|
37722
37722
|
this.emit("renewedToken", ret);
|
|
37723
37723
|
return;
|
|
37724
37724
|
} catch (e2) {
|
|
@@ -37730,7 +37730,7 @@ ${codeText}
|
|
|
37730
37730
|
this.retryCount++;
|
|
37731
37731
|
const seconds = Math.min(this.retryCount * 3, 30);
|
|
37732
37732
|
const retryTime = seconds * 1e3;
|
|
37733
|
-
logger$
|
|
37733
|
+
logger$30.info(`waiting for renew token: ${seconds}s`);
|
|
37734
37734
|
await sleep(retryTime);
|
|
37735
37735
|
}
|
|
37736
37736
|
} finally {
|
|
@@ -37741,29 +37741,29 @@ ${codeText}
|
|
|
37741
37741
|
this.stop = true;
|
|
37742
37742
|
}
|
|
37743
37743
|
}
|
|
37744
|
-
const logger$
|
|
37744
|
+
const logger$2$ = getLogger("connection-status");
|
|
37745
37745
|
class ConnectionStatus extends tinyTypedEmitter.TypedEmitter {
|
|
37746
37746
|
constructor(connection2) {
|
|
37747
37747
|
super();
|
|
37748
37748
|
__publicField(this, "handleClosed", () => {
|
|
37749
|
-
logger$
|
|
37749
|
+
logger$2$.info("connection closed");
|
|
37750
37750
|
});
|
|
37751
37751
|
__publicField(this, "handleCommonError", (error2) => {
|
|
37752
|
-
logger$
|
|
37752
|
+
logger$2$.error(`connection error${JSON.stringify(error2)}`);
|
|
37753
37753
|
this.emit("unknownError", error2);
|
|
37754
37754
|
});
|
|
37755
37755
|
__publicField(this, "handleConnecting", () => {
|
|
37756
|
-
logger$
|
|
37756
|
+
logger$2$.info("connection connecting");
|
|
37757
37757
|
});
|
|
37758
37758
|
__publicField(this, "handleConnected", () => {
|
|
37759
|
-
logger$
|
|
37759
|
+
logger$2$.info("connection connected");
|
|
37760
37760
|
});
|
|
37761
37761
|
__publicField(this, "handleConnectionError", (error2) => {
|
|
37762
|
-
logger$
|
|
37762
|
+
logger$2$.error(`connection error${JSON.stringify(error2)}`);
|
|
37763
37763
|
this.emit("connectionError", error2);
|
|
37764
37764
|
});
|
|
37765
37765
|
__publicField(this, "handleStateChanged", (newState, reason) => {
|
|
37766
|
-
logger$
|
|
37766
|
+
logger$2$.info("state changed", `${newState} ${reason}`);
|
|
37767
37767
|
if (newState === "disconnected") {
|
|
37768
37768
|
this.emit("disconnected", reason);
|
|
37769
37769
|
}
|
|
@@ -37785,12 +37785,12 @@ ${codeText}
|
|
|
37785
37785
|
this.connection.removeListener("connection error", this.handleConnectionError);
|
|
37786
37786
|
}
|
|
37787
37787
|
}
|
|
37788
|
-
const logger$
|
|
37788
|
+
const logger$2_ = getLogger("auth-connection");
|
|
37789
37789
|
function silentTry(fn) {
|
|
37790
37790
|
try {
|
|
37791
37791
|
fn();
|
|
37792
37792
|
} catch (e2) {
|
|
37793
|
-
logger$
|
|
37793
|
+
logger$2_.error(e2);
|
|
37794
37794
|
}
|
|
37795
37795
|
}
|
|
37796
37796
|
class AuthConnection extends tinyTypedEmitter.TypedEmitter {
|
|
@@ -37815,7 +37815,7 @@ ${codeText}
|
|
|
37815
37815
|
this.emit("renewTokenError", error2);
|
|
37816
37816
|
return;
|
|
37817
37817
|
}
|
|
37818
|
-
logger$
|
|
37818
|
+
logger$2_.warn("auth error, try to reauth");
|
|
37819
37819
|
if (!this.autoRenewToken) {
|
|
37820
37820
|
let counter = 0;
|
|
37821
37821
|
this.autoRenewToken = new AutoRenewToken(this.renewTokenFunc);
|
|
@@ -37867,7 +37867,7 @@ ${codeText}
|
|
|
37867
37867
|
return toBase64URL(this.getBaseURL());
|
|
37868
37868
|
}
|
|
37869
37869
|
getToken() {
|
|
37870
|
-
assert(logger$
|
|
37870
|
+
assert(logger$2_, this.token, "no token");
|
|
37871
37871
|
return this.token;
|
|
37872
37872
|
}
|
|
37873
37873
|
getResourceToken() {
|
|
@@ -37878,7 +37878,7 @@ ${codeText}
|
|
|
37878
37878
|
}
|
|
37879
37879
|
async verifyAuth(authMessage) {
|
|
37880
37880
|
this.authMessage = authMessage;
|
|
37881
|
-
assert(logger$
|
|
37881
|
+
assert(logger$2_, authMessage.token, "no auth token");
|
|
37882
37882
|
const authURL = `${this.getBaseURL()}/auth`;
|
|
37883
37883
|
const ret = await window.fetch(authURL, {
|
|
37884
37884
|
method: "GET",
|
|
@@ -37921,12 +37921,12 @@ ${codeText}
|
|
|
37921
37921
|
minReconnectionDelay: 1e3 * 5
|
|
37922
37922
|
});
|
|
37923
37923
|
this.connection = Object.create(Connection.prototype);
|
|
37924
|
-
assert(logger$
|
|
37924
|
+
assert(logger$2_, this.connection, "no this.connection");
|
|
37925
37925
|
const thatWs = this.ws;
|
|
37926
37926
|
const pingOptions = this.pingOptions;
|
|
37927
37927
|
const self2 = this;
|
|
37928
37928
|
this.connection._initializeHandshake = function handshake() {
|
|
37929
|
-
logger$
|
|
37929
|
+
logger$2_.debug("connection handshake, send auth message");
|
|
37930
37930
|
const authMessage = self2.authMessage;
|
|
37931
37931
|
this.send({ a: "hs", id: this.id, auth: authMessage, options: { ping: pingOptions } });
|
|
37932
37932
|
if (this._ping == null) {
|
|
@@ -38017,26 +38017,26 @@ ${codeText}
|
|
|
38017
38017
|
if (err === AuthError.err) {
|
|
38018
38018
|
this.handleAuthError(msg);
|
|
38019
38019
|
} else if (err === MaxUserError.err) {
|
|
38020
|
-
logger$
|
|
38020
|
+
logger$2_.warn(MaxUserError.msg);
|
|
38021
38021
|
this.emitMaxUsersError();
|
|
38022
38022
|
} else if (err === RequestReloadError.err) {
|
|
38023
|
-
logger$
|
|
38023
|
+
logger$2_.warn(RequestReloadError.msg);
|
|
38024
38024
|
try {
|
|
38025
38025
|
this.emitRequestReloadError();
|
|
38026
38026
|
} catch (errTemp) {
|
|
38027
|
-
logger$
|
|
38027
|
+
logger$2_.error(`error occurred while process reload error: ${JSON.stringify(errTemp)}`);
|
|
38028
38028
|
} finally {
|
|
38029
38029
|
this.end(false);
|
|
38030
38030
|
}
|
|
38031
38031
|
} else if (err === PermissionError.err) {
|
|
38032
38032
|
this.emitPermissionError();
|
|
38033
38033
|
} else {
|
|
38034
|
-
logger$
|
|
38034
|
+
logger$2_.error(`unknown message received: ${JSON.stringify(msg)}`);
|
|
38035
38035
|
this.emit("unknownError", new Error(`unknown message received: ${JSON.stringify(msg)}`));
|
|
38036
38036
|
}
|
|
38037
38037
|
}
|
|
38038
38038
|
get(collectionName, documentID) {
|
|
38039
|
-
assert(logger$
|
|
38039
|
+
assert(logger$2_, this.connection, "no this.connection");
|
|
38040
38040
|
return this.connection.get(collectionName, documentID);
|
|
38041
38041
|
}
|
|
38042
38042
|
end(logout) {
|
|
@@ -38094,8 +38094,8 @@ ${codeText}
|
|
|
38094
38094
|
const result = hasher.digest();
|
|
38095
38095
|
return toBase64URL(result);
|
|
38096
38096
|
}
|
|
38097
|
-
const logger$
|
|
38098
|
-
const axiosInstance$
|
|
38097
|
+
const logger$2Z = getLogger("sharedb-doc/client");
|
|
38098
|
+
const axiosInstance$2 = axios__default.default.create();
|
|
38099
38099
|
class ShareDBClient {
|
|
38100
38100
|
constructor(auth, serverUrl, reauthFunc) {
|
|
38101
38101
|
__publicField(this, "connection");
|
|
@@ -38111,13 +38111,13 @@ ${codeText}
|
|
|
38111
38111
|
resolve();
|
|
38112
38112
|
});
|
|
38113
38113
|
});
|
|
38114
|
-
assert(logger$
|
|
38114
|
+
assert(logger$2Z, !this.doc, "This websocket has opened a doc.");
|
|
38115
38115
|
await this.connection.init();
|
|
38116
38116
|
const auth = this.connection.getAuthMessage();
|
|
38117
38117
|
const doc2 = this.connection.get(auth.appId, auth.docId);
|
|
38118
38118
|
this.doc = doc2;
|
|
38119
38119
|
await fetchDoc(doc2);
|
|
38120
|
-
logger$
|
|
38120
|
+
logger$2Z.debug(doc2);
|
|
38121
38121
|
return doc2;
|
|
38122
38122
|
});
|
|
38123
38123
|
const url = `${serverUrl}/${auth.appId}/${auth.docId}`;
|
|
@@ -38144,7 +38144,7 @@ ${codeText}
|
|
|
38144
38144
|
const auth = this.authMessage();
|
|
38145
38145
|
const apiServer = this.apiServer();
|
|
38146
38146
|
const last = `/${auth.appId}/${auth.docId}`;
|
|
38147
|
-
assert(logger$
|
|
38147
|
+
assert(logger$2Z, apiServer.endsWith(last), `invalid api server: ${apiServer}, ${last}`);
|
|
38148
38148
|
return apiServer.substr(0, apiServer.length - last.length);
|
|
38149
38149
|
}
|
|
38150
38150
|
close(logout) {
|
|
@@ -38221,7 +38221,7 @@ ${codeText}
|
|
|
38221
38221
|
}
|
|
38222
38222
|
max += 500;
|
|
38223
38223
|
const handleUploadProgress = (event) => {
|
|
38224
|
-
logger$
|
|
38224
|
+
logger$2Z.info(`on progress: ${event.loaded}`);
|
|
38225
38225
|
let value = event.loaded * 100 / max;
|
|
38226
38226
|
if (value > 100)
|
|
38227
38227
|
value = 100;
|
|
@@ -38250,7 +38250,7 @@ ${codeText}
|
|
|
38250
38250
|
},
|
|
38251
38251
|
onUploadProgress: handleUploadProgress
|
|
38252
38252
|
});
|
|
38253
|
-
logger$
|
|
38253
|
+
logger$2Z.info(result);
|
|
38254
38254
|
onProgress(100);
|
|
38255
38255
|
return Array.isArray(result.data) ? result.data[0] : result.data;
|
|
38256
38256
|
}
|
|
@@ -38259,11 +38259,11 @@ ${codeText}
|
|
|
38259
38259
|
const server = this.apiServer();
|
|
38260
38260
|
const api = `${server}/resources`;
|
|
38261
38261
|
const token = this.connection.getResourceToken();
|
|
38262
|
-
assert(logger$
|
|
38262
|
+
assert(logger$2Z, token, "no connection token");
|
|
38263
38263
|
const ret = await this.uploadFile(api, file2, {
|
|
38264
38264
|
[AuthHeader]: token
|
|
38265
38265
|
}, onProgress, options);
|
|
38266
|
-
assert(logger$
|
|
38266
|
+
assert(logger$2Z, ret, "no result");
|
|
38267
38267
|
return ret;
|
|
38268
38268
|
}
|
|
38269
38269
|
async request(url, opt) {
|
|
@@ -38276,7 +38276,7 @@ ${codeText}
|
|
|
38276
38276
|
if (!options.headers) {
|
|
38277
38277
|
options.headers = {};
|
|
38278
38278
|
}
|
|
38279
|
-
assert(logger$
|
|
38279
|
+
assert(logger$2Z, token, "no token");
|
|
38280
38280
|
options.headers = {
|
|
38281
38281
|
...options.headers,
|
|
38282
38282
|
[AuthHeader]: token,
|
|
@@ -38286,7 +38286,7 @@ ${codeText}
|
|
|
38286
38286
|
if (window.isReauthError && Logger$2.level === LogLevel.DEBUG) {
|
|
38287
38287
|
throw new Error("reauth error");
|
|
38288
38288
|
}
|
|
38289
|
-
const ret = await axiosInstance$
|
|
38289
|
+
const ret = await axiosInstance$2(url, options);
|
|
38290
38290
|
return ret;
|
|
38291
38291
|
} catch (err) {
|
|
38292
38292
|
lastErr = err;
|
|
@@ -38305,7 +38305,7 @@ ${codeText}
|
|
|
38305
38305
|
throw err;
|
|
38306
38306
|
}
|
|
38307
38307
|
}
|
|
38308
|
-
assert(logger$
|
|
38308
|
+
assert(logger$2Z, lastErr, "no error");
|
|
38309
38309
|
throw lastErr;
|
|
38310
38310
|
}
|
|
38311
38311
|
async getVersions() {
|
|
@@ -38348,7 +38348,7 @@ ${codeText}
|
|
|
38348
38348
|
}
|
|
38349
38349
|
let doc2;
|
|
38350
38350
|
if (createdDoc) {
|
|
38351
|
-
assert(logger$
|
|
38351
|
+
assert(logger$2Z, createdDoc.create, "no createDoc.create");
|
|
38352
38352
|
doc2 = createdDoc.create.data;
|
|
38353
38353
|
} else {
|
|
38354
38354
|
doc2 = JSON.parse(ret.data.data);
|
|
@@ -38463,7 +38463,7 @@ ${codeText}
|
|
|
38463
38463
|
const id = genId();
|
|
38464
38464
|
return { blocks: [{ id, type: "text", text: [] }], comments: {}, meta: {} };
|
|
38465
38465
|
}
|
|
38466
|
-
const logger$
|
|
38466
|
+
const logger$2Y = getLogger("block-ids");
|
|
38467
38467
|
class BlockIds {
|
|
38468
38468
|
constructor() {
|
|
38469
38469
|
__publicField(this, "ids", /* @__PURE__ */ new Map());
|
|
@@ -38474,7 +38474,7 @@ ${codeText}
|
|
|
38474
38474
|
const index2 = indexes[i];
|
|
38475
38475
|
if (index2 >= blockIndex) {
|
|
38476
38476
|
const oldId = this.ids.get(index2);
|
|
38477
|
-
assert(logger$
|
|
38477
|
+
assert(logger$2Y, oldId !== void 0, "old id is not exists");
|
|
38478
38478
|
this.ids.delete(index2);
|
|
38479
38479
|
this.ids.set(index2 + 1, oldId);
|
|
38480
38480
|
}
|
|
@@ -38489,7 +38489,7 @@ ${codeText}
|
|
|
38489
38489
|
const index2 = indexes[i];
|
|
38490
38490
|
if (index2 > blockIndex) {
|
|
38491
38491
|
const oldId = this.ids.get(index2);
|
|
38492
|
-
assert(logger$
|
|
38492
|
+
assert(logger$2Y, oldId !== void 0, "old id is not exists");
|
|
38493
38493
|
this.ids.delete(index2);
|
|
38494
38494
|
this.ids.set(index2 - 1, oldId);
|
|
38495
38495
|
}
|
|
@@ -38540,7 +38540,7 @@ ${codeText}
|
|
|
38540
38540
|
};
|
|
38541
38541
|
}
|
|
38542
38542
|
}
|
|
38543
|
-
assert(logger$
|
|
38543
|
+
assert(logger$2Y, false, "fault error: failed to get block index");
|
|
38544
38544
|
return { containerId: "error", blockIndex: -1 };
|
|
38545
38545
|
}
|
|
38546
38546
|
}
|
|
@@ -38566,7 +38566,7 @@ ${codeText}
|
|
|
38566
38566
|
};
|
|
38567
38567
|
}
|
|
38568
38568
|
}
|
|
38569
|
-
const logger$
|
|
38569
|
+
const logger$2X = getLogger("op-parse-handler");
|
|
38570
38570
|
class ParseHandler {
|
|
38571
38571
|
constructor(outerHandler, local) {
|
|
38572
38572
|
__publicField(this, "actions", []);
|
|
@@ -38674,7 +38674,7 @@ ${codeText}
|
|
|
38674
38674
|
blockIds.onDeleteBlock(a.containerId, a.blockIndex);
|
|
38675
38675
|
const ignoreObjectData = updatingBlockDataDeltaMap.get(blockId);
|
|
38676
38676
|
if (ignoreObjectData) {
|
|
38677
|
-
logger$
|
|
38677
|
+
logger$2X.debug(`ignore update object data before delete block: ${JSON.stringify(ignoreObjectData)}`);
|
|
38678
38678
|
updatingBlockDataDeltaMap.delete(blockId);
|
|
38679
38679
|
}
|
|
38680
38680
|
const deletesBlockKey = `${a.containerId}-${a.blockIndex}`;
|
|
@@ -38684,7 +38684,7 @@ ${codeText}
|
|
|
38684
38684
|
const a = action;
|
|
38685
38685
|
const deletesBlockKey = `${a.containerId}-${a.blockIndex}`;
|
|
38686
38686
|
if (deletedBlocks.has(deletesBlockKey)) {
|
|
38687
|
-
logger$
|
|
38687
|
+
logger$2X.warn("delete block data after delete block, ignore it");
|
|
38688
38688
|
continue;
|
|
38689
38689
|
}
|
|
38690
38690
|
const blockId = blockIds.getBlockId(a.containerId, a.blockIndex);
|
|
@@ -38695,7 +38695,7 @@ ${codeText}
|
|
|
38695
38695
|
}
|
|
38696
38696
|
delta.delete(a.key);
|
|
38697
38697
|
} else {
|
|
38698
|
-
assert(logger$
|
|
38698
|
+
assert(logger$2X, false, `invalid action type, ${action.type}`);
|
|
38699
38699
|
}
|
|
38700
38700
|
}
|
|
38701
38701
|
this.actions.forEach((action) => {
|
|
@@ -38743,7 +38743,7 @@ ${codeText}
|
|
|
38743
38743
|
});
|
|
38744
38744
|
}
|
|
38745
38745
|
}
|
|
38746
|
-
const logger$
|
|
38746
|
+
const logger$2W = getLogger("op-parser");
|
|
38747
38747
|
class DeleteBlockAction {
|
|
38748
38748
|
}
|
|
38749
38749
|
class DeleteBlockDataAction {
|
|
@@ -38790,8 +38790,8 @@ ${codeText}
|
|
|
38790
38790
|
}
|
|
38791
38791
|
}
|
|
38792
38792
|
const blockData = firstOp.i;
|
|
38793
|
-
assert(logger$
|
|
38794
|
-
assert(logger$
|
|
38793
|
+
assert(logger$2W, blockData.id, "block id is required");
|
|
38794
|
+
assert(logger$2W, blockData.type, "block type is required");
|
|
38795
38795
|
for (let i = 1; i < ops.length; i++) {
|
|
38796
38796
|
const nextOp = ops[i];
|
|
38797
38797
|
const key = nextOp[0];
|
|
@@ -38805,7 +38805,7 @@ ${codeText}
|
|
|
38805
38805
|
if (processType === "upsert" && parseInsertBlockOnlyOp(containerId, orgOps, processor)) {
|
|
38806
38806
|
return;
|
|
38807
38807
|
}
|
|
38808
|
-
assert(logger$
|
|
38808
|
+
assert(logger$2W, Array.isArray(orgOps), `invalid block op: ${containerId}, ${JSON.stringify(orgOps)}`);
|
|
38809
38809
|
const ops = orgOps.concat();
|
|
38810
38810
|
const blockIndex = ops[0];
|
|
38811
38811
|
ops.shift();
|
|
@@ -38814,22 +38814,22 @@ ${codeText}
|
|
|
38814
38814
|
const data2 = ops[0];
|
|
38815
38815
|
if (data2 === "text") {
|
|
38816
38816
|
const opData = ops[1];
|
|
38817
|
-
assert(logger$
|
|
38818
|
-
assert(logger$
|
|
38817
|
+
assert(logger$2W, typeof opData === "object", `invalid block op: ${containerId}, ${JSON.stringify(orgOps)}`);
|
|
38818
|
+
assert(logger$2W, opData.et === "rich-text", `invalid block op: ${containerId}, ${JSON.stringify(orgOps)}`);
|
|
38819
38819
|
ops.splice(0, 2);
|
|
38820
38820
|
if (processType === "upsert") {
|
|
38821
38821
|
const deltaOps = opData.e;
|
|
38822
38822
|
const richTextData = deltaOps;
|
|
38823
38823
|
processor.onUpdateBlockText(containerId, blockIndex, richTextData);
|
|
38824
38824
|
}
|
|
38825
|
-
assert(logger$
|
|
38825
|
+
assert(logger$2W, ops.length === 0, `invalid block ops.length !== 0, ${JSON.stringify(ops)}`);
|
|
38826
38826
|
} else if (Array.isArray(data2)) {
|
|
38827
|
-
assert(logger$
|
|
38827
|
+
assert(logger$2W, data2.length === 2, `invalid block op: data.length !== 2, ${JSON.stringify(data2)}`);
|
|
38828
38828
|
const key = data2[0];
|
|
38829
|
-
assert(logger$
|
|
38829
|
+
assert(logger$2W, typeof key === "string", `invalid block op: key ${JSON.stringify(key)}`);
|
|
38830
38830
|
const opData = data2[1];
|
|
38831
38831
|
if (key === "text") {
|
|
38832
|
-
assert(logger$
|
|
38832
|
+
assert(logger$2W, typeof opData === "object", `invalid opData type, ${JSON.stringify(opData)}`);
|
|
38833
38833
|
if (opData.i) {
|
|
38834
38834
|
if (processType === "upsert") {
|
|
38835
38835
|
processor.onInsertBlockData(containerId, blockIndex, key, opData.i);
|
|
@@ -38874,9 +38874,9 @@ ${codeText}
|
|
|
38874
38874
|
}
|
|
38875
38875
|
ops.shift();
|
|
38876
38876
|
} else {
|
|
38877
|
-
assert(logger$
|
|
38878
|
-
assert(logger$
|
|
38879
|
-
assert(logger$
|
|
38877
|
+
assert(logger$2W, typeof data2 === "string", "data is not string");
|
|
38878
|
+
assert(logger$2W, data2 !== "text", "data !== 'text'");
|
|
38879
|
+
assert(logger$2W, ops.length === 2, `invalid block op: ops.length !== 2, ${JSON.stringify(ops)}`);
|
|
38880
38880
|
const key = data2;
|
|
38881
38881
|
const opData = ops[1];
|
|
38882
38882
|
if (processType === "remove") {
|
|
@@ -38899,20 +38899,20 @@ ${codeText}
|
|
|
38899
38899
|
} else if (a instanceof DeleteBlockDataAction) {
|
|
38900
38900
|
processor.onDeleteBlockData(containerId, blockIndex, a.key);
|
|
38901
38901
|
} else {
|
|
38902
|
-
assert(logger$
|
|
38902
|
+
assert(logger$2W, false, `invalid action type: ${typeof a}, ${JSON.stringify(a)}`);
|
|
38903
38903
|
}
|
|
38904
38904
|
});
|
|
38905
38905
|
}
|
|
38906
38906
|
function parseMetaOp(ops, parseType, handler) {
|
|
38907
|
-
logger$
|
|
38907
|
+
logger$2W.warn(`unsupported meta op, ${JSON.stringify(ops)}`);
|
|
38908
38908
|
}
|
|
38909
38909
|
function parseCommentsOp(ops, parseType, handler) {
|
|
38910
38910
|
const commentId = ops[1];
|
|
38911
38911
|
const actions2 = ops[2];
|
|
38912
|
-
assert(logger$
|
|
38913
|
-
assert(logger$
|
|
38912
|
+
assert(logger$2W, commentId, `invalid comment op, no commentId: ${JSON.stringify(ops)}`);
|
|
38913
|
+
assert(logger$2W, actions2, `invalid comment op, no actions: ${JSON.stringify(ops)}`);
|
|
38914
38914
|
if (typeof actions2 === "string") {
|
|
38915
|
-
logger$
|
|
38915
|
+
logger$2W.error(`unknown comment op, ${JSON.stringify(ops)}`);
|
|
38916
38916
|
} else {
|
|
38917
38917
|
if (actions2.i && actions2.r) {
|
|
38918
38918
|
if (parseType === "upsert") {
|
|
@@ -38927,7 +38927,7 @@ ${codeText}
|
|
|
38927
38927
|
handler.onDeleteComment(commentId);
|
|
38928
38928
|
}
|
|
38929
38929
|
} else {
|
|
38930
|
-
logger$
|
|
38930
|
+
logger$2W.error(`unknown comment op, ${JSON.stringify(ops)}`);
|
|
38931
38931
|
}
|
|
38932
38932
|
}
|
|
38933
38933
|
}
|
|
@@ -38940,7 +38940,7 @@ ${codeText}
|
|
|
38940
38940
|
return;
|
|
38941
38941
|
}
|
|
38942
38942
|
const rootKey = firstOp;
|
|
38943
|
-
assert(logger$
|
|
38943
|
+
assert(logger$2W, typeof rootKey === "string", `invalid container id: ${JSON.stringify(ops)}`);
|
|
38944
38944
|
if (rootKey === "meta") {
|
|
38945
38945
|
parseMetaOp(ops);
|
|
38946
38946
|
return;
|
|
@@ -38974,7 +38974,7 @@ ${codeText}
|
|
|
38974
38974
|
}
|
|
38975
38975
|
}
|
|
38976
38976
|
} else {
|
|
38977
|
-
assert(logger$
|
|
38977
|
+
assert(logger$2W, typeof ops[1] === "number", `invalid ops[1], not a number: ${JSON.stringify(ops)}`);
|
|
38978
38978
|
parseBlockOp(containerId, ops.slice(1), parseType, handler);
|
|
38979
38979
|
}
|
|
38980
38980
|
}
|
|
@@ -38995,10 +38995,10 @@ ${codeText}
|
|
|
38995
38995
|
}
|
|
38996
38996
|
innerHandler.end();
|
|
38997
38997
|
}
|
|
38998
|
-
const logger$
|
|
38998
|
+
const logger$2V = getLogger("sharedb-comments");
|
|
38999
38999
|
function shareDBCommentToDocObject(comment) {
|
|
39000
39000
|
const root2 = comment.blocks;
|
|
39001
|
-
assert(logger$
|
|
39001
|
+
assert(logger$2V, root2, "no comment blocks");
|
|
39002
39002
|
const doc2 = {
|
|
39003
39003
|
blocks: {
|
|
39004
39004
|
root: root2
|
|
@@ -39047,7 +39047,7 @@ ${codeText}
|
|
|
39047
39047
|
delete ret.children;
|
|
39048
39048
|
return ret;
|
|
39049
39049
|
}
|
|
39050
|
-
const logger$
|
|
39050
|
+
const logger$2U = getLogger("edit-status");
|
|
39051
39051
|
class EditStatus {
|
|
39052
39052
|
constructor(options) {
|
|
39053
39053
|
__publicField(this, "dirtyTimeout", null);
|
|
@@ -39058,13 +39058,13 @@ ${codeText}
|
|
|
39058
39058
|
var _a, _b, _c;
|
|
39059
39059
|
if (status === "clean") {
|
|
39060
39060
|
if (this.dirtyTimeout) {
|
|
39061
|
-
logger$
|
|
39061
|
+
logger$2U.info("on clean");
|
|
39062
39062
|
clearTimeout(this.dirtyTimeout);
|
|
39063
39063
|
this.dirtyTimeout = null;
|
|
39064
39064
|
}
|
|
39065
39065
|
if (this.waitingForSave) {
|
|
39066
39066
|
this.waitingForSave = false;
|
|
39067
|
-
logger$
|
|
39067
|
+
logger$2U.info("on saved");
|
|
39068
39068
|
(_b = (_a = this.options) == null ? void 0 : _a.onClean) == null ? void 0 : _b.call(_a);
|
|
39069
39069
|
}
|
|
39070
39070
|
} else {
|
|
@@ -39072,7 +39072,7 @@ ${codeText}
|
|
|
39072
39072
|
const timeout = ((_c = this.options) == null ? void 0 : _c.dirtyTimeout) || 1e3 * 10;
|
|
39073
39073
|
this.dirtyTimeout = setTimeout(() => {
|
|
39074
39074
|
var _a2, _b2;
|
|
39075
|
-
logger$
|
|
39075
|
+
logger$2U.error("dirty timeout");
|
|
39076
39076
|
this.dirtyTimeout = null;
|
|
39077
39077
|
(_b2 = (_a2 = this.options) == null ? void 0 : _a2.onDirtyTimeoutError) == null ? void 0 : _b2.call(_a2);
|
|
39078
39078
|
this.waitingForSave = true;
|
|
@@ -39087,7 +39087,7 @@ ${codeText}
|
|
|
39087
39087
|
}
|
|
39088
39088
|
}
|
|
39089
39089
|
}
|
|
39090
|
-
const logger$
|
|
39090
|
+
const logger$2T = getLogger("sharedb-doc/doc-container");
|
|
39091
39091
|
const JSON1_TYPE_NAME = "ot-json1";
|
|
39092
39092
|
json1__namespace.type.registerSubtype(richText.type);
|
|
39093
39093
|
json1__namespace.type.name = JSON1_TYPE_NAME;
|
|
@@ -39192,22 +39192,22 @@ ${codeText}
|
|
|
39192
39192
|
__publicField(this, "data", () => this.doc.data);
|
|
39193
39193
|
__publicField(this, "submitOp", async (ops) => new Promise((resolve, reject) => {
|
|
39194
39194
|
if (this.destroyed) {
|
|
39195
|
-
logger$
|
|
39195
|
+
logger$2T.warn("submit op after destroyed");
|
|
39196
39196
|
return;
|
|
39197
39197
|
}
|
|
39198
39198
|
this.setStatus("dirty");
|
|
39199
39199
|
this.doc.submitOp(ops, {}, (err) => {
|
|
39200
39200
|
if (err) {
|
|
39201
|
-
logger$
|
|
39201
|
+
logger$2T.error(`invalid op, ${err.message}, ${JSON.stringify(ops)}`);
|
|
39202
39202
|
reject(err);
|
|
39203
|
-
logger$
|
|
39203
|
+
logger$2T.error("Transform detected write conflict, reload editor");
|
|
39204
39204
|
this.handleReset("write conflict");
|
|
39205
39205
|
} else {
|
|
39206
39206
|
resolve();
|
|
39207
39207
|
}
|
|
39208
39208
|
});
|
|
39209
39209
|
if (!this.doc.data) {
|
|
39210
|
-
logger$
|
|
39210
|
+
logger$2T.error("no data after submit op, may be the submitted op is invalid");
|
|
39211
39211
|
this.handleReset(`invalid op, ${JSON.stringify(ops)}`);
|
|
39212
39212
|
}
|
|
39213
39213
|
}));
|
|
@@ -39271,18 +39271,18 @@ ${codeText}
|
|
|
39271
39271
|
});
|
|
39272
39272
|
__publicField(this, "handleOp", (ops, source, clientId) => {
|
|
39273
39273
|
if (!ops) {
|
|
39274
|
-
logger$
|
|
39274
|
+
logger$2T.warn("handleOp: no ops");
|
|
39275
39275
|
return;
|
|
39276
39276
|
}
|
|
39277
39277
|
if (this.destroyed) {
|
|
39278
|
-
logger$
|
|
39278
|
+
logger$2T.warn("handleOp: destroyed");
|
|
39279
39279
|
return;
|
|
39280
39280
|
}
|
|
39281
39281
|
try {
|
|
39282
39282
|
const local = !!source;
|
|
39283
39283
|
parseOps(ops, this, local);
|
|
39284
39284
|
} catch (err) {
|
|
39285
|
-
logger$
|
|
39285
|
+
logger$2T.error(err);
|
|
39286
39286
|
throw err;
|
|
39287
39287
|
}
|
|
39288
39288
|
});
|
|
@@ -39301,7 +39301,7 @@ ${codeText}
|
|
|
39301
39301
|
}
|
|
39302
39302
|
endBatchUpdate() {
|
|
39303
39303
|
this.batching--;
|
|
39304
|
-
assert(logger$
|
|
39304
|
+
assert(logger$2T, this.batching >= 0, "invalid call beginBatchUpdate/endBatchUpdate");
|
|
39305
39305
|
if (this.batching === 0) {
|
|
39306
39306
|
this.doc.preventCompose = true;
|
|
39307
39307
|
}
|
|
@@ -39329,8 +39329,8 @@ ${codeText}
|
|
|
39329
39329
|
shareDBDoc.initEvents();
|
|
39330
39330
|
return shareDBDoc;
|
|
39331
39331
|
} catch (err) {
|
|
39332
|
-
logger$
|
|
39333
|
-
logger$
|
|
39332
|
+
logger$2T.error(err);
|
|
39333
|
+
logger$2T.error(`failed to load doc: ${JSON.stringify(err)}`);
|
|
39334
39334
|
throw err;
|
|
39335
39335
|
}
|
|
39336
39336
|
}
|
|
@@ -39423,24 +39423,24 @@ ${codeText}
|
|
|
39423
39423
|
}
|
|
39424
39424
|
getContainerBlocks(containerId) {
|
|
39425
39425
|
const doc2 = this.data();
|
|
39426
|
-
assert(logger$
|
|
39426
|
+
assert(logger$2T, doc2, "no doc data");
|
|
39427
39427
|
const blocks = doc2[docObjectContainerId2EditorDocContainerId(containerId)];
|
|
39428
|
-
assert(logger$
|
|
39428
|
+
assert(logger$2T, blocks, `no container data: ${containerId}`);
|
|
39429
39429
|
return cloneDeep__default.default(blocks);
|
|
39430
39430
|
}
|
|
39431
39431
|
findContainerBlocks(containerId) {
|
|
39432
39432
|
const doc2 = this.data();
|
|
39433
|
-
assert(logger$
|
|
39433
|
+
assert(logger$2T, doc2, "no doc data");
|
|
39434
39434
|
const blocks = doc2[docObjectContainerId2EditorDocContainerId(containerId)];
|
|
39435
39435
|
return blocks != null ? blocks : null;
|
|
39436
39436
|
}
|
|
39437
39437
|
getBlockData(containerId, blockIndex) {
|
|
39438
39438
|
const doc2 = this.data();
|
|
39439
|
-
assert(logger$
|
|
39439
|
+
assert(logger$2T, doc2, "no doc data");
|
|
39440
39440
|
const blocks = doc2[docObjectContainerId2EditorDocContainerId(containerId)];
|
|
39441
|
-
assert(logger$
|
|
39441
|
+
assert(logger$2T, blocks, `no container data: ${containerId}`);
|
|
39442
39442
|
const blockData = blocks[blockIndex];
|
|
39443
|
-
assert(logger$
|
|
39443
|
+
assert(logger$2T, blockData, `no block data: ${blockIndex}`);
|
|
39444
39444
|
return cloneDeep__default.default(blockData);
|
|
39445
39445
|
}
|
|
39446
39446
|
localInsertBlock(containerId, blockIndex, data2) {
|
|
@@ -39454,11 +39454,11 @@ ${codeText}
|
|
|
39454
39454
|
}
|
|
39455
39455
|
localUpdateBlockText(containerId, blockIndex, actions2) {
|
|
39456
39456
|
const oldBlockData = this.getBlockData(containerId, blockIndex);
|
|
39457
|
-
assert(logger$
|
|
39457
|
+
assert(logger$2T, oldBlockData.text, "no block text");
|
|
39458
39458
|
const oldText = cloneDeep__default.default(oldBlockData.text);
|
|
39459
39459
|
this.submitUpdateRichText(containerId, blockIndex, actions2);
|
|
39460
39460
|
const newText = RichText.apply(oldText, actions2);
|
|
39461
|
-
assert(logger$
|
|
39461
|
+
assert(logger$2T, newText, "no block text");
|
|
39462
39462
|
return newText;
|
|
39463
39463
|
}
|
|
39464
39464
|
localUpdateBlockData(containerId, blockIndex, delta) {
|
|
@@ -39516,65 +39516,65 @@ ${codeText}
|
|
|
39516
39516
|
this.editStatus.destroy();
|
|
39517
39517
|
}
|
|
39518
39518
|
onDeleteBlock(containerId, blockIndex, local) {
|
|
39519
|
-
assert(logger$
|
|
39519
|
+
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39520
39520
|
this.callbacks.forEach((cb) => {
|
|
39521
39521
|
var _a;
|
|
39522
39522
|
return (_a = cb.onDeleteBlock) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, local);
|
|
39523
39523
|
});
|
|
39524
39524
|
}
|
|
39525
39525
|
onInsertBlock(containerId, blockIndex, data2, local) {
|
|
39526
|
-
assert(logger$
|
|
39526
|
+
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39527
39527
|
this.callbacks.forEach((cb) => {
|
|
39528
39528
|
var _a;
|
|
39529
39529
|
return (_a = cb.onInsertBlock) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, data2, local);
|
|
39530
39530
|
});
|
|
39531
39531
|
}
|
|
39532
39532
|
onUpdateBlockData(containerId, blockIndex, delta, local) {
|
|
39533
|
-
assert(logger$
|
|
39533
|
+
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39534
39534
|
this.callbacks.forEach((cb) => {
|
|
39535
39535
|
var _a;
|
|
39536
39536
|
return (_a = cb.onUpdateBlockData) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, delta, local);
|
|
39537
39537
|
});
|
|
39538
39538
|
}
|
|
39539
39539
|
onUpdateBlockText(containerId, blockIndex, actions2, local) {
|
|
39540
|
-
assert(logger$
|
|
39540
|
+
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39541
39541
|
this.callbacks.forEach((cb) => {
|
|
39542
39542
|
var _a;
|
|
39543
39543
|
return (_a = cb.onUpdateBlockText) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, actions2, local);
|
|
39544
39544
|
});
|
|
39545
39545
|
}
|
|
39546
39546
|
onDeleteContainer(containerId, local) {
|
|
39547
|
-
assert(logger$
|
|
39548
|
-
assert(logger$
|
|
39547
|
+
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39548
|
+
assert(logger$2T, containerId !== "root", "should not delete root container in doc");
|
|
39549
39549
|
this.callbacks.forEach((cb) => {
|
|
39550
39550
|
var _a;
|
|
39551
39551
|
return (_a = cb.onDeleteChildContainer) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), local);
|
|
39552
39552
|
});
|
|
39553
39553
|
}
|
|
39554
39554
|
onCreateContainer(containerId, blocks, local) {
|
|
39555
|
-
assert(logger$
|
|
39556
|
-
assert(logger$
|
|
39555
|
+
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39556
|
+
assert(logger$2T, containerId !== "root", "should not create root container in doc");
|
|
39557
39557
|
this.callbacks.forEach((cb) => {
|
|
39558
39558
|
var _a;
|
|
39559
39559
|
return (_a = cb.onInsertChildContainer) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blocks, local);
|
|
39560
39560
|
});
|
|
39561
39561
|
}
|
|
39562
39562
|
onDeleteComment(commentId, local) {
|
|
39563
|
-
assert(logger$
|
|
39563
|
+
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39564
39564
|
this.callbacks.forEach((cb) => {
|
|
39565
39565
|
var _a;
|
|
39566
39566
|
return (_a = cb.onDeleteComment) == null ? void 0 : _a.call(cb, commentId, local);
|
|
39567
39567
|
});
|
|
39568
39568
|
}
|
|
39569
39569
|
onCreateComment(commentId, local) {
|
|
39570
|
-
assert(logger$
|
|
39570
|
+
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39571
39571
|
this.callbacks.forEach((cb) => {
|
|
39572
39572
|
var _a;
|
|
39573
39573
|
return (_a = cb.onCreateComment) == null ? void 0 : _a.call(cb, commentId, local);
|
|
39574
39574
|
});
|
|
39575
39575
|
}
|
|
39576
39576
|
onUpdateComment(commentId, local) {
|
|
39577
|
-
assert(logger$
|
|
39577
|
+
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39578
39578
|
this.callbacks.forEach((cb) => {
|
|
39579
39579
|
var _a;
|
|
39580
39580
|
return (_a = cb.onUpdateComment) == null ? void 0 : _a.call(cb, commentId, local);
|
|
@@ -39754,7 +39754,7 @@ ${codeText}
|
|
|
39754
39754
|
this.editor.doc.getRemoteUsers().removeListener("remote-carets-change", this.handleRemoteCaretsChanged);
|
|
39755
39755
|
}
|
|
39756
39756
|
}
|
|
39757
|
-
const logger$
|
|
39757
|
+
const logger$2S = getLogger("remote-cursor-decorator");
|
|
39758
39758
|
class RemoteCaretsDecorator {
|
|
39759
39759
|
decorateText(editor, path, blockText) {
|
|
39760
39760
|
const remoteUsers = editor.doc.getRemoteUsers();
|
|
@@ -39763,8 +39763,8 @@ ${codeText}
|
|
|
39763
39763
|
}
|
|
39764
39764
|
const insertions = /* @__PURE__ */ new Map();
|
|
39765
39765
|
const { containerId, blockIndex } = path[path.length - 1];
|
|
39766
|
-
assert(logger$
|
|
39767
|
-
assert(logger$
|
|
39766
|
+
assert(logger$2S, typeof containerId === "string", "invalid path containerId");
|
|
39767
|
+
assert(logger$2S, typeof blockIndex === "number", "invalid path blockIndex");
|
|
39768
39768
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
39769
39769
|
const length = getTextLength(blockText);
|
|
39770
39770
|
const cursorMessages = remoteUsers.getSimpleCursors(blockData.id);
|
|
@@ -39794,7 +39794,7 @@ ${codeText}
|
|
|
39794
39794
|
};
|
|
39795
39795
|
}
|
|
39796
39796
|
}
|
|
39797
|
-
const logger$
|
|
39797
|
+
const logger$2R = getLogger("sharedb-server");
|
|
39798
39798
|
class ShareDBClientBase {
|
|
39799
39799
|
async getFileUrlByHash(uploadFileUrl, hash, name, size, headers) {
|
|
39800
39800
|
try {
|
|
@@ -39846,7 +39846,7 @@ ${codeText}
|
|
|
39846
39846
|
}
|
|
39847
39847
|
max += 500;
|
|
39848
39848
|
const handleUploadProgress = (event) => {
|
|
39849
|
-
logger$
|
|
39849
|
+
logger$2R.info(`on progress: ${event.loaded}`);
|
|
39850
39850
|
let value = event.loaded * 100 / max;
|
|
39851
39851
|
if (value > 100)
|
|
39852
39852
|
value = 100;
|
|
@@ -39875,7 +39875,7 @@ ${codeText}
|
|
|
39875
39875
|
},
|
|
39876
39876
|
onUploadProgress: handleUploadProgress
|
|
39877
39877
|
});
|
|
39878
|
-
logger$
|
|
39878
|
+
logger$2R.info(result);
|
|
39879
39879
|
onProgress(100);
|
|
39880
39880
|
return Array.isArray(result.data) ? result.data[0] : result.data;
|
|
39881
39881
|
}
|
|
@@ -39884,11 +39884,11 @@ ${codeText}
|
|
|
39884
39884
|
const server = this.apiServer();
|
|
39885
39885
|
const api = `${server}/resources`;
|
|
39886
39886
|
const token = this.token();
|
|
39887
|
-
assert(logger$
|
|
39887
|
+
assert(logger$2R, token, "no connection token");
|
|
39888
39888
|
const ret = await this.uploadFile(api, file2, {
|
|
39889
39889
|
[AuthHeader]: token
|
|
39890
39890
|
}, onProgress, options);
|
|
39891
|
-
assert(logger$
|
|
39891
|
+
assert(logger$2R, ret, "no result");
|
|
39892
39892
|
return ret;
|
|
39893
39893
|
}
|
|
39894
39894
|
getResourceId(url) {
|
|
@@ -39952,10 +39952,14 @@ ${codeText}
|
|
|
39952
39952
|
return ret;
|
|
39953
39953
|
}
|
|
39954
39954
|
}
|
|
39955
|
+
const logger$2Q = getLogger("sharedb-local-doc");
|
|
39956
|
+
const axiosInstance$1 = axios__default.default.create();
|
|
39955
39957
|
class ShareDBLocalClient extends ShareDBClientBase {
|
|
39956
39958
|
constructor(_options) {
|
|
39957
39959
|
super();
|
|
39960
|
+
__publicField(this, "reauthFunc");
|
|
39958
39961
|
this._options = _options;
|
|
39962
|
+
this.reauthFunc = _options.onReauth;
|
|
39959
39963
|
}
|
|
39960
39964
|
token() {
|
|
39961
39965
|
return this._options.token;
|
|
@@ -39969,13 +39973,46 @@ ${codeText}
|
|
|
39969
39973
|
docId() {
|
|
39970
39974
|
return this._options.docId;
|
|
39971
39975
|
}
|
|
39972
|
-
request(url, opt) {
|
|
39973
|
-
|
|
39974
|
-
|
|
39975
|
-
|
|
39976
|
-
|
|
39976
|
+
async request(url, opt) {
|
|
39977
|
+
var _a, _b;
|
|
39978
|
+
let token = this.token();
|
|
39979
|
+
let lastErr;
|
|
39980
|
+
for (let i = 0; i < 2; i++) {
|
|
39981
|
+
const options = opt || {};
|
|
39982
|
+
options.url = url;
|
|
39983
|
+
if (!options.headers) {
|
|
39984
|
+
options.headers = {};
|
|
39977
39985
|
}
|
|
39978
|
-
|
|
39986
|
+
assert(logger$2Q, token, "no token");
|
|
39987
|
+
options.headers = {
|
|
39988
|
+
...options.headers,
|
|
39989
|
+
[AuthHeader]: token
|
|
39990
|
+
};
|
|
39991
|
+
try {
|
|
39992
|
+
if (window.isReauthError && Logger$2.level === LogLevel.DEBUG) {
|
|
39993
|
+
throw new Error("reauth error");
|
|
39994
|
+
}
|
|
39995
|
+
const ret = await axiosInstance$1(url, options);
|
|
39996
|
+
return ret;
|
|
39997
|
+
} catch (err) {
|
|
39998
|
+
lastErr = err;
|
|
39999
|
+
if (((_a = err == null ? void 0 : err.response) == null ? void 0 : _a.status) === 403 && this.reauthFunc) {
|
|
40000
|
+
const newToken = await this.reauthFunc();
|
|
40001
|
+
if (!newToken) {
|
|
40002
|
+
throw err;
|
|
40003
|
+
}
|
|
40004
|
+
token = newToken;
|
|
40005
|
+
this._options.token = token;
|
|
40006
|
+
continue;
|
|
40007
|
+
}
|
|
40008
|
+
if ((_b = err.response) == null ? void 0 : _b.data) {
|
|
40009
|
+
err.responseData = err.response.data;
|
|
40010
|
+
}
|
|
40011
|
+
throw err;
|
|
40012
|
+
}
|
|
40013
|
+
}
|
|
40014
|
+
assert(logger$2Q, lastErr, "no error");
|
|
40015
|
+
throw lastErr;
|
|
39979
40016
|
}
|
|
39980
40017
|
}
|
|
39981
40018
|
class ShareDBLocalDoc extends LocalDoc {
|
|
@@ -93140,7 +93177,7 @@ ${data2.plantumlText}
|
|
|
93140
93177
|
}
|
|
93141
93178
|
}
|
|
93142
93179
|
});
|
|
93143
|
-
editor.version = "2.8.
|
|
93180
|
+
editor.version = "2.8.27";
|
|
93144
93181
|
return editor;
|
|
93145
93182
|
}
|
|
93146
93183
|
function isDoc(doc2) {
|
|
@@ -93253,7 +93290,7 @@ ${data2.plantumlText}
|
|
|
93253
93290
|
}
|
|
93254
93291
|
});
|
|
93255
93292
|
OnesEditorToolbar.register(editor);
|
|
93256
|
-
editor.version = "2.8.
|
|
93293
|
+
editor.version = "2.8.27";
|
|
93257
93294
|
return editor;
|
|
93258
93295
|
}
|
|
93259
93296
|
async function showDocVersions(editor, options, serverUrl) {
|
|
@@ -139765,7 +139802,7 @@ ${data2.plantumlText}
|
|
|
139765
139802
|
exports2.loadJs = loadJs;
|
|
139766
139803
|
exports2.loadJsPromise = loadJsPromise;
|
|
139767
139804
|
exports2.lockers = lockers;
|
|
139768
|
-
exports2.logger = logger$
|
|
139805
|
+
exports2.logger = logger$4r;
|
|
139769
139806
|
exports2.markdownToDoc = markdownToDoc;
|
|
139770
139807
|
exports2.mergeCommands = mergeCommands;
|
|
139771
139808
|
exports2.mergeDocs = mergeDocs;
|