@ones-editor/editor 5.0.4-beta.h1449.3 → 5.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9334,7 +9334,7 @@ var __publicField = (obj, key, value) => {
9334
9334
  imageExportFailed: "Bild konnte nicht geladen werden"
9335
9335
  }
9336
9336
  };
9337
- const logger$4W = getLogger("i18n");
9337
+ const logger$4X = getLogger("i18n");
9338
9338
  const langs$3 = {
9339
9339
  "en-US": enUS$y,
9340
9340
  "zh-CN": zhCN$y,
@@ -9356,7 +9356,7 @@ var __publicField = (obj, key, value) => {
9356
9356
  function t$8(key, args) {
9357
9357
  const ret = i18n.get(key, args);
9358
9358
  if (ret === key) {
9359
- logger$4W.warn(`no locale value for key ${key}`);
9359
+ logger$4X.warn(`no locale value for key ${key}`);
9360
9360
  }
9361
9361
  return ret;
9362
9362
  }
@@ -9974,7 +9974,7 @@ var __publicField = (obj, key, value) => {
9974
9974
  this._callbacks.clear();
9975
9975
  }
9976
9976
  }
9977
- const logger$4V = getLogger("await-locker");
9977
+ const logger$4W = getLogger("await-locker");
9978
9978
  class AwaitLock {
9979
9979
  constructor() {
9980
9980
  __publicField(this, "_acquired", false);
@@ -10016,7 +10016,7 @@ var __publicField = (obj, key, value) => {
10016
10016
  }
10017
10017
  if (this._waitingResolvers.length > 0) {
10018
10018
  const resolve = this._waitingResolvers.shift();
10019
- assert(logger$4V, resolve, "Resolver missing");
10019
+ assert(logger$4W, resolve, "Resolver missing");
10020
10020
  resolve(void 0);
10021
10021
  } else {
10022
10022
  this._acquired = false;
@@ -10099,7 +10099,7 @@ var __publicField = (obj, key, value) => {
10099
10099
  isMobileSafari: false
10100
10100
  };
10101
10101
  clientType.isMobileSafari = clientType.isMobile && clientType.isSafari;
10102
- const logger$4U = getLogger("dom-utils");
10102
+ const logger$4V = getLogger("dom-utils");
10103
10103
  function addClass(dom, ...className) {
10104
10104
  if (dom && dom.nodeType === Node.ELEMENT_NODE) {
10105
10105
  dom.classList.add(...className);
@@ -10156,7 +10156,7 @@ var __publicField = (obj, key, value) => {
10156
10156
  range.setStart(node, offset);
10157
10157
  return range;
10158
10158
  } catch (err) {
10159
- assert(logger$4U, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
10159
+ assert(logger$4V, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
10160
10160
  }
10161
10161
  }
10162
10162
  function createExpandedRange(startNode, startOffset, endNode, endOffset) {
@@ -10166,17 +10166,17 @@ var __publicField = (obj, key, value) => {
10166
10166
  range.setEnd(endNode, endOffset);
10167
10167
  return range;
10168
10168
  } catch (err) {
10169
- assert(logger$4U, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
10169
+ assert(logger$4V, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
10170
10170
  }
10171
10171
  }
10172
10172
  function getFirstClientRect(elem) {
10173
10173
  const rects = elem.getClientRects();
10174
- assert(logger$4U, rects.length >= 1, "getFirstClientRect: no rects");
10174
+ assert(logger$4V, rects.length >= 1, "getFirstClientRect: no rects");
10175
10175
  return rects[0];
10176
10176
  }
10177
10177
  function getLastClientRect(elem) {
10178
10178
  const rects = elem.getClientRects();
10179
- assert(logger$4U, rects.length >= 1, "getLastClientRect: no rects");
10179
+ assert(logger$4V, rects.length >= 1, "getLastClientRect: no rects");
10180
10180
  return rects[rects.length - 1];
10181
10181
  }
10182
10182
  function getDistanceSquare(rect, x, y) {
@@ -10223,7 +10223,7 @@ var __publicField = (obj, key, value) => {
10223
10223
  return 0;
10224
10224
  }
10225
10225
  if (!elem1.parentElement || !elem2.parentElement) {
10226
- assert(logger$4U, false, "invalid dom node to compare");
10226
+ assert(logger$4V, false, "invalid dom node to compare");
10227
10227
  }
10228
10228
  if (elem1.parentElement === elem2.parentElement) {
10229
10229
  const children = Array.from(elem1.parentElement.children);
@@ -10240,7 +10240,7 @@ var __publicField = (obj, key, value) => {
10240
10240
  const parents1 = getParents(elem1);
10241
10241
  const parents2 = getParents(elem2);
10242
10242
  if (parents1[0] !== parents2[0]) {
10243
- assert(logger$4U, false, "invalid dom node to compare, different tree");
10243
+ assert(logger$4V, false, "invalid dom node to compare, different tree");
10244
10244
  }
10245
10245
  for (let i = 1; ; i++) {
10246
10246
  const parent1 = parents1[i];
@@ -10840,7 +10840,7 @@ var __publicField = (obj, key, value) => {
10840
10840
  }
10841
10841
  }
10842
10842
  const MIN_DISTANCE_THRESHOLD$3 = 3;
10843
- const logger$4T = getLogger("drag-drop");
10843
+ const logger$4U = getLogger("drag-drop");
10844
10844
  class DragDrop {
10845
10845
  constructor(options) {
10846
10846
  __publicField(this, "dragStarted", false);
@@ -10861,7 +10861,7 @@ var __publicField = (obj, key, value) => {
10861
10861
  var _a;
10862
10862
  event.preventDefault();
10863
10863
  event.stopPropagation();
10864
- assert(logger$4T, this.mouseDownEvent, "no mouse down event");
10864
+ assert(logger$4U, this.mouseDownEvent, "no mouse down event");
10865
10865
  const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
10866
10866
  const newPos = DragDrop.getEventPosition(event);
10867
10867
  const deltaX = newPos.x - oldPos.x;
@@ -10877,7 +10877,7 @@ var __publicField = (obj, key, value) => {
10877
10877
  });
10878
10878
  __publicField(this, "handleMouseUp", (event) => {
10879
10879
  if (event instanceof MouseEvent && event.button === 0 || event instanceof TouchEvent) {
10880
- assert(logger$4T, this.mouseDownEvent, "no mouse down event");
10880
+ assert(logger$4U, this.mouseDownEvent, "no mouse down event");
10881
10881
  const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
10882
10882
  const newPos = DragDrop.getEventPosition(event);
10883
10883
  const deltaX = newPos.x - oldPos.x;
@@ -10986,7 +10986,7 @@ var __publicField = (obj, key, value) => {
10986
10986
  const dragDrop = new DragDrop(options);
10987
10987
  return dragDrop;
10988
10988
  }
10989
- const logger$4S = getLogger("character");
10989
+ const logger$4T = getLogger("character");
10990
10990
  function checkChar(charCode, rangeList) {
10991
10991
  for (let i = 0; i < rangeList.length; i++) {
10992
10992
  const start = rangeList[i][0];
@@ -11037,7 +11037,7 @@ var __publicField = (obj, key, value) => {
11037
11037
  }
11038
11038
  function trimChar(s, char) {
11039
11039
  let c = char;
11040
- assert(logger$4S, c.length === 1, "invalid char length");
11040
+ assert(logger$4T, c.length === 1, "invalid char length");
11041
11041
  if (c === "]")
11042
11042
  c = "\\]";
11043
11043
  if (c === "\\")
@@ -11395,7 +11395,7 @@ var __publicField = (obj, key, value) => {
11395
11395
  return 200;
11396
11396
  }
11397
11397
  }
11398
- const logger$4R = getLogger("editor-clipboard");
11398
+ const logger$4S = getLogger("editor-clipboard");
11399
11399
  async function setClipboardDataByEvent(items, event) {
11400
11400
  if (event.clipboardData) {
11401
11401
  const data2 = event.clipboardData;
@@ -11453,7 +11453,7 @@ var __publicField = (obj, key, value) => {
11453
11453
  document.body.removeChild(textarea2);
11454
11454
  return true;
11455
11455
  } catch (ex) {
11456
- logger$4R.error(ex);
11456
+ logger$4S.error(ex);
11457
11457
  document.body.removeChild(textarea2);
11458
11458
  return false;
11459
11459
  }
@@ -11474,7 +11474,7 @@ var __publicField = (obj, key, value) => {
11474
11474
  document.body.removeChild(div);
11475
11475
  return true;
11476
11476
  } catch (ex) {
11477
- logger$4R.error(ex);
11477
+ logger$4S.error(ex);
11478
11478
  document.body.removeChild(div);
11479
11479
  return false;
11480
11480
  }
@@ -11501,7 +11501,7 @@ var __publicField = (obj, key, value) => {
11501
11501
  await navigator.clipboard.write([clipboardItems]);
11502
11502
  return true;
11503
11503
  } catch (err) {
11504
- logger$4R.error(err);
11504
+ logger$4S.error(err);
11505
11505
  return await execCommandCopy(items);
11506
11506
  }
11507
11507
  }
@@ -11557,7 +11557,7 @@ var __publicField = (obj, key, value) => {
11557
11557
  a.click();
11558
11558
  a.remove();
11559
11559
  }
11560
- const logger$4Q = getLogger("auto-scroll");
11560
+ const logger$4R = getLogger("auto-scroll");
11561
11561
  function scrollable(scrollElement, direction) {
11562
11562
  if (scrollElement.scrollHeight === scrollElement.clientHeight) {
11563
11563
  return false;
@@ -11581,7 +11581,7 @@ var __publicField = (obj, key, value) => {
11581
11581
  const isHorizontal = direction === "left" || direction === "right";
11582
11582
  const scroll = () => {
11583
11583
  if (!scrollable(scrollElement, direction)) {
11584
- logger$4Q.debug("No need for scroll");
11584
+ logger$4R.debug("No need for scroll");
11585
11585
  return null;
11586
11586
  }
11587
11587
  if (isHorizontal) {
@@ -11638,7 +11638,7 @@ var __publicField = (obj, key, value) => {
11638
11638
  if (this.scrolling) {
11639
11639
  return;
11640
11640
  }
11641
- logger$4Q.debug(`scroll direction: ${direction}`);
11641
+ logger$4R.debug(`scroll direction: ${direction}`);
11642
11642
  this.cancelScroll = continuousScroll(scrollElement, {
11643
11643
  direction,
11644
11644
  step
@@ -11888,7 +11888,7 @@ var __publicField = (obj, key, value) => {
11888
11888
  const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
11889
11889
  return ColorNames[colorIndex];
11890
11890
  }
11891
- const logger$4P = getLogger("container");
11891
+ const logger$4Q = getLogger("container");
11892
11892
  function isContainer(elem) {
11893
11893
  return elem.getAttribute("data-type") === "editor-container";
11894
11894
  }
@@ -11900,9 +11900,9 @@ var __publicField = (obj, key, value) => {
11900
11900
  }
11901
11901
  function getContainerId(container) {
11902
11902
  const id = container.getAttribute("data-container-id");
11903
- assert(logger$4P, id, "no id for container");
11903
+ assert(logger$4Q, id, "no id for container");
11904
11904
  if (isRootContainer(container)) {
11905
- assert(logger$4P, id === "root", `invalid root container id, : ${id}`);
11905
+ assert(logger$4Q, id === "root", `invalid root container id, : ${id}`);
11906
11906
  }
11907
11907
  return id;
11908
11908
  }
@@ -11913,7 +11913,7 @@ var __publicField = (obj, key, value) => {
11913
11913
  function generateEditorContainerId(containerId) {
11914
11914
  return `ones-editor-container-${containerId}`;
11915
11915
  }
11916
- const logger$4O = getLogger("element");
11916
+ const logger$4P = getLogger("element");
11917
11917
  function createContainerElement(parent, type, containerId) {
11918
11918
  const container = createElement("div", [type], parent);
11919
11919
  container.setAttribute("data-type", "editor-container");
@@ -11924,7 +11924,7 @@ var __publicField = (obj, key, value) => {
11924
11924
  }
11925
11925
  function getContainerById(editor, containerId) {
11926
11926
  const container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
11927
- assert(logger$4O, container, `no container: ${containerId}`);
11927
+ assert(logger$4P, container, `no container: ${containerId}`);
11928
11928
  return container;
11929
11929
  }
11930
11930
  function getExistsContainerById(editor, containerId) {
@@ -11933,7 +11933,7 @@ var __publicField = (obj, key, value) => {
11933
11933
  }
11934
11934
  function getContainerBlocksElement(container) {
11935
11935
  const blocks = container.querySelector(":scope > .container-blocks");
11936
- assert(logger$4O, blocks, "no container blocks element");
11936
+ assert(logger$4P, blocks, "no container blocks element");
11937
11937
  return blocks;
11938
11938
  }
11939
11939
  function getContainerToolsElement(container) {
@@ -11946,11 +11946,11 @@ var __publicField = (obj, key, value) => {
11946
11946
  function isContainerBlocksElement(element) {
11947
11947
  return element.classList.contains("container-blocks");
11948
11948
  }
11949
- const logger$4N = getLogger("container-children");
11949
+ const logger$4O = getLogger("container-children");
11950
11950
  function getChildBlocks(container, traverseChild) {
11951
11951
  const content = getContainerBlocksElement(container);
11952
11952
  const blocks = Array.from(content.children);
11953
- assert(logger$4N, blocks.length > 0, "container have not any child block");
11953
+ assert(logger$4O, blocks.length > 0, "container have not any child block");
11954
11954
  if (traverseChild) {
11955
11955
  const { condition, editor } = traverseChild;
11956
11956
  return blocks.reduce((result, block) => {
@@ -11973,7 +11973,7 @@ var __publicField = (obj, key, value) => {
11973
11973
  }
11974
11974
  function getFirstChildBlock(container) {
11975
11975
  const block = container.querySelector(":scope > .container-blocks > div[data-type=editor-block]");
11976
- assert(logger$4N, block, "container have not any child block");
11976
+ assert(logger$4O, block, "container have not any child block");
11977
11977
  return block;
11978
11978
  }
11979
11979
  function getLastChildBlock(container) {
@@ -11985,14 +11985,14 @@ var __publicField = (obj, key, value) => {
11985
11985
  }
11986
11986
  function getBlockByIndex(container, blockIndex) {
11987
11987
  const block = getChildBlocks(container)[blockIndex];
11988
- assert(logger$4N, block, `container have not block at index ${blockIndex}`);
11988
+ assert(logger$4O, block, `container have not block at index ${blockIndex}`);
11989
11989
  return block;
11990
11990
  }
11991
11991
  function findBlockByIndex(container, blockIndex) {
11992
11992
  var _a;
11993
11993
  return (_a = getChildBlocks(container)[blockIndex]) != null ? _a : null;
11994
11994
  }
11995
- const logger$4M = getLogger("block-dom");
11995
+ const logger$4N = getLogger("block-dom");
11996
11996
  function isBlock$1(node) {
11997
11997
  if (!(node instanceof HTMLDivElement)) {
11998
11998
  return false;
@@ -12013,12 +12013,12 @@ var __publicField = (obj, key, value) => {
12013
12013
  }
12014
12014
  function getBlockId(block) {
12015
12015
  const { id } = block;
12016
- assert(logger$4M, id, "no block id");
12016
+ assert(logger$4N, id, "no block id");
12017
12017
  return id;
12018
12018
  }
12019
12019
  function getBlockType(block) {
12020
12020
  const type = block.getAttribute("data-block-type");
12021
- assert(logger$4M, type, "invalid block dom, no data-type");
12021
+ assert(logger$4N, type, "invalid block dom, no data-type");
12022
12022
  return type;
12023
12023
  }
12024
12024
  function getParentBlock(node) {
@@ -12041,12 +12041,12 @@ var __publicField = (obj, key, value) => {
12041
12041
  }
12042
12042
  function getParentContainer(block) {
12043
12043
  const container = block.closest("div[data-type=editor-container]");
12044
- assert(logger$4M, container, "failed to get block container");
12044
+ assert(logger$4N, container, "failed to get block container");
12045
12045
  return container;
12046
12046
  }
12047
12047
  function getBlockContent(block) {
12048
12048
  const content = block.querySelector(":scope >div[data-type=block-content]");
12049
- assert(logger$4M, content, "no block content");
12049
+ assert(logger$4N, content, "no block content");
12050
12050
  return content;
12051
12051
  }
12052
12052
  function getBlockTools(block) {
@@ -12055,7 +12055,7 @@ var __publicField = (obj, key, value) => {
12055
12055
  tools = createElement("div", [], block);
12056
12056
  tools.setAttribute("data-type", "block-tools");
12057
12057
  }
12058
- assert(logger$4M, tools, "no block tools");
12058
+ assert(logger$4N, tools, "no block tools");
12059
12059
  return tools;
12060
12060
  }
12061
12061
  function getExistsBlockTools(block) {
@@ -12076,7 +12076,7 @@ var __publicField = (obj, key, value) => {
12076
12076
  function createBlockElement(editor, path, data2) {
12077
12077
  const blockData = editor.editorDecorators.decorateBlock(path, data2);
12078
12078
  const { id, type } = blockData;
12079
- assert(logger$4M, id, "no block id");
12079
+ assert(logger$4N, id, "no block id");
12080
12080
  const elem = createElement("div", [`${type}-block`], null);
12081
12081
  elem.id = id;
12082
12082
  elem.setAttribute("data-type", "editor-block");
@@ -12114,7 +12114,7 @@ var __publicField = (obj, key, value) => {
12114
12114
  }
12115
12115
  function getBoxTypeFromElement(box) {
12116
12116
  const type = box.getAttribute("data-box-type");
12117
- assert(logger$4M, type, "not a valid box element, no type");
12117
+ assert(logger$4N, type, "not a valid box element, no type");
12118
12118
  return type;
12119
12119
  }
12120
12120
  function isBox(node) {
@@ -12125,7 +12125,7 @@ var __publicField = (obj, key, value) => {
12125
12125
  }
12126
12126
  function getBoxId(box) {
12127
12127
  const { id } = box;
12128
- assert(logger$4M, id, "no box id");
12128
+ assert(logger$4N, id, "no box id");
12129
12129
  return id;
12130
12130
  }
12131
12131
  function getParentBox(node) {
@@ -12147,7 +12147,7 @@ var __publicField = (obj, key, value) => {
12147
12147
  }
12148
12148
  function getBoxContent(box) {
12149
12149
  const content = box.querySelector("span[data-type=box-content]");
12150
- assert(logger$4M, content, "invalid box dom, no content");
12150
+ assert(logger$4N, content, "invalid box dom, no content");
12151
12151
  return content;
12152
12152
  }
12153
12153
  function createInsertionElement(type, id, attributes) {
@@ -12169,7 +12169,7 @@ var __publicField = (obj, key, value) => {
12169
12169
  }
12170
12170
  function getInsertionContent(insertion) {
12171
12171
  const content = insertion.querySelector("span[data-type=insertion-content]");
12172
- assert(logger$4M, content, "invalid insertion-child dom, no content");
12172
+ assert(logger$4N, content, "invalid insertion-child dom, no content");
12173
12173
  return content;
12174
12174
  }
12175
12175
  function getPrevBlock(block) {
@@ -12229,7 +12229,7 @@ var __publicField = (obj, key, value) => {
12229
12229
  const container = getParentContainer(block);
12230
12230
  const children = getChildBlocks(container);
12231
12231
  const index2 = children.indexOf(block);
12232
- assert(logger$4M, index2 !== -1, "invalid block & container dom, failed to get block index");
12232
+ assert(logger$4N, index2 !== -1, "invalid block & container dom, failed to get block index");
12233
12233
  return index2;
12234
12234
  }
12235
12235
  function isInBlock(target) {
@@ -12254,18 +12254,18 @@ var __publicField = (obj, key, value) => {
12254
12254
  function isTitleBlock$2(block) {
12255
12255
  return block.hasAttribute("data-document-title");
12256
12256
  }
12257
- const logger$4L = getLogger("block-class");
12257
+ const logger$4M = getLogger("block-class");
12258
12258
  function getBlockClass(editor, block) {
12259
12259
  return editor.editorBlocks.getBlockClass(getBlockType(block));
12260
12260
  }
12261
12261
  function getTextBlockClass(editor, block) {
12262
12262
  const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
12263
- assert(logger$4L, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
12263
+ assert(logger$4M, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
12264
12264
  return text2;
12265
12265
  }
12266
12266
  function getComplexBlockClass(editor, block) {
12267
12267
  const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
12268
- assert(logger$4L, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
12268
+ assert(logger$4M, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
12269
12269
  return complex;
12270
12270
  }
12271
12271
  function getBlockClassByType(editor, type) {
@@ -12286,7 +12286,7 @@ var __publicField = (obj, key, value) => {
12286
12286
  function getBlockKind(editor, block) {
12287
12287
  return getBlockClass(editor, block).blockKind;
12288
12288
  }
12289
- const logger$4K = getLogger("text-block-child");
12289
+ const logger$4L = getLogger("text-block-child");
12290
12290
  function isTextBlockContentChild(elem) {
12291
12291
  if (elem.tagName !== "SPAN") {
12292
12292
  return false;
@@ -12294,14 +12294,14 @@ var __publicField = (obj, key, value) => {
12294
12294
  return true;
12295
12295
  }
12296
12296
  function isTextBlockContentBoxChild(elem) {
12297
- assert(logger$4K, isTextBlockContentChild(elem), "not a valid text child");
12297
+ assert(logger$4L, isTextBlockContentChild(elem), "not a valid text child");
12298
12298
  if (elem.getAttribute("data-type") === "editor-box") {
12299
12299
  return true;
12300
12300
  }
12301
12301
  return false;
12302
12302
  }
12303
12303
  function isTextBlockContentInsertionChild(elem) {
12304
- assert(logger$4K, isTextBlockContentChild(elem), "not a valid text child");
12304
+ assert(logger$4L, isTextBlockContentChild(elem), "not a valid text child");
12305
12305
  if (elem.getAttribute("data-type") === "editor-insertion") {
12306
12306
  return true;
12307
12307
  }
@@ -12311,7 +12311,7 @@ var __publicField = (obj, key, value) => {
12311
12311
  return !isTextBlockContentBoxChild(elem) && !isTextBlockContentInsertionChild(elem);
12312
12312
  }
12313
12313
  function getTextBlockContentChildType(child) {
12314
- assert(logger$4K, isTextBlockContentChild(child), "not a valid text child");
12314
+ assert(logger$4L, isTextBlockContentChild(child), "not a valid text child");
12315
12315
  if (isTextBlockContentBoxChild(child)) {
12316
12316
  return "box";
12317
12317
  }
@@ -12326,15 +12326,15 @@ var __publicField = (obj, key, value) => {
12326
12326
  return 0;
12327
12327
  if (type === "box")
12328
12328
  return 1;
12329
- assert(logger$4K, child.textContent !== null, "text block content is undefined");
12330
- assert(logger$4K, child.textContent.length >= 0, "text block content length is negative");
12329
+ assert(logger$4L, child.textContent !== null, "text block content is undefined");
12330
+ assert(logger$4L, child.textContent.length >= 0, "text block content length is negative");
12331
12331
  return child.textContent.length;
12332
12332
  }
12333
12333
  function getTextBlockContentChildren(block) {
12334
12334
  const content = getBlockContent(block);
12335
12335
  const children = Array.from(content.children);
12336
12336
  children.forEach((child) => {
12337
- assert(logger$4K, isTextBlockContentChild(child), "not a valid text child");
12337
+ assert(logger$4L, isTextBlockContentChild(child), "not a valid text child");
12338
12338
  });
12339
12339
  return children;
12340
12340
  }
@@ -12363,17 +12363,17 @@ var __publicField = (obj, key, value) => {
12363
12363
  };
12364
12364
  }
12365
12365
  const offset = blockOffset - start;
12366
- assert(logger$4K, offset > 0, "invalid offset value");
12367
- assert(logger$4K, !isTextBlockContentBoxChild(child), "invalid box child");
12366
+ assert(logger$4L, offset > 0, "invalid offset value");
12367
+ assert(logger$4L, !isTextBlockContentBoxChild(child), "invalid box child");
12368
12368
  return {
12369
12369
  prev: child,
12370
12370
  next: child,
12371
12371
  offset
12372
12372
  };
12373
12373
  }
12374
- assert(logger$4K, false, `invalid block child at position: ${blockOffset}`);
12374
+ assert(logger$4L, false, `invalid block child at position: ${blockOffset}`);
12375
12375
  }
12376
- const logger$4J = getLogger("block-path");
12376
+ const logger$4K = getLogger("block-path");
12377
12377
  function getBlockPath(block) {
12378
12378
  const ret = [];
12379
12379
  let current = block;
@@ -12387,26 +12387,26 @@ var __publicField = (obj, key, value) => {
12387
12387
  return ret;
12388
12388
  }
12389
12389
  const parentBlock = getParentBlock(container);
12390
- assert(logger$4J, parentBlock, "no parent block");
12390
+ assert(logger$4K, parentBlock, "no parent block");
12391
12391
  current = parentBlock;
12392
12392
  }
12393
- assert(logger$4J, false, "no parent block");
12393
+ assert(logger$4K, false, "no parent block");
12394
12394
  return [];
12395
12395
  }
12396
- const logger$4I = getLogger("child-container-path");
12396
+ const logger$4J = getLogger("child-container-path");
12397
12397
  function getContainerBlockPath(container) {
12398
12398
  if (isRootContainer(container)) {
12399
12399
  return [];
12400
12400
  }
12401
12401
  const parentBlock = getParentBlock(container);
12402
- assert(logger$4I, parentBlock, "no parent block");
12402
+ assert(logger$4J, parentBlock, "no parent block");
12403
12403
  return getBlockPath(parentBlock);
12404
12404
  }
12405
- const logger$4H = getLogger("load-blocks");
12405
+ const logger$4I = getLogger("load-blocks");
12406
12406
  function loadBlocks(editor, container, path) {
12407
12407
  const containerId = getContainerId(container);
12408
12408
  const blocks = getContainerBlocks$1(container, editor.doc);
12409
- assert(logger$4H, blocks.length > 0, "no blocks in container");
12409
+ assert(logger$4I, blocks.length > 0, "no blocks in container");
12410
12410
  const fragment = document.createDocumentFragment();
12411
12411
  blocks.forEach((b, index2) => {
12412
12412
  const block = editor.editorBlocks.createBlock([...path, { containerId, blockIndex: index2 }], container, b);
@@ -12422,7 +12422,7 @@ var __publicField = (obj, key, value) => {
12422
12422
  return block;
12423
12423
  }
12424
12424
  const blocks = getChildBlocks(container);
12425
- assert(logger$4H, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
12425
+ assert(logger$4I, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
12426
12426
  if (blockIndex === blocks.length) {
12427
12427
  containerBlocksElement.appendChild(block);
12428
12428
  } else {
@@ -12440,7 +12440,7 @@ var __publicField = (obj, key, value) => {
12440
12440
  insertBlockAt(container, blockIndex, block);
12441
12441
  return block;
12442
12442
  }
12443
- const logger$4G = getLogger("root-container");
12443
+ const logger$4H = getLogger("root-container");
12444
12444
  const MIN_DISTANCE_THRESHOLD$2 = 3;
12445
12445
  class RootContainer {
12446
12446
  constructor(editor, rootContainer) {
@@ -12468,7 +12468,7 @@ var __publicField = (obj, key, value) => {
12468
12468
  this.editor.selection.updateSelection(null);
12469
12469
  this.editor.emit("resize", this.editor);
12470
12470
  } catch (err) {
12471
- logger$4G.warn(`failed to update selection while container resizing: ${err.message}`);
12471
+ logger$4H.warn(`failed to update selection while container resizing: ${err.message}`);
12472
12472
  }
12473
12473
  });
12474
12474
  __publicField(this, "handleClick", (event) => {
@@ -12502,7 +12502,7 @@ var __publicField = (obj, key, value) => {
12502
12502
  const box = getParentBox(elem);
12503
12503
  if (box && isChildNode(box, eTarget)) {
12504
12504
  const block2 = getParentBlock(box);
12505
- assert(logger$4G, block2, "no parent block");
12505
+ assert(logger$4H, block2, "no parent block");
12506
12506
  (_b = (_a = this.editor.editorBoxes.getBoxClass(getBoxTypeFromElement(box))) == null ? void 0 : _a.handleClickBox) == null ? void 0 : _b.call(_a, this.editor, box, event);
12507
12507
  return;
12508
12508
  }
@@ -12558,7 +12558,7 @@ var __publicField = (obj, key, value) => {
12558
12558
  this.editor.input.focus({ preventScroll: true });
12559
12559
  });
12560
12560
  __publicField(this, "handleMouseMove", (event) => {
12561
- assert(logger$4G, this.mouseDownEvent, "no mouse down event");
12561
+ assert(logger$4H, this.mouseDownEvent, "no mouse down event");
12562
12562
  if (ensureIsMobileEvent(this.mouseDownEvent))
12563
12563
  return;
12564
12564
  const deltaX = event.x - this.mouseDownEvent.x;
@@ -12674,7 +12674,7 @@ var __publicField = (obj, key, value) => {
12674
12674
  loadBlocks(editor, container, path);
12675
12675
  return container;
12676
12676
  }
12677
- const logger$4F = getLogger("block");
12677
+ const logger$4G = getLogger("block");
12678
12678
  function getBlockTextLength$6(editor, block) {
12679
12679
  return getBlockClass(editor, block).getBlockTextLength(block);
12680
12680
  }
@@ -12693,7 +12693,7 @@ var __publicField = (obj, key, value) => {
12693
12693
  return block;
12694
12694
  }
12695
12695
  const parent = getParentBlock(container);
12696
- assert(logger$4F, parent, "no parent block exists for child container");
12696
+ assert(logger$4G, parent, "no parent block exists for child container");
12697
12697
  block = parent;
12698
12698
  }
12699
12699
  }
@@ -12729,7 +12729,7 @@ var __publicField = (obj, key, value) => {
12729
12729
  }
12730
12730
  return fun(editor, block, options);
12731
12731
  } catch (err) {
12732
- logger$4F.debug(`unsupported block type: ${type}`);
12732
+ logger$4G.debug(`unsupported block type: ${type}`);
12733
12733
  return null;
12734
12734
  }
12735
12735
  }
@@ -12749,7 +12749,7 @@ var __publicField = (obj, key, value) => {
12749
12749
  const styles2 = Object.fromEntries(Object.entries(data2).filter(([key]) => key.startsWith("style-")));
12750
12750
  Object.entries(styles2).forEach(([, value]) => {
12751
12751
  const type = typeof value;
12752
- assert(logger$4F, type === "string" || type === "number" || type === "boolean", "invalid style value");
12752
+ assert(logger$4G, type === "string" || type === "number" || type === "boolean", "invalid style value");
12753
12753
  });
12754
12754
  return styles2;
12755
12755
  }
@@ -12874,7 +12874,7 @@ var __publicField = (obj, key, value) => {
12874
12874
  }
12875
12875
  return { element: null, blockCommands: [], boxCommands: [] };
12876
12876
  }
12877
- const logger$4E = getLogger("embed-block-common");
12877
+ const logger$4F = getLogger("embed-block-common");
12878
12878
  function isColumnsBlock(block) {
12879
12879
  return getBlockType(block) === "layout";
12880
12880
  }
@@ -12882,9 +12882,9 @@ var __publicField = (obj, key, value) => {
12882
12882
  return getBlockType(block) === "embed";
12883
12883
  }
12884
12884
  function getEmbedType(block) {
12885
- assert(logger$4E, isEmbedBlock(block), "not an embed block");
12885
+ assert(logger$4F, isEmbedBlock(block), "not an embed block");
12886
12886
  const type = block.getAttribute("data-embed-type");
12887
- assert(logger$4E, type, "no embed data type");
12887
+ assert(logger$4F, type, "no embed data type");
12888
12888
  return type;
12889
12889
  }
12890
12890
  function getEmbedClassFromBlock(editor, block) {
@@ -12950,10 +12950,10 @@ var __publicField = (obj, key, value) => {
12950
12950
  data: (_c = overrideOptions == null ? void 0 : overrideOptions.data) != null ? _c : data2
12951
12951
  });
12952
12952
  }
12953
- const logger$4D = getLogger("execute-block-command");
12953
+ const logger$4E = getLogger("execute-block-command");
12954
12954
  function executeEmbedBlockCommand(editor, block, commandGroup, item) {
12955
12955
  var _a;
12956
- assert(logger$4D, isEmbedBlock(block), "not a embed block");
12956
+ assert(logger$4E, isEmbedBlock(block), "not a embed block");
12957
12957
  const embedType = getEmbedType(block);
12958
12958
  const embed = getEmbedClassByType(editor, embedType);
12959
12959
  if (!embed.getOptions) {
@@ -12986,14 +12986,14 @@ var __publicField = (obj, key, value) => {
12986
12986
  }
12987
12987
  return void 0;
12988
12988
  }
12989
- const logger$4C = getLogger("block-class");
12989
+ const logger$4D = getLogger("block-class");
12990
12990
  function isHeadingBlock$1(block) {
12991
12991
  return !!block.getAttribute("data-style-heading");
12992
12992
  }
12993
12993
  function getBlockHeading(block) {
12994
12994
  var _a;
12995
12995
  const heading = Number.parseInt((_a = block.getAttribute("data-style-heading")) != null ? _a : "", 10);
12996
- assert(logger$4C, heading, "not a heading block");
12996
+ assert(logger$4D, heading, "not a heading block");
12997
12997
  return heading;
12998
12998
  }
12999
12999
  function isExpandedHeadingBlock(block) {
@@ -13004,7 +13004,7 @@ var __publicField = (obj, key, value) => {
13004
13004
  }
13005
13005
  function getHeadingBlockChildren(block, oldHeading) {
13006
13006
  if (!oldHeading) {
13007
- assert(logger$4C, isHeadingBlock$1(block), "not a heading block");
13007
+ assert(logger$4D, isHeadingBlock$1(block), "not a heading block");
13008
13008
  }
13009
13009
  const children = [];
13010
13010
  const heading = oldHeading != null ? oldHeading : getBlockHeading(block);
@@ -13034,7 +13034,7 @@ var __publicField = (obj, key, value) => {
13034
13034
  }
13035
13035
  return children;
13036
13036
  }
13037
- const logger$4B = getLogger("complex-block-position");
13037
+ const logger$4C = getLogger("complex-block-position");
13038
13038
  class EditorComplexBlockPosition {
13039
13039
  constructor(block, childContainerId, custom) {
13040
13040
  __publicField(this, "blockId");
@@ -13043,7 +13043,7 @@ var __publicField = (obj, key, value) => {
13043
13043
  if (block instanceof HTMLElement) {
13044
13044
  this.blockId = getBlockId(block);
13045
13045
  } else {
13046
- assert(logger$4B, typeof block === "string", `not a valid block id: ${block}`);
13046
+ assert(logger$4C, typeof block === "string", `not a valid block id: ${block}`);
13047
13047
  this.blockId = block;
13048
13048
  }
13049
13049
  this.childContainerId = childContainerId;
@@ -13055,7 +13055,7 @@ var __publicField = (obj, key, value) => {
13055
13055
  return false;
13056
13056
  }
13057
13057
  }
13058
- const logger$4A = getLogger("simple-block-position");
13058
+ const logger$4B = getLogger("simple-block-position");
13059
13059
  class EditorSimpleBlockPosition {
13060
13060
  constructor(block, offset, type) {
13061
13061
  __publicField(this, "blockId");
@@ -13064,7 +13064,7 @@ var __publicField = (obj, key, value) => {
13064
13064
  if (block instanceof HTMLElement) {
13065
13065
  this.blockId = getBlockId(block);
13066
13066
  } else {
13067
- assert(logger$4A, typeof block === "string", `not a valid block id: ${block}`);
13067
+ assert(logger$4B, typeof block === "string", `not a valid block id: ${block}`);
13068
13068
  this.blockId = block;
13069
13069
  }
13070
13070
  this.offset = offset;
@@ -13074,7 +13074,7 @@ var __publicField = (obj, key, value) => {
13074
13074
  return true;
13075
13075
  }
13076
13076
  }
13077
- const logger$4z = getLogger("editor-position");
13077
+ const logger$4A = getLogger("editor-position");
13078
13078
  function createSimpleBlockPosition(block, offset, type) {
13079
13079
  return new EditorSimpleBlockPosition(block, offset, type);
13080
13080
  }
@@ -13096,7 +13096,7 @@ var __publicField = (obj, key, value) => {
13096
13096
  }
13097
13097
  const block1 = editor.getBlockById(pos1.blockId);
13098
13098
  const block2 = editor.getBlockById(pos2.blockId);
13099
- assert(logger$4z, block1 !== block2, "comparePosition: blocks are the same");
13099
+ assert(logger$4A, block1 !== block2, "comparePosition: blocks are the same");
13100
13100
  return compareElement(block1, block2);
13101
13101
  }
13102
13102
  if (isComplexBlockPosition(pos1) && isComplexBlockPosition(pos2)) {
@@ -13107,13 +13107,13 @@ var __publicField = (obj, key, value) => {
13107
13107
  }
13108
13108
  const container1 = editor.getContainerById(p1.childContainerId);
13109
13109
  const container2 = editor.getContainerById(p2.childContainerId);
13110
- assert(logger$4z, container1 !== container2, "comparePosition: containers are the same");
13110
+ assert(logger$4A, container1 !== container2, "comparePosition: containers are the same");
13111
13111
  return compareElement(container1, container2);
13112
13112
  }
13113
- assert(logger$4z, false, "invalid ");
13113
+ assert(logger$4A, false, "invalid ");
13114
13114
  return 0;
13115
13115
  }
13116
- const logger$4y = getLogger("simple-range");
13116
+ const logger$4z = getLogger("simple-range");
13117
13117
  class EditorSimpleSelectionRange {
13118
13118
  constructor(editor, options) {
13119
13119
  __publicField(this, "editor");
@@ -13162,11 +13162,11 @@ var __publicField = (obj, key, value) => {
13162
13162
  const { editor } = this;
13163
13163
  const startBlock = editor.getBlockById(this.start.blockId);
13164
13164
  const endBlock = editor.getBlockById(this.end.blockId);
13165
- assert(logger$4y, startBlock, "no start block");
13166
- assert(logger$4y, endBlock, "no end block");
13165
+ assert(logger$4z, startBlock, "no start block");
13166
+ assert(logger$4z, endBlock, "no end block");
13167
13167
  const startContainer = getParentContainer(startBlock);
13168
13168
  const endContainer = getParentContainer(endBlock);
13169
- assert(logger$4y, startContainer === endContainer, "invalid range");
13169
+ assert(logger$4z, startContainer === endContainer, "invalid range");
13170
13170
  const ret = [];
13171
13171
  if (startBlock === endBlock) {
13172
13172
  ret.push({
@@ -13177,7 +13177,7 @@ var __publicField = (obj, key, value) => {
13177
13177
  } else {
13178
13178
  const startIndex = getBlockIndex(startBlock);
13179
13179
  const endIndex = getBlockIndex(endBlock);
13180
- assert(logger$4y, startIndex < endIndex, "invalid range, start > index");
13180
+ assert(logger$4z, startIndex < endIndex, "invalid range, start > index");
13181
13181
  ret.push({
13182
13182
  block: startBlock,
13183
13183
  start: this.start,
@@ -13277,7 +13277,7 @@ var __publicField = (obj, key, value) => {
13277
13277
  clearSelection: clearSelection$6,
13278
13278
  convertTo: convertTo$m
13279
13279
  };
13280
- const logger$4x = getLogger("editor-blocks");
13280
+ const logger$4y = getLogger("editor-blocks");
13281
13281
  class EditorBlocks {
13282
13282
  constructor(editor) {
13283
13283
  __publicField(this, "blocks", /* @__PURE__ */ new Map());
@@ -13286,12 +13286,12 @@ var __publicField = (obj, key, value) => {
13286
13286
  registerBlockClass(blockClass) {
13287
13287
  const type = blockClass.blockType;
13288
13288
  const exists = this.blocks.get(type);
13289
- assert(logger$4x, !exists, `duplicated block type: ${type}`);
13289
+ assert(logger$4y, !exists, `duplicated block type: ${type}`);
13290
13290
  this.blocks.set(type, blockClass);
13291
13291
  }
13292
13292
  getBlockClass(type) {
13293
13293
  const exists = this.blocks.get(type);
13294
- assert(logger$4x, exists, `unknown block type: ${type}`);
13294
+ assert(logger$4y, exists, `unknown block type: ${type}`);
13295
13295
  return exists;
13296
13296
  }
13297
13297
  hasBlock(type) {
@@ -13307,7 +13307,7 @@ var __publicField = (obj, key, value) => {
13307
13307
  }
13308
13308
  const content = blockClass.createBlockContent(this.editor, path, container, blockElement, block);
13309
13309
  if (content.parentElement !== blockElement) {
13310
- logger$4x.warn("content parent is not block");
13310
+ logger$4y.warn("content parent is not block");
13311
13311
  blockElement.appendChild(content);
13312
13312
  }
13313
13313
  this.editor.blockHooks.forEach((hook) => {
@@ -13328,7 +13328,7 @@ var __publicField = (obj, key, value) => {
13328
13328
  return newBlock;
13329
13329
  }
13330
13330
  }
13331
- const logger$4w = getLogger("editor-embeds");
13331
+ const logger$4x = getLogger("editor-embeds");
13332
13332
  class EditorEmbeds {
13333
13333
  constructor(editor) {
13334
13334
  __publicField(this, "objects", /* @__PURE__ */ new Map());
@@ -13337,12 +13337,12 @@ var __publicField = (obj, key, value) => {
13337
13337
  registerEmbedClass(embedClass) {
13338
13338
  const type = embedClass.embedType;
13339
13339
  const exists = this.objects.get(type);
13340
- assert(logger$4w, !exists, `duplicated embed object type: ${type}`);
13340
+ assert(logger$4x, !exists, `duplicated embed object type: ${type}`);
13341
13341
  this.objects.set(type, embedClass);
13342
13342
  }
13343
13343
  getEmbedClass(type) {
13344
13344
  const exists = this.objects.get(type);
13345
- assert(logger$4w, exists, `unknown embed type: ${type}`);
13345
+ assert(logger$4x, exists, `unknown embed type: ${type}`);
13346
13346
  return exists;
13347
13347
  }
13348
13348
  getEmbedClassFromBlock(block) {
@@ -13352,12 +13352,12 @@ var __publicField = (obj, key, value) => {
13352
13352
  this.objects.forEach(callback);
13353
13353
  }
13354
13354
  }
13355
- const logger$4v = getLogger("embed-block");
13355
+ const logger$4w = getLogger("embed-block");
13356
13356
  function createBlockContent$6(editor, path, container, blockElement, blockData) {
13357
13357
  const content = createBlockContentElement(blockElement, "div");
13358
- assert(logger$4v, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
13358
+ assert(logger$4w, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
13359
13359
  const embedBlockData = blockData;
13360
- assert(logger$4v, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
13360
+ assert(logger$4w, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
13361
13361
  const embedClass = editor.editorEmbeds.getEmbedClass(embedBlockData.embedType);
13362
13362
  embedClass.createEmbedContent(editor, content, embedBlockData, path, container, blockElement);
13363
13363
  blockElement.setAttribute("data-embed-type", embedBlockData.embedType);
@@ -13385,7 +13385,7 @@ var __publicField = (obj, key, value) => {
13385
13385
  function getCaretRect$4(block, pos) {
13386
13386
  const content = getBlockContent(block);
13387
13387
  const rect = content.getBoundingClientRect();
13388
- assert(logger$4v, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
13388
+ assert(logger$4w, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
13389
13389
  if (pos.offset === 1) {
13390
13390
  return new DOMRect(rect.right, rect.top, 0, rect.height);
13391
13391
  }
@@ -13525,18 +13525,18 @@ var __publicField = (obj, key, value) => {
13525
13525
  toStandardDoc: toStandardDoc$2,
13526
13526
  getResources: getResources$2
13527
13527
  };
13528
- const logger$4u = getLogger("complex-block-helper");
13528
+ const logger$4v = getLogger("complex-block-helper");
13529
13529
  function complexBlockGetAllChildContainers(editor, block, options) {
13530
13530
  const blockClass = getComplexBlockClass(editor, block);
13531
13531
  return blockClass.getChildContainers(editor, block, options);
13532
13532
  }
13533
13533
  function complexBlockGetSelectedContainers(editor, block, start, end) {
13534
13534
  if (start.isSimple()) {
13535
- assert(logger$4u, end.isSimple(), "invalid start and end position");
13535
+ assert(logger$4v, end.isSimple(), "invalid start and end position");
13536
13536
  return complexBlockGetAllChildContainers(editor, block);
13537
13537
  }
13538
- assert(logger$4u, !start.isSimple(), "invalid start pos");
13539
- assert(logger$4u, !end.isSimple(), "invalid end pos");
13538
+ assert(logger$4v, !start.isSimple(), "invalid start pos");
13539
+ assert(logger$4v, !end.isSimple(), "invalid end pos");
13540
13540
  const blockClass = getComplexBlockClass(editor, block);
13541
13541
  return blockClass.getSelectedContainers(editor, block, start, end);
13542
13542
  }
@@ -13547,11 +13547,11 @@ var __publicField = (obj, key, value) => {
13547
13547
  const parentComplexBlock = getParentBlock(getParentContainer(childBlock));
13548
13548
  if (!parentComplexBlock)
13549
13549
  return false;
13550
- assert(logger$4u, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13550
+ assert(logger$4v, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13551
13551
  const childContainer = getParentContainer(childBlock);
13552
13552
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
13553
13553
  const index2 = childContainers.indexOf(childContainer);
13554
- assert(logger$4u, index2 >= 0, "not valid child container");
13554
+ assert(logger$4v, index2 >= 0, "not valid child container");
13555
13555
  return index2 === 0;
13556
13556
  }
13557
13557
  function complexBlockGetFirstSimpleChild(editor, complexBlock, options) {
@@ -13604,13 +13604,13 @@ var __publicField = (obj, key, value) => {
13604
13604
  return block;
13605
13605
  }
13606
13606
  function findPrevSimpleBlockBeforeChildContainer(editor, childContainer, options) {
13607
- assert(logger$4u, isChildContainer(childContainer), "not a child container");
13607
+ assert(logger$4v, isChildContainer(childContainer), "not a child container");
13608
13608
  const parentComplexBlock = getParentBlock(childContainer);
13609
- assert(logger$4u, parentComplexBlock, "no parent block");
13610
- assert(logger$4u, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13609
+ assert(logger$4v, parentComplexBlock, "no parent block");
13610
+ assert(logger$4v, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13611
13611
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock, options);
13612
13612
  const containerIndex = childContainers.indexOf(childContainer);
13613
- assert(logger$4u, containerIndex !== -1, "child container not found");
13613
+ assert(logger$4v, containerIndex !== -1, "child container not found");
13614
13614
  if (containerIndex === 0) {
13615
13615
  const prevBlock = getPrevBlock(parentComplexBlock);
13616
13616
  if (!prevBlock)
@@ -13628,9 +13628,9 @@ var __publicField = (obj, key, value) => {
13628
13628
  return lastBlock2;
13629
13629
  }
13630
13630
  function complexBlockGetTopChildContainers(editor, complexBlock) {
13631
- assert(logger$4u, isComplexKindBlock(editor, complexBlock), "not a complex block");
13631
+ assert(logger$4v, isComplexKindBlock(editor, complexBlock), "not a complex block");
13632
13632
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
13633
- assert(logger$4u, childContainers.length > 0, "no child container");
13633
+ assert(logger$4v, childContainers.length > 0, "no child container");
13634
13634
  if (childContainers.length === 1) {
13635
13635
  return childContainers;
13636
13636
  }
@@ -13655,9 +13655,9 @@ var __publicField = (obj, key, value) => {
13655
13655
  return ret;
13656
13656
  }
13657
13657
  function complexBlockGetBottomChildContainers(editor, complexBlock) {
13658
- assert(logger$4u, isComplexKindBlock(editor, complexBlock), "not a complex block");
13658
+ assert(logger$4v, isComplexKindBlock(editor, complexBlock), "not a complex block");
13659
13659
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
13660
- assert(logger$4u, childContainers.length > 0, "no child container");
13660
+ assert(logger$4v, childContainers.length > 0, "no child container");
13661
13661
  if (childContainers.length === 1) {
13662
13662
  return childContainers;
13663
13663
  }
@@ -13762,11 +13762,11 @@ var __publicField = (obj, key, value) => {
13762
13762
  return result;
13763
13763
  }
13764
13764
  const anchor = "";
13765
- const logger$4t = getLogger("text-range");
13765
+ const logger$4u = getLogger("text-range");
13766
13766
  function getBlockRangeInfo(block, blockOffset) {
13767
13767
  const getChildRange = (child, offset) => {
13768
13768
  if (isTextBlockContentInsertionChild(child)) {
13769
- assert(logger$4t, offset === 0, `invalid offset for insertion child: ${offset}`);
13769
+ assert(logger$4u, offset === 0, `invalid offset for insertion child: ${offset}`);
13770
13770
  const childOffset = 2;
13771
13771
  return {
13772
13772
  child,
@@ -13775,7 +13775,7 @@ var __publicField = (obj, key, value) => {
13775
13775
  };
13776
13776
  }
13777
13777
  if (isTextBlockContentBoxChild(child)) {
13778
- assert(logger$4t, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
13778
+ assert(logger$4u, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
13779
13779
  const childOffset = offset === 0 ? 1 : 2;
13780
13780
  return {
13781
13781
  child,
@@ -13784,17 +13784,17 @@ var __publicField = (obj, key, value) => {
13784
13784
  };
13785
13785
  }
13786
13786
  const textNode = child.firstChild;
13787
- assert(logger$4t, textNode, "no child node for text child");
13788
- assert(logger$4t, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
13787
+ assert(logger$4u, textNode, "no child node for text child");
13788
+ assert(logger$4u, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
13789
13789
  if (textNode instanceof HTMLBRElement) {
13790
- assert(logger$4t, offset >= 0 && offset <= 0, "invalid offset for text child");
13790
+ assert(logger$4u, offset >= 0 && offset <= 0, "invalid offset for text child");
13791
13791
  return {
13792
13792
  child,
13793
13793
  container: textNode,
13794
13794
  offset
13795
13795
  };
13796
13796
  }
13797
- assert(logger$4t, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
13797
+ assert(logger$4u, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
13798
13798
  return {
13799
13799
  child,
13800
13800
  container: textNode,
@@ -13823,38 +13823,38 @@ var __publicField = (obj, key, value) => {
13823
13823
  }
13824
13824
  start += childLength;
13825
13825
  }
13826
- assert(logger$4t, false, "failed to get range info");
13826
+ assert(logger$4u, false, "failed to get range info");
13827
13827
  }
13828
13828
  function createChildRange(child, start, end) {
13829
13829
  if (start === end) {
13830
- assert(logger$4t, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
13830
+ assert(logger$4u, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
13831
13831
  } else {
13832
- assert(logger$4t, start < end, `invalid start & end: ${start}, ${end}`);
13832
+ assert(logger$4u, start < end, `invalid start & end: ${start}, ${end}`);
13833
13833
  }
13834
13834
  if (isTextBlockContentInsertionChild(child)) {
13835
- assert(logger$4t, start === end, `invalid insertion child range offset: ${start}, ${end}`);
13836
- assert(logger$4t, start === 0, `invalid insertion child range start: ${start}`);
13835
+ assert(logger$4u, start === end, `invalid insertion child range offset: ${start}, ${end}`);
13836
+ assert(logger$4u, start === 0, `invalid insertion child range start: ${start}`);
13837
13837
  const insertionElem = child;
13838
- assert(logger$4t, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
13838
+ assert(logger$4u, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
13839
13839
  const range = createExpandedRange(insertionElem, 1, insertionElem, 2);
13840
13840
  return range;
13841
13841
  }
13842
13842
  if (isTextBlockContentBoxChild(child)) {
13843
- assert(logger$4t, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
13844
- assert(logger$4t, start === 0, `invalid box child range start: ${start}`);
13843
+ assert(logger$4u, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
13844
+ assert(logger$4u, start === 0, `invalid box child range start: ${start}`);
13845
13845
  const box = child;
13846
- assert(logger$4t, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
13846
+ assert(logger$4u, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
13847
13847
  const range = createExpandedRange(box, 1, box, 2);
13848
13848
  return range;
13849
13849
  }
13850
13850
  const length = getTextBlockContentChildTextLength(child);
13851
- assert(logger$4t, end <= length, `invalid child end: ${end}, ${length}`);
13851
+ assert(logger$4u, end <= length, `invalid child end: ${end}, ${length}`);
13852
13852
  const textNode = child.firstChild;
13853
- assert(logger$4t, textNode instanceof Text, "invalid block text child");
13854
- assert(logger$4t, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
13853
+ assert(logger$4u, textNode instanceof Text, "invalid block text child");
13854
+ assert(logger$4u, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
13855
13855
  return createExpandedRange(textNode, start, textNode, end);
13856
13856
  }
13857
- const logger$4s = getLogger("caret-rect");
13857
+ const logger$4t = getLogger("caret-rect");
13858
13858
  function getChildClientRects(block, child) {
13859
13859
  if (isBox(child)) {
13860
13860
  const box = child;
@@ -13863,7 +13863,7 @@ var __publicField = (obj, key, value) => {
13863
13863
  const blockContent = getBlockContent(block);
13864
13864
  const lineHeight = Number.parseFloat(window.getComputedStyle(blockContent).lineHeight) || boxContent.getBoundingClientRect().height;
13865
13865
  const rects = Array.from(boxContent.getClientRects());
13866
- assert(logger$4s, rects.length > 0, "no box client rects");
13866
+ assert(logger$4t, rects.length > 0, "no box client rects");
13867
13867
  const blockRect = blockContent.getBoundingClientRect();
13868
13868
  const firstRect = rects[0];
13869
13869
  const lastRect = new DOMRect(blockRect.left, firstRect.bottom, 1, lineHeight);
@@ -13883,22 +13883,22 @@ var __publicField = (obj, key, value) => {
13883
13883
  const rect2 = getLastClientRect(ranges[0].child);
13884
13884
  return new DOMRect(rect2.right, rect2.top, 1, rect2.height);
13885
13885
  }
13886
- assert(logger$4s, ranges[1], "invalid ranges");
13886
+ assert(logger$4t, ranges[1], "invalid ranges");
13887
13887
  const rect = getFirstClientRect(ranges[1].child);
13888
13888
  return new DOMRect(rect.left, rect.top, 1, rect.height);
13889
13889
  }
13890
13890
  let rangeInfo = ranges[0];
13891
- assert(logger$4s, ranges.length >= 1, "failed to get block range");
13891
+ assert(logger$4t, ranges.length >= 1, "failed to get block range");
13892
13892
  if (ranges.length === 1) {
13893
13893
  rangeInfo = ranges[0];
13894
13894
  } else {
13895
- assert(logger$4s, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
13895
+ assert(logger$4t, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
13896
13896
  if (isTextBlockContentInsertionChild(ranges[ranges.length - 1].child)) {
13897
13897
  rangeInfo = ranges[ranges.length - 1];
13898
13898
  const child = rangeInfo.child;
13899
13899
  const content = getInsertionContent(child);
13900
13900
  const rects2 = content.getClientRects();
13901
- assert(logger$4s, rects2.length >= 1, "no client rects for box content");
13901
+ assert(logger$4t, rects2.length >= 1, "no client rects for box content");
13902
13902
  const rect = rects2[rects2.length - 1];
13903
13903
  return new DOMRect(rect.right, rect.y, 1, rect.height);
13904
13904
  }
@@ -13915,9 +13915,9 @@ var __publicField = (obj, key, value) => {
13915
13915
  }
13916
13916
  }
13917
13917
  if (rangeInfo.container instanceof HTMLBRElement) {
13918
- assert(logger$4s, pos.offset === 0, "invalid offset for empty block text");
13918
+ assert(logger$4t, pos.offset === 0, "invalid offset for empty block text");
13919
13919
  const parent = rangeInfo.container.parentElement;
13920
- assert(logger$4s, parent, "invalid br parent");
13920
+ assert(logger$4t, parent, "invalid br parent");
13921
13921
  const rect = parent.getBoundingClientRect();
13922
13922
  const ret = new DOMRect(rect.left, rect.top, 1, rect.height);
13923
13923
  return ret;
@@ -13925,11 +13925,11 @@ var __publicField = (obj, key, value) => {
13925
13925
  const range = createRange(rangeInfo.container, rangeInfo.offset);
13926
13926
  const rects = Array.from(range.getClientRects());
13927
13927
  if (rects.length === 0) {
13928
- assert(logger$4s, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
13929
- assert(logger$4s, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
13928
+ assert(logger$4t, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
13929
+ assert(logger$4t, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
13930
13930
  const child = rangeInfo.child;
13931
13931
  const rects2 = getChildClientRects(block, child);
13932
- assert(logger$4s, rects2.length >= 1, "no client rects for box content");
13932
+ assert(logger$4t, rects2.length >= 1, "no client rects for box content");
13933
13933
  if (rangeInfo.offset === 1) {
13934
13934
  const rect2 = rects2[0];
13935
13935
  return new DOMRect(rect2.x, rect2.y, 1, rect2.height);
@@ -13975,7 +13975,7 @@ var __publicField = (obj, key, value) => {
13975
13975
  });
13976
13976
  }
13977
13977
  }
13978
- assert(logger$4s, rects.length > 0, "no client rects for range");
13978
+ assert(logger$4t, rects.length > 0, "no client rects for range");
13979
13979
  if (pos.type === "home") {
13980
13980
  return rects[rects.length - 1];
13981
13981
  }
@@ -14055,13 +14055,13 @@ var __publicField = (obj, key, value) => {
14055
14055
  };
14056
14056
  }
14057
14057
  }
14058
- const logger$4r = getLogger("selection-range");
14058
+ const logger$4s = getLogger("selection-range");
14059
14059
  function createEditorSelectionRange(editor, options) {
14060
14060
  const { anchor: anchor2, focus } = options;
14061
14061
  if (anchor2 instanceof EditorSimpleBlockPosition && focus instanceof EditorSimpleBlockPosition) {
14062
14062
  return new EditorSimpleSelectionRange(editor, { anchor: anchor2, focus });
14063
14063
  }
14064
- assert(logger$4r, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
14064
+ assert(logger$4s, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
14065
14065
  return new EditorComplexSelectionRange(editor, { anchor: anchor2, focus });
14066
14066
  }
14067
14067
  function createBlockSimpleRange(editor, block, anchor2, focus) {
@@ -14083,7 +14083,7 @@ var __publicField = (obj, key, value) => {
14083
14083
  const focus = createSimpleBlockPosition(range.focus.blockId, range.focus.offset, "normal");
14084
14084
  return createEditorSelectionRange(editor, { anchor: anchor2, focus });
14085
14085
  }
14086
- const logger$4q = getLogger("range-from-point");
14086
+ const logger$4r = getLogger("range-from-point");
14087
14087
  function getBlockRangeFromPoint(editor, pointX, pointY, dragging) {
14088
14088
  const yOffsets = [0, -12, 12];
14089
14089
  let x = pointX;
@@ -14115,7 +14115,7 @@ var __publicField = (obj, key, value) => {
14115
14115
  const rect = elem.getBoundingClientRect();
14116
14116
  if (rect.width && rect.top && i === 0) {
14117
14117
  if (rect.left + rect.width < x || rect.top + rect.height < y) {
14118
- logger$4q.debug("click on scrollbar, out of element rect");
14118
+ logger$4r.debug("click on scrollbar, out of element rect");
14119
14119
  return null;
14120
14120
  }
14121
14121
  }
@@ -14153,7 +14153,7 @@ var __publicField = (obj, key, value) => {
14153
14153
  let block = getLastChildBlock(container);
14154
14154
  if (!isVisibleBlock(block)) {
14155
14155
  const preBlock = getPrevVisibleBlock(block);
14156
- assert(logger$4q, preBlock, "container must have visible block");
14156
+ assert(logger$4r, preBlock, "container must have visible block");
14157
14157
  block = preBlock;
14158
14158
  }
14159
14159
  const range = getBlockClass(editor, block).getRangeFromPoint(editor, block, x, block.getBoundingClientRect().bottom - 4);
@@ -14172,7 +14172,7 @@ var __publicField = (obj, key, value) => {
14172
14172
  if (range instanceof EditorSimpleSelectionRange) {
14173
14173
  return range;
14174
14174
  }
14175
- assert(logger$4q, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
14175
+ assert(logger$4r, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
14176
14176
  const complexRange = range;
14177
14177
  const container2 = editor.getContainerById(complexRange.start.childContainerId);
14178
14178
  return getRangeInContainer(editor, container2, x, y);
@@ -14195,7 +14195,7 @@ var __publicField = (obj, key, value) => {
14195
14195
  });
14196
14196
  return getRangeInContainer(editor, container, x, y);
14197
14197
  }
14198
- const logger$4p = getLogger("adjust-selection-pos");
14198
+ const logger$4q = getLogger("adjust-selection-pos");
14199
14199
  function getParentContainers(block) {
14200
14200
  const containers = [];
14201
14201
  while (block) {
@@ -14205,10 +14205,10 @@ var __publicField = (obj, key, value) => {
14205
14205
  return containers;
14206
14206
  }
14207
14207
  const newBlock = getParentBlock(container);
14208
- assert(logger$4p, newBlock, "child container has not parent container");
14208
+ assert(logger$4q, newBlock, "child container has not parent container");
14209
14209
  block = newBlock;
14210
14210
  }
14211
- assert(logger$4p, false, "should not come here: getParentContainers");
14211
+ assert(logger$4q, false, "should not come here: getParentContainers");
14212
14212
  }
14213
14213
  function getParentBlockInContainer(container, block) {
14214
14214
  while (block) {
@@ -14217,16 +14217,16 @@ var __publicField = (obj, key, value) => {
14217
14217
  return block;
14218
14218
  }
14219
14219
  const newBlock = getParentBlock(parent);
14220
- assert(logger$4p, newBlock, "could not find parent block for a child container");
14220
+ assert(logger$4q, newBlock, "could not find parent block for a child container");
14221
14221
  block = newBlock;
14222
14222
  }
14223
- assert(logger$4p, false, "no parent block in specified container");
14223
+ assert(logger$4q, false, "no parent block in specified container");
14224
14224
  }
14225
14225
  function getClosestParentBlock(block1, block2) {
14226
14226
  const containers1 = getParentContainers(block1);
14227
14227
  const containers2 = getParentContainers(block2);
14228
- assert(logger$4p, containers1.length > 0 && containers2.length > 0, "block has not parent container");
14229
- assert(logger$4p, containers1[0] === containers2[0], "root container does not equal");
14228
+ assert(logger$4q, containers1.length > 0 && containers2.length > 0, "block has not parent container");
14229
+ assert(logger$4q, containers1[0] === containers2[0], "root container does not equal");
14230
14230
  let parentContainer = containers1[0];
14231
14231
  for (let i = 1; i < containers1.length || containers2.length; i++) {
14232
14232
  if (containers1[i] === containers2[i]) {
@@ -14245,23 +14245,23 @@ var __publicField = (obj, key, value) => {
14245
14245
  }
14246
14246
  function getParentContainerInComplexBlock(parentComplexBlock, element) {
14247
14247
  let block = getParentBlock(element);
14248
- assert(logger$4p, block, "element is not in a block");
14248
+ assert(logger$4q, block, "element is not in a block");
14249
14249
  while (block) {
14250
14250
  const container = getParentContainer(block);
14251
- assert(logger$4p, isChildContainer(container), "not a child container");
14251
+ assert(logger$4q, isChildContainer(container), "not a child container");
14252
14252
  const parentBlock = getParentBlock(container);
14253
- assert(logger$4p, parentBlock, "child container has not parent block");
14253
+ assert(logger$4q, parentBlock, "child container has not parent block");
14254
14254
  if (parentBlock === parentComplexBlock) {
14255
14255
  return container;
14256
14256
  }
14257
14257
  block = parentBlock;
14258
14258
  }
14259
- assert(logger$4p, false, "failed to find parent container in complex block");
14259
+ assert(logger$4q, false, "failed to find parent container in complex block");
14260
14260
  }
14261
14261
  function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
14262
14262
  const blockId = getBlockId(complexBlock);
14263
- assert(logger$4p, blockId === anchor2.blockId, "invalid start pos");
14264
- assert(logger$4p, blockId === focus.blockId, "invalid end pos");
14263
+ assert(logger$4q, blockId === anchor2.blockId, "invalid start pos");
14264
+ assert(logger$4q, blockId === focus.blockId, "invalid end pos");
14265
14265
  const blockClass = getComplexBlockClass(editor, complexBlock);
14266
14266
  if (blockClass.adjustSelectionPos) {
14267
14267
  return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
@@ -14295,8 +14295,8 @@ var __publicField = (obj, key, value) => {
14295
14295
  if (focus instanceof EditorComplexBlockPosition) {
14296
14296
  focus = createSimpleBlockPosition(focusBlock, getBlockTextLength$6(editor, focusBlock), "end");
14297
14297
  }
14298
- assert(logger$4p, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
14299
- assert(logger$4p, focus instanceof EditorSimpleBlockPosition, "not valid position type");
14298
+ assert(logger$4q, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
14299
+ assert(logger$4q, focus instanceof EditorSimpleBlockPosition, "not valid position type");
14300
14300
  return {
14301
14301
  anchor: anchor2,
14302
14302
  focus
@@ -14350,7 +14350,7 @@ var __publicField = (obj, key, value) => {
14350
14350
  focus
14351
14351
  };
14352
14352
  }
14353
- const logger$4o = getLogger("core");
14353
+ const logger$4p = getLogger("core");
14354
14354
  function createBlockAnchor(editor, block, id, refClientRect) {
14355
14355
  const tools = getBlockTools(block);
14356
14356
  let elem = tools.querySelector(`.block-anchor[data-id=${id}]`);
@@ -14368,7 +14368,7 @@ var __publicField = (obj, key, value) => {
14368
14368
  return elem;
14369
14369
  }
14370
14370
  function createBlockCaretAnchor(editor, block, offset, id) {
14371
- assert(logger$4o, isTextKindBlock(editor, block), "not a text kind block");
14371
+ assert(logger$4p, isTextKindBlock(editor, block), "not a text kind block");
14372
14372
  const caretRect = getTextCaretRect(block, createSimpleBlockPosition(block, offset, "normal"));
14373
14373
  const blockRect = block.getBoundingClientRect();
14374
14374
  const tools = getBlockTools(block);
@@ -14727,19 +14727,19 @@ var __publicField = (obj, key, value) => {
14727
14727
  return result + (index2 ? "-" : "") + word.toLowerCase();
14728
14728
  });
14729
14729
  const kebabCase$1 = kebabCase;
14730
- const logger$4n = getLogger("box");
14730
+ const logger$4o = getLogger("box");
14731
14731
  function isBoxOp(op) {
14732
14732
  if (!op.attributes)
14733
14733
  return false;
14734
14734
  if (!op.attributes.box)
14735
14735
  return false;
14736
- assert(logger$4n, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
14737
- assert(logger$4n, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
14736
+ assert(logger$4o, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
14737
+ assert(logger$4o, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
14738
14738
  return true;
14739
14739
  }
14740
- const logger$4m = getLogger("text-op");
14740
+ const logger$4n = getLogger("text-op");
14741
14741
  function getOpLength(op) {
14742
- assert(logger$4m, typeof op.insert === "string", "invalid op, no insert");
14742
+ assert(logger$4n, typeof op.insert === "string", "invalid op, no insert");
14743
14743
  return op.insert.length;
14744
14744
  }
14745
14745
  function getOpAt(text2, offset) {
@@ -14747,7 +14747,7 @@ var __publicField = (obj, key, value) => {
14747
14747
  let pos = 0;
14748
14748
  for (let i = 0; i < ops.length; i++) {
14749
14749
  const op = ops[i];
14750
- assert(logger$4m, typeof op.insert === "string", "invalid text op, no insert");
14750
+ assert(logger$4n, typeof op.insert === "string", "invalid text op, no insert");
14751
14751
  const end = pos + getOpLength(op);
14752
14752
  if (end > offset) {
14753
14753
  return [op];
@@ -14763,22 +14763,22 @@ var __publicField = (obj, key, value) => {
14763
14763
  }
14764
14764
  return [];
14765
14765
  }
14766
- const logger$4l = getLogger("rich-text-length");
14766
+ const logger$4m = getLogger("rich-text-length");
14767
14767
  function getTextOpLength(op) {
14768
- assert(logger$4l, typeof op.insert === "string", "op.insert is not string");
14768
+ assert(logger$4m, typeof op.insert === "string", "op.insert is not string");
14769
14769
  return op.insert.length;
14770
14770
  }
14771
14771
  function getTextLength(ops) {
14772
14772
  let count = 0;
14773
14773
  ops.forEach((op) => {
14774
14774
  if (op.insert) {
14775
- assert(logger$4l, typeof op.insert === "string", "op.insert is not string");
14775
+ assert(logger$4m, typeof op.insert === "string", "op.insert is not string");
14776
14776
  count += getTextOpLength(op);
14777
14777
  }
14778
14778
  });
14779
14779
  return count;
14780
14780
  }
14781
- const logger$4k = getLogger("split-text");
14781
+ const logger$4l = getLogger("split-text");
14782
14782
  function splitText(ops, offset, splitResult) {
14783
14783
  ops = cloneDeep__default.default(ops);
14784
14784
  if (offset === 0) {
@@ -14796,8 +14796,8 @@ var __publicField = (obj, key, value) => {
14796
14796
  let counted = 0;
14797
14797
  for (let i = 0; i < ops.length; i++) {
14798
14798
  const op = ops[i];
14799
- assert(logger$4k, typeof op === "object", `invalid op type, ${typeof op}`);
14800
- assert(logger$4k, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
14799
+ assert(logger$4l, typeof op === "object", `invalid op type, ${typeof op}`);
14800
+ assert(logger$4l, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
14801
14801
  const subLen = getTextOpLength(op);
14802
14802
  if (counted + subLen < offset) {
14803
14803
  counted += subLen;
@@ -14807,18 +14807,18 @@ var __publicField = (obj, key, value) => {
14807
14807
  right: ops.slice(i + 1)
14808
14808
  };
14809
14809
  } else {
14810
- assert(logger$4k, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
14810
+ assert(logger$4l, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
14811
14811
  const splitIndex = offset - counted;
14812
14812
  const copied = cloneDeep__default.default(op);
14813
- assert(logger$4k, copied.insert, "no copied.insert");
14814
- assert(logger$4k, typeof copied.insert === "string", "invalid copied.insert type");
14813
+ assert(logger$4l, copied.insert, "no copied.insert");
14814
+ assert(logger$4l, typeof copied.insert === "string", "invalid copied.insert type");
14815
14815
  copied.insert = copied.insert.substr(0, splitIndex);
14816
14816
  op.insert = op.insert.substr(splitIndex);
14817
14817
  if (copied.insert === "") {
14818
- assert(logger$4k, false, "invalid copied.insert, is empty string");
14818
+ assert(logger$4l, false, "invalid copied.insert, is empty string");
14819
14819
  }
14820
14820
  if (op.insert === "") {
14821
- assert(logger$4k, false, "invalid op.insert, is empty string");
14821
+ assert(logger$4l, false, "invalid op.insert, is empty string");
14822
14822
  }
14823
14823
  const right = [
14824
14824
  op,
@@ -14837,9 +14837,9 @@ var __publicField = (obj, key, value) => {
14837
14837
  throw new Error(`invalid split offset: ${offset}, ${JSON.stringify(ops)}`);
14838
14838
  }
14839
14839
  function splitToThree(text2, offset, length) {
14840
- assert(logger$4k, offset >= 0, "invalid offset, < 0");
14841
- assert(logger$4k, length > 0, "invalid length, <= 0");
14842
- assert(logger$4k, offset + length <= getTextLength(text2), "invalid offset + length < text length");
14840
+ assert(logger$4l, offset >= 0, "invalid offset, < 0");
14841
+ assert(logger$4l, length > 0, "invalid length, <= 0");
14842
+ assert(logger$4l, offset + length <= getTextLength(text2), "invalid offset + length < text length");
14843
14843
  const { left: temp, right } = splitText(text2, offset + length);
14844
14844
  const { left, right: middle } = splitText(temp, offset);
14845
14845
  return { left, middle, right };
@@ -15062,9 +15062,9 @@ var __publicField = (obj, key, value) => {
15062
15062
  }
15063
15063
  return [color, backgroundColor];
15064
15064
  }
15065
- const logger$4j = getLogger("text-block-content");
15065
+ const logger$4k = getLogger("text-block-content");
15066
15066
  function updateBlockContentCore(editor, blockPath, content, blockText, insertions) {
15067
- assert(logger$4j, blockText, "no text for block");
15067
+ assert(logger$4k, blockText, "no text for block");
15068
15068
  if (blockText.length === 0 && (!insertions || insertions.size === 0)) {
15069
15069
  content.innerHTML = "<span><br></span>";
15070
15070
  return;
@@ -15096,9 +15096,9 @@ var __publicField = (obj, key, value) => {
15096
15096
  for (let i2 = 0; i2 < text2.length; i2++) {
15097
15097
  const op = text2[i2];
15098
15098
  if (isBoxOp(op)) {
15099
- assert(logger$4j, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
15099
+ assert(logger$4k, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
15100
15100
  const span2 = editor.editorBoxes.createBox(content, op.attributes);
15101
- assert(logger$4j, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
15101
+ assert(logger$4k, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
15102
15102
  const ret = editor.editorBlockRenders.renderBox(blockPath, op.attributes);
15103
15103
  if (ret.classes) {
15104
15104
  addClass(span2, ...ret.classes);
@@ -15116,7 +15116,7 @@ var __publicField = (obj, key, value) => {
15116
15116
  fragment.appendChild(span2);
15117
15117
  continue;
15118
15118
  }
15119
- assert(logger$4j, op.insert, `no insert in op: ${JSON.stringify(op)}`);
15119
+ assert(logger$4k, op.insert, `no insert in op: ${JSON.stringify(op)}`);
15120
15120
  const span = createElement("span", ["text"], fragment, op.insert);
15121
15121
  if (op.attributes) {
15122
15122
  const ret = editor.editorBlockRenders.renderText(blockPath, op.attributes);
@@ -15147,7 +15147,7 @@ var __publicField = (obj, key, value) => {
15147
15147
  const compositionText = editor.compositingText;
15148
15148
  if (compositionText) {
15149
15149
  const pos = editor.selection.range.start;
15150
- assert(logger$4j, pos.isSimple(), "not an simple position while compositing");
15150
+ assert(logger$4k, pos.isSimple(), "not an simple position while compositing");
15151
15151
  if (pos.blockId === blockId) {
15152
15152
  const attributes = getAttributesAt(text2, 0);
15153
15153
  insertions.set(pos.offset, [{
@@ -15163,11 +15163,11 @@ var __publicField = (obj, key, value) => {
15163
15163
  function clearAllTempCompositionText(editor) {
15164
15164
  const children = editor.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');
15165
15165
  if (children.length) {
15166
- logger$4j.debug(`remove ${children.length} temp composition span`);
15166
+ logger$4k.debug(`remove ${children.length} temp composition span`);
15167
15167
  }
15168
15168
  Array.from(children).forEach((c) => c.remove());
15169
15169
  }
15170
- const logger$4i = getLogger("client-rects");
15170
+ const logger$4j = getLogger("client-rects");
15171
15171
  function getChildrenOffsets(block) {
15172
15172
  const children = getTextBlockContentChildren(block);
15173
15173
  let start = 0;
@@ -15185,15 +15185,15 @@ var __publicField = (obj, key, value) => {
15185
15185
  return ret;
15186
15186
  }
15187
15187
  function getChildrenInRange(editor, block, from, to) {
15188
- assert(logger$4i, from < to, `invalid from & to: ${from}, ${to}`);
15188
+ assert(logger$4j, from < to, `invalid from & to: ${from}, ${to}`);
15189
15189
  const blockLength = getBlockTextLength$6(editor, block);
15190
- assert(logger$4i, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
15190
+ assert(logger$4j, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
15191
15191
  const offsets = getChildrenOffsets(block);
15192
15192
  const startIndex = offsets.findIndex((c) => c.startBlockOffset <= from && from < c.endBlockOffset);
15193
15193
  const endIndex = offsets.findIndex((c) => c.startBlockOffset < to && to <= c.endBlockOffset);
15194
- assert(logger$4i, startIndex !== -1, "failed to find start child");
15195
- assert(logger$4i, endIndex !== -1, "failed to find end child");
15196
- assert(logger$4i, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
15194
+ assert(logger$4j, startIndex !== -1, "failed to find start child");
15195
+ assert(logger$4j, endIndex !== -1, "failed to find end child");
15196
+ assert(logger$4j, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
15197
15197
  if (startIndex === endIndex) {
15198
15198
  const child = offsets[startIndex];
15199
15199
  return [{
@@ -15275,16 +15275,16 @@ var __publicField = (obj, key, value) => {
15275
15275
  return rects;
15276
15276
  }
15277
15277
  function getRangeClientRects(editor, block, range) {
15278
- assert(logger$4i, range instanceof EditorSimpleSelectionRange, "invalid range");
15278
+ assert(logger$4j, range instanceof EditorSimpleSelectionRange, "invalid range");
15279
15279
  const start = range.start;
15280
15280
  const end = range.end;
15281
- assert(logger$4i, start.isSimple(), "text block only allow simple position");
15282
- assert(logger$4i, end.isSimple(), "text block only allow simple position");
15283
- assert(logger$4i, start.blockId === end.blockId, "only allow update one text block selection");
15284
- assert(logger$4i, start.blockId === getBlockId(block), "only allow update one text block selection");
15281
+ assert(logger$4j, start.isSimple(), "text block only allow simple position");
15282
+ assert(logger$4j, end.isSimple(), "text block only allow simple position");
15283
+ assert(logger$4j, start.blockId === end.blockId, "only allow update one text block selection");
15284
+ assert(logger$4j, start.blockId === getBlockId(block), "only allow update one text block selection");
15285
15285
  return getClientRects$2(editor, block, start, end);
15286
15286
  }
15287
- const logger$4h = getLogger("selection-background");
15287
+ const logger$4i = getLogger("selection-background");
15288
15288
  function getLineHeight(elem) {
15289
15289
  const style2 = window.getComputedStyle(elem);
15290
15290
  const lineHeightStyle = style2.getPropertyValue("line-height");
@@ -15304,9 +15304,9 @@ var __publicField = (obj, key, value) => {
15304
15304
  return lineHeight;
15305
15305
  }
15306
15306
  function updateSelection$4(editor, block, start, end) {
15307
- assert(logger$4h, start.isSimple(), "text block only allow simple position");
15308
- assert(logger$4h, end.isSimple(), "text block only allow simple position");
15309
- assert(logger$4h, start.blockId === end.blockId, "only allow update one text block selection");
15307
+ assert(logger$4i, start.isSimple(), "text block only allow simple position");
15308
+ assert(logger$4i, end.isSimple(), "text block only allow simple position");
15309
+ assert(logger$4i, start.blockId === end.blockId, "only allow update one text block selection");
15310
15310
  const from = start.offset;
15311
15311
  const to = end.offset;
15312
15312
  if (from === to) {
@@ -15365,7 +15365,7 @@ var __publicField = (obj, key, value) => {
15365
15365
  }
15366
15366
  });
15367
15367
  }
15368
- const logger$4g = getLogger("line-breaker");
15368
+ const logger$4h = getLogger("line-breaker");
15369
15369
  function mergeTextRects(rects) {
15370
15370
  const result = [];
15371
15371
  let lastRect = null;
@@ -15492,7 +15492,7 @@ var __publicField = (obj, key, value) => {
15492
15492
  }
15493
15493
  const textChild = child;
15494
15494
  const rects = mergeTextRects(textChild.getClientRects());
15495
- assert(logger$4g, rects.length > 0, "invalid text child dom");
15495
+ assert(logger$4h, rects.length > 0, "invalid text child dom");
15496
15496
  if (rects.length === 1) {
15497
15497
  const nextChild = children[i + 1];
15498
15498
  if (!nextChild) {
@@ -15517,10 +15517,10 @@ var __publicField = (obj, key, value) => {
15517
15517
  continue;
15518
15518
  }
15519
15519
  const textNode = textChild.firstChild;
15520
- assert(logger$4g, textNode, "invalid text child, no text node");
15521
- assert(logger$4g, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
15520
+ assert(logger$4h, textNode, "invalid text child, no text node");
15521
+ assert(logger$4h, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
15522
15522
  const textChildLength = getTextBlockContentChildTextLength(textChild);
15523
- assert(logger$4g, textNode.data.length === textChildLength, "text node data length not equal child text length");
15523
+ assert(logger$4h, textNode.data.length === textChildLength, "text node data length not equal child text length");
15524
15524
  const textRects = getTextRects(textNode);
15525
15525
  for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
15526
15526
  const rect = textRects[rIndex];
@@ -15562,7 +15562,7 @@ var __publicField = (obj, key, value) => {
15562
15562
  }
15563
15563
  }
15564
15564
  }
15565
- assert(logger$4g, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
15565
+ assert(logger$4h, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
15566
15566
  return {
15567
15567
  lineIndex: lineBreaks.length,
15568
15568
  lineBreaks
@@ -24335,7 +24335,7 @@ var __publicField = (obj, key, value) => {
24335
24335
  const Graphemer_1 = __importDefault(Graphemer$1);
24336
24336
  var _default = lib$1.default = Graphemer_1.default;
24337
24337
  const splitter = new _default();
24338
- const logger$4f = getLogger("text-offset");
24338
+ const logger$4g = getLogger("text-offset");
24339
24339
  function getChildOffset(block, child) {
24340
24340
  const children = getTextBlockContentChildren(block);
24341
24341
  let start = 0;
@@ -24351,26 +24351,26 @@ var __publicField = (obj, key, value) => {
24351
24351
  }
24352
24352
  start += testLength;
24353
24353
  }
24354
- assert(logger$4f, false, "can not find child in children");
24354
+ assert(logger$4g, false, "can not find child in children");
24355
24355
  }
24356
24356
  function isValidOffset(block, blockOffset) {
24357
- assert(logger$4f, blockOffset >= 0, `invalid offset: ${blockOffset}`);
24357
+ assert(logger$4g, blockOffset >= 0, `invalid offset: ${blockOffset}`);
24358
24358
  const childInfo = getTextBlockChild(block, blockOffset);
24359
24359
  const { prev, next: next2, offset } = childInfo;
24360
24360
  if (!prev && !next2) {
24361
- assert(logger$4f, false, "invalid offset, no prev & next child at offset");
24361
+ assert(logger$4g, false, "invalid offset, no prev & next child at offset");
24362
24362
  }
24363
24363
  if (prev !== next2) {
24364
24364
  return true;
24365
24365
  }
24366
24366
  const child = prev;
24367
- assert(logger$4f, child, "no child");
24367
+ assert(logger$4g, child, "no child");
24368
24368
  if (isTextBlockContentBoxChild(child)) {
24369
- assert(logger$4f, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
24369
+ assert(logger$4g, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
24370
24370
  return true;
24371
24371
  }
24372
24372
  const text2 = child.textContent;
24373
- assert(logger$4f, text2, "no content for text child");
24373
+ assert(logger$4g, text2, "no content for text child");
24374
24374
  const chars = splitter.splitGraphemes(text2);
24375
24375
  const validOffsets = /* @__PURE__ */ new Set();
24376
24376
  let start = 0;
@@ -24400,7 +24400,7 @@ var __publicField = (obj, key, value) => {
24400
24400
  }
24401
24401
  function getNextValidOffset(block, blockOffset) {
24402
24402
  const length = getTextBlockLength(block);
24403
- assert(logger$4f, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
24403
+ assert(logger$4g, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
24404
24404
  if (blockOffset === length) {
24405
24405
  return length;
24406
24406
  }
@@ -24414,7 +24414,7 @@ var __publicField = (obj, key, value) => {
24414
24414
  }
24415
24415
  return ret;
24416
24416
  }
24417
- const logger$4e = getLogger("line-offset");
24417
+ const logger$4f = getLogger("line-offset");
24418
24418
  function getLineOffsets(block) {
24419
24419
  const lineBreaks = getLineBreaks(block);
24420
24420
  const ret = [];
@@ -24435,7 +24435,7 @@ var __publicField = (obj, key, value) => {
24435
24435
  }
24436
24436
  function getLineOffset(block, lineIndex) {
24437
24437
  const lines = getLineOffsets(block);
24438
- assert(logger$4e, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
24438
+ assert(logger$4f, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
24439
24439
  return lines[lineIndex];
24440
24440
  }
24441
24441
  function getLineOffsetByPos(block, pos) {
@@ -24492,7 +24492,7 @@ var __publicField = (obj, key, value) => {
24492
24492
  function getLineCount(block) {
24493
24493
  return getLineOffsets(block).length;
24494
24494
  }
24495
- const logger$4d = getLogger("find-text-position");
24495
+ const logger$4e = getLogger("find-text-position");
24496
24496
  function isWrappedLine(block, lineIndex) {
24497
24497
  const { start, end } = getLineOffset(block, lineIndex);
24498
24498
  const blockId = getBlockId(block);
@@ -24503,13 +24503,13 @@ var __publicField = (obj, key, value) => {
24503
24503
  return false;
24504
24504
  }
24505
24505
  const childInfo = getTextBlockChild(block, start);
24506
- assert(logger$4d, childInfo.next, "no next child at offset");
24507
- assert(logger$4d, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
24506
+ assert(logger$4e, childInfo.next, "no next child at offset");
24507
+ assert(logger$4e, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
24508
24508
  return true;
24509
24509
  }
24510
24510
  function getWrappedLineOffsets(block, lineIndex) {
24511
24511
  const blockId = getBlockId(block);
24512
- assert(logger$4d, isWrappedLine(block, lineIndex), "line is not wrapped");
24512
+ assert(logger$4e, isWrappedLine(block, lineIndex), "line is not wrapped");
24513
24513
  const { start, end } = getLineOffset(block, lineIndex);
24514
24514
  const homePos = createSimpleBlockPosition(blockId, start, "home");
24515
24515
  for (let offset = start + 1; offset <= end; offset += 1) {
@@ -24524,11 +24524,11 @@ var __publicField = (obj, key, value) => {
24524
24524
  return offset - 1;
24525
24525
  }
24526
24526
  }
24527
- assert(logger$4d, false, "failed to find wrapped offset");
24527
+ assert(logger$4e, false, "failed to find wrapped offset");
24528
24528
  return 0;
24529
24529
  }
24530
24530
  function findTextPositionInLine(editor, block, lineIndex, sourceBlock, pos, findDirection, suggestedX) {
24531
- assert(logger$4d, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
24531
+ assert(logger$4e, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
24532
24532
  const { start, end } = getLineOffset(block, lineIndex);
24533
24533
  let from = start;
24534
24534
  const blockId = getBlockId(block);
@@ -24570,11 +24570,11 @@ var __publicField = (obj, key, value) => {
24570
24570
  return retPos;
24571
24571
  }
24572
24572
  function findPrevTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
24573
- assert(logger$4d, isTextKindBlock(editor, block), "not a text block");
24573
+ assert(logger$4e, isTextKindBlock(editor, block), "not a text block");
24574
24574
  return findTextPositionInLine(editor, block, getLineCount(block) - 1, sourceBlock, pos, "up", suggestedX);
24575
24575
  }
24576
24576
  function findNextTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
24577
- assert(logger$4d, isTextKindBlock(editor, block), "not a text block");
24577
+ assert(logger$4e, isTextKindBlock(editor, block), "not a text block");
24578
24578
  return findTextPositionInLine(editor, block, 0, sourceBlock, pos, "down", suggestedX);
24579
24579
  }
24580
24580
  function moveDown(editor, block, position, suggestedX) {
@@ -24682,7 +24682,7 @@ var __publicField = (obj, key, value) => {
24682
24682
  }
24683
24683
  return pos;
24684
24684
  }
24685
- const logger$4c = getLogger("move-caret");
24685
+ const logger$4d = getLogger("move-caret");
24686
24686
  function moveTextCaret(editor, block, position, direction) {
24687
24687
  if (direction === "ArrowLeft") {
24688
24688
  const ret = moveLeft(block, position);
@@ -24712,9 +24712,9 @@ var __publicField = (obj, key, value) => {
24712
24712
  }
24713
24713
  return createSimpleBlockPosition(getBlockId(block), ret.offset, ret.type);
24714
24714
  }
24715
- assert(logger$4c, false, `invalid navigation direction: ${direction}`);
24715
+ assert(logger$4d, false, `invalid navigation direction: ${direction}`);
24716
24716
  }
24717
- const logger$4b = getLogger("text-range");
24717
+ const logger$4c = getLogger("text-range");
24718
24718
  function getBlockRects(block) {
24719
24719
  const ret = [];
24720
24720
  const children = getTextBlockContentChildren(block);
@@ -24772,9 +24772,9 @@ var __publicField = (obj, key, value) => {
24772
24772
  return null;
24773
24773
  }
24774
24774
  const children = getTextBlockContentChildren(block);
24775
- assert(logger$4b, children.indexOf(child) !== -1, "failed to find child in children");
24775
+ assert(logger$4c, children.indexOf(child) !== -1, "failed to find child in children");
24776
24776
  const offsetInfo = getChildOffset(block, child);
24777
- assert(logger$4b, offsetInfo, "failed to get child offset");
24777
+ assert(logger$4c, offsetInfo, "failed to get child offset");
24778
24778
  const { start } = offsetInfo;
24779
24779
  let offset;
24780
24780
  let length;
@@ -24790,7 +24790,7 @@ var __publicField = (obj, key, value) => {
24790
24790
  }
24791
24791
  length = 0;
24792
24792
  } else {
24793
- assert(logger$4b, child.firstChild instanceof Text, "child is not text");
24793
+ assert(logger$4c, child.firstChild instanceof Text, "child is not text");
24794
24794
  offset = start + textNodeOffsetFromPoint(child.firstChild, x, y);
24795
24795
  length = 0;
24796
24796
  }
@@ -24823,9 +24823,9 @@ var __publicField = (obj, key, value) => {
24823
24823
  }
24824
24824
  return versions;
24825
24825
  }
24826
- const logger$4a = getLogger("create-text-op");
24826
+ const logger$4b = getLogger("create-text-op");
24827
24827
  function createTextOp(text2, attributes) {
24828
- assert(logger$4a, text2, "text is empty");
24828
+ assert(logger$4b, text2, "text is empty");
24829
24829
  const ret = {
24830
24830
  insert: text2
24831
24831
  };
@@ -24848,7 +24848,7 @@ var __publicField = (obj, key, value) => {
24848
24848
  }
24849
24849
  return result;
24850
24850
  }
24851
- const logger$49 = getLogger("merge-ops");
24851
+ const logger$4a = getLogger("merge-ops");
24852
24852
  function mergeOps(text2) {
24853
24853
  if (text2.length <= 1) {
24854
24854
  return text2;
@@ -24870,10 +24870,10 @@ var __publicField = (obj, key, value) => {
24870
24870
  return false;
24871
24871
  }
24872
24872
  if (op1.attributes === void 0) {
24873
- assert(logger$49, op2.attributes === void 0, "op2.attributes is not undefined");
24873
+ assert(logger$4a, op2.attributes === void 0, "op2.attributes is not undefined");
24874
24874
  return true;
24875
24875
  }
24876
- assert(logger$49, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
24876
+ assert(logger$4a, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
24877
24877
  return isEqual__default.default(op1.attributes, op2.attributes);
24878
24878
  };
24879
24879
  const newOps = [];
@@ -24882,8 +24882,8 @@ var __publicField = (obj, key, value) => {
24882
24882
  for (let i = 1; i < text2.length; i += 1) {
24883
24883
  const op = text2[i];
24884
24884
  if (isSameTypeOp(before, op)) {
24885
- assert(logger$49, typeof before.insert === "string", "before.insert is not string");
24886
- assert(logger$49, typeof op.insert === "string", "op.insert is not string");
24885
+ assert(logger$4a, typeof before.insert === "string", "before.insert is not string");
24886
+ assert(logger$4a, typeof op.insert === "string", "op.insert is not string");
24887
24887
  before.insert += op.insert;
24888
24888
  } else {
24889
24889
  newOps.push(op);
@@ -24911,15 +24911,15 @@ var __publicField = (obj, key, value) => {
24911
24911
  }
24912
24912
  return text2.slice(0, i + 1);
24913
24913
  }
24914
- const logger$48 = getLogger("delete-text");
24914
+ const logger$49 = getLogger("delete-text");
24915
24915
  function deleteText(richText2, offset, count) {
24916
24916
  const { left, right } = splitToThree(richText2, offset, count);
24917
24917
  const result = [...left, ...right];
24918
24918
  return mergeOps(result);
24919
24919
  }
24920
24920
  function createDeleteOps(offset, count) {
24921
- assert(logger$48, offset >= 0, `invalid offset: ${offset}`);
24922
- assert(logger$48, count >= 1, `invalid delete count: ${count}`);
24921
+ assert(logger$49, offset >= 0, `invalid offset: ${offset}`);
24922
+ assert(logger$49, count >= 1, `invalid delete count: ${count}`);
24923
24923
  const ops = [];
24924
24924
  if (offset !== 0) {
24925
24925
  ops.push({
@@ -24931,7 +24931,7 @@ var __publicField = (obj, key, value) => {
24931
24931
  });
24932
24932
  return ops;
24933
24933
  }
24934
- const logger$47 = getLogger("delta");
24934
+ const logger$48 = getLogger("delta");
24935
24935
  function diffRichText(oldText, newText) {
24936
24936
  const delta1D = new Delta__default.default(oldText);
24937
24937
  const delta2D = new Delta__default.default(newText);
@@ -24941,7 +24941,7 @@ var __publicField = (obj, key, value) => {
24941
24941
  return new Delta__default.default(ops).transformPosition(cursor, !isLocalOp);
24942
24942
  }
24943
24943
  function isValidDocText(text2) {
24944
- assert(logger$47, text2, "ops is null or undefined");
24944
+ assert(logger$48, text2, "ops is null or undefined");
24945
24945
  for (let i = 0; i < text2.length; i++) {
24946
24946
  const op = text2[i];
24947
24947
  if (op.insert === null || op.insert === void 0) {
@@ -24961,7 +24961,7 @@ var __publicField = (obj, key, value) => {
24961
24961
  }
24962
24962
  class RichText {
24963
24963
  static ensureValidText(text2) {
24964
- assert(logger$47, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
24964
+ assert(logger$48, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
24965
24965
  }
24966
24966
  static diff(oldText, newText) {
24967
24967
  this.ensureValidText(oldText);
@@ -24983,9 +24983,9 @@ var __publicField = (obj, key, value) => {
24983
24983
  return resultText;
24984
24984
  }
24985
24985
  }
24986
- const logger$46 = getLogger("insert-text");
24986
+ const logger$47 = getLogger("insert-text");
24987
24987
  function insertText(richText2, offset, text2, attributes) {
24988
- assert(logger$46, text2, `invalid text to insert: ${text2}`);
24988
+ assert(logger$47, text2, `invalid text to insert: ${text2}`);
24989
24989
  const { left, right } = splitText(richText2, offset);
24990
24990
  const insertedText = typeof text2 === "string" ? [createTextOp(text2, attributes)] : text2;
24991
24991
  const result = [...left, ...insertedText, ...right];
@@ -24998,7 +24998,7 @@ var __publicField = (obj, key, value) => {
24998
24998
  };
24999
24999
  }
25000
25000
  function createInsertOps(offset, text2, attributes) {
25001
- assert(logger$46, offset >= 0, `invalid offset: ${offset}`);
25001
+ assert(logger$47, offset >= 0, `invalid offset: ${offset}`);
25002
25002
  if (text2.length === 0) {
25003
25003
  return [];
25004
25004
  }
@@ -25028,7 +25028,7 @@ var __publicField = (obj, key, value) => {
25028
25028
  function cloneText(text2) {
25029
25029
  return cloneDeep__default.default(text2);
25030
25030
  }
25031
- const logger$45 = getLogger("update-op-attribute");
25031
+ const logger$46 = getLogger("update-op-attribute");
25032
25032
  function updateOpAttributes(orgOps, key, value, newAttributes) {
25033
25033
  const ops = cloneText(orgOps);
25034
25034
  const index2 = ops.findIndex((op2) => {
@@ -25036,7 +25036,7 @@ var __publicField = (obj, key, value) => {
25036
25036
  return false;
25037
25037
  return op2.attributes[key] === value;
25038
25038
  });
25039
- assert(logger$45, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
25039
+ assert(logger$46, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
25040
25040
  const op = ops[index2];
25041
25041
  op.attributes = {
25042
25042
  ...op.attributes,
@@ -25111,11 +25111,11 @@ var __publicField = (obj, key, value) => {
25111
25111
  ]);
25112
25112
  }
25113
25113
  const FILL_CHAR = "\u200B";
25114
- const logger$44 = getLogger("to-plain-text");
25114
+ const logger$45 = getLogger("to-plain-text");
25115
25115
  function toPlainText(ops, options) {
25116
25116
  let text2 = "";
25117
25117
  ops.forEach((op) => {
25118
- assert(logger$44, typeof op.insert === "string", "invalid op");
25118
+ assert(logger$45, typeof op.insert === "string", "invalid op");
25119
25119
  if (op.attributes && op.attributes.box === true) {
25120
25120
  if (options == null ? void 0 : options.boxReplacement) {
25121
25121
  text2 += options.boxReplacement;
@@ -25170,6 +25170,91 @@ var __publicField = (obj, key, value) => {
25170
25170
  focus: pos
25171
25171
  };
25172
25172
  }
25173
+ const logger$44 = getLogger("repair-duplicated-block-ids");
25174
+ const ROOT_CONTAINER_ID = "root";
25175
+ function buildChildContainersDelta(doc2, block) {
25176
+ const children = block.children;
25177
+ if (!Array.isArray(children) || children.length === 0) {
25178
+ return null;
25179
+ }
25180
+ const idMap = /* @__PURE__ */ new Map();
25181
+ const newContainers = [];
25182
+ children.forEach((oldChildId) => {
25183
+ const newChildId = genId();
25184
+ idMap.set(oldChildId, newChildId);
25185
+ const childBlocks = doc2.findContainerBlocks(oldChildId);
25186
+ newContainers.push({
25187
+ containerId: newChildId,
25188
+ blocks: childBlocks ? cloneDeep__default.default(childBlocks) : []
25189
+ });
25190
+ });
25191
+ doc2.localInsertChildContainers(newContainers);
25192
+ const insert = {
25193
+ children: children.map((oldChildId) => idMap.get(oldChildId))
25194
+ };
25195
+ const remove2 = ["children"];
25196
+ Object.keys(block).forEach((key) => {
25197
+ const oldChildId = children.find((childId) => key.startsWith(`${childId}_`));
25198
+ if (!oldChildId)
25199
+ return;
25200
+ const newChildId = idMap.get(oldChildId);
25201
+ insert[newChildId + key.substr(oldChildId.length)] = block[key];
25202
+ remove2.push(key);
25203
+ });
25204
+ return { insert, delete: remove2 };
25205
+ }
25206
+ function repairDuplicatedBlockIds(doc2, readonly) {
25207
+ const seenBlockIds = /* @__PURE__ */ new Set();
25208
+ const visitedContainers = /* @__PURE__ */ new Set();
25209
+ const duplicatedIds = [];
25210
+ let repaired = 0;
25211
+ const visitContainer = (containerId) => {
25212
+ var _a, _b;
25213
+ if (visitedContainers.has(containerId))
25214
+ return;
25215
+ visitedContainers.add(containerId);
25216
+ const blocks = doc2.findContainerBlocks(containerId);
25217
+ if (!blocks)
25218
+ return;
25219
+ const blockCount = blocks.length;
25220
+ for (let blockIndex = 0; blockIndex < blockCount; blockIndex += 1) {
25221
+ let block = doc2.getBlockData(containerId, blockIndex);
25222
+ if (seenBlockIds.has(block.id)) {
25223
+ duplicatedIds.push(block.id);
25224
+ if (readonly) {
25225
+ logger$44.warn(`duplicated block id ${block.id} at ${containerId}[${blockIndex}], readonly, skip repairing`);
25226
+ } else {
25227
+ const newId = genId();
25228
+ logger$44.warn(`repair duplicated block id ${block.id} -> ${newId} at ${containerId}[${blockIndex}]`);
25229
+ const childDelta = buildChildContainersDelta(doc2, block);
25230
+ doc2.localUpdateBlockData(
25231
+ containerId,
25232
+ blockIndex,
25233
+ {
25234
+ insert: { id: newId, ...(_a = childDelta == null ? void 0 : childDelta.insert) != null ? _a : {} },
25235
+ delete: ["id", ...(_b = childDelta == null ? void 0 : childDelta.delete) != null ? _b : []]
25236
+ },
25237
+ createBlockSimpleDocRange(newId, 0)
25238
+ );
25239
+ repaired += 1;
25240
+ block = doc2.getBlockData(containerId, blockIndex);
25241
+ }
25242
+ }
25243
+ seenBlockIds.add(block.id);
25244
+ const children = block.children;
25245
+ if (Array.isArray(children)) {
25246
+ children.forEach(visitContainer);
25247
+ }
25248
+ }
25249
+ };
25250
+ visitContainer(ROOT_CONTAINER_ID);
25251
+ if (duplicatedIds.length > 0) {
25252
+ logger$44.error(
25253
+ `found ${duplicatedIds.length} duplicated block id(s): ${duplicatedIds.join(", ")}, repaired ${repaired}`
25254
+ );
25255
+ }
25256
+ return { repaired, duplicatedIds };
25257
+ }
25173
25258
  const logger$43 = getLogger("block-to-text");
25174
25259
  function textBlockToText$1(editor, ops, doc2) {
25175
25260
  let text2 = "";
@@ -32282,6 +32367,7 @@ ${codeText}
32282
32367
  this.id = (_l = optionalOptions == null ? void 0 : optionalOptions.id) != null ? _l : genId();
32283
32368
  this.clientId = genId();
32284
32369
  this.undoManager = new UndoManager(this);
32370
+ repairDuplicatedBlockIds(doc2, this._readonly);
32285
32371
  this.doc = new EditorDoc(this, doc2, this.undoManager);
32286
32372
  this.parent = parent;
32287
32373
  this.rootElement = createElement("div", ["editor-root"], this.parent);
@@ -97575,7 +97661,7 @@ ${JSON.stringify(error2, null, 2)}`);
97575
97661
  }
97576
97662
  }
97577
97663
  });
97578
- editor.version = "5.0.4-beta.h1449.3";
97664
+ editor.version = "5.0.4";
97579
97665
  return editor;
97580
97666
  }
97581
97667
  function isDoc(doc2) {
@@ -97711,7 +97797,7 @@ ${JSON.stringify(error2, null, 2)}`);
97711
97797
  OnesEditorDropTarget.register(editor);
97712
97798
  OnesEditorTocProvider.register(editor);
97713
97799
  OnesEditorExclusiveBlock.register(editor);
97714
- editor.version = "5.0.4-beta.h1449.3";
97800
+ editor.version = "5.0.4";
97715
97801
  return editor;
97716
97802
  } catch (error2) {
97717
97803
  try {
@@ -97854,7 +97940,7 @@ ${JSON.stringify(error2, null, 2)}`);
97854
97940
  }
97855
97941
  }
97856
97942
  });
97857
- editor.version = "5.0.4-beta.h1449.3";
97943
+ editor.version = "5.0.4";
97858
97944
  return editor;
97859
97945
  }
97860
97946
  const emojis$1 = {
@@ -144332,7 +144418,7 @@ ${JSON.stringify(error2, null, 2)}`);
144332
144418
  exports2.loadJs = loadJs;
144333
144419
  exports2.loadJsPromise = loadJsPromise;
144334
144420
  exports2.lockers = lockers;
144335
- exports2.logger = logger$4u;
144421
+ exports2.logger = logger$4v;
144336
144422
  exports2.markdownToDoc = markdownToDoc;
144337
144423
  exports2.mergeCommands = mergeCommands;
144338
144424
  exports2.mergeDocs = mergeDocs;
@@ -144355,6 +144441,7 @@ ${JSON.stringify(error2, null, 2)}`);
144355
144441
  exports2.removeLastBr = removeLastBr;
144356
144442
  exports2.removePlaceholderFromBlock = removePlaceholderFromBlock;
144357
144443
  exports2.removeStyle = removeStyle;
144444
+ exports2.repairDuplicatedBlockIds = repairDuplicatedBlockIds;
144358
144445
  exports2.replaceAll = replaceAll$1;
144359
144446
  exports2.replaceAllCaseInsensitive = replaceAllCaseInsensitive;
144360
144447
  exports2.replaceAllText = replaceAllText;