@ones-editor/editor 1.1.7-beta.15 → 1.1.7-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +410 -305
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6088,7 +6088,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6088
6088
|
imageExportFailed: "\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F"
|
|
6089
6089
|
}
|
|
6090
6090
|
};
|
|
6091
|
-
const logger$
|
|
6091
|
+
const logger$4c = getLogger("i18n");
|
|
6092
6092
|
const langs$2 = {
|
|
6093
6093
|
"en-US": enUS$u,
|
|
6094
6094
|
"zh-CN": zhCN$u,
|
|
@@ -6108,7 +6108,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6108
6108
|
function t$8(key, args) {
|
|
6109
6109
|
const ret = i18n.get(key, args);
|
|
6110
6110
|
if (ret === key) {
|
|
6111
|
-
logger$
|
|
6111
|
+
logger$4c.warn(`no locale value for key ${key}`);
|
|
6112
6112
|
}
|
|
6113
6113
|
return ret;
|
|
6114
6114
|
}
|
|
@@ -6721,7 +6721,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6721
6721
|
this._callbacks.clear();
|
|
6722
6722
|
}
|
|
6723
6723
|
}
|
|
6724
|
-
const logger$
|
|
6724
|
+
const logger$4b = getLogger("await-locker");
|
|
6725
6725
|
class AwaitLock {
|
|
6726
6726
|
constructor() {
|
|
6727
6727
|
__publicField(this, "_acquired", false);
|
|
@@ -6763,7 +6763,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6763
6763
|
}
|
|
6764
6764
|
if (this._waitingResolvers.length > 0) {
|
|
6765
6765
|
const resolve = this._waitingResolvers.shift();
|
|
6766
|
-
assert(logger$
|
|
6766
|
+
assert(logger$4b, resolve, "Resolver missing");
|
|
6767
6767
|
resolve(void 0);
|
|
6768
6768
|
} else {
|
|
6769
6769
|
this._acquired = false;
|
|
@@ -6815,7 +6815,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6815
6815
|
}
|
|
6816
6816
|
}
|
|
6817
6817
|
const lockers = new Lockers();
|
|
6818
|
-
const logger$
|
|
6818
|
+
const logger$4a = getLogger("dom-utils");
|
|
6819
6819
|
function addClass(dom, ...className) {
|
|
6820
6820
|
if (dom && dom.nodeType === Node.ELEMENT_NODE) {
|
|
6821
6821
|
dom.classList.add(...className);
|
|
@@ -6869,7 +6869,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6869
6869
|
range.setStart(node, offset);
|
|
6870
6870
|
return range;
|
|
6871
6871
|
} catch (err) {
|
|
6872
|
-
assert(logger$
|
|
6872
|
+
assert(logger$4a, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
|
|
6873
6873
|
}
|
|
6874
6874
|
}
|
|
6875
6875
|
function createExpandedRange(startNode, startOffset, endNode, endOffset) {
|
|
@@ -6879,17 +6879,17 @@ var __publicField = (obj, key, value) => {
|
|
|
6879
6879
|
range.setEnd(endNode, endOffset);
|
|
6880
6880
|
return range;
|
|
6881
6881
|
} catch (err) {
|
|
6882
|
-
assert(logger$
|
|
6882
|
+
assert(logger$4a, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
|
|
6883
6883
|
}
|
|
6884
6884
|
}
|
|
6885
6885
|
function getFirstClientRect(elem) {
|
|
6886
6886
|
const rects = elem.getClientRects();
|
|
6887
|
-
assert(logger$
|
|
6887
|
+
assert(logger$4a, rects.length >= 1, "getFirstClientRect: no rects");
|
|
6888
6888
|
return rects[0];
|
|
6889
6889
|
}
|
|
6890
6890
|
function getLastClientRect(elem) {
|
|
6891
6891
|
const rects = elem.getClientRects();
|
|
6892
|
-
assert(logger$
|
|
6892
|
+
assert(logger$4a, rects.length >= 1, "getLastClientRect: no rects");
|
|
6893
6893
|
return rects[rects.length - 1];
|
|
6894
6894
|
}
|
|
6895
6895
|
function getDistanceSquare(rect, x, y) {
|
|
@@ -6929,7 +6929,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6929
6929
|
return 0;
|
|
6930
6930
|
}
|
|
6931
6931
|
if (!elem1.parentElement || !elem2.parentElement) {
|
|
6932
|
-
assert(logger$
|
|
6932
|
+
assert(logger$4a, false, "invalid dom node to compare");
|
|
6933
6933
|
}
|
|
6934
6934
|
if (elem1.parentElement === elem2.parentElement) {
|
|
6935
6935
|
const children = Array.from(elem1.parentElement.children);
|
|
@@ -6946,7 +6946,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6946
6946
|
const parents1 = getParents(elem1);
|
|
6947
6947
|
const parents2 = getParents(elem2);
|
|
6948
6948
|
if (parents1[0] !== parents2[0]) {
|
|
6949
|
-
assert(logger$
|
|
6949
|
+
assert(logger$4a, false, "invalid dom node to compare, different tree");
|
|
6950
6950
|
}
|
|
6951
6951
|
for (let i = 1; ; i++) {
|
|
6952
6952
|
const parent1 = parents1[i];
|
|
@@ -7445,7 +7445,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7445
7445
|
}
|
|
7446
7446
|
}
|
|
7447
7447
|
const MIN_DISTANCE_THRESHOLD = 3;
|
|
7448
|
-
const logger$
|
|
7448
|
+
const logger$49 = getLogger("drag-drop");
|
|
7449
7449
|
class DragDrop {
|
|
7450
7450
|
constructor(options) {
|
|
7451
7451
|
__publicField(this, "dragStarted", false);
|
|
@@ -7465,7 +7465,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7465
7465
|
var _a;
|
|
7466
7466
|
event.preventDefault();
|
|
7467
7467
|
event.stopPropagation();
|
|
7468
|
-
assert(logger$
|
|
7468
|
+
assert(logger$49, this.mouseDownEvent, "no mouse down event");
|
|
7469
7469
|
const deltaX = event.x - this.mouseDownEvent.x;
|
|
7470
7470
|
const deltaY = event.y - this.mouseDownEvent.y;
|
|
7471
7471
|
if (this.dragStarted) {
|
|
@@ -7479,7 +7479,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7479
7479
|
});
|
|
7480
7480
|
__publicField(this, "handleMouseUp", (event) => {
|
|
7481
7481
|
if (event.button === 0) {
|
|
7482
|
-
assert(logger$
|
|
7482
|
+
assert(logger$49, this.mouseDownEvent, "no mouse down event");
|
|
7483
7483
|
const deltaX = event.x - this.mouseDownEvent.x;
|
|
7484
7484
|
const deltaY = event.y - this.mouseDownEvent.y;
|
|
7485
7485
|
this.onDragEnd(event, deltaX, deltaY);
|
|
@@ -7552,7 +7552,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7552
7552
|
const dragDrop = new DragDrop(options);
|
|
7553
7553
|
return dragDrop;
|
|
7554
7554
|
}
|
|
7555
|
-
const logger$
|
|
7555
|
+
const logger$48 = getLogger("character");
|
|
7556
7556
|
function checkChar(charCode, rangeList) {
|
|
7557
7557
|
for (let i = 0; i < rangeList.length; i++) {
|
|
7558
7558
|
const start = rangeList[i][0];
|
|
@@ -7599,7 +7599,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7599
7599
|
}
|
|
7600
7600
|
function trimChar(s, char) {
|
|
7601
7601
|
let c = char;
|
|
7602
|
-
assert(logger$
|
|
7602
|
+
assert(logger$48, c.length === 1, "invalid char length");
|
|
7603
7603
|
if (c === "]")
|
|
7604
7604
|
c = "\\]";
|
|
7605
7605
|
if (c === "\\")
|
|
@@ -7953,7 +7953,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7953
7953
|
const metrics = context.measureText(text2);
|
|
7954
7954
|
return metrics.width + 4;
|
|
7955
7955
|
}
|
|
7956
|
-
const logger$
|
|
7956
|
+
const logger$47 = getLogger("editor-clipboard");
|
|
7957
7957
|
async function setClipboardDataByEvent(items, event) {
|
|
7958
7958
|
if (event.clipboardData) {
|
|
7959
7959
|
const data = event.clipboardData;
|
|
@@ -7974,7 +7974,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7974
7974
|
await navigator.clipboard.write([clipboardItems]);
|
|
7975
7975
|
return true;
|
|
7976
7976
|
} catch (err) {
|
|
7977
|
-
logger$
|
|
7977
|
+
logger$47.error(err);
|
|
7978
7978
|
return false;
|
|
7979
7979
|
}
|
|
7980
7980
|
}
|
|
@@ -8024,7 +8024,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8024
8024
|
a.click();
|
|
8025
8025
|
a.remove();
|
|
8026
8026
|
}
|
|
8027
|
-
const logger$
|
|
8027
|
+
const logger$46 = getLogger("auto-scroll");
|
|
8028
8028
|
function scrollable(scrollElement, direction) {
|
|
8029
8029
|
if (scrollElement.scrollHeight === scrollElement.clientHeight) {
|
|
8030
8030
|
return false;
|
|
@@ -8048,7 +8048,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8048
8048
|
const isHorizontal = direction === "left" || direction === "right";
|
|
8049
8049
|
const scroll = () => {
|
|
8050
8050
|
if (!scrollable(scrollElement, direction)) {
|
|
8051
|
-
logger$
|
|
8051
|
+
logger$46.debug("No need for scroll");
|
|
8052
8052
|
return null;
|
|
8053
8053
|
}
|
|
8054
8054
|
if (isHorizontal) {
|
|
@@ -8106,7 +8106,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8106
8106
|
if (this.scrolling) {
|
|
8107
8107
|
return;
|
|
8108
8108
|
}
|
|
8109
|
-
logger$
|
|
8109
|
+
logger$46.debug(`scroll direction: ${direction}`);
|
|
8110
8110
|
this.cancelScroll = continuousScroll(scrollElement, {
|
|
8111
8111
|
direction,
|
|
8112
8112
|
step
|
|
@@ -8357,7 +8357,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8357
8357
|
const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
|
|
8358
8358
|
return ColorNames[colorIndex];
|
|
8359
8359
|
}
|
|
8360
|
-
const logger$
|
|
8360
|
+
const logger$45 = getLogger("element");
|
|
8361
8361
|
function createContainerElement(parent, type, containerId) {
|
|
8362
8362
|
const container = createElement("div", [type], parent);
|
|
8363
8363
|
container.setAttribute("data-type", "editor-container");
|
|
@@ -8367,7 +8367,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8367
8367
|
}
|
|
8368
8368
|
function getContainerById(editor, containerId) {
|
|
8369
8369
|
const container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
|
|
8370
|
-
assert(logger$
|
|
8370
|
+
assert(logger$45, container, `no container: ${containerId}`);
|
|
8371
8371
|
return container;
|
|
8372
8372
|
}
|
|
8373
8373
|
function getExistsContainerById(editor, containerId) {
|
|
@@ -8376,7 +8376,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8376
8376
|
}
|
|
8377
8377
|
function getContainerBlocksElement(container) {
|
|
8378
8378
|
const blocks = container.querySelector(":scope > .container-blocks");
|
|
8379
|
-
assert(logger$
|
|
8379
|
+
assert(logger$45, blocks, "no container blocks element");
|
|
8380
8380
|
return blocks;
|
|
8381
8381
|
}
|
|
8382
8382
|
function getContainerToolsElement(container) {
|
|
@@ -8386,16 +8386,16 @@ var __publicField = (obj, key, value) => {
|
|
|
8386
8386
|
}
|
|
8387
8387
|
return tools;
|
|
8388
8388
|
}
|
|
8389
|
-
const logger$
|
|
8389
|
+
const logger$44 = getLogger("container-children");
|
|
8390
8390
|
function getChildBlocks(container) {
|
|
8391
8391
|
const content = getContainerBlocksElement(container);
|
|
8392
8392
|
const blocks = Array.from(content.children);
|
|
8393
|
-
assert(logger$
|
|
8393
|
+
assert(logger$44, blocks.length > 0, "container have not any child block");
|
|
8394
8394
|
return blocks;
|
|
8395
8395
|
}
|
|
8396
8396
|
function getFirstChildBlock(container) {
|
|
8397
8397
|
const block = container.querySelector(":scope > .container-blocks > div[data-type=editor-block]");
|
|
8398
|
-
assert(logger$
|
|
8398
|
+
assert(logger$44, block, "container have not any child block");
|
|
8399
8399
|
return block;
|
|
8400
8400
|
}
|
|
8401
8401
|
function getLastChildBlock(container) {
|
|
@@ -8407,7 +8407,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8407
8407
|
}
|
|
8408
8408
|
function getBlockByIndex(container, blockIndex) {
|
|
8409
8409
|
const block = getChildBlocks(container)[blockIndex];
|
|
8410
|
-
assert(logger$
|
|
8410
|
+
assert(logger$44, block, `container have not block at index ${blockIndex}`);
|
|
8411
8411
|
return block;
|
|
8412
8412
|
}
|
|
8413
8413
|
function findBlockByIndex(container, blockIndex) {
|
|
@@ -8513,18 +8513,18 @@ var __publicField = (obj, key, value) => {
|
|
|
8513
8513
|
});
|
|
8514
8514
|
}
|
|
8515
8515
|
}
|
|
8516
|
-
const logger$
|
|
8516
|
+
const logger$43 = getLogger("block-class");
|
|
8517
8517
|
function getBlockClass(editor, block) {
|
|
8518
8518
|
return editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
8519
8519
|
}
|
|
8520
8520
|
function getTextBlockClass(editor, block) {
|
|
8521
8521
|
const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
8522
|
-
assert(logger$
|
|
8522
|
+
assert(logger$43, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
|
|
8523
8523
|
return text2;
|
|
8524
8524
|
}
|
|
8525
8525
|
function getComplexBlockClass(editor, block) {
|
|
8526
8526
|
const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
8527
|
-
assert(logger$
|
|
8527
|
+
assert(logger$43, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
|
|
8528
8528
|
return complex;
|
|
8529
8529
|
}
|
|
8530
8530
|
function getBlockClassByType(editor, type) {
|
|
@@ -8722,7 +8722,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8722
8722
|
return { classes, attributes: newAttributes, styles: newStyles };
|
|
8723
8723
|
}
|
|
8724
8724
|
}
|
|
8725
|
-
const logger$
|
|
8725
|
+
const logger$42 = getLogger("block-dom");
|
|
8726
8726
|
function isBlock(node) {
|
|
8727
8727
|
if (!(node instanceof HTMLDivElement)) {
|
|
8728
8728
|
return false;
|
|
@@ -8743,12 +8743,12 @@ var __publicField = (obj, key, value) => {
|
|
|
8743
8743
|
}
|
|
8744
8744
|
function getBlockId(block) {
|
|
8745
8745
|
const { id } = block;
|
|
8746
|
-
assert(logger$
|
|
8746
|
+
assert(logger$42, id, "no block id");
|
|
8747
8747
|
return id;
|
|
8748
8748
|
}
|
|
8749
8749
|
function getBlockType(block) {
|
|
8750
8750
|
const type = block.getAttribute("data-block-type");
|
|
8751
|
-
assert(logger$
|
|
8751
|
+
assert(logger$42, type, "invalid block dom, no data-type");
|
|
8752
8752
|
return type;
|
|
8753
8753
|
}
|
|
8754
8754
|
function getParentBlock(node) {
|
|
@@ -8771,12 +8771,12 @@ var __publicField = (obj, key, value) => {
|
|
|
8771
8771
|
}
|
|
8772
8772
|
function getParentContainer(block) {
|
|
8773
8773
|
const container = block.closest("div[data-type=editor-container]");
|
|
8774
|
-
assert(logger$
|
|
8774
|
+
assert(logger$42, container, "failed to get block container");
|
|
8775
8775
|
return container;
|
|
8776
8776
|
}
|
|
8777
8777
|
function getBlockContent(block) {
|
|
8778
8778
|
const content = block.querySelector(":scope >div[data-type=block-content]");
|
|
8779
|
-
assert(logger$
|
|
8779
|
+
assert(logger$42, content, "no block content");
|
|
8780
8780
|
return content;
|
|
8781
8781
|
}
|
|
8782
8782
|
function getBlockTools(block) {
|
|
@@ -8785,7 +8785,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8785
8785
|
tools = createElement("div", [], block);
|
|
8786
8786
|
tools.setAttribute("data-type", "block-tools");
|
|
8787
8787
|
}
|
|
8788
|
-
assert(logger$
|
|
8788
|
+
assert(logger$42, tools, "no block tools");
|
|
8789
8789
|
return tools;
|
|
8790
8790
|
}
|
|
8791
8791
|
function getExistsBlockTools(block) {
|
|
@@ -8806,7 +8806,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8806
8806
|
function createBlockElement(editor, path, data) {
|
|
8807
8807
|
const blockData = editor.editorDecorators.decorateBlock(path, data);
|
|
8808
8808
|
const { id, type } = blockData;
|
|
8809
|
-
assert(logger$
|
|
8809
|
+
assert(logger$42, id, "no block id");
|
|
8810
8810
|
const elem = createElement("div", [`${type}-block`], null);
|
|
8811
8811
|
elem.id = id;
|
|
8812
8812
|
elem.setAttribute("data-type", "editor-block");
|
|
@@ -8844,7 +8844,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8844
8844
|
}
|
|
8845
8845
|
function getBoxTypeFromElement(box) {
|
|
8846
8846
|
const type = box.getAttribute("data-box-type");
|
|
8847
|
-
assert(logger$
|
|
8847
|
+
assert(logger$42, type, "not a valid box element, no type");
|
|
8848
8848
|
return type;
|
|
8849
8849
|
}
|
|
8850
8850
|
function isBox(node) {
|
|
@@ -8855,7 +8855,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8855
8855
|
}
|
|
8856
8856
|
function getBoxId(box) {
|
|
8857
8857
|
const { id } = box;
|
|
8858
|
-
assert(logger$
|
|
8858
|
+
assert(logger$42, id, "no box id");
|
|
8859
8859
|
return id;
|
|
8860
8860
|
}
|
|
8861
8861
|
function getParentBox(node) {
|
|
@@ -8877,7 +8877,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8877
8877
|
}
|
|
8878
8878
|
function getBoxContent(box) {
|
|
8879
8879
|
const content = box.querySelector("span[data-type=box-content]");
|
|
8880
|
-
assert(logger$
|
|
8880
|
+
assert(logger$42, content, "invalid box dom, no content");
|
|
8881
8881
|
return content;
|
|
8882
8882
|
}
|
|
8883
8883
|
function createInsertionElement(type, id, attributes) {
|
|
@@ -8909,7 +8909,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8909
8909
|
}
|
|
8910
8910
|
function getInsertionContent(insertion) {
|
|
8911
8911
|
const content = insertion.querySelector("span[data-type=insertion-content]");
|
|
8912
|
-
assert(logger$
|
|
8912
|
+
assert(logger$42, content, "invalid insertion-child dom, no content");
|
|
8913
8913
|
return content;
|
|
8914
8914
|
}
|
|
8915
8915
|
function getPrevBlock(block) {
|
|
@@ -8956,7 +8956,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8956
8956
|
const container = getParentContainer(block);
|
|
8957
8957
|
const children = getChildBlocks(container);
|
|
8958
8958
|
const index2 = children.indexOf(block);
|
|
8959
|
-
assert(logger$
|
|
8959
|
+
assert(logger$42, index2 !== -1, "invalid block & container dom, failed to get block index");
|
|
8960
8960
|
return index2;
|
|
8961
8961
|
}
|
|
8962
8962
|
function isInBlock(target) {
|
|
@@ -8985,7 +8985,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8985
8985
|
const blockClass = getBlockClass(editor, block);
|
|
8986
8986
|
return blockClass.getCaretRect(block, pos);
|
|
8987
8987
|
}
|
|
8988
|
-
const logger$
|
|
8988
|
+
const logger$41 = getLogger("container");
|
|
8989
8989
|
function isContainer(elem) {
|
|
8990
8990
|
return elem.getAttribute("data-type") === "editor-container";
|
|
8991
8991
|
}
|
|
@@ -8997,9 +8997,9 @@ var __publicField = (obj, key, value) => {
|
|
|
8997
8997
|
}
|
|
8998
8998
|
function getContainerId(container) {
|
|
8999
8999
|
const id = container.getAttribute("data-container-id");
|
|
9000
|
-
assert(logger$
|
|
9000
|
+
assert(logger$41, id, "no id for container");
|
|
9001
9001
|
if (isRootContainer(container)) {
|
|
9002
|
-
assert(logger$
|
|
9002
|
+
assert(logger$41, id === "root", `invalid root container id, : ${id}`);
|
|
9003
9003
|
}
|
|
9004
9004
|
return id;
|
|
9005
9005
|
}
|
|
@@ -9007,7 +9007,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9007
9007
|
const containerId = getContainerId(container);
|
|
9008
9008
|
return doc2.getContainerBlocks(containerId);
|
|
9009
9009
|
}
|
|
9010
|
-
const logger$
|
|
9010
|
+
const logger$40 = getLogger("block");
|
|
9011
9011
|
function getBlockTextLength$4(editor, block) {
|
|
9012
9012
|
return getBlockClass(editor, block).getBlockTextLength(block);
|
|
9013
9013
|
}
|
|
@@ -9026,7 +9026,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9026
9026
|
return block;
|
|
9027
9027
|
}
|
|
9028
9028
|
const parent = getParentBlock(container);
|
|
9029
|
-
assert(logger$
|
|
9029
|
+
assert(logger$40, parent, "no parent block exists for child container");
|
|
9030
9030
|
block = parent;
|
|
9031
9031
|
}
|
|
9032
9032
|
}
|
|
@@ -9050,7 +9050,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9050
9050
|
}
|
|
9051
9051
|
return fun(editor, block, options);
|
|
9052
9052
|
} catch (err) {
|
|
9053
|
-
logger$
|
|
9053
|
+
logger$40.debug(`unsupported block type: ${type}`);
|
|
9054
9054
|
return null;
|
|
9055
9055
|
}
|
|
9056
9056
|
}
|
|
@@ -9070,7 +9070,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9070
9070
|
const styles = Object.fromEntries(Object.entries(data).filter(([key]) => key.startsWith("style-")));
|
|
9071
9071
|
Object.entries(styles).forEach(([, value]) => {
|
|
9072
9072
|
const type = typeof value;
|
|
9073
|
-
assert(logger$
|
|
9073
|
+
assert(logger$40, type === "string" || type === "number" || type === "boolean", "invalid style value");
|
|
9074
9074
|
});
|
|
9075
9075
|
return styles;
|
|
9076
9076
|
}
|
|
@@ -9080,7 +9080,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9080
9080
|
}
|
|
9081
9081
|
return false;
|
|
9082
9082
|
}
|
|
9083
|
-
const logger$
|
|
9083
|
+
const logger$3$ = getLogger("block-path");
|
|
9084
9084
|
function getBlockPath(block) {
|
|
9085
9085
|
const ret = [];
|
|
9086
9086
|
let current = block;
|
|
@@ -9094,10 +9094,10 @@ var __publicField = (obj, key, value) => {
|
|
|
9094
9094
|
return ret;
|
|
9095
9095
|
}
|
|
9096
9096
|
const parentBlock = getParentBlock(container);
|
|
9097
|
-
assert(logger$
|
|
9097
|
+
assert(logger$3$, parentBlock, "no parent block");
|
|
9098
9098
|
current = parentBlock;
|
|
9099
9099
|
}
|
|
9100
|
-
assert(logger$
|
|
9100
|
+
assert(logger$3$, false, "no parent block");
|
|
9101
9101
|
return [];
|
|
9102
9102
|
}
|
|
9103
9103
|
function getBlockOptions(editor, block) {
|
|
@@ -9165,14 +9165,14 @@ var __publicField = (obj, key, value) => {
|
|
|
9165
9165
|
}
|
|
9166
9166
|
return { element: null, commands: [] };
|
|
9167
9167
|
}
|
|
9168
|
-
const logger$
|
|
9168
|
+
const logger$3_ = getLogger("embed-block-common");
|
|
9169
9169
|
function isEmbedBlock(block) {
|
|
9170
9170
|
return getBlockType(block) === "embed";
|
|
9171
9171
|
}
|
|
9172
9172
|
function getEmbedType(block) {
|
|
9173
|
-
assert(logger$
|
|
9173
|
+
assert(logger$3_, isEmbedBlock(block), "not an embed block");
|
|
9174
9174
|
const type = block.getAttribute("data-embed-type");
|
|
9175
|
-
assert(logger$
|
|
9175
|
+
assert(logger$3_, type, "no embed data type");
|
|
9176
9176
|
return type;
|
|
9177
9177
|
}
|
|
9178
9178
|
function getEmbedClassFromBlock(editor, block) {
|
|
@@ -9224,10 +9224,10 @@ var __publicField = (obj, key, value) => {
|
|
|
9224
9224
|
data
|
|
9225
9225
|
});
|
|
9226
9226
|
}
|
|
9227
|
-
const logger$
|
|
9227
|
+
const logger$3Z = getLogger("execute-block-command");
|
|
9228
9228
|
function executeEmbedBlockCommand(editor, block, commandGroup, item) {
|
|
9229
9229
|
var _a;
|
|
9230
|
-
assert(logger$
|
|
9230
|
+
assert(logger$3Z, isEmbedBlock(block), "not a embed block");
|
|
9231
9231
|
const embedType = getEmbedType(block);
|
|
9232
9232
|
const embed = getEmbedClassByType(editor, embedType);
|
|
9233
9233
|
if (!embed.getOptions) {
|
|
@@ -9259,7 +9259,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9259
9259
|
}
|
|
9260
9260
|
return void 0;
|
|
9261
9261
|
}
|
|
9262
|
-
const logger$
|
|
9262
|
+
const logger$3Y = getLogger("text-block-child");
|
|
9263
9263
|
function isTextBlockContentChild(elem) {
|
|
9264
9264
|
if (elem.tagName !== "SPAN") {
|
|
9265
9265
|
return false;
|
|
@@ -9267,14 +9267,14 @@ var __publicField = (obj, key, value) => {
|
|
|
9267
9267
|
return true;
|
|
9268
9268
|
}
|
|
9269
9269
|
function isTextBlockContentBoxChild(elem) {
|
|
9270
|
-
assert(logger$
|
|
9270
|
+
assert(logger$3Y, isTextBlockContentChild(elem), "not a valid text child");
|
|
9271
9271
|
if (elem.getAttribute("data-type") === "editor-box") {
|
|
9272
9272
|
return true;
|
|
9273
9273
|
}
|
|
9274
9274
|
return false;
|
|
9275
9275
|
}
|
|
9276
9276
|
function isTextBlockContentInsertionChild(elem) {
|
|
9277
|
-
assert(logger$
|
|
9277
|
+
assert(logger$3Y, isTextBlockContentChild(elem), "not a valid text child");
|
|
9278
9278
|
if (elem.getAttribute("data-type") === "editor-insertion") {
|
|
9279
9279
|
return true;
|
|
9280
9280
|
}
|
|
@@ -9284,7 +9284,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9284
9284
|
return !isTextBlockContentBoxChild(elem) && !isTextBlockContentInsertionChild(elem);
|
|
9285
9285
|
}
|
|
9286
9286
|
function getTextBlockContentChildType(child) {
|
|
9287
|
-
assert(logger$
|
|
9287
|
+
assert(logger$3Y, isTextBlockContentChild(child), "not a valid text child");
|
|
9288
9288
|
if (isTextBlockContentBoxChild(child)) {
|
|
9289
9289
|
return "box";
|
|
9290
9290
|
}
|
|
@@ -9299,15 +9299,15 @@ var __publicField = (obj, key, value) => {
|
|
|
9299
9299
|
return 0;
|
|
9300
9300
|
if (type === "box")
|
|
9301
9301
|
return 1;
|
|
9302
|
-
assert(logger$
|
|
9303
|
-
assert(logger$
|
|
9302
|
+
assert(logger$3Y, child.textContent !== null, "text block content is undefined");
|
|
9303
|
+
assert(logger$3Y, child.textContent.length >= 0, "text block content length is negative");
|
|
9304
9304
|
return child.textContent.length;
|
|
9305
9305
|
}
|
|
9306
9306
|
function getTextBlockContentChildren(block) {
|
|
9307
9307
|
const content = getBlockContent(block);
|
|
9308
9308
|
const children = Array.from(content.children);
|
|
9309
9309
|
children.forEach((child) => {
|
|
9310
|
-
assert(logger$
|
|
9310
|
+
assert(logger$3Y, isTextBlockContentChild(child), "not a valid text child");
|
|
9311
9311
|
});
|
|
9312
9312
|
return children;
|
|
9313
9313
|
}
|
|
@@ -9336,30 +9336,30 @@ var __publicField = (obj, key, value) => {
|
|
|
9336
9336
|
};
|
|
9337
9337
|
}
|
|
9338
9338
|
const offset = blockOffset - start;
|
|
9339
|
-
assert(logger$
|
|
9340
|
-
assert(logger$
|
|
9339
|
+
assert(logger$3Y, offset > 0, "invalid offset value");
|
|
9340
|
+
assert(logger$3Y, !isTextBlockContentBoxChild(child), "invalid box child");
|
|
9341
9341
|
return {
|
|
9342
9342
|
prev: child,
|
|
9343
9343
|
next: child,
|
|
9344
9344
|
offset
|
|
9345
9345
|
};
|
|
9346
9346
|
}
|
|
9347
|
-
assert(logger$
|
|
9347
|
+
assert(logger$3Y, false, `invalid block child at position: ${blockOffset}`);
|
|
9348
9348
|
}
|
|
9349
|
-
const logger$
|
|
9349
|
+
const logger$3X = getLogger("child-container-path");
|
|
9350
9350
|
function getContainerBlockPath(container) {
|
|
9351
9351
|
if (isRootContainer(container)) {
|
|
9352
9352
|
return [];
|
|
9353
9353
|
}
|
|
9354
9354
|
const parentBlock = getParentBlock(container);
|
|
9355
|
-
assert(logger$
|
|
9355
|
+
assert(logger$3X, parentBlock, "no parent block");
|
|
9356
9356
|
return getBlockPath(parentBlock);
|
|
9357
9357
|
}
|
|
9358
|
-
const logger$
|
|
9358
|
+
const logger$3W = getLogger("load-blocks");
|
|
9359
9359
|
function loadBlocks(editor, container, path) {
|
|
9360
9360
|
const containerId = getContainerId(container);
|
|
9361
9361
|
const blocks = getContainerBlocks$1(container, editor.doc);
|
|
9362
|
-
assert(logger$
|
|
9362
|
+
assert(logger$3W, blocks.length > 0, "no blocks in container");
|
|
9363
9363
|
const fragment = document.createDocumentFragment();
|
|
9364
9364
|
blocks.forEach((b, index2) => {
|
|
9365
9365
|
const block = editor.editorBlocks.createBlock([...path, { containerId, blockIndex: index2 }], container, b);
|
|
@@ -9375,7 +9375,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9375
9375
|
return block;
|
|
9376
9376
|
}
|
|
9377
9377
|
const blocks = getChildBlocks(container);
|
|
9378
|
-
assert(logger$
|
|
9378
|
+
assert(logger$3W, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
|
|
9379
9379
|
if (blockIndex === blocks.length) {
|
|
9380
9380
|
containerBlocksElement.appendChild(block);
|
|
9381
9381
|
} else {
|
|
@@ -9393,7 +9393,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9393
9393
|
insertBlockAt(container, blockIndex, block);
|
|
9394
9394
|
return block;
|
|
9395
9395
|
}
|
|
9396
|
-
const logger$
|
|
9396
|
+
const logger$3V = getLogger("root-container");
|
|
9397
9397
|
class RootContainer {
|
|
9398
9398
|
constructor(editor, rootContainer) {
|
|
9399
9399
|
__publicField(this, "resizeObserver");
|
|
@@ -9411,7 +9411,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9411
9411
|
this.editor.selection.updateSelection(null);
|
|
9412
9412
|
this.editor.emit("resize", this.editor);
|
|
9413
9413
|
} catch (err) {
|
|
9414
|
-
logger$
|
|
9414
|
+
logger$3V.warn(`failed to update selection while container resizing: ${err.message}`);
|
|
9415
9415
|
}
|
|
9416
9416
|
});
|
|
9417
9417
|
__publicField(this, "handleClick", (event) => {
|
|
@@ -9444,7 +9444,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9444
9444
|
const box = getParentBox(elem);
|
|
9445
9445
|
if (box) {
|
|
9446
9446
|
const block2 = getParentBlock(box);
|
|
9447
|
-
assert(logger$
|
|
9447
|
+
assert(logger$3V, block2, "no parent block");
|
|
9448
9448
|
(_b = (_a = this.editor.editorBoxes.getBoxClass(getBoxTypeFromElement(box))) == null ? void 0 : _a.handleClickBox) == null ? void 0 : _b.call(_a, this.editor, box, event);
|
|
9449
9449
|
return;
|
|
9450
9450
|
}
|
|
@@ -9606,7 +9606,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9606
9606
|
}
|
|
9607
9607
|
return isEmptyTextBlock(editor, blocks[0]);
|
|
9608
9608
|
}
|
|
9609
|
-
const logger$
|
|
9609
|
+
const logger$3U = getLogger("complex-block-position");
|
|
9610
9610
|
class EditorComplexBlockPosition {
|
|
9611
9611
|
constructor(block, childContainerId, custom) {
|
|
9612
9612
|
__publicField(this, "blockId");
|
|
@@ -9615,7 +9615,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9615
9615
|
if (block instanceof HTMLElement) {
|
|
9616
9616
|
this.blockId = getBlockId(block);
|
|
9617
9617
|
} else {
|
|
9618
|
-
assert(logger$
|
|
9618
|
+
assert(logger$3U, typeof block === "string", `not a valid block id: ${block}`);
|
|
9619
9619
|
this.blockId = block;
|
|
9620
9620
|
}
|
|
9621
9621
|
this.childContainerId = childContainerId;
|
|
@@ -9627,7 +9627,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9627
9627
|
return false;
|
|
9628
9628
|
}
|
|
9629
9629
|
}
|
|
9630
|
-
const logger$
|
|
9630
|
+
const logger$3T = getLogger("simple-block-position");
|
|
9631
9631
|
class EditorSimpleBlockPosition {
|
|
9632
9632
|
constructor(block, offset, type) {
|
|
9633
9633
|
__publicField(this, "blockId");
|
|
@@ -9636,7 +9636,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9636
9636
|
if (block instanceof HTMLElement) {
|
|
9637
9637
|
this.blockId = getBlockId(block);
|
|
9638
9638
|
} else {
|
|
9639
|
-
assert(logger$
|
|
9639
|
+
assert(logger$3T, typeof block === "string", `not a valid block id: ${block}`);
|
|
9640
9640
|
this.blockId = block;
|
|
9641
9641
|
}
|
|
9642
9642
|
this.offset = offset;
|
|
@@ -9646,7 +9646,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9646
9646
|
return true;
|
|
9647
9647
|
}
|
|
9648
9648
|
}
|
|
9649
|
-
const logger$
|
|
9649
|
+
const logger$3S = getLogger("editor-position");
|
|
9650
9650
|
function createSimpleBlockPosition(block, offset, type) {
|
|
9651
9651
|
return new EditorSimpleBlockPosition(block, offset, type);
|
|
9652
9652
|
}
|
|
@@ -9668,7 +9668,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9668
9668
|
}
|
|
9669
9669
|
const block1 = editor.getBlockById(pos1.blockId);
|
|
9670
9670
|
const block2 = editor.getBlockById(pos2.blockId);
|
|
9671
|
-
assert(logger$
|
|
9671
|
+
assert(logger$3S, block1 !== block2, "comparePosition: blocks are the same");
|
|
9672
9672
|
return compareElement(block1, block2);
|
|
9673
9673
|
}
|
|
9674
9674
|
if (isComplexBlockPosition(pos1) && isComplexBlockPosition(pos2)) {
|
|
@@ -9679,13 +9679,13 @@ var __publicField = (obj, key, value) => {
|
|
|
9679
9679
|
}
|
|
9680
9680
|
const container1 = editor.getContainerById(p1.childContainerId);
|
|
9681
9681
|
const container2 = editor.getContainerById(p2.childContainerId);
|
|
9682
|
-
assert(logger$
|
|
9682
|
+
assert(logger$3S, container1 !== container2, "comparePosition: containers are the same");
|
|
9683
9683
|
return compareElement(container1, container2);
|
|
9684
9684
|
}
|
|
9685
|
-
assert(logger$
|
|
9685
|
+
assert(logger$3S, false, "invalid ");
|
|
9686
9686
|
return 0;
|
|
9687
9687
|
}
|
|
9688
|
-
const logger$
|
|
9688
|
+
const logger$3R = getLogger("simple-range");
|
|
9689
9689
|
class EditorSimpleSelectionRange {
|
|
9690
9690
|
constructor(editor, options) {
|
|
9691
9691
|
__publicField(this, "editor");
|
|
@@ -9734,11 +9734,11 @@ var __publicField = (obj, key, value) => {
|
|
|
9734
9734
|
const { editor } = this;
|
|
9735
9735
|
const startBlock = editor.getBlockById(this.start.blockId);
|
|
9736
9736
|
const endBlock = editor.getBlockById(this.end.blockId);
|
|
9737
|
-
assert(logger$
|
|
9738
|
-
assert(logger$
|
|
9737
|
+
assert(logger$3R, startBlock, "no start block");
|
|
9738
|
+
assert(logger$3R, endBlock, "no end block");
|
|
9739
9739
|
const startContainer = getParentContainer(startBlock);
|
|
9740
9740
|
const endContainer = getParentContainer(endBlock);
|
|
9741
|
-
assert(logger$
|
|
9741
|
+
assert(logger$3R, startContainer === endContainer, "invalid range");
|
|
9742
9742
|
const ret = [];
|
|
9743
9743
|
if (startBlock === endBlock) {
|
|
9744
9744
|
ret.push({
|
|
@@ -9749,7 +9749,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9749
9749
|
} else {
|
|
9750
9750
|
const startIndex = getBlockIndex(startBlock);
|
|
9751
9751
|
const endIndex = getBlockIndex(endBlock);
|
|
9752
|
-
assert(logger$
|
|
9752
|
+
assert(logger$3R, startIndex < endIndex, "invalid range, start > index");
|
|
9753
9753
|
ret.push({
|
|
9754
9754
|
block: startBlock,
|
|
9755
9755
|
start: this.start,
|
|
@@ -9848,7 +9848,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9848
9848
|
clearSelection: clearSelection$4,
|
|
9849
9849
|
convertTo: convertTo$k
|
|
9850
9850
|
};
|
|
9851
|
-
const logger$
|
|
9851
|
+
const logger$3Q = getLogger("editor-blocks");
|
|
9852
9852
|
class EditorBlocks {
|
|
9853
9853
|
constructor(editor) {
|
|
9854
9854
|
__publicField(this, "blocks", /* @__PURE__ */ new Map());
|
|
@@ -9857,12 +9857,12 @@ var __publicField = (obj, key, value) => {
|
|
|
9857
9857
|
registerBlockClass(blockClass) {
|
|
9858
9858
|
const type = blockClass.blockType;
|
|
9859
9859
|
const exists = this.blocks.get(type);
|
|
9860
|
-
assert(logger$
|
|
9860
|
+
assert(logger$3Q, !exists, `duplicated block type: ${type}`);
|
|
9861
9861
|
this.blocks.set(type, blockClass);
|
|
9862
9862
|
}
|
|
9863
9863
|
getBlockClass(type) {
|
|
9864
9864
|
const exists = this.blocks.get(type);
|
|
9865
|
-
assert(logger$
|
|
9865
|
+
assert(logger$3Q, exists, `unknown block type: ${type}`);
|
|
9866
9866
|
return exists;
|
|
9867
9867
|
}
|
|
9868
9868
|
hasBlock(type) {
|
|
@@ -9878,7 +9878,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9878
9878
|
}
|
|
9879
9879
|
const content = blockClass.createBlockContent(this.editor, path, container, blockElement, block);
|
|
9880
9880
|
if (content.parentElement !== blockElement) {
|
|
9881
|
-
logger$
|
|
9881
|
+
logger$3Q.warn("content parent is not block");
|
|
9882
9882
|
blockElement.appendChild(content);
|
|
9883
9883
|
}
|
|
9884
9884
|
this.editor.blockHooks.forEach((hook) => {
|
|
@@ -9899,7 +9899,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9899
9899
|
return newBlock;
|
|
9900
9900
|
}
|
|
9901
9901
|
}
|
|
9902
|
-
const logger$
|
|
9902
|
+
const logger$3P = getLogger("editor-embeds");
|
|
9903
9903
|
class EditorEmbeds {
|
|
9904
9904
|
constructor(editor) {
|
|
9905
9905
|
__publicField(this, "objects", /* @__PURE__ */ new Map());
|
|
@@ -9908,12 +9908,12 @@ var __publicField = (obj, key, value) => {
|
|
|
9908
9908
|
registerEmbedClass(embedClass) {
|
|
9909
9909
|
const type = embedClass.embedType;
|
|
9910
9910
|
const exists = this.objects.get(type);
|
|
9911
|
-
assert(logger$
|
|
9911
|
+
assert(logger$3P, !exists, `duplicated embed object type: ${type}`);
|
|
9912
9912
|
this.objects.set(type, embedClass);
|
|
9913
9913
|
}
|
|
9914
9914
|
getEmbedClass(type) {
|
|
9915
9915
|
const exists = this.objects.get(type);
|
|
9916
|
-
assert(logger$
|
|
9916
|
+
assert(logger$3P, exists, `unknown embed type: ${type}`);
|
|
9917
9917
|
return exists;
|
|
9918
9918
|
}
|
|
9919
9919
|
getEmbedClassFromBlock(block) {
|
|
@@ -9923,12 +9923,12 @@ var __publicField = (obj, key, value) => {
|
|
|
9923
9923
|
this.objects.forEach(callback);
|
|
9924
9924
|
}
|
|
9925
9925
|
}
|
|
9926
|
-
const logger$
|
|
9926
|
+
const logger$3O = getLogger("embed-block");
|
|
9927
9927
|
function createBlockContent$4(editor, path, container, blockElement, blockData) {
|
|
9928
9928
|
const content = createBlockContentElement(blockElement, "div");
|
|
9929
|
-
assert(logger$
|
|
9929
|
+
assert(logger$3O, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
|
|
9930
9930
|
const embedBlockData = blockData;
|
|
9931
|
-
assert(logger$
|
|
9931
|
+
assert(logger$3O, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
|
|
9932
9932
|
const embedClass = editor.editorEmbeds.getEmbedClass(embedBlockData.embedType);
|
|
9933
9933
|
embedClass.createEmbedContent(editor, content, embedBlockData, path, container, blockElement);
|
|
9934
9934
|
blockElement.setAttribute("data-embed-type", embedBlockData.embedType);
|
|
@@ -10092,18 +10092,18 @@ var __publicField = (obj, key, value) => {
|
|
|
10092
10092
|
toStandardDoc: toStandardDoc$1,
|
|
10093
10093
|
getResources: getResources$2
|
|
10094
10094
|
};
|
|
10095
|
-
const logger$
|
|
10095
|
+
const logger$3N = getLogger("complex-block-helper");
|
|
10096
10096
|
function complexBlockGetAllChildContainers(editor, block, options) {
|
|
10097
10097
|
const blockClass = getComplexBlockClass(editor, block);
|
|
10098
10098
|
return blockClass.getChildContainers(editor, block, options);
|
|
10099
10099
|
}
|
|
10100
10100
|
function complexBlockGetSelectedContainers(editor, block, start, end) {
|
|
10101
10101
|
if (start.isSimple()) {
|
|
10102
|
-
assert(logger$
|
|
10102
|
+
assert(logger$3N, end.isSimple(), "invalid start and end position");
|
|
10103
10103
|
return complexBlockGetAllChildContainers(editor, block);
|
|
10104
10104
|
}
|
|
10105
|
-
assert(logger$
|
|
10106
|
-
assert(logger$
|
|
10105
|
+
assert(logger$3N, !start.isSimple(), "invalid start pos");
|
|
10106
|
+
assert(logger$3N, !end.isSimple(), "invalid end pos");
|
|
10107
10107
|
const blockClass = getComplexBlockClass(editor, block);
|
|
10108
10108
|
return blockClass.getSelectedContainers(editor, block, start, end);
|
|
10109
10109
|
}
|
|
@@ -10114,11 +10114,11 @@ var __publicField = (obj, key, value) => {
|
|
|
10114
10114
|
const parentComplexBlock = getParentBlock(getParentContainer(childBlock));
|
|
10115
10115
|
if (!parentComplexBlock)
|
|
10116
10116
|
return false;
|
|
10117
|
-
assert(logger$
|
|
10117
|
+
assert(logger$3N, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
|
|
10118
10118
|
const childContainer = getParentContainer(childBlock);
|
|
10119
10119
|
const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
|
|
10120
10120
|
const index2 = childContainers.indexOf(childContainer);
|
|
10121
|
-
assert(logger$
|
|
10121
|
+
assert(logger$3N, index2 >= 0, "not valid child container");
|
|
10122
10122
|
return index2 === 0;
|
|
10123
10123
|
}
|
|
10124
10124
|
function complexBlockGeFirstSimpleChild(editor, complexBlock, options) {
|
|
@@ -10152,13 +10152,13 @@ var __publicField = (obj, key, value) => {
|
|
|
10152
10152
|
return lastBlock2;
|
|
10153
10153
|
}
|
|
10154
10154
|
function findPrevSimpleBlockBeforeChildContainer(editor, childContainer) {
|
|
10155
|
-
assert(logger$
|
|
10155
|
+
assert(logger$3N, isChildContainer(childContainer), "not a child container");
|
|
10156
10156
|
const parentComplexBlock = getParentBlock(childContainer);
|
|
10157
|
-
assert(logger$
|
|
10158
|
-
assert(logger$
|
|
10157
|
+
assert(logger$3N, parentComplexBlock, "no parent block");
|
|
10158
|
+
assert(logger$3N, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
|
|
10159
10159
|
const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
|
|
10160
10160
|
const containerIndex = childContainers.indexOf(childContainer);
|
|
10161
|
-
assert(logger$
|
|
10161
|
+
assert(logger$3N, containerIndex !== -1, "child container not found");
|
|
10162
10162
|
if (containerIndex === 0) {
|
|
10163
10163
|
const prevBlock = getPrevBlock(parentComplexBlock);
|
|
10164
10164
|
if (!prevBlock)
|
|
@@ -10176,9 +10176,9 @@ var __publicField = (obj, key, value) => {
|
|
|
10176
10176
|
return lastBlock2;
|
|
10177
10177
|
}
|
|
10178
10178
|
function complexBlockGetTopChildContainers(editor, complexBlock) {
|
|
10179
|
-
assert(logger$
|
|
10179
|
+
assert(logger$3N, isComplexKindBlock(editor, complexBlock), "not a complex block");
|
|
10180
10180
|
const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
|
|
10181
|
-
assert(logger$
|
|
10181
|
+
assert(logger$3N, childContainers.length > 0, "no child container");
|
|
10182
10182
|
if (childContainers.length === 1) {
|
|
10183
10183
|
return childContainers;
|
|
10184
10184
|
}
|
|
@@ -10203,9 +10203,9 @@ var __publicField = (obj, key, value) => {
|
|
|
10203
10203
|
return ret;
|
|
10204
10204
|
}
|
|
10205
10205
|
function complexBlockGetBottomChildContainers(editor, complexBlock) {
|
|
10206
|
-
assert(logger$
|
|
10206
|
+
assert(logger$3N, isComplexKindBlock(editor, complexBlock), "not a complex block");
|
|
10207
10207
|
const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
|
|
10208
|
-
assert(logger$
|
|
10208
|
+
assert(logger$3N, childContainers.length > 0, "no child container");
|
|
10209
10209
|
if (childContainers.length === 1) {
|
|
10210
10210
|
return childContainers;
|
|
10211
10211
|
}
|
|
@@ -10248,8 +10248,8 @@ var __publicField = (obj, key, value) => {
|
|
|
10248
10248
|
}
|
|
10249
10249
|
function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
|
|
10250
10250
|
const blockId = getBlockId(complexBlock);
|
|
10251
|
-
assert(logger$
|
|
10252
|
-
assert(logger$
|
|
10251
|
+
assert(logger$3N, blockId === anchor2.blockId, "invalid start pos");
|
|
10252
|
+
assert(logger$3N, blockId === focus.blockId, "invalid end pos");
|
|
10253
10253
|
const blockClass = getComplexBlockClass(editor, complexBlock);
|
|
10254
10254
|
if (blockClass.adjustSelectionPos) {
|
|
10255
10255
|
return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
|
|
@@ -10332,13 +10332,13 @@ var __publicField = (obj, key, value) => {
|
|
|
10332
10332
|
};
|
|
10333
10333
|
}
|
|
10334
10334
|
}
|
|
10335
|
-
const logger$
|
|
10335
|
+
const logger$3M = getLogger("selection-range");
|
|
10336
10336
|
function createEditorSelectionRange(editor, options) {
|
|
10337
10337
|
const { anchor: anchor2, focus } = options;
|
|
10338
10338
|
if (anchor2 instanceof EditorSimpleBlockPosition && focus instanceof EditorSimpleBlockPosition) {
|
|
10339
10339
|
return new EditorSimpleSelectionRange(editor, { anchor: anchor2, focus });
|
|
10340
10340
|
}
|
|
10341
|
-
assert(logger$
|
|
10341
|
+
assert(logger$3M, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
|
|
10342
10342
|
return new EditorComplexSelectionRange(editor, { anchor: anchor2, focus });
|
|
10343
10343
|
}
|
|
10344
10344
|
function createBlockSimpleRange(editor, block, anchor2, focus) {
|
|
@@ -10360,7 +10360,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10360
10360
|
const focus = createSimpleBlockPosition(range.focus.blockId, range.focus.offset, "normal");
|
|
10361
10361
|
return createEditorSelectionRange(editor, { anchor: anchor2, focus });
|
|
10362
10362
|
}
|
|
10363
|
-
const logger$
|
|
10363
|
+
const logger$3L = getLogger("range-from-point");
|
|
10364
10364
|
function getBlockRangeFromPoint(editor, pointX, pointY) {
|
|
10365
10365
|
const yOffsets = [0, -12, 12];
|
|
10366
10366
|
let x = pointX;
|
|
@@ -10391,7 +10391,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10391
10391
|
const rect = elem.getBoundingClientRect();
|
|
10392
10392
|
if (elem.clientWidth && elem.clientHeight && i === 0) {
|
|
10393
10393
|
if (rect.left + elem.clientWidth < x || rect.top + elem.clientHeight < y) {
|
|
10394
|
-
logger$
|
|
10394
|
+
logger$3L.debug("click on scrollbar, out of element rect");
|
|
10395
10395
|
return null;
|
|
10396
10396
|
}
|
|
10397
10397
|
}
|
|
@@ -10443,7 +10443,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10443
10443
|
if (range instanceof EditorSimpleSelectionRange) {
|
|
10444
10444
|
return range;
|
|
10445
10445
|
}
|
|
10446
|
-
assert(logger$
|
|
10446
|
+
assert(logger$3L, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
|
|
10447
10447
|
const complexRange = range;
|
|
10448
10448
|
const container2 = editor.getContainerById(complexRange.start.childContainerId);
|
|
10449
10449
|
return getRangeInContainer(editor, container2, x, y);
|
|
@@ -10511,11 +10511,11 @@ var __publicField = (obj, key, value) => {
|
|
|
10511
10511
|
return result;
|
|
10512
10512
|
}
|
|
10513
10513
|
const anchor = "";
|
|
10514
|
-
const logger$
|
|
10514
|
+
const logger$3K = getLogger("text-range");
|
|
10515
10515
|
function getBlockRangeInfo(block, blockOffset) {
|
|
10516
10516
|
const getChildRange = (child, offset) => {
|
|
10517
10517
|
if (isTextBlockContentInsertionChild(child)) {
|
|
10518
|
-
assert(logger$
|
|
10518
|
+
assert(logger$3K, offset === 0, `invalid offset for insertion child: ${offset}`);
|
|
10519
10519
|
const childOffset = 2;
|
|
10520
10520
|
return {
|
|
10521
10521
|
child,
|
|
@@ -10524,7 +10524,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10524
10524
|
};
|
|
10525
10525
|
}
|
|
10526
10526
|
if (isTextBlockContentBoxChild(child)) {
|
|
10527
|
-
assert(logger$
|
|
10527
|
+
assert(logger$3K, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
|
|
10528
10528
|
const childOffset = offset === 0 ? 1 : 2;
|
|
10529
10529
|
return {
|
|
10530
10530
|
child,
|
|
@@ -10533,17 +10533,17 @@ var __publicField = (obj, key, value) => {
|
|
|
10533
10533
|
};
|
|
10534
10534
|
}
|
|
10535
10535
|
const textNode = child.firstChild;
|
|
10536
|
-
assert(logger$
|
|
10537
|
-
assert(logger$
|
|
10536
|
+
assert(logger$3K, textNode, "no child node for text child");
|
|
10537
|
+
assert(logger$3K, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
|
|
10538
10538
|
if (textNode instanceof HTMLBRElement) {
|
|
10539
|
-
assert(logger$
|
|
10539
|
+
assert(logger$3K, offset >= 0 && offset <= 0, "invalid offset for text child");
|
|
10540
10540
|
return {
|
|
10541
10541
|
child,
|
|
10542
10542
|
container: textNode,
|
|
10543
10543
|
offset
|
|
10544
10544
|
};
|
|
10545
10545
|
}
|
|
10546
|
-
assert(logger$
|
|
10546
|
+
assert(logger$3K, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
|
|
10547
10547
|
return {
|
|
10548
10548
|
child,
|
|
10549
10549
|
container: textNode,
|
|
@@ -10572,38 +10572,38 @@ var __publicField = (obj, key, value) => {
|
|
|
10572
10572
|
}
|
|
10573
10573
|
start += childLength;
|
|
10574
10574
|
}
|
|
10575
|
-
assert(logger$
|
|
10575
|
+
assert(logger$3K, false, "failed to get range info");
|
|
10576
10576
|
}
|
|
10577
10577
|
function createChildRange(child, start, end) {
|
|
10578
10578
|
if (start === end) {
|
|
10579
|
-
assert(logger$
|
|
10579
|
+
assert(logger$3K, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
|
|
10580
10580
|
} else {
|
|
10581
|
-
assert(logger$
|
|
10581
|
+
assert(logger$3K, start < end, `invalid start & end: ${start}, ${end}`);
|
|
10582
10582
|
}
|
|
10583
10583
|
if (isTextBlockContentInsertionChild(child)) {
|
|
10584
|
-
assert(logger$
|
|
10585
|
-
assert(logger$
|
|
10584
|
+
assert(logger$3K, start === end, `invalid insertion child range offset: ${start}, ${end}`);
|
|
10585
|
+
assert(logger$3K, start === 0, `invalid insertion child range start: ${start}`);
|
|
10586
10586
|
const insertionElem = child;
|
|
10587
|
-
assert(logger$
|
|
10587
|
+
assert(logger$3K, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
|
|
10588
10588
|
const range = createExpandedRange(insertionElem, 1, insertionElem, 2);
|
|
10589
10589
|
return range;
|
|
10590
10590
|
}
|
|
10591
10591
|
if (isTextBlockContentBoxChild(child)) {
|
|
10592
|
-
assert(logger$
|
|
10593
|
-
assert(logger$
|
|
10592
|
+
assert(logger$3K, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
|
|
10593
|
+
assert(logger$3K, start === 0, `invalid box child range start: ${start}`);
|
|
10594
10594
|
const box = child;
|
|
10595
|
-
assert(logger$
|
|
10595
|
+
assert(logger$3K, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
|
|
10596
10596
|
const range = createExpandedRange(box, 1, box, 2);
|
|
10597
10597
|
return range;
|
|
10598
10598
|
}
|
|
10599
10599
|
const length = getTextBlockContentChildTextLength(child);
|
|
10600
|
-
assert(logger$
|
|
10600
|
+
assert(logger$3K, end <= length, `invalid child end: ${end}, ${length}`);
|
|
10601
10601
|
const textNode = child.firstChild;
|
|
10602
|
-
assert(logger$
|
|
10603
|
-
assert(logger$
|
|
10602
|
+
assert(logger$3K, textNode instanceof Text, "invalid block text child");
|
|
10603
|
+
assert(logger$3K, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
|
|
10604
10604
|
return createExpandedRange(textNode, start, textNode, end);
|
|
10605
10605
|
}
|
|
10606
|
-
const logger$
|
|
10606
|
+
const logger$3J = getLogger("caret-rect");
|
|
10607
10607
|
function getChildClientRects(block, child) {
|
|
10608
10608
|
if (isBox(child)) {
|
|
10609
10609
|
const box = child;
|
|
@@ -10612,7 +10612,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10612
10612
|
const blockContent = getBlockContent(block);
|
|
10613
10613
|
const lineHeight = Number.parseFloat(window.getComputedStyle(blockContent).lineHeight) || boxContent.getBoundingClientRect().height;
|
|
10614
10614
|
const rects = Array.from(boxContent.getClientRects());
|
|
10615
|
-
assert(logger$
|
|
10615
|
+
assert(logger$3J, rects.length > 0, "no box client rects");
|
|
10616
10616
|
const blockRect = blockContent.getBoundingClientRect();
|
|
10617
10617
|
const firstRect = rects[0];
|
|
10618
10618
|
const lastRect = new DOMRect(blockRect.left, firstRect.bottom, 1, lineHeight);
|
|
@@ -10632,22 +10632,22 @@ var __publicField = (obj, key, value) => {
|
|
|
10632
10632
|
const rect2 = getLastClientRect(ranges[0].child);
|
|
10633
10633
|
return new DOMRect(rect2.right, rect2.top, 1, rect2.height);
|
|
10634
10634
|
}
|
|
10635
|
-
assert(logger$
|
|
10635
|
+
assert(logger$3J, ranges[1], "invalid ranges");
|
|
10636
10636
|
const rect = getFirstClientRect(ranges[1].child);
|
|
10637
10637
|
return new DOMRect(rect.left, rect.top, 1, rect.height);
|
|
10638
10638
|
}
|
|
10639
10639
|
let rangeInfo = ranges[0];
|
|
10640
|
-
assert(logger$
|
|
10640
|
+
assert(logger$3J, ranges.length >= 1, "failed to get block range");
|
|
10641
10641
|
if (ranges.length === 1) {
|
|
10642
10642
|
rangeInfo = ranges[0];
|
|
10643
10643
|
} else {
|
|
10644
|
-
assert(logger$
|
|
10644
|
+
assert(logger$3J, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
|
|
10645
10645
|
if (isTextBlockContentInsertionChild(ranges[ranges.length - 1].child)) {
|
|
10646
10646
|
rangeInfo = ranges[ranges.length - 1];
|
|
10647
10647
|
const child = rangeInfo.child;
|
|
10648
10648
|
const content = getInsertionContent(child);
|
|
10649
10649
|
const rects2 = content.getClientRects();
|
|
10650
|
-
assert(logger$
|
|
10650
|
+
assert(logger$3J, rects2.length >= 1, "no client rects for box content");
|
|
10651
10651
|
const rect = rects2[rects2.length - 1];
|
|
10652
10652
|
return new DOMRect(rect.right, rect.y, 1, rect.height);
|
|
10653
10653
|
}
|
|
@@ -10664,9 +10664,9 @@ var __publicField = (obj, key, value) => {
|
|
|
10664
10664
|
}
|
|
10665
10665
|
}
|
|
10666
10666
|
if (rangeInfo.container instanceof HTMLBRElement) {
|
|
10667
|
-
assert(logger$
|
|
10667
|
+
assert(logger$3J, pos.offset === 0, "invalid offset for empty block text");
|
|
10668
10668
|
const parent = rangeInfo.container.parentElement;
|
|
10669
|
-
assert(logger$
|
|
10669
|
+
assert(logger$3J, parent, "invalid br parent");
|
|
10670
10670
|
const rect = parent.getBoundingClientRect();
|
|
10671
10671
|
const ret = new DOMRect(rect.left, rect.top, 1, rect.height);
|
|
10672
10672
|
return ret;
|
|
@@ -10674,11 +10674,11 @@ var __publicField = (obj, key, value) => {
|
|
|
10674
10674
|
const range = createRange(rangeInfo.container, rangeInfo.offset);
|
|
10675
10675
|
const rects = Array.from(range.getClientRects());
|
|
10676
10676
|
if (rects.length === 0) {
|
|
10677
|
-
assert(logger$
|
|
10678
|
-
assert(logger$
|
|
10677
|
+
assert(logger$3J, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
|
|
10678
|
+
assert(logger$3J, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
|
|
10679
10679
|
const child = rangeInfo.child;
|
|
10680
10680
|
const rects2 = getChildClientRects(block, child);
|
|
10681
|
-
assert(logger$
|
|
10681
|
+
assert(logger$3J, rects2.length >= 1, "no client rects for box content");
|
|
10682
10682
|
if (rangeInfo.offset === 1) {
|
|
10683
10683
|
const rect2 = rects2[0];
|
|
10684
10684
|
return new DOMRect(rect2.x, rect2.y, 1, rect2.height);
|
|
@@ -10724,13 +10724,13 @@ var __publicField = (obj, key, value) => {
|
|
|
10724
10724
|
});
|
|
10725
10725
|
}
|
|
10726
10726
|
}
|
|
10727
|
-
assert(logger$
|
|
10727
|
+
assert(logger$3J, rects.length > 0, "no client rects for range");
|
|
10728
10728
|
if (pos.type === "home") {
|
|
10729
10729
|
return rects[rects.length - 1];
|
|
10730
10730
|
}
|
|
10731
10731
|
return rects[0];
|
|
10732
10732
|
}
|
|
10733
|
-
const logger$
|
|
10733
|
+
const logger$3I = getLogger("core");
|
|
10734
10734
|
function createBlockAnchor(editor, block, id, refClientRect) {
|
|
10735
10735
|
const tools = getBlockTools(block);
|
|
10736
10736
|
let elem = tools.querySelector(`.block-anchor[data-id=${id}]`);
|
|
@@ -10748,7 +10748,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10748
10748
|
return elem;
|
|
10749
10749
|
}
|
|
10750
10750
|
function createBlockCaretAnchor(editor, block, offset, id) {
|
|
10751
|
-
assert(logger$
|
|
10751
|
+
assert(logger$3I, isTextKindBlock(editor, block), "not a text kind block");
|
|
10752
10752
|
const caretRect = getTextCaretRect(block, createSimpleBlockPosition(block, offset, "normal"));
|
|
10753
10753
|
const blockRect = block.getBoundingClientRect();
|
|
10754
10754
|
const tools = getBlockTools(block);
|
|
@@ -11617,19 +11617,19 @@ var __publicField = (obj, key, value) => {
|
|
|
11617
11617
|
return object == null ? {} : basePick(object, paths);
|
|
11618
11618
|
});
|
|
11619
11619
|
const pick$1 = pick;
|
|
11620
|
-
const logger$
|
|
11620
|
+
const logger$3H = getLogger("box");
|
|
11621
11621
|
function isBoxOp(op) {
|
|
11622
11622
|
if (!op.attributes)
|
|
11623
11623
|
return false;
|
|
11624
11624
|
if (!op.attributes.box)
|
|
11625
11625
|
return false;
|
|
11626
|
-
assert(logger$
|
|
11627
|
-
assert(logger$
|
|
11626
|
+
assert(logger$3H, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
|
|
11627
|
+
assert(logger$3H, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
|
|
11628
11628
|
return true;
|
|
11629
11629
|
}
|
|
11630
|
-
const logger$
|
|
11630
|
+
const logger$3G = getLogger("text-op");
|
|
11631
11631
|
function getOpLength(op) {
|
|
11632
|
-
assert(logger$
|
|
11632
|
+
assert(logger$3G, typeof op.insert === "string", "invalid op, no insert");
|
|
11633
11633
|
return op.insert.length;
|
|
11634
11634
|
}
|
|
11635
11635
|
function getOpAt(text2, offset) {
|
|
@@ -11637,7 +11637,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11637
11637
|
let pos = 0;
|
|
11638
11638
|
for (let i = 0; i < ops.length; i++) {
|
|
11639
11639
|
const op = ops[i];
|
|
11640
|
-
assert(logger$
|
|
11640
|
+
assert(logger$3G, typeof op.insert === "string", "invalid text op, no insert");
|
|
11641
11641
|
const end = pos + getOpLength(op);
|
|
11642
11642
|
if (end > offset) {
|
|
11643
11643
|
return [op];
|
|
@@ -11653,22 +11653,22 @@ var __publicField = (obj, key, value) => {
|
|
|
11653
11653
|
}
|
|
11654
11654
|
return [];
|
|
11655
11655
|
}
|
|
11656
|
-
const logger$
|
|
11656
|
+
const logger$3F = getLogger("rich-text-length");
|
|
11657
11657
|
function getTextOpLength(op) {
|
|
11658
|
-
assert(logger$
|
|
11658
|
+
assert(logger$3F, typeof op.insert === "string", "op.insert is not string");
|
|
11659
11659
|
return op.insert.length;
|
|
11660
11660
|
}
|
|
11661
11661
|
function getTextLength(ops) {
|
|
11662
11662
|
let count = 0;
|
|
11663
11663
|
ops.forEach((op) => {
|
|
11664
11664
|
if (op.insert) {
|
|
11665
|
-
assert(logger$
|
|
11665
|
+
assert(logger$3F, typeof op.insert === "string", "op.insert is not string");
|
|
11666
11666
|
count += getTextOpLength(op);
|
|
11667
11667
|
}
|
|
11668
11668
|
});
|
|
11669
11669
|
return count;
|
|
11670
11670
|
}
|
|
11671
|
-
const logger$
|
|
11671
|
+
const logger$3E = getLogger("split-text");
|
|
11672
11672
|
function splitText(ops, offset, splitResult) {
|
|
11673
11673
|
ops = cloneDeep__default.default(ops);
|
|
11674
11674
|
if (offset === 0) {
|
|
@@ -11686,8 +11686,8 @@ var __publicField = (obj, key, value) => {
|
|
|
11686
11686
|
let counted = 0;
|
|
11687
11687
|
for (let i = 0; i < ops.length; i++) {
|
|
11688
11688
|
const op = ops[i];
|
|
11689
|
-
assert(logger$
|
|
11690
|
-
assert(logger$
|
|
11689
|
+
assert(logger$3E, typeof op === "object", `invalid op type, ${typeof op}`);
|
|
11690
|
+
assert(logger$3E, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
|
|
11691
11691
|
const subLen = getTextOpLength(op);
|
|
11692
11692
|
if (counted + subLen < offset) {
|
|
11693
11693
|
counted += subLen;
|
|
@@ -11697,18 +11697,18 @@ var __publicField = (obj, key, value) => {
|
|
|
11697
11697
|
right: ops.slice(i + 1)
|
|
11698
11698
|
};
|
|
11699
11699
|
} else {
|
|
11700
|
-
assert(logger$
|
|
11700
|
+
assert(logger$3E, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
|
|
11701
11701
|
const splitIndex = offset - counted;
|
|
11702
11702
|
const copied = cloneDeep__default.default(op);
|
|
11703
|
-
assert(logger$
|
|
11704
|
-
assert(logger$
|
|
11703
|
+
assert(logger$3E, copied.insert, "no copied.insert");
|
|
11704
|
+
assert(logger$3E, typeof copied.insert === "string", "invalid copied.insert type");
|
|
11705
11705
|
copied.insert = copied.insert.substr(0, splitIndex);
|
|
11706
11706
|
op.insert = op.insert.substr(splitIndex);
|
|
11707
11707
|
if (copied.insert === "") {
|
|
11708
|
-
assert(logger$
|
|
11708
|
+
assert(logger$3E, false, "invalid copied.insert, is empty string");
|
|
11709
11709
|
}
|
|
11710
11710
|
if (op.insert === "") {
|
|
11711
|
-
assert(logger$
|
|
11711
|
+
assert(logger$3E, false, "invalid op.insert, is empty string");
|
|
11712
11712
|
}
|
|
11713
11713
|
const right = [
|
|
11714
11714
|
op,
|
|
@@ -11727,9 +11727,9 @@ var __publicField = (obj, key, value) => {
|
|
|
11727
11727
|
throw new Error(`invalid split offset: ${offset}, ${JSON.stringify(ops)}`);
|
|
11728
11728
|
}
|
|
11729
11729
|
function splitToThree(text2, offset, length) {
|
|
11730
|
-
assert(logger$
|
|
11731
|
-
assert(logger$
|
|
11732
|
-
assert(logger$
|
|
11730
|
+
assert(logger$3E, offset >= 0, "invalid offset, < 0");
|
|
11731
|
+
assert(logger$3E, length > 0, "invalid length, <= 0");
|
|
11732
|
+
assert(logger$3E, offset + length <= getTextLength(text2), "invalid offset + length < text length");
|
|
11733
11733
|
const { left: temp, right } = splitText(text2, offset + length);
|
|
11734
11734
|
const { left, right: middle } = splitText(temp, offset);
|
|
11735
11735
|
return { left, middle, right };
|
|
@@ -11950,9 +11950,9 @@ var __publicField = (obj, key, value) => {
|
|
|
11950
11950
|
}
|
|
11951
11951
|
return [color, backgroundColor];
|
|
11952
11952
|
}
|
|
11953
|
-
const logger$
|
|
11953
|
+
const logger$3D = getLogger("text-block-content");
|
|
11954
11954
|
function updateBlockContentCore(editor, blockPath, content, blockText, insertions) {
|
|
11955
|
-
assert(logger$
|
|
11955
|
+
assert(logger$3D, blockText, "no text for block");
|
|
11956
11956
|
if (blockText.length === 0 && (!insertions || insertions.size === 0)) {
|
|
11957
11957
|
content.innerHTML = "<span><br></span>";
|
|
11958
11958
|
return;
|
|
@@ -11984,9 +11984,9 @@ var __publicField = (obj, key, value) => {
|
|
|
11984
11984
|
for (let i2 = 0; i2 < text2.length; i2++) {
|
|
11985
11985
|
const op = text2[i2];
|
|
11986
11986
|
if (isBoxOp(op)) {
|
|
11987
|
-
assert(logger$
|
|
11987
|
+
assert(logger$3D, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
|
|
11988
11988
|
const span2 = editor.editorBoxes.createBox(content, op.attributes);
|
|
11989
|
-
assert(logger$
|
|
11989
|
+
assert(logger$3D, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
|
|
11990
11990
|
const ret = editor.editorBlockRenders.renderBox(blockPath, op.attributes);
|
|
11991
11991
|
if (ret.classes) {
|
|
11992
11992
|
addClass(span2, ...ret.classes);
|
|
@@ -12004,7 +12004,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12004
12004
|
fragment.appendChild(span2);
|
|
12005
12005
|
continue;
|
|
12006
12006
|
}
|
|
12007
|
-
assert(logger$
|
|
12007
|
+
assert(logger$3D, op.insert, `no insert in op: ${JSON.stringify(op)}`);
|
|
12008
12008
|
const span = createElement("span", ["text"], fragment, op.insert);
|
|
12009
12009
|
if (op.attributes) {
|
|
12010
12010
|
const ret = editor.editorBlockRenders.renderText(blockPath, op.attributes);
|
|
@@ -12034,7 +12034,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12034
12034
|
const compositionText = editor.compositingText;
|
|
12035
12035
|
if (compositionText) {
|
|
12036
12036
|
const pos = editor.selection.range.start;
|
|
12037
|
-
assert(logger$
|
|
12037
|
+
assert(logger$3D, pos.isSimple(), "not an simple position while compositing");
|
|
12038
12038
|
if (pos.blockId === blockId) {
|
|
12039
12039
|
const attributes = getAttributesAt(text2, 0);
|
|
12040
12040
|
insertions.set(pos.offset, [{
|
|
@@ -12050,11 +12050,11 @@ var __publicField = (obj, key, value) => {
|
|
|
12050
12050
|
function clearAllTempCompositionText(editor) {
|
|
12051
12051
|
const children = editor.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');
|
|
12052
12052
|
if (children.length) {
|
|
12053
|
-
logger$
|
|
12053
|
+
logger$3D.debug(`remove ${children.length} temp composition span`);
|
|
12054
12054
|
}
|
|
12055
12055
|
Array.from(children).forEach((c) => c.remove());
|
|
12056
12056
|
}
|
|
12057
|
-
const logger$
|
|
12057
|
+
const logger$3C = getLogger("client-rects");
|
|
12058
12058
|
function getChildrenOffsets(block) {
|
|
12059
12059
|
const children = getTextBlockContentChildren(block);
|
|
12060
12060
|
let start = 0;
|
|
@@ -12072,15 +12072,15 @@ var __publicField = (obj, key, value) => {
|
|
|
12072
12072
|
return ret;
|
|
12073
12073
|
}
|
|
12074
12074
|
function getChildrenInRange(editor, block, from, to) {
|
|
12075
|
-
assert(logger$
|
|
12075
|
+
assert(logger$3C, from < to, `invalid from & to: ${from}, ${to}`);
|
|
12076
12076
|
const blockLength = getBlockTextLength$4(editor, block);
|
|
12077
|
-
assert(logger$
|
|
12077
|
+
assert(logger$3C, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
|
|
12078
12078
|
const offsets = getChildrenOffsets(block);
|
|
12079
12079
|
const startIndex = offsets.findIndex((c) => c.startBlockOffset <= from && from < c.endBlockOffset);
|
|
12080
12080
|
const endIndex = offsets.findIndex((c) => c.startBlockOffset < to && to <= c.endBlockOffset);
|
|
12081
|
-
assert(logger$
|
|
12082
|
-
assert(logger$
|
|
12083
|
-
assert(logger$
|
|
12081
|
+
assert(logger$3C, startIndex !== -1, "failed to find start child");
|
|
12082
|
+
assert(logger$3C, endIndex !== -1, "failed to find end child");
|
|
12083
|
+
assert(logger$3C, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
|
|
12084
12084
|
if (startIndex === endIndex) {
|
|
12085
12085
|
const child = offsets[startIndex];
|
|
12086
12086
|
return [{
|
|
@@ -12155,20 +12155,20 @@ var __publicField = (obj, key, value) => {
|
|
|
12155
12155
|
return rects;
|
|
12156
12156
|
}
|
|
12157
12157
|
function getRangeClientRects(editor, block, range) {
|
|
12158
|
-
assert(logger$
|
|
12158
|
+
assert(logger$3C, range instanceof EditorSimpleSelectionRange, "invalid range");
|
|
12159
12159
|
const start = range.start;
|
|
12160
12160
|
const end = range.end;
|
|
12161
|
-
assert(logger$
|
|
12162
|
-
assert(logger$
|
|
12163
|
-
assert(logger$
|
|
12164
|
-
assert(logger$
|
|
12161
|
+
assert(logger$3C, start.isSimple(), "text block only allow simple position");
|
|
12162
|
+
assert(logger$3C, end.isSimple(), "text block only allow simple position");
|
|
12163
|
+
assert(logger$3C, start.blockId === end.blockId, "only allow update one text block selection");
|
|
12164
|
+
assert(logger$3C, start.blockId === getBlockId(block), "only allow update one text block selection");
|
|
12165
12165
|
return getClientRects$2(editor, block, start, end);
|
|
12166
12166
|
}
|
|
12167
|
-
const logger$
|
|
12167
|
+
const logger$3B = getLogger("selection-background");
|
|
12168
12168
|
function updateSelection$2(editor, block, start, end) {
|
|
12169
|
-
assert(logger$
|
|
12170
|
-
assert(logger$
|
|
12171
|
-
assert(logger$
|
|
12169
|
+
assert(logger$3B, start.isSimple(), "text block only allow simple position");
|
|
12170
|
+
assert(logger$3B, end.isSimple(), "text block only allow simple position");
|
|
12171
|
+
assert(logger$3B, start.blockId === end.blockId, "only allow update one text block selection");
|
|
12172
12172
|
const from = start.offset;
|
|
12173
12173
|
const to = end.offset;
|
|
12174
12174
|
if (from === to) {
|
|
@@ -12212,7 +12212,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12212
12212
|
}
|
|
12213
12213
|
});
|
|
12214
12214
|
}
|
|
12215
|
-
const logger$
|
|
12215
|
+
const logger$3A = getLogger("line-breaker");
|
|
12216
12216
|
function mergeTextRects(rects) {
|
|
12217
12217
|
const result = [];
|
|
12218
12218
|
let lastRect = null;
|
|
@@ -12336,7 +12336,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12336
12336
|
}
|
|
12337
12337
|
const textChild = child;
|
|
12338
12338
|
const rects = mergeTextRects(textChild.getClientRects());
|
|
12339
|
-
assert(logger$
|
|
12339
|
+
assert(logger$3A, rects.length > 0, "invalid text child dom");
|
|
12340
12340
|
if (rects.length === 1) {
|
|
12341
12341
|
const nextChild = children[i + 1];
|
|
12342
12342
|
if (!nextChild) {
|
|
@@ -12361,10 +12361,10 @@ var __publicField = (obj, key, value) => {
|
|
|
12361
12361
|
continue;
|
|
12362
12362
|
}
|
|
12363
12363
|
const textNode = textChild.firstChild;
|
|
12364
|
-
assert(logger$
|
|
12365
|
-
assert(logger$
|
|
12364
|
+
assert(logger$3A, textNode, "invalid text child, no text node");
|
|
12365
|
+
assert(logger$3A, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
|
|
12366
12366
|
const textChildLength = getTextBlockContentChildTextLength(textChild);
|
|
12367
|
-
assert(logger$
|
|
12367
|
+
assert(logger$3A, textNode.data.length === textChildLength, "text node data length not equal child text length");
|
|
12368
12368
|
const textRects = getTextRects(textNode);
|
|
12369
12369
|
for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
|
|
12370
12370
|
const rect = textRects[rIndex];
|
|
@@ -12406,7 +12406,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12406
12406
|
}
|
|
12407
12407
|
}
|
|
12408
12408
|
}
|
|
12409
|
-
assert(logger$
|
|
12409
|
+
assert(logger$3A, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
|
|
12410
12410
|
return {
|
|
12411
12411
|
lineIndex: lineBreaks.length,
|
|
12412
12412
|
lineBreaks
|
|
@@ -21179,7 +21179,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21179
21179
|
const Graphemer_1 = __importDefault(Graphemer$1);
|
|
21180
21180
|
var _default = lib$1.default = Graphemer_1.default;
|
|
21181
21181
|
const splitter = new _default();
|
|
21182
|
-
const logger$
|
|
21182
|
+
const logger$3z = getLogger("text-offset");
|
|
21183
21183
|
function getChildOffset(block, child) {
|
|
21184
21184
|
const children = getTextBlockContentChildren(block);
|
|
21185
21185
|
let start = 0;
|
|
@@ -21195,26 +21195,26 @@ var __publicField = (obj, key, value) => {
|
|
|
21195
21195
|
}
|
|
21196
21196
|
start += testLength;
|
|
21197
21197
|
}
|
|
21198
|
-
assert(logger$
|
|
21198
|
+
assert(logger$3z, false, "can not find child in children");
|
|
21199
21199
|
}
|
|
21200
21200
|
function isValidOffset(block, blockOffset) {
|
|
21201
|
-
assert(logger$
|
|
21201
|
+
assert(logger$3z, blockOffset >= 0, `invalid offset: ${blockOffset}`);
|
|
21202
21202
|
const childInfo = getTextBlockChild(block, blockOffset);
|
|
21203
21203
|
const { prev, next, offset } = childInfo;
|
|
21204
21204
|
if (!prev && !next) {
|
|
21205
|
-
assert(logger$
|
|
21205
|
+
assert(logger$3z, false, "invalid offset, no prev & next child at offset");
|
|
21206
21206
|
}
|
|
21207
21207
|
if (prev !== next) {
|
|
21208
21208
|
return true;
|
|
21209
21209
|
}
|
|
21210
21210
|
const child = prev;
|
|
21211
|
-
assert(logger$
|
|
21211
|
+
assert(logger$3z, child, "no child");
|
|
21212
21212
|
if (isTextBlockContentBoxChild(child)) {
|
|
21213
|
-
assert(logger$
|
|
21213
|
+
assert(logger$3z, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
|
|
21214
21214
|
return true;
|
|
21215
21215
|
}
|
|
21216
21216
|
const text2 = child.textContent;
|
|
21217
|
-
assert(logger$
|
|
21217
|
+
assert(logger$3z, text2, "no content for text child");
|
|
21218
21218
|
const chars = splitter.splitGraphemes(text2);
|
|
21219
21219
|
const validOffsets = /* @__PURE__ */ new Set();
|
|
21220
21220
|
let start = 0;
|
|
@@ -21244,7 +21244,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21244
21244
|
}
|
|
21245
21245
|
function getNextValidOffset(block, blockOffset) {
|
|
21246
21246
|
const length = getTextBlockLength(block);
|
|
21247
|
-
assert(logger$
|
|
21247
|
+
assert(logger$3z, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
|
|
21248
21248
|
if (blockOffset === length) {
|
|
21249
21249
|
return length;
|
|
21250
21250
|
}
|
|
@@ -21258,7 +21258,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21258
21258
|
}
|
|
21259
21259
|
return ret;
|
|
21260
21260
|
}
|
|
21261
|
-
const logger$
|
|
21261
|
+
const logger$3y = getLogger("line-offset");
|
|
21262
21262
|
function getLineOffsets(block) {
|
|
21263
21263
|
const lineBreaks = getLineBreaks(block);
|
|
21264
21264
|
const ret = [];
|
|
@@ -21279,7 +21279,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21279
21279
|
}
|
|
21280
21280
|
function getLineOffset(block, lineIndex) {
|
|
21281
21281
|
const lines = getLineOffsets(block);
|
|
21282
|
-
assert(logger$
|
|
21282
|
+
assert(logger$3y, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
|
|
21283
21283
|
return lines[lineIndex];
|
|
21284
21284
|
}
|
|
21285
21285
|
function getLineOffsetByPos(block, pos) {
|
|
@@ -21333,7 +21333,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21333
21333
|
function getLineCount(block) {
|
|
21334
21334
|
return getLineOffsets(block).length;
|
|
21335
21335
|
}
|
|
21336
|
-
const logger$
|
|
21336
|
+
const logger$3x = getLogger("find-text-position");
|
|
21337
21337
|
function isWrappedLine(block, lineIndex) {
|
|
21338
21338
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
21339
21339
|
const blockId = getBlockId(block);
|
|
@@ -21344,13 +21344,13 @@ var __publicField = (obj, key, value) => {
|
|
|
21344
21344
|
return false;
|
|
21345
21345
|
}
|
|
21346
21346
|
const childInfo = getTextBlockChild(block, start);
|
|
21347
|
-
assert(logger$
|
|
21348
|
-
assert(logger$
|
|
21347
|
+
assert(logger$3x, childInfo.next, "no next child at offset");
|
|
21348
|
+
assert(logger$3x, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
|
|
21349
21349
|
return true;
|
|
21350
21350
|
}
|
|
21351
21351
|
function getWrappedLineOffsets(block, lineIndex) {
|
|
21352
21352
|
const blockId = getBlockId(block);
|
|
21353
|
-
assert(logger$
|
|
21353
|
+
assert(logger$3x, isWrappedLine(block, lineIndex), "line is not wrapped");
|
|
21354
21354
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
21355
21355
|
const homePos = createSimpleBlockPosition(blockId, start, "home");
|
|
21356
21356
|
for (let offset = start + 1; offset <= end; offset += 1) {
|
|
@@ -21365,11 +21365,11 @@ var __publicField = (obj, key, value) => {
|
|
|
21365
21365
|
return offset - 1;
|
|
21366
21366
|
}
|
|
21367
21367
|
}
|
|
21368
|
-
assert(logger$
|
|
21368
|
+
assert(logger$3x, false, "failed to find wrapped offset");
|
|
21369
21369
|
return 0;
|
|
21370
21370
|
}
|
|
21371
21371
|
function findTextPositionInLine(editor, block, lineIndex, sourceBlock, pos, findDirection, suggestedX) {
|
|
21372
|
-
assert(logger$
|
|
21372
|
+
assert(logger$3x, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
|
|
21373
21373
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
21374
21374
|
let from = start;
|
|
21375
21375
|
const blockId = getBlockId(block);
|
|
@@ -21411,11 +21411,11 @@ var __publicField = (obj, key, value) => {
|
|
|
21411
21411
|
return retPos;
|
|
21412
21412
|
}
|
|
21413
21413
|
function findPrevTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
|
|
21414
|
-
assert(logger$
|
|
21414
|
+
assert(logger$3x, isTextKindBlock(editor, block), "not a text block");
|
|
21415
21415
|
return findTextPositionInLine(editor, block, getLineCount(block) - 1, sourceBlock, pos, "up", suggestedX);
|
|
21416
21416
|
}
|
|
21417
21417
|
function findNextTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
|
|
21418
|
-
assert(logger$
|
|
21418
|
+
assert(logger$3x, isTextKindBlock(editor, block), "not a text block");
|
|
21419
21419
|
return findTextPositionInLine(editor, block, 0, sourceBlock, pos, "down", suggestedX);
|
|
21420
21420
|
}
|
|
21421
21421
|
function moveDown(editor, block, position, suggestedX) {
|
|
@@ -21523,7 +21523,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21523
21523
|
}
|
|
21524
21524
|
return pos;
|
|
21525
21525
|
}
|
|
21526
|
-
const logger$
|
|
21526
|
+
const logger$3w = getLogger("move-caret");
|
|
21527
21527
|
function moveTextCaret(editor, block, position, direction) {
|
|
21528
21528
|
if (direction === "ArrowLeft") {
|
|
21529
21529
|
const ret = moveLeft(block, position);
|
|
@@ -21553,9 +21553,9 @@ var __publicField = (obj, key, value) => {
|
|
|
21553
21553
|
}
|
|
21554
21554
|
return createSimpleBlockPosition(getBlockId(block), ret.offset, ret.type);
|
|
21555
21555
|
}
|
|
21556
|
-
assert(logger$
|
|
21556
|
+
assert(logger$3w, false, `invalid navigation direction: ${direction}`);
|
|
21557
21557
|
}
|
|
21558
|
-
const logger$
|
|
21558
|
+
const logger$3v = getLogger("text-range");
|
|
21559
21559
|
function getBlockRects(block) {
|
|
21560
21560
|
const ret = [];
|
|
21561
21561
|
const children = getTextBlockContentChildren(block);
|
|
@@ -21631,9 +21631,9 @@ var __publicField = (obj, key, value) => {
|
|
|
21631
21631
|
return null;
|
|
21632
21632
|
}
|
|
21633
21633
|
const children = getTextBlockContentChildren(block);
|
|
21634
|
-
assert(logger$
|
|
21634
|
+
assert(logger$3v, children.indexOf(child) !== -1, "failed to find child in children");
|
|
21635
21635
|
const offsetInfo = getChildOffset(block, child);
|
|
21636
|
-
assert(logger$
|
|
21636
|
+
assert(logger$3v, offsetInfo, "failed to get child offset");
|
|
21637
21637
|
const { start } = offsetInfo;
|
|
21638
21638
|
let offset;
|
|
21639
21639
|
let length;
|
|
@@ -21644,7 +21644,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21644
21644
|
offset = start;
|
|
21645
21645
|
length = 0;
|
|
21646
21646
|
} else {
|
|
21647
|
-
assert(logger$
|
|
21647
|
+
assert(logger$3v, child.firstChild instanceof Text, "child is not text");
|
|
21648
21648
|
offset = start + textNodeOffsetFromPoint(child.firstChild, x, y);
|
|
21649
21649
|
length = 0;
|
|
21650
21650
|
}
|
|
@@ -21668,9 +21668,9 @@ var __publicField = (obj, key, value) => {
|
|
|
21668
21668
|
}
|
|
21669
21669
|
return new EditorSimpleSelectionRange(editor, { anchor: startPos, focus: endPos != null ? endPos : startPos });
|
|
21670
21670
|
}
|
|
21671
|
-
const logger$
|
|
21671
|
+
const logger$3u = getLogger("create-text-op");
|
|
21672
21672
|
function createTextOp(text2, attributes) {
|
|
21673
|
-
assert(logger$
|
|
21673
|
+
assert(logger$3u, text2, "text is empty");
|
|
21674
21674
|
const ret = {
|
|
21675
21675
|
insert: text2
|
|
21676
21676
|
};
|
|
@@ -21693,7 +21693,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21693
21693
|
}
|
|
21694
21694
|
return result;
|
|
21695
21695
|
}
|
|
21696
|
-
const logger$
|
|
21696
|
+
const logger$3t = getLogger("merge-ops");
|
|
21697
21697
|
function mergeOps(text2) {
|
|
21698
21698
|
if (text2.length <= 1) {
|
|
21699
21699
|
return text2;
|
|
@@ -21715,10 +21715,10 @@ var __publicField = (obj, key, value) => {
|
|
|
21715
21715
|
return false;
|
|
21716
21716
|
}
|
|
21717
21717
|
if (op1.attributes === void 0) {
|
|
21718
|
-
assert(logger$
|
|
21718
|
+
assert(logger$3t, op2.attributes === void 0, "op2.attributes is not undefined");
|
|
21719
21719
|
return true;
|
|
21720
21720
|
}
|
|
21721
|
-
assert(logger$
|
|
21721
|
+
assert(logger$3t, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
|
|
21722
21722
|
return isEqual__default.default(op1.attributes, op2.attributes);
|
|
21723
21723
|
};
|
|
21724
21724
|
const newOps = [];
|
|
@@ -21727,8 +21727,8 @@ var __publicField = (obj, key, value) => {
|
|
|
21727
21727
|
for (let i = 1; i < text2.length; i += 1) {
|
|
21728
21728
|
const op = text2[i];
|
|
21729
21729
|
if (isSameTypeOp(before, op)) {
|
|
21730
|
-
assert(logger$
|
|
21731
|
-
assert(logger$
|
|
21730
|
+
assert(logger$3t, typeof before.insert === "string", "before.insert is not string");
|
|
21731
|
+
assert(logger$3t, typeof op.insert === "string", "op.insert is not string");
|
|
21732
21732
|
before.insert += op.insert;
|
|
21733
21733
|
} else {
|
|
21734
21734
|
newOps.push(op);
|
|
@@ -21756,15 +21756,15 @@ var __publicField = (obj, key, value) => {
|
|
|
21756
21756
|
}
|
|
21757
21757
|
return text2.slice(0, i + 1);
|
|
21758
21758
|
}
|
|
21759
|
-
const logger$
|
|
21759
|
+
const logger$3s = getLogger("delete-text");
|
|
21760
21760
|
function deleteText(richText2, offset, count) {
|
|
21761
21761
|
const { left, right } = splitToThree(richText2, offset, count);
|
|
21762
21762
|
const result = [...left, ...right];
|
|
21763
21763
|
return mergeOps(result);
|
|
21764
21764
|
}
|
|
21765
21765
|
function createDeleteOps(offset, count) {
|
|
21766
|
-
assert(logger$
|
|
21767
|
-
assert(logger$
|
|
21766
|
+
assert(logger$3s, offset >= 0, `invalid offset: ${offset}`);
|
|
21767
|
+
assert(logger$3s, count >= 1, `invalid delete count: ${count}`);
|
|
21768
21768
|
const ops = [];
|
|
21769
21769
|
if (offset !== 0) {
|
|
21770
21770
|
ops.push({
|
|
@@ -21776,7 +21776,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21776
21776
|
});
|
|
21777
21777
|
return ops;
|
|
21778
21778
|
}
|
|
21779
|
-
const logger$
|
|
21779
|
+
const logger$3r = getLogger("delta");
|
|
21780
21780
|
function diffRichText(oldText, newText) {
|
|
21781
21781
|
const delta1D = new Delta__default.default(oldText);
|
|
21782
21782
|
const delta2D = new Delta__default.default(newText);
|
|
@@ -21786,7 +21786,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21786
21786
|
return new Delta__default.default(ops).transformPosition(cursor, !isLocalOp);
|
|
21787
21787
|
}
|
|
21788
21788
|
function isValidDocText(text2) {
|
|
21789
|
-
assert(logger$
|
|
21789
|
+
assert(logger$3r, text2, "ops is null or undefined");
|
|
21790
21790
|
for (let i = 0; i < text2.length; i++) {
|
|
21791
21791
|
const op = text2[i];
|
|
21792
21792
|
if (op.insert === null || op.insert === void 0) {
|
|
@@ -21806,7 +21806,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21806
21806
|
}
|
|
21807
21807
|
class RichText {
|
|
21808
21808
|
static ensureValidText(text2) {
|
|
21809
|
-
assert(logger$
|
|
21809
|
+
assert(logger$3r, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
|
|
21810
21810
|
}
|
|
21811
21811
|
static diff(oldText, newText) {
|
|
21812
21812
|
this.ensureValidText(oldText);
|
|
@@ -21828,9 +21828,9 @@ var __publicField = (obj, key, value) => {
|
|
|
21828
21828
|
return resultText;
|
|
21829
21829
|
}
|
|
21830
21830
|
}
|
|
21831
|
-
const logger$
|
|
21831
|
+
const logger$3q = getLogger("insert-text");
|
|
21832
21832
|
function insertText(richText2, offset, text2, attributes) {
|
|
21833
|
-
assert(logger$
|
|
21833
|
+
assert(logger$3q, text2, `invalid text to insert: ${text2}`);
|
|
21834
21834
|
const { left, right } = splitText(richText2, offset);
|
|
21835
21835
|
const insertedText = typeof text2 === "string" ? [createTextOp(text2, attributes)] : text2;
|
|
21836
21836
|
const result = [...left, ...insertedText, ...right];
|
|
@@ -21843,7 +21843,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21843
21843
|
};
|
|
21844
21844
|
}
|
|
21845
21845
|
function createInsertOps(offset, text2, attributes) {
|
|
21846
|
-
assert(logger$
|
|
21846
|
+
assert(logger$3q, offset >= 0, `invalid offset: ${offset}`);
|
|
21847
21847
|
if (text2.length === 0) {
|
|
21848
21848
|
return [];
|
|
21849
21849
|
}
|
|
@@ -21873,7 +21873,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21873
21873
|
function cloneText(text2) {
|
|
21874
21874
|
return cloneDeep__default.default(text2);
|
|
21875
21875
|
}
|
|
21876
|
-
const logger$
|
|
21876
|
+
const logger$3p = getLogger("update-op-attribute");
|
|
21877
21877
|
function updateOpAttributes(orgOps, key, value, newAttributes) {
|
|
21878
21878
|
const ops = cloneText(orgOps);
|
|
21879
21879
|
const index2 = ops.findIndex((op2) => {
|
|
@@ -21881,7 +21881,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21881
21881
|
return false;
|
|
21882
21882
|
return op2.attributes[key] === value;
|
|
21883
21883
|
});
|
|
21884
|
-
assert(logger$
|
|
21884
|
+
assert(logger$3p, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
|
|
21885
21885
|
const op = ops[index2];
|
|
21886
21886
|
op.attributes = {
|
|
21887
21887
|
...op.attributes,
|
|
@@ -21957,11 +21957,11 @@ var __publicField = (obj, key, value) => {
|
|
|
21957
21957
|
]);
|
|
21958
21958
|
}
|
|
21959
21959
|
const FILL_CHAR = "\u200B";
|
|
21960
|
-
const logger$
|
|
21960
|
+
const logger$3o = getLogger("to-plain-text");
|
|
21961
21961
|
function toPlainText(ops, options) {
|
|
21962
21962
|
let text2 = "";
|
|
21963
21963
|
ops.forEach((op) => {
|
|
21964
|
-
assert(logger$
|
|
21964
|
+
assert(logger$3o, typeof op.insert === "string", "invalid op");
|
|
21965
21965
|
if (op.attributes && op.attributes.box === true) {
|
|
21966
21966
|
if (options == null ? void 0 : options.boxReplacement) {
|
|
21967
21967
|
text2 += options.boxReplacement;
|
|
@@ -22016,11 +22016,11 @@ var __publicField = (obj, key, value) => {
|
|
|
22016
22016
|
focus: pos
|
|
22017
22017
|
};
|
|
22018
22018
|
}
|
|
22019
|
-
const logger$
|
|
22019
|
+
const logger$3n = getLogger("block-to-text");
|
|
22020
22020
|
function textBlockToText$1(editor, ops, doc2) {
|
|
22021
22021
|
let text2 = "";
|
|
22022
22022
|
ops.forEach((op) => {
|
|
22023
|
-
assert(logger$
|
|
22023
|
+
assert(logger$3n, typeof op.insert === "string", "invalid op");
|
|
22024
22024
|
if (op.attributes && op.attributes.box === true) {
|
|
22025
22025
|
const box = op.attributes;
|
|
22026
22026
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -22038,11 +22038,11 @@ var __publicField = (obj, key, value) => {
|
|
|
22038
22038
|
});
|
|
22039
22039
|
return text2;
|
|
22040
22040
|
}
|
|
22041
|
-
const logger$
|
|
22041
|
+
const logger$3m = getLogger("block-to-text");
|
|
22042
22042
|
function textToMarkdownText(editor, ops, doc2) {
|
|
22043
22043
|
let text2 = "";
|
|
22044
22044
|
ops.forEach((op) => {
|
|
22045
|
-
assert(logger$
|
|
22045
|
+
assert(logger$3m, typeof op.insert === "string", "invalid op");
|
|
22046
22046
|
if (op.attributes && op.attributes.box === true) {
|
|
22047
22047
|
const box = op.attributes;
|
|
22048
22048
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -22165,11 +22165,11 @@ var __publicField = (obj, key, value) => {
|
|
|
22165
22165
|
return void 0;
|
|
22166
22166
|
}
|
|
22167
22167
|
}
|
|
22168
|
-
const logger$
|
|
22168
|
+
const logger$3l = getLogger("block-to-text");
|
|
22169
22169
|
function textBlockToHtml(editor, ops, doc2) {
|
|
22170
22170
|
let html = "";
|
|
22171
22171
|
ops.forEach((op) => {
|
|
22172
|
-
assert(logger$
|
|
22172
|
+
assert(logger$3l, typeof op.insert === "string", "invalid op");
|
|
22173
22173
|
if (op.attributes && op.attributes.box === true) {
|
|
22174
22174
|
const box = op.attributes;
|
|
22175
22175
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -22238,16 +22238,16 @@ var __publicField = (obj, key, value) => {
|
|
|
22238
22238
|
}
|
|
22239
22239
|
return `<p>${html}</p>`;
|
|
22240
22240
|
}
|
|
22241
|
-
const logger$
|
|
22241
|
+
const logger$3k = getLogger("text-block");
|
|
22242
22242
|
function createBlockContent$3(editor, path, container, blockElement, blockData) {
|
|
22243
22243
|
const { text: text2 } = blockData;
|
|
22244
|
-
assert(logger$
|
|
22244
|
+
assert(logger$3k, text2, "no text for text block");
|
|
22245
22245
|
const content = createBlockContentElement(blockElement, "div");
|
|
22246
22246
|
updateBlockContent$1(editor, path, blockData.id, content, text2);
|
|
22247
22247
|
return content;
|
|
22248
22248
|
}
|
|
22249
22249
|
function updateBlockText$1(editor, block, text2) {
|
|
22250
|
-
assert(logger$
|
|
22250
|
+
assert(logger$3k, text2, "no text to update");
|
|
22251
22251
|
const newContent = createBlockContentElement(null, "div");
|
|
22252
22252
|
updateBlockContent$1(editor, getBlockPath(block), getBlockId(block), newContent, text2);
|
|
22253
22253
|
const oldContent = getBlockContent(block);
|
|
@@ -22274,7 +22274,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22274
22274
|
return res.trim();
|
|
22275
22275
|
}
|
|
22276
22276
|
function getBlockProperties$b(editor, block) {
|
|
22277
|
-
assert(logger$
|
|
22277
|
+
assert(logger$3k, isTextKindBlock(editor, block), "block in not textBlock");
|
|
22278
22278
|
const range = editor.selection.range;
|
|
22279
22279
|
let abstract = "";
|
|
22280
22280
|
if (range.isCollapsed()) {
|
|
@@ -22284,7 +22284,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22284
22284
|
const blockId = getBlockId(block);
|
|
22285
22285
|
const selectedBlock = getAllSelectedBlocks(editor, { simpleBlockOnly: true }).find((b) => getBlockId(b.block) === blockId);
|
|
22286
22286
|
if (selectedBlock && !isEmptyTextBlock(editor, selectedBlock.block)) {
|
|
22287
|
-
assert(logger$
|
|
22287
|
+
assert(logger$3k, selectedBlock.block === block, "block not match");
|
|
22288
22288
|
const blockOps = editor.getBlockText(block);
|
|
22289
22289
|
const { start, end } = selectedBlock;
|
|
22290
22290
|
const offset = start.offset;
|
|
@@ -22300,7 +22300,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22300
22300
|
};
|
|
22301
22301
|
}
|
|
22302
22302
|
function convertTo$i(editor, blockData, doc2, type) {
|
|
22303
|
-
assert(logger$
|
|
22303
|
+
assert(logger$3k, blockData.text, "no text for text block");
|
|
22304
22304
|
if (type === "text") {
|
|
22305
22305
|
return textBlockToText$1(editor, blockData.text, doc2);
|
|
22306
22306
|
}
|
|
@@ -22325,7 +22325,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22325
22325
|
convertTo: convertTo$i
|
|
22326
22326
|
};
|
|
22327
22327
|
const updateTextBlockContent = updateBlockContent$1;
|
|
22328
|
-
const logger$
|
|
22328
|
+
const logger$3j = getLogger("action-helper");
|
|
22329
22329
|
function editorGetBlockData(editor, block) {
|
|
22330
22330
|
const container = getParentContainer(block);
|
|
22331
22331
|
const containerId = getContainerId(container);
|
|
@@ -22333,10 +22333,10 @@ var __publicField = (obj, key, value) => {
|
|
|
22333
22333
|
return editor.doc.getBlockData(containerId, blockIndex);
|
|
22334
22334
|
}
|
|
22335
22335
|
function editorGetBlockText(editor, block) {
|
|
22336
|
-
assert(logger$
|
|
22336
|
+
assert(logger$3j, isTextKindBlock(editor, block), "not a text kind block");
|
|
22337
22337
|
const data = editorGetBlockData(editor, block);
|
|
22338
22338
|
const text2 = data.text;
|
|
22339
|
-
assert(logger$
|
|
22339
|
+
assert(logger$3j, text2, "no text in block");
|
|
22340
22340
|
return text2;
|
|
22341
22341
|
}
|
|
22342
22342
|
function editorGetBlockTextEx(editor, block, length) {
|
|
@@ -22344,7 +22344,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22344
22344
|
}
|
|
22345
22345
|
function editorGetBoxData(editor, box) {
|
|
22346
22346
|
const block = getParentBlock(box);
|
|
22347
|
-
assert(logger$
|
|
22347
|
+
assert(logger$3j, block, "no parent block");
|
|
22348
22348
|
const text2 = editorGetBlockText(editor, block);
|
|
22349
22349
|
const id = getBoxId(box);
|
|
22350
22350
|
const op = text2.find((op2) => {
|
|
@@ -22354,60 +22354,60 @@ var __publicField = (obj, key, value) => {
|
|
|
22354
22354
|
}
|
|
22355
22355
|
return false;
|
|
22356
22356
|
});
|
|
22357
|
-
assert(logger$
|
|
22357
|
+
assert(logger$3j, op, "failed to find box");
|
|
22358
22358
|
return op.attributes;
|
|
22359
22359
|
}
|
|
22360
|
-
const logger$
|
|
22360
|
+
const logger$3i = getLogger("block-text");
|
|
22361
22361
|
function getTextAfterOffset(editor, block, offset) {
|
|
22362
|
-
assert(logger$
|
|
22363
|
-
assert(logger$
|
|
22364
|
-
assert(logger$
|
|
22362
|
+
assert(logger$3i, isTextKindBlock(editor, block), "not a text kind block");
|
|
22363
|
+
assert(logger$3i, isValidOffset(block, offset), "not a valid offset");
|
|
22364
|
+
assert(logger$3i, offset >= 0 && offset < getBlockTextLength$4(editor, block), `invalid offset: ${offset}`);
|
|
22365
22365
|
const newOffset = getNextValidOffset(block, offset);
|
|
22366
22366
|
const length = newOffset - offset;
|
|
22367
22367
|
if (length === 0) {
|
|
22368
|
-
assert(logger$
|
|
22368
|
+
assert(logger$3i, false, `no text after offset: ${offset}`);
|
|
22369
22369
|
}
|
|
22370
22370
|
const text2 = editorGetBlockText(editor, block);
|
|
22371
22371
|
const { middle } = splitToThree(text2, offset, length);
|
|
22372
|
-
assert(logger$
|
|
22372
|
+
assert(logger$3i, middle.length === 1, "failed to split text to 3 parts");
|
|
22373
22373
|
const op = middle[0];
|
|
22374
22374
|
if (isBoxOp(op)) {
|
|
22375
22375
|
return " ";
|
|
22376
22376
|
}
|
|
22377
|
-
assert(logger$
|
|
22377
|
+
assert(logger$3i, op.insert.length === 1 || op.insert.length === 2, "invalid op");
|
|
22378
22378
|
return op.insert;
|
|
22379
22379
|
}
|
|
22380
22380
|
function getTextBeforeOffset(editor, block, offset) {
|
|
22381
|
-
assert(logger$
|
|
22382
|
-
assert(logger$
|
|
22383
|
-
assert(logger$
|
|
22381
|
+
assert(logger$3i, isTextKindBlock(editor, block), "not a text kind block");
|
|
22382
|
+
assert(logger$3i, isValidOffset(block, offset), "not a valid offset");
|
|
22383
|
+
assert(logger$3i, offset > 0 && offset <= getBlockTextLength$4(editor, block), `invalid offset: ${offset}`);
|
|
22384
22384
|
const newOffset = getPrevValidOffset(block, offset);
|
|
22385
22385
|
const length = offset - newOffset;
|
|
22386
22386
|
if (length === 0) {
|
|
22387
|
-
assert(logger$
|
|
22387
|
+
assert(logger$3i, false, `no text before offset: ${offset}`);
|
|
22388
22388
|
}
|
|
22389
22389
|
const text2 = editorGetBlockText(editor, block);
|
|
22390
22390
|
const { middle } = splitToThree(text2, newOffset, length);
|
|
22391
|
-
assert(logger$
|
|
22391
|
+
assert(logger$3i, middle.length === 1, "failed to split text to 3 parts");
|
|
22392
22392
|
const op = middle[0];
|
|
22393
22393
|
if (isBoxOp(op)) {
|
|
22394
22394
|
return " ";
|
|
22395
22395
|
}
|
|
22396
|
-
assert(logger$
|
|
22396
|
+
assert(logger$3i, op.insert.length === 1 || op.insert.length === 2, "invalid op");
|
|
22397
22397
|
return op.insert;
|
|
22398
22398
|
}
|
|
22399
22399
|
function getOffsetInfoBefore(editor, block, offset) {
|
|
22400
|
-
assert(logger$
|
|
22401
|
-
assert(logger$
|
|
22402
|
-
assert(logger$
|
|
22400
|
+
assert(logger$3i, isTextKindBlock(editor, block), "not a text kind block");
|
|
22401
|
+
assert(logger$3i, isValidOffset(block, offset), "not a valid offset");
|
|
22402
|
+
assert(logger$3i, offset > 0 && offset <= getBlockTextLength$4(editor, block), `invalid offset: ${offset}`);
|
|
22403
22403
|
const newOffset = getPrevValidOffset(block, offset);
|
|
22404
22404
|
const length = offset - newOffset;
|
|
22405
22405
|
if (length === 0) {
|
|
22406
|
-
assert(logger$
|
|
22406
|
+
assert(logger$3i, false, `no text before offset: ${offset}`);
|
|
22407
22407
|
}
|
|
22408
22408
|
const text2 = editorGetBlockText(editor, block);
|
|
22409
22409
|
const { middle } = splitToThree(text2, newOffset, length);
|
|
22410
|
-
assert(logger$
|
|
22410
|
+
assert(logger$3i, middle.length === 1, "failed to split text to 3 parts");
|
|
22411
22411
|
const op = middle[0];
|
|
22412
22412
|
if (isBoxOp(op)) {
|
|
22413
22413
|
return {
|
|
@@ -22425,17 +22425,17 @@ var __publicField = (obj, key, value) => {
|
|
|
22425
22425
|
};
|
|
22426
22426
|
}
|
|
22427
22427
|
function getOffsetInfoAfter(editor, block, offset) {
|
|
22428
|
-
assert(logger$
|
|
22429
|
-
assert(logger$
|
|
22430
|
-
assert(logger$
|
|
22428
|
+
assert(logger$3i, isTextKindBlock(editor, block), "not a text kind block");
|
|
22429
|
+
assert(logger$3i, isValidOffset(block, offset), "not a valid offset");
|
|
22430
|
+
assert(logger$3i, offset >= 0 && offset < getBlockTextLength$4(editor, block), `invalid offset: ${offset}`);
|
|
22431
22431
|
const newOffset = getNextValidOffset(block, offset);
|
|
22432
22432
|
const length = newOffset - offset;
|
|
22433
22433
|
if (length === 0) {
|
|
22434
|
-
assert(logger$
|
|
22434
|
+
assert(logger$3i, false, `no text after offset: ${offset}`);
|
|
22435
22435
|
}
|
|
22436
22436
|
const text2 = editorGetBlockText(editor, block);
|
|
22437
22437
|
const { middle } = splitToThree(text2, offset, length);
|
|
22438
|
-
assert(logger$
|
|
22438
|
+
assert(logger$3i, middle.length === 1, "failed to split text to 3 parts");
|
|
22439
22439
|
const op = middle[0];
|
|
22440
22440
|
if (isBoxOp(op)) {
|
|
22441
22441
|
return {
|
|
@@ -22499,7 +22499,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22499
22499
|
return null;
|
|
22500
22500
|
}
|
|
22501
22501
|
function findWordLeft(editor, block, offset) {
|
|
22502
|
-
assert(logger$
|
|
22502
|
+
assert(logger$3i, isTextKindBlock(editor, block), "invalid blok type");
|
|
22503
22503
|
if (isEmptyTextBlock(editor, block)) {
|
|
22504
22504
|
return 0;
|
|
22505
22505
|
}
|
|
@@ -22527,7 +22527,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22527
22527
|
return startInfo.offset + startInfo.length;
|
|
22528
22528
|
}
|
|
22529
22529
|
function findWordEnd(editor, block, offset) {
|
|
22530
|
-
assert(logger$
|
|
22530
|
+
assert(logger$3i, isTextKindBlock(editor, block), "invalid blok type");
|
|
22531
22531
|
if (isEmptyTextBlock(editor, block)) {
|
|
22532
22532
|
return 0;
|
|
22533
22533
|
}
|
|
@@ -22554,10 +22554,10 @@ var __publicField = (obj, key, value) => {
|
|
|
22554
22554
|
return getBlockTextLength$4(editor, block);
|
|
22555
22555
|
return startInfo.offset;
|
|
22556
22556
|
}
|
|
22557
|
-
const logger$
|
|
22557
|
+
const logger$3h = getLogger("text-box");
|
|
22558
22558
|
function updateBoxContent$7(editor, boxElement, boxContent, boxData) {
|
|
22559
|
-
assert(logger$
|
|
22560
|
-
assert(logger$
|
|
22559
|
+
assert(logger$3h, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
|
|
22560
|
+
assert(logger$3h, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
|
|
22561
22561
|
createElement("span", [], boxContent, boxData.text);
|
|
22562
22562
|
}
|
|
22563
22563
|
function convertTo$h(editor, boxData, doc2, type) {
|
|
@@ -22591,7 +22591,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22591
22591
|
updateBoxContent: updateBoxContent$6,
|
|
22592
22592
|
convertTo: convertTo$g
|
|
22593
22593
|
};
|
|
22594
|
-
const logger$
|
|
22594
|
+
const logger$3g = getLogger("editor-boxes");
|
|
22595
22595
|
class EditorBoxes {
|
|
22596
22596
|
constructor(editor) {
|
|
22597
22597
|
__publicField(this, "boxes", /* @__PURE__ */ new Map());
|
|
@@ -22600,12 +22600,12 @@ var __publicField = (obj, key, value) => {
|
|
|
22600
22600
|
registerBoxClass(boxClass) {
|
|
22601
22601
|
const type = boxClass.boxType;
|
|
22602
22602
|
const exists = this.boxes.get(type);
|
|
22603
|
-
assert(logger$
|
|
22603
|
+
assert(logger$3g, !exists, `duplicated box type: ${type}`);
|
|
22604
22604
|
this.boxes.set(type, boxClass);
|
|
22605
22605
|
}
|
|
22606
22606
|
getBoxClass(type) {
|
|
22607
22607
|
const exists = this.boxes.get(type);
|
|
22608
|
-
assert(logger$
|
|
22608
|
+
assert(logger$3g, exists, `unknown box type: ${type}`);
|
|
22609
22609
|
return exists;
|
|
22610
22610
|
}
|
|
22611
22611
|
createBox(blockContent, box) {
|
|
@@ -22656,7 +22656,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22656
22656
|
insertionType: "inputting",
|
|
22657
22657
|
updateInsertionContent: updateInsertionContent$1
|
|
22658
22658
|
};
|
|
22659
|
-
const logger$
|
|
22659
|
+
const logger$3f = getLogger("editor-insertion");
|
|
22660
22660
|
class EditorInsertions {
|
|
22661
22661
|
constructor(editor) {
|
|
22662
22662
|
__publicField(this, "insertions", /* @__PURE__ */ new Map());
|
|
@@ -22665,12 +22665,12 @@ var __publicField = (obj, key, value) => {
|
|
|
22665
22665
|
registerInsertionClass(insertionClass) {
|
|
22666
22666
|
const type = insertionClass.insertionType;
|
|
22667
22667
|
const exists = this.insertions.get(type);
|
|
22668
|
-
assert(logger$
|
|
22668
|
+
assert(logger$3f, !exists, `duplicated insertion type: ${type}`);
|
|
22669
22669
|
this.insertions.set(type, insertionClass);
|
|
22670
22670
|
}
|
|
22671
22671
|
getInsertionClass(type) {
|
|
22672
22672
|
const exists = this.insertions.get(type);
|
|
22673
|
-
assert(logger$
|
|
22673
|
+
assert(logger$3f, exists, `unknown insertion type: ${type}`);
|
|
22674
22674
|
return exists;
|
|
22675
22675
|
}
|
|
22676
22676
|
createInsertion(blockContent, insertion) {
|
|
@@ -22776,7 +22776,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22776
22776
|
};
|
|
22777
22777
|
}
|
|
22778
22778
|
}
|
|
22779
|
-
const logger$
|
|
22779
|
+
const logger$3e = getLogger("editor-input");
|
|
22780
22780
|
class EditorInput {
|
|
22781
22781
|
constructor(editor, callbacks) {
|
|
22782
22782
|
__publicField(this, "editor");
|
|
@@ -22883,7 +22883,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22883
22883
|
return;
|
|
22884
22884
|
}
|
|
22885
22885
|
this.callbacks.onCut(event);
|
|
22886
|
-
logger$
|
|
22886
|
+
logger$3e.debug("on cut");
|
|
22887
22887
|
});
|
|
22888
22888
|
__publicField(this, "handlePaste", (event) => {
|
|
22889
22889
|
if (event.isTrusted) {
|
|
@@ -22969,11 +22969,11 @@ var __publicField = (obj, key, value) => {
|
|
|
22969
22969
|
this.callbacks.removeHandler(handler);
|
|
22970
22970
|
}
|
|
22971
22971
|
defaultInsertText(editor, containerId, blockIndex, offset, text2) {
|
|
22972
|
-
assert(logger$
|
|
22972
|
+
assert(logger$3e, editor === this.editor, "invalid editor");
|
|
22973
22973
|
this.callbacks.defaultInsertText(editor, containerId, blockIndex, offset, text2);
|
|
22974
22974
|
}
|
|
22975
22975
|
defaultHandleKeydown(editor, event) {
|
|
22976
|
-
assert(logger$
|
|
22976
|
+
assert(logger$3e, editor === this.editor, "invalid editor");
|
|
22977
22977
|
return this.callbacks.defaultHandleKeydown(editor, event);
|
|
22978
22978
|
}
|
|
22979
22979
|
forEach(callback) {
|
|
@@ -22998,7 +22998,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22998
22998
|
input2.style.left = `${x / scale}px`;
|
|
22999
22999
|
input2.style.top = `${y / scale}px`;
|
|
23000
23000
|
}
|
|
23001
|
-
const logger$
|
|
23001
|
+
const logger$3d = getLogger("editor-caret");
|
|
23002
23002
|
function getFirefoxVersion() {
|
|
23003
23003
|
const userAgent = window.navigator.userAgent;
|
|
23004
23004
|
const match = userAgent.match(/Firefox\/(\d+)\./);
|
|
@@ -23061,11 +23061,11 @@ var __publicField = (obj, key, value) => {
|
|
|
23061
23061
|
return;
|
|
23062
23062
|
}
|
|
23063
23063
|
const { range } = this.editor.selection;
|
|
23064
|
-
assert(logger$
|
|
23064
|
+
assert(logger$3d, range.isCollapsed, "range is not collapsed");
|
|
23065
23065
|
const pos = range.start;
|
|
23066
|
-
assert(logger$
|
|
23066
|
+
assert(logger$3d, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
|
|
23067
23067
|
const block = this.editor.getBlockById(pos.blockId);
|
|
23068
|
-
assert(logger$
|
|
23068
|
+
assert(logger$3d, isTextKindBlock(this.editor, block), "only text kind block can has caret");
|
|
23069
23069
|
let rect;
|
|
23070
23070
|
const compositionSpan = block.querySelector("span.inputting-insertion");
|
|
23071
23071
|
if (compositionSpan) {
|
|
@@ -23103,12 +23103,117 @@ var __publicField = (obj, key, value) => {
|
|
|
23103
23103
|
clearAllSelection(editor);
|
|
23104
23104
|
editor.selection.range.getSelectedBlocks().forEach((s) => updateBlockSelection(editor, s.block, s.start, s.end));
|
|
23105
23105
|
}
|
|
23106
|
-
getLogger("editor-dom");
|
|
23106
|
+
const logger$3c = getLogger("editor-dom");
|
|
23107
23107
|
function editorGetClientHeight(editor) {
|
|
23108
23108
|
const scrollContainer = getScrollContainer$1(editor.rootContainer);
|
|
23109
23109
|
return scrollContainer.clientHeight;
|
|
23110
23110
|
}
|
|
23111
|
+
function editorGetVisibleRect(editor) {
|
|
23112
|
+
const elem = getScrollContainer$1(editor.rootContainer);
|
|
23113
|
+
const rect = elem.getBoundingClientRect();
|
|
23114
|
+
const x1 = rect.x < 0 ? 0 : rect.x;
|
|
23115
|
+
const y1 = rect.y < 0 ? 0 : rect.y;
|
|
23116
|
+
const x2 = rect.right > window.innerWidth ? window.innerWidth : rect.right;
|
|
23117
|
+
const y2 = rect.bottom > window.innerHeight ? window.innerHeight : rect.bottom;
|
|
23118
|
+
return new DOMRect(x1, y1, x2 - x1, y2 - y1);
|
|
23119
|
+
}
|
|
23120
|
+
function isBlockPositionVisible(editor, pos) {
|
|
23121
|
+
const visibleRect = editorGetVisibleRect(editor);
|
|
23122
|
+
const block = editor.getBlockById(pos.blockId);
|
|
23123
|
+
const caretRect = getBlockCaretRect(editor, block, pos);
|
|
23124
|
+
const rect = caretRect;
|
|
23125
|
+
return pointInRect(visibleRect, rect.x, rect.y) && pointInRect(visibleRect, rect.right, rect.bottom);
|
|
23126
|
+
}
|
|
23127
|
+
function isBlockPartialVisible(editor, block) {
|
|
23128
|
+
const visibleRect = editorGetVisibleRect(editor);
|
|
23129
|
+
const rect = block.getBoundingClientRect();
|
|
23130
|
+
if (rect.top >= visibleRect.top && rect.top <= visibleRect.bottom) {
|
|
23131
|
+
return true;
|
|
23132
|
+
}
|
|
23133
|
+
if (rect.bottom <= visibleRect.bottom && rect.bottom >= visibleRect.top) {
|
|
23134
|
+
return true;
|
|
23135
|
+
}
|
|
23136
|
+
return false;
|
|
23137
|
+
}
|
|
23138
|
+
function getBlockPartialVisiblePercent(editor, block) {
|
|
23139
|
+
const visibleRect = editorGetVisibleRect(editor);
|
|
23140
|
+
const rect = block.getBoundingClientRect();
|
|
23141
|
+
if (rect.top >= visibleRect.top && rect.top <= visibleRect.bottom && rect.bottom <= visibleRect.bottom && rect.bottom >= visibleRect.top) {
|
|
23142
|
+
return 100;
|
|
23143
|
+
}
|
|
23144
|
+
const intersectionX = Math.max(0, Math.min(rect.right, visibleRect.right) - Math.max(rect.left, visibleRect.left));
|
|
23145
|
+
const intersectionY = Math.max(0, Math.min(rect.bottom, visibleRect.bottom) - Math.max(rect.top, visibleRect.top));
|
|
23146
|
+
const intersectionArea = intersectionX * intersectionY;
|
|
23147
|
+
const elementAArea = rect.width * rect.height;
|
|
23148
|
+
return intersectionArea / elementAArea * 100;
|
|
23149
|
+
}
|
|
23150
|
+
function isChildContainerVisible(editor, container) {
|
|
23151
|
+
const visibleRect = editorGetVisibleRect(editor);
|
|
23152
|
+
const rect = container.getBoundingClientRect();
|
|
23153
|
+
return pointInRect(visibleRect, rect.x, rect.y) || pointInRect(visibleRect, rect.right, rect.bottom);
|
|
23154
|
+
}
|
|
23111
23155
|
function editorScrollIntoView(editor) {
|
|
23156
|
+
if (!isElementVisible(editor.rootContainer)) {
|
|
23157
|
+
logger$3c.warn("editorScrollIntoView: editor is not visible");
|
|
23158
|
+
return;
|
|
23159
|
+
}
|
|
23160
|
+
const rootClientRect = editor.rootContainer.getBoundingClientRect();
|
|
23161
|
+
if (rootClientRect.height < 1 && rootClientRect.width < 1) {
|
|
23162
|
+
return;
|
|
23163
|
+
}
|
|
23164
|
+
const selection = editor.selection;
|
|
23165
|
+
const pos = selection.range.focus;
|
|
23166
|
+
if (!pos.isSimple()) {
|
|
23167
|
+
const complexPos = pos;
|
|
23168
|
+
const childContainer = editor.getContainerById(complexPos.childContainerId);
|
|
23169
|
+
if (!isChildContainerVisible(editor, childContainer)) {
|
|
23170
|
+
childContainer.scrollIntoView();
|
|
23171
|
+
}
|
|
23172
|
+
return;
|
|
23173
|
+
}
|
|
23174
|
+
if (selection.range.start.blockId === selection.range.end.blockId) {
|
|
23175
|
+
const block2 = editor.getBlockById(selection.range.start.blockId);
|
|
23176
|
+
if (isEmbedBlock(block2) && isBlockPartialVisible(editor, block2) && getBlockPartialVisiblePercent(editor, block2) >= 95) {
|
|
23177
|
+
return;
|
|
23178
|
+
}
|
|
23179
|
+
if (isComplexKindBlock(editor, block2) && isBlockPartialVisible(editor, block2)) {
|
|
23180
|
+
return;
|
|
23181
|
+
}
|
|
23182
|
+
}
|
|
23183
|
+
const simplePos = pos;
|
|
23184
|
+
const block = editor.getBlockById(simplePos.blockId);
|
|
23185
|
+
if (isBlockPositionVisible(editor, simplePos)) {
|
|
23186
|
+
return;
|
|
23187
|
+
}
|
|
23188
|
+
if (isEmbedBlock(block)) {
|
|
23189
|
+
const next = getNextBlock(block);
|
|
23190
|
+
if (next) {
|
|
23191
|
+
const delayEmbedBlockTypes = ["image"];
|
|
23192
|
+
if (delayEmbedBlockTypes.includes(getEmbedType(block))) {
|
|
23193
|
+
setTimeout(() => {
|
|
23194
|
+
animateScrollTo(next, {
|
|
23195
|
+
elementToScroll: getScrollContainer$1(editor.rootContainer)
|
|
23196
|
+
});
|
|
23197
|
+
}, 500);
|
|
23198
|
+
} else {
|
|
23199
|
+
animateScrollTo(next, {
|
|
23200
|
+
elementToScroll: getScrollContainer$1(editor.rootContainer)
|
|
23201
|
+
});
|
|
23202
|
+
}
|
|
23203
|
+
return;
|
|
23204
|
+
}
|
|
23205
|
+
}
|
|
23206
|
+
const rect = getBlockCaretRect(editor, block, simplePos);
|
|
23207
|
+
const blockRect = block.getBoundingClientRect();
|
|
23208
|
+
const tools = getBlockTools(block);
|
|
23209
|
+
const anchorElem = createElement("div", ["editor-block-anchor"], tools);
|
|
23210
|
+
const scale = getElementScale(block);
|
|
23211
|
+
anchorElem.style.top = `${(rect.top - blockRect.top) / scale}px`;
|
|
23212
|
+
animateScrollTo(anchorElem, {
|
|
23213
|
+
elementToScroll: getScrollContainer$1(editor.rootContainer)
|
|
23214
|
+
});
|
|
23215
|
+
setTimeout(() => {
|
|
23216
|
+
}, 200);
|
|
23112
23217
|
}
|
|
23113
23218
|
function allSelected(editor, range) {
|
|
23114
23219
|
if (range.isCollapsed()) {
|