@ones-editor/editor 2.5.1-beta.6 → 2.6.1-beta.2

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.
Files changed (59) hide show
  1. package/@ones-editor/core/src/core/blocks/common/block-dom.d.ts +3 -2
  2. package/@ones-editor/core/src/core/blocks/text-blocks/base/block-text.d.ts +1 -1
  3. package/@ones-editor/core/src/core/input-handler/actions.d.ts +4 -0
  4. package/@ones-editor/core/src/core/input-handler/handle-delete.d.ts +4 -0
  5. package/@ones-editor/core/src/core/selection/actions/index.d.ts +3 -1
  6. package/@ones-editor/core/src/core/selection/actions/move-block-end.d.ts +2 -0
  7. package/@ones-editor/core/src/core/selection/actions/move-block-start.d.ts +2 -0
  8. package/@ones-editor/core/src/utils/character.d.ts +1 -0
  9. package/@ones-editor/tsconfig.tsbuildinfo +1 -1
  10. package/@ones-editor/ui/src/index.d.ts +2 -2
  11. package/@ones-editor/ui/src/shortcuts/align-shortcuts.d.ts +2 -0
  12. package/@ones-editor/ui/src/shortcuts/index.d.ts +3 -2
  13. package/@ones-editor/ui/src/shortcuts/text-color-shortcuts.d.ts +2 -0
  14. package/@ones-editor/ui/src/shortcuts/text-style-shortcuts.d.ts +1 -2
  15. package/@ones-editor/ui-base/src/color-button/index.d.ts +1 -2
  16. package/@ones-editor/ui-base/src/color-button/text-color-item.d.ts +2 -0
  17. package/dist/index.js +817 -529
  18. package/package.json +1 -9
  19. package/@ones-editor/server-tools/package.json +0 -22
  20. package/@ones-editor/server-tools/src/fake-browser.d.ts +0 -1
  21. package/@ones-editor/server-tools/src/from-markdown/index.d.ts +0 -1
  22. package/@ones-editor/server-tools/src/index.d.ts +0 -2
  23. package/@ones-editor/server-tools/src/to-markdown/blocks/code.d.ts +0 -3
  24. package/@ones-editor/server-tools/src/to-markdown/blocks/index.d.ts +0 -12
  25. package/@ones-editor/server-tools/src/to-markdown/blocks/list.d.ts +0 -14
  26. package/@ones-editor/server-tools/src/to-markdown/blocks/table.d.ts +0 -3
  27. package/@ones-editor/server-tools/src/to-markdown/blocks/text.d.ts +0 -4
  28. package/@ones-editor/server-tools/src/to-markdown/boxes/br.d.ts +0 -1
  29. package/@ones-editor/server-tools/src/to-markdown/boxes/date.d.ts +0 -2
  30. package/@ones-editor/server-tools/src/to-markdown/boxes/file.d.ts +0 -11
  31. package/@ones-editor/server-tools/src/to-markdown/boxes/image.d.ts +0 -5
  32. package/@ones-editor/server-tools/src/to-markdown/boxes/index.d.ts +0 -18
  33. package/@ones-editor/server-tools/src/to-markdown/boxes/known-link.d.ts +0 -11
  34. package/@ones-editor/server-tools/src/to-markdown/boxes/mathjax.d.ts +0 -2
  35. package/@ones-editor/server-tools/src/to-markdown/boxes/mention.d.ts +0 -7
  36. package/@ones-editor/server-tools/src/to-markdown/boxes/task-link.d.ts +0 -2
  37. package/@ones-editor/server-tools/src/to-markdown/convert-block.d.ts +0 -3
  38. package/@ones-editor/server-tools/src/to-markdown/convert-box.d.ts +0 -3
  39. package/@ones-editor/server-tools/src/to-markdown/embeds/drawio.d.ts +0 -2
  40. package/@ones-editor/server-tools/src/to-markdown/embeds/file-list.d.ts +0 -5
  41. package/@ones-editor/server-tools/src/to-markdown/embeds/file.d.ts +0 -2
  42. package/@ones-editor/server-tools/src/to-markdown/embeds/flowchart.d.ts +0 -2
  43. package/@ones-editor/server-tools/src/to-markdown/embeds/hr.d.ts +0 -1
  44. package/@ones-editor/server-tools/src/to-markdown/embeds/image.d.ts +0 -18
  45. package/@ones-editor/server-tools/src/to-markdown/embeds/index.d.ts +0 -3
  46. package/@ones-editor/server-tools/src/to-markdown/embeds/mathjax.d.ts +0 -2
  47. package/@ones-editor/server-tools/src/to-markdown/embeds/media.d.ts +0 -2
  48. package/@ones-editor/server-tools/src/to-markdown/embeds/mermaid.d.ts +0 -2
  49. package/@ones-editor/server-tools/src/to-markdown/embeds/plantuml.d.ts +0 -2
  50. package/@ones-editor/server-tools/src/to-markdown/embeds/sub-pages.d.ts +0 -2
  51. package/@ones-editor/server-tools/src/to-markdown/embeds/task-list.d.ts +0 -7
  52. package/@ones-editor/server-tools/src/to-markdown/embeds/toc.d.ts +0 -2
  53. package/@ones-editor/server-tools/src/to-markdown/embeds/webpage.d.ts +0 -5
  54. package/@ones-editor/server-tools/src/to-markdown/embeds/xmind.d.ts +0 -8
  55. package/@ones-editor/server-tools/src/to-markdown/index.d.ts +0 -1
  56. package/@ones-editor/server-tools/src/to-markdown/types.d.ts +0 -7
  57. package/@ones-editor/server-tools/src/tools.d.ts +0 -1
  58. package/@ones-editor/server-tools/src/utils/editor-doc.d.ts +0 -22
  59. package/@ones-editor/server-tools/src/utils/object.d.ts +0 -1
package/dist/index.js CHANGED
@@ -8901,7 +8901,7 @@ var __publicField = (obj, key, value) => {
8901
8901
  imageExportFailed: "\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F"
8902
8902
  }
8903
8903
  };
