@ones-editor/editor 5.0.6-beta.DNP8216.1 → 5.0.6-beta.DNP8216.3
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/types.d.ts +10 -3
- package/@ones-editor/core/src/core/undo-manager/actions/async-action.d.ts +10 -0
- package/@ones-editor/core/src/core/undo-manager/actions/macro-edit-action.d.ts +3 -9
- package/@ones-editor/core/src/core/undo-manager/undo-manager.d.ts +7 -1
- package/@ones-editor/core/src/core/undo-manager/undo-manager.test.d.ts +1 -0
- package/@ones-editor/server-tools/src/to-markdown/embeds/wiki-macro.d.ts +4 -0
- package/@ones-editor/server-tools/src/to-markdown/embeds/wiki-macro.test.d.ts +1 -0
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +607 -538
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9342,7 +9342,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9342
9342
|
imageExportFailed: "Bild konnte nicht geladen werden"
|
|
9343
9343
|
}
|
|
9344
9344
|
};
|
|
9345
|
-
const logger$
|
|
9345
|
+
const logger$4Y = getLogger("i18n");
|
|
9346
9346
|
const langs$3 = {
|
|
9347
9347
|
"en-US": enUS$y,
|
|
9348
9348
|
"zh-CN": zhCN$y,
|
|
@@ -9364,7 +9364,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9364
9364
|
function t$8(key, args) {
|
|
9365
9365
|
const ret = i18n.get(key, args);
|
|
9366
9366
|
if (ret === key) {
|
|
9367
|
-
logger$
|
|
9367
|
+
logger$4Y.warn(`no locale value for key ${key}`);
|
|
9368
9368
|
}
|
|
9369
9369
|
return ret;
|
|
9370
9370
|
}
|
|
@@ -9982,7 +9982,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9982
9982
|
this._callbacks.clear();
|
|
9983
9983
|
}
|
|
9984
9984
|
}
|
|
9985
|
-
const logger$
|
|
9985
|
+
const logger$4X = getLogger("await-locker");
|
|
9986
9986
|
class AwaitLock {
|
|
9987
9987
|
constructor() {
|
|
9988
9988
|
__publicField(this, "_acquired", false);
|
|
@@ -10024,7 +10024,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10024
10024
|
}
|
|
10025
10025
|
if (this._waitingResolvers.length > 0) {
|
|
10026
10026
|
const resolve = this._waitingResolvers.shift();
|
|
10027
|
-
assert(logger$
|
|
10027
|
+
assert(logger$4X, resolve, "Resolver missing");
|
|
10028
10028
|
resolve(void 0);
|
|
10029
10029
|
} else {
|
|
10030
10030
|
this._acquired = false;
|
|
@@ -10107,7 +10107,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10107
10107
|
isMobileSafari: false
|
|
10108
10108
|
};
|
|
10109
10109
|
clientType.isMobileSafari = clientType.isMobile && clientType.isSafari;
|
|
10110
|
-
const logger$
|
|
10110
|
+
const logger$4W = getLogger("dom-utils");
|
|
10111
10111
|
function addClass(dom, ...className) {
|
|
10112
10112
|
if (dom && dom.nodeType === Node.ELEMENT_NODE) {
|
|
10113
10113
|
dom.classList.add(...className);
|
|
@@ -10164,7 +10164,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10164
10164
|
range.setStart(node, offset);
|
|
10165
10165
|
return range;
|
|
10166
10166
|
} catch (err) {
|
|
10167
|
-
assert(logger$
|
|
10167
|
+
assert(logger$4W, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
|
|
10168
10168
|
}
|
|
10169
10169
|
}
|
|
10170
10170
|
function createExpandedRange(startNode, startOffset, endNode, endOffset) {
|
|
@@ -10174,17 +10174,17 @@ var __publicField = (obj, key, value) => {
|
|
|
10174
10174
|
range.setEnd(endNode, endOffset);
|
|
10175
10175
|
return range;
|
|
10176
10176
|
} catch (err) {
|
|
10177
|
-
assert(logger$
|
|
10177
|
+
assert(logger$4W, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
|
|
10178
10178
|
}
|
|
10179
10179
|
}
|
|
10180
10180
|
function getFirstClientRect(elem) {
|
|
10181
10181
|
const rects = elem.getClientRects();
|
|
10182
|
-
assert(logger$
|
|
10182
|
+
assert(logger$4W, rects.length >= 1, "getFirstClientRect: no rects");
|
|
10183
10183
|
return rects[0];
|
|
10184
10184
|
}
|
|
10185
10185
|
function getLastClientRect(elem) {
|
|
10186
10186
|
const rects = elem.getClientRects();
|
|
10187
|
-
assert(logger$
|
|
10187
|
+
assert(logger$4W, rects.length >= 1, "getLastClientRect: no rects");
|
|
10188
10188
|
return rects[rects.length - 1];
|
|
10189
10189
|
}
|
|
10190
10190
|
function getDistanceSquare(rect, x, y) {
|
|
@@ -10231,7 +10231,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10231
10231
|
return 0;
|
|
10232
10232
|
}
|
|
10233
10233
|
if (!elem1.parentElement || !elem2.parentElement) {
|
|
10234
|
-
assert(logger$
|
|
10234
|
+
assert(logger$4W, false, "invalid dom node to compare");
|
|
10235
10235
|
}
|
|
10236
10236
|
if (elem1.parentElement === elem2.parentElement) {
|
|
10237
10237
|
const children = Array.from(elem1.parentElement.children);
|
|
@@ -10248,7 +10248,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10248
10248
|
const parents1 = getParents(elem1);
|
|
10249
10249
|
const parents2 = getParents(elem2);
|
|
10250
10250
|
if (parents1[0] !== parents2[0]) {
|
|
10251
|
-
assert(logger$
|
|
10251
|
+
assert(logger$4W, false, "invalid dom node to compare, different tree");
|
|
10252
10252
|
}
|
|
10253
10253
|
for (let i = 1; ; i++) {
|
|
10254
10254
|
const parent1 = parents1[i];
|
|
@@ -10848,7 +10848,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10848
10848
|
}
|
|
10849
10849
|
}
|
|
10850
10850
|
const MIN_DISTANCE_THRESHOLD$3 = 3;
|
|
10851
|
-
const logger$
|
|
10851
|
+
const logger$4V = getLogger("drag-drop");
|
|
10852
10852
|
class DragDrop {
|
|
10853
10853
|
constructor(options) {
|
|
10854
10854
|
__publicField(this, "dragStarted", false);
|
|
@@ -10869,7 +10869,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10869
10869
|
var _a;
|
|
10870
10870
|
event.preventDefault();
|
|
10871
10871
|
event.stopPropagation();
|
|
10872
|
-
assert(logger$
|
|
10872
|
+
assert(logger$4V, this.mouseDownEvent, "no mouse down event");
|
|
10873
10873
|
const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
|
|
10874
10874
|
const newPos = DragDrop.getEventPosition(event);
|
|
10875
10875
|
const deltaX = newPos.x - oldPos.x;
|
|
@@ -10885,7 +10885,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10885
10885
|
});
|
|
10886
10886
|
__publicField(this, "handleMouseUp", (event) => {
|
|
10887
10887
|
if (event instanceof MouseEvent && event.button === 0 || event instanceof TouchEvent) {
|
|
10888
|
-
assert(logger$
|
|
10888
|
+
assert(logger$4V, this.mouseDownEvent, "no mouse down event");
|
|
10889
10889
|
const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
|
|
10890
10890
|
const newPos = DragDrop.getEventPosition(event);
|
|
10891
10891
|
const deltaX = newPos.x - oldPos.x;
|
|
@@ -10994,7 +10994,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10994
10994
|
const dragDrop = new DragDrop(options);
|
|
10995
10995
|
return dragDrop;
|
|
10996
10996
|
}
|
|
10997
|
-
const logger$
|
|
10997
|
+
const logger$4U = getLogger("character");
|
|
10998
10998
|
function checkChar(charCode, rangeList) {
|
|
10999
10999
|
for (let i = 0; i < rangeList.length; i++) {
|
|
11000
11000
|
const start = rangeList[i][0];
|
|
@@ -11045,7 +11045,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11045
11045
|
}
|
|
11046
11046
|
function trimChar(s, char) {
|
|
11047
11047
|
let c = char;
|
|
11048
|
-
assert(logger$
|
|
11048
|
+
assert(logger$4U, c.length === 1, "invalid char length");
|
|
11049
11049
|
if (c === "]")
|
|
11050
11050
|
c = "\\]";
|
|
11051
11051
|
if (c === "\\")
|
|
@@ -11403,7 +11403,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11403
11403
|
return 200;
|
|
11404
11404
|
}
|
|
11405
11405
|
}
|
|
11406
|
-
const logger$
|
|
11406
|
+
const logger$4T = getLogger("editor-clipboard");
|
|
11407
11407
|
async function setClipboardDataByEvent(items, event) {
|
|
11408
11408
|
if (event.clipboardData) {
|
|
11409
11409
|
const data2 = event.clipboardData;
|
|
@@ -11461,7 +11461,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11461
11461
|
document.body.removeChild(textarea2);
|
|
11462
11462
|
return true;
|
|
11463
11463
|
} catch (ex) {
|
|
11464
|
-
logger$
|
|
11464
|
+
logger$4T.error(ex);
|
|
11465
11465
|
document.body.removeChild(textarea2);
|
|
11466
11466
|
return false;
|
|
11467
11467
|
}
|
|
@@ -11482,7 +11482,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11482
11482
|
document.body.removeChild(div);
|
|
11483
11483
|
return true;
|
|
11484
11484
|
} catch (ex) {
|
|
11485
|
-
logger$
|
|
11485
|
+
logger$4T.error(ex);
|
|
11486
11486
|
document.body.removeChild(div);
|
|
11487
11487
|
return false;
|
|
11488
11488
|
}
|
|
@@ -11509,7 +11509,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11509
11509
|
await navigator.clipboard.write([clipboardItems]);
|
|
11510
11510
|
return true;
|
|
11511
11511
|
} catch (err) {
|
|
11512
|
-
logger$
|
|
11512
|
+
logger$4T.error(err);
|
|
11513
11513
|
return await execCommandCopy(items);
|
|
11514
11514
|
}
|
|
11515
11515
|
}
|
|
@@ -11565,7 +11565,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11565
11565
|
a.click();
|
|
11566
11566
|
a.remove();
|
|
11567
11567
|
}
|
|
11568
|
-
const logger$
|
|
11568
|
+
const logger$4S = getLogger("auto-scroll");
|
|
11569
11569
|
function scrollable(scrollElement, direction) {
|
|
11570
11570
|
if (scrollElement.scrollHeight === scrollElement.clientHeight) {
|
|
11571
11571
|
return false;
|
|
@@ -11589,7 +11589,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11589
11589
|
const isHorizontal = direction === "left" || direction === "right";
|
|
11590
11590
|
const scroll = () => {
|
|
11591
11591
|
if (!scrollable(scrollElement, direction)) {
|
|
11592
|
-
logger$
|
|
11592
|
+
logger$4S.debug("No need for scroll");
|
|
11593
11593
|
return null;
|
|
11594
11594
|
}
|
|
11595
11595
|
if (isHorizontal) {
|
|
@@ -11646,7 +11646,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11646
11646
|
if (this.scrolling) {
|
|
11647
11647
|
return;
|
|
11648
11648
|
}
|
|
11649
|
-
logger$
|
|
11649
|
+
logger$4S.debug(`scroll direction: ${direction}`);
|
|
11650
11650
|
this.cancelScroll = continuousScroll(scrollElement, {
|
|
11651
11651
|
direction,
|
|
11652
11652
|
step
|
|
@@ -11984,7 +11984,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11984
11984
|
var _a;
|
|
11985
11985
|
(_a = pendingEditors.get(editor)) == null ? void 0 : _a.renderId(id);
|
|
11986
11986
|
}
|
|
11987
|
-
const logger$
|
|
11987
|
+
const logger$4R = getLogger("container");
|
|
11988
11988
|
function isContainer(elem) {
|
|
11989
11989
|
return elem.getAttribute("data-type") === "editor-container";
|
|
11990
11990
|
}
|
|
@@ -11996,9 +11996,9 @@ var __publicField = (obj, key, value) => {
|
|
|
11996
11996
|
}
|
|
11997
11997
|
function getContainerId(container) {
|
|
11998
11998
|
const id = container.getAttribute("data-container-id");
|
|
11999
|
-
assert(logger$
|
|
11999
|
+
assert(logger$4R, id, "no id for container");
|
|
12000
12000
|
if (isRootContainer(container)) {
|
|
12001
|
-
assert(logger$
|
|
12001
|
+
assert(logger$4R, id === "root", `invalid root container id, : ${id}`);
|
|
12002
12002
|
}
|
|
12003
12003
|
return id;
|
|
12004
12004
|
}
|
|
@@ -12009,7 +12009,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12009
12009
|
function generateEditorContainerId(containerId) {
|
|
12010
12010
|
return `ones-editor-container-${containerId}`;
|
|
12011
12011
|
}
|
|
12012
|
-
const logger$
|
|
12012
|
+
const logger$4Q = getLogger("element");
|
|
12013
12013
|
function createContainerElement(parent, type, containerId) {
|
|
12014
12014
|
const container = createElement("div", [type], parent);
|
|
12015
12015
|
container.setAttribute("data-type", "editor-container");
|
|
@@ -12024,7 +12024,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12024
12024
|
renderDeferredId(editor, containerId);
|
|
12025
12025
|
container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
|
|
12026
12026
|
}
|
|
12027
|
-
assert(logger$
|
|
12027
|
+
assert(logger$4Q, container, `no container: ${containerId}`);
|
|
12028
12028
|
return container;
|
|
12029
12029
|
}
|
|
12030
12030
|
function getExistsContainerById(editor, containerId) {
|
|
@@ -12033,7 +12033,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12033
12033
|
}
|
|
12034
12034
|
function getContainerBlocksElement(container) {
|
|
12035
12035
|
const blocks = container.querySelector(":scope > .container-blocks");
|
|
12036
|
-
assert(logger$
|
|
12036
|
+
assert(logger$4Q, blocks, "no container blocks element");
|
|
12037
12037
|
return blocks;
|
|
12038
12038
|
}
|
|
12039
12039
|
function getContainerToolsElement(container) {
|
|
@@ -12046,11 +12046,11 @@ var __publicField = (obj, key, value) => {
|
|
|
12046
12046
|
function isContainerBlocksElement(element) {
|
|
12047
12047
|
return element.classList.contains("container-blocks");
|
|
12048
12048
|
}
|
|
12049
|
-
const logger$
|
|
12049
|
+
const logger$4P = getLogger("container-children");
|
|
12050
12050
|
function getChildBlocks(container, traverseChild) {
|
|
12051
12051
|
const content = getContainerBlocksElement(container);
|
|
12052
12052
|
const blocks = Array.from(content.children);
|
|
12053
|
-
assert(logger$
|
|
12053
|
+
assert(logger$4P, blocks.length > 0, "container have not any child block");
|
|
12054
12054
|
if (traverseChild) {
|
|
12055
12055
|
const { condition, editor } = traverseChild;
|
|
12056
12056
|
return blocks.reduce((result, block) => {
|
|
@@ -12073,7 +12073,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12073
12073
|
}
|
|
12074
12074
|
function getFirstChildBlock(container) {
|
|
12075
12075
|
const block = container.querySelector(":scope > .container-blocks > div[data-type=editor-block]");
|
|
12076
|
-
assert(logger$
|
|
12076
|
+
assert(logger$4P, block, "container have not any child block");
|
|
12077
12077
|
return block;
|
|
12078
12078
|
}
|
|
12079
12079
|
function getLastChildBlock(container) {
|
|
@@ -12085,14 +12085,14 @@ var __publicField = (obj, key, value) => {
|
|
|
12085
12085
|
}
|
|
12086
12086
|
function getBlockByIndex(container, blockIndex) {
|
|
12087
12087
|
const block = getChildBlocks(container)[blockIndex];
|
|
12088
|
-
assert(logger$
|
|
12088
|
+
assert(logger$4P, block, `container have not block at index ${blockIndex}`);
|
|
12089
12089
|
return block;
|
|
12090
12090
|
}
|
|
12091
12091
|
function findBlockByIndex(container, blockIndex) {
|
|
12092
12092
|
var _a;
|
|
12093
12093
|
return (_a = getChildBlocks(container)[blockIndex]) != null ? _a : null;
|
|
12094
12094
|
}
|
|
12095
|
-
const logger$
|
|
12095
|
+
const logger$4O = getLogger("block-dom");
|
|
12096
12096
|
function isBlock$1(node) {
|
|
12097
12097
|
if (!(node instanceof HTMLDivElement)) {
|
|
12098
12098
|
return false;
|
|
@@ -12113,12 +12113,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12113
12113
|
}
|
|
12114
12114
|
function getBlockId(block) {
|
|
12115
12115
|
const { id } = block;
|
|
12116
|
-
assert(logger$
|
|
12116
|
+
assert(logger$4O, id, "no block id");
|
|
12117
12117
|
return id;
|
|
12118
12118
|
}
|
|
12119
12119
|
function getBlockType(block) {
|
|
12120
12120
|
const type = block.getAttribute("data-block-type");
|
|
12121
|
-
assert(logger$
|
|
12121
|
+
assert(logger$4O, type, "invalid block dom, no data-type");
|
|
12122
12122
|
return type;
|
|
12123
12123
|
}
|
|
12124
12124
|
function getParentBlock(node) {
|
|
@@ -12141,12 +12141,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12141
12141
|
}
|
|
12142
12142
|
function getParentContainer(block) {
|
|
12143
12143
|
const container = block.closest("div[data-type=editor-container]");
|
|
12144
|
-
assert(logger$
|
|
12144
|
+
assert(logger$4O, container, "failed to get block container");
|
|
12145
12145
|
return container;
|
|
12146
12146
|
}
|
|
12147
12147
|
function getBlockContent(block) {
|
|
12148
12148
|
const content = block.querySelector(":scope >div[data-type=block-content]");
|
|
12149
|
-
assert(logger$
|
|
12149
|
+
assert(logger$4O, content, "no block content");
|
|
12150
12150
|
return content;
|
|
12151
12151
|
}
|
|
12152
12152
|
function getBlockTools(block) {
|
|
@@ -12155,7 +12155,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12155
12155
|
tools = createElement("div", [], block);
|
|
12156
12156
|
tools.setAttribute("data-type", "block-tools");
|
|
12157
12157
|
}
|
|
12158
|
-
assert(logger$
|
|
12158
|
+
assert(logger$4O, tools, "no block tools");
|
|
12159
12159
|
return tools;
|
|
12160
12160
|
}
|
|
12161
12161
|
function getExistsBlockTools(block) {
|
|
@@ -12176,7 +12176,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12176
12176
|
function createBlockElement(editor, path, data2) {
|
|
12177
12177
|
const blockData = editor.editorDecorators.decorateBlock(path, data2);
|
|
12178
12178
|
const { id, type } = blockData;
|
|
12179
|
-
assert(logger$
|
|
12179
|
+
assert(logger$4O, id, "no block id");
|
|
12180
12180
|
const elem = createElement("div", [`${type}-block`], null);
|
|
12181
12181
|
elem.id = id;
|
|
12182
12182
|
elem.setAttribute("data-type", "editor-block");
|
|
@@ -12214,7 +12214,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12214
12214
|
}
|
|
12215
12215
|
function getBoxTypeFromElement(box) {
|
|
12216
12216
|
const type = box.getAttribute("data-box-type");
|
|
12217
|
-
assert(logger$
|
|
12217
|
+
assert(logger$4O, type, "not a valid box element, no type");
|
|
12218
12218
|
return type;
|
|
12219
12219
|
}
|
|
12220
12220
|
function isBox(node) {
|
|
@@ -12225,7 +12225,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12225
12225
|
}
|
|
12226
12226
|
function getBoxId(box) {
|
|
12227
12227
|
const { id } = box;
|
|
12228
|
-
assert(logger$
|
|
12228
|
+
assert(logger$4O, id, "no box id");
|
|
12229
12229
|
return id;
|
|
12230
12230
|
}
|
|
12231
12231
|
function getParentBox(node) {
|
|
@@ -12247,7 +12247,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12247
12247
|
}
|
|
12248
12248
|
function getBoxContent(box) {
|
|
12249
12249
|
const content = box.querySelector("span[data-type=box-content]");
|
|
12250
|
-
assert(logger$
|
|
12250
|
+
assert(logger$4O, content, "invalid box dom, no content");
|
|
12251
12251
|
return content;
|
|
12252
12252
|
}
|
|
12253
12253
|
function createInsertionElement(type, id, attributes) {
|
|
@@ -12269,7 +12269,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12269
12269
|
}
|
|
12270
12270
|
function getInsertionContent(insertion) {
|
|
12271
12271
|
const content = insertion.querySelector("span[data-type=insertion-content]");
|
|
12272
|
-
assert(logger$
|
|
12272
|
+
assert(logger$4O, content, "invalid insertion-child dom, no content");
|
|
12273
12273
|
return content;
|
|
12274
12274
|
}
|
|
12275
12275
|
function getPrevBlock(block) {
|
|
@@ -12329,7 +12329,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12329
12329
|
const container = getParentContainer(block);
|
|
12330
12330
|
const children = getChildBlocks(container);
|
|
12331
12331
|
const index2 = children.indexOf(block);
|
|
12332
|
-
assert(logger$
|
|
12332
|
+
assert(logger$4O, index2 !== -1, "invalid block & container dom, failed to get block index");
|
|
12333
12333
|
return index2;
|
|
12334
12334
|
}
|
|
12335
12335
|
function isInBlock(target) {
|
|
@@ -12354,18 +12354,18 @@ var __publicField = (obj, key, value) => {
|
|
|
12354
12354
|
function isTitleBlock$2(block) {
|
|
12355
12355
|
return block.hasAttribute("data-document-title");
|
|
12356
12356
|
}
|
|
12357
|
-
const logger$
|
|
12357
|
+
const logger$4N = getLogger("block-class");
|
|
12358
12358
|
function getBlockClass(editor, block) {
|
|
12359
12359
|
return editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
12360
12360
|
}
|
|
12361
12361
|
function getTextBlockClass(editor, block) {
|
|
12362
12362
|
const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
12363
|
-
assert(logger$
|
|
12363
|
+
assert(logger$4N, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
|
|
12364
12364
|
return text2;
|
|
12365
12365
|
}
|
|
12366
12366
|
function getComplexBlockClass(editor, block) {
|
|
12367
12367
|
const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
|
|
12368
|
-
assert(logger$
|
|
12368
|
+
assert(logger$4N, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
|
|
12369
12369
|
return complex;
|
|
12370
12370
|
}
|
|
12371
12371
|
function getBlockClassByType(editor, type) {
|
|
@@ -12386,7 +12386,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12386
12386
|
function getBlockKind(editor, block) {
|
|
12387
12387
|
return getBlockClass(editor, block).blockKind;
|
|
12388
12388
|
}
|
|
12389
|
-
const logger$
|
|
12389
|
+
const logger$4M = getLogger("text-block-child");
|
|
12390
12390
|
function isTextBlockContentChild(elem) {
|
|
12391
12391
|
if (elem.tagName !== "SPAN") {
|
|
12392
12392
|
return false;
|
|
@@ -12394,14 +12394,14 @@ var __publicField = (obj, key, value) => {
|
|
|
12394
12394
|
return true;
|
|
12395
12395
|
}
|
|
12396
12396
|
function isTextBlockContentBoxChild(elem) {
|
|
12397
|
-
assert(logger$
|
|
12397
|
+
assert(logger$4M, isTextBlockContentChild(elem), "not a valid text child");
|
|
12398
12398
|
if (elem.getAttribute("data-type") === "editor-box") {
|
|
12399
12399
|
return true;
|
|
12400
12400
|
}
|
|
12401
12401
|
return false;
|
|
12402
12402
|
}
|
|
12403
12403
|
function isTextBlockContentInsertionChild(elem) {
|
|
12404
|
-
assert(logger$
|
|
12404
|
+
assert(logger$4M, isTextBlockContentChild(elem), "not a valid text child");
|
|
12405
12405
|
if (elem.getAttribute("data-type") === "editor-insertion") {
|
|
12406
12406
|
return true;
|
|
12407
12407
|
}
|
|
@@ -12411,7 +12411,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12411
12411
|
return !isTextBlockContentBoxChild(elem) && !isTextBlockContentInsertionChild(elem);
|
|
12412
12412
|
}
|
|
12413
12413
|
function getTextBlockContentChildType(child) {
|
|
12414
|
-
assert(logger$
|
|
12414
|
+
assert(logger$4M, isTextBlockContentChild(child), "not a valid text child");
|
|
12415
12415
|
if (isTextBlockContentBoxChild(child)) {
|
|
12416
12416
|
return "box";
|
|
12417
12417
|
}
|
|
@@ -12426,15 +12426,15 @@ var __publicField = (obj, key, value) => {
|
|
|
12426
12426
|
return 0;
|
|
12427
12427
|
if (type === "box")
|
|
12428
12428
|
return 1;
|
|
12429
|
-
assert(logger$
|
|
12430
|
-
assert(logger$
|
|
12429
|
+
assert(logger$4M, child.textContent !== null, "text block content is undefined");
|
|
12430
|
+
assert(logger$4M, child.textContent.length >= 0, "text block content length is negative");
|
|
12431
12431
|
return child.textContent.length;
|
|
12432
12432
|
}
|
|
12433
12433
|
function getTextBlockContentChildren(block) {
|
|
12434
12434
|
const content = getBlockContent(block);
|
|
12435
12435
|
const children = Array.from(content.children);
|
|
12436
12436
|
children.forEach((child) => {
|
|
12437
|
-
assert(logger$
|
|
12437
|
+
assert(logger$4M, isTextBlockContentChild(child), "not a valid text child");
|
|
12438
12438
|
});
|
|
12439
12439
|
return children;
|
|
12440
12440
|
}
|
|
@@ -12463,17 +12463,17 @@ var __publicField = (obj, key, value) => {
|
|
|
12463
12463
|
};
|
|
12464
12464
|
}
|
|
12465
12465
|
const offset = blockOffset - start;
|
|
12466
|
-
assert(logger$
|
|
12467
|
-
assert(logger$
|
|
12466
|
+
assert(logger$4M, offset > 0, "invalid offset value");
|
|
12467
|
+
assert(logger$4M, !isTextBlockContentBoxChild(child), "invalid box child");
|
|
12468
12468
|
return {
|
|
12469
12469
|
prev: child,
|
|
12470
12470
|
next: child,
|
|
12471
12471
|
offset
|
|
12472
12472
|
};
|
|
12473
12473
|
}
|
|
12474
|
-
assert(logger$
|
|
12474
|
+
assert(logger$4M, false, `invalid block child at position: ${blockOffset}`);
|
|
12475
12475
|
}
|
|
12476
|
-
const logger$
|
|
12476
|
+
const logger$4L = getLogger("block-path");
|
|
12477
12477
|
function getBlockPath(block) {
|
|
12478
12478
|
const ret = [];
|
|
12479
12479
|
let current = block;
|
|
@@ -12487,26 +12487,26 @@ var __publicField = (obj, key, value) => {
|
|
|
12487
12487
|
return ret;
|
|
12488
12488
|
}
|
|
12489
12489
|
const parentBlock = getParentBlock(container);
|
|
12490
|
-
assert(logger$
|
|
12490
|
+
assert(logger$4L, parentBlock, "no parent block");
|
|
12491
12491
|
current = parentBlock;
|
|
12492
12492
|
}
|
|
12493
|
-
assert(logger$
|
|
12493
|
+
assert(logger$4L, false, "no parent block");
|
|
12494
12494
|
return [];
|
|
12495
12495
|
}
|
|
12496
|
-
const logger$
|
|
12496
|
+
const logger$4K = getLogger("child-container-path");
|
|
12497
12497
|
function getContainerBlockPath(container) {
|
|
12498
12498
|
if (isRootContainer(container)) {
|
|
12499
12499
|
return [];
|
|
12500
12500
|
}
|
|
12501
12501
|
const parentBlock = getParentBlock(container);
|
|
12502
|
-
assert(logger$
|
|
12502
|
+
assert(logger$4K, parentBlock, "no parent block");
|
|
12503
12503
|
return getBlockPath(parentBlock);
|
|
12504
12504
|
}
|
|
12505
|
-
const logger$
|
|
12505
|
+
const logger$4J = getLogger("load-blocks");
|
|
12506
12506
|
function loadBlocks(editor, container, path) {
|
|
12507
12507
|
const containerId = getContainerId(container);
|
|
12508
12508
|
const blocks = getContainerBlocks$1(container, editor.doc);
|
|
12509
|
-
assert(logger$
|
|
12509
|
+
assert(logger$4J, blocks.length > 0, "no blocks in container");
|
|
12510
12510
|
const fragment = document.createDocumentFragment();
|
|
12511
12511
|
blocks.forEach((b, index2) => {
|
|
12512
12512
|
const block = editor.editorBlocks.createBlock([...path, { containerId, blockIndex: index2 }], container, b);
|
|
@@ -12522,7 +12522,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12522
12522
|
return block;
|
|
12523
12523
|
}
|
|
12524
12524
|
const blocks = getChildBlocks(container);
|
|
12525
|
-
assert(logger$
|
|
12525
|
+
assert(logger$4J, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
|
|
12526
12526
|
if (blockIndex === blocks.length) {
|
|
12527
12527
|
containerBlocksElement.appendChild(block);
|
|
12528
12528
|
} else {
|
|
@@ -12540,7 +12540,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12540
12540
|
insertBlockAt(container, blockIndex, block);
|
|
12541
12541
|
return block;
|
|
12542
12542
|
}
|
|
12543
|
-
const logger$
|
|
12543
|
+
const logger$4I = getLogger("root-container");
|
|
12544
12544
|
const MIN_DISTANCE_THRESHOLD$2 = 3;
|
|
12545
12545
|
class RootContainer {
|
|
12546
12546
|
constructor(editor, rootContainer) {
|
|
@@ -12568,7 +12568,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12568
12568
|
this.editor.selection.updateSelection(null);
|
|
12569
12569
|
this.editor.emit("resize", this.editor);
|
|
12570
12570
|
} catch (err) {
|
|
12571
|
-
logger$
|
|
12571
|
+
logger$4I.warn(`failed to update selection while container resizing: ${err.message}`);
|
|
12572
12572
|
}
|
|
12573
12573
|
});
|
|
12574
12574
|
__publicField(this, "handleClick", (event) => {
|
|
@@ -12602,7 +12602,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12602
12602
|
const box = getParentBox(elem);
|
|
12603
12603
|
if (box && isChildNode(box, eTarget)) {
|
|
12604
12604
|
const block2 = getParentBlock(box);
|
|
12605
|
-
assert(logger$
|
|
12605
|
+
assert(logger$4I, block2, "no parent block");
|
|
12606
12606
|
(_b = (_a = this.editor.editorBoxes.getBoxClass(getBoxTypeFromElement(box))) == null ? void 0 : _a.handleClickBox) == null ? void 0 : _b.call(_a, this.editor, box, event);
|
|
12607
12607
|
return;
|
|
12608
12608
|
}
|
|
@@ -12658,7 +12658,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12658
12658
|
this.editor.input.focus({ preventScroll: true });
|
|
12659
12659
|
});
|
|
12660
12660
|
__publicField(this, "handleMouseMove", (event) => {
|
|
12661
|
-
assert(logger$
|
|
12661
|
+
assert(logger$4I, this.mouseDownEvent, "no mouse down event");
|
|
12662
12662
|
if (ensureIsMobileEvent(this.mouseDownEvent))
|
|
12663
12663
|
return;
|
|
12664
12664
|
const deltaX = event.x - this.mouseDownEvent.x;
|
|
@@ -12774,7 +12774,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12774
12774
|
loadBlocks(editor, container, path);
|
|
12775
12775
|
return container;
|
|
12776
12776
|
}
|
|
12777
|
-
const logger$
|
|
12777
|
+
const logger$4H = getLogger("block");
|
|
12778
12778
|
function getBlockTextLength$6(editor, block) {
|
|
12779
12779
|
return getBlockClass(editor, block).getBlockTextLength(block);
|
|
12780
12780
|
}
|
|
@@ -12793,7 +12793,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12793
12793
|
return block;
|
|
12794
12794
|
}
|
|
12795
12795
|
const parent = getParentBlock(container);
|
|
12796
|
-
assert(logger$
|
|
12796
|
+
assert(logger$4H, parent, "no parent block exists for child container");
|
|
12797
12797
|
block = parent;
|
|
12798
12798
|
}
|
|
12799
12799
|
}
|
|
@@ -12829,7 +12829,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12829
12829
|
}
|
|
12830
12830
|
return fun(editor, block, options);
|
|
12831
12831
|
} catch (err) {
|
|
12832
|
-
logger$
|
|
12832
|
+
logger$4H.debug(`unsupported block type: ${type}`);
|
|
12833
12833
|
return null;
|
|
12834
12834
|
}
|
|
12835
12835
|
}
|
|
@@ -12849,7 +12849,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12849
12849
|
const styles2 = Object.fromEntries(Object.entries(data2).filter(([key]) => key.startsWith("style-")));
|
|
12850
12850
|
Object.entries(styles2).forEach(([, value]) => {
|
|
12851
12851
|
const type = typeof value;
|
|
12852
|
-
assert(logger$
|
|
12852
|
+
assert(logger$4H, type === "string" || type === "number" || type === "boolean", "invalid style value");
|
|
12853
12853
|
});
|
|
12854
12854
|
return styles2;
|
|
12855
12855
|
}
|
|
@@ -12974,7 +12974,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12974
12974
|
}
|
|
12975
12975
|
return { element: null, blockCommands: [], boxCommands: [] };
|
|
12976
12976
|
}
|
|
12977
|
-
const logger$
|
|
12977
|
+
const logger$4G = getLogger("embed-block-common");
|
|
12978
12978
|
function isColumnsBlock(block) {
|
|
12979
12979
|
return getBlockType(block) === "layout";
|
|
12980
12980
|
}
|
|
@@ -12982,9 +12982,9 @@ var __publicField = (obj, key, value) => {
|
|
|
12982
12982
|
return getBlockType(block) === "embed";
|
|
12983
12983
|
}
|
|
12984
12984
|
function getEmbedType(block) {
|
|
12985
|
-
assert(logger$
|
|
12985
|
+
assert(logger$4G, isEmbedBlock(block), "not an embed block");
|
|
12986
12986
|
const type = block.getAttribute("data-embed-type");
|
|
12987
|
-
assert(logger$
|
|
12987
|
+
assert(logger$4G, type, "no embed data type");
|
|
12988
12988
|
return type;
|
|
12989
12989
|
}
|
|
12990
12990
|
function getEmbedClassFromBlock(editor, block) {
|
|
@@ -13050,10 +13050,10 @@ var __publicField = (obj, key, value) => {
|
|
|
13050
13050
|
data: (_c = overrideOptions == null ? void 0 : overrideOptions.data) != null ? _c : data2
|
|
13051
13051
|
});
|
|
13052
13052
|
}
|
|
13053
|
-
const logger$
|
|
13053
|
+
const logger$4F = getLogger("execute-block-command");
|
|
13054
13054
|
function executeEmbedBlockCommand(editor, block, commandGroup, item) {
|
|
13055
13055
|
var _a;
|
|
13056
|
-
assert(logger$
|
|
13056
|
+
assert(logger$4F, isEmbedBlock(block), "not a embed block");
|
|
13057
13057
|
const embedType = getEmbedType(block);
|
|
13058
13058
|
const embed = getEmbedClassByType(editor, embedType);
|
|
13059
13059
|
if (!embed.getOptions) {
|
|
@@ -13086,14 +13086,14 @@ var __publicField = (obj, key, value) => {
|
|
|
13086
13086
|
}
|
|
13087
13087
|
return void 0;
|
|
13088
13088
|
}
|
|
13089
|
-
const logger$
|
|
13089
|
+
const logger$4E = getLogger("block-class");
|
|
13090
13090
|
function isHeadingBlock$1(block) {
|
|
13091
13091
|
return !!block.getAttribute("data-style-heading");
|
|
13092
13092
|
}
|
|
13093
13093
|
function getBlockHeading(block) {
|
|
13094
13094
|
var _a;
|
|
13095
13095
|
const heading = Number.parseInt((_a = block.getAttribute("data-style-heading")) != null ? _a : "", 10);
|
|
13096
|
-
assert(logger$
|
|
13096
|
+
assert(logger$4E, heading, "not a heading block");
|
|
13097
13097
|
return heading;
|
|
13098
13098
|
}
|
|
13099
13099
|
function isExpandedHeadingBlock(block) {
|
|
@@ -13104,7 +13104,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13104
13104
|
}
|
|
13105
13105
|
function getHeadingBlockChildren(block, oldHeading) {
|
|
13106
13106
|
if (!oldHeading) {
|
|
13107
|
-
assert(logger$
|
|
13107
|
+
assert(logger$4E, isHeadingBlock$1(block), "not a heading block");
|
|
13108
13108
|
}
|
|
13109
13109
|
const children = [];
|
|
13110
13110
|
const heading = oldHeading != null ? oldHeading : getBlockHeading(block);
|
|
@@ -13134,7 +13134,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13134
13134
|
}
|
|
13135
13135
|
return children;
|
|
13136
13136
|
}
|
|
13137
|
-
const logger$
|
|
13137
|
+
const logger$4D = getLogger("complex-block-position");
|
|
13138
13138
|
class EditorComplexBlockPosition {
|
|
13139
13139
|
constructor(block, childContainerId, custom) {
|
|
13140
13140
|
__publicField(this, "blockId");
|
|
@@ -13143,7 +13143,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13143
13143
|
if (block instanceof HTMLElement) {
|
|
13144
13144
|
this.blockId = getBlockId(block);
|
|
13145
13145
|
} else {
|
|
13146
|
-
assert(logger$
|
|
13146
|
+
assert(logger$4D, typeof block === "string", `not a valid block id: ${block}`);
|
|
13147
13147
|
this.blockId = block;
|
|
13148
13148
|
}
|
|
13149
13149
|
this.childContainerId = childContainerId;
|
|
@@ -13155,7 +13155,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13155
13155
|
return false;
|
|
13156
13156
|
}
|
|
13157
13157
|
}
|
|
13158
|
-
const logger$
|
|
13158
|
+
const logger$4C = getLogger("simple-block-position");
|
|
13159
13159
|
class EditorSimpleBlockPosition {
|
|
13160
13160
|
constructor(block, offset, type) {
|
|
13161
13161
|
__publicField(this, "blockId");
|
|
@@ -13164,7 +13164,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13164
13164
|
if (block instanceof HTMLElement) {
|
|
13165
13165
|
this.blockId = getBlockId(block);
|
|
13166
13166
|
} else {
|
|
13167
|
-
assert(logger$
|
|
13167
|
+
assert(logger$4C, typeof block === "string", `not a valid block id: ${block}`);
|
|
13168
13168
|
this.blockId = block;
|
|
13169
13169
|
}
|
|
13170
13170
|
this.offset = offset;
|
|
@@ -13174,7 +13174,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13174
13174
|
return true;
|
|
13175
13175
|
}
|
|
13176
13176
|
}
|
|
13177
|
-
const logger$
|
|
13177
|
+
const logger$4B = getLogger("editor-position");
|
|
13178
13178
|
function createSimpleBlockPosition(block, offset, type) {
|
|
13179
13179
|
return new EditorSimpleBlockPosition(block, offset, type);
|
|
13180
13180
|
}
|
|
@@ -13196,7 +13196,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13196
13196
|
}
|
|
13197
13197
|
const block1 = editor.getBlockById(pos1.blockId);
|
|
13198
13198
|
const block2 = editor.getBlockById(pos2.blockId);
|
|
13199
|
-
assert(logger$
|
|
13199
|
+
assert(logger$4B, block1 !== block2, "comparePosition: blocks are the same");
|
|
13200
13200
|
return compareElement(block1, block2);
|
|
13201
13201
|
}
|
|
13202
13202
|
if (isComplexBlockPosition(pos1) && isComplexBlockPosition(pos2)) {
|
|
@@ -13207,13 +13207,13 @@ var __publicField = (obj, key, value) => {
|
|
|
13207
13207
|
}
|
|
13208
13208
|
const container1 = editor.getContainerById(p1.childContainerId);
|
|
13209
13209
|
const container2 = editor.getContainerById(p2.childContainerId);
|
|
13210
|
-
assert(logger$
|
|
13210
|
+
assert(logger$4B, container1 !== container2, "comparePosition: containers are the same");
|
|
13211
13211
|
return compareElement(container1, container2);
|
|
13212
13212
|
}
|
|
13213
|
-
assert(logger$
|
|
13213
|
+
assert(logger$4B, false, "invalid ");
|
|
13214
13214
|
return 0;
|
|
13215
13215
|
}
|
|
13216
|
-
const logger$
|
|
13216
|
+
const logger$4A = getLogger("simple-range");
|
|
13217
13217
|
class EditorSimpleSelectionRange {
|
|
13218
13218
|
constructor(editor, options) {
|
|
13219
13219
|
__publicField(this, "editor");
|
|
@@ -13262,11 +13262,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13262
13262
|
const { editor } = this;
|
|
13263
13263
|
const startBlock = editor.getBlockById(this.start.blockId);
|
|
13264
13264
|
const endBlock = editor.getBlockById(this.end.blockId);
|
|
13265
|
-
assert(logger$
|
|
13266
|
-
assert(logger$
|
|
13265
|
+
assert(logger$4A, startBlock, "no start block");
|
|
13266
|
+
assert(logger$4A, endBlock, "no end block");
|
|
13267
13267
|
const startContainer = getParentContainer(startBlock);
|
|
13268
13268
|
const endContainer = getParentContainer(endBlock);
|
|
13269
|
-
assert(logger$
|
|
13269
|
+
assert(logger$4A, startContainer === endContainer, "invalid range");
|
|
13270
13270
|
const ret = [];
|
|
13271
13271
|
if (startBlock === endBlock) {
|
|
13272
13272
|
ret.push({
|
|
@@ -13277,7 +13277,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13277
13277
|
} else {
|
|
13278
13278
|
const startIndex = getBlockIndex(startBlock);
|
|
13279
13279
|
const endIndex = getBlockIndex(endBlock);
|
|
13280
|
-
assert(logger$
|
|
13280
|
+
assert(logger$4A, startIndex < endIndex, "invalid range, start > index");
|
|
13281
13281
|
ret.push({
|
|
13282
13282
|
block: startBlock,
|
|
13283
13283
|
start: this.start,
|
|
@@ -13377,7 +13377,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13377
13377
|
clearSelection: clearSelection$6,
|
|
13378
13378
|
convertTo: convertTo$m
|
|
13379
13379
|
};
|
|
13380
|
-
const logger$
|
|
13380
|
+
const logger$4z = getLogger("editor-blocks");
|
|
13381
13381
|
class EditorBlocks {
|
|
13382
13382
|
constructor(editor) {
|
|
13383
13383
|
__publicField(this, "blocks", /* @__PURE__ */ new Map());
|
|
@@ -13386,12 +13386,12 @@ var __publicField = (obj, key, value) => {
|
|
|
13386
13386
|
registerBlockClass(blockClass) {
|
|
13387
13387
|
const type = blockClass.blockType;
|
|
13388
13388
|
const exists = this.blocks.get(type);
|
|
13389
|
-
assert(logger$
|
|
13389
|
+
assert(logger$4z, !exists, `duplicated block type: ${type}`);
|
|
13390
13390
|
this.blocks.set(type, blockClass);
|
|
13391
13391
|
}
|
|
13392
13392
|
getBlockClass(type) {
|
|
13393
13393
|
const exists = this.blocks.get(type);
|
|
13394
|
-
assert(logger$
|
|
13394
|
+
assert(logger$4z, exists, `unknown block type: ${type}`);
|
|
13395
13395
|
return exists;
|
|
13396
13396
|
}
|
|
13397
13397
|
hasBlock(type) {
|
|
@@ -13407,7 +13407,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13407
13407
|
}
|
|
13408
13408
|
const content = blockClass.createBlockContent(this.editor, path, container, blockElement, block);
|
|
13409
13409
|
if (content.parentElement !== blockElement) {
|
|
13410
|
-
logger$
|
|
13410
|
+
logger$4z.warn("content parent is not block");
|
|
13411
13411
|
blockElement.appendChild(content);
|
|
13412
13412
|
}
|
|
13413
13413
|
this.editor.blockHooks.forEach((hook) => {
|
|
@@ -13428,7 +13428,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13428
13428
|
return newBlock;
|
|
13429
13429
|
}
|
|
13430
13430
|
}
|
|
13431
|
-
const logger$
|
|
13431
|
+
const logger$4y = getLogger("editor-embeds");
|
|
13432
13432
|
class EditorEmbeds {
|
|
13433
13433
|
constructor(editor) {
|
|
13434
13434
|
__publicField(this, "objects", /* @__PURE__ */ new Map());
|
|
@@ -13437,12 +13437,12 @@ var __publicField = (obj, key, value) => {
|
|
|
13437
13437
|
registerEmbedClass(embedClass) {
|
|
13438
13438
|
const type = embedClass.embedType;
|
|
13439
13439
|
const exists = this.objects.get(type);
|
|
13440
|
-
assert(logger$
|
|
13440
|
+
assert(logger$4y, !exists, `duplicated embed object type: ${type}`);
|
|
13441
13441
|
this.objects.set(type, embedClass);
|
|
13442
13442
|
}
|
|
13443
13443
|
getEmbedClass(type) {
|
|
13444
13444
|
const exists = this.objects.get(type);
|
|
13445
|
-
assert(logger$
|
|
13445
|
+
assert(logger$4y, exists, `unknown embed type: ${type}`);
|
|
13446
13446
|
return exists;
|
|
13447
13447
|
}
|
|
13448
13448
|
getEmbedClassFromBlock(block) {
|
|
@@ -13452,12 +13452,12 @@ var __publicField = (obj, key, value) => {
|
|
|
13452
13452
|
this.objects.forEach(callback);
|
|
13453
13453
|
}
|
|
13454
13454
|
}
|
|
13455
|
-
const logger$
|
|
13455
|
+
const logger$4x = getLogger("embed-block");
|
|
13456
13456
|
function createBlockContent$6(editor, path, container, blockElement, blockData) {
|
|
13457
13457
|
const content = createBlockContentElement(blockElement, "div");
|
|
13458
|
-
assert(logger$
|
|
13458
|
+
assert(logger$4x, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
|
|
13459
13459
|
const embedBlockData = blockData;
|
|
13460
|
-
assert(logger$
|
|
13460
|
+
assert(logger$4x, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
|
|
13461
13461
|
const embedClass = editor.editorEmbeds.getEmbedClass(embedBlockData.embedType);
|
|
13462
13462
|
embedClass.createEmbedContent(editor, content, embedBlockData, path, container, blockElement);
|
|
13463
13463
|
blockElement.setAttribute("data-embed-type", embedBlockData.embedType);
|
|
@@ -13485,7 +13485,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13485
13485
|
function getCaretRect$4(block, pos) {
|
|
13486
13486
|
const content = getBlockContent(block);
|
|
13487
13487
|
const rect = content.getBoundingClientRect();
|
|
13488
|
-
assert(logger$
|
|
13488
|
+
assert(logger$4x, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
|
|
13489
13489
|
if (pos.offset === 1) {
|
|
13490
13490
|
return new DOMRect(rect.right, rect.top, 0, rect.height);
|
|
13491
13491
|
}
|
|
@@ -13625,18 +13625,18 @@ var __publicField = (obj, key, value) => {
|
|
|
13625
13625
|
toStandardDoc: toStandardDoc$2,
|
|
13626
13626
|
getResources: getResources$2
|
|
13627
13627
|
};
|
|
13628
|
-
const logger$
|
|
13628
|
+
const logger$4w = getLogger("complex-block-helper");
|
|
13629
13629
|
function complexBlockGetAllChildContainers(editor, block, options) {
|
|
13630
13630
|
const blockClass = getComplexBlockClass(editor, block);
|
|
13631
13631
|
return blockClass.getChildContainers(editor, block, options);
|
|
13632
13632
|
}
|
|
13633
13633
|
function complexBlockGetSelectedContainers(editor, block, start, end) {
|
|
13634
13634
|
if (start.isSimple()) {
|
|
13635
|
-
assert(logger$
|
|
13635
|
+
assert(logger$4w, end.isSimple(), "invalid start and end position");
|
|
13636
13636
|
return complexBlockGetAllChildContainers(editor, block);
|
|
13637
13637
|
}
|
|
13638
|
-
assert(logger$
|
|
13639
|
-
assert(logger$
|
|
13638
|
+
assert(logger$4w, !start.isSimple(), "invalid start pos");
|
|
13639
|
+
assert(logger$4w, !end.isSimple(), "invalid end pos");
|
|
13640
13640
|
const blockClass = getComplexBlockClass(editor, block);
|
|
13641
13641
|
return blockClass.getSelectedContainers(editor, block, start, end);
|
|
13642
13642
|
}
|
|
@@ -13647,11 +13647,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13647
13647
|
const parentComplexBlock = getParentBlock(getParentContainer(childBlock));
|
|
13648
13648
|
if (!parentComplexBlock)
|
|
13649
13649
|
return false;
|
|
13650
|
-
assert(logger$
|
|
13650
|
+
assert(logger$4w, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
|
|
13651
13651
|
const childContainer = getParentContainer(childBlock);
|
|
13652
13652
|
const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
|
|
13653
13653
|
const index2 = childContainers.indexOf(childContainer);
|
|
13654
|
-
assert(logger$
|
|
13654
|
+
assert(logger$4w, index2 >= 0, "not valid child container");
|
|
13655
13655
|
return index2 === 0;
|
|
13656
13656
|
}
|
|
13657
13657
|
function complexBlockGetFirstSimpleChild(editor, complexBlock, options) {
|
|
@@ -13704,13 +13704,13 @@ var __publicField = (obj, key, value) => {
|
|
|
13704
13704
|
return block;
|
|
13705
13705
|
}
|
|
13706
13706
|
function findPrevSimpleBlockBeforeChildContainer(editor, childContainer, options) {
|
|
13707
|
-
assert(logger$
|
|
13707
|
+
assert(logger$4w, isChildContainer(childContainer), "not a child container");
|
|
13708
13708
|
const parentComplexBlock = getParentBlock(childContainer);
|
|
13709
|
-
assert(logger$
|
|
13710
|
-
assert(logger$
|
|
13709
|
+
assert(logger$4w, parentComplexBlock, "no parent block");
|
|
13710
|
+
assert(logger$4w, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
|
|
13711
13711
|
const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock, options);
|
|
13712
13712
|
const containerIndex = childContainers.indexOf(childContainer);
|
|
13713
|
-
assert(logger$
|
|
13713
|
+
assert(logger$4w, containerIndex !== -1, "child container not found");
|
|
13714
13714
|
if (containerIndex === 0) {
|
|
13715
13715
|
const prevBlock = getPrevBlock(parentComplexBlock);
|
|
13716
13716
|
if (!prevBlock)
|
|
@@ -13728,9 +13728,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13728
13728
|
return lastBlock2;
|
|
13729
13729
|
}
|
|
13730
13730
|
function complexBlockGetTopChildContainers(editor, complexBlock) {
|
|
13731
|
-
assert(logger$
|
|
13731
|
+
assert(logger$4w, isComplexKindBlock(editor, complexBlock), "not a complex block");
|
|
13732
13732
|
const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
|
|
13733
|
-
assert(logger$
|
|
13733
|
+
assert(logger$4w, childContainers.length > 0, "no child container");
|
|
13734
13734
|
if (childContainers.length === 1) {
|
|
13735
13735
|
return childContainers;
|
|
13736
13736
|
}
|
|
@@ -13755,9 +13755,9 @@ var __publicField = (obj, key, value) => {
|
|
|
13755
13755
|
return ret;
|
|
13756
13756
|
}
|
|
13757
13757
|
function complexBlockGetBottomChildContainers(editor, complexBlock) {
|
|
13758
|
-
assert(logger$
|
|
13758
|
+
assert(logger$4w, isComplexKindBlock(editor, complexBlock), "not a complex block");
|
|
13759
13759
|
const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
|
|
13760
|
-
assert(logger$
|
|
13760
|
+
assert(logger$4w, childContainers.length > 0, "no child container");
|
|
13761
13761
|
if (childContainers.length === 1) {
|
|
13762
13762
|
return childContainers;
|
|
13763
13763
|
}
|
|
@@ -13862,11 +13862,11 @@ var __publicField = (obj, key, value) => {
|
|
|
13862
13862
|
return result;
|
|
13863
13863
|
}
|
|
13864
13864
|
const anchor = "";
|
|
13865
|
-
const logger$
|
|
13865
|
+
const logger$4v = getLogger("text-range");
|
|
13866
13866
|
function getBlockRangeInfo(block, blockOffset) {
|
|
13867
13867
|
const getChildRange = (child, offset) => {
|
|
13868
13868
|
if (isTextBlockContentInsertionChild(child)) {
|
|
13869
|
-
assert(logger$
|
|
13869
|
+
assert(logger$4v, offset === 0, `invalid offset for insertion child: ${offset}`);
|
|
13870
13870
|
const childOffset = 2;
|
|
13871
13871
|
return {
|
|
13872
13872
|
child,
|
|
@@ -13875,7 +13875,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13875
13875
|
};
|
|
13876
13876
|
}
|
|
13877
13877
|
if (isTextBlockContentBoxChild(child)) {
|
|
13878
|
-
assert(logger$
|
|
13878
|
+
assert(logger$4v, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
|
|
13879
13879
|
const childOffset = offset === 0 ? 1 : 2;
|
|
13880
13880
|
return {
|
|
13881
13881
|
child,
|
|
@@ -13884,17 +13884,17 @@ var __publicField = (obj, key, value) => {
|
|
|
13884
13884
|
};
|
|
13885
13885
|
}
|
|
13886
13886
|
const textNode = child.firstChild;
|
|
13887
|
-
assert(logger$
|
|
13888
|
-
assert(logger$
|
|
13887
|
+
assert(logger$4v, textNode, "no child node for text child");
|
|
13888
|
+
assert(logger$4v, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
|
|
13889
13889
|
if (textNode instanceof HTMLBRElement) {
|
|
13890
|
-
assert(logger$
|
|
13890
|
+
assert(logger$4v, offset >= 0 && offset <= 0, "invalid offset for text child");
|
|
13891
13891
|
return {
|
|
13892
13892
|
child,
|
|
13893
13893
|
container: textNode,
|
|
13894
13894
|
offset
|
|
13895
13895
|
};
|
|
13896
13896
|
}
|
|
13897
|
-
assert(logger$
|
|
13897
|
+
assert(logger$4v, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
|
|
13898
13898
|
return {
|
|
13899
13899
|
child,
|
|
13900
13900
|
container: textNode,
|
|
@@ -13923,38 +13923,38 @@ var __publicField = (obj, key, value) => {
|
|
|
13923
13923
|
}
|
|
13924
13924
|
start += childLength;
|
|
13925
13925
|
}
|
|
13926
|
-
assert(logger$
|
|
13926
|
+
assert(logger$4v, false, "failed to get range info");
|
|
13927
13927
|
}
|
|
13928
13928
|
function createChildRange(child, start, end) {
|
|
13929
13929
|
if (start === end) {
|
|
13930
|
-
assert(logger$
|
|
13930
|
+
assert(logger$4v, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
|
|
13931
13931
|
} else {
|
|
13932
|
-
assert(logger$
|
|
13932
|
+
assert(logger$4v, start < end, `invalid start & end: ${start}, ${end}`);
|
|
13933
13933
|
}
|
|
13934
13934
|
if (isTextBlockContentInsertionChild(child)) {
|
|
13935
|
-
assert(logger$
|
|
13936
|
-
assert(logger$
|
|
13935
|
+
assert(logger$4v, start === end, `invalid insertion child range offset: ${start}, ${end}`);
|
|
13936
|
+
assert(logger$4v, start === 0, `invalid insertion child range start: ${start}`);
|
|
13937
13937
|
const insertionElem = child;
|
|
13938
|
-
assert(logger$
|
|
13938
|
+
assert(logger$4v, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
|
|
13939
13939
|
const range = createExpandedRange(insertionElem, 1, insertionElem, 2);
|
|
13940
13940
|
return range;
|
|
13941
13941
|
}
|
|
13942
13942
|
if (isTextBlockContentBoxChild(child)) {
|
|
13943
|
-
assert(logger$
|
|
13944
|
-
assert(logger$
|
|
13943
|
+
assert(logger$4v, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
|
|
13944
|
+
assert(logger$4v, start === 0, `invalid box child range start: ${start}`);
|
|
13945
13945
|
const box = child;
|
|
13946
|
-
assert(logger$
|
|
13946
|
+
assert(logger$4v, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
|
|
13947
13947
|
const range = createExpandedRange(box, 1, box, 2);
|
|
13948
13948
|
return range;
|
|
13949
13949
|
}
|
|
13950
13950
|
const length = getTextBlockContentChildTextLength(child);
|
|
13951
|
-
assert(logger$
|
|
13951
|
+
assert(logger$4v, end <= length, `invalid child end: ${end}, ${length}`);
|
|
13952
13952
|
const textNode = child.firstChild;
|
|
13953
|
-
assert(logger$
|
|
13954
|
-
assert(logger$
|
|
13953
|
+
assert(logger$4v, textNode instanceof Text, "invalid block text child");
|
|
13954
|
+
assert(logger$4v, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
|
|
13955
13955
|
return createExpandedRange(textNode, start, textNode, end);
|
|
13956
13956
|
}
|
|
13957
|
-
const logger$
|
|
13957
|
+
const logger$4u = getLogger("caret-rect");
|
|
13958
13958
|
function getChildClientRects(block, child) {
|
|
13959
13959
|
if (isBox(child)) {
|
|
13960
13960
|
const box = child;
|
|
@@ -13963,7 +13963,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13963
13963
|
const blockContent = getBlockContent(block);
|
|
13964
13964
|
const lineHeight = Number.parseFloat(window.getComputedStyle(blockContent).lineHeight) || boxContent.getBoundingClientRect().height;
|
|
13965
13965
|
const rects = Array.from(boxContent.getClientRects());
|
|
13966
|
-
assert(logger$
|
|
13966
|
+
assert(logger$4u, rects.length > 0, "no box client rects");
|
|
13967
13967
|
const blockRect = blockContent.getBoundingClientRect();
|
|
13968
13968
|
const firstRect = rects[0];
|
|
13969
13969
|
const lastRect = new DOMRect(blockRect.left, firstRect.bottom, 1, lineHeight);
|
|
@@ -13983,22 +13983,22 @@ var __publicField = (obj, key, value) => {
|
|
|
13983
13983
|
const rect2 = getLastClientRect(ranges[0].child);
|
|
13984
13984
|
return new DOMRect(rect2.right, rect2.top, 1, rect2.height);
|
|
13985
13985
|
}
|
|
13986
|
-
assert(logger$
|
|
13986
|
+
assert(logger$4u, ranges[1], "invalid ranges");
|
|
13987
13987
|
const rect = getFirstClientRect(ranges[1].child);
|
|
13988
13988
|
return new DOMRect(rect.left, rect.top, 1, rect.height);
|
|
13989
13989
|
}
|
|
13990
13990
|
let rangeInfo = ranges[0];
|
|
13991
|
-
assert(logger$
|
|
13991
|
+
assert(logger$4u, ranges.length >= 1, "failed to get block range");
|
|
13992
13992
|
if (ranges.length === 1) {
|
|
13993
13993
|
rangeInfo = ranges[0];
|
|
13994
13994
|
} else {
|
|
13995
|
-
assert(logger$
|
|
13995
|
+
assert(logger$4u, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
|
|
13996
13996
|
if (isTextBlockContentInsertionChild(ranges[ranges.length - 1].child)) {
|
|
13997
13997
|
rangeInfo = ranges[ranges.length - 1];
|
|
13998
13998
|
const child = rangeInfo.child;
|
|
13999
13999
|
const content = getInsertionContent(child);
|
|
14000
14000
|
const rects2 = content.getClientRects();
|
|
14001
|
-
assert(logger$
|
|
14001
|
+
assert(logger$4u, rects2.length >= 1, "no client rects for box content");
|
|
14002
14002
|
const rect = rects2[rects2.length - 1];
|
|
14003
14003
|
return new DOMRect(rect.right, rect.y, 1, rect.height);
|
|
14004
14004
|
}
|
|
@@ -14015,9 +14015,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14015
14015
|
}
|
|
14016
14016
|
}
|
|
14017
14017
|
if (rangeInfo.container instanceof HTMLBRElement) {
|
|
14018
|
-
assert(logger$
|
|
14018
|
+
assert(logger$4u, pos.offset === 0, "invalid offset for empty block text");
|
|
14019
14019
|
const parent = rangeInfo.container.parentElement;
|
|
14020
|
-
assert(logger$
|
|
14020
|
+
assert(logger$4u, parent, "invalid br parent");
|
|
14021
14021
|
const rect = parent.getBoundingClientRect();
|
|
14022
14022
|
const ret = new DOMRect(rect.left, rect.top, 1, rect.height);
|
|
14023
14023
|
return ret;
|
|
@@ -14025,11 +14025,11 @@ var __publicField = (obj, key, value) => {
|
|
|
14025
14025
|
const range = createRange(rangeInfo.container, rangeInfo.offset);
|
|
14026
14026
|
const rects = Array.from(range.getClientRects());
|
|
14027
14027
|
if (rects.length === 0) {
|
|
14028
|
-
assert(logger$
|
|
14029
|
-
assert(logger$
|
|
14028
|
+
assert(logger$4u, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
|
|
14029
|
+
assert(logger$4u, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
|
|
14030
14030
|
const child = rangeInfo.child;
|
|
14031
14031
|
const rects2 = getChildClientRects(block, child);
|
|
14032
|
-
assert(logger$
|
|
14032
|
+
assert(logger$4u, rects2.length >= 1, "no client rects for box content");
|
|
14033
14033
|
if (rangeInfo.offset === 1) {
|
|
14034
14034
|
const rect2 = rects2[0];
|
|
14035
14035
|
return new DOMRect(rect2.x, rect2.y, 1, rect2.height);
|
|
@@ -14075,7 +14075,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14075
14075
|
});
|
|
14076
14076
|
}
|
|
14077
14077
|
}
|
|
14078
|
-
assert(logger$
|
|
14078
|
+
assert(logger$4u, rects.length > 0, "no client rects for range");
|
|
14079
14079
|
if (pos.type === "home") {
|
|
14080
14080
|
return rects[rects.length - 1];
|
|
14081
14081
|
}
|
|
@@ -14155,13 +14155,13 @@ var __publicField = (obj, key, value) => {
|
|
|
14155
14155
|
};
|
|
14156
14156
|
}
|
|
14157
14157
|
}
|
|
14158
|
-
const logger$
|
|
14158
|
+
const logger$4t = getLogger("selection-range");
|
|
14159
14159
|
function createEditorSelectionRange(editor, options) {
|
|
14160
14160
|
const { anchor: anchor2, focus } = options;
|
|
14161
14161
|
if (anchor2 instanceof EditorSimpleBlockPosition && focus instanceof EditorSimpleBlockPosition) {
|
|
14162
14162
|
return new EditorSimpleSelectionRange(editor, { anchor: anchor2, focus });
|
|
14163
14163
|
}
|
|
14164
|
-
assert(logger$
|
|
14164
|
+
assert(logger$4t, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
|
|
14165
14165
|
return new EditorComplexSelectionRange(editor, { anchor: anchor2, focus });
|
|
14166
14166
|
}
|
|
14167
14167
|
function createBlockSimpleRange(editor, block, anchor2, focus) {
|
|
@@ -14183,7 +14183,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14183
14183
|
const focus = createSimpleBlockPosition(range.focus.blockId, range.focus.offset, "normal");
|
|
14184
14184
|
return createEditorSelectionRange(editor, { anchor: anchor2, focus });
|
|
14185
14185
|
}
|
|
14186
|
-
const logger$
|
|
14186
|
+
const logger$4s = getLogger("range-from-point");
|
|
14187
14187
|
function getBlockRangeFromPoint(editor, pointX, pointY, dragging) {
|
|
14188
14188
|
const yOffsets = [0, -12, 12];
|
|
14189
14189
|
let x = pointX;
|
|
@@ -14215,7 +14215,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14215
14215
|
const rect = elem.getBoundingClientRect();
|
|
14216
14216
|
if (rect.width && rect.top && i === 0) {
|
|
14217
14217
|
if (rect.left + rect.width < x || rect.top + rect.height < y) {
|
|
14218
|
-
logger$
|
|
14218
|
+
logger$4s.debug("click on scrollbar, out of element rect");
|
|
14219
14219
|
return null;
|
|
14220
14220
|
}
|
|
14221
14221
|
}
|
|
@@ -14253,7 +14253,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14253
14253
|
let block = getLastChildBlock(container);
|
|
14254
14254
|
if (!isVisibleBlock(block)) {
|
|
14255
14255
|
const preBlock = getPrevVisibleBlock(block);
|
|
14256
|
-
assert(logger$
|
|
14256
|
+
assert(logger$4s, preBlock, "container must have visible block");
|
|
14257
14257
|
block = preBlock;
|
|
14258
14258
|
}
|
|
14259
14259
|
const range = getBlockClass(editor, block).getRangeFromPoint(editor, block, x, block.getBoundingClientRect().bottom - 4);
|
|
@@ -14272,7 +14272,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14272
14272
|
if (range instanceof EditorSimpleSelectionRange) {
|
|
14273
14273
|
return range;
|
|
14274
14274
|
}
|
|
14275
|
-
assert(logger$
|
|
14275
|
+
assert(logger$4s, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
|
|
14276
14276
|
const complexRange = range;
|
|
14277
14277
|
const container2 = editor.getContainerById(complexRange.start.childContainerId);
|
|
14278
14278
|
return getRangeInContainer(editor, container2, x, y);
|
|
@@ -14295,7 +14295,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14295
14295
|
});
|
|
14296
14296
|
return getRangeInContainer(editor, container, x, y);
|
|
14297
14297
|
}
|
|
14298
|
-
const logger$
|
|
14298
|
+
const logger$4r = getLogger("adjust-selection-pos");
|
|
14299
14299
|
function getParentContainers(block) {
|
|
14300
14300
|
const containers = [];
|
|
14301
14301
|
while (block) {
|
|
@@ -14305,10 +14305,10 @@ var __publicField = (obj, key, value) => {
|
|
|
14305
14305
|
return containers;
|
|
14306
14306
|
}
|
|
14307
14307
|
const newBlock = getParentBlock(container);
|
|
14308
|
-
assert(logger$
|
|
14308
|
+
assert(logger$4r, newBlock, "child container has not parent container");
|
|
14309
14309
|
block = newBlock;
|
|
14310
14310
|
}
|
|
14311
|
-
assert(logger$
|
|
14311
|
+
assert(logger$4r, false, "should not come here: getParentContainers");
|
|
14312
14312
|
}
|
|
14313
14313
|
function getParentBlockInContainer(container, block) {
|
|
14314
14314
|
while (block) {
|
|
@@ -14317,16 +14317,16 @@ var __publicField = (obj, key, value) => {
|
|
|
14317
14317
|
return block;
|
|
14318
14318
|
}
|
|
14319
14319
|
const newBlock = getParentBlock(parent);
|
|
14320
|
-
assert(logger$
|
|
14320
|
+
assert(logger$4r, newBlock, "could not find parent block for a child container");
|
|
14321
14321
|
block = newBlock;
|
|
14322
14322
|
}
|
|
14323
|
-
assert(logger$
|
|
14323
|
+
assert(logger$4r, false, "no parent block in specified container");
|
|
14324
14324
|
}
|
|
14325
14325
|
function getClosestParentBlock(block1, block2) {
|
|
14326
14326
|
const containers1 = getParentContainers(block1);
|
|
14327
14327
|
const containers2 = getParentContainers(block2);
|
|
14328
|
-
assert(logger$
|
|
14329
|
-
assert(logger$
|
|
14328
|
+
assert(logger$4r, containers1.length > 0 && containers2.length > 0, "block has not parent container");
|
|
14329
|
+
assert(logger$4r, containers1[0] === containers2[0], "root container does not equal");
|
|
14330
14330
|
let parentContainer = containers1[0];
|
|
14331
14331
|
for (let i = 1; i < containers1.length || containers2.length; i++) {
|
|
14332
14332
|
if (containers1[i] === containers2[i]) {
|
|
@@ -14345,23 +14345,23 @@ var __publicField = (obj, key, value) => {
|
|
|
14345
14345
|
}
|
|
14346
14346
|
function getParentContainerInComplexBlock(parentComplexBlock, element) {
|
|
14347
14347
|
let block = getParentBlock(element);
|
|
14348
|
-
assert(logger$
|
|
14348
|
+
assert(logger$4r, block, "element is not in a block");
|
|
14349
14349
|
while (block) {
|
|
14350
14350
|
const container = getParentContainer(block);
|
|
14351
|
-
assert(logger$
|
|
14351
|
+
assert(logger$4r, isChildContainer(container), "not a child container");
|
|
14352
14352
|
const parentBlock = getParentBlock(container);
|
|
14353
|
-
assert(logger$
|
|
14353
|
+
assert(logger$4r, parentBlock, "child container has not parent block");
|
|
14354
14354
|
if (parentBlock === parentComplexBlock) {
|
|
14355
14355
|
return container;
|
|
14356
14356
|
}
|
|
14357
14357
|
block = parentBlock;
|
|
14358
14358
|
}
|
|
14359
|
-
assert(logger$
|
|
14359
|
+
assert(logger$4r, false, "failed to find parent container in complex block");
|
|
14360
14360
|
}
|
|
14361
14361
|
function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
|
|
14362
14362
|
const blockId = getBlockId(complexBlock);
|
|
14363
|
-
assert(logger$
|
|
14364
|
-
assert(logger$
|
|
14363
|
+
assert(logger$4r, blockId === anchor2.blockId, "invalid start pos");
|
|
14364
|
+
assert(logger$4r, blockId === focus.blockId, "invalid end pos");
|
|
14365
14365
|
const blockClass = getComplexBlockClass(editor, complexBlock);
|
|
14366
14366
|
if (blockClass.adjustSelectionPos) {
|
|
14367
14367
|
return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
|
|
@@ -14395,8 +14395,8 @@ var __publicField = (obj, key, value) => {
|
|
|
14395
14395
|
if (focus instanceof EditorComplexBlockPosition) {
|
|
14396
14396
|
focus = createSimpleBlockPosition(focusBlock, getBlockTextLength$6(editor, focusBlock), "end");
|
|
14397
14397
|
}
|
|
14398
|
-
assert(logger$
|
|
14399
|
-
assert(logger$
|
|
14398
|
+
assert(logger$4r, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
|
|
14399
|
+
assert(logger$4r, focus instanceof EditorSimpleBlockPosition, "not valid position type");
|
|
14400
14400
|
return {
|
|
14401
14401
|
anchor: anchor2,
|
|
14402
14402
|
focus
|
|
@@ -14450,7 +14450,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14450
14450
|
focus
|
|
14451
14451
|
};
|
|
14452
14452
|
}
|
|
14453
|
-
const logger$
|
|
14453
|
+
const logger$4q = getLogger("core");
|
|
14454
14454
|
function createBlockAnchor(editor, block, id, refClientRect) {
|
|
14455
14455
|
const tools = getBlockTools(block);
|
|
14456
14456
|
let elem = tools.querySelector(`.block-anchor[data-id=${id}]`);
|
|
@@ -14468,7 +14468,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14468
14468
|
return elem;
|
|
14469
14469
|
}
|
|
14470
14470
|
function createBlockCaretAnchor(editor, block, offset, id) {
|
|
14471
|
-
assert(logger$
|
|
14471
|
+
assert(logger$4q, isTextKindBlock(editor, block), "not a text kind block");
|
|
14472
14472
|
const caretRect = getTextCaretRect(block, createSimpleBlockPosition(block, offset, "normal"));
|
|
14473
14473
|
const blockRect = block.getBoundingClientRect();
|
|
14474
14474
|
const tools = getBlockTools(block);
|
|
@@ -14827,19 +14827,19 @@ var __publicField = (obj, key, value) => {
|
|
|
14827
14827
|
return result + (index2 ? "-" : "") + word.toLowerCase();
|
|
14828
14828
|
});
|
|
14829
14829
|
const kebabCase$1 = kebabCase;
|
|
14830
|
-
const logger$
|
|
14830
|
+
const logger$4p = getLogger("box");
|
|
14831
14831
|
function isBoxOp(op) {
|
|
14832
14832
|
if (!op.attributes)
|
|
14833
14833
|
return false;
|
|
14834
14834
|
if (!op.attributes.box)
|
|
14835
14835
|
return false;
|
|
14836
|
-
assert(logger$
|
|
14837
|
-
assert(logger$
|
|
14836
|
+
assert(logger$4p, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
|
|
14837
|
+
assert(logger$4p, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
|
|
14838
14838
|
return true;
|
|
14839
14839
|
}
|
|
14840
|
-
const logger$
|
|
14840
|
+
const logger$4o = getLogger("text-op");
|
|
14841
14841
|
function getOpLength(op) {
|
|
14842
|
-
assert(logger$
|
|
14842
|
+
assert(logger$4o, typeof op.insert === "string", "invalid op, no insert");
|
|
14843
14843
|
return op.insert.length;
|
|
14844
14844
|
}
|
|
14845
14845
|
function getOpAt(text2, offset) {
|
|
@@ -14847,7 +14847,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14847
14847
|
let pos = 0;
|
|
14848
14848
|
for (let i = 0; i < ops.length; i++) {
|
|
14849
14849
|
const op = ops[i];
|
|
14850
|
-
assert(logger$
|
|
14850
|
+
assert(logger$4o, typeof op.insert === "string", "invalid text op, no insert");
|
|
14851
14851
|
const end = pos + getOpLength(op);
|
|
14852
14852
|
if (end > offset) {
|
|
14853
14853
|
return [op];
|
|
@@ -14863,22 +14863,22 @@ var __publicField = (obj, key, value) => {
|
|
|
14863
14863
|
}
|
|
14864
14864
|
return [];
|
|
14865
14865
|
}
|
|
14866
|
-
const logger$
|
|
14866
|
+
const logger$4n = getLogger("rich-text-length");
|
|
14867
14867
|
function getTextOpLength(op) {
|
|
14868
|
-
assert(logger$
|
|
14868
|
+
assert(logger$4n, typeof op.insert === "string", "op.insert is not string");
|
|
14869
14869
|
return op.insert.length;
|
|
14870
14870
|
}
|
|
14871
14871
|
function getTextLength(ops) {
|
|
14872
14872
|
let count = 0;
|
|
14873
14873
|
ops.forEach((op) => {
|
|
14874
14874
|
if (op.insert) {
|
|
14875
|
-
assert(logger$
|
|
14875
|
+
assert(logger$4n, typeof op.insert === "string", "op.insert is not string");
|
|
14876
14876
|
count += getTextOpLength(op);
|
|
14877
14877
|
}
|
|
14878
14878
|
});
|
|
14879
14879
|
return count;
|
|
14880
14880
|
}
|
|
14881
|
-
const logger$
|
|
14881
|
+
const logger$4m = getLogger("split-text");
|
|
14882
14882
|
function splitText(ops, offset, splitResult) {
|
|
14883
14883
|
ops = cloneDeep__default.default(ops);
|
|
14884
14884
|
if (offset === 0) {
|
|
@@ -14896,8 +14896,8 @@ var __publicField = (obj, key, value) => {
|
|
|
14896
14896
|
let counted = 0;
|
|
14897
14897
|
for (let i = 0; i < ops.length; i++) {
|
|
14898
14898
|
const op = ops[i];
|
|
14899
|
-
assert(logger$
|
|
14900
|
-
assert(logger$
|
|
14899
|
+
assert(logger$4m, typeof op === "object", `invalid op type, ${typeof op}`);
|
|
14900
|
+
assert(logger$4m, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
|
|
14901
14901
|
const subLen = getTextOpLength(op);
|
|
14902
14902
|
if (counted + subLen < offset) {
|
|
14903
14903
|
counted += subLen;
|
|
@@ -14907,18 +14907,18 @@ var __publicField = (obj, key, value) => {
|
|
|
14907
14907
|
right: ops.slice(i + 1)
|
|
14908
14908
|
};
|
|
14909
14909
|
} else {
|
|
14910
|
-
assert(logger$
|
|
14910
|
+
assert(logger$4m, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
|
|
14911
14911
|
const splitIndex = offset - counted;
|
|
14912
14912
|
const copied = cloneDeep__default.default(op);
|
|
14913
|
-
assert(logger$
|
|
14914
|
-
assert(logger$
|
|
14913
|
+
assert(logger$4m, copied.insert, "no copied.insert");
|
|
14914
|
+
assert(logger$4m, typeof copied.insert === "string", "invalid copied.insert type");
|
|
14915
14915
|
copied.insert = copied.insert.substr(0, splitIndex);
|
|
14916
14916
|
op.insert = op.insert.substr(splitIndex);
|
|
14917
14917
|
if (copied.insert === "") {
|
|
14918
|
-
assert(logger$
|
|
14918
|
+
assert(logger$4m, false, "invalid copied.insert, is empty string");
|
|
14919
14919
|
}
|
|
14920
14920
|
if (op.insert === "") {
|
|
14921
|
-
assert(logger$
|
|
14921
|
+
assert(logger$4m, false, "invalid op.insert, is empty string");
|
|
14922
14922
|
}
|
|
14923
14923
|
const right = [
|
|
14924
14924
|
op,
|
|
@@ -14937,9 +14937,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14937
14937
|
throw new Error(`invalid split offset: ${offset}, ${JSON.stringify(ops)}`);
|
|
14938
14938
|
}
|
|
14939
14939
|
function splitToThree(text2, offset, length) {
|
|
14940
|
-
assert(logger$
|
|
14941
|
-
assert(logger$
|
|
14942
|
-
assert(logger$
|
|
14940
|
+
assert(logger$4m, offset >= 0, "invalid offset, < 0");
|
|
14941
|
+
assert(logger$4m, length > 0, "invalid length, <= 0");
|
|
14942
|
+
assert(logger$4m, offset + length <= getTextLength(text2), "invalid offset + length < text length");
|
|
14943
14943
|
const { left: temp, right } = splitText(text2, offset + length);
|
|
14944
14944
|
const { left, right: middle } = splitText(temp, offset);
|
|
14945
14945
|
return { left, middle, right };
|
|
@@ -15162,9 +15162,9 @@ var __publicField = (obj, key, value) => {
|
|
|
15162
15162
|
}
|
|
15163
15163
|
return [color, backgroundColor];
|
|
15164
15164
|
}
|
|
15165
|
-
const logger$
|
|
15165
|
+
const logger$4l = getLogger("text-block-content");
|
|
15166
15166
|
function updateBlockContentCore(editor, blockPath, content, blockText, insertions) {
|
|
15167
|
-
assert(logger$
|
|
15167
|
+
assert(logger$4l, blockText, "no text for block");
|
|
15168
15168
|
if (blockText.length === 0 && (!insertions || insertions.size === 0)) {
|
|
15169
15169
|
content.innerHTML = "<span><br></span>";
|
|
15170
15170
|
return;
|
|
@@ -15196,9 +15196,9 @@ var __publicField = (obj, key, value) => {
|
|
|
15196
15196
|
for (let i2 = 0; i2 < text2.length; i2++) {
|
|
15197
15197
|
const op = text2[i2];
|
|
15198
15198
|
if (isBoxOp(op)) {
|
|
15199
|
-
assert(logger$
|
|
15199
|
+
assert(logger$4l, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
|
|
15200
15200
|
const span2 = editor.editorBoxes.createBox(content, op.attributes);
|
|
15201
|
-
assert(logger$
|
|
15201
|
+
assert(logger$4l, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
|
|
15202
15202
|
const ret = editor.editorBlockRenders.renderBox(blockPath, op.attributes);
|
|
15203
15203
|
if (ret.classes) {
|
|
15204
15204
|
addClass(span2, ...ret.classes);
|
|
@@ -15216,7 +15216,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15216
15216
|
fragment.appendChild(span2);
|
|
15217
15217
|
continue;
|
|
15218
15218
|
}
|
|
15219
|
-
assert(logger$
|
|
15219
|
+
assert(logger$4l, op.insert, `no insert in op: ${JSON.stringify(op)}`);
|
|
15220
15220
|
const span = createElement("span", ["text"], fragment, op.insert);
|
|
15221
15221
|
if (op.attributes) {
|
|
15222
15222
|
const ret = editor.editorBlockRenders.renderText(blockPath, op.attributes);
|
|
@@ -15247,7 +15247,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15247
15247
|
const compositionText = editor.compositingText;
|
|
15248
15248
|
if (compositionText) {
|
|
15249
15249
|
const pos = editor.selection.range.start;
|
|
15250
|
-
assert(logger$
|
|
15250
|
+
assert(logger$4l, pos.isSimple(), "not an simple position while compositing");
|
|
15251
15251
|
if (pos.blockId === blockId) {
|
|
15252
15252
|
const attributes = getAttributesAt(text2, 0);
|
|
15253
15253
|
insertions.set(pos.offset, [{
|
|
@@ -15263,11 +15263,11 @@ var __publicField = (obj, key, value) => {
|
|
|
15263
15263
|
function clearAllTempCompositionText(editor) {
|
|
15264
15264
|
const children = editor.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');
|
|
15265
15265
|
if (children.length) {
|
|
15266
|
-
logger$
|
|
15266
|
+
logger$4l.debug(`remove ${children.length} temp composition span`);
|
|
15267
15267
|
}
|
|
15268
15268
|
Array.from(children).forEach((c) => c.remove());
|
|
15269
15269
|
}
|
|
15270
|
-
const logger$
|
|
15270
|
+
const logger$4k = getLogger("client-rects");
|
|
15271
15271
|
function getChildrenOffsets(block) {
|
|
15272
15272
|
const children = getTextBlockContentChildren(block);
|
|
15273
15273
|
let start = 0;
|
|
@@ -15285,15 +15285,15 @@ var __publicField = (obj, key, value) => {
|
|
|
15285
15285
|
return ret;
|
|
15286
15286
|
}
|
|
15287
15287
|
function getChildrenInRange(editor, block, from, to) {
|
|
15288
|
-
assert(logger$
|
|
15288
|
+
assert(logger$4k, from < to, `invalid from & to: ${from}, ${to}`);
|
|
15289
15289
|
const blockLength = getBlockTextLength$6(editor, block);
|
|
15290
|
-
assert(logger$
|
|
15290
|
+
assert(logger$4k, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
|
|
15291
15291
|
const offsets = getChildrenOffsets(block);
|
|
15292
15292
|
const startIndex = offsets.findIndex((c) => c.startBlockOffset <= from && from < c.endBlockOffset);
|
|
15293
15293
|
const endIndex = offsets.findIndex((c) => c.startBlockOffset < to && to <= c.endBlockOffset);
|
|
15294
|
-
assert(logger$
|
|
15295
|
-
assert(logger$
|
|
15296
|
-
assert(logger$
|
|
15294
|
+
assert(logger$4k, startIndex !== -1, "failed to find start child");
|
|
15295
|
+
assert(logger$4k, endIndex !== -1, "failed to find end child");
|
|
15296
|
+
assert(logger$4k, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
|
|
15297
15297
|
if (startIndex === endIndex) {
|
|
15298
15298
|
const child = offsets[startIndex];
|
|
15299
15299
|
return [{
|
|
@@ -15375,16 +15375,16 @@ var __publicField = (obj, key, value) => {
|
|
|
15375
15375
|
return rects;
|
|
15376
15376
|
}
|
|
15377
15377
|
function getRangeClientRects(editor, block, range) {
|
|
15378
|
-
assert(logger$
|
|
15378
|
+
assert(logger$4k, range instanceof EditorSimpleSelectionRange, "invalid range");
|
|
15379
15379
|
const start = range.start;
|
|
15380
15380
|
const end = range.end;
|
|
15381
|
-
assert(logger$
|
|
15382
|
-
assert(logger$
|
|
15383
|
-
assert(logger$
|
|
15384
|
-
assert(logger$
|
|
15381
|
+
assert(logger$4k, start.isSimple(), "text block only allow simple position");
|
|
15382
|
+
assert(logger$4k, end.isSimple(), "text block only allow simple position");
|
|
15383
|
+
assert(logger$4k, start.blockId === end.blockId, "only allow update one text block selection");
|
|
15384
|
+
assert(logger$4k, start.blockId === getBlockId(block), "only allow update one text block selection");
|
|
15385
15385
|
return getClientRects$2(editor, block, start, end);
|
|
15386
15386
|
}
|
|
15387
|
-
const logger$
|
|
15387
|
+
const logger$4j = getLogger("selection-background");
|
|
15388
15388
|
function getLineHeight(elem) {
|
|
15389
15389
|
const style2 = window.getComputedStyle(elem);
|
|
15390
15390
|
const lineHeightStyle = style2.getPropertyValue("line-height");
|
|
@@ -15404,9 +15404,9 @@ var __publicField = (obj, key, value) => {
|
|
|
15404
15404
|
return lineHeight;
|
|
15405
15405
|
}
|
|
15406
15406
|
function updateSelection$4(editor, block, start, end) {
|
|
15407
|
-
assert(logger$
|
|
15408
|
-
assert(logger$
|
|
15409
|
-
assert(logger$
|
|
15407
|
+
assert(logger$4j, start.isSimple(), "text block only allow simple position");
|
|
15408
|
+
assert(logger$4j, end.isSimple(), "text block only allow simple position");
|
|
15409
|
+
assert(logger$4j, start.blockId === end.blockId, "only allow update one text block selection");
|
|
15410
15410
|
const from = start.offset;
|
|
15411
15411
|
const to = end.offset;
|
|
15412
15412
|
if (from === to) {
|
|
@@ -15465,7 +15465,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15465
15465
|
}
|
|
15466
15466
|
});
|
|
15467
15467
|
}
|
|
15468
|
-
const logger$
|
|
15468
|
+
const logger$4i = getLogger("line-breaker");
|
|
15469
15469
|
function mergeTextRects(rects) {
|
|
15470
15470
|
const result = [];
|
|
15471
15471
|
let lastRect = null;
|
|
@@ -15592,7 +15592,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15592
15592
|
}
|
|
15593
15593
|
const textChild = child;
|
|
15594
15594
|
const rects = mergeTextRects(textChild.getClientRects());
|
|
15595
|
-
assert(logger$
|
|
15595
|
+
assert(logger$4i, rects.length > 0, "invalid text child dom");
|
|
15596
15596
|
if (rects.length === 1) {
|
|
15597
15597
|
const nextChild = children[i + 1];
|
|
15598
15598
|
if (!nextChild) {
|
|
@@ -15617,10 +15617,10 @@ var __publicField = (obj, key, value) => {
|
|
|
15617
15617
|
continue;
|
|
15618
15618
|
}
|
|
15619
15619
|
const textNode = textChild.firstChild;
|
|
15620
|
-
assert(logger$
|
|
15621
|
-
assert(logger$
|
|
15620
|
+
assert(logger$4i, textNode, "invalid text child, no text node");
|
|
15621
|
+
assert(logger$4i, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
|
|
15622
15622
|
const textChildLength = getTextBlockContentChildTextLength(textChild);
|
|
15623
|
-
assert(logger$
|
|
15623
|
+
assert(logger$4i, textNode.data.length === textChildLength, "text node data length not equal child text length");
|
|
15624
15624
|
const textRects = getTextRects(textNode);
|
|
15625
15625
|
for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
|
|
15626
15626
|
const rect = textRects[rIndex];
|
|
@@ -15662,7 +15662,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15662
15662
|
}
|
|
15663
15663
|
}
|
|
15664
15664
|
}
|
|
15665
|
-
assert(logger$
|
|
15665
|
+
assert(logger$4i, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
|
|
15666
15666
|
return {
|
|
15667
15667
|
lineIndex: lineBreaks.length,
|
|
15668
15668
|
lineBreaks
|
|
@@ -24435,7 +24435,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24435
24435
|
const Graphemer_1 = __importDefault(Graphemer$1);
|
|
24436
24436
|
var _default = lib$1.default = Graphemer_1.default;
|
|
24437
24437
|
const splitter = new _default();
|
|
24438
|
-
const logger$
|
|
24438
|
+
const logger$4h = getLogger("text-offset");
|
|
24439
24439
|
function getChildOffset(block, child) {
|
|
24440
24440
|
const children = getTextBlockContentChildren(block);
|
|
24441
24441
|
let start = 0;
|
|
@@ -24451,26 +24451,26 @@ var __publicField = (obj, key, value) => {
|
|
|
24451
24451
|
}
|
|
24452
24452
|
start += testLength;
|
|
24453
24453
|
}
|
|
24454
|
-
assert(logger$
|
|
24454
|
+
assert(logger$4h, false, "can not find child in children");
|
|
24455
24455
|
}
|
|
24456
24456
|
function isValidOffset(block, blockOffset) {
|
|
24457
|
-
assert(logger$
|
|
24457
|
+
assert(logger$4h, blockOffset >= 0, `invalid offset: ${blockOffset}`);
|
|
24458
24458
|
const childInfo = getTextBlockChild(block, blockOffset);
|
|
24459
24459
|
const { prev, next: next2, offset } = childInfo;
|
|
24460
24460
|
if (!prev && !next2) {
|
|
24461
|
-
assert(logger$
|
|
24461
|
+
assert(logger$4h, false, "invalid offset, no prev & next child at offset");
|
|
24462
24462
|
}
|
|
24463
24463
|
if (prev !== next2) {
|
|
24464
24464
|
return true;
|
|
24465
24465
|
}
|
|
24466
24466
|
const child = prev;
|
|
24467
|
-
assert(logger$
|
|
24467
|
+
assert(logger$4h, child, "no child");
|
|
24468
24468
|
if (isTextBlockContentBoxChild(child)) {
|
|
24469
|
-
assert(logger$
|
|
24469
|
+
assert(logger$4h, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
|
|
24470
24470
|
return true;
|
|
24471
24471
|
}
|
|
24472
24472
|
const text2 = child.textContent;
|
|
24473
|
-
assert(logger$
|
|
24473
|
+
assert(logger$4h, text2, "no content for text child");
|
|
24474
24474
|
const chars = splitter.splitGraphemes(text2);
|
|
24475
24475
|
const validOffsets = /* @__PURE__ */ new Set();
|
|
24476
24476
|
let start = 0;
|
|
@@ -24500,7 +24500,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24500
24500
|
}
|
|
24501
24501
|
function getNextValidOffset(block, blockOffset) {
|
|
24502
24502
|
const length = getTextBlockLength(block);
|
|
24503
|
-
assert(logger$
|
|
24503
|
+
assert(logger$4h, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
|
|
24504
24504
|
if (blockOffset === length) {
|
|
24505
24505
|
return length;
|
|
24506
24506
|
}
|
|
@@ -24514,7 +24514,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24514
24514
|
}
|
|
24515
24515
|
return ret;
|
|
24516
24516
|
}
|
|
24517
|
-
const logger$
|
|
24517
|
+
const logger$4g = getLogger("line-offset");
|
|
24518
24518
|
function getLineOffsets(block) {
|
|
24519
24519
|
const lineBreaks = getLineBreaks(block);
|
|
24520
24520
|
const ret = [];
|
|
@@ -24535,7 +24535,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24535
24535
|
}
|
|
24536
24536
|
function getLineOffset(block, lineIndex) {
|
|
24537
24537
|
const lines = getLineOffsets(block);
|
|
24538
|
-
assert(logger$
|
|
24538
|
+
assert(logger$4g, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
|
|
24539
24539
|
return lines[lineIndex];
|
|
24540
24540
|
}
|
|
24541
24541
|
function getLineOffsetByPos(block, pos) {
|
|
@@ -24592,7 +24592,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24592
24592
|
function getLineCount(block) {
|
|
24593
24593
|
return getLineOffsets(block).length;
|
|
24594
24594
|
}
|
|
24595
|
-
const logger$
|
|
24595
|
+
const logger$4f = getLogger("find-text-position");
|
|
24596
24596
|
function isWrappedLine(block, lineIndex) {
|
|
24597
24597
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24598
24598
|
const blockId = getBlockId(block);
|
|
@@ -24603,13 +24603,13 @@ var __publicField = (obj, key, value) => {
|
|
|
24603
24603
|
return false;
|
|
24604
24604
|
}
|
|
24605
24605
|
const childInfo = getTextBlockChild(block, start);
|
|
24606
|
-
assert(logger$
|
|
24607
|
-
assert(logger$
|
|
24606
|
+
assert(logger$4f, childInfo.next, "no next child at offset");
|
|
24607
|
+
assert(logger$4f, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
|
|
24608
24608
|
return true;
|
|
24609
24609
|
}
|
|
24610
24610
|
function getWrappedLineOffsets(block, lineIndex) {
|
|
24611
24611
|
const blockId = getBlockId(block);
|
|
24612
|
-
assert(logger$
|
|
24612
|
+
assert(logger$4f, isWrappedLine(block, lineIndex), "line is not wrapped");
|
|
24613
24613
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24614
24614
|
const homePos = createSimpleBlockPosition(blockId, start, "home");
|
|
24615
24615
|
for (let offset = start + 1; offset <= end; offset += 1) {
|
|
@@ -24624,11 +24624,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24624
24624
|
return offset - 1;
|
|
24625
24625
|
}
|
|
24626
24626
|
}
|
|
24627
|
-
assert(logger$
|
|
24627
|
+
assert(logger$4f, false, "failed to find wrapped offset");
|
|
24628
24628
|
return 0;
|
|
24629
24629
|
}
|
|
24630
24630
|
function findTextPositionInLine(editor, block, lineIndex, sourceBlock, pos, findDirection, suggestedX) {
|
|
24631
|
-
assert(logger$
|
|
24631
|
+
assert(logger$4f, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
|
|
24632
24632
|
const { start, end } = getLineOffset(block, lineIndex);
|
|
24633
24633
|
let from = start;
|
|
24634
24634
|
const blockId = getBlockId(block);
|
|
@@ -24670,11 +24670,11 @@ var __publicField = (obj, key, value) => {
|
|
|
24670
24670
|
return retPos;
|
|
24671
24671
|
}
|
|
24672
24672
|
function findPrevTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
|
|
24673
|
-
assert(logger$
|
|
24673
|
+
assert(logger$4f, isTextKindBlock(editor, block), "not a text block");
|
|
24674
24674
|
return findTextPositionInLine(editor, block, getLineCount(block) - 1, sourceBlock, pos, "up", suggestedX);
|
|
24675
24675
|
}
|
|
24676
24676
|
function findNextTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
|
|
24677
|
-
assert(logger$
|
|
24677
|
+
assert(logger$4f, isTextKindBlock(editor, block), "not a text block");
|
|
24678
24678
|
return findTextPositionInLine(editor, block, 0, sourceBlock, pos, "down", suggestedX);
|
|
24679
24679
|
}
|
|
24680
24680
|
function moveDown(editor, block, position, suggestedX) {
|
|
@@ -24782,7 +24782,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24782
24782
|
}
|
|
24783
24783
|
return pos;
|
|
24784
24784
|
}
|
|
24785
|
-
const logger$
|
|
24785
|
+
const logger$4e = getLogger("move-caret");
|
|
24786
24786
|
function moveTextCaret(editor, block, position, direction) {
|
|
24787
24787
|
if (direction === "ArrowLeft") {
|
|
24788
24788
|
const ret = moveLeft(block, position);
|
|
@@ -24812,9 +24812,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24812
24812
|
}
|
|
24813
24813
|
return createSimpleBlockPosition(getBlockId(block), ret.offset, ret.type);
|
|
24814
24814
|
}
|
|
24815
|
-
assert(logger$
|
|
24815
|
+
assert(logger$4e, false, `invalid navigation direction: ${direction}`);
|
|
24816
24816
|
}
|
|
24817
|
-
const logger$
|
|
24817
|
+
const logger$4d = getLogger("text-range");
|
|
24818
24818
|
function getBlockRects(block) {
|
|
24819
24819
|
const ret = [];
|
|
24820
24820
|
const children = getTextBlockContentChildren(block);
|
|
@@ -24872,9 +24872,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24872
24872
|
return null;
|
|
24873
24873
|
}
|
|
24874
24874
|
const children = getTextBlockContentChildren(block);
|
|
24875
|
-
assert(logger$
|
|
24875
|
+
assert(logger$4d, children.indexOf(child) !== -1, "failed to find child in children");
|
|
24876
24876
|
const offsetInfo = getChildOffset(block, child);
|
|
24877
|
-
assert(logger$
|
|
24877
|
+
assert(logger$4d, offsetInfo, "failed to get child offset");
|
|
24878
24878
|
const { start } = offsetInfo;
|
|
24879
24879
|
let offset;
|
|
24880
24880
|
let length;
|
|
@@ -24890,7 +24890,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24890
24890
|
}
|
|
24891
24891
|
length = 0;
|
|
24892
24892
|
} else {
|
|
24893
|
-
assert(logger$
|
|
24893
|
+
assert(logger$4d, child.firstChild instanceof Text, "child is not text");
|
|
24894
24894
|
offset = start + textNodeOffsetFromPoint(child.firstChild, x, y);
|
|
24895
24895
|
length = 0;
|
|
24896
24896
|
}
|
|
@@ -24936,9 +24936,9 @@ var __publicField = (obj, key, value) => {
|
|
|
24936
24936
|
this.limitBytes = details.limitBytes;
|
|
24937
24937
|
}
|
|
24938
24938
|
}
|
|
24939
|
-
const logger$
|
|
24939
|
+
const logger$4c = getLogger("create-text-op");
|
|
24940
24940
|
function createTextOp(text2, attributes) {
|
|
24941
|
-
assert(logger$
|
|
24941
|
+
assert(logger$4c, text2, "text is empty");
|
|
24942
24942
|
const ret = {
|
|
24943
24943
|
insert: text2
|
|
24944
24944
|
};
|
|
@@ -24961,7 +24961,7 @@ var __publicField = (obj, key, value) => {
|
|
|
24961
24961
|
}
|
|
24962
24962
|
return result;
|
|
24963
24963
|
}
|
|
24964
|
-
const logger$
|
|
24964
|
+
const logger$4b = getLogger("merge-ops");
|
|
24965
24965
|
function mergeOps(text2) {
|
|
24966
24966
|
if (text2.length <= 1) {
|
|
24967
24967
|
return text2;
|
|
@@ -24983,10 +24983,10 @@ var __publicField = (obj, key, value) => {
|
|
|
24983
24983
|
return false;
|
|
24984
24984
|
}
|
|
24985
24985
|
if (op1.attributes === void 0) {
|
|
24986
|
-
assert(logger$
|
|
24986
|
+
assert(logger$4b, op2.attributes === void 0, "op2.attributes is not undefined");
|
|
24987
24987
|
return true;
|
|
24988
24988
|
}
|
|
24989
|
-
assert(logger$
|
|
24989
|
+
assert(logger$4b, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
|
|
24990
24990
|
return isEqual__default.default(op1.attributes, op2.attributes);
|
|
24991
24991
|
};
|
|
24992
24992
|
const newOps = [];
|
|
@@ -24995,8 +24995,8 @@ var __publicField = (obj, key, value) => {
|
|
|
24995
24995
|
for (let i = 1; i < text2.length; i += 1) {
|
|
24996
24996
|
const op = text2[i];
|
|
24997
24997
|
if (isSameTypeOp(before, op)) {
|
|
24998
|
-
assert(logger$
|
|
24999
|
-
assert(logger$
|
|
24998
|
+
assert(logger$4b, typeof before.insert === "string", "before.insert is not string");
|
|
24999
|
+
assert(logger$4b, typeof op.insert === "string", "op.insert is not string");
|
|
25000
25000
|
before.insert += op.insert;
|
|
25001
25001
|
} else {
|
|
25002
25002
|
newOps.push(op);
|
|
@@ -25024,15 +25024,15 @@ var __publicField = (obj, key, value) => {
|
|
|
25024
25024
|
}
|
|
25025
25025
|
return text2.slice(0, i + 1);
|
|
25026
25026
|
}
|
|
25027
|
-
const logger$
|
|
25027
|
+
const logger$4a = getLogger("delete-text");
|
|
25028
25028
|
function deleteText(richText2, offset, count) {
|
|
25029
25029
|
const { left, right } = splitToThree(richText2, offset, count);
|
|
25030
25030
|
const result = [...left, ...right];
|
|
25031
25031
|
return mergeOps(result);
|
|
25032
25032
|
}
|
|
25033
25033
|
function createDeleteOps(offset, count) {
|
|
25034
|
-
assert(logger$
|
|
25035
|
-
assert(logger$
|
|
25034
|
+
assert(logger$4a, offset >= 0, `invalid offset: ${offset}`);
|
|
25035
|
+
assert(logger$4a, count >= 1, `invalid delete count: ${count}`);
|
|
25036
25036
|
const ops = [];
|
|
25037
25037
|
if (offset !== 0) {
|
|
25038
25038
|
ops.push({
|
|
@@ -25044,7 +25044,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25044
25044
|
});
|
|
25045
25045
|
return ops;
|
|
25046
25046
|
}
|
|
25047
|
-
const logger$
|
|
25047
|
+
const logger$49 = getLogger("delta");
|
|
25048
25048
|
function diffRichText(oldText, newText) {
|
|
25049
25049
|
const delta1D = new Delta__default.default(oldText);
|
|
25050
25050
|
const delta2D = new Delta__default.default(newText);
|
|
@@ -25054,7 +25054,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25054
25054
|
return new Delta__default.default(ops).transformPosition(cursor, !isLocalOp);
|
|
25055
25055
|
}
|
|
25056
25056
|
function isValidDocText(text2) {
|
|
25057
|
-
assert(logger$
|
|
25057
|
+
assert(logger$49, text2, "ops is null or undefined");
|
|
25058
25058
|
for (let i = 0; i < text2.length; i++) {
|
|
25059
25059
|
const op = text2[i];
|
|
25060
25060
|
if (op.insert === null || op.insert === void 0) {
|
|
@@ -25074,7 +25074,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25074
25074
|
}
|
|
25075
25075
|
class RichText {
|
|
25076
25076
|
static ensureValidText(text2) {
|
|
25077
|
-
assert(logger$
|
|
25077
|
+
assert(logger$49, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
|
|
25078
25078
|
}
|
|
25079
25079
|
static diff(oldText, newText) {
|
|
25080
25080
|
this.ensureValidText(oldText);
|
|
@@ -25096,9 +25096,9 @@ var __publicField = (obj, key, value) => {
|
|
|
25096
25096
|
return resultText;
|
|
25097
25097
|
}
|
|
25098
25098
|
}
|
|
25099
|
-
const logger$
|
|
25099
|
+
const logger$48 = getLogger("insert-text");
|
|
25100
25100
|
function insertText(richText2, offset, text2, attributes) {
|
|
25101
|
-
assert(logger$
|
|
25101
|
+
assert(logger$48, text2, `invalid text to insert: ${text2}`);
|
|
25102
25102
|
const { left, right } = splitText(richText2, offset);
|
|
25103
25103
|
const insertedText = typeof text2 === "string" ? [createTextOp(text2, attributes)] : text2;
|
|
25104
25104
|
const result = [...left, ...insertedText, ...right];
|
|
@@ -25111,7 +25111,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25111
25111
|
};
|
|
25112
25112
|
}
|
|
25113
25113
|
function createInsertOps(offset, text2, attributes) {
|
|
25114
|
-
assert(logger$
|
|
25114
|
+
assert(logger$48, offset >= 0, `invalid offset: ${offset}`);
|
|
25115
25115
|
if (text2.length === 0) {
|
|
25116
25116
|
return [];
|
|
25117
25117
|
}
|
|
@@ -25141,7 +25141,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25141
25141
|
function cloneText(text2) {
|
|
25142
25142
|
return cloneDeep__default.default(text2);
|
|
25143
25143
|
}
|
|
25144
|
-
const logger$
|
|
25144
|
+
const logger$47 = getLogger("update-op-attribute");
|
|
25145
25145
|
function updateOpAttributes(orgOps, key, value, newAttributes) {
|
|
25146
25146
|
const ops = cloneText(orgOps);
|
|
25147
25147
|
const index2 = ops.findIndex((op2) => {
|
|
@@ -25149,7 +25149,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25149
25149
|
return false;
|
|
25150
25150
|
return op2.attributes[key] === value;
|
|
25151
25151
|
});
|
|
25152
|
-
assert(logger$
|
|
25152
|
+
assert(logger$47, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
|
|
25153
25153
|
const op = ops[index2];
|
|
25154
25154
|
op.attributes = {
|
|
25155
25155
|
...op.attributes,
|
|
@@ -25224,11 +25224,11 @@ var __publicField = (obj, key, value) => {
|
|
|
25224
25224
|
]);
|
|
25225
25225
|
}
|
|
25226
25226
|
const FILL_CHAR = "\u200B";
|
|
25227
|
-
const logger$
|
|
25227
|
+
const logger$46 = getLogger("to-plain-text");
|
|
25228
25228
|
function toPlainText(ops, options) {
|
|
25229
25229
|
let text2 = "";
|
|
25230
25230
|
ops.forEach((op) => {
|
|
25231
|
-
assert(logger$
|
|
25231
|
+
assert(logger$46, typeof op.insert === "string", "invalid op");
|
|
25232
25232
|
if (op.attributes && op.attributes.box === true) {
|
|
25233
25233
|
if (options == null ? void 0 : options.boxReplacement) {
|
|
25234
25234
|
text2 += options.boxReplacement;
|
|
@@ -25283,7 +25283,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25283
25283
|
focus: pos
|
|
25284
25284
|
};
|
|
25285
25285
|
}
|
|
25286
|
-
const logger$
|
|
25286
|
+
const logger$45 = getLogger("repair-duplicated-block-ids");
|
|
25287
25287
|
const ROOT_CONTAINER_ID = "root";
|
|
25288
25288
|
function buildChildContainersDelta(doc2, block) {
|
|
25289
25289
|
const children = block.children;
|
|
@@ -25335,10 +25335,10 @@ var __publicField = (obj, key, value) => {
|
|
|
25335
25335
|
if (seenBlockIds.has(block.id)) {
|
|
25336
25336
|
duplicatedIds.push(block.id);
|
|
25337
25337
|
if (readonly) {
|
|
25338
|
-
logger$
|
|
25338
|
+
logger$45.warn(`duplicated block id ${block.id} at ${containerId}[${blockIndex}], readonly, skip repairing`);
|
|
25339
25339
|
} else {
|
|
25340
25340
|
const newId = genId();
|
|
25341
|
-
logger$
|
|
25341
|
+
logger$45.warn(`repair duplicated block id ${block.id} -> ${newId} at ${containerId}[${blockIndex}]`);
|
|
25342
25342
|
const childDelta = buildChildContainersDelta(doc2, block);
|
|
25343
25343
|
doc2.localUpdateBlockData(
|
|
25344
25344
|
containerId,
|
|
@@ -25362,17 +25362,17 @@ var __publicField = (obj, key, value) => {
|
|
|
25362
25362
|
};
|
|
25363
25363
|
visitContainer(ROOT_CONTAINER_ID);
|
|
25364
25364
|
if (duplicatedIds.length > 0) {
|
|
25365
|
-
logger$
|
|
25365
|
+
logger$45.error(
|
|
25366
25366
|
`found ${duplicatedIds.length} duplicated block id(s): ${duplicatedIds.join(", ")}, repaired ${repaired}`
|
|
25367
25367
|
);
|
|
25368
25368
|
}
|
|
25369
25369
|
return { repaired, duplicatedIds };
|
|
25370
25370
|
}
|
|
25371
|
-
const logger$
|
|
25371
|
+
const logger$44 = getLogger("block-to-text");
|
|
25372
25372
|
function textBlockToText$1(editor, ops, doc2) {
|
|
25373
25373
|
let text2 = "";
|
|
25374
25374
|
ops.forEach((op) => {
|
|
25375
|
-
assert(logger$
|
|
25375
|
+
assert(logger$44, typeof op.insert === "string", "invalid op");
|
|
25376
25376
|
if (op.attributes && op.attributes.box === true) {
|
|
25377
25377
|
const box = op.attributes;
|
|
25378
25378
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -25390,11 +25390,11 @@ var __publicField = (obj, key, value) => {
|
|
|
25390
25390
|
});
|
|
25391
25391
|
return text2;
|
|
25392
25392
|
}
|
|
25393
|
-
const logger$
|
|
25393
|
+
const logger$43 = getLogger("block-to-text");
|
|
25394
25394
|
function textToMarkdownText(editor, ops, doc2) {
|
|
25395
25395
|
let text2 = "";
|
|
25396
25396
|
ops.forEach((op) => {
|
|
25397
|
-
assert(logger$
|
|
25397
|
+
assert(logger$43, typeof op.insert === "string", "invalid op");
|
|
25398
25398
|
if (op.attributes && op.attributes.box === true) {
|
|
25399
25399
|
const box = op.attributes;
|
|
25400
25400
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -25517,12 +25517,12 @@ var __publicField = (obj, key, value) => {
|
|
|
25517
25517
|
return void 0;
|
|
25518
25518
|
}
|
|
25519
25519
|
}
|
|
25520
|
-
const logger$
|
|
25520
|
+
const logger$42 = getLogger("block-to-text");
|
|
25521
25521
|
function textBlockToHtml(editor, blockData, doc2) {
|
|
25522
25522
|
let html = "";
|
|
25523
25523
|
const ops = blockData.text || [];
|
|
25524
25524
|
ops.forEach((op) => {
|
|
25525
|
-
assert(logger$
|
|
25525
|
+
assert(logger$42, typeof op.insert === "string", "invalid op");
|
|
25526
25526
|
if (op.attributes && op.attributes.box === true) {
|
|
25527
25527
|
const box = op.attributes;
|
|
25528
25528
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -25598,16 +25598,16 @@ var __publicField = (obj, key, value) => {
|
|
|
25598
25598
|
}
|
|
25599
25599
|
return `<p>${html}</p>`;
|
|
25600
25600
|
}
|
|
25601
|
-
const logger$
|
|
25601
|
+
const logger$41 = getLogger("text-block");
|
|
25602
25602
|
function createBlockContent$5(editor, path, container, blockElement, blockData) {
|
|
25603
25603
|
const { text: text2 } = blockData;
|
|
25604
|
-
assert(logger$
|
|
25604
|
+
assert(logger$41, text2, "no text for text block");
|
|
25605
25605
|
const content = createBlockContentElement(blockElement, "div");
|
|
25606
25606
|
updateBlockContent$1(editor, path, blockData.id, content, text2);
|
|
25607
25607
|
return content;
|
|
25608
25608
|
}
|
|
25609
25609
|
function updateBlockText$1(editor, block, text2) {
|
|
25610
|
-
assert(logger$
|
|
25610
|
+
assert(logger$41, text2, "no text to update");
|
|
25611
25611
|
const newContent = createBlockContentElement(null, "div");
|
|
25612
25612
|
updateBlockContent$1(editor, getBlockPath(block), getBlockId(block), newContent, text2);
|
|
25613
25613
|
const oldContent = getBlockContent(block);
|
|
@@ -25617,7 +25617,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25617
25617
|
return getRangeClientRects(editor, block, range);
|
|
25618
25618
|
}
|
|
25619
25619
|
function convertTo$k(editor, blockData, doc2, type) {
|
|
25620
|
-
assert(logger$
|
|
25620
|
+
assert(logger$41, blockData.text, "no text for text block");
|
|
25621
25621
|
if (type === "text") {
|
|
25622
25622
|
return textBlockToText$1(editor, blockData.text, doc2);
|
|
25623
25623
|
}
|
|
@@ -25631,7 +25631,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25631
25631
|
blockData.id = genId();
|
|
25632
25632
|
info == null ? void 0 : info.blockIdMap.set(srcBlockData.id, blockData.id);
|
|
25633
25633
|
const { text: text2 } = blockData;
|
|
25634
|
-
assert(logger$
|
|
25634
|
+
assert(logger$41, text2, "no text for text block");
|
|
25635
25635
|
text2.forEach((op) => {
|
|
25636
25636
|
if (op.insert && op.attributes && op.attributes.box === true) {
|
|
25637
25637
|
const boxId = genId();
|
|
@@ -25664,7 +25664,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25664
25664
|
blockToDoc: blockToDoc$1
|
|
25665
25665
|
};
|
|
25666
25666
|
const updateTextBlockContent = updateBlockContent$1;
|
|
25667
|
-
const logger$
|
|
25667
|
+
const logger$40 = getLogger("action-helper");
|
|
25668
25668
|
function editorGetBlockData(editor, block) {
|
|
25669
25669
|
const container = getParentContainer(block);
|
|
25670
25670
|
const containerId = getContainerId(container);
|
|
@@ -25672,10 +25672,10 @@ var __publicField = (obj, key, value) => {
|
|
|
25672
25672
|
return editor.doc.getBlockData(containerId, blockIndex);
|
|
25673
25673
|
}
|
|
25674
25674
|
function editorGetBlockText(editor, block) {
|
|
25675
|
-
assert(logger$
|
|
25675
|
+
assert(logger$40, isTextKindBlock(editor, block), "not a text kind block");
|
|
25676
25676
|
const data2 = editorGetBlockData(editor, block);
|
|
25677
25677
|
const text2 = data2.text;
|
|
25678
|
-
assert(logger$
|
|
25678
|
+
assert(logger$40, text2, "no text in block");
|
|
25679
25679
|
return text2;
|
|
25680
25680
|
}
|
|
25681
25681
|
function editorGetBlockTextEx(editor, block, length) {
|
|
@@ -25683,7 +25683,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25683
25683
|
}
|
|
25684
25684
|
function editorGetBoxData(editor, box) {
|
|
25685
25685
|
const block = getParentBlock(box);
|
|
25686
|
-
assert(logger$
|
|
25686
|
+
assert(logger$40, block, "no parent block");
|
|
25687
25687
|
const text2 = editorGetBlockText(editor, block);
|
|
25688
25688
|
const id = getBoxId(box);
|
|
25689
25689
|
const op = text2.find((op2) => {
|
|
@@ -25693,60 +25693,60 @@ var __publicField = (obj, key, value) => {
|
|
|
25693
25693
|
}
|
|
25694
25694
|
return false;
|
|
25695
25695
|
});
|
|
25696
|
-
assert(logger$
|
|
25696
|
+
assert(logger$40, op, "failed to find box");
|
|
25697
25697
|
return op.attributes;
|
|
25698
25698
|
}
|
|
25699
|
-
const logger$
|
|
25699
|
+
const logger$3$ = getLogger("block-text");
|
|
25700
25700
|
function getTextAfterOffset(editor, block, offset) {
|
|
25701
|
-
assert(logger$
|
|
25702
|
-
assert(logger$
|
|
25703
|
-
assert(logger$
|
|
25701
|
+
assert(logger$3$, isTextKindBlock(editor, block), "not a text kind block");
|
|
25702
|
+
assert(logger$3$, isValidOffset(block, offset), "not a valid offset");
|
|
25703
|
+
assert(logger$3$, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25704
25704
|
const newOffset = getNextValidOffset(block, offset);
|
|
25705
25705
|
const length = newOffset - offset;
|
|
25706
25706
|
if (length === 0) {
|
|
25707
|
-
assert(logger$
|
|
25707
|
+
assert(logger$3$, false, `no text after offset: ${offset}`);
|
|
25708
25708
|
}
|
|
25709
25709
|
const text2 = editorGetBlockText(editor, block);
|
|
25710
25710
|
const { middle } = splitToThree(text2, offset, length);
|
|
25711
|
-
assert(logger$
|
|
25711
|
+
assert(logger$3$, middle.length === 1, "failed to split text to 3 parts");
|
|
25712
25712
|
const op = middle[0];
|
|
25713
25713
|
if (isBoxOp(op)) {
|
|
25714
25714
|
return " ";
|
|
25715
25715
|
}
|
|
25716
|
-
assert(logger$
|
|
25716
|
+
assert(logger$3$, op.insert.length === 1 || op.insert.length === 2, "invalid op");
|
|
25717
25717
|
return op.insert;
|
|
25718
25718
|
}
|
|
25719
25719
|
function getTextBeforeOffset(editor, block, offset) {
|
|
25720
|
-
assert(logger$
|
|
25721
|
-
assert(logger$
|
|
25722
|
-
assert(logger$
|
|
25720
|
+
assert(logger$3$, isTextKindBlock(editor, block), "not a text kind block");
|
|
25721
|
+
assert(logger$3$, isValidOffset(block, offset), "not a valid offset");
|
|
25722
|
+
assert(logger$3$, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25723
25723
|
const newOffset = getPrevValidOffset(block, offset);
|
|
25724
25724
|
const length = offset - newOffset;
|
|
25725
25725
|
if (length === 0) {
|
|
25726
|
-
assert(logger$
|
|
25726
|
+
assert(logger$3$, false, `no text before offset: ${offset}`);
|
|
25727
25727
|
}
|
|
25728
25728
|
const text2 = editorGetBlockText(editor, block);
|
|
25729
25729
|
const { middle } = splitToThree(text2, newOffset, length);
|
|
25730
|
-
assert(logger$
|
|
25730
|
+
assert(logger$3$, middle.length === 1, "failed to split text to 3 parts");
|
|
25731
25731
|
const op = middle[0];
|
|
25732
25732
|
if (isBoxOp(op)) {
|
|
25733
25733
|
return " ";
|
|
25734
25734
|
}
|
|
25735
|
-
assert(logger$
|
|
25735
|
+
assert(logger$3$, op.insert.length === 1 || op.insert.length === 2, "invalid op");
|
|
25736
25736
|
return op.insert;
|
|
25737
25737
|
}
|
|
25738
25738
|
function getOffsetInfoBefore(editor, block, offset) {
|
|
25739
|
-
assert(logger$
|
|
25740
|
-
assert(logger$
|
|
25741
|
-
assert(logger$
|
|
25739
|
+
assert(logger$3$, isTextKindBlock(editor, block), "not a text kind block");
|
|
25740
|
+
assert(logger$3$, isValidOffset(block, offset), "not a valid offset");
|
|
25741
|
+
assert(logger$3$, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25742
25742
|
const newOffset = getPrevValidOffset(block, offset);
|
|
25743
25743
|
const length = offset - newOffset;
|
|
25744
25744
|
if (length === 0) {
|
|
25745
|
-
assert(logger$
|
|
25745
|
+
assert(logger$3$, false, `no text before offset: ${offset}`);
|
|
25746
25746
|
}
|
|
25747
25747
|
const text2 = editorGetBlockText(editor, block);
|
|
25748
25748
|
const { middle } = splitToThree(text2, newOffset, length);
|
|
25749
|
-
assert(logger$
|
|
25749
|
+
assert(logger$3$, middle.length === 1, "failed to split text to 3 parts");
|
|
25750
25750
|
const op = middle[0];
|
|
25751
25751
|
if (isBoxOp(op)) {
|
|
25752
25752
|
return {
|
|
@@ -25772,17 +25772,17 @@ var __publicField = (obj, key, value) => {
|
|
|
25772
25772
|
};
|
|
25773
25773
|
}
|
|
25774
25774
|
function getOffsetInfoAfter(editor, block, offset) {
|
|
25775
|
-
assert(logger$
|
|
25776
|
-
assert(logger$
|
|
25777
|
-
assert(logger$
|
|
25775
|
+
assert(logger$3$, isTextKindBlock(editor, block), "not a text kind block");
|
|
25776
|
+
assert(logger$3$, isValidOffset(block, offset), "not a valid offset");
|
|
25777
|
+
assert(logger$3$, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
25778
25778
|
const newOffset = getNextValidOffset(block, offset);
|
|
25779
25779
|
const length = newOffset - offset;
|
|
25780
25780
|
if (length === 0) {
|
|
25781
|
-
assert(logger$
|
|
25781
|
+
assert(logger$3$, false, `no text after offset: ${offset}`);
|
|
25782
25782
|
}
|
|
25783
25783
|
const text2 = editorGetBlockText(editor, block);
|
|
25784
25784
|
const { middle } = splitToThree(text2, offset, length);
|
|
25785
|
-
assert(logger$
|
|
25785
|
+
assert(logger$3$, middle.length === 1, "failed to split text to 3 parts");
|
|
25786
25786
|
const op = middle[0];
|
|
25787
25787
|
if (isBoxOp(op)) {
|
|
25788
25788
|
return {
|
|
@@ -25854,7 +25854,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25854
25854
|
return null;
|
|
25855
25855
|
}
|
|
25856
25856
|
function findWordLeft(editor, block, offset) {
|
|
25857
|
-
assert(logger$
|
|
25857
|
+
assert(logger$3$, isTextKindBlock(editor, block), "invalid blok type");
|
|
25858
25858
|
if (isEmptyTextBlock(editor, block)) {
|
|
25859
25859
|
return 0;
|
|
25860
25860
|
}
|
|
@@ -25884,7 +25884,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25884
25884
|
return startInfo.offset + startInfo.length;
|
|
25885
25885
|
}
|
|
25886
25886
|
function findWordEnd(editor, block, offset) {
|
|
25887
|
-
assert(logger$
|
|
25887
|
+
assert(logger$3$, isTextKindBlock(editor, block), "invalid blok type");
|
|
25888
25888
|
if (isEmptyTextBlock(editor, block)) {
|
|
25889
25889
|
return 0;
|
|
25890
25890
|
}
|
|
@@ -25913,10 +25913,10 @@ var __publicField = (obj, key, value) => {
|
|
|
25913
25913
|
return getBlockTextLength$6(editor, block);
|
|
25914
25914
|
return startInfo.offset;
|
|
25915
25915
|
}
|
|
25916
|
-
const logger$
|
|
25916
|
+
const logger$3_ = getLogger("text-box");
|
|
25917
25917
|
function updateBoxContent$8(editor, boxElement, boxContent, boxData) {
|
|
25918
|
-
assert(logger$
|
|
25919
|
-
assert(logger$
|
|
25918
|
+
assert(logger$3_, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
|
|
25919
|
+
assert(logger$3_, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
|
|
25920
25920
|
createElement("span", [], boxContent, boxData.text);
|
|
25921
25921
|
}
|
|
25922
25922
|
function convertTo$j(editor, boxData, doc2, type) {
|
|
@@ -25950,7 +25950,7 @@ var __publicField = (obj, key, value) => {
|
|
|
25950
25950
|
updateBoxContent: updateBoxContent$7,
|
|
25951
25951
|
convertTo: convertTo$i
|
|
25952
25952
|
};
|
|
25953
|
-
const logger$
|
|
25953
|
+
const logger$3Z = getLogger("editor-boxes");
|
|
25954
25954
|
class EditorBoxes {
|
|
25955
25955
|
constructor(editor) {
|
|
25956
25956
|
__publicField(this, "boxes", /* @__PURE__ */ new Map());
|
|
@@ -25959,12 +25959,12 @@ var __publicField = (obj, key, value) => {
|
|
|
25959
25959
|
registerBoxClass(boxClass) {
|
|
25960
25960
|
const type = boxClass.boxType;
|
|
25961
25961
|
const exists = this.boxes.get(type);
|
|
25962
|
-
assert(logger$
|
|
25962
|
+
assert(logger$3Z, !exists, `duplicated box type: ${type}`);
|
|
25963
25963
|
this.boxes.set(type, boxClass);
|
|
25964
25964
|
}
|
|
25965
25965
|
getBoxClass(type) {
|
|
25966
25966
|
const exists = this.boxes.get(type);
|
|
25967
|
-
assert(logger$
|
|
25967
|
+
assert(logger$3Z, exists, `unknown box type: ${type}`);
|
|
25968
25968
|
return exists;
|
|
25969
25969
|
}
|
|
25970
25970
|
createBox(blockContent, box) {
|
|
@@ -26368,7 +26368,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26368
26368
|
return { classes, attributes: newAttributes, styles: newStyles };
|
|
26369
26369
|
}
|
|
26370
26370
|
}
|
|
26371
|
-
const logger$
|
|
26371
|
+
const logger$3Y = getLogger("editor-insertion");
|
|
26372
26372
|
class EditorInsertions {
|
|
26373
26373
|
constructor(editor) {
|
|
26374
26374
|
__publicField(this, "insertions", /* @__PURE__ */ new Map());
|
|
@@ -26377,12 +26377,12 @@ var __publicField = (obj, key, value) => {
|
|
|
26377
26377
|
registerInsertionClass(insertionClass) {
|
|
26378
26378
|
const type = insertionClass.insertionType;
|
|
26379
26379
|
const exists = this.insertions.get(type);
|
|
26380
|
-
assert(logger$
|
|
26380
|
+
assert(logger$3Y, !exists, `duplicated insertion type: ${type}`);
|
|
26381
26381
|
this.insertions.set(type, insertionClass);
|
|
26382
26382
|
}
|
|
26383
26383
|
getInsertionClass(type) {
|
|
26384
26384
|
const exists = this.insertions.get(type);
|
|
26385
|
-
assert(logger$
|
|
26385
|
+
assert(logger$3Y, exists, `unknown insertion type: ${type}`);
|
|
26386
26386
|
return exists;
|
|
26387
26387
|
}
|
|
26388
26388
|
createInsertionElement(type, id, attributes) {
|
|
@@ -26502,7 +26502,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26502
26502
|
};
|
|
26503
26503
|
}
|
|
26504
26504
|
}
|
|
26505
|
-
const logger$
|
|
26505
|
+
const logger$3X = getLogger("editor-input");
|
|
26506
26506
|
class EditorInput$1 {
|
|
26507
26507
|
constructor(editor, callbacks) {
|
|
26508
26508
|
__publicField(this, "editor");
|
|
@@ -26639,7 +26639,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26639
26639
|
return;
|
|
26640
26640
|
}
|
|
26641
26641
|
this.callbacks.onCut(event);
|
|
26642
|
-
logger$
|
|
26642
|
+
logger$3X.debug("on cut");
|
|
26643
26643
|
});
|
|
26644
26644
|
__publicField(this, "handlePaste", (event) => {
|
|
26645
26645
|
if (event.isTrusted) {
|
|
@@ -26760,11 +26760,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26760
26760
|
this.callbacks.removeHandler(handler);
|
|
26761
26761
|
}
|
|
26762
26762
|
defaultInsertText(editor, containerId, blockIndex, offset, text2) {
|
|
26763
|
-
assert(logger$
|
|
26763
|
+
assert(logger$3X, editor === this.editor, "invalid editor");
|
|
26764
26764
|
this.callbacks.defaultInsertText(editor, containerId, blockIndex, offset, text2);
|
|
26765
26765
|
}
|
|
26766
26766
|
defaultHandleKeydown(editor, event) {
|
|
26767
|
-
assert(logger$
|
|
26767
|
+
assert(logger$3X, editor === this.editor, "invalid editor");
|
|
26768
26768
|
return this.callbacks.defaultHandleKeydown(editor, event);
|
|
26769
26769
|
}
|
|
26770
26770
|
forEach(callback) {
|
|
@@ -26790,7 +26790,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26790
26790
|
input2.style.left = `${x}px`;
|
|
26791
26791
|
input2.style.top = `${y}px`;
|
|
26792
26792
|
}
|
|
26793
|
-
const logger$
|
|
26793
|
+
const logger$3W = getLogger("editor-caret");
|
|
26794
26794
|
function getFirefoxVersion() {
|
|
26795
26795
|
const userAgent = window.navigator.userAgent;
|
|
26796
26796
|
const match = userAgent.match(/Firefox\/(\d+)\./);
|
|
@@ -26858,11 +26858,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26858
26858
|
}
|
|
26859
26859
|
try {
|
|
26860
26860
|
const { range } = this.editor.selection;
|
|
26861
|
-
assert(logger$
|
|
26861
|
+
assert(logger$3W, range.isCollapsed, "range is not collapsed");
|
|
26862
26862
|
const pos = range.start;
|
|
26863
|
-
assert(logger$
|
|
26863
|
+
assert(logger$3W, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
|
|
26864
26864
|
const block = this.editor.getBlockById(pos.blockId);
|
|
26865
|
-
assert(logger$
|
|
26865
|
+
assert(logger$3W, isTextKindBlock(this.editor, block), "only text kind block can has caret");
|
|
26866
26866
|
let rect;
|
|
26867
26867
|
const compositionSpan = block.querySelector("span.inputting-insertion");
|
|
26868
26868
|
if (compositionSpan) {
|
|
@@ -26895,7 +26895,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26895
26895
|
cursor.style.display = "";
|
|
26896
26896
|
}
|
|
26897
26897
|
} catch (err) {
|
|
26898
|
-
logger$
|
|
26898
|
+
logger$3W.error(err);
|
|
26899
26899
|
}
|
|
26900
26900
|
}
|
|
26901
26901
|
}
|
|
@@ -26919,7 +26919,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26919
26919
|
updateBlockSelection(editor, s.block, s.start, s.end);
|
|
26920
26920
|
});
|
|
26921
26921
|
}
|
|
26922
|
-
const logger$
|
|
26922
|
+
const logger$3V = getLogger("editor-dom");
|
|
26923
26923
|
function editorGetClientHeight(editor) {
|
|
26924
26924
|
const scrollContainer = getScrollContainer$1(editor.rootContainer);
|
|
26925
26925
|
return scrollContainer.clientHeight;
|
|
@@ -27010,7 +27010,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27010
27010
|
return;
|
|
27011
27011
|
}
|
|
27012
27012
|
if (!isElementVisible(editor.rootContainer)) {
|
|
27013
|
-
logger$
|
|
27013
|
+
logger$3V.warn("editorScrollIntoView: editor is not visible");
|
|
27014
27014
|
return;
|
|
27015
27015
|
}
|
|
27016
27016
|
const rootClientRect = editor.rootContainer.getBoundingClientRect();
|
|
@@ -27066,7 +27066,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27066
27066
|
anchorElem.remove();
|
|
27067
27067
|
}, 200);
|
|
27068
27068
|
}
|
|
27069
|
-
const logger$
|
|
27069
|
+
const logger$3U = getLogger("range-in-block");
|
|
27070
27070
|
function rangeInBlock(block, range) {
|
|
27071
27071
|
const editor = range.getEditor();
|
|
27072
27072
|
const start = editor.getBlockById(range.start.blockId);
|
|
@@ -27093,11 +27093,11 @@ var __publicField = (obj, key, value) => {
|
|
|
27093
27093
|
}
|
|
27094
27094
|
}
|
|
27095
27095
|
const nextBlock = getNextVisibleBlock(block);
|
|
27096
|
-
assert(logger$
|
|
27096
|
+
assert(logger$3U, nextBlock, "no prev and next block while deleting a block");
|
|
27097
27097
|
newRange = createBlockSimpleRange(editor, nextBlock, 0);
|
|
27098
27098
|
return newRange;
|
|
27099
27099
|
}
|
|
27100
|
-
const logger$
|
|
27100
|
+
const logger$3T = getLogger("block-to-html");
|
|
27101
27101
|
function blockToHtml(editor, blockData, doc2, path) {
|
|
27102
27102
|
const blockClass = getBlockClassByType(editor, blockData.type);
|
|
27103
27103
|
if (blockClass.convertTo) {
|
|
@@ -27106,15 +27106,15 @@ var __publicField = (obj, key, value) => {
|
|
|
27106
27106
|
if (blockClass.blockKind !== "text") {
|
|
27107
27107
|
return `[${blockData.type}]`;
|
|
27108
27108
|
}
|
|
27109
|
-
assert(logger$
|
|
27109
|
+
assert(logger$3T, blockData.text, "no text");
|
|
27110
27110
|
const plainText = toPlainText(blockData.text);
|
|
27111
27111
|
return `<div>${escapeHtmlText(plainText)}</div>`;
|
|
27112
27112
|
}
|
|
27113
|
-
const logger$
|
|
27113
|
+
const logger$3S = getLogger("block-to-text");
|
|
27114
27114
|
function textBlockToText(editor, ops, doc2) {
|
|
27115
27115
|
let text2 = "";
|
|
27116
27116
|
ops.forEach((op) => {
|
|
27117
|
-
assert(logger$
|
|
27117
|
+
assert(logger$3S, typeof op.insert === "string", "invalid op");
|
|
27118
27118
|
if (op.attributes && op.attributes.box === true) {
|
|
27119
27119
|
const box = op.attributes;
|
|
27120
27120
|
const boxClass = editor.editorBoxes.getBoxClass(box.type);
|
|
@@ -27140,7 +27140,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27140
27140
|
if (blockClass.blockKind !== "text") {
|
|
27141
27141
|
return `[${blockData.type}]`;
|
|
27142
27142
|
}
|
|
27143
|
-
assert(logger$
|
|
27143
|
+
assert(logger$3S, blockData.text, "no text");
|
|
27144
27144
|
const plainText = textBlockToText(editor, blockData.text, doc2);
|
|
27145
27145
|
return plainText;
|
|
27146
27146
|
}
|
|
@@ -27173,11 +27173,11 @@ var __publicField = (obj, key, value) => {
|
|
|
27173
27173
|
const markdown2 = lines.join("\n");
|
|
27174
27174
|
return markdown2;
|
|
27175
27175
|
}
|
|
27176
|
-
const logger$
|
|
27176
|
+
const logger$3R = getLogger("get-text-position");
|
|
27177
27177
|
function editorGetTextPosition(editor, insertPos) {
|
|
27178
27178
|
const pos = insertPos != null ? insertPos : editor.selection.range.start;
|
|
27179
27179
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
27180
|
-
assert(logger$
|
|
27180
|
+
assert(logger$3R, false, `invalid insert pos type: ${typeof pos}`);
|
|
27181
27181
|
}
|
|
27182
27182
|
const { blockId } = pos;
|
|
27183
27183
|
const block = editor.getBlockById(blockId);
|
|
@@ -27265,14 +27265,14 @@ var __publicField = (obj, key, value) => {
|
|
|
27265
27265
|
return attributes;
|
|
27266
27266
|
}
|
|
27267
27267
|
}
|
|
27268
|
-
const logger$
|
|
27268
|
+
const logger$3Q = getLogger("insert-text");
|
|
27269
27269
|
function getTextAttributes(editor, containerId, blockIndex, offset) {
|
|
27270
27270
|
var _a, _b;
|
|
27271
27271
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
27272
|
-
assert(logger$
|
|
27273
|
-
assert(logger$
|
|
27272
|
+
assert(logger$3Q, blockData, "no block data");
|
|
27273
|
+
assert(logger$3Q, blockData.text, "no block text");
|
|
27274
27274
|
if (getTextLength(blockData.text) === 0) {
|
|
27275
|
-
assert(logger$
|
|
27275
|
+
assert(logger$3Q, offset === 0, "invalid text offset");
|
|
27276
27276
|
return BlockAttributesHandler.get(editor).getEmptyBlockTextAttributes(blockData.id);
|
|
27277
27277
|
}
|
|
27278
27278
|
if (offset === 0) {
|
|
@@ -27319,7 +27319,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27319
27319
|
}
|
|
27320
27320
|
for (let i = 0; i < text2.length; i++) {
|
|
27321
27321
|
const op = text2[i];
|
|
27322
|
-
assert(logger$
|
|
27322
|
+
assert(logger$3Q, typeof op.insert === "string", "invalid text op, no insert");
|
|
27323
27323
|
const endPos = pos + getOpLength(op);
|
|
27324
27324
|
if (endPos === start) {
|
|
27325
27325
|
return false;
|
|
@@ -27333,8 +27333,8 @@ var __publicField = (obj, key, value) => {
|
|
|
27333
27333
|
}
|
|
27334
27334
|
function editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset) {
|
|
27335
27335
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
27336
|
-
assert(logger$
|
|
27337
|
-
assert(logger$
|
|
27336
|
+
assert(logger$3Q, blockData, "no block data");
|
|
27337
|
+
assert(logger$3Q, blockData.text, "no block text");
|
|
27338
27338
|
const attributes = getTextAttributes(editor, containerId, blockIndex, offset);
|
|
27339
27339
|
if (attributes && Object.keys(attributes).includes("link")) {
|
|
27340
27340
|
const inOp = checkRangeInOp(blockData.text, offset);
|
|
@@ -27353,21 +27353,21 @@ var __publicField = (obj, key, value) => {
|
|
|
27353
27353
|
const { containerId, blockIndex, offset } = editorGetTextPosition(editor);
|
|
27354
27354
|
editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset);
|
|
27355
27355
|
}
|
|
27356
|
-
const logger$
|
|
27356
|
+
const logger$3P = getLogger("update-composition-text");
|
|
27357
27357
|
function editorUpdateCompositionText(editor) {
|
|
27358
27358
|
const pos = editor.selection.range.start;
|
|
27359
27359
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
27360
|
-
assert(logger$
|
|
27360
|
+
assert(logger$3P, false, `invalid insert pos type: ${typeof pos}`);
|
|
27361
27361
|
}
|
|
27362
27362
|
const { blockId } = pos;
|
|
27363
27363
|
const block = editor.getBlockById(blockId);
|
|
27364
|
-
assert(logger$
|
|
27364
|
+
assert(logger$3P, isTextKindBlock(editor, block), "not a text kind block");
|
|
27365
27365
|
const container = getParentContainer(block);
|
|
27366
27366
|
const containerId = getContainerId(container);
|
|
27367
27367
|
const blockIndex = getBlockIndex(block);
|
|
27368
27368
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
27369
|
-
assert(logger$
|
|
27370
|
-
assert(logger$
|
|
27369
|
+
assert(logger$3P, blockData, "no block data in doc");
|
|
27370
|
+
assert(logger$3P, blockData.text, "no text data in text block");
|
|
27371
27371
|
const blockContent = getBlockContent(block);
|
|
27372
27372
|
updateBlockContent$1(editor, getBlockPath(block), blockId, blockContent, blockData.text);
|
|
27373
27373
|
}
|
|
@@ -27379,25 +27379,25 @@ var __publicField = (obj, key, value) => {
|
|
|
27379
27379
|
const block = editor.getBlockById(blockData.id);
|
|
27380
27380
|
return block;
|
|
27381
27381
|
}
|
|
27382
|
-
const logger$
|
|
27382
|
+
const logger$3O = getLogger("delete-block-text");
|
|
27383
27383
|
function editorDeleteBlockText(editor, block, offset, count, options) {
|
|
27384
27384
|
if (!editor.isBlockWritable(block)) {
|
|
27385
|
-
logger$
|
|
27385
|
+
logger$3O.error("block is not writable");
|
|
27386
27386
|
return 0;
|
|
27387
27387
|
}
|
|
27388
|
-
assert(logger$
|
|
27388
|
+
assert(logger$3O, isTextKindBlock(editor, block), "block is not a text kind block");
|
|
27389
27389
|
const container = getParentContainer(block);
|
|
27390
27390
|
const containerId = getContainerId(container);
|
|
27391
27391
|
const blockIndex = getBlockIndex(block);
|
|
27392
27392
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
27393
|
-
assert(logger$
|
|
27394
|
-
assert(logger$
|
|
27393
|
+
assert(logger$3O, blockData, "no block data in doc");
|
|
27394
|
+
assert(logger$3O, blockData.text, "no text data in text block");
|
|
27395
27395
|
let from = offset;
|
|
27396
27396
|
if (!isValidOffset(block, offset)) {
|
|
27397
27397
|
from = getPrevValidOffset(block, from);
|
|
27398
27398
|
}
|
|
27399
27399
|
let to = offset + count;
|
|
27400
|
-
assert(logger$
|
|
27400
|
+
assert(logger$3O, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
|
|
27401
27401
|
if (!isValidOffset(block, to)) {
|
|
27402
27402
|
to = getNextValidOffset(block, to);
|
|
27403
27403
|
}
|
|
@@ -27406,7 +27406,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27406
27406
|
editor.doc.localUpdateBlockText(containerId, blockIndex, actions2, options);
|
|
27407
27407
|
return deleteCount;
|
|
27408
27408
|
}
|
|
27409
|
-
const logger$
|
|
27409
|
+
const logger$3N = getLogger("break-text-block");
|
|
27410
27410
|
function copyBlockAttributes(editor, block, options) {
|
|
27411
27411
|
const blockData = editor.getBlockData(block);
|
|
27412
27412
|
const quoted = blockData.quoted;
|
|
@@ -27423,8 +27423,8 @@ var __publicField = (obj, key, value) => {
|
|
|
27423
27423
|
return ret;
|
|
27424
27424
|
}
|
|
27425
27425
|
function editorBreakTextBlock(editor, block, offset, options) {
|
|
27426
|
-
assert(logger$
|
|
27427
|
-
assert(logger$
|
|
27426
|
+
assert(logger$3N, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
|
|
27427
|
+
assert(logger$3N, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
|
|
27428
27428
|
const container = getParentContainer(block);
|
|
27429
27429
|
const containerId = getContainerId(container);
|
|
27430
27430
|
const blockIndex = getBlockIndex(block);
|
|
@@ -27454,7 +27454,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27454
27454
|
};
|
|
27455
27455
|
}
|
|
27456
27456
|
}
|
|
27457
|
-
assert(logger$
|
|
27457
|
+
assert(logger$3N, isValidOffset(block, offset), "not a valid offset");
|
|
27458
27458
|
const text2 = editorGetBlockText(editor, block);
|
|
27459
27459
|
const { right } = splitText(text2, offset);
|
|
27460
27460
|
const rightLength = getTextLength(right);
|
|
@@ -27480,12 +27480,12 @@ var __publicField = (obj, key, value) => {
|
|
|
27480
27480
|
newBlock
|
|
27481
27481
|
};
|
|
27482
27482
|
}
|
|
27483
|
-
const logger$
|
|
27483
|
+
const logger$3M = getLogger("prepare-insert-new-block");
|
|
27484
27484
|
function editorPrepareInsertNewBlock(editor, containerId, blockIndex) {
|
|
27485
27485
|
if (containerId && blockIndex !== void 0 && blockIndex !== null) {
|
|
27486
27486
|
const container = editor.getContainerById(containerId);
|
|
27487
27487
|
const blocks = getChildBlocks(container);
|
|
27488
|
-
assert(logger$
|
|
27488
|
+
assert(logger$3M, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
|
|
27489
27489
|
return {
|
|
27490
27490
|
containerId,
|
|
27491
27491
|
blockIndex
|
|
@@ -27519,10 +27519,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27519
27519
|
blockIndex: getBlockIndex(newBlock)
|
|
27520
27520
|
};
|
|
27521
27521
|
}
|
|
27522
|
-
const logger$
|
|
27522
|
+
const logger$3L = getLogger("auto-insert-block");
|
|
27523
27523
|
function editorAutoInsertBlock(editor, blockData, containerId, blockIndex, newRange, insertBlockOptions) {
|
|
27524
27524
|
const result = editorPrepareInsertNewBlock(editor, containerId, blockIndex);
|
|
27525
|
-
assert(logger$
|
|
27525
|
+
assert(logger$3L, result, `not an valid insert position: ${editor.selection.range}`);
|
|
27526
27526
|
const defaultPos = { blockId: blockData.id, offset: 0 };
|
|
27527
27527
|
const defaultRange = { anchor: defaultPos, focus: defaultPos };
|
|
27528
27528
|
return editorInsertBlock(editor, result.containerId, result.blockIndex, blockData, newRange != null ? newRange : defaultRange, insertBlockOptions);
|
|
@@ -27604,7 +27604,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27604
27604
|
state == null ? void 0 : state.activeSessions.clear();
|
|
27605
27605
|
editorLeases.delete(editor);
|
|
27606
27606
|
}
|
|
27607
|
-
const logger$
|
|
27607
|
+
const logger$3K = getLogger("delete-block");
|
|
27608
27608
|
function getAllChildContainers(editor, blockData, containerIds) {
|
|
27609
27609
|
if (blockData.children) {
|
|
27610
27610
|
blockData.children.forEach((childContainerId) => {
|
|
@@ -27613,7 +27613,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27613
27613
|
}
|
|
27614
27614
|
const childBlocks = editor.doc.findContainerBlocks(childContainerId);
|
|
27615
27615
|
if (!Array.isArray(childBlocks)) {
|
|
27616
|
-
logger$
|
|
27616
|
+
logger$3K.warn(`skip invalid child container while deleting: parentBlock=${blockData.id}, container=${childContainerId}`);
|
|
27617
27617
|
return;
|
|
27618
27618
|
}
|
|
27619
27619
|
containerIds.add(childContainerId);
|
|
@@ -27628,7 +27628,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27628
27628
|
const containerId = getContainerId(container);
|
|
27629
27629
|
const blockIndex = getBlockIndex(block);
|
|
27630
27630
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
27631
|
-
assert(logger$
|
|
27631
|
+
assert(logger$3K, blockData, "no block data in doc");
|
|
27632
27632
|
editor.doc.localDeleteBlock(containerId, blockIndex, createEditorSelectionRange(editor, { anchor: newRange.start, focus: newRange.end }));
|
|
27633
27633
|
return blockData;
|
|
27634
27634
|
}
|
|
@@ -27676,15 +27676,15 @@ var __publicField = (obj, key, value) => {
|
|
|
27676
27676
|
});
|
|
27677
27677
|
editor.doc.localDeleteChildContainers(Array.from(containerIds));
|
|
27678
27678
|
}
|
|
27679
|
-
const logger$
|
|
27679
|
+
const logger$3J = getLogger("merge-text-block");
|
|
27680
27680
|
function editorMergeTextBlock(editor, block1, block2) {
|
|
27681
|
-
assert(logger$
|
|
27682
|
-
assert(logger$
|
|
27681
|
+
assert(logger$3J, isTextKindBlock(editor, block1), "only text block can be merged");
|
|
27682
|
+
assert(logger$3J, isTextKindBlock(editor, block2), "only text block can be merged");
|
|
27683
27683
|
const data1 = editorGetBlockData(editor, block1);
|
|
27684
27684
|
const data2 = editorGetBlockData(editor, block2);
|
|
27685
27685
|
const text1 = data1.text;
|
|
27686
27686
|
const text2 = data2.text;
|
|
27687
|
-
assert(logger$
|
|
27687
|
+
assert(logger$3J, text1 && text2, "block data has no text");
|
|
27688
27688
|
const container = getParentContainer(block1);
|
|
27689
27689
|
const containerId = getContainerId(container);
|
|
27690
27690
|
const blockIndex = getBlockIndex(block1);
|
|
@@ -27694,15 +27694,15 @@ var __publicField = (obj, key, value) => {
|
|
|
27694
27694
|
editorDeleteBlock(editor, block2, newRange);
|
|
27695
27695
|
return block;
|
|
27696
27696
|
}
|
|
27697
|
-
const logger$
|
|
27697
|
+
const logger$3I = getLogger("clear-selected-contents");
|
|
27698
27698
|
function deleteTextBlockSelection(editor, selectedBlock) {
|
|
27699
|
-
assert(logger$
|
|
27699
|
+
assert(logger$3I, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
|
|
27700
27700
|
const { start, end } = selectedBlock;
|
|
27701
|
-
assert(logger$
|
|
27702
|
-
assert(logger$
|
|
27701
|
+
assert(logger$3I, start.isSimple(), "not a simple block position");
|
|
27702
|
+
assert(logger$3I, end.isSimple(), "not a simple block position");
|
|
27703
27703
|
const startOffset = start.offset;
|
|
27704
27704
|
const endOffset = end.offset;
|
|
27705
|
-
assert(logger$
|
|
27705
|
+
assert(logger$3I, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
|
|
27706
27706
|
if (startOffset === endOffset) {
|
|
27707
27707
|
return;
|
|
27708
27708
|
}
|
|
@@ -27727,7 +27727,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27727
27727
|
return;
|
|
27728
27728
|
}
|
|
27729
27729
|
if (isEmbedBlock(block) || start.isSimple()) {
|
|
27730
|
-
assert(logger$
|
|
27730
|
+
assert(logger$3I, end.isSimple(), "invalid range");
|
|
27731
27731
|
const container = getParentContainer(block);
|
|
27732
27732
|
const blockIndex = getBlockIndex(block);
|
|
27733
27733
|
const newBlock = editor.insertTextBlock("", getContainerId(container), blockIndex);
|
|
@@ -27735,8 +27735,8 @@ var __publicField = (obj, key, value) => {
|
|
|
27735
27735
|
editor.deleteBlock(block);
|
|
27736
27736
|
return;
|
|
27737
27737
|
}
|
|
27738
|
-
assert(logger$
|
|
27739
|
-
assert(logger$
|
|
27738
|
+
assert(logger$3I, isComplexKindBlock(editor, block), "invalid block kind");
|
|
27739
|
+
assert(logger$3I, !start.isSimple() && !end.isSimple(), "invalid range");
|
|
27740
27740
|
complexBlockGetSelectedContainers(editor, block, start, end);
|
|
27741
27741
|
const containers = editor.selection.range.getSelectedContainers();
|
|
27742
27742
|
containers.forEach((container, index2) => {
|
|
@@ -27753,7 +27753,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27753
27753
|
return;
|
|
27754
27754
|
}
|
|
27755
27755
|
const selectedBlocks = range.getSelectedBlocks();
|
|
27756
|
-
assert(logger$
|
|
27756
|
+
assert(logger$3I, selectedBlocks.length > 0, "no selected block");
|
|
27757
27757
|
if (selectedBlocks.length === 1) {
|
|
27758
27758
|
clearOneBlock(editor, selectedBlocks[0]);
|
|
27759
27759
|
return;
|
|
@@ -27761,7 +27761,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27761
27761
|
const firstSelectedBlock = selectedBlocks[0];
|
|
27762
27762
|
const firstBlock = firstSelectedBlock.block;
|
|
27763
27763
|
const container = getParentContainer(firstBlock);
|
|
27764
|
-
assert(logger$
|
|
27764
|
+
assert(logger$3I, selectedBlocks.length > 1, "no selected block");
|
|
27765
27765
|
const lastSelectedBlock = selectedBlocks[selectedBlocks.length - 1];
|
|
27766
27766
|
const lastBlock2 = lastSelectedBlock.block;
|
|
27767
27767
|
if (isTextKindBlock(editor, firstBlock)) {
|
|
@@ -27791,7 +27791,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27791
27791
|
}
|
|
27792
27792
|
const prevBlock = getPrevBlock(firstBlock);
|
|
27793
27793
|
const nextBlock = getNextBlock(lastBlock2);
|
|
27794
|
-
assert(logger$
|
|
27794
|
+
assert(logger$3I, prevBlock || nextBlock, "no prev or next block");
|
|
27795
27795
|
selectedBlocks.forEach((selectedBlock) => editor.deleteBlock(selectedBlock.block));
|
|
27796
27796
|
}
|
|
27797
27797
|
function editorClearSelectedContents(editor, selectionRange) {
|
|
@@ -27810,7 +27810,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27810
27810
|
editor.emit("afterClearSelection", editor);
|
|
27811
27811
|
});
|
|
27812
27812
|
}
|
|
27813
|
-
const logger$
|
|
27813
|
+
const logger$3H = getLogger("core");
|
|
27814
27814
|
function editorUpdateBlockText(editor, block, ops, options) {
|
|
27815
27815
|
const container = getParentContainer(block);
|
|
27816
27816
|
const containerId = getContainerId(container);
|
|
@@ -27823,7 +27823,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27823
27823
|
}
|
|
27824
27824
|
function editorSetBlockText(editor, block, newText, options) {
|
|
27825
27825
|
if (!editor.isBlockWritable(block)) {
|
|
27826
|
-
logger$
|
|
27826
|
+
logger$3H.error("block is not writable");
|
|
27827
27827
|
return;
|
|
27828
27828
|
}
|
|
27829
27829
|
const oldText = editor.getBlockText(block);
|
|
@@ -27836,7 +27836,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27836
27836
|
const ops = RichText.diff(oldText, newText);
|
|
27837
27837
|
return editorUpdateBlockText(editor, block, ops);
|
|
27838
27838
|
}
|
|
27839
|
-
const logger$
|
|
27839
|
+
const logger$3G = getLogger("update-block-data");
|
|
27840
27840
|
function editorUpdateBlockData(editor, block, data2, newRange, options) {
|
|
27841
27841
|
const container = getParentContainer(block);
|
|
27842
27842
|
const containerId = getContainerId(container);
|
|
@@ -27853,17 +27853,17 @@ var __publicField = (obj, key, value) => {
|
|
|
27853
27853
|
if (oldKey === "id" || oldKey === "type" || oldKey === "text") {
|
|
27854
27854
|
return;
|
|
27855
27855
|
}
|
|
27856
|
-
logger$
|
|
27856
|
+
logger$3G.debug(`delete key: ${oldKey}`);
|
|
27857
27857
|
delta.delete.push(oldKey);
|
|
27858
27858
|
}
|
|
27859
27859
|
});
|
|
27860
27860
|
const entries = Object.entries(data2);
|
|
27861
27861
|
entries.forEach(([key, value]) => {
|
|
27862
|
-
assert(logger$
|
|
27862
|
+
assert(logger$3G, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
|
|
27863
27863
|
const oldValue = oldData[key];
|
|
27864
27864
|
if (value === null || value === void 0) {
|
|
27865
27865
|
if (oldValue !== null && oldValue !== void 0) {
|
|
27866
|
-
logger$
|
|
27866
|
+
logger$3G.debug(`delete key: ${key}`);
|
|
27867
27867
|
delta.delete.push(key);
|
|
27868
27868
|
}
|
|
27869
27869
|
return;
|
|
@@ -27881,10 +27881,10 @@ var __publicField = (obj, key, value) => {
|
|
|
27881
27881
|
}
|
|
27882
27882
|
}
|
|
27883
27883
|
if (oldKeys.has(key)) {
|
|
27884
|
-
logger$
|
|
27884
|
+
logger$3G.debug(`replace key: ${key}`);
|
|
27885
27885
|
delta.delete.push(key);
|
|
27886
27886
|
} else {
|
|
27887
|
-
logger$
|
|
27887
|
+
logger$3G.debug(`insert key: ${key}`);
|
|
27888
27888
|
}
|
|
27889
27889
|
delta.insert[key] = value;
|
|
27890
27890
|
});
|
|
@@ -27929,13 +27929,13 @@ var __publicField = (obj, key, value) => {
|
|
|
27929
27929
|
comments: {}
|
|
27930
27930
|
};
|
|
27931
27931
|
}
|
|
27932
|
-
const logger$
|
|
27932
|
+
const logger$3F = getLogger("clone-block");
|
|
27933
27933
|
function cloneBlock(editorBlocks, oldDoc, data2, info) {
|
|
27934
27934
|
var _a;
|
|
27935
27935
|
const blockClass = editorBlocks.getBlockClass(data2.type);
|
|
27936
27936
|
if (blockClass.blockToDoc) {
|
|
27937
27937
|
return blockClass.blockToDoc(oldDoc, data2, (oldDoc2, childBlock) => {
|
|
27938
|
-
assert(logger$
|
|
27938
|
+
assert(logger$3F, data2 !== childBlock, "invalid child block");
|
|
27939
27939
|
return cloneBlock(editorBlocks, oldDoc2, data2, info);
|
|
27940
27940
|
}, info);
|
|
27941
27941
|
}
|
|
@@ -27948,7 +27948,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27948
27948
|
}
|
|
27949
27949
|
const newChildContainerId = genId();
|
|
27950
27950
|
const childBlocks = oldDoc.blocks[oldChildContainerId];
|
|
27951
|
-
assert(logger$
|
|
27951
|
+
assert(logger$3F, Array.isArray(childBlocks), "invalid child blocks");
|
|
27952
27952
|
const newDocs = childBlocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
|
|
27953
27953
|
const newDoc = mergeDocs(newDocs);
|
|
27954
27954
|
const { root: root2, ...childContainersData } = newDoc.blocks;
|
|
@@ -27977,7 +27977,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27977
27977
|
if (key.startsWith(prefix1)) {
|
|
27978
27978
|
const keyContent = key.substring(prefix1.length);
|
|
27979
27979
|
const newKey = `${newContainerId}/${keyContent}`;
|
|
27980
|
-
logger$
|
|
27980
|
+
logger$3F.debug(`replace key: ${key} -> ${newKey}`);
|
|
27981
27981
|
return newKey;
|
|
27982
27982
|
}
|
|
27983
27983
|
}
|
|
@@ -27986,7 +27986,7 @@ var __publicField = (obj, key, value) => {
|
|
|
27986
27986
|
if (key.startsWith(prefix2)) {
|
|
27987
27987
|
const keyContent = key.substring(prefix2.length);
|
|
27988
27988
|
const newKey = `${newContainerId}_${keyContent}`;
|
|
27989
|
-
logger$
|
|
27989
|
+
logger$3F.debug(`replace key: ${key} -> ${newKey}`);
|
|
27990
27990
|
return newKey;
|
|
27991
27991
|
}
|
|
27992
27992
|
}
|
|
@@ -28019,7 +28019,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28019
28019
|
}
|
|
28020
28020
|
function cloneChildContainer(editorBlocks, oldDoc, containerId, info) {
|
|
28021
28021
|
const blocks = oldDoc.blocks[containerId];
|
|
28022
|
-
assert(logger$
|
|
28022
|
+
assert(logger$3F, Array.isArray(blocks), "invalid child blocks");
|
|
28023
28023
|
const newDocs = blocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
|
|
28024
28024
|
const newDoc = mergeDocs(newDocs);
|
|
28025
28025
|
return newDoc;
|
|
@@ -28028,11 +28028,11 @@ var __publicField = (obj, key, value) => {
|
|
|
28028
28028
|
const docs = doc2.blocks.root.map((b) => cloneBlock(editor.editorBlocks, doc2, b, info));
|
|
28029
28029
|
return cloneDeep__default.default(mergeDocs(docs));
|
|
28030
28030
|
}
|
|
28031
|
-
const logger$
|
|
28031
|
+
const logger$3E = getLogger("insert-doc");
|
|
28032
28032
|
function editorInsertDoc(editor, block, offset, insertedDoc, cloneDocResult) {
|
|
28033
28033
|
var _a;
|
|
28034
28034
|
if (isComplexKindBlock(editor, block)) {
|
|
28035
|
-
logger$
|
|
28035
|
+
logger$3E.warn("failed to insert doc into a complex block");
|
|
28036
28036
|
return;
|
|
28037
28037
|
}
|
|
28038
28038
|
const doc2 = cloneDoc(editor, insertedDoc, cloneDocResult);
|
|
@@ -28070,7 +28070,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28070
28070
|
}
|
|
28071
28071
|
return;
|
|
28072
28072
|
}
|
|
28073
|
-
assert(logger$
|
|
28073
|
+
assert(logger$3E, isTextKindBlock(editor, block), "not a text block");
|
|
28074
28074
|
if (isEmptyTextBlock(editor, block)) {
|
|
28075
28075
|
const blockIndex2 = getBlockIndex(block);
|
|
28076
28076
|
let lastBlock22;
|
|
@@ -28202,11 +28202,11 @@ var __publicField = (obj, key, value) => {
|
|
|
28202
28202
|
editor.deleteBlock(block);
|
|
28203
28203
|
}
|
|
28204
28204
|
}
|
|
28205
|
-
const logger$
|
|
28205
|
+
const logger$3D = getLogger("add-text-attribute");
|
|
28206
28206
|
function editorRemoveTextAttribute(editor, block, range, attributeName) {
|
|
28207
28207
|
const { start, end } = range;
|
|
28208
|
-
assert(logger$
|
|
28209
|
-
assert(logger$
|
|
28208
|
+
assert(logger$3D, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
28209
|
+
assert(logger$3D, attributeName, "invalid attribute name");
|
|
28210
28210
|
const oldText = editor.getBlockText(block);
|
|
28211
28211
|
const newText = rangeRemoveAttribute(start.offset, end.offset - start.offset, oldText, attributeName, void 0, { ignoreValue: true });
|
|
28212
28212
|
editor.setBlockText(block, newText);
|
|
@@ -28214,8 +28214,8 @@ var __publicField = (obj, key, value) => {
|
|
|
28214
28214
|
}
|
|
28215
28215
|
function editorAddTextAttribute(editor, block, range, attributeName, value) {
|
|
28216
28216
|
const { start, end } = range;
|
|
28217
|
-
assert(logger$
|
|
28218
|
-
assert(logger$
|
|
28217
|
+
assert(logger$3D, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
28218
|
+
assert(logger$3D, attributeName, "invalid attribute name");
|
|
28219
28219
|
const oldText = editor.getBlockText(block);
|
|
28220
28220
|
const newText = rangeAddAttribute(start.offset, end.offset - start.offset, oldText, attributeName, value);
|
|
28221
28221
|
editor.setBlockText(block, newText);
|
|
@@ -28223,7 +28223,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28223
28223
|
}
|
|
28224
28224
|
function editorSetTextColor(editor, block, range, type, value) {
|
|
28225
28225
|
const { start, end } = range;
|
|
28226
|
-
assert(logger$
|
|
28226
|
+
assert(logger$3D, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
|
|
28227
28227
|
const oldText = editor.getBlockText(block);
|
|
28228
28228
|
const newText = rangeSetTextColor(start.offset, end.offset - start.offset, oldText, type, value);
|
|
28229
28229
|
editor.setBlockText(block, newText);
|
|
@@ -28312,10 +28312,10 @@ var __publicField = (obj, key, value) => {
|
|
|
28312
28312
|
});
|
|
28313
28313
|
return [color, backgroundColor];
|
|
28314
28314
|
}
|
|
28315
|
-
const logger$
|
|
28315
|
+
const logger$3C = getLogger("move-complex-block-position");
|
|
28316
28316
|
function moveComplexBlockPosition(editor, old, type) {
|
|
28317
28317
|
const block = editor.getBlockById(old.blockId);
|
|
28318
|
-
assert(logger$
|
|
28318
|
+
assert(logger$3C, isComplexKindBlock(editor, block), "is not a complex block");
|
|
28319
28319
|
const blockClass = getComplexBlockClass(editor, block);
|
|
28320
28320
|
const focusedContainer = editor.getContainerById(old.childContainerId);
|
|
28321
28321
|
const nextContainer = blockClass.getNextContainer(editor, block, focusedContainer, type, { noWrap: true });
|
|
@@ -28324,24 +28324,24 @@ var __publicField = (obj, key, value) => {
|
|
|
28324
28324
|
}
|
|
28325
28325
|
return createComplexBlockPosition(block, getContainerId(nextContainer));
|
|
28326
28326
|
}
|
|
28327
|
-
const logger$
|
|
28327
|
+
const logger$3B = getLogger("move-simple-block-position");
|
|
28328
28328
|
function getFirstChildBlockInComplexBlock(editor, complexBlock) {
|
|
28329
28329
|
const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
|
|
28330
28330
|
if (containers.length === 0) {
|
|
28331
|
-
logger$
|
|
28331
|
+
logger$3B.warn("complex block has not any child container, not loaded?");
|
|
28332
28332
|
return null;
|
|
28333
28333
|
}
|
|
28334
|
-
assert(logger$
|
|
28334
|
+
assert(logger$3B, containers.length > 0, "complex block has not any child container");
|
|
28335
28335
|
const container = containers[0];
|
|
28336
28336
|
return getFirstChildBlock(container);
|
|
28337
28337
|
}
|
|
28338
28338
|
function getLastChildBlockInComplexBlock(editor, complexBlock) {
|
|
28339
28339
|
const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
|
|
28340
28340
|
if (containers.length === 0) {
|
|
28341
|
-
logger$
|
|
28341
|
+
logger$3B.warn("complex block has not any child container, not loaded?");
|
|
28342
28342
|
return null;
|
|
28343
28343
|
}
|
|
28344
|
-
assert(logger$
|
|
28344
|
+
assert(logger$3B, containers.length > 0, "complex block has not any child container");
|
|
28345
28345
|
const container = containers[containers.length - 1];
|
|
28346
28346
|
return getLastChildBlock(container);
|
|
28347
28347
|
}
|
|
@@ -28386,8 +28386,8 @@ var __publicField = (obj, key, value) => {
|
|
|
28386
28386
|
return null;
|
|
28387
28387
|
}
|
|
28388
28388
|
const parentComplexBlock = getParentBlock(container);
|
|
28389
|
-
assert(logger$
|
|
28390
|
-
assert(logger$
|
|
28389
|
+
assert(logger$3B, parentComplexBlock, "child container has not parent block");
|
|
28390
|
+
assert(logger$3B, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
|
|
28391
28391
|
const nextContainer = getComplexBlockClass(editor, parentComplexBlock).getNextContainer(editor, parentComplexBlock, container, type);
|
|
28392
28392
|
if (nextContainer) {
|
|
28393
28393
|
if (isFindPrev(type)) {
|
|
@@ -28409,7 +28409,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28409
28409
|
return null;
|
|
28410
28410
|
}
|
|
28411
28411
|
const parentBlock = getParentBlock(container);
|
|
28412
|
-
assert(logger$
|
|
28412
|
+
assert(logger$3B, parentBlock, "child container has not parent block");
|
|
28413
28413
|
if (isFindPrev(type)) {
|
|
28414
28414
|
const prev = getPrevBlock(parentBlock);
|
|
28415
28415
|
if (prev) {
|
|
@@ -28464,7 +28464,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28464
28464
|
}
|
|
28465
28465
|
if (!targetBlock) {
|
|
28466
28466
|
if (isComplexKindBlock(editor, block) && complexBlockGetAllChildContainers(editor, block).length === 0) {
|
|
28467
|
-
logger$
|
|
28467
|
+
logger$3B.warn("complex block has not any child container, not loaded?");
|
|
28468
28468
|
targetBlock = direction === "ArrowDown" || direction === "ArrowRight" ? getNextVisibleBlock(block) : getPrevVisibleBlock(block);
|
|
28469
28469
|
}
|
|
28470
28470
|
}
|
|
@@ -28611,10 +28611,10 @@ var __publicField = (obj, key, value) => {
|
|
|
28611
28611
|
editorAdjustSelection(editor, "ArrowUp", "select");
|
|
28612
28612
|
return true;
|
|
28613
28613
|
}
|
|
28614
|
-
const logger$
|
|
28614
|
+
const logger$3A = getLogger("word-offset");
|
|
28615
28615
|
function editorGetWordLeftPos(editor, type) {
|
|
28616
28616
|
const old = editor.selection.range.focus;
|
|
28617
|
-
assert(logger$
|
|
28617
|
+
assert(logger$3A, old.isSimple(), "invalid range type");
|
|
28618
28618
|
const block = editor.getBlockById(old.blockId);
|
|
28619
28619
|
if (isEmptyTextBlock(editor, block)) {
|
|
28620
28620
|
return createSimpleBlockPosition(block, 0, "home");
|
|
@@ -28639,7 +28639,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28639
28639
|
}
|
|
28640
28640
|
function editorGetWordRightPos(editor, type) {
|
|
28641
28641
|
const old = editor.selection.range.focus;
|
|
28642
|
-
assert(logger$
|
|
28642
|
+
assert(logger$3A, old.isSimple(), "invalid range type");
|
|
28643
28643
|
const block = editor.getBlockById(old.blockId);
|
|
28644
28644
|
if (isEmptyTextBlock(editor, block)) {
|
|
28645
28645
|
return createSimpleBlockPosition(block, 0, "end");
|
|
@@ -28751,10 +28751,10 @@ var __publicField = (obj, key, value) => {
|
|
|
28751
28751
|
editor.selection.setSelection(editor.selection.getAnchorPos(), pos);
|
|
28752
28752
|
return true;
|
|
28753
28753
|
}
|
|
28754
|
-
const logger$
|
|
28754
|
+
const logger$3z = getLogger("line-offset");
|
|
28755
28755
|
function editorGetLineHomePos(editor) {
|
|
28756
28756
|
const old = editor.selection.range.focus;
|
|
28757
|
-
assert(logger$
|
|
28757
|
+
assert(logger$3z, old.isSimple(), "invalid range type");
|
|
28758
28758
|
const block = editor.getBlockById(old.blockId);
|
|
28759
28759
|
if (old.offset === 0 || !isTextKindBlock(editor, block)) {
|
|
28760
28760
|
const newPos2 = createSimpleBlockPosition(block, 0, "home");
|
|
@@ -28771,7 +28771,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28771
28771
|
}
|
|
28772
28772
|
function editorGetLineEndPos(editor) {
|
|
28773
28773
|
const old = editor.selection.range.focus;
|
|
28774
|
-
assert(logger$
|
|
28774
|
+
assert(logger$3z, old.isSimple(), "invalid range type");
|
|
28775
28775
|
const block = editor.getBlockById(old.blockId);
|
|
28776
28776
|
if (old.offset === getBlockTextLength$6(editor, block) || !isTextKindBlock(editor, block)) {
|
|
28777
28777
|
const newPos2 = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
|
|
@@ -28871,7 +28871,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28871
28871
|
editorPageDownScroll(editor);
|
|
28872
28872
|
return true;
|
|
28873
28873
|
}
|
|
28874
|
-
const logger$
|
|
28874
|
+
const logger$3y = getLogger("table-scroll");
|
|
28875
28875
|
class DomEventHandler {
|
|
28876
28876
|
constructor(editor, dom, name, handler, data2, options) {
|
|
28877
28877
|
__publicField(this, "handleEvent", (event) => {
|
|
@@ -28903,7 +28903,7 @@ var __publicField = (obj, key, value) => {
|
|
|
28903
28903
|
const existsHandlers = this.handlers.get(element);
|
|
28904
28904
|
if (existsHandlers) {
|
|
28905
28905
|
if (existsHandlers.find((handler) => handler.handler === eventHandler && handler.name === eventName)) {
|
|
28906
|
-
logger$
|
|
28906
|
+
logger$3y.warn(`event has already registered: ${eventName}`);
|
|
28907
28907
|
return;
|
|
28908
28908
|
}
|
|
28909
28909
|
existsHandlers.push(new DomEventHandler(this.editor, element, eventName, eventHandler, data2, options));
|
|
@@ -29013,7 +29013,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29013
29013
|
});
|
|
29014
29014
|
return true;
|
|
29015
29015
|
}
|
|
29016
|
-
const logger$
|
|
29016
|
+
const logger$3x = getLogger("select-all");
|
|
29017
29017
|
function isContainerSelectedAllChildBlocks(container, range) {
|
|
29018
29018
|
const firstBlock = getFirstChildBlock(container);
|
|
29019
29019
|
const lastBlock2 = getLastChildBlock(container);
|
|
@@ -29028,8 +29028,8 @@ var __publicField = (obj, key, value) => {
|
|
|
29028
29028
|
return range.start.blockId === blockId && range.start.childContainerId === getContainerId(first) && range.end.blockId === blockId && range.end.childContainerId === getContainerId(last);
|
|
29029
29029
|
}
|
|
29030
29030
|
function selectComplexBlock(editor, block) {
|
|
29031
|
-
assert(logger$
|
|
29032
|
-
assert(logger$
|
|
29031
|
+
assert(logger$3x, block, "no parent block");
|
|
29032
|
+
assert(logger$3x, isComplexKindBlock(editor, block), "not a complex block");
|
|
29033
29033
|
const containers = getComplexBlockClass(editor, block).getChildContainers(editor, block);
|
|
29034
29034
|
const first = containers[0];
|
|
29035
29035
|
const last = containers[containers.length - 1];
|
|
@@ -29065,13 +29065,13 @@ var __publicField = (obj, key, value) => {
|
|
|
29065
29065
|
selectParentContainer(editor, getFirstChildBlock(editor.rootContainer));
|
|
29066
29066
|
return false;
|
|
29067
29067
|
}
|
|
29068
|
-
assert(logger$
|
|
29068
|
+
assert(logger$3x, !range.isSimple(), "invalid range type");
|
|
29069
29069
|
if (isComplexBlockSelectedAllChildContainer(focusedBlock, range)) {
|
|
29070
29070
|
selectParentContainer(editor, focusedBlock);
|
|
29071
29071
|
return false;
|
|
29072
29072
|
}
|
|
29073
|
-
assert(logger$
|
|
29074
|
-
assert(logger$
|
|
29073
|
+
assert(logger$3x, focusedBlock, "no parent block");
|
|
29074
|
+
assert(logger$3x, isComplexKindBlock(editor, focusedBlock), "not a complex block");
|
|
29075
29075
|
selectComplexBlock(editor, focusedBlock);
|
|
29076
29076
|
return true;
|
|
29077
29077
|
}
|
|
@@ -29219,7 +29219,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29219
29219
|
}
|
|
29220
29220
|
return cloned;
|
|
29221
29221
|
}
|
|
29222
|
-
const logger$
|
|
29222
|
+
const logger$3w = getLogger("selected-block-to-doc");
|
|
29223
29223
|
function appendBlockChildren(editor, data2, doc2) {
|
|
29224
29224
|
if (!data2.children)
|
|
29225
29225
|
return;
|
|
@@ -29240,7 +29240,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29240
29240
|
if (isTextKindBlock(editor, selectedBlock.block)) {
|
|
29241
29241
|
const start = selectedBlock.start;
|
|
29242
29242
|
const end = selectedBlock.end;
|
|
29243
|
-
assert(logger$
|
|
29243
|
+
assert(logger$3w, data2.text, "no block text");
|
|
29244
29244
|
if (start.offset === end.offset) {
|
|
29245
29245
|
return {
|
|
29246
29246
|
blocks: {
|
|
@@ -29274,8 +29274,8 @@ var __publicField = (obj, key, value) => {
|
|
|
29274
29274
|
comments: {}
|
|
29275
29275
|
};
|
|
29276
29276
|
}
|
|
29277
|
-
assert(logger$
|
|
29278
|
-
assert(logger$
|
|
29277
|
+
assert(logger$3w, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
|
|
29278
|
+
assert(logger$3w, data2.children, "no children");
|
|
29279
29279
|
const ret = {
|
|
29280
29280
|
blocks: {
|
|
29281
29281
|
root: [
|
|
@@ -29293,9 +29293,9 @@ var __publicField = (obj, key, value) => {
|
|
|
29293
29293
|
const end = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
|
|
29294
29294
|
return selectedBlockToDoc(editor, { block, start, end });
|
|
29295
29295
|
}
|
|
29296
|
-
const logger$
|
|
29296
|
+
const logger$3v = getLogger("block-to-doc");
|
|
29297
29297
|
function blocksToDoc(editor, blocks) {
|
|
29298
|
-
assert(logger$
|
|
29298
|
+
assert(logger$3v, blocks.length > 0, "invalid params, no blocks");
|
|
29299
29299
|
const docs = blocks.map((b) => blockToDoc(editor, b));
|
|
29300
29300
|
return mergeDocs(docs);
|
|
29301
29301
|
}
|
|
@@ -29320,7 +29320,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29320
29320
|
const newDocs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s));
|
|
29321
29321
|
return mergeDocs(newDocs);
|
|
29322
29322
|
}
|
|
29323
|
-
const logger$
|
|
29323
|
+
const logger$3u = getLogger("ensure-block-visible");
|
|
29324
29324
|
function ensureBlockVisible(editor, block) {
|
|
29325
29325
|
var _a;
|
|
29326
29326
|
while (block) {
|
|
@@ -29330,16 +29330,16 @@ var __publicField = (obj, key, value) => {
|
|
|
29330
29330
|
return;
|
|
29331
29331
|
}
|
|
29332
29332
|
const parentComplexBlock = getParentBlock(container);
|
|
29333
|
-
assert(logger$
|
|
29333
|
+
assert(logger$3u, parentComplexBlock, "no parent block");
|
|
29334
29334
|
const parentComplexBlockClass = getBlockClass(editor, parentComplexBlock);
|
|
29335
29335
|
if (parentComplexBlockClass.isChildContainerVisible && !((_a = parentComplexBlockClass.isChildContainerVisible) == null ? void 0 : _a.call(parentComplexBlockClass, editor, parentComplexBlock, container))) {
|
|
29336
|
-
assert(logger$
|
|
29336
|
+
assert(logger$3u, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
|
|
29337
29337
|
parentComplexBlockClass.showChildContainer(editor, parentComplexBlock, container);
|
|
29338
29338
|
}
|
|
29339
29339
|
block = parentComplexBlock;
|
|
29340
29340
|
}
|
|
29341
29341
|
}
|
|
29342
|
-
const logger$
|
|
29342
|
+
const logger$3t = getLogger("editor-selection");
|
|
29343
29343
|
class EditorSelection {
|
|
29344
29344
|
constructor(editor) {
|
|
29345
29345
|
__publicField(this, "editor");
|
|
@@ -29352,7 +29352,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29352
29352
|
}
|
|
29353
29353
|
const range = this.range;
|
|
29354
29354
|
if (rangeInBlock(deletedBlock, range)) {
|
|
29355
|
-
logger$
|
|
29355
|
+
logger$3t.debug("adjust selection because remote deleted current block");
|
|
29356
29356
|
const newRange = moveSelectionBeforeDeleteBlock(editor, deletedBlock);
|
|
29357
29357
|
this.setRange(newRange, { noScroll: true, local: false });
|
|
29358
29358
|
}
|
|
@@ -29492,14 +29492,14 @@ var __publicField = (obj, key, value) => {
|
|
|
29492
29492
|
if (pos.isSimple()) {
|
|
29493
29493
|
const ok = pos.offset >= 0 && pos.offset <= getBlockTextLength$6(this.editor, block);
|
|
29494
29494
|
if (!ok) {
|
|
29495
|
-
assert(logger$
|
|
29495
|
+
assert(logger$3t, false, "invalid block position, out of range");
|
|
29496
29496
|
}
|
|
29497
29497
|
} else {
|
|
29498
29498
|
const childContainerId = pos.childContainerId;
|
|
29499
29499
|
const container = this.editor.getContainerById(childContainerId);
|
|
29500
29500
|
const ok = !!container;
|
|
29501
29501
|
if (!ok) {
|
|
29502
|
-
assert(logger$
|
|
29502
|
+
assert(logger$3t, false, "invalid complex block position, no container found");
|
|
29503
29503
|
}
|
|
29504
29504
|
}
|
|
29505
29505
|
}
|
|
@@ -29560,7 +29560,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29560
29560
|
let container = getParentContainer(block);
|
|
29561
29561
|
while (isChildContainer(container)) {
|
|
29562
29562
|
const parentBlock = getParentBlock(container);
|
|
29563
|
-
assert(logger$
|
|
29563
|
+
assert(logger$3t, parentBlock, "parent block not found");
|
|
29564
29564
|
addClass(parentBlock, "child-focused");
|
|
29565
29565
|
container = getParentContainer(parentBlock);
|
|
29566
29566
|
}
|
|
@@ -29678,15 +29678,15 @@ var __publicField = (obj, key, value) => {
|
|
|
29678
29678
|
editor.undoManager.redo();
|
|
29679
29679
|
return true;
|
|
29680
29680
|
}
|
|
29681
|
-
const logger$
|
|
29681
|
+
const logger$3s = getLogger("delete-text");
|
|
29682
29682
|
function editorDeleteText(editor, type, count, insertPos) {
|
|
29683
29683
|
const pos = insertPos != null ? insertPos : editor.selection.range.start;
|
|
29684
29684
|
if (!(pos instanceof EditorSimpleBlockPosition)) {
|
|
29685
|
-
assert(logger$
|
|
29685
|
+
assert(logger$3s, false, `invalid insert pos type: ${typeof pos}`);
|
|
29686
29686
|
}
|
|
29687
29687
|
const { blockId } = pos;
|
|
29688
29688
|
const block = editor.getBlockById(blockId);
|
|
29689
|
-
assert(logger$
|
|
29689
|
+
assert(logger$3s, isTextKindBlock(editor, block), "block is not a text kind block");
|
|
29690
29690
|
let { offset } = pos;
|
|
29691
29691
|
if (type === "backward") {
|
|
29692
29692
|
if (offset - count < 0) {
|
|
@@ -29716,7 +29716,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29716
29716
|
}
|
|
29717
29717
|
return false;
|
|
29718
29718
|
}
|
|
29719
|
-
const logger$
|
|
29719
|
+
const logger$3r = getLogger("handle-backspace");
|
|
29720
29720
|
function tryDeleteEmptyBlock(editor, block) {
|
|
29721
29721
|
if (!isEmptyTextBlock(editor, block)) {
|
|
29722
29722
|
return;
|
|
@@ -29756,7 +29756,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29756
29756
|
}
|
|
29757
29757
|
} else {
|
|
29758
29758
|
tryDeleteEmptyBlock(editor, block);
|
|
29759
|
-
assert(logger$
|
|
29759
|
+
assert(logger$3r, isEmbedBlock(prevBlock), "prev block is not embed block");
|
|
29760
29760
|
editor.selection.selectBlock(prevBlock, 1);
|
|
29761
29761
|
}
|
|
29762
29762
|
} else {
|
|
@@ -29790,7 +29790,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29790
29790
|
editor.deleteBlock(block);
|
|
29791
29791
|
}
|
|
29792
29792
|
}
|
|
29793
|
-
const logger$
|
|
29793
|
+
const logger$3q = getLogger("word-offset");
|
|
29794
29794
|
function handleEditorDelete(editor, event) {
|
|
29795
29795
|
if (!editor.selection.range.isCollapsed()) {
|
|
29796
29796
|
editor.clearSelectedContents();
|
|
@@ -29827,7 +29827,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29827
29827
|
}
|
|
29828
29828
|
function handleEditorDeleteLeftWord(editor, event) {
|
|
29829
29829
|
const old = editor.selection.range.focus;
|
|
29830
|
-
assert(logger$
|
|
29830
|
+
assert(logger$3q, old.isSimple(), "invalid range type");
|
|
29831
29831
|
const block = editor.getBlockById(old.blockId);
|
|
29832
29832
|
if (!isTextKindBlock(editor, block)) {
|
|
29833
29833
|
editor.deleteBlock(block);
|
|
@@ -29869,7 +29869,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29869
29869
|
}
|
|
29870
29870
|
function handleEditorDeleteRightWord(editor, event) {
|
|
29871
29871
|
const old = editor.selection.range.focus;
|
|
29872
|
-
assert(logger$
|
|
29872
|
+
assert(logger$3q, old.isSimple(), "invalid range type");
|
|
29873
29873
|
const block = editor.getBlockById(old.blockId);
|
|
29874
29874
|
if (!isTextKindBlock(editor, block)) {
|
|
29875
29875
|
editor.deleteBlock(block);
|
|
@@ -29910,7 +29910,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29910
29910
|
}
|
|
29911
29911
|
function handleEditorDeleteAfterWords(editor) {
|
|
29912
29912
|
const old = editor.selection.range.focus;
|
|
29913
|
-
assert(logger$
|
|
29913
|
+
assert(logger$3q, old.isSimple(), "invalid range type");
|
|
29914
29914
|
const block = editor.getBlockById(old.blockId);
|
|
29915
29915
|
if (!isTextKindBlock(editor, block)) {
|
|
29916
29916
|
editor.deleteBlock(block);
|
|
@@ -29923,7 +29923,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29923
29923
|
}
|
|
29924
29924
|
function handleEditorDeleteRightChar(editor) {
|
|
29925
29925
|
const old = editor.selection.range.focus;
|
|
29926
|
-
assert(logger$
|
|
29926
|
+
assert(logger$3q, old.isSimple(), "invalid range type");
|
|
29927
29927
|
const block = editor.getBlockById(old.blockId);
|
|
29928
29928
|
if (!isTextKindBlock(editor, block)) {
|
|
29929
29929
|
editor.deleteBlock(block);
|
|
@@ -29994,6 +29994,56 @@ var __publicField = (obj, key, value) => {
|
|
|
29994
29994
|
});
|
|
29995
29995
|
return true;
|
|
29996
29996
|
}
|
|
29997
|
+
const editorHooks = /* @__PURE__ */ new WeakMap();
|
|
29998
|
+
function registerDocResourceHook(editor, hook) {
|
|
29999
|
+
if (editor.destroyed) {
|
|
30000
|
+
throw new Error("Cannot register a document resource hook on a destroyed editor");
|
|
30001
|
+
}
|
|
30002
|
+
const registration = { hook, collect: hook.collect, rewrite: hook.rewrite };
|
|
30003
|
+
let hooks = editorHooks.get(editor);
|
|
30004
|
+
if (!hooks) {
|
|
30005
|
+
hooks = /* @__PURE__ */ new Set();
|
|
30006
|
+
editorHooks.set(editor, hooks);
|
|
30007
|
+
}
|
|
30008
|
+
const registrations = hooks;
|
|
30009
|
+
registrations.add(registration);
|
|
30010
|
+
return () => {
|
|
30011
|
+
if (!registrations.delete(registration)) {
|
|
30012
|
+
return;
|
|
30013
|
+
}
|
|
30014
|
+
if (registrations.size === 0 && editorHooks.get(editor) === registrations) {
|
|
30015
|
+
editorHooks.delete(editor);
|
|
30016
|
+
}
|
|
30017
|
+
};
|
|
30018
|
+
}
|
|
30019
|
+
function collectDocResourceHooks(editor, doc2, resources) {
|
|
30020
|
+
const hooks = editorHooks.get(editor);
|
|
30021
|
+
if (!hooks) {
|
|
30022
|
+
return;
|
|
30023
|
+
}
|
|
30024
|
+
for (const registration of hooks) {
|
|
30025
|
+
const ids = registration.collect.call(registration.hook, doc2);
|
|
30026
|
+
for (const id of ids) {
|
|
30027
|
+
resources.add(id);
|
|
30028
|
+
}
|
|
30029
|
+
}
|
|
30030
|
+
}
|
|
30031
|
+
function rewriteDocResourceHooks(editor, doc2, resources) {
|
|
30032
|
+
const hooks = editorHooks.get(editor);
|
|
30033
|
+
if (!hooks) {
|
|
30034
|
+
return;
|
|
30035
|
+
}
|
|
30036
|
+
for (const registration of hooks) {
|
|
30037
|
+
registration.rewrite.call(registration.hook, doc2, resources);
|
|
30038
|
+
}
|
|
30039
|
+
}
|
|
30040
|
+
function clearDocResourceHooks(editor) {
|
|
30041
|
+
const hooks = editorHooks.get(editor);
|
|
30042
|
+
if (hooks) {
|
|
30043
|
+
hooks.clear();
|
|
30044
|
+
editorHooks.delete(editor);
|
|
30045
|
+
}
|
|
30046
|
+
}
|
|
29997
30047
|
function defaultGetResourceFromBlock(editor, doc2, block, resources) {
|
|
29998
30048
|
if (block.type === "embed") {
|
|
29999
30049
|
const embedData = block.embedData;
|
|
@@ -30068,6 +30118,7 @@ var __publicField = (obj, key, value) => {
|
|
|
30068
30118
|
defaultGetResourceFromBlock(editor, doc2, block, resources);
|
|
30069
30119
|
}
|
|
30070
30120
|
});
|
|
30121
|
+
collectDocResourceHooks(editor, doc2, resources);
|
|
30071
30122
|
return Array.from(resources);
|
|
30072
30123
|
}
|
|
30073
30124
|
function injectDocToHtmlFragment(htmlFragment, doc2) {
|
|
@@ -30151,7 +30202,7 @@ var __publicField = (obj, key, value) => {
|
|
|
30151
30202
|
const doc2 = blockToDoc(editor, block);
|
|
30152
30203
|
editorCopyDoc(editor, doc2);
|
|
30153
30204
|
}
|
|
30154
|
-
const logger$
|
|
30205
|
+
const logger$3p = getLogger("input-handler-actions");
|
|
30155
30206
|
function editorHandleEnter(editor, event) {
|
|
30156
30207
|
if (editor.readonly || !editor.isWritable()) {
|
|
30157
30208
|
return false;
|
|
@@ -30233,7 +30284,7 @@ var __publicField = (obj, key, value) => {
|
|
|
30233
30284
|
toPlainText: true
|
|
30234
30285
|
});
|
|
30235
30286
|
}).catch((err) => {
|
|
30236
|
-
logger$
|
|
30287
|
+
logger$3p.error(err);
|
|
30237
30288
|
});
|
|
30238
30289
|
return true;
|
|
30239
30290
|
}
|
|
@@ -30440,6 +30491,7 @@ ${codeText}
|
|
|
30440
30491
|
defaultReplaceBlockResources(doc2, block, resources);
|
|
30441
30492
|
}
|
|
30442
30493
|
});
|
|
30494
|
+
rewriteDocResourceHooks(editor, doc2, resources);
|
|
30443
30495
|
}
|
|
30444
30496
|
async function addLocalResourcesToDoc(editor, resources) {
|
|
30445
30497
|
let localResources = resources.filter((res) => res.indexOf(":") === -1);
|
|
@@ -31078,14 +31130,14 @@ ${codeText}
|
|
|
31078
31130
|
editor.selection.updateSelection(null, { focusBlockChanged: true });
|
|
31079
31131
|
});
|
|
31080
31132
|
}
|
|
31081
|
-
const logger$
|
|
31133
|
+
const logger$3o = getLogger("transform-selection");
|
|
31082
31134
|
function transformSelection(editor, blockId, delta, local) {
|
|
31083
31135
|
const { range } = editor.selection;
|
|
31084
31136
|
const { anchor: anchor2, focus } = range;
|
|
31085
31137
|
if (anchor2.blockId !== blockId && focus.blockId !== blockId) {
|
|
31086
31138
|
return range;
|
|
31087
31139
|
}
|
|
31088
|
-
assert(logger$
|
|
31140
|
+
assert(logger$3o, anchor2.isSimple() && focus.isSimple(), "invalid text pos type");
|
|
31089
31141
|
let newAnchor = anchor2;
|
|
31090
31142
|
if (anchor2.blockId === blockId) {
|
|
31091
31143
|
const newOffset = RichText.transformCursor(anchor2.offset, delta, local);
|
|
@@ -31098,12 +31150,12 @@ ${codeText}
|
|
|
31098
31150
|
}
|
|
31099
31151
|
return createEditorSelectionRange(editor, { anchor: newAnchor, focus: newFocus });
|
|
31100
31152
|
}
|
|
31101
|
-
const logger$
|
|
31153
|
+
const logger$3n = getLogger("handle-block-text-changed");
|
|
31102
31154
|
function onBlockTextChanged(editor, containerId, blockIndex, actions2, local) {
|
|
31103
31155
|
const container = editor.getContainerById(containerId);
|
|
31104
31156
|
const block = getBlockByIndex(container, blockIndex);
|
|
31105
31157
|
const blockData = editor.doc.getBlockData(containerId, blockIndex);
|
|
31106
|
-
assert(logger$
|
|
31158
|
+
assert(logger$3n, blockData.text, "no block text");
|
|
31107
31159
|
getTextBlockClass(editor, block).setBlockText(editor, block, blockData.text);
|
|
31108
31160
|
if (!local) {
|
|
31109
31161
|
const newRange = transformSelection(editor, blockData.id, actions2, local);
|
|
@@ -31135,7 +31187,7 @@ ${codeText}
|
|
|
31135
31187
|
});
|
|
31136
31188
|
handleDeleteBlock$8(editor, block, local, { child: false });
|
|
31137
31189
|
}
|
|
31138
|
-
const logger$
|
|
31190
|
+
const logger$3m = getLogger("editor-doc");
|
|
31139
31191
|
class EditorDoc extends EventCallbacks {
|
|
31140
31192
|
constructor(editor, externalDoc, localEvents) {
|
|
31141
31193
|
super();
|
|
@@ -31206,14 +31258,14 @@ ${codeText}
|
|
|
31206
31258
|
}
|
|
31207
31259
|
verifyBlockWritable(containerId, blockIndex) {
|
|
31208
31260
|
const block = this.editor.getBlockByIndex(containerId, blockIndex);
|
|
31209
|
-
assert(logger$
|
|
31261
|
+
assert(logger$3m, this.editor.isBlockWritable(block), `block is not writable, ${containerId}, ${blockIndex}`);
|
|
31210
31262
|
}
|
|
31211
31263
|
localUpdateBlockText(containerId, blockIndex, actions2, options) {
|
|
31212
31264
|
const blockData = this.getBlockData(containerId, blockIndex);
|
|
31213
31265
|
if (isWikiMacroBlockLocked(this.editor, blockData))
|
|
31214
31266
|
throw new WikiMacroError({ code: "LOCK_CONFLICT" });
|
|
31215
31267
|
const oldText = blockData.text;
|
|
31216
|
-
assert(logger$
|
|
31268
|
+
assert(logger$3m, oldText, `no text, ${containerId}, ${blockIndex}`);
|
|
31217
31269
|
const newRange = transformSelection(this.editor, blockData.id, actions2, true);
|
|
31218
31270
|
const newText = RichText.apply(oldText, actions2);
|
|
31219
31271
|
this.localEvents.forEach((event) => event.onBeforeUpdateBlockText(containerId, blockData.id, oldText, newText, newRange.toDocRange()));
|
|
@@ -31231,7 +31283,7 @@ ${codeText}
|
|
|
31231
31283
|
const deletedKeys = Array.from(delta.delete).filter((key) => key !== "comments");
|
|
31232
31284
|
const insertedKeys = Object.keys(delta.insert).filter((key) => key !== "comments");
|
|
31233
31285
|
if (deletedKeys.length > 0 || insertedKeys.length > 0) {
|
|
31234
|
-
assert(logger$
|
|
31286
|
+
assert(logger$3m, false, `block is not writable, comment supported only, ${JSON.stringify(delta)}}`);
|
|
31235
31287
|
}
|
|
31236
31288
|
}
|
|
31237
31289
|
const oldData = cloneDeep__default.default(this.getBlockData(containerId, blockIndex));
|
|
@@ -31242,7 +31294,7 @@ ${codeText}
|
|
|
31242
31294
|
return ret;
|
|
31243
31295
|
}
|
|
31244
31296
|
localInsertBlock(containerId, blockIndex, data2, newRange, options) {
|
|
31245
|
-
assert(logger$
|
|
31297
|
+
assert(logger$3m, !this.editor.readonly, "editor is readonly");
|
|
31246
31298
|
if (isWikiMacroBlockLocked(this.editor, data2))
|
|
31247
31299
|
throw new WikiMacroError({ code: "LOCK_CONFLICT" });
|
|
31248
31300
|
this.localEvents.forEach((event) => event.onBeforeInsertBlock(containerId, blockIndex, data2, newRange));
|
|
@@ -31253,7 +31305,7 @@ ${codeText}
|
|
|
31253
31305
|
return ret;
|
|
31254
31306
|
}
|
|
31255
31307
|
localDeleteBlock(containerId, blockIndex, newRange) {
|
|
31256
|
-
assert(logger$
|
|
31308
|
+
assert(logger$3m, !this.editor.readonly, "editor is readonly");
|
|
31257
31309
|
this.verifyBlockWritable(containerId, blockIndex);
|
|
31258
31310
|
const blockData = cloneDeep__default.default(this.getBlockData(containerId, blockIndex));
|
|
31259
31311
|
this.localEvents.forEach((event) => event.onBeforeDeleteBlock(containerId, blockIndex, blockData, newRange));
|
|
@@ -31262,7 +31314,7 @@ ${codeText}
|
|
|
31262
31314
|
return ret;
|
|
31263
31315
|
}
|
|
31264
31316
|
localDeleteChildContainers(containerIds) {
|
|
31265
|
-
assert(logger$
|
|
31317
|
+
assert(logger$3m, !this.editor.readonly, "editor is readonly");
|
|
31266
31318
|
if (containerIds.some((containerId) => this.getContainerBlocks(containerId).some((block) => isWikiMacroBlockLocked(this.editor, block)))) {
|
|
31267
31319
|
throw new WikiMacroError({ code: "LOCK_CONFLICT" });
|
|
31268
31320
|
}
|
|
@@ -31273,7 +31325,7 @@ ${codeText}
|
|
|
31273
31325
|
return this.externalDoc.localDeleteChildContainers(containerIds);
|
|
31274
31326
|
}
|
|
31275
31327
|
localInsertChildContainers(containers) {
|
|
31276
|
-
assert(logger$
|
|
31328
|
+
assert(logger$3m, !this.editor.readonly, "editor is readonly");
|
|
31277
31329
|
if (containers.some((container) => container.blocks.some((block) => isWikiMacroBlockLocked(this.editor, block)))) {
|
|
31278
31330
|
throw new WikiMacroError({ code: "LOCK_CONFLICT" });
|
|
31279
31331
|
}
|
|
@@ -31284,7 +31336,7 @@ ${codeText}
|
|
|
31284
31336
|
this.externalDoc.localInsertChildContainers(data2);
|
|
31285
31337
|
}
|
|
31286
31338
|
onRequestReload(reason) {
|
|
31287
|
-
logger$
|
|
31339
|
+
logger$3m.debug(`reload doc: ${reason}`);
|
|
31288
31340
|
this.editor.reload();
|
|
31289
31341
|
this.callbacks.forEach((c) => {
|
|
31290
31342
|
var _a;
|
|
@@ -31399,7 +31451,7 @@ ${codeText}
|
|
|
31399
31451
|
}
|
|
31400
31452
|
reset(doc2) {
|
|
31401
31453
|
var _a;
|
|
31402
|
-
logger$
|
|
31454
|
+
logger$3m.log("reset doc");
|
|
31403
31455
|
(_a = this.unsubscribeMacroLocks) == null ? void 0 : _a.call(this);
|
|
31404
31456
|
clearWikiMacroLocks(this.editor);
|
|
31405
31457
|
this.externalDoc = doc2;
|
|
@@ -31409,7 +31461,7 @@ ${codeText}
|
|
|
31409
31461
|
this.subscribeMacroLocks();
|
|
31410
31462
|
}
|
|
31411
31463
|
}
|
|
31412
|
-
const logger$
|
|
31464
|
+
const logger$3l = getLogger("undo-action");
|
|
31413
31465
|
class Action {
|
|
31414
31466
|
constructor(editor, containerId, afterRange, batchActionId) {
|
|
31415
31467
|
__publicField(this, "beforeRange");
|
|
@@ -31431,18 +31483,18 @@ ${codeText}
|
|
|
31431
31483
|
return false;
|
|
31432
31484
|
}
|
|
31433
31485
|
combinable(other) {
|
|
31434
|
-
assert(logger$
|
|
31486
|
+
assert(logger$3l, other, "no other action");
|
|
31435
31487
|
return false;
|
|
31436
31488
|
}
|
|
31437
31489
|
combine(other) {
|
|
31438
|
-
assert(logger$
|
|
31490
|
+
assert(logger$3l, false, "no other");
|
|
31439
31491
|
}
|
|
31440
31492
|
getBatchActionId() {
|
|
31441
31493
|
return this.batchActionId;
|
|
31442
31494
|
}
|
|
31443
31495
|
setAfterRange(range) {
|
|
31444
31496
|
if (this.afterRange) {
|
|
31445
|
-
logger$
|
|
31497
|
+
logger$3l.warn("after range has already set");
|
|
31446
31498
|
}
|
|
31447
31499
|
this.afterRange = range;
|
|
31448
31500
|
}
|
|
@@ -31464,7 +31516,7 @@ ${codeText}
|
|
|
31464
31516
|
const containerId = blockData.children[i];
|
|
31465
31517
|
const container = doc2.blocks[containerId];
|
|
31466
31518
|
if (!container) {
|
|
31467
|
-
logger$
|
|
31519
|
+
logger$3l.warn(`container (${containerId}) not found, deleted by others?`);
|
|
31468
31520
|
return false;
|
|
31469
31521
|
}
|
|
31470
31522
|
}
|
|
@@ -31472,24 +31524,31 @@ ${codeText}
|
|
|
31472
31524
|
return true;
|
|
31473
31525
|
}
|
|
31474
31526
|
}
|
|
31475
|
-
|
|
31476
|
-
|
|
31527
|
+
const logger$3k = getLogger("async-undo-action");
|
|
31528
|
+
class AsyncAction extends Action {
|
|
31529
|
+
constructor(editor, operation) {
|
|
31477
31530
|
super(editor, "", editor.selection.range.toDocRange());
|
|
31478
|
-
__publicField(this, "
|
|
31479
|
-
this.
|
|
31531
|
+
__publicField(this, "operation");
|
|
31532
|
+
this.operation = operation;
|
|
31480
31533
|
}
|
|
31481
31534
|
apply(direction) {
|
|
31482
|
-
if (!this.
|
|
31483
|
-
return Promise.reject(new
|
|
31484
|
-
|
|
31485
|
-
return this.options[direction]();
|
|
31535
|
+
if (!this.operation)
|
|
31536
|
+
return Promise.reject(Object.assign(new Error("Async history action disposed"), { code: "SESSION_EXPIRED" }));
|
|
31537
|
+
return this.operation[direction]();
|
|
31486
31538
|
}
|
|
31487
31539
|
reportError(error2) {
|
|
31488
31540
|
var _a, _b;
|
|
31489
|
-
(_b = (_a = this.
|
|
31541
|
+
(_b = (_a = this.operation) == null ? void 0 : _a.onError) == null ? void 0 : _b.call(_a, error2);
|
|
31490
31542
|
}
|
|
31491
31543
|
dispose() {
|
|
31492
|
-
|
|
31544
|
+
var _a;
|
|
31545
|
+
const operation = this.operation;
|
|
31546
|
+
this.operation = null;
|
|
31547
|
+
try {
|
|
31548
|
+
(_a = operation == null ? void 0 : operation.onDiscard) == null ? void 0 : _a.call(operation);
|
|
31549
|
+
} catch {
|
|
31550
|
+
logger$3k.error("Async history discard callback failed");
|
|
31551
|
+
}
|
|
31493
31552
|
}
|
|
31494
31553
|
}
|
|
31495
31554
|
function addActions(actions2, action) {
|
|
@@ -31866,6 +31925,8 @@ ${codeText}
|
|
|
31866
31925
|
__publicField(this, "macroSessions", /* @__PURE__ */ new Set());
|
|
31867
31926
|
__publicField(this, "macroActionIds", /* @__PURE__ */ new Set());
|
|
31868
31927
|
__publicField(this, "pendingMacroAction", null);
|
|
31928
|
+
__publicField(this, "pendingAsyncPromise", null);
|
|
31929
|
+
__publicField(this, "undoLocks", /* @__PURE__ */ new Set());
|
|
31869
31930
|
__publicField(this, "macroGeneration", 0);
|
|
31870
31931
|
__publicField(this, "destroyed", false);
|
|
31871
31932
|
__publicField(this, "handleSelectionChange", (editor) => {
|
|
@@ -31890,11 +31951,43 @@ ${codeText}
|
|
|
31890
31951
|
}
|
|
31891
31952
|
if (this.macroActionIds.has(options.actionId))
|
|
31892
31953
|
return;
|
|
31893
|
-
this.
|
|
31954
|
+
this.addAsyncAction(options);
|
|
31894
31955
|
this.macroActionIds.add(options.actionId);
|
|
31895
|
-
|
|
31956
|
+
}
|
|
31957
|
+
addAsyncAction(operation) {
|
|
31958
|
+
if (this.destroyed)
|
|
31959
|
+
throw new Error("Editor destroyed");
|
|
31960
|
+
if (this.currentGroup)
|
|
31961
|
+
throw new Error("Async actions require an independent undo boundary");
|
|
31962
|
+
this.prepareSaveUndoState();
|
|
31963
|
+
const action = new AsyncAction(this.editor, operation);
|
|
31896
31964
|
this.actions.push(action);
|
|
31897
|
-
|
|
31965
|
+
try {
|
|
31966
|
+
this.editor.input.handleChanged(action);
|
|
31967
|
+
} catch {
|
|
31968
|
+
logger$3f.error("Async history change observer failed");
|
|
31969
|
+
}
|
|
31970
|
+
}
|
|
31971
|
+
acquireUndoLock() {
|
|
31972
|
+
const lock = Symbol("pending-undo-session");
|
|
31973
|
+
this.undoLocks.add(lock);
|
|
31974
|
+
return () => {
|
|
31975
|
+
this.undoLocks.delete(lock);
|
|
31976
|
+
};
|
|
31977
|
+
}
|
|
31978
|
+
async undoAsync() {
|
|
31979
|
+
var _a;
|
|
31980
|
+
if (this.pendingMacroAction)
|
|
31981
|
+
return false;
|
|
31982
|
+
const accepted = this.undo();
|
|
31983
|
+
return (_a = this.pendingAsyncPromise) != null ? _a : accepted;
|
|
31984
|
+
}
|
|
31985
|
+
async redoAsync() {
|
|
31986
|
+
var _a;
|
|
31987
|
+
if (this.pendingMacroAction)
|
|
31988
|
+
return false;
|
|
31989
|
+
const accepted = this.redo();
|
|
31990
|
+
return (_a = this.pendingAsyncPromise) != null ? _a : accepted;
|
|
31898
31991
|
}
|
|
31899
31992
|
setMacroEditSessionActive(sessionId, active) {
|
|
31900
31993
|
if (this.destroyed)
|
|
@@ -31910,6 +32003,7 @@ ${codeText}
|
|
|
31910
32003
|
this.destroyed = true;
|
|
31911
32004
|
this.reset();
|
|
31912
32005
|
this.macroSessions.clear();
|
|
32006
|
+
this.undoLocks.clear();
|
|
31913
32007
|
this.editor.removeListener("selectionChanged", this.handleSelectionChange);
|
|
31914
32008
|
}
|
|
31915
32009
|
applyMacroAction(action, direction) {
|
|
@@ -31917,13 +32011,13 @@ ${codeText}
|
|
|
31917
32011
|
const cursor = this.undoCursor;
|
|
31918
32012
|
const historyLength = this.actions.length;
|
|
31919
32013
|
this.pendingMacroAction = action;
|
|
31920
|
-
Promise.resolve().then(() => action.apply(direction)).then(() => {
|
|
32014
|
+
this.pendingAsyncPromise = Promise.resolve().then(() => action.apply(direction)).then(() => {
|
|
31921
32015
|
if (generation !== this.macroGeneration || this.destroyed)
|
|
31922
|
-
return;
|
|
32016
|
+
return false;
|
|
31923
32017
|
const index2 = this.actions.indexOf(action);
|
|
31924
32018
|
if (direction === "undo") {
|
|
31925
32019
|
if (index2 < 0)
|
|
31926
|
-
return;
|
|
32020
|
+
return false;
|
|
31927
32021
|
if (this.undoCursor === cursor && this.actions.length === historyLength) {
|
|
31928
32022
|
this.undoCursor = index2;
|
|
31929
32023
|
} else {
|
|
@@ -31944,18 +32038,21 @@ ${codeText}
|
|
|
31944
32038
|
} catch (error2) {
|
|
31945
32039
|
logger$3f.error("Macro history change observer failed");
|
|
31946
32040
|
}
|
|
32041
|
+
return true;
|
|
31947
32042
|
}).catch((error2) => {
|
|
31948
32043
|
if (generation !== this.macroGeneration || this.destroyed)
|
|
31949
|
-
return;
|
|
32044
|
+
return false;
|
|
31950
32045
|
const failure = error2 instanceof Error ? error2 : new Error("Macro history action failed");
|
|
31951
32046
|
try {
|
|
31952
32047
|
action.reportError(failure);
|
|
31953
32048
|
} catch (callbackError) {
|
|
31954
32049
|
logger$3f.error("Macro history error callback failed");
|
|
31955
32050
|
}
|
|
32051
|
+
return false;
|
|
31956
32052
|
}).finally(() => {
|
|
31957
32053
|
if (generation === this.macroGeneration) {
|
|
31958
32054
|
this.pendingMacroAction = null;
|
|
32055
|
+
this.pendingAsyncPromise = null;
|
|
31959
32056
|
if (!this.actions.includes(action))
|
|
31960
32057
|
action.dispose();
|
|
31961
32058
|
}
|
|
@@ -31967,8 +32064,9 @@ ${codeText}
|
|
|
31967
32064
|
this.macroGeneration += 1;
|
|
31968
32065
|
(_a = this.pendingMacroAction) == null ? void 0 : _a.dispose();
|
|
31969
32066
|
this.pendingMacroAction = null;
|
|
32067
|
+
this.pendingAsyncPromise = null;
|
|
31970
32068
|
this.actions.forEach((action) => {
|
|
31971
|
-
if (action instanceof
|
|
32069
|
+
if (action instanceof AsyncAction)
|
|
31972
32070
|
action.dispose();
|
|
31973
32071
|
});
|
|
31974
32072
|
this.macroActionIds.clear();
|
|
@@ -31979,7 +32077,7 @@ ${codeText}
|
|
|
31979
32077
|
if (this.undoCursor !== -1) {
|
|
31980
32078
|
const removed = this.actions.splice(this.undoCursor);
|
|
31981
32079
|
removed.forEach((action) => {
|
|
31982
|
-
if (action instanceof
|
|
32080
|
+
if (action instanceof AsyncAction && action !== this.pendingMacroAction)
|
|
31983
32081
|
action.dispose();
|
|
31984
32082
|
});
|
|
31985
32083
|
this.undoCursor = -1;
|
|
@@ -32063,10 +32161,10 @@ ${codeText}
|
|
|
32063
32161
|
}
|
|
32064
32162
|
}
|
|
32065
32163
|
undo() {
|
|
32066
|
-
if (this.destroyed || this.macroSessions.size > 0 || this.pendingMacroAction)
|
|
32164
|
+
if (this.destroyed || this.macroSessions.size > 0 || this.undoLocks.size > 0 || this.pendingMacroAction)
|
|
32067
32165
|
return false;
|
|
32068
32166
|
const candidate = this.actions[(this.undoCursor === -1 ? this.actions.length : this.undoCursor) - 1];
|
|
32069
|
-
if (candidate instanceof
|
|
32167
|
+
if (candidate instanceof AsyncAction)
|
|
32070
32168
|
return this.applyMacroAction(candidate, "undo");
|
|
32071
32169
|
if (this.undoCursor === -1) {
|
|
32072
32170
|
this.undoCursor = this.actions.length;
|
|
@@ -32075,7 +32173,7 @@ ${codeText}
|
|
|
32075
32173
|
this.undoRedoing = true;
|
|
32076
32174
|
while (this.undoCursor > 0) {
|
|
32077
32175
|
const action = this.actions[this.undoCursor - 1];
|
|
32078
|
-
if (action instanceof
|
|
32176
|
+
if (action instanceof AsyncAction) {
|
|
32079
32177
|
return this.applyMacroAction(action, "undo");
|
|
32080
32178
|
}
|
|
32081
32179
|
this.undoCursor -= 1;
|
|
@@ -32104,10 +32202,10 @@ ${codeText}
|
|
|
32104
32202
|
}
|
|
32105
32203
|
}
|
|
32106
32204
|
redo() {
|
|
32107
|
-
if (this.destroyed || this.macroSessions.size > 0 || this.pendingMacroAction)
|
|
32205
|
+
if (this.destroyed || this.macroSessions.size > 0 || this.undoLocks.size > 0 || this.pendingMacroAction)
|
|
32108
32206
|
return false;
|
|
32109
32207
|
const candidate = this.actions[this.undoCursor];
|
|
32110
|
-
if (candidate instanceof
|
|
32208
|
+
if (candidate instanceof AsyncAction)
|
|
32111
32209
|
return this.applyMacroAction(candidate, "redo");
|
|
32112
32210
|
if (this.undoCursor === -1) {
|
|
32113
32211
|
this.undoCursor = this.actions.length;
|
|
@@ -32116,7 +32214,7 @@ ${codeText}
|
|
|
32116
32214
|
this.undoRedoing = true;
|
|
32117
32215
|
while (this.undoCursor < this.actions.length) {
|
|
32118
32216
|
const action = this.actions[this.undoCursor];
|
|
32119
|
-
if (action instanceof
|
|
32217
|
+
if (action instanceof AsyncAction) {
|
|
32120
32218
|
return this.applyMacroAction(action, "redo");
|
|
32121
32219
|
}
|
|
32122
32220
|
this.undoCursor += 1;
|
|
@@ -32147,7 +32245,7 @@ ${codeText}
|
|
|
32147
32245
|
}
|
|
32148
32246
|
}
|
|
32149
32247
|
canUndo() {
|
|
32150
|
-
if (this.destroyed || this.macroSessions.size > 0 || this.pendingMacroAction)
|
|
32248
|
+
if (this.destroyed || this.macroSessions.size > 0 || this.undoLocks.size > 0 || this.pendingMacroAction)
|
|
32151
32249
|
return false;
|
|
32152
32250
|
if (this.actions.length === 0) {
|
|
32153
32251
|
return false;
|
|
@@ -32158,7 +32256,7 @@ ${codeText}
|
|
|
32158
32256
|
return true;
|
|
32159
32257
|
}
|
|
32160
32258
|
canRedo() {
|
|
32161
|
-
if (this.destroyed || this.macroSessions.size > 0 || this.pendingMacroAction)
|
|
32259
|
+
if (this.destroyed || this.macroSessions.size > 0 || this.undoLocks.size > 0 || this.pendingMacroAction)
|
|
32162
32260
|
return false;
|
|
32163
32261
|
if (this.actions.length === 0) {
|
|
32164
32262
|
return false;
|
|
@@ -32185,7 +32283,7 @@ ${codeText}
|
|
|
32185
32283
|
if (lastAction === action) {
|
|
32186
32284
|
return true;
|
|
32187
32285
|
}
|
|
32188
|
-
if (this.pendingMacroAction || lastAction instanceof
|
|
32286
|
+
if (this.pendingMacroAction || lastAction instanceof AsyncAction) {
|
|
32189
32287
|
this.undo();
|
|
32190
32288
|
return false;
|
|
32191
32289
|
}
|
|
@@ -32725,35 +32823,6 @@ ${codeText}
|
|
|
32725
32823
|
return void 0;
|
|
32726
32824
|
}
|
|
32727
32825
|
}
|
|
32728
|
-
const editorHooks = /* @__PURE__ */ new WeakMap();
|
|
32729
|
-
function registerDocResourceHook(editor, hook) {
|
|
32730
|
-
if (editor.destroyed) {
|
|
32731
|
-
throw new Error("Cannot register a document resource hook on a destroyed editor");
|
|
32732
|
-
}
|
|
32733
|
-
const registration = { hook, collect: hook.collect, rewrite: hook.rewrite };
|
|
32734
|
-
let hooks = editorHooks.get(editor);
|
|
32735
|
-
if (!hooks) {
|
|
32736
|
-
hooks = /* @__PURE__ */ new Set();
|
|
32737
|
-
editorHooks.set(editor, hooks);
|
|
32738
|
-
}
|
|
32739
|
-
const registrations = hooks;
|
|
32740
|
-
registrations.add(registration);
|
|
32741
|
-
return () => {
|
|
32742
|
-
if (!registrations.delete(registration)) {
|
|
32743
|
-
return;
|
|
32744
|
-
}
|
|
32745
|
-
if (registrations.size === 0 && editorHooks.get(editor) === registrations) {
|
|
32746
|
-
editorHooks.delete(editor);
|
|
32747
|
-
}
|
|
32748
|
-
};
|
|
32749
|
-
}
|
|
32750
|
-
function clearDocResourceHooks(editor) {
|
|
32751
|
-
const hooks = editorHooks.get(editor);
|
|
32752
|
-
if (hooks) {
|
|
32753
|
-
hooks.clear();
|
|
32754
|
-
editorHooks.delete(editor);
|
|
32755
|
-
}
|
|
32756
|
-
}
|
|
32757
32826
|
const logger$3b = getLogger("editor");
|
|
32758
32827
|
class Editor extends tinyTypedEmitter.TypedEmitter {
|
|
32759
32828
|
constructor(parent, doc2, optionalOptions) {
|
|
@@ -98420,7 +98489,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98420
98489
|
}
|
|
98421
98490
|
}
|
|
98422
98491
|
});
|
|
98423
|
-
editor.version = "5.0.6-beta.DNP8216.
|
|
98492
|
+
editor.version = "5.0.6-beta.DNP8216.3";
|
|
98424
98493
|
return editor;
|
|
98425
98494
|
}
|
|
98426
98495
|
function isDoc(doc2) {
|
|
@@ -98556,7 +98625,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98556
98625
|
OnesEditorDropTarget.register(editor);
|
|
98557
98626
|
OnesEditorTocProvider.register(editor);
|
|
98558
98627
|
OnesEditorExclusiveBlock.register(editor);
|
|
98559
|
-
editor.version = "5.0.6-beta.DNP8216.
|
|
98628
|
+
editor.version = "5.0.6-beta.DNP8216.3";
|
|
98560
98629
|
return editor;
|
|
98561
98630
|
} catch (error2) {
|
|
98562
98631
|
try {
|
|
@@ -98699,7 +98768,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98699
98768
|
}
|
|
98700
98769
|
}
|
|
98701
98770
|
});
|
|
98702
|
-
editor.version = "5.0.6-beta.DNP8216.
|
|
98771
|
+
editor.version = "5.0.6-beta.DNP8216.3";
|
|
98703
98772
|
return editor;
|
|
98704
98773
|
}
|
|
98705
98774
|
const emojis$1 = {
|
|
@@ -145180,7 +145249,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
145180
145249
|
exports2.loadJs = loadJs;
|
|
145181
145250
|
exports2.loadJsPromise = loadJsPromise;
|
|
145182
145251
|
exports2.lockers = lockers;
|
|
145183
|
-
exports2.logger = logger$
|
|
145252
|
+
exports2.logger = logger$4w;
|
|
145184
145253
|
exports2.markdownToDoc = markdownToDoc;
|
|
145185
145254
|
exports2.mergeCommands = mergeCommands;
|
|
145186
145255
|
exports2.mergeDocs = mergeDocs;
|