@ones-editor/editor 2.6.1-beta.1 → 2.7.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@ones-editor/core/src/core/blocks/common/block-dom.d.ts +2 -3
- package/@ones-editor/core/src/core/input-handler/actions.d.ts +0 -4
- package/@ones-editor/core/src/core/input-handler/handle-delete.d.ts +0 -4
- package/@ones-editor/core/src/core/selection/actions/index.d.ts +1 -3
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/ui/src/index.d.ts +2 -2
- package/@ones-editor/ui/src/shortcuts/index.d.ts +2 -3
- package/@ones-editor/ui/src/shortcuts/text-style-shortcuts.d.ts +2 -1
- package/@ones-editor/ui-base/src/color-button/index.d.ts +2 -1
- package/@ones-editor/ui-base/src/color-button/text-color-item.d.ts +0 -2
- package/dist/index.js +477 -775
- package/package.json +1 -1
- package/@ones-editor/core/src/core/selection/actions/move-block-end.d.ts +0 -2
- package/@ones-editor/core/src/core/selection/actions/move-block-start.d.ts +0 -2
- package/@ones-editor/ui/src/shortcuts/align-shortcuts.d.ts +0 -2
- package/@ones-editor/ui/src/shortcuts/text-color-shortcuts.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -335,12 +335,12 @@ div.editor-root div.editor-content div[data-type=editor-container] div[data-type
|
|
|
335
335
|
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.hover .embed-hover-content {
|
|
336
336
|
outline: 1px solid #0064ff;
|
|
337
337
|
}
|
|
338
|
-
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected > div[data-type=block-content],
|
|
339
|
-
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected .embed-selected-content {
|
|
338
|
+
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected:not(.no-mask) > div[data-type=block-content],
|
|
339
|
+
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected:not(.no-mask) .embed-selected-content {
|
|
340
340
|
position: relative;
|
|
341
341
|
}
|
|
342
|
-
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected > div[data-type=block-content]::before,
|
|
343
|
-
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected .embed-selected-content::before {
|
|
342
|
+
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected:not(.no-mask) > div[data-type=block-content]::before,
|
|
343
|
+
div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected:not(.no-mask) .embed-selected-content::before {
|
|
344
344
|
content: " ";
|
|
345
345
|
position: absolute;
|
|
346
346
|
left: 0;
|
|
@@ -8901,7 +8901,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8901
8901
|
imageExportFailed: "\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F"
|
|
8902
8902
|
}
|
|
8903
8903
|
};
|
|
8904
|
-
const logger$
|
|
8904
|
+
const logger$4R = getLogger("i18n");
|
|
8905
8905
|
const langs$3 = {
|
|
8906
8906
|
"en-US": enUS$x,
|
|
8907
8907
|
"zh-CN": zhCN$x,
|
|
@@ -8921,7 +8921,7 @@ var __publicField = (obj, key, value) => {
|
|
|
8921
8921
|
function t$8(key, args) {
|
|
8922
8922
|
const ret = i18n.get(key, args);
|
|
8923
8923
|
if (ret === key) {
|
|
8924
|
-
logger$
|
|
8924
|
+
logger$4R.warn(`no locale value for key ${key}`);
|
|
8925
8925
|
}
|
|
8926
8926
|
return ret;
|
|
8927
8927
|
}
|
|
@@ -9534,7 +9534,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9534
9534
|
this._callbacks.clear();
|
|
9535
9535
|
}
|
|
9536
9536
|
}
|
|
9537
|
-
const logger$
|
|
9537
|
+
const logger$4Q = getLogger("await-locker");
|
|
9538
9538
|
class AwaitLock {
|
|
9539
9539
|
constructor() {
|
|
9540
9540
|
__publicField(this, "_acquired", false);
|
|
@@ -9576,7 +9576,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9576
9576
|
}
|
|
9577
9577
|
if (this._waitingResolvers.length > 0) {
|
|
9578
9578
|
const resolve = this._waitingResolvers.shift();
|
|
9579
|
-
assert(logger$
|
|
9579
|
+
assert(logger$4Q, resolve, "Resolver missing");
|
|
9580
9580
|
resolve(void 0);
|
|
9581
9581
|
} else {
|
|
9582
9582
|
this._acquired = false;
|
|
@@ -9659,7 +9659,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9659
9659
|
isMobileSafari: false
|
|
9660
9660
|
};
|
|
9661
9661
|
clientType.isMobileSafari = clientType.isMobile && clientType.isSafari;
|
|
9662
|
-
const logger$
|
|
9662
|
+
const logger$4P = getLogger("dom-utils");
|
|
9663
9663
|
function addClass(dom, ...className) {
|
|
9664
9664
|
if (dom && dom.nodeType === Node.ELEMENT_NODE) {
|
|
9665
9665
|
dom.classList.add(...className);
|
|
@@ -9713,7 +9713,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9713
9713
|
range.setStart(node, offset);
|
|
9714
9714
|
return range;
|
|
9715
9715
|
} catch (err) {
|
|
9716
|
-
assert(logger$
|
|
9716
|
+
assert(logger$4P, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
|
|
9717
9717
|
}
|
|
9718
9718
|
}
|
|
9719
9719
|
function createExpandedRange(startNode, startOffset, endNode, endOffset) {
|
|
@@ -9723,17 +9723,17 @@ var __publicField = (obj, key, value) => {
|
|
|
9723
9723
|
range.setEnd(endNode, endOffset);
|
|
9724
9724
|
return range;
|
|
9725
9725
|
} catch (err) {
|
|
9726
|
-
assert(logger$
|
|
9726
|
+
assert(logger$4P, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
|
|
9727
9727
|
}
|
|
9728
9728
|
}
|
|
9729
9729
|
function getFirstClientRect(elem) {
|
|
9730
9730
|
const rects = elem.getClientRects();
|
|
9731
|
-
assert(logger$
|
|
9731
|
+
assert(logger$4P, rects.length >= 1, "getFirstClientRect: no rects");
|
|
9732
9732
|
return rects[0];
|
|
9733
9733
|
}
|
|
9734
9734
|
function getLastClientRect(elem) {
|
|
9735
9735
|
const rects = elem.getClientRects();
|
|
9736
|
-
assert(logger$
|
|
9736
|
+
assert(logger$4P, rects.length >= 1, "getLastClientRect: no rects");
|
|
9737
9737
|
return rects[rects.length - 1];
|
|
9738
9738
|
}
|
|
9739
9739
|
function getDistanceSquare(rect, x, y) {
|
|
@@ -9780,7 +9780,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9780
9780
|
return 0;
|
|
9781
9781
|
}
|
|
9782
9782
|
if (!elem1.parentElement || !elem2.parentElement) {
|
|
9783
|
-
assert(logger$
|
|
9783
|
+
assert(logger$4P, false, "invalid dom node to compare");
|
|
9784
9784
|
}
|
|
9785
9785
|
if (elem1.parentElement === elem2.parentElement) {
|
|
9786
9786
|
const children = Array.from(elem1.parentElement.children);
|
|
@@ -9797,7 +9797,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9797
9797
|
const parents1 = getParents(elem1);
|
|
9798
9798
|
const parents2 = getParents(elem2);
|
|
9799
9799
|
if (parents1[0] !== parents2[0]) {
|
|
9800
|
-
assert(logger$
|
|
9800
|
+
assert(logger$4P, false, "invalid dom node to compare, different tree");
|
|
9801
9801
|
}
|
|
9802
9802
|
for (let i = 1; ; i++) {
|
|
9803
9803
|
const parent1 = parents1[i];
|
|
@@ -10397,7 +10397,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10397
10397
|
}
|
|
10398
10398
|
}
|
|
10399
10399
|
const MIN_DISTANCE_THRESHOLD$3 = 3;
|
|
10400
|
-
const logger$
|
|
10400
|
+
const logger$4O = getLogger("drag-drop");
|
|
10401
10401
|
class DragDrop {
|
|
10402
10402
|
constructor(options) {
|
|
10403
10403
|
__publicField(this, "dragStarted", false);
|
|
@@ -10418,7 +10418,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10418
10418
|
var _a;
|
|
10419
10419
|
event.preventDefault();
|
|
10420
10420
|
event.stopPropagation();
|
|
10421
|
-
assert(logger$
|
|
10421
|
+
assert(logger$4O, this.mouseDownEvent, "no mouse down event");
|
|
10422
10422
|
const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
|
|
10423
10423
|
const newPos = DragDrop.getEventPosition(event);
|
|
10424
10424
|
const deltaX = newPos.x - oldPos.x;
|
|
@@ -10434,7 +10434,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10434
10434
|
});
|
|
10435
10435
|
__publicField(this, "handleMouseUp", (event) => {
|
|
10436
10436
|
if (event instanceof MouseEvent && event.button === 0 || event instanceof TouchEvent) {
|
|
10437
|
-
assert(logger$
|
|
10437
|
+
assert(logger$4O, this.mouseDownEvent, "no mouse down event");
|
|
10438
10438
|
const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
|
|
10439
10439
|
const newPos = DragDrop.getEventPosition(event);
|
|
10440
10440
|
const deltaX = newPos.x - oldPos.x;
|
|
@@ -10543,7 +10543,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10543
10543
|
const dragDrop = new DragDrop(options);
|
|
10544
10544
|
return dragDrop;
|
|
10545
10545
|
}
|
|
10546
|
-
const logger$
|
|
10546
|
+
const logger$4N = getLogger("character");
|
|
10547
10547
|
function checkChar(charCode, rangeList) {
|
|
10548
10548
|
for (let i = 0; i < rangeList.length; i++) {
|
|
10549
10549
|
const start = rangeList[i][0];
|
|
@@ -10590,7 +10590,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10590
10590
|
}
|
|
10591
10591
|
function trimChar(s, char) {
|
|
10592
10592
|
let c = char;
|
|
10593
|
-
assert(logger$
|
|
10593
|
+
assert(logger$4N, c.length === 1, "invalid char length");
|
|
10594
10594
|
if (c === "]")
|
|
10595
10595
|
c = "\\]";
|
|
10596
10596
|
if (c === "\\")
|
|
@@ -10924,7 +10924,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10924
10924
|
const metrics = context.measureText(text2);
|
|
10925
10925
|
return metrics.width + 4;
|
|
10926
10926
|
}
|
|
10927
|
-
const logger$
|
|
10927
|
+
const logger$4M = getLogger("editor-clipboard");
|
|
10928
10928
|
async function setClipboardDataByEvent(items, event) {
|
|
10929
10929
|
if (event.clipboardData) {
|
|
10930
10930
|
const data2 = event.clipboardData;
|
|
@@ -10982,7 +10982,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10982
10982
|
document.body.removeChild(textarea2);
|
|
10983
10983
|
return true;
|
|
10984
10984
|
} catch (ex) {
|
|
10985
|
-
logger$
|
|
10985
|
+
logger$4M.error(ex);
|
|
10986
10986
|
document.body.removeChild(textarea2);
|
|
10987
10987
|
return false;
|
|
10988
10988
|
}
|
|
@@ -11003,7 +11003,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11003
11003
|
document.body.removeChild(div);
|
|
11004
11004
|
return true;
|
|
11005
11005
|
} catch (ex) {
|
|
11006
|
-
logger$
|
|
11006
|
+
logger$4M.error(ex);
|
|
11007
11007
|
document.body.removeChild(div);
|
|
11008
11008
|
return false;
|
|
11009
11009
|
}
|
|
@@ -11030,7 +11030,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11030
11030
|
await navigator.clipboard.write([clipboardItems]);
|
|
11031
11031
|
return true;
|
|
11032
11032
|
} catch (err) {
|
|
11033
|
-
logger$
|
|
11033
|
+
logger$4M.error(err);
|
|
11034
11034
|
return await execCommandCopy(items);
|
|
11035
11035
|
}
|
|
11036
11036
|
}
|
|
@@ -11086,7 +11086,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11086
11086
|
a.click();
|
|
11087
11087
|
a.remove();
|
|
11088
11088
|
}
|
|
11089
|
-
const logger$
|
|
11089
|
+
const logger$4L = getLogger("auto-scroll");
|
|
11090
11090
|
function scrollable(scrollElement, direction) {
|
|
11091
11091
|
if (scrollElement.scrollHeight === scrollElement.clientHeight) {
|
|
11092
11092
|
return false;
|
|
@@ -11110,7 +11110,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11110
11110
|
const isHorizontal = direction === "left" || direction === "right";
|
|
11111
11111
|
const scroll = () => {
|
|
11112
11112
|
if (!scrollable(scrollElement, direction)) {
|
|
11113
|
-
logger$
|
|
11113
|
+
logger$4L.debug("No need for scroll");
|
|
11114
11114
|
return null;
|
|
11115
11115
|
}
|
|
11116
11116
|
if (isHorizontal) {
|
|
@@ -11167,7 +11167,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11167
11167
|
if (this.scrolling) {
|
|
11168
11168
|
return;
|
|
11169
11169
|
}
|
|
11170
|
-
logger$
|
|
11170
|
+
logger$4L.debug(`scroll direction: ${direction}`);
|
|
11171
11171
|
this.cancelScroll = continuousScroll(scrollElement, {
|
|
11172
11172
|
direction,
|
|
11173
11173
|
step
|
|
@@ -11417,7 +11417,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11417
11417
|
const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
|
|
11418
11418
|
return ColorNames[colorIndex];
|
|
11419
11419
|
}
|
|
11420
|
-
const logger$
|
|
11420
|
+
const logger$4K = getLogger("container");
|
|
11421
11421
|
function isContainer(elem) {
|
|
11422
11422
|
return elem.getAttribute("data-type") === "editor-container";
|
|
11423
11423
|
}
|
|
@@ -11429,9 +11429,9 @@ var __publicField = (obj, key, value) => {
|
|
|
11429
11429
|
}
|
|
11430
11430
|
function getContainerId(container) {
|
|
11431
11431
|
const id = container.getAttribute("data-container-id");
|
|
11432
|
-
assert(logger$
|
|
11432
|
+
assert(logger$4K, id, "no id for container");
|
|
11433
11433
|
if (isRootContainer(container)) {
|
|
11434
|
-
assert(logger$
|
|
11434
|
+
assert(logger$4K, id === "root", `invalid root container id, : ${id}`);
|
|
11435
11435
|
}
|
|
11436
11436
|
return id;
|
|
11437
11437
|
}
|
|
@@ -11442,7 +11442,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11442
11442
|
function generateEditorContainerId(containerId) {
|
|
11443
11443
|
return `ones-editor-container-${containerId}`;
|
|
11444
11444
|
}
|
|
11445
|
-
const logger$
|
|
11445
|
+
const logger$4J = getLogger("element");
|
|
11446
11446
|
function createContainerElement(parent, type, containerId) {
|
|
11447
11447
|
const container = createElement("div", [type], parent);
|
|
11448
11448
|
container.setAttribute("data-type", "editor-container");
|
|
@@ -11453,7 +11453,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11453
11453
|
}
|
|
11454
11454
|
function getContainerById(editor, containerId) {
|
|
11455
11455
|
const container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
|
|
11456
|
-
assert(logger$
|
|
11456
|
+
assert(logger$4J, container, `no container: ${containerId}`);
|
|
11457
11457
|
return container;
|
|
11458
11458
|
}
|
|
11459
11459
|
function getExistsContainerById(editor, containerId) {
|
|
@@ -11462,7 +11462,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11462
11462
|
}
|
|
11463
11463
|
function getContainerBlocksElement(container) {
|
|
11464
11464
|
const blocks = container.querySelector(":scope > .container-blocks");
|
|
11465
|
-
assert(logger$
|
|
11465
|
+
assert(logger$4J, blocks, "no container blocks element");
|
|
11466
11466
|
return blocks;
|
|
11467
11467
|
}
|
|
11468
11468
|
function getContainerToolsElement(container) {
|
|
@@ -11475,11 +11475,11 @@ var __publicField = (obj, key, value) => {
|
|
|
11475
11475
|
function isContainerBlocksElement(element) {
|
|
11476
11476
|
return element.classList.contains("container-blocks");
|
|
11477
11477
|
}
|
|
11478
|
-
const logger$
|
|
11478
|
+
const logger$4I = getLogger("container-children");
|
|
11479
11479
|
function getChildBlocks(container, traverseChild) {
|
|
11480
11480
|
const content = getContainerBlocksElement(container);
|
|
11481
11481
|
const blocks = Array.from(content.children);
|
|
11482
|
-
assert(logger$
|
|
11482
|
+
assert(logger$4I, blocks.length > 0, "container have not any child block");
|
|
11483
11483
|
if (traverseChild) {
|
|
11484
11484
|
const { condition, editor } = traverseChild;
|
|
11485
11485
|
return blocks.reduce((result, block) => {
|
|
@@ -11502,7 +11502,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11502
11502
|
}
|
|
11503
11503
|
function getFirstChildBlock(container) {
|
|
11504
11504
|
const block = container.querySelector(":scope > .container-blocks > div[data-type=editor-block]");
|
|
11505
|
-
assert(logger$
|
|
11505
|
+
assert(logger$4I, block, "container have not any child block");
|
|
11506
11506
|
return block;
|
|
11507
11507
|
}
|
|
11508
11508
|
function getLastChildBlock(container) {
|
|
@@ -11514,14 +11514,14 @@ var __publicField = (obj, key, value) => {
|
|
|
11514
11514
|
}
|
|
11515
11515
|
function getBlockByIndex(container, blockIndex) {
|
|
11516
11516
|
const block = getChildBlocks(container)[blockIndex];
|
|
11517
|
-
assert(logger$
|
|
11517
|
+
assert(logger$4I, block, `container have not block at index ${blockIndex}`);
|
|
11518
11518
|
return block;
|
|
11519
11519
|
}
|
|
11520
11520
|
function findBlockByIndex(container, blockIndex) {
|
|
11521
11521
|
var _a;
|
|
11522
11522
|
return (_a = getChildBlocks(container)[blockIndex]) != null ? _a : null;
|
|
11523
11523
|
}
|
|
11524
|
-
const logger$
|
|
11524
|
+
const logger$4H = getLogger("block-dom");
|
|
11525
11525
|
function isBlock$1(node) {
|
|
11526
11526
|
if (!(node instanceof HTMLDivElement)) {
|
|
11527
11527
|
return false;
|
|
@@ -11542,12 +11542,12 @@ var __publicField = (obj, key, value) => {
|
|
|
11542
11542
|
}
|
|
11543
11543
|
function getBlockId(block) {
|
|
11544
11544
|
const { id } = block;
|
|
11545
|
-
assert(logger$
|
|
11545
|
+
assert(logger$4H, id, "no block id");
|
|
11546
11546
|
return id;
|
|
11547
11547
|
}
|
|
11548
11548
|
function getBlockType(block) {
|
|
11549
11549
|
const type = block.getAttribute("data-block-type");
|
|
11550
|
-
assert(logger$
|
|
11550
|
+
assert(logger$4H, type, "invalid block dom, no data-type");
|
|
11551
11551
|
return type;
|
|
11552
11552
|
}
|
|
11553
11553
|
function getParentBlock(node) {
|
|
@@ -11570,12 +11570,12 @@ var __publicField = (obj, key, value) => {
|
|
|
11570
11570
|
}
|
|
11571
11571
|
function getParentContainer(block) {
|
|
11572
11572
|
const container = block.closest("div[data-type=editor-container]");
|
|
11573
|
-
assert(logger$
|
|
11573
|
+
assert(logger$4H, container, "failed to get block container");
|
|
11574
11574
|
return container;
|
|
11575
11575
|
}
|
|
11576
11576
|
function getBlockContent(block) {
|
|
11577
11577
|
const content = block.querySelector(":scope >div[data-type=block-content]");
|
|
11578
|
-
assert(logger$
|
|
11578
|
+
assert(logger$4H, content, "no block content");
|
|
11579
11579
|
return content;
|
|
11580
11580
|
}
|
|
11581
11581
|
function getBlockTools(block) {
|
|
@@ -11584,7 +11584,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11584
11584
|
tools = createElement("div", [], block);
|
|
11585
11585
|
tools.setAttribute("data-type", "block-tools");
|
|
11586
11586
|
}
|
|
11587
|
-
assert(logger$
|
|
11587
|
+
assert(logger$4H, tools, "no block tools");
|
|
11588
11588
|
return tools;
|
|
11589
11589
|
}
|
|
11590
11590
|
function getExistsBlockTools(block) {
|
|
@@ -11605,7 +11605,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11605
11605
|
function createBlockElement(editor, path, data2) {
|
|
11606
11606
|
const blockData = editor.editorDecorators.decorateBlock(path, data2);
|
|
11607
11607
|
const { id, type } = blockData;
|
|
11608
|
-
assert(logger$
|
|
11608
|
+
assert(logger$4H, id, "no block id");
|
|
11609
11609
|
const elem = createElement("div", [`${type}-block`], null);
|
|
11610
11610
|
elem.id = id;
|
|
11611
11611
|
elem.setAttribute("data-type", "editor-block");
|
|
@@ -11643,7 +11643,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11643
11643
|
}
|
|
11644
11644
|
function getBoxTypeFromElement(box) {
|
|
11645
11645
|
const type = box.getAttribute("data-box-type");
|
|
11646
|
-
assert(logger$
|
|
11646
|
+
assert(logger$4H, type, "not a valid box element, no type");
|
|
11647
11647
|
return type;
|
|
11648
11648
|
}
|
|
11649
11649
|
function isBox(node) {
|
|
@@ -11654,7 +11654,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11654
11654
|
}
|
|
11655
11655
|
function getBoxId(box) {
|
|
11656
11656
|
const { id } = box;
|
|
11657
|
-
assert(logger$
|
|
11657
|
+
assert(logger$4H, id, "no box id");
|
|
11658
11658
|
return id;
|
|
11659
11659
|
}
|
|
11660
11660
|
function getParentBox(node) {
|
|
@@ -11676,7 +11676,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11676
11676
|
}
|
|
11677
11677
|
function getBoxContent(box) {
|
|
11678
11678
|
const content = box.querySelector("span[data-type=box-content]");
|
|
11679
|
-
assert(logger$
|
|
11679
|
+
assert(logger$4H, content, "invalid box dom, no content");
|
|
11680
11680
|
return content;
|
|
11681
11681
|
}
|
|
11682
11682
|
function createInsertionElement(type, id, attributes) {
|
|
@@ -11698,7 +11698,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11698
11698
|
}
|
|
11699
11699
|
function getInsertionContent(insertion) {
|
|
11700
11700
|
const content = insertion.querySelector("span[data-type=insertion-content]");
|
|
11701
|
-
assert(logger$
|
|
11701
|
+
assert(logger$4H, content, "invalid insertion-child dom, no content");
|
|
11702
11702
|
return content;
|
|
11703
11703
|
}
|
|
11704
11704
|
function getPrevBlock(block) {
|
|
@@ -11721,44 +11721,31 @@ var __publicField = (obj, key, value) => {
|
|
|
11721
11721
|
}
|
|
11722
11722
|
return null;
|
|
11723
11723
|
}
|
|
11724
|
-
function getPrevVisibleBlock(block
|
|
11725
|
-
const mergedMatcher = matcher || (() => true);
|
|
11724
|
+
function getPrevVisibleBlock(block) {
|
|
11726
11725
|
let prev = block.previousElementSibling;
|
|
11727
11726
|
while (prev) {
|
|
11728
|
-
if (isBlock$1(prev) && isVisibleBlock(prev)
|
|
11727
|
+
if (isBlock$1(prev) && isVisibleBlock(prev)) {
|
|
11729
11728
|
return prev;
|
|
11730
11729
|
}
|
|
11731
11730
|
prev = prev.previousElementSibling;
|
|
11732
11731
|
}
|
|
11733
11732
|
return null;
|
|
11734
11733
|
}
|
|
11735
|
-
function getNextVisibleBlock(block
|
|
11736
|
-
const mergedMatcher = matcher || (() => true);
|
|
11734
|
+
function getNextVisibleBlock(block) {
|
|
11737
11735
|
let next2 = block.nextElementSibling;
|
|
11738
11736
|
while (next2) {
|
|
11739
|
-
if (isBlock$1(next2) && isVisibleBlock(next2)
|
|
11737
|
+
if (isBlock$1(next2) && isVisibleBlock(next2)) {
|
|
11740
11738
|
return next2;
|
|
11741
11739
|
}
|
|
11742
11740
|
next2 = next2.nextElementSibling;
|
|
11743
11741
|
}
|
|
11744
11742
|
return null;
|
|
11745
11743
|
}
|
|
11746
|
-
function getBlocksBetween(start, end, matcher) {
|
|
11747
|
-
const blocks = [];
|
|
11748
|
-
let cur = start;
|
|
11749
|
-
while (cur !== end) {
|
|
11750
|
-
if (isBlock$1(cur) && matcher(cur)) {
|
|
11751
|
-
blocks.push(cur);
|
|
11752
|
-
}
|
|
11753
|
-
cur = cur.nextElementSibling;
|
|
11754
|
-
}
|
|
11755
|
-
return blocks;
|
|
11756
|
-
}
|
|
11757
11744
|
function getBlockIndex(block) {
|
|
11758
11745
|
const container = getParentContainer(block);
|
|
11759
11746
|
const children = getChildBlocks(container);
|
|
11760
11747
|
const index2 = children.indexOf(block);
|
|
11761
|
-
assert(logger$
|
|
11748
|
+
assert(logger$4H, index2 !== -1, "invalid block & container dom, failed to get block index");
|
|
11762
11749
|
return index2;
|
|
11763
11750
|
}
|
|
11764
11751
|
function isInBlock(target) {
|
|
@@ -11783,18 +11770,18 @@ var __publicField = (obj, key, value) => {
|
|
|
11783
11770
|
function isTitleBlock$2(block) {
|
|
11784
11771
|
return block.hasAttribute("data-document-title");
|
|
11785
11772
|
}
|
|
11786
|
-
const logger$
|
|
11773
|
+
const logger$4G = getLogger("block-class");
|
|
11787
11774
|
function getBlockClass(editor, block) {
|
|
11788
11775
|
return editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
11789
11776
|
}
|
|
11790
11777
|
function getTextBlockClass(editor, block) {
|
|
11791
11778
|
const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
11792
|
-
assert(logger$
|
|
11779
|
+
assert(logger$4G, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
|
|
11793
11780
|
return text2;
|
|
11794
11781
|
}
|
|
11795
11782
|
function getComplexBlockClass(editor, block) {
|
|
11796
11783
|
const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
11797
|
-
assert(logger$
|
|
11784
|
+
assert(logger$4G, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
|
|
11798
11785
|
return complex;
|
|
11799
11786
|
}
|
|
11800
11787
|
function getBlockClassByType(editor, type) {
|
|
@@ -11815,7 +11802,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11815
11802
|
function getBlockKind(editor, block) {
|
|
11816
11803
|
return getBlockClass(editor, block).blockKind;
|
|
11817
11804
|
}
|
|
11818
|
-
const logger$
|
|
11805
|
+
const logger$4F = getLogger("text-block-child");
|
|
11819
11806
|
function isTextBlockContentChild(elem) {
|
|
11820
11807
|
if (elem.tagName !== "SPAN") {
|
|
11821
11808
|
return false;
|
|
@@ -11823,14 +11810,14 @@ var __publicField = (obj, key, value) => {
|
|
|
11823
11810
|
return true;
|
|
11824
11811
|
}
|
|
11825
11812
|
function isTextBlockContentBoxChild(elem) {
|
|
11826
|
-
assert(logger$
|
|
11813
|
+
assert(logger$4F, isTextBlockContentChild(elem), "not a valid text child");
|
|
11827
11814
|
if (elem.getAttribute("data-type") === "editor-box") {
|
|
11828
11815
|
return true;
|
|
11829
11816
|
}
|
|
11830
11817
|
return false;
|
|
11831
11818
|
}
|
|
11832
11819
|
function isTextBlockContentInsertionChild(elem) {
|
|
11833
|
-
assert(logger$
|
|
11820
|
+
assert(logger$4F, isTextBlockContentChild(elem), "not a valid text child");
|
|
11834
11821
|
if (elem.getAttribute("data-type") === "editor-insertion") {
|
|
11835
11822
|
return true;
|
|
11836
11823
|
}
|
|
@@ -11840,7 +11827,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11840
11827
|
return !isTextBlockContentBoxChild(elem) && !isTextBlockContentInsertionChild(elem);
|
|
11841
11828
|
}
|
|
11842
11829
|
function getTextBlockContentChildType(child) {
|
|
11843
|
-
assert(logger$
|
|
11830
|
+
assert(logger$4F, isTextBlockContentChild(child), "not a valid text child");
|
|
11844
11831
|
if (isTextBlockContentBoxChild(child)) {
|
|
11845
11832
|
return "box";
|
|
11846
11833
|
}
|
|
@@ -11855,15 +11842,15 @@ var __publicField = (obj, key, value) => {
|
|
|
11855
11842
|
return 0;
|
|
11856
11843
|
if (type === "box")
|
|
11857
11844
|
return 1;
|
|
11858
|
-
assert(logger$
|
|
11859
|
-
assert(logger$
|
|
11845
|
+
assert(logger$4F, child.textContent !== null, "text block content is undefined");
|
|
11846
|
+
assert(logger$4F, child.textContent.length >= 0, "text block content length is negative");
|
|
11860
11847
|
return child.textContent.length;
|
|
11861
11848
|
}
|
|
11862
11849
|
function getTextBlockContentChildren(block) {
|
|
11863
11850
|
const content = getBlockContent(block);
|
|
11864
11851
|
const children = Array.from(content.children);
|
|
11865
11852
|
children.forEach((child) => {
|
|
11866
|
-
assert(logger$
|
|
11853
|
+
assert(logger$4F, isTextBlockContentChild(child), "not a valid text child");
|
|
11867
11854
|
});
|
|
11868
11855
|
return children;
|
|
11869
11856
|
}
|
|
@@ -11892,17 +11879,17 @@ var __publicField = (obj, key, value) => {
|
|
|
11892
11879
|
};
|
|
11893
11880
|
}
|
|
11894
11881
|
const offset = blockOffset - start;
|
|
11895
|
-
assert(logger$
|
|
11896
|
-
assert(logger$
|
|
11882
|
+
assert(logger$4F, offset > 0, "invalid offset value");
|
|
11883
|
+
assert(logger$4F, !isTextBlockContentBoxChild(child), "invalid box child");
|
|
11897
11884
|
return {
|
|
11898
11885
|
prev: child,
|
|
11899
11886
|
next: child,
|
|
11900
11887
|
offset
|
|
11901
11888
|
};
|
|
11902
11889
|
}
|
|
11903
|
-
assert(logger$
|
|
11890
|
+
assert(logger$4F, false, `invalid block child at position: ${blockOffset}`);
|
|
11904
11891
|
}
|
|
11905
|
-
const logger$
|
|
11892
|
+
const logger$4E = getLogger("block-path");
|
|
11906
11893
|
function getBlockPath(block) {
|
|
11907
11894
|
const ret = [];
|
|
11908
11895
|
let current = block;
|
|
@@ -11916,26 +11903,26 @@ var __publicField = (obj, key, value) => {
|
|
|
11916
11903
|
return ret;
|
|
11917
11904
|
}
|
|
11918
11905
|
const parentBlock = getParentBlock(container);
|
|
11919
|
-
assert(logger$
|
|
11906
|
+
assert(logger$4E, parentBlock, "no parent block");
|
|
11920
11907
|
current = parentBlock;
|
|
11921
11908
|
}
|
|
11922
|
-
assert(logger$
|
|
11909
|
+
assert(logger$4E, false, "no parent block");
|
|
11923
11910
|
return [];
|
|
11924
11911
|
}
|
|
11925
|
-
const logger$
|
|
11912
|
+
const logger$4D = getLogger("child-container-path");
|
|
11926
11913
|
function getContainerBlockPath(container) {
|
|
11927
11914
|
if (isRootContainer(container)) {
|
|
11928
11915
|
return [];
|
|
11929
11916
|
}
|
|
11930
11917
|
const parentBlock = getParentBlock(container);
|
|
11931
|
-
assert(logger$
|
|
11918
|
+
assert(logger$4D, parentBlock, "no parent block");
|
|
11932
11919
|
return getBlockPath(parentBlock);
|
|
11933
11920
|
}
|
|
11934
|
-
const logger$
|
|
11921
|
+
const logger$4C = getLogger("load-blocks");
|
|
11935
11922
|
function loadBlocks(editor, container, path) {
|
|
11936
11923
|
const containerId = getContainerId(container);
|
|
11937
11924
|
const blocks = getContainerBlocks$1(container, editor.doc);
|
|
11938
|
-
assert(logger$
|
|
11925
|
+
assert(logger$4C, blocks.length > 0, "no blocks in container");
|
|
11939
11926
|
const fragment = document.createDocumentFragment();
|
|
11940
11927
|
blocks.forEach((b, index2) => {
|
|
11941
11928
|
const block = editor.editorBlocks.createBlock([...path, { containerId, blockIndex: index2 }], container, b);
|
|
@@ -11951,7 +11938,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11951
11938
|
return block;
|
|
11952
11939
|
}
|
|
11953
11940
|
const blocks = getChildBlocks(container);
|
|
11954
|
-
assert(logger$
|
|
11941
|
+
assert(logger$4C, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
|
|
11955
11942
|
if (blockIndex === blocks.length) {
|
|
11956
11943
|
containerBlocksElement.appendChild(block);
|
|
11957
11944
|
} else {
|
|
@@ -11969,7 +11956,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11969
11956
|
insertBlockAt(container, blockIndex, block);
|
|
11970
11957
|
return block;
|
|
11971
11958
|
}
|
|
11972
|
-
const logger$
|
|
11959
|
+
const logger$4B = getLogger("root-container");
|
|
11973
11960
|
const MIN_DISTANCE_THRESHOLD$2 = 3;
|
|
11974
11961
|
class RootContainer {
|
|
11975
11962
|
constructor(editor, rootContainer) {
|
|
@@ -11997,7 +11984,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11997
11984
|
this.editor.selection.updateSelection(null);
|
|
11998
11985
|
this.editor.emit("resize", this.editor);
|
|
11999
11986
|
} catch (err) {
|
|
12000
|
-
logger$
|
|
11987
|
+
logger$4B.warn(`failed to update selection while container resizing: ${err.message}`);
|
|
12001
11988
|
}
|
|
12002
11989
|
});
|
|
12003
11990
|
__publicField(this, "handleClick", (event) => {
|
|
@@ -12030,7 +12017,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12030
12017
|
const box = getParentBox(elem);
|
|
12031
12018
|
if (box) {
|
|
12032
12019
|
const block2 = getParentBlock(box);
|
|
12033
|
-
assert(logger$
|
|
12020
|
+
assert(logger$4B, block2, "no parent block");
|
|
12034
12021
|
(_b = (_a = this.editor.editorBoxes.getBoxClass(getBoxTypeFromElement(box))) == null ? void 0 : _a.handleClickBox) == null ? void 0 : _b.call(_a, this.editor, box, event);
|
|
12035
12022
|
return;
|
|
12036
12023
|
}
|
|
@@ -12085,7 +12072,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12085
12072
|
this.editor.input.focus({ preventScroll: true });
|
|
12086
12073
|
});
|
|
12087
12074
|
__publicField(this, "handleMouseMove", (event) => {
|
|
12088
|
-
assert(logger$
|
|
12075
|
+
assert(logger$4B, this.mouseDownEvent, "no mouse down event");
|
|
12089
12076
|
if (ensureIsMobileEvent(this.mouseDownEvent))
|
|
12090
12077
|
return;
|
|
12091
12078
|
const deltaX = event.x - this.mouseDownEvent.x;
|
|
@@ -12201,7 +12188,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12201
12188
|
loadBlocks(editor, container, path);
|
|
12202
12189
|
return container;
|
|
12203
12190
|
}
|
|
12204
|
-
const logger$
|
|
12191
|
+
const logger$4A = getLogger("block");
|
|
12205
12192
|
function getBlockTextLength$6(editor, block) {
|
|
12206
12193
|
return getBlockClass(editor, block).getBlockTextLength(block);
|
|
12207
12194
|
}
|
|
@@ -12220,7 +12207,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12220
12207
|
return block;
|
|
12221
12208
|
}
|
|
12222
12209
|
const parent = getParentBlock(container);
|
|
12223
|
-
assert(logger$
|
|
12210
|
+
assert(logger$4A, parent, "no parent block exists for child container");
|
|
12224
12211
|
block = parent;
|
|
12225
12212
|
}
|
|
12226
12213
|
}
|
|
@@ -12256,7 +12243,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12256
12243
|
}
|
|
12257
12244
|
return fun(editor, block, options);
|
|
12258
12245
|
} catch (err) {
|
|
12259
|
-
logger$
|
|
12246
|
+
logger$4A.debug(`unsupported block type: ${type}`);
|
|
12260
12247
|
return null;
|
|
12261
12248
|
}
|
|
12262
12249
|
}
|
|
@@ -12276,7 +12263,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12276
12263
|
const styles = Object.fromEntries(Object.entries(data2).filter(([key]) => key.startsWith("style-")));
|
|
12277
12264
|
Object.entries(styles).forEach(([, value]) => {
|
|
12278
12265
|
const type = typeof value;
|
|
12279
|
-
assert(logger$
|
|
12266
|
+
assert(logger$4A, type === "string" || type === "number" || type === "boolean", "invalid style value");
|
|
12280
12267
|
});
|
|
12281
12268
|
return styles;
|
|
12282
12269
|
}
|
|
@@ -12401,7 +12388,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12401
12388
|
}
|
|
12402
12389
|
return { element: null, blockCommands: [], boxCommands: [] };
|
|
12403
12390
|
}
|
|
12404
|
-
const logger$
|
|
12391
|
+
const logger$4z = getLogger("embed-block-common");
|
|
12405
12392
|
function isColumnsBlock(block) {
|
|
12406
12393
|
return getBlockType(block) === "layout";
|
|
12407
12394
|
}
|
|
@@ -12409,9 +12396,9 @@ var __publicField = (obj, key, value) => {
|
|
|
12409
12396
|
return getBlockType(block) === "embed";
|
|
12410
12397
|
}
|
|
12411
12398
|
function getEmbedType(block) {
|
|
12412
|
-
assert(logger$
|
|
12399
|
+
assert(logger$4z, isEmbedBlock(block), "not an embed block");
|
|
12413
12400
|
const type = block.getAttribute("data-embed-type");
|
|
12414
|
-
assert(logger$
|
|
12401
|
+
assert(logger$4z, type, "no embed data type");
|
|
12415
12402
|
return type;
|
|
12416
12403
|
}
|
|
12417
12404
|
function getEmbedClassFromBlock(editor, block) {
|
|
@@ -12477,10 +12464,10 @@ var __publicField = (obj, key, value) => {
|
|
|
12477
12464
|
data: (_c = overrideOptions == null ? void 0 : overrideOptions.data) != null ? _c : data2
|
|
12478
12465
|
});
|
|
12479
12466
|
}
|
|
12480
|
-
const logger$
|
|
12467
|
+
const logger$4y = getLogger("execute-block-command");
|
|
12481
12468
|
function executeEmbedBlockCommand(editor, block, commandGroup, item) {
|
|
12482
12469
|
var _a;
|
|
12483
|
-
assert(logger$
|
|
12470
|
+
assert(logger$4y, isEmbedBlock(block), "not a embed block");
|
|
12484
12471
|
const embedType = getEmbedType(block);
|
|
12485
12472
|
const embed = getEmbedClassByType(editor, embedType);
|
|
12486
12473
|
if (!embed.getOptions) {
|
|
@@ -12513,14 +12500,14 @@ var __publicField = (obj, key, value) => {
|
|
|
12513
12500
|
}
|
|
12514
12501
|
return void 0;
|
|
12515
12502
|
}
|
|
12516
|
-
const logger$
|
|
12503
|
+
const logger$4x = getLogger("block-class");
|
|
12517
12504
|
function isHeadingBlock$1(block) {
|
|
12518
12505
|
return !!block.getAttribute("data-style-heading");
|
|
12519
12506
|
}
|
|
12520
12507
|
function getBlockHeading(block) {
|
|
12521
12508
|
var _a;
|
|
12522
12509
|
const heading = Number.parseInt((_a = block.getAttribute("data-style-heading")) != null ? _a : "", 10);
|
|
12523
|
-
assert(logger$
|
|
12510
|
+
assert(logger$4x, heading, "not a heading block");
|
|
12524
12511
|
return heading;
|
|
12525
12512
|
}
|
|
12526
12513
|
function isExpandedHeadingBlock(block) {
|
|
@@ -12531,7 +12518,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12531
12518
|
}
|
|
12532
12519
|
function getHeadingBlockChildren(block, oldHeading) {
|
|
12533
12520
|
if (!oldHeading) {
|
|
12534
|
-
assert(logger$
|
|
12521
|
+
assert(logger$4x, isHeadingBlock$1(block), "not a heading block");
|
|
12535
12522
|
}
|
|
12536
12523
|
const children = [];
|
|
12537
12524
|
const heading = oldHeading != null ? oldHeading : getBlockHeading(block);
|
|
@@ -12561,7 +12548,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12561
12548
|
}
|
|
12562
12549
|
return children;
|
|
12563
12550
|
}
|
|
12564
|
-
const logger$
|
|
12551
|
+
const logger$4w = getLogger("complex-block-position");
|
|
12565
12552
|
class EditorComplexBlockPosition {
|
|
12566
12553
|
constructor(block, childContainerId, custom) {
|
|
12567
12554
|
__publicField(this, "blockId");
|
|
@@ -12570,7 +12557,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12570
12557
|
if (block instanceof HTMLElement) {
|
|
12571
12558
|
this.blockId = getBlockId(block);
|
|
12572
12559
|
} else {
|
|
12573
|
-
assert(logger$
|
|
12560
|
+
assert(logger$4w, typeof block === "string", `not a valid block id: ${block}`);
|
|
12574
12561
|
this.blockId = block;
|
|
12575
12562
|
}
|
|
12576
12563
|
this.childContainerId = childContainerId;
|
|
@@ -12582,7 +12569,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12582
12569
|
return false;
|
|
12583
12570
|
}
|
|
12584
12571
|
}
|
|
12585
|
-
const logger$
|
|
12572
|
+
const logger$4v = getLogger("simple-block-position");
|
|
12586
12573
|
class EditorSimpleBlockPosition {
|
|
12587
12574
|
constructor(block, offset, type) {
|
|
12588
12575
|
__publicField(this, "blockId");
|
|
@@ -12591,7 +12578,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12591
12578
|
if (block instanceof HTMLElement) {
|
|
12592
12579
|
this.blockId = getBlockId(block);
|
|
12593
12580
|
} else {
|
|
12594
|
-
assert(logger$
|
|
12581
|
+
assert(logger$4v, typeof block === "string", `not a valid block id: ${block}`);
|
|
12595
12582
|
this.blockId = block;
|
|
12596
12583
|
}
|
|
12597
12584
|
this.offset = offset;
|
|
@@ -12601,7 +12588,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12601
12588
|
return true;
|
|
12602
12589
|
}
|
|
12603
12590
|
}
|
|
12604
|
-
const logger$
|
|
12591
|
+
const logger$4u = getLogger("editor-position");
|
|
12605
12592
|
function createSimpleBlockPosition(block, offset, type) {
|
|
12606
12593
|
return new EditorSimpleBlockPosition(block, offset, type);
|
|
12607
12594
|
}
|
|
@@ -12623,7 +12610,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12623
12610
|
}
|
|
12624
12611
|
const block1 = editor.getBlockById(pos1.blockId);
|
|
12625
12612
|
const block2 = editor.getBlockById(pos2.blockId);
|
|
12626
|
-
assert(logger$
|
|
12613
|
+
assert(logger$4u, block1 !== block2, "comparePosition: blocks are the same");
|
|
12627
12614
|
return compareElement(block1, block2);
|
|
12628
12615
|
}
|
|
12629
12616
|
if (isComplexBlockPosition(pos1) && isComplexBlockPosition(pos2)) {
|
|
@@ -12634,13 +12621,13 @@ var __publicField = (obj, key, value) => {
|
|
|
12634
12621
|
}
|
|
12635
12622
|
const container1 = editor.getContainerById(p1.childContainerId);
|
|
12636
12623
|
const container2 = editor.getContainerById(p2.childContainerId);
|
|
12637
|
-
assert(logger$
|
|
12624
|
+
assert(logger$4u, container1 !== container2, "comparePosition: containers are the same");
|
|
12638
12625
|
return compareElement(container1, container2);
|
|
12639
12626
|
}
|
|
12640
|
-
assert(logger$
|
|
12627
|
+
assert(logger$4u, false, "invalid ");
|
|
12641
12628
|
return 0;
|
|
12642
12629
|
}
|
|
12643
|
-
const logger$
|
|
12630
|
+
const logger$4t = getLogger("simple-range");
|
|
12644
12631
|
class EditorSimpleSelectionRange {
|
|
12645
12632
|
constructor(editor, options) {
|
|
12646
12633
|
__publicField(this, "editor");
|
|
@@ -12689,11 +12676,11 @@ var __publicField = (obj, key, value) => {
|
|
|
12689
12676
|
const { editor } = this;
|
|
12690
12677
|
const startBlock = editor.getBlockById(this.start.blockId);
|
|
12691
12678
|
const endBlock = editor.getBlockById(this.end.blockId);
|
|
12692
|
-
assert(logger$
|
|
12693
|
-
assert(logger$
|
|
12679
|
+
assert(logger$4t, startBlock, "no start block");
|
|
12680
|
+
assert(logger$4t, endBlock, "no end block");
|
|
12694
12681
|
const startContainer = getParentContainer(startBlock);
|
|
12695
12682
|
const endContainer = getParentContainer(endBlock);
|
|
12696
|
-
assert(logger$
|
|
12683
|
+
assert(logger$4t, startContainer === endContainer, "invalid range");
|
|
12697
12684
|
const ret = [];
|
|
12698
12685
|
if (startBlock === endBlock) {
|
|
12699
12686
|
ret.push({
|
|
@@ -12704,7 +12691,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12704
12691
|
} else {
|
|
12705
12692
|
const startIndex = getBlockIndex(startBlock);
|
|
12706
12693
|
const endIndex = getBlockIndex(endBlock);
|
|
12707
|
-
assert(logger$
|
|
12694
|
+
assert(logger$4t, startIndex < endIndex, "invalid range, start > index");
|
|
12708
12695
|
ret.push({
|
|
12709
12696
|
block: startBlock,
|
|
12710
12697
|
start: this.start,
|
|
@@ -12804,7 +12791,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12804
12791
|
clearSelection: clearSelection$6,
|
|
12805
12792
|
convertTo: convertTo$m
|
|
12806
12793
|
};
|
|
12807
|
-
const logger$
|
|
12794
|
+
const logger$4s = getLogger("editor-blocks");
|
|
12808
12795
|
class EditorBlocks {
|
|
12809
12796
|
constructor(editor) {
|
|
12810
12797
|
__publicField(this, "blocks", /* @__PURE__ */ new Map());
|
|
@@ -12813,12 +12800,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12813
12800
|
registerBlockClass(blockClass) {
|
|
12814
12801
|
const type = blockClass.blockType;
|
|
12815
12802
|
const exists = this.blocks.get(type);
|
|
12816
|
-
assert(logger$
|
|
12803
|
+
assert(logger$4s, !exists, `duplicated block type: ${type}`);
|
|
12817
12804
|
this.blocks.set(type, blockClass);
|
|
12818
12805
|
}
|
|
12819
12806
|
getBlockClass(type) {
|
|
12820
12807
|
const exists = this.blocks.get(type);
|
|
12821
|
-
assert(logger$
|
|
12808
|
+
assert(logger$4s, exists, `unknown block type: ${type}`);
|
|
12822
12809
|
return exists;
|
|
12823
12810
|
}
|
|
12824
12811
|
hasBlock(type) {
|
|
@@ -12834,7 +12821,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12834
12821
|
}
|
|
12835
12822
|
const content = blockClass.createBlockContent(this.editor, path, container, blockElement, block);
|
|
12836
12823
|
if (content.parentElement !== blockElement) {
|
|
12837
|
-
logger$
|
|
12824
|
+
logger$4s.warn("content parent is not block");
|
|
12838
12825
|
blockElement.appendChild(content);
|
|
12839
12826
|
}
|
|
12840
12827
|
this.editor.blockHooks.forEach((hook) => {
|
|
@@ -12855,7 +12842,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12855
12842
|
return newBlock;
|
|
12856
12843
|
}
|
|
12857
12844
|
}
|
|
12858
|
-
const logger$
|
|
12845
|
+
const logger$4r = getLogger("editor-embeds");
|
|
12859
12846
|
class EditorEmbeds {
|
|
12860
12847
|
constructor(editor) {
|
|
12861
12848
|
__publicField(this, "objects", /* @__PURE__ */ new Map());
|
|
@@ -12864,12 +12851,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12864
12851
|
registerEmbedClass(embedClass) {
|
|
12865
12852
|
const type = embedClass.embedType;
|
|
12866
12853
|
const exists = this.objects.get(type);
|
|
12867
|
-
assert(logger$
|
|
12854
|
+
assert(logger$4r, !exists, `duplicated embed object type: ${type}`);
|
|
12868
12855
|
this.objects.set(type, embedClass);
|
|
12869
12856
|
}
|
|
12870
12857
|
getEmbedClass(type) {
|
|
12871
12858
|
const exists = this.objects.get(type);
|
|
12872
|
-
assert(logger$
|
|
12859
|
+
assert(logger$4r, exists, `unknown embed type: ${type}`);
|
|
12873
12860
|
return exists;
|
|
12874
12861
|
}
|
|
12875
12862
|
getEmbedClassFromBlock(block) {
|
|
@@ -12879,12 +12866,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12879
12866
|
this.objects.forEach(callback);
|
|
12880
12867
|
}
|
|
12881
12868
|
}
|
|
12882
|
-
const logger$
|
|
12869
|
+
const logger$4q = getLogger("embed-block");
|
|
12883
12870
|
function createBlockContent$6(editor, path, container, blockElement, blockData) {
|
|
12884
12871
|
const content = createBlockContentElement(blockElement, "div");
|
|
12885
|
-
assert(logger$
|
|
12872
|
+
assert(logger$4q, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
|
|
12886
12873
|
const embedBlockData = blockData;
|
|
12887
|
-
assert(logger$
|
|
12874
|
+
assert(logger$4q, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
|
|
12888
12875
|
const embedClass = editor.editorEmbeds.getEmbedClass(embedBlockData.embedType);
|
|
12889
12876
|
embedClass.createEmbedContent(editor, content, embedBlockData, path, container, blockElement);
|
|
12890
12877
|
blockElement.setAttribute("data-embed-type", embedBlockData.embedType);
|
|
@@ -12912,7 +12899,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12912
12899
|
function getCaretRect$4(block, pos) {
|
|
12913
12900
|
const content = getBlockContent(block);
|
|
12914
12901
|
const rect = content.getBoundingClientRect();
|
|
12915
|
-
assert(logger$
|
|
12902
|
+
assert(logger$4q, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
|
|
12916
12903
|
if (pos.offset === 1) {
|
|
12917
12904
|
return new DOMRect(rect.right, rect.top, 0, rect.height);
|
|
12918
12905
|
}
|
|
@@ -13052,18 +13039,18 @@ var __publicField = (obj, key, value) => {
|
|
|
13052
13039
|
toStandardDoc: toStandardDoc$2,
|
|
13053
13040
|
getResources: getResources$2
|
|
13054
13041
|
};
|
|
13055
|
-
const logger$
|
|
13042
|
+
const logger$4p = getLogger("complex-block-helper");
|
|
13056
13043
|
function complexBlockGetAllChildContainers(editor, block, options) {
|
|
13057
13044
|
const blockClass = getComplexBlockClass(editor, block);
|
|
13058
13045
|
return blockClass.getChildContainers(editor, block, options);
|
|
13059
13046
|
}
|
|
13060
13047
|
function complexBlockGetSelectedContainers(editor, block, start, end) {
|
|
13061
13048
|
if (start.isSimple()) {
|
|
13062
|
-
assert(logger$
|
|
13049
|
+
assert(logger$4p, end.isSimple(), "invalid start and end position");
|
|
13063
13050
|
return complexBlockGetAllChildContainers(editor, block);
|
|
13064
13051
|
}
|
|
13065
|
-
assert(logger$
|
|
13066
|
-
assert(logger$
|
|
13052
|
+
assert(logger$4p, !start.isSimple(), "invalid start pos");
|
|
13053
|
+
assert(logger$4p, !end.isSimple(), "invalid end pos");
|
|
13067
13054
|
const blockClass = getComplexBlockClass(editor, block);
|
|
13068
13055
|
return blockClass.getSelectedContainers(editor, block, start, end);
|
|
13069
13056
|
}
|
|
@@ -13074,11 +13061,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13074
13061
|
const parentComplexBlock = getParentBlock(getParentContainer(childBlock));
|
|
13075
13062
|
if (!parentComplexBlock)
|
|
13076
13063
|
return false;
|
|
13077
|
-
assert(logger$
|
|
13064
|
+
assert(logger$4p, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
|
|
13078
13065
|
const childContainer = getParentContainer(childBlock);
|
|
13079
13066
|
const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
|
|
13080
13067
|
const index2 = childContainers.indexOf(childContainer);
|
|
13081
|
-
assert(logger$
|
|
13068
|
+
assert(logger$4p, index2 >= 0, "not valid child container");
|
|
13082
13069
|
return index2 === 0;
|
|
13083
13070
|
}
|
|
13084
13071
|
function complexBlockGetFirstSimpleChild(editor, complexBlock, options) {
|
|
@@ -13131,13 +13118,13 @@ var __publicField = (obj, key, value) => {
|
|
|
13131
13118
|
return block;
|
|
13132
13119
|
}
|
|
13133
13120
|
function findPrevSimpleBlockBeforeChildContainer(editor, childContainer, options) {
|
|
13134
|
-
assert(logger$
|
|
13121
|
+
assert(logger$4p, isChildContainer(childContainer), "not a child container");
|
|
13135
13122
|
const parentComplexBlock = getParentBlock(childContainer);
|
|
13136
|
-
assert(logger$
|
|
13137
|
-
assert(logger$
|
|
13123
|
+
assert(logger$4p, parentComplexBlock, "no parent block");
|
|
13124
|
+
assert(logger$4p, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
|
|
13138
13125
|
const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock, options);
|
|
13139
13126
|
const containerIndex = childContainers.indexOf(childContainer);
|
|
13140
|
-
assert(logger$
|
|
13127
|
+
assert(logger$4p, containerIndex !== -1, "child container not found");
|
|
13141
13128
|
if (containerIndex === 0) {
|
|
13142
13129
|
const prevBlock = getPrevBlock(parentComplexBlock);
|
|
13143
13130
|
if (!prevBlock)
|
|
@@ -13155,9 +13142,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13155
13142
|
return lastBlock2;
|
|
13156
13143
|
}
|
|
13157
13144
|
function complexBlockGetTopChildContainers(editor, complexBlock) {
|
|
13158
|
-
assert(logger$
|
|
13145
|
+
assert(logger$4p, isComplexKindBlock(editor, complexBlock), "not a complex block");
|
|
13159
13146
|
const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
|
|
13160
|
-
assert(logger$
|
|
13147
|
+
assert(logger$4p, childContainers.length > 0, "no child container");
|
|
13161
13148
|
if (childContainers.length === 1) {
|
|
13162
13149
|
return childContainers;
|
|
13163
13150
|
}
|
|
@@ -13182,9 +13169,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13182
13169
|
return ret;
|
|
13183
13170
|
}
|
|
13184
13171
|
function complexBlockGetBottomChildContainers(editor, complexBlock) {
|
|
13185
|
-
assert(logger$
|
|
13172
|
+
assert(logger$4p, isComplexKindBlock(editor, complexBlock), "not a complex block");
|
|
13186
13173
|
const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
|
|
13187
|
-
assert(logger$
|
|
13174
|
+
assert(logger$4p, childContainers.length > 0, "no child container");
|
|
13188
13175
|
if (childContainers.length === 1) {
|
|
13189
13176
|
return childContainers;
|
|
13190
13177
|
}
|
|
@@ -13289,11 +13276,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13289
13276
|
return result;
|
|
13290
13277
|
}
|
|
13291
13278
|
const anchor = "";
|
|
13292
|
-
const logger$
|
|
13279
|
+
const logger$4o = getLogger("text-range");
|
|
13293
13280
|
function getBlockRangeInfo(block, blockOffset) {
|
|
13294
13281
|
const getChildRange = (child, offset) => {
|
|
13295
13282
|
if (isTextBlockContentInsertionChild(child)) {
|
|
13296
|
-
assert(logger$
|
|
13283
|
+
assert(logger$4o, offset === 0, `invalid offset for insertion child: ${offset}`);
|
|
13297
13284
|
const childOffset = 2;
|
|
13298
13285
|
return {
|
|
13299
13286
|
child,
|
|
@@ -13302,7 +13289,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13302
13289
|
};
|
|
13303
13290
|
}
|
|
13304
13291
|
if (isTextBlockContentBoxChild(child)) {
|
|
13305
|
-
assert(logger$
|
|
13292
|
+
assert(logger$4o, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
|
|
13306
13293
|
const childOffset = offset === 0 ? 1 : 2;
|
|
13307
13294
|
return {
|
|
13308
13295
|
child,
|
|
@@ -13311,17 +13298,17 @@ var __publicField = (obj, key, value) => {
|
|
|
13311
13298
|
};
|
|
13312
13299
|
}
|
|
13313
13300
|
const textNode = child.firstChild;
|
|
13314
|
-
assert(logger$
|
|
13315
|
-
assert(logger$
|
|
13301
|
+
assert(logger$4o, textNode, "no child node for text child");
|
|
13302
|
+
assert(logger$4o, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
|
|
13316
13303
|
if (textNode instanceof HTMLBRElement) {
|
|
13317
|
-
assert(logger$
|
|
13304
|
+
assert(logger$4o, offset >= 0 && offset <= 0, "invalid offset for text child");
|
|
13318
13305
|
return {
|
|
13319
13306
|
child,
|
|
13320
13307
|
container: textNode,
|
|
13321
13308
|
offset
|
|
13322
13309
|
};
|
|
13323
13310
|
}
|
|
13324
|
-
assert(logger$
|
|
13311
|
+
assert(logger$4o, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
|
|
13325
13312
|
return {
|
|
13326
13313
|
child,
|
|
13327
13314
|
container: textNode,
|
|
@@ -13350,38 +13337,38 @@ var __publicField = (obj, key, value) => {
|
|
|
13350
13337
|
}
|
|
13351
13338
|
start += childLength;
|
|
13352
13339
|
}
|
|
13353
|
-
assert(logger$
|
|
13340
|
+
assert(logger$4o, false, "failed to get range info");
|
|
13354
13341
|
}
|
|
13355
13342
|
function createChildRange(child, start, end) {
|
|
13356
13343
|
if (start === end) {
|
|
13357
|
-
assert(logger$
|
|
13344
|
+
assert(logger$4o, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
|
|
13358
13345
|
} else {
|
|
13359
|
-
assert(logger$
|
|
13346
|
+
assert(logger$4o, start < end, `invalid start & end: ${start}, ${end}`);
|
|
13360
13347
|
}
|
|
13361
13348
|
if (isTextBlockContentInsertionChild(child)) {
|
|
13362
|
-
assert(logger$
|
|
13363
|
-
assert(logger$
|
|
13349
|
+
assert(logger$4o, start === end, `invalid insertion child range offset: ${start}, ${end}`);
|
|
13350
|
+
assert(logger$4o, start === 0, `invalid insertion child range start: ${start}`);
|
|
13364
13351
|
const insertionElem = child;
|
|
13365
|
-
assert(logger$
|
|
13352
|
+
assert(logger$4o, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
|
|
13366
13353
|
const range = createExpandedRange(insertionElem, 1, insertionElem, 2);
|
|
13367
13354
|
return range;
|
|
13368
13355
|
}
|
|
13369
13356
|
if (isTextBlockContentBoxChild(child)) {
|
|
13370
|
-
assert(logger$
|
|
13371
|
-
assert(logger$
|
|
13357
|
+
assert(logger$4o, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
|
|
13358
|
+
assert(logger$4o, start === 0, `invalid box child range start: ${start}`);
|
|
13372
13359
|
const box = child;
|
|
13373
|
-
assert(logger$
|
|
13360
|
+
assert(logger$4o, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
|
|
13374
13361
|
const range = createExpandedRange(box, 1, box, 2);
|
|
13375
13362
|
return range;
|
|
13376
13363
|
}
|
|
13377
13364
|
const length = getTextBlockContentChildTextLength(child);
|
|
13378
|
-
assert(logger$
|
|
13365
|
+
assert(logger$4o, end <= length, `invalid child end: ${end}, ${length}`);
|
|
13379
13366
|
const textNode = child.firstChild;
|
|
13380
|
-
assert(logger$
|
|
13381
|
-
assert(logger$
|
|
13367
|
+
assert(logger$4o, textNode instanceof Text, "invalid block text child");
|
|
13368
|
+
assert(logger$4o, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
|
|
13382
13369
|
return createExpandedRange(textNode, start, textNode, end);
|
|
13383
13370
|
}
|
|
13384
|
-
const logger$
|
|
13371
|
+
const logger$4n = getLogger("caret-rect");
|
|
13385
13372
|
function getChildClientRects(block, child) {
|
|
13386
13373
|
if (isBox(child)) {
|
|
13387
13374
|
const box = child;
|
|
@@ -13390,7 +13377,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13390
13377
|
const blockContent = getBlockContent(block);
|
|
13391
13378
|
const lineHeight = Number.parseFloat(window.getComputedStyle(blockContent).lineHeight) || boxContent.getBoundingClientRect().height;
|
|
13392
13379
|
const rects = Array.from(boxContent.getClientRects());
|
|
13393
|
-
assert(logger$
|
|
13380
|
+
assert(logger$4n, rects.length > 0, "no box client rects");
|
|
13394
13381
|
const blockRect = blockContent.getBoundingClientRect();
|
|
13395
13382
|
const firstRect = rects[0];
|
|
13396
13383
|
const lastRect = new DOMRect(blockRect.left, firstRect.bottom, 1, lineHeight);
|
|
@@ -13410,22 +13397,22 @@ var __publicField = (obj, key, value) => {
|
|
|
13410
13397
|
const rect2 = getLastClientRect(ranges[0].child);
|
|
13411
13398
|
return new DOMRect(rect2.right, rect2.top, 1, rect2.height);
|
|
13412
13399
|
}
|
|
13413
|
-
assert(logger$
|
|
13400
|
+
assert(logger$4n, ranges[1], "invalid ranges");
|
|
13414
13401
|
const rect = getFirstClientRect(ranges[1].child);
|
|
13415
13402
|
return new DOMRect(rect.left, rect.top, 1, rect.height);
|
|
13416
13403
|
}
|
|
13417
13404
|
let rangeInfo = ranges[0];
|
|
13418
|
-
assert(logger$
|
|
13405
|
+
assert(logger$4n, ranges.length >= 1, "failed to get block range");
|
|
13419
13406
|
if (ranges.length === 1) {
|
|
13420
13407
|
rangeInfo = ranges[0];
|
|
13421
13408
|
} else {
|
|
13422
|
-
assert(logger$
|
|
13409
|
+
assert(logger$4n, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
|
|
13423
13410
|
if (isTextBlockContentInsertionChild(ranges[ranges.length - 1].child)) {
|
|
13424
13411
|
rangeInfo = ranges[ranges.length - 1];
|
|
13425
13412
|
const child = rangeInfo.child;
|
|
13426
13413
|
const content = getInsertionContent(child);
|
|
13427
13414
|
const rects2 = content.getClientRects();
|
|
13428
|
-
assert(logger$
|
|
13415
|
+
assert(logger$4n, rects2.length >= 1, "no client rects for box content");
|
|
13429
13416
|
const rect = rects2[rects2.length - 1];
|
|
13430
13417
|
return new DOMRect(rect.right, rect.y, 1, rect.height);
|
|
13431
13418
|
}
|
|
@@ -13442,9 +13429,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13442
13429
|
}
|
|
13443
13430
|
}
|
|
13444
13431
|
if (rangeInfo.container instanceof HTMLBRElement) {
|
|
13445
|
-
assert(logger$
|
|
13432
|
+
assert(logger$4n, pos.offset === 0, "invalid offset for empty block text");
|
|
13446
13433
|
const parent = rangeInfo.container.parentElement;
|
|
13447
|
-
assert(logger$
|
|
13434
|
+
assert(logger$4n, parent, "invalid br parent");
|
|
13448
13435
|
const rect = parent.getBoundingClientRect();
|
|
13449
13436
|
const ret = new DOMRect(rect.left, rect.top, 1, rect.height);
|
|
13450
13437
|
return ret;
|
|
@@ -13452,11 +13439,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13452
13439
|
const range = createRange(rangeInfo.container, rangeInfo.offset);
|
|
13453
13440
|
const rects = Array.from(range.getClientRects());
|
|
13454
13441
|
if (rects.length === 0) {
|
|
13455
|
-
assert(logger$
|
|
13456
|
-
assert(logger$
|
|
13442
|
+
assert(logger$4n, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
|
|
13443
|
+
assert(logger$4n, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
|
|
13457
13444
|
const child = rangeInfo.child;
|
|
13458
13445
|
const rects2 = getChildClientRects(block, child);
|
|
13459
|
-
assert(logger$
|
|
13446
|
+
assert(logger$4n, rects2.length >= 1, "no client rects for box content");
|
|
13460
13447
|
if (rangeInfo.offset === 1) {
|
|
13461
13448
|
const rect2 = rects2[0];
|
|
13462
13449
|
return new DOMRect(rect2.x, rect2.y, 1, rect2.height);
|
|
@@ -13502,7 +13489,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13502
13489
|
});
|
|
13503
13490
|
}
|
|
13504
13491
|
}
|
|
13505
|
-
assert(logger$
|
|
13492
|
+
assert(logger$4n, rects.length > 0, "no client rects for range");
|
|
13506
13493
|
if (pos.type === "home") {
|
|
13507
13494
|
return rects[rects.length - 1];
|
|
13508
13495
|
}
|
|
@@ -13582,13 +13569,13 @@ var __publicField = (obj, key, value) => {
|
|
|
13582
13569
|
};
|
|
13583
13570
|
}
|
|
13584
13571
|
}
|
|
13585
|
-
const logger$
|
|
13572
|
+
const logger$4m = getLogger("selection-range");
|
|
13586
13573
|
function createEditorSelectionRange(editor, options) {
|
|
13587
13574
|
const { anchor: anchor2, focus } = options;
|
|
13588
13575
|
if (anchor2 instanceof EditorSimpleBlockPosition && focus instanceof EditorSimpleBlockPosition) {
|
|
13589
13576
|
return new EditorSimpleSelectionRange(editor, { anchor: anchor2, focus });
|
|
13590
13577
|
}
|
|
13591
|
-
assert(logger$
|
|
13578
|
+
assert(logger$4m, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
|
|
13592
13579
|
return new EditorComplexSelectionRange(editor, { anchor: anchor2, focus });
|
|
13593
13580
|
}
|
|
13594
13581
|
function createBlockSimpleRange(editor, block, anchor2, focus) {
|
|
@@ -13610,7 +13597,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13610
13597
|
const focus = createSimpleBlockPosition(range.focus.blockId, range.focus.offset, "normal");
|
|
13611
13598
|
return createEditorSelectionRange(editor, { anchor: anchor2, focus });
|
|
13612
13599
|
}
|
|
13613
|
-
const logger$
|
|
13600
|
+
const logger$4l = getLogger("range-from-point");
|
|
13614
13601
|
function getBlockRangeFromPoint(editor, pointX, pointY, dragging) {
|
|
13615
13602
|
const yOffsets = [0, -12, 12];
|
|
13616
13603
|
let x = pointX;
|
|
@@ -13642,7 +13629,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13642
13629
|
const rect = elem.getBoundingClientRect();
|
|
13643
13630
|
if (rect.width && rect.top && i === 0) {
|
|
13644
13631
|
if (rect.left + rect.width < x || rect.top + rect.height < y) {
|
|
13645
|
-
logger$
|
|
13632
|
+
logger$4l.debug("click on scrollbar, out of element rect");
|
|
13646
13633
|
return null;
|
|
13647
13634
|
}
|
|
13648
13635
|
}
|
|
@@ -13680,7 +13667,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13680
13667
|
let block = getLastChildBlock(container);
|
|
13681
13668
|
if (!isVisibleBlock(block)) {
|
|
13682
13669
|
const preBlock = getPrevVisibleBlock(block);
|
|
13683
|
-
assert(logger$
|
|
13670
|
+
assert(logger$4l, preBlock, "container must have visible block");
|
|
13684
13671
|
block = preBlock;
|
|
13685
13672
|
}
|
|
13686
13673
|
const range = getBlockClass(editor, block).getRangeFromPoint(editor, block, x, block.getBoundingClientRect().bottom - 4);
|
|
@@ -13699,7 +13686,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13699
13686
|
if (range instanceof EditorSimpleSelectionRange) {
|
|
13700
13687
|
return range;
|
|
13701
13688
|
}
|
|
13702
|
-
assert(logger$
|
|
13689
|
+
assert(logger$4l, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
|
|
13703
13690
|
const complexRange = range;
|
|
13704
13691
|
const container2 = editor.getContainerById(complexRange.start.childContainerId);
|
|
13705
13692
|
return getRangeInContainer(editor, container2, x, y);
|
|
@@ -13722,7 +13709,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13722
13709
|
});
|
|
13723
13710
|
return getRangeInContainer(editor, container, x, y);
|
|
13724
13711
|
}
|
|
13725
|
-
const logger$
|
|
13712
|
+
const logger$4k = getLogger("adjust-selection-pos");
|
|
13726
13713
|
function getParentContainers(block) {
|
|
13727
13714
|
const containers = [];
|
|
13728
13715
|
while (block) {
|
|
@@ -13732,10 +13719,10 @@ var __publicField = (obj, key, value) => {
|
|
|
13732
13719
|
return containers;
|
|
13733
13720
|
}
|
|
13734
13721
|
const newBlock = getParentBlock(container);
|
|
13735
|
-
assert(logger$
|
|
13722
|
+
assert(logger$4k, newBlock, "child container has not parent container");
|
|
13736
13723
|
block = newBlock;
|
|
13737
13724
|
}
|
|
13738
|
-
assert(logger$
|
|
13725
|
+
assert(logger$4k, false, "should not come here: getParentContainers");
|
|
13739
13726
|
}
|
|
13740
13727
|
function getParentBlockInContainer(container, block) {
|
|
13741
13728
|
while (block) {
|
|
@@ -13744,16 +13731,16 @@ var __publicField = (obj, key, value) => {
|
|
|
13744
13731
|
return block;
|
|
13745
13732
|
}
|
|
13746
13733
|
const newBlock = getParentBlock(parent);
|
|
13747
|
-
assert(logger$
|
|
13734
|
+
assert(logger$4k, newBlock, "could not find parent block for a child container");
|
|
13748
13735
|
block = newBlock;
|
|
13749
13736
|
}
|
|
13750
|
-
assert(logger$
|
|
13737
|
+
assert(logger$4k, false, "no parent block in specified container");
|
|
13751
13738
|
}
|
|
13752
13739
|
function getClosestParentBlock(block1, block2) {
|
|
13753
13740
|
const containers1 = getParentContainers(block1);
|
|
13754
13741
|
const containers2 = getParentContainers(block2);
|
|
13755
|
-
assert(logger$
|
|
13756
|
-
assert(logger$
|
|
13742
|
+
assert(logger$4k, containers1.length > 0 && containers2.length > 0, "block has not parent container");
|
|
13743
|
+
assert(logger$4k, containers1[0] === containers2[0], "root container does not equal");
|
|
13757
13744
|
let parentContainer = containers1[0];
|
|
13758
13745
|
for (let i = 1; i < containers1.length || containers2.length; i++) {
|
|
13759
13746
|
if (containers1[i] === containers2[i]) {
|
|
@@ -13772,23 +13759,23 @@ var __publicField = (obj, key, value) => {
|
|
|
13772
13759
|
}
|
|
13773
13760
|
function getParentContainerInComplexBlock(parentComplexBlock, element) {
|
|
13774
13761
|
let block = getParentBlock(element);
|
|
13775
|
-
assert(logger$
|
|
13762
|
+
assert(logger$4k, block, "element is not in a block");
|
|
13776
13763
|
while (block) {
|
|
13777
13764
|
const container = getParentContainer(block);
|
|
13778
|
-
assert(logger$
|
|
13765
|
+
assert(logger$4k, isChildContainer(container), "not a child container");
|
|
13779
13766
|
const parentBlock = getParentBlock(container);
|
|
13780
|
-
assert(logger$
|
|
13767
|
+
assert(logger$4k, parentBlock, "child container has not parent block");
|
|
13781
13768
|
if (parentBlock === parentComplexBlock) {
|
|
13782
13769
|
return container;
|
|
13783
13770
|
}
|
|
13784
13771
|
block = parentBlock;
|
|
13785
13772
|
}
|
|
13786
|
-
assert(logger$
|
|
13773
|
+
assert(logger$4k, false, "failed to find parent container in complex block");
|
|
13787
13774
|
}
|
|
13788
13775
|
function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
|
|
13789
13776
|
const blockId = getBlockId(complexBlock);
|
|
13790
|
-
assert(logger$
|
|
13791
|
-
assert(logger$
|
|
13777
|
+
assert(logger$4k, blockId === anchor2.blockId, "invalid start pos");
|
|
13778
|
+
assert(logger$4k, blockId === focus.blockId, "invalid end pos");
|
|
13792
13779
|
const blockClass = getComplexBlockClass(editor, complexBlock);
|
|
13793
13780
|
if (blockClass.adjustSelectionPos) {
|
|
13794
13781
|
return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
|
|
@@ -13822,8 +13809,8 @@ var __publicField = (obj, key, value) => {
|
|
|
13822
13809
|
if (focus instanceof EditorComplexBlockPosition) {
|
|
13823
13810
|
focus = createSimpleBlockPosition(focusBlock, getBlockTextLength$6(editor, focusBlock), "end");
|
|
13824
13811
|
}
|
|
13825
|
-
assert(logger$
|
|
13826
|
-
assert(logger$
|
|
13812
|
+
assert(logger$4k, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
|
|
13813
|
+
assert(logger$4k, focus instanceof EditorSimpleBlockPosition, "not valid position type");
|
|
13827
13814
|
return {
|
|
13828
13815
|
anchor: anchor2,
|
|
13829
13816
|
focus
|
|
@@ -13877,7 +13864,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13877
13864
|
focus
|
|
13878
13865
|
};
|
|
13879
13866
|
}
|
|
13880
|
-
const logger$
|
|
13867
|
+
const logger$4j = getLogger("core");
|
|
13881
13868
|
function createBlockAnchor(editor, block, id, refClientRect) {
|
|
13882
13869
|
const tools = getBlockTools(block);
|
|
13883
13870
|
let elem = tools.querySelector(`.block-anchor[data-id=${id}]`);
|
|
@@ -13895,7 +13882,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13895
13882
|
return elem;
|
|
13896
13883
|
}
|
|
13897
13884
|
function createBlockCaretAnchor(editor, block, offset, id) {
|
|
13898
|
-
assert(logger$
|
|
13885
|
+
assert(logger$4j, isTextKindBlock(editor, block), "not a text kind block");
|
|
13899
13886
|
const caretRect = getTextCaretRect(block, createSimpleBlockPosition(block, offset, "normal"));
|
|
13900
13887
|
const blockRect = block.getBoundingClientRect();
|
|
13901
13888
|
const tools = getBlockTools(block);
|
|
@@ -14254,19 +14241,19 @@ var __publicField = (obj, key, value) => {
|
|
|
14254
14241
|
return result + (index2 ? "-" : "") + word.toLowerCase();
|
|
14255
14242
|
});
|
|
14256
14243
|
const kebabCase$1 = kebabCase;
|
|
14257
|
-
const logger$
|
|
14244
|
+
const logger$4i = getLogger("box");
|
|
14258
14245
|
function isBoxOp(op) {
|
|
14259
14246
|
if (!op.attributes)
|
|
14260
14247
|
return false;
|
|
14261
14248
|
if (!op.attributes.box)
|
|
14262
14249
|
return false;
|
|
14263
|
-
assert(logger$
|
|
14264
|
-
assert(logger$
|
|
14250
|
+
assert(logger$4i, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
|
|
14251
|
+
assert(logger$4i, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
|
|
14265
14252
|
return true;
|
|
14266
14253
|
}
|
|
14267
|
-
const logger$
|
|
14254
|
+
const logger$4h = getLogger("text-op");
|
|
14268
14255
|
function getOpLength(op) {
|
|
14269
|
-
assert(logger$
|
|
14256
|
+
assert(logger$4h, typeof op.insert === "string", "invalid op, no insert");
|
|
14270
14257
|
return op.insert.length;
|
|
14271
14258
|
}
|
|
14272
14259
|
function getOpAt(text2, offset) {
|
|
@@ -14274,7 +14261,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14274
14261
|
let pos = 0;
|
|
14275
14262
|
for (let i = 0; i < ops.length; i++) {
|
|
14276
14263
|
const op = ops[i];
|
|
14277
|
-
assert(logger$
|
|
14264
|
+
assert(logger$4h, typeof op.insert === "string", "invalid text op, no insert");
|
|
14278
14265
|
const end = pos + getOpLength(op);
|
|
14279
14266
|
if (end > offset) {
|
|
14280
14267
|
return [op];
|
|
@@ -14290,22 +14277,22 @@ var __publicField = (obj, key, value) => {
|
|
|
14290
14277
|
}
|
|
14291
14278
|
return [];
|
|
14292
14279
|
}
|
|
14293
|
-
const logger$
|
|
14280
|
+
const logger$4g = getLogger("rich-text-length");
|
|
14294
14281
|
function getTextOpLength(op) {
|
|
14295
|
-
assert(logger$
|
|
14282
|
+
assert(logger$4g, typeof op.insert === "string", "op.insert is not string");
|
|
14296
14283
|
return op.insert.length;
|
|
14297
14284
|
}
|
|
14298
14285
|
function getTextLength(ops) {
|
|
14299
14286
|
let count = 0;
|
|
14300
14287
|
ops.forEach((op) => {
|
|
14301
14288
|
if (op.insert) {
|
|
14302
|
-
assert(logger$
|
|
14289
|
+
assert(logger$4g, typeof op.insert === "string", "op.insert is not string");
|
|
14303
14290
|
count += getTextOpLength(op);
|
|
14304
14291
|
}
|
|
14305
14292
|
});
|
|
14306
14293
|
return count;
|
|
14307
14294
|
}
|
|
14308
|
-
const logger$
|
|
14295
|
+
const logger$4f = getLogger("split-text");
|
|
14309
14296
|
function splitText(ops, offset, splitResult) {
|
|
14310
14297
|
ops = cloneDeep__default.default(ops);
|
|
14311
14298
|
if (offset === 0) {
|
|
@@ -14323,8 +14310,8 @@ var __publicField = (obj, key, value) => {
|
|
|
14323
14310
|
let counted = 0;
|
|
14324
14311
|
for (let i = 0; i < ops.length; i++) {
|
|
14325
14312
|
const op = ops[i];
|
|
14326
|
-
assert(logger$
|
|
14327
|
-
assert(logger$
|
|
14313
|
+
assert(logger$4f, typeof op === "object", `invalid op type, ${typeof op}`);
|
|
14314
|
+
assert(logger$4f, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
|
|
14328
14315
|
const subLen = getTextOpLength(op);
|
|
14329
14316
|
if (counted + subLen < offset) {
|
|
14330
14317
|
counted += subLen;
|
|
@@ -14334,18 +14321,18 @@ var __publicField = (obj, key, value) => {
|
|
|
14334
14321
|
right: ops.slice(i + 1)
|
|
14335
14322
|
};
|
|
14336
14323
|
} else {
|
|
14337
|
-
assert(logger$
|
|
14324
|
+
assert(logger$4f, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
|
|
14338
14325
|
const splitIndex = offset - counted;
|
|
14339
14326
|
const copied = cloneDeep__default.default(op);
|
|
14340
|
-
assert(logger$
|
|
14341
|
-
assert(logger$
|
|
14327
|
+
assert(logger$4f, copied.insert, "no copied.insert");
|
|
14328
|
+
assert(logger$4f, typeof copied.insert === "string", "invalid copied.insert type");
|
|
14342
14329
|
copied.insert = copied.insert.substr(0, splitIndex);
|
|
14343
14330
|
op.insert = op.insert.substr(splitIndex);
|
|
14344
14331
|
if (copied.insert === "") {
|
|
14345
|
-
assert(logger$
|
|
14332
|
+
assert(logger$4f, false, "invalid copied.insert, is empty string");
|
|
14346
14333
|
}
|
|
14347
14334
|
if (op.insert === "") {
|
|
14348
|
-
assert(logger$
|
|
14335
|
+
assert(logger$4f, false, "invalid op.insert, is empty string");
|
|
14349
14336
|
}
|
|
14350
14337
|
const right = [
|
|
14351
14338
|
op,
|
|
@@ -14364,9 +14351,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14364
14351
|
throw new Error(`invalid split offset: ${offset}, ${JSON.stringify(ops)}`);
|
|
14365
14352
|
}
|
|
14366
14353
|
function splitToThree(text2, offset, length) {
|
|
14367
|
-
assert(logger$
|
|
14368
|
-
assert(logger$
|
|
14369
|
-
assert(logger$
|
|
14354
|
+
assert(logger$4f, offset >= 0, "invalid offset, < 0");
|
|
14355
|
+
assert(logger$4f, length > 0, "invalid length, <= 0");
|
|
14356
|
+
assert(logger$4f, offset + length <= getTextLength(text2), "invalid offset + length < text length");
|
|
14370
14357
|
const { left: temp, right } = splitText(text2, offset + length);
|
|
14371
14358
|
const { left, right: middle } = splitText(temp, offset);
|
|
14372
14359
|
return { left, middle, right };
|
|
@@ -14589,9 +14576,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14589
14576
|
}
|
|
14590
14577
|
return [color, backgroundColor];
|
|
14591
14578
|
}
|
|
14592
|
-
const logger$
|
|
14579
|
+
const logger$4e = getLogger("text-block-content");
|
|
14593
14580
|
function updateBlockContentCore(editor, blockPath, content, blockText, insertions) {
|
|
14594
|
-
assert(logger$
|
|
14581
|
+
assert(logger$4e, blockText, "no text for block");
|
|
14595
14582
|
if (blockText.length === 0 && (!insertions || insertions.size === 0)) {
|
|
14596
14583
|
content.innerHTML = "<span><br></span>";
|
|
14597
14584
|
return;
|
|
@@ -14623,9 +14610,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14623
14610
|
for (let i2 = 0; i2 < text2.length; i2++) {
|
|
14624
14611
|
const op = text2[i2];
|
|
14625
14612
|
if (isBoxOp(op)) {
|
|
14626
|
-
assert(logger$
|
|
14613
|
+
assert(logger$4e, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
|
|
14627
14614
|
const span2 = editor.editorBoxes.createBox(content, op.attributes);
|
|
14628
|
-
assert(logger$
|
|
14615
|
+
assert(logger$4e, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
|
|
14629
14616
|
const ret = editor.editorBlockRenders.renderBox(blockPath, op.attributes);
|
|
14630
14617
|
if (ret.classes) {
|
|
14631
14618
|
addClass(span2, ...ret.classes);
|
|
@@ -14643,7 +14630,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14643
14630
|
fragment.appendChild(span2);
|
|
14644
14631
|
continue;
|
|
14645
14632
|
}
|
|
14646
|
-
assert(logger$
|
|
14633
|
+
assert(logger$4e, op.insert, `no insert in op: ${JSON.stringify(op)}`);
|
|
14647
14634
|
const span = createElement("span", ["text"], fragment, op.insert);
|
|
14648
14635
|
if (op.attributes) {
|
|
14649
14636
|
const ret = editor.editorBlockRenders.renderText(blockPath, op.attributes);
|
|
@@ -14674,7 +14661,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14674
14661
|
const compositionText = editor.compositingText;
|
|
14675
14662
|
if (compositionText) {
|
|
14676
14663
|
const pos = editor.selection.range.start;
|
|
14677
|
-
assert(logger$
|
|
14664
|
+
assert(logger$4e, pos.isSimple(), "not an simple position while compositing");
|
|
14678
14665
|
if (pos.blockId === blockId) {
|
|
14679
14666
|
const attributes = getAttributesAt(text2, 0);
|
|
14680
14667
|
insertions.set(pos.offset, [{
|
|
@@ -14690,11 +14677,11 @@ var __publicField = (obj, key, value) => {
|
|
|
14690
14677
|
function clearAllTempCompositionText(editor) {
|
|
14691
14678
|
const children = editor.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');
|
|
14692
14679
|
if (children.length) {
|
|
14693
|
-
logger$
|
|
14680
|
+
logger$4e.debug(`remove ${children.length} temp composition span`);
|
|
14694
14681
|
}
|
|
14695
14682
|
Array.from(children).forEach((c) => c.remove());
|
|
14696
14683
|
}
|
|
14697
|
-
const logger$
|
|
14684
|
+
const logger$4d = getLogger("client-rects");
|
|
14698
14685
|
function getChildrenOffsets(block) {
|
|
14699
14686
|
const children = getTextBlockContentChildren(block);
|
|
14700
14687
|
let start = 0;
|
|
@@ -14712,15 +14699,15 @@ var __publicField = (obj, key, value) => {
|
|
|
14712
14699
|
return ret;
|
|
14713
14700
|
}
|
|
14714
14701
|
function getChildrenInRange(editor, block, from, to) {
|
|
14715
|
-
assert(logger$
|
|
14702
|
+
assert(logger$4d, from < to, `invalid from & to: ${from}, ${to}`);
|
|
14716
14703
|
const blockLength = getBlockTextLength$6(editor, block);
|
|
14717
|
-
assert(logger$
|
|
14704
|
+
assert(logger$4d, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
|
|
14718
14705
|
const offsets = getChildrenOffsets(block);
|
|
14719
14706
|
const startIndex = offsets.findIndex((c) => c.startBlockOffset <= from && from < c.endBlockOffset);
|
|
14720
14707
|
const endIndex = offsets.findIndex((c) => c.startBlockOffset < to && to <= c.endBlockOffset);
|
|
14721
|
-
assert(logger$
|
|
14722
|
-
assert(logger$
|
|
14723
|
-
assert(logger$
|
|
14708
|
+
assert(logger$4d, startIndex !== -1, "failed to find start child");
|
|
14709
|
+
assert(logger$4d, endIndex !== -1, "failed to find end child");
|
|
14710
|
+
assert(logger$4d, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
|
|
14724
14711
|
if (startIndex === endIndex) {
|
|
14725
14712
|
const child = offsets[startIndex];
|
|
14726
14713
|
return [{
|
|
@@ -14802,16 +14789,16 @@ var __publicField = (obj, key, value) => {
|
|
|
14802
14789
|
return rects;
|
|
14803
14790
|
}
|
|
14804
14791
|
function getRangeClientRects(editor, block, range) {
|
|
14805
|
-
assert(logger$
|
|
14792
|
+
assert(logger$4d, range instanceof EditorSimpleSelectionRange, "invalid range");
|
|
14806
14793
|
const start = range.start;
|
|
14807
14794
|
const end = range.end;
|
|
14808
|
-
assert(logger$
|
|
14809
|
-
assert(logger$
|
|
14810
|
-
assert(logger$
|
|
14811
|
-
assert(logger$
|
|
14795
|
+
assert(logger$4d, start.isSimple(), "text block only allow simple position");
|
|
14796
|
+
assert(logger$4d, end.isSimple(), "text block only allow simple position");
|
|
14797
|
+
assert(logger$4d, start.blockId === end.blockId, "only allow update one text block selection");
|
|
14798
|
+
assert(logger$4d, start.blockId === getBlockId(block), "only allow update one text block selection");
|
|
14812
14799
|
return getClientRects$2(editor, block, start, end);
|
|
14813
14800
|
}
|
|
14814
|
-
const logger$
|
|
14801
|
+
const logger$4c = getLogger("selection-background");
|
|
14815
14802
|
function getLineHeight(elem) {
|
|
14816
14803
|
const style2 = window.getComputedStyle(elem);
|
|
14817
14804
|
const lineHeightStyle = style2.getPropertyValue("line-height");
|
|
@@ -14831,9 +14818,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14831
14818
|
return lineHeight;
|
|
14832
14819
|
}
|
|
14833
14820
|
function updateSelection$4(editor, block, start, end) {
|
|
14834
|
-
assert(logger$
|
|
14835
|
-
assert(logger$
|
|
14836
|
-
assert(logger$
|
|
14821
|
+
assert(logger$4c, start.isSimple(), "text block only allow simple position");
|
|
14822
|
+
assert(logger$4c, end.isSimple(), "text block only allow simple position");
|
|
14823
|
+
assert(logger$4c, start.blockId === end.blockId, "only allow update one text block selection");
|
|
14837
14824
|
const from = start.offset;
|
|
14838
14825
|
const to = end.offset;
|
|
14839
14826
|
if (from === to) {
|
|
@@ -14892,7 +14879,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14892
14879
|
}
|
|
14893
14880
|
});
|
|
14894
14881
|
}
|
|
14895
|
-
const logger$
|
|
14882
|
+
const logger$4b = getLogger("line-breaker");
|
|
14896
14883
|
function mergeTextRects(rects) {
|
|
14897
14884
|
const result = [];
|
|
14898
14885
|
let lastRect = null;
|
|
@@ -15019,7 +15006,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15019
15006
|
}
|
|
15020
15007
|
const textChild = child;
|
|
15021
15008
|
const rects = mergeTextRects(textChild.getClientRects());
|
|
15022
|
-
assert(logger$
|
|
15009
|
+
assert(logger$4b, rects.length > 0, "invalid text child dom");
|
|
15023
15010
|
if (rects.length === 1) {
|
|
15024
15011
|
const nextChild = children[i + 1];
|
|
15025
15012
|
if (!nextChild) {
|
|
@@ -15044,10 +15031,10 @@ var __publicField = (obj, key, value) => {
|
|
|
15044
15031
|
continue;
|
|
15045
15032
|
}
|
|
15046
15033
|
const textNode = textChild.firstChild;
|
|
15047
|
-
assert(logger$
|
|
15048
|
-
assert(logger$
|
|
15034
|
+
assert(logger$4b, textNode, "invalid text child, no text node");
|
|
15035
|
+
assert(logger$4b, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
|
|
15049
15036
|
const textChildLength = getTextBlockContentChildTextLength(textChild);
|
|
15050
|
-
assert(logger$
|
|
15037
|
+
assert(logger$4b, textNode.data.length === textChildLength, "text node data length not equal child text length");
|
|
15051
15038
|
const textRects = getTextRects(textNode);
|
|
15052
15039
|
for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
|
|
15053
15040
|
const rect = textRects[rIndex];
|
|
@@ -15089,7 +15076,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15089
15076
|
}
|
|
15090
15077
|
}
|
|
15091
15078
|
}
|
|
15092
|
-
assert(logger$
|
|
15079
|
+
assert(logger$4b, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
|
|
15093
15080
|
return {
|
|
15094
15081
|
lineIndex: lineBreaks.length,
|
|
15095
15082
|
lineBreaks
|
|
@@ -23862,7 +23849,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23862
23849
|
const Graphemer_1 = __importDefault(Graphemer$1);
|
|
23863
23850
|
var _default = lib$1.default = Graphemer_1.default;
|
|
23864
23851
|
const splitter = new _default();
|
|
23865
|
-
const logger$
|
|
23852
|
+
const logger$4a = getLogger("text-offset");
|
|
23866
23853
|
function getChildOffset(block, child) {
|
|
23867
23854
|
const children = getTextBlockContentChildren(block);
|
|
23868
23855
|
let start = 0;
|
|
@@ -23878,26 +23865,26 @@ var __publicField = (obj, key, value) => {
|
|
|
23878
23865
|
}
|
|
23879
23866
|
start += testLength;
|
|
23880
23867
|
}
|
|
23881
|
-
assert(logger$
|
|
23868
|
+
assert(logger$4a, false, "can not find child in children");
|
|
23882
23869
|
}
|
|
23883
23870
|
function isValidOffset(block, blockOffset) {
|
|
23884
|
-
assert(logger$
|
|
23871
|
+
assert(logger$4a, blockOffset >= 0, `invalid offset: ${blockOffset}`);
|
|
23885
23872
|
const childInfo = getTextBlockChild(block, blockOffset);
|
|
23886
23873
|
const { prev, next: next2, offset } = childInfo;
|
|
23887
23874
|
if (!prev && !next2) {
|
|
23888
|
-
assert(logger$
|
|
23875
|
+
assert(logger$4a, false, "invalid offset, no prev & next child at offset");
|
|
23889
23876
|
}
|
|
23890
23877
|
if (prev !== next2) {
|
|
23891
23878
|
return true;
|
|
23892
23879
|
}
|
|
23893
23880
|
const child = prev;
|
|
23894
|
-
assert(logger$
|
|
23881
|
+
assert(logger$4a, child, "no child");
|
|
23895
23882
|
if (isTextBlockContentBoxChild(child)) {
|
|
23896
|
-
assert(logger$
|
|
23883
|
+
assert(logger$4a, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
|
|
23897
23884
|
return true;
|
|
23898
23885
|
}
|
|
23899
23886
|
const text2 = child.textContent;
|
|
23900
|
-
assert(logger$
|
|
23887
|
+
assert(logger$4a, text2, "no content for text child");
|
|
23901
23888
|
const chars = splitter.splitGraphemes(text2);
|
|
23902
23889
|
const validOffsets = /* @__PURE__ */ new Set();
|
|
23903
23890
|
let start = 0;
|
|
@@ -23927,7 +23914,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23927
23914
|
}
|
|
23928
23915
|
function getNextValidOffset(block, blockOffset) {
|
|
23929
23916
|
const length = getTextBlockLength(block);
|
|
23930
|
-
assert(logger$
|
|
23917
|
+
assert(logger$4a, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
|
|
23931
23918
|
if (blockOffset === length) {
|
|
23932
23919
|
return length;
|
|
23933
23920
|
}
|
|
@@ -23941,7 +23928,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23941
23928
|
}
|
|
23942
23929
|
return ret;
|
|
23943
23930
|
}
|
|
23944
|
-
const logger$
|
|
23931
|
+
const logger$49 = getLogger("line-offset");
|
|
23945
23932
|
function getLineOffsets(block) {
|
|
23946
23933
|
const lineBreaks = getLineBreaks(block);
|
|
23947
23934
|
const ret = [];
|
|
@@ -23962,7 +23949,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23962
23949
|
}
|
|
23963
23950
|
function getLineOffset(block, lineIndex) {
|
|
23964
23951
|
const lines = getLineOffsets(block);
|
|
23965
|
-
assert(logger$
|
|
23952
|
+
assert(logger$49, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
|
|
23966
23953
|
return lines[lineIndex];
|
|
23967
23954
|
}
|
|
23968
23955
|
function getLineOffsetByPos(block, pos) {
|
|
@@ -24019,7 +24006,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24019
24006
|
function getLineCount(block) {
|
|
24020
24007
|
return getLineOffsets(block).length;
|
|
24021
24008
|
}
|
|
24022
|
-
const logger$
|
|
24009
|
+
const logger$48 = getLogger("find-text-position");
|
|
24023
24010
|
function isWrappedLine(block, lineIndex) {
|
|
24024
24011
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24025
24012
|
const blockId = getBlockId(block);
|
|
@@ -24030,13 +24017,13 @@ var __publicField = (obj, key, value) => {
|
|
|
24030
24017
|
return false;
|
|
24031
24018
|
}
|
|
24032
24019
|
const childInfo = getTextBlockChild(block, start);
|
|
24033
|
-
assert(logger$
|
|
24034
|
-
assert(logger$
|
|
24020
|
+
assert(logger$48, childInfo.next, "no next child at offset");
|
|
24021
|
+
assert(logger$48, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
|
|
24035
24022
|
return true;
|
|
24036
24023
|
}
|
|
24037
24024
|
function getWrappedLineOffsets(block, lineIndex) {
|
|
24038
24025
|
const blockId = getBlockId(block);
|
|
24039
|
-
assert(logger$
|
|
24026
|
+
assert(logger$48, isWrappedLine(block, lineIndex), "line is not wrapped");
|
|
24040
24027
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24041
24028
|
const homePos = createSimpleBlockPosition(blockId, start, "home");
|
|
24042
24029
|
for (let offset = start + 1; offset <= end; offset += 1) {
|
|
@@ -24051,11 +24038,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24051
24038
|
return offset - 1;
|
|
24052
24039
|
}
|
|
24053
24040
|
}
|
|
24054
|
-
assert(logger$
|
|
24041
|
+
assert(logger$48, false, "failed to find wrapped offset");
|
|
24055
24042
|
return 0;
|
|
24056
24043
|
}
|
|
24057
24044
|
function findTextPositionInLine(editor, block, lineIndex, sourceBlock, pos, findDirection, suggestedX) {
|
|
24058
|
-
assert(logger$
|
|
24045
|
+
assert(logger$48, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
|
|
24059
24046
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24060
24047
|
let from = start;
|
|
24061
24048
|
const blockId = getBlockId(block);
|
|
@@ -24097,11 +24084,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24097
24084
|
return retPos;
|
|
24098
24085
|
}
|
|
24099
24086
|
function findPrevTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
|
|
24100
|
-
assert(logger$
|
|
24087
|
+
assert(logger$48, isTextKindBlock(editor, block), "not a text block");
|
|
24101
24088
|
return findTextPositionInLine(editor, block, getLineCount(block) - 1, sourceBlock, pos, "up", suggestedX);
|
|
24102
24089
|
}
|
|
24103
24090
|
function findNextTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
|
|
24104
|
-
assert(logger$
|
|
24091
|
+
assert(logger$48, isTextKindBlock(editor, block), "not a text block");
|
|
24105
24092
|
return findTextPositionInLine(editor, block, 0, sourceBlock, pos, "down", suggestedX);
|
|
24106
24093
|
}
|
|
24107
24094
|
function moveDown(editor, block, position, suggestedX) {
|
|
@@ -24209,7 +24196,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24209
24196
|
}
|
|
24210
24197
|
return pos;
|
|
24211
24198
|
}
|
|
24212
|
-
const logger$
|
|
24199
|
+
const logger$47 = getLogger("move-caret");
|
|
24213
24200
|
function moveTextCaret(editor, block, position, direction) {
|
|
24214
24201
|
if (direction === "ArrowLeft") {
|
|
24215
24202
|
const ret = moveLeft(block, position);
|
|
@@ -24239,9 +24226,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24239
24226
|
}
|
|
24240
24227
|
return createSimpleBlockPosition(getBlockId(block), ret.offset, ret.type);
|
|
24241
24228
|
}
|
|
24242
|
-
assert(logger$
|
|
24229
|
+
assert(logger$47, false, `invalid navigation direction: ${direction}`);
|
|
24243
24230
|
}
|
|
24244
|
-
const logger$
|
|
24231
|
+
const logger$46 = getLogger("text-range");
|
|
24245
24232
|
function getBlockRects(block) {
|
|
24246
24233
|
const ret = [];
|
|
24247
24234
|
const children = getTextBlockContentChildren(block);
|
|
@@ -24299,9 +24286,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24299
24286
|
return null;
|
|
24300
24287
|
}
|
|
24301
24288
|
const children = getTextBlockContentChildren(block);
|
|
24302
|
-
assert(logger$
|
|
24289
|
+
assert(logger$46, children.indexOf(child) !== -1, "failed to find child in children");
|
|
24303
24290
|
const offsetInfo = getChildOffset(block, child);
|
|
24304
|
-
assert(logger$
|
|
24291
|
+
assert(logger$46, offsetInfo, "failed to get child offset");
|
|
24305
24292
|
const { start } = offsetInfo;
|
|
24306
24293
|
let offset;
|
|
24307
24294
|
let length;
|
|
@@ -24317,7 +24304,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24317
24304
|
}
|
|
24318
24305
|
length = 0;
|
|
24319
24306
|
} else {
|
|
24320
|
-
assert(logger$
|
|
24307
|
+
assert(logger$46, child.firstChild instanceof Text, "child is not text");
|
|
24321
24308
|
offset = start + textNodeOffsetFromPoint(child.firstChild, x, y);
|
|
24322
24309
|
length = 0;
|
|
24323
24310
|
}
|
|
@@ -24341,9 +24328,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24341
24328
|
}
|
|
24342
24329
|
return new EditorSimpleSelectionRange(editor, { anchor: startPos, focus: endPos != null ? endPos : startPos });
|
|
24343
24330
|
}
|
|
24344
|
-
const logger$
|
|
24331
|
+
const logger$45 = getLogger("create-text-op");
|
|
24345
24332
|
function createTextOp(text2, attributes) {
|
|
24346
|
-
assert(logger$
|
|
24333
|
+
assert(logger$45, text2, "text is empty");
|
|
24347
24334
|
const ret = {
|
|
24348
24335
|
insert: text2
|
|
24349
24336
|
};
|
|
@@ -24366,7 +24353,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24366
24353
|
}
|
|
24367
24354
|
return result;
|
|
24368
24355
|
}
|
|
24369
|
-
const logger$
|
|
24356
|
+
const logger$44 = getLogger("merge-ops");
|
|
24370
24357
|
function mergeOps(text2) {
|
|
24371
24358
|
if (text2.length <= 1) {
|
|
24372
24359
|
return text2;
|
|
@@ -24388,10 +24375,10 @@ var __publicField = (obj, key, value) => {
|
|
|
24388
24375
|
return false;
|
|
24389
24376
|
}
|
|
24390
24377
|
if (op1.attributes === void 0) {
|
|
24391
|
-
assert(logger$
|
|
24378
|
+
assert(logger$44, op2.attributes === void 0, "op2.attributes is not undefined");
|
|
24392
24379
|
return true;
|
|
24393
24380
|
}
|
|
24394
|
-
assert(logger$
|
|
24381
|
+
assert(logger$44, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
|
|
24395
24382
|
return isEqual__default.default(op1.attributes, op2.attributes);
|
|
24396
24383
|
};
|
|
24397
24384
|
const newOps = [];
|
|
@@ -24400,8 +24387,8 @@ var __publicField = (obj, key, value) => {
|
|
|
24400
24387
|
for (let i = 1; i < text2.length; i += 1) {
|
|
24401
24388
|
const op = text2[i];
|
|
24402
24389
|
if (isSameTypeOp(before, op)) {
|
|
24403
|
-
assert(logger$
|
|
24404
|
-
assert(logger$
|
|
24390
|
+
assert(logger$44, typeof before.insert === "string", "before.insert is not string");
|
|
24391
|
+
assert(logger$44, typeof op.insert === "string", "op.insert is not string");
|
|
24405
24392
|
before.insert += op.insert;
|
|
24406
24393
|
} else {
|
|
24407
24394
|
newOps.push(op);
|
|
@@ -24429,15 +24416,15 @@ var __publicField = (obj, key, value) => {
|
|
|
24429
24416
|
}
|
|
24430
24417
|
return text2.slice(0, i + 1);
|
|
24431
24418
|
}
|
|
24432
|
-
const logger$
|
|
24419
|
+
const logger$43 = getLogger("delete-text");
|
|
24433
24420
|
function deleteText(richText2, offset, count) {
|
|
24434
24421
|
const { left, right } = splitToThree(richText2, offset, count);
|
|
24435
24422
|
const result = [...left, ...right];
|
|
24436
24423
|
return mergeOps(result);
|
|
24437
24424
|
}
|
|
24438
24425
|
function createDeleteOps(offset, count) {
|
|
24439
|
-
assert(logger$
|
|
24440
|
-
assert(logger$
|
|
24426
|
+
assert(logger$43, offset >= 0, `invalid offset: ${offset}`);
|
|
24427
|
+
assert(logger$43, count >= 1, `invalid delete count: ${count}`);
|
|
24441
24428
|
const ops = [];
|
|
24442
24429
|
if (offset !== 0) {
|
|
24443
24430
|
ops.push({
|
|
@@ -24449,7 +24436,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24449
24436
|
});
|
|
24450
24437
|
return ops;
|
|
24451
24438
|
}
|
|
24452
|
-
const logger$
|
|
24439
|
+
const logger$42 = getLogger("delta");
|
|
24453
24440
|
function diffRichText(oldText, newText) {
|
|
24454
24441
|
const delta1D = new Delta__default.default(oldText);
|
|
24455
24442
|
const delta2D = new Delta__default.default(newText);
|
|
@@ -24459,7 +24446,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24459
24446
|
return new Delta__default.default(ops).transformPosition(cursor, !isLocalOp);
|
|
24460
24447
|
}
|
|
24461
24448
|
function isValidDocText(text2) {
|
|
24462
|
-
assert(logger$
|
|
24449
|
+
assert(logger$42, text2, "ops is null or undefined");
|
|
24463
24450
|
for (let i = 0; i < text2.length; i++) {
|
|
24464
24451
|
const op = text2[i];
|
|
24465
24452
|
if (op.insert === null || op.insert === void 0) {
|
|
@@ -24479,7 +24466,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24479
24466
|
}
|
|
24480
24467
|
class RichText {
|
|
24481
24468
|
static ensureValidText(text2) {
|
|
24482
|
-
assert(logger$
|
|
24469
|
+
assert(logger$42, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
|
|
24483
24470
|
}
|
|
24484
24471
|
static diff(oldText, newText) {
|
|
24485
24472
|
this.ensureValidText(oldText);
|
|
@@ -24501,9 +24488,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24501
24488
|
return resultText;
|
|
24502
24489
|
}
|
|
24503
24490
|
}
|
|
24504
|
-
const logger$
|
|
24491
|
+
const logger$41 = getLogger("insert-text");
|
|
24505
24492
|
function insertText(richText2, offset, text2, attributes) {
|
|
24506
|
-
assert(logger$
|
|
24493
|
+
assert(logger$41, text2, `invalid text to insert: ${text2}`);
|
|
24507
24494
|
const { left, right } = splitText(richText2, offset);
|
|
24508
24495
|
const insertedText = typeof text2 === "string" ? [createTextOp(text2, attributes)] : text2;
|
|
24509
24496
|
const result = [...left, ...insertedText, ...right];
|
|
@@ -24516,7 +24503,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24516
24503
|
};
|
|
24517
24504
|
}
|
|
24518
24505
|
function createInsertOps(offset, text2, attributes) {
|
|
24519
|
-
assert(logger$
|
|
24506
|
+
assert(logger$41, offset >= 0, `invalid offset: ${offset}`);
|
|
24520
24507
|
if (text2.length === 0) {
|
|
24521
24508
|
return [];
|
|
24522
24509
|
}
|
|
@@ -24546,7 +24533,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24546
24533
|
function cloneText(text2) {
|
|
24547
24534
|
return cloneDeep__default.default(text2);
|
|
24548
24535
|
}
|
|
24549
|
-
const logger$
|
|
24536
|
+
const logger$40 = getLogger("update-op-attribute");
|
|
24550
24537
|
function updateOpAttributes(orgOps, key, value, newAttributes) {
|
|
24551
24538
|
const ops = cloneText(orgOps);
|
|
24552
24539
|
const index2 = ops.findIndex((op2) => {
|
|
@@ -24554,7 +24541,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24554
24541
|
return false;
|
|
24555
24542
|
return op2.attributes[key] === value;
|
|
24556
24543
|
});
|
|
24557
|
-
assert(logger$
|
|
24544
|
+
assert(logger$40, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
|
|
24558
24545
|
const op = ops[index2];
|
|
24559
24546
|
op.attributes = {
|
|
24560
24547
|
...op.attributes,
|
|
@@ -24636,11 +24623,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24636
24623
|
]);
|
|
24637
24624
|
}
|
|
24638
24625
|
const FILL_CHAR = "\u200B";
|
|
24639
|
-
const logger$
|
|
24626
|
+
const logger$3$ = getLogger("to-plain-text");
|
|
24640
24627
|
function toPlainText(ops, options) {
|
|
24641
24628
|
let text2 = "";
|
|
24642
24629
|
ops.forEach((op) => {
|
|
24643
|
-
assert(logger$
|
|
24630
|
+
assert(logger$3$, typeof op.insert === "string", "invalid op");
|
|
24644
24631
|
if (op.attributes && op.attributes.box === true) {
|
|
24645
24632
|
if (options == null ? void 0 : options.boxReplacement) {
|
|
24646
24633
|
text2 += options.boxReplacement;
|
|
@@ -24695,11 +24682,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24695
24682
|
focus: pos
|
|
24696
24683
|
};
|
|
24697
24684
|
}
|
|
24698
|
-
const logger$
|
|
24685
|
+
const logger$3_ = getLogger("block-to-text");
|
|
24699
24686
|
function textBlockToText$1(editor, ops, doc2) {
|
|
24700
24687
|
let text2 = "";
|
|
24701
24688
|
ops.forEach((op) => {
|
|
24702
|
-
assert(logger$
|
|
24689
|
+
assert(logger$3_, typeof op.insert === "string", "invalid op");
|
|
24703
24690
|
if (op.attributes && op.attributes.box === true) {
|
|
24704
24691
|
const box = op.attributes;
|
|
24705
24692
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -24717,11 +24704,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24717
24704
|
});
|
|
24718
24705
|
return text2;
|
|
24719
24706
|
}
|
|
24720
|
-
const logger$
|
|
24707
|
+
const logger$3Z = getLogger("block-to-text");
|
|
24721
24708
|
function textToMarkdownText(editor, ops, doc2) {
|
|
24722
24709
|
let text2 = "";
|
|
24723
24710
|
ops.forEach((op) => {
|
|
24724
|
-
assert(logger$
|
|
24711
|
+
assert(logger$3Z, typeof op.insert === "string", "invalid op");
|
|
24725
24712
|
if (op.attributes && op.attributes.box === true) {
|
|
24726
24713
|
const box = op.attributes;
|
|
24727
24714
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -24844,12 +24831,12 @@ var __publicField = (obj, key, value) => {
|
|
|
24844
24831
|
return void 0;
|
|
24845
24832
|
}
|
|
24846
24833
|
}
|
|
24847
|
-
const logger$
|
|
24834
|
+
const logger$3Y = getLogger("block-to-text");
|
|
24848
24835
|
function textBlockToHtml(editor, blockData, doc2) {
|
|
24849
24836
|
let html = "";
|
|
24850
24837
|
const ops = blockData.text || [];
|
|
24851
24838
|
ops.forEach((op) => {
|
|
24852
|
-
assert(logger$
|
|
24839
|
+
assert(logger$3Y, typeof op.insert === "string", "invalid op");
|
|
24853
24840
|
if (op.attributes && op.attributes.box === true) {
|
|
24854
24841
|
const box = op.attributes;
|
|
24855
24842
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -24925,16 +24912,16 @@ var __publicField = (obj, key, value) => {
|
|
|
24925
24912
|
}
|
|
24926
24913
|
return `<p>${html}</p>`;
|
|
24927
24914
|
}
|
|
24928
|
-
const logger$
|
|
24915
|
+
const logger$3X = getLogger("text-block");
|
|
24929
24916
|
function createBlockContent$5(editor, path, container, blockElement, blockData) {
|
|
24930
24917
|
const { text: text2 } = blockData;
|
|
24931
|
-
assert(logger$
|
|
24918
|
+
assert(logger$3X, text2, "no text for text block");
|
|
24932
24919
|
const content = createBlockContentElement(blockElement, "div");
|
|
24933
24920
|
updateBlockContent$1(editor, path, blockData.id, content, text2);
|
|
24934
24921
|
return content;
|
|
24935
24922
|
}
|
|
24936
24923
|
function updateBlockText$1(editor, block, text2) {
|
|
24937
|
-
assert(logger$
|
|
24924
|
+
assert(logger$3X, text2, "no text to update");
|
|
24938
24925
|
const newContent = createBlockContentElement(null, "div");
|
|
24939
24926
|
updateBlockContent$1(editor, getBlockPath(block), getBlockId(block), newContent, text2);
|
|
24940
24927
|
const oldContent = getBlockContent(block);
|
|
@@ -24944,7 +24931,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24944
24931
|
return getRangeClientRects(editor, block, range);
|
|
24945
24932
|
}
|
|
24946
24933
|
function convertTo$k(editor, blockData, doc2, type) {
|
|
24947
|
-
assert(logger$
|
|
24934
|
+
assert(logger$3X, blockData.text, "no text for text block");
|
|
24948
24935
|
if (type === "text") {
|
|
24949
24936
|
return textBlockToText$1(editor, blockData.text, doc2);
|
|
24950
24937
|
}
|
|
@@ -24958,7 +24945,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24958
24945
|
blockData.id = genId();
|
|
24959
24946
|
info == null ? void 0 : info.blockIdMap.set(srcBlockData.id, blockData.id);
|
|
24960
24947
|
const { text: text2 } = blockData;
|
|
24961
|
-
assert(logger$
|
|
24948
|
+
assert(logger$3X, text2, "no text for text block");
|
|
24962
24949
|
text2.forEach((op) => {
|
|
24963
24950
|
if (op.insert && op.attributes && op.attributes.box === true) {
|
|
24964
24951
|
const boxId = genId();
|
|
@@ -24990,7 +24977,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24990
24977
|
blockToDoc: blockToDoc$1
|
|
24991
24978
|
};
|
|
24992
24979
|
const updateTextBlockContent = updateBlockContent$1;
|
|
24993
|
-
const logger$
|
|
24980
|
+
const logger$3W = getLogger("action-helper");
|
|
24994
24981
|
function editorGetBlockData(editor, block) {
|
|
24995
24982
|
const container = getParentContainer(block);
|
|
24996
24983
|
const containerId = getContainerId(container);
|
|
@@ -24998,10 +24985,10 @@ var __publicField = (obj, key, value) => {
|
|
|
24998
24985
|
return editor.doc.getBlockData(containerId, blockIndex);
|
|
24999
24986
|
}
|
|
25000
24987
|
function editorGetBlockText(editor, block) {
|
|
25001
|
-
assert(logger$
|
|
24988
|
+
assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
|
|
25002
24989
|
const data2 = editorGetBlockData(editor, block);
|
|
25003
24990
|
const text2 = data2.text;
|
|
25004
|
-
assert(logger$
|
|
24991
|
+
assert(logger$3W, text2, "no text in block");
|
|
25005
24992
|
return text2;
|
|
25006
24993
|
}
|
|
25007
24994
|
function editorGetBlockTextEx(editor, block, length) {
|
|
@@ -25009,7 +24996,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25009
24996
|
}
|
|
25010
24997
|
function editorGetBoxData(editor, box) {
|
|
25011
24998
|
const block = getParentBlock(box);
|
|
25012
|
-
assert(logger$
|
|
24999
|
+
assert(logger$3W, block, "no parent block");
|
|
25013
25000
|
const text2 = editorGetBlockText(editor, block);
|
|
25014
25001
|
const id = getBoxId(box);
|
|
25015
25002
|
const op = text2.find((op2) => {
|
|
@@ -25019,60 +25006,60 @@ var __publicField = (obj, key, value) => {
|
|
|
25019
25006
|
}
|
|
25020
25007
|
return false;
|
|
25021
25008
|
});
|
|
25022
|
-
assert(logger$
|
|
25009
|
+
assert(logger$3W, op, "failed to find box");
|
|
25023
25010
|
return op.attributes;
|
|
25024
25011
|
}
|
|
25025
|
-
const logger$
|
|
25012
|
+
const logger$3V = getLogger("block-text");
|
|
25026
25013
|
function getTextAfterOffset(editor, block, offset) {
|
|
25027
|
-
assert(logger$
|
|
25028
|
-
assert(logger$
|
|
25029
|
-
assert(logger$
|
|
25014
|
+
assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
|
|
25015
|
+
assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
|
|
25016
|
+
assert(logger$3V, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25030
25017
|
const newOffset = getNextValidOffset(block, offset);
|
|
25031
25018
|
const length = newOffset - offset;
|
|
25032
25019
|
if (length === 0) {
|
|
25033
|
-
assert(logger$
|
|
25020
|
+
assert(logger$3V, false, `no text after offset: ${offset}`);
|
|
25034
25021
|
}
|
|
25035
25022
|
const text2 = editorGetBlockText(editor, block);
|
|
25036
25023
|
const { middle } = splitToThree(text2, offset, length);
|
|
25037
|
-
assert(logger$
|
|
25024
|
+
assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
|
|
25038
25025
|
const op = middle[0];
|
|
25039
25026
|
if (isBoxOp(op)) {
|
|
25040
25027
|
return " ";
|
|
25041
25028
|
}
|
|
25042
|
-
assert(logger$
|
|
25029
|
+
assert(logger$3V, op.insert.length === 1 || op.insert.length === 2, "invalid op");
|
|
25043
25030
|
return op.insert;
|
|
25044
25031
|
}
|
|
25045
25032
|
function getTextBeforeOffset(editor, block, offset) {
|
|
25046
|
-
assert(logger$
|
|
25047
|
-
assert(logger$
|
|
25048
|
-
assert(logger$
|
|
25033
|
+
assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
|
|
25034
|
+
assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
|
|
25035
|
+
assert(logger$3V, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25049
25036
|
const newOffset = getPrevValidOffset(block, offset);
|
|
25050
25037
|
const length = offset - newOffset;
|
|
25051
25038
|
if (length === 0) {
|
|
25052
|
-
assert(logger$
|
|
25039
|
+
assert(logger$3V, false, `no text before offset: ${offset}`);
|
|
25053
25040
|
}
|
|
25054
25041
|
const text2 = editorGetBlockText(editor, block);
|
|
25055
25042
|
const { middle } = splitToThree(text2, newOffset, length);
|
|
25056
|
-
assert(logger$
|
|
25043
|
+
assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
|
|
25057
25044
|
const op = middle[0];
|
|
25058
25045
|
if (isBoxOp(op)) {
|
|
25059
25046
|
return " ";
|
|
25060
25047
|
}
|
|
25061
|
-
assert(logger$
|
|
25048
|
+
assert(logger$3V, op.insert.length === 1 || op.insert.length === 2, "invalid op");
|
|
25062
25049
|
return op.insert;
|
|
25063
25050
|
}
|
|
25064
25051
|
function getOffsetInfoBefore(editor, block, offset) {
|
|
25065
|
-
assert(logger$
|
|
25066
|
-
assert(logger$
|
|
25067
|
-
assert(logger$
|
|
25052
|
+
assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
|
|
25053
|
+
assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
|
|
25054
|
+
assert(logger$3V, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25068
25055
|
const newOffset = getPrevValidOffset(block, offset);
|
|
25069
25056
|
const length = offset - newOffset;
|
|
25070
25057
|
if (length === 0) {
|
|
25071
|
-
assert(logger$
|
|
25058
|
+
assert(logger$3V, false, `no text before offset: ${offset}`);
|
|
25072
25059
|
}
|
|
25073
25060
|
const text2 = editorGetBlockText(editor, block);
|
|
25074
25061
|
const { middle } = splitToThree(text2, newOffset, length);
|
|
25075
|
-
assert(logger$
|
|
25062
|
+
assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
|
|
25076
25063
|
const op = middle[0];
|
|
25077
25064
|
if (isBoxOp(op)) {
|
|
25078
25065
|
return {
|
|
@@ -25090,17 +25077,17 @@ var __publicField = (obj, key, value) => {
|
|
|
25090
25077
|
};
|
|
25091
25078
|
}
|
|
25092
25079
|
function getOffsetInfoAfter(editor, block, offset) {
|
|
25093
|
-
assert(logger$
|
|
25094
|
-
assert(logger$
|
|
25095
|
-
assert(logger$
|
|
25080
|
+
assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
|
|
25081
|
+
assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
|
|
25082
|
+
assert(logger$3V, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25096
25083
|
const newOffset = getNextValidOffset(block, offset);
|
|
25097
25084
|
const length = newOffset - offset;
|
|
25098
25085
|
if (length === 0) {
|
|
25099
|
-
assert(logger$
|
|
25086
|
+
assert(logger$3V, false, `no text after offset: ${offset}`);
|
|
25100
25087
|
}
|
|
25101
25088
|
const text2 = editorGetBlockText(editor, block);
|
|
25102
25089
|
const { middle } = splitToThree(text2, offset, length);
|
|
25103
|
-
assert(logger$
|
|
25090
|
+
assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
|
|
25104
25091
|
const op = middle[0];
|
|
25105
25092
|
if (isBoxOp(op)) {
|
|
25106
25093
|
return {
|
|
@@ -25164,7 +25151,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25164
25151
|
return null;
|
|
25165
25152
|
}
|
|
25166
25153
|
function findWordLeft(editor, block, offset) {
|
|
25167
|
-
assert(logger$
|
|
25154
|
+
assert(logger$3V, isTextKindBlock(editor, block), "invalid blok type");
|
|
25168
25155
|
if (isEmptyTextBlock(editor, block)) {
|
|
25169
25156
|
return 0;
|
|
25170
25157
|
}
|
|
@@ -25192,7 +25179,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25192
25179
|
return startInfo.offset + startInfo.length;
|
|
25193
25180
|
}
|
|
25194
25181
|
function findWordEnd(editor, block, offset) {
|
|
25195
|
-
assert(logger$
|
|
25182
|
+
assert(logger$3V, isTextKindBlock(editor, block), "invalid blok type");
|
|
25196
25183
|
if (isEmptyTextBlock(editor, block)) {
|
|
25197
25184
|
return 0;
|
|
25198
25185
|
}
|
|
@@ -25219,10 +25206,10 @@ var __publicField = (obj, key, value) => {
|
|
|
25219
25206
|
return getBlockTextLength$6(editor, block);
|
|
25220
25207
|
return startInfo.offset;
|
|
25221
25208
|
}
|
|
25222
|
-
const logger$
|
|
25209
|
+
const logger$3U = getLogger("text-box");
|
|
25223
25210
|
function updateBoxContent$8(editor, boxElement, boxContent, boxData) {
|
|
25224
|
-
assert(logger$
|
|
25225
|
-
assert(logger$
|
|
25211
|
+
assert(logger$3U, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
|
|
25212
|
+
assert(logger$3U, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
|
|
25226
25213
|
createElement("span", [], boxContent, boxData.text);
|
|
25227
25214
|
}
|
|
25228
25215
|
function convertTo$j(editor, boxData, doc2, type) {
|
|
@@ -25256,7 +25243,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25256
25243
|
updateBoxContent: updateBoxContent$7,
|
|
25257
25244
|
convertTo: convertTo$i
|
|
25258
25245
|
};
|
|
25259
|
-
const logger$
|
|
25246
|
+
const logger$3T = getLogger("editor-boxes");
|
|
25260
25247
|
class EditorBoxes {
|
|
25261
25248
|
constructor(editor) {
|
|
25262
25249
|
__publicField(this, "boxes", /* @__PURE__ */ new Map());
|
|
@@ -25265,12 +25252,12 @@ var __publicField = (obj, key, value) => {
|
|
|
25265
25252
|
registerBoxClass(boxClass) {
|
|
25266
25253
|
const type = boxClass.boxType;
|
|
25267
25254
|
const exists = this.boxes.get(type);
|
|
25268
|
-
assert(logger$
|
|
25255
|
+
assert(logger$3T, !exists, `duplicated box type: ${type}`);
|
|
25269
25256
|
this.boxes.set(type, boxClass);
|
|
25270
25257
|
}
|
|
25271
25258
|
getBoxClass(type) {
|
|
25272
25259
|
const exists = this.boxes.get(type);
|
|
25273
|
-
assert(logger$
|
|
25260
|
+
assert(logger$3T, exists, `unknown box type: ${type}`);
|
|
25274
25261
|
return exists;
|
|
25275
25262
|
}
|
|
25276
25263
|
createBox(blockContent, box) {
|
|
@@ -25635,7 +25622,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25635
25622
|
return { classes, attributes: newAttributes, styles: newStyles };
|
|
25636
25623
|
}
|
|
25637
25624
|
}
|
|
25638
|
-
const logger$
|
|
25625
|
+
const logger$3S = getLogger("editor-insertion");
|
|
25639
25626
|
class EditorInsertions {
|
|
25640
25627
|
constructor(editor) {
|
|
25641
25628
|
__publicField(this, "insertions", /* @__PURE__ */ new Map());
|
|
@@ -25644,12 +25631,12 @@ var __publicField = (obj, key, value) => {
|
|
|
25644
25631
|
registerInsertionClass(insertionClass) {
|
|
25645
25632
|
const type = insertionClass.insertionType;
|
|
25646
25633
|
const exists = this.insertions.get(type);
|
|
25647
|
-
assert(logger$
|
|
25634
|
+
assert(logger$3S, !exists, `duplicated insertion type: ${type}`);
|
|
25648
25635
|
this.insertions.set(type, insertionClass);
|
|
25649
25636
|
}
|
|
25650
25637
|
getInsertionClass(type) {
|
|
25651
25638
|
const exists = this.insertions.get(type);
|
|
25652
|
-
assert(logger$
|
|
25639
|
+
assert(logger$3S, exists, `unknown insertion type: ${type}`);
|
|
25653
25640
|
return exists;
|
|
25654
25641
|
}
|
|
25655
25642
|
createInsertionElement(type, id, attributes) {
|
|
@@ -25769,7 +25756,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25769
25756
|
};
|
|
25770
25757
|
}
|
|
25771
25758
|
}
|
|
25772
|
-
const logger$
|
|
25759
|
+
const logger$3R = getLogger("editor-input");
|
|
25773
25760
|
class EditorInput$1 {
|
|
25774
25761
|
constructor(editor, callbacks) {
|
|
25775
25762
|
__publicField(this, "editor");
|
|
@@ -25891,7 +25878,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25891
25878
|
return;
|
|
25892
25879
|
}
|
|
25893
25880
|
this.callbacks.onCut(event);
|
|
25894
|
-
logger$
|
|
25881
|
+
logger$3R.debug("on cut");
|
|
25895
25882
|
});
|
|
25896
25883
|
__publicField(this, "handlePaste", (event) => {
|
|
25897
25884
|
if (event.isTrusted) {
|
|
@@ -26006,11 +25993,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26006
25993
|
this.callbacks.removeHandler(handler);
|
|
26007
25994
|
}
|
|
26008
25995
|
defaultInsertText(editor, containerId, blockIndex, offset, text2) {
|
|
26009
|
-
assert(logger$
|
|
25996
|
+
assert(logger$3R, editor === this.editor, "invalid editor");
|
|
26010
25997
|
this.callbacks.defaultInsertText(editor, containerId, blockIndex, offset, text2);
|
|
26011
25998
|
}
|
|
26012
25999
|
defaultHandleKeydown(editor, event) {
|
|
26013
|
-
assert(logger$
|
|
26000
|
+
assert(logger$3R, editor === this.editor, "invalid editor");
|
|
26014
26001
|
return this.callbacks.defaultHandleKeydown(editor, event);
|
|
26015
26002
|
}
|
|
26016
26003
|
forEach(callback) {
|
|
@@ -26035,7 +26022,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26035
26022
|
input2.style.left = `${x / scale}px`;
|
|
26036
26023
|
input2.style.top = `${y / scale}px`;
|
|
26037
26024
|
}
|
|
26038
|
-
const logger$
|
|
26025
|
+
const logger$3Q = getLogger("editor-caret");
|
|
26039
26026
|
function getFirefoxVersion() {
|
|
26040
26027
|
const userAgent = window.navigator.userAgent;
|
|
26041
26028
|
const match = userAgent.match(/Firefox\/(\d+)\./);
|
|
@@ -26098,11 +26085,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26098
26085
|
return;
|
|
26099
26086
|
}
|
|
26100
26087
|
const { range } = this.editor.selection;
|
|
26101
|
-
assert(logger$
|
|
26088
|
+
assert(logger$3Q, range.isCollapsed, "range is not collapsed");
|
|
26102
26089
|
const pos = range.start;
|
|
26103
|
-
assert(logger$
|
|
26090
|
+
assert(logger$3Q, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
|
|
26104
26091
|
const block = this.editor.getBlockById(pos.blockId);
|
|
26105
|
-
assert(logger$
|
|
26092
|
+
assert(logger$3Q, isTextKindBlock(this.editor, block), "only text kind block can has caret");
|
|
26106
26093
|
let rect;
|
|
26107
26094
|
const compositionSpan = block.querySelector("span.inputting-insertion");
|
|
26108
26095
|
if (compositionSpan) {
|
|
@@ -26140,7 +26127,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26140
26127
|
clearAllSelection(editor);
|
|
26141
26128
|
editor.selection.range.getSelectedBlocks().forEach((s) => updateBlockSelection(editor, s.block, s.start, s.end));
|
|
26142
26129
|
}
|
|
26143
|
-
const logger$
|
|
26130
|
+
const logger$3P = getLogger("editor-dom");
|
|
26144
26131
|
function editorGetClientHeight(editor) {
|
|
26145
26132
|
const scrollContainer = getScrollContainer$1(editor.rootContainer);
|
|
26146
26133
|
return scrollContainer.clientHeight;
|
|
@@ -26228,7 +26215,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26228
26215
|
}
|
|
26229
26216
|
function editorScrollIntoView(editor) {
|
|
26230
26217
|
if (!isElementVisible(editor.rootContainer)) {
|
|
26231
|
-
logger$
|
|
26218
|
+
logger$3P.warn("editorScrollIntoView: editor is not visible");
|
|
26232
26219
|
return;
|
|
26233
26220
|
}
|
|
26234
26221
|
const rootClientRect = editor.rootContainer.getBoundingClientRect();
|
|
@@ -26293,7 +26280,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26293
26280
|
const { start, end } = range;
|
|
26294
26281
|
return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
|
|
26295
26282
|
}
|
|
26296
|
-
const logger$
|
|
26283
|
+
const logger$3O = getLogger("range-in-block");
|
|
26297
26284
|
function rangeInBlock(block, range) {
|
|
26298
26285
|
const editor = range.getEditor();
|
|
26299
26286
|
const start = editor.getBlockById(range.start.blockId);
|
|
@@ -26314,16 +26301,16 @@ var __publicField = (obj, key, value) => {
|
|
|
26314
26301
|
while (prevBlock && !blocks.has(getBlockId(prevBlock))) {
|
|
26315
26302
|
prevBlock = getPrevVisibleBlock(prevBlock);
|
|
26316
26303
|
}
|
|
26317
|
-
assert(logger$
|
|
26304
|
+
assert(logger$3O, prevBlock, "no prev block while deleting a block");
|
|
26318
26305
|
newRange = createBlockSimpleRange(editor, prevBlock, getBlockTextLength$6(editor, prevBlock));
|
|
26319
26306
|
} else {
|
|
26320
26307
|
const nextBlock = getNextVisibleBlock(block);
|
|
26321
|
-
assert(logger$
|
|
26308
|
+
assert(logger$3O, nextBlock, "no prev and next block while deleting a block");
|
|
26322
26309
|
newRange = createBlockSimpleRange(editor, nextBlock, 0);
|
|
26323
26310
|
}
|
|
26324
26311
|
return newRange;
|
|
26325
26312
|
}
|
|
26326
|
-
const logger$
|
|
26313
|
+
const logger$3N = getLogger("block-to-html");
|
|
26327
26314
|
function blockToHtml(editor, blockData, doc2, path) {
|
|
26328
26315
|
const blockClass = getBlockClassByType(editor, blockData.type);
|
|
26329
26316
|
if (blockClass.convertTo) {
|
|
@@ -26332,15 +26319,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26332
26319
|
if (blockClass.blockKind !== "text") {
|
|
26333
26320
|
return `[${blockData.type}]`;
|
|
26334
26321
|
}
|
|
26335
|
-
assert(logger$
|
|
26322
|
+
assert(logger$3N, blockData.text, "no text");
|
|
26336
26323
|
const plainText = toPlainText(blockData.text);
|
|
26337
26324
|
return `<div>${escapeHtmlText(plainText)}</div>`;
|
|
26338
26325
|
}
|
|
26339
|
-
const logger$
|
|
26326
|
+
const logger$3M = getLogger("block-to-text");
|
|
26340
26327
|
function textBlockToText(editor, ops, doc2) {
|
|
26341
26328
|
let text2 = "";
|
|
26342
26329
|
ops.forEach((op) => {
|
|
26343
|
-
assert(logger$
|
|
26330
|
+
assert(logger$3M, typeof op.insert === "string", "invalid op");
|
|
26344
26331
|
if (op.attributes && op.attributes.box === true) {
|
|
26345
26332
|
const box = op.attributes;
|
|
26346
26333
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -26366,7 +26353,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26366
26353
|
if (blockClass.blockKind !== "text") {
|
|
26367
26354
|
return `[${blockData.type}]`;
|
|
26368
26355
|
}
|
|
26369
|
-
assert(logger$
|
|
26356
|
+
assert(logger$3M, blockData.text, "no text");
|
|
26370
26357
|
const plainText = textBlockToText(editor, blockData.text, doc2);
|
|
26371
26358
|
return plainText;
|
|
26372
26359
|
}
|
|
@@ -26399,11 +26386,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26399
26386
|
const markdown = lines.join("\n");
|
|
26400
26387
|
return markdown;
|
|
26401
26388
|
}
|
|
26402
|
-
const logger$
|
|
26389
|
+
const logger$3L = getLogger("get-text-position");
|
|
26403
26390
|
function editorGetTextPosition(editor, insertPos) {
|
|
26404
26391
|
const pos = insertPos != null ? insertPos : editor.selection.range.start;
|
|
26405
26392
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
26406
|
-
assert(logger$
|
|
26393
|
+
assert(logger$3L, false, `invalid insert pos type: ${typeof pos}`);
|
|
26407
26394
|
}
|
|
26408
26395
|
const { blockId } = pos;
|
|
26409
26396
|
const block = editor.getBlockById(blockId);
|
|
@@ -26491,14 +26478,14 @@ var __publicField = (obj, key, value) => {
|
|
|
26491
26478
|
return attributes;
|
|
26492
26479
|
}
|
|
26493
26480
|
}
|
|
26494
|
-
const logger$
|
|
26481
|
+
const logger$3K = getLogger("insert-text");
|
|
26495
26482
|
function getTextAttributes(editor, containerId, blockIndex, offset) {
|
|
26496
26483
|
var _a, _b;
|
|
26497
26484
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26498
|
-
assert(logger$
|
|
26499
|
-
assert(logger$
|
|
26485
|
+
assert(logger$3K, blockData, "no block data");
|
|
26486
|
+
assert(logger$3K, blockData.text, "no block text");
|
|
26500
26487
|
if (getTextLength(blockData.text) === 0) {
|
|
26501
|
-
assert(logger$
|
|
26488
|
+
assert(logger$3K, offset === 0, "invalid text offset");
|
|
26502
26489
|
return BlockAttributesHandler.get(editor).getEmptyBlockTextAttributes(blockData.id);
|
|
26503
26490
|
}
|
|
26504
26491
|
if (offset === 0) {
|
|
@@ -26545,7 +26532,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26545
26532
|
}
|
|
26546
26533
|
for (let i = 0; i < text2.length; i++) {
|
|
26547
26534
|
const op = text2[i];
|
|
26548
|
-
assert(logger$
|
|
26535
|
+
assert(logger$3K, typeof op.insert === "string", "invalid text op, no insert");
|
|
26549
26536
|
const endPos = pos + getOpLength(op);
|
|
26550
26537
|
if (endPos === start) {
|
|
26551
26538
|
return false;
|
|
@@ -26559,8 +26546,8 @@ var __publicField = (obj, key, value) => {
|
|
|
26559
26546
|
}
|
|
26560
26547
|
function editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset) {
|
|
26561
26548
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26562
|
-
assert(logger$
|
|
26563
|
-
assert(logger$
|
|
26549
|
+
assert(logger$3K, blockData, "no block data");
|
|
26550
|
+
assert(logger$3K, blockData.text, "no block text");
|
|
26564
26551
|
const attributes = getTextAttributes(editor, containerId, blockIndex, offset);
|
|
26565
26552
|
if (attributes && Object.keys(attributes).includes("link")) {
|
|
26566
26553
|
const inOp = checkRangeInOp(blockData.text, offset);
|
|
@@ -26579,21 +26566,21 @@ var __publicField = (obj, key, value) => {
|
|
|
26579
26566
|
const { containerId, blockIndex, offset } = editorGetTextPosition(editor);
|
|
26580
26567
|
editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset);
|
|
26581
26568
|
}
|
|
26582
|
-
const logger$
|
|
26569
|
+
const logger$3J = getLogger("update-composition-text");
|
|
26583
26570
|
function editorUpdateCompositionText(editor) {
|
|
26584
26571
|
const pos = editor.selection.range.start;
|
|
26585
26572
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
26586
|
-
assert(logger$
|
|
26573
|
+
assert(logger$3J, false, `invalid insert pos type: ${typeof pos}`);
|
|
26587
26574
|
}
|
|
26588
26575
|
const { blockId } = pos;
|
|
26589
26576
|
const block = editor.getBlockById(blockId);
|
|
26590
|
-
assert(logger$
|
|
26577
|
+
assert(logger$3J, isTextKindBlock(editor, block), "not a text kind block");
|
|
26591
26578
|
const container = getParentContainer(block);
|
|
26592
26579
|
const containerId = getContainerId(container);
|
|
26593
26580
|
const blockIndex = getBlockIndex(block);
|
|
26594
26581
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26595
|
-
assert(logger$
|
|
26596
|
-
assert(logger$
|
|
26582
|
+
assert(logger$3J, blockData, "no block data in doc");
|
|
26583
|
+
assert(logger$3J, blockData.text, "no text data in text block");
|
|
26597
26584
|
const blockContent = getBlockContent(block);
|
|
26598
26585
|
updateBlockContent$1(editor, getBlockPath(block), blockId, blockContent, blockData.text);
|
|
26599
26586
|
}
|
|
@@ -26605,25 +26592,25 @@ var __publicField = (obj, key, value) => {
|
|
|
26605
26592
|
const block = editor.getBlockById(blockData.id);
|
|
26606
26593
|
return block;
|
|
26607
26594
|
}
|
|
26608
|
-
const logger$
|
|
26595
|
+
const logger$3I = getLogger("delete-block-text");
|
|
26609
26596
|
function editorDeleteBlockText(editor, block, offset, count, options) {
|
|
26610
26597
|
if (!editor.isBlockWritable(block)) {
|
|
26611
|
-
logger$
|
|
26598
|
+
logger$3I.error("block is not writable");
|
|
26612
26599
|
return 0;
|
|
26613
26600
|
}
|
|
26614
|
-
assert(logger$
|
|
26601
|
+
assert(logger$3I, isTextKindBlock(editor, block), "block is not a text kind block");
|
|
26615
26602
|
const container = getParentContainer(block);
|
|
26616
26603
|
const containerId = getContainerId(container);
|
|
26617
26604
|
const blockIndex = getBlockIndex(block);
|
|
26618
26605
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26619
|
-
assert(logger$
|
|
26620
|
-
assert(logger$
|
|
26606
|
+
assert(logger$3I, blockData, "no block data in doc");
|
|
26607
|
+
assert(logger$3I, blockData.text, "no text data in text block");
|
|
26621
26608
|
let from = offset;
|
|
26622
26609
|
if (!isValidOffset(block, offset)) {
|
|
26623
26610
|
from = getPrevValidOffset(block, from);
|
|
26624
26611
|
}
|
|
26625
26612
|
let to = offset + count;
|
|
26626
|
-
assert(logger$
|
|
26613
|
+
assert(logger$3I, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
|
|
26627
26614
|
if (!isValidOffset(block, to)) {
|
|
26628
26615
|
to = getNextValidOffset(block, to);
|
|
26629
26616
|
}
|
|
@@ -26632,7 +26619,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26632
26619
|
editor.doc.localUpdateBlockText(containerId, blockIndex, actions2, options);
|
|
26633
26620
|
return deleteCount;
|
|
26634
26621
|
}
|
|
26635
|
-
const logger$
|
|
26622
|
+
const logger$3H = getLogger("break-text-block");
|
|
26636
26623
|
function copyBlockAttributes(editor, block) {
|
|
26637
26624
|
const blockData = editor.getBlockData(block);
|
|
26638
26625
|
const quoted = blockData.quoted;
|
|
@@ -26644,8 +26631,8 @@ var __publicField = (obj, key, value) => {
|
|
|
26644
26631
|
return {};
|
|
26645
26632
|
}
|
|
26646
26633
|
function editorBreakTextBlock(editor, block, offset, options) {
|
|
26647
|
-
assert(logger$
|
|
26648
|
-
assert(logger$
|
|
26634
|
+
assert(logger$3H, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
|
|
26635
|
+
assert(logger$3H, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
26649
26636
|
const container = getParentContainer(block);
|
|
26650
26637
|
const containerId = getContainerId(container);
|
|
26651
26638
|
const blockIndex = getBlockIndex(block);
|
|
@@ -26675,7 +26662,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26675
26662
|
};
|
|
26676
26663
|
}
|
|
26677
26664
|
}
|
|
26678
|
-
assert(logger$
|
|
26665
|
+
assert(logger$3H, isValidOffset(block, offset), "not a valid offset");
|
|
26679
26666
|
const text2 = editorGetBlockText(editor, block);
|
|
26680
26667
|
const { right } = splitText(text2, offset);
|
|
26681
26668
|
const rightLength = getTextLength(right);
|
|
@@ -26701,12 +26688,12 @@ var __publicField = (obj, key, value) => {
|
|
|
26701
26688
|
newBlock
|
|
26702
26689
|
};
|
|
26703
26690
|
}
|
|
26704
|
-
const logger$
|
|
26691
|
+
const logger$3G = getLogger("prepare-insert-new-block");
|
|
26705
26692
|
function editorPrepareInsertNewBlock(editor, containerId, blockIndex) {
|
|
26706
26693
|
if (containerId && blockIndex !== void 0 && blockIndex !== null) {
|
|
26707
26694
|
const container = editor.getContainerById(containerId);
|
|
26708
26695
|
const blocks = getChildBlocks(container);
|
|
26709
|
-
assert(logger$
|
|
26696
|
+
assert(logger$3G, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
|
|
26710
26697
|
return {
|
|
26711
26698
|
containerId,
|
|
26712
26699
|
blockIndex
|
|
@@ -26740,15 +26727,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26740
26727
|
blockIndex: getBlockIndex(newBlock)
|
|
26741
26728
|
};
|
|
26742
26729
|
}
|
|
26743
|
-
const logger$
|
|
26730
|
+
const logger$3F = getLogger("auto-insert-block");
|
|
26744
26731
|
function editorAutoInsertBlock(editor, blockData, containerId, blockIndex, newRange, insertBlockOptions) {
|
|
26745
26732
|
const result = editorPrepareInsertNewBlock(editor, containerId, blockIndex);
|
|
26746
|
-
assert(logger$
|
|
26733
|
+
assert(logger$3F, result, `not an valid insert position: ${editor.selection.range}`);
|
|
26747
26734
|
const defaultPos = { blockId: blockData.id, offset: 0 };
|
|
26748
26735
|
const defaultRange = { anchor: defaultPos, focus: defaultPos };
|
|
26749
26736
|
return editorInsertBlock(editor, result.containerId, result.blockIndex, blockData, newRange != null ? newRange : defaultRange, insertBlockOptions);
|
|
26750
26737
|
}
|
|
26751
|
-
const logger$
|
|
26738
|
+
const logger$3E = getLogger("delete-block");
|
|
26752
26739
|
function getAllChildContainers(editor, blockData, containerIds) {
|
|
26753
26740
|
if (blockData.children) {
|
|
26754
26741
|
containerIds.push(...blockData.children);
|
|
@@ -26765,7 +26752,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26765
26752
|
const containerId = getContainerId(container);
|
|
26766
26753
|
const blockIndex = getBlockIndex(block);
|
|
26767
26754
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26768
|
-
assert(logger$
|
|
26755
|
+
assert(logger$3E, blockData, "no block data in doc");
|
|
26769
26756
|
editor.doc.localDeleteBlock(containerId, blockIndex, createEditorSelectionRange(editor, { anchor: newRange.start, focus: newRange.end }));
|
|
26770
26757
|
return blockData;
|
|
26771
26758
|
}
|
|
@@ -26811,15 +26798,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26811
26798
|
});
|
|
26812
26799
|
editor.doc.localDeleteChildContainers(containerIds);
|
|
26813
26800
|
}
|
|
26814
|
-
const logger$
|
|
26801
|
+
const logger$3D = getLogger("merge-text-block");
|
|
26815
26802
|
function editorMergeTextBlock(editor, block1, block2) {
|
|
26816
|
-
assert(logger$
|
|
26817
|
-
assert(logger$
|
|
26803
|
+
assert(logger$3D, isTextKindBlock(editor, block1), "only text block can be merged");
|
|
26804
|
+
assert(logger$3D, isTextKindBlock(editor, block2), "only text block can be merged");
|
|
26818
26805
|
const data1 = editorGetBlockData(editor, block1);
|
|
26819
26806
|
const data2 = editorGetBlockData(editor, block2);
|
|
26820
26807
|
const text1 = data1.text;
|
|
26821
26808
|
const text2 = data2.text;
|
|
26822
|
-
assert(logger$
|
|
26809
|
+
assert(logger$3D, text1 && text2, "block data has no text");
|
|
26823
26810
|
const container = getParentContainer(block1);
|
|
26824
26811
|
const containerId = getContainerId(container);
|
|
26825
26812
|
const blockIndex = getBlockIndex(block1);
|
|
@@ -26829,15 +26816,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26829
26816
|
editorDeleteBlock(editor, block2, newRange);
|
|
26830
26817
|
return block;
|
|
26831
26818
|
}
|
|
26832
|
-
const logger$
|
|
26819
|
+
const logger$3C = getLogger("clear-selected-contents");
|
|
26833
26820
|
function deleteTextBlockSelection(editor, selectedBlock) {
|
|
26834
|
-
assert(logger$
|
|
26821
|
+
assert(logger$3C, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
|
|
26835
26822
|
const { start, end } = selectedBlock;
|
|
26836
|
-
assert(logger$
|
|
26837
|
-
assert(logger$
|
|
26823
|
+
assert(logger$3C, start.isSimple(), "not a simple block position");
|
|
26824
|
+
assert(logger$3C, end.isSimple(), "not a simple block position");
|
|
26838
26825
|
const startOffset = start.offset;
|
|
26839
26826
|
const endOffset = end.offset;
|
|
26840
|
-
assert(logger$
|
|
26827
|
+
assert(logger$3C, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
|
|
26841
26828
|
if (startOffset === endOffset) {
|
|
26842
26829
|
return;
|
|
26843
26830
|
}
|
|
@@ -26862,7 +26849,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26862
26849
|
return;
|
|
26863
26850
|
}
|
|
26864
26851
|
if (isEmbedBlock(block) || start.isSimple()) {
|
|
26865
|
-
assert(logger$
|
|
26852
|
+
assert(logger$3C, end.isSimple(), "invalid range");
|
|
26866
26853
|
const container = getParentContainer(block);
|
|
26867
26854
|
const blockIndex = getBlockIndex(block);
|
|
26868
26855
|
const newBlock = editor.insertTextBlock("", getContainerId(container), blockIndex);
|
|
@@ -26870,8 +26857,8 @@ var __publicField = (obj, key, value) => {
|
|
|
26870
26857
|
editor.deleteBlock(block);
|
|
26871
26858
|
return;
|
|
26872
26859
|
}
|
|
26873
|
-
assert(logger$
|
|
26874
|
-
assert(logger$
|
|
26860
|
+
assert(logger$3C, isComplexKindBlock(editor, block), "invalid block kind");
|
|
26861
|
+
assert(logger$3C, !start.isSimple() && !end.isSimple(), "invalid range");
|
|
26875
26862
|
complexBlockGetSelectedContainers(editor, block, start, end);
|
|
26876
26863
|
const containers = editor.selection.range.getSelectedContainers();
|
|
26877
26864
|
containers.forEach((container, index2) => {
|
|
@@ -26888,7 +26875,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26888
26875
|
return;
|
|
26889
26876
|
}
|
|
26890
26877
|
const selectedBlocks = range.getSelectedBlocks();
|
|
26891
|
-
assert(logger$
|
|
26878
|
+
assert(logger$3C, selectedBlocks.length > 0, "no selected block");
|
|
26892
26879
|
if (selectedBlocks.length === 1) {
|
|
26893
26880
|
clearOneBlock(editor, selectedBlocks[0]);
|
|
26894
26881
|
return;
|
|
@@ -26896,7 +26883,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26896
26883
|
const firstSelectedBlock = selectedBlocks[0];
|
|
26897
26884
|
const firstBlock = firstSelectedBlock.block;
|
|
26898
26885
|
const container = getParentContainer(firstBlock);
|
|
26899
|
-
assert(logger$
|
|
26886
|
+
assert(logger$3C, selectedBlocks.length > 1, "no selected block");
|
|
26900
26887
|
const lastSelectedBlock = selectedBlocks[selectedBlocks.length - 1];
|
|
26901
26888
|
const lastBlock2 = lastSelectedBlock.block;
|
|
26902
26889
|
if (isTextKindBlock(editor, firstBlock)) {
|
|
@@ -26926,7 +26913,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26926
26913
|
}
|
|
26927
26914
|
const prevBlock = getPrevBlock(firstBlock);
|
|
26928
26915
|
const nextBlock = getNextBlock(lastBlock2);
|
|
26929
|
-
assert(logger$
|
|
26916
|
+
assert(logger$3C, prevBlock || nextBlock, "no prev or next block");
|
|
26930
26917
|
selectedBlocks.forEach((selectedBlock) => editor.deleteBlock(selectedBlock.block));
|
|
26931
26918
|
}
|
|
26932
26919
|
function editorClearSelectedContents(editor, selectionRange) {
|
|
@@ -26945,7 +26932,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26945
26932
|
editor.emit("afterClearSelection", editor);
|
|
26946
26933
|
});
|
|
26947
26934
|
}
|
|
26948
|
-
const logger$
|
|
26935
|
+
const logger$3B = getLogger("core");
|
|
26949
26936
|
function editorUpdateBlockText(editor, block, ops, options) {
|
|
26950
26937
|
const container = getParentContainer(block);
|
|
26951
26938
|
const containerId = getContainerId(container);
|
|
@@ -26958,7 +26945,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26958
26945
|
}
|
|
26959
26946
|
function editorSetBlockText(editor, block, newText, options) {
|
|
26960
26947
|
if (!editor.isBlockWritable(block)) {
|
|
26961
|
-
logger$
|
|
26948
|
+
logger$3B.error("block is not writable");
|
|
26962
26949
|
return;
|
|
26963
26950
|
}
|
|
26964
26951
|
const oldText = editor.getBlockText(block);
|
|
@@ -26971,7 +26958,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26971
26958
|
const ops = RichText.diff(oldText, newText);
|
|
26972
26959
|
return editorUpdateBlockText(editor, block, ops);
|
|
26973
26960
|
}
|
|
26974
|
-
const logger$
|
|
26961
|
+
const logger$3A = getLogger("update-block-data");
|
|
26975
26962
|
function editorUpdateBlockData(editor, block, data2, newRange, options) {
|
|
26976
26963
|
const container = getParentContainer(block);
|
|
26977
26964
|
const containerId = getContainerId(container);
|
|
@@ -26988,17 +26975,17 @@ var __publicField = (obj, key, value) => {
|
|
|
26988
26975
|
if (oldKey === "id" || oldKey === "type" || oldKey === "text") {
|
|
26989
26976
|
return;
|
|
26990
26977
|
}
|
|
26991
|
-
logger$
|
|
26978
|
+
logger$3A.debug(`delete key: ${oldKey}`);
|
|
26992
26979
|
delta.delete.push(oldKey);
|
|
26993
26980
|
}
|
|
26994
26981
|
});
|
|
26995
26982
|
const entries = Object.entries(data2);
|
|
26996
26983
|
entries.forEach(([key, value]) => {
|
|
26997
|
-
assert(logger$
|
|
26984
|
+
assert(logger$3A, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
|
|
26998
26985
|
const oldValue = oldData[key];
|
|
26999
26986
|
if (value === null || value === void 0) {
|
|
27000
26987
|
if (oldValue !== null && oldValue !== void 0) {
|
|
27001
|
-
logger$
|
|
26988
|
+
logger$3A.debug(`delete key: ${key}`);
|
|
27002
26989
|
delta.delete.push(key);
|
|
27003
26990
|
}
|
|
27004
26991
|
return;
|
|
@@ -27016,10 +27003,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27016
27003
|
}
|
|
27017
27004
|
}
|
|
27018
27005
|
if (oldKeys.has(key)) {
|
|
27019
|
-
logger$
|
|
27006
|
+
logger$3A.debug(`replace key: ${key}`);
|
|
27020
27007
|
delta.delete.push(key);
|
|
27021
27008
|
} else {
|
|
27022
|
-
logger$
|
|
27009
|
+
logger$3A.debug(`insert key: ${key}`);
|
|
27023
27010
|
}
|
|
27024
27011
|
delta.insert[key] = value;
|
|
27025
27012
|
});
|
|
@@ -27064,13 +27051,13 @@ var __publicField = (obj, key, value) => {
|
|
|
27064
27051
|
comments: {}
|
|
27065
27052
|
};
|
|
27066
27053
|
}
|
|
27067
|
-
const logger$
|
|
27054
|
+
const logger$3z = getLogger("clone-block");
|
|
27068
27055
|
function cloneBlock(editorBlocks, oldDoc, data2, info) {
|
|
27069
27056
|
var _a;
|
|
27070
27057
|
const blockClass = editorBlocks.getBlockClass(data2.type);
|
|
27071
27058
|
if (blockClass.blockToDoc) {
|
|
27072
27059
|
return blockClass.blockToDoc(oldDoc, data2, (oldDoc2, childBlock) => {
|
|
27073
|
-
assert(logger$
|
|
27060
|
+
assert(logger$3z, data2 !== childBlock, "invalid child block");
|
|
27074
27061
|
return cloneBlock(editorBlocks, oldDoc2, data2, info);
|
|
27075
27062
|
}, info);
|
|
27076
27063
|
}
|
|
@@ -27083,7 +27070,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27083
27070
|
}
|
|
27084
27071
|
const newChildContainerId = genId();
|
|
27085
27072
|
const childBlocks = oldDoc.blocks[oldChildContainerId];
|
|
27086
|
-
assert(logger$
|
|
27073
|
+
assert(logger$3z, Array.isArray(childBlocks), "invalid child blocks");
|
|
27087
27074
|
const newDocs = childBlocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
|
|
27088
27075
|
const newDoc = mergeDocs(newDocs);
|
|
27089
27076
|
const { root: root2, ...childContainersData } = newDoc.blocks;
|
|
@@ -27112,7 +27099,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27112
27099
|
if (key.startsWith(prefix1)) {
|
|
27113
27100
|
const keyContent = key.substring(prefix1.length);
|
|
27114
27101
|
const newKey = `${newContainerId}/${keyContent}`;
|
|
27115
|
-
logger$
|
|
27102
|
+
logger$3z.debug(`replace key: ${key} -> ${newKey}`);
|
|
27116
27103
|
return newKey;
|
|
27117
27104
|
}
|
|
27118
27105
|
}
|
|
@@ -27121,7 +27108,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27121
27108
|
if (key.startsWith(prefix2)) {
|
|
27122
27109
|
const keyContent = key.substring(prefix2.length);
|
|
27123
27110
|
const newKey = `${newContainerId}_${keyContent}`;
|
|
27124
|
-
logger$
|
|
27111
|
+
logger$3z.debug(`replace key: ${key} -> ${newKey}`);
|
|
27125
27112
|
return newKey;
|
|
27126
27113
|
}
|
|
27127
27114
|
}
|
|
@@ -27151,7 +27138,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27151
27138
|
}
|
|
27152
27139
|
function cloneChildContainer(editorBlocks, oldDoc, containerId, info) {
|
|
27153
27140
|
const blocks = oldDoc.blocks[containerId];
|
|
27154
|
-
assert(logger$
|
|
27141
|
+
assert(logger$3z, Array.isArray(blocks), "invalid child blocks");
|
|
27155
27142
|
const newDocs = blocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
|
|
27156
27143
|
const newDoc = mergeDocs(newDocs);
|
|
27157
27144
|
return newDoc;
|
|
@@ -27160,10 +27147,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27160
27147
|
const docs = doc2.blocks.root.map((b) => cloneBlock(editor.editorBlocks, doc2, b, info));
|
|
27161
27148
|
return cloneDeep__default.default(mergeDocs(docs));
|
|
27162
27149
|
}
|
|
27163
|
-
const logger$
|
|
27150
|
+
const logger$3y = getLogger("insert-doc");
|
|
27164
27151
|
function editorInsertDoc(editor, block, offset, insertedDoc, cloneDocResult) {
|
|
27165
27152
|
if (isComplexKindBlock(editor, block)) {
|
|
27166
|
-
logger$
|
|
27153
|
+
logger$3y.warn("failed to insert doc into a complex block");
|
|
27167
27154
|
return;
|
|
27168
27155
|
}
|
|
27169
27156
|
const doc2 = cloneDoc(editor, insertedDoc, cloneDocResult);
|
|
@@ -27197,7 +27184,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27197
27184
|
}
|
|
27198
27185
|
return;
|
|
27199
27186
|
}
|
|
27200
|
-
assert(logger$
|
|
27187
|
+
assert(logger$3y, isTextKindBlock(editor, block), "not a text block");
|
|
27201
27188
|
if (isEmptyTextBlock(editor, block)) {
|
|
27202
27189
|
const blockIndex2 = getBlockIndex(block);
|
|
27203
27190
|
let lastBlock22;
|
|
@@ -27329,11 +27316,11 @@ var __publicField = (obj, key, value) => {
|
|
|
27329
27316
|
editor.deleteBlock(block);
|
|
27330
27317
|
}
|
|
27331
27318
|
}
|
|
27332
|
-
const logger$
|
|
27319
|
+
const logger$3x = getLogger("add-text-attribute");
|
|
27333
27320
|
function editorRemoveTextAttribute(editor, block, range, attributeName) {
|
|
27334
27321
|
const { start, end } = range;
|
|
27335
|
-
assert(logger$
|
|
27336
|
-
assert(logger$
|
|
27322
|
+
assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
27323
|
+
assert(logger$3x, attributeName, "invalid attribute name");
|
|
27337
27324
|
const oldText = editor.getBlockText(block);
|
|
27338
27325
|
const newText = rangeRemoveAttribute(start.offset, end.offset - start.offset, oldText, attributeName, void 0, { ignoreValue: true });
|
|
27339
27326
|
editor.setBlockText(block, newText);
|
|
@@ -27341,8 +27328,8 @@ var __publicField = (obj, key, value) => {
|
|
|
27341
27328
|
}
|
|
27342
27329
|
function editorAddTextAttribute(editor, block, range, attributeName, value) {
|
|
27343
27330
|
const { start, end } = range;
|
|
27344
|
-
assert(logger$
|
|
27345
|
-
assert(logger$
|
|
27331
|
+
assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
27332
|
+
assert(logger$3x, attributeName, "invalid attribute name");
|
|
27346
27333
|
const oldText = editor.getBlockText(block);
|
|
27347
27334
|
const newText = rangeAddAttribute(start.offset, end.offset - start.offset, oldText, attributeName, value);
|
|
27348
27335
|
editor.setBlockText(block, newText);
|
|
@@ -27350,7 +27337,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27350
27337
|
}
|
|
27351
27338
|
function editorSetTextColor(editor, block, range, type, value) {
|
|
27352
27339
|
const { start, end } = range;
|
|
27353
|
-
assert(logger$
|
|
27340
|
+
assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
27354
27341
|
const oldText = editor.getBlockText(block);
|
|
27355
27342
|
const newText = rangeSetTextColor(start.offset, end.offset - start.offset, oldText, type, value);
|
|
27356
27343
|
editor.setBlockText(block, newText);
|
|
@@ -27439,10 +27426,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27439
27426
|
});
|
|
27440
27427
|
return [color, backgroundColor];
|
|
27441
27428
|
}
|
|
27442
|
-
const logger$
|
|
27429
|
+
const logger$3w = getLogger("move-complex-block-position");
|
|
27443
27430
|
function moveComplexBlockPosition(editor, old, type) {
|
|
27444
27431
|
const block = editor.getBlockById(old.blockId);
|
|
27445
|
-
assert(logger$
|
|
27432
|
+
assert(logger$3w, isComplexKindBlock(editor, block), "is not a complex block");
|
|
27446
27433
|
const blockClass = getComplexBlockClass(editor, block);
|
|
27447
27434
|
const focusedContainer = editor.getContainerById(old.childContainerId);
|
|
27448
27435
|
const nextContainer = blockClass.getNextContainer(editor, block, focusedContainer, type, { noWrap: true });
|
|
@@ -27451,24 +27438,24 @@ var __publicField = (obj, key, value) => {
|
|
|
27451
27438
|
}
|
|
27452
27439
|
return createComplexBlockPosition(block, getContainerId(nextContainer));
|
|
27453
27440
|
}
|
|
27454
|
-
const logger$
|
|
27441
|
+
const logger$3v = getLogger("move-simple-block-position");
|
|
27455
27442
|
function getFirstChildBlockInComplexBlock(editor, complexBlock) {
|
|
27456
27443
|
const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
|
|
27457
27444
|
if (containers.length === 0) {
|
|
27458
|
-
logger$
|
|
27445
|
+
logger$3v.warn("complex block has not any child container, not loaded?");
|
|
27459
27446
|
return null;
|
|
27460
27447
|
}
|
|
27461
|
-
assert(logger$
|
|
27448
|
+
assert(logger$3v, containers.length > 0, "complex block has not any child container");
|
|
27462
27449
|
const container = containers[0];
|
|
27463
27450
|
return getFirstChildBlock(container);
|
|
27464
27451
|
}
|
|
27465
27452
|
function getLastChildBlockInComplexBlock(editor, complexBlock) {
|
|
27466
27453
|
const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
|
|
27467
27454
|
if (containers.length === 0) {
|
|
27468
|
-
logger$
|
|
27455
|
+
logger$3v.warn("complex block has not any child container, not loaded?");
|
|
27469
27456
|
return null;
|
|
27470
27457
|
}
|
|
27471
|
-
assert(logger$
|
|
27458
|
+
assert(logger$3v, containers.length > 0, "complex block has not any child container");
|
|
27472
27459
|
const container = containers[containers.length - 1];
|
|
27473
27460
|
return getLastChildBlock(container);
|
|
27474
27461
|
}
|
|
@@ -27513,8 +27500,8 @@ var __publicField = (obj, key, value) => {
|
|
|
27513
27500
|
return null;
|
|
27514
27501
|
}
|
|
27515
27502
|
const parentComplexBlock = getParentBlock(container);
|
|
27516
|
-
assert(logger$
|
|
27517
|
-
assert(logger$
|
|
27503
|
+
assert(logger$3v, parentComplexBlock, "child container has not parent block");
|
|
27504
|
+
assert(logger$3v, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
|
|
27518
27505
|
const nextContainer = getComplexBlockClass(editor, parentComplexBlock).getNextContainer(editor, parentComplexBlock, container, type);
|
|
27519
27506
|
if (nextContainer) {
|
|
27520
27507
|
if (isFindPrev(type)) {
|
|
@@ -27536,7 +27523,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27536
27523
|
return null;
|
|
27537
27524
|
}
|
|
27538
27525
|
const parentBlock = getParentBlock(container);
|
|
27539
|
-
assert(logger$
|
|
27526
|
+
assert(logger$3v, parentBlock, "child container has not parent block");
|
|
27540
27527
|
if (isFindPrev(type)) {
|
|
27541
27528
|
const prev = getPrevBlock(parentBlock);
|
|
27542
27529
|
if (prev) {
|
|
@@ -27591,7 +27578,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27591
27578
|
}
|
|
27592
27579
|
if (!targetBlock) {
|
|
27593
27580
|
if (isComplexKindBlock(editor, block) && complexBlockGetAllChildContainers(editor, block).length === 0) {
|
|
27594
|
-
logger$
|
|
27581
|
+
logger$3v.warn("complex block has not any child container, not loaded?");
|
|
27595
27582
|
targetBlock = direction === "ArrowDown" || direction === "ArrowRight" ? getNextVisibleBlock(block) : getPrevVisibleBlock(block);
|
|
27596
27583
|
}
|
|
27597
27584
|
}
|
|
@@ -27738,10 +27725,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27738
27725
|
editorAdjustSelection(editor, "ArrowUp", "select");
|
|
27739
27726
|
return true;
|
|
27740
27727
|
}
|
|
27741
|
-
const logger$
|
|
27728
|
+
const logger$3u = getLogger("word-offset");
|
|
27742
27729
|
function editorGetWordLeftPos(editor, type) {
|
|
27743
27730
|
const old = editor.selection.range.focus;
|
|
27744
|
-
assert(logger$
|
|
27731
|
+
assert(logger$3u, old.isSimple(), "invalid range type");
|
|
27745
27732
|
const block = editor.getBlockById(old.blockId);
|
|
27746
27733
|
if (isEmptyTextBlock(editor, block)) {
|
|
27747
27734
|
return createSimpleBlockPosition(block, 0, "home");
|
|
@@ -27766,7 +27753,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27766
27753
|
}
|
|
27767
27754
|
function editorGetWordRightPos(editor, type) {
|
|
27768
27755
|
const old = editor.selection.range.focus;
|
|
27769
|
-
assert(logger$
|
|
27756
|
+
assert(logger$3u, old.isSimple(), "invalid range type");
|
|
27770
27757
|
const block = editor.getBlockById(old.blockId);
|
|
27771
27758
|
if (isEmptyTextBlock(editor, block)) {
|
|
27772
27759
|
return createSimpleBlockPosition(block, 0, "end");
|
|
@@ -27878,10 +27865,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27878
27865
|
editor.selection.setSelection(editor.selection.getAnchorPos(), pos);
|
|
27879
27866
|
return true;
|
|
27880
27867
|
}
|
|
27881
|
-
const logger$
|
|
27868
|
+
const logger$3t = getLogger("line-offset");
|
|
27882
27869
|
function editorGetLineHomePos(editor) {
|
|
27883
27870
|
const old = editor.selection.range.focus;
|
|
27884
|
-
assert(logger$
|
|
27871
|
+
assert(logger$3t, old.isSimple(), "invalid range type");
|
|
27885
27872
|
const block = editor.getBlockById(old.blockId);
|
|
27886
27873
|
if (old.offset === 0 || !isTextKindBlock(editor, block)) {
|
|
27887
27874
|
const newPos2 = createSimpleBlockPosition(block, 0, "home");
|
|
@@ -27898,7 +27885,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27898
27885
|
}
|
|
27899
27886
|
function editorGetLineEndPos(editor) {
|
|
27900
27887
|
const old = editor.selection.range.focus;
|
|
27901
|
-
assert(logger$
|
|
27888
|
+
assert(logger$3t, old.isSimple(), "invalid range type");
|
|
27902
27889
|
const block = editor.getBlockById(old.blockId);
|
|
27903
27890
|
if (old.offset === getBlockTextLength$6(editor, block) || !isTextKindBlock(editor, block)) {
|
|
27904
27891
|
const newPos2 = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
|
|
@@ -27998,7 +27985,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27998
27985
|
editorPageDownScroll(editor);
|
|
27999
27986
|
return true;
|
|
28000
27987
|
}
|
|
28001
|
-
const logger$
|
|
27988
|
+
const logger$3s = getLogger("table-scroll");
|
|
28002
27989
|
class DomEventHandler {
|
|
28003
27990
|
constructor(editor, dom, name, handler, data2, options) {
|
|
28004
27991
|
__publicField(this, "handleEvent", (event) => {
|
|
@@ -28030,7 +28017,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28030
28017
|
const existsHandlers = this.handlers.get(element);
|
|
28031
28018
|
if (existsHandlers) {
|
|
28032
28019
|
if (existsHandlers.find((handler) => handler.handler === eventHandler && handler.name === eventName)) {
|
|
28033
|
-
logger$
|
|
28020
|
+
logger$3s.warn(`event has already registered: ${eventName}`);
|
|
28034
28021
|
return;
|
|
28035
28022
|
}
|
|
28036
28023
|
existsHandlers.push(new DomEventHandler(this.editor, element, eventName, eventHandler, data2, options));
|
|
@@ -28140,7 +28127,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28140
28127
|
});
|
|
28141
28128
|
return true;
|
|
28142
28129
|
}
|
|
28143
|
-
const logger$
|
|
28130
|
+
const logger$3r = getLogger("select-all");
|
|
28144
28131
|
function isContainerSelectedAllChildBlocks(container, range) {
|
|
28145
28132
|
const firstBlock = getFirstChildBlock(container);
|
|
28146
28133
|
const lastBlock2 = getLastChildBlock(container);
|
|
@@ -28155,8 +28142,8 @@ var __publicField = (obj, key, value) => {
|
|
|
28155
28142
|
return range.start.blockId === blockId && range.start.childContainerId === getContainerId(first) && range.end.blockId === blockId && range.end.childContainerId === getContainerId(last);
|
|
28156
28143
|
}
|
|
28157
28144
|
function selectComplexBlock(editor, block) {
|
|
28158
|
-
assert(logger$
|
|
28159
|
-
assert(logger$
|
|
28145
|
+
assert(logger$3r, block, "no parent block");
|
|
28146
|
+
assert(logger$3r, isComplexKindBlock(editor, block), "not a complex block");
|
|
28160
28147
|
const containers = getComplexBlockClass(editor, block).getChildContainers(editor, block);
|
|
28161
28148
|
const first = containers[0];
|
|
28162
28149
|
const last = containers[containers.length - 1];
|
|
@@ -28192,13 +28179,13 @@ var __publicField = (obj, key, value) => {
|
|
|
28192
28179
|
selectParentContainer(editor, getFirstChildBlock(editor.rootContainer));
|
|
28193
28180
|
return false;
|
|
28194
28181
|
}
|
|
28195
|
-
assert(logger$
|
|
28182
|
+
assert(logger$3r, !range.isSimple(), "invalid range type");
|
|
28196
28183
|
if (isComplexBlockSelectedAllChildContainer(focusedBlock, range)) {
|
|
28197
28184
|
selectParentContainer(editor, focusedBlock);
|
|
28198
28185
|
return false;
|
|
28199
28186
|
}
|
|
28200
|
-
assert(logger$
|
|
28201
|
-
assert(logger$
|
|
28187
|
+
assert(logger$3r, focusedBlock, "no parent block");
|
|
28188
|
+
assert(logger$3r, isComplexKindBlock(editor, focusedBlock), "not a complex block");
|
|
28202
28189
|
selectComplexBlock(editor, focusedBlock);
|
|
28203
28190
|
return true;
|
|
28204
28191
|
}
|
|
@@ -28234,30 +28221,6 @@ var __publicField = (obj, key, value) => {
|
|
|
28234
28221
|
}
|
|
28235
28222
|
editor.selection.setSelection(newStartPos, newEndPos);
|
|
28236
28223
|
}
|
|
28237
|
-
function editorMoveBlockStart(editor) {
|
|
28238
|
-
const focus = editor.selection.range.focus;
|
|
28239
|
-
const block = editor.getBlockById(focus.blockId);
|
|
28240
|
-
if (!block)
|
|
28241
|
-
return false;
|
|
28242
|
-
if (!isSimpleBlock(editor, block))
|
|
28243
|
-
return false;
|
|
28244
|
-
const newPos = createSimpleBlockPosition(block, 0, "home");
|
|
28245
|
-
editor.selection.setSelection(newPos);
|
|
28246
|
-
editor.selection.updateLastCaretRect();
|
|
28247
|
-
return true;
|
|
28248
|
-
}
|
|
28249
|
-
function editorMoveBlockEnd(editor) {
|
|
28250
|
-
const focus = editor.selection.range.focus;
|
|
28251
|
-
const block = editor.getBlockById(focus.blockId);
|
|
28252
|
-
if (!block)
|
|
28253
|
-
return false;
|
|
28254
|
-
if (!isSimpleBlock(editor, block))
|
|
28255
|
-
return false;
|
|
28256
|
-
const newPos = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
|
|
28257
|
-
editor.selection.setSelection(newPos);
|
|
28258
|
-
editor.selection.updateLastCaretRect();
|
|
28259
|
-
return true;
|
|
28260
|
-
}
|
|
28261
28224
|
function editorFocusToEnd(editor) {
|
|
28262
28225
|
editorSelectEnd(editor);
|
|
28263
28226
|
editor.focus();
|
|
@@ -28337,7 +28300,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28337
28300
|
}
|
|
28338
28301
|
return cloned;
|
|
28339
28302
|
}
|
|
28340
|
-
const logger$
|
|
28303
|
+
const logger$3q = getLogger("selected-block-to-doc");
|
|
28341
28304
|
function appendBlockChildren(editor, data2, doc2) {
|
|
28342
28305
|
if (!data2.children)
|
|
28343
28306
|
return;
|
|
@@ -28358,7 +28321,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28358
28321
|
if (isTextKindBlock(editor, selectedBlock.block)) {
|
|
28359
28322
|
const start = selectedBlock.start;
|
|
28360
28323
|
const end = selectedBlock.end;
|
|
28361
|
-
assert(logger$
|
|
28324
|
+
assert(logger$3q, data2.text, "no block text");
|
|
28362
28325
|
if (start.offset === end.offset) {
|
|
28363
28326
|
return {
|
|
28364
28327
|
blocks: {
|
|
@@ -28392,8 +28355,8 @@ var __publicField = (obj, key, value) => {
|
|
|
28392
28355
|
comments: {}
|
|
28393
28356
|
};
|
|
28394
28357
|
}
|
|
28395
|
-
assert(logger$
|
|
28396
|
-
assert(logger$
|
|
28358
|
+
assert(logger$3q, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
|
|
28359
|
+
assert(logger$3q, data2.children, "no children");
|
|
28397
28360
|
const ret = {
|
|
28398
28361
|
blocks: {
|
|
28399
28362
|
root: [
|
|
@@ -28411,9 +28374,9 @@ var __publicField = (obj, key, value) => {
|
|
|
28411
28374
|
const end = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
|
|
28412
28375
|
return selectedBlockToDoc(editor, { block, start, end });
|
|
28413
28376
|
}
|
|
28414
|
-
const logger$
|
|
28377
|
+
const logger$3p = getLogger("block-to-doc");
|
|
28415
28378
|
function blocksToDoc(editor, blocks) {
|
|
28416
|
-
assert(logger$
|
|
28379
|
+
assert(logger$3p, blocks.length > 0, "invalid params, no blocks");
|
|
28417
28380
|
const docs = blocks.map((b) => blockToDoc(editor, b));
|
|
28418
28381
|
return mergeDocs(docs);
|
|
28419
28382
|
}
|
|
@@ -28433,7 +28396,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28433
28396
|
const newDocs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s));
|
|
28434
28397
|
return mergeDocs(newDocs);
|
|
28435
28398
|
}
|
|
28436
|
-
const logger$
|
|
28399
|
+
const logger$3o = getLogger("ensure-block-visible");
|
|
28437
28400
|
function ensureBlockVisible(editor, block) {
|
|
28438
28401
|
var _a;
|
|
28439
28402
|
while (block) {
|
|
@@ -28443,16 +28406,16 @@ var __publicField = (obj, key, value) => {
|
|
|
28443
28406
|
return;
|
|
28444
28407
|
}
|
|
28445
28408
|
const parentComplexBlock = getParentBlock(container);
|
|
28446
|
-
assert(logger$
|
|
28409
|
+
assert(logger$3o, parentComplexBlock, "no parent block");
|
|
28447
28410
|
const parentComplexBlockClass = getBlockClass(editor, parentComplexBlock);
|
|
28448
28411
|
if (parentComplexBlockClass.isChildContainerVisible && !((_a = parentComplexBlockClass.isChildContainerVisible) == null ? void 0 : _a.call(parentComplexBlockClass, editor, parentComplexBlock, container))) {
|
|
28449
|
-
assert(logger$
|
|
28412
|
+
assert(logger$3o, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
|
|
28450
28413
|
parentComplexBlockClass.showChildContainer(editor, parentComplexBlock, container);
|
|
28451
28414
|
}
|
|
28452
28415
|
block = parentComplexBlock;
|
|
28453
28416
|
}
|
|
28454
28417
|
}
|
|
28455
|
-
const logger$
|
|
28418
|
+
const logger$3n = getLogger("editor-selection");
|
|
28456
28419
|
class EditorSelection {
|
|
28457
28420
|
constructor(editor) {
|
|
28458
28421
|
__publicField(this, "editor");
|
|
@@ -28465,7 +28428,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28465
28428
|
}
|
|
28466
28429
|
const range = this.range;
|
|
28467
28430
|
if (rangeInBlock(deletedBlock, range)) {
|
|
28468
|
-
logger$
|
|
28431
|
+
logger$3n.debug("adjust selection because remote deleted current block");
|
|
28469
28432
|
const newRange = moveSelectionBeforeDeleteBlock(editor, deletedBlock);
|
|
28470
28433
|
this.setRange(newRange, { noScroll: true });
|
|
28471
28434
|
}
|
|
@@ -28590,14 +28553,14 @@ var __publicField = (obj, key, value) => {
|
|
|
28590
28553
|
if (pos.isSimple()) {
|
|
28591
28554
|
const ok = pos.offset >= 0 && pos.offset <= getBlockTextLength$6(this.editor, block);
|
|
28592
28555
|
if (!ok) {
|
|
28593
|
-
assert(logger$
|
|
28556
|
+
assert(logger$3n, false, "invalid block position, out of range");
|
|
28594
28557
|
}
|
|
28595
28558
|
} else {
|
|
28596
28559
|
const childContainerId = pos.childContainerId;
|
|
28597
28560
|
const container = this.editor.getContainerById(childContainerId);
|
|
28598
28561
|
const ok = !!container;
|
|
28599
28562
|
if (!ok) {
|
|
28600
|
-
assert(logger$
|
|
28563
|
+
assert(logger$3n, false, "invalid complex block position, no container found");
|
|
28601
28564
|
}
|
|
28602
28565
|
}
|
|
28603
28566
|
}
|
|
@@ -28658,7 +28621,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28658
28621
|
let container = getParentContainer(block);
|
|
28659
28622
|
while (isChildContainer(container)) {
|
|
28660
28623
|
const parentBlock = getParentBlock(container);
|
|
28661
|
-
assert(logger$
|
|
28624
|
+
assert(logger$3n, parentBlock, "parent block not found");
|
|
28662
28625
|
addClass(parentBlock, "child-focused");
|
|
28663
28626
|
container = getParentContainer(parentBlock);
|
|
28664
28627
|
}
|
|
@@ -28768,15 +28731,15 @@ var __publicField = (obj, key, value) => {
|
|
|
28768
28731
|
editor.undoManager.redo();
|
|
28769
28732
|
return true;
|
|
28770
28733
|
}
|
|
28771
|
-
const logger$
|
|
28734
|
+
const logger$3m = getLogger("delete-text");
|
|
28772
28735
|
function editorDeleteText(editor, type, count, insertPos) {
|
|
28773
28736
|
const pos = insertPos != null ? insertPos : editor.selection.range.start;
|
|
28774
28737
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
28775
|
-
assert(logger$
|
|
28738
|
+
assert(logger$3m, false, `invalid insert pos type: ${typeof pos}`);
|
|
28776
28739
|
}
|
|
28777
28740
|
const { blockId } = pos;
|
|
28778
28741
|
const block = editor.getBlockById(blockId);
|
|
28779
|
-
assert(logger$
|
|
28742
|
+
assert(logger$3m, isTextKindBlock(editor, block), "block is not a text kind block");
|
|
28780
28743
|
let { offset } = pos;
|
|
28781
28744
|
if (type === "backward") {
|
|
28782
28745
|
if (offset - count < 0) {
|
|
@@ -28806,7 +28769,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28806
28769
|
}
|
|
28807
28770
|
return false;
|
|
28808
28771
|
}
|
|
28809
|
-
const logger$
|
|
28772
|
+
const logger$3l = getLogger("handle-backspace");
|
|
28810
28773
|
function tryDeleteEmptyBlock(editor, block) {
|
|
28811
28774
|
if (!isEmptyTextBlock(editor, block)) {
|
|
28812
28775
|
return;
|
|
@@ -28846,7 +28809,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28846
28809
|
}
|
|
28847
28810
|
} else {
|
|
28848
28811
|
tryDeleteEmptyBlock(editor, block);
|
|
28849
|
-
assert(logger$
|
|
28812
|
+
assert(logger$3l, isEmbedBlock(prevBlock), "prev block is not embed block");
|
|
28850
28813
|
editor.selection.selectBlock(prevBlock, 1);
|
|
28851
28814
|
}
|
|
28852
28815
|
} else {
|
|
@@ -28873,7 +28836,6 @@ var __publicField = (obj, key, value) => {
|
|
|
28873
28836
|
editor.deleteBlock(block);
|
|
28874
28837
|
}
|
|
28875
28838
|
}
|
|
28876
|
-
const logger$3l = getLogger("word-offset");
|
|
28877
28839
|
function handleEditorDelete(editor, event) {
|
|
28878
28840
|
if (!editor.selection.range.isCollapsed()) {
|
|
28879
28841
|
editor.clearSelectedContents();
|
|
@@ -28908,130 +28870,6 @@ var __publicField = (obj, key, value) => {
|
|
|
28908
28870
|
editor.deleteBlock(block);
|
|
28909
28871
|
}
|
|
28910
28872
|
}
|
|
28911
|
-
function handleEditorDeleteLeftWord(editor, event) {
|
|
28912
|
-
const old = editor.selection.range.focus;
|
|
28913
|
-
assert(logger$3l, old.isSimple(), "invalid range type");
|
|
28914
|
-
const block = editor.getBlockById(old.blockId);
|
|
28915
|
-
if (!isTextKindBlock(editor, block)) {
|
|
28916
|
-
editor.deleteBlock(block);
|
|
28917
|
-
return true;
|
|
28918
|
-
}
|
|
28919
|
-
if (old.offset === 0) {
|
|
28920
|
-
const matchNonEmptyTextBlockOrOtherBlock = (block2) => {
|
|
28921
|
-
if (!isTextKindBlock(editor, block2))
|
|
28922
|
-
return true;
|
|
28923
|
-
return !isEmptyTextBlock(editor, block2);
|
|
28924
|
-
};
|
|
28925
|
-
const prevBlock = getPrevVisibleBlock(block, matchNonEmptyTextBlockOrOtherBlock);
|
|
28926
|
-
if (!prevBlock)
|
|
28927
|
-
return false;
|
|
28928
|
-
const matchEmptyTextBlock = (block2) => isEmptyTextBlock(editor, block2);
|
|
28929
|
-
const emptyTextBlocks = getBlocksBetween(prevBlock, block, matchEmptyTextBlock);
|
|
28930
|
-
emptyTextBlocks.forEach((b) => {
|
|
28931
|
-
editor.deleteBlock(b);
|
|
28932
|
-
});
|
|
28933
|
-
if (!isTextKindBlock(editor, prevBlock)) {
|
|
28934
|
-
editor.deleteBlock(prevBlock);
|
|
28935
|
-
return true;
|
|
28936
|
-
}
|
|
28937
|
-
const textBlockLen = getBlockTextLength$6(editor, prevBlock);
|
|
28938
|
-
const newOffset2 = findWordLeft(editor, prevBlock, textBlockLen);
|
|
28939
|
-
editor.deleteTextFromBlock(prevBlock, newOffset2, textBlockLen - newOffset2);
|
|
28940
|
-
const currentBlockText = editor.getBlockText(block);
|
|
28941
|
-
editor.insertTextToBlock(prevBlock, newOffset2, currentBlockText);
|
|
28942
|
-
editor.deleteBlock(block);
|
|
28943
|
-
const pos = createSimpleBlockPosition(prevBlock, newOffset2, "normal");
|
|
28944
|
-
editor.selection.setSelection(pos);
|
|
28945
|
-
editor.selection.updateLastCaretRect();
|
|
28946
|
-
return true;
|
|
28947
|
-
}
|
|
28948
|
-
const newOffset = findWordLeft(editor, block, old.offset);
|
|
28949
|
-
const deletedCount = old.offset - newOffset;
|
|
28950
|
-
editor.deleteTextFromBlock(block, newOffset, deletedCount);
|
|
28951
|
-
return true;
|
|
28952
|
-
}
|
|
28953
|
-
function handleEditorDeleteRightWord(editor, event) {
|
|
28954
|
-
const old = editor.selection.range.focus;
|
|
28955
|
-
assert(logger$3l, old.isSimple(), "invalid range type");
|
|
28956
|
-
const block = editor.getBlockById(old.blockId);
|
|
28957
|
-
if (!isTextKindBlock(editor, block)) {
|
|
28958
|
-
editor.deleteBlock(block);
|
|
28959
|
-
return true;
|
|
28960
|
-
}
|
|
28961
|
-
if (old.offset === getTextBlockLength(block)) {
|
|
28962
|
-
const matchNonEmptyTextBlockOrOtherBlock = (block2) => {
|
|
28963
|
-
if (!isTextKindBlock(editor, block2))
|
|
28964
|
-
return true;
|
|
28965
|
-
return !isEmptyTextBlock(editor, block2);
|
|
28966
|
-
};
|
|
28967
|
-
const nextBlock = getNextVisibleBlock(block, matchNonEmptyTextBlockOrOtherBlock);
|
|
28968
|
-
if (!nextBlock)
|
|
28969
|
-
return false;
|
|
28970
|
-
const matchEmptyTextBlock = (block2) => isEmptyTextBlock(editor, block2);
|
|
28971
|
-
const emptyTextBlocks = getBlocksBetween(block, nextBlock, matchEmptyTextBlock);
|
|
28972
|
-
emptyTextBlocks.forEach((b) => {
|
|
28973
|
-
editor.deleteBlock(b);
|
|
28974
|
-
});
|
|
28975
|
-
if (!isTextKindBlock(editor, nextBlock)) {
|
|
28976
|
-
editor.deleteBlock(nextBlock);
|
|
28977
|
-
return true;
|
|
28978
|
-
}
|
|
28979
|
-
const newOffset = findWordEnd(editor, nextBlock, 0);
|
|
28980
|
-
editor.deleteTextFromBlock(nextBlock, 0, newOffset);
|
|
28981
|
-
const nextBlockText = editor.getBlockText(nextBlock);
|
|
28982
|
-
editor.insertTextToBlock(block, old.offset, nextBlockText);
|
|
28983
|
-
editor.deleteBlock(nextBlock);
|
|
28984
|
-
const pos = createSimpleBlockPosition(block, old.offset, "normal");
|
|
28985
|
-
editor.selection.setSelection(pos);
|
|
28986
|
-
editor.selection.updateLastCaretRect();
|
|
28987
|
-
return true;
|
|
28988
|
-
}
|
|
28989
|
-
const endOffset = findWordEnd(editor, block, old.offset);
|
|
28990
|
-
const deletedCount = endOffset - old.offset;
|
|
28991
|
-
editor.deleteTextFromBlock(block, old.offset, deletedCount);
|
|
28992
|
-
return true;
|
|
28993
|
-
}
|
|
28994
|
-
function handleEditorDeleteAfterWords(editor) {
|
|
28995
|
-
const old = editor.selection.range.focus;
|
|
28996
|
-
assert(logger$3l, old.isSimple(), "invalid range type");
|
|
28997
|
-
const block = editor.getBlockById(old.blockId);
|
|
28998
|
-
if (!isTextKindBlock(editor, block)) {
|
|
28999
|
-
editor.deleteBlock(block);
|
|
29000
|
-
return;
|
|
29001
|
-
}
|
|
29002
|
-
const needDeleteCount = getTextBlockLength(block) - old.offset;
|
|
29003
|
-
if (needDeleteCount === 0)
|
|
29004
|
-
return;
|
|
29005
|
-
editor.deleteTextFromBlock(block, old.offset, needDeleteCount);
|
|
29006
|
-
}
|
|
29007
|
-
function handleEditorDeleteRightChar(editor) {
|
|
29008
|
-
const old = editor.selection.range.focus;
|
|
29009
|
-
assert(logger$3l, old.isSimple(), "invalid range type");
|
|
29010
|
-
const block = editor.getBlockById(old.blockId);
|
|
29011
|
-
if (!isTextKindBlock(editor, block)) {
|
|
29012
|
-
editor.deleteBlock(block);
|
|
29013
|
-
return;
|
|
29014
|
-
}
|
|
29015
|
-
if (old.offset === getBlockTextLength$6(editor, block)) {
|
|
29016
|
-
const nextVisibleBlock = getNextVisibleBlock(block);
|
|
29017
|
-
if (!nextVisibleBlock)
|
|
29018
|
-
return;
|
|
29019
|
-
if (!isTextKindBlock(editor, nextVisibleBlock))
|
|
29020
|
-
return;
|
|
29021
|
-
if (isEmptyTextBlock(editor, nextVisibleBlock)) {
|
|
29022
|
-
editor.deleteBlock(nextVisibleBlock);
|
|
29023
|
-
return;
|
|
29024
|
-
}
|
|
29025
|
-
const nextBlockText = editor.getBlockText(nextVisibleBlock);
|
|
29026
|
-
editor.deleteBlock(nextVisibleBlock);
|
|
29027
|
-
editor.insertTextToBlock(block, old.offset, nextBlockText);
|
|
29028
|
-
const pos = createSimpleBlockPosition(block, old.offset, "normal");
|
|
29029
|
-
editor.selection.setSelection(pos);
|
|
29030
|
-
editor.selection.updateLastCaretRect();
|
|
29031
|
-
return;
|
|
29032
|
-
}
|
|
29033
|
-
editorDeleteText(editor, "forward", 1, null);
|
|
29034
|
-
}
|
|
29035
28873
|
function handleEditorEnterEvent$1(editor, event) {
|
|
29036
28874
|
if (isFullSelectedOneComplexBlock(editor)) {
|
|
29037
28875
|
const focusedBlock2 = editor.getFocusedBlock();
|
|
@@ -29253,42 +29091,6 @@ var __publicField = (obj, key, value) => {
|
|
|
29253
29091
|
return true;
|
|
29254
29092
|
});
|
|
29255
29093
|
}
|
|
29256
|
-
function editorHandleDeleteLeftWord(editor, event) {
|
|
29257
|
-
if (editor.readonly || !editor.isWritable()) {
|
|
29258
|
-
return false;
|
|
29259
|
-
}
|
|
29260
|
-
return editor.undoManager.runInGroup(() => {
|
|
29261
|
-
handleEditorDeleteLeftWord(editor);
|
|
29262
|
-
return true;
|
|
29263
|
-
});
|
|
29264
|
-
}
|
|
29265
|
-
function editorHandleDeleteRightWord(editor, event) {
|
|
29266
|
-
if (editor.readonly || !editor.isWritable()) {
|
|
29267
|
-
return false;
|
|
29268
|
-
}
|
|
29269
|
-
return editor.undoManager.runInGroup(() => {
|
|
29270
|
-
handleEditorDeleteRightWord(editor);
|
|
29271
|
-
return true;
|
|
29272
|
-
});
|
|
29273
|
-
}
|
|
29274
|
-
function editorHandleDeleteAfterWords(editor, event) {
|
|
29275
|
-
if (editor.readonly || !editor.isWritable()) {
|
|
29276
|
-
return false;
|
|
29277
|
-
}
|
|
29278
|
-
return editor.undoManager.runInGroup(() => {
|
|
29279
|
-
handleEditorDeleteAfterWords(editor);
|
|
29280
|
-
return true;
|
|
29281
|
-
});
|
|
29282
|
-
}
|
|
29283
|
-
function editorHandleDeleteRightChar(editor, event) {
|
|
29284
|
-
if (editor.readonly || !editor.isWritable()) {
|
|
29285
|
-
return false;
|
|
29286
|
-
}
|
|
29287
|
-
return editor.undoManager.runInGroup(() => {
|
|
29288
|
-
handleEditorDeleteRightChar(editor);
|
|
29289
|
-
return true;
|
|
29290
|
-
});
|
|
29291
|
-
}
|
|
29292
29094
|
function editorHandleBackspace(editor, event) {
|
|
29293
29095
|
if (editor.readonly || !editor.isWritable()) {
|
|
29294
29096
|
return false;
|
|
@@ -29382,10 +29184,6 @@ ${codeText}
|
|
|
29382
29184
|
__proto__: null,
|
|
29383
29185
|
editorHandleEnter,
|
|
29384
29186
|
editorHandleDelete,
|
|
29385
|
-
editorHandleDeleteLeftWord,
|
|
29386
|
-
editorHandleDeleteRightWord,
|
|
29387
|
-
editorHandleDeleteAfterWords,
|
|
29388
|
-
editorHandleDeleteRightChar,
|
|
29389
29187
|
editorHandleBackspace,
|
|
29390
29188
|
editorHandleInsertBr,
|
|
29391
29189
|
editorHandlePastePlainText,
|
|
@@ -29393,39 +29191,6 @@ ${codeText}
|
|
|
29393
29191
|
getSelectedCodeBlockMarkdown,
|
|
29394
29192
|
editorHandleCopyMarkdown
|
|
29395
29193
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
29396
|
-
const MacShortcuts = {
|
|
29397
|
-
"Cmd+ArrowLeft": editorMoveLineHome,
|
|
29398
|
-
"Cmd+ArrowRight": editorMoveLineEnd,
|
|
29399
|
-
"Option+ArrowLeft": editorMoveWordLeft,
|
|
29400
|
-
"Option+ArrowRight": editorMoveWordEnd,
|
|
29401
|
-
"Ctrl+Shift+ArrowLeft": editorSelectWordLeft,
|
|
29402
|
-
"Ctrl+Shift+ArrowRight": editorSelectWordEnd,
|
|
29403
|
-
"Cmd+Shift+ArrowLeft": editorSelectLineHome,
|
|
29404
|
-
"Cmd+Shift+ArrowRight": editorSelectLineEnd,
|
|
29405
|
-
"Ctrl+A": editorMoveBlockStart,
|
|
29406
|
-
"Ctrl+E": editorMoveBlockEnd,
|
|
29407
|
-
"Option+Delete": editorHandleDeleteRightWord,
|
|
29408
|
-
"Option+Backspace": editorHandleDeleteLeftWord,
|
|
29409
|
-
"Ctrl+B": editorMoveLeft,
|
|
29410
|
-
"Ctrl+F": editorMoveRight,
|
|
29411
|
-
"Ctrl+N": editorMoveDown,
|
|
29412
|
-
"Ctrl+P": editorMoveUp,
|
|
29413
|
-
"Ctrl+K": editorHandleDeleteAfterWords,
|
|
29414
|
-
"Ctrl+H": editorHandleBackspace,
|
|
29415
|
-
"Ctrl+D": editorHandleDeleteRightChar
|
|
29416
|
-
};
|
|
29417
|
-
const WinLinuxShortcuts = {
|
|
29418
|
-
"Home": editorMoveLineHome,
|
|
29419
|
-
"End": editorMoveLineEnd,
|
|
29420
|
-
"Shift+Home": editorSelectLineHome,
|
|
29421
|
-
"Shift+End": editorSelectLineEnd,
|
|
29422
|
-
"Ctrl+Delete": editorHandleDeleteRightWord,
|
|
29423
|
-
"Ctrl+Backspace": editorHandleDeleteLeftWord,
|
|
29424
|
-
"Ctrl+ArrowLeft": editorMoveWordLeft,
|
|
29425
|
-
"Ctrl+ArrowRight": editorMoveWordEnd
|
|
29426
|
-
};
|
|
29427
|
-
const isMac = clientType.isMac;
|
|
29428
|
-
const CustomShortcuts = isMac ? MacShortcuts : WinLinuxShortcuts;
|
|
29429
29194
|
const DefaultShortcuts = {
|
|
29430
29195
|
"ArrowDown": editorMoveDown,
|
|
29431
29196
|
"ArrowUp": editorMoveUp,
|
|
@@ -29435,11 +29200,19 @@ ${codeText}
|
|
|
29435
29200
|
"Shift+ArrowUp": editorSelectUp,
|
|
29436
29201
|
"Shift+ArrowLeft": editorSelectLeft,
|
|
29437
29202
|
"Shift+ArrowRight": editorSelectRight,
|
|
29203
|
+
"CtrlOrCmd+ArrowLeft": editorMoveWordLeft,
|
|
29204
|
+
"CtrlOrCmd+ArrowRight": editorMoveWordEnd,
|
|
29205
|
+
"CtrlOrCmd+Shift+ArrowLeft": editorSelectWordLeft,
|
|
29206
|
+
"CtrlOrCmd+Shift+ArrowRight": editorSelectWordEnd,
|
|
29438
29207
|
"CtrlOrCmd+ArrowUp": editorMoveHome,
|
|
29439
29208
|
"CtrlOrCmd+ArrowDown": editorMoveEnd,
|
|
29440
29209
|
"CtrlOrCmd+Shift+ArrowUp": editorSelectHome,
|
|
29441
29210
|
"CtrlOrCmd+Shift+ArrowDown": editorSelectEnd,
|
|
29442
29211
|
"CtrlOrCmd+A": editorSelectAll,
|
|
29212
|
+
"Home": editorMoveLineHome,
|
|
29213
|
+
"End": editorMoveLineEnd,
|
|
29214
|
+
"Shift+Home": editorSelectLineHome,
|
|
29215
|
+
"Shift+End": editorSelectLineEnd,
|
|
29443
29216
|
"PageUp": editorMovePageUp,
|
|
29444
29217
|
"PageDown": editorMovePageDown,
|
|
29445
29218
|
"Shift+PageUp": editorSelectPageUp,
|
|
@@ -29451,8 +29224,7 @@ ${codeText}
|
|
|
29451
29224
|
"Backspace": editorHandleBackspace,
|
|
29452
29225
|
"Shift+Enter": editorHandleInsertBr,
|
|
29453
29226
|
"CtrlOrCmd+Shift+V": editorHandlePastePlainText,
|
|
29454
|
-
"CtrlOrCmd+Shift+C": editorHandleCopyMarkdown
|
|
29455
|
-
...CustomShortcuts
|
|
29227
|
+
"CtrlOrCmd+Shift+C": editorHandleCopyMarkdown
|
|
29456
29228
|
};
|
|
29457
29229
|
function editorHandleKeyboardEvent(editor, event) {
|
|
29458
29230
|
const result = editor.shortcuts.handleKeyboardEvents(editor, event);
|
|
@@ -43230,21 +43002,8 @@ ${codeText}
|
|
|
43230
43002
|
const textColorItem = "";
|
|
43231
43003
|
const DEFAULT_BG_COLOR = 2;
|
|
43232
43004
|
const NULLABLE_COLOR = -1;
|
|
43233
|
-
const STORAGE_NAME = "color-item";
|
|
43234
|
-
function getColorsFromLocalStorage(editor) {
|
|
43235
|
-
const colors = [null, null];
|
|
43236
|
-
const color = Number.parseInt(editor.settingsProvider.getItem(`${STORAGE_NAME}-color`) || "", 10);
|
|
43237
|
-
const backgroundColor = Number.parseInt(editor.settingsProvider.getItem(`${STORAGE_NAME}-backgroundColor`) || `${DEFAULT_BG_COLOR}`, 10);
|
|
43238
|
-
if (!Number.isNaN(color)) {
|
|
43239
|
-
colors[0] = color;
|
|
43240
|
-
}
|
|
43241
|
-
if (!Number.isNaN(backgroundColor)) {
|
|
43242
|
-
colors[1] = backgroundColor;
|
|
43243
|
-
}
|
|
43244
|
-
return colors;
|
|
43245
|
-
}
|
|
43246
43005
|
class TextColorItem extends tinyTypedEmitter.TypedEmitter {
|
|
43247
|
-
constructor(editor, storageName =
|
|
43006
|
+
constructor(editor, storageName = "color-item") {
|
|
43248
43007
|
super();
|
|
43249
43008
|
__publicField(this, "id", "text-color-item");
|
|
43250
43009
|
__publicField(this, "name", i18n$1.t("colorPalette.name"));
|
|
@@ -50939,7 +50698,7 @@ ${codeText}
|
|
|
50939
50698
|
}
|
|
50940
50699
|
return handleDragList(editor, draggedBlock, targetBlock, insertPos);
|
|
50941
50700
|
}
|
|
50942
|
-
function executeShortcut$
|
|
50701
|
+
function executeShortcut$1(editor, type) {
|
|
50943
50702
|
if (!editor.isWritable()) {
|
|
50944
50703
|
return false;
|
|
50945
50704
|
}
|
|
@@ -50953,8 +50712,8 @@ ${codeText}
|
|
|
50953
50712
|
return true;
|
|
50954
50713
|
}
|
|
50955
50714
|
const ListBlockShortcuts = {
|
|
50956
|
-
"Shift+CtrlOrCmd+L": (editor) => executeShortcut$
|
|
50957
|
-
"Shift+CtrlOrCmd+U": (editor) => executeShortcut$
|
|
50715
|
+
"Shift+CtrlOrCmd+L": (editor) => executeShortcut$1(editor, "ordered-list"),
|
|
50716
|
+
"Shift+CtrlOrCmd+U": (editor) => executeShortcut$1(editor, "unordered-list")
|
|
50958
50717
|
};
|
|
50959
50718
|
function getBlockPadding$1(block) {
|
|
50960
50719
|
const padding = block.getAttribute("block-padding-level");
|
|
@@ -61464,31 +61223,6 @@ $$${mathData.mathjaxText}$$
|
|
|
61464
61223
|
return editor.addCustom("overflow-tooltip-helper", () => new OverflowTooltipHelper(editor));
|
|
61465
61224
|
}
|
|
61466
61225
|
}
|
|
61467
|
-
function executeShortcut$2(editor, style2) {
|
|
61468
|
-
if (!editor.isWritable()) {
|
|
61469
|
-
return false;
|
|
61470
|
-
}
|
|
61471
|
-
const range = editor.selection.range;
|
|
61472
|
-
const allCommands = editor.editorCommandProviders.getCommands(range);
|
|
61473
|
-
const alignCommands = allCommands.flatMap((command2) => {
|
|
61474
|
-
if (command2.id === "align") {
|
|
61475
|
-
return command2.children;
|
|
61476
|
-
}
|
|
61477
|
-
return [];
|
|
61478
|
-
});
|
|
61479
|
-
const command = alignCommands.find((c) => c.id === `align-${style2}`);
|
|
61480
|
-
if (!command) {
|
|
61481
|
-
return false;
|
|
61482
|
-
}
|
|
61483
|
-
editor.editorCommandProviders.executeCommand(range, command, {});
|
|
61484
|
-
OnesEditorToolbar.get(editor).update("selectionChange");
|
|
61485
|
-
return true;
|
|
61486
|
-
}
|
|
61487
|
-
const AlignShortcuts = {
|
|
61488
|
-
"CtrlOrCmd+Shift+E": (editor) => executeShortcut$2(editor, "center"),
|
|
61489
|
-
"CtrlOrCmd+Shift+O": (editor) => executeShortcut$2(editor, "left"),
|
|
61490
|
-
"CtrlOrCmd+Shift+R": (editor) => executeShortcut$2(editor, "right")
|
|
61491
|
-
};
|
|
61492
61226
|
const TextCommands = {
|
|
61493
61227
|
"text/style-bold": "bold",
|
|
61494
61228
|
"text/style-italic": "italic",
|
|
@@ -61504,7 +61238,7 @@ $$${mathData.mathjaxText}$$
|
|
|
61504
61238
|
const styleCommands = blockCommands.filter((command) => styleCommandsSet.has(command.id));
|
|
61505
61239
|
return styleCommands;
|
|
61506
61240
|
}
|
|
61507
|
-
function executeShortcut
|
|
61241
|
+
function executeShortcut(editor, style2) {
|
|
61508
61242
|
if (!editor.isWritable()) {
|
|
61509
61243
|
return false;
|
|
61510
61244
|
}
|
|
@@ -61549,37 +61283,13 @@ $$${mathData.mathjaxText}$$
|
|
|
61549
61283
|
return shortcuts2;
|
|
61550
61284
|
};
|
|
61551
61285
|
const TextStyleShortcuts = {
|
|
61552
|
-
"CtrlOrCmd+B": (editor) => executeShortcut
|
|
61553
|
-
"CtrlOrCmd+I": (editor) => executeShortcut
|
|
61554
|
-
"CtrlOrCmd+U": (editor) => executeShortcut
|
|
61555
|
-
"CtrlOrCmd+D": (editor) => executeShortcut
|
|
61556
|
-
"CtrlOrCmd+K": (editor) => executeShortcut
|
|
61286
|
+
"CtrlOrCmd+B": (editor) => executeShortcut(editor, "style-bold"),
|
|
61287
|
+
"CtrlOrCmd+I": (editor) => executeShortcut(editor, "style-italic"),
|
|
61288
|
+
"CtrlOrCmd+U": (editor) => executeShortcut(editor, "style-underline"),
|
|
61289
|
+
"CtrlOrCmd+D": (editor) => executeShortcut(editor, "style-strikethrough"),
|
|
61290
|
+
"CtrlOrCmd+K": (editor) => executeShortcut(editor, "link"),
|
|
61557
61291
|
...headingShortcut()
|
|
61558
61292
|
};
|
|
61559
|
-
function executeShortcut(editor) {
|
|
61560
|
-
if (!editor.isWritable()) {
|
|
61561
|
-
return false;
|
|
61562
|
-
}
|
|
61563
|
-
const range = editor.selection.range;
|
|
61564
|
-
if (range.isCollapsed()) {
|
|
61565
|
-
return false;
|
|
61566
|
-
}
|
|
61567
|
-
editor.undoManager.runInGroup(() => {
|
|
61568
|
-
const colors = getColorsFromLocalStorage(editor);
|
|
61569
|
-
colors.forEach((color, idx) => {
|
|
61570
|
-
if (color === null) {
|
|
61571
|
-
return;
|
|
61572
|
-
}
|
|
61573
|
-
const type = idx === 0 ? "color" : "backgroundColor";
|
|
61574
|
-
editorRangeSetColor(editor, type, color, () => {
|
|
61575
|
-
});
|
|
61576
|
-
});
|
|
61577
|
-
});
|
|
61578
|
-
return true;
|
|
61579
|
-
}
|
|
61580
|
-
const TextColorShortcuts = {
|
|
61581
|
-
"CtrlOrCmd+Alt+KeyH": (editor) => executeShortcut(editor)
|
|
61582
|
-
};
|
|
61583
61293
|
const zhCN$p = {
|
|
61584
61294
|
quickMenu: {
|
|
61585
61295
|
basic: {
|
|
@@ -62338,7 +62048,7 @@ $$${mathData.mathjaxText}$$
|
|
|
62338
62048
|
__publicField(this, "updateButtonColor", (range) => {
|
|
62339
62049
|
const currentTextColor = editorRangeGetColor(this.editor, range, this.getEmptyTextBlockColor);
|
|
62340
62050
|
this.colorItem.setCurrentTextColors(currentTextColor);
|
|
62341
|
-
const lastButtonColor = getColorsFromLocalStorage(
|
|
62051
|
+
const lastButtonColor = this.colorItem.getColorsFromLocalStorage();
|
|
62342
62052
|
this.colorItem.setCurrentButtonColor(lastButtonColor);
|
|
62343
62053
|
});
|
|
62344
62054
|
__publicField(this, "setActiveAttribute", (type, value) => {
|
|
@@ -92193,11 +91903,9 @@ ${data2.plantumlText}
|
|
|
92193
91903
|
FindReplaceShortcuts,
|
|
92194
91904
|
BlockPaddingShortcuts,
|
|
92195
91905
|
TextStyleShortcuts,
|
|
92196
|
-
AlignShortcuts,
|
|
92197
91906
|
AutoLinkShortcuts,
|
|
92198
91907
|
DefaultShortcuts,
|
|
92199
91908
|
ListBlockShortcuts,
|
|
92200
|
-
TextColorShortcuts,
|
|
92201
91909
|
...options.shortcuts || []
|
|
92202
91910
|
],
|
|
92203
91911
|
colors: [
|
|
@@ -92406,7 +92114,7 @@ ${data2.plantumlText}
|
|
|
92406
92114
|
}
|
|
92407
92115
|
}
|
|
92408
92116
|
});
|
|
92409
|
-
editor.version = "2.
|
|
92117
|
+
editor.version = "2.7.1-beta.1";
|
|
92410
92118
|
return editor;
|
|
92411
92119
|
}
|
|
92412
92120
|
function isDoc(doc2) {
|
|
@@ -92519,7 +92227,7 @@ ${data2.plantumlText}
|
|
|
92519
92227
|
}
|
|
92520
92228
|
});
|
|
92521
92229
|
OnesEditorToolbar.register(editor);
|
|
92522
|
-
editor.version = "2.
|
|
92230
|
+
editor.version = "2.7.1-beta.1";
|
|
92523
92231
|
return editor;
|
|
92524
92232
|
}
|
|
92525
92233
|
async function showDocVersions(editor, options, serverUrl) {
|
|
@@ -138305,7 +138013,6 @@ ${data2.plantumlText}
|
|
|
138305
138013
|
exports2.AlignProvider = AlignProvider;
|
|
138306
138014
|
exports2.AlignRightIcon = AlignRightIcon;
|
|
138307
138015
|
exports2.AlignRightItem = AlignRightItem;
|
|
138308
|
-
exports2.AlignShortcuts = AlignShortcuts;
|
|
138309
138016
|
exports2.AnchorBox = AnchorBox;
|
|
138310
138017
|
exports2.ArrowDownIcon = ArrowDownIcon$1;
|
|
138311
138018
|
exports2.ArrowLeftIcon = arrowLeft;
|
|
@@ -138562,7 +138269,6 @@ ${data2.plantumlText}
|
|
|
138562
138269
|
exports2.TextBox = TextBox;
|
|
138563
138270
|
exports2.TextColorIcon = TextColorIcon;
|
|
138564
138271
|
exports2.TextColorItem = TextColorItem;
|
|
138565
|
-
exports2.TextColorShortcuts = TextColorShortcuts;
|
|
138566
138272
|
exports2.TextCommandProvider = TextCommandProvider;
|
|
138567
138273
|
exports2.TextGroupIcon = TextGroupIcon;
|
|
138568
138274
|
exports2.TextIcon = TextIcon;
|
|
@@ -138732,8 +138438,6 @@ ${data2.plantumlText}
|
|
|
138732
138438
|
exports2.editorInsertTextToBlock = editorInsertTextToBlock;
|
|
138733
138439
|
exports2.editorInsertTextToBlockEx = editorInsertTextToBlockEx;
|
|
138734
138440
|
exports2.editorMergeTextBlock = editorMergeTextBlock;
|
|
138735
|
-
exports2.editorMoveBlockEnd = editorMoveBlockEnd;
|
|
138736
|
-
exports2.editorMoveBlockStart = editorMoveBlockStart;
|
|
138737
138441
|
exports2.editorMoveDown = editorMoveDown;
|
|
138738
138442
|
exports2.editorMoveEnd = editorMoveEnd;
|
|
138739
138443
|
exports2.editorMoveHome = editorMoveHome;
|
|
@@ -138838,7 +138542,6 @@ ${data2.plantumlText}
|
|
|
138838
138542
|
exports2.getBlockTextLength = getBlockTextLength$6;
|
|
138839
138543
|
exports2.getBlockTools = getBlockTools;
|
|
138840
138544
|
exports2.getBlockType = getBlockType;
|
|
138841
|
-
exports2.getBlocksBetween = getBlocksBetween;
|
|
138842
138545
|
exports2.getBlocksWidth = getBlocksWidth;
|
|
138843
138546
|
exports2.getBoxContent = getBoxContent;
|
|
138844
138547
|
exports2.getBoxId = getBoxId;
|
|
@@ -138851,7 +138554,6 @@ ${data2.plantumlText}
|
|
|
138851
138554
|
exports2.getClosestContainerByCondition = getClosestContainerByCondition;
|
|
138852
138555
|
exports2.getColorFromAttributes = getColorFromAttributes;
|
|
138853
138556
|
exports2.getColorFromContent = getColorFromContent;
|
|
138854
|
-
exports2.getColorsFromLocalStorage = getColorsFromLocalStorage;
|
|
138855
138557
|
exports2.getComplexBlockClass = getComplexBlockClass;
|
|
138856
138558
|
exports2.getContainerBlockOverrideOptions = getContainerBlockOverrideOptions;
|
|
138857
138559
|
exports2.getContainerBlockPath = getContainerBlockPath;
|
|
@@ -139026,7 +138728,7 @@ ${data2.plantumlText}
|
|
|
139026
138728
|
exports2.loadJs = loadJs;
|
|
139027
138729
|
exports2.loadJsPromise = loadJsPromise;
|
|
139028
138730
|
exports2.lockers = lockers;
|
|
139029
|
-
exports2.logger = logger$
|
|
138731
|
+
exports2.logger = logger$4p;
|
|
139030
138732
|
exports2.markdownToDoc = markdownToDoc;
|
|
139031
138733
|
exports2.mergeCommands = mergeCommands;
|
|
139032
138734
|
exports2.mergeDocs = mergeDocs;
|