@ones-editor/editor 2.5.1-beta.5 → 2.6.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 +3 -2
- package/@ones-editor/core/src/core/input-handler/actions.d.ts +4 -0
- package/@ones-editor/core/src/core/input-handler/handle-delete.d.ts +4 -0
- package/@ones-editor/core/src/core/selection/actions/index.d.ts +3 -1
- package/@ones-editor/core/src/core/selection/actions/move-block-end.d.ts +2 -0
- package/@ones-editor/core/src/core/selection/actions/move-block-start.d.ts +2 -0
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/ui/src/index.d.ts +2 -2
- package/@ones-editor/ui/src/shortcuts/align-shortcuts.d.ts +2 -0
- package/@ones-editor/ui/src/shortcuts/index.d.ts +3 -2
- package/@ones-editor/ui/src/shortcuts/text-color-shortcuts.d.ts +2 -0
- package/@ones-editor/ui/src/shortcuts/text-style-shortcuts.d.ts +1 -2
- package/@ones-editor/ui-base/src/color-button/index.d.ts +1 -2
- package/@ones-editor/ui-base/src/color-button/text-color-item.d.ts +2 -0
- package/dist/index.js +786 -509
- package/package.json +1 -9
- package/@ones-editor/server-tools/package.json +0 -22
- package/@ones-editor/server-tools/src/fake-browser.d.ts +0 -1
- package/@ones-editor/server-tools/src/from-markdown/index.d.ts +0 -1
- package/@ones-editor/server-tools/src/index.d.ts +0 -2
- package/@ones-editor/server-tools/src/to-markdown/blocks/code.d.ts +0 -3
- package/@ones-editor/server-tools/src/to-markdown/blocks/index.d.ts +0 -12
- package/@ones-editor/server-tools/src/to-markdown/blocks/list.d.ts +0 -14
- package/@ones-editor/server-tools/src/to-markdown/blocks/table.d.ts +0 -3
- package/@ones-editor/server-tools/src/to-markdown/blocks/text.d.ts +0 -4
- package/@ones-editor/server-tools/src/to-markdown/boxes/br.d.ts +0 -1
- package/@ones-editor/server-tools/src/to-markdown/boxes/date.d.ts +0 -2
- package/@ones-editor/server-tools/src/to-markdown/boxes/file.d.ts +0 -11
- package/@ones-editor/server-tools/src/to-markdown/boxes/index.d.ts +0 -16
- package/@ones-editor/server-tools/src/to-markdown/boxes/known-link.d.ts +0 -11
- package/@ones-editor/server-tools/src/to-markdown/boxes/mathjax.d.ts +0 -2
- package/@ones-editor/server-tools/src/to-markdown/boxes/mention.d.ts +0 -7
- package/@ones-editor/server-tools/src/to-markdown/boxes/task-link.d.ts +0 -2
- package/@ones-editor/server-tools/src/to-markdown/convert-block.d.ts +0 -3
- package/@ones-editor/server-tools/src/to-markdown/convert-box.d.ts +0 -3
- package/@ones-editor/server-tools/src/to-markdown/embeds/drawio.d.ts +0 -2
- package/@ones-editor/server-tools/src/to-markdown/embeds/file-list.d.ts +0 -5
- package/@ones-editor/server-tools/src/to-markdown/embeds/file.d.ts +0 -2
- package/@ones-editor/server-tools/src/to-markdown/embeds/flowchart.d.ts +0 -2
- package/@ones-editor/server-tools/src/to-markdown/embeds/hr.d.ts +0 -1
- package/@ones-editor/server-tools/src/to-markdown/embeds/image.d.ts +0 -18
- package/@ones-editor/server-tools/src/to-markdown/embeds/index.d.ts +0 -3
- package/@ones-editor/server-tools/src/to-markdown/embeds/mathjax.d.ts +0 -2
- package/@ones-editor/server-tools/src/to-markdown/embeds/media.d.ts +0 -2
- package/@ones-editor/server-tools/src/to-markdown/embeds/mermaid.d.ts +0 -2
- package/@ones-editor/server-tools/src/to-markdown/embeds/plantuml.d.ts +0 -2
- package/@ones-editor/server-tools/src/to-markdown/embeds/sub-pages.d.ts +0 -2
- package/@ones-editor/server-tools/src/to-markdown/embeds/task-list.d.ts +0 -7
- package/@ones-editor/server-tools/src/to-markdown/embeds/toc.d.ts +0 -2
- package/@ones-editor/server-tools/src/to-markdown/embeds/webpage.d.ts +0 -5
- package/@ones-editor/server-tools/src/to-markdown/embeds/xmind.d.ts +0 -8
- package/@ones-editor/server-tools/src/to-markdown/index.d.ts +0 -1
- package/@ones-editor/server-tools/src/to-markdown/types.d.ts +0 -7
- package/@ones-editor/server-tools/src/tools.d.ts +0 -1
- package/@ones-editor/server-tools/src/utils/editor-doc.d.ts +0 -22
- package/@ones-editor/server-tools/src/utils/object.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -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$4S = 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$4S.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$4R = 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$4R, 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$4Q = 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$4Q, 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$4Q, 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$4Q, 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$4Q, 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$4Q, 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$4Q, 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$4P = 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$4P, 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$4P, 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$4O = 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$4O, c.length === 1, "invalid char length");
|
|
10594
10594
|
if (c === "]")
|
|
10595
10595
|
c = "\\]";
|
|
10596
10596
|
if (c === "\\")
|
|
@@ -10907,31 +10907,24 @@ var __publicField = (obj, key, value) => {
|
|
|
10907
10907
|
return elementFont;
|
|
10908
10908
|
}
|
|
10909
10909
|
function getTextWidth(text2, font) {
|
|
10910
|
-
|
|
10911
|
-
|
|
10912
|
-
|
|
10913
|
-
}
|
|
10914
|
-
const canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
|
|
10915
|
-
const context = canvas.getContext("2d");
|
|
10916
|
-
if (!context) {
|
|
10917
|
-
return 200;
|
|
10918
|
-
}
|
|
10919
|
-
if (typeof font === "string") {
|
|
10920
|
-
if (!font) {
|
|
10921
|
-
context.font = getStyleFont(window.getComputedStyle(document.body));
|
|
10922
|
-
} else {
|
|
10923
|
-
context.font = font;
|
|
10924
|
-
}
|
|
10925
|
-
} else if (font instanceof Element) {
|
|
10926
|
-
context.font = getStyleFont(window.getComputedStyle(font));
|
|
10927
|
-
}
|
|
10928
|
-
const metrics = context.measureText(text2);
|
|
10929
|
-
return metrics.width + 4;
|
|
10930
|
-
} catch (err) {
|
|
10910
|
+
const canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
|
|
10911
|
+
const context = canvas.getContext("2d");
|
|
10912
|
+
if (!context) {
|
|
10931
10913
|
return 200;
|
|
10932
10914
|
}
|
|
10915
|
+
if (typeof font === "string") {
|
|
10916
|
+
if (!font) {
|
|
10917
|
+
context.font = getStyleFont(window.getComputedStyle(document.body));
|
|
10918
|
+
} else {
|
|
10919
|
+
context.font = font;
|
|
10920
|
+
}
|
|
10921
|
+
} else if (font instanceof Element) {
|
|
10922
|
+
context.font = getStyleFont(window.getComputedStyle(font));
|
|
10923
|
+
}
|
|
10924
|
+
const metrics = context.measureText(text2);
|
|
10925
|
+
return metrics.width + 4;
|
|
10933
10926
|
}
|
|
10934
|
-
const logger$
|
|
10927
|
+
const logger$4N = getLogger("editor-clipboard");
|
|
10935
10928
|
async function setClipboardDataByEvent(items, event) {
|
|
10936
10929
|
if (event.clipboardData) {
|
|
10937
10930
|
const data2 = event.clipboardData;
|
|
@@ -10989,7 +10982,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10989
10982
|
document.body.removeChild(textarea2);
|
|
10990
10983
|
return true;
|
|
10991
10984
|
} catch (ex) {
|
|
10992
|
-
logger$
|
|
10985
|
+
logger$4N.error(ex);
|
|
10993
10986
|
document.body.removeChild(textarea2);
|
|
10994
10987
|
return false;
|
|
10995
10988
|
}
|
|
@@ -11010,7 +11003,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11010
11003
|
document.body.removeChild(div);
|
|
11011
11004
|
return true;
|
|
11012
11005
|
} catch (ex) {
|
|
11013
|
-
logger$
|
|
11006
|
+
logger$4N.error(ex);
|
|
11014
11007
|
document.body.removeChild(div);
|
|
11015
11008
|
return false;
|
|
11016
11009
|
}
|
|
@@ -11037,7 +11030,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11037
11030
|
await navigator.clipboard.write([clipboardItems]);
|
|
11038
11031
|
return true;
|
|
11039
11032
|
} catch (err) {
|
|
11040
|
-
logger$
|
|
11033
|
+
logger$4N.error(err);
|
|
11041
11034
|
return await execCommandCopy(items);
|
|
11042
11035
|
}
|
|
11043
11036
|
}
|
|
@@ -11093,7 +11086,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11093
11086
|
a.click();
|
|
11094
11087
|
a.remove();
|
|
11095
11088
|
}
|
|
11096
|
-
const logger$
|
|
11089
|
+
const logger$4M = getLogger("auto-scroll");
|
|
11097
11090
|
function scrollable(scrollElement, direction) {
|
|
11098
11091
|
if (scrollElement.scrollHeight === scrollElement.clientHeight) {
|
|
11099
11092
|
return false;
|
|
@@ -11117,7 +11110,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11117
11110
|
const isHorizontal = direction === "left" || direction === "right";
|
|
11118
11111
|
const scroll = () => {
|
|
11119
11112
|
if (!scrollable(scrollElement, direction)) {
|
|
11120
|
-
logger$
|
|
11113
|
+
logger$4M.debug("No need for scroll");
|
|
11121
11114
|
return null;
|
|
11122
11115
|
}
|
|
11123
11116
|
if (isHorizontal) {
|
|
@@ -11174,7 +11167,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11174
11167
|
if (this.scrolling) {
|
|
11175
11168
|
return;
|
|
11176
11169
|
}
|
|
11177
|
-
logger$
|
|
11170
|
+
logger$4M.debug(`scroll direction: ${direction}`);
|
|
11178
11171
|
this.cancelScroll = continuousScroll(scrollElement, {
|
|
11179
11172
|
direction,
|
|
11180
11173
|
step
|
|
@@ -11424,7 +11417,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11424
11417
|
const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
|
|
11425
11418
|
return ColorNames[colorIndex];
|
|
11426
11419
|
}
|
|
11427
|
-
const logger$
|
|
11420
|
+
const logger$4L = getLogger("container");
|
|
11428
11421
|
function isContainer(elem) {
|
|
11429
11422
|
return elem.getAttribute("data-type") === "editor-container";
|
|
11430
11423
|
}
|
|
@@ -11436,9 +11429,9 @@ var __publicField = (obj, key, value) => {
|
|
|
11436
11429
|
}
|
|
11437
11430
|
function getContainerId(container) {
|
|
11438
11431
|
const id = container.getAttribute("data-container-id");
|
|
11439
|
-
assert(logger$
|
|
11432
|
+
assert(logger$4L, id, "no id for container");
|
|
11440
11433
|
if (isRootContainer(container)) {
|
|
11441
|
-
assert(logger$
|
|
11434
|
+
assert(logger$4L, id === "root", `invalid root container id, : ${id}`);
|
|
11442
11435
|
}
|
|
11443
11436
|
return id;
|
|
11444
11437
|
}
|
|
@@ -11449,7 +11442,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11449
11442
|
function generateEditorContainerId(containerId) {
|
|
11450
11443
|
return `ones-editor-container-${containerId}`;
|
|
11451
11444
|
}
|
|
11452
|
-
const logger$
|
|
11445
|
+
const logger$4K = getLogger("element");
|
|
11453
11446
|
function createContainerElement(parent, type, containerId) {
|
|
11454
11447
|
const container = createElement("div", [type], parent);
|
|
11455
11448
|
container.setAttribute("data-type", "editor-container");
|
|
@@ -11460,7 +11453,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11460
11453
|
}
|
|
11461
11454
|
function getContainerById(editor, containerId) {
|
|
11462
11455
|
const container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
|
|
11463
|
-
assert(logger$
|
|
11456
|
+
assert(logger$4K, container, `no container: ${containerId}`);
|
|
11464
11457
|
return container;
|
|
11465
11458
|
}
|
|
11466
11459
|
function getExistsContainerById(editor, containerId) {
|
|
@@ -11469,7 +11462,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11469
11462
|
}
|
|
11470
11463
|
function getContainerBlocksElement(container) {
|
|
11471
11464
|
const blocks = container.querySelector(":scope > .container-blocks");
|
|
11472
|
-
assert(logger$
|
|
11465
|
+
assert(logger$4K, blocks, "no container blocks element");
|
|
11473
11466
|
return blocks;
|
|
11474
11467
|
}
|
|
11475
11468
|
function getContainerToolsElement(container) {
|
|
@@ -11482,11 +11475,11 @@ var __publicField = (obj, key, value) => {
|
|
|
11482
11475
|
function isContainerBlocksElement(element) {
|
|
11483
11476
|
return element.classList.contains("container-blocks");
|
|
11484
11477
|
}
|
|
11485
|
-
const logger$
|
|
11478
|
+
const logger$4J = getLogger("container-children");
|
|
11486
11479
|
function getChildBlocks(container, traverseChild) {
|
|
11487
11480
|
const content = getContainerBlocksElement(container);
|
|
11488
11481
|
const blocks = Array.from(content.children);
|
|
11489
|
-
assert(logger$
|
|
11482
|
+
assert(logger$4J, blocks.length > 0, "container have not any child block");
|
|
11490
11483
|
if (traverseChild) {
|
|
11491
11484
|
const { condition, editor } = traverseChild;
|
|
11492
11485
|
return blocks.reduce((result, block) => {
|
|
@@ -11509,7 +11502,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11509
11502
|
}
|
|
11510
11503
|
function getFirstChildBlock(container) {
|
|
11511
11504
|
const block = container.querySelector(":scope > .container-blocks > div[data-type=editor-block]");
|
|
11512
|
-
assert(logger$
|
|
11505
|
+
assert(logger$4J, block, "container have not any child block");
|
|
11513
11506
|
return block;
|
|
11514
11507
|
}
|
|
11515
11508
|
function getLastChildBlock(container) {
|
|
@@ -11521,14 +11514,14 @@ var __publicField = (obj, key, value) => {
|
|
|
11521
11514
|
}
|
|
11522
11515
|
function getBlockByIndex(container, blockIndex) {
|
|
11523
11516
|
const block = getChildBlocks(container)[blockIndex];
|
|
11524
|
-
assert(logger$
|
|
11517
|
+
assert(logger$4J, block, `container have not block at index ${blockIndex}`);
|
|
11525
11518
|
return block;
|
|
11526
11519
|
}
|
|
11527
11520
|
function findBlockByIndex(container, blockIndex) {
|
|
11528
11521
|
var _a;
|
|
11529
11522
|
return (_a = getChildBlocks(container)[blockIndex]) != null ? _a : null;
|
|
11530
11523
|
}
|
|
11531
|
-
const logger$
|
|
11524
|
+
const logger$4I = getLogger("block-dom");
|
|
11532
11525
|
function isBlock$1(node) {
|
|
11533
11526
|
if (!(node instanceof HTMLDivElement)) {
|
|
11534
11527
|
return false;
|
|
@@ -11549,12 +11542,12 @@ var __publicField = (obj, key, value) => {
|
|
|
11549
11542
|
}
|
|
11550
11543
|
function getBlockId(block) {
|
|
11551
11544
|
const { id } = block;
|
|
11552
|
-
assert(logger$
|
|
11545
|
+
assert(logger$4I, id, "no block id");
|
|
11553
11546
|
return id;
|
|
11554
11547
|
}
|
|
11555
11548
|
function getBlockType(block) {
|
|
11556
11549
|
const type = block.getAttribute("data-block-type");
|
|
11557
|
-
assert(logger$
|
|
11550
|
+
assert(logger$4I, type, "invalid block dom, no data-type");
|
|
11558
11551
|
return type;
|
|
11559
11552
|
}
|
|
11560
11553
|
function getParentBlock(node) {
|
|
@@ -11577,12 +11570,12 @@ var __publicField = (obj, key, value) => {
|
|
|
11577
11570
|
}
|
|
11578
11571
|
function getParentContainer(block) {
|
|
11579
11572
|
const container = block.closest("div[data-type=editor-container]");
|
|
11580
|
-
assert(logger$
|
|
11573
|
+
assert(logger$4I, container, "failed to get block container");
|
|
11581
11574
|
return container;
|
|
11582
11575
|
}
|
|
11583
11576
|
function getBlockContent(block) {
|
|
11584
11577
|
const content = block.querySelector(":scope >div[data-type=block-content]");
|
|
11585
|
-
assert(logger$
|
|
11578
|
+
assert(logger$4I, content, "no block content");
|
|
11586
11579
|
return content;
|
|
11587
11580
|
}
|
|
11588
11581
|
function getBlockTools(block) {
|
|
@@ -11591,7 +11584,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11591
11584
|
tools = createElement("div", [], block);
|
|
11592
11585
|
tools.setAttribute("data-type", "block-tools");
|
|
11593
11586
|
}
|
|
11594
|
-
assert(logger$
|
|
11587
|
+
assert(logger$4I, tools, "no block tools");
|
|
11595
11588
|
return tools;
|
|
11596
11589
|
}
|
|
11597
11590
|
function getExistsBlockTools(block) {
|
|
@@ -11612,7 +11605,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11612
11605
|
function createBlockElement(editor, path, data2) {
|
|
11613
11606
|
const blockData = editor.editorDecorators.decorateBlock(path, data2);
|
|
11614
11607
|
const { id, type } = blockData;
|
|
11615
|
-
assert(logger$
|
|
11608
|
+
assert(logger$4I, id, "no block id");
|
|
11616
11609
|
const elem = createElement("div", [`${type}-block`], null);
|
|
11617
11610
|
elem.id = id;
|
|
11618
11611
|
elem.setAttribute("data-type", "editor-block");
|
|
@@ -11650,7 +11643,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11650
11643
|
}
|
|
11651
11644
|
function getBoxTypeFromElement(box) {
|
|
11652
11645
|
const type = box.getAttribute("data-box-type");
|
|
11653
|
-
assert(logger$
|
|
11646
|
+
assert(logger$4I, type, "not a valid box element, no type");
|
|
11654
11647
|
return type;
|
|
11655
11648
|
}
|
|
11656
11649
|
function isBox(node) {
|
|
@@ -11661,7 +11654,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11661
11654
|
}
|
|
11662
11655
|
function getBoxId(box) {
|
|
11663
11656
|
const { id } = box;
|
|
11664
|
-
assert(logger$
|
|
11657
|
+
assert(logger$4I, id, "no box id");
|
|
11665
11658
|
return id;
|
|
11666
11659
|
}
|
|
11667
11660
|
function getParentBox(node) {
|
|
@@ -11683,7 +11676,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11683
11676
|
}
|
|
11684
11677
|
function getBoxContent(box) {
|
|
11685
11678
|
const content = box.querySelector("span[data-type=box-content]");
|
|
11686
|
-
assert(logger$
|
|
11679
|
+
assert(logger$4I, content, "invalid box dom, no content");
|
|
11687
11680
|
return content;
|
|
11688
11681
|
}
|
|
11689
11682
|
function createInsertionElement(type, id, attributes) {
|
|
@@ -11705,7 +11698,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11705
11698
|
}
|
|
11706
11699
|
function getInsertionContent(insertion) {
|
|
11707
11700
|
const content = insertion.querySelector("span[data-type=insertion-content]");
|
|
11708
|
-
assert(logger$
|
|
11701
|
+
assert(logger$4I, content, "invalid insertion-child dom, no content");
|
|
11709
11702
|
return content;
|
|
11710
11703
|
}
|
|
11711
11704
|
function getPrevBlock(block) {
|
|
@@ -11728,31 +11721,44 @@ var __publicField = (obj, key, value) => {
|
|
|
11728
11721
|
}
|
|
11729
11722
|
return null;
|
|
11730
11723
|
}
|
|
11731
|
-
function getPrevVisibleBlock(block) {
|
|
11724
|
+
function getPrevVisibleBlock(block, matcher) {
|
|
11725
|
+
const mergedMatcher = matcher || (() => true);
|
|
11732
11726
|
let prev = block.previousElementSibling;
|
|
11733
11727
|
while (prev) {
|
|
11734
|
-
if (isBlock$1(prev) && isVisibleBlock(prev)) {
|
|
11728
|
+
if (isBlock$1(prev) && isVisibleBlock(prev) && mergedMatcher(prev)) {
|
|
11735
11729
|
return prev;
|
|
11736
11730
|
}
|
|
11737
11731
|
prev = prev.previousElementSibling;
|
|
11738
11732
|
}
|
|
11739
11733
|
return null;
|
|
11740
11734
|
}
|
|
11741
|
-
function getNextVisibleBlock(block) {
|
|
11735
|
+
function getNextVisibleBlock(block, matcher) {
|
|
11736
|
+
const mergedMatcher = matcher || (() => true);
|
|
11742
11737
|
let next2 = block.nextElementSibling;
|
|
11743
11738
|
while (next2) {
|
|
11744
|
-
if (isBlock$1(next2) && isVisibleBlock(next2)) {
|
|
11739
|
+
if (isBlock$1(next2) && isVisibleBlock(next2) && mergedMatcher(next2)) {
|
|
11745
11740
|
return next2;
|
|
11746
11741
|
}
|
|
11747
11742
|
next2 = next2.nextElementSibling;
|
|
11748
11743
|
}
|
|
11749
11744
|
return null;
|
|
11750
11745
|
}
|
|
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
|
+
}
|
|
11751
11757
|
function getBlockIndex(block) {
|
|
11752
11758
|
const container = getParentContainer(block);
|
|
11753
11759
|
const children = getChildBlocks(container);
|
|
11754
11760
|
const index2 = children.indexOf(block);
|
|
11755
|
-
assert(logger$
|
|
11761
|
+
assert(logger$4I, index2 !== -1, "invalid block & container dom, failed to get block index");
|
|
11756
11762
|
return index2;
|
|
11757
11763
|
}
|
|
11758
11764
|
function isInBlock(target) {
|
|
@@ -11777,18 +11783,18 @@ var __publicField = (obj, key, value) => {
|
|
|
11777
11783
|
function isTitleBlock$2(block) {
|
|
11778
11784
|
return block.hasAttribute("data-document-title");
|
|
11779
11785
|
}
|
|
11780
|
-
const logger$
|
|
11786
|
+
const logger$4H = getLogger("block-class");
|
|
11781
11787
|
function getBlockClass(editor, block) {
|
|
11782
11788
|
return editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
11783
11789
|
}
|
|
11784
11790
|
function getTextBlockClass(editor, block) {
|
|
11785
11791
|
const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
11786
|
-
assert(logger$
|
|
11792
|
+
assert(logger$4H, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
|
|
11787
11793
|
return text2;
|
|
11788
11794
|
}
|
|
11789
11795
|
function getComplexBlockClass(editor, block) {
|
|
11790
11796
|
const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
11791
|
-
assert(logger$
|
|
11797
|
+
assert(logger$4H, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
|
|
11792
11798
|
return complex;
|
|
11793
11799
|
}
|
|
11794
11800
|
function getBlockClassByType(editor, type) {
|
|
@@ -11809,7 +11815,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11809
11815
|
function getBlockKind(editor, block) {
|
|
11810
11816
|
return getBlockClass(editor, block).blockKind;
|
|
11811
11817
|
}
|
|
11812
|
-
const logger$
|
|
11818
|
+
const logger$4G = getLogger("text-block-child");
|
|
11813
11819
|
function isTextBlockContentChild(elem) {
|
|
11814
11820
|
if (elem.tagName !== "SPAN") {
|
|
11815
11821
|
return false;
|
|
@@ -11817,14 +11823,14 @@ var __publicField = (obj, key, value) => {
|
|
|
11817
11823
|
return true;
|
|
11818
11824
|
}
|
|
11819
11825
|
function isTextBlockContentBoxChild(elem) {
|
|
11820
|
-
assert(logger$
|
|
11826
|
+
assert(logger$4G, isTextBlockContentChild(elem), "not a valid text child");
|
|
11821
11827
|
if (elem.getAttribute("data-type") === "editor-box") {
|
|
11822
11828
|
return true;
|
|
11823
11829
|
}
|
|
11824
11830
|
return false;
|
|
11825
11831
|
}
|
|
11826
11832
|
function isTextBlockContentInsertionChild(elem) {
|
|
11827
|
-
assert(logger$
|
|
11833
|
+
assert(logger$4G, isTextBlockContentChild(elem), "not a valid text child");
|
|
11828
11834
|
if (elem.getAttribute("data-type") === "editor-insertion") {
|
|
11829
11835
|
return true;
|
|
11830
11836
|
}
|
|
@@ -11834,7 +11840,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11834
11840
|
return !isTextBlockContentBoxChild(elem) && !isTextBlockContentInsertionChild(elem);
|
|
11835
11841
|
}
|
|
11836
11842
|
function getTextBlockContentChildType(child) {
|
|
11837
|
-
assert(logger$
|
|
11843
|
+
assert(logger$4G, isTextBlockContentChild(child), "not a valid text child");
|
|
11838
11844
|
if (isTextBlockContentBoxChild(child)) {
|
|
11839
11845
|
return "box";
|
|
11840
11846
|
}
|
|
@@ -11849,15 +11855,15 @@ var __publicField = (obj, key, value) => {
|
|
|
11849
11855
|
return 0;
|
|
11850
11856
|
if (type === "box")
|
|
11851
11857
|
return 1;
|
|
11852
|
-
assert(logger$
|
|
11853
|
-
assert(logger$
|
|
11858
|
+
assert(logger$4G, child.textContent !== null, "text block content is undefined");
|
|
11859
|
+
assert(logger$4G, child.textContent.length >= 0, "text block content length is negative");
|
|
11854
11860
|
return child.textContent.length;
|
|
11855
11861
|
}
|
|
11856
11862
|
function getTextBlockContentChildren(block) {
|
|
11857
11863
|
const content = getBlockContent(block);
|
|
11858
11864
|
const children = Array.from(content.children);
|
|
11859
11865
|
children.forEach((child) => {
|
|
11860
|
-
assert(logger$
|
|
11866
|
+
assert(logger$4G, isTextBlockContentChild(child), "not a valid text child");
|
|
11861
11867
|
});
|
|
11862
11868
|
return children;
|
|
11863
11869
|
}
|
|
@@ -11886,17 +11892,17 @@ var __publicField = (obj, key, value) => {
|
|
|
11886
11892
|
};
|
|
11887
11893
|
}
|
|
11888
11894
|
const offset = blockOffset - start;
|
|
11889
|
-
assert(logger$
|
|
11890
|
-
assert(logger$
|
|
11895
|
+
assert(logger$4G, offset > 0, "invalid offset value");
|
|
11896
|
+
assert(logger$4G, !isTextBlockContentBoxChild(child), "invalid box child");
|
|
11891
11897
|
return {
|
|
11892
11898
|
prev: child,
|
|
11893
11899
|
next: child,
|
|
11894
11900
|
offset
|
|
11895
11901
|
};
|
|
11896
11902
|
}
|
|
11897
|
-
assert(logger$
|
|
11903
|
+
assert(logger$4G, false, `invalid block child at position: ${blockOffset}`);
|
|
11898
11904
|
}
|
|
11899
|
-
const logger$
|
|
11905
|
+
const logger$4F = getLogger("block-path");
|
|
11900
11906
|
function getBlockPath(block) {
|
|
11901
11907
|
const ret = [];
|
|
11902
11908
|
let current = block;
|
|
@@ -11910,26 +11916,26 @@ var __publicField = (obj, key, value) => {
|
|
|
11910
11916
|
return ret;
|
|
11911
11917
|
}
|
|
11912
11918
|
const parentBlock = getParentBlock(container);
|
|
11913
|
-
assert(logger$
|
|
11919
|
+
assert(logger$4F, parentBlock, "no parent block");
|
|
11914
11920
|
current = parentBlock;
|
|
11915
11921
|
}
|
|
11916
|
-
assert(logger$
|
|
11922
|
+
assert(logger$4F, false, "no parent block");
|
|
11917
11923
|
return [];
|
|
11918
11924
|
}
|
|
11919
|
-
const logger$
|
|
11925
|
+
const logger$4E = getLogger("child-container-path");
|
|
11920
11926
|
function getContainerBlockPath(container) {
|
|
11921
11927
|
if (isRootContainer(container)) {
|
|
11922
11928
|
return [];
|
|
11923
11929
|
}
|
|
11924
11930
|
const parentBlock = getParentBlock(container);
|
|
11925
|
-
assert(logger$
|
|
11931
|
+
assert(logger$4E, parentBlock, "no parent block");
|
|
11926
11932
|
return getBlockPath(parentBlock);
|
|
11927
11933
|
}
|
|
11928
|
-
const logger$
|
|
11934
|
+
const logger$4D = getLogger("load-blocks");
|
|
11929
11935
|
function loadBlocks(editor, container, path) {
|
|
11930
11936
|
const containerId = getContainerId(container);
|
|
11931
11937
|
const blocks = getContainerBlocks$1(container, editor.doc);
|
|
11932
|
-
assert(logger$
|
|
11938
|
+
assert(logger$4D, blocks.length > 0, "no blocks in container");
|
|
11933
11939
|
const fragment = document.createDocumentFragment();
|
|
11934
11940
|
blocks.forEach((b, index2) => {
|
|
11935
11941
|
const block = editor.editorBlocks.createBlock([...path, { containerId, blockIndex: index2 }], container, b);
|
|
@@ -11945,7 +11951,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11945
11951
|
return block;
|
|
11946
11952
|
}
|
|
11947
11953
|
const blocks = getChildBlocks(container);
|
|
11948
|
-
assert(logger$
|
|
11954
|
+
assert(logger$4D, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
|
|
11949
11955
|
if (blockIndex === blocks.length) {
|
|
11950
11956
|
containerBlocksElement.appendChild(block);
|
|
11951
11957
|
} else {
|
|
@@ -11963,7 +11969,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11963
11969
|
insertBlockAt(container, blockIndex, block);
|
|
11964
11970
|
return block;
|
|
11965
11971
|
}
|
|
11966
|
-
const logger$
|
|
11972
|
+
const logger$4C = getLogger("root-container");
|
|
11967
11973
|
const MIN_DISTANCE_THRESHOLD$2 = 3;
|
|
11968
11974
|
class RootContainer {
|
|
11969
11975
|
constructor(editor, rootContainer) {
|
|
@@ -11991,7 +11997,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11991
11997
|
this.editor.selection.updateSelection(null);
|
|
11992
11998
|
this.editor.emit("resize", this.editor);
|
|
11993
11999
|
} catch (err) {
|
|
11994
|
-
logger$
|
|
12000
|
+
logger$4C.warn(`failed to update selection while container resizing: ${err.message}`);
|
|
11995
12001
|
}
|
|
11996
12002
|
});
|
|
11997
12003
|
__publicField(this, "handleClick", (event) => {
|
|
@@ -12024,7 +12030,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12024
12030
|
const box = getParentBox(elem);
|
|
12025
12031
|
if (box) {
|
|
12026
12032
|
const block2 = getParentBlock(box);
|
|
12027
|
-
assert(logger$
|
|
12033
|
+
assert(logger$4C, block2, "no parent block");
|
|
12028
12034
|
(_b = (_a = this.editor.editorBoxes.getBoxClass(getBoxTypeFromElement(box))) == null ? void 0 : _a.handleClickBox) == null ? void 0 : _b.call(_a, this.editor, box, event);
|
|
12029
12035
|
return;
|
|
12030
12036
|
}
|
|
@@ -12079,7 +12085,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12079
12085
|
this.editor.input.focus({ preventScroll: true });
|
|
12080
12086
|
});
|
|
12081
12087
|
__publicField(this, "handleMouseMove", (event) => {
|
|
12082
|
-
assert(logger$
|
|
12088
|
+
assert(logger$4C, this.mouseDownEvent, "no mouse down event");
|
|
12083
12089
|
if (ensureIsMobileEvent(this.mouseDownEvent))
|
|
12084
12090
|
return;
|
|
12085
12091
|
const deltaX = event.x - this.mouseDownEvent.x;
|
|
@@ -12195,7 +12201,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12195
12201
|
loadBlocks(editor, container, path);
|
|
12196
12202
|
return container;
|
|
12197
12203
|
}
|
|
12198
|
-
const logger$
|
|
12204
|
+
const logger$4B = getLogger("block");
|
|
12199
12205
|
function getBlockTextLength$6(editor, block) {
|
|
12200
12206
|
return getBlockClass(editor, block).getBlockTextLength(block);
|
|
12201
12207
|
}
|
|
@@ -12214,7 +12220,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12214
12220
|
return block;
|
|
12215
12221
|
}
|
|
12216
12222
|
const parent = getParentBlock(container);
|
|
12217
|
-
assert(logger$
|
|
12223
|
+
assert(logger$4B, parent, "no parent block exists for child container");
|
|
12218
12224
|
block = parent;
|
|
12219
12225
|
}
|
|
12220
12226
|
}
|
|
@@ -12250,7 +12256,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12250
12256
|
}
|
|
12251
12257
|
return fun(editor, block, options);
|
|
12252
12258
|
} catch (err) {
|
|
12253
|
-
logger$
|
|
12259
|
+
logger$4B.debug(`unsupported block type: ${type}`);
|
|
12254
12260
|
return null;
|
|
12255
12261
|
}
|
|
12256
12262
|
}
|
|
@@ -12270,7 +12276,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12270
12276
|
const styles = Object.fromEntries(Object.entries(data2).filter(([key]) => key.startsWith("style-")));
|
|
12271
12277
|
Object.entries(styles).forEach(([, value]) => {
|
|
12272
12278
|
const type = typeof value;
|
|
12273
|
-
assert(logger$
|
|
12279
|
+
assert(logger$4B, type === "string" || type === "number" || type === "boolean", "invalid style value");
|
|
12274
12280
|
});
|
|
12275
12281
|
return styles;
|
|
12276
12282
|
}
|
|
@@ -12395,7 +12401,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12395
12401
|
}
|
|
12396
12402
|
return { element: null, blockCommands: [], boxCommands: [] };
|
|
12397
12403
|
}
|
|
12398
|
-
const logger$
|
|
12404
|
+
const logger$4A = getLogger("embed-block-common");
|
|
12399
12405
|
function isColumnsBlock(block) {
|
|
12400
12406
|
return getBlockType(block) === "layout";
|
|
12401
12407
|
}
|
|
@@ -12403,9 +12409,9 @@ var __publicField = (obj, key, value) => {
|
|
|
12403
12409
|
return getBlockType(block) === "embed";
|
|
12404
12410
|
}
|
|
12405
12411
|
function getEmbedType(block) {
|
|
12406
|
-
assert(logger$
|
|
12412
|
+
assert(logger$4A, isEmbedBlock(block), "not an embed block");
|
|
12407
12413
|
const type = block.getAttribute("data-embed-type");
|
|
12408
|
-
assert(logger$
|
|
12414
|
+
assert(logger$4A, type, "no embed data type");
|
|
12409
12415
|
return type;
|
|
12410
12416
|
}
|
|
12411
12417
|
function getEmbedClassFromBlock(editor, block) {
|
|
@@ -12471,10 +12477,10 @@ var __publicField = (obj, key, value) => {
|
|
|
12471
12477
|
data: (_c = overrideOptions == null ? void 0 : overrideOptions.data) != null ? _c : data2
|
|
12472
12478
|
});
|
|
12473
12479
|
}
|
|
12474
|
-
const logger$
|
|
12480
|
+
const logger$4z = getLogger("execute-block-command");
|
|
12475
12481
|
function executeEmbedBlockCommand(editor, block, commandGroup, item) {
|
|
12476
12482
|
var _a;
|
|
12477
|
-
assert(logger$
|
|
12483
|
+
assert(logger$4z, isEmbedBlock(block), "not a embed block");
|
|
12478
12484
|
const embedType = getEmbedType(block);
|
|
12479
12485
|
const embed = getEmbedClassByType(editor, embedType);
|
|
12480
12486
|
if (!embed.getOptions) {
|
|
@@ -12507,14 +12513,14 @@ var __publicField = (obj, key, value) => {
|
|
|
12507
12513
|
}
|
|
12508
12514
|
return void 0;
|
|
12509
12515
|
}
|
|
12510
|
-
const logger$
|
|
12516
|
+
const logger$4y = getLogger("block-class");
|
|
12511
12517
|
function isHeadingBlock$1(block) {
|
|
12512
12518
|
return !!block.getAttribute("data-style-heading");
|
|
12513
12519
|
}
|
|
12514
12520
|
function getBlockHeading(block) {
|
|
12515
12521
|
var _a;
|
|
12516
12522
|
const heading = Number.parseInt((_a = block.getAttribute("data-style-heading")) != null ? _a : "", 10);
|
|
12517
|
-
assert(logger$
|
|
12523
|
+
assert(logger$4y, heading, "not a heading block");
|
|
12518
12524
|
return heading;
|
|
12519
12525
|
}
|
|
12520
12526
|
function isExpandedHeadingBlock(block) {
|
|
@@ -12525,7 +12531,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12525
12531
|
}
|
|
12526
12532
|
function getHeadingBlockChildren(block, oldHeading) {
|
|
12527
12533
|
if (!oldHeading) {
|
|
12528
|
-
assert(logger$
|
|
12534
|
+
assert(logger$4y, isHeadingBlock$1(block), "not a heading block");
|
|
12529
12535
|
}
|
|
12530
12536
|
const children = [];
|
|
12531
12537
|
const heading = oldHeading != null ? oldHeading : getBlockHeading(block);
|
|
@@ -12555,7 +12561,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12555
12561
|
}
|
|
12556
12562
|
return children;
|
|
12557
12563
|
}
|
|
12558
|
-
const logger$
|
|
12564
|
+
const logger$4x = getLogger("complex-block-position");
|
|
12559
12565
|
class EditorComplexBlockPosition {
|
|
12560
12566
|
constructor(block, childContainerId, custom) {
|
|
12561
12567
|
__publicField(this, "blockId");
|
|
@@ -12564,7 +12570,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12564
12570
|
if (block instanceof HTMLElement) {
|
|
12565
12571
|
this.blockId = getBlockId(block);
|
|
12566
12572
|
} else {
|
|
12567
|
-
assert(logger$
|
|
12573
|
+
assert(logger$4x, typeof block === "string", `not a valid block id: ${block}`);
|
|
12568
12574
|
this.blockId = block;
|
|
12569
12575
|
}
|
|
12570
12576
|
this.childContainerId = childContainerId;
|
|
@@ -12576,7 +12582,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12576
12582
|
return false;
|
|
12577
12583
|
}
|
|
12578
12584
|
}
|
|
12579
|
-
const logger$
|
|
12585
|
+
const logger$4w = getLogger("simple-block-position");
|
|
12580
12586
|
class EditorSimpleBlockPosition {
|
|
12581
12587
|
constructor(block, offset, type) {
|
|
12582
12588
|
__publicField(this, "blockId");
|
|
@@ -12585,7 +12591,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12585
12591
|
if (block instanceof HTMLElement) {
|
|
12586
12592
|
this.blockId = getBlockId(block);
|
|
12587
12593
|
} else {
|
|
12588
|
-
assert(logger$
|
|
12594
|
+
assert(logger$4w, typeof block === "string", `not a valid block id: ${block}`);
|
|
12589
12595
|
this.blockId = block;
|
|
12590
12596
|
}
|
|
12591
12597
|
this.offset = offset;
|
|
@@ -12595,7 +12601,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12595
12601
|
return true;
|
|
12596
12602
|
}
|
|
12597
12603
|
}
|
|
12598
|
-
const logger$
|
|
12604
|
+
const logger$4v = getLogger("editor-position");
|
|
12599
12605
|
function createSimpleBlockPosition(block, offset, type) {
|
|
12600
12606
|
return new EditorSimpleBlockPosition(block, offset, type);
|
|
12601
12607
|
}
|
|
@@ -12617,7 +12623,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12617
12623
|
}
|
|
12618
12624
|
const block1 = editor.getBlockById(pos1.blockId);
|
|
12619
12625
|
const block2 = editor.getBlockById(pos2.blockId);
|
|
12620
|
-
assert(logger$
|
|
12626
|
+
assert(logger$4v, block1 !== block2, "comparePosition: blocks are the same");
|
|
12621
12627
|
return compareElement(block1, block2);
|
|
12622
12628
|
}
|
|
12623
12629
|
if (isComplexBlockPosition(pos1) && isComplexBlockPosition(pos2)) {
|
|
@@ -12628,13 +12634,13 @@ var __publicField = (obj, key, value) => {
|
|
|
12628
12634
|
}
|
|
12629
12635
|
const container1 = editor.getContainerById(p1.childContainerId);
|
|
12630
12636
|
const container2 = editor.getContainerById(p2.childContainerId);
|
|
12631
|
-
assert(logger$
|
|
12637
|
+
assert(logger$4v, container1 !== container2, "comparePosition: containers are the same");
|
|
12632
12638
|
return compareElement(container1, container2);
|
|
12633
12639
|
}
|
|
12634
|
-
assert(logger$
|
|
12640
|
+
assert(logger$4v, false, "invalid ");
|
|
12635
12641
|
return 0;
|
|
12636
12642
|
}
|
|
12637
|
-
const logger$
|
|
12643
|
+
const logger$4u = getLogger("simple-range");
|
|
12638
12644
|
class EditorSimpleSelectionRange {
|
|
12639
12645
|
constructor(editor, options) {
|
|
12640
12646
|
__publicField(this, "editor");
|
|
@@ -12683,11 +12689,11 @@ var __publicField = (obj, key, value) => {
|
|
|
12683
12689
|
const { editor } = this;
|
|
12684
12690
|
const startBlock = editor.getBlockById(this.start.blockId);
|
|
12685
12691
|
const endBlock = editor.getBlockById(this.end.blockId);
|
|
12686
|
-
assert(logger$
|
|
12687
|
-
assert(logger$
|
|
12692
|
+
assert(logger$4u, startBlock, "no start block");
|
|
12693
|
+
assert(logger$4u, endBlock, "no end block");
|
|
12688
12694
|
const startContainer = getParentContainer(startBlock);
|
|
12689
12695
|
const endContainer = getParentContainer(endBlock);
|
|
12690
|
-
assert(logger$
|
|
12696
|
+
assert(logger$4u, startContainer === endContainer, "invalid range");
|
|
12691
12697
|
const ret = [];
|
|
12692
12698
|
if (startBlock === endBlock) {
|
|
12693
12699
|
ret.push({
|
|
@@ -12698,7 +12704,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12698
12704
|
} else {
|
|
12699
12705
|
const startIndex = getBlockIndex(startBlock);
|
|
12700
12706
|
const endIndex = getBlockIndex(endBlock);
|
|
12701
|
-
assert(logger$
|
|
12707
|
+
assert(logger$4u, startIndex < endIndex, "invalid range, start > index");
|
|
12702
12708
|
ret.push({
|
|
12703
12709
|
block: startBlock,
|
|
12704
12710
|
start: this.start,
|
|
@@ -12798,7 +12804,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12798
12804
|
clearSelection: clearSelection$6,
|
|
12799
12805
|
convertTo: convertTo$m
|
|
12800
12806
|
};
|
|
12801
|
-
const logger$
|
|
12807
|
+
const logger$4t = getLogger("editor-blocks");
|
|
12802
12808
|
class EditorBlocks {
|
|
12803
12809
|
constructor(editor) {
|
|
12804
12810
|
__publicField(this, "blocks", /* @__PURE__ */ new Map());
|
|
@@ -12807,12 +12813,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12807
12813
|
registerBlockClass(blockClass) {
|
|
12808
12814
|
const type = blockClass.blockType;
|
|
12809
12815
|
const exists = this.blocks.get(type);
|
|
12810
|
-
assert(logger$
|
|
12816
|
+
assert(logger$4t, !exists, `duplicated block type: ${type}`);
|
|
12811
12817
|
this.blocks.set(type, blockClass);
|
|
12812
12818
|
}
|
|
12813
12819
|
getBlockClass(type) {
|
|
12814
12820
|
const exists = this.blocks.get(type);
|
|
12815
|
-
assert(logger$
|
|
12821
|
+
assert(logger$4t, exists, `unknown block type: ${type}`);
|
|
12816
12822
|
return exists;
|
|
12817
12823
|
}
|
|
12818
12824
|
hasBlock(type) {
|
|
@@ -12828,7 +12834,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12828
12834
|
}
|
|
12829
12835
|
const content = blockClass.createBlockContent(this.editor, path, container, blockElement, block);
|
|
12830
12836
|
if (content.parentElement !== blockElement) {
|
|
12831
|
-
logger$
|
|
12837
|
+
logger$4t.warn("content parent is not block");
|
|
12832
12838
|
blockElement.appendChild(content);
|
|
12833
12839
|
}
|
|
12834
12840
|
this.editor.blockHooks.forEach((hook) => {
|
|
@@ -12849,7 +12855,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12849
12855
|
return newBlock;
|
|
12850
12856
|
}
|
|
12851
12857
|
}
|
|
12852
|
-
const logger$
|
|
12858
|
+
const logger$4s = getLogger("editor-embeds");
|
|
12853
12859
|
class EditorEmbeds {
|
|
12854
12860
|
constructor(editor) {
|
|
12855
12861
|
__publicField(this, "objects", /* @__PURE__ */ new Map());
|
|
@@ -12858,12 +12864,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12858
12864
|
registerEmbedClass(embedClass) {
|
|
12859
12865
|
const type = embedClass.embedType;
|
|
12860
12866
|
const exists = this.objects.get(type);
|
|
12861
|
-
assert(logger$
|
|
12867
|
+
assert(logger$4s, !exists, `duplicated embed object type: ${type}`);
|
|
12862
12868
|
this.objects.set(type, embedClass);
|
|
12863
12869
|
}
|
|
12864
12870
|
getEmbedClass(type) {
|
|
12865
12871
|
const exists = this.objects.get(type);
|
|
12866
|
-
assert(logger$
|
|
12872
|
+
assert(logger$4s, exists, `unknown embed type: ${type}`);
|
|
12867
12873
|
return exists;
|
|
12868
12874
|
}
|
|
12869
12875
|
getEmbedClassFromBlock(block) {
|
|
@@ -12873,12 +12879,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12873
12879
|
this.objects.forEach(callback);
|
|
12874
12880
|
}
|
|
12875
12881
|
}
|
|
12876
|
-
const logger$
|
|
12882
|
+
const logger$4r = getLogger("embed-block");
|
|
12877
12883
|
function createBlockContent$6(editor, path, container, blockElement, blockData) {
|
|
12878
12884
|
const content = createBlockContentElement(blockElement, "div");
|
|
12879
|
-
assert(logger$
|
|
12885
|
+
assert(logger$4r, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
|
|
12880
12886
|
const embedBlockData = blockData;
|
|
12881
|
-
assert(logger$
|
|
12887
|
+
assert(logger$4r, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
|
|
12882
12888
|
const embedClass = editor.editorEmbeds.getEmbedClass(embedBlockData.embedType);
|
|
12883
12889
|
embedClass.createEmbedContent(editor, content, embedBlockData, path, container, blockElement);
|
|
12884
12890
|
blockElement.setAttribute("data-embed-type", embedBlockData.embedType);
|
|
@@ -12906,7 +12912,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12906
12912
|
function getCaretRect$4(block, pos) {
|
|
12907
12913
|
const content = getBlockContent(block);
|
|
12908
12914
|
const rect = content.getBoundingClientRect();
|
|
12909
|
-
assert(logger$
|
|
12915
|
+
assert(logger$4r, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
|
|
12910
12916
|
if (pos.offset === 1) {
|
|
12911
12917
|
return new DOMRect(rect.right, rect.top, 0, rect.height);
|
|
12912
12918
|
}
|
|
@@ -13046,18 +13052,18 @@ var __publicField = (obj, key, value) => {
|
|
|
13046
13052
|
toStandardDoc: toStandardDoc$2,
|
|
13047
13053
|
getResources: getResources$2
|
|
13048
13054
|
};
|
|
13049
|
-
const logger$
|
|
13055
|
+
const logger$4q = getLogger("complex-block-helper");
|
|
13050
13056
|
function complexBlockGetAllChildContainers(editor, block, options) {
|
|
13051
13057
|
const blockClass = getComplexBlockClass(editor, block);
|
|
13052
13058
|
return blockClass.getChildContainers(editor, block, options);
|
|
13053
13059
|
}
|
|
13054
13060
|
function complexBlockGetSelectedContainers(editor, block, start, end) {
|
|
13055
13061
|
if (start.isSimple()) {
|
|
13056
|
-
assert(logger$
|
|
13062
|
+
assert(logger$4q, end.isSimple(), "invalid start and end position");
|
|
13057
13063
|
return complexBlockGetAllChildContainers(editor, block);
|
|
13058
13064
|
}
|
|
13059
|
-
assert(logger$
|
|
13060
|
-
assert(logger$
|
|
13065
|
+
assert(logger$4q, !start.isSimple(), "invalid start pos");
|
|
13066
|
+
assert(logger$4q, !end.isSimple(), "invalid end pos");
|
|
13061
13067
|
const blockClass = getComplexBlockClass(editor, block);
|
|
13062
13068
|
return blockClass.getSelectedContainers(editor, block, start, end);
|
|
13063
13069
|
}
|
|
@@ -13068,11 +13074,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13068
13074
|
const parentComplexBlock = getParentBlock(getParentContainer(childBlock));
|
|
13069
13075
|
if (!parentComplexBlock)
|
|
13070
13076
|
return false;
|
|
13071
|
-
assert(logger$
|
|
13077
|
+
assert(logger$4q, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
|
|
13072
13078
|
const childContainer = getParentContainer(childBlock);
|
|
13073
13079
|
const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
|
|
13074
13080
|
const index2 = childContainers.indexOf(childContainer);
|
|
13075
|
-
assert(logger$
|
|
13081
|
+
assert(logger$4q, index2 >= 0, "not valid child container");
|
|
13076
13082
|
return index2 === 0;
|
|
13077
13083
|
}
|
|
13078
13084
|
function complexBlockGetFirstSimpleChild(editor, complexBlock, options) {
|
|
@@ -13125,13 +13131,13 @@ var __publicField = (obj, key, value) => {
|
|
|
13125
13131
|
return block;
|
|
13126
13132
|
}
|
|
13127
13133
|
function findPrevSimpleBlockBeforeChildContainer(editor, childContainer, options) {
|
|
13128
|
-
assert(logger$
|
|
13134
|
+
assert(logger$4q, isChildContainer(childContainer), "not a child container");
|
|
13129
13135
|
const parentComplexBlock = getParentBlock(childContainer);
|
|
13130
|
-
assert(logger$
|
|
13131
|
-
assert(logger$
|
|
13136
|
+
assert(logger$4q, parentComplexBlock, "no parent block");
|
|
13137
|
+
assert(logger$4q, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
|
|
13132
13138
|
const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock, options);
|
|
13133
13139
|
const containerIndex = childContainers.indexOf(childContainer);
|
|
13134
|
-
assert(logger$
|
|
13140
|
+
assert(logger$4q, containerIndex !== -1, "child container not found");
|
|
13135
13141
|
if (containerIndex === 0) {
|
|
13136
13142
|
const prevBlock = getPrevBlock(parentComplexBlock);
|
|
13137
13143
|
if (!prevBlock)
|
|
@@ -13149,9 +13155,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13149
13155
|
return lastBlock2;
|
|
13150
13156
|
}
|
|
13151
13157
|
function complexBlockGetTopChildContainers(editor, complexBlock) {
|
|
13152
|
-
assert(logger$
|
|
13158
|
+
assert(logger$4q, isComplexKindBlock(editor, complexBlock), "not a complex block");
|
|
13153
13159
|
const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
|
|
13154
|
-
assert(logger$
|
|
13160
|
+
assert(logger$4q, childContainers.length > 0, "no child container");
|
|
13155
13161
|
if (childContainers.length === 1) {
|
|
13156
13162
|
return childContainers;
|
|
13157
13163
|
}
|
|
@@ -13176,9 +13182,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13176
13182
|
return ret;
|
|
13177
13183
|
}
|
|
13178
13184
|
function complexBlockGetBottomChildContainers(editor, complexBlock) {
|
|
13179
|
-
assert(logger$
|
|
13185
|
+
assert(logger$4q, isComplexKindBlock(editor, complexBlock), "not a complex block");
|
|
13180
13186
|
const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
|
|
13181
|
-
assert(logger$
|
|
13187
|
+
assert(logger$4q, childContainers.length > 0, "no child container");
|
|
13182
13188
|
if (childContainers.length === 1) {
|
|
13183
13189
|
return childContainers;
|
|
13184
13190
|
}
|
|
@@ -13283,11 +13289,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13283
13289
|
return result;
|
|
13284
13290
|
}
|
|
13285
13291
|
const anchor = "";
|
|
13286
|
-
const logger$
|
|
13292
|
+
const logger$4p = getLogger("text-range");
|
|
13287
13293
|
function getBlockRangeInfo(block, blockOffset) {
|
|
13288
13294
|
const getChildRange = (child, offset) => {
|
|
13289
13295
|
if (isTextBlockContentInsertionChild(child)) {
|
|
13290
|
-
assert(logger$
|
|
13296
|
+
assert(logger$4p, offset === 0, `invalid offset for insertion child: ${offset}`);
|
|
13291
13297
|
const childOffset = 2;
|
|
13292
13298
|
return {
|
|
13293
13299
|
child,
|
|
@@ -13296,7 +13302,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13296
13302
|
};
|
|
13297
13303
|
}
|
|
13298
13304
|
if (isTextBlockContentBoxChild(child)) {
|
|
13299
|
-
assert(logger$
|
|
13305
|
+
assert(logger$4p, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
|
|
13300
13306
|
const childOffset = offset === 0 ? 1 : 2;
|
|
13301
13307
|
return {
|
|
13302
13308
|
child,
|
|
@@ -13305,17 +13311,17 @@ var __publicField = (obj, key, value) => {
|
|
|
13305
13311
|
};
|
|
13306
13312
|
}
|
|
13307
13313
|
const textNode = child.firstChild;
|
|
13308
|
-
assert(logger$
|
|
13309
|
-
assert(logger$
|
|
13314
|
+
assert(logger$4p, textNode, "no child node for text child");
|
|
13315
|
+
assert(logger$4p, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
|
|
13310
13316
|
if (textNode instanceof HTMLBRElement) {
|
|
13311
|
-
assert(logger$
|
|
13317
|
+
assert(logger$4p, offset >= 0 && offset <= 0, "invalid offset for text child");
|
|
13312
13318
|
return {
|
|
13313
13319
|
child,
|
|
13314
13320
|
container: textNode,
|
|
13315
13321
|
offset
|
|
13316
13322
|
};
|
|
13317
13323
|
}
|
|
13318
|
-
assert(logger$
|
|
13324
|
+
assert(logger$4p, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
|
|
13319
13325
|
return {
|
|
13320
13326
|
child,
|
|
13321
13327
|
container: textNode,
|
|
@@ -13344,38 +13350,38 @@ var __publicField = (obj, key, value) => {
|
|
|
13344
13350
|
}
|
|
13345
13351
|
start += childLength;
|
|
13346
13352
|
}
|
|
13347
|
-
assert(logger$
|
|
13353
|
+
assert(logger$4p, false, "failed to get range info");
|
|
13348
13354
|
}
|
|
13349
13355
|
function createChildRange(child, start, end) {
|
|
13350
13356
|
if (start === end) {
|
|
13351
|
-
assert(logger$
|
|
13357
|
+
assert(logger$4p, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
|
|
13352
13358
|
} else {
|
|
13353
|
-
assert(logger$
|
|
13359
|
+
assert(logger$4p, start < end, `invalid start & end: ${start}, ${end}`);
|
|
13354
13360
|
}
|
|
13355
13361
|
if (isTextBlockContentInsertionChild(child)) {
|
|
13356
|
-
assert(logger$
|
|
13357
|
-
assert(logger$
|
|
13362
|
+
assert(logger$4p, start === end, `invalid insertion child range offset: ${start}, ${end}`);
|
|
13363
|
+
assert(logger$4p, start === 0, `invalid insertion child range start: ${start}`);
|
|
13358
13364
|
const insertionElem = child;
|
|
13359
|
-
assert(logger$
|
|
13365
|
+
assert(logger$4p, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
|
|
13360
13366
|
const range = createExpandedRange(insertionElem, 1, insertionElem, 2);
|
|
13361
13367
|
return range;
|
|
13362
13368
|
}
|
|
13363
13369
|
if (isTextBlockContentBoxChild(child)) {
|
|
13364
|
-
assert(logger$
|
|
13365
|
-
assert(logger$
|
|
13370
|
+
assert(logger$4p, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
|
|
13371
|
+
assert(logger$4p, start === 0, `invalid box child range start: ${start}`);
|
|
13366
13372
|
const box = child;
|
|
13367
|
-
assert(logger$
|
|
13373
|
+
assert(logger$4p, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
|
|
13368
13374
|
const range = createExpandedRange(box, 1, box, 2);
|
|
13369
13375
|
return range;
|
|
13370
13376
|
}
|
|
13371
13377
|
const length = getTextBlockContentChildTextLength(child);
|
|
13372
|
-
assert(logger$
|
|
13378
|
+
assert(logger$4p, end <= length, `invalid child end: ${end}, ${length}`);
|
|
13373
13379
|
const textNode = child.firstChild;
|
|
13374
|
-
assert(logger$
|
|
13375
|
-
assert(logger$
|
|
13380
|
+
assert(logger$4p, textNode instanceof Text, "invalid block text child");
|
|
13381
|
+
assert(logger$4p, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
|
|
13376
13382
|
return createExpandedRange(textNode, start, textNode, end);
|
|
13377
13383
|
}
|
|
13378
|
-
const logger$
|
|
13384
|
+
const logger$4o = getLogger("caret-rect");
|
|
13379
13385
|
function getChildClientRects(block, child) {
|
|
13380
13386
|
if (isBox(child)) {
|
|
13381
13387
|
const box = child;
|
|
@@ -13384,7 +13390,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13384
13390
|
const blockContent = getBlockContent(block);
|
|
13385
13391
|
const lineHeight = Number.parseFloat(window.getComputedStyle(blockContent).lineHeight) || boxContent.getBoundingClientRect().height;
|
|
13386
13392
|
const rects = Array.from(boxContent.getClientRects());
|
|
13387
|
-
assert(logger$
|
|
13393
|
+
assert(logger$4o, rects.length > 0, "no box client rects");
|
|
13388
13394
|
const blockRect = blockContent.getBoundingClientRect();
|
|
13389
13395
|
const firstRect = rects[0];
|
|
13390
13396
|
const lastRect = new DOMRect(blockRect.left, firstRect.bottom, 1, lineHeight);
|
|
@@ -13404,22 +13410,22 @@ var __publicField = (obj, key, value) => {
|
|
|
13404
13410
|
const rect2 = getLastClientRect(ranges[0].child);
|
|
13405
13411
|
return new DOMRect(rect2.right, rect2.top, 1, rect2.height);
|
|
13406
13412
|
}
|
|
13407
|
-
assert(logger$
|
|
13413
|
+
assert(logger$4o, ranges[1], "invalid ranges");
|
|
13408
13414
|
const rect = getFirstClientRect(ranges[1].child);
|
|
13409
13415
|
return new DOMRect(rect.left, rect.top, 1, rect.height);
|
|
13410
13416
|
}
|
|
13411
13417
|
let rangeInfo = ranges[0];
|
|
13412
|
-
assert(logger$
|
|
13418
|
+
assert(logger$4o, ranges.length >= 1, "failed to get block range");
|
|
13413
13419
|
if (ranges.length === 1) {
|
|
13414
13420
|
rangeInfo = ranges[0];
|
|
13415
13421
|
} else {
|
|
13416
|
-
assert(logger$
|
|
13422
|
+
assert(logger$4o, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
|
|
13417
13423
|
if (isTextBlockContentInsertionChild(ranges[ranges.length - 1].child)) {
|
|
13418
13424
|
rangeInfo = ranges[ranges.length - 1];
|
|
13419
13425
|
const child = rangeInfo.child;
|
|
13420
13426
|
const content = getInsertionContent(child);
|
|
13421
13427
|
const rects2 = content.getClientRects();
|
|
13422
|
-
assert(logger$
|
|
13428
|
+
assert(logger$4o, rects2.length >= 1, "no client rects for box content");
|
|
13423
13429
|
const rect = rects2[rects2.length - 1];
|
|
13424
13430
|
return new DOMRect(rect.right, rect.y, 1, rect.height);
|
|
13425
13431
|
}
|
|
@@ -13436,9 +13442,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13436
13442
|
}
|
|
13437
13443
|
}
|
|
13438
13444
|
if (rangeInfo.container instanceof HTMLBRElement) {
|
|
13439
|
-
assert(logger$
|
|
13445
|
+
assert(logger$4o, pos.offset === 0, "invalid offset for empty block text");
|
|
13440
13446
|
const parent = rangeInfo.container.parentElement;
|
|
13441
|
-
assert(logger$
|
|
13447
|
+
assert(logger$4o, parent, "invalid br parent");
|
|
13442
13448
|
const rect = parent.getBoundingClientRect();
|
|
13443
13449
|
const ret = new DOMRect(rect.left, rect.top, 1, rect.height);
|
|
13444
13450
|
return ret;
|
|
@@ -13446,11 +13452,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13446
13452
|
const range = createRange(rangeInfo.container, rangeInfo.offset);
|
|
13447
13453
|
const rects = Array.from(range.getClientRects());
|
|
13448
13454
|
if (rects.length === 0) {
|
|
13449
|
-
assert(logger$
|
|
13450
|
-
assert(logger$
|
|
13455
|
+
assert(logger$4o, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
|
|
13456
|
+
assert(logger$4o, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
|
|
13451
13457
|
const child = rangeInfo.child;
|
|
13452
13458
|
const rects2 = getChildClientRects(block, child);
|
|
13453
|
-
assert(logger$
|
|
13459
|
+
assert(logger$4o, rects2.length >= 1, "no client rects for box content");
|
|
13454
13460
|
if (rangeInfo.offset === 1) {
|
|
13455
13461
|
const rect2 = rects2[0];
|
|
13456
13462
|
return new DOMRect(rect2.x, rect2.y, 1, rect2.height);
|
|
@@ -13496,7 +13502,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13496
13502
|
});
|
|
13497
13503
|
}
|
|
13498
13504
|
}
|
|
13499
|
-
assert(logger$
|
|
13505
|
+
assert(logger$4o, rects.length > 0, "no client rects for range");
|
|
13500
13506
|
if (pos.type === "home") {
|
|
13501
13507
|
return rects[rects.length - 1];
|
|
13502
13508
|
}
|
|
@@ -13576,13 +13582,13 @@ var __publicField = (obj, key, value) => {
|
|
|
13576
13582
|
};
|
|
13577
13583
|
}
|
|
13578
13584
|
}
|
|
13579
|
-
const logger$
|
|
13585
|
+
const logger$4n = getLogger("selection-range");
|
|
13580
13586
|
function createEditorSelectionRange(editor, options) {
|
|
13581
13587
|
const { anchor: anchor2, focus } = options;
|
|
13582
13588
|
if (anchor2 instanceof EditorSimpleBlockPosition && focus instanceof EditorSimpleBlockPosition) {
|
|
13583
13589
|
return new EditorSimpleSelectionRange(editor, { anchor: anchor2, focus });
|
|
13584
13590
|
}
|
|
13585
|
-
assert(logger$
|
|
13591
|
+
assert(logger$4n, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
|
|
13586
13592
|
return new EditorComplexSelectionRange(editor, { anchor: anchor2, focus });
|
|
13587
13593
|
}
|
|
13588
13594
|
function createBlockSimpleRange(editor, block, anchor2, focus) {
|
|
@@ -13604,7 +13610,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13604
13610
|
const focus = createSimpleBlockPosition(range.focus.blockId, range.focus.offset, "normal");
|
|
13605
13611
|
return createEditorSelectionRange(editor, { anchor: anchor2, focus });
|
|
13606
13612
|
}
|
|
13607
|
-
const logger$
|
|
13613
|
+
const logger$4m = getLogger("range-from-point");
|
|
13608
13614
|
function getBlockRangeFromPoint(editor, pointX, pointY, dragging) {
|
|
13609
13615
|
const yOffsets = [0, -12, 12];
|
|
13610
13616
|
let x = pointX;
|
|
@@ -13636,7 +13642,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13636
13642
|
const rect = elem.getBoundingClientRect();
|
|
13637
13643
|
if (rect.width && rect.top && i === 0) {
|
|
13638
13644
|
if (rect.left + rect.width < x || rect.top + rect.height < y) {
|
|
13639
|
-
logger$
|
|
13645
|
+
logger$4m.debug("click on scrollbar, out of element rect");
|
|
13640
13646
|
return null;
|
|
13641
13647
|
}
|
|
13642
13648
|
}
|
|
@@ -13674,7 +13680,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13674
13680
|
let block = getLastChildBlock(container);
|
|
13675
13681
|
if (!isVisibleBlock(block)) {
|
|
13676
13682
|
const preBlock = getPrevVisibleBlock(block);
|
|
13677
|
-
assert(logger$
|
|
13683
|
+
assert(logger$4m, preBlock, "container must have visible block");
|
|
13678
13684
|
block = preBlock;
|
|
13679
13685
|
}
|
|
13680
13686
|
const range = getBlockClass(editor, block).getRangeFromPoint(editor, block, x, block.getBoundingClientRect().bottom - 4);
|
|
@@ -13693,7 +13699,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13693
13699
|
if (range instanceof EditorSimpleSelectionRange) {
|
|
13694
13700
|
return range;
|
|
13695
13701
|
}
|
|
13696
|
-
assert(logger$
|
|
13702
|
+
assert(logger$4m, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
|
|
13697
13703
|
const complexRange = range;
|
|
13698
13704
|
const container2 = editor.getContainerById(complexRange.start.childContainerId);
|
|
13699
13705
|
return getRangeInContainer(editor, container2, x, y);
|
|
@@ -13716,7 +13722,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13716
13722
|
});
|
|
13717
13723
|
return getRangeInContainer(editor, container, x, y);
|
|
13718
13724
|
}
|
|
13719
|
-
const logger$
|
|
13725
|
+
const logger$4l = getLogger("adjust-selection-pos");
|
|
13720
13726
|
function getParentContainers(block) {
|
|
13721
13727
|
const containers = [];
|
|
13722
13728
|
while (block) {
|
|
@@ -13726,10 +13732,10 @@ var __publicField = (obj, key, value) => {
|
|
|
13726
13732
|
return containers;
|
|
13727
13733
|
}
|
|
13728
13734
|
const newBlock = getParentBlock(container);
|
|
13729
|
-
assert(logger$
|
|
13735
|
+
assert(logger$4l, newBlock, "child container has not parent container");
|
|
13730
13736
|
block = newBlock;
|
|
13731
13737
|
}
|
|
13732
|
-
assert(logger$
|
|
13738
|
+
assert(logger$4l, false, "should not come here: getParentContainers");
|
|
13733
13739
|
}
|
|
13734
13740
|
function getParentBlockInContainer(container, block) {
|
|
13735
13741
|
while (block) {
|
|
@@ -13738,16 +13744,16 @@ var __publicField = (obj, key, value) => {
|
|
|
13738
13744
|
return block;
|
|
13739
13745
|
}
|
|
13740
13746
|
const newBlock = getParentBlock(parent);
|
|
13741
|
-
assert(logger$
|
|
13747
|
+
assert(logger$4l, newBlock, "could not find parent block for a child container");
|
|
13742
13748
|
block = newBlock;
|
|
13743
13749
|
}
|
|
13744
|
-
assert(logger$
|
|
13750
|
+
assert(logger$4l, false, "no parent block in specified container");
|
|
13745
13751
|
}
|
|
13746
13752
|
function getClosestParentBlock(block1, block2) {
|
|
13747
13753
|
const containers1 = getParentContainers(block1);
|
|
13748
13754
|
const containers2 = getParentContainers(block2);
|
|
13749
|
-
assert(logger$
|
|
13750
|
-
assert(logger$
|
|
13755
|
+
assert(logger$4l, containers1.length > 0 && containers2.length > 0, "block has not parent container");
|
|
13756
|
+
assert(logger$4l, containers1[0] === containers2[0], "root container does not equal");
|
|
13751
13757
|
let parentContainer = containers1[0];
|
|
13752
13758
|
for (let i = 1; i < containers1.length || containers2.length; i++) {
|
|
13753
13759
|
if (containers1[i] === containers2[i]) {
|
|
@@ -13766,23 +13772,23 @@ var __publicField = (obj, key, value) => {
|
|
|
13766
13772
|
}
|
|
13767
13773
|
function getParentContainerInComplexBlock(parentComplexBlock, element) {
|
|
13768
13774
|
let block = getParentBlock(element);
|
|
13769
|
-
assert(logger$
|
|
13775
|
+
assert(logger$4l, block, "element is not in a block");
|
|
13770
13776
|
while (block) {
|
|
13771
13777
|
const container = getParentContainer(block);
|
|
13772
|
-
assert(logger$
|
|
13778
|
+
assert(logger$4l, isChildContainer(container), "not a child container");
|
|
13773
13779
|
const parentBlock = getParentBlock(container);
|
|
13774
|
-
assert(logger$
|
|
13780
|
+
assert(logger$4l, parentBlock, "child container has not parent block");
|
|
13775
13781
|
if (parentBlock === parentComplexBlock) {
|
|
13776
13782
|
return container;
|
|
13777
13783
|
}
|
|
13778
13784
|
block = parentBlock;
|
|
13779
13785
|
}
|
|
13780
|
-
assert(logger$
|
|
13786
|
+
assert(logger$4l, false, "failed to find parent container in complex block");
|
|
13781
13787
|
}
|
|
13782
13788
|
function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
|
|
13783
13789
|
const blockId = getBlockId(complexBlock);
|
|
13784
|
-
assert(logger$
|
|
13785
|
-
assert(logger$
|
|
13790
|
+
assert(logger$4l, blockId === anchor2.blockId, "invalid start pos");
|
|
13791
|
+
assert(logger$4l, blockId === focus.blockId, "invalid end pos");
|
|
13786
13792
|
const blockClass = getComplexBlockClass(editor, complexBlock);
|
|
13787
13793
|
if (blockClass.adjustSelectionPos) {
|
|
13788
13794
|
return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
|
|
@@ -13816,8 +13822,8 @@ var __publicField = (obj, key, value) => {
|
|
|
13816
13822
|
if (focus instanceof EditorComplexBlockPosition) {
|
|
13817
13823
|
focus = createSimpleBlockPosition(focusBlock, getBlockTextLength$6(editor, focusBlock), "end");
|
|
13818
13824
|
}
|
|
13819
|
-
assert(logger$
|
|
13820
|
-
assert(logger$
|
|
13825
|
+
assert(logger$4l, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
|
|
13826
|
+
assert(logger$4l, focus instanceof EditorSimpleBlockPosition, "not valid position type");
|
|
13821
13827
|
return {
|
|
13822
13828
|
anchor: anchor2,
|
|
13823
13829
|
focus
|
|
@@ -13871,7 +13877,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13871
13877
|
focus
|
|
13872
13878
|
};
|
|
13873
13879
|
}
|
|
13874
|
-
const logger$
|
|
13880
|
+
const logger$4k = getLogger("core");
|
|
13875
13881
|
function createBlockAnchor(editor, block, id, refClientRect) {
|
|
13876
13882
|
const tools = getBlockTools(block);
|
|
13877
13883
|
let elem = tools.querySelector(`.block-anchor[data-id=${id}]`);
|
|
@@ -13889,7 +13895,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13889
13895
|
return elem;
|
|
13890
13896
|
}
|
|
13891
13897
|
function createBlockCaretAnchor(editor, block, offset, id) {
|
|
13892
|
-
assert(logger$
|
|
13898
|
+
assert(logger$4k, isTextKindBlock(editor, block), "not a text kind block");
|
|
13893
13899
|
const caretRect = getTextCaretRect(block, createSimpleBlockPosition(block, offset, "normal"));
|
|
13894
13900
|
const blockRect = block.getBoundingClientRect();
|
|
13895
13901
|
const tools = getBlockTools(block);
|
|
@@ -14248,19 +14254,19 @@ var __publicField = (obj, key, value) => {
|
|
|
14248
14254
|
return result + (index2 ? "-" : "") + word.toLowerCase();
|
|
14249
14255
|
});
|
|
14250
14256
|
const kebabCase$1 = kebabCase;
|
|
14251
|
-
const logger$
|
|
14257
|
+
const logger$4j = getLogger("box");
|
|
14252
14258
|
function isBoxOp(op) {
|
|
14253
14259
|
if (!op.attributes)
|
|
14254
14260
|
return false;
|
|
14255
14261
|
if (!op.attributes.box)
|
|
14256
14262
|
return false;
|
|
14257
|
-
assert(logger$
|
|
14258
|
-
assert(logger$
|
|
14263
|
+
assert(logger$4j, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
|
|
14264
|
+
assert(logger$4j, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
|
|
14259
14265
|
return true;
|
|
14260
14266
|
}
|
|
14261
|
-
const logger$
|
|
14267
|
+
const logger$4i = getLogger("text-op");
|
|
14262
14268
|
function getOpLength(op) {
|
|
14263
|
-
assert(logger$
|
|
14269
|
+
assert(logger$4i, typeof op.insert === "string", "invalid op, no insert");
|
|
14264
14270
|
return op.insert.length;
|
|
14265
14271
|
}
|
|
14266
14272
|
function getOpAt(text2, offset) {
|
|
@@ -14268,7 +14274,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14268
14274
|
let pos = 0;
|
|
14269
14275
|
for (let i = 0; i < ops.length; i++) {
|
|
14270
14276
|
const op = ops[i];
|
|
14271
|
-
assert(logger$
|
|
14277
|
+
assert(logger$4i, typeof op.insert === "string", "invalid text op, no insert");
|
|
14272
14278
|
const end = pos + getOpLength(op);
|
|
14273
14279
|
if (end > offset) {
|
|
14274
14280
|
return [op];
|
|
@@ -14284,22 +14290,22 @@ var __publicField = (obj, key, value) => {
|
|
|
14284
14290
|
}
|
|
14285
14291
|
return [];
|
|
14286
14292
|
}
|
|
14287
|
-
const logger$
|
|
14293
|
+
const logger$4h = getLogger("rich-text-length");
|
|
14288
14294
|
function getTextOpLength(op) {
|
|
14289
|
-
assert(logger$
|
|
14295
|
+
assert(logger$4h, typeof op.insert === "string", "op.insert is not string");
|
|
14290
14296
|
return op.insert.length;
|
|
14291
14297
|
}
|
|
14292
14298
|
function getTextLength(ops) {
|
|
14293
14299
|
let count = 0;
|
|
14294
14300
|
ops.forEach((op) => {
|
|
14295
14301
|
if (op.insert) {
|
|
14296
|
-
assert(logger$
|
|
14302
|
+
assert(logger$4h, typeof op.insert === "string", "op.insert is not string");
|
|
14297
14303
|
count += getTextOpLength(op);
|
|
14298
14304
|
}
|
|
14299
14305
|
});
|
|
14300
14306
|
return count;
|
|
14301
14307
|
}
|
|
14302
|
-
const logger$
|
|
14308
|
+
const logger$4g = getLogger("split-text");
|
|
14303
14309
|
function splitText(ops, offset, splitResult) {
|
|
14304
14310
|
ops = cloneDeep__default.default(ops);
|
|
14305
14311
|
if (offset === 0) {
|
|
@@ -14317,8 +14323,8 @@ var __publicField = (obj, key, value) => {
|
|
|
14317
14323
|
let counted = 0;
|
|
14318
14324
|
for (let i = 0; i < ops.length; i++) {
|
|
14319
14325
|
const op = ops[i];
|
|
14320
|
-
assert(logger$
|
|
14321
|
-
assert(logger$
|
|
14326
|
+
assert(logger$4g, typeof op === "object", `invalid op type, ${typeof op}`);
|
|
14327
|
+
assert(logger$4g, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
|
|
14322
14328
|
const subLen = getTextOpLength(op);
|
|
14323
14329
|
if (counted + subLen < offset) {
|
|
14324
14330
|
counted += subLen;
|
|
@@ -14328,18 +14334,18 @@ var __publicField = (obj, key, value) => {
|
|
|
14328
14334
|
right: ops.slice(i + 1)
|
|
14329
14335
|
};
|
|
14330
14336
|
} else {
|
|
14331
|
-
assert(logger$
|
|
14337
|
+
assert(logger$4g, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
|
|
14332
14338
|
const splitIndex = offset - counted;
|
|
14333
14339
|
const copied = cloneDeep__default.default(op);
|
|
14334
|
-
assert(logger$
|
|
14335
|
-
assert(logger$
|
|
14340
|
+
assert(logger$4g, copied.insert, "no copied.insert");
|
|
14341
|
+
assert(logger$4g, typeof copied.insert === "string", "invalid copied.insert type");
|
|
14336
14342
|
copied.insert = copied.insert.substr(0, splitIndex);
|
|
14337
14343
|
op.insert = op.insert.substr(splitIndex);
|
|
14338
14344
|
if (copied.insert === "") {
|
|
14339
|
-
assert(logger$
|
|
14345
|
+
assert(logger$4g, false, "invalid copied.insert, is empty string");
|
|
14340
14346
|
}
|
|
14341
14347
|
if (op.insert === "") {
|
|
14342
|
-
assert(logger$
|
|
14348
|
+
assert(logger$4g, false, "invalid op.insert, is empty string");
|
|
14343
14349
|
}
|
|
14344
14350
|
const right = [
|
|
14345
14351
|
op,
|
|
@@ -14358,9 +14364,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14358
14364
|
throw new Error(`invalid split offset: ${offset}, ${JSON.stringify(ops)}`);
|
|
14359
14365
|
}
|
|
14360
14366
|
function splitToThree(text2, offset, length) {
|
|
14361
|
-
assert(logger$
|
|
14362
|
-
assert(logger$
|
|
14363
|
-
assert(logger$
|
|
14367
|
+
assert(logger$4g, offset >= 0, "invalid offset, < 0");
|
|
14368
|
+
assert(logger$4g, length > 0, "invalid length, <= 0");
|
|
14369
|
+
assert(logger$4g, offset + length <= getTextLength(text2), "invalid offset + length < text length");
|
|
14364
14370
|
const { left: temp, right } = splitText(text2, offset + length);
|
|
14365
14371
|
const { left, right: middle } = splitText(temp, offset);
|
|
14366
14372
|
return { left, middle, right };
|
|
@@ -14583,9 +14589,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14583
14589
|
}
|
|
14584
14590
|
return [color, backgroundColor];
|
|
14585
14591
|
}
|
|
14586
|
-
const logger$
|
|
14592
|
+
const logger$4f = getLogger("text-block-content");
|
|
14587
14593
|
function updateBlockContentCore(editor, blockPath, content, blockText, insertions) {
|
|
14588
|
-
assert(logger$
|
|
14594
|
+
assert(logger$4f, blockText, "no text for block");
|
|
14589
14595
|
if (blockText.length === 0 && (!insertions || insertions.size === 0)) {
|
|
14590
14596
|
content.innerHTML = "<span><br></span>";
|
|
14591
14597
|
return;
|
|
@@ -14617,9 +14623,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14617
14623
|
for (let i2 = 0; i2 < text2.length; i2++) {
|
|
14618
14624
|
const op = text2[i2];
|
|
14619
14625
|
if (isBoxOp(op)) {
|
|
14620
|
-
assert(logger$
|
|
14626
|
+
assert(logger$4f, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
|
|
14621
14627
|
const span2 = editor.editorBoxes.createBox(content, op.attributes);
|
|
14622
|
-
assert(logger$
|
|
14628
|
+
assert(logger$4f, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
|
|
14623
14629
|
const ret = editor.editorBlockRenders.renderBox(blockPath, op.attributes);
|
|
14624
14630
|
if (ret.classes) {
|
|
14625
14631
|
addClass(span2, ...ret.classes);
|
|
@@ -14637,7 +14643,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14637
14643
|
fragment.appendChild(span2);
|
|
14638
14644
|
continue;
|
|
14639
14645
|
}
|
|
14640
|
-
assert(logger$
|
|
14646
|
+
assert(logger$4f, op.insert, `no insert in op: ${JSON.stringify(op)}`);
|
|
14641
14647
|
const span = createElement("span", ["text"], fragment, op.insert);
|
|
14642
14648
|
if (op.attributes) {
|
|
14643
14649
|
const ret = editor.editorBlockRenders.renderText(blockPath, op.attributes);
|
|
@@ -14668,7 +14674,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14668
14674
|
const compositionText = editor.compositingText;
|
|
14669
14675
|
if (compositionText) {
|
|
14670
14676
|
const pos = editor.selection.range.start;
|
|
14671
|
-
assert(logger$
|
|
14677
|
+
assert(logger$4f, pos.isSimple(), "not an simple position while compositing");
|
|
14672
14678
|
if (pos.blockId === blockId) {
|
|
14673
14679
|
const attributes = getAttributesAt(text2, 0);
|
|
14674
14680
|
insertions.set(pos.offset, [{
|
|
@@ -14684,11 +14690,11 @@ var __publicField = (obj, key, value) => {
|
|
|
14684
14690
|
function clearAllTempCompositionText(editor) {
|
|
14685
14691
|
const children = editor.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');
|
|
14686
14692
|
if (children.length) {
|
|
14687
|
-
logger$
|
|
14693
|
+
logger$4f.debug(`remove ${children.length} temp composition span`);
|
|
14688
14694
|
}
|
|
14689
14695
|
Array.from(children).forEach((c) => c.remove());
|
|
14690
14696
|
}
|
|
14691
|
-
const logger$
|
|
14697
|
+
const logger$4e = getLogger("client-rects");
|
|
14692
14698
|
function getChildrenOffsets(block) {
|
|
14693
14699
|
const children = getTextBlockContentChildren(block);
|
|
14694
14700
|
let start = 0;
|
|
@@ -14706,15 +14712,15 @@ var __publicField = (obj, key, value) => {
|
|
|
14706
14712
|
return ret;
|
|
14707
14713
|
}
|
|
14708
14714
|
function getChildrenInRange(editor, block, from, to) {
|
|
14709
|
-
assert(logger$
|
|
14715
|
+
assert(logger$4e, from < to, `invalid from & to: ${from}, ${to}`);
|
|
14710
14716
|
const blockLength = getBlockTextLength$6(editor, block);
|
|
14711
|
-
assert(logger$
|
|
14717
|
+
assert(logger$4e, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
|
|
14712
14718
|
const offsets = getChildrenOffsets(block);
|
|
14713
14719
|
const startIndex = offsets.findIndex((c) => c.startBlockOffset <= from && from < c.endBlockOffset);
|
|
14714
14720
|
const endIndex = offsets.findIndex((c) => c.startBlockOffset < to && to <= c.endBlockOffset);
|
|
14715
|
-
assert(logger$
|
|
14716
|
-
assert(logger$
|
|
14717
|
-
assert(logger$
|
|
14721
|
+
assert(logger$4e, startIndex !== -1, "failed to find start child");
|
|
14722
|
+
assert(logger$4e, endIndex !== -1, "failed to find end child");
|
|
14723
|
+
assert(logger$4e, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
|
|
14718
14724
|
if (startIndex === endIndex) {
|
|
14719
14725
|
const child = offsets[startIndex];
|
|
14720
14726
|
return [{
|
|
@@ -14796,16 +14802,16 @@ var __publicField = (obj, key, value) => {
|
|
|
14796
14802
|
return rects;
|
|
14797
14803
|
}
|
|
14798
14804
|
function getRangeClientRects(editor, block, range) {
|
|
14799
|
-
assert(logger$
|
|
14805
|
+
assert(logger$4e, range instanceof EditorSimpleSelectionRange, "invalid range");
|
|
14800
14806
|
const start = range.start;
|
|
14801
14807
|
const end = range.end;
|
|
14802
|
-
assert(logger$
|
|
14803
|
-
assert(logger$
|
|
14804
|
-
assert(logger$
|
|
14805
|
-
assert(logger$
|
|
14808
|
+
assert(logger$4e, start.isSimple(), "text block only allow simple position");
|
|
14809
|
+
assert(logger$4e, end.isSimple(), "text block only allow simple position");
|
|
14810
|
+
assert(logger$4e, start.blockId === end.blockId, "only allow update one text block selection");
|
|
14811
|
+
assert(logger$4e, start.blockId === getBlockId(block), "only allow update one text block selection");
|
|
14806
14812
|
return getClientRects$2(editor, block, start, end);
|
|
14807
14813
|
}
|
|
14808
|
-
const logger$
|
|
14814
|
+
const logger$4d = getLogger("selection-background");
|
|
14809
14815
|
function getLineHeight(elem) {
|
|
14810
14816
|
const style2 = window.getComputedStyle(elem);
|
|
14811
14817
|
const lineHeightStyle = style2.getPropertyValue("line-height");
|
|
@@ -14825,9 +14831,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14825
14831
|
return lineHeight;
|
|
14826
14832
|
}
|
|
14827
14833
|
function updateSelection$4(editor, block, start, end) {
|
|
14828
|
-
assert(logger$
|
|
14829
|
-
assert(logger$
|
|
14830
|
-
assert(logger$
|
|
14834
|
+
assert(logger$4d, start.isSimple(), "text block only allow simple position");
|
|
14835
|
+
assert(logger$4d, end.isSimple(), "text block only allow simple position");
|
|
14836
|
+
assert(logger$4d, start.blockId === end.blockId, "only allow update one text block selection");
|
|
14831
14837
|
const from = start.offset;
|
|
14832
14838
|
const to = end.offset;
|
|
14833
14839
|
if (from === to) {
|
|
@@ -14886,7 +14892,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14886
14892
|
}
|
|
14887
14893
|
});
|
|
14888
14894
|
}
|
|
14889
|
-
const logger$
|
|
14895
|
+
const logger$4c = getLogger("line-breaker");
|
|
14890
14896
|
function mergeTextRects(rects) {
|
|
14891
14897
|
const result = [];
|
|
14892
14898
|
let lastRect = null;
|
|
@@ -15013,7 +15019,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15013
15019
|
}
|
|
15014
15020
|
const textChild = child;
|
|
15015
15021
|
const rects = mergeTextRects(textChild.getClientRects());
|
|
15016
|
-
assert(logger$
|
|
15022
|
+
assert(logger$4c, rects.length > 0, "invalid text child dom");
|
|
15017
15023
|
if (rects.length === 1) {
|
|
15018
15024
|
const nextChild = children[i + 1];
|
|
15019
15025
|
if (!nextChild) {
|
|
@@ -15038,10 +15044,10 @@ var __publicField = (obj, key, value) => {
|
|
|
15038
15044
|
continue;
|
|
15039
15045
|
}
|
|
15040
15046
|
const textNode = textChild.firstChild;
|
|
15041
|
-
assert(logger$
|
|
15042
|
-
assert(logger$
|
|
15047
|
+
assert(logger$4c, textNode, "invalid text child, no text node");
|
|
15048
|
+
assert(logger$4c, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
|
|
15043
15049
|
const textChildLength = getTextBlockContentChildTextLength(textChild);
|
|
15044
|
-
assert(logger$
|
|
15050
|
+
assert(logger$4c, textNode.data.length === textChildLength, "text node data length not equal child text length");
|
|
15045
15051
|
const textRects = getTextRects(textNode);
|
|
15046
15052
|
for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
|
|
15047
15053
|
const rect = textRects[rIndex];
|
|
@@ -15083,7 +15089,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15083
15089
|
}
|
|
15084
15090
|
}
|
|
15085
15091
|
}
|
|
15086
|
-
assert(logger$
|
|
15092
|
+
assert(logger$4c, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
|
|
15087
15093
|
return {
|
|
15088
15094
|
lineIndex: lineBreaks.length,
|
|
15089
15095
|
lineBreaks
|
|
@@ -23856,7 +23862,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23856
23862
|
const Graphemer_1 = __importDefault(Graphemer$1);
|
|
23857
23863
|
var _default = lib$1.default = Graphemer_1.default;
|
|
23858
23864
|
const splitter = new _default();
|
|
23859
|
-
const logger$
|
|
23865
|
+
const logger$4b = getLogger("text-offset");
|
|
23860
23866
|
function getChildOffset(block, child) {
|
|
23861
23867
|
const children = getTextBlockContentChildren(block);
|
|
23862
23868
|
let start = 0;
|
|
@@ -23872,26 +23878,26 @@ var __publicField = (obj, key, value) => {
|
|
|
23872
23878
|
}
|
|
23873
23879
|
start += testLength;
|
|
23874
23880
|
}
|
|
23875
|
-
assert(logger$
|
|
23881
|
+
assert(logger$4b, false, "can not find child in children");
|
|
23876
23882
|
}
|
|
23877
23883
|
function isValidOffset(block, blockOffset) {
|
|
23878
|
-
assert(logger$
|
|
23884
|
+
assert(logger$4b, blockOffset >= 0, `invalid offset: ${blockOffset}`);
|
|
23879
23885
|
const childInfo = getTextBlockChild(block, blockOffset);
|
|
23880
23886
|
const { prev, next: next2, offset } = childInfo;
|
|
23881
23887
|
if (!prev && !next2) {
|
|
23882
|
-
assert(logger$
|
|
23888
|
+
assert(logger$4b, false, "invalid offset, no prev & next child at offset");
|
|
23883
23889
|
}
|
|
23884
23890
|
if (prev !== next2) {
|
|
23885
23891
|
return true;
|
|
23886
23892
|
}
|
|
23887
23893
|
const child = prev;
|
|
23888
|
-
assert(logger$
|
|
23894
|
+
assert(logger$4b, child, "no child");
|
|
23889
23895
|
if (isTextBlockContentBoxChild(child)) {
|
|
23890
|
-
assert(logger$
|
|
23896
|
+
assert(logger$4b, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
|
|
23891
23897
|
return true;
|
|
23892
23898
|
}
|
|
23893
23899
|
const text2 = child.textContent;
|
|
23894
|
-
assert(logger$
|
|
23900
|
+
assert(logger$4b, text2, "no content for text child");
|
|
23895
23901
|
const chars = splitter.splitGraphemes(text2);
|
|
23896
23902
|
const validOffsets = /* @__PURE__ */ new Set();
|
|
23897
23903
|
let start = 0;
|
|
@@ -23921,7 +23927,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23921
23927
|
}
|
|
23922
23928
|
function getNextValidOffset(block, blockOffset) {
|
|
23923
23929
|
const length = getTextBlockLength(block);
|
|
23924
|
-
assert(logger$
|
|
23930
|
+
assert(logger$4b, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
|
|
23925
23931
|
if (blockOffset === length) {
|
|
23926
23932
|
return length;
|
|
23927
23933
|
}
|
|
@@ -23935,7 +23941,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23935
23941
|
}
|
|
23936
23942
|
return ret;
|
|
23937
23943
|
}
|
|
23938
|
-
const logger$
|
|
23944
|
+
const logger$4a = getLogger("line-offset");
|
|
23939
23945
|
function getLineOffsets(block) {
|
|
23940
23946
|
const lineBreaks = getLineBreaks(block);
|
|
23941
23947
|
const ret = [];
|
|
@@ -23956,7 +23962,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23956
23962
|
}
|
|
23957
23963
|
function getLineOffset(block, lineIndex) {
|
|
23958
23964
|
const lines = getLineOffsets(block);
|
|
23959
|
-
assert(logger$
|
|
23965
|
+
assert(logger$4a, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
|
|
23960
23966
|
return lines[lineIndex];
|
|
23961
23967
|
}
|
|
23962
23968
|
function getLineOffsetByPos(block, pos) {
|
|
@@ -24013,7 +24019,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24013
24019
|
function getLineCount(block) {
|
|
24014
24020
|
return getLineOffsets(block).length;
|
|
24015
24021
|
}
|
|
24016
|
-
const logger$
|
|
24022
|
+
const logger$49 = getLogger("find-text-position");
|
|
24017
24023
|
function isWrappedLine(block, lineIndex) {
|
|
24018
24024
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24019
24025
|
const blockId = getBlockId(block);
|
|
@@ -24024,13 +24030,13 @@ var __publicField = (obj, key, value) => {
|
|
|
24024
24030
|
return false;
|
|
24025
24031
|
}
|
|
24026
24032
|
const childInfo = getTextBlockChild(block, start);
|
|
24027
|
-
assert(logger$
|
|
24028
|
-
assert(logger$
|
|
24033
|
+
assert(logger$49, childInfo.next, "no next child at offset");
|
|
24034
|
+
assert(logger$49, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
|
|
24029
24035
|
return true;
|
|
24030
24036
|
}
|
|
24031
24037
|
function getWrappedLineOffsets(block, lineIndex) {
|
|
24032
24038
|
const blockId = getBlockId(block);
|
|
24033
|
-
assert(logger$
|
|
24039
|
+
assert(logger$49, isWrappedLine(block, lineIndex), "line is not wrapped");
|
|
24034
24040
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24035
24041
|
const homePos = createSimpleBlockPosition(blockId, start, "home");
|
|
24036
24042
|
for (let offset = start + 1; offset <= end; offset += 1) {
|
|
@@ -24045,11 +24051,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24045
24051
|
return offset - 1;
|
|
24046
24052
|
}
|
|
24047
24053
|
}
|
|
24048
|
-
assert(logger$
|
|
24054
|
+
assert(logger$49, false, "failed to find wrapped offset");
|
|
24049
24055
|
return 0;
|
|
24050
24056
|
}
|
|
24051
24057
|
function findTextPositionInLine(editor, block, lineIndex, sourceBlock, pos, findDirection, suggestedX) {
|
|
24052
|
-
assert(logger$
|
|
24058
|
+
assert(logger$49, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
|
|
24053
24059
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24054
24060
|
let from = start;
|
|
24055
24061
|
const blockId = getBlockId(block);
|
|
@@ -24091,11 +24097,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24091
24097
|
return retPos;
|
|
24092
24098
|
}
|
|
24093
24099
|
function findPrevTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
|
|
24094
|
-
assert(logger$
|
|
24100
|
+
assert(logger$49, isTextKindBlock(editor, block), "not a text block");
|
|
24095
24101
|
return findTextPositionInLine(editor, block, getLineCount(block) - 1, sourceBlock, pos, "up", suggestedX);
|
|
24096
24102
|
}
|
|
24097
24103
|
function findNextTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
|
|
24098
|
-
assert(logger$
|
|
24104
|
+
assert(logger$49, isTextKindBlock(editor, block), "not a text block");
|
|
24099
24105
|
return findTextPositionInLine(editor, block, 0, sourceBlock, pos, "down", suggestedX);
|
|
24100
24106
|
}
|
|
24101
24107
|
function moveDown(editor, block, position, suggestedX) {
|
|
@@ -24203,7 +24209,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24203
24209
|
}
|
|
24204
24210
|
return pos;
|
|
24205
24211
|
}
|
|
24206
|
-
const logger$
|
|
24212
|
+
const logger$48 = getLogger("move-caret");
|
|
24207
24213
|
function moveTextCaret(editor, block, position, direction) {
|
|
24208
24214
|
if (direction === "ArrowLeft") {
|
|
24209
24215
|
const ret = moveLeft(block, position);
|
|
@@ -24233,9 +24239,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24233
24239
|
}
|
|
24234
24240
|
return createSimpleBlockPosition(getBlockId(block), ret.offset, ret.type);
|
|
24235
24241
|
}
|
|
24236
|
-
assert(logger$
|
|
24242
|
+
assert(logger$48, false, `invalid navigation direction: ${direction}`);
|
|
24237
24243
|
}
|
|
24238
|
-
const logger$
|
|
24244
|
+
const logger$47 = getLogger("text-range");
|
|
24239
24245
|
function getBlockRects(block) {
|
|
24240
24246
|
const ret = [];
|
|
24241
24247
|
const children = getTextBlockContentChildren(block);
|
|
@@ -24293,9 +24299,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24293
24299
|
return null;
|
|
24294
24300
|
}
|
|
24295
24301
|
const children = getTextBlockContentChildren(block);
|
|
24296
|
-
assert(logger$
|
|
24302
|
+
assert(logger$47, children.indexOf(child) !== -1, "failed to find child in children");
|
|
24297
24303
|
const offsetInfo = getChildOffset(block, child);
|
|
24298
|
-
assert(logger$
|
|
24304
|
+
assert(logger$47, offsetInfo, "failed to get child offset");
|
|
24299
24305
|
const { start } = offsetInfo;
|
|
24300
24306
|
let offset;
|
|
24301
24307
|
let length;
|
|
@@ -24311,7 +24317,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24311
24317
|
}
|
|
24312
24318
|
length = 0;
|
|
24313
24319
|
} else {
|
|
24314
|
-
assert(logger$
|
|
24320
|
+
assert(logger$47, child.firstChild instanceof Text, "child is not text");
|
|
24315
24321
|
offset = start + textNodeOffsetFromPoint(child.firstChild, x, y);
|
|
24316
24322
|
length = 0;
|
|
24317
24323
|
}
|
|
@@ -24335,9 +24341,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24335
24341
|
}
|
|
24336
24342
|
return new EditorSimpleSelectionRange(editor, { anchor: startPos, focus: endPos != null ? endPos : startPos });
|
|
24337
24343
|
}
|
|
24338
|
-
const logger$
|
|
24344
|
+
const logger$46 = getLogger("create-text-op");
|
|
24339
24345
|
function createTextOp(text2, attributes) {
|
|
24340
|
-
assert(logger$
|
|
24346
|
+
assert(logger$46, text2, "text is empty");
|
|
24341
24347
|
const ret = {
|
|
24342
24348
|
insert: text2
|
|
24343
24349
|
};
|
|
@@ -24360,7 +24366,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24360
24366
|
}
|
|
24361
24367
|
return result;
|
|
24362
24368
|
}
|
|
24363
|
-
const logger$
|
|
24369
|
+
const logger$45 = getLogger("merge-ops");
|
|
24364
24370
|
function mergeOps(text2) {
|
|
24365
24371
|
if (text2.length <= 1) {
|
|
24366
24372
|
return text2;
|
|
@@ -24382,10 +24388,10 @@ var __publicField = (obj, key, value) => {
|
|
|
24382
24388
|
return false;
|
|
24383
24389
|
}
|
|
24384
24390
|
if (op1.attributes === void 0) {
|
|
24385
|
-
assert(logger$
|
|
24391
|
+
assert(logger$45, op2.attributes === void 0, "op2.attributes is not undefined");
|
|
24386
24392
|
return true;
|
|
24387
24393
|
}
|
|
24388
|
-
assert(logger$
|
|
24394
|
+
assert(logger$45, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
|
|
24389
24395
|
return isEqual__default.default(op1.attributes, op2.attributes);
|
|
24390
24396
|
};
|
|
24391
24397
|
const newOps = [];
|
|
@@ -24394,8 +24400,8 @@ var __publicField = (obj, key, value) => {
|
|
|
24394
24400
|
for (let i = 1; i < text2.length; i += 1) {
|
|
24395
24401
|
const op = text2[i];
|
|
24396
24402
|
if (isSameTypeOp(before, op)) {
|
|
24397
|
-
assert(logger$
|
|
24398
|
-
assert(logger$
|
|
24403
|
+
assert(logger$45, typeof before.insert === "string", "before.insert is not string");
|
|
24404
|
+
assert(logger$45, typeof op.insert === "string", "op.insert is not string");
|
|
24399
24405
|
before.insert += op.insert;
|
|
24400
24406
|
} else {
|
|
24401
24407
|
newOps.push(op);
|
|
@@ -24423,15 +24429,15 @@ var __publicField = (obj, key, value) => {
|
|
|
24423
24429
|
}
|
|
24424
24430
|
return text2.slice(0, i + 1);
|
|
24425
24431
|
}
|
|
24426
|
-
const logger$
|
|
24432
|
+
const logger$44 = getLogger("delete-text");
|
|
24427
24433
|
function deleteText(richText2, offset, count) {
|
|
24428
24434
|
const { left, right } = splitToThree(richText2, offset, count);
|
|
24429
24435
|
const result = [...left, ...right];
|
|
24430
24436
|
return mergeOps(result);
|
|
24431
24437
|
}
|
|
24432
24438
|
function createDeleteOps(offset, count) {
|
|
24433
|
-
assert(logger$
|
|
24434
|
-
assert(logger$
|
|
24439
|
+
assert(logger$44, offset >= 0, `invalid offset: ${offset}`);
|
|
24440
|
+
assert(logger$44, count >= 1, `invalid delete count: ${count}`);
|
|
24435
24441
|
const ops = [];
|
|
24436
24442
|
if (offset !== 0) {
|
|
24437
24443
|
ops.push({
|
|
@@ -24443,7 +24449,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24443
24449
|
});
|
|
24444
24450
|
return ops;
|
|
24445
24451
|
}
|
|
24446
|
-
const logger$
|
|
24452
|
+
const logger$43 = getLogger("delta");
|
|
24447
24453
|
function diffRichText(oldText, newText) {
|
|
24448
24454
|
const delta1D = new Delta__default.default(oldText);
|
|
24449
24455
|
const delta2D = new Delta__default.default(newText);
|
|
@@ -24453,7 +24459,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24453
24459
|
return new Delta__default.default(ops).transformPosition(cursor, !isLocalOp);
|
|
24454
24460
|
}
|
|
24455
24461
|
function isValidDocText(text2) {
|
|
24456
|
-
assert(logger$
|
|
24462
|
+
assert(logger$43, text2, "ops is null or undefined");
|
|
24457
24463
|
for (let i = 0; i < text2.length; i++) {
|
|
24458
24464
|
const op = text2[i];
|
|
24459
24465
|
if (op.insert === null || op.insert === void 0) {
|
|
@@ -24473,7 +24479,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24473
24479
|
}
|
|
24474
24480
|
class RichText {
|
|
24475
24481
|
static ensureValidText(text2) {
|
|
24476
|
-
assert(logger$
|
|
24482
|
+
assert(logger$43, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
|
|
24477
24483
|
}
|
|
24478
24484
|
static diff(oldText, newText) {
|
|
24479
24485
|
this.ensureValidText(oldText);
|
|
@@ -24495,9 +24501,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24495
24501
|
return resultText;
|
|
24496
24502
|
}
|
|
24497
24503
|
}
|
|
24498
|
-
const logger$
|
|
24504
|
+
const logger$42 = getLogger("insert-text");
|
|
24499
24505
|
function insertText(richText2, offset, text2, attributes) {
|
|
24500
|
-
assert(logger$
|
|
24506
|
+
assert(logger$42, text2, `invalid text to insert: ${text2}`);
|
|
24501
24507
|
const { left, right } = splitText(richText2, offset);
|
|
24502
24508
|
const insertedText = typeof text2 === "string" ? [createTextOp(text2, attributes)] : text2;
|
|
24503
24509
|
const result = [...left, ...insertedText, ...right];
|
|
@@ -24510,7 +24516,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24510
24516
|
};
|
|
24511
24517
|
}
|
|
24512
24518
|
function createInsertOps(offset, text2, attributes) {
|
|
24513
|
-
assert(logger$
|
|
24519
|
+
assert(logger$42, offset >= 0, `invalid offset: ${offset}`);
|
|
24514
24520
|
if (text2.length === 0) {
|
|
24515
24521
|
return [];
|
|
24516
24522
|
}
|
|
@@ -24540,7 +24546,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24540
24546
|
function cloneText(text2) {
|
|
24541
24547
|
return cloneDeep__default.default(text2);
|
|
24542
24548
|
}
|
|
24543
|
-
const logger$
|
|
24549
|
+
const logger$41 = getLogger("update-op-attribute");
|
|
24544
24550
|
function updateOpAttributes(orgOps, key, value, newAttributes) {
|
|
24545
24551
|
const ops = cloneText(orgOps);
|
|
24546
24552
|
const index2 = ops.findIndex((op2) => {
|
|
@@ -24548,7 +24554,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24548
24554
|
return false;
|
|
24549
24555
|
return op2.attributes[key] === value;
|
|
24550
24556
|
});
|
|
24551
|
-
assert(logger$
|
|
24557
|
+
assert(logger$41, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
|
|
24552
24558
|
const op = ops[index2];
|
|
24553
24559
|
op.attributes = {
|
|
24554
24560
|
...op.attributes,
|
|
@@ -24630,11 +24636,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24630
24636
|
]);
|
|
24631
24637
|
}
|
|
24632
24638
|
const FILL_CHAR = "\u200B";
|
|
24633
|
-
const logger$
|
|
24639
|
+
const logger$40 = getLogger("to-plain-text");
|
|
24634
24640
|
function toPlainText(ops, options) {
|
|
24635
24641
|
let text2 = "";
|
|
24636
24642
|
ops.forEach((op) => {
|
|
24637
|
-
assert(logger$
|
|
24643
|
+
assert(logger$40, typeof op.insert === "string", "invalid op");
|
|
24638
24644
|
if (op.attributes && op.attributes.box === true) {
|
|
24639
24645
|
if (options == null ? void 0 : options.boxReplacement) {
|
|
24640
24646
|
text2 += options.boxReplacement;
|
|
@@ -24689,11 +24695,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24689
24695
|
focus: pos
|
|
24690
24696
|
};
|
|
24691
24697
|
}
|
|
24692
|
-
const logger$
|
|
24698
|
+
const logger$3$ = getLogger("block-to-text");
|
|
24693
24699
|
function textBlockToText$1(editor, ops, doc2) {
|
|
24694
24700
|
let text2 = "";
|
|
24695
24701
|
ops.forEach((op) => {
|
|
24696
|
-
assert(logger$
|
|
24702
|
+
assert(logger$3$, typeof op.insert === "string", "invalid op");
|
|
24697
24703
|
if (op.attributes && op.attributes.box === true) {
|
|
24698
24704
|
const box = op.attributes;
|
|
24699
24705
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -24711,11 +24717,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24711
24717
|
});
|
|
24712
24718
|
return text2;
|
|
24713
24719
|
}
|
|
24714
|
-
const logger$
|
|
24720
|
+
const logger$3_ = getLogger("block-to-text");
|
|
24715
24721
|
function textToMarkdownText(editor, ops, doc2) {
|
|
24716
24722
|
let text2 = "";
|
|
24717
24723
|
ops.forEach((op) => {
|
|
24718
|
-
assert(logger$
|
|
24724
|
+
assert(logger$3_, typeof op.insert === "string", "invalid op");
|
|
24719
24725
|
if (op.attributes && op.attributes.box === true) {
|
|
24720
24726
|
const box = op.attributes;
|
|
24721
24727
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -24838,12 +24844,12 @@ var __publicField = (obj, key, value) => {
|
|
|
24838
24844
|
return void 0;
|
|
24839
24845
|
}
|
|
24840
24846
|
}
|
|
24841
|
-
const logger$
|
|
24847
|
+
const logger$3Z = getLogger("block-to-text");
|
|
24842
24848
|
function textBlockToHtml(editor, blockData, doc2) {
|
|
24843
24849
|
let html = "";
|
|
24844
24850
|
const ops = blockData.text || [];
|
|
24845
24851
|
ops.forEach((op) => {
|
|
24846
|
-
assert(logger$
|
|
24852
|
+
assert(logger$3Z, typeof op.insert === "string", "invalid op");
|
|
24847
24853
|
if (op.attributes && op.attributes.box === true) {
|
|
24848
24854
|
const box = op.attributes;
|
|
24849
24855
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -24919,16 +24925,16 @@ var __publicField = (obj, key, value) => {
|
|
|
24919
24925
|
}
|
|
24920
24926
|
return `<p>${html}</p>`;
|
|
24921
24927
|
}
|
|
24922
|
-
const logger$
|
|
24928
|
+
const logger$3Y = getLogger("text-block");
|
|
24923
24929
|
function createBlockContent$5(editor, path, container, blockElement, blockData) {
|
|
24924
24930
|
const { text: text2 } = blockData;
|
|
24925
|
-
assert(logger$
|
|
24931
|
+
assert(logger$3Y, text2, "no text for text block");
|
|
24926
24932
|
const content = createBlockContentElement(blockElement, "div");
|
|
24927
24933
|
updateBlockContent$1(editor, path, blockData.id, content, text2);
|
|
24928
24934
|
return content;
|
|
24929
24935
|
}
|
|
24930
24936
|
function updateBlockText$1(editor, block, text2) {
|
|
24931
|
-
assert(logger$
|
|
24937
|
+
assert(logger$3Y, text2, "no text to update");
|
|
24932
24938
|
const newContent = createBlockContentElement(null, "div");
|
|
24933
24939
|
updateBlockContent$1(editor, getBlockPath(block), getBlockId(block), newContent, text2);
|
|
24934
24940
|
const oldContent = getBlockContent(block);
|
|
@@ -24938,7 +24944,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24938
24944
|
return getRangeClientRects(editor, block, range);
|
|
24939
24945
|
}
|
|
24940
24946
|
function convertTo$k(editor, blockData, doc2, type) {
|
|
24941
|
-
assert(logger$
|
|
24947
|
+
assert(logger$3Y, blockData.text, "no text for text block");
|
|
24942
24948
|
if (type === "text") {
|
|
24943
24949
|
return textBlockToText$1(editor, blockData.text, doc2);
|
|
24944
24950
|
}
|
|
@@ -24952,7 +24958,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24952
24958
|
blockData.id = genId();
|
|
24953
24959
|
info == null ? void 0 : info.blockIdMap.set(srcBlockData.id, blockData.id);
|
|
24954
24960
|
const { text: text2 } = blockData;
|
|
24955
|
-
assert(logger$
|
|
24961
|
+
assert(logger$3Y, text2, "no text for text block");
|
|
24956
24962
|
text2.forEach((op) => {
|
|
24957
24963
|
if (op.insert && op.attributes && op.attributes.box === true) {
|
|
24958
24964
|
const boxId = genId();
|
|
@@ -24984,7 +24990,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24984
24990
|
blockToDoc: blockToDoc$1
|
|
24985
24991
|
};
|
|
24986
24992
|
const updateTextBlockContent = updateBlockContent$1;
|
|
24987
|
-
const logger$
|
|
24993
|
+
const logger$3X = getLogger("action-helper");
|
|
24988
24994
|
function editorGetBlockData(editor, block) {
|
|
24989
24995
|
const container = getParentContainer(block);
|
|
24990
24996
|
const containerId = getContainerId(container);
|
|
@@ -24992,10 +24998,10 @@ var __publicField = (obj, key, value) => {
|
|
|
24992
24998
|
return editor.doc.getBlockData(containerId, blockIndex);
|
|
24993
24999
|
}
|
|
24994
25000
|
function editorGetBlockText(editor, block) {
|
|
24995
|
-
assert(logger$
|
|
25001
|
+
assert(logger$3X, isTextKindBlock(editor, block), "not a text kind block");
|
|
24996
25002
|
const data2 = editorGetBlockData(editor, block);
|
|
24997
25003
|
const text2 = data2.text;
|
|
24998
|
-
assert(logger$
|
|
25004
|
+
assert(logger$3X, text2, "no text in block");
|
|
24999
25005
|
return text2;
|
|
25000
25006
|
}
|
|
25001
25007
|
function editorGetBlockTextEx(editor, block, length) {
|
|
@@ -25003,7 +25009,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25003
25009
|
}
|
|
25004
25010
|
function editorGetBoxData(editor, box) {
|
|
25005
25011
|
const block = getParentBlock(box);
|
|
25006
|
-
assert(logger$
|
|
25012
|
+
assert(logger$3X, block, "no parent block");
|
|
25007
25013
|
const text2 = editorGetBlockText(editor, block);
|
|
25008
25014
|
const id = getBoxId(box);
|
|
25009
25015
|
const op = text2.find((op2) => {
|
|
@@ -25013,60 +25019,60 @@ var __publicField = (obj, key, value) => {
|
|
|
25013
25019
|
}
|
|
25014
25020
|
return false;
|
|
25015
25021
|
});
|
|
25016
|
-
assert(logger$
|
|
25022
|
+
assert(logger$3X, op, "failed to find box");
|
|
25017
25023
|
return op.attributes;
|
|
25018
25024
|
}
|
|
25019
|
-
const logger$
|
|
25025
|
+
const logger$3W = getLogger("block-text");
|
|
25020
25026
|
function getTextAfterOffset(editor, block, offset) {
|
|
25021
|
-
assert(logger$
|
|
25022
|
-
assert(logger$
|
|
25023
|
-
assert(logger$
|
|
25027
|
+
assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
|
|
25028
|
+
assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
|
|
25029
|
+
assert(logger$3W, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25024
25030
|
const newOffset = getNextValidOffset(block, offset);
|
|
25025
25031
|
const length = newOffset - offset;
|
|
25026
25032
|
if (length === 0) {
|
|
25027
|
-
assert(logger$
|
|
25033
|
+
assert(logger$3W, false, `no text after offset: ${offset}`);
|
|
25028
25034
|
}
|
|
25029
25035
|
const text2 = editorGetBlockText(editor, block);
|
|
25030
25036
|
const { middle } = splitToThree(text2, offset, length);
|
|
25031
|
-
assert(logger$
|
|
25037
|
+
assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
|
|
25032
25038
|
const op = middle[0];
|
|
25033
25039
|
if (isBoxOp(op)) {
|
|
25034
25040
|
return " ";
|
|
25035
25041
|
}
|
|
25036
|
-
assert(logger$
|
|
25042
|
+
assert(logger$3W, op.insert.length === 1 || op.insert.length === 2, "invalid op");
|
|
25037
25043
|
return op.insert;
|
|
25038
25044
|
}
|
|
25039
25045
|
function getTextBeforeOffset(editor, block, offset) {
|
|
25040
|
-
assert(logger$
|
|
25041
|
-
assert(logger$
|
|
25042
|
-
assert(logger$
|
|
25046
|
+
assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
|
|
25047
|
+
assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
|
|
25048
|
+
assert(logger$3W, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25043
25049
|
const newOffset = getPrevValidOffset(block, offset);
|
|
25044
25050
|
const length = offset - newOffset;
|
|
25045
25051
|
if (length === 0) {
|
|
25046
|
-
assert(logger$
|
|
25052
|
+
assert(logger$3W, false, `no text before offset: ${offset}`);
|
|
25047
25053
|
}
|
|
25048
25054
|
const text2 = editorGetBlockText(editor, block);
|
|
25049
25055
|
const { middle } = splitToThree(text2, newOffset, length);
|
|
25050
|
-
assert(logger$
|
|
25056
|
+
assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
|
|
25051
25057
|
const op = middle[0];
|
|
25052
25058
|
if (isBoxOp(op)) {
|
|
25053
25059
|
return " ";
|
|
25054
25060
|
}
|
|
25055
|
-
assert(logger$
|
|
25061
|
+
assert(logger$3W, op.insert.length === 1 || op.insert.length === 2, "invalid op");
|
|
25056
25062
|
return op.insert;
|
|
25057
25063
|
}
|
|
25058
25064
|
function getOffsetInfoBefore(editor, block, offset) {
|
|
25059
|
-
assert(logger$
|
|
25060
|
-
assert(logger$
|
|
25061
|
-
assert(logger$
|
|
25065
|
+
assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
|
|
25066
|
+
assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
|
|
25067
|
+
assert(logger$3W, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25062
25068
|
const newOffset = getPrevValidOffset(block, offset);
|
|
25063
25069
|
const length = offset - newOffset;
|
|
25064
25070
|
if (length === 0) {
|
|
25065
|
-
assert(logger$
|
|
25071
|
+
assert(logger$3W, false, `no text before offset: ${offset}`);
|
|
25066
25072
|
}
|
|
25067
25073
|
const text2 = editorGetBlockText(editor, block);
|
|
25068
25074
|
const { middle } = splitToThree(text2, newOffset, length);
|
|
25069
|
-
assert(logger$
|
|
25075
|
+
assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
|
|
25070
25076
|
const op = middle[0];
|
|
25071
25077
|
if (isBoxOp(op)) {
|
|
25072
25078
|
return {
|
|
@@ -25084,17 +25090,17 @@ var __publicField = (obj, key, value) => {
|
|
|
25084
25090
|
};
|
|
25085
25091
|
}
|
|
25086
25092
|
function getOffsetInfoAfter(editor, block, offset) {
|
|
25087
|
-
assert(logger$
|
|
25088
|
-
assert(logger$
|
|
25089
|
-
assert(logger$
|
|
25093
|
+
assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
|
|
25094
|
+
assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
|
|
25095
|
+
assert(logger$3W, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25090
25096
|
const newOffset = getNextValidOffset(block, offset);
|
|
25091
25097
|
const length = newOffset - offset;
|
|
25092
25098
|
if (length === 0) {
|
|
25093
|
-
assert(logger$
|
|
25099
|
+
assert(logger$3W, false, `no text after offset: ${offset}`);
|
|
25094
25100
|
}
|
|
25095
25101
|
const text2 = editorGetBlockText(editor, block);
|
|
25096
25102
|
const { middle } = splitToThree(text2, offset, length);
|
|
25097
|
-
assert(logger$
|
|
25103
|
+
assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
|
|
25098
25104
|
const op = middle[0];
|
|
25099
25105
|
if (isBoxOp(op)) {
|
|
25100
25106
|
return {
|
|
@@ -25158,7 +25164,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25158
25164
|
return null;
|
|
25159
25165
|
}
|
|
25160
25166
|
function findWordLeft(editor, block, offset) {
|
|
25161
|
-
assert(logger$
|
|
25167
|
+
assert(logger$3W, isTextKindBlock(editor, block), "invalid blok type");
|
|
25162
25168
|
if (isEmptyTextBlock(editor, block)) {
|
|
25163
25169
|
return 0;
|
|
25164
25170
|
}
|
|
@@ -25186,7 +25192,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25186
25192
|
return startInfo.offset + startInfo.length;
|
|
25187
25193
|
}
|
|
25188
25194
|
function findWordEnd(editor, block, offset) {
|
|
25189
|
-
assert(logger$
|
|
25195
|
+
assert(logger$3W, isTextKindBlock(editor, block), "invalid blok type");
|
|
25190
25196
|
if (isEmptyTextBlock(editor, block)) {
|
|
25191
25197
|
return 0;
|
|
25192
25198
|
}
|
|
@@ -25213,10 +25219,10 @@ var __publicField = (obj, key, value) => {
|
|
|
25213
25219
|
return getBlockTextLength$6(editor, block);
|
|
25214
25220
|
return startInfo.offset;
|
|
25215
25221
|
}
|
|
25216
|
-
const logger$
|
|
25222
|
+
const logger$3V = getLogger("text-box");
|
|
25217
25223
|
function updateBoxContent$8(editor, boxElement, boxContent, boxData) {
|
|
25218
|
-
assert(logger$
|
|
25219
|
-
assert(logger$
|
|
25224
|
+
assert(logger$3V, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
|
|
25225
|
+
assert(logger$3V, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
|
|
25220
25226
|
createElement("span", [], boxContent, boxData.text);
|
|
25221
25227
|
}
|
|
25222
25228
|
function convertTo$j(editor, boxData, doc2, type) {
|
|
@@ -25250,7 +25256,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25250
25256
|
updateBoxContent: updateBoxContent$7,
|
|
25251
25257
|
convertTo: convertTo$i
|
|
25252
25258
|
};
|
|
25253
|
-
const logger$
|
|
25259
|
+
const logger$3U = getLogger("editor-boxes");
|
|
25254
25260
|
class EditorBoxes {
|
|
25255
25261
|
constructor(editor) {
|
|
25256
25262
|
__publicField(this, "boxes", /* @__PURE__ */ new Map());
|
|
@@ -25259,12 +25265,12 @@ var __publicField = (obj, key, value) => {
|
|
|
25259
25265
|
registerBoxClass(boxClass) {
|
|
25260
25266
|
const type = boxClass.boxType;
|
|
25261
25267
|
const exists = this.boxes.get(type);
|
|
25262
|
-
assert(logger$
|
|
25268
|
+
assert(logger$3U, !exists, `duplicated box type: ${type}`);
|
|
25263
25269
|
this.boxes.set(type, boxClass);
|
|
25264
25270
|
}
|
|
25265
25271
|
getBoxClass(type) {
|
|
25266
25272
|
const exists = this.boxes.get(type);
|
|
25267
|
-
assert(logger$
|
|
25273
|
+
assert(logger$3U, exists, `unknown box type: ${type}`);
|
|
25268
25274
|
return exists;
|
|
25269
25275
|
}
|
|
25270
25276
|
createBox(blockContent, box) {
|
|
@@ -25629,7 +25635,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25629
25635
|
return { classes, attributes: newAttributes, styles: newStyles };
|
|
25630
25636
|
}
|
|
25631
25637
|
}
|
|
25632
|
-
const logger$
|
|
25638
|
+
const logger$3T = getLogger("editor-insertion");
|
|
25633
25639
|
class EditorInsertions {
|
|
25634
25640
|
constructor(editor) {
|
|
25635
25641
|
__publicField(this, "insertions", /* @__PURE__ */ new Map());
|
|
@@ -25638,12 +25644,12 @@ var __publicField = (obj, key, value) => {
|
|
|
25638
25644
|
registerInsertionClass(insertionClass) {
|
|
25639
25645
|
const type = insertionClass.insertionType;
|
|
25640
25646
|
const exists = this.insertions.get(type);
|
|
25641
|
-
assert(logger$
|
|
25647
|
+
assert(logger$3T, !exists, `duplicated insertion type: ${type}`);
|
|
25642
25648
|
this.insertions.set(type, insertionClass);
|
|
25643
25649
|
}
|
|
25644
25650
|
getInsertionClass(type) {
|
|
25645
25651
|
const exists = this.insertions.get(type);
|
|
25646
|
-
assert(logger$
|
|
25652
|
+
assert(logger$3T, exists, `unknown insertion type: ${type}`);
|
|
25647
25653
|
return exists;
|
|
25648
25654
|
}
|
|
25649
25655
|
createInsertionElement(type, id, attributes) {
|
|
@@ -25763,7 +25769,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25763
25769
|
};
|
|
25764
25770
|
}
|
|
25765
25771
|
}
|
|
25766
|
-
const logger$
|
|
25772
|
+
const logger$3S = getLogger("editor-input");
|
|
25767
25773
|
class EditorInput$1 {
|
|
25768
25774
|
constructor(editor, callbacks) {
|
|
25769
25775
|
__publicField(this, "editor");
|
|
@@ -25885,7 +25891,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25885
25891
|
return;
|
|
25886
25892
|
}
|
|
25887
25893
|
this.callbacks.onCut(event);
|
|
25888
|
-
logger$
|
|
25894
|
+
logger$3S.debug("on cut");
|
|
25889
25895
|
});
|
|
25890
25896
|
__publicField(this, "handlePaste", (event) => {
|
|
25891
25897
|
if (event.isTrusted) {
|
|
@@ -26000,11 +26006,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26000
26006
|
this.callbacks.removeHandler(handler);
|
|
26001
26007
|
}
|
|
26002
26008
|
defaultInsertText(editor, containerId, blockIndex, offset, text2) {
|
|
26003
|
-
assert(logger$
|
|
26009
|
+
assert(logger$3S, editor === this.editor, "invalid editor");
|
|
26004
26010
|
this.callbacks.defaultInsertText(editor, containerId, blockIndex, offset, text2);
|
|
26005
26011
|
}
|
|
26006
26012
|
defaultHandleKeydown(editor, event) {
|
|
26007
|
-
assert(logger$
|
|
26013
|
+
assert(logger$3S, editor === this.editor, "invalid editor");
|
|
26008
26014
|
return this.callbacks.defaultHandleKeydown(editor, event);
|
|
26009
26015
|
}
|
|
26010
26016
|
forEach(callback) {
|
|
@@ -26029,7 +26035,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26029
26035
|
input2.style.left = `${x / scale}px`;
|
|
26030
26036
|
input2.style.top = `${y / scale}px`;
|
|
26031
26037
|
}
|
|
26032
|
-
const logger$
|
|
26038
|
+
const logger$3R = getLogger("editor-caret");
|
|
26033
26039
|
function getFirefoxVersion() {
|
|
26034
26040
|
const userAgent = window.navigator.userAgent;
|
|
26035
26041
|
const match = userAgent.match(/Firefox\/(\d+)\./);
|
|
@@ -26092,11 +26098,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26092
26098
|
return;
|
|
26093
26099
|
}
|
|
26094
26100
|
const { range } = this.editor.selection;
|
|
26095
|
-
assert(logger$
|
|
26101
|
+
assert(logger$3R, range.isCollapsed, "range is not collapsed");
|
|
26096
26102
|
const pos = range.start;
|
|
26097
|
-
assert(logger$
|
|
26103
|
+
assert(logger$3R, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
|
|
26098
26104
|
const block = this.editor.getBlockById(pos.blockId);
|
|
26099
|
-
assert(logger$
|
|
26105
|
+
assert(logger$3R, isTextKindBlock(this.editor, block), "only text kind block can has caret");
|
|
26100
26106
|
let rect;
|
|
26101
26107
|
const compositionSpan = block.querySelector("span.inputting-insertion");
|
|
26102
26108
|
if (compositionSpan) {
|
|
@@ -26134,7 +26140,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26134
26140
|
clearAllSelection(editor);
|
|
26135
26141
|
editor.selection.range.getSelectedBlocks().forEach((s) => updateBlockSelection(editor, s.block, s.start, s.end));
|
|
26136
26142
|
}
|
|
26137
|
-
const logger$
|
|
26143
|
+
const logger$3Q = getLogger("editor-dom");
|
|
26138
26144
|
function editorGetClientHeight(editor) {
|
|
26139
26145
|
const scrollContainer = getScrollContainer$1(editor.rootContainer);
|
|
26140
26146
|
return scrollContainer.clientHeight;
|
|
@@ -26222,7 +26228,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26222
26228
|
}
|
|
26223
26229
|
function editorScrollIntoView(editor) {
|
|
26224
26230
|
if (!isElementVisible(editor.rootContainer)) {
|
|
26225
|
-
logger$
|
|
26231
|
+
logger$3Q.warn("editorScrollIntoView: editor is not visible");
|
|
26226
26232
|
return;
|
|
26227
26233
|
}
|
|
26228
26234
|
const rootClientRect = editor.rootContainer.getBoundingClientRect();
|
|
@@ -26287,7 +26293,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26287
26293
|
const { start, end } = range;
|
|
26288
26294
|
return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
|
|
26289
26295
|
}
|
|
26290
|
-
const logger$
|
|
26296
|
+
const logger$3P = getLogger("range-in-block");
|
|
26291
26297
|
function rangeInBlock(block, range) {
|
|
26292
26298
|
const editor = range.getEditor();
|
|
26293
26299
|
const start = editor.getBlockById(range.start.blockId);
|
|
@@ -26308,16 +26314,16 @@ var __publicField = (obj, key, value) => {
|
|
|
26308
26314
|
while (prevBlock && !blocks.has(getBlockId(prevBlock))) {
|
|
26309
26315
|
prevBlock = getPrevVisibleBlock(prevBlock);
|
|
26310
26316
|
}
|
|
26311
|
-
assert(logger$
|
|
26317
|
+
assert(logger$3P, prevBlock, "no prev block while deleting a block");
|
|
26312
26318
|
newRange = createBlockSimpleRange(editor, prevBlock, getBlockTextLength$6(editor, prevBlock));
|
|
26313
26319
|
} else {
|
|
26314
26320
|
const nextBlock = getNextVisibleBlock(block);
|
|
26315
|
-
assert(logger$
|
|
26321
|
+
assert(logger$3P, nextBlock, "no prev and next block while deleting a block");
|
|
26316
26322
|
newRange = createBlockSimpleRange(editor, nextBlock, 0);
|
|
26317
26323
|
}
|
|
26318
26324
|
return newRange;
|
|
26319
26325
|
}
|
|
26320
|
-
const logger$
|
|
26326
|
+
const logger$3O = getLogger("block-to-html");
|
|
26321
26327
|
function blockToHtml(editor, blockData, doc2, path) {
|
|
26322
26328
|
const blockClass = getBlockClassByType(editor, blockData.type);
|
|
26323
26329
|
if (blockClass.convertTo) {
|
|
@@ -26326,15 +26332,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26326
26332
|
if (blockClass.blockKind !== "text") {
|
|
26327
26333
|
return `[${blockData.type}]`;
|
|
26328
26334
|
}
|
|
26329
|
-
assert(logger$
|
|
26335
|
+
assert(logger$3O, blockData.text, "no text");
|
|
26330
26336
|
const plainText = toPlainText(blockData.text);
|
|
26331
26337
|
return `<div>${escapeHtmlText(plainText)}</div>`;
|
|
26332
26338
|
}
|
|
26333
|
-
const logger$
|
|
26339
|
+
const logger$3N = getLogger("block-to-text");
|
|
26334
26340
|
function textBlockToText(editor, ops, doc2) {
|
|
26335
26341
|
let text2 = "";
|
|
26336
26342
|
ops.forEach((op) => {
|
|
26337
|
-
assert(logger$
|
|
26343
|
+
assert(logger$3N, typeof op.insert === "string", "invalid op");
|
|
26338
26344
|
if (op.attributes && op.attributes.box === true) {
|
|
26339
26345
|
const box = op.attributes;
|
|
26340
26346
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -26360,7 +26366,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26360
26366
|
if (blockClass.blockKind !== "text") {
|
|
26361
26367
|
return `[${blockData.type}]`;
|
|
26362
26368
|
}
|
|
26363
|
-
assert(logger$
|
|
26369
|
+
assert(logger$3N, blockData.text, "no text");
|
|
26364
26370
|
const plainText = textBlockToText(editor, blockData.text, doc2);
|
|
26365
26371
|
return plainText;
|
|
26366
26372
|
}
|
|
@@ -26393,11 +26399,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26393
26399
|
const markdown = lines.join("\n");
|
|
26394
26400
|
return markdown;
|
|
26395
26401
|
}
|
|
26396
|
-
const logger$
|
|
26402
|
+
const logger$3M = getLogger("get-text-position");
|
|
26397
26403
|
function editorGetTextPosition(editor, insertPos) {
|
|
26398
26404
|
const pos = insertPos != null ? insertPos : editor.selection.range.start;
|
|
26399
26405
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
26400
|
-
assert(logger$
|
|
26406
|
+
assert(logger$3M, false, `invalid insert pos type: ${typeof pos}`);
|
|
26401
26407
|
}
|
|
26402
26408
|
const { blockId } = pos;
|
|
26403
26409
|
const block = editor.getBlockById(blockId);
|
|
@@ -26485,14 +26491,14 @@ var __publicField = (obj, key, value) => {
|
|
|
26485
26491
|
return attributes;
|
|
26486
26492
|
}
|
|
26487
26493
|
}
|
|
26488
|
-
const logger$
|
|
26494
|
+
const logger$3L = getLogger("insert-text");
|
|
26489
26495
|
function getTextAttributes(editor, containerId, blockIndex, offset) {
|
|
26490
26496
|
var _a, _b;
|
|
26491
26497
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26492
|
-
assert(logger$
|
|
26493
|
-
assert(logger$
|
|
26498
|
+
assert(logger$3L, blockData, "no block data");
|
|
26499
|
+
assert(logger$3L, blockData.text, "no block text");
|
|
26494
26500
|
if (getTextLength(blockData.text) === 0) {
|
|
26495
|
-
assert(logger$
|
|
26501
|
+
assert(logger$3L, offset === 0, "invalid text offset");
|
|
26496
26502
|
return BlockAttributesHandler.get(editor).getEmptyBlockTextAttributes(blockData.id);
|
|
26497
26503
|
}
|
|
26498
26504
|
if (offset === 0) {
|
|
@@ -26539,7 +26545,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26539
26545
|
}
|
|
26540
26546
|
for (let i = 0; i < text2.length; i++) {
|
|
26541
26547
|
const op = text2[i];
|
|
26542
|
-
assert(logger$
|
|
26548
|
+
assert(logger$3L, typeof op.insert === "string", "invalid text op, no insert");
|
|
26543
26549
|
const endPos = pos + getOpLength(op);
|
|
26544
26550
|
if (endPos === start) {
|
|
26545
26551
|
return false;
|
|
@@ -26553,8 +26559,8 @@ var __publicField = (obj, key, value) => {
|
|
|
26553
26559
|
}
|
|
26554
26560
|
function editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset) {
|
|
26555
26561
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26556
|
-
assert(logger$
|
|
26557
|
-
assert(logger$
|
|
26562
|
+
assert(logger$3L, blockData, "no block data");
|
|
26563
|
+
assert(logger$3L, blockData.text, "no block text");
|
|
26558
26564
|
const attributes = getTextAttributes(editor, containerId, blockIndex, offset);
|
|
26559
26565
|
if (attributes && Object.keys(attributes).includes("link")) {
|
|
26560
26566
|
const inOp = checkRangeInOp(blockData.text, offset);
|
|
@@ -26573,21 +26579,21 @@ var __publicField = (obj, key, value) => {
|
|
|
26573
26579
|
const { containerId, blockIndex, offset } = editorGetTextPosition(editor);
|
|
26574
26580
|
editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset);
|
|
26575
26581
|
}
|
|
26576
|
-
const logger$
|
|
26582
|
+
const logger$3K = getLogger("update-composition-text");
|
|
26577
26583
|
function editorUpdateCompositionText(editor) {
|
|
26578
26584
|
const pos = editor.selection.range.start;
|
|
26579
26585
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
26580
|
-
assert(logger$
|
|
26586
|
+
assert(logger$3K, false, `invalid insert pos type: ${typeof pos}`);
|
|
26581
26587
|
}
|
|
26582
26588
|
const { blockId } = pos;
|
|
26583
26589
|
const block = editor.getBlockById(blockId);
|
|
26584
|
-
assert(logger$
|
|
26590
|
+
assert(logger$3K, isTextKindBlock(editor, block), "not a text kind block");
|
|
26585
26591
|
const container = getParentContainer(block);
|
|
26586
26592
|
const containerId = getContainerId(container);
|
|
26587
26593
|
const blockIndex = getBlockIndex(block);
|
|
26588
26594
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26589
|
-
assert(logger$
|
|
26590
|
-
assert(logger$
|
|
26595
|
+
assert(logger$3K, blockData, "no block data in doc");
|
|
26596
|
+
assert(logger$3K, blockData.text, "no text data in text block");
|
|
26591
26597
|
const blockContent = getBlockContent(block);
|
|
26592
26598
|
updateBlockContent$1(editor, getBlockPath(block), blockId, blockContent, blockData.text);
|
|
26593
26599
|
}
|
|
@@ -26599,25 +26605,25 @@ var __publicField = (obj, key, value) => {
|
|
|
26599
26605
|
const block = editor.getBlockById(blockData.id);
|
|
26600
26606
|
return block;
|
|
26601
26607
|
}
|
|
26602
|
-
const logger$
|
|
26608
|
+
const logger$3J = getLogger("delete-block-text");
|
|
26603
26609
|
function editorDeleteBlockText(editor, block, offset, count, options) {
|
|
26604
26610
|
if (!editor.isBlockWritable(block)) {
|
|
26605
|
-
logger$
|
|
26611
|
+
logger$3J.error("block is not writable");
|
|
26606
26612
|
return 0;
|
|
26607
26613
|
}
|
|
26608
|
-
assert(logger$
|
|
26614
|
+
assert(logger$3J, isTextKindBlock(editor, block), "block is not a text kind block");
|
|
26609
26615
|
const container = getParentContainer(block);
|
|
26610
26616
|
const containerId = getContainerId(container);
|
|
26611
26617
|
const blockIndex = getBlockIndex(block);
|
|
26612
26618
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26613
|
-
assert(logger$
|
|
26614
|
-
assert(logger$
|
|
26619
|
+
assert(logger$3J, blockData, "no block data in doc");
|
|
26620
|
+
assert(logger$3J, blockData.text, "no text data in text block");
|
|
26615
26621
|
let from = offset;
|
|
26616
26622
|
if (!isValidOffset(block, offset)) {
|
|
26617
26623
|
from = getPrevValidOffset(block, from);
|
|
26618
26624
|
}
|
|
26619
26625
|
let to = offset + count;
|
|
26620
|
-
assert(logger$
|
|
26626
|
+
assert(logger$3J, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
|
|
26621
26627
|
if (!isValidOffset(block, to)) {
|
|
26622
26628
|
to = getNextValidOffset(block, to);
|
|
26623
26629
|
}
|
|
@@ -26626,7 +26632,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26626
26632
|
editor.doc.localUpdateBlockText(containerId, blockIndex, actions2, options);
|
|
26627
26633
|
return deleteCount;
|
|
26628
26634
|
}
|
|
26629
|
-
const logger$
|
|
26635
|
+
const logger$3I = getLogger("break-text-block");
|
|
26630
26636
|
function copyBlockAttributes(editor, block) {
|
|
26631
26637
|
const blockData = editor.getBlockData(block);
|
|
26632
26638
|
const quoted = blockData.quoted;
|
|
@@ -26638,8 +26644,8 @@ var __publicField = (obj, key, value) => {
|
|
|
26638
26644
|
return {};
|
|
26639
26645
|
}
|
|
26640
26646
|
function editorBreakTextBlock(editor, block, offset, options) {
|
|
26641
|
-
assert(logger$
|
|
26642
|
-
assert(logger$
|
|
26647
|
+
assert(logger$3I, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
|
|
26648
|
+
assert(logger$3I, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
26643
26649
|
const container = getParentContainer(block);
|
|
26644
26650
|
const containerId = getContainerId(container);
|
|
26645
26651
|
const blockIndex = getBlockIndex(block);
|
|
@@ -26669,7 +26675,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26669
26675
|
};
|
|
26670
26676
|
}
|
|
26671
26677
|
}
|
|
26672
|
-
assert(logger$
|
|
26678
|
+
assert(logger$3I, isValidOffset(block, offset), "not a valid offset");
|
|
26673
26679
|
const text2 = editorGetBlockText(editor, block);
|
|
26674
26680
|
const { right } = splitText(text2, offset);
|
|
26675
26681
|
const rightLength = getTextLength(right);
|
|
@@ -26695,12 +26701,12 @@ var __publicField = (obj, key, value) => {
|
|
|
26695
26701
|
newBlock
|
|
26696
26702
|
};
|
|
26697
26703
|
}
|
|
26698
|
-
const logger$
|
|
26704
|
+
const logger$3H = getLogger("prepare-insert-new-block");
|
|
26699
26705
|
function editorPrepareInsertNewBlock(editor, containerId, blockIndex) {
|
|
26700
26706
|
if (containerId && blockIndex !== void 0 && blockIndex !== null) {
|
|
26701
26707
|
const container = editor.getContainerById(containerId);
|
|
26702
26708
|
const blocks = getChildBlocks(container);
|
|
26703
|
-
assert(logger$
|
|
26709
|
+
assert(logger$3H, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
|
|
26704
26710
|
return {
|
|
26705
26711
|
containerId,
|
|
26706
26712
|
blockIndex
|
|
@@ -26734,15 +26740,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26734
26740
|
blockIndex: getBlockIndex(newBlock)
|
|
26735
26741
|
};
|
|
26736
26742
|
}
|
|
26737
|
-
const logger$
|
|
26743
|
+
const logger$3G = getLogger("auto-insert-block");
|
|
26738
26744
|
function editorAutoInsertBlock(editor, blockData, containerId, blockIndex, newRange, insertBlockOptions) {
|
|
26739
26745
|
const result = editorPrepareInsertNewBlock(editor, containerId, blockIndex);
|
|
26740
|
-
assert(logger$
|
|
26746
|
+
assert(logger$3G, result, `not an valid insert position: ${editor.selection.range}`);
|
|
26741
26747
|
const defaultPos = { blockId: blockData.id, offset: 0 };
|
|
26742
26748
|
const defaultRange = { anchor: defaultPos, focus: defaultPos };
|
|
26743
26749
|
return editorInsertBlock(editor, result.containerId, result.blockIndex, blockData, newRange != null ? newRange : defaultRange, insertBlockOptions);
|
|
26744
26750
|
}
|
|
26745
|
-
const logger$
|
|
26751
|
+
const logger$3F = getLogger("delete-block");
|
|
26746
26752
|
function getAllChildContainers(editor, blockData, containerIds) {
|
|
26747
26753
|
if (blockData.children) {
|
|
26748
26754
|
containerIds.push(...blockData.children);
|
|
@@ -26759,7 +26765,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26759
26765
|
const containerId = getContainerId(container);
|
|
26760
26766
|
const blockIndex = getBlockIndex(block);
|
|
26761
26767
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
26762
|
-
assert(logger$
|
|
26768
|
+
assert(logger$3F, blockData, "no block data in doc");
|
|
26763
26769
|
editor.doc.localDeleteBlock(containerId, blockIndex, createEditorSelectionRange(editor, { anchor: newRange.start, focus: newRange.end }));
|
|
26764
26770
|
return blockData;
|
|
26765
26771
|
}
|
|
@@ -26805,15 +26811,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26805
26811
|
});
|
|
26806
26812
|
editor.doc.localDeleteChildContainers(containerIds);
|
|
26807
26813
|
}
|
|
26808
|
-
const logger$
|
|
26814
|
+
const logger$3E = getLogger("merge-text-block");
|
|
26809
26815
|
function editorMergeTextBlock(editor, block1, block2) {
|
|
26810
|
-
assert(logger$
|
|
26811
|
-
assert(logger$
|
|
26816
|
+
assert(logger$3E, isTextKindBlock(editor, block1), "only text block can be merged");
|
|
26817
|
+
assert(logger$3E, isTextKindBlock(editor, block2), "only text block can be merged");
|
|
26812
26818
|
const data1 = editorGetBlockData(editor, block1);
|
|
26813
26819
|
const data2 = editorGetBlockData(editor, block2);
|
|
26814
26820
|
const text1 = data1.text;
|
|
26815
26821
|
const text2 = data2.text;
|
|
26816
|
-
assert(logger$
|
|
26822
|
+
assert(logger$3E, text1 && text2, "block data has no text");
|
|
26817
26823
|
const container = getParentContainer(block1);
|
|
26818
26824
|
const containerId = getContainerId(container);
|
|
26819
26825
|
const blockIndex = getBlockIndex(block1);
|
|
@@ -26823,15 +26829,15 @@ var __publicField = (obj, key, value) => {
|
|
|
26823
26829
|
editorDeleteBlock(editor, block2, newRange);
|
|
26824
26830
|
return block;
|
|
26825
26831
|
}
|
|
26826
|
-
const logger$
|
|
26832
|
+
const logger$3D = getLogger("clear-selected-contents");
|
|
26827
26833
|
function deleteTextBlockSelection(editor, selectedBlock) {
|
|
26828
|
-
assert(logger$
|
|
26834
|
+
assert(logger$3D, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
|
|
26829
26835
|
const { start, end } = selectedBlock;
|
|
26830
|
-
assert(logger$
|
|
26831
|
-
assert(logger$
|
|
26836
|
+
assert(logger$3D, start.isSimple(), "not a simple block position");
|
|
26837
|
+
assert(logger$3D, end.isSimple(), "not a simple block position");
|
|
26832
26838
|
const startOffset = start.offset;
|
|
26833
26839
|
const endOffset = end.offset;
|
|
26834
|
-
assert(logger$
|
|
26840
|
+
assert(logger$3D, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
|
|
26835
26841
|
if (startOffset === endOffset) {
|
|
26836
26842
|
return;
|
|
26837
26843
|
}
|
|
@@ -26856,7 +26862,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26856
26862
|
return;
|
|
26857
26863
|
}
|
|
26858
26864
|
if (isEmbedBlock(block) || start.isSimple()) {
|
|
26859
|
-
assert(logger$
|
|
26865
|
+
assert(logger$3D, end.isSimple(), "invalid range");
|
|
26860
26866
|
const container = getParentContainer(block);
|
|
26861
26867
|
const blockIndex = getBlockIndex(block);
|
|
26862
26868
|
const newBlock = editor.insertTextBlock("", getContainerId(container), blockIndex);
|
|
@@ -26864,8 +26870,8 @@ var __publicField = (obj, key, value) => {
|
|
|
26864
26870
|
editor.deleteBlock(block);
|
|
26865
26871
|
return;
|
|
26866
26872
|
}
|
|
26867
|
-
assert(logger$
|
|
26868
|
-
assert(logger$
|
|
26873
|
+
assert(logger$3D, isComplexKindBlock(editor, block), "invalid block kind");
|
|
26874
|
+
assert(logger$3D, !start.isSimple() && !end.isSimple(), "invalid range");
|
|
26869
26875
|
complexBlockGetSelectedContainers(editor, block, start, end);
|
|
26870
26876
|
const containers = editor.selection.range.getSelectedContainers();
|
|
26871
26877
|
containers.forEach((container, index2) => {
|
|
@@ -26882,7 +26888,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26882
26888
|
return;
|
|
26883
26889
|
}
|
|
26884
26890
|
const selectedBlocks = range.getSelectedBlocks();
|
|
26885
|
-
assert(logger$
|
|
26891
|
+
assert(logger$3D, selectedBlocks.length > 0, "no selected block");
|
|
26886
26892
|
if (selectedBlocks.length === 1) {
|
|
26887
26893
|
clearOneBlock(editor, selectedBlocks[0]);
|
|
26888
26894
|
return;
|
|
@@ -26890,7 +26896,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26890
26896
|
const firstSelectedBlock = selectedBlocks[0];
|
|
26891
26897
|
const firstBlock = firstSelectedBlock.block;
|
|
26892
26898
|
const container = getParentContainer(firstBlock);
|
|
26893
|
-
assert(logger$
|
|
26899
|
+
assert(logger$3D, selectedBlocks.length > 1, "no selected block");
|
|
26894
26900
|
const lastSelectedBlock = selectedBlocks[selectedBlocks.length - 1];
|
|
26895
26901
|
const lastBlock2 = lastSelectedBlock.block;
|
|
26896
26902
|
if (isTextKindBlock(editor, firstBlock)) {
|
|
@@ -26920,7 +26926,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26920
26926
|
}
|
|
26921
26927
|
const prevBlock = getPrevBlock(firstBlock);
|
|
26922
26928
|
const nextBlock = getNextBlock(lastBlock2);
|
|
26923
|
-
assert(logger$
|
|
26929
|
+
assert(logger$3D, prevBlock || nextBlock, "no prev or next block");
|
|
26924
26930
|
selectedBlocks.forEach((selectedBlock) => editor.deleteBlock(selectedBlock.block));
|
|
26925
26931
|
}
|
|
26926
26932
|
function editorClearSelectedContents(editor, selectionRange) {
|
|
@@ -26939,7 +26945,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26939
26945
|
editor.emit("afterClearSelection", editor);
|
|
26940
26946
|
});
|
|
26941
26947
|
}
|
|
26942
|
-
const logger$
|
|
26948
|
+
const logger$3C = getLogger("core");
|
|
26943
26949
|
function editorUpdateBlockText(editor, block, ops, options) {
|
|
26944
26950
|
const container = getParentContainer(block);
|
|
26945
26951
|
const containerId = getContainerId(container);
|
|
@@ -26952,7 +26958,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26952
26958
|
}
|
|
26953
26959
|
function editorSetBlockText(editor, block, newText, options) {
|
|
26954
26960
|
if (!editor.isBlockWritable(block)) {
|
|
26955
|
-
logger$
|
|
26961
|
+
logger$3C.error("block is not writable");
|
|
26956
26962
|
return;
|
|
26957
26963
|
}
|
|
26958
26964
|
const oldText = editor.getBlockText(block);
|
|
@@ -26965,7 +26971,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26965
26971
|
const ops = RichText.diff(oldText, newText);
|
|
26966
26972
|
return editorUpdateBlockText(editor, block, ops);
|
|
26967
26973
|
}
|
|
26968
|
-
const logger$
|
|
26974
|
+
const logger$3B = getLogger("update-block-data");
|
|
26969
26975
|
function editorUpdateBlockData(editor, block, data2, newRange, options) {
|
|
26970
26976
|
const container = getParentContainer(block);
|
|
26971
26977
|
const containerId = getContainerId(container);
|
|
@@ -26982,17 +26988,17 @@ var __publicField = (obj, key, value) => {
|
|
|
26982
26988
|
if (oldKey === "id" || oldKey === "type" || oldKey === "text") {
|
|
26983
26989
|
return;
|
|
26984
26990
|
}
|
|
26985
|
-
logger$
|
|
26991
|
+
logger$3B.debug(`delete key: ${oldKey}`);
|
|
26986
26992
|
delta.delete.push(oldKey);
|
|
26987
26993
|
}
|
|
26988
26994
|
});
|
|
26989
26995
|
const entries = Object.entries(data2);
|
|
26990
26996
|
entries.forEach(([key, value]) => {
|
|
26991
|
-
assert(logger$
|
|
26997
|
+
assert(logger$3B, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
|
|
26992
26998
|
const oldValue = oldData[key];
|
|
26993
26999
|
if (value === null || value === void 0) {
|
|
26994
27000
|
if (oldValue !== null && oldValue !== void 0) {
|
|
26995
|
-
logger$
|
|
27001
|
+
logger$3B.debug(`delete key: ${key}`);
|
|
26996
27002
|
delta.delete.push(key);
|
|
26997
27003
|
}
|
|
26998
27004
|
return;
|
|
@@ -27010,10 +27016,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27010
27016
|
}
|
|
27011
27017
|
}
|
|
27012
27018
|
if (oldKeys.has(key)) {
|
|
27013
|
-
logger$
|
|
27019
|
+
logger$3B.debug(`replace key: ${key}`);
|
|
27014
27020
|
delta.delete.push(key);
|
|
27015
27021
|
} else {
|
|
27016
|
-
logger$
|
|
27022
|
+
logger$3B.debug(`insert key: ${key}`);
|
|
27017
27023
|
}
|
|
27018
27024
|
delta.insert[key] = value;
|
|
27019
27025
|
});
|
|
@@ -27058,13 +27064,13 @@ var __publicField = (obj, key, value) => {
|
|
|
27058
27064
|
comments: {}
|
|
27059
27065
|
};
|
|
27060
27066
|
}
|
|
27061
|
-
const logger$
|
|
27067
|
+
const logger$3A = getLogger("clone-block");
|
|
27062
27068
|
function cloneBlock(editorBlocks, oldDoc, data2, info) {
|
|
27063
27069
|
var _a;
|
|
27064
27070
|
const blockClass = editorBlocks.getBlockClass(data2.type);
|
|
27065
27071
|
if (blockClass.blockToDoc) {
|
|
27066
27072
|
return blockClass.blockToDoc(oldDoc, data2, (oldDoc2, childBlock) => {
|
|
27067
|
-
assert(logger$
|
|
27073
|
+
assert(logger$3A, data2 !== childBlock, "invalid child block");
|
|
27068
27074
|
return cloneBlock(editorBlocks, oldDoc2, data2, info);
|
|
27069
27075
|
}, info);
|
|
27070
27076
|
}
|
|
@@ -27077,7 +27083,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27077
27083
|
}
|
|
27078
27084
|
const newChildContainerId = genId();
|
|
27079
27085
|
const childBlocks = oldDoc.blocks[oldChildContainerId];
|
|
27080
|
-
assert(logger$
|
|
27086
|
+
assert(logger$3A, Array.isArray(childBlocks), "invalid child blocks");
|
|
27081
27087
|
const newDocs = childBlocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
|
|
27082
27088
|
const newDoc = mergeDocs(newDocs);
|
|
27083
27089
|
const { root: root2, ...childContainersData } = newDoc.blocks;
|
|
@@ -27106,7 +27112,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27106
27112
|
if (key.startsWith(prefix1)) {
|
|
27107
27113
|
const keyContent = key.substring(prefix1.length);
|
|
27108
27114
|
const newKey = `${newContainerId}/${keyContent}`;
|
|
27109
|
-
logger$
|
|
27115
|
+
logger$3A.debug(`replace key: ${key} -> ${newKey}`);
|
|
27110
27116
|
return newKey;
|
|
27111
27117
|
}
|
|
27112
27118
|
}
|
|
@@ -27115,7 +27121,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27115
27121
|
if (key.startsWith(prefix2)) {
|
|
27116
27122
|
const keyContent = key.substring(prefix2.length);
|
|
27117
27123
|
const newKey = `${newContainerId}_${keyContent}`;
|
|
27118
|
-
logger$
|
|
27124
|
+
logger$3A.debug(`replace key: ${key} -> ${newKey}`);
|
|
27119
27125
|
return newKey;
|
|
27120
27126
|
}
|
|
27121
27127
|
}
|
|
@@ -27145,7 +27151,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27145
27151
|
}
|
|
27146
27152
|
function cloneChildContainer(editorBlocks, oldDoc, containerId, info) {
|
|
27147
27153
|
const blocks = oldDoc.blocks[containerId];
|
|
27148
|
-
assert(logger$
|
|
27154
|
+
assert(logger$3A, Array.isArray(blocks), "invalid child blocks");
|
|
27149
27155
|
const newDocs = blocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
|
|
27150
27156
|
const newDoc = mergeDocs(newDocs);
|
|
27151
27157
|
return newDoc;
|
|
@@ -27154,10 +27160,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27154
27160
|
const docs = doc2.blocks.root.map((b) => cloneBlock(editor.editorBlocks, doc2, b, info));
|
|
27155
27161
|
return cloneDeep__default.default(mergeDocs(docs));
|
|
27156
27162
|
}
|
|
27157
|
-
const logger$
|
|
27163
|
+
const logger$3z = getLogger("insert-doc");
|
|
27158
27164
|
function editorInsertDoc(editor, block, offset, insertedDoc, cloneDocResult) {
|
|
27159
27165
|
if (isComplexKindBlock(editor, block)) {
|
|
27160
|
-
logger$
|
|
27166
|
+
logger$3z.warn("failed to insert doc into a complex block");
|
|
27161
27167
|
return;
|
|
27162
27168
|
}
|
|
27163
27169
|
const doc2 = cloneDoc(editor, insertedDoc, cloneDocResult);
|
|
@@ -27191,7 +27197,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27191
27197
|
}
|
|
27192
27198
|
return;
|
|
27193
27199
|
}
|
|
27194
|
-
assert(logger$
|
|
27200
|
+
assert(logger$3z, isTextKindBlock(editor, block), "not a text block");
|
|
27195
27201
|
if (isEmptyTextBlock(editor, block)) {
|
|
27196
27202
|
const blockIndex2 = getBlockIndex(block);
|
|
27197
27203
|
let lastBlock22;
|
|
@@ -27323,11 +27329,11 @@ var __publicField = (obj, key, value) => {
|
|
|
27323
27329
|
editor.deleteBlock(block);
|
|
27324
27330
|
}
|
|
27325
27331
|
}
|
|
27326
|
-
const logger$
|
|
27332
|
+
const logger$3y = getLogger("add-text-attribute");
|
|
27327
27333
|
function editorRemoveTextAttribute(editor, block, range, attributeName) {
|
|
27328
27334
|
const { start, end } = range;
|
|
27329
|
-
assert(logger$
|
|
27330
|
-
assert(logger$
|
|
27335
|
+
assert(logger$3y, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
27336
|
+
assert(logger$3y, attributeName, "invalid attribute name");
|
|
27331
27337
|
const oldText = editor.getBlockText(block);
|
|
27332
27338
|
const newText = rangeRemoveAttribute(start.offset, end.offset - start.offset, oldText, attributeName, void 0, { ignoreValue: true });
|
|
27333
27339
|
editor.setBlockText(block, newText);
|
|
@@ -27335,8 +27341,8 @@ var __publicField = (obj, key, value) => {
|
|
|
27335
27341
|
}
|
|
27336
27342
|
function editorAddTextAttribute(editor, block, range, attributeName, value) {
|
|
27337
27343
|
const { start, end } = range;
|
|
27338
|
-
assert(logger$
|
|
27339
|
-
assert(logger$
|
|
27344
|
+
assert(logger$3y, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
27345
|
+
assert(logger$3y, attributeName, "invalid attribute name");
|
|
27340
27346
|
const oldText = editor.getBlockText(block);
|
|
27341
27347
|
const newText = rangeAddAttribute(start.offset, end.offset - start.offset, oldText, attributeName, value);
|
|
27342
27348
|
editor.setBlockText(block, newText);
|
|
@@ -27344,7 +27350,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27344
27350
|
}
|
|
27345
27351
|
function editorSetTextColor(editor, block, range, type, value) {
|
|
27346
27352
|
const { start, end } = range;
|
|
27347
|
-
assert(logger$
|
|
27353
|
+
assert(logger$3y, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
27348
27354
|
const oldText = editor.getBlockText(block);
|
|
27349
27355
|
const newText = rangeSetTextColor(start.offset, end.offset - start.offset, oldText, type, value);
|
|
27350
27356
|
editor.setBlockText(block, newText);
|
|
@@ -27433,10 +27439,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27433
27439
|
});
|
|
27434
27440
|
return [color, backgroundColor];
|
|
27435
27441
|
}
|
|
27436
|
-
const logger$
|
|
27442
|
+
const logger$3x = getLogger("move-complex-block-position");
|
|
27437
27443
|
function moveComplexBlockPosition(editor, old, type) {
|
|
27438
27444
|
const block = editor.getBlockById(old.blockId);
|
|
27439
|
-
assert(logger$
|
|
27445
|
+
assert(logger$3x, isComplexKindBlock(editor, block), "is not a complex block");
|
|
27440
27446
|
const blockClass = getComplexBlockClass(editor, block);
|
|
27441
27447
|
const focusedContainer = editor.getContainerById(old.childContainerId);
|
|
27442
27448
|
const nextContainer = blockClass.getNextContainer(editor, block, focusedContainer, type, { noWrap: true });
|
|
@@ -27445,24 +27451,24 @@ var __publicField = (obj, key, value) => {
|
|
|
27445
27451
|
}
|
|
27446
27452
|
return createComplexBlockPosition(block, getContainerId(nextContainer));
|
|
27447
27453
|
}
|
|
27448
|
-
const logger$
|
|
27454
|
+
const logger$3w = getLogger("move-simple-block-position");
|
|
27449
27455
|
function getFirstChildBlockInComplexBlock(editor, complexBlock) {
|
|
27450
27456
|
const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
|
|
27451
27457
|
if (containers.length === 0) {
|
|
27452
|
-
logger$
|
|
27458
|
+
logger$3w.warn("complex block has not any child container, not loaded?");
|
|
27453
27459
|
return null;
|
|
27454
27460
|
}
|
|
27455
|
-
assert(logger$
|
|
27461
|
+
assert(logger$3w, containers.length > 0, "complex block has not any child container");
|
|
27456
27462
|
const container = containers[0];
|
|
27457
27463
|
return getFirstChildBlock(container);
|
|
27458
27464
|
}
|
|
27459
27465
|
function getLastChildBlockInComplexBlock(editor, complexBlock) {
|
|
27460
27466
|
const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
|
|
27461
27467
|
if (containers.length === 0) {
|
|
27462
|
-
logger$
|
|
27468
|
+
logger$3w.warn("complex block has not any child container, not loaded?");
|
|
27463
27469
|
return null;
|
|
27464
27470
|
}
|
|
27465
|
-
assert(logger$
|
|
27471
|
+
assert(logger$3w, containers.length > 0, "complex block has not any child container");
|
|
27466
27472
|
const container = containers[containers.length - 1];
|
|
27467
27473
|
return getLastChildBlock(container);
|
|
27468
27474
|
}
|
|
@@ -27507,8 +27513,8 @@ var __publicField = (obj, key, value) => {
|
|
|
27507
27513
|
return null;
|
|
27508
27514
|
}
|
|
27509
27515
|
const parentComplexBlock = getParentBlock(container);
|
|
27510
|
-
assert(logger$
|
|
27511
|
-
assert(logger$
|
|
27516
|
+
assert(logger$3w, parentComplexBlock, "child container has not parent block");
|
|
27517
|
+
assert(logger$3w, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
|
|
27512
27518
|
const nextContainer = getComplexBlockClass(editor, parentComplexBlock).getNextContainer(editor, parentComplexBlock, container, type);
|
|
27513
27519
|
if (nextContainer) {
|
|
27514
27520
|
if (isFindPrev(type)) {
|
|
@@ -27530,7 +27536,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27530
27536
|
return null;
|
|
27531
27537
|
}
|
|
27532
27538
|
const parentBlock = getParentBlock(container);
|
|
27533
|
-
assert(logger$
|
|
27539
|
+
assert(logger$3w, parentBlock, "child container has not parent block");
|
|
27534
27540
|
if (isFindPrev(type)) {
|
|
27535
27541
|
const prev = getPrevBlock(parentBlock);
|
|
27536
27542
|
if (prev) {
|
|
@@ -27585,7 +27591,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27585
27591
|
}
|
|
27586
27592
|
if (!targetBlock) {
|
|
27587
27593
|
if (isComplexKindBlock(editor, block) && complexBlockGetAllChildContainers(editor, block).length === 0) {
|
|
27588
|
-
logger$
|
|
27594
|
+
logger$3w.warn("complex block has not any child container, not loaded?");
|
|
27589
27595
|
targetBlock = direction === "ArrowDown" || direction === "ArrowRight" ? getNextVisibleBlock(block) : getPrevVisibleBlock(block);
|
|
27590
27596
|
}
|
|
27591
27597
|
}
|
|
@@ -27732,10 +27738,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27732
27738
|
editorAdjustSelection(editor, "ArrowUp", "select");
|
|
27733
27739
|
return true;
|
|
27734
27740
|
}
|
|
27735
|
-
const logger$
|
|
27741
|
+
const logger$3v = getLogger("word-offset");
|
|
27736
27742
|
function editorGetWordLeftPos(editor, type) {
|
|
27737
27743
|
const old = editor.selection.range.focus;
|
|
27738
|
-
assert(logger$
|
|
27744
|
+
assert(logger$3v, old.isSimple(), "invalid range type");
|
|
27739
27745
|
const block = editor.getBlockById(old.blockId);
|
|
27740
27746
|
if (isEmptyTextBlock(editor, block)) {
|
|
27741
27747
|
return createSimpleBlockPosition(block, 0, "home");
|
|
@@ -27760,7 +27766,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27760
27766
|
}
|
|
27761
27767
|
function editorGetWordRightPos(editor, type) {
|
|
27762
27768
|
const old = editor.selection.range.focus;
|
|
27763
|
-
assert(logger$
|
|
27769
|
+
assert(logger$3v, old.isSimple(), "invalid range type");
|
|
27764
27770
|
const block = editor.getBlockById(old.blockId);
|
|
27765
27771
|
if (isEmptyTextBlock(editor, block)) {
|
|
27766
27772
|
return createSimpleBlockPosition(block, 0, "end");
|
|
@@ -27872,10 +27878,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27872
27878
|
editor.selection.setSelection(editor.selection.getAnchorPos(), pos);
|
|
27873
27879
|
return true;
|
|
27874
27880
|
}
|
|
27875
|
-
const logger$
|
|
27881
|
+
const logger$3u = getLogger("line-offset");
|
|
27876
27882
|
function editorGetLineHomePos(editor) {
|
|
27877
27883
|
const old = editor.selection.range.focus;
|
|
27878
|
-
assert(logger$
|
|
27884
|
+
assert(logger$3u, old.isSimple(), "invalid range type");
|
|
27879
27885
|
const block = editor.getBlockById(old.blockId);
|
|
27880
27886
|
if (old.offset === 0 || !isTextKindBlock(editor, block)) {
|
|
27881
27887
|
const newPos2 = createSimpleBlockPosition(block, 0, "home");
|
|
@@ -27892,7 +27898,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27892
27898
|
}
|
|
27893
27899
|
function editorGetLineEndPos(editor) {
|
|
27894
27900
|
const old = editor.selection.range.focus;
|
|
27895
|
-
assert(logger$
|
|
27901
|
+
assert(logger$3u, old.isSimple(), "invalid range type");
|
|
27896
27902
|
const block = editor.getBlockById(old.blockId);
|
|
27897
27903
|
if (old.offset === getBlockTextLength$6(editor, block) || !isTextKindBlock(editor, block)) {
|
|
27898
27904
|
const newPos2 = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
|
|
@@ -27992,7 +27998,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27992
27998
|
editorPageDownScroll(editor);
|
|
27993
27999
|
return true;
|
|
27994
28000
|
}
|
|
27995
|
-
const logger$
|
|
28001
|
+
const logger$3t = getLogger("table-scroll");
|
|
27996
28002
|
class DomEventHandler {
|
|
27997
28003
|
constructor(editor, dom, name, handler, data2, options) {
|
|
27998
28004
|
__publicField(this, "handleEvent", (event) => {
|
|
@@ -28024,7 +28030,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28024
28030
|
const existsHandlers = this.handlers.get(element);
|
|
28025
28031
|
if (existsHandlers) {
|
|
28026
28032
|
if (existsHandlers.find((handler) => handler.handler === eventHandler && handler.name === eventName)) {
|
|
28027
|
-
logger$
|
|
28033
|
+
logger$3t.warn(`event has already registered: ${eventName}`);
|
|
28028
28034
|
return;
|
|
28029
28035
|
}
|
|
28030
28036
|
existsHandlers.push(new DomEventHandler(this.editor, element, eventName, eventHandler, data2, options));
|
|
@@ -28134,7 +28140,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28134
28140
|
});
|
|
28135
28141
|
return true;
|
|
28136
28142
|
}
|
|
28137
|
-
const logger$
|
|
28143
|
+
const logger$3s = getLogger("select-all");
|
|
28138
28144
|
function isContainerSelectedAllChildBlocks(container, range) {
|
|
28139
28145
|
const firstBlock = getFirstChildBlock(container);
|
|
28140
28146
|
const lastBlock2 = getLastChildBlock(container);
|
|
@@ -28149,8 +28155,8 @@ var __publicField = (obj, key, value) => {
|
|
|
28149
28155
|
return range.start.blockId === blockId && range.start.childContainerId === getContainerId(first) && range.end.blockId === blockId && range.end.childContainerId === getContainerId(last);
|
|
28150
28156
|
}
|
|
28151
28157
|
function selectComplexBlock(editor, block) {
|
|
28152
|
-
assert(logger$
|
|
28153
|
-
assert(logger$
|
|
28158
|
+
assert(logger$3s, block, "no parent block");
|
|
28159
|
+
assert(logger$3s, isComplexKindBlock(editor, block), "not a complex block");
|
|
28154
28160
|
const containers = getComplexBlockClass(editor, block).getChildContainers(editor, block);
|
|
28155
28161
|
const first = containers[0];
|
|
28156
28162
|
const last = containers[containers.length - 1];
|
|
@@ -28186,13 +28192,13 @@ var __publicField = (obj, key, value) => {
|
|
|
28186
28192
|
selectParentContainer(editor, getFirstChildBlock(editor.rootContainer));
|
|
28187
28193
|
return false;
|
|
28188
28194
|
}
|
|
28189
|
-
assert(logger$
|
|
28195
|
+
assert(logger$3s, !range.isSimple(), "invalid range type");
|
|
28190
28196
|
if (isComplexBlockSelectedAllChildContainer(focusedBlock, range)) {
|
|
28191
28197
|
selectParentContainer(editor, focusedBlock);
|
|
28192
28198
|
return false;
|
|
28193
28199
|
}
|
|
28194
|
-
assert(logger$
|
|
28195
|
-
assert(logger$
|
|
28200
|
+
assert(logger$3s, focusedBlock, "no parent block");
|
|
28201
|
+
assert(logger$3s, isComplexKindBlock(editor, focusedBlock), "not a complex block");
|
|
28196
28202
|
selectComplexBlock(editor, focusedBlock);
|
|
28197
28203
|
return true;
|
|
28198
28204
|
}
|
|
@@ -28228,6 +28234,30 @@ var __publicField = (obj, key, value) => {
|
|
|
28228
28234
|
}
|
|
28229
28235
|
editor.selection.setSelection(newStartPos, newEndPos);
|
|
28230
28236
|
}
|
|
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
|
+
}
|
|
28231
28261
|
function editorFocusToEnd(editor) {
|
|
28232
28262
|
editorSelectEnd(editor);
|
|
28233
28263
|
editor.focus();
|
|
@@ -28307,7 +28337,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28307
28337
|
}
|
|
28308
28338
|
return cloned;
|
|
28309
28339
|
}
|
|
28310
|
-
const logger$
|
|
28340
|
+
const logger$3r = getLogger("selected-block-to-doc");
|
|
28311
28341
|
function appendBlockChildren(editor, data2, doc2) {
|
|
28312
28342
|
if (!data2.children)
|
|
28313
28343
|
return;
|
|
@@ -28328,7 +28358,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28328
28358
|
if (isTextKindBlock(editor, selectedBlock.block)) {
|
|
28329
28359
|
const start = selectedBlock.start;
|
|
28330
28360
|
const end = selectedBlock.end;
|
|
28331
|
-
assert(logger$
|
|
28361
|
+
assert(logger$3r, data2.text, "no block text");
|
|
28332
28362
|
if (start.offset === end.offset) {
|
|
28333
28363
|
return {
|
|
28334
28364
|
blocks: {
|
|
@@ -28362,8 +28392,8 @@ var __publicField = (obj, key, value) => {
|
|
|
28362
28392
|
comments: {}
|
|
28363
28393
|
};
|
|
28364
28394
|
}
|
|
28365
|
-
assert(logger$
|
|
28366
|
-
assert(logger$
|
|
28395
|
+
assert(logger$3r, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
|
|
28396
|
+
assert(logger$3r, data2.children, "no children");
|
|
28367
28397
|
const ret = {
|
|
28368
28398
|
blocks: {
|
|
28369
28399
|
root: [
|
|
@@ -28381,9 +28411,9 @@ var __publicField = (obj, key, value) => {
|
|
|
28381
28411
|
const end = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
|
|
28382
28412
|
return selectedBlockToDoc(editor, { block, start, end });
|
|
28383
28413
|
}
|
|
28384
|
-
const logger$
|
|
28414
|
+
const logger$3q = getLogger("block-to-doc");
|
|
28385
28415
|
function blocksToDoc(editor, blocks) {
|
|
28386
|
-
assert(logger$
|
|
28416
|
+
assert(logger$3q, blocks.length > 0, "invalid params, no blocks");
|
|
28387
28417
|
const docs = blocks.map((b) => blockToDoc(editor, b));
|
|
28388
28418
|
return mergeDocs(docs);
|
|
28389
28419
|
}
|
|
@@ -28403,7 +28433,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28403
28433
|
const newDocs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s));
|
|
28404
28434
|
return mergeDocs(newDocs);
|
|
28405
28435
|
}
|
|
28406
|
-
const logger$
|
|
28436
|
+
const logger$3p = getLogger("ensure-block-visible");
|
|
28407
28437
|
function ensureBlockVisible(editor, block) {
|
|
28408
28438
|
var _a;
|
|
28409
28439
|
while (block) {
|
|
@@ -28413,16 +28443,16 @@ var __publicField = (obj, key, value) => {
|
|
|
28413
28443
|
return;
|
|
28414
28444
|
}
|
|
28415
28445
|
const parentComplexBlock = getParentBlock(container);
|
|
28416
|
-
assert(logger$
|
|
28446
|
+
assert(logger$3p, parentComplexBlock, "no parent block");
|
|
28417
28447
|
const parentComplexBlockClass = getBlockClass(editor, parentComplexBlock);
|
|
28418
28448
|
if (parentComplexBlockClass.isChildContainerVisible && !((_a = parentComplexBlockClass.isChildContainerVisible) == null ? void 0 : _a.call(parentComplexBlockClass, editor, parentComplexBlock, container))) {
|
|
28419
|
-
assert(logger$
|
|
28449
|
+
assert(logger$3p, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
|
|
28420
28450
|
parentComplexBlockClass.showChildContainer(editor, parentComplexBlock, container);
|
|
28421
28451
|
}
|
|
28422
28452
|
block = parentComplexBlock;
|
|
28423
28453
|
}
|
|
28424
28454
|
}
|
|
28425
|
-
const logger$
|
|
28455
|
+
const logger$3o = getLogger("editor-selection");
|
|
28426
28456
|
class EditorSelection {
|
|
28427
28457
|
constructor(editor) {
|
|
28428
28458
|
__publicField(this, "editor");
|
|
@@ -28435,7 +28465,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28435
28465
|
}
|
|
28436
28466
|
const range = this.range;
|
|
28437
28467
|
if (rangeInBlock(deletedBlock, range)) {
|
|
28438
|
-
logger$
|
|
28468
|
+
logger$3o.debug("adjust selection because remote deleted current block");
|
|
28439
28469
|
const newRange = moveSelectionBeforeDeleteBlock(editor, deletedBlock);
|
|
28440
28470
|
this.setRange(newRange, { noScroll: true });
|
|
28441
28471
|
}
|
|
@@ -28560,14 +28590,14 @@ var __publicField = (obj, key, value) => {
|
|
|
28560
28590
|
if (pos.isSimple()) {
|
|
28561
28591
|
const ok = pos.offset >= 0 && pos.offset <= getBlockTextLength$6(this.editor, block);
|
|
28562
28592
|
if (!ok) {
|
|
28563
|
-
assert(logger$
|
|
28593
|
+
assert(logger$3o, false, "invalid block position, out of range");
|
|
28564
28594
|
}
|
|
28565
28595
|
} else {
|
|
28566
28596
|
const childContainerId = pos.childContainerId;
|
|
28567
28597
|
const container = this.editor.getContainerById(childContainerId);
|
|
28568
28598
|
const ok = !!container;
|
|
28569
28599
|
if (!ok) {
|
|
28570
|
-
assert(logger$
|
|
28600
|
+
assert(logger$3o, false, "invalid complex block position, no container found");
|
|
28571
28601
|
}
|
|
28572
28602
|
}
|
|
28573
28603
|
}
|
|
@@ -28628,7 +28658,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28628
28658
|
let container = getParentContainer(block);
|
|
28629
28659
|
while (isChildContainer(container)) {
|
|
28630
28660
|
const parentBlock = getParentBlock(container);
|
|
28631
|
-
assert(logger$
|
|
28661
|
+
assert(logger$3o, parentBlock, "parent block not found");
|
|
28632
28662
|
addClass(parentBlock, "child-focused");
|
|
28633
28663
|
container = getParentContainer(parentBlock);
|
|
28634
28664
|
}
|
|
@@ -28738,15 +28768,15 @@ var __publicField = (obj, key, value) => {
|
|
|
28738
28768
|
editor.undoManager.redo();
|
|
28739
28769
|
return true;
|
|
28740
28770
|
}
|
|
28741
|
-
const logger$
|
|
28771
|
+
const logger$3n = getLogger("delete-text");
|
|
28742
28772
|
function editorDeleteText(editor, type, count, insertPos) {
|
|
28743
28773
|
const pos = insertPos != null ? insertPos : editor.selection.range.start;
|
|
28744
28774
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
28745
|
-
assert(logger$
|
|
28775
|
+
assert(logger$3n, false, `invalid insert pos type: ${typeof pos}`);
|
|
28746
28776
|
}
|
|
28747
28777
|
const { blockId } = pos;
|
|
28748
28778
|
const block = editor.getBlockById(blockId);
|
|
28749
|
-
assert(logger$
|
|
28779
|
+
assert(logger$3n, isTextKindBlock(editor, block), "block is not a text kind block");
|
|
28750
28780
|
let { offset } = pos;
|
|
28751
28781
|
if (type === "backward") {
|
|
28752
28782
|
if (offset - count < 0) {
|
|
@@ -28776,7 +28806,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28776
28806
|
}
|
|
28777
28807
|
return false;
|
|
28778
28808
|
}
|
|
28779
|
-
const logger$
|
|
28809
|
+
const logger$3m = getLogger("handle-backspace");
|
|
28780
28810
|
function tryDeleteEmptyBlock(editor, block) {
|
|
28781
28811
|
if (!isEmptyTextBlock(editor, block)) {
|
|
28782
28812
|
return;
|
|
@@ -28816,7 +28846,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28816
28846
|
}
|
|
28817
28847
|
} else {
|
|
28818
28848
|
tryDeleteEmptyBlock(editor, block);
|
|
28819
|
-
assert(logger$
|
|
28849
|
+
assert(logger$3m, isEmbedBlock(prevBlock), "prev block is not embed block");
|
|
28820
28850
|
editor.selection.selectBlock(prevBlock, 1);
|
|
28821
28851
|
}
|
|
28822
28852
|
} else {
|
|
@@ -28843,6 +28873,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28843
28873
|
editor.deleteBlock(block);
|
|
28844
28874
|
}
|
|
28845
28875
|
}
|
|
28876
|
+
const logger$3l = getLogger("word-offset");
|
|
28846
28877
|
function handleEditorDelete(editor, event) {
|
|
28847
28878
|
if (!editor.selection.range.isCollapsed()) {
|
|
28848
28879
|
editor.clearSelectedContents();
|
|
@@ -28877,6 +28908,130 @@ var __publicField = (obj, key, value) => {
|
|
|
28877
28908
|
editor.deleteBlock(block);
|
|
28878
28909
|
}
|
|
28879
28910
|
}
|
|
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
|
+
}
|
|
28880
29035
|
function handleEditorEnterEvent$1(editor, event) {
|
|
28881
29036
|
if (isFullSelectedOneComplexBlock(editor)) {
|
|
28882
29037
|
const focusedBlock2 = editor.getFocusedBlock();
|
|
@@ -29098,6 +29253,42 @@ var __publicField = (obj, key, value) => {
|
|
|
29098
29253
|
return true;
|
|
29099
29254
|
});
|
|
29100
29255
|
}
|
|
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
|
+
}
|
|
29101
29292
|
function editorHandleBackspace(editor, event) {
|
|
29102
29293
|
if (editor.readonly || !editor.isWritable()) {
|
|
29103
29294
|
return false;
|
|
@@ -29191,6 +29382,10 @@ ${codeText}
|
|
|
29191
29382
|
__proto__: null,
|
|
29192
29383
|
editorHandleEnter,
|
|
29193
29384
|
editorHandleDelete,
|
|
29385
|
+
editorHandleDeleteLeftWord,
|
|
29386
|
+
editorHandleDeleteRightWord,
|
|
29387
|
+
editorHandleDeleteAfterWords,
|
|
29388
|
+
editorHandleDeleteRightChar,
|
|
29194
29389
|
editorHandleBackspace,
|
|
29195
29390
|
editorHandleInsertBr,
|
|
29196
29391
|
editorHandlePastePlainText,
|
|
@@ -29198,6 +29393,39 @@ ${codeText}
|
|
|
29198
29393
|
getSelectedCodeBlockMarkdown,
|
|
29199
29394
|
editorHandleCopyMarkdown
|
|
29200
29395
|
}, 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;
|
|
29201
29429
|
const DefaultShortcuts = {
|
|
29202
29430
|
"ArrowDown": editorMoveDown,
|
|
29203
29431
|
"ArrowUp": editorMoveUp,
|
|
@@ -29207,19 +29435,11 @@ ${codeText}
|
|
|
29207
29435
|
"Shift+ArrowUp": editorSelectUp,
|
|
29208
29436
|
"Shift+ArrowLeft": editorSelectLeft,
|
|
29209
29437
|
"Shift+ArrowRight": editorSelectRight,
|
|
29210
|
-
"CtrlOrCmd+ArrowLeft": editorMoveWordLeft,
|
|
29211
|
-
"CtrlOrCmd+ArrowRight": editorMoveWordEnd,
|
|
29212
|
-
"CtrlOrCmd+Shift+ArrowLeft": editorSelectWordLeft,
|
|
29213
|
-
"CtrlOrCmd+Shift+ArrowRight": editorSelectWordEnd,
|
|
29214
29438
|
"CtrlOrCmd+ArrowUp": editorMoveHome,
|
|
29215
29439
|
"CtrlOrCmd+ArrowDown": editorMoveEnd,
|
|
29216
29440
|
"CtrlOrCmd+Shift+ArrowUp": editorSelectHome,
|
|
29217
29441
|
"CtrlOrCmd+Shift+ArrowDown": editorSelectEnd,
|
|
29218
29442
|
"CtrlOrCmd+A": editorSelectAll,
|
|
29219
|
-
"Home": editorMoveLineHome,
|
|
29220
|
-
"End": editorMoveLineEnd,
|
|
29221
|
-
"Shift+Home": editorSelectLineHome,
|
|
29222
|
-
"Shift+End": editorSelectLineEnd,
|
|
29223
29443
|
"PageUp": editorMovePageUp,
|
|
29224
29444
|
"PageDown": editorMovePageDown,
|
|
29225
29445
|
"Shift+PageUp": editorSelectPageUp,
|
|
@@ -29231,7 +29451,8 @@ ${codeText}
|
|
|
29231
29451
|
"Backspace": editorHandleBackspace,
|
|
29232
29452
|
"Shift+Enter": editorHandleInsertBr,
|
|
29233
29453
|
"CtrlOrCmd+Shift+V": editorHandlePastePlainText,
|
|
29234
|
-
"CtrlOrCmd+Shift+C": editorHandleCopyMarkdown
|
|
29454
|
+
"CtrlOrCmd+Shift+C": editorHandleCopyMarkdown,
|
|
29455
|
+
...CustomShortcuts
|
|
29235
29456
|
};
|
|
29236
29457
|
function editorHandleKeyboardEvent(editor, event) {
|
|
29237
29458
|
const result = editor.shortcuts.handleKeyboardEvents(editor, event);
|
|
@@ -43009,8 +43230,21 @@ ${codeText}
|
|
|
43009
43230
|
const textColorItem = "";
|
|
43010
43231
|
const DEFAULT_BG_COLOR = 2;
|
|
43011
43232
|
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
|
+
}
|
|
43012
43246
|
class TextColorItem extends tinyTypedEmitter.TypedEmitter {
|
|
43013
|
-
constructor(editor, storageName =
|
|
43247
|
+
constructor(editor, storageName = STORAGE_NAME) {
|
|
43014
43248
|
super();
|
|
43015
43249
|
__publicField(this, "id", "text-color-item");
|
|
43016
43250
|
__publicField(this, "name", i18n$1.t("colorPalette.name"));
|
|
@@ -50705,7 +50939,7 @@ ${codeText}
|
|
|
50705
50939
|
}
|
|
50706
50940
|
return handleDragList(editor, draggedBlock, targetBlock, insertPos);
|
|
50707
50941
|
}
|
|
50708
|
-
function executeShortcut$
|
|
50942
|
+
function executeShortcut$3(editor, type) {
|
|
50709
50943
|
if (!editor.isWritable()) {
|
|
50710
50944
|
return false;
|
|
50711
50945
|
}
|
|
@@ -50719,8 +50953,8 @@ ${codeText}
|
|
|
50719
50953
|
return true;
|
|
50720
50954
|
}
|
|
50721
50955
|
const ListBlockShortcuts = {
|
|
50722
|
-
"Shift+CtrlOrCmd+L": (editor) => executeShortcut$
|
|
50723
|
-
"Shift+CtrlOrCmd+U": (editor) => executeShortcut$
|
|
50956
|
+
"Shift+CtrlOrCmd+L": (editor) => executeShortcut$3(editor, "ordered-list"),
|
|
50957
|
+
"Shift+CtrlOrCmd+U": (editor) => executeShortcut$3(editor, "unordered-list")
|
|
50724
50958
|
};
|
|
50725
50959
|
function getBlockPadding$1(block) {
|
|
50726
50960
|
const padding = block.getAttribute("block-padding-level");
|
|
@@ -61230,6 +61464,31 @@ $$${mathData.mathjaxText}$$
|
|
|
61230
61464
|
return editor.addCustom("overflow-tooltip-helper", () => new OverflowTooltipHelper(editor));
|
|
61231
61465
|
}
|
|
61232
61466
|
}
|
|
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
|
+
};
|
|
61233
61492
|
const TextCommands = {
|
|
61234
61493
|
"text/style-bold": "bold",
|
|
61235
61494
|
"text/style-italic": "italic",
|
|
@@ -61245,7 +61504,7 @@ $$${mathData.mathjaxText}$$
|
|
|
61245
61504
|
const styleCommands = blockCommands.filter((command) => styleCommandsSet.has(command.id));
|
|
61246
61505
|
return styleCommands;
|
|
61247
61506
|
}
|
|
61248
|
-
function executeShortcut(editor, style2) {
|
|
61507
|
+
function executeShortcut$1(editor, style2) {
|
|
61249
61508
|
if (!editor.isWritable()) {
|
|
61250
61509
|
return false;
|
|
61251
61510
|
}
|
|
@@ -61290,13 +61549,37 @@ $$${mathData.mathjaxText}$$
|
|
|
61290
61549
|
return shortcuts2;
|
|
61291
61550
|
};
|
|
61292
61551
|
const TextStyleShortcuts = {
|
|
61293
|
-
"CtrlOrCmd+B": (editor) => executeShortcut(editor, "style-bold"),
|
|
61294
|
-
"CtrlOrCmd+I": (editor) => executeShortcut(editor, "style-italic"),
|
|
61295
|
-
"CtrlOrCmd+U": (editor) => executeShortcut(editor, "style-underline"),
|
|
61296
|
-
"CtrlOrCmd+D": (editor) => executeShortcut(editor, "style-strikethrough"),
|
|
61297
|
-
"CtrlOrCmd+K": (editor) => executeShortcut(editor, "link"),
|
|
61552
|
+
"CtrlOrCmd+B": (editor) => executeShortcut$1(editor, "style-bold"),
|
|
61553
|
+
"CtrlOrCmd+I": (editor) => executeShortcut$1(editor, "style-italic"),
|
|
61554
|
+
"CtrlOrCmd+U": (editor) => executeShortcut$1(editor, "style-underline"),
|
|
61555
|
+
"CtrlOrCmd+D": (editor) => executeShortcut$1(editor, "style-strikethrough"),
|
|
61556
|
+
"CtrlOrCmd+K": (editor) => executeShortcut$1(editor, "link"),
|
|
61298
61557
|
...headingShortcut()
|
|
61299
61558
|
};
|
|
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
|
+
};
|
|
61300
61583
|
const zhCN$p = {
|
|
61301
61584
|
quickMenu: {
|
|
61302
61585
|
basic: {
|
|
@@ -62055,7 +62338,7 @@ $$${mathData.mathjaxText}$$
|
|
|
62055
62338
|
__publicField(this, "updateButtonColor", (range) => {
|
|
62056
62339
|
const currentTextColor = editorRangeGetColor(this.editor, range, this.getEmptyTextBlockColor);
|
|
62057
62340
|
this.colorItem.setCurrentTextColors(currentTextColor);
|
|
62058
|
-
const lastButtonColor = this.
|
|
62341
|
+
const lastButtonColor = getColorsFromLocalStorage(this.editor);
|
|
62059
62342
|
this.colorItem.setCurrentButtonColor(lastButtonColor);
|
|
62060
62343
|
});
|
|
62061
62344
|
__publicField(this, "setActiveAttribute", (type, value) => {
|
|
@@ -73677,8 +73960,6 @@ ${codeText}
|
|
|
73677
73960
|
});
|
|
73678
73961
|
}
|
|
73679
73962
|
const StyleTags = {
|
|
73680
|
-
i: "style-italic",
|
|
73681
|
-
b: "style-bold",
|
|
73682
73963
|
u: "style-underline",
|
|
73683
73964
|
strong: "style-bold",
|
|
73684
73965
|
em: "style-italic",
|
|
@@ -73832,18 +74113,6 @@ ${codeText}
|
|
|
73832
74113
|
}
|
|
73833
74114
|
if (token.type === "html") {
|
|
73834
74115
|
const html = token.text;
|
|
73835
|
-
const testBr = html.trim().toLowerCase();
|
|
73836
|
-
if (testBr === "<br>" || testBr === "<br/>" || testBr === "<br />") {
|
|
73837
|
-
return [{
|
|
73838
|
-
insert: " ",
|
|
73839
|
-
attributes: {
|
|
73840
|
-
id: genId(),
|
|
73841
|
-
created: Date.now(),
|
|
73842
|
-
box: true,
|
|
73843
|
-
type: "br"
|
|
73844
|
-
}
|
|
73845
|
-
}];
|
|
73846
|
-
}
|
|
73847
74116
|
applyHtmlToText(html, attributes);
|
|
73848
74117
|
applyColorTagToText(html, attributes);
|
|
73849
74118
|
applyFontSizeTagToText(html, attributes);
|
|
@@ -75540,8 +75809,8 @@ ${content}
|
|
|
75540
75809
|
const container = document.createElement("div");
|
|
75541
75810
|
container.classList.add("highlight-text-wizdoc");
|
|
75542
75811
|
const code = document.createElement("pre");
|
|
75543
|
-
code.textContent = base64;
|
|
75544
75812
|
container.appendChild(code);
|
|
75813
|
+
code.innerText = base64;
|
|
75545
75814
|
node.insertAdjacentElement("beforebegin", container);
|
|
75546
75815
|
node.remove();
|
|
75547
75816
|
return;
|
|
@@ -91924,9 +92193,11 @@ ${data2.plantumlText}
|
|
|
91924
92193
|
FindReplaceShortcuts,
|
|
91925
92194
|
BlockPaddingShortcuts,
|
|
91926
92195
|
TextStyleShortcuts,
|
|
92196
|
+
AlignShortcuts,
|
|
91927
92197
|
AutoLinkShortcuts,
|
|
91928
92198
|
DefaultShortcuts,
|
|
91929
92199
|
ListBlockShortcuts,
|
|
92200
|
+
TextColorShortcuts,
|
|
91930
92201
|
...options.shortcuts || []
|
|
91931
92202
|
],
|
|
91932
92203
|
colors: [
|
|
@@ -92135,7 +92406,7 @@ ${data2.plantumlText}
|
|
|
92135
92406
|
}
|
|
92136
92407
|
}
|
|
92137
92408
|
});
|
|
92138
|
-
editor.version = "2.
|
|
92409
|
+
editor.version = "2.6.1-beta.1";
|
|
92139
92410
|
return editor;
|
|
92140
92411
|
}
|
|
92141
92412
|
function isDoc(doc2) {
|
|
@@ -92248,7 +92519,7 @@ ${data2.plantumlText}
|
|
|
92248
92519
|
}
|
|
92249
92520
|
});
|
|
92250
92521
|
OnesEditorToolbar.register(editor);
|
|
92251
|
-
editor.version = "2.
|
|
92522
|
+
editor.version = "2.6.1-beta.1";
|
|
92252
92523
|
return editor;
|
|
92253
92524
|
}
|
|
92254
92525
|
async function showDocVersions(editor, options, serverUrl) {
|
|
@@ -138034,6 +138305,7 @@ ${data2.plantumlText}
|
|
|
138034
138305
|
exports2.AlignProvider = AlignProvider;
|
|
138035
138306
|
exports2.AlignRightIcon = AlignRightIcon;
|
|
138036
138307
|
exports2.AlignRightItem = AlignRightItem;
|
|
138308
|
+
exports2.AlignShortcuts = AlignShortcuts;
|
|
138037
138309
|
exports2.AnchorBox = AnchorBox;
|
|
138038
138310
|
exports2.ArrowDownIcon = ArrowDownIcon$1;
|
|
138039
138311
|
exports2.ArrowLeftIcon = arrowLeft;
|
|
@@ -138290,6 +138562,7 @@ ${data2.plantumlText}
|
|
|
138290
138562
|
exports2.TextBox = TextBox;
|
|
138291
138563
|
exports2.TextColorIcon = TextColorIcon;
|
|
138292
138564
|
exports2.TextColorItem = TextColorItem;
|
|
138565
|
+
exports2.TextColorShortcuts = TextColorShortcuts;
|
|
138293
138566
|
exports2.TextCommandProvider = TextCommandProvider;
|
|
138294
138567
|
exports2.TextGroupIcon = TextGroupIcon;
|
|
138295
138568
|
exports2.TextIcon = TextIcon;
|
|
@@ -138459,6 +138732,8 @@ ${data2.plantumlText}
|
|
|
138459
138732
|
exports2.editorInsertTextToBlock = editorInsertTextToBlock;
|
|
138460
138733
|
exports2.editorInsertTextToBlockEx = editorInsertTextToBlockEx;
|
|
138461
138734
|
exports2.editorMergeTextBlock = editorMergeTextBlock;
|
|
138735
|
+
exports2.editorMoveBlockEnd = editorMoveBlockEnd;
|
|
138736
|
+
exports2.editorMoveBlockStart = editorMoveBlockStart;
|
|
138462
138737
|
exports2.editorMoveDown = editorMoveDown;
|
|
138463
138738
|
exports2.editorMoveEnd = editorMoveEnd;
|
|
138464
138739
|
exports2.editorMoveHome = editorMoveHome;
|
|
@@ -138563,6 +138838,7 @@ ${data2.plantumlText}
|
|
|
138563
138838
|
exports2.getBlockTextLength = getBlockTextLength$6;
|
|
138564
138839
|
exports2.getBlockTools = getBlockTools;
|
|
138565
138840
|
exports2.getBlockType = getBlockType;
|
|
138841
|
+
exports2.getBlocksBetween = getBlocksBetween;
|
|
138566
138842
|
exports2.getBlocksWidth = getBlocksWidth;
|
|
138567
138843
|
exports2.getBoxContent = getBoxContent;
|
|
138568
138844
|
exports2.getBoxId = getBoxId;
|
|
@@ -138575,6 +138851,7 @@ ${data2.plantumlText}
|
|
|
138575
138851
|
exports2.getClosestContainerByCondition = getClosestContainerByCondition;
|
|
138576
138852
|
exports2.getColorFromAttributes = getColorFromAttributes;
|
|
138577
138853
|
exports2.getColorFromContent = getColorFromContent;
|
|
138854
|
+
exports2.getColorsFromLocalStorage = getColorsFromLocalStorage;
|
|
138578
138855
|
exports2.getComplexBlockClass = getComplexBlockClass;
|
|
138579
138856
|
exports2.getContainerBlockOverrideOptions = getContainerBlockOverrideOptions;
|
|
138580
138857
|
exports2.getContainerBlockPath = getContainerBlockPath;
|
|
@@ -138749,7 +139026,7 @@ ${data2.plantumlText}
|
|
|
138749
139026
|
exports2.loadJs = loadJs;
|
|
138750
139027
|
exports2.loadJsPromise = loadJsPromise;
|
|
138751
139028
|
exports2.lockers = lockers;
|
|
138752
|
-
exports2.logger = logger$
|
|
139029
|
+
exports2.logger = logger$4q;
|
|
138753
139030
|
exports2.markdownToDoc = markdownToDoc;
|
|
138754
139031
|
exports2.mergeCommands = mergeCommands;
|
|
138755
139032
|
exports2.mergeDocs = mergeDocs;
|