@ones-editor/editor 4.0.4-beta.h1448.3 → 4.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
@@ -9330,7 +9330,7 @@ var __publicField = (obj, key, value) => {
9330
9330
  imageExportFailed: "Bild konnte nicht geladen werden"
9331
9331
  }
9332
9332
  };
9333
- const logger$4V = getLogger("i18n");
9333
+ const logger$4W = getLogger("i18n");
9334
9334
  const langs$3 = {
9335
9335
  "en-US": enUS$y,
9336
9336
  "zh-CN": zhCN$y,
@@ -9352,7 +9352,7 @@ var __publicField = (obj, key, value) => {
9352
9352
  function t$8(key, args) {
9353
9353
  const ret = i18n.get(key, args);
9354
9354
  if (ret === key) {
9355
- logger$4V.warn(`no locale value for key ${key}`);
9355
+ logger$4W.warn(`no locale value for key ${key}`);
9356
9356
  }
9357
9357
  return ret;
9358
9358
  }
@@ -9970,7 +9970,7 @@ var __publicField = (obj, key, value) => {
9970
9970
  this._callbacks.clear();
9971
9971
  }
9972
9972
  }
9973
- const logger$4U = getLogger("await-locker");
9973
+ const logger$4V = getLogger("await-locker");
9974
9974
  class AwaitLock {
9975
9975
  constructor() {
9976
9976
  __publicField(this, "_acquired", false);
@@ -10012,7 +10012,7 @@ var __publicField = (obj, key, value) => {
10012
10012
  }
10013
10013
  if (this._waitingResolvers.length > 0) {
10014
10014
  const resolve = this._waitingResolvers.shift();
10015
- assert(logger$4U, resolve, "Resolver missing");
10015
+ assert(logger$4V, resolve, "Resolver missing");
10016
10016
  resolve(void 0);
10017
10017
  } else {
10018
10018
  this._acquired = false;
@@ -10095,7 +10095,7 @@ var __publicField = (obj, key, value) => {
10095
10095
  isMobileSafari: false
10096
10096
  };
10097
10097
  clientType.isMobileSafari = clientType.isMobile && clientType.isSafari;
10098
- const logger$4T = getLogger("dom-utils");
10098
+ const logger$4U = getLogger("dom-utils");
10099
10099
  function addClass(dom, ...className) {
10100
10100
  if (dom && dom.nodeType === Node.ELEMENT_NODE) {
10101
10101
  dom.classList.add(...className);
@@ -10152,7 +10152,7 @@ var __publicField = (obj, key, value) => {
10152
10152
  range.setStart(node, offset);
10153
10153
  return range;
10154
10154
  } catch (err) {
10155
- assert(logger$4T, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
10155
+ assert(logger$4U, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
10156
10156
  }
10157
10157
  }
10158
10158
  function createExpandedRange(startNode, startOffset, endNode, endOffset) {
@@ -10162,17 +10162,17 @@ var __publicField = (obj, key, value) => {
10162
10162
  range.setEnd(endNode, endOffset);
10163
10163
  return range;
10164
10164
  } catch (err) {
10165
- assert(logger$4T, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
10165
+ assert(logger$4U, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
10166
10166
  }
10167
10167
  }
10168
10168
  function getFirstClientRect(elem) {
10169
10169
  const rects = elem.getClientRects();
10170
- assert(logger$4T, rects.length >= 1, "getFirstClientRect: no rects");
10170
+ assert(logger$4U, rects.length >= 1, "getFirstClientRect: no rects");
10171
10171
  return rects[0];
10172
10172
  }
10173
10173
  function getLastClientRect(elem) {
10174
10174
  const rects = elem.getClientRects();
10175
- assert(logger$4T, rects.length >= 1, "getLastClientRect: no rects");
10175
+ assert(logger$4U, rects.length >= 1, "getLastClientRect: no rects");
10176
10176
  return rects[rects.length - 1];
10177
10177
  }
10178
10178
  function getDistanceSquare(rect, x, y) {
@@ -10219,7 +10219,7 @@ var __publicField = (obj, key, value) => {
10219
10219
  return 0;
10220
10220
  }
10221
10221
  if (!elem1.parentElement || !elem2.parentElement) {
10222
- assert(logger$4T, false, "invalid dom node to compare");
10222
+ assert(logger$4U, false, "invalid dom node to compare");
10223
10223
  }
10224
10224
  if (elem1.parentElement === elem2.parentElement) {
10225
10225
  const children = Array.from(elem1.parentElement.children);
@@ -10236,7 +10236,7 @@ var __publicField = (obj, key, value) => {
10236
10236
  const parents1 = getParents(elem1);
10237
10237
  const parents2 = getParents(elem2);
10238
10238
  if (parents1[0] !== parents2[0]) {
10239
- assert(logger$4T, false, "invalid dom node to compare, different tree");
10239
+ assert(logger$4U, false, "invalid dom node to compare, different tree");
10240
10240
  }
10241
10241
  for (let i = 1; ; i++) {
10242
10242
  const parent1 = parents1[i];
@@ -10836,7 +10836,7 @@ var __publicField = (obj, key, value) => {
10836
10836
  }
10837
10837
  }
10838
10838
  const MIN_DISTANCE_THRESHOLD$3 = 3;
10839
- const logger$4S = getLogger("drag-drop");
10839
+ const logger$4T = getLogger("drag-drop");
10840
10840
  class DragDrop {
10841
10841
  constructor(options) {
10842
10842
  __publicField(this, "dragStarted", false);
@@ -10857,7 +10857,7 @@ var __publicField = (obj, key, value) => {
10857
10857
  var _a;
10858
10858
  event.preventDefault();
10859
10859
  event.stopPropagation();
10860
- assert(logger$4S, this.mouseDownEvent, "no mouse down event");
10860
+ assert(logger$4T, this.mouseDownEvent, "no mouse down event");
10861
10861
  const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
10862
10862
  const newPos = DragDrop.getEventPosition(event);
10863
10863
  const deltaX = newPos.x - oldPos.x;
@@ -10873,7 +10873,7 @@ var __publicField = (obj, key, value) => {
10873
10873
  });
10874
10874
  __publicField(this, "handleMouseUp", (event) => {
10875
10875
  if (event instanceof MouseEvent && event.button === 0 || event instanceof TouchEvent) {
10876
- assert(logger$4S, this.mouseDownEvent, "no mouse down event");
10876
+ assert(logger$4T, this.mouseDownEvent, "no mouse down event");
10877
10877
  const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
10878
10878
  const newPos = DragDrop.getEventPosition(event);
10879
10879
  const deltaX = newPos.x - oldPos.x;
@@ -10982,7 +10982,7 @@ var __publicField = (obj, key, value) => {
10982
10982
  const dragDrop = new DragDrop(options);
10983
10983
  return dragDrop;
10984
10984
  }
10985
- const logger$4R = getLogger("character");
10985
+ const logger$4S = getLogger("character");
10986
10986
  function checkChar(charCode, rangeList) {
10987
10987
  for (let i = 0; i < rangeList.length; i++) {
10988
10988
  const start = rangeList[i][0];
@@ -11033,7 +11033,7 @@ var __publicField = (obj, key, value) => {
11033
11033
  }
11034
11034
  function trimChar(s, char) {
11035
11035
  let c = char;
11036
- assert(logger$4R, c.length === 1, "invalid char length");
11036
+ assert(logger$4S, c.length === 1, "invalid char length");
11037
11037
  if (c === "]")
11038
11038
  c = "\\]";
11039
11039
  if (c === "\\")
@@ -11391,7 +11391,7 @@ var __publicField = (obj, key, value) => {
11391
11391
  return 200;
11392
11392
  }
11393
11393
  }
11394
- const logger$4Q = getLogger("editor-clipboard");
11394
+ const logger$4R = getLogger("editor-clipboard");
11395
11395
  async function setClipboardDataByEvent(items, event) {
11396
11396
  if (event.clipboardData) {
11397
11397
  const data2 = event.clipboardData;
@@ -11449,7 +11449,7 @@ var __publicField = (obj, key, value) => {
11449
11449
  document.body.removeChild(textarea2);
11450
11450
  return true;
11451
11451
  } catch (ex) {
11452
- logger$4Q.error(ex);
11452
+ logger$4R.error(ex);
11453
11453
  document.body.removeChild(textarea2);
11454
11454
  return false;
11455
11455
  }
@@ -11470,7 +11470,7 @@ var __publicField = (obj, key, value) => {
11470
11470
  document.body.removeChild(div);
11471
11471
  return true;
11472
11472
  } catch (ex) {
11473
- logger$4Q.error(ex);
11473
+ logger$4R.error(ex);
11474
11474
  document.body.removeChild(div);
11475
11475
  return false;
11476
11476
  }
@@ -11497,7 +11497,7 @@ var __publicField = (obj, key, value) => {
11497
11497
  await navigator.clipboard.write([clipboardItems]);
11498
11498
  return true;
11499
11499
  } catch (err) {
11500
- logger$4Q.error(err);
11500
+ logger$4R.error(err);
11501
11501
  return await execCommandCopy(items);
11502
11502
  }
11503
11503
  }
@@ -11553,7 +11553,7 @@ var __publicField = (obj, key, value) => {
11553
11553
  a.click();
11554
11554
  a.remove();
11555
11555
  }
11556
- const logger$4P = getLogger("auto-scroll");
11556
+ const logger$4Q = getLogger("auto-scroll");
11557
11557
  function scrollable(scrollElement, direction) {
11558
11558
  if (scrollElement.scrollHeight === scrollElement.clientHeight) {
11559
11559
  return false;
@@ -11577,7 +11577,7 @@ var __publicField = (obj, key, value) => {
11577
11577
  const isHorizontal = direction === "left" || direction === "right";
11578
11578
  const scroll = () => {
11579
11579
  if (!scrollable(scrollElement, direction)) {
11580
- logger$4P.debug("No need for scroll");
11580
+ logger$4Q.debug("No need for scroll");
11581
11581
  return null;
11582
11582
  }
11583
11583
  if (isHorizontal) {
@@ -11634,7 +11634,7 @@ var __publicField = (obj, key, value) => {
11634
11634
  if (this.scrolling) {
11635
11635
  return;
11636
11636
  }
11637
- logger$4P.debug(`scroll direction: ${direction}`);
11637
+ logger$4Q.debug(`scroll direction: ${direction}`);
11638
11638
  this.cancelScroll = continuousScroll(scrollElement, {
11639
11639
  direction,
11640
11640
  step
@@ -11884,7 +11884,7 @@ var __publicField = (obj, key, value) => {
11884
11884
  const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
11885
11885
  return ColorNames[colorIndex];
11886
11886
  }
11887
- const logger$4O = getLogger("container");
11887
+ const logger$4P = getLogger("container");
11888
11888
  function isContainer(elem) {
11889
11889
  return elem.getAttribute("data-type") === "editor-container";
11890
11890
  }
@@ -11896,9 +11896,9 @@ var __publicField = (obj, key, value) => {
11896
11896
  }
11897
11897
  function getContainerId(container) {
11898
11898
  const id = container.getAttribute("data-container-id");
11899
- assert(logger$4O, id, "no id for container");
11899
+ assert(logger$4P, id, "no id for container");
11900
11900
  if (isRootContainer(container)) {
11901
- assert(logger$4O, id === "root", `invalid root container id, : ${id}`);
11901
+ assert(logger$4P, id === "root", `invalid root container id, : ${id}`);
11902
11902
  }
11903
11903
  return id;
11904
11904
  }
@@ -11909,7 +11909,7 @@ var __publicField = (obj, key, value) => {
11909
11909
  function generateEditorContainerId(containerId) {
11910
11910
  return `ones-editor-container-${containerId}`;
11911
11911
  }
11912
- const logger$4N = getLogger("element");
11912
+ const logger$4O = getLogger("element");
11913
11913
  function createContainerElement(parent, type, containerId) {
11914
11914
  const container = createElement("div", [type], parent);
11915
11915
  container.setAttribute("data-type", "editor-container");
@@ -11920,7 +11920,7 @@ var __publicField = (obj, key, value) => {
11920
11920
  }
11921
11921
  function getContainerById(editor, containerId) {
11922
11922
  const container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
11923
- assert(logger$4N, container, `no container: ${containerId}`);
11923
+ assert(logger$4O, container, `no container: ${containerId}`);
11924
11924
  return container;
11925
11925
  }
11926
11926
  function getExistsContainerById(editor, containerId) {
@@ -11929,7 +11929,7 @@ var __publicField = (obj, key, value) => {
11929
11929
  }
11930
11930
  function getContainerBlocksElement(container) {
11931
11931
  const blocks = container.querySelector(":scope > .container-blocks");
11932
- assert(logger$4N, blocks, "no container blocks element");
11932
+ assert(logger$4O, blocks, "no container blocks element");
11933
11933
  return blocks;
11934
11934
  }
11935
11935
  function getContainerToolsElement(container) {
@@ -11942,11 +11942,11 @@ var __publicField = (obj, key, value) => {
11942
11942
  function isContainerBlocksElement(element) {
11943
11943
  return element.classList.contains("container-blocks");
11944
11944
  }
11945
- const logger$4M = getLogger("container-children");
11945
+ const logger$4N = getLogger("container-children");
11946
11946
  function getChildBlocks(container, traverseChild) {
11947
11947
  const content = getContainerBlocksElement(container);
11948
11948
  const blocks = Array.from(content.children);
11949
- assert(logger$4M, blocks.length > 0, "container have not any child block");
11949
+ assert(logger$4N, blocks.length > 0, "container have not any child block");
11950
11950
  if (traverseChild) {
11951
11951
  const { condition, editor } = traverseChild;
11952
11952
  return blocks.reduce((result, block) => {
@@ -11969,7 +11969,7 @@ var __publicField = (obj, key, value) => {
11969
11969
  }
11970
11970
  function getFirstChildBlock(container) {
11971
11971
  const block = container.querySelector(":scope > .container-blocks > div[data-type=editor-block]");
11972
- assert(logger$4M, block, "container have not any child block");
11972
+ assert(logger$4N, block, "container have not any child block");
11973
11973
  return block;
11974
11974
  }
11975
11975
  function getLastChildBlock(container) {
@@ -11981,14 +11981,14 @@ var __publicField = (obj, key, value) => {
11981
11981
  }
11982
11982
  function getBlockByIndex(container, blockIndex) {
11983
11983
  const block = getChildBlocks(container)[blockIndex];
11984
- assert(logger$4M, block, `container have not block at index ${blockIndex}`);
11984
+ assert(logger$4N, block, `container have not block at index ${blockIndex}`);
11985
11985
  return block;
11986
11986
  }
11987
11987
  function findBlockByIndex(container, blockIndex) {
11988
11988
  var _a;
11989
11989
  return (_a = getChildBlocks(container)[blockIndex]) != null ? _a : null;
11990
11990
  }
11991
- const logger$4L = getLogger("block-dom");
11991
+ const logger$4M = getLogger("block-dom");
11992
11992
  function isBlock$1(node) {
11993
11993
  if (!(node instanceof HTMLDivElement)) {
11994
11994
  return false;
@@ -12009,12 +12009,12 @@ var __publicField = (obj, key, value) => {
12009
12009
  }
12010
12010
  function getBlockId(block) {
12011
12011
  const { id } = block;
12012
- assert(logger$4L, id, "no block id");
12012
+ assert(logger$4M, id, "no block id");
12013
12013
  return id;
12014
12014
  }
12015
12015
  function getBlockType(block) {
12016
12016
  const type = block.getAttribute("data-block-type");
12017
- assert(logger$4L, type, "invalid block dom, no data-type");
12017
+ assert(logger$4M, type, "invalid block dom, no data-type");
12018
12018
  return type;
12019
12019
  }
12020
12020
  function getParentBlock(node) {
@@ -12037,12 +12037,12 @@ var __publicField = (obj, key, value) => {
12037
12037
  }
12038
12038
  function getParentContainer(block) {
12039
12039
  const container = block.closest("div[data-type=editor-container]");
12040
- assert(logger$4L, container, "failed to get block container");
12040
+ assert(logger$4M, container, "failed to get block container");
12041
12041
  return container;
12042
12042
  }
12043
12043
  function getBlockContent(block) {
12044
12044
  const content = block.querySelector(":scope >div[data-type=block-content]");
12045
- assert(logger$4L, content, "no block content");
12045
+ assert(logger$4M, content, "no block content");
12046
12046
  return content;
12047
12047
  }
12048
12048
  function getBlockTools(block) {
@@ -12051,7 +12051,7 @@ var __publicField = (obj, key, value) => {
12051
12051
  tools = createElement("div", [], block);
12052
12052
  tools.setAttribute("data-type", "block-tools");
12053
12053
  }
12054
- assert(logger$4L, tools, "no block tools");
12054
+ assert(logger$4M, tools, "no block tools");
12055
12055
  return tools;
12056
12056
  }
12057
12057
  function getExistsBlockTools(block) {
@@ -12072,7 +12072,7 @@ var __publicField = (obj, key, value) => {
12072
12072
  function createBlockElement(editor, path, data2) {
12073
12073
  const blockData = editor.editorDecorators.decorateBlock(path, data2);
12074
12074
  const { id, type } = blockData;
12075
- assert(logger$4L, id, "no block id");
12075
+ assert(logger$4M, id, "no block id");
12076
12076
  const elem = createElement("div", [`${type}-block`], null);
12077
12077
  elem.id = id;
12078
12078
  elem.setAttribute("data-type", "editor-block");
@@ -12110,7 +12110,7 @@ var __publicField = (obj, key, value) => {
12110
12110
  }
12111
12111
  function getBoxTypeFromElement(box) {
12112
12112
  const type = box.getAttribute("data-box-type");
12113
- assert(logger$4L, type, "not a valid box element, no type");
12113
+ assert(logger$4M, type, "not a valid box element, no type");
12114
12114
  return type;
12115
12115
  }
12116
12116
  function isBox(node) {
@@ -12121,7 +12121,7 @@ var __publicField = (obj, key, value) => {
12121
12121
  }
12122
12122
  function getBoxId(box) {
12123
12123
  const { id } = box;
12124
- assert(logger$4L, id, "no box id");
12124
+ assert(logger$4M, id, "no box id");
12125
12125
  return id;
12126
12126
  }
12127
12127
  function getParentBox(node) {
@@ -12143,7 +12143,7 @@ var __publicField = (obj, key, value) => {
12143
12143
  }
12144
12144
  function getBoxContent(box) {
12145
12145
  const content = box.querySelector("span[data-type=box-content]");
12146
- assert(logger$4L, content, "invalid box dom, no content");
12146
+ assert(logger$4M, content, "invalid box dom, no content");
12147
12147
  return content;
12148
12148
  }
12149
12149
  function createInsertionElement(type, id, attributes) {
@@ -12165,7 +12165,7 @@ var __publicField = (obj, key, value) => {
12165
12165
  }
12166
12166
  function getInsertionContent(insertion) {
12167
12167
  const content = insertion.querySelector("span[data-type=insertion-content]");
12168
- assert(logger$4L, content, "invalid insertion-child dom, no content");
12168
+ assert(logger$4M, content, "invalid insertion-child dom, no content");
12169
12169
  return content;
12170
12170
  }
12171
12171
  function getPrevBlock(block) {
@@ -12225,7 +12225,7 @@ var __publicField = (obj, key, value) => {
12225
12225
  const container = getParentContainer(block);
12226
12226
  const children = getChildBlocks(container);
12227
12227
  const index2 = children.indexOf(block);
12228
- assert(logger$4L, index2 !== -1, "invalid block & container dom, failed to get block index");
12228
+ assert(logger$4M, index2 !== -1, "invalid block & container dom, failed to get block index");
12229
12229
  return index2;
12230
12230
  }
12231
12231
  function isInBlock(target) {
@@ -12250,18 +12250,18 @@ var __publicField = (obj, key, value) => {
12250
12250
  function isTitleBlock$2(block) {
12251
12251
  return block.hasAttribute("data-document-title");
12252
12252
  }
12253
- const logger$4K = getLogger("block-class");
12253
+ const logger$4L = getLogger("block-class");
12254
12254
  function getBlockClass(editor, block) {
12255
12255
  return editor.editorBlocks.getBlockClass(getBlockType(block));
12256
12256
  }
12257
12257
  function getTextBlockClass(editor, block) {
12258
12258
  const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
12259
- assert(logger$4K, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
12259
+ assert(logger$4L, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
12260
12260
  return text2;
12261
12261
  }
12262
12262
  function getComplexBlockClass(editor, block) {
12263
12263
  const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
12264
- assert(logger$4K, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
12264
+ assert(logger$4L, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
12265
12265
  return complex;
12266
12266
  }
12267
12267
  function getBlockClassByType(editor, type) {
@@ -12282,7 +12282,7 @@ var __publicField = (obj, key, value) => {
12282
12282
  function getBlockKind(editor, block) {
12283
12283
  return getBlockClass(editor, block).blockKind;
12284
12284
  }
12285
- const logger$4J = getLogger("text-block-child");
12285
+ const logger$4K = getLogger("text-block-child");
12286
12286
  function isTextBlockContentChild(elem) {
12287
12287
  if (elem.tagName !== "SPAN") {
12288
12288
  return false;
@@ -12290,14 +12290,14 @@ var __publicField = (obj, key, value) => {
12290
12290
  return true;
12291
12291
  }
12292
12292
  function isTextBlockContentBoxChild(elem) {
12293
- assert(logger$4J, isTextBlockContentChild(elem), "not a valid text child");
12293
+ assert(logger$4K, isTextBlockContentChild(elem), "not a valid text child");
12294
12294
  if (elem.getAttribute("data-type") === "editor-box") {
12295
12295
  return true;
12296
12296
  }
12297
12297
  return false;
12298
12298
  }
12299
12299
  function isTextBlockContentInsertionChild(elem) {
12300
- assert(logger$4J, isTextBlockContentChild(elem), "not a valid text child");
12300
+ assert(logger$4K, isTextBlockContentChild(elem), "not a valid text child");
12301
12301
  if (elem.getAttribute("data-type") === "editor-insertion") {
12302
12302
  return true;
12303
12303
  }
@@ -12307,7 +12307,7 @@ var __publicField = (obj, key, value) => {
12307
12307
  return !isTextBlockContentBoxChild(elem) && !isTextBlockContentInsertionChild(elem);
12308
12308
  }
12309
12309
  function getTextBlockContentChildType(child) {
12310
- assert(logger$4J, isTextBlockContentChild(child), "not a valid text child");
12310
+ assert(logger$4K, isTextBlockContentChild(child), "not a valid text child");
12311
12311
  if (isTextBlockContentBoxChild(child)) {
12312
12312
  return "box";
12313
12313
  }
@@ -12322,15 +12322,15 @@ var __publicField = (obj, key, value) => {
12322
12322
  return 0;
12323
12323
  if (type === "box")
12324
12324
  return 1;
12325
- assert(logger$4J, child.textContent !== null, "text block content is undefined");
12326
- assert(logger$4J, child.textContent.length >= 0, "text block content length is negative");
12325
+ assert(logger$4K, child.textContent !== null, "text block content is undefined");
12326
+ assert(logger$4K, child.textContent.length >= 0, "text block content length is negative");
12327
12327
  return child.textContent.length;
12328
12328
  }
12329
12329
  function getTextBlockContentChildren(block) {
12330
12330
  const content = getBlockContent(block);
12331
12331
  const children = Array.from(content.children);
12332
12332
  children.forEach((child) => {
12333
- assert(logger$4J, isTextBlockContentChild(child), "not a valid text child");
12333
+ assert(logger$4K, isTextBlockContentChild(child), "not a valid text child");
12334
12334
  });
12335
12335
  return children;
12336
12336
  }
@@ -12359,17 +12359,17 @@ var __publicField = (obj, key, value) => {
12359
12359
  };
12360
12360
  }
12361
12361
  const offset = blockOffset - start;
12362
- assert(logger$4J, offset > 0, "invalid offset value");
12363
- assert(logger$4J, !isTextBlockContentBoxChild(child), "invalid box child");
12362
+ assert(logger$4K, offset > 0, "invalid offset value");
12363
+ assert(logger$4K, !isTextBlockContentBoxChild(child), "invalid box child");
12364
12364
  return {
12365
12365
  prev: child,
12366
12366
  next: child,
12367
12367
  offset
12368
12368
  };
12369
12369
  }
12370
- assert(logger$4J, false, `invalid block child at position: ${blockOffset}`);
12370
+ assert(logger$4K, false, `invalid block child at position: ${blockOffset}`);
12371
12371
  }
12372
- const logger$4I = getLogger("block-path");
12372
+ const logger$4J = getLogger("block-path");
12373
12373
  function getBlockPath(block) {
12374
12374
  const ret = [];
12375
12375
  let current = block;
@@ -12383,26 +12383,26 @@ var __publicField = (obj, key, value) => {
12383
12383
  return ret;
12384
12384
  }
12385
12385
  const parentBlock = getParentBlock(container);
12386
- assert(logger$4I, parentBlock, "no parent block");
12386
+ assert(logger$4J, parentBlock, "no parent block");
12387
12387
  current = parentBlock;
12388
12388
  }
12389
- assert(logger$4I, false, "no parent block");
12389
+ assert(logger$4J, false, "no parent block");
12390
12390
  return [];
12391
12391
  }
12392
- const logger$4H = getLogger("child-container-path");
12392
+ const logger$4I = getLogger("child-container-path");
12393
12393
  function getContainerBlockPath(container) {
12394
12394
  if (isRootContainer(container)) {
12395
12395
  return [];
12396
12396
  }
12397
12397
  const parentBlock = getParentBlock(container);
12398
- assert(logger$4H, parentBlock, "no parent block");
12398
+ assert(logger$4I, parentBlock, "no parent block");
12399
12399
  return getBlockPath(parentBlock);
12400
12400
  }
12401
- const logger$4G = getLogger("load-blocks");
12401
+ const logger$4H = getLogger("load-blocks");
12402
12402
  function loadBlocks(editor, container, path) {
12403
12403
  const containerId = getContainerId(container);
12404
12404
  const blocks = getContainerBlocks$1(container, editor.doc);
12405
- assert(logger$4G, blocks.length > 0, "no blocks in container");
12405
+ assert(logger$4H, blocks.length > 0, "no blocks in container");
12406
12406
  const fragment = document.createDocumentFragment();
12407
12407
  blocks.forEach((b, index2) => {
12408
12408
  const block = editor.editorBlocks.createBlock([...path, { containerId, blockIndex: index2 }], container, b);
@@ -12418,7 +12418,7 @@ var __publicField = (obj, key, value) => {
12418
12418
  return block;
12419
12419
  }
12420
12420
  const blocks = getChildBlocks(container);
12421
- assert(logger$4G, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
12421
+ assert(logger$4H, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
12422
12422
  if (blockIndex === blocks.length) {
12423
12423
  containerBlocksElement.appendChild(block);
12424
12424
  } else {
@@ -12436,7 +12436,7 @@ var __publicField = (obj, key, value) => {
12436
12436
  insertBlockAt(container, blockIndex, block);
12437
12437
  return block;
12438
12438
  }
12439
- const logger$4F = getLogger("root-container");
12439
+ const logger$4G = getLogger("root-container");
12440
12440
  const MIN_DISTANCE_THRESHOLD$2 = 3;
12441
12441
  class RootContainer {
12442
12442
  constructor(editor, rootContainer) {
@@ -12464,7 +12464,7 @@ var __publicField = (obj, key, value) => {
12464
12464
  this.editor.selection.updateSelection(null);
12465
12465
  this.editor.emit("resize", this.editor);
12466
12466
  } catch (err) {
12467
- logger$4F.warn(`failed to update selection while container resizing: ${err.message}`);
12467
+ logger$4G.warn(`failed to update selection while container resizing: ${err.message}`);
12468
12468
  }
12469
12469
  });
12470
12470
  __publicField(this, "handleClick", (event) => {
@@ -12498,7 +12498,7 @@ var __publicField = (obj, key, value) => {
12498
12498
  const box = getParentBox(elem);
12499
12499
  if (box && isChildNode(box, eTarget)) {
12500
12500
  const block2 = getParentBlock(box);
12501
- assert(logger$4F, block2, "no parent block");
12501
+ assert(logger$4G, block2, "no parent block");
12502
12502
  (_b = (_a = this.editor.editorBoxes.getBoxClass(getBoxTypeFromElement(box))) == null ? void 0 : _a.handleClickBox) == null ? void 0 : _b.call(_a, this.editor, box, event);
12503
12503
  return;
12504
12504
  }
@@ -12554,7 +12554,7 @@ var __publicField = (obj, key, value) => {
12554
12554
  this.editor.input.focus({ preventScroll: true });
12555
12555
  });
12556
12556
  __publicField(this, "handleMouseMove", (event) => {
12557
- assert(logger$4F, this.mouseDownEvent, "no mouse down event");
12557
+ assert(logger$4G, this.mouseDownEvent, "no mouse down event");
12558
12558
  if (ensureIsMobileEvent(this.mouseDownEvent))
12559
12559
  return;
12560
12560
  const deltaX = event.x - this.mouseDownEvent.x;
@@ -12670,7 +12670,7 @@ var __publicField = (obj, key, value) => {
12670
12670
  loadBlocks(editor, container, path);
12671
12671
  return container;
12672
12672
  }
12673
- const logger$4E = getLogger("block");
12673
+ const logger$4F = getLogger("block");
12674
12674
  function getBlockTextLength$6(editor, block) {
12675
12675
  return getBlockClass(editor, block).getBlockTextLength(block);
12676
12676
  }
@@ -12689,7 +12689,7 @@ var __publicField = (obj, key, value) => {
12689
12689
  return block;
12690
12690
  }
12691
12691
  const parent = getParentBlock(container);
12692
- assert(logger$4E, parent, "no parent block exists for child container");
12692
+ assert(logger$4F, parent, "no parent block exists for child container");
12693
12693
  block = parent;
12694
12694
  }
12695
12695
  }
@@ -12725,7 +12725,7 @@ var __publicField = (obj, key, value) => {
12725
12725
  }
12726
12726
  return fun(editor, block, options);
12727
12727
  } catch (err) {
12728
- logger$4E.debug(`unsupported block type: ${type}`);
12728
+ logger$4F.debug(`unsupported block type: ${type}`);
12729
12729
  return null;
12730
12730
  }
12731
12731
  }
@@ -12745,7 +12745,7 @@ var __publicField = (obj, key, value) => {
12745
12745
  const styles2 = Object.fromEntries(Object.entries(data2).filter(([key]) => key.startsWith("style-")));
12746
12746
  Object.entries(styles2).forEach(([, value]) => {
12747
12747
  const type = typeof value;
12748
- assert(logger$4E, type === "string" || type === "number" || type === "boolean", "invalid style value");
12748
+ assert(logger$4F, type === "string" || type === "number" || type === "boolean", "invalid style value");
12749
12749
  });
12750
12750
  return styles2;
12751
12751
  }
@@ -12870,7 +12870,7 @@ var __publicField = (obj, key, value) => {
12870
12870
  }
12871
12871
  return { element: null, blockCommands: [], boxCommands: [] };
12872
12872
  }
12873
- const logger$4D = getLogger("embed-block-common");
12873
+ const logger$4E = getLogger("embed-block-common");
12874
12874
  function isColumnsBlock(block) {
12875
12875
  return getBlockType(block) === "layout";
12876
12876
  }
@@ -12878,9 +12878,9 @@ var __publicField = (obj, key, value) => {
12878
12878
  return getBlockType(block) === "embed";
12879
12879
  }
12880
12880
  function getEmbedType(block) {
12881
- assert(logger$4D, isEmbedBlock(block), "not an embed block");
12881
+ assert(logger$4E, isEmbedBlock(block), "not an embed block");
12882
12882
  const type = block.getAttribute("data-embed-type");
12883
- assert(logger$4D, type, "no embed data type");
12883
+ assert(logger$4E, type, "no embed data type");
12884
12884
  return type;
12885
12885
  }
12886
12886
  function getEmbedClassFromBlock(editor, block) {
@@ -12946,10 +12946,10 @@ var __publicField = (obj, key, value) => {
12946
12946
  data: (_c = overrideOptions == null ? void 0 : overrideOptions.data) != null ? _c : data2
12947
12947
  });
12948
12948
  }
12949
- const logger$4C = getLogger("execute-block-command");
12949
+ const logger$4D = getLogger("execute-block-command");
12950
12950
  function executeEmbedBlockCommand(editor, block, commandGroup, item) {
12951
12951
  var _a;
12952
- assert(logger$4C, isEmbedBlock(block), "not a embed block");
12952
+ assert(logger$4D, isEmbedBlock(block), "not a embed block");
12953
12953
  const embedType = getEmbedType(block);
12954
12954
  const embed = getEmbedClassByType(editor, embedType);
12955
12955
  if (!embed.getOptions) {
@@ -12982,14 +12982,14 @@ var __publicField = (obj, key, value) => {
12982
12982
  }
12983
12983
  return void 0;
12984
12984
  }
12985
- const logger$4B = getLogger("block-class");
12985
+ const logger$4C = getLogger("block-class");
12986
12986
  function isHeadingBlock$1(block) {
12987
12987
  return !!block.getAttribute("data-style-heading");
12988
12988
  }
12989
12989
  function getBlockHeading(block) {
12990
12990
  var _a;
12991
12991
  const heading = Number.parseInt((_a = block.getAttribute("data-style-heading")) != null ? _a : "", 10);
12992
- assert(logger$4B, heading, "not a heading block");
12992
+ assert(logger$4C, heading, "not a heading block");
12993
12993
  return heading;
12994
12994
  }
12995
12995
  function isExpandedHeadingBlock(block) {
@@ -13000,7 +13000,7 @@ var __publicField = (obj, key, value) => {
13000
13000
  }
13001
13001
  function getHeadingBlockChildren(block, oldHeading) {
13002
13002
  if (!oldHeading) {
13003
- assert(logger$4B, isHeadingBlock$1(block), "not a heading block");
13003
+ assert(logger$4C, isHeadingBlock$1(block), "not a heading block");
13004
13004
  }
13005
13005
  const children = [];
13006
13006
  const heading = oldHeading != null ? oldHeading : getBlockHeading(block);
@@ -13030,7 +13030,7 @@ var __publicField = (obj, key, value) => {
13030
13030
  }
13031
13031
  return children;
13032
13032
  }
13033
- const logger$4A = getLogger("complex-block-position");
13033
+ const logger$4B = getLogger("complex-block-position");
13034
13034
  class EditorComplexBlockPosition {
13035
13035
  constructor(block, childContainerId, custom) {
13036
13036
  __publicField(this, "blockId");
@@ -13039,7 +13039,7 @@ var __publicField = (obj, key, value) => {
13039
13039
  if (block instanceof HTMLElement) {
13040
13040
  this.blockId = getBlockId(block);
13041
13041
  } else {
13042
- assert(logger$4A, typeof block === "string", `not a valid block id: ${block}`);
13042
+ assert(logger$4B, typeof block === "string", `not a valid block id: ${block}`);
13043
13043
  this.blockId = block;
13044
13044
  }
13045
13045
  this.childContainerId = childContainerId;
@@ -13051,7 +13051,7 @@ var __publicField = (obj, key, value) => {
13051
13051
  return false;
13052
13052
  }
13053
13053
  }
13054
- const logger$4z = getLogger("simple-block-position");
13054
+ const logger$4A = getLogger("simple-block-position");
13055
13055
  class EditorSimpleBlockPosition {
13056
13056
  constructor(block, offset, type) {
13057
13057
  __publicField(this, "blockId");
@@ -13060,7 +13060,7 @@ var __publicField = (obj, key, value) => {
13060
13060
  if (block instanceof HTMLElement) {
13061
13061
  this.blockId = getBlockId(block);
13062
13062
  } else {
13063
- assert(logger$4z, typeof block === "string", `not a valid block id: ${block}`);
13063
+ assert(logger$4A, typeof block === "string", `not a valid block id: ${block}`);
13064
13064
  this.blockId = block;
13065
13065
  }
13066
13066
  this.offset = offset;
@@ -13070,7 +13070,7 @@ var __publicField = (obj, key, value) => {
13070
13070
  return true;
13071
13071
  }
13072
13072
  }
13073
- const logger$4y = getLogger("editor-position");
13073
+ const logger$4z = getLogger("editor-position");
13074
13074
  function createSimpleBlockPosition(block, offset, type) {
13075
13075
  return new EditorSimpleBlockPosition(block, offset, type);
13076
13076
  }
@@ -13092,7 +13092,7 @@ var __publicField = (obj, key, value) => {
13092
13092
  }
13093
13093
  const block1 = editor.getBlockById(pos1.blockId);
13094
13094
  const block2 = editor.getBlockById(pos2.blockId);
13095
- assert(logger$4y, block1 !== block2, "comparePosition: blocks are the same");
13095
+ assert(logger$4z, block1 !== block2, "comparePosition: blocks are the same");
13096
13096
  return compareElement(block1, block2);
13097
13097
  }
13098
13098
  if (isComplexBlockPosition(pos1) && isComplexBlockPosition(pos2)) {
@@ -13103,13 +13103,13 @@ var __publicField = (obj, key, value) => {
13103
13103
  }
13104
13104
  const container1 = editor.getContainerById(p1.childContainerId);
13105
13105
  const container2 = editor.getContainerById(p2.childContainerId);
13106
- assert(logger$4y, container1 !== container2, "comparePosition: containers are the same");
13106
+ assert(logger$4z, container1 !== container2, "comparePosition: containers are the same");
13107
13107
  return compareElement(container1, container2);
13108
13108
  }
13109
- assert(logger$4y, false, "invalid ");
13109
+ assert(logger$4z, false, "invalid ");
13110
13110
  return 0;
13111
13111
  }
13112
- const logger$4x = getLogger("simple-range");
13112
+ const logger$4y = getLogger("simple-range");
13113
13113
  class EditorSimpleSelectionRange {
13114
13114
  constructor(editor, options) {
13115
13115
  __publicField(this, "editor");
@@ -13158,11 +13158,11 @@ var __publicField = (obj, key, value) => {
13158
13158
  const { editor } = this;
13159
13159
  const startBlock = editor.getBlockById(this.start.blockId);
13160
13160
  const endBlock = editor.getBlockById(this.end.blockId);
13161
- assert(logger$4x, startBlock, "no start block");
13162
- assert(logger$4x, endBlock, "no end block");
13161
+ assert(logger$4y, startBlock, "no start block");
13162
+ assert(logger$4y, endBlock, "no end block");
13163
13163
  const startContainer = getParentContainer(startBlock);
13164
13164
  const endContainer = getParentContainer(endBlock);
13165
- assert(logger$4x, startContainer === endContainer, "invalid range");
13165
+ assert(logger$4y, startContainer === endContainer, "invalid range");
13166
13166
  const ret = [];
13167
13167
  if (startBlock === endBlock) {
13168
13168
  ret.push({
@@ -13173,7 +13173,7 @@ var __publicField = (obj, key, value) => {
13173
13173
  } else {
13174
13174
  const startIndex = getBlockIndex(startBlock);
13175
13175
  const endIndex = getBlockIndex(endBlock);
13176
- assert(logger$4x, startIndex < endIndex, "invalid range, start > index");
13176
+ assert(logger$4y, startIndex < endIndex, "invalid range, start > index");
13177
13177
  ret.push({
13178
13178
  block: startBlock,
13179
13179
  start: this.start,
@@ -13273,7 +13273,7 @@ var __publicField = (obj, key, value) => {
13273
13273
  clearSelection: clearSelection$6,
13274
13274
  convertTo: convertTo$m
13275
13275
  };
13276
- const logger$4w = getLogger("editor-blocks");
13276
+ const logger$4x = getLogger("editor-blocks");
13277
13277
  class EditorBlocks {
13278
13278
  constructor(editor) {
13279
13279
  __publicField(this, "blocks", /* @__PURE__ */ new Map());
@@ -13282,12 +13282,12 @@ var __publicField = (obj, key, value) => {
13282
13282
  registerBlockClass(blockClass) {
13283
13283
  const type = blockClass.blockType;
13284
13284
  const exists = this.blocks.get(type);
13285
- assert(logger$4w, !exists, `duplicated block type: ${type}`);
13285
+ assert(logger$4x, !exists, `duplicated block type: ${type}`);
13286
13286
  this.blocks.set(type, blockClass);
13287
13287
  }
13288
13288
  getBlockClass(type) {
13289
13289
  const exists = this.blocks.get(type);
13290
- assert(logger$4w, exists, `unknown block type: ${type}`);
13290
+ assert(logger$4x, exists, `unknown block type: ${type}`);
13291
13291
  return exists;
13292
13292
  }
13293
13293
  hasBlock(type) {
@@ -13303,7 +13303,7 @@ var __publicField = (obj, key, value) => {
13303
13303
  }
13304
13304
  const content = blockClass.createBlockContent(this.editor, path, container, blockElement, block);
13305
13305
  if (content.parentElement !== blockElement) {
13306
- logger$4w.warn("content parent is not block");
13306
+ logger$4x.warn("content parent is not block");
13307
13307
  blockElement.appendChild(content);
13308
13308
  }
13309
13309
  this.editor.blockHooks.forEach((hook) => {
@@ -13324,7 +13324,7 @@ var __publicField = (obj, key, value) => {
13324
13324
  return newBlock;
13325
13325
  }
13326
13326
  }
13327
- const logger$4v = getLogger("editor-embeds");
13327
+ const logger$4w = getLogger("editor-embeds");
13328
13328
  class EditorEmbeds {
13329
13329
  constructor(editor) {
13330
13330
  __publicField(this, "objects", /* @__PURE__ */ new Map());
@@ -13333,12 +13333,12 @@ var __publicField = (obj, key, value) => {
13333
13333
  registerEmbedClass(embedClass) {
13334
13334
  const type = embedClass.embedType;
13335
13335
  const exists = this.objects.get(type);
13336
- assert(logger$4v, !exists, `duplicated embed object type: ${type}`);
13336
+ assert(logger$4w, !exists, `duplicated embed object type: ${type}`);
13337
13337
  this.objects.set(type, embedClass);
13338
13338
  }
13339
13339
  getEmbedClass(type) {
13340
13340
  const exists = this.objects.get(type);
13341
- assert(logger$4v, exists, `unknown embed type: ${type}`);
13341
+ assert(logger$4w, exists, `unknown embed type: ${type}`);
13342
13342
  return exists;
13343
13343
  }
13344
13344
  getEmbedClassFromBlock(block) {
@@ -13348,12 +13348,12 @@ var __publicField = (obj, key, value) => {
13348
13348
  this.objects.forEach(callback);
13349
13349
  }
13350
13350
  }
13351
- const logger$4u = getLogger("embed-block");
13351
+ const logger$4v = getLogger("embed-block");
13352
13352
  function createBlockContent$6(editor, path, container, blockElement, blockData) {
13353
13353
  const content = createBlockContentElement(blockElement, "div");
13354
- assert(logger$4u, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
13354
+ assert(logger$4v, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
13355
13355
  const embedBlockData = blockData;
13356
- assert(logger$4u, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
13356
+ assert(logger$4v, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
13357
13357
  const embedClass = editor.editorEmbeds.getEmbedClass(embedBlockData.embedType);
13358
13358
  embedClass.createEmbedContent(editor, content, embedBlockData, path, container, blockElement);
13359
13359
  blockElement.setAttribute("data-embed-type", embedBlockData.embedType);
@@ -13381,7 +13381,7 @@ var __publicField = (obj, key, value) => {
13381
13381
  function getCaretRect$4(block, pos) {
13382
13382
  const content = getBlockContent(block);
13383
13383
  const rect = content.getBoundingClientRect();
13384
- assert(logger$4u, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
13384
+ assert(logger$4v, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
13385
13385
  if (pos.offset === 1) {
13386
13386
  return new DOMRect(rect.right, rect.top, 0, rect.height);
13387
13387
  }
@@ -13521,18 +13521,18 @@ var __publicField = (obj, key, value) => {
13521
13521
  toStandardDoc: toStandardDoc$2,
13522
13522
  getResources: getResources$2
13523
13523
  };
13524
- const logger$4t = getLogger("complex-block-helper");
13524
+ const logger$4u = getLogger("complex-block-helper");
13525
13525
  function complexBlockGetAllChildContainers(editor, block, options) {
13526
13526
  const blockClass = getComplexBlockClass(editor, block);
13527
13527
  return blockClass.getChildContainers(editor, block, options);
13528
13528
  }
13529
13529
  function complexBlockGetSelectedContainers(editor, block, start, end) {
13530
13530
  if (start.isSimple()) {
13531
- assert(logger$4t, end.isSimple(), "invalid start and end position");
13531
+ assert(logger$4u, end.isSimple(), "invalid start and end position");
13532
13532
  return complexBlockGetAllChildContainers(editor, block);
13533
13533
  }
13534
- assert(logger$4t, !start.isSimple(), "invalid start pos");
13535
- assert(logger$4t, !end.isSimple(), "invalid end pos");
13534
+ assert(logger$4u, !start.isSimple(), "invalid start pos");
13535
+ assert(logger$4u, !end.isSimple(), "invalid end pos");
13536
13536
  const blockClass = getComplexBlockClass(editor, block);
13537
13537
  return blockClass.getSelectedContainers(editor, block, start, end);
13538
13538
  }
@@ -13543,11 +13543,11 @@ var __publicField = (obj, key, value) => {
13543
13543
  const parentComplexBlock = getParentBlock(getParentContainer(childBlock));
13544
13544
  if (!parentComplexBlock)
13545
13545
  return false;
13546
- assert(logger$4t, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13546
+ assert(logger$4u, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13547
13547
  const childContainer = getParentContainer(childBlock);
13548
13548
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
13549
13549
  const index2 = childContainers.indexOf(childContainer);
13550
- assert(logger$4t, index2 >= 0, "not valid child container");
13550
+ assert(logger$4u, index2 >= 0, "not valid child container");
13551
13551
  return index2 === 0;
13552
13552
  }
13553
13553
  function complexBlockGetFirstSimpleChild(editor, complexBlock, options) {
@@ -13600,13 +13600,13 @@ var __publicField = (obj, key, value) => {
13600
13600
  return block;
13601
13601
  }
13602
13602
  function findPrevSimpleBlockBeforeChildContainer(editor, childContainer, options) {
13603
- assert(logger$4t, isChildContainer(childContainer), "not a child container");
13603
+ assert(logger$4u, isChildContainer(childContainer), "not a child container");
13604
13604
  const parentComplexBlock = getParentBlock(childContainer);
13605
- assert(logger$4t, parentComplexBlock, "no parent block");
13606
- assert(logger$4t, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13605
+ assert(logger$4u, parentComplexBlock, "no parent block");
13606
+ assert(logger$4u, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13607
13607
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock, options);
13608
13608
  const containerIndex = childContainers.indexOf(childContainer);
13609
- assert(logger$4t, containerIndex !== -1, "child container not found");
13609
+ assert(logger$4u, containerIndex !== -1, "child container not found");
13610
13610
  if (containerIndex === 0) {
13611
13611
  const prevBlock = getPrevBlock(parentComplexBlock);
13612
13612
  if (!prevBlock)
@@ -13624,9 +13624,9 @@ var __publicField = (obj, key, value) => {
13624
13624
  return lastBlock2;
13625
13625
  }
13626
13626
  function complexBlockGetTopChildContainers(editor, complexBlock) {
13627
- assert(logger$4t, isComplexKindBlock(editor, complexBlock), "not a complex block");
13627
+ assert(logger$4u, isComplexKindBlock(editor, complexBlock), "not a complex block");
13628
13628
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
13629
- assert(logger$4t, childContainers.length > 0, "no child container");
13629
+ assert(logger$4u, childContainers.length > 0, "no child container");
13630
13630
  if (childContainers.length === 1) {
13631
13631
  return childContainers;
13632
13632
  }
@@ -13651,9 +13651,9 @@ var __publicField = (obj, key, value) => {
13651
13651
  return ret;
13652
13652
  }
13653
13653
  function complexBlockGetBottomChildContainers(editor, complexBlock) {
13654
- assert(logger$4t, isComplexKindBlock(editor, complexBlock), "not a complex block");
13654
+ assert(logger$4u, isComplexKindBlock(editor, complexBlock), "not a complex block");
13655
13655
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
13656
- assert(logger$4t, childContainers.length > 0, "no child container");
13656
+ assert(logger$4u, childContainers.length > 0, "no child container");
13657
13657
  if (childContainers.length === 1) {
13658
13658
  return childContainers;
13659
13659
  }
@@ -13758,11 +13758,11 @@ var __publicField = (obj, key, value) => {
13758
13758
  return result;
13759
13759
  }
13760
13760
  const anchor = "";
13761
- const logger$4s = getLogger("text-range");
13761
+ const logger$4t = getLogger("text-range");
13762
13762
  function getBlockRangeInfo(block, blockOffset) {
13763
13763
  const getChildRange = (child, offset) => {
13764
13764
  if (isTextBlockContentInsertionChild(child)) {
13765
- assert(logger$4s, offset === 0, `invalid offset for insertion child: ${offset}`);
13765
+ assert(logger$4t, offset === 0, `invalid offset for insertion child: ${offset}`);
13766
13766
  const childOffset = 2;
13767
13767
  return {
13768
13768
  child,
@@ -13771,7 +13771,7 @@ var __publicField = (obj, key, value) => {
13771
13771
  };
13772
13772
  }
13773
13773
  if (isTextBlockContentBoxChild(child)) {
13774
- assert(logger$4s, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
13774
+ assert(logger$4t, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
13775
13775
  const childOffset = offset === 0 ? 1 : 2;
13776
13776
  return {
13777
13777
  child,
@@ -13780,17 +13780,17 @@ var __publicField = (obj, key, value) => {
13780
13780
  };
13781
13781
  }
13782
13782
  const textNode = child.firstChild;
13783
- assert(logger$4s, textNode, "no child node for text child");
13784
- assert(logger$4s, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
13783
+ assert(logger$4t, textNode, "no child node for text child");
13784
+ assert(logger$4t, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
13785
13785
  if (textNode instanceof HTMLBRElement) {
13786
- assert(logger$4s, offset >= 0 && offset <= 0, "invalid offset for text child");
13786
+ assert(logger$4t, offset >= 0 && offset <= 0, "invalid offset for text child");
13787
13787
  return {
13788
13788
  child,
13789
13789
  container: textNode,
13790
13790
  offset
13791
13791
  };
13792
13792
  }
13793
- assert(logger$4s, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
13793
+ assert(logger$4t, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
13794
13794
  return {
13795
13795
  child,
13796
13796
  container: textNode,
@@ -13819,38 +13819,38 @@ var __publicField = (obj, key, value) => {
13819
13819
  }
13820
13820
  start += childLength;
13821
13821
  }
13822
- assert(logger$4s, false, "failed to get range info");
13822
+ assert(logger$4t, false, "failed to get range info");
13823
13823
  }
13824
13824
  function createChildRange(child, start, end) {
13825
13825
  if (start === end) {
13826
- assert(logger$4s, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
13826
+ assert(logger$4t, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
13827
13827
  } else {
13828
- assert(logger$4s, start < end, `invalid start & end: ${start}, ${end}`);
13828
+ assert(logger$4t, start < end, `invalid start & end: ${start}, ${end}`);
13829
13829
  }
13830
13830
  if (isTextBlockContentInsertionChild(child)) {
13831
- assert(logger$4s, start === end, `invalid insertion child range offset: ${start}, ${end}`);
13832
- assert(logger$4s, start === 0, `invalid insertion child range start: ${start}`);
13831
+ assert(logger$4t, start === end, `invalid insertion child range offset: ${start}, ${end}`);
13832
+ assert(logger$4t, start === 0, `invalid insertion child range start: ${start}`);
13833
13833
  const insertionElem = child;
13834
- assert(logger$4s, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
13834
+ assert(logger$4t, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
13835
13835
  const range = createExpandedRange(insertionElem, 1, insertionElem, 2);
13836
13836
  return range;
13837
13837
  }
13838
13838
  if (isTextBlockContentBoxChild(child)) {
13839
- assert(logger$4s, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
13840
- assert(logger$4s, start === 0, `invalid box child range start: ${start}`);
13839
+ assert(logger$4t, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
13840
+ assert(logger$4t, start === 0, `invalid box child range start: ${start}`);
13841
13841
  const box = child;
13842
- assert(logger$4s, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
13842
+ assert(logger$4t, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
13843
13843
  const range = createExpandedRange(box, 1, box, 2);
13844
13844
  return range;
13845
13845
  }
13846
13846
  const length = getTextBlockContentChildTextLength(child);
13847
- assert(logger$4s, end <= length, `invalid child end: ${end}, ${length}`);
13847
+ assert(logger$4t, end <= length, `invalid child end: ${end}, ${length}`);
13848
13848
  const textNode = child.firstChild;
13849
- assert(logger$4s, textNode instanceof Text, "invalid block text child");
13850
- assert(logger$4s, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
13849
+ assert(logger$4t, textNode instanceof Text, "invalid block text child");
13850
+ assert(logger$4t, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
13851
13851
  return createExpandedRange(textNode, start, textNode, end);
13852
13852
  }
13853
- const logger$4r = getLogger("caret-rect");
13853
+ const logger$4s = getLogger("caret-rect");
13854
13854
  function getChildClientRects(block, child) {
13855
13855
  if (isBox(child)) {
13856
13856
  const box = child;
@@ -13859,7 +13859,7 @@ var __publicField = (obj, key, value) => {
13859
13859
  const blockContent = getBlockContent(block);
13860
13860
  const lineHeight = Number.parseFloat(window.getComputedStyle(blockContent).lineHeight) || boxContent.getBoundingClientRect().height;
13861
13861
  const rects = Array.from(boxContent.getClientRects());
13862
- assert(logger$4r, rects.length > 0, "no box client rects");
13862
+ assert(logger$4s, rects.length > 0, "no box client rects");
13863
13863
  const blockRect = blockContent.getBoundingClientRect();
13864
13864
  const firstRect = rects[0];
13865
13865
  const lastRect = new DOMRect(blockRect.left, firstRect.bottom, 1, lineHeight);
@@ -13879,22 +13879,22 @@ var __publicField = (obj, key, value) => {
13879
13879
  const rect2 = getLastClientRect(ranges[0].child);
13880
13880
  return new DOMRect(rect2.right, rect2.top, 1, rect2.height);
13881
13881
  }
13882
- assert(logger$4r, ranges[1], "invalid ranges");
13882
+ assert(logger$4s, ranges[1], "invalid ranges");
13883
13883
  const rect = getFirstClientRect(ranges[1].child);
13884
13884
  return new DOMRect(rect.left, rect.top, 1, rect.height);
13885
13885
  }
13886
13886
  let rangeInfo = ranges[0];
13887
- assert(logger$4r, ranges.length >= 1, "failed to get block range");
13887
+ assert(logger$4s, ranges.length >= 1, "failed to get block range");
13888
13888
  if (ranges.length === 1) {
13889
13889
  rangeInfo = ranges[0];
13890
13890
  } else {
13891
- assert(logger$4r, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
13891
+ assert(logger$4s, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
13892
13892
  if (isTextBlockContentInsertionChild(ranges[ranges.length - 1].child)) {
13893
13893
  rangeInfo = ranges[ranges.length - 1];
13894
13894
  const child = rangeInfo.child;
13895
13895
  const content = getInsertionContent(child);
13896
13896
  const rects2 = content.getClientRects();
13897
- assert(logger$4r, rects2.length >= 1, "no client rects for box content");
13897
+ assert(logger$4s, rects2.length >= 1, "no client rects for box content");
13898
13898
  const rect = rects2[rects2.length - 1];
13899
13899
  return new DOMRect(rect.right, rect.y, 1, rect.height);
13900
13900
  }
@@ -13911,9 +13911,9 @@ var __publicField = (obj, key, value) => {
13911
13911
  }
13912
13912
  }
13913
13913
  if (rangeInfo.container instanceof HTMLBRElement) {
13914
- assert(logger$4r, pos.offset === 0, "invalid offset for empty block text");
13914
+ assert(logger$4s, pos.offset === 0, "invalid offset for empty block text");
13915
13915
  const parent = rangeInfo.container.parentElement;
13916
- assert(logger$4r, parent, "invalid br parent");
13916
+ assert(logger$4s, parent, "invalid br parent");
13917
13917
  const rect = parent.getBoundingClientRect();
13918
13918
  const ret = new DOMRect(rect.left, rect.top, 1, rect.height);
13919
13919
  return ret;
@@ -13921,11 +13921,11 @@ var __publicField = (obj, key, value) => {
13921
13921
  const range = createRange(rangeInfo.container, rangeInfo.offset);
13922
13922
  const rects = Array.from(range.getClientRects());
13923
13923
  if (rects.length === 0) {
13924
- assert(logger$4r, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
13925
- assert(logger$4r, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
13924
+ assert(logger$4s, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
13925
+ assert(logger$4s, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
13926
13926
  const child = rangeInfo.child;
13927
13927
  const rects2 = getChildClientRects(block, child);
13928
- assert(logger$4r, rects2.length >= 1, "no client rects for box content");
13928
+ assert(logger$4s, rects2.length >= 1, "no client rects for box content");
13929
13929
  if (rangeInfo.offset === 1) {
13930
13930
  const rect2 = rects2[0];
13931
13931
  return new DOMRect(rect2.x, rect2.y, 1, rect2.height);
@@ -13971,7 +13971,7 @@ var __publicField = (obj, key, value) => {
13971
13971
  });
13972
13972
  }
13973
13973
  }
13974
- assert(logger$4r, rects.length > 0, "no client rects for range");
13974
+ assert(logger$4s, rects.length > 0, "no client rects for range");
13975
13975
  if (pos.type === "home") {
13976
13976
  return rects[rects.length - 1];
13977
13977
  }
@@ -14051,13 +14051,13 @@ var __publicField = (obj, key, value) => {
14051
14051
  };
14052
14052
  }
14053
14053
  }
14054
- const logger$4q = getLogger("selection-range");
14054
+ const logger$4r = getLogger("selection-range");
14055
14055
  function createEditorSelectionRange(editor, options) {
14056
14056
  const { anchor: anchor2, focus } = options;
14057
14057
  if (anchor2 instanceof EditorSimpleBlockPosition && focus instanceof EditorSimpleBlockPosition) {
14058
14058
  return new EditorSimpleSelectionRange(editor, { anchor: anchor2, focus });
14059
14059
  }
14060
- assert(logger$4q, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
14060
+ assert(logger$4r, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
14061
14061
  return new EditorComplexSelectionRange(editor, { anchor: anchor2, focus });
14062
14062
  }
14063
14063
  function createBlockSimpleRange(editor, block, anchor2, focus) {
@@ -14079,7 +14079,7 @@ var __publicField = (obj, key, value) => {
14079
14079
  const focus = createSimpleBlockPosition(range.focus.blockId, range.focus.offset, "normal");
14080
14080
  return createEditorSelectionRange(editor, { anchor: anchor2, focus });
14081
14081
  }
14082
- const logger$4p = getLogger("range-from-point");
14082
+ const logger$4q = getLogger("range-from-point");
14083
14083
  function getBlockRangeFromPoint(editor, pointX, pointY, dragging) {
14084
14084
  const yOffsets = [0, -12, 12];
14085
14085
  let x = pointX;
@@ -14111,7 +14111,7 @@ var __publicField = (obj, key, value) => {
14111
14111
  const rect = elem.getBoundingClientRect();
14112
14112
  if (rect.width && rect.top && i === 0) {
14113
14113
  if (rect.left + rect.width < x || rect.top + rect.height < y) {
14114
- logger$4p.debug("click on scrollbar, out of element rect");
14114
+ logger$4q.debug("click on scrollbar, out of element rect");
14115
14115
  return null;
14116
14116
  }
14117
14117
  }
@@ -14149,7 +14149,7 @@ var __publicField = (obj, key, value) => {
14149
14149
  let block = getLastChildBlock(container);
14150
14150
  if (!isVisibleBlock(block)) {
14151
14151
  const preBlock = getPrevVisibleBlock(block);
14152
- assert(logger$4p, preBlock, "container must have visible block");
14152
+ assert(logger$4q, preBlock, "container must have visible block");
14153
14153
  block = preBlock;
14154
14154
  }
14155
14155
  const range = getBlockClass(editor, block).getRangeFromPoint(editor, block, x, block.getBoundingClientRect().bottom - 4);
@@ -14168,7 +14168,7 @@ var __publicField = (obj, key, value) => {
14168
14168
  if (range instanceof EditorSimpleSelectionRange) {
14169
14169
  return range;
14170
14170
  }
14171
- assert(logger$4p, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
14171
+ assert(logger$4q, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
14172
14172
  const complexRange = range;
14173
14173
  const container2 = editor.getContainerById(complexRange.start.childContainerId);
14174
14174
  return getRangeInContainer(editor, container2, x, y);
@@ -14191,7 +14191,7 @@ var __publicField = (obj, key, value) => {
14191
14191
  });
14192
14192
  return getRangeInContainer(editor, container, x, y);
14193
14193
  }
14194
- const logger$4o = getLogger("adjust-selection-pos");
14194
+ const logger$4p = getLogger("adjust-selection-pos");
14195
14195
  function getParentContainers(block) {
14196
14196
  const containers = [];
14197
14197
  while (block) {
@@ -14201,10 +14201,10 @@ var __publicField = (obj, key, value) => {
14201
14201
  return containers;
14202
14202
  }
14203
14203
  const newBlock = getParentBlock(container);
14204
- assert(logger$4o, newBlock, "child container has not parent container");
14204
+ assert(logger$4p, newBlock, "child container has not parent container");
14205
14205
  block = newBlock;
14206
14206
  }
14207
- assert(logger$4o, false, "should not come here: getParentContainers");
14207
+ assert(logger$4p, false, "should not come here: getParentContainers");
14208
14208
  }
14209
14209
  function getParentBlockInContainer(container, block) {
14210
14210
  while (block) {
@@ -14213,16 +14213,16 @@ var __publicField = (obj, key, value) => {
14213
14213
  return block;
14214
14214
  }
14215
14215
  const newBlock = getParentBlock(parent);
14216
- assert(logger$4o, newBlock, "could not find parent block for a child container");
14216
+ assert(logger$4p, newBlock, "could not find parent block for a child container");
14217
14217
  block = newBlock;
14218
14218
  }
14219
- assert(logger$4o, false, "no parent block in specified container");
14219
+ assert(logger$4p, false, "no parent block in specified container");
14220
14220
  }
14221
14221
  function getClosestParentBlock(block1, block2) {
14222
14222
  const containers1 = getParentContainers(block1);
14223
14223
  const containers2 = getParentContainers(block2);
14224
- assert(logger$4o, containers1.length > 0 && containers2.length > 0, "block has not parent container");
14225
- assert(logger$4o, containers1[0] === containers2[0], "root container does not equal");
14224
+ assert(logger$4p, containers1.length > 0 && containers2.length > 0, "block has not parent container");
14225
+ assert(logger$4p, containers1[0] === containers2[0], "root container does not equal");
14226
14226
  let parentContainer = containers1[0];
14227
14227
  for (let i = 1; i < containers1.length || containers2.length; i++) {
14228
14228
  if (containers1[i] === containers2[i]) {
@@ -14241,23 +14241,23 @@ var __publicField = (obj, key, value) => {
14241
14241
  }
14242
14242
  function getParentContainerInComplexBlock(parentComplexBlock, element) {
14243
14243
  let block = getParentBlock(element);
14244
- assert(logger$4o, block, "element is not in a block");
14244
+ assert(logger$4p, block, "element is not in a block");
14245
14245
  while (block) {
14246
14246
  const container = getParentContainer(block);
14247
- assert(logger$4o, isChildContainer(container), "not a child container");
14247
+ assert(logger$4p, isChildContainer(container), "not a child container");
14248
14248
  const parentBlock = getParentBlock(container);
14249
- assert(logger$4o, parentBlock, "child container has not parent block");
14249
+ assert(logger$4p, parentBlock, "child container has not parent block");
14250
14250
  if (parentBlock === parentComplexBlock) {
14251
14251
  return container;
14252
14252
  }
14253
14253
  block = parentBlock;
14254
14254
  }
14255
- assert(logger$4o, false, "failed to find parent container in complex block");
14255
+ assert(logger$4p, false, "failed to find parent container in complex block");
14256
14256
  }
14257
14257
  function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
14258
14258
  const blockId = getBlockId(complexBlock);
14259
- assert(logger$4o, blockId === anchor2.blockId, "invalid start pos");
14260
- assert(logger$4o, blockId === focus.blockId, "invalid end pos");
14259
+ assert(logger$4p, blockId === anchor2.blockId, "invalid start pos");
14260
+ assert(logger$4p, blockId === focus.blockId, "invalid end pos");
14261
14261
  const blockClass = getComplexBlockClass(editor, complexBlock);
14262
14262
  if (blockClass.adjustSelectionPos) {
14263
14263
  return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
@@ -14291,8 +14291,8 @@ var __publicField = (obj, key, value) => {
14291
14291
  if (focus instanceof EditorComplexBlockPosition) {
14292
14292
  focus = createSimpleBlockPosition(focusBlock, getBlockTextLength$6(editor, focusBlock), "end");
14293
14293
  }
14294
- assert(logger$4o, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
14295
- assert(logger$4o, focus instanceof EditorSimpleBlockPosition, "not valid position type");
14294
+ assert(logger$4p, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
14295
+ assert(logger$4p, focus instanceof EditorSimpleBlockPosition, "not valid position type");
14296
14296
  return {
14297
14297
  anchor: anchor2,
14298
14298
  focus
@@ -14346,7 +14346,7 @@ var __publicField = (obj, key, value) => {
14346
14346
  focus
14347
14347
  };
14348
14348
  }
14349
- const logger$4n = getLogger("core");
14349
+ const logger$4o = getLogger("core");
14350
14350
  function createBlockAnchor(editor, block, id, refClientRect) {
14351
14351
  const tools = getBlockTools(block);
14352
14352
  let elem = tools.querySelector(`.block-anchor[data-id=${id}]`);
@@ -14364,7 +14364,7 @@ var __publicField = (obj, key, value) => {
14364
14364
  return elem;
14365
14365
  }
14366
14366
  function createBlockCaretAnchor(editor, block, offset, id) {
14367
- assert(logger$4n, isTextKindBlock(editor, block), "not a text kind block");
14367
+ assert(logger$4o, isTextKindBlock(editor, block), "not a text kind block");
14368
14368
  const caretRect = getTextCaretRect(block, createSimpleBlockPosition(block, offset, "normal"));
14369
14369
  const blockRect = block.getBoundingClientRect();
14370
14370
  const tools = getBlockTools(block);
@@ -14723,19 +14723,19 @@ var __publicField = (obj, key, value) => {
14723
14723
  return result + (index2 ? "-" : "") + word.toLowerCase();
14724
14724
  });
14725
14725
  const kebabCase$1 = kebabCase;
14726
- const logger$4m = getLogger("box");
14726
+ const logger$4n = getLogger("box");
14727
14727
  function isBoxOp(op) {
14728
14728
  if (!op.attributes)
14729
14729
  return false;
14730
14730
  if (!op.attributes.box)
14731
14731
  return false;
14732
- assert(logger$4m, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
14733
- assert(logger$4m, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
14732
+ assert(logger$4n, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
14733
+ assert(logger$4n, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
14734
14734
  return true;
14735
14735
  }
14736
- const logger$4l = getLogger("text-op");
14736
+ const logger$4m = getLogger("text-op");
14737
14737
  function getOpLength(op) {
14738
- assert(logger$4l, typeof op.insert === "string", "invalid op, no insert");
14738
+ assert(logger$4m, typeof op.insert === "string", "invalid op, no insert");
14739
14739
  return op.insert.length;
14740
14740
  }
14741
14741
  function getOpAt(text2, offset) {
@@ -14743,7 +14743,7 @@ var __publicField = (obj, key, value) => {
14743
14743
  let pos = 0;
14744
14744
  for (let i = 0; i < ops.length; i++) {
14745
14745
  const op = ops[i];
14746
- assert(logger$4l, typeof op.insert === "string", "invalid text op, no insert");
14746
+ assert(logger$4m, typeof op.insert === "string", "invalid text op, no insert");
14747
14747
  const end = pos + getOpLength(op);
14748
14748
  if (end > offset) {
14749
14749
  return [op];
@@ -14759,22 +14759,22 @@ var __publicField = (obj, key, value) => {
14759
14759
  }
14760
14760
  return [];
14761
14761
  }
14762
- const logger$4k = getLogger("rich-text-length");
14762
+ const logger$4l = getLogger("rich-text-length");
14763
14763
  function getTextOpLength(op) {
14764
- assert(logger$4k, typeof op.insert === "string", "op.insert is not string");
14764
+ assert(logger$4l, typeof op.insert === "string", "op.insert is not string");
14765
14765
  return op.insert.length;
14766
14766
  }
14767
14767
  function getTextLength(ops) {
14768
14768
  let count = 0;
14769
14769
  ops.forEach((op) => {
14770
14770
  if (op.insert) {
14771
- assert(logger$4k, typeof op.insert === "string", "op.insert is not string");
14771
+ assert(logger$4l, typeof op.insert === "string", "op.insert is not string");
14772
14772
  count += getTextOpLength(op);
14773
14773
  }
14774
14774
  });
14775
14775
  return count;
14776
14776
  }
14777
- const logger$4j = getLogger("split-text");
14777
+ const logger$4k = getLogger("split-text");
14778
14778
  function splitText(ops, offset, splitResult) {
14779
14779
  ops = cloneDeep__default.default(ops);
14780
14780
  if (offset === 0) {
@@ -14792,8 +14792,8 @@ var __publicField = (obj, key, value) => {
14792
14792
  let counted = 0;
14793
14793
  for (let i = 0; i < ops.length; i++) {
14794
14794
  const op = ops[i];
14795
- assert(logger$4j, typeof op === "object", `invalid op type, ${typeof op}`);
14796
- assert(logger$4j, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
14795
+ assert(logger$4k, typeof op === "object", `invalid op type, ${typeof op}`);
14796
+ assert(logger$4k, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
14797
14797
  const subLen = getTextOpLength(op);
14798
14798
  if (counted + subLen < offset) {
14799
14799
  counted += subLen;
@@ -14803,18 +14803,18 @@ var __publicField = (obj, key, value) => {
14803
14803
  right: ops.slice(i + 1)
14804
14804
  };
14805
14805
  } else {
14806
- assert(logger$4j, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
14806
+ assert(logger$4k, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
14807
14807
  const splitIndex = offset - counted;
14808
14808
  const copied = cloneDeep__default.default(op);
14809
- assert(logger$4j, copied.insert, "no copied.insert");
14810
- assert(logger$4j, typeof copied.insert === "string", "invalid copied.insert type");
14809
+ assert(logger$4k, copied.insert, "no copied.insert");
14810
+ assert(logger$4k, typeof copied.insert === "string", "invalid copied.insert type");
14811
14811
  copied.insert = copied.insert.substr(0, splitIndex);
14812
14812
  op.insert = op.insert.substr(splitIndex);
14813
14813
  if (copied.insert === "") {
14814
- assert(logger$4j, false, "invalid copied.insert, is empty string");
14814
+ assert(logger$4k, false, "invalid copied.insert, is empty string");
14815
14815
  }
14816
14816
  if (op.insert === "") {
14817
- assert(logger$4j, false, "invalid op.insert, is empty string");
14817
+ assert(logger$4k, false, "invalid op.insert, is empty string");
14818
14818
  }
14819
14819
  const right = [
14820
14820
  op,
@@ -14833,9 +14833,9 @@ var __publicField = (obj, key, value) => {
14833
14833
  throw new Error(`invalid split offset: ${offset}, ${JSON.stringify(ops)}`);
14834
14834
  }
14835
14835
  function splitToThree(text2, offset, length) {
14836
- assert(logger$4j, offset >= 0, "invalid offset, < 0");
14837
- assert(logger$4j, length > 0, "invalid length, <= 0");
14838
- assert(logger$4j, offset + length <= getTextLength(text2), "invalid offset + length < text length");
14836
+ assert(logger$4k, offset >= 0, "invalid offset, < 0");
14837
+ assert(logger$4k, length > 0, "invalid length, <= 0");
14838
+ assert(logger$4k, offset + length <= getTextLength(text2), "invalid offset + length < text length");
14839
14839
  const { left: temp, right } = splitText(text2, offset + length);
14840
14840
  const { left, right: middle } = splitText(temp, offset);
14841
14841
  return { left, middle, right };
@@ -15058,9 +15058,9 @@ var __publicField = (obj, key, value) => {
15058
15058
  }
15059
15059
  return [color, backgroundColor];
15060
15060
  }
15061
- const logger$4i = getLogger("text-block-content");
15061
+ const logger$4j = getLogger("text-block-content");
15062
15062
  function updateBlockContentCore(editor, blockPath, content, blockText, insertions) {
15063
- assert(logger$4i, blockText, "no text for block");
15063
+ assert(logger$4j, blockText, "no text for block");
15064
15064
  if (blockText.length === 0 && (!insertions || insertions.size === 0)) {
15065
15065
  content.innerHTML = "<span><br></span>";
15066
15066
  return;
@@ -15092,9 +15092,9 @@ var __publicField = (obj, key, value) => {
15092
15092
  for (let i2 = 0; i2 < text2.length; i2++) {
15093
15093
  const op = text2[i2];
15094
15094
  if (isBoxOp(op)) {
15095
- assert(logger$4i, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
15095
+ assert(logger$4j, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
15096
15096
  const span2 = editor.editorBoxes.createBox(content, op.attributes);
15097
- assert(logger$4i, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
15097
+ assert(logger$4j, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
15098
15098
  const ret = editor.editorBlockRenders.renderBox(blockPath, op.attributes);
15099
15099
  if (ret.classes) {
15100
15100
  addClass(span2, ...ret.classes);
@@ -15112,7 +15112,7 @@ var __publicField = (obj, key, value) => {
15112
15112
  fragment.appendChild(span2);
15113
15113
  continue;
15114
15114
  }
15115
- assert(logger$4i, op.insert, `no insert in op: ${JSON.stringify(op)}`);
15115
+ assert(logger$4j, op.insert, `no insert in op: ${JSON.stringify(op)}`);
15116
15116
  const span = createElement("span", ["text"], fragment, op.insert);
15117
15117
  if (op.attributes) {
15118
15118
  const ret = editor.editorBlockRenders.renderText(blockPath, op.attributes);
@@ -15143,7 +15143,7 @@ var __publicField = (obj, key, value) => {
15143
15143
  const compositionText = editor.compositingText;
15144
15144
  if (compositionText) {
15145
15145
  const pos = editor.selection.range.start;
15146
- assert(logger$4i, pos.isSimple(), "not an simple position while compositing");
15146
+ assert(logger$4j, pos.isSimple(), "not an simple position while compositing");
15147
15147
  if (pos.blockId === blockId) {
15148
15148
  const attributes = getAttributesAt(text2, 0);
15149
15149
  insertions.set(pos.offset, [{
@@ -15159,11 +15159,11 @@ var __publicField = (obj, key, value) => {
15159
15159
  function clearAllTempCompositionText(editor) {
15160
15160
  const children = editor.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');
15161
15161
  if (children.length) {
15162
- logger$4i.debug(`remove ${children.length} temp composition span`);
15162
+ logger$4j.debug(`remove ${children.length} temp composition span`);
15163
15163
  }
15164
15164
  Array.from(children).forEach((c) => c.remove());
15165
15165
  }
15166
- const logger$4h = getLogger("client-rects");
15166
+ const logger$4i = getLogger("client-rects");
15167
15167
  function getChildrenOffsets(block) {
15168
15168
  const children = getTextBlockContentChildren(block);
15169
15169
  let start = 0;
@@ -15181,15 +15181,15 @@ var __publicField = (obj, key, value) => {
15181
15181
  return ret;
15182
15182
  }
15183
15183
  function getChildrenInRange(editor, block, from, to) {
15184
- assert(logger$4h, from < to, `invalid from & to: ${from}, ${to}`);
15184
+ assert(logger$4i, from < to, `invalid from & to: ${from}, ${to}`);
15185
15185
  const blockLength = getBlockTextLength$6(editor, block);
15186
- assert(logger$4h, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
15186
+ assert(logger$4i, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
15187
15187
  const offsets = getChildrenOffsets(block);
15188
15188
  const startIndex = offsets.findIndex((c) => c.startBlockOffset <= from && from < c.endBlockOffset);
15189
15189
  const endIndex = offsets.findIndex((c) => c.startBlockOffset < to && to <= c.endBlockOffset);
15190
- assert(logger$4h, startIndex !== -1, "failed to find start child");
15191
- assert(logger$4h, endIndex !== -1, "failed to find end child");
15192
- assert(logger$4h, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
15190
+ assert(logger$4i, startIndex !== -1, "failed to find start child");
15191
+ assert(logger$4i, endIndex !== -1, "failed to find end child");
15192
+ assert(logger$4i, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
15193
15193
  if (startIndex === endIndex) {
15194
15194
  const child = offsets[startIndex];
15195
15195
  return [{
@@ -15271,16 +15271,16 @@ var __publicField = (obj, key, value) => {
15271
15271
  return rects;
15272
15272
  }
15273
15273
  function getRangeClientRects(editor, block, range) {
15274
- assert(logger$4h, range instanceof EditorSimpleSelectionRange, "invalid range");
15274
+ assert(logger$4i, range instanceof EditorSimpleSelectionRange, "invalid range");
15275
15275
  const start = range.start;
15276
15276
  const end = range.end;
15277
- assert(logger$4h, start.isSimple(), "text block only allow simple position");
15278
- assert(logger$4h, end.isSimple(), "text block only allow simple position");
15279
- assert(logger$4h, start.blockId === end.blockId, "only allow update one text block selection");
15280
- assert(logger$4h, start.blockId === getBlockId(block), "only allow update one text block selection");
15277
+ assert(logger$4i, start.isSimple(), "text block only allow simple position");
15278
+ assert(logger$4i, end.isSimple(), "text block only allow simple position");
15279
+ assert(logger$4i, start.blockId === end.blockId, "only allow update one text block selection");
15280
+ assert(logger$4i, start.blockId === getBlockId(block), "only allow update one text block selection");
15281
15281
  return getClientRects$2(editor, block, start, end);
15282
15282
  }
15283
- const logger$4g = getLogger("selection-background");
15283
+ const logger$4h = getLogger("selection-background");
15284
15284
  function getLineHeight(elem) {
15285
15285
  const style2 = window.getComputedStyle(elem);
15286
15286
  const lineHeightStyle = style2.getPropertyValue("line-height");
@@ -15300,9 +15300,9 @@ var __publicField = (obj, key, value) => {
15300
15300
  return lineHeight;
15301
15301
  }
15302
15302
  function updateSelection$4(editor, block, start, end) {
15303
- assert(logger$4g, start.isSimple(), "text block only allow simple position");
15304
- assert(logger$4g, end.isSimple(), "text block only allow simple position");
15305
- assert(logger$4g, start.blockId === end.blockId, "only allow update one text block selection");
15303
+ assert(logger$4h, start.isSimple(), "text block only allow simple position");
15304
+ assert(logger$4h, end.isSimple(), "text block only allow simple position");
15305
+ assert(logger$4h, start.blockId === end.blockId, "only allow update one text block selection");
15306
15306
  const from = start.offset;
15307
15307
  const to = end.offset;
15308
15308
  if (from === to) {
@@ -15361,7 +15361,7 @@ var __publicField = (obj, key, value) => {
15361
15361
  }
15362
15362
  });
15363
15363
  }
15364
- const logger$4f = getLogger("line-breaker");
15364
+ const logger$4g = getLogger("line-breaker");
15365
15365
  function mergeTextRects(rects) {
15366
15366
  const result = [];
15367
15367
  let lastRect = null;
@@ -15488,7 +15488,7 @@ var __publicField = (obj, key, value) => {
15488
15488
  }
15489
15489
  const textChild = child;
15490
15490
  const rects = mergeTextRects(textChild.getClientRects());
15491
- assert(logger$4f, rects.length > 0, "invalid text child dom");
15491
+ assert(logger$4g, rects.length > 0, "invalid text child dom");
15492
15492
  if (rects.length === 1) {
15493
15493
  const nextChild = children[i + 1];
15494
15494
  if (!nextChild) {
@@ -15513,10 +15513,10 @@ var __publicField = (obj, key, value) => {
15513
15513
  continue;
15514
15514
  }
15515
15515
  const textNode = textChild.firstChild;
15516
- assert(logger$4f, textNode, "invalid text child, no text node");
15517
- assert(logger$4f, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
15516
+ assert(logger$4g, textNode, "invalid text child, no text node");
15517
+ assert(logger$4g, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
15518
15518
  const textChildLength = getTextBlockContentChildTextLength(textChild);
15519
- assert(logger$4f, textNode.data.length === textChildLength, "text node data length not equal child text length");
15519
+ assert(logger$4g, textNode.data.length === textChildLength, "text node data length not equal child text length");
15520
15520
  const textRects = getTextRects(textNode);
15521
15521
  for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
15522
15522
  const rect = textRects[rIndex];
@@ -15558,7 +15558,7 @@ var __publicField = (obj, key, value) => {
15558
15558
  }
15559
15559
  }
15560
15560
  }
15561
- assert(logger$4f, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
15561
+ assert(logger$4g, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
15562
15562
  return {
15563
15563
  lineIndex: lineBreaks.length,
15564
15564
  lineBreaks
@@ -24331,7 +24331,7 @@ var __publicField = (obj, key, value) => {
24331
24331
  const Graphemer_1 = __importDefault(Graphemer$1);
24332
24332
  var _default = lib$1.default = Graphemer_1.default;
24333
24333
  const splitter = new _default();
24334
- const logger$4e = getLogger("text-offset");
24334
+ const logger$4f = getLogger("text-offset");
24335
24335
  function getChildOffset(block, child) {
24336
24336
  const children = getTextBlockContentChildren(block);
24337
24337
  let start = 0;
@@ -24347,26 +24347,26 @@ var __publicField = (obj, key, value) => {
24347
24347
  }
24348
24348
  start += testLength;
24349
24349
  }
24350
- assert(logger$4e, false, "can not find child in children");
24350
+ assert(logger$4f, false, "can not find child in children");
24351
24351
  }
24352
24352
  function isValidOffset(block, blockOffset) {
24353
- assert(logger$4e, blockOffset >= 0, `invalid offset: ${blockOffset}`);
24353
+ assert(logger$4f, blockOffset >= 0, `invalid offset: ${blockOffset}`);
24354
24354
  const childInfo = getTextBlockChild(block, blockOffset);
24355
24355
  const { prev, next: next2, offset } = childInfo;
24356
24356
  if (!prev && !next2) {
24357
- assert(logger$4e, false, "invalid offset, no prev & next child at offset");
24357
+ assert(logger$4f, false, "invalid offset, no prev & next child at offset");
24358
24358
  }
24359
24359
  if (prev !== next2) {
24360
24360
  return true;
24361
24361
  }
24362
24362
  const child = prev;
24363
- assert(logger$4e, child, "no child");
24363
+ assert(logger$4f, child, "no child");
24364
24364
  if (isTextBlockContentBoxChild(child)) {
24365
- assert(logger$4e, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
24365
+ assert(logger$4f, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
24366
24366
  return true;
24367
24367
  }
24368
24368
  const text2 = child.textContent;
24369
- assert(logger$4e, text2, "no content for text child");
24369
+ assert(logger$4f, text2, "no content for text child");
24370
24370
  const chars = splitter.splitGraphemes(text2);
24371
24371
  const validOffsets = /* @__PURE__ */ new Set();
24372
24372
  let start = 0;
@@ -24396,7 +24396,7 @@ var __publicField = (obj, key, value) => {
24396
24396
  }
24397
24397
  function getNextValidOffset(block, blockOffset) {
24398
24398
  const length = getTextBlockLength(block);
24399
- assert(logger$4e, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
24399
+ assert(logger$4f, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
24400
24400
  if (blockOffset === length) {
24401
24401
  return length;
24402
24402
  }
@@ -24410,7 +24410,7 @@ var __publicField = (obj, key, value) => {
24410
24410
  }
24411
24411
  return ret;
24412
24412
  }
24413
- const logger$4d = getLogger("line-offset");
24413
+ const logger$4e = getLogger("line-offset");
24414
24414
  function getLineOffsets(block) {
24415
24415
  const lineBreaks = getLineBreaks(block);
24416
24416
  const ret = [];
@@ -24431,7 +24431,7 @@ var __publicField = (obj, key, value) => {
24431
24431
  }
24432
24432
  function getLineOffset(block, lineIndex) {
24433
24433
  const lines = getLineOffsets(block);
24434
- assert(logger$4d, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
24434
+ assert(logger$4e, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
24435
24435
  return lines[lineIndex];
24436
24436
  }
24437
24437
  function getLineOffsetByPos(block, pos) {
@@ -24488,7 +24488,7 @@ var __publicField = (obj, key, value) => {
24488
24488
  function getLineCount(block) {
24489
24489
  return getLineOffsets(block).length;
24490
24490
  }
24491
- const logger$4c = getLogger("find-text-position");
24491
+ const logger$4d = getLogger("find-text-position");
24492
24492
  function isWrappedLine(block, lineIndex) {
24493
24493
  const { start, end } = getLineOffset(block, lineIndex);
24494
24494
  const blockId = getBlockId(block);
@@ -24499,13 +24499,13 @@ var __publicField = (obj, key, value) => {
24499
24499
  return false;
24500
24500
  }
24501
24501
  const childInfo = getTextBlockChild(block, start);
24502
- assert(logger$4c, childInfo.next, "no next child at offset");
24503
- assert(logger$4c, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
24502
+ assert(logger$4d, childInfo.next, "no next child at offset");
24503
+ assert(logger$4d, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
24504
24504
  return true;
24505
24505
  }
24506
24506
  function getWrappedLineOffsets(block, lineIndex) {
24507
24507
  const blockId = getBlockId(block);
24508
- assert(logger$4c, isWrappedLine(block, lineIndex), "line is not wrapped");
24508
+ assert(logger$4d, isWrappedLine(block, lineIndex), "line is not wrapped");
24509
24509
  const { start, end } = getLineOffset(block, lineIndex);
24510
24510
  const homePos = createSimpleBlockPosition(blockId, start, "home");
24511
24511
  for (let offset = start + 1; offset <= end; offset += 1) {
@@ -24520,11 +24520,11 @@ var __publicField = (obj, key, value) => {
24520
24520
  return offset - 1;
24521
24521
  }
24522
24522
  }
24523
- assert(logger$4c, false, "failed to find wrapped offset");
24523
+ assert(logger$4d, false, "failed to find wrapped offset");
24524
24524
  return 0;
24525
24525
  }
24526
24526
  function findTextPositionInLine(editor, block, lineIndex, sourceBlock, pos, findDirection, suggestedX) {
24527
- assert(logger$4c, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
24527
+ assert(logger$4d, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
24528
24528
  const { start, end } = getLineOffset(block, lineIndex);
24529
24529
  let from = start;
24530
24530
  const blockId = getBlockId(block);
@@ -24566,11 +24566,11 @@ var __publicField = (obj, key, value) => {
24566
24566
  return retPos;
24567
24567
  }
24568
24568
  function findPrevTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
24569
- assert(logger$4c, isTextKindBlock(editor, block), "not a text block");
24569
+ assert(logger$4d, isTextKindBlock(editor, block), "not a text block");
24570
24570
  return findTextPositionInLine(editor, block, getLineCount(block) - 1, sourceBlock, pos, "up", suggestedX);
24571
24571
  }
24572
24572
  function findNextTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
24573
- assert(logger$4c, isTextKindBlock(editor, block), "not a text block");
24573
+ assert(logger$4d, isTextKindBlock(editor, block), "not a text block");
24574
24574
  return findTextPositionInLine(editor, block, 0, sourceBlock, pos, "down", suggestedX);
24575
24575
  }
24576
24576
  function moveDown(editor, block, position, suggestedX) {
@@ -24678,7 +24678,7 @@ var __publicField = (obj, key, value) => {
24678
24678
  }
24679
24679
  return pos;
24680
24680
  }
24681
- const logger$4b = getLogger("move-caret");
24681
+ const logger$4c = getLogger("move-caret");
24682
24682
  function moveTextCaret(editor, block, position, direction) {
24683
24683
  if (direction === "ArrowLeft") {
24684
24684
  const ret = moveLeft(block, position);
@@ -24708,9 +24708,9 @@ var __publicField = (obj, key, value) => {
24708
24708
  }
24709
24709
  return createSimpleBlockPosition(getBlockId(block), ret.offset, ret.type);
24710
24710
  }
24711
- assert(logger$4b, false, `invalid navigation direction: ${direction}`);
24711
+ assert(logger$4c, false, `invalid navigation direction: ${direction}`);
24712
24712
  }
24713
- const logger$4a = getLogger("text-range");
24713
+ const logger$4b = getLogger("text-range");
24714
24714
  function getBlockRects(block) {
24715
24715
  const ret = [];
24716
24716
  const children = getTextBlockContentChildren(block);
@@ -24768,9 +24768,9 @@ var __publicField = (obj, key, value) => {
24768
24768
  return null;
24769
24769
  }
24770
24770
  const children = getTextBlockContentChildren(block);
24771
- assert(logger$4a, children.indexOf(child) !== -1, "failed to find child in children");
24771
+ assert(logger$4b, children.indexOf(child) !== -1, "failed to find child in children");
24772
24772
  const offsetInfo = getChildOffset(block, child);
24773
- assert(logger$4a, offsetInfo, "failed to get child offset");
24773
+ assert(logger$4b, offsetInfo, "failed to get child offset");
24774
24774
  const { start } = offsetInfo;
24775
24775
  let offset;
24776
24776
  let length;
@@ -24786,7 +24786,7 @@ var __publicField = (obj, key, value) => {
24786
24786
  }
24787
24787
  length = 0;
24788
24788
  } else {
24789
- assert(logger$4a, child.firstChild instanceof Text, "child is not text");
24789
+ assert(logger$4b, child.firstChild instanceof Text, "child is not text");
24790
24790
  offset = start + textNodeOffsetFromPoint(child.firstChild, x, y);
24791
24791
  length = 0;
24792
24792
  }
@@ -24819,9 +24819,9 @@ var __publicField = (obj, key, value) => {
24819
24819
  }
24820
24820
  return versions;
24821
24821
  }
24822
- const logger$49 = getLogger("create-text-op");
24822
+ const logger$4a = getLogger("create-text-op");
24823
24823
  function createTextOp(text2, attributes) {
24824
- assert(logger$49, text2, "text is empty");
24824
+ assert(logger$4a, text2, "text is empty");
24825
24825
  const ret = {
24826
24826
  insert: text2
24827
24827
  };
@@ -24844,7 +24844,7 @@ var __publicField = (obj, key, value) => {
24844
24844
  }
24845
24845
  return result;
24846
24846
  }
24847
- const logger$48 = getLogger("merge-ops");
24847
+ const logger$49 = getLogger("merge-ops");
24848
24848
  function mergeOps(text2) {
24849
24849
  if (text2.length <= 1) {
24850
24850
  return text2;
@@ -24866,10 +24866,10 @@ var __publicField = (obj, key, value) => {
24866
24866
  return false;
24867
24867
  }
24868
24868
  if (op1.attributes === void 0) {
24869
- assert(logger$48, op2.attributes === void 0, "op2.attributes is not undefined");
24869
+ assert(logger$49, op2.attributes === void 0, "op2.attributes is not undefined");
24870
24870
  return true;
24871
24871
  }
24872
- assert(logger$48, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
24872
+ assert(logger$49, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
24873
24873
  return isEqual__default.default(op1.attributes, op2.attributes);
24874
24874
  };
24875
24875
  const newOps = [];
@@ -24878,8 +24878,8 @@ var __publicField = (obj, key, value) => {
24878
24878
  for (let i = 1; i < text2.length; i += 1) {
24879
24879
  const op = text2[i];
24880
24880
  if (isSameTypeOp(before, op)) {
24881
- assert(logger$48, typeof before.insert === "string", "before.insert is not string");
24882
- assert(logger$48, typeof op.insert === "string", "op.insert is not string");
24881
+ assert(logger$49, typeof before.insert === "string", "before.insert is not string");
24882
+ assert(logger$49, typeof op.insert === "string", "op.insert is not string");
24883
24883
  before.insert += op.insert;
24884
24884
  } else {
24885
24885
  newOps.push(op);
@@ -24907,15 +24907,15 @@ var __publicField = (obj, key, value) => {
24907
24907
  }
24908
24908
  return text2.slice(0, i + 1);
24909
24909
  }
24910
- const logger$47 = getLogger("delete-text");
24910
+ const logger$48 = getLogger("delete-text");
24911
24911
  function deleteText(richText2, offset, count) {
24912
24912
  const { left, right } = splitToThree(richText2, offset, count);
24913
24913
  const result = [...left, ...right];
24914
24914
  return mergeOps(result);
24915
24915
  }
24916
24916
  function createDeleteOps(offset, count) {
24917
- assert(logger$47, offset >= 0, `invalid offset: ${offset}`);
24918
- assert(logger$47, count >= 1, `invalid delete count: ${count}`);
24917
+ assert(logger$48, offset >= 0, `invalid offset: ${offset}`);
24918
+ assert(logger$48, count >= 1, `invalid delete count: ${count}`);
24919
24919
  const ops = [];
24920
24920
  if (offset !== 0) {
24921
24921
  ops.push({
@@ -24927,7 +24927,7 @@ var __publicField = (obj, key, value) => {
24927
24927
  });
24928
24928
  return ops;
24929
24929
  }
24930
- const logger$46 = getLogger("delta");
24930
+ const logger$47 = getLogger("delta");
24931
24931
  function diffRichText(oldText, newText) {
24932
24932
  const delta1D = new Delta__default.default(oldText);
24933
24933
  const delta2D = new Delta__default.default(newText);
@@ -24937,7 +24937,7 @@ var __publicField = (obj, key, value) => {
24937
24937
  return new Delta__default.default(ops).transformPosition(cursor, !isLocalOp);
24938
24938
  }
24939
24939
  function isValidDocText(text2) {
24940
- assert(logger$46, text2, "ops is null or undefined");
24940
+ assert(logger$47, text2, "ops is null or undefined");
24941
24941
  for (let i = 0; i < text2.length; i++) {
24942
24942
  const op = text2[i];
24943
24943
  if (op.insert === null || op.insert === void 0) {
@@ -24957,7 +24957,7 @@ var __publicField = (obj, key, value) => {
24957
24957
  }
24958
24958
  class RichText {
24959
24959
  static ensureValidText(text2) {
24960
- assert(logger$46, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
24960
+ assert(logger$47, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
24961
24961
  }
24962
24962
  static diff(oldText, newText) {
24963
24963
  this.ensureValidText(oldText);
@@ -24979,9 +24979,9 @@ var __publicField = (obj, key, value) => {
24979
24979
  return resultText;
24980
24980
  }
24981
24981
  }
24982
- const logger$45 = getLogger("insert-text");
24982
+ const logger$46 = getLogger("insert-text");
24983
24983
  function insertText(richText2, offset, text2, attributes) {
24984
- assert(logger$45, text2, `invalid text to insert: ${text2}`);
24984
+ assert(logger$46, text2, `invalid text to insert: ${text2}`);
24985
24985
  const { left, right } = splitText(richText2, offset);
24986
24986
  const insertedText = typeof text2 === "string" ? [createTextOp(text2, attributes)] : text2;
24987
24987
  const result = [...left, ...insertedText, ...right];
@@ -24994,7 +24994,7 @@ var __publicField = (obj, key, value) => {
24994
24994
  };
24995
24995
  }
24996
24996
  function createInsertOps(offset, text2, attributes) {
24997
- assert(logger$45, offset >= 0, `invalid offset: ${offset}`);
24997
+ assert(logger$46, offset >= 0, `invalid offset: ${offset}`);
24998
24998
  if (text2.length === 0) {
24999
24999
  return [];
25000
25000
  }
@@ -25024,7 +25024,7 @@ var __publicField = (obj, key, value) => {
25024
25024
  function cloneText(text2) {
25025
25025
  return cloneDeep__default.default(text2);
25026
25026
  }
25027
- const logger$44 = getLogger("update-op-attribute");
25027
+ const logger$45 = getLogger("update-op-attribute");
25028
25028
  function updateOpAttributes(orgOps, key, value, newAttributes) {
25029
25029
  const ops = cloneText(orgOps);
25030
25030
  const index2 = ops.findIndex((op2) => {
@@ -25032,7 +25032,7 @@ var __publicField = (obj, key, value) => {
25032
25032
  return false;
25033
25033
  return op2.attributes[key] === value;
25034
25034
  });
25035
- assert(logger$44, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
25035
+ assert(logger$45, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
25036
25036
  const op = ops[index2];
25037
25037
  op.attributes = {
25038
25038
  ...op.attributes,
@@ -25107,11 +25107,11 @@ var __publicField = (obj, key, value) => {
25107
25107
  ]);
25108
25108
  }
25109
25109
  const FILL_CHAR = "\u200B";
25110
- const logger$43 = getLogger("to-plain-text");
25110
+ const logger$44 = getLogger("to-plain-text");
25111
25111
  function toPlainText(ops, options) {
25112
25112
  let text2 = "";
25113
25113
  ops.forEach((op) => {
25114
- assert(logger$43, typeof op.insert === "string", "invalid op");
25114
+ assert(logger$44, typeof op.insert === "string", "invalid op");
25115
25115
  if (op.attributes && op.attributes.box === true) {
25116
25116
  if (options == null ? void 0 : options.boxReplacement) {
25117
25117
  text2 += options.boxReplacement;
@@ -25166,6 +25166,91 @@ var __publicField = (obj, key, value) => {
25166
25166
  focus: pos
25167
25167
  };
25168
25168
  }
25169
+ const logger$43 = getLogger("repair-duplicated-block-ids");
25170
+ const ROOT_CONTAINER_ID = "root";
25171
+ function buildChildContainersDelta(doc2, block) {
25172
+ const children = block.children;
25173
+ if (!Array.isArray(children) || children.length === 0) {
25174
+ return null;
25175
+ }
25176
+ const idMap = /* @__PURE__ */ new Map();
25177
+ const newContainers = [];
25178
+ children.forEach((oldChildId) => {
25179
+ const newChildId = genId();
25180
+ idMap.set(oldChildId, newChildId);
25181
+ const childBlocks = doc2.findContainerBlocks(oldChildId);
25182
+ newContainers.push({
25183
+ containerId: newChildId,
25184
+ blocks: childBlocks ? cloneDeep__default.default(childBlocks) : []
25185
+ });
25186
+ });
25187
+ doc2.localInsertChildContainers(newContainers);
25188
+ const insert = {
25189
+ children: children.map((oldChildId) => idMap.get(oldChildId))
25190
+ };
25191
+ const remove2 = ["children"];
25192
+ Object.keys(block).forEach((key) => {
25193
+ const oldChildId = children.find((childId) => key.startsWith(`${childId}_`));
25194
+ if (!oldChildId)
25195
+ return;
25196
+ const newChildId = idMap.get(oldChildId);
25197
+ insert[newChildId + key.substr(oldChildId.length)] = block[key];
25198
+ remove2.push(key);
25199
+ });
25200
+ return { insert, delete: remove2 };
25201
+ }
25202
+ function repairDuplicatedBlockIds(doc2, readonly) {
25203
+ const seenBlockIds = /* @__PURE__ */ new Set();
25204
+ const visitedContainers = /* @__PURE__ */ new Set();
25205
+ const duplicatedIds = [];
25206
+ let repaired = 0;
25207
+ const visitContainer = (containerId) => {
25208
+ var _a, _b;
25209
+ if (visitedContainers.has(containerId))
25210
+ return;
25211
+ visitedContainers.add(containerId);
25212
+ const blocks = doc2.findContainerBlocks(containerId);
25213
+ if (!blocks)
25214
+ return;
25215
+ const blockCount = blocks.length;
25216
+ for (let blockIndex = 0; blockIndex < blockCount; blockIndex += 1) {
25217
+ let block = doc2.getBlockData(containerId, blockIndex);
25218
+ if (seenBlockIds.has(block.id)) {
25219
+ duplicatedIds.push(block.id);
25220
+ if (readonly) {
25221
+ logger$43.warn(`duplicated block id ${block.id} at ${containerId}[${blockIndex}], readonly, skip repairing`);
25222
+ } else {
25223
+ const newId = genId();
25224
+ logger$43.warn(`repair duplicated block id ${block.id} -> ${newId} at ${containerId}[${blockIndex}]`);
25225
+ const childDelta = buildChildContainersDelta(doc2, block);
25226
+ doc2.localUpdateBlockData(
25227
+ containerId,
25228
+ blockIndex,
25229
+ {
25230
+ insert: { id: newId, ...(_a = childDelta == null ? void 0 : childDelta.insert) != null ? _a : {} },
25231
+ delete: ["id", ...(_b = childDelta == null ? void 0 : childDelta.delete) != null ? _b : []]
25232
+ },
25233
+ createBlockSimpleDocRange(newId, 0)
25234
+ );
25235
+ repaired += 1;
25236
+ block = doc2.getBlockData(containerId, blockIndex);
25237
+ }
25238
+ }
25239
+ seenBlockIds.add(block.id);
25240
+ const children = block.children;
25241
+ if (Array.isArray(children)) {
25242
+ children.forEach(visitContainer);
25243
+ }
25244
+ }
25245
+ };
25246
+ visitContainer(ROOT_CONTAINER_ID);
25247
+ if (duplicatedIds.length > 0) {
25248
+ logger$43.error(
25249
+ `found ${duplicatedIds.length} duplicated block id(s): ${duplicatedIds.join(", ")}, repaired ${repaired}`
25250
+ );
25251
+ }
25252
+ return { repaired, duplicatedIds };
25253
+ }
25169
25254
  const logger$42 = getLogger("block-to-text");
25170
25255
  function textBlockToText$1(editor, ops, doc2) {
25171
25256
  let text2 = "";
@@ -32278,6 +32363,7 @@ ${codeText}
32278
32363
  this.id = (_l = optionalOptions == null ? void 0 : optionalOptions.id) != null ? _l : genId();
32279
32364
  this.clientId = genId();
32280
32365
  this.undoManager = new UndoManager(this);
32366
+ repairDuplicatedBlockIds(doc2, this._readonly);
32281
32367
  this.doc = new EditorDoc(this, doc2, this.undoManager);
32282
32368
  this.parent = parent;
32283
32369
  this.rootElement = createElement("div", ["editor-root"], this.parent);
@@ -97256,7 +97342,7 @@ ${JSON.stringify(error2, null, 2)}`);
97256
97342
  }
97257
97343
  }
97258
97344
  });
97259
- editor.version = "4.0.4-beta.h1448.3";
97345
+ editor.version = "4.0.4";
97260
97346
  return editor;
97261
97347
  }
97262
97348
  function isDoc(doc2) {
@@ -97392,7 +97478,7 @@ ${JSON.stringify(error2, null, 2)}`);
97392
97478
  OnesEditorDropTarget.register(editor);
97393
97479
  OnesEditorTocProvider.register(editor);
97394
97480
  OnesEditorExclusiveBlock.register(editor);
97395
- editor.version = "4.0.4-beta.h1448.3";
97481
+ editor.version = "4.0.4";
97396
97482
  return editor;
97397
97483
  } catch (error2) {
97398
97484
  try {
@@ -97535,7 +97621,7 @@ ${JSON.stringify(error2, null, 2)}`);
97535
97621
  }
97536
97622
  }
97537
97623
  });
97538
- editor.version = "4.0.4-beta.h1448.3";
97624
+ editor.version = "4.0.4";
97539
97625
  return editor;
97540
97626
  }
97541
97627
  const emojis$1 = {
@@ -144011,7 +144097,7 @@ ${JSON.stringify(error2, null, 2)}`);
144011
144097
  exports2.loadJs = loadJs;
144012
144098
  exports2.loadJsPromise = loadJsPromise;
144013
144099
  exports2.lockers = lockers;
144014
- exports2.logger = logger$4t;
144100
+ exports2.logger = logger$4u;
144015
144101
  exports2.markdownToDoc = markdownToDoc;
144016
144102
  exports2.mergeCommands = mergeCommands;
144017
144103
  exports2.mergeDocs = mergeDocs;
@@ -144033,6 +144119,7 @@ ${JSON.stringify(error2, null, 2)}`);
144033
144119
  exports2.removeLastBr = removeLastBr;
144034
144120
  exports2.removePlaceholderFromBlock = removePlaceholderFromBlock;
144035
144121
  exports2.removeStyle = removeStyle;
144122
+ exports2.repairDuplicatedBlockIds = repairDuplicatedBlockIds;
144036
144123
  exports2.replaceAll = replaceAll$1;
144037
144124
  exports2.replaceAllCaseInsensitive = replaceAllCaseInsensitive;
144038
144125
  exports2.replaceAllText = replaceAllText;