8904
- const logger$4R = getLogger("i18n");
8904
+ const logger$4S = getLogger("i18n");
8905
8905
  const langs$3 = {
8906
8906
  "en-US": enUS$x,
8907
8907
  "zh-CN": zhCN$x,
@@ -8921,7 +8921,7 @@ var __publicField = (obj, key, value) => {
8921
8921
  function t$8(key, args) {
8922
8922
  const ret = i18n.get(key, args);
8923
8923
  if (ret === key) {
8924
- logger$4R.warn(`no locale value for key ${key}`);
8924
+ logger$4S.warn(`no locale value for key ${key}`);
8925
8925
  }
8926
8926
  return ret;
8927
8927
  }
@@ -9534,7 +9534,7 @@ var __publicField = (obj, key, value) => {
9534
9534
  this._callbacks.clear();
9535
9535
  }
9536
9536
  }
9537
- const logger$4Q = getLogger("await-locker");
9537
+ const logger$4R = getLogger("await-locker");
9538
9538
  class AwaitLock {
9539
9539
  constructor() {
9540
9540
  __publicField(this, "_acquired", false);
@@ -9576,7 +9576,7 @@ var __publicField = (obj, key, value) => {
9576
9576
  }
9577
9577
  if (this._waitingResolvers.length > 0) {
9578
9578
  const resolve = this._waitingResolvers.shift();
9579
- assert(logger$4Q, resolve, "Resolver missing");
9579
+ assert(logger$4R, resolve, "Resolver missing");
9580
9580
  resolve(void 0);
9581
9581
  } else {
9582
9582
  this._acquired = false;
@@ -9659,7 +9659,7 @@ var __publicField = (obj, key, value) => {
9659
9659
  isMobileSafari: false
9660
9660
  };
9661
9661
  clientType.isMobileSafari = clientType.isMobile && clientType.isSafari;
9662
- const logger$4P = getLogger("dom-utils");
9662
+ const logger$4Q = getLogger("dom-utils");
9663
9663
  function addClass(dom, ...className) {
9664
9664
  if (dom && dom.nodeType === Node.ELEMENT_NODE) {
9665
9665
  dom.classList.add(...className);
@@ -9713,7 +9713,7 @@ var __publicField = (obj, key, value) => {
9713
9713
  range.setStart(node, offset);
9714
9714
  return range;
9715
9715
  } catch (err) {
9716
- assert(logger$4P, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
9716
+ assert(logger$4Q, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
9717
9717
  }
9718
9718
  }
9719
9719
  function createExpandedRange(startNode, startOffset, endNode, endOffset) {
@@ -9723,17 +9723,17 @@ var __publicField = (obj, key, value) => {
9723
9723
  range.setEnd(endNode, endOffset);
9724
9724
  return range;
9725
9725
  } catch (err) {
9726
- assert(logger$4P, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
9726
+ assert(logger$4Q, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
9727
9727
  }
9728
9728
  }
9729
9729
  function getFirstClientRect(elem) {
9730
9730
  const rects = elem.getClientRects();
9731
- assert(logger$4P, rects.length >= 1, "getFirstClientRect: no rects");
9731
+ assert(logger$4Q, rects.length >= 1, "getFirstClientRect: no rects");
9732
9732
  return rects[0];
9733
9733
  }
9734
9734
  function getLastClientRect(elem) {
9735
9735
  const rects = elem.getClientRects();
9736
- assert(logger$4P, rects.length >= 1, "getLastClientRect: no rects");
9736
+ assert(logger$4Q, rects.length >= 1, "getLastClientRect: no rects");
9737
9737
  return rects[rects.length - 1];
9738
9738
  }
9739
9739
  function getDistanceSquare(rect, x, y) {
@@ -9780,7 +9780,7 @@ var __publicField = (obj, key, value) => {
9780
9780
  return 0;
9781
9781
  }
9782
9782
  if (!elem1.parentElement || !elem2.parentElement) {
9783
- assert(logger$4P, false, "invalid dom node to compare");
9783
+ assert(logger$4Q, false, "invalid dom node to compare");
9784
9784
  }
9785
9785
  if (elem1.parentElement === elem2.parentElement) {
9786
9786
  const children = Array.from(elem1.parentElement.children);
@@ -9797,7 +9797,7 @@ var __publicField = (obj, key, value) => {
9797
9797
  const parents1 = getParents(elem1);
9798
9798
  const parents2 = getParents(elem2);
9799
9799
  if (parents1[0] !== parents2[0]) {
9800
- assert(logger$4P, false, "invalid dom node to compare, different tree");
9800
+ assert(logger$4Q, false, "invalid dom node to compare, different tree");
9801
9801
  }
9802
9802
  for (let i = 1; ; i++) {
9803
9803
  const parent1 = parents1[i];
@@ -10397,7 +10397,7 @@ var __publicField = (obj, key, value) => {
10397
10397
  }
10398
10398
  }
10399
10399
  const MIN_DISTANCE_THRESHOLD$3 = 3;
10400
- const logger$4O = getLogger("drag-drop");
10400
+ const logger$4P = getLogger("drag-drop");
10401
10401
  class DragDrop {
10402
10402
  constructor(options) {
10403
10403
  __publicField(this, "dragStarted", false);
@@ -10418,7 +10418,7 @@ var __publicField = (obj, key, value) => {
10418
10418
  var _a;
10419
10419
  event.preventDefault();
10420
10420
  event.stopPropagation();
10421
- assert(logger$4O, this.mouseDownEvent, "no mouse down event");
10421
+ assert(logger$4P, this.mouseDownEvent, "no mouse down event");
10422
10422
  const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
10423
10423
  const newPos = DragDrop.getEventPosition(event);
10424
10424
  const deltaX = newPos.x - oldPos.x;
@@ -10434,7 +10434,7 @@ var __publicField = (obj, key, value) => {
10434
10434
  });
10435
10435
  __publicField(this, "handleMouseUp", (event) => {
10436
10436
  if (event instanceof MouseEvent && event.button === 0 || event instanceof TouchEvent) {
10437
- assert(logger$4O, this.mouseDownEvent, "no mouse down event");
10437
+ assert(logger$4P, this.mouseDownEvent, "no mouse down event");
10438
10438
  const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
10439
10439
  const newPos = DragDrop.getEventPosition(event);
10440
10440
  const deltaX = newPos.x - oldPos.x;
@@ -10543,7 +10543,7 @@ var __publicField = (obj, key, value) => {
10543
10543
  const dragDrop = new DragDrop(options);
10544
10544
  return dragDrop;
10545
10545
  }
10546
- const logger$4N = getLogger("character");
10546
+ const logger$4O = getLogger("character");
10547
10547
  function checkChar(charCode, rangeList) {
10548
10548
  for (let i = 0; i < rangeList.length; i++) {
10549
10549
  const start = rangeList[i][0];
@@ -10588,9 +10588,13 @@ var __publicField = (obj, key, value) => {
10588
10588
  ];
10589
10589
  return checkChar(str.charCodeAt(0), CJKRange);
10590
10590
  }
10591
+ function isCJKPunctuation(char) {
10592
+ const reg = /[\u3000-\u303F\uFF00-\uFFEF\u2000-\u206F\u2E00-\u2E7F]/;
10593
+ return reg.test(char);
10594
+ }
10591
10595
  function trimChar(s, char) {
10592
10596
  let c = char;
10593
- assert(logger$4N, c.length === 1, "invalid char length");
10597
+ assert(logger$4O, c.length === 1, "invalid char length");
10594
10598
  if (c === "]")
10595
10599
  c = "\\]";
10596
10600
  if (c === "\\")
@@ -10907,31 +10911,24 @@ var __publicField = (obj, key, value) => {
10907
10911
  return elementFont;
10908
10912
  }
10909
10913
  function getTextWidth(text2, font) {
10910
- try {
10911
- if (window.fakebrowser) {
10912
- return 200;
10913
- }
10914
- const canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
10915
- const context = canvas.getContext("2d");
10916
- if (!context) {
10917
- return 200;
10918
- }
10919
- if (typeof font === "string") {
10920
- if (!font) {
10921
- context.font = getStyleFont(window.getComputedStyle(document.body));
10922
- } else {
10923
- context.font = font;
10924
- }
10925
- } else if (font instanceof Element) {
10926
- context.font = getStyleFont(window.getComputedStyle(font));
10927
- }
10928
- const metrics = context.measureText(text2);
10929
- return metrics.width + 4;
10930
- } catch (err) {
10914
+ const canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
10915
+ const context = canvas.getContext("2d");
10916
+ if (!context) {
10931
10917
  return 200;
10932
10918
  }
10919
+ if (typeof font === "string") {
10920
+ if (!font) {
10921
+ context.font = getStyleFont(window.getComputedStyle(document.body));
10922
+ } else {
10923
+ context.font = font;
10924
+ }
10925
+ } else if (font instanceof Element) {
10926
+ context.font = getStyleFont(window.getComputedStyle(font));
10927
+ }
10928
+ const metrics = context.measureText(text2);
10929
+ return metrics.width + 4;
10933
10930
  }
10934
- const logger$4M = getLogger("editor-clipboard");
10931
+ const logger$4N = getLogger("editor-clipboard");
10935
10932
  async function setClipboardDataByEvent(items, event) {
10936
10933
  if (event.clipboardData) {
10937
10934
  const data2 = event.clipboardData;
@@ -10989,7 +10986,7 @@ var __publicField = (obj, key, value) => {
10989
10986
  document.body.removeChild(textarea2);
10990
10987
  return true;
10991
10988
  } catch (ex) {
10992
- logger$4M.error(ex);
10989
+ logger$4N.error(ex);
10993
10990
  document.body.removeChild(textarea2);
10994
10991
  return false;
10995
10992
  }
@@ -11010,7 +11007,7 @@ var __publicField = (obj, key, value) => {
11010
11007
  document.body.removeChild(div);
11011
11008
  return true;
11012
11009
  } catch (ex) {
11013
- logger$4M.error(ex);
11010
+ logger$4N.error(ex);
11014
11011
  document.body.removeChild(div);
11015
11012
  return false;
11016
11013
  }
@@ -11037,7 +11034,7 @@ var __publicField = (obj, key, value) => {
11037
11034
  await navigator.clipboard.write([clipboardItems]);
11038
11035
  return true;
11039
11036
  } catch (err) {
11040
- logger$4M.error(err);
11037
+ logger$4N.error(err);
11041
11038
  return await execCommandCopy(items);
11042
11039
  }
11043
11040
  }
@@ -11093,7 +11090,7 @@ var __publicField = (obj, key, value) => {
11093
11090
  a.click();
11094
11091
  a.remove();
11095
11092
  }
11096
- const logger$4L = getLogger("auto-scroll");
11093
+ const logger$4M = getLogger("auto-scroll");
11097
11094
  function scrollable(scrollElement, direction) {
11098
11095
  if (scrollElement.scrollHeight === scrollElement.clientHeight) {
11099
11096
  return false;
@@ -11117,7 +11114,7 @@ var __publicField = (obj, key, value) => {
11117
11114
  const isHorizontal = direction === "left" || direction === "right";
11118
11115
  const scroll = () => {
11119
11116
  if (!scrollable(scrollElement, direction)) {
11120
- logger$4L.debug("No need for scroll");
11117
+ logger$4M.debug("No need for scroll");
11121
11118
  return null;
11122
11119
  }
11123
11120
  if (isHorizontal) {
@@ -11174,7 +11171,7 @@ var __publicField = (obj, key, value) => {
11174
11171
  if (this.scrolling) {
11175
11172
  return;
11176
11173
  }
11177
- logger$4L.debug(`scroll direction: ${direction}`);
11174
+ logger$4M.debug(`scroll direction: ${direction}`);
11178
11175
  this.cancelScroll = continuousScroll(scrollElement, {
11179
11176
  direction,
11180
11177
  step
@@ -11424,7 +11421,7 @@ var __publicField = (obj, key, value) => {
11424
11421
  const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
11425
11422
  return ColorNames[colorIndex];
11426
11423
  }
11427
- const logger$4K = getLogger("container");
11424
+ const logger$4L = getLogger("container");
11428
11425
  function isContainer(elem) {
11429
11426
  return elem.getAttribute("data-type") === "editor-container";
11430
11427
  }
@@ -11436,9 +11433,9 @@ var __publicField = (obj, key, value) => {
11436
11433
  }
11437
11434
  function getContainerId(container) {
11438
11435
  const id = container.getAttribute("data-container-id");
11439
- assert(logger$4K, id, "no id for container");
11436
+ assert(logger$4L, id, "no id for container");
11440
11437
  if (isRootContainer(container)) {
11441
- assert(logger$4K, id === "root", `invalid root container id, : ${id}`);
11438
+ assert(logger$4L, id === "root", `invalid root container id, : ${id}`);
11442
11439
  }
11443
11440
  return id;
11444
11441
  }
@@ -11449,7 +11446,7 @@ var __publicField = (obj, key, value) => {
11449
11446
  function generateEditorContainerId(containerId) {
11450
11447
  return `ones-editor-container-${containerId}`;
11451
11448
  }
11452
- const logger$4J = getLogger("element");
11449
+ const logger$4K = getLogger("element");
11453
11450
  function createContainerElement(parent, type, containerId) {
11454
11451
  const container = createElement("div", [type], parent);
11455
11452
  container.setAttribute("data-type", "editor-container");
@@ -11460,7 +11457,7 @@ var __publicField = (obj, key, value) => {
11460
11457
  }
11461
11458
  function getContainerById(editor, containerId) {
11462
11459
  const container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
11463
- assert(logger$4J, container, `no container: ${containerId}`);
11460
+ assert(logger$4K, container, `no container: ${containerId}`);
11464
11461
  return container;
11465
11462
  }
11466
11463
  function getExistsContainerById(editor, containerId) {
@@ -11469,7 +11466,7 @@ var __publicField = (obj, key, value) => {
11469
11466
  }
11470
11467
  function getContainerBlocksElement(container) {
11471
11468
  const blocks = container.querySelector(":scope > .container-blocks");
11472
- assert(logger$4J, blocks, "no container blocks element");
11469
+ assert(logger$4K, blocks, "no container blocks element");
11473
11470
  return blocks;
11474
11471
  }
11475
11472
  function getContainerToolsElement(container) {
@@ -11482,11 +11479,11 @@ var __publicField = (obj, key, value) => {
11482
11479
  function isContainerBlocksElement(element) {
11483
11480
  return element.classList.contains("container-blocks");
11484
11481
  }
11485
- const logger$4I = getLogger("container-children");
11482
+ const logger$4J = getLogger("container-children");
11486
11483
  function getChildBlocks(container, traverseChild) {
11487
11484
  const content = getContainerBlocksElement(container);
11488
11485
  const blocks = Array.from(content.children);
11489
- assert(logger$4I, blocks.length > 0, "container have not any child block");
11486
+ assert(logger$4J, blocks.length > 0, "container have not any child block");
11490
11487
  if (traverseChild) {
11491
11488
  const { condition, editor } = traverseChild;
11492
11489
  return blocks.reduce((result, block) => {
@@ -11509,7 +11506,7 @@ var __publicField = (obj, key, value) => {
11509
11506
  }
11510
11507
  function getFirstChildBlock(container) {
11511
11508
  const block = container.querySelector(":scope > .container-blocks > div[data-type=editor-block]");
11512
- assert(logger$4I, block, "container have not any child block");
11509
+ assert(logger$4J, block, "container have not any child block");
11513
11510
  return block;
11514
11511
  }
11515
11512
  function getLastChildBlock(container) {
@@ -11521,14 +11518,14 @@ var __publicField = (obj, key, value) => {
11521
11518
  }
11522
11519
  function getBlockByIndex(container, blockIndex) {
11523
11520
  const block = getChildBlocks(container)[blockIndex];
11524
- assert(logger$4I, block, `container have not block at index ${blockIndex}`);
11521
+ assert(logger$4J, block, `container have not block at index ${blockIndex}`);
11525
11522
  return block;
11526
11523
  }
11527
11524
  function findBlockByIndex(container, blockIndex) {
11528
11525
  var _a;
11529
11526
  return (_a = getChildBlocks(container)[blockIndex]) != null ? _a : null;
11530
11527
  }
11531
- const logger$4H = getLogger("block-dom");
11528
+ const logger$4I = getLogger("block-dom");
11532
11529
  function isBlock$1(node) {
11533
11530
  if (!(node instanceof HTMLDivElement)) {
11534
11531
  return false;
@@ -11549,12 +11546,12 @@ var __publicField = (obj, key, value) => {
11549
11546
  }
11550
11547
  function getBlockId(block) {
11551
11548
  const { id } = block;
11552
- assert(logger$4H, id, "no block id");
11549
+ assert(logger$4I, id, "no block id");
11553
11550
  return id;
11554
11551
  }
11555
11552
  function getBlockType(block) {
11556
11553
  const type = block.getAttribute("data-block-type");
11557
- assert(logger$4H, type, "invalid block dom, no data-type");
11554
+ assert(logger$4I, type, "invalid block dom, no data-type");
11558
11555
  return type;
11559
11556
  }
11560
11557
  function getParentBlock(node) {
@@ -11577,12 +11574,12 @@ var __publicField = (obj, key, value) => {
11577
11574
  }
11578
11575
  function getParentContainer(block) {
11579
11576
  const container = block.closest("div[data-type=editor-container]");
11580
- assert(logger$4H, container, "failed to get block container");
11577
+ assert(logger$4I, container, "failed to get block container");
11581
11578
  return container;
11582
11579
  }
11583
11580
  function getBlockContent(block) {
11584
11581
  const content = block.querySelector(":scope >div[data-type=block-content]");
11585
- assert(logger$4H, content, "no block content");
11582
+ assert(logger$4I, content, "no block content");
11586
11583
  return content;
11587
11584
  }
11588
11585
  function getBlockTools(block) {
@@ -11591,7 +11588,7 @@ var __publicField = (obj, key, value) => {
11591
11588
  tools = createElement("div", [], block);
11592
11589
  tools.setAttribute("data-type", "block-tools");
11593
11590
  }
11594
- assert(logger$4H, tools, "no block tools");
11591
+ assert(logger$4I, tools, "no block tools");
11595
11592
  return tools;
11596
11593
  }
11597
11594
  function getExistsBlockTools(block) {
@@ -11612,7 +11609,7 @@ var __publicField = (obj, key, value) => {
11612
11609
  function createBlockElement(editor, path, data2) {
11613
11610
  const blockData = editor.editorDecorators.decorateBlock(path, data2);
11614
11611
  const { id, type } = blockData;
11615
- assert(logger$4H, id, "no block id");
11612
+ assert(logger$4I, id, "no block id");
11616
11613
  const elem = createElement("div", [`${type}-block`], null);
11617
11614
  elem.id = id;
11618
11615
  elem.setAttribute("data-type", "editor-block");
@@ -11650,7 +11647,7 @@ var __publicField = (obj, key, value) => {
11650
11647
  }
11651
11648
  function getBoxTypeFromElement(box) {
11652
11649
  const type = box.getAttribute("data-box-type");
11653
- assert(logger$4H, type, "not a valid box element, no type");
11650
+ assert(logger$4I, type, "not a valid box element, no type");
11654
11651
  return type;
11655
11652
  }
11656
11653
  function isBox(node) {
@@ -11661,7 +11658,7 @@ var __publicField = (obj, key, value) => {
11661
11658
  }
11662
11659
  function getBoxId(box) {
11663
11660
  const { id } = box;
11664
- assert(logger$4H, id, "no box id");
11661
+ assert(logger$4I, id, "no box id");
11665
11662
  return id;
11666
11663
  }
11667
11664
  function getParentBox(node) {
@@ -11683,7 +11680,7 @@ var __publicField = (obj, key, value) => {
11683
11680
  }
11684
11681
  function getBoxContent(box) {
11685
11682
  const content = box.querySelector("span[data-type=box-content]");
11686
- assert(logger$4H, content, "invalid box dom, no content");
11683
+ assert(logger$4I, content, "invalid box dom, no content");
11687
11684
  return content;
11688
11685
  }
11689
11686
  function createInsertionElement(type, id, attributes) {
@@ -11705,7 +11702,7 @@ var __publicField = (obj, key, value) => {
11705
11702
  }
11706
11703
  function getInsertionContent(insertion) {
11707
11704
  const content = insertion.querySelector("span[data-type=insertion-content]");
11708
- assert(logger$4H, content, "invalid insertion-child dom, no content");
11705
+ assert(logger$4I, content, "invalid insertion-child dom, no content");
11709
11706
  return content;
11710
11707
  }
11711
11708
  function getPrevBlock(block) {
@@ -11728,31 +11725,44 @@ var __publicField = (obj, key, value) => {
11728
11725
  }
11729
11726
  return null;
11730
11727
  }
11731
- function getPrevVisibleBlock(block) {
11728
+ function getPrevVisibleBlock(block, matcher) {
11729
+ const mergedMatcher = matcher || (() => true);
11732
11730
  let prev = block.previousElementSibling;
11733
11731
  while (prev) {
11734
- if (isBlock$1(prev) && isVisibleBlock(prev)) {
11732
+ if (isBlock$1(prev) && isVisibleBlock(prev) && mergedMatcher(prev)) {
11735
11733
  return prev;
11736
11734
  }
11737
11735
  prev = prev.previousElementSibling;
11738
11736
  }
11739
11737
  return null;
11740
11738
  }
11741
- function getNextVisibleBlock(block) {
11739
+ function getNextVisibleBlock(block, matcher) {
11740
+ const mergedMatcher = matcher || (() => true);
11742
11741
  let next2 = block.nextElementSibling;
11743
11742
  while (next2) {
11744
- if (isBlock$1(next2) && isVisibleBlock(next2)) {
11743
+ if (isBlock$1(next2) && isVisibleBlock(next2) && mergedMatcher(next2)) {
11745
11744
  return next2;
11746
11745
  }
11747
11746
  next2 = next2.nextElementSibling;
11748
11747
  }
11749
11748
  return null;
11750
11749
  }
11750
+ function getBlocksBetween(start, end, matcher) {
11751
+ const blocks = [];
11752
+ let cur = start;
11753
+ while (cur !== end) {
11754
+ if (isBlock$1(cur) && matcher(cur)) {
11755
+ blocks.push(cur);
11756
+ }
11757
+ cur = cur.nextElementSibling;
11758
+ }
11759
+ return blocks;
11760
+ }
11751
11761
  function getBlockIndex(block) {
11752
11762
  const container = getParentContainer(block);
11753
11763
  const children = getChildBlocks(container);
11754
11764
  const index2 = children.indexOf(block);
11755
- assert(logger$4H, index2 !== -1, "invalid block & container dom, failed to get block index");
11765
+ assert(logger$4I, index2 !== -1, "invalid block & container dom, failed to get block index");
11756
11766
  return index2;
11757
11767
  }
11758
11768
  function isInBlock(target) {
@@ -11777,18 +11787,18 @@ var __publicField = (obj, key, value) => {
11777
11787
  function isTitleBlock$2(block) {
11778
11788
  return block.hasAttribute("data-document-title");
11779
11789
  }
11780
- const logger$4G = getLogger("block-class");
11790
+ const logger$4H = getLogger("block-class");
11781
11791
  function getBlockClass(editor, block) {
11782
11792
  return editor.editorBlocks.getBlockClass(getBlockType(block));
11783
11793
  }
11784
11794
  function getTextBlockClass(editor, block) {
11785
11795
  const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
11786
- assert(logger$4G, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
11796
+ assert(logger$4H, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
11787
11797
  return text2;
11788
11798
  }
11789
11799
  function getComplexBlockClass(editor, block) {
11790
11800
  const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
11791
- assert(logger$4G, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
11801
+ assert(logger$4H, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
11792
11802
  return complex;
11793
11803
  }
11794
11804
  function getBlockClassByType(editor, type) {
@@ -11809,7 +11819,7 @@ var __publicField = (obj, key, value) => {
11809
11819
  function getBlockKind(editor, block) {
11810
11820
  return getBlockClass(editor, block).blockKind;
11811
11821
  }
11812
- const logger$4F = getLogger("text-block-child");
11822
+ const logger$4G = getLogger("text-block-child");
11813
11823
  function isTextBlockContentChild(elem) {
11814
11824
  if (elem.tagName !== "SPAN") {
11815
11825
  return false;
@@ -11817,14 +11827,14 @@ var __publicField = (obj, key, value) => {
11817
11827
  return true;
11818
11828
  }
11819
11829
  function isTextBlockContentBoxChild(elem) {
11820
- assert(logger$4F, isTextBlockContentChild(elem), "not a valid text child");
11830
+ assert(logger$4G, isTextBlockContentChild(elem), "not a valid text child");
11821
11831
  if (elem.getAttribute("data-type") === "editor-box") {
11822
11832
  return true;
11823
11833
  }
11824
11834
  return false;
11825
11835
  }
11826
11836
  function isTextBlockContentInsertionChild(elem) {
11827
- assert(logger$4F, isTextBlockContentChild(elem), "not a valid text child");
11837
+ assert(logger$4G, isTextBlockContentChild(elem), "not a valid text child");
11828
11838
  if (elem.getAttribute("data-type") === "editor-insertion") {
11829
11839
  return true;
11830
11840
  }
@@ -11834,7 +11844,7 @@ var __publicField = (obj, key, value) => {
11834
11844
  return !isTextBlockContentBoxChild(elem) && !isTextBlockContentInsertionChild(elem);
11835
11845
  }
11836
11846
  function getTextBlockContentChildType(child) {
11837
- assert(logger$4F, isTextBlockContentChild(child), "not a valid text child");
11847
+ assert(logger$4G, isTextBlockContentChild(child), "not a valid text child");
11838
11848
  if (isTextBlockContentBoxChild(child)) {
11839
11849
  return "box";
11840
11850
  }
@@ -11849,15 +11859,15 @@ var __publicField = (obj, key, value) => {
11849
11859
  return 0;
11850
11860
  if (type === "box")
11851
11861
  return 1;
11852
- assert(logger$4F, child.textContent !== null, "text block content is undefined");
11853
- assert(logger$4F, child.textContent.length >= 0, "text block content length is negative");
11862
+ assert(logger$4G, child.textContent !== null, "text block content is undefined");
11863
+ assert(logger$4G, child.textContent.length >= 0, "text block content length is negative");
11854
11864
  return child.textContent.length;
11855
11865
  }
11856
11866
  function getTextBlockContentChildren(block) {
11857
11867
  const content = getBlockContent(block);
11858
11868
  const children = Array.from(content.children);
11859
11869
  children.forEach((child) => {
11860
- assert(logger$4F, isTextBlockContentChild(child), "not a valid text child");
11870
+ assert(logger$4G, isTextBlockContentChild(child), "not a valid text child");
11861
11871
  });
11862
11872
  return children;
11863
11873
  }
@@ -11886,17 +11896,17 @@ var __publicField = (obj, key, value) => {
11886
11896
  };
11887
11897
  }
11888
11898
  const offset = blockOffset - start;
11889
- assert(logger$4F, offset > 0, "invalid offset value");
11890
- assert(logger$4F, !isTextBlockContentBoxChild(child), "invalid box child");
11899
+ assert(logger$4G, offset > 0, "invalid offset value");
11900
+ assert(logger$4G, !isTextBlockContentBoxChild(child), "invalid box child");
11891
11901
  return {
11892
11902
  prev: child,
11893
11903
  next: child,
11894
11904
  offset
11895
11905
  };
11896
11906
  }
11897
- assert(logger$4F, false, `invalid block child at position: ${blockOffset}`);
11907
+ assert(logger$4G, false, `invalid block child at position: ${blockOffset}`);
11898
11908
  }
11899
- const logger$4E = getLogger("block-path");
11909
+ const logger$4F = getLogger("block-path");
11900
11910
  function getBlockPath(block) {
11901
11911
  const ret = [];
11902
11912
  let current = block;
@@ -11910,26 +11920,26 @@ var __publicField = (obj, key, value) => {
11910
11920
  return ret;
11911
11921
  }
11912
11922
  const parentBlock = getParentBlock(container);
11913
- assert(logger$4E, parentBlock, "no parent block");
11923
+ assert(logger$4F, parentBlock, "no parent block");
11914
11924
  current = parentBlock;
11915
11925
  }
11916
- assert(logger$4E, false, "no parent block");
11926
+ assert(logger$4F, false, "no parent block");
11917
11927
  return [];
11918
11928
  }
11919
- const logger$4D = getLogger("child-container-path");
11929
+ const logger$4E = getLogger("child-container-path");
11920
11930
  function getContainerBlockPath(container) {
11921
11931
  if (isRootContainer(container)) {
11922
11932
  return [];
11923
11933
  }
11924
11934
  const parentBlock = getParentBlock(container);
11925
- assert(logger$4D, parentBlock, "no parent block");
11935
+ assert(logger$4E, parentBlock, "no parent block");
11926
11936
  return getBlockPath(parentBlock);
11927
11937
  }
11928
- const logger$4C = getLogger("load-blocks");
11938
+ const logger$4D = getLogger("load-blocks");
11929
11939
  function loadBlocks(editor, container, path) {
11930
11940
  const containerId = getContainerId(container);
11931
11941
  const blocks = getContainerBlocks$1(container, editor.doc);
11932
- assert(logger$4C, blocks.length > 0, "no blocks in container");
11942
+ assert(logger$4D, blocks.length > 0, "no blocks in container");
11933
11943
  const fragment = document.createDocumentFragment();
11934
11944
  blocks.forEach((b, index2) => {
11935
11945
  const block = editor.editorBlocks.createBlock([...path, { containerId, blockIndex: index2 }], container, b);
@@ -11945,7 +11955,7 @@ var __publicField = (obj, key, value) => {
11945
11955
  return block;
11946
11956
  }
11947
11957
  const blocks = getChildBlocks(container);
11948
- assert(logger$4C, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
11958
+ assert(logger$4D, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
11949
11959
  if (blockIndex === blocks.length) {
11950
11960
  containerBlocksElement.appendChild(block);
11951
11961
  } else {
@@ -11963,7 +11973,7 @@ var __publicField = (obj, key, value) => {
11963
11973
  insertBlockAt(container, blockIndex, block);
11964
11974
  return block;
11965
11975
  }
11966
- const logger$4B = getLogger("root-container");
11976
+ const logger$4C = getLogger("root-container");
11967
11977
  const MIN_DISTANCE_THRESHOLD$2 = 3;
11968
11978
  class RootContainer {
11969
11979
  constructor(editor, rootContainer) {
@@ -11991,7 +12001,7 @@ var __publicField = (obj, key, value) => {
11991
12001
  this.editor.selection.updateSelection(null);
11992
12002
  this.editor.emit("resize", this.editor);
11993
12003
  } catch (err) {
11994
- logger$4B.warn(`failed to update selection while container resizing: ${err.message}`);
12004
+ logger$4C.warn(`failed to update selection while container resizing: ${err.message}`);
11995
12005
  }
11996
12006
  });
11997
12007
  __publicField(this, "handleClick", (event) => {
@@ -12024,7 +12034,7 @@ var __publicField = (obj, key, value) => {
12024
12034
  const box = getParentBox(elem);
12025
12035
  if (box) {
12026
12036
  const block2 = getParentBlock(box);
12027
- assert(logger$4B, block2, "no parent block");
12037
+ assert(logger$4C, block2, "no parent block");
12028
12038
  (_b = (_a = this.editor.editorBoxes.getBoxClass(getBoxTypeFromElement(box))) == null ? void 0 : _a.handleClickBox) == null ? void 0 : _b.call(_a, this.editor, box, event);
12029
12039
  return;
12030
12040
  }
@@ -12079,7 +12089,7 @@ var __publicField = (obj, key, value) => {
12079
12089
  this.editor.input.focus({ preventScroll: true });
12080
12090
  });
12081
12091
  __publicField(this, "handleMouseMove", (event) => {
12082
- assert(logger$4B, this.mouseDownEvent, "no mouse down event");
12092
+ assert(logger$4C, this.mouseDownEvent, "no mouse down event");
12083
12093
  if (ensureIsMobileEvent(this.mouseDownEvent))
12084
12094
  return;
12085
12095
  const deltaX = event.x - this.mouseDownEvent.x;
@@ -12195,7 +12205,7 @@ var __publicField = (obj, key, value) => {
12195
12205
  loadBlocks(editor, container, path);
12196
12206
  return container;
12197
12207
  }
12198
- const logger$4A = getLogger("block");
12208
+ const logger$4B = getLogger("block");
12199
12209
  function getBlockTextLength$6(editor, block) {
12200
12210
  return getBlockClass(editor, block).getBlockTextLength(block);
12201
12211
  }
@@ -12214,7 +12224,7 @@ var __publicField = (obj, key, value) => {
12214
12224
  return block;
12215
12225
  }
12216
12226
  const parent = getParentBlock(container);
12217
- assert(logger$4A, parent, "no parent block exists for child container");
12227
+ assert(logger$4B, parent, "no parent block exists for child container");
12218
12228
  block = parent;
12219
12229
  }
12220
12230
  }
@@ -12250,7 +12260,7 @@ var __publicField = (obj, key, value) => {
12250
12260
  }
12251
12261
  return fun(editor, block, options);
12252
12262
  } catch (err) {
12253
- logger$4A.debug(`unsupported block type: ${type}`);
12263
+ logger$4B.debug(`unsupported block type: ${type}`);
12254
12264
  return null;
12255
12265
  }
12256
12266
  }
@@ -12270,7 +12280,7 @@ var __publicField = (obj, key, value) => {
12270
12280
  const styles = Object.fromEntries(Object.entries(data2).filter(([key]) => key.startsWith("style-")));
12271
12281
  Object.entries(styles).forEach(([, value]) => {
12272
12282
  const type = typeof value;
12273
- assert(logger$4A, type === "string" || type === "number" || type === "boolean", "invalid style value");
12283
+ assert(logger$4B, type === "string" || type === "number" || type === "boolean", "invalid style value");
12274
12284
  });
12275
12285
  return styles;
12276
12286
  }
@@ -12395,7 +12405,7 @@ var __publicField = (obj, key, value) => {
12395
12405
  }
12396
12406
  return { element: null, blockCommands: [], boxCommands: [] };
12397
12407
  }
12398
- const logger$4z = getLogger("embed-block-common");
12408
+ const logger$4A = getLogger("embed-block-common");
12399
12409
  function isColumnsBlock(block) {
12400
12410
  return getBlockType(block) === "layout";
12401
12411
  }
@@ -12403,9 +12413,9 @@ var __publicField = (obj, key, value) => {
12403
12413
  return getBlockType(block) === "embed";
12404
12414
  }
12405
12415
  function getEmbedType(block) {
12406
- assert(logger$4z, isEmbedBlock(block), "not an embed block");
12416
+ assert(logger$4A, isEmbedBlock(block), "not an embed block");
12407
12417
  const type = block.getAttribute("data-embed-type");
12408
- assert(logger$4z, type, "no embed data type");
12418
+ assert(logger$4A, type, "no embed data type");
12409
12419
  return type;
12410
12420
  }
12411
12421
  function getEmbedClassFromBlock(editor, block) {
@@ -12471,10 +12481,10 @@ var __publicField = (obj, key, value) => {
12471
12481
  data: (_c = overrideOptions == null ? void 0 : overrideOptions.data) != null ? _c : data2
12472
12482
  });
12473
12483
  }
12474
- const logger$4y = getLogger("execute-block-command");
12484
+ const logger$4z = getLogger("execute-block-command");
12475
12485
  function executeEmbedBlockCommand(editor, block, commandGroup, item) {
12476
12486
  var _a;
12477
- assert(logger$4y, isEmbedBlock(block), "not a embed block");
12487
+ assert(logger$4z, isEmbedBlock(block), "not a embed block");
12478
12488
  const embedType = getEmbedType(block);
12479
12489
  const embed = getEmbedClassByType(editor, embedType);
12480
12490
  if (!embed.getOptions) {
@@ -12507,14 +12517,14 @@ var __publicField = (obj, key, value) => {
12507
12517
  }
12508
12518
  return void 0;
12509
12519
  }
12510
- const logger$4x = getLogger("block-class");
12520
+ const logger$4y = getLogger("block-class");
12511
12521
  function isHeadingBlock$1(block) {
12512
12522
  return !!block.getAttribute("data-style-heading");
12513
12523
  }
12514
12524
  function getBlockHeading(block) {
12515
12525
  var _a;
12516
12526
  const heading = Number.parseInt((_a = block.getAttribute("data-style-heading")) != null ? _a : "", 10);
12517
- assert(logger$4x, heading, "not a heading block");
12527
+ assert(logger$4y, heading, "not a heading block");
12518
12528
  return heading;
12519
12529
  }
12520
12530
  function isExpandedHeadingBlock(block) {
@@ -12525,7 +12535,7 @@ var __publicField = (obj, key, value) => {
12525
12535
  }
12526
12536
  function getHeadingBlockChildren(block, oldHeading) {
12527
12537
  if (!oldHeading) {
12528
- assert(logger$4x, isHeadingBlock$1(block), "not a heading block");
12538
+ assert(logger$4y, isHeadingBlock$1(block), "not a heading block");
12529
12539
  }
12530
12540
  const children = [];
12531
12541
  const heading = oldHeading != null ? oldHeading : getBlockHeading(block);
@@ -12555,7 +12565,7 @@ var __publicField = (obj, key, value) => {
12555
12565
  }
12556
12566
  return children;
12557
12567
  }
12558
- const logger$4w = getLogger("complex-block-position");
12568
+ const logger$4x = getLogger("complex-block-position");
12559
12569
  class EditorComplexBlockPosition {
12560
12570
  constructor(block, childContainerId, custom) {
12561
12571
  __publicField(this, "blockId");
@@ -12564,7 +12574,7 @@ var __publicField = (obj, key, value) => {
12564
12574
  if (block instanceof HTMLElement) {
12565
12575
  this.blockId = getBlockId(block);
12566
12576
  } else {
12567
- assert(logger$4w, typeof block === "string", `not a valid block id: ${block}`);
12577
+ assert(logger$4x, typeof block === "string", `not a valid block id: ${block}`);
12568
12578
  this.blockId = block;
12569
12579
  }
12570
12580
  this.childContainerId = childContainerId;
@@ -12576,7 +12586,7 @@ var __publicField = (obj, key, value) => {
12576
12586
  return false;
12577
12587
  }
12578
12588
  }
12579
- const logger$4v = getLogger("simple-block-position");
12589
+ const logger$4w = getLogger("simple-block-position");
12580
12590
  class EditorSimpleBlockPosition {
12581
12591
  constructor(block, offset, type) {
12582
12592
  __publicField(this, "blockId");
@@ -12585,7 +12595,7 @@ var __publicField = (obj, key, value) => {
12585
12595
  if (block instanceof HTMLElement) {
12586
12596
  this.blockId = getBlockId(block);
12587
12597
  } else {
12588
- assert(logger$4v, typeof block === "string", `not a valid block id: ${block}`);
12598
+ assert(logger$4w, typeof block === "string", `not a valid block id: ${block}`);
12589
12599
  this.blockId = block;
12590
12600
  }
12591
12601
  this.offset = offset;
@@ -12595,7 +12605,7 @@ var __publicField = (obj, key, value) => {
12595
12605
  return true;
12596
12606
  }
12597
12607
  }
12598
- const logger$4u = getLogger("editor-position");
12608
+ const logger$4v = getLogger("editor-position");
12599
12609
  function createSimpleBlockPosition(block, offset, type) {
12600
12610
  return new EditorSimpleBlockPosition(block, offset, type);
12601
12611
  }
@@ -12617,7 +12627,7 @@ var __publicField = (obj, key, value) => {
12617
12627
  }
12618
12628
  const block1 = editor.getBlockById(pos1.blockId);
12619
12629
  const block2 = editor.getBlockById(pos2.blockId);
12620
- assert(logger$4u, block1 !== block2, "comparePosition: blocks are the same");
12630
+ assert(logger$4v, block1 !== block2, "comparePosition: blocks are the same");
12621
12631
  return compareElement(block1, block2);
12622
12632
  }
12623
12633
  if (isComplexBlockPosition(pos1) && isComplexBlockPosition(pos2)) {
@@ -12628,13 +12638,13 @@ var __publicField = (obj, key, value) => {
12628
12638
  }
12629
12639
  const container1 = editor.getContainerById(p1.childContainerId);
12630
12640
  const container2 = editor.getContainerById(p2.childContainerId);
12631
- assert(logger$4u, container1 !== container2, "comparePosition: containers are the same");
12641
+ assert(logger$4v, container1 !== container2, "comparePosition: containers are the same");
12632
12642
  return compareElement(container1, container2);
12633
12643
  }
12634
- assert(logger$4u, false, "invalid ");
12644
+ assert(logger$4v, false, "invalid ");
12635
12645
  return 0;
12636
12646
  }
12637
- const logger$4t = getLogger("simple-range");
12647
+ const logger$4u = getLogger("simple-range");
12638
12648
  class EditorSimpleSelectionRange {
12639
12649
  constructor(editor, options) {
12640
12650
  __publicField(this, "editor");
@@ -12683,11 +12693,11 @@ var __publicField = (obj, key, value) => {
12683
12693
  const { editor } = this;
12684
12694
  const startBlock = editor.getBlockById(this.start.blockId);
12685
12695
  const endBlock = editor.getBlockById(this.end.blockId);
12686
- assert(logger$4t, startBlock, "no start block");
12687
- assert(logger$4t, endBlock, "no end block");
12696
+ assert(logger$4u, startBlock, "no start block");
12697
+ assert(logger$4u, endBlock, "no end block");
12688
12698
  const startContainer = getParentContainer(startBlock);
12689
12699
  const endContainer = getParentContainer(endBlock);
12690
- assert(logger$4t, startContainer === endContainer, "invalid range");
12700
+ assert(logger$4u, startContainer === endContainer, "invalid range");
12691
12701
  const ret = [];
12692
12702
  if (startBlock === endBlock) {
12693
12703
  ret.push({
@@ -12698,7 +12708,7 @@ var __publicField = (obj, key, value) => {
12698
12708
  } else {
12699
12709
  const startIndex = getBlockIndex(startBlock);
12700
12710
  const endIndex = getBlockIndex(endBlock);
12701
- assert(logger$4t, startIndex < endIndex, "invalid range, start > index");
12711
+ assert(logger$4u, startIndex < endIndex, "invalid range, start > index");
12702
12712
  ret.push({
12703
12713
  block: startBlock,
12704
12714
  start: this.start,
@@ -12798,7 +12808,7 @@ var __publicField = (obj, key, value) => {
12798
12808
  clearSelection: clearSelection$6,
12799
12809
  convertTo: convertTo$m
12800
12810
  };
12801
- const logger$4s = getLogger("editor-blocks");
12811
+ const logger$4t = getLogger("editor-blocks");
12802
12812
  class EditorBlocks {
12803
12813
  constructor(editor) {
12804
12814
  __publicField(this, "blocks", /* @__PURE__ */ new Map());
@@ -12807,12 +12817,12 @@ var __publicField = (obj, key, value) => {
12807
12817
  registerBlockClass(blockClass) {
12808
12818
  const type = blockClass.blockType;
12809
12819
  const exists = this.blocks.get(type);
12810
- assert(logger$4s, !exists, `duplicated block type: ${type}`);
12820
+ assert(logger$4t, !exists, `duplicated block type: ${type}`);
12811
12821
  this.blocks.set(type, blockClass);
12812
12822
  }
12813
12823
  getBlockClass(type) {
12814
12824
  const exists = this.blocks.get(type);
12815
- assert(logger$4s, exists, `unknown block type: ${type}`);
12825
+ assert(logger$4t, exists, `unknown block type: ${type}`);
12816
12826
  return exists;
12817
12827
  }
12818
12828
  hasBlock(type) {
@@ -12828,7 +12838,7 @@ var __publicField = (obj, key, value) => {
12828
12838
  }
12829
12839
  const content = blockClass.createBlockContent(this.editor, path, container, blockElement, block);
12830
12840
  if (content.parentElement !== blockElement) {
12831
- logger$4s.warn("content parent is not block");
12841
+ logger$4t.warn("content parent is not block");
12832
12842
  blockElement.appendChild(content);
12833
12843
  }
12834
12844
  this.editor.blockHooks.forEach((hook) => {
@@ -12849,7 +12859,7 @@ var __publicField = (obj, key, value) => {
12849
12859
  return newBlock;
12850
12860
  }
12851
12861
  }
12852
- const logger$4r = getLogger("editor-embeds");
12862
+ const logger$4s = getLogger("editor-embeds");
12853
12863
  class EditorEmbeds {
12854
12864
  constructor(editor) {
12855
12865
  __publicField(this, "objects", /* @__PURE__ */ new Map());
@@ -12858,12 +12868,12 @@ var __publicField = (obj, key, value) => {
12858
12868
  registerEmbedClass(embedClass) {
12859
12869
  const type = embedClass.embedType;
12860
12870
  const exists = this.objects.get(type);
12861
- assert(logger$4r, !exists, `duplicated embed object type: ${type}`);
12871
+ assert(logger$4s, !exists, `duplicated embed object type: ${type}`);
12862
12872
  this.objects.set(type, embedClass);
12863
12873
  }
12864
12874
  getEmbedClass(type) {
12865
12875
  const exists = this.objects.get(type);
12866
- assert(logger$4r, exists, `unknown embed type: ${type}`);
12876
+ assert(logger$4s, exists, `unknown embed type: ${type}`);
12867
12877
  return exists;
12868
12878
  }
12869
12879
  getEmbedClassFromBlock(block) {
@@ -12873,12 +12883,12 @@ var __publicField = (obj, key, value) => {
12873
12883
  this.objects.forEach(callback);
12874
12884
  }
12875
12885
  }
12876
- const logger$4q = getLogger("embed-block");
12886
+ const logger$4r = getLogger("embed-block");
12877
12887
  function createBlockContent$6(editor, path, container, blockElement, blockData) {
12878
12888
  const content = createBlockContentElement(blockElement, "div");
12879
- assert(logger$4q, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
12889
+ assert(logger$4r, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
12880
12890
  const embedBlockData = blockData;
12881
- assert(logger$4q, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
12891
+ assert(logger$4r, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
12882
12892
  const embedClass = editor.editorEmbeds.getEmbedClass(embedBlockData.embedType);
12883
12893
  embedClass.createEmbedContent(editor, content, embedBlockData, path, container, blockElement);
12884
12894
  blockElement.setAttribute("data-embed-type", embedBlockData.embedType);
@@ -12906,7 +12916,7 @@ var __publicField = (obj, key, value) => {
12906
12916
  function getCaretRect$4(block, pos) {
12907
12917
  const content = getBlockContent(block);
12908
12918
  const rect = content.getBoundingClientRect();
12909
- assert(logger$4q, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
12919
+ assert(logger$4r, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
12910
12920
  if (pos.offset === 1) {
12911
12921
  return new DOMRect(rect.right, rect.top, 0, rect.height);
12912
12922
  }
@@ -13046,18 +13056,18 @@ var __publicField = (obj, key, value) => {
13046
13056
  toStandardDoc: toStandardDoc$2,
13047
13057
  getResources: getResources$2
13048
13058
  };
13049
- const logger$4p = getLogger("complex-block-helper");
13059
+ const logger$4q = getLogger("complex-block-helper");
13050
13060
  function complexBlockGetAllChildContainers(editor, block, options) {
13051
13061
  const blockClass = getComplexBlockClass(editor, block);
13052
13062
  return blockClass.getChildContainers(editor, block, options);
13053
13063
  }
13054
13064
  function complexBlockGetSelectedContainers(editor, block, start, end) {
13055
13065
  if (start.isSimple()) {
13056
- assert(logger$4p, end.isSimple(), "invalid start and end position");
13066
+ assert(logger$4q, end.isSimple(), "invalid start and end position");
13057
13067
  return complexBlockGetAllChildContainers(editor, block);
13058
13068
  }
13059
- assert(logger$4p, !start.isSimple(), "invalid start pos");
13060
- assert(logger$4p, !end.isSimple(), "invalid end pos");
13069
+ assert(logger$4q, !start.isSimple(), "invalid start pos");
13070
+ assert(logger$4q, !end.isSimple(), "invalid end pos");
13061
13071
  const blockClass = getComplexBlockClass(editor, block);
13062
13072
  return blockClass.getSelectedContainers(editor, block, start, end);
13063
13073
  }
@@ -13068,11 +13078,11 @@ var __publicField = (obj, key, value) => {
13068
13078
  const parentComplexBlock = getParentBlock(getParentContainer(childBlock));
13069
13079
  if (!parentComplexBlock)
13070
13080
  return false;
13071
- assert(logger$4p, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13081
+ assert(logger$4q, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13072
13082
  const childContainer = getParentContainer(childBlock);
13073
13083
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
13074
13084
  const index2 = childContainers.indexOf(childContainer);
13075
- assert(logger$4p, index2 >= 0, "not valid child container");
13085
+ assert(logger$4q, index2 >= 0, "not valid child container");
13076
13086
  return index2 === 0;
13077
13087
  }
13078
13088
  function complexBlockGetFirstSimpleChild(editor, complexBlock, options) {
@@ -13125,13 +13135,13 @@ var __publicField = (obj, key, value) => {
13125
13135
  return block;
13126
13136
  }
13127
13137
  function findPrevSimpleBlockBeforeChildContainer(editor, childContainer, options) {
13128
- assert(logger$4p, isChildContainer(childContainer), "not a child container");
13138
+ assert(logger$4q, isChildContainer(childContainer), "not a child container");
13129
13139
  const parentComplexBlock = getParentBlock(childContainer);
13130
- assert(logger$4p, parentComplexBlock, "no parent block");
13131
- assert(logger$4p, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13140
+ assert(logger$4q, parentComplexBlock, "no parent block");
13141
+ assert(logger$4q, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13132
13142
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock, options);
13133
13143
  const containerIndex = childContainers.indexOf(childContainer);
13134
- assert(logger$4p, containerIndex !== -1, "child container not found");
13144
+ assert(logger$4q, containerIndex !== -1, "child container not found");
13135
13145
  if (containerIndex === 0) {
13136
13146
  const prevBlock = getPrevBlock(parentComplexBlock);
13137
13147
  if (!prevBlock)
@@ -13149,9 +13159,9 @@ var __publicField = (obj, key, value) => {
13149
13159
  return lastBlock2;
13150
13160
  }
13151
13161
  function complexBlockGetTopChildContainers(editor, complexBlock) {
13152
- assert(logger$4p, isComplexKindBlock(editor, complexBlock), "not a complex block");
13162
+ assert(logger$4q, isComplexKindBlock(editor, complexBlock), "not a complex block");
13153
13163
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
13154
- assert(logger$4p, childContainers.length > 0, "no child container");
13164
+ assert(logger$4q, childContainers.length > 0, "no child container");
13155
13165
  if (childContainers.length === 1) {
13156
13166
  return childContainers;
13157
13167
  }
@@ -13176,9 +13186,9 @@ var __publicField = (obj, key, value) => {
13176
13186
  return ret;
13177
13187
  }
13178
13188
  function complexBlockGetBottomChildContainers(editor, complexBlock) {
13179
- assert(logger$4p, isComplexKindBlock(editor, complexBlock), "not a complex block");
13189
+ assert(logger$4q, isComplexKindBlock(editor, complexBlock), "not a complex block");
13180
13190
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
13181
- assert(logger$4p, childContainers.length > 0, "no child container");
13191
+ assert(logger$4q, childContainers.length > 0, "no child container");
13182
13192
  if (childContainers.length === 1) {
13183
13193
  return childContainers;
13184
13194
  }
@@ -13283,11 +13293,11 @@ var __publicField = (obj, key, value) => {
13283
13293
  return result;
13284
13294
  }
13285
13295
  const anchor = "";
13286
- const logger$4o = getLogger("text-range");
13296
+ const logger$4p = getLogger("text-range");
13287
13297
  function getBlockRangeInfo(block, blockOffset) {
13288
13298
  const getChildRange = (child, offset) => {
13289
13299
  if (isTextBlockContentInsertionChild(child)) {
13290
- assert(logger$4o, offset === 0, `invalid offset for insertion child: ${offset}`);
13300
+ assert(logger$4p, offset === 0, `invalid offset for insertion child: ${offset}`);
13291
13301
  const childOffset = 2;
13292
13302
  return {
13293
13303
  child,
@@ -13296,7 +13306,7 @@ var __publicField = (obj, key, value) => {
13296
13306
  };
13297
13307
  }
13298
13308
  if (isTextBlockContentBoxChild(child)) {
13299
- assert(logger$4o, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
13309
+ assert(logger$4p, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
13300
13310
  const childOffset = offset === 0 ? 1 : 2;
13301
13311
  return {
13302
13312
  child,
@@ -13305,17 +13315,17 @@ var __publicField = (obj, key, value) => {
13305
13315
  };
13306
13316
  }
13307
13317
  const textNode = child.firstChild;
13308
- assert(logger$4o, textNode, "no child node for text child");
13309
- assert(logger$4o, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
13318
+ assert(logger$4p, textNode, "no child node for text child");
13319
+ assert(logger$4p, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
13310
13320
  if (textNode instanceof HTMLBRElement) {
13311
- assert(logger$4o, offset >= 0 && offset <= 0, "invalid offset for text child");
13321
+ assert(logger$4p, offset >= 0 && offset <= 0, "invalid offset for text child");
13312
13322
  return {
13313
13323
  child,
13314
13324
  container: textNode,
13315
13325
  offset
13316
13326
  };
13317
13327
  }
13318
- assert(logger$4o, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
13328
+ assert(logger$4p, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
13319
13329
  return {
13320
13330
  child,
13321
13331
  container: textNode,
@@ -13344,38 +13354,38 @@ var __publicField = (obj, key, value) => {
13344
13354
  }
13345
13355
  start += childLength;
13346
13356
  }
13347
- assert(logger$4o, false, "failed to get range info");
13357
+ assert(logger$4p, false, "failed to get range info");
13348
13358
  }
13349
13359
  function createChildRange(child, start, end) {
13350
13360
  if (start === end) {
13351
- assert(logger$4o, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
13361
+ assert(logger$4p, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
13352
13362
  } else {
13353
- assert(logger$4o, start < end, `invalid start & end: ${start}, ${end}`);
13363
+ assert(logger$4p, start < end, `invalid start & end: ${start}, ${end}`);
13354
13364
  }
13355
13365
  if (isTextBlockContentInsertionChild(child)) {
13356
- assert(logger$4o, start === end, `invalid insertion child range offset: ${start}, ${end}`);
13357
- assert(logger$4o, start === 0, `invalid insertion child range start: ${start}`);
13366
+ assert(logger$4p, start === end, `invalid insertion child range offset: ${start}, ${end}`);
13367
+ assert(logger$4p, start === 0, `invalid insertion child range start: ${start}`);
13358
13368
  const insertionElem = child;
13359
- assert(logger$4o, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
13369
+ assert(logger$4p, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
13360
13370
  const range = createExpandedRange(insertionElem, 1, insertionElem, 2);
13361
13371
  return range;
13362
13372
  }
13363
13373
  if (isTextBlockContentBoxChild(child)) {
13364
- assert(logger$4o, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
13365
- assert(logger$4o, start === 0, `invalid box child range start: ${start}`);
13374
+ assert(logger$4p, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
13375
+ assert(logger$4p, start === 0, `invalid box child range start: ${start}`);
13366
13376
  const box = child;
13367
- assert(logger$4o, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
13377
+ assert(logger$4p, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
13368
13378
  const range = createExpandedRange(box, 1, box, 2);
13369
13379
  return range;
13370
13380
  }
13371
13381
  const length = getTextBlockContentChildTextLength(child);
13372
- assert(logger$4o, end <= length, `invalid child end: ${end}, ${length}`);
13382
+ assert(logger$4p, end <= length, `invalid child end: ${end}, ${length}`);
13373
13383
  const textNode = child.firstChild;
13374
- assert(logger$4o, textNode instanceof Text, "invalid block text child");
13375
- assert(logger$4o, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
13384
+ assert(logger$4p, textNode instanceof Text, "invalid block text child");
13385
+ assert(logger$4p, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
13376
13386
  return createExpandedRange(textNode, start, textNode, end);
13377
13387
  }
13378
- const logger$4n = getLogger("caret-rect");
13388
+ const logger$4o = getLogger("caret-rect");
13379
13389
  function getChildClientRects(block, child) {
13380
13390
  if (isBox(child)) {
13381
13391
  const box = child;
@@ -13384,7 +13394,7 @@ var __publicField = (obj, key, value) => {
13384
13394
  const blockContent = getBlockContent(block);
13385
13395
  const lineHeight = Number.parseFloat(window.getComputedStyle(blockContent).lineHeight) || boxContent.getBoundingClientRect().height;
13386
13396
  const rects = Array.from(boxContent.getClientRects());
13387
- assert(logger$4n, rects.length > 0, "no box client rects");
13397
+ assert(logger$4o, rects.length > 0, "no box client rects");
13388
13398
  const blockRect = blockContent.getBoundingClientRect();
13389
13399
  const firstRect = rects[0];
13390
13400
  const lastRect = new DOMRect(blockRect.left, firstRect.bottom, 1, lineHeight);
@@ -13404,22 +13414,22 @@ var __publicField = (obj, key, value) => {
13404
13414
  const rect2 = getLastClientRect(ranges[0].child);
13405
13415
  return new DOMRect(rect2.right, rect2.top, 1, rect2.height);
13406
13416
  }
13407
- assert(logger$4n, ranges[1], "invalid ranges");
13417
+ assert(logger$4o, ranges[1], "invalid ranges");
13408
13418
  const rect = getFirstClientRect(ranges[1].child);
13409
13419
  return new DOMRect(rect.left, rect.top, 1, rect.height);
13410
13420
  }
13411
13421
  let rangeInfo = ranges[0];
13412
- assert(logger$4n, ranges.length >= 1, "failed to get block range");
13422
+ assert(logger$4o, ranges.length >= 1, "failed to get block range");
13413
13423
  if (ranges.length === 1) {
13414
13424
  rangeInfo = ranges[0];
13415
13425
  } else {
13416
- assert(logger$4n, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
13426
+ assert(logger$4o, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
13417
13427
  if (isTextBlockContentInsertionChild(ranges[ranges.length - 1].child)) {
13418
13428
  rangeInfo = ranges[ranges.length - 1];
13419
13429
  const child = rangeInfo.child;
13420
13430
  const content = getInsertionContent(child);
13421
13431
  const rects2 = content.getClientRects();
13422
- assert(logger$4n, rects2.length >= 1, "no client rects for box content");
13432
+ assert(logger$4o, rects2.length >= 1, "no client rects for box content");
13423
13433
  const rect = rects2[rects2.length - 1];
13424
13434
  return new DOMRect(rect.right, rect.y, 1, rect.height);
13425
13435
  }
@@ -13436,9 +13446,9 @@ var __publicField = (obj, key, value) => {
13436
13446
  }
13437
13447
  }
13438
13448
  if (rangeInfo.container instanceof HTMLBRElement) {
13439
- assert(logger$4n, pos.offset === 0, "invalid offset for empty block text");
13449
+ assert(logger$4o, pos.offset === 0, "invalid offset for empty block text");
13440
13450
  const parent = rangeInfo.container.parentElement;
13441
- assert(logger$4n, parent, "invalid br parent");
13451
+ assert(logger$4o, parent, "invalid br parent");
13442
13452
  const rect = parent.getBoundingClientRect();
13443
13453
  const ret = new DOMRect(rect.left, rect.top, 1, rect.height);
13444
13454
  return ret;
@@ -13446,11 +13456,11 @@ var __publicField = (obj, key, value) => {
13446
13456
  const range = createRange(rangeInfo.container, rangeInfo.offset);
13447
13457
  const rects = Array.from(range.getClientRects());
13448
13458
  if (rects.length === 0) {
13449
- assert(logger$4n, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
13450
- assert(logger$4n, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
13459
+ assert(logger$4o, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
13460
+ assert(logger$4o, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
13451
13461
  const child = rangeInfo.child;
13452
13462
  const rects2 = getChildClientRects(block, child);
13453
- assert(logger$4n, rects2.length >= 1, "no client rects for box content");
13463
+ assert(logger$4o, rects2.length >= 1, "no client rects for box content");
13454
13464
  if (rangeInfo.offset === 1) {
13455
13465
  const rect2 = rects2[0];
13456
13466
  return new DOMRect(rect2.x, rect2.y, 1, rect2.height);
@@ -13496,7 +13506,7 @@ var __publicField = (obj, key, value) => {
13496
13506
  });
13497
13507
  }
13498
13508
  }
13499
- assert(logger$4n, rects.length > 0, "no client rects for range");
13509
+ assert(logger$4o, rects.length > 0, "no client rects for range");
13500
13510
  if (pos.type === "home") {
13501
13511
  return rects[rects.length - 1];
13502
13512
  }
@@ -13576,13 +13586,13 @@ var __publicField = (obj, key, value) => {
13576
13586
  };
13577
13587
  }
13578
13588
  }
13579
- const logger$4m = getLogger("selection-range");
13589
+ const logger$4n = getLogger("selection-range");
13580
13590
  function createEditorSelectionRange(editor, options) {
13581
13591
  const { anchor: anchor2, focus } = options;
13582
13592
  if (anchor2 instanceof EditorSimpleBlockPosition && focus instanceof EditorSimpleBlockPosition) {
13583
13593
  return new EditorSimpleSelectionRange(editor, { anchor: anchor2, focus });
13584
13594
  }
13585
- assert(logger$4m, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
13595
+ assert(logger$4n, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
13586
13596
  return new EditorComplexSelectionRange(editor, { anchor: anchor2, focus });
13587
13597
  }
13588
13598
  function createBlockSimpleRange(editor, block, anchor2, focus) {
@@ -13604,7 +13614,7 @@ var __publicField = (obj, key, value) => {
13604
13614
  const focus = createSimpleBlockPosition(range.focus.blockId, range.focus.offset, "normal");
13605
13615
  return createEditorSelectionRange(editor, { anchor: anchor2, focus });
13606
13616
  }
13607
- const logger$4l = getLogger("range-from-point");
13617
+ const logger$4m = getLogger("range-from-point");
13608
13618
  function getBlockRangeFromPoint(editor, pointX, pointY, dragging) {
13609
13619
  const yOffsets = [0, -12, 12];
13610
13620
  let x = pointX;
@@ -13636,7 +13646,7 @@ var __publicField = (obj, key, value) => {
13636
13646
  const rect = elem.getBoundingClientRect();
13637
13647
  if (rect.width && rect.top && i === 0) {
13638
13648
  if (rect.left + rect.width < x || rect.top + rect.height < y) {
13639
- logger$4l.debug("click on scrollbar, out of element rect");
13649
+ logger$4m.debug("click on scrollbar, out of element rect");
13640
13650
  return null;
13641
13651
  }
13642
13652
  }
@@ -13674,7 +13684,7 @@ var __publicField = (obj, key, value) => {
13674
13684
  let block = getLastChildBlock(container);
13675
13685
  if (!isVisibleBlock(block)) {
13676
13686
  const preBlock = getPrevVisibleBlock(block);
13677
- assert(logger$4l, preBlock, "container must have visible block");
13687
+ assert(logger$4m, preBlock, "container must have visible block");
13678
13688
  block = preBlock;
13679
13689
  }
13680
13690
  const range = getBlockClass(editor, block).getRangeFromPoint(editor, block, x, block.getBoundingClientRect().bottom - 4);
@@ -13693,7 +13703,7 @@ var __publicField = (obj, key, value) => {
13693
13703
  if (range instanceof EditorSimpleSelectionRange) {
13694
13704
  return range;
13695
13705
  }
13696
- assert(logger$4l, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
13706
+ assert(logger$4m, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
13697
13707
  const complexRange = range;
13698
13708
  const container2 = editor.getContainerById(complexRange.start.childContainerId);
13699
13709
  return getRangeInContainer(editor, container2, x, y);
@@ -13716,7 +13726,7 @@ var __publicField = (obj, key, value) => {
13716
13726
  });
13717
13727
  return getRangeInContainer(editor, container, x, y);
13718
13728
  }
13719
- const logger$4k = getLogger("adjust-selection-pos");
13729
+ const logger$4l = getLogger("adjust-selection-pos");
13720
13730
  function getParentContainers(block) {
13721
13731
  const containers = [];
13722
13732
  while (block) {
@@ -13726,10 +13736,10 @@ var __publicField = (obj, key, value) => {
13726
13736
  return containers;
13727
13737
  }
13728
13738
  const newBlock = getParentBlock(container);
13729
- assert(logger$4k, newBlock, "child container has not parent container");
13739
+ assert(logger$4l, newBlock, "child container has not parent container");
13730
13740
  block = newBlock;
13731
13741
  }
13732
- assert(logger$4k, false, "should not come here: getParentContainers");
13742
+ assert(logger$4l, false, "should not come here: getParentContainers");
13733
13743
  }
13734
13744
  function getParentBlockInContainer(container, block) {
13735
13745
  while (block) {
@@ -13738,16 +13748,16 @@ var __publicField = (obj, key, value) => {
13738
13748
  return block;
13739
13749
  }
13740
13750
  const newBlock = getParentBlock(parent);
13741
- assert(logger$4k, newBlock, "could not find parent block for a child container");
13751
+ assert(logger$4l, newBlock, "could not find parent block for a child container");
13742
13752
  block = newBlock;
13743
13753
  }
13744
- assert(logger$4k, false, "no parent block in specified container");
13754
+ assert(logger$4l, false, "no parent block in specified container");
13745
13755
  }
13746
13756
  function getClosestParentBlock(block1, block2) {
13747
13757
  const containers1 = getParentContainers(block1);
13748
13758
  const containers2 = getParentContainers(block2);
13749
- assert(logger$4k, containers1.length > 0 && containers2.length > 0, "block has not parent container");
13750
- assert(logger$4k, containers1[0] === containers2[0], "root container does not equal");
13759
+ assert(logger$4l, containers1.length > 0 && containers2.length > 0, "block has not parent container");
13760
+ assert(logger$4l, containers1[0] === containers2[0], "root container does not equal");
13751
13761
  let parentContainer = containers1[0];
13752
13762
  for (let i = 1; i < containers1.length || containers2.length; i++) {
13753
13763
  if (containers1[i] === containers2[i]) {
@@ -13766,23 +13776,23 @@ var __publicField = (obj, key, value) => {
13766
13776
  }
13767
13777
  function getParentContainerInComplexBlock(parentComplexBlock, element) {
13768
13778
  let block = getParentBlock(element);
13769
- assert(logger$4k, block, "element is not in a block");
13779
+ assert(logger$4l, block, "element is not in a block");
13770
13780
  while (block) {
13771
13781
  const container = getParentContainer(block);
13772
- assert(logger$4k, isChildContainer(container), "not a child container");
13782
+ assert(logger$4l, isChildContainer(container), "not a child container");
13773
13783
  const parentBlock = getParentBlock(container);
13774
- assert(logger$4k, parentBlock, "child container has not parent block");
13784
+ assert(logger$4l, parentBlock, "child container has not parent block");
13775
13785
  if (parentBlock === parentComplexBlock) {
13776
13786
  return container;
13777
13787
  }
13778
13788
  block = parentBlock;
13779
13789
  }
13780
- assert(logger$4k, false, "failed to find parent container in complex block");
13790
+ assert(logger$4l, false, "failed to find parent container in complex block");
13781
13791
  }
13782
13792
  function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
13783
13793
  const blockId = getBlockId(complexBlock);
13784
- assert(logger$4k, blockId === anchor2.blockId, "invalid start pos");
13785
- assert(logger$4k, blockId === focus.blockId, "invalid end pos");
13794
+ assert(logger$4l, blockId === anchor2.blockId, "invalid start pos");
13795
+ assert(logger$4l, blockId === focus.blockId, "invalid end pos");
13786
13796
  const blockClass = getComplexBlockClass(editor, complexBlock);
13787
13797
  if (blockClass.adjustSelectionPos) {
13788
13798
  return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
@@ -13816,8 +13826,8 @@ var __publicField = (obj, key, value) => {
13816
13826
  if (focus instanceof EditorComplexBlockPosition) {
13817
13827
  focus = createSimpleBlockPosition(focusBlock, getBlockTextLength$6(editor, focusBlock), "end");
13818
13828
  }
13819
- assert(logger$4k, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
13820
- assert(logger$4k, focus instanceof EditorSimpleBlockPosition, "not valid position type");
13829
+ assert(logger$4l, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
13830
+ assert(logger$4l, focus instanceof EditorSimpleBlockPosition, "not valid position type");
13821
13831
  return {
13822
13832
  anchor: anchor2,
13823
13833
  focus
@@ -13871,7 +13881,7 @@ var __publicField = (obj, key, value) => {
13871
13881
  focus
13872
13882
  };
13873
13883
  }
13874
- const logger$4j = getLogger("core");
13884
+ const logger$4k = getLogger("core");
13875
13885
  function createBlockAnchor(editor, block, id, refClientRect) {
13876
13886
  const tools = getBlockTools(block);
13877
13887
  let elem = tools.querySelector(`.block-anchor[data-id=${id}]`);
@@ -13889,7 +13899,7 @@ var __publicField = (obj, key, value) => {
13889
13899
  return elem;
13890
13900
  }
13891
13901
  function createBlockCaretAnchor(editor, block, offset, id) {
13892
- assert(logger$4j, isTextKindBlock(editor, block), "not a text kind block");
13902
+ assert(logger$4k, isTextKindBlock(editor, block), "not a text kind block");
13893
13903
  const caretRect = getTextCaretRect(block, createSimpleBlockPosition(block, offset, "normal"));
13894
13904
  const blockRect = block.getBoundingClientRect();
13895
13905
  const tools = getBlockTools(block);
@@ -14248,19 +14258,19 @@ var __publicField = (obj, key, value) => {
14248
14258
  return result + (index2 ? "-" : "") + word.toLowerCase();
14249
14259
  });
14250
14260
  const kebabCase$1 = kebabCase;
14251
- const logger$4i = getLogger("box");
14261
+ const logger$4j = getLogger("box");
14252
14262
  function isBoxOp(op) {
14253
14263
  if (!op.attributes)
14254
14264
  return false;
14255
14265
  if (!op.attributes.box)
14256
14266
  return false;
14257
- assert(logger$4i, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
14258
- assert(logger$4i, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
14267
+ assert(logger$4j, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
14268
+ assert(logger$4j, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
14259
14269
  return true;
14260
14270
  }
14261
- const logger$4h = getLogger("text-op");
14271
+ const logger$4i = getLogger("text-op");
14262
14272
  function getOpLength(op) {
14263
- assert(logger$4h, typeof op.insert === "string", "invalid op, no insert");
14273
+ assert(logger$4i, typeof op.insert === "string", "invalid op, no insert");
14264
14274
  return op.insert.length;
14265
14275
  }
14266
14276
  function getOpAt(text2, offset) {
@@ -14268,7 +14278,7 @@ var __publicField = (obj, key, value) => {
14268
14278
  let pos = 0;
14269
14279
  for (let i = 0; i < ops.length; i++) {
14270
14280
  const op = ops[i];
14271
- assert(logger$4h, typeof op.insert === "string", "invalid text op, no insert");
14281
+ assert(logger$4i, typeof op.insert === "string", "invalid text op, no insert");
14272
14282
  const end = pos + getOpLength(op);
14273
14283
  if (end > offset) {
14274
14284
  return [op];
@@ -14284,22 +14294,22 @@ var __publicField = (obj, key, value) => {
14284
14294
  }
14285
14295
  return [];
14286
14296
  }
14287
- const logger$4g = getLogger("rich-text-length");
14297
+ const logger$4h = getLogger("rich-text-length");
14288
14298
  function getTextOpLength(op) {
14289
- assert(logger$4g, typeof op.insert === "string", "op.insert is not string");
14299
+ assert(logger$4h, typeof op.insert === "string", "op.insert is not string");
14290
14300
  return op.insert.length;
14291
14301
  }
14292
14302
  function getTextLength(ops) {
14293
14303
  let count = 0;
14294
14304
  ops.forEach((op) => {
14295
14305
  if (op.insert) {
14296
- assert(logger$4g, typeof op.insert === "string", "op.insert is not string");
14306
+ assert(logger$4h, typeof op.insert === "string", "op.insert is not string");
14297
14307
  count += getTextOpLength(op);
14298
14308
  }
14299
14309
  });
14300
14310
  return count;
14301
14311
  }
14302
- const logger$4f = getLogger("split-text");
14312
+ const logger$4g = getLogger("split-text");
14303
14313
  function splitText(ops, offset, splitResult) {
14304
14314
  ops = cloneDeep__default.default(ops);
14305
14315
  if (offset === 0) {
@@ -14317,8 +14327,8 @@ var __publicField = (obj, key, value) => {
14317
14327
  let counted = 0;
14318
14328
  for (let i = 0; i < ops.length; i++) {
14319
14329
  const op = ops[i];
14320
- assert(logger$4f, typeof op === "object", `invalid op type, ${typeof op}`);
14321
- assert(logger$4f, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
14330
+ assert(logger$4g, typeof op === "object", `invalid op type, ${typeof op}`);
14331
+ assert(logger$4g, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
14322
14332
  const subLen = getTextOpLength(op);
14323
14333
  if (counted + subLen < offset) {
14324
14334
  counted += subLen;
@@ -14328,18 +14338,18 @@ var __publicField = (obj, key, value) => {
14328
14338
  right: ops.slice(i + 1)
14329
14339
  };
14330
14340
  } else {
14331
- assert(logger$4f, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
14341
+ assert(logger$4g, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
14332
14342
  const splitIndex = offset - counted;
14333
14343
  const copied = cloneDeep__default.default(op);
14334
- assert(logger$4f, copied.insert, "no copied.insert");
14335
- assert(logger$4f, typeof copied.insert === "string", "invalid copied.insert type");
14344
+ assert(logger$4g, copied.insert, "no copied.insert");
14345
+ assert(logger$4g, typeof copied.insert === "string", "invalid copied.insert type");
14336
14346
  copied.insert = copied.insert.substr(0, splitIndex);
14337
14347
  op.insert = op.insert.substr(splitIndex);
14338
14348
  if (copied.insert === "") {
14339
- assert(logger$4f, false, "invalid copied.insert, is empty string");
14349
+ assert(logger$4g, false, "invalid copied.insert, is empty string");
14340
14350
  }
14341
14351
  if (op.insert === "") {
14342
- assert(logger$4f, false, "invalid op.insert, is empty string");
14352
+ assert(logger$4g, false, "invalid op.insert, is empty string");
14343
14353
  }
14344
14354
  const right = [
14345
14355
  op,
@@ -14358,9 +14368,9 @@ var __publicField = (obj, key, value) => {
14358
14368
  throw new Error(`invalid split offset: ${offset}, ${JSON.stringify(ops)}`);
14359
14369
  }
14360
14370
  function splitToThree(text2, offset, length) {
14361
- assert(logger$4f, offset >= 0, "invalid offset, < 0");
14362
- assert(logger$4f, length > 0, "invalid length, <= 0");
14363
- assert(logger$4f, offset + length <= getTextLength(text2), "invalid offset + length < text length");
14371
+ assert(logger$4g, offset >= 0, "invalid offset, < 0");
14372
+ assert(logger$4g, length > 0, "invalid length, <= 0");
14373
+ assert(logger$4g, offset + length <= getTextLength(text2), "invalid offset + length < text length");
14364
14374
  const { left: temp, right } = splitText(text2, offset + length);
14365
14375
  const { left, right: middle } = splitText(temp, offset);
14366
14376
  return { left, middle, right };
@@ -14583,9 +14593,9 @@ var __publicField = (obj, key, value) => {
14583
14593
  }
14584
14594
  return [color, backgroundColor];
14585
14595
  }
14586
- const logger$4e = getLogger("text-block-content");
14596
+ const logger$4f = getLogger("text-block-content");
14587
14597
  function updateBlockContentCore(editor, blockPath, content, blockText, insertions) {
14588
- assert(logger$4e, blockText, "no text for block");
14598
+ assert(logger$4f, blockText, "no text for block");
14589
14599
  if (blockText.length === 0 && (!insertions || insertions.size === 0)) {
14590
14600
  content.innerHTML = "<span><br></span>";
14591
14601
  return;
@@ -14617,9 +14627,9 @@ var __publicField = (obj, key, value) => {
14617
14627
  for (let i2 = 0; i2 < text2.length; i2++) {
14618
14628
  const op = text2[i2];
14619
14629
  if (isBoxOp(op)) {
14620
- assert(logger$4e, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
14630
+ assert(logger$4f, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
14621
14631
  const span2 = editor.editorBoxes.createBox(content, op.attributes);
14622
- assert(logger$4e, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
14632
+ assert(logger$4f, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
14623
14633
  const ret = editor.editorBlockRenders.renderBox(blockPath, op.attributes);
14624
14634
  if (ret.classes) {
14625
14635
  addClass(span2, ...ret.classes);
@@ -14637,7 +14647,7 @@ var __publicField = (obj, key, value) => {
14637
14647
  fragment.appendChild(span2);
14638
14648
  continue;
14639
14649
  }
14640
- assert(logger$4e, op.insert, `no insert in op: ${JSON.stringify(op)}`);
14650
+ assert(logger$4f, op.insert, `no insert in op: ${JSON.stringify(op)}`);
14641
14651
  const span = createElement("span", ["text"], fragment, op.insert);
14642
14652
  if (op.attributes) {
14643
14653
  const ret = editor.editorBlockRenders.renderText(blockPath, op.attributes);
@@ -14668,7 +14678,7 @@ var __publicField = (obj, key, value) => {
14668
14678
  const compositionText = editor.compositingText;
14669
14679
  if (compositionText) {
14670
14680
  const pos = editor.selection.range.start;
14671
- assert(logger$4e, pos.isSimple(), "not an simple position while compositing");
14681
+ assert(logger$4f, pos.isSimple(), "not an simple position while compositing");
14672
14682
  if (pos.blockId === blockId) {
14673
14683
  const attributes = getAttributesAt(text2, 0);
14674
14684
  insertions.set(pos.offset, [{
@@ -14684,11 +14694,11 @@ var __publicField = (obj, key, value) => {
14684
14694
  function clearAllTempCompositionText(editor) {
14685
14695
  const children = editor.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');
14686
14696
  if (children.length) {
14687
- logger$4e.debug(`remove ${children.length} temp composition span`);
14697
+ logger$4f.debug(`remove ${children.length} temp composition span`);
14688
14698
  }
14689
14699
  Array.from(children).forEach((c) => c.remove());
14690
14700
  }
14691
- const logger$4d = getLogger("client-rects");
14701
+ const logger$4e = getLogger("client-rects");
14692
14702
  function getChildrenOffsets(block) {
14693
14703
  const children = getTextBlockContentChildren(block);
14694
14704
  let start = 0;
@@ -14706,15 +14716,15 @@ var __publicField = (obj, key, value) => {
14706
14716
  return ret;
14707
14717
  }
14708
14718
  function getChildrenInRange(editor, block, from, to) {
14709
- assert(logger$4d, from < to, `invalid from & to: ${from}, ${to}`);
14719
+ assert(logger$4e, from < to, `invalid from & to: ${from}, ${to}`);
14710
14720
  const blockLength = getBlockTextLength$6(editor, block);
14711
- assert(logger$4d, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
14721
+ assert(logger$4e, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
14712
14722
  const offsets = getChildrenOffsets(block);
14713
14723
  const startIndex = offsets.findIndex((c) => c.startBlockOffset <= from && from < c.endBlockOffset);
14714
14724
  const endIndex = offsets.findIndex((c) => c.startBlockOffset < to && to <= c.endBlockOffset);
14715
- assert(logger$4d, startIndex !== -1, "failed to find start child");
14716
- assert(logger$4d, endIndex !== -1, "failed to find end child");
14717
- assert(logger$4d, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
14725
+ assert(logger$4e, startIndex !== -1, "failed to find start child");
14726
+ assert(logger$4e, endIndex !== -1, "failed to find end child");
14727
+ assert(logger$4e, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
14718
14728
  if (startIndex === endIndex) {
14719
14729
  const child = offsets[startIndex];
14720
14730
  return [{
@@ -14796,16 +14806,16 @@ var __publicField = (obj, key, value) => {
14796
14806
  return rects;
14797
14807
  }
14798
14808
  function getRangeClientRects(editor, block, range) {
14799
- assert(logger$4d, range instanceof EditorSimpleSelectionRange, "invalid range");
14809
+ assert(logger$4e, range instanceof EditorSimpleSelectionRange, "invalid range");
14800
14810
  const start = range.start;
14801
14811
  const end = range.end;
14802
- assert(logger$4d, start.isSimple(), "text block only allow simple position");
14803
- assert(logger$4d, end.isSimple(), "text block only allow simple position");
14804
- assert(logger$4d, start.blockId === end.blockId, "only allow update one text block selection");
14805
- assert(logger$4d, start.blockId === getBlockId(block), "only allow update one text block selection");
14812
+ assert(logger$4e, start.isSimple(), "text block only allow simple position");
14813
+ assert(logger$4e, end.isSimple(), "text block only allow simple position");
14814
+ assert(logger$4e, start.blockId === end.blockId, "only allow update one text block selection");
14815
+ assert(logger$4e, start.blockId === getBlockId(block), "only allow update one text block selection");
14806
14816
  return getClientRects$2(editor, block, start, end);
14807
14817
  }
14808
- const logger$4c = getLogger("selection-background");
14818
+ const logger$4d = getLogger("selection-background");
14809
14819
  function getLineHeight(elem) {
14810
14820
  const style2 = window.getComputedStyle(elem);
14811
14821
  const lineHeightStyle = style2.getPropertyValue("line-height");
@@ -14825,9 +14835,9 @@ var __publicField = (obj, key, value) => {
14825
14835
  return lineHeight;
14826
14836
  }
14827
14837
  function updateSelection$4(editor, block, start, end) {
14828
- assert(logger$4c, start.isSimple(), "text block only allow simple position");
14829
- assert(logger$4c, end.isSimple(), "text block only allow simple position");
14830
- assert(logger$4c, start.blockId === end.blockId, "only allow update one text block selection");
14838
+ assert(logger$4d, start.isSimple(), "text block only allow simple position");
14839
+ assert(logger$4d, end.isSimple(), "text block only allow simple position");
14840
+ assert(logger$4d, start.blockId === end.blockId, "only allow update one text block selection");
14831
14841
  const from = start.offset;
14832
14842
  const to = end.offset;
14833
14843
  if (from === to) {
@@ -14886,7 +14896,7 @@ var __publicField = (obj, key, value) => {
14886
14896
  }
14887
14897
  });
14888
14898
  }
14889
- const logger$4b = getLogger("line-breaker");
14899
+ const logger$4c = getLogger("line-breaker");
14890
14900
  function mergeTextRects(rects) {
14891
14901
  const result = [];
14892
14902
  let lastRect = null;
@@ -15013,7 +15023,7 @@ var __publicField = (obj, key, value) => {
15013
15023
  }
15014
15024
  const textChild = child;
15015
15025
  const rects = mergeTextRects(textChild.getClientRects());
15016
- assert(logger$4b, rects.length > 0, "invalid text child dom");
15026
+ assert(logger$4c, rects.length > 0, "invalid text child dom");
15017
15027
  if (rects.length === 1) {
15018
15028
  const nextChild = children[i + 1];
15019
15029
  if (!nextChild) {
@@ -15038,10 +15048,10 @@ var __publicField = (obj, key, value) => {
15038
15048
  continue;
15039
15049
  }
15040
15050
  const textNode = textChild.firstChild;
15041
- assert(logger$4b, textNode, "invalid text child, no text node");
15042
- assert(logger$4b, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
15051
+ assert(logger$4c, textNode, "invalid text child, no text node");
15052
+ assert(logger$4c, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
15043
15053
  const textChildLength = getTextBlockContentChildTextLength(textChild);
15044
- assert(logger$4b, textNode.data.length === textChildLength, "text node data length not equal child text length");
15054
+ assert(logger$4c, textNode.data.length === textChildLength, "text node data length not equal child text length");
15045
15055
  const textRects = getTextRects(textNode);
15046
15056
  for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
15047
15057
  const rect = textRects[rIndex];
@@ -15083,7 +15093,7 @@ var __publicField = (obj, key, value) => {
15083
15093
  }
15084
15094
  }
15085
15095
  }
15086
- assert(logger$4b, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
15096
+ assert(logger$4c, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
15087
15097
  return {
15088
15098
  lineIndex: lineBreaks.length,
15089
15099
  lineBreaks
@@ -23856,7 +23866,7 @@ var __publicField = (obj, key, value) => {
23856
23866
  const Graphemer_1 = __importDefault(Graphemer$1);
23857
23867
  var _default = lib$1.default = Graphemer_1.default;
23858
23868
  const splitter = new _default();
23859
- const logger$4a = getLogger("text-offset");
23869
+ const logger$4b = getLogger("text-offset");
23860
23870
  function getChildOffset(block, child) {
23861
23871
  const children = getTextBlockContentChildren(block);
23862
23872
  let start = 0;
@@ -23872,26 +23882,26 @@ var __publicField = (obj, key, value) => {
23872
23882
  }
23873
23883
  start += testLength;
23874
23884
  }
23875
- assert(logger$4a, false, "can not find child in children");
23885
+ assert(logger$4b, false, "can not find child in children");
23876
23886
  }
23877
23887
  function isValidOffset(block, blockOffset) {
23878
- assert(logger$4a, blockOffset >= 0, `invalid offset: ${blockOffset}`);
23888
+ assert(logger$4b, blockOffset >= 0, `invalid offset: ${blockOffset}`);
23879
23889
  const childInfo = getTextBlockChild(block, blockOffset);
23880
23890
  const { prev, next: next2, offset } = childInfo;
23881
23891
  if (!prev && !next2) {
23882
- assert(logger$4a, false, "invalid offset, no prev & next child at offset");
23892
+ assert(logger$4b, false, "invalid offset, no prev & next child at offset");
23883
23893
  }
23884
23894
  if (prev !== next2) {
23885
23895
  return true;
23886
23896
  }
23887
23897
  const child = prev;
23888
- assert(logger$4a, child, "no child");
23898
+ assert(logger$4b, child, "no child");
23889
23899
  if (isTextBlockContentBoxChild(child)) {
23890
- assert(logger$4a, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
23900
+ assert(logger$4b, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
23891
23901
  return true;
23892
23902
  }
23893
23903
  const text2 = child.textContent;
23894
- assert(logger$4a, text2, "no content for text child");
23904
+ assert(logger$4b, text2, "no content for text child");
23895
23905
  const chars = splitter.splitGraphemes(text2);
23896
23906
  const validOffsets = /* @__PURE__ */ new Set();
23897
23907
  let start = 0;
@@ -23921,7 +23931,7 @@ var __publicField = (obj, key, value) => {
23921
23931
  }
23922
23932
  function getNextValidOffset(block, blockOffset) {
23923
23933
  const length = getTextBlockLength(block);
23924
- assert(logger$4a, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
23934
+ assert(logger$4b, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
23925
23935
  if (blockOffset === length) {
23926
23936
  return length;
23927
23937
  }
@@ -23935,7 +23945,7 @@ var __publicField = (obj, key, value) => {
23935
23945
  }
23936
23946
  return ret;
23937
23947
  }
23938
- const logger$49 = getLogger("line-offset");
23948
+ const logger$4a = getLogger("line-offset");
23939
23949
  function getLineOffsets(block) {
23940
23950
  const lineBreaks = getLineBreaks(block);
23941
23951
  const ret = [];
@@ -23956,7 +23966,7 @@ var __publicField = (obj, key, value) => {
23956
23966
  }
23957
23967
  function getLineOffset(block, lineIndex) {
23958
23968
  const lines = getLineOffsets(block);
23959
- assert(logger$49, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
23969
+ assert(logger$4a, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
23960
23970
  return lines[lineIndex];
23961
23971
  }
23962
23972
  function getLineOffsetByPos(block, pos) {
@@ -24013,7 +24023,7 @@ var __publicField = (obj, key, value) => {
24013
24023
  function getLineCount(block) {
24014
24024
  return getLineOffsets(block).length;
24015
24025
  }
24016
- const logger$48 = getLogger("find-text-position");
24026
+ const logger$49 = getLogger("find-text-position");
24017
24027
  function isWrappedLine(block, lineIndex) {
24018
24028
  const { start, end } = getLineOffset(block, lineIndex);
24019
24029
  const blockId = getBlockId(block);
@@ -24024,13 +24034,13 @@ var __publicField = (obj, key, value) => {
24024
24034
  return false;
24025
24035
  }
24026
24036
  const childInfo = getTextBlockChild(block, start);
24027
- assert(logger$48, childInfo.next, "no next child at offset");
24028
- assert(logger$48, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
24037
+ assert(logger$49, childInfo.next, "no next child at offset");
24038
+ assert(logger$49, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
24029
24039
  return true;
24030
24040
  }
24031
24041
  function getWrappedLineOffsets(block, lineIndex) {
24032
24042
  const blockId = getBlockId(block);
24033
- assert(logger$48, isWrappedLine(block, lineIndex), "line is not wrapped");
24043
+ assert(logger$49, isWrappedLine(block, lineIndex), "line is not wrapped");
24034
24044
  const { start, end } = getLineOffset(block, lineIndex);
24035
24045
  const homePos = createSimpleBlockPosition(blockId, start, "home");
24036
24046
  for (let offset = start + 1; offset <= end; offset += 1) {
@@ -24045,11 +24055,11 @@ var __publicField = (obj, key, value) => {
24045
24055
  return offset - 1;
24046
24056
  }
24047
24057
  }
24048
- assert(logger$48, false, "failed to find wrapped offset");
24058
+ assert(logger$49, false, "failed to find wrapped offset");
24049
24059
  return 0;
24050
24060
  }
24051
24061
  function findTextPositionInLine(editor, block, lineIndex, sourceBlock, pos, findDirection, suggestedX) {
24052
- assert(logger$48, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
24062
+ assert(logger$49, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
24053
24063
  const { start, end } = getLineOffset(block, lineIndex);
24054
24064
  let from = start;
24055
24065
  const blockId = getBlockId(block);
@@ -24091,11 +24101,11 @@ var __publicField = (obj, key, value) => {
24091
24101
  return retPos;
24092
24102
  }
24093
24103
  function findPrevTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
24094
- assert(logger$48, isTextKindBlock(editor, block), "not a text block");
24104
+ assert(logger$49, isTextKindBlock(editor, block), "not a text block");
24095
24105
  return findTextPositionInLine(editor, block, getLineCount(block) - 1, sourceBlock, pos, "up", suggestedX);
24096
24106
  }
24097
24107
  function findNextTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
24098
- assert(logger$48, isTextKindBlock(editor, block), "not a text block");
24108
+ assert(logger$49, isTextKindBlock(editor, block), "not a text block");
24099
24109
  return findTextPositionInLine(editor, block, 0, sourceBlock, pos, "down", suggestedX);
24100
24110
  }
24101
24111
  function moveDown(editor, block, position, suggestedX) {
@@ -24203,7 +24213,7 @@ var __publicField = (obj, key, value) => {
24203
24213
  }
24204
24214
  return pos;
24205
24215
  }
24206
- const logger$47 = getLogger("move-caret");
24216
+ const logger$48 = getLogger("move-caret");
24207
24217
  function moveTextCaret(editor, block, position, direction) {
24208
24218
  if (direction === "ArrowLeft") {
24209
24219
  const ret = moveLeft(block, position);
@@ -24233,9 +24243,9 @@ var __publicField = (obj, key, value) => {
24233
24243
  }
24234
24244
  return createSimpleBlockPosition(getBlockId(block), ret.offset, ret.type);
24235
24245
  }
24236
- assert(logger$47, false, `invalid navigation direction: ${direction}`);
24246
+ assert(logger$48, false, `invalid navigation direction: ${direction}`);
24237
24247
  }
24238
- const logger$46 = getLogger("text-range");
24248
+ const logger$47 = getLogger("text-range");
24239
24249
  function getBlockRects(block) {
24240
24250
  const ret = [];
24241
24251
  const children = getTextBlockContentChildren(block);
@@ -24293,9 +24303,9 @@ var __publicField = (obj, key, value) => {
24293
24303
  return null;
24294
24304
  }
24295
24305
  const children = getTextBlockContentChildren(block);
24296
- assert(logger$46, children.indexOf(child) !== -1, "failed to find child in children");
24306
+ assert(logger$47, children.indexOf(child) !== -1, "failed to find child in children");
24297
24307
  const offsetInfo = getChildOffset(block, child);
24298
- assert(logger$46, offsetInfo, "failed to get child offset");
24308
+ assert(logger$47, offsetInfo, "failed to get child offset");
24299
24309
  const { start } = offsetInfo;
24300
24310
  let offset;
24301
24311
  let length;
@@ -24311,7 +24321,7 @@ var __publicField = (obj, key, value) => {
24311
24321
  }
24312
24322
  length = 0;
24313
24323
  } else {
24314
- assert(logger$46, child.firstChild instanceof Text, "child is not text");
24324
+ assert(logger$47, child.firstChild instanceof Text, "child is not text");
24315
24325
  offset = start + textNodeOffsetFromPoint(child.firstChild, x, y);
24316
24326
  length = 0;
24317
24327
  }
@@ -24335,9 +24345,9 @@ var __publicField = (obj, key, value) => {
24335
24345
  }
24336
24346
  return new EditorSimpleSelectionRange(editor, { anchor: startPos, focus: endPos != null ? endPos : startPos });
24337
24347
  }
24338
- const logger$45 = getLogger("create-text-op");
24348
+ const logger$46 = getLogger("create-text-op");
24339
24349
  function createTextOp(text2, attributes) {
24340
- assert(logger$45, text2, "text is empty");
24350
+ assert(logger$46, text2, "text is empty");
24341
24351
  const ret = {
24342
24352
  insert: text2
24343
24353
  };
@@ -24360,7 +24370,7 @@ var __publicField = (obj, key, value) => {
24360
24370
  }
24361
24371
  return result;
24362
24372
  }
24363
- const logger$44 = getLogger("merge-ops");
24373
+ const logger$45 = getLogger("merge-ops");
24364
24374
  function mergeOps(text2) {
24365
24375
  if (text2.length <= 1) {
24366
24376
  return text2;
@@ -24382,10 +24392,10 @@ var __publicField = (obj, key, value) => {
24382
24392
  return false;
24383
24393
  }
24384
24394
  if (op1.attributes === void 0) {
24385
- assert(logger$44, op2.attributes === void 0, "op2.attributes is not undefined");
24395
+ assert(logger$45, op2.attributes === void 0, "op2.attributes is not undefined");
24386
24396
  return true;
24387
24397
  }
24388
- assert(logger$44, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
24398
+ assert(logger$45, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
24389
24399
  return isEqual__default.default(op1.attributes, op2.attributes);
24390
24400
  };
24391
24401
  const newOps = [];
@@ -24394,8 +24404,8 @@ var __publicField = (obj, key, value) => {
24394
24404
  for (let i = 1; i < text2.length; i += 1) {
24395
24405
  const op = text2[i];
24396
24406
  if (isSameTypeOp(before, op)) {
24397
- assert(logger$44, typeof before.insert === "string", "before.insert is not string");
24398
- assert(logger$44, typeof op.insert === "string", "op.insert is not string");
24407
+ assert(logger$45, typeof before.insert === "string", "before.insert is not string");
24408
+ assert(logger$45, typeof op.insert === "string", "op.insert is not string");
24399
24409
  before.insert += op.insert;
24400
24410
  } else {
24401
24411
  newOps.push(op);
@@ -24423,15 +24433,15 @@ var __publicField = (obj, key, value) => {
24423
24433
  }
24424
24434
  return text2.slice(0, i + 1);
24425
24435
  }
24426
- const logger$43 = getLogger("delete-text");
24436
+ const logger$44 = getLogger("delete-text");
24427
24437
  function deleteText(richText2, offset, count) {
24428
24438
  const { left, right } = splitToThree(richText2, offset, count);
24429
24439
  const result = [...left, ...right];
24430
24440
  return mergeOps(result);
24431
24441
  }
24432
24442
  function createDeleteOps(offset, count) {
24433
- assert(logger$43, offset >= 0, `invalid offset: ${offset}`);
24434
- assert(logger$43, count >= 1, `invalid delete count: ${count}`);
24443
+ assert(logger$44, offset >= 0, `invalid offset: ${offset}`);
24444
+ assert(logger$44, count >= 1, `invalid delete count: ${count}`);
24435
24445
  const ops = [];
24436
24446
  if (offset !== 0) {
24437
24447
  ops.push({
@@ -24443,7 +24453,7 @@ var __publicField = (obj, key, value) => {
24443
24453
  });
24444
24454
  return ops;
24445
24455
  }
24446
- const logger$42 = getLogger("delta");
24456
+ const logger$43 = getLogger("delta");
24447
24457
  function diffRichText(oldText, newText) {
24448
24458
  const delta1D = new Delta__default.default(oldText);
24449
24459
  const delta2D = new Delta__default.default(newText);
@@ -24453,7 +24463,7 @@ var __publicField = (obj, key, value) => {
24453
24463
  return new Delta__default.default(ops).transformPosition(cursor, !isLocalOp);
24454
24464
  }
24455
24465
  function isValidDocText(text2) {
24456
- assert(logger$42, text2, "ops is null or undefined");
24466
+ assert(logger$43, text2, "ops is null or undefined");
24457
24467
  for (let i = 0; i < text2.length; i++) {
24458
24468
  const op = text2[i];
24459
24469
  if (op.insert === null || op.insert === void 0) {
@@ -24473,7 +24483,7 @@ var __publicField = (obj, key, value) => {
24473
24483
  }
24474
24484
  class RichText {
24475
24485
  static ensureValidText(text2) {
24476
- assert(logger$42, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
24486
+ assert(logger$43, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
24477
24487
  }
24478
24488
  static diff(oldText, newText) {
24479
24489
  this.ensureValidText(oldText);
@@ -24495,9 +24505,9 @@ var __publicField = (obj, key, value) => {
24495
24505
  return resultText;
24496
24506
  }
24497
24507
  }
24498
- const logger$41 = getLogger("insert-text");
24508
+ const logger$42 = getLogger("insert-text");
24499
24509
  function insertText(richText2, offset, text2, attributes) {
24500
- assert(logger$41, text2, `invalid text to insert: ${text2}`);
24510
+ assert(logger$42, text2, `invalid text to insert: ${text2}`);
24501
24511
  const { left, right } = splitText(richText2, offset);
24502
24512
  const insertedText = typeof text2 === "string" ? [createTextOp(text2, attributes)] : text2;
24503
24513
  const result = [...left, ...insertedText, ...right];
@@ -24510,7 +24520,7 @@ var __publicField = (obj, key, value) => {
24510
24520
  };
24511
24521
  }
24512
24522
  function createInsertOps(offset, text2, attributes) {
24513
- assert(logger$41, offset >= 0, `invalid offset: ${offset}`);
24523
+ assert(logger$42, offset >= 0, `invalid offset: ${offset}`);
24514
24524
  if (text2.length === 0) {
24515
24525
  return [];
24516
24526
  }
@@ -24540,7 +24550,7 @@ var __publicField = (obj, key, value) => {
24540
24550
  function cloneText(text2) {
24541
24551
  return cloneDeep__default.default(text2);
24542
24552
  }
24543
- const logger$40 = getLogger("update-op-attribute");
24553
+ const logger$41 = getLogger("update-op-attribute");
24544
24554
  function updateOpAttributes(orgOps, key, value, newAttributes) {
24545
24555
  const ops = cloneText(orgOps);
24546
24556
  const index2 = ops.findIndex((op2) => {
@@ -24548,7 +24558,7 @@ var __publicField = (obj, key, value) => {
24548
24558
  return false;
24549
24559
  return op2.attributes[key] === value;
24550
24560
  });
24551
- assert(logger$40, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
24561
+ assert(logger$41, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
24552
24562
  const op = ops[index2];
24553
24563
  op.attributes = {
24554
24564
  ...op.attributes,
@@ -24630,11 +24640,11 @@ var __publicField = (obj, key, value) => {
24630
24640
  ]);
24631
24641
  }
24632
24642
  const FILL_CHAR = "\u200B";
24633
- const logger$3$ = getLogger("to-plain-text");
24643
+ const logger$40 = getLogger("to-plain-text");
24634
24644
  function toPlainText(ops, options) {
24635
24645
  let text2 = "";
24636
24646
  ops.forEach((op) => {
24637
- assert(logger$3$, typeof op.insert === "string", "invalid op");
24647
+ assert(logger$40, typeof op.insert === "string", "invalid op");
24638
24648
  if (op.attributes && op.attributes.box === true) {
24639
24649
  if (options == null ? void 0 : options.boxReplacement) {
24640
24650
  text2 += options.boxReplacement;
@@ -24689,11 +24699,11 @@ var __publicField = (obj, key, value) => {
24689
24699
  focus: pos
24690
24700
  };
24691
24701
  }
24692
- const logger$3_ = getLogger("block-to-text");
24702
+ const logger$3$ = getLogger("block-to-text");
24693
24703
  function textBlockToText$1(editor, ops, doc2) {
24694
24704
  let text2 = "";
24695
24705
  ops.forEach((op) => {
24696
- assert(logger$3_, typeof op.insert === "string", "invalid op");
24706
+ assert(logger$3$, typeof op.insert === "string", "invalid op");
24697
24707
  if (op.attributes && op.attributes.box === true) {
24698
24708
  const box = op.attributes;
24699
24709
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -24711,11 +24721,11 @@ var __publicField = (obj, key, value) => {
24711
24721
  });
24712
24722
  return text2;
24713
24723
  }
24714
- const logger$3Z = getLogger("block-to-text");
24724
+ const logger$3_ = getLogger("block-to-text");
24715
24725
  function textToMarkdownText(editor, ops, doc2) {
24716
24726
  let text2 = "";
24717
24727
  ops.forEach((op) => {
24718
- assert(logger$3Z, typeof op.insert === "string", "invalid op");
24728
+ assert(logger$3_, typeof op.insert === "string", "invalid op");
24719
24729
  if (op.attributes && op.attributes.box === true) {
24720
24730
  const box = op.attributes;
24721
24731
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -24838,12 +24848,12 @@ var __publicField = (obj, key, value) => {
24838
24848
  return void 0;
24839
24849
  }
24840
24850
  }
24841
- const logger$3Y = getLogger("block-to-text");
24851
+ const logger$3Z = getLogger("block-to-text");
24842
24852
  function textBlockToHtml(editor, blockData, doc2) {
24843
24853
  let html = "";
24844
24854
  const ops = blockData.text || [];
24845
24855
  ops.forEach((op) => {
24846
- assert(logger$3Y, typeof op.insert === "string", "invalid op");
24856
+ assert(logger$3Z, typeof op.insert === "string", "invalid op");
24847
24857
  if (op.attributes && op.attributes.box === true) {
24848
24858
  const box = op.attributes;
24849
24859
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -24919,16 +24929,16 @@ var __publicField = (obj, key, value) => {
24919
24929
  }
24920
24930
  return `<p>${html}</p>`;
24921
24931
  }
24922
- const logger$3X = getLogger("text-block");
24932
+ const logger$3Y = getLogger("text-block");
24923
24933
  function createBlockContent$5(editor, path, container, blockElement, blockData) {
24924
24934
  const { text: text2 } = blockData;
24925
- assert(logger$3X, text2, "no text for text block");
24935
+ assert(logger$3Y, text2, "no text for text block");
24926
24936
  const content = createBlockContentElement(blockElement, "div");
24927
24937
  updateBlockContent$1(editor, path, blockData.id, content, text2);
24928
24938
  return content;
24929
24939
  }
24930
24940
  function updateBlockText$1(editor, block, text2) {
24931
- assert(logger$3X, text2, "no text to update");
24941
+ assert(logger$3Y, text2, "no text to update");
24932
24942
  const newContent = createBlockContentElement(null, "div");
24933
24943
  updateBlockContent$1(editor, getBlockPath(block), getBlockId(block), newContent, text2);
24934
24944
  const oldContent = getBlockContent(block);
@@ -24938,7 +24948,7 @@ var __publicField = (obj, key, value) => {
24938
24948
  return getRangeClientRects(editor, block, range);
24939
24949
  }
24940
24950
  function convertTo$k(editor, blockData, doc2, type) {
24941
- assert(logger$3X, blockData.text, "no text for text block");
24951
+ assert(logger$3Y, blockData.text, "no text for text block");
24942
24952
  if (type === "text") {
24943
24953
  return textBlockToText$1(editor, blockData.text, doc2);
24944
24954
  }
@@ -24952,7 +24962,7 @@ var __publicField = (obj, key, value) => {
24952
24962
  blockData.id = genId();
24953
24963
  info == null ? void 0 : info.blockIdMap.set(srcBlockData.id, blockData.id);
24954
24964
  const { text: text2 } = blockData;
24955
- assert(logger$3X, text2, "no text for text block");
24965
+ assert(logger$3Y, text2, "no text for text block");
24956
24966
  text2.forEach((op) => {
24957
24967
  if (op.insert && op.attributes && op.attributes.box === true) {
24958
24968
  const boxId = genId();
@@ -24984,7 +24994,7 @@ var __publicField = (obj, key, value) => {
24984
24994
  blockToDoc: blockToDoc$1
24985
24995
  };
24986
24996
  const updateTextBlockContent = updateBlockContent$1;
24987
- const logger$3W = getLogger("action-helper");
24997
+ const logger$3X = getLogger("action-helper");
24988
24998
  function editorGetBlockData(editor, block) {
24989
24999
  const container = getParentContainer(block);
24990
25000
  const containerId = getContainerId(container);
@@ -24992,10 +25002,10 @@ var __publicField = (obj, key, value) => {
24992
25002
  return editor.doc.getBlockData(containerId, blockIndex);
24993
25003
  }
24994
25004
  function editorGetBlockText(editor, block) {
24995
- assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25005
+ assert(logger$3X, isTextKindBlock(editor, block), "not a text kind block");
24996
25006
  const data2 = editorGetBlockData(editor, block);
24997
25007
  const text2 = data2.text;
24998
- assert(logger$3W, text2, "no text in block");
25008
+ assert(logger$3X, text2, "no text in block");
24999
25009
  return text2;
25000
25010
  }
25001
25011
  function editorGetBlockTextEx(editor, block, length) {
@@ -25003,7 +25013,7 @@ var __publicField = (obj, key, value) => {
25003
25013
  }
25004
25014
  function editorGetBoxData(editor, box) {
25005
25015
  const block = getParentBlock(box);
25006
- assert(logger$3W, block, "no parent block");
25016
+ assert(logger$3X, block, "no parent block");
25007
25017
  const text2 = editorGetBlockText(editor, block);
25008
25018
  const id = getBoxId(box);
25009
25019
  const op = text2.find((op2) => {
@@ -25013,60 +25023,60 @@ var __publicField = (obj, key, value) => {
25013
25023
  }
25014
25024
  return false;
25015
25025
  });
25016
- assert(logger$3W, op, "failed to find box");
25026
+ assert(logger$3X, op, "failed to find box");
25017
25027
  return op.attributes;
25018
25028
  }
25019
- const logger$3V = getLogger("block-text");
25029
+ const logger$3W = getLogger("block-text");
25020
25030
  function getTextAfterOffset(editor, block, offset) {
25021
- assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
25022
- assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
25023
- assert(logger$3V, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25031
+ assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25032
+ assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
25033
+ assert(logger$3W, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25024
25034
  const newOffset = getNextValidOffset(block, offset);
25025
25035
  const length = newOffset - offset;
25026
25036
  if (length === 0) {
25027
- assert(logger$3V, false, `no text after offset: ${offset}`);
25037
+ assert(logger$3W, false, `no text after offset: ${offset}`);
25028
25038
  }
25029
25039
  const text2 = editorGetBlockText(editor, block);
25030
25040
  const { middle } = splitToThree(text2, offset, length);
25031
- assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
25041
+ assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
25032
25042
  const op = middle[0];
25033
25043
  if (isBoxOp(op)) {
25034
25044
  return " ";
25035
25045
  }
25036
- assert(logger$3V, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25046
+ assert(logger$3W, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25037
25047
  return op.insert;
25038
25048
  }
25039
25049
  function getTextBeforeOffset(editor, block, offset) {
25040
- assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
25041
- assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
25042
- assert(logger$3V, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25050
+ assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25051
+ assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
25052
+ assert(logger$3W, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25043
25053
  const newOffset = getPrevValidOffset(block, offset);
25044
25054
  const length = offset - newOffset;
25045
25055
  if (length === 0) {
25046
- assert(logger$3V, false, `no text before offset: ${offset}`);
25056
+ assert(logger$3W, false, `no text before offset: ${offset}`);
25047
25057
  }
25048
25058
  const text2 = editorGetBlockText(editor, block);
25049
25059
  const { middle } = splitToThree(text2, newOffset, length);
25050
- assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
25060
+ assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
25051
25061
  const op = middle[0];
25052
25062
  if (isBoxOp(op)) {
25053
25063
  return " ";
25054
25064
  }
25055
- assert(logger$3V, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25065
+ assert(logger$3W, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25056
25066
  return op.insert;
25057
25067
  }
25058
25068
  function getOffsetInfoBefore(editor, block, offset) {
25059
- assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
25060
- assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
25061
- assert(logger$3V, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25069
+ assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25070
+ assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
25071
+ assert(logger$3W, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25062
25072
  const newOffset = getPrevValidOffset(block, offset);
25063
25073
  const length = offset - newOffset;
25064
25074
  if (length === 0) {
25065
- assert(logger$3V, false, `no text before offset: ${offset}`);
25075
+ assert(logger$3W, false, `no text before offset: ${offset}`);
25066
25076
  }
25067
25077
  const text2 = editorGetBlockText(editor, block);
25068
25078
  const { middle } = splitToThree(text2, newOffset, length);
25069
- assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
25079
+ assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
25070
25080
  const op = middle[0];
25071
25081
  if (isBoxOp(op)) {
25072
25082
  return {
@@ -25076,25 +25086,33 @@ var __publicField = (obj, key, value) => {
25076
25086
  length: 1
25077
25087
  };
25078
25088
  }
25089
+ let charType = "text";
25090
+ if (isSpace(op.insert)) {
25091
+ charType = "space";
25092
+ } else if (isCJKPunctuation(op.insert)) {
25093
+ charType = "cjk_punctuation";
25094
+ } else if (isCJK(op.insert)) {
25095
+ charType = "cjk";
25096
+ }
25079
25097
  return {
25080
25098
  op,
25081
- charType: isSpace(op.insert) ? "space" : "text",
25099
+ charType,
25082
25100
  offset: newOffset,
25083
25101
  length: op.insert.length
25084
25102
  };
25085
25103
  }
25086
25104
  function getOffsetInfoAfter(editor, block, offset) {
25087
- assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
25088
- assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
25089
- assert(logger$3V, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25105
+ assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25106
+ assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
25107
+ assert(logger$3W, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25090
25108
  const newOffset = getNextValidOffset(block, offset);
25091
25109
  const length = newOffset - offset;
25092
25110
  if (length === 0) {
25093
- assert(logger$3V, false, `no text after offset: ${offset}`);
25111
+ assert(logger$3W, false, `no text after offset: ${offset}`);
25094
25112
  }
25095
25113
  const text2 = editorGetBlockText(editor, block);
25096
25114
  const { middle } = splitToThree(text2, offset, length);
25097
- assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
25115
+ assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
25098
25116
  const op = middle[0];
25099
25117
  if (isBoxOp(op)) {
25100
25118
  return {
@@ -25104,9 +25122,17 @@ var __publicField = (obj, key, value) => {
25104
25122
  length: 1
25105
25123
  };
25106
25124
  }
25125
+ let charType = "text";
25126
+ if (isSpace(op.insert)) {
25127
+ charType = "space";
25128
+ } else if (isCJKPunctuation(op.insert)) {
25129
+ charType = "cjk_punctuation";
25130
+ } else if (isCJK(op.insert)) {
25131
+ charType = "cjk";
25132
+ }
25107
25133
  return {
25108
25134
  op,
25109
- charType: isSpace(op.insert) ? "space" : "text",
25135
+ charType,
25110
25136
  offset,
25111
25137
  length: op.insert.length
25112
25138
  };
@@ -25158,7 +25184,7 @@ var __publicField = (obj, key, value) => {
25158
25184
  return null;
25159
25185
  }
25160
25186
  function findWordLeft(editor, block, offset) {
25161
- assert(logger$3V, isTextKindBlock(editor, block), "invalid blok type");
25187
+ assert(logger$3W, isTextKindBlock(editor, block), "invalid blok type");
25162
25188
  if (isEmptyTextBlock(editor, block)) {
25163
25189
  return 0;
25164
25190
  }
@@ -25167,6 +25193,7 @@ var __publicField = (obj, key, value) => {
25167
25193
  return offset - 1;
25168
25194
  }
25169
25195
  let start = offset;
25196
+ let find = offsetInfo.charType;
25170
25197
  if (offsetInfo.charType === "space") {
25171
25198
  const startInfo2 = findPrevOffsetNotType(editor, block, start, "space");
25172
25199
  if (!startInfo2) {
@@ -25179,14 +25206,15 @@ var __publicField = (obj, key, value) => {
25179
25206
  return startInfo2.offset;
25180
25207
  }
25181
25208
  start = startInfo2.offset;
25209
+ find = getOffsetInfoBefore(editor, block, start).charType;
25182
25210
  }
25183
- const startInfo = findPrevOffsetNotType(editor, block, start, "text");
25211
+ const startInfo = findPrevOffsetNotType(editor, block, start, find);
25184
25212
  if (!startInfo)
25185
25213
  return 0;
25186
25214
  return startInfo.offset + startInfo.length;
25187
25215
  }
25188
25216
  function findWordEnd(editor, block, offset) {
25189
- assert(logger$3V, isTextKindBlock(editor, block), "invalid blok type");
25217
+ assert(logger$3W, isTextKindBlock(editor, block), "invalid blok type");
25190
25218
  if (isEmptyTextBlock(editor, block)) {
25191
25219
  return 0;
25192
25220
  }
@@ -25195,6 +25223,7 @@ var __publicField = (obj, key, value) => {
25195
25223
  return offset + 1;
25196
25224
  }
25197
25225
  let start = offset;
25226
+ let find = offsetInfo.charType;
25198
25227
  if (offsetInfo.charType === "space") {
25199
25228
  const startInfo2 = findAfterOffsetNotType(editor, block, start, "space");
25200
25229
  if (!startInfo2) {
@@ -25207,16 +25236,17 @@ var __publicField = (obj, key, value) => {
25207
25236
  return startInfo2.offset;
25208
25237
  }
25209
25238
  start = startInfo2.offset;
25239
+ find = getOffsetInfoAfter(editor, block, start).charType;
25210
25240
  }
25211
- const startInfo = findAfterOffsetNotType(editor, block, start, "text");
25241
+ const startInfo = findAfterOffsetNotType(editor, block, start, find);
25212
25242
  if (!startInfo)
25213
25243
  return getBlockTextLength$6(editor, block);
25214
25244
  return startInfo.offset;
25215
25245
  }
25216
- const logger$3U = getLogger("text-box");
25246
+ const logger$3V = getLogger("text-box");
25217
25247
  function updateBoxContent$8(editor, boxElement, boxContent, boxData) {
25218
- assert(logger$3U, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
25219
- assert(logger$3U, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
25248
+ assert(logger$3V, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
25249
+ assert(logger$3V, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
25220
25250
  createElement("span", [], boxContent, boxData.text);
25221
25251
  }
25222
25252
  function convertTo$j(editor, boxData, doc2, type) {
@@ -25250,7 +25280,7 @@ var __publicField = (obj, key, value) => {
25250
25280
  updateBoxContent: updateBoxContent$7,
25251
25281
  convertTo: convertTo$i
25252
25282
  };
25253
- const logger$3T = getLogger("editor-boxes");
25283
+ const logger$3U = getLogger("editor-boxes");
25254
25284
  class EditorBoxes {
25255
25285
  constructor(editor) {
25256
25286
  __publicField(this, "boxes", /* @__PURE__ */ new Map());
@@ -25259,12 +25289,12 @@ var __publicField = (obj, key, value) => {
25259
25289
  registerBoxClass(boxClass) {
25260
25290
  const type = boxClass.boxType;
25261
25291
  const exists = this.boxes.get(type);
25262
- assert(logger$3T, !exists, `duplicated box type: ${type}`);
25292
+ assert(logger$3U, !exists, `duplicated box type: ${type}`);
25263
25293
  this.boxes.set(type, boxClass);
25264
25294
  }
25265
25295
  getBoxClass(type) {
25266
25296
  const exists = this.boxes.get(type);
25267
- assert(logger$3T, exists, `unknown box type: ${type}`);
25297
+ assert(logger$3U, exists, `unknown box type: ${type}`);
25268
25298
  return exists;
25269
25299
  }
25270
25300
  createBox(blockContent, box) {
@@ -25629,7 +25659,7 @@ var __publicField = (obj, key, value) => {
25629
25659
  return { classes, attributes: newAttributes, styles: newStyles };
25630
25660
  }
25631
25661
  }
25632
- const logger$3S = getLogger("editor-insertion");
25662
+ const logger$3T = getLogger("editor-insertion");
25633
25663
  class EditorInsertions {
25634
25664
  constructor(editor) {
25635
25665
  __publicField(this, "insertions", /* @__PURE__ */ new Map());
@@ -25638,12 +25668,12 @@ var __publicField = (obj, key, value) => {
25638
25668
  registerInsertionClass(insertionClass) {
25639
25669
  const type = insertionClass.insertionType;
25640
25670
  const exists = this.insertions.get(type);
25641
- assert(logger$3S, !exists, `duplicated insertion type: ${type}`);
25671
+ assert(logger$3T, !exists, `duplicated insertion type: ${type}`);
25642
25672
  this.insertions.set(type, insertionClass);
25643
25673
  }
25644
25674
  getInsertionClass(type) {
25645
25675
  const exists = this.insertions.get(type);
25646
- assert(logger$3S, exists, `unknown insertion type: ${type}`);
25676
+ assert(logger$3T, exists, `unknown insertion type: ${type}`);
25647
25677
  return exists;
25648
25678
  }
25649
25679
  createInsertionElement(type, id, attributes) {
@@ -25763,7 +25793,7 @@ var __publicField = (obj, key, value) => {
25763
25793
  };
25764
25794
  }
25765
25795
  }
25766
- const logger$3R = getLogger("editor-input");
25796
+ const logger$3S = getLogger("editor-input");
25767
25797
  class EditorInput$1 {
25768
25798
  constructor(editor, callbacks) {
25769
25799
  __publicField(this, "editor");
@@ -25885,7 +25915,7 @@ var __publicField = (obj, key, value) => {
25885
25915
  return;
25886
25916
  }
25887
25917
  this.callbacks.onCut(event);
25888
- logger$3R.debug("on cut");
25918
+ logger$3S.debug("on cut");
25889
25919
  });
25890
25920
  __publicField(this, "handlePaste", (event) => {
25891
25921
  if (event.isTrusted) {
@@ -26000,11 +26030,11 @@ var __publicField = (obj, key, value) => {
26000
26030
  this.callbacks.removeHandler(handler);
26001
26031
  }
26002
26032
  defaultInsertText(editor, containerId, blockIndex, offset, text2) {
26003
- assert(logger$3R, editor === this.editor, "invalid editor");
26033
+ assert(logger$3S, editor === this.editor, "invalid editor");
26004
26034
  this.callbacks.defaultInsertText(editor, containerId, blockIndex, offset, text2);
26005
26035
  }
26006
26036
  defaultHandleKeydown(editor, event) {
26007
- assert(logger$3R, editor === this.editor, "invalid editor");
26037
+ assert(logger$3S, editor === this.editor, "invalid editor");
26008
26038
  return this.callbacks.defaultHandleKeydown(editor, event);
26009
26039
  }
26010
26040
  forEach(callback) {
@@ -26029,7 +26059,7 @@ var __publicField = (obj, key, value) => {
26029
26059
  input2.style.left = `${x / scale}px`;
26030
26060
  input2.style.top = `${y / scale}px`;
26031
26061
  }
26032
- const logger$3Q = getLogger("editor-caret");
26062
+ const logger$3R = getLogger("editor-caret");
26033
26063
  function getFirefoxVersion() {
26034
26064
  const userAgent = window.navigator.userAgent;
26035
26065
  const match = userAgent.match(/Firefox\/(\d+)\./);
@@ -26092,11 +26122,11 @@ var __publicField = (obj, key, value) => {
26092
26122
  return;
26093
26123
  }
26094
26124
  const { range } = this.editor.selection;
26095
- assert(logger$3Q, range.isCollapsed, "range is not collapsed");
26125
+ assert(logger$3R, range.isCollapsed, "range is not collapsed");
26096
26126
  const pos = range.start;
26097
- assert(logger$3Q, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
26127
+ assert(logger$3R, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
26098
26128
  const block = this.editor.getBlockById(pos.blockId);
26099
- assert(logger$3Q, isTextKindBlock(this.editor, block), "only text kind block can has caret");
26129
+ assert(logger$3R, isTextKindBlock(this.editor, block), "only text kind block can has caret");
26100
26130
  let rect;
26101
26131
  const compositionSpan = block.querySelector("span.inputting-insertion");
26102
26132
  if (compositionSpan) {
@@ -26134,7 +26164,7 @@ var __publicField = (obj, key, value) => {
26134
26164
  clearAllSelection(editor);
26135
26165
  editor.selection.range.getSelectedBlocks().forEach((s) => updateBlockSelection(editor, s.block, s.start, s.end));
26136
26166
  }
26137
- const logger$3P = getLogger("editor-dom");
26167
+ const logger$3Q = getLogger("editor-dom");
26138
26168
  function editorGetClientHeight(editor) {
26139
26169
  const scrollContainer = getScrollContainer$1(editor.rootContainer);
26140
26170
  return scrollContainer.clientHeight;
@@ -26222,7 +26252,7 @@ var __publicField = (obj, key, value) => {
26222
26252
  }
26223
26253
  function editorScrollIntoView(editor) {
26224
26254
  if (!isElementVisible(editor.rootContainer)) {
26225
- logger$3P.warn("editorScrollIntoView: editor is not visible");
26255
+ logger$3Q.warn("editorScrollIntoView: editor is not visible");
26226
26256
  return;
26227
26257
  }
26228
26258
  const rootClientRect = editor.rootContainer.getBoundingClientRect();
@@ -26287,7 +26317,7 @@ var __publicField = (obj, key, value) => {
26287
26317
  const { start, end } = range;
26288
26318
  return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
26289
26319
  }
26290
- const logger$3O = getLogger("range-in-block");
26320
+ const logger$3P = getLogger("range-in-block");
26291
26321
  function rangeInBlock(block, range) {
26292
26322
  const editor = range.getEditor();
26293
26323
  const start = editor.getBlockById(range.start.blockId);
@@ -26308,16 +26338,16 @@ var __publicField = (obj, key, value) => {
26308
26338
  while (prevBlock && !blocks.has(getBlockId(prevBlock))) {
26309
26339
  prevBlock = getPrevVisibleBlock(prevBlock);
26310
26340
  }
26311
- assert(logger$3O, prevBlock, "no prev block while deleting a block");
26341
+ assert(logger$3P, prevBlock, "no prev block while deleting a block");
26312
26342
  newRange = createBlockSimpleRange(editor, prevBlock, getBlockTextLength$6(editor, prevBlock));
26313
26343
  } else {
26314
26344
  const nextBlock = getNextVisibleBlock(block);
26315
- assert(logger$3O, nextBlock, "no prev and next block while deleting a block");
26345
+ assert(logger$3P, nextBlock, "no prev and next block while deleting a block");
26316
26346
  newRange = createBlockSimpleRange(editor, nextBlock, 0);
26317
26347
  }
26318
26348
  return newRange;
26319
26349
  }
26320
- const logger$3N = getLogger("block-to-html");
26350
+ const logger$3O = getLogger("block-to-html");
26321
26351
  function blockToHtml(editor, blockData, doc2, path) {
26322
26352
  const blockClass = getBlockClassByType(editor, blockData.type);
26323
26353
  if (blockClass.convertTo) {
@@ -26326,15 +26356,15 @@ var __publicField = (obj, key, value) => {
26326
26356
  if (blockClass.blockKind !== "text") {
26327
26357
  return `[${blockData.type}]`;
26328
26358
  }
26329
- assert(logger$3N, blockData.text, "no text");
26359
+ assert(logger$3O, blockData.text, "no text");
26330
26360
  const plainText = toPlainText(blockData.text);
26331
26361
  return `<div>${escapeHtmlText(plainText)}</div>`;
26332
26362
  }
26333
- const logger$3M = getLogger("block-to-text");
26363
+ const logger$3N = getLogger("block-to-text");
26334
26364
  function textBlockToText(editor, ops, doc2) {
26335
26365
  let text2 = "";
26336
26366
  ops.forEach((op) => {
26337
- assert(logger$3M, typeof op.insert === "string", "invalid op");
26367
+ assert(logger$3N, typeof op.insert === "string", "invalid op");
26338
26368
  if (op.attributes && op.attributes.box === true) {
26339
26369
  const box = op.attributes;
26340
26370
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -26360,7 +26390,7 @@ var __publicField = (obj, key, value) => {
26360
26390
  if (blockClass.blockKind !== "text") {
26361
26391
  return `[${blockData.type}]`;
26362
26392
  }
26363
- assert(logger$3M, blockData.text, "no text");
26393
+ assert(logger$3N, blockData.text, "no text");
26364
26394
  const plainText = textBlockToText(editor, blockData.text, doc2);
26365
26395
  return plainText;
26366
26396
  }
@@ -26393,11 +26423,11 @@ var __publicField = (obj, key, value) => {
26393
26423
  const markdown = lines.join("\n");
26394
26424
  return markdown;
26395
26425
  }
26396
- const logger$3L = getLogger("get-text-position");
26426
+ const logger$3M = getLogger("get-text-position");
26397
26427
  function editorGetTextPosition(editor, insertPos) {
26398
26428
  const pos = insertPos != null ? insertPos : editor.selection.range.start;
26399
26429
  if (!(pos instanceof EditorSimpleBlockPosition)) {
26400
- assert(logger$3L, false, `invalid insert pos type: ${typeof pos}`);
26430
+ assert(logger$3M, false, `invalid insert pos type: ${typeof pos}`);
26401
26431
  }
26402
26432
  const { blockId } = pos;
26403
26433
  const block = editor.getBlockById(blockId);
@@ -26485,14 +26515,14 @@ var __publicField = (obj, key, value) => {
26485
26515
  return attributes;
26486
26516
  }
26487
26517
  }
26488
- const logger$3K = getLogger("insert-text");
26518
+ const logger$3L = getLogger("insert-text");
26489
26519
  function getTextAttributes(editor, containerId, blockIndex, offset) {
26490
26520
  var _a, _b;
26491
26521
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26492
- assert(logger$3K, blockData, "no block data");
26493
- assert(logger$3K, blockData.text, "no block text");
26522
+ assert(logger$3L, blockData, "no block data");
26523
+ assert(logger$3L, blockData.text, "no block text");
26494
26524
  if (getTextLength(blockData.text) === 0) {
26495
- assert(logger$3K, offset === 0, "invalid text offset");
26525
+ assert(logger$3L, offset === 0, "invalid text offset");
26496
26526
  return BlockAttributesHandler.get(editor).getEmptyBlockTextAttributes(blockData.id);
26497
26527
  }
26498
26528
  if (offset === 0) {
@@ -26539,7 +26569,7 @@ var __publicField = (obj, key, value) => {
26539
26569
  }
26540
26570
  for (let i = 0; i < text2.length; i++) {
26541
26571
  const op = text2[i];
26542
- assert(logger$3K, typeof op.insert === "string", "invalid text op, no insert");
26572
+ assert(logger$3L, typeof op.insert === "string", "invalid text op, no insert");
26543
26573
  const endPos = pos + getOpLength(op);
26544
26574
  if (endPos === start) {
26545
26575
  return false;
@@ -26553,8 +26583,8 @@ var __publicField = (obj, key, value) => {
26553
26583
  }
26554
26584
  function editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset) {
26555
26585
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26556
- assert(logger$3K, blockData, "no block data");
26557
- assert(logger$3K, blockData.text, "no block text");
26586
+ assert(logger$3L, blockData, "no block data");
26587
+ assert(logger$3L, blockData.text, "no block text");
26558
26588
  const attributes = getTextAttributes(editor, containerId, blockIndex, offset);
26559
26589
  if (attributes && Object.keys(attributes).includes("link")) {
26560
26590
  const inOp = checkRangeInOp(blockData.text, offset);
@@ -26573,21 +26603,21 @@ var __publicField = (obj, key, value) => {
26573
26603
  const { containerId, blockIndex, offset } = editorGetTextPosition(editor);
26574
26604
  editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset);
26575
26605
  }
26576
- const logger$3J = getLogger("update-composition-text");
26606
+ const logger$3K = getLogger("update-composition-text");
26577
26607
  function editorUpdateCompositionText(editor) {
26578
26608
  const pos = editor.selection.range.start;
26579
26609
  if (!(pos instanceof EditorSimpleBlockPosition)) {
26580
- assert(logger$3J, false, `invalid insert pos type: ${typeof pos}`);
26610
+ assert(logger$3K, false, `invalid insert pos type: ${typeof pos}`);
26581
26611
  }
26582
26612
  const { blockId } = pos;
26583
26613
  const block = editor.getBlockById(blockId);
26584
- assert(logger$3J, isTextKindBlock(editor, block), "not a text kind block");
26614
+ assert(logger$3K, isTextKindBlock(editor, block), "not a text kind block");
26585
26615
  const container = getParentContainer(block);
26586
26616
  const containerId = getContainerId(container);
26587
26617
  const blockIndex = getBlockIndex(block);
26588
26618
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26589
- assert(logger$3J, blockData, "no block data in doc");
26590
- assert(logger$3J, blockData.text, "no text data in text block");
26619
+ assert(logger$3K, blockData, "no block data in doc");
26620
+ assert(logger$3K, blockData.text, "no text data in text block");
26591
26621
  const blockContent = getBlockContent(block);
26592
26622
  updateBlockContent$1(editor, getBlockPath(block), blockId, blockContent, blockData.text);
26593
26623
  }
@@ -26599,25 +26629,25 @@ var __publicField = (obj, key, value) => {
26599
26629
  const block = editor.getBlockById(blockData.id);
26600
26630
  return block;
26601
26631
  }
26602
- const logger$3I = getLogger("delete-block-text");
26632
+ const logger$3J = getLogger("delete-block-text");
26603
26633
  function editorDeleteBlockText(editor, block, offset, count, options) {
26604
26634
  if (!editor.isBlockWritable(block)) {
26605
- logger$3I.error("block is not writable");
26635
+ logger$3J.error("block is not writable");
26606
26636
  return 0;
26607
26637
  }
26608
- assert(logger$3I, isTextKindBlock(editor, block), "block is not a text kind block");
26638
+ assert(logger$3J, isTextKindBlock(editor, block), "block is not a text kind block");
26609
26639
  const container = getParentContainer(block);
26610
26640
  const containerId = getContainerId(container);
26611
26641
  const blockIndex = getBlockIndex(block);
26612
26642
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26613
- assert(logger$3I, blockData, "no block data in doc");
26614
- assert(logger$3I, blockData.text, "no text data in text block");
26643
+ assert(logger$3J, blockData, "no block data in doc");
26644
+ assert(logger$3J, blockData.text, "no text data in text block");
26615
26645
  let from = offset;
26616
26646
  if (!isValidOffset(block, offset)) {
26617
26647
  from = getPrevValidOffset(block, from);
26618
26648
  }
26619
26649
  let to = offset + count;
26620
- assert(logger$3I, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
26650
+ assert(logger$3J, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
26621
26651
  if (!isValidOffset(block, to)) {
26622
26652
  to = getNextValidOffset(block, to);
26623
26653
  }
@@ -26626,7 +26656,7 @@ var __publicField = (obj, key, value) => {
26626
26656
  editor.doc.localUpdateBlockText(containerId, blockIndex, actions2, options);
26627
26657
  return deleteCount;
26628
26658
  }
26629
- const logger$3H = getLogger("break-text-block");
26659
+ const logger$3I = getLogger("break-text-block");
26630
26660
  function copyBlockAttributes(editor, block) {
26631
26661
  const blockData = editor.getBlockData(block);
26632
26662
  const quoted = blockData.quoted;
@@ -26638,8 +26668,8 @@ var __publicField = (obj, key, value) => {
26638
26668
  return {};
26639
26669
  }
26640
26670
  function editorBreakTextBlock(editor, block, offset, options) {
26641
- assert(logger$3H, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
26642
- assert(logger$3H, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
26671
+ assert(logger$3I, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
26672
+ assert(logger$3I, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
26643
26673
  const container = getParentContainer(block);
26644
26674
  const containerId = getContainerId(container);
26645
26675
  const blockIndex = getBlockIndex(block);
@@ -26669,7 +26699,7 @@ var __publicField = (obj, key, value) => {
26669
26699
  };
26670
26700
  }
26671
26701
  }
26672
- assert(logger$3H, isValidOffset(block, offset), "not a valid offset");
26702
+ assert(logger$3I, isValidOffset(block, offset), "not a valid offset");
26673
26703
  const text2 = editorGetBlockText(editor, block);
26674
26704
  const { right } = splitText(text2, offset);
26675
26705
  const rightLength = getTextLength(right);
@@ -26695,12 +26725,12 @@ var __publicField = (obj, key, value) => {
26695
26725
  newBlock
26696
26726
  };
26697
26727
  }
26698
- const logger$3G = getLogger("prepare-insert-new-block");
26728
+ const logger$3H = getLogger("prepare-insert-new-block");
26699
26729
  function editorPrepareInsertNewBlock(editor, containerId, blockIndex) {
26700
26730
  if (containerId && blockIndex !== void 0 && blockIndex !== null) {
26701
26731
  const container = editor.getContainerById(containerId);
26702
26732
  const blocks = getChildBlocks(container);
26703
- assert(logger$3G, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
26733
+ assert(logger$3H, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
26704
26734
  return {
26705
26735
  containerId,
26706
26736
  blockIndex
@@ -26734,15 +26764,15 @@ var __publicField = (obj, key, value) => {
26734
26764
  blockIndex: getBlockIndex(newBlock)
26735
26765
  };
26736
26766
  }
26737
- const logger$3F = getLogger("auto-insert-block");
26767
+ const logger$3G = getLogger("auto-insert-block");
26738
26768
  function editorAutoInsertBlock(editor, blockData, containerId, blockIndex, newRange, insertBlockOptions) {
26739
26769
  const result = editorPrepareInsertNewBlock(editor, containerId, blockIndex);
26740
- assert(logger$3F, result, `not an valid insert position: ${editor.selection.range}`);
26770
+ assert(logger$3G, result, `not an valid insert position: ${editor.selection.range}`);
26741
26771
  const defaultPos = { blockId: blockData.id, offset: 0 };
26742
26772
  const defaultRange = { anchor: defaultPos, focus: defaultPos };
26743
26773
  return editorInsertBlock(editor, result.containerId, result.blockIndex, blockData, newRange != null ? newRange : defaultRange, insertBlockOptions);
26744
26774
  }
26745
- const logger$3E = getLogger("delete-block");
26775
+ const logger$3F = getLogger("delete-block");
26746
26776
  function getAllChildContainers(editor, blockData, containerIds) {
26747
26777
  if (blockData.children) {
26748
26778
  containerIds.push(...blockData.children);
@@ -26759,7 +26789,7 @@ var __publicField = (obj, key, value) => {
26759
26789
  const containerId = getContainerId(container);
26760
26790
  const blockIndex = getBlockIndex(block);
26761
26791
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26762
- assert(logger$3E, blockData, "no block data in doc");
26792
+ assert(logger$3F, blockData, "no block data in doc");
26763
26793
  editor.doc.localDeleteBlock(containerId, blockIndex, createEditorSelectionRange(editor, { anchor: newRange.start, focus: newRange.end }));
26764
26794
  return blockData;
26765
26795
  }
@@ -26805,15 +26835,15 @@ var __publicField = (obj, key, value) => {
26805
26835
  });
26806
26836
  editor.doc.localDeleteChildContainers(containerIds);
26807
26837
  }
26808
- const logger$3D = getLogger("merge-text-block");
26838
+ const logger$3E = getLogger("merge-text-block");
26809
26839
  function editorMergeTextBlock(editor, block1, block2) {
26810
- assert(logger$3D, isTextKindBlock(editor, block1), "only text block can be merged");
26811
- assert(logger$3D, isTextKindBlock(editor, block2), "only text block can be merged");
26840
+ assert(logger$3E, isTextKindBlock(editor, block1), "only text block can be merged");
26841
+ assert(logger$3E, isTextKindBlock(editor, block2), "only text block can be merged");
26812
26842
  const data1 = editorGetBlockData(editor, block1);
26813
26843
  const data2 = editorGetBlockData(editor, block2);
26814
26844
  const text1 = data1.text;
26815
26845
  const text2 = data2.text;
26816
- assert(logger$3D, text1 && text2, "block data has no text");
26846
+ assert(logger$3E, text1 && text2, "block data has no text");
26817
26847
  const container = getParentContainer(block1);
26818
26848
  const containerId = getContainerId(container);
26819
26849
  const blockIndex = getBlockIndex(block1);
@@ -26823,15 +26853,15 @@ var __publicField = (obj, key, value) => {
26823
26853
  editorDeleteBlock(editor, block2, newRange);
26824
26854
  return block;
26825
26855
  }
26826
- const logger$3C = getLogger("clear-selected-contents");
26856
+ const logger$3D = getLogger("clear-selected-contents");
26827
26857
  function deleteTextBlockSelection(editor, selectedBlock) {
26828
- assert(logger$3C, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
26858
+ assert(logger$3D, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
26829
26859
  const { start, end } = selectedBlock;
26830
- assert(logger$3C, start.isSimple(), "not a simple block position");
26831
- assert(logger$3C, end.isSimple(), "not a simple block position");
26860
+ assert(logger$3D, start.isSimple(), "not a simple block position");
26861
+ assert(logger$3D, end.isSimple(), "not a simple block position");
26832
26862
  const startOffset = start.offset;
26833
26863
  const endOffset = end.offset;
26834
- assert(logger$3C, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
26864
+ assert(logger$3D, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
26835
26865
  if (startOffset === endOffset) {
26836
26866
  return;
26837
26867
  }
@@ -26856,7 +26886,7 @@ var __publicField = (obj, key, value) => {
26856
26886
  return;
26857
26887
  }
26858
26888
  if (isEmbedBlock(block) || start.isSimple()) {
26859
- assert(logger$3C, end.isSimple(), "invalid range");
26889
+ assert(logger$3D, end.isSimple(), "invalid range");
26860
26890
  const container = getParentContainer(block);
26861
26891
  const blockIndex = getBlockIndex(block);
26862
26892
  const newBlock = editor.insertTextBlock("", getContainerId(container), blockIndex);
@@ -26864,8 +26894,8 @@ var __publicField = (obj, key, value) => {
26864
26894
  editor.deleteBlock(block);
26865
26895
  return;
26866
26896
  }
26867
- assert(logger$3C, isComplexKindBlock(editor, block), "invalid block kind");
26868
- assert(logger$3C, !start.isSimple() && !end.isSimple(), "invalid range");
26897
+ assert(logger$3D, isComplexKindBlock(editor, block), "invalid block kind");
26898
+ assert(logger$3D, !start.isSimple() && !end.isSimple(), "invalid range");
26869
26899
  complexBlockGetSelectedContainers(editor, block, start, end);
26870
26900
  const containers = editor.selection.range.getSelectedContainers();
26871
26901
  containers.forEach((container, index2) => {
@@ -26882,7 +26912,7 @@ var __publicField = (obj, key, value) => {
26882
26912
  return;
26883
26913
  }
26884
26914
  const selectedBlocks = range.getSelectedBlocks();
26885
- assert(logger$3C, selectedBlocks.length > 0, "no selected block");
26915
+ assert(logger$3D, selectedBlocks.length > 0, "no selected block");
26886
26916
  if (selectedBlocks.length === 1) {
26887
26917
  clearOneBlock(editor, selectedBlocks[0]);
26888
26918
  return;
@@ -26890,7 +26920,7 @@ var __publicField = (obj, key, value) => {
26890
26920
  const firstSelectedBlock = selectedBlocks[0];
26891
26921
  const firstBlock = firstSelectedBlock.block;
26892
26922
  const container = getParentContainer(firstBlock);
26893
- assert(logger$3C, selectedBlocks.length > 1, "no selected block");
26923
+ assert(logger$3D, selectedBlocks.length > 1, "no selected block");
26894
26924
  const lastSelectedBlock = selectedBlocks[selectedBlocks.length - 1];
26895
26925
  const lastBlock2 = lastSelectedBlock.block;
26896
26926
  if (isTextKindBlock(editor, firstBlock)) {
@@ -26920,7 +26950,7 @@ var __publicField = (obj, key, value) => {
26920
26950
  }
26921
26951
  const prevBlock = getPrevBlock(firstBlock);
26922
26952
  const nextBlock = getNextBlock(lastBlock2);
26923
- assert(logger$3C, prevBlock || nextBlock, "no prev or next block");
26953
+ assert(logger$3D, prevBlock || nextBlock, "no prev or next block");
26924
26954
  selectedBlocks.forEach((selectedBlock) => editor.deleteBlock(selectedBlock.block));
26925
26955
  }
26926
26956
  function editorClearSelectedContents(editor, selectionRange) {
@@ -26939,7 +26969,7 @@ var __publicField = (obj, key, value) => {
26939
26969
  editor.emit("afterClearSelection", editor);
26940
26970
  });
26941
26971
  }
26942
- const logger$3B = getLogger("core");
26972
+ const logger$3C = getLogger("core");
26943
26973
  function editorUpdateBlockText(editor, block, ops, options) {
26944
26974
  const container = getParentContainer(block);
26945
26975
  const containerId = getContainerId(container);
@@ -26952,7 +26982,7 @@ var __publicField = (obj, key, value) => {
26952
26982
  }
26953
26983
  function editorSetBlockText(editor, block, newText, options) {
26954
26984
  if (!editor.isBlockWritable(block)) {
26955
- logger$3B.error("block is not writable");
26985
+ logger$3C.error("block is not writable");
26956
26986
  return;
26957
26987
  }
26958
26988
  const oldText = editor.getBlockText(block);
@@ -26965,7 +26995,7 @@ var __publicField = (obj, key, value) => {
26965
26995
  const ops = RichText.diff(oldText, newText);
26966
26996
  return editorUpdateBlockText(editor, block, ops);
26967
26997
  }
26968
- const logger$3A = getLogger("update-block-data");
26998
+ const logger$3B = getLogger("update-block-data");
26969
26999
  function editorUpdateBlockData(editor, block, data2, newRange, options) {
26970
27000
  const container = getParentContainer(block);
26971
27001
  const containerId = getContainerId(container);
@@ -26982,17 +27012,17 @@ var __publicField = (obj, key, value) => {
26982
27012
  if (oldKey === "id" || oldKey === "type" || oldKey === "text") {
26983
27013
  return;
26984
27014
  }
26985
- logger$3A.debug(`delete key: ${oldKey}`);
27015
+ logger$3B.debug(`delete key: ${oldKey}`);
26986
27016
  delta.delete.push(oldKey);
26987
27017
  }
26988
27018
  });
26989
27019
  const entries = Object.entries(data2);
26990
27020
  entries.forEach(([key, value]) => {
26991
- assert(logger$3A, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
27021
+ assert(logger$3B, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
26992
27022
  const oldValue = oldData[key];
26993
27023
  if (value === null || value === void 0) {
26994
27024
  if (oldValue !== null && oldValue !== void 0) {
26995
- logger$3A.debug(`delete key: ${key}`);
27025
+ logger$3B.debug(`delete key: ${key}`);
26996
27026
  delta.delete.push(key);
26997
27027
  }
26998
27028
  return;
@@ -27010,10 +27040,10 @@ var __publicField = (obj, key, value) => {
27010
27040
  }
27011
27041
  }
27012
27042
  if (oldKeys.has(key)) {
27013
- logger$3A.debug(`replace key: ${key}`);
27043
+ logger$3B.debug(`replace key: ${key}`);
27014
27044
  delta.delete.push(key);
27015
27045
  } else {
27016
- logger$3A.debug(`insert key: ${key}`);
27046
+ logger$3B.debug(`insert key: ${key}`);
27017
27047
  }
27018
27048
  delta.insert[key] = value;
27019
27049
  });
@@ -27058,13 +27088,13 @@ var __publicField = (obj, key, value) => {
27058
27088
  comments: {}
27059
27089
  };
27060
27090
  }
27061
- const logger$3z = getLogger("clone-block");
27091
+ const logger$3A = getLogger("clone-block");
27062
27092
  function cloneBlock(editorBlocks, oldDoc, data2, info) {
27063
27093
  var _a;
27064
27094
  const blockClass = editorBlocks.getBlockClass(data2.type);
27065
27095
  if (blockClass.blockToDoc) {
27066
27096
  return blockClass.blockToDoc(oldDoc, data2, (oldDoc2, childBlock) => {
27067
- assert(logger$3z, data2 !== childBlock, "invalid child block");
27097
+ assert(logger$3A, data2 !== childBlock, "invalid child block");
27068
27098
  return cloneBlock(editorBlocks, oldDoc2, data2, info);
27069
27099
  }, info);
27070
27100
  }
@@ -27077,7 +27107,7 @@ var __publicField = (obj, key, value) => {
27077
27107
  }
27078
27108
  const newChildContainerId = genId();
27079
27109
  const childBlocks = oldDoc.blocks[oldChildContainerId];
27080
- assert(logger$3z, Array.isArray(childBlocks), "invalid child blocks");
27110
+ assert(logger$3A, Array.isArray(childBlocks), "invalid child blocks");
27081
27111
  const newDocs = childBlocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
27082
27112
  const newDoc = mergeDocs(newDocs);
27083
27113
  const { root: root2, ...childContainersData } = newDoc.blocks;
@@ -27106,7 +27136,7 @@ var __publicField = (obj, key, value) => {
27106
27136
  if (key.startsWith(prefix1)) {
27107
27137
  const keyContent = key.substring(prefix1.length);
27108
27138
  const newKey = `${newContainerId}/${keyContent}`;
27109
- logger$3z.debug(`replace key: ${key} -> ${newKey}`);
27139
+ logger$3A.debug(`replace key: ${key} -> ${newKey}`);
27110
27140
  return newKey;
27111
27141
  }
27112
27142
  }
@@ -27115,7 +27145,7 @@ var __publicField = (obj, key, value) => {
27115
27145
  if (key.startsWith(prefix2)) {
27116
27146
  const keyContent = key.substring(prefix2.length);
27117
27147
  const newKey = `${newContainerId}_${keyContent}`;
27118
- logger$3z.debug(`replace key: ${key} -> ${newKey}`);
27148
+ logger$3A.debug(`replace key: ${key} -> ${newKey}`);
27119
27149
  return newKey;
27120
27150
  }
27121
27151
  }
@@ -27145,7 +27175,7 @@ var __publicField = (obj, key, value) => {
27145
27175
  }
27146
27176
  function cloneChildContainer(editorBlocks, oldDoc, containerId, info) {
27147
27177
  const blocks = oldDoc.blocks[containerId];
27148
- assert(logger$3z, Array.isArray(blocks), "invalid child blocks");
27178
+ assert(logger$3A, Array.isArray(blocks), "invalid child blocks");
27149
27179
  const newDocs = blocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
27150
27180
  const newDoc = mergeDocs(newDocs);
27151
27181
  return newDoc;
@@ -27154,10 +27184,10 @@ var __publicField = (obj, key, value) => {
27154
27184
  const docs = doc2.blocks.root.map((b) => cloneBlock(editor.editorBlocks, doc2, b, info));
27155
27185
  return cloneDeep__default.default(mergeDocs(docs));
27156
27186
  }
27157
- const logger$3y = getLogger("insert-doc");
27187
+ const logger$3z = getLogger("insert-doc");
27158
27188
  function editorInsertDoc(editor, block, offset, insertedDoc, cloneDocResult) {
27159
27189
  if (isComplexKindBlock(editor, block)) {
27160
- logger$3y.warn("failed to insert doc into a complex block");
27190
+ logger$3z.warn("failed to insert doc into a complex block");
27161
27191
  return;
27162
27192
  }
27163
27193
  const doc2 = cloneDoc(editor, insertedDoc, cloneDocResult);
@@ -27191,7 +27221,7 @@ var __publicField = (obj, key, value) => {
27191
27221
  }
27192
27222
  return;
27193
27223
  }
27194
- assert(logger$3y, isTextKindBlock(editor, block), "not a text block");
27224
+ assert(logger$3z, isTextKindBlock(editor, block), "not a text block");
27195
27225
  if (isEmptyTextBlock(editor, block)) {
27196
27226
  const blockIndex2 = getBlockIndex(block);
27197
27227
  let lastBlock22;
@@ -27323,11 +27353,11 @@ var __publicField = (obj, key, value) => {
27323
27353
  editor.deleteBlock(block);
27324
27354
  }
27325
27355
  }
27326
- const logger$3x = getLogger("add-text-attribute");
27356
+ const logger$3y = getLogger("add-text-attribute");
27327
27357
  function editorRemoveTextAttribute(editor, block, range, attributeName) {
27328
27358
  const { start, end } = range;
27329
- assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27330
- assert(logger$3x, attributeName, "invalid attribute name");
27359
+ assert(logger$3y, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27360
+ assert(logger$3y, attributeName, "invalid attribute name");
27331
27361
  const oldText = editor.getBlockText(block);
27332
27362
  const newText = rangeRemoveAttribute(start.offset, end.offset - start.offset, oldText, attributeName, void 0, { ignoreValue: true });
27333
27363
  editor.setBlockText(block, newText);
@@ -27335,8 +27365,8 @@ var __publicField = (obj, key, value) => {
27335
27365
  }
27336
27366
  function editorAddTextAttribute(editor, block, range, attributeName, value) {
27337
27367
  const { start, end } = range;
27338
- assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27339
- assert(logger$3x, attributeName, "invalid attribute name");
27368
+ assert(logger$3y, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27369
+ assert(logger$3y, attributeName, "invalid attribute name");
27340
27370
  const oldText = editor.getBlockText(block);
27341
27371
  const newText = rangeAddAttribute(start.offset, end.offset - start.offset, oldText, attributeName, value);
27342
27372
  editor.setBlockText(block, newText);
@@ -27344,7 +27374,7 @@ var __publicField = (obj, key, value) => {
27344
27374
  }
27345
27375
  function editorSetTextColor(editor, block, range, type, value) {
27346
27376
  const { start, end } = range;
27347
- assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27377
+ assert(logger$3y, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27348
27378
  const oldText = editor.getBlockText(block);
27349
27379
  const newText = rangeSetTextColor(start.offset, end.offset - start.offset, oldText, type, value);
27350
27380
  editor.setBlockText(block, newText);
@@ -27433,10 +27463,10 @@ var __publicField = (obj, key, value) => {
27433
27463
  });
27434
27464
  return [color, backgroundColor];
27435
27465
  }
27436
- const logger$3w = getLogger("move-complex-block-position");
27466
+ const logger$3x = getLogger("move-complex-block-position");
27437
27467
  function moveComplexBlockPosition(editor, old, type) {
27438
27468
  const block = editor.getBlockById(old.blockId);
27439
- assert(logger$3w, isComplexKindBlock(editor, block), "is not a complex block");
27469
+ assert(logger$3x, isComplexKindBlock(editor, block), "is not a complex block");
27440
27470
  const blockClass = getComplexBlockClass(editor, block);
27441
27471
  const focusedContainer = editor.getContainerById(old.childContainerId);
27442
27472
  const nextContainer = blockClass.getNextContainer(editor, block, focusedContainer, type, { noWrap: true });
@@ -27445,24 +27475,24 @@ var __publicField = (obj, key, value) => {
27445
27475
  }
27446
27476
  return createComplexBlockPosition(block, getContainerId(nextContainer));
27447
27477
  }
27448
- const logger$3v = getLogger("move-simple-block-position");
27478
+ const logger$3w = getLogger("move-simple-block-position");
27449
27479
  function getFirstChildBlockInComplexBlock(editor, complexBlock) {
27450
27480
  const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
27451
27481
  if (containers.length === 0) {
27452
- logger$3v.warn("complex block has not any child container, not loaded?");
27482
+ logger$3w.warn("complex block has not any child container, not loaded?");
27453
27483
  return null;
27454
27484
  }
27455
- assert(logger$3v, containers.length > 0, "complex block has not any child container");
27485
+ assert(logger$3w, containers.length > 0, "complex block has not any child container");
27456
27486
  const container = containers[0];
27457
27487
  return getFirstChildBlock(container);
27458
27488
  }
27459
27489
  function getLastChildBlockInComplexBlock(editor, complexBlock) {
27460
27490
  const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
27461
27491
  if (containers.length === 0) {
27462
- logger$3v.warn("complex block has not any child container, not loaded?");
27492
+ logger$3w.warn("complex block has not any child container, not loaded?");
27463
27493
  return null;
27464
27494
  }
27465
- assert(logger$3v, containers.length > 0, "complex block has not any child container");
27495
+ assert(logger$3w, containers.length > 0, "complex block has not any child container");
27466
27496
  const container = containers[containers.length - 1];
27467
27497
  return getLastChildBlock(container);
27468
27498
  }
@@ -27507,8 +27537,8 @@ var __publicField = (obj, key, value) => {
27507
27537
  return null;
27508
27538
  }
27509
27539
  const parentComplexBlock = getParentBlock(container);
27510
- assert(logger$3v, parentComplexBlock, "child container has not parent block");
27511
- assert(logger$3v, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
27540
+ assert(logger$3w, parentComplexBlock, "child container has not parent block");
27541
+ assert(logger$3w, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
27512
27542
  const nextContainer = getComplexBlockClass(editor, parentComplexBlock).getNextContainer(editor, parentComplexBlock, container, type);
27513
27543
  if (nextContainer) {
27514
27544
  if (isFindPrev(type)) {
@@ -27530,7 +27560,7 @@ var __publicField = (obj, key, value) => {
27530
27560
  return null;
27531
27561
  }
27532
27562
  const parentBlock = getParentBlock(container);
27533
- assert(logger$3v, parentBlock, "child container has not parent block");
27563
+ assert(logger$3w, parentBlock, "child container has not parent block");
27534
27564
  if (isFindPrev(type)) {
27535
27565
  const prev = getPrevBlock(parentBlock);
27536
27566
  if (prev) {
@@ -27585,7 +27615,7 @@ var __publicField = (obj, key, value) => {
27585
27615
  }
27586
27616
  if (!targetBlock) {
27587
27617
  if (isComplexKindBlock(editor, block) && complexBlockGetAllChildContainers(editor, block).length === 0) {
27588
- logger$3v.warn("complex block has not any child container, not loaded?");
27618
+ logger$3w.warn("complex block has not any child container, not loaded?");
27589
27619
  targetBlock = direction === "ArrowDown" || direction === "ArrowRight" ? getNextVisibleBlock(block) : getPrevVisibleBlock(block);
27590
27620
  }
27591
27621
  }
@@ -27732,10 +27762,10 @@ var __publicField = (obj, key, value) => {
27732
27762
  editorAdjustSelection(editor, "ArrowUp", "select");
27733
27763
  return true;
27734
27764
  }
27735
- const logger$3u = getLogger("word-offset");
27765
+ const logger$3v = getLogger("word-offset");
27736
27766
  function editorGetWordLeftPos(editor, type) {
27737
27767
  const old = editor.selection.range.focus;
27738
- assert(logger$3u, old.isSimple(), "invalid range type");
27768
+ assert(logger$3v, old.isSimple(), "invalid range type");
27739
27769
  const block = editor.getBlockById(old.blockId);
27740
27770
  if (isEmptyTextBlock(editor, block)) {
27741
27771
  return createSimpleBlockPosition(block, 0, "home");
@@ -27760,7 +27790,7 @@ var __publicField = (obj, key, value) => {
27760
27790
  }
27761
27791
  function editorGetWordRightPos(editor, type) {
27762
27792
  const old = editor.selection.range.focus;
27763
- assert(logger$3u, old.isSimple(), "invalid range type");
27793
+ assert(logger$3v, old.isSimple(), "invalid range type");
27764
27794
  const block = editor.getBlockById(old.blockId);
27765
27795
  if (isEmptyTextBlock(editor, block)) {
27766
27796
  return createSimpleBlockPosition(block, 0, "end");
@@ -27872,10 +27902,10 @@ var __publicField = (obj, key, value) => {
27872
27902
  editor.selection.setSelection(editor.selection.getAnchorPos(), pos);
27873
27903
  return true;
27874
27904
  }
27875
- const logger$3t = getLogger("line-offset");
27905
+ const logger$3u = getLogger("line-offset");
27876
27906
  function editorGetLineHomePos(editor) {
27877
27907
  const old = editor.selection.range.focus;
27878
- assert(logger$3t, old.isSimple(), "invalid range type");
27908
+ assert(logger$3u, old.isSimple(), "invalid range type");
27879
27909
  const block = editor.getBlockById(old.blockId);
27880
27910
  if (old.offset === 0 || !isTextKindBlock(editor, block)) {
27881
27911
  const newPos2 = createSimpleBlockPosition(block, 0, "home");
@@ -27892,7 +27922,7 @@ var __publicField = (obj, key, value) => {
27892
27922
  }
27893
27923
  function editorGetLineEndPos(editor) {
27894
27924
  const old = editor.selection.range.focus;
27895
- assert(logger$3t, old.isSimple(), "invalid range type");
27925
+ assert(logger$3u, old.isSimple(), "invalid range type");
27896
27926
  const block = editor.getBlockById(old.blockId);
27897
27927
  if (old.offset === getBlockTextLength$6(editor, block) || !isTextKindBlock(editor, block)) {
27898
27928
  const newPos2 = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
@@ -27992,7 +28022,7 @@ var __publicField = (obj, key, value) => {
27992
28022
  editorPageDownScroll(editor);
27993
28023
  return true;
27994
28024
  }
27995
- const logger$3s = getLogger("table-scroll");
28025
+ const logger$3t = getLogger("table-scroll");
27996
28026
  class DomEventHandler {
27997
28027
  constructor(editor, dom, name, handler, data2, options) {
27998
28028
  __publicField(this, "handleEvent", (event) => {
@@ -28024,7 +28054,7 @@ var __publicField = (obj, key, value) => {
28024
28054
  const existsHandlers = this.handlers.get(element);
28025
28055
  if (existsHandlers) {
28026
28056
  if (existsHandlers.find((handler) => handler.handler === eventHandler && handler.name === eventName)) {
28027
- logger$3s.warn(`event has already registered: ${eventName}`);
28057
+ logger$3t.warn(`event has already registered: ${eventName}`);
28028
28058
  return;
28029
28059
  }
28030
28060
  existsHandlers.push(new DomEventHandler(this.editor, element, eventName, eventHandler, data2, options));
@@ -28134,7 +28164,7 @@ var __publicField = (obj, key, value) => {
28134
28164
  });
28135
28165
  return true;
28136
28166
  }
28137
- const logger$3r = getLogger("select-all");
28167
+ const logger$3s = getLogger("select-all");
28138
28168
  function isContainerSelectedAllChildBlocks(container, range) {
28139
28169
  const firstBlock = getFirstChildBlock(container);
28140
28170
  const lastBlock2 = getLastChildBlock(container);
@@ -28149,8 +28179,8 @@ var __publicField = (obj, key, value) => {
28149
28179
  return range.start.blockId === blockId && range.start.childContainerId === getContainerId(first) && range.end.blockId === blockId && range.end.childContainerId === getContainerId(last);
28150
28180
  }
28151
28181
  function selectComplexBlock(editor, block) {
28152
- assert(logger$3r, block, "no parent block");
28153
- assert(logger$3r, isComplexKindBlock(editor, block), "not a complex block");
28182
+ assert(logger$3s, block, "no parent block");
28183
+ assert(logger$3s, isComplexKindBlock(editor, block), "not a complex block");
28154
28184
  const containers = getComplexBlockClass(editor, block).getChildContainers(editor, block);
28155
28185
  const first = containers[0];
28156
28186
  const last = containers[containers.length - 1];
@@ -28186,13 +28216,13 @@ var __publicField = (obj, key, value) => {
28186
28216
  selectParentContainer(editor, getFirstChildBlock(editor.rootContainer));
28187
28217
  return false;
28188
28218
  }
28189
- assert(logger$3r, !range.isSimple(), "invalid range type");
28219
+ assert(logger$3s, !range.isSimple(), "invalid range type");
28190
28220
  if (isComplexBlockSelectedAllChildContainer(focusedBlock, range)) {
28191
28221
  selectParentContainer(editor, focusedBlock);
28192
28222
  return false;
28193
28223
  }
28194
- assert(logger$3r, focusedBlock, "no parent block");
28195
- assert(logger$3r, isComplexKindBlock(editor, focusedBlock), "not a complex block");
28224
+ assert(logger$3s, focusedBlock, "no parent block");
28225
+ assert(logger$3s, isComplexKindBlock(editor, focusedBlock), "not a complex block");
28196
28226
  selectComplexBlock(editor, focusedBlock);
28197
28227
  return true;
28198
28228
  }
@@ -28228,6 +28258,30 @@ var __publicField = (obj, key, value) => {
28228
28258
  }
28229
28259
  editor.selection.setSelection(newStartPos, newEndPos);
28230
28260
  }
28261
+ function editorMoveBlockStart(editor) {
28262
+ const focus = editor.selection.range.focus;
28263
+ const block = editor.getBlockById(focus.blockId);
28264
+ if (!block)
28265
+ return false;
28266
+ if (!isSimpleBlock(editor, block))
28267
+ return false;
28268
+ const newPos = createSimpleBlockPosition(block, 0, "home");
28269
+ editor.selection.setSelection(newPos);
28270
+ editor.selection.updateLastCaretRect();
28271
+ return true;
28272
+ }
28273
+ function editorMoveBlockEnd(editor) {
28274
+ const focus = editor.selection.range.focus;
28275
+ const block = editor.getBlockById(focus.blockId);
28276
+ if (!block)
28277
+ return false;
28278
+ if (!isSimpleBlock(editor, block))
28279
+ return false;
28280
+ const newPos = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
28281
+ editor.selection.setSelection(newPos);
28282
+ editor.selection.updateLastCaretRect();
28283
+ return true;
28284
+ }
28231
28285
  function editorFocusToEnd(editor) {
28232
28286
  editorSelectEnd(editor);
28233
28287
  editor.focus();
@@ -28307,7 +28361,7 @@ var __publicField = (obj, key, value) => {
28307
28361
  }
28308
28362
  return cloned;
28309
28363
  }
28310
- const logger$3q = getLogger("selected-block-to-doc");
28364
+ const logger$3r = getLogger("selected-block-to-doc");
28311
28365
  function appendBlockChildren(editor, data2, doc2) {
28312
28366
  if (!data2.children)
28313
28367
  return;
@@ -28328,7 +28382,7 @@ var __publicField = (obj, key, value) => {
28328
28382
  if (isTextKindBlock(editor, selectedBlock.block)) {
28329
28383
  const start = selectedBlock.start;
28330
28384
  const end = selectedBlock.end;
28331
- assert(logger$3q, data2.text, "no block text");
28385
+ assert(logger$3r, data2.text, "no block text");
28332
28386
  if (start.offset === end.offset) {
28333
28387
  return {
28334
28388
  blocks: {
@@ -28362,8 +28416,8 @@ var __publicField = (obj, key, value) => {
28362
28416
  comments: {}
28363
28417
  };
28364
28418
  }
28365
- assert(logger$3q, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
28366
- assert(logger$3q, data2.children, "no children");
28419
+ assert(logger$3r, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
28420
+ assert(logger$3r, data2.children, "no children");
28367
28421
  const ret = {
28368
28422
  blocks: {
28369
28423
  root: [
@@ -28381,9 +28435,9 @@ var __publicField = (obj, key, value) => {
28381
28435
  const end = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
28382
28436
  return selectedBlockToDoc(editor, { block, start, end });
28383
28437
  }
28384
- const logger$3p = getLogger("block-to-doc");
28438
+ const logger$3q = getLogger("block-to-doc");
28385
28439
  function blocksToDoc(editor, blocks) {
28386
- assert(logger$3p, blocks.length > 0, "invalid params, no blocks");
28440
+ assert(logger$3q, blocks.length > 0, "invalid params, no blocks");
28387
28441
  const docs = blocks.map((b) => blockToDoc(editor, b));
28388
28442
  return mergeDocs(docs);
28389
28443
  }
@@ -28403,7 +28457,7 @@ var __publicField = (obj, key, value) => {
28403
28457
  const newDocs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s));
28404
28458
  return mergeDocs(newDocs);
28405
28459
  }
28406
- const logger$3o = getLogger("ensure-block-visible");
28460
+ const logger$3p = getLogger("ensure-block-visible");
28407
28461
  function ensureBlockVisible(editor, block) {
28408
28462
  var _a;
28409
28463
  while (block) {
@@ -28413,16 +28467,16 @@ var __publicField = (obj, key, value) => {
28413
28467
  return;
28414
28468
  }
28415
28469
  const parentComplexBlock = getParentBlock(container);
28416
- assert(logger$3o, parentComplexBlock, "no parent block");
28470
+ assert(logger$3p, parentComplexBlock, "no parent block");
28417
28471
  const parentComplexBlockClass = getBlockClass(editor, parentComplexBlock);
28418
28472
  if (parentComplexBlockClass.isChildContainerVisible && !((_a = parentComplexBlockClass.isChildContainerVisible) == null ? void 0 : _a.call(parentComplexBlockClass, editor, parentComplexBlock, container))) {
28419
- assert(logger$3o, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
28473
+ assert(logger$3p, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
28420
28474
  parentComplexBlockClass.showChildContainer(editor, parentComplexBlock, container);
28421
28475
  }
28422
28476
  block = parentComplexBlock;
28423
28477
  }
28424
28478
  }
28425
- const logger$3n = getLogger("editor-selection");
28479
+ const logger$3o = getLogger("editor-selection");
28426
28480
  class EditorSelection {
28427
28481
  constructor(editor) {
28428
28482
  __publicField(this, "editor");
@@ -28435,7 +28489,7 @@ var __publicField = (obj, key, value) => {
28435
28489
  }
28436
28490
  const range = this.range;
28437
28491
  if (rangeInBlock(deletedBlock, range)) {
28438
- logger$3n.debug("adjust selection because remote deleted current block");
28492
+ logger$3o.debug("adjust selection because remote deleted current block");
28439
28493
  const newRange = moveSelectionBeforeDeleteBlock(editor, deletedBlock);
28440
28494
  this.setRange(newRange, { noScroll: true });
28441
28495
  }
@@ -28560,14 +28614,14 @@ var __publicField = (obj, key, value) => {
28560
28614
  if (pos.isSimple()) {
28561
28615
  const ok = pos.offset >= 0 && pos.offset <= getBlockTextLength$6(this.editor, block);
28562
28616
  if (!ok) {
28563
- assert(logger$3n, false, "invalid block position, out of range");
28617
+ assert(logger$3o, false, "invalid block position, out of range");
28564
28618
  }
28565
28619
  } else {
28566
28620
  const childContainerId = pos.childContainerId;
28567
28621
  const container = this.editor.getContainerById(childContainerId);
28568
28622
  const ok = !!container;
28569
28623
  if (!ok) {
28570
- assert(logger$3n, false, "invalid complex block position, no container found");
28624
+ assert(logger$3o, false, "invalid complex block position, no container found");
28571
28625
  }
28572
28626
  }
28573
28627
  }
@@ -28628,7 +28682,7 @@ var __publicField = (obj, key, value) => {
28628
28682
  let container = getParentContainer(block);
28629
28683
  while (isChildContainer(container)) {
28630
28684
  const parentBlock = getParentBlock(container);
28631
- assert(logger$3n, parentBlock, "parent block not found");
28685
+ assert(logger$3o, parentBlock, "parent block not found");
28632
28686
  addClass(parentBlock, "child-focused");
28633
28687
  container = getParentContainer(parentBlock);
28634
28688
  }
@@ -28738,15 +28792,15 @@ var __publicField = (obj, key, value) => {
28738
28792
  editor.undoManager.redo();
28739
28793
  return true;
28740
28794
  }
28741
- const logger$3m = getLogger("delete-text");
28795
+ const logger$3n = getLogger("delete-text");
28742
28796
  function editorDeleteText(editor, type, count, insertPos) {
28743
28797
  const pos = insertPos != null ? insertPos : editor.selection.range.start;
28744
28798
  if (!(pos instanceof EditorSimpleBlockPosition)) {
28745
- assert(logger$3m, false, `invalid insert pos type: ${typeof pos}`);
28799
+ assert(logger$3n, false, `invalid insert pos type: ${typeof pos}`);
28746
28800
  }
28747
28801
  const { blockId } = pos;
28748
28802
  const block = editor.getBlockById(blockId);
28749
- assert(logger$3m, isTextKindBlock(editor, block), "block is not a text kind block");
28803
+ assert(logger$3n, isTextKindBlock(editor, block), "block is not a text kind block");
28750
28804
  let { offset } = pos;
28751
28805
  if (type === "backward") {
28752
28806
  if (offset - count < 0) {
@@ -28776,7 +28830,7 @@ var __publicField = (obj, key, value) => {
28776
28830
  }
28777
28831
  return false;
28778
28832
  }
28779
- const logger$3l = getLogger("handle-backspace");
28833
+ const logger$3m = getLogger("handle-backspace");
28780
28834
  function tryDeleteEmptyBlock(editor, block) {
28781
28835
  if (!isEmptyTextBlock(editor, block)) {
28782
28836
  return;
@@ -28816,7 +28870,7 @@ var __publicField = (obj, key, value) => {
28816
28870
  }
28817
28871
  } else {
28818
28872
  tryDeleteEmptyBlock(editor, block);
28819
- assert(logger$3l, isEmbedBlock(prevBlock), "prev block is not embed block");
28873
+ assert(logger$3m, isEmbedBlock(prevBlock), "prev block is not embed block");
28820
28874
  editor.selection.selectBlock(prevBlock, 1);
28821
28875
  }
28822
28876
  } else {
@@ -28843,6 +28897,7 @@ var __publicField = (obj, key, value) => {
28843
28897
  editor.deleteBlock(block);
28844
28898
  }
28845
28899
  }
28900
+ const logger$3l = getLogger("word-offset");
28846
28901
  function handleEditorDelete(editor, event) {
28847
28902
  if (!editor.selection.range.isCollapsed()) {
28848
28903
  editor.clearSelectedContents();
@@ -28877,6 +28932,130 @@ var __publicField = (obj, key, value) => {
28877
28932
  editor.deleteBlock(block);
28878
28933
  }
28879
28934
  }
28935
+ function handleEditorDeleteLeftWord(editor, event) {
28936
+ const old = editor.selection.range.focus;
28937
+ assert(logger$3l, old.isSimple(), "invalid range type");
28938
+ const block = editor.getBlockById(old.blockId);
28939
+ if (!isTextKindBlock(editor, block)) {
28940
+ editor.deleteBlock(block);
28941
+ return true;
28942
+ }
28943
+ if (old.offset === 0) {
28944
+ const matchNonEmptyTextBlockOrOtherBlock = (block2) => {
28945
+ if (!isTextKindBlock(editor, block2))
28946
+ return true;
28947
+ return !isEmptyTextBlock(editor, block2);
28948
+ };
28949
+ const prevBlock = getPrevVisibleBlock(block, matchNonEmptyTextBlockOrOtherBlock);
28950
+ if (!prevBlock)
28951
+ return false;
28952
+ const matchEmptyTextBlock = (block2) => isEmptyTextBlock(editor, block2);
28953
+ const emptyTextBlocks = getBlocksBetween(prevBlock, block, matchEmptyTextBlock);
28954
+ emptyTextBlocks.forEach((b) => {
28955
+ editor.deleteBlock(b);
28956
+ });
28957
+ if (!isTextKindBlock(editor, prevBlock)) {
28958
+ editor.deleteBlock(prevBlock);
28959
+ return true;
28960
+ }
28961
+ const textBlockLen = getBlockTextLength$6(editor, prevBlock);
28962
+ const newOffset2 = findWordLeft(editor, prevBlock, textBlockLen);
28963
+ editor.deleteTextFromBlock(prevBlock, newOffset2, textBlockLen - newOffset2);
28964
+ const currentBlockText = editor.getBlockText(block);
28965
+ editor.insertTextToBlock(prevBlock, newOffset2, currentBlockText);
28966
+ editor.deleteBlock(block);
28967
+ const pos = createSimpleBlockPosition(prevBlock, newOffset2, "normal");
28968
+ editor.selection.setSelection(pos);
28969
+ editor.selection.updateLastCaretRect();
28970
+ return true;
28971
+ }
28972
+ const newOffset = findWordLeft(editor, block, old.offset);
28973
+ const deletedCount = old.offset - newOffset;
28974
+ editor.deleteTextFromBlock(block, newOffset, deletedCount);
28975
+ return true;
28976
+ }
28977
+ function handleEditorDeleteRightWord(editor, event) {
28978
+ const old = editor.selection.range.focus;
28979
+ assert(logger$3l, old.isSimple(), "invalid range type");
28980
+ const block = editor.getBlockById(old.blockId);
28981
+ if (!isTextKindBlock(editor, block)) {
28982
+ editor.deleteBlock(block);
28983
+ return true;
28984
+ }
28985
+ if (old.offset === getTextBlockLength(block)) {
28986
+ const matchNonEmptyTextBlockOrOtherBlock = (block2) => {
28987
+ if (!isTextKindBlock(editor, block2))
28988
+ return true;
28989
+ return !isEmptyTextBlock(editor, block2);
28990
+ };
28991
+ const nextBlock = getNextVisibleBlock(block, matchNonEmptyTextBlockOrOtherBlock);
28992
+ if (!nextBlock)
28993
+ return false;
28994
+ const matchEmptyTextBlock = (block2) => isEmptyTextBlock(editor, block2);
28995
+ const emptyTextBlocks = getBlocksBetween(block, nextBlock, matchEmptyTextBlock);
28996
+ emptyTextBlocks.forEach((b) => {
28997
+ editor.deleteBlock(b);
28998
+ });
28999
+ if (!isTextKindBlock(editor, nextBlock)) {
29000
+ editor.deleteBlock(nextBlock);
29001
+ return true;
29002
+ }
29003
+ const newOffset = findWordEnd(editor, nextBlock, 0);
29004
+ editor.deleteTextFromBlock(nextBlock, 0, newOffset);
29005
+ const nextBlockText = editor.getBlockText(nextBlock);
29006
+ editor.insertTextToBlock(block, old.offset, nextBlockText);
29007
+ editor.deleteBlock(nextBlock);
29008
+ const pos = createSimpleBlockPosition(block, old.offset, "normal");
29009
+ editor.selection.setSelection(pos);
29010
+ editor.selection.updateLastCaretRect();
29011
+ return true;
29012
+ }
29013
+ const endOffset = findWordEnd(editor, block, old.offset);
29014
+ const deletedCount = endOffset - old.offset;
29015
+ editor.deleteTextFromBlock(block, old.offset, deletedCount);
29016
+ return true;
29017
+ }
29018
+ function handleEditorDeleteAfterWords(editor) {
29019
+ const old = editor.selection.range.focus;
29020
+ assert(logger$3l, old.isSimple(), "invalid range type");
29021
+ const block = editor.getBlockById(old.blockId);
29022
+ if (!isTextKindBlock(editor, block)) {
29023
+ editor.deleteBlock(block);
29024
+ return;
29025
+ }
29026
+ const needDeleteCount = getTextBlockLength(block) - old.offset;
29027
+ if (needDeleteCount === 0)
29028
+ return;
29029
+ editor.deleteTextFromBlock(block, old.offset, needDeleteCount);
29030
+ }
29031
+ function handleEditorDeleteRightChar(editor) {
29032
+ const old = editor.selection.range.focus;
29033
+ assert(logger$3l, old.isSimple(), "invalid range type");
29034
+ const block = editor.getBlockById(old.blockId);
29035
+ if (!isTextKindBlock(editor, block)) {
29036
+ editor.deleteBlock(block);
29037
+ return;
29038
+ }
29039
+ if (old.offset === getBlockTextLength$6(editor, block)) {
29040
+ const nextVisibleBlock = getNextVisibleBlock(block);
29041
+ if (!nextVisibleBlock)
29042
+ return;
29043
+ if (!isTextKindBlock(editor, nextVisibleBlock))
29044
+ return;
29045
+ if (isEmptyTextBlock(editor, nextVisibleBlock)) {
29046
+ editor.deleteBlock(nextVisibleBlock);
29047
+ return;
29048
+ }
29049
+ const nextBlockText = editor.getBlockText(nextVisibleBlock);
29050
+ editor.deleteBlock(nextVisibleBlock);
29051
+ editor.insertTextToBlock(block, old.offset, nextBlockText);
29052
+ const pos = createSimpleBlockPosition(block, old.offset, "normal");
29053
+ editor.selection.setSelection(pos);
29054
+ editor.selection.updateLastCaretRect();
29055
+ return;
29056
+ }
29057
+ editorDeleteText(editor, "forward", 1, null);
29058
+ }
28880
29059
  function handleEditorEnterEvent$1(editor, event) {
28881
29060
  if (isFullSelectedOneComplexBlock(editor)) {
28882
29061
  const focusedBlock2 = editor.getFocusedBlock();
@@ -29098,6 +29277,42 @@ var __publicField = (obj, key, value) => {
29098
29277
  return true;
29099
29278
  });
29100
29279
  }
29280
+ function editorHandleDeleteLeftWord(editor, event) {
29281
+ if (editor.readonly || !editor.isWritable()) {
29282
+ return false;
29283
+ }
29284
+ return editor.undoManager.runInGroup(() => {
29285
+ handleEditorDeleteLeftWord(editor);
29286
+ return true;
29287
+ });
29288
+ }
29289
+ function editorHandleDeleteRightWord(editor, event) {
29290
+ if (editor.readonly || !editor.isWritable()) {
29291
+ return false;
29292
+ }
29293
+ return editor.undoManager.runInGroup(() => {
29294
+ handleEditorDeleteRightWord(editor);
29295
+ return true;
29296
+ });
29297
+ }
29298
+ function editorHandleDeleteAfterWords(editor, event) {
29299
+ if (editor.readonly || !editor.isWritable()) {
29300
+ return false;
29301
+ }
29302
+ return editor.undoManager.runInGroup(() => {
29303
+ handleEditorDeleteAfterWords(editor);
29304
+ return true;
29305
+ });
29306
+ }
29307
+ function editorHandleDeleteRightChar(editor, event) {
29308
+ if (editor.readonly || !editor.isWritable()) {
29309
+ return false;
29310
+ }
29311
+ return editor.undoManager.runInGroup(() => {
29312
+ handleEditorDeleteRightChar(editor);
29313
+ return true;
29314
+ });
29315
+ }
29101
29316
  function editorHandleBackspace(editor, event) {
29102
29317
  if (editor.readonly || !editor.isWritable()) {
29103
29318
  return false;
@@ -29191,6 +29406,10 @@ ${codeText}
29191
29406
  __proto__: null,
29192
29407
  editorHandleEnter,
29193
29408
  editorHandleDelete,
29409
+ editorHandleDeleteLeftWord,
29410
+ editorHandleDeleteRightWord,
29411
+ editorHandleDeleteAfterWords,
29412
+ editorHandleDeleteRightChar,
29194
29413
  editorHandleBackspace,
29195
29414
  editorHandleInsertBr,
29196
29415
  editorHandlePastePlainText,
@@ -29198,6 +29417,41 @@ ${codeText}
29198
29417
  getSelectedCodeBlockMarkdown,
29199
29418
  editorHandleCopyMarkdown
29200
29419
  }, Symbol.toStringTag, { value: "Module" }));
29420
+ const MacShortcuts = {
29421
+ "Cmd+ArrowLeft": editorMoveLineHome,
29422
+ "Cmd+ArrowRight": editorMoveLineEnd,
29423
+ "Option+ArrowLeft": editorMoveWordLeft,
29424
+ "Option+ArrowRight": editorMoveWordEnd,
29425
+ "Option+Shift+ArrowLeft": editorSelectWordLeft,
29426
+ "Option+Shift+ArrowRight": editorSelectWordEnd,
29427
+ "Cmd+Shift+ArrowLeft": editorSelectLineHome,
29428
+ "Cmd+Shift+ArrowRight": editorSelectLineEnd,
29429
+ "Ctrl+A": editorMoveBlockStart,
29430
+ "Ctrl+E": editorMoveBlockEnd,
29431
+ "Option+Delete": editorHandleDeleteRightWord,
29432
+ "Option+Backspace": editorHandleDeleteLeftWord,
29433
+ "Ctrl+B": editorMoveLeft,
29434
+ "Ctrl+F": editorMoveRight,
29435
+ "Ctrl+N": editorMoveDown,
29436
+ "Ctrl+P": editorMoveUp,
29437
+ "Ctrl+K": editorHandleDeleteAfterWords,
29438
+ "Ctrl+H": editorHandleBackspace,
29439
+ "Ctrl+D": editorHandleDeleteRightChar
29440
+ };
29441
+ const WinLinuxShortcuts = {
29442
+ "Home": editorMoveLineHome,
29443
+ "End": editorMoveLineEnd,
29444
+ "Shift+Home": editorSelectLineHome,
29445
+ "Shift+End": editorSelectLineEnd,
29446
+ "Ctrl+Delete": editorHandleDeleteRightWord,
29447
+ "Ctrl+Backspace": editorHandleDeleteLeftWord,
29448
+ "Ctrl+ArrowLeft": editorMoveWordLeft,
29449
+ "Ctrl+ArrowRight": editorMoveWordEnd,
29450
+ "Ctrl+Shift+ArrowLeft": editorSelectWordLeft,
29451
+ "Ctrl+Shift+ArrowRight": editorSelectWordEnd
29452
+ };
29453
+ const isMac = clientType.isMac;
29454
+ const CustomShortcuts = isMac ? MacShortcuts : WinLinuxShortcuts;
29201
29455
  const DefaultShortcuts = {
29202
29456
  "ArrowDown": editorMoveDown,
29203
29457
  "ArrowUp": editorMoveUp,
@@ -29207,19 +29461,11 @@ ${codeText}
29207
29461
  "Shift+ArrowUp": editorSelectUp,
29208
29462
  "Shift+ArrowLeft": editorSelectLeft,
29209
29463
  "Shift+ArrowRight": editorSelectRight,
29210
- "CtrlOrCmd+ArrowLeft": editorMoveWordLeft,
29211
- "CtrlOrCmd+ArrowRight": editorMoveWordEnd,
29212
- "CtrlOrCmd+Shift+ArrowLeft": editorSelectWordLeft,
29213
- "CtrlOrCmd+Shift+ArrowRight": editorSelectWordEnd,
29214
29464
  "CtrlOrCmd+ArrowUp": editorMoveHome,
29215
29465
  "CtrlOrCmd+ArrowDown": editorMoveEnd,
29216
29466
  "CtrlOrCmd+Shift+ArrowUp": editorSelectHome,
29217
29467
  "CtrlOrCmd+Shift+ArrowDown": editorSelectEnd,
29218
29468
  "CtrlOrCmd+A": editorSelectAll,
29219
- "Home": editorMoveLineHome,
29220
- "End": editorMoveLineEnd,
29221
- "Shift+Home": editorSelectLineHome,
29222
- "Shift+End": editorSelectLineEnd,
29223
29469
  "PageUp": editorMovePageUp,
29224
29470
  "PageDown": editorMovePageDown,
29225
29471
  "Shift+PageUp": editorSelectPageUp,
@@ -29231,7 +29477,8 @@ ${codeText}
29231
29477
  "Backspace": editorHandleBackspace,
29232
29478
  "Shift+Enter": editorHandleInsertBr,
29233
29479
  "CtrlOrCmd+Shift+V": editorHandlePastePlainText,
29234
- "CtrlOrCmd+Shift+C": editorHandleCopyMarkdown
29480
+ "CtrlOrCmd+Shift+C": editorHandleCopyMarkdown,
29481
+ ...CustomShortcuts
29235
29482
  };
29236
29483
  function editorHandleKeyboardEvent(editor, event) {
29237
29484
  const result = editor.shortcuts.handleKeyboardEvents(editor, event);
@@ -43009,8 +43256,21 @@ ${codeText}
43009
43256
  const textColorItem = "";
43010
43257
  const DEFAULT_BG_COLOR = 2;
43011
43258
  const NULLABLE_COLOR = -1;
43259
+ const STORAGE_NAME = "color-item";
43260
+ function getColorsFromLocalStorage(editor) {
43261
+ const colors = [null, null];
43262
+ const color = Number.parseInt(editor.settingsProvider.getItem(`${STORAGE_NAME}-color`) || "", 10);
43263
+ const backgroundColor = Number.parseInt(editor.settingsProvider.getItem(`${STORAGE_NAME}-backgroundColor`) || `${DEFAULT_BG_COLOR}`, 10);
43264
+ if (!Number.isNaN(color)) {
43265
+ colors[0] = color;
43266
+ }
43267
+ if (!Number.isNaN(backgroundColor)) {
43268
+ colors[1] = backgroundColor;
43269
+ }
43270
+ return colors;
43271
+ }
43012
43272
  class TextColorItem extends tinyTypedEmitter.TypedEmitter {
43013
- constructor(editor, storageName = "color-item") {
43273
+ constructor(editor, storageName = STORAGE_NAME) {
43014
43274
  super();
43015
43275
  __publicField(this, "id", "text-color-item");
43016
43276
  __publicField(this, "name", i18n$1.t("colorPalette.name"));
@@ -50705,7 +50965,7 @@ ${codeText}
50705
50965
  }
50706
50966
  return handleDragList(editor, draggedBlock, targetBlock, insertPos);
50707
50967
  }
50708
- function executeShortcut$1(editor, type) {
50968
+ function executeShortcut$3(editor, type) {
50709
50969
  if (!editor.isWritable()) {
50710
50970
  return false;
50711
50971
  }
@@ -50719,8 +50979,8 @@ ${codeText}
50719
50979
  return true;
50720
50980
  }
50721
50981
  const ListBlockShortcuts = {
50722
- "Shift+CtrlOrCmd+L": (editor) => executeShortcut$1(editor, "ordered-list"),
50723
- "Shift+CtrlOrCmd+U": (editor) => executeShortcut$1(editor, "unordered-list")
50982
+ "Shift+CtrlOrCmd+L": (editor) => executeShortcut$3(editor, "ordered-list"),
50983
+ "Shift+CtrlOrCmd+U": (editor) => executeShortcut$3(editor, "unordered-list")
50724
50984
  };
50725
50985
  function getBlockPadding$1(block) {
50726
50986
  const padding = block.getAttribute("block-padding-level");
@@ -61230,6 +61490,31 @@ $$${mathData.mathjaxText}$$
61230
61490
  return editor.addCustom("overflow-tooltip-helper", () => new OverflowTooltipHelper(editor));
61231
61491
  }
61232
61492
  }
61493
+ function executeShortcut$2(editor, style2) {
61494
+ if (!editor.isWritable()) {
61495
+ return false;
61496
+ }
61497
+ const range = editor.selection.range;
61498
+ const allCommands = editor.editorCommandProviders.getCommands(range);
61499
+ const alignCommands = allCommands.flatMap((command2) => {
61500
+ if (command2.id === "align") {
61501
+ return command2.children;
61502
+ }
61503
+ return [];
61504
+ });
61505
+ const command = alignCommands.find((c) => c.id === `align-${style2}`);
61506
+ if (!command) {
61507
+ return false;
61508
+ }
61509
+ editor.editorCommandProviders.executeCommand(range, command, {});
61510
+ OnesEditorToolbar.get(editor).update("selectionChange");
61511
+ return true;
61512
+ }
61513
+ const AlignShortcuts = {
61514
+ "CtrlOrCmd+Shift+E": (editor) => executeShortcut$2(editor, "center"),
61515
+ "CtrlOrCmd+Shift+O": (editor) => executeShortcut$2(editor, "left"),
61516
+ "CtrlOrCmd+Shift+R": (editor) => executeShortcut$2(editor, "right")
61517
+ };
61233
61518
  const TextCommands = {
61234
61519
  "text/style-bold": "bold",
61235
61520
  "text/style-italic": "italic",
@@ -61245,7 +61530,7 @@ $$${mathData.mathjaxText}$$
61245
61530
  const styleCommands = blockCommands.filter((command) => styleCommandsSet.has(command.id));
61246
61531
  return styleCommands;
61247
61532
  }
61248
- function executeShortcut(editor, style2) {
61533
+ function executeShortcut$1(editor, style2) {
61249
61534
  if (!editor.isWritable()) {
61250
61535
  return false;
61251
61536
  }
@@ -61290,13 +61575,37 @@ $$${mathData.mathjaxText}$$
61290
61575
  return shortcuts2;
61291
61576
  };
61292
61577
  const TextStyleShortcuts = {
61293
- "CtrlOrCmd+B": (editor) => executeShortcut(editor, "style-bold"),
61294
- "CtrlOrCmd+I": (editor) => executeShortcut(editor, "style-italic"),
61295
- "CtrlOrCmd+U": (editor) => executeShortcut(editor, "style-underline"),
61296
- "CtrlOrCmd+D": (editor) => executeShortcut(editor, "style-strikethrough"),
61297
- "CtrlOrCmd+K": (editor) => executeShortcut(editor, "link"),
61578
+ "CtrlOrCmd+B": (editor) => executeShortcut$1(editor, "style-bold"),
61579
+ "CtrlOrCmd+I": (editor) => executeShortcut$1(editor, "style-italic"),
61580
+ "CtrlOrCmd+U": (editor) => executeShortcut$1(editor, "style-underline"),
61581
+ "CtrlOrCmd+D": (editor) => executeShortcut$1(editor, "style-strikethrough"),
61582
+ "CtrlOrCmd+K": (editor) => executeShortcut$1(editor, "link"),
61298
61583
  ...headingShortcut()
61299
61584
  };
61585
+ function executeShortcut(editor) {
61586
+ if (!editor.isWritable()) {
61587
+ return false;
61588
+ }
61589
+ const range = editor.selection.range;
61590
+ if (range.isCollapsed()) {
61591
+ return false;
61592
+ }
61593
+ editor.undoManager.runInGroup(() => {
61594
+ const colors = getColorsFromLocalStorage(editor);
61595
+ colors.forEach((color, idx) => {
61596
+ if (color === null) {
61597
+ return;
61598
+ }
61599
+ const type = idx === 0 ? "color" : "backgroundColor";
61600
+ editorRangeSetColor(editor, type, color, () => {
61601
+ });
61602
+ });
61603
+ });
61604
+ return true;
61605
+ }
61606
+ const TextColorShortcuts = {
61607
+ "CtrlOrCmd+Alt+KeyH": (editor) => executeShortcut(editor)
61608
+ };
61300
61609
  const zhCN$p = {
61301
61610
  quickMenu: {
61302
61611
  basic: {
@@ -62055,7 +62364,7 @@ $$${mathData.mathjaxText}$$
62055
62364
  __publicField(this, "updateButtonColor", (range) => {
62056
62365
  const currentTextColor = editorRangeGetColor(this.editor, range, this.getEmptyTextBlockColor);
62057
62366
  this.colorItem.setCurrentTextColors(currentTextColor);
62058
- const lastButtonColor = this.colorItem.getColorsFromLocalStorage();
62367
+ const lastButtonColor = getColorsFromLocalStorage(this.editor);
62059
62368
  this.colorItem.setCurrentButtonColor(lastButtonColor);
62060
62369
  });
62061
62370
  __publicField(this, "setActiveAttribute", (type, value) => {
@@ -73677,8 +73986,6 @@ ${codeText}
73677
73986
  });
73678
73987
  }
73679
73988
  const StyleTags = {
73680
- i: "style-italic",
73681
- b: "style-bold",
73682
73989
  u: "style-underline",
73683
73990
  strong: "style-bold",
73684
73991
  em: "style-italic",
@@ -73832,18 +74139,6 @@ ${codeText}
73832
74139
  }
73833
74140
  if (token.type === "html") {
73834
74141
  const html = token.text;
73835
- const testBr = html.trim().toLowerCase();
73836
- if (testBr === "<br>" || testBr === "<br/>" || testBr === "<br />") {
73837
- return [{
73838
- insert: " ",
73839
- attributes: {
73840
- id: genId(),
73841
- created: Date.now(),
73842
- box: true,
73843
- type: "br"
73844
- }
73845
- }];
73846
- }
73847
74142
  applyHtmlToText(html, attributes);
73848
74143
  applyColorTagToText(html, attributes);
73849
74144
  applyFontSizeTagToText(html, attributes);
@@ -73878,22 +74173,6 @@ ${codeText}
73878
74173
  }
73879
74174
  }];
73880
74175
  }
73881
- if (token.type === "image") {
73882
- const href = token.href || "";
73883
- if (href) {
73884
- const boxData = {
73885
- id: genId(),
73886
- created: Date.now(),
73887
- box: true,
73888
- type: "image",
73889
- src: href
73890
- };
73891
- return [{
73892
- insert: " ",
73893
- attributes: boxData
73894
- }];
73895
- }
73896
- }
73897
74176
  logger$Q.warn(`unknown token in text: ${JSON.stringify(token)}`);
73898
74177
  return [];
73899
74178
  });
@@ -75556,8 +75835,8 @@ ${content}
75556
75835
  const container = document.createElement("div");
75557
75836
  container.classList.add("highlight-text-wizdoc");
75558
75837
  const code = document.createElement("pre");
75559
- code.textContent = base64;
75560
75838
  container.appendChild(code);
75839
+ code.innerText = base64;
75561
75840
  node.insertAdjacentElement("beforebegin", container);
75562
75841
  node.remove();
75563
75842
  return;
@@ -91940,9 +92219,11 @@ ${data2.plantumlText}
91940
92219
  FindReplaceShortcuts,
91941
92220
  BlockPaddingShortcuts,
91942
92221
  TextStyleShortcuts,
92222
+ AlignShortcuts,
91943
92223
  AutoLinkShortcuts,
91944
92224
  DefaultShortcuts,
91945
92225
  ListBlockShortcuts,
92226
+ TextColorShortcuts,
91946
92227
  ...options.shortcuts || []
91947
92228
  ],
91948
92229
  colors: [
@@ -92151,7 +92432,7 @@ ${data2.plantumlText}
92151
92432
  }
92152
92433
  }
92153
92434
  });
92154
- editor.version = "2.5.1-beta.6";
92435
+ editor.version = "2.6.1-beta.2";
92155
92436
  return editor;
92156
92437
  }
92157
92438
  function isDoc(doc2) {
@@ -92264,7 +92545,7 @@ ${data2.plantumlText}
92264
92545
  }
92265
92546
  });
92266
92547
  OnesEditorToolbar.register(editor);
92267
- editor.version = "2.5.1-beta.6";
92548
+ editor.version = "2.6.1-beta.2";
92268
92549
  return editor;
92269
92550
  }
92270
92551
  async function showDocVersions(editor, options, serverUrl) {
@@ -138050,6 +138331,7 @@ ${data2.plantumlText}
138050
138331
  exports2.AlignProvider = AlignProvider;
138051
138332
  exports2.AlignRightIcon = AlignRightIcon;
138052
138333
  exports2.AlignRightItem = AlignRightItem;
138334
+ exports2.AlignShortcuts = AlignShortcuts;
138053
138335
  exports2.AnchorBox = AnchorBox;
138054
138336
  exports2.ArrowDownIcon = ArrowDownIcon$1;
138055
138337
  exports2.ArrowLeftIcon = arrowLeft;
@@ -138306,6 +138588,7 @@ ${data2.plantumlText}
138306
138588
  exports2.TextBox = TextBox;
138307
138589
  exports2.TextColorIcon = TextColorIcon;
138308
138590
  exports2.TextColorItem = TextColorItem;
138591
+ exports2.TextColorShortcuts = TextColorShortcuts;
138309
138592
  exports2.TextCommandProvider = TextCommandProvider;
138310
138593
  exports2.TextGroupIcon = TextGroupIcon;
138311
138594
  exports2.TextIcon = TextIcon;
@@ -138475,6 +138758,8 @@ ${data2.plantumlText}
138475
138758
  exports2.editorInsertTextToBlock = editorInsertTextToBlock;
138476
138759
  exports2.editorInsertTextToBlockEx = editorInsertTextToBlockEx;
138477
138760
  exports2.editorMergeTextBlock = editorMergeTextBlock;
138761
+ exports2.editorMoveBlockEnd = editorMoveBlockEnd;
138762
+ exports2.editorMoveBlockStart = editorMoveBlockStart;
138478
138763
  exports2.editorMoveDown = editorMoveDown;
138479
138764
  exports2.editorMoveEnd = editorMoveEnd;
138480
138765
  exports2.editorMoveHome = editorMoveHome;
@@ -138579,6 +138864,7 @@ ${data2.plantumlText}
138579
138864
  exports2.getBlockTextLength = getBlockTextLength$6;
138580
138865
  exports2.getBlockTools = getBlockTools;
138581
138866
  exports2.getBlockType = getBlockType;
138867
+ exports2.getBlocksBetween = getBlocksBetween;
138582
138868
  exports2.getBlocksWidth = getBlocksWidth;
138583
138869
  exports2.getBoxContent = getBoxContent;
138584
138870
  exports2.getBoxId = getBoxId;
@@ -138591,6 +138877,7 @@ ${data2.plantumlText}
138591
138877
  exports2.getClosestContainerByCondition = getClosestContainerByCondition;
138592
138878
  exports2.getColorFromAttributes = getColorFromAttributes;
138593
138879
  exports2.getColorFromContent = getColorFromContent;
138880
+ exports2.getColorsFromLocalStorage = getColorsFromLocalStorage;
138594
138881
  exports2.getComplexBlockClass = getComplexBlockClass;
138595
138882
  exports2.getContainerBlockOverrideOptions = getContainerBlockOverrideOptions;
138596
138883
  exports2.getContainerBlockPath = getContainerBlockPath;
@@ -138693,6 +138980,7 @@ ${data2.plantumlText}
138693
138980
  exports2.isBox = isBox;
138694
138981
  exports2.isBoxOp = isBoxOp;
138695
138982
  exports2.isCJK = isCJK;
138983
+ exports2.isCJKPunctuation = isCJKPunctuation;
138696
138984
  exports2.isChildContainer = isChildContainer;
138697
138985
  exports2.isChildNode = isChildNode;
138698
138986
  exports2.isClipboardEmpty = isClipboardEmpty$1;
@@ -138765,7 +139053,7 @@ ${data2.plantumlText}
138765
139053
  exports2.loadJs = loadJs;
138766
139054
  exports2.loadJsPromise = loadJsPromise;
138767
139055
  exports2.lockers = lockers;
138768
- exports2.logger = logger$4p;
139056
+ exports2.logger = logger$4q;
138769
139057
  exports2.markdownToDoc = markdownToDoc;
138770
139058
  exports2.mergeCommands = mergeCommands;
138771
139059
  exports2.mergeDocs = mergeDocs;