@ones-editor/editor 2.7.1-beta.1 → 2.8.0

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 (62) 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/server-tools/package.json +22 -0
  10. package/@ones-editor/server-tools/src/fake-browser.d.ts +1 -0
  11. package/@ones-editor/server-tools/src/from-markdown/index.d.ts +1 -0
  12. package/@ones-editor/server-tools/src/index.d.ts +2 -0
  13. package/@ones-editor/server-tools/src/to-markdown/blocks/code.d.ts +3 -0
  14. package/@ones-editor/server-tools/src/to-markdown/blocks/index.d.ts +12 -0
  15. package/@ones-editor/server-tools/src/to-markdown/blocks/list.d.ts +14 -0
  16. package/@ones-editor/server-tools/src/to-markdown/blocks/table.d.ts +3 -0
  17. package/@ones-editor/server-tools/src/to-markdown/blocks/text.d.ts +4 -0
  18. package/@ones-editor/server-tools/src/to-markdown/boxes/br.d.ts +1 -0
  19. package/@ones-editor/server-tools/src/to-markdown/boxes/date.d.ts +2 -0
  20. package/@ones-editor/server-tools/src/to-markdown/boxes/file.d.ts +11 -0
  21. package/@ones-editor/server-tools/src/to-markdown/boxes/image.d.ts +5 -0
  22. package/@ones-editor/server-tools/src/to-markdown/boxes/index.d.ts +18 -0
  23. package/@ones-editor/server-tools/src/to-markdown/boxes/known-link.d.ts +11 -0
  24. package/@ones-editor/server-tools/src/to-markdown/boxes/mathjax.d.ts +2 -0
  25. package/@ones-editor/server-tools/src/to-markdown/boxes/mention.d.ts +7 -0
  26. package/@ones-editor/server-tools/src/to-markdown/boxes/task-link.d.ts +2 -0
  27. package/@ones-editor/server-tools/src/to-markdown/convert-block.d.ts +3 -0
  28. package/@ones-editor/server-tools/src/to-markdown/convert-box.d.ts +3 -0
  29. package/@ones-editor/server-tools/src/to-markdown/embeds/drawio.d.ts +2 -0
  30. package/@ones-editor/server-tools/src/to-markdown/embeds/file-list.d.ts +5 -0
  31. package/@ones-editor/server-tools/src/to-markdown/embeds/file.d.ts +2 -0
  32. package/@ones-editor/server-tools/src/to-markdown/embeds/flowchart.d.ts +2 -0
  33. package/@ones-editor/server-tools/src/to-markdown/embeds/hr.d.ts +1 -0
  34. package/@ones-editor/server-tools/src/to-markdown/embeds/image.d.ts +18 -0
  35. package/@ones-editor/server-tools/src/to-markdown/embeds/index.d.ts +3 -0
  36. package/@ones-editor/server-tools/src/to-markdown/embeds/mathjax.d.ts +2 -0
  37. package/@ones-editor/server-tools/src/to-markdown/embeds/media.d.ts +2 -0
  38. package/@ones-editor/server-tools/src/to-markdown/embeds/mermaid.d.ts +2 -0
  39. package/@ones-editor/server-tools/src/to-markdown/embeds/plantuml.d.ts +2 -0
  40. package/@ones-editor/server-tools/src/to-markdown/embeds/plugin.d.ts +2 -0
  41. package/@ones-editor/server-tools/src/to-markdown/embeds/sub-pages.d.ts +2 -0
  42. package/@ones-editor/server-tools/src/to-markdown/embeds/task-list.d.ts +7 -0
  43. package/@ones-editor/server-tools/src/to-markdown/embeds/toc.d.ts +2 -0
  44. package/@ones-editor/server-tools/src/to-markdown/embeds/webpage.d.ts +5 -0
  45. package/@ones-editor/server-tools/src/to-markdown/embeds/xmind.d.ts +8 -0
  46. package/@ones-editor/server-tools/src/to-markdown/index.d.ts +1 -0
  47. package/@ones-editor/server-tools/src/to-markdown/types.d.ts +7 -0
  48. package/@ones-editor/server-tools/src/tools.d.ts +1 -0
  49. package/@ones-editor/server-tools/src/utils/editor-doc.d.ts +22 -0
  50. package/@ones-editor/server-tools/src/utils/is-binary.d.ts +14 -0
  51. package/@ones-editor/server-tools/src/utils/object.d.ts +1 -0
  52. package/@ones-editor/tsconfig.tsbuildinfo +1 -1
  53. package/@ones-editor/ui/src/index.d.ts +2 -2
  54. package/@ones-editor/ui/src/shortcuts/align-shortcuts.d.ts +2 -0
  55. package/@ones-editor/ui/src/shortcuts/index.d.ts +3 -2
  56. package/@ones-editor/ui/src/shortcuts/text-color-shortcuts.d.ts +2 -0
  57. package/@ones-editor/ui/src/shortcuts/text-style-shortcuts.d.ts +1 -2
  58. package/@ones-editor/ui-base/src/auto-suggest/auto-suggest.d.ts +3 -0
  59. package/@ones-editor/ui-base/src/color-button/index.d.ts +1 -2
  60. package/@ones-editor/ui-base/src/color-button/text-color-item.d.ts +2 -0
  61. package/dist/index.js +950 -518
  62. package/package.json +9 -1
package/dist/index.js CHANGED
@@ -44,7 +44,6 @@ div.editor-root {
44
44
  box-sizing: border-box;
45
45
  min-height: 100%;
46
46
  width: 100%;
47
- z-index: 1;
48
47
  }
49
48
  div.editor-root.readonly div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] span.text.link {
50
49
  cursor: pointer;
@@ -335,12 +334,12 @@ div.editor-root div.editor-content div[data-type=editor-container] div[data-type
335
334
  div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.hover .embed-hover-content {
336
335
  outline: 1px solid #0064ff;
337
336
  }
338
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected:not(.no-mask) > div[data-type=block-content],
339
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected:not(.no-mask) .embed-selected-content {
337
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected > div[data-type=block-content],
338
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected .embed-selected-content {
340
339
  position: relative;
341
340
  }
342
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected:not(.no-mask) > div[data-type=block-content]::before,
343
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected:not(.no-mask) .embed-selected-content::before {
341
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected > div[data-type=block-content]::before,
342
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected .embed-selected-content::before {
344
343
  content: " ";
345
344
  position: absolute;
346
345
  left: 0;
@@ -8901,7 +8900,7 @@ var __publicField = (obj, key, value) => {
8901
8900
  imageExportFailed: "\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F"
8902
8901
  }
8903
8902
  };
8904
- const logger$4R = getLogger("i18n");
8903
+ const logger$4S = getLogger("i18n");
8905
8904
  const langs$3 = {
8906
8905
  "en-US": enUS$x,
8907
8906
  "zh-CN": zhCN$x,
@@ -8921,7 +8920,7 @@ var __publicField = (obj, key, value) => {
8921
8920
  function t$8(key, args) {
8922
8921
  const ret = i18n.get(key, args);
8923
8922
  if (ret === key) {
8924
- logger$4R.warn(`no locale value for key ${key}`);
8923
+ logger$4S.warn(`no locale value for key ${key}`);
8925
8924
  }
8926
8925
  return ret;
8927
8926
  }
@@ -9534,7 +9533,7 @@ var __publicField = (obj, key, value) => {
9534
9533
  this._callbacks.clear();
9535
9534
  }
9536
9535
  }
9537
- const logger$4Q = getLogger("await-locker");
9536
+ const logger$4R = getLogger("await-locker");
9538
9537
  class AwaitLock {
9539
9538
  constructor() {
9540
9539
  __publicField(this, "_acquired", false);
@@ -9576,7 +9575,7 @@ var __publicField = (obj, key, value) => {
9576
9575
  }
9577
9576
  if (this._waitingResolvers.length > 0) {
9578
9577
  const resolve = this._waitingResolvers.shift();
9579
- assert(logger$4Q, resolve, "Resolver missing");
9578
+ assert(logger$4R, resolve, "Resolver missing");
9580
9579
  resolve(void 0);
9581
9580
  } else {
9582
9581
  this._acquired = false;
@@ -9659,7 +9658,7 @@ var __publicField = (obj, key, value) => {
9659
9658
  isMobileSafari: false
9660
9659
  };
9661
9660
  clientType.isMobileSafari = clientType.isMobile && clientType.isSafari;
9662
- const logger$4P = getLogger("dom-utils");
9661
+ const logger$4Q = getLogger("dom-utils");
9663
9662
  function addClass(dom, ...className) {
9664
9663
  if (dom && dom.nodeType === Node.ELEMENT_NODE) {
9665
9664
  dom.classList.add(...className);
@@ -9713,7 +9712,7 @@ var __publicField = (obj, key, value) => {
9713
9712
  range.setStart(node, offset);
9714
9713
  return range;
9715
9714
  } catch (err) {
9716
- assert(logger$4P, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
9715
+ assert(logger$4Q, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
9717
9716
  }
9718
9717
  }
9719
9718
  function createExpandedRange(startNode, startOffset, endNode, endOffset) {
@@ -9723,17 +9722,17 @@ var __publicField = (obj, key, value) => {
9723
9722
  range.setEnd(endNode, endOffset);
9724
9723
  return range;
9725
9724
  } catch (err) {
9726
- assert(logger$4P, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
9725
+ assert(logger$4Q, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
9727
9726
  }
9728
9727
  }
9729
9728
  function getFirstClientRect(elem) {
9730
9729
  const rects = elem.getClientRects();
9731
- assert(logger$4P, rects.length >= 1, "getFirstClientRect: no rects");
9730
+ assert(logger$4Q, rects.length >= 1, "getFirstClientRect: no rects");
9732
9731
  return rects[0];
9733
9732
  }
9734
9733
  function getLastClientRect(elem) {
9735
9734
  const rects = elem.getClientRects();
9736
- assert(logger$4P, rects.length >= 1, "getLastClientRect: no rects");
9735
+ assert(logger$4Q, rects.length >= 1, "getLastClientRect: no rects");
9737
9736
  return rects[rects.length - 1];
9738
9737
  }
9739
9738
  function getDistanceSquare(rect, x, y) {
@@ -9780,7 +9779,7 @@ var __publicField = (obj, key, value) => {
9780
9779
  return 0;
9781
9780
  }
9782
9781
  if (!elem1.parentElement || !elem2.parentElement) {
9783
- assert(logger$4P, false, "invalid dom node to compare");
9782
+ assert(logger$4Q, false, "invalid dom node to compare");
9784
9783
  }
9785
9784
  if (elem1.parentElement === elem2.parentElement) {
9786
9785
  const children = Array.from(elem1.parentElement.children);
@@ -9797,7 +9796,7 @@ var __publicField = (obj, key, value) => {
9797
9796
  const parents1 = getParents(elem1);
9798
9797
  const parents2 = getParents(elem2);
9799
9798
  if (parents1[0] !== parents2[0]) {
9800
- assert(logger$4P, false, "invalid dom node to compare, different tree");
9799
+ assert(logger$4Q, false, "invalid dom node to compare, different tree");
9801
9800
  }
9802
9801
  for (let i = 1; ; i++) {
9803
9802
  const parent1 = parents1[i];
@@ -10397,7 +10396,7 @@ var __publicField = (obj, key, value) => {
10397
10396
  }
10398
10397
  }
10399
10398
  const MIN_DISTANCE_THRESHOLD$3 = 3;
10400
- const logger$4O = getLogger("drag-drop");
10399
+ const logger$4P = getLogger("drag-drop");
10401
10400
  class DragDrop {
10402
10401
  constructor(options) {
10403
10402
  __publicField(this, "dragStarted", false);
@@ -10418,7 +10417,7 @@ var __publicField = (obj, key, value) => {
10418
10417
  var _a;
10419
10418
  event.preventDefault();
10420
10419
  event.stopPropagation();
10421
- assert(logger$4O, this.mouseDownEvent, "no mouse down event");
10420
+ assert(logger$4P, this.mouseDownEvent, "no mouse down event");
10422
10421
  const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
10423
10422
  const newPos = DragDrop.getEventPosition(event);
10424
10423
  const deltaX = newPos.x - oldPos.x;
@@ -10434,7 +10433,7 @@ var __publicField = (obj, key, value) => {
10434
10433
  });
10435
10434
  __publicField(this, "handleMouseUp", (event) => {
10436
10435
  if (event instanceof MouseEvent && event.button === 0 || event instanceof TouchEvent) {
10437
- assert(logger$4O, this.mouseDownEvent, "no mouse down event");
10436
+ assert(logger$4P, this.mouseDownEvent, "no mouse down event");
10438
10437
  const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
10439
10438
  const newPos = DragDrop.getEventPosition(event);
10440
10439
  const deltaX = newPos.x - oldPos.x;
@@ -10543,7 +10542,7 @@ var __publicField = (obj, key, value) => {
10543
10542
  const dragDrop = new DragDrop(options);
10544
10543
  return dragDrop;
10545
10544
  }
10546
- const logger$4N = getLogger("character");
10545
+ const logger$4O = getLogger("character");
10547
10546
  function checkChar(charCode, rangeList) {
10548
10547
  for (let i = 0; i < rangeList.length; i++) {
10549
10548
  const start = rangeList[i][0];
@@ -10588,9 +10587,13 @@ var __publicField = (obj, key, value) => {
10588
10587
  ];
10589
10588
  return checkChar(str.charCodeAt(0), CJKRange);
10590
10589
  }
10590
+ function isCJKPunctuation(char) {
10591
+ const reg = /[\u3000-\u303F\uFF00-\uFFEF\u2000-\u206F\u2E00-\u2E7F]/;
10592
+ return reg.test(char);
10593
+ }
10591
10594
  function trimChar(s, char) {
10592
10595
  let c = char;
10593
- assert(logger$4N, c.length === 1, "invalid char length");
10596
+ assert(logger$4O, c.length === 1, "invalid char length");
10594
10597
  if (c === "]")
10595
10598
  c = "\\]";
10596
10599
  if (c === "\\")
@@ -10756,7 +10759,7 @@ var __publicField = (obj, key, value) => {
10756
10759
  if (parsedShortcut.key.length === 1) {
10757
10760
  return parsedShortcut.key === event.key.toUpperCase();
10758
10761
  }
10759
- return parsedShortcut.key.toUpperCase() === event.key.toUpperCase() || parsedShortcut.key.toUpperCase() === event.code.toUpperCase();
10762
+ return parsedShortcut.key.toUpperCase() === event.key.toUpperCase() || !(event.isComposing === false && event.key.toLowerCase() === "process") && parsedShortcut.key.toUpperCase() === event.code.toUpperCase();
10760
10763
  }
10761
10764
  function updateUrl(url, query2) {
10762
10765
  return queryString.stringifyUrl({
@@ -10907,24 +10910,31 @@ var __publicField = (obj, key, value) => {
10907
10910
  return elementFont;
10908
10911
  }
10909
10912
  function getTextWidth(text2, font) {
10910
- const canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
10911
- const context = canvas.getContext("2d");
10912
- if (!context) {
10913
- return 200;
10914
- }
10915
- if (typeof font === "string") {
10916
- if (!font) {
10917
- context.font = getStyleFont(window.getComputedStyle(document.body));
10918
- } else {
10919
- context.font = font;
10913
+ try {
10914
+ if (window.fakebrowser) {
10915
+ return 200;
10916
+ }
10917
+ const canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
10918
+ const context = canvas.getContext("2d");
10919
+ if (!context) {
10920
+ return 200;
10920
10921
  }
10921
- } else if (font instanceof Element) {
10922
- context.font = getStyleFont(window.getComputedStyle(font));
10922
+ if (typeof font === "string") {
10923
+ if (!font) {
10924
+ context.font = getStyleFont(window.getComputedStyle(document.body));
10925
+ } else {
10926
+ context.font = font;
10927
+ }
10928
+ } else if (font instanceof Element) {
10929
+ context.font = getStyleFont(window.getComputedStyle(font));
10930
+ }
10931
+ const metrics = context.measureText(text2);
10932
+ return metrics.width + 4;
10933
+ } catch (err) {
10934
+ return 200;
10923
10935
  }
10924
- const metrics = context.measureText(text2);
10925
- return metrics.width + 4;
10926
10936
  }
10927
- const logger$4M = getLogger("editor-clipboard");
10937
+ const logger$4N = getLogger("editor-clipboard");
10928
10938
  async function setClipboardDataByEvent(items, event) {
10929
10939
  if (event.clipboardData) {
10930
10940
  const data2 = event.clipboardData;
@@ -10982,7 +10992,7 @@ var __publicField = (obj, key, value) => {
10982
10992
  document.body.removeChild(textarea2);
10983
10993
  return true;
10984
10994
  } catch (ex) {
10985
- logger$4M.error(ex);
10995
+ logger$4N.error(ex);
10986
10996
  document.body.removeChild(textarea2);
10987
10997
  return false;
10988
10998
  }
@@ -11003,7 +11013,7 @@ var __publicField = (obj, key, value) => {
11003
11013
  document.body.removeChild(div);
11004
11014
  return true;
11005
11015
  } catch (ex) {
11006
- logger$4M.error(ex);
11016
+ logger$4N.error(ex);
11007
11017
  document.body.removeChild(div);
11008
11018
  return false;
11009
11019
  }
@@ -11030,7 +11040,7 @@ var __publicField = (obj, key, value) => {
11030
11040
  await navigator.clipboard.write([clipboardItems]);
11031
11041
  return true;
11032
11042
  } catch (err) {
11033
- logger$4M.error(err);
11043
+ logger$4N.error(err);
11034
11044
  return await execCommandCopy(items);
11035
11045
  }
11036
11046
  }
@@ -11086,7 +11096,7 @@ var __publicField = (obj, key, value) => {
11086
11096
  a.click();
11087
11097
  a.remove();
11088
11098
  }
11089
- const logger$4L = getLogger("auto-scroll");
11099
+ const logger$4M = getLogger("auto-scroll");
11090
11100
  function scrollable(scrollElement, direction) {
11091
11101
  if (scrollElement.scrollHeight === scrollElement.clientHeight) {
11092
11102
  return false;
@@ -11110,7 +11120,7 @@ var __publicField = (obj, key, value) => {
11110
11120
  const isHorizontal = direction === "left" || direction === "right";
11111
11121
  const scroll = () => {
11112
11122
  if (!scrollable(scrollElement, direction)) {
11113
- logger$4L.debug("No need for scroll");
11123
+ logger$4M.debug("No need for scroll");
11114
11124
  return null;
11115
11125
  }
11116
11126
  if (isHorizontal) {
@@ -11167,7 +11177,7 @@ var __publicField = (obj, key, value) => {
11167
11177
  if (this.scrolling) {
11168
11178
  return;
11169
11179
  }
11170
- logger$4L.debug(`scroll direction: ${direction}`);
11180
+ logger$4M.debug(`scroll direction: ${direction}`);
11171
11181
  this.cancelScroll = continuousScroll(scrollElement, {
11172
11182
  direction,
11173
11183
  step
@@ -11417,7 +11427,7 @@ var __publicField = (obj, key, value) => {
11417
11427
  const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
11418
11428
  return ColorNames[colorIndex];
11419
11429
  }
11420
- const logger$4K = getLogger("container");
11430
+ const logger$4L = getLogger("container");
11421
11431
  function isContainer(elem) {
11422
11432
  return elem.getAttribute("data-type") === "editor-container";
11423
11433
  }
@@ -11429,9 +11439,9 @@ var __publicField = (obj, key, value) => {
11429
11439
  }
11430
11440
  function getContainerId(container) {
11431
11441
  const id = container.getAttribute("data-container-id");
11432
- assert(logger$4K, id, "no id for container");
11442
+ assert(logger$4L, id, "no id for container");
11433
11443
  if (isRootContainer(container)) {
11434
- assert(logger$4K, id === "root", `invalid root container id, : ${id}`);
11444
+ assert(logger$4L, id === "root", `invalid root container id, : ${id}`);
11435
11445
  }
11436
11446
  return id;
11437
11447
  }
@@ -11442,7 +11452,7 @@ var __publicField = (obj, key, value) => {
11442
11452
  function generateEditorContainerId(containerId) {
11443
11453
  return `ones-editor-container-${containerId}`;
11444
11454
  }
11445
- const logger$4J = getLogger("element");
11455
+ const logger$4K = getLogger("element");
11446
11456
  function createContainerElement(parent, type, containerId) {
11447
11457
  const container = createElement("div", [type], parent);
11448
11458
  container.setAttribute("data-type", "editor-container");
@@ -11453,7 +11463,7 @@ var __publicField = (obj, key, value) => {
11453
11463
  }
11454
11464
  function getContainerById(editor, containerId) {
11455
11465
  const container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
11456
- assert(logger$4J, container, `no container: ${containerId}`);
11466
+ assert(logger$4K, container, `no container: ${containerId}`);
11457
11467
  return container;
11458
11468
  }
11459
11469
  function getExistsContainerById(editor, containerId) {
@@ -11462,7 +11472,7 @@ var __publicField = (obj, key, value) => {
11462
11472
  }
11463
11473
  function getContainerBlocksElement(container) {
11464
11474
  const blocks = container.querySelector(":scope > .container-blocks");
11465
- assert(logger$4J, blocks, "no container blocks element");
11475
+ assert(logger$4K, blocks, "no container blocks element");
11466
11476
  return blocks;
11467
11477
  }
11468
11478
  function getContainerToolsElement(container) {
@@ -11475,11 +11485,11 @@ var __publicField = (obj, key, value) => {
11475
11485
  function isContainerBlocksElement(element) {
11476
11486
  return element.classList.contains("container-blocks");
11477
11487
  }
11478
- const logger$4I = getLogger("container-children");
11488
+ const logger$4J = getLogger("container-children");
11479
11489
  function getChildBlocks(container, traverseChild) {
11480
11490
  const content = getContainerBlocksElement(container);
11481
11491
  const blocks = Array.from(content.children);
11482
- assert(logger$4I, blocks.length > 0, "container have not any child block");
11492
+ assert(logger$4J, blocks.length > 0, "container have not any child block");
11483
11493
  if (traverseChild) {
11484
11494
  const { condition, editor } = traverseChild;
11485
11495
  return blocks.reduce((result, block) => {
@@ -11502,7 +11512,7 @@ var __publicField = (obj, key, value) => {
11502
11512
  }
11503
11513
  function getFirstChildBlock(container) {
11504
11514
  const block = container.querySelector(":scope > .container-blocks > div[data-type=editor-block]");
11505
- assert(logger$4I, block, "container have not any child block");
11515
+ assert(logger$4J, block, "container have not any child block");
11506
11516
  return block;
11507
11517
  }
11508
11518
  function getLastChildBlock(container) {
@@ -11514,14 +11524,14 @@ var __publicField = (obj, key, value) => {
11514
11524
  }
11515
11525
  function getBlockByIndex(container, blockIndex) {
11516
11526
  const block = getChildBlocks(container)[blockIndex];
11517
- assert(logger$4I, block, `container have not block at index ${blockIndex}`);
11527
+ assert(logger$4J, block, `container have not block at index ${blockIndex}`);
11518
11528
  return block;
11519
11529
  }
11520
11530
  function findBlockByIndex(container, blockIndex) {
11521
11531
  var _a;
11522
11532
  return (_a = getChildBlocks(container)[blockIndex]) != null ? _a : null;
11523
11533
  }
11524
- const logger$4H = getLogger("block-dom");
11534
+ const logger$4I = getLogger("block-dom");
11525
11535
  function isBlock$1(node) {
11526
11536
  if (!(node instanceof HTMLDivElement)) {
11527
11537
  return false;
@@ -11542,12 +11552,12 @@ var __publicField = (obj, key, value) => {
11542
11552
  }
11543
11553
  function getBlockId(block) {
11544
11554
  const { id } = block;
11545
- assert(logger$4H, id, "no block id");
11555
+ assert(logger$4I, id, "no block id");
11546
11556
  return id;
11547
11557
  }
11548
11558
  function getBlockType(block) {
11549
11559
  const type = block.getAttribute("data-block-type");
11550
- assert(logger$4H, type, "invalid block dom, no data-type");
11560
+ assert(logger$4I, type, "invalid block dom, no data-type");
11551
11561
  return type;
11552
11562
  }
11553
11563
  function getParentBlock(node) {
@@ -11570,12 +11580,12 @@ var __publicField = (obj, key, value) => {
11570
11580
  }
11571
11581
  function getParentContainer(block) {
11572
11582
  const container = block.closest("div[data-type=editor-container]");
11573
- assert(logger$4H, container, "failed to get block container");
11583
+ assert(logger$4I, container, "failed to get block container");
11574
11584
  return container;
11575
11585
  }
11576
11586
  function getBlockContent(block) {
11577
11587
  const content = block.querySelector(":scope >div[data-type=block-content]");
11578
- assert(logger$4H, content, "no block content");
11588
+ assert(logger$4I, content, "no block content");
11579
11589
  return content;
11580
11590
  }
11581
11591
  function getBlockTools(block) {
@@ -11584,7 +11594,7 @@ var __publicField = (obj, key, value) => {
11584
11594
  tools = createElement("div", [], block);
11585
11595
  tools.setAttribute("data-type", "block-tools");
11586
11596
  }
11587
- assert(logger$4H, tools, "no block tools");
11597
+ assert(logger$4I, tools, "no block tools");
11588
11598
  return tools;
11589
11599
  }
11590
11600
  function getExistsBlockTools(block) {
@@ -11605,7 +11615,7 @@ var __publicField = (obj, key, value) => {
11605
11615
  function createBlockElement(editor, path, data2) {
11606
11616
  const blockData = editor.editorDecorators.decorateBlock(path, data2);
11607
11617
  const { id, type } = blockData;
11608
- assert(logger$4H, id, "no block id");
11618
+ assert(logger$4I, id, "no block id");
11609
11619
  const elem = createElement("div", [`${type}-block`], null);
11610
11620
  elem.id = id;
11611
11621
  elem.setAttribute("data-type", "editor-block");
@@ -11643,7 +11653,7 @@ var __publicField = (obj, key, value) => {
11643
11653
  }
11644
11654
  function getBoxTypeFromElement(box) {
11645
11655
  const type = box.getAttribute("data-box-type");
11646
- assert(logger$4H, type, "not a valid box element, no type");
11656
+ assert(logger$4I, type, "not a valid box element, no type");
11647
11657
  return type;
11648
11658
  }
11649
11659
  function isBox(node) {
@@ -11654,7 +11664,7 @@ var __publicField = (obj, key, value) => {
11654
11664
  }
11655
11665
  function getBoxId(box) {
11656
11666
  const { id } = box;
11657
- assert(logger$4H, id, "no box id");
11667
+ assert(logger$4I, id, "no box id");
11658
11668
  return id;
11659
11669
  }
11660
11670
  function getParentBox(node) {
@@ -11676,7 +11686,7 @@ var __publicField = (obj, key, value) => {
11676
11686
  }
11677
11687
  function getBoxContent(box) {
11678
11688
  const content = box.querySelector("span[data-type=box-content]");
11679
- assert(logger$4H, content, "invalid box dom, no content");
11689
+ assert(logger$4I, content, "invalid box dom, no content");
11680
11690
  return content;
11681
11691
  }
11682
11692
  function createInsertionElement(type, id, attributes) {
@@ -11698,7 +11708,7 @@ var __publicField = (obj, key, value) => {
11698
11708
  }
11699
11709
  function getInsertionContent(insertion) {
11700
11710
  const content = insertion.querySelector("span[data-type=insertion-content]");
11701
- assert(logger$4H, content, "invalid insertion-child dom, no content");
11711
+ assert(logger$4I, content, "invalid insertion-child dom, no content");
11702
11712
  return content;
11703
11713
  }
11704
11714
  function getPrevBlock(block) {
@@ -11721,31 +11731,44 @@ var __publicField = (obj, key, value) => {
11721
11731
  }
11722
11732
  return null;
11723
11733
  }
11724
- function getPrevVisibleBlock(block) {
11734
+ function getPrevVisibleBlock(block, matcher) {
11735
+ const mergedMatcher = matcher || (() => true);
11725
11736
  let prev = block.previousElementSibling;
11726
11737
  while (prev) {
11727
- if (isBlock$1(prev) && isVisibleBlock(prev)) {
11738
+ if (isBlock$1(prev) && isVisibleBlock(prev) && mergedMatcher(prev)) {
11728
11739
  return prev;
11729
11740
  }
11730
11741
  prev = prev.previousElementSibling;
11731
11742
  }
11732
11743
  return null;
11733
11744
  }
11734
- function getNextVisibleBlock(block) {
11745
+ function getNextVisibleBlock(block, matcher) {
11746
+ const mergedMatcher = matcher || (() => true);
11735
11747
  let next2 = block.nextElementSibling;
11736
11748
  while (next2) {
11737
- if (isBlock$1(next2) && isVisibleBlock(next2)) {
11749
+ if (isBlock$1(next2) && isVisibleBlock(next2) && mergedMatcher(next2)) {
11738
11750
  return next2;
11739
11751
  }
11740
11752
  next2 = next2.nextElementSibling;
11741
11753
  }
11742
11754
  return null;
11743
11755
  }
11756
+ function getBlocksBetween(start, end, matcher) {
11757
+ const blocks = [];
11758
+ let cur = start;
11759
+ while (cur !== end) {
11760
+ if (isBlock$1(cur) && matcher(cur)) {
11761
+ blocks.push(cur);
11762
+ }
11763
+ cur = cur.nextElementSibling;
11764
+ }
11765
+ return blocks;
11766
+ }
11744
11767
  function getBlockIndex(block) {
11745
11768
  const container = getParentContainer(block);
11746
11769
  const children = getChildBlocks(container);
11747
11770
  const index2 = children.indexOf(block);
11748
- assert(logger$4H, index2 !== -1, "invalid block & container dom, failed to get block index");
11771
+ assert(logger$4I, index2 !== -1, "invalid block & container dom, failed to get block index");
11749
11772
  return index2;
11750
11773
  }
11751
11774
  function isInBlock(target) {
@@ -11770,18 +11793,18 @@ var __publicField = (obj, key, value) => {
11770
11793
  function isTitleBlock$2(block) {
11771
11794
  return block.hasAttribute("data-document-title");
11772
11795
  }
11773
- const logger$4G = getLogger("block-class");
11796
+ const logger$4H = getLogger("block-class");
11774
11797
  function getBlockClass(editor, block) {
11775
11798
  return editor.editorBlocks.getBlockClass(getBlockType(block));
11776
11799
  }
11777
11800
  function getTextBlockClass(editor, block) {
11778
11801
  const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
11779
- assert(logger$4G, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
11802
+ assert(logger$4H, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
11780
11803
  return text2;
11781
11804
  }
11782
11805
  function getComplexBlockClass(editor, block) {
11783
11806
  const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
11784
- assert(logger$4G, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
11807
+ assert(logger$4H, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
11785
11808
  return complex;
11786
11809
  }
11787
11810
  function getBlockClassByType(editor, type) {
@@ -11802,7 +11825,7 @@ var __publicField = (obj, key, value) => {
11802
11825
  function getBlockKind(editor, block) {
11803
11826
  return getBlockClass(editor, block).blockKind;
11804
11827
  }
11805
- const logger$4F = getLogger("text-block-child");
11828
+ const logger$4G = getLogger("text-block-child");
11806
11829
  function isTextBlockContentChild(elem) {
11807
11830
  if (elem.tagName !== "SPAN") {
11808
11831
  return false;
@@ -11810,14 +11833,14 @@ var __publicField = (obj, key, value) => {
11810
11833
  return true;
11811
11834
  }
11812
11835
  function isTextBlockContentBoxChild(elem) {
11813
- assert(logger$4F, isTextBlockContentChild(elem), "not a valid text child");
11836
+ assert(logger$4G, isTextBlockContentChild(elem), "not a valid text child");
11814
11837
  if (elem.getAttribute("data-type") === "editor-box") {
11815
11838
  return true;
11816
11839
  }
11817
11840
  return false;
11818
11841
  }
11819
11842
  function isTextBlockContentInsertionChild(elem) {
11820
- assert(logger$4F, isTextBlockContentChild(elem), "not a valid text child");
11843
+ assert(logger$4G, isTextBlockContentChild(elem), "not a valid text child");
11821
11844
  if (elem.getAttribute("data-type") === "editor-insertion") {
11822
11845
  return true;
11823
11846
  }
@@ -11827,7 +11850,7 @@ var __publicField = (obj, key, value) => {
11827
11850
  return !isTextBlockContentBoxChild(elem) && !isTextBlockContentInsertionChild(elem);
11828
11851
  }
11829
11852
  function getTextBlockContentChildType(child) {
11830
- assert(logger$4F, isTextBlockContentChild(child), "not a valid text child");
11853
+ assert(logger$4G, isTextBlockContentChild(child), "not a valid text child");
11831
11854
  if (isTextBlockContentBoxChild(child)) {
11832
11855
  return "box";
11833
11856
  }
@@ -11842,15 +11865,15 @@ var __publicField = (obj, key, value) => {
11842
11865
  return 0;
11843
11866
  if (type === "box")
11844
11867
  return 1;
11845
- assert(logger$4F, child.textContent !== null, "text block content is undefined");
11846
- assert(logger$4F, child.textContent.length >= 0, "text block content length is negative");
11868
+ assert(logger$4G, child.textContent !== null, "text block content is undefined");
11869
+ assert(logger$4G, child.textContent.length >= 0, "text block content length is negative");
11847
11870
  return child.textContent.length;
11848
11871
  }
11849
11872
  function getTextBlockContentChildren(block) {
11850
11873
  const content = getBlockContent(block);
11851
11874
  const children = Array.from(content.children);
11852
11875
  children.forEach((child) => {
11853
- assert(logger$4F, isTextBlockContentChild(child), "not a valid text child");
11876
+ assert(logger$4G, isTextBlockContentChild(child), "not a valid text child");
11854
11877
  });
11855
11878
  return children;
11856
11879
  }
@@ -11879,17 +11902,17 @@ var __publicField = (obj, key, value) => {
11879
11902
  };
11880
11903
  }
11881
11904
  const offset = blockOffset - start;
11882
- assert(logger$4F, offset > 0, "invalid offset value");
11883
- assert(logger$4F, !isTextBlockContentBoxChild(child), "invalid box child");
11905
+ assert(logger$4G, offset > 0, "invalid offset value");
11906
+ assert(logger$4G, !isTextBlockContentBoxChild(child), "invalid box child");
11884
11907
  return {
11885
11908
  prev: child,
11886
11909
  next: child,
11887
11910
  offset
11888
11911
  };
11889
11912
  }
11890
- assert(logger$4F, false, `invalid block child at position: ${blockOffset}`);
11913
+ assert(logger$4G, false, `invalid block child at position: ${blockOffset}`);
11891
11914
  }
11892
- const logger$4E = getLogger("block-path");
11915
+ const logger$4F = getLogger("block-path");
11893
11916
  function getBlockPath(block) {
11894
11917
  const ret = [];
11895
11918
  let current = block;
@@ -11903,26 +11926,26 @@ var __publicField = (obj, key, value) => {
11903
11926
  return ret;
11904
11927
  }
11905
11928
  const parentBlock = getParentBlock(container);
11906
- assert(logger$4E, parentBlock, "no parent block");
11929
+ assert(logger$4F, parentBlock, "no parent block");
11907
11930
  current = parentBlock;
11908
11931
  }
11909
- assert(logger$4E, false, "no parent block");
11932
+ assert(logger$4F, false, "no parent block");
11910
11933
  return [];
11911
11934
  }
11912
- const logger$4D = getLogger("child-container-path");
11935
+ const logger$4E = getLogger("child-container-path");
11913
11936
  function getContainerBlockPath(container) {
11914
11937
  if (isRootContainer(container)) {
11915
11938
  return [];
11916
11939
  }
11917
11940
  const parentBlock = getParentBlock(container);
11918
- assert(logger$4D, parentBlock, "no parent block");
11941
+ assert(logger$4E, parentBlock, "no parent block");
11919
11942
  return getBlockPath(parentBlock);
11920
11943
  }
11921
- const logger$4C = getLogger("load-blocks");
11944
+ const logger$4D = getLogger("load-blocks");
11922
11945
  function loadBlocks(editor, container, path) {
11923
11946
  const containerId = getContainerId(container);
11924
11947
  const blocks = getContainerBlocks$1(container, editor.doc);
11925
- assert(logger$4C, blocks.length > 0, "no blocks in container");
11948
+ assert(logger$4D, blocks.length > 0, "no blocks in container");
11926
11949
  const fragment = document.createDocumentFragment();
11927
11950
  blocks.forEach((b, index2) => {
11928
11951
  const block = editor.editorBlocks.createBlock([...path, { containerId, blockIndex: index2 }], container, b);
@@ -11938,7 +11961,7 @@ var __publicField = (obj, key, value) => {
11938
11961
  return block;
11939
11962
  }
11940
11963
  const blocks = getChildBlocks(container);
11941
- assert(logger$4C, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
11964
+ assert(logger$4D, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
11942
11965
  if (blockIndex === blocks.length) {
11943
11966
  containerBlocksElement.appendChild(block);
11944
11967
  } else {
@@ -11956,7 +11979,7 @@ var __publicField = (obj, key, value) => {
11956
11979
  insertBlockAt(container, blockIndex, block);
11957
11980
  return block;
11958
11981
  }
11959
- const logger$4B = getLogger("root-container");
11982
+ const logger$4C = getLogger("root-container");
11960
11983
  const MIN_DISTANCE_THRESHOLD$2 = 3;
11961
11984
  class RootContainer {
11962
11985
  constructor(editor, rootContainer) {
@@ -11984,7 +12007,7 @@ var __publicField = (obj, key, value) => {
11984
12007
  this.editor.selection.updateSelection(null);
11985
12008
  this.editor.emit("resize", this.editor);
11986
12009
  } catch (err) {
11987
- logger$4B.warn(`failed to update selection while container resizing: ${err.message}`);
12010
+ logger$4C.warn(`failed to update selection while container resizing: ${err.message}`);
11988
12011
  }
11989
12012
  });
11990
12013
  __publicField(this, "handleClick", (event) => {
@@ -12017,7 +12040,7 @@ var __publicField = (obj, key, value) => {
12017
12040
  const box = getParentBox(elem);
12018
12041
  if (box) {
12019
12042
  const block2 = getParentBlock(box);
12020
- assert(logger$4B, block2, "no parent block");
12043
+ assert(logger$4C, block2, "no parent block");
12021
12044
  (_b = (_a = this.editor.editorBoxes.getBoxClass(getBoxTypeFromElement(box))) == null ? void 0 : _a.handleClickBox) == null ? void 0 : _b.call(_a, this.editor, box, event);
12022
12045
  return;
12023
12046
  }
@@ -12072,7 +12095,7 @@ var __publicField = (obj, key, value) => {
12072
12095
  this.editor.input.focus({ preventScroll: true });
12073
12096
  });
12074
12097
  __publicField(this, "handleMouseMove", (event) => {
12075
- assert(logger$4B, this.mouseDownEvent, "no mouse down event");
12098
+ assert(logger$4C, this.mouseDownEvent, "no mouse down event");
12076
12099
  if (ensureIsMobileEvent(this.mouseDownEvent))
12077
12100
  return;
12078
12101
  const deltaX = event.x - this.mouseDownEvent.x;
@@ -12188,7 +12211,7 @@ var __publicField = (obj, key, value) => {
12188
12211
  loadBlocks(editor, container, path);
12189
12212
  return container;
12190
12213
  }
12191
- const logger$4A = getLogger("block");
12214
+ const logger$4B = getLogger("block");
12192
12215
  function getBlockTextLength$6(editor, block) {
12193
12216
  return getBlockClass(editor, block).getBlockTextLength(block);
12194
12217
  }
@@ -12207,7 +12230,7 @@ var __publicField = (obj, key, value) => {
12207
12230
  return block;
12208
12231
  }
12209
12232
  const parent = getParentBlock(container);
12210
- assert(logger$4A, parent, "no parent block exists for child container");
12233
+ assert(logger$4B, parent, "no parent block exists for child container");
12211
12234
  block = parent;
12212
12235
  }
12213
12236
  }
@@ -12243,7 +12266,7 @@ var __publicField = (obj, key, value) => {
12243
12266
  }
12244
12267
  return fun(editor, block, options);
12245
12268
  } catch (err) {
12246
- logger$4A.debug(`unsupported block type: ${type}`);
12269
+ logger$4B.debug(`unsupported block type: ${type}`);
12247
12270
  return null;
12248
12271
  }
12249
12272
  }
@@ -12263,7 +12286,7 @@ var __publicField = (obj, key, value) => {
12263
12286
  const styles = Object.fromEntries(Object.entries(data2).filter(([key]) => key.startsWith("style-")));
12264
12287
  Object.entries(styles).forEach(([, value]) => {
12265
12288
  const type = typeof value;
12266
- assert(logger$4A, type === "string" || type === "number" || type === "boolean", "invalid style value");
12289
+ assert(logger$4B, type === "string" || type === "number" || type === "boolean", "invalid style value");
12267
12290
  });
12268
12291
  return styles;
12269
12292
  }
@@ -12388,7 +12411,7 @@ var __publicField = (obj, key, value) => {
12388
12411
  }
12389
12412
  return { element: null, blockCommands: [], boxCommands: [] };
12390
12413
  }
12391
- const logger$4z = getLogger("embed-block-common");
12414
+ const logger$4A = getLogger("embed-block-common");
12392
12415
  function isColumnsBlock(block) {
12393
12416
  return getBlockType(block) === "layout";
12394
12417
  }
@@ -12396,9 +12419,9 @@ var __publicField = (obj, key, value) => {
12396
12419
  return getBlockType(block) === "embed";
12397
12420
  }
12398
12421
  function getEmbedType(block) {
12399
- assert(logger$4z, isEmbedBlock(block), "not an embed block");
12422
+ assert(logger$4A, isEmbedBlock(block), "not an embed block");
12400
12423
  const type = block.getAttribute("data-embed-type");
12401
- assert(logger$4z, type, "no embed data type");
12424
+ assert(logger$4A, type, "no embed data type");
12402
12425
  return type;
12403
12426
  }
12404
12427
  function getEmbedClassFromBlock(editor, block) {
@@ -12464,10 +12487,10 @@ var __publicField = (obj, key, value) => {
12464
12487
  data: (_c = overrideOptions == null ? void 0 : overrideOptions.data) != null ? _c : data2
12465
12488
  });
12466
12489
  }
12467
- const logger$4y = getLogger("execute-block-command");
12490
+ const logger$4z = getLogger("execute-block-command");
12468
12491
  function executeEmbedBlockCommand(editor, block, commandGroup, item) {
12469
12492
  var _a;
12470
- assert(logger$4y, isEmbedBlock(block), "not a embed block");
12493
+ assert(logger$4z, isEmbedBlock(block), "not a embed block");
12471
12494
  const embedType = getEmbedType(block);
12472
12495
  const embed = getEmbedClassByType(editor, embedType);
12473
12496
  if (!embed.getOptions) {
@@ -12500,14 +12523,14 @@ var __publicField = (obj, key, value) => {
12500
12523
  }
12501
12524
  return void 0;
12502
12525
  }
12503
- const logger$4x = getLogger("block-class");
12526
+ const logger$4y = getLogger("block-class");
12504
12527
  function isHeadingBlock$1(block) {
12505
12528
  return !!block.getAttribute("data-style-heading");
12506
12529
  }
12507
12530
  function getBlockHeading(block) {
12508
12531
  var _a;
12509
12532
  const heading = Number.parseInt((_a = block.getAttribute("data-style-heading")) != null ? _a : "", 10);
12510
- assert(logger$4x, heading, "not a heading block");
12533
+ assert(logger$4y, heading, "not a heading block");
12511
12534
  return heading;
12512
12535
  }
12513
12536
  function isExpandedHeadingBlock(block) {
@@ -12518,7 +12541,7 @@ var __publicField = (obj, key, value) => {
12518
12541
  }
12519
12542
  function getHeadingBlockChildren(block, oldHeading) {
12520
12543
  if (!oldHeading) {
12521
- assert(logger$4x, isHeadingBlock$1(block), "not a heading block");
12544
+ assert(logger$4y, isHeadingBlock$1(block), "not a heading block");
12522
12545
  }
12523
12546
  const children = [];
12524
12547
  const heading = oldHeading != null ? oldHeading : getBlockHeading(block);
@@ -12548,7 +12571,7 @@ var __publicField = (obj, key, value) => {
12548
12571
  }
12549
12572
  return children;
12550
12573
  }
12551
- const logger$4w = getLogger("complex-block-position");
12574
+ const logger$4x = getLogger("complex-block-position");
12552
12575
  class EditorComplexBlockPosition {
12553
12576
  constructor(block, childContainerId, custom) {
12554
12577
  __publicField(this, "blockId");
@@ -12557,7 +12580,7 @@ var __publicField = (obj, key, value) => {
12557
12580
  if (block instanceof HTMLElement) {
12558
12581
  this.blockId = getBlockId(block);
12559
12582
  } else {
12560
- assert(logger$4w, typeof block === "string", `not a valid block id: ${block}`);
12583
+ assert(logger$4x, typeof block === "string", `not a valid block id: ${block}`);
12561
12584
  this.blockId = block;
12562
12585
  }
12563
12586
  this.childContainerId = childContainerId;
@@ -12569,7 +12592,7 @@ var __publicField = (obj, key, value) => {
12569
12592
  return false;
12570
12593
  }
12571
12594
  }
12572
- const logger$4v = getLogger("simple-block-position");
12595
+ const logger$4w = getLogger("simple-block-position");
12573
12596
  class EditorSimpleBlockPosition {
12574
12597
  constructor(block, offset, type) {
12575
12598
  __publicField(this, "blockId");
@@ -12578,7 +12601,7 @@ var __publicField = (obj, key, value) => {
12578
12601
  if (block instanceof HTMLElement) {
12579
12602
  this.blockId = getBlockId(block);
12580
12603
  } else {
12581
- assert(logger$4v, typeof block === "string", `not a valid block id: ${block}`);
12604
+ assert(logger$4w, typeof block === "string", `not a valid block id: ${block}`);
12582
12605
  this.blockId = block;
12583
12606
  }
12584
12607
  this.offset = offset;
@@ -12588,7 +12611,7 @@ var __publicField = (obj, key, value) => {
12588
12611
  return true;
12589
12612
  }
12590
12613
  }
12591
- const logger$4u = getLogger("editor-position");
12614
+ const logger$4v = getLogger("editor-position");
12592
12615
  function createSimpleBlockPosition(block, offset, type) {
12593
12616
  return new EditorSimpleBlockPosition(block, offset, type);
12594
12617
  }
@@ -12610,7 +12633,7 @@ var __publicField = (obj, key, value) => {
12610
12633
  }
12611
12634
  const block1 = editor.getBlockById(pos1.blockId);
12612
12635
  const block2 = editor.getBlockById(pos2.blockId);
12613
- assert(logger$4u, block1 !== block2, "comparePosition: blocks are the same");
12636
+ assert(logger$4v, block1 !== block2, "comparePosition: blocks are the same");
12614
12637
  return compareElement(block1, block2);
12615
12638
  }
12616
12639
  if (isComplexBlockPosition(pos1) && isComplexBlockPosition(pos2)) {
@@ -12621,13 +12644,13 @@ var __publicField = (obj, key, value) => {
12621
12644
  }
12622
12645
  const container1 = editor.getContainerById(p1.childContainerId);
12623
12646
  const container2 = editor.getContainerById(p2.childContainerId);
12624
- assert(logger$4u, container1 !== container2, "comparePosition: containers are the same");
12647
+ assert(logger$4v, container1 !== container2, "comparePosition: containers are the same");
12625
12648
  return compareElement(container1, container2);
12626
12649
  }
12627
- assert(logger$4u, false, "invalid ");
12650
+ assert(logger$4v, false, "invalid ");
12628
12651
  return 0;
12629
12652
  }
12630
- const logger$4t = getLogger("simple-range");
12653
+ const logger$4u = getLogger("simple-range");
12631
12654
  class EditorSimpleSelectionRange {
12632
12655
  constructor(editor, options) {
12633
12656
  __publicField(this, "editor");
@@ -12676,11 +12699,11 @@ var __publicField = (obj, key, value) => {
12676
12699
  const { editor } = this;
12677
12700
  const startBlock = editor.getBlockById(this.start.blockId);
12678
12701
  const endBlock = editor.getBlockById(this.end.blockId);
12679
- assert(logger$4t, startBlock, "no start block");
12680
- assert(logger$4t, endBlock, "no end block");
12702
+ assert(logger$4u, startBlock, "no start block");
12703
+ assert(logger$4u, endBlock, "no end block");
12681
12704
  const startContainer = getParentContainer(startBlock);
12682
12705
  const endContainer = getParentContainer(endBlock);
12683
- assert(logger$4t, startContainer === endContainer, "invalid range");
12706
+ assert(logger$4u, startContainer === endContainer, "invalid range");
12684
12707
  const ret = [];
12685
12708
  if (startBlock === endBlock) {
12686
12709
  ret.push({
@@ -12691,7 +12714,7 @@ var __publicField = (obj, key, value) => {
12691
12714
  } else {
12692
12715
  const startIndex = getBlockIndex(startBlock);
12693
12716
  const endIndex = getBlockIndex(endBlock);
12694
- assert(logger$4t, startIndex < endIndex, "invalid range, start > index");
12717
+ assert(logger$4u, startIndex < endIndex, "invalid range, start > index");
12695
12718
  ret.push({
12696
12719
  block: startBlock,
12697
12720
  start: this.start,
@@ -12791,7 +12814,7 @@ var __publicField = (obj, key, value) => {
12791
12814
  clearSelection: clearSelection$6,
12792
12815
  convertTo: convertTo$m
12793
12816
  };
12794
- const logger$4s = getLogger("editor-blocks");
12817
+ const logger$4t = getLogger("editor-blocks");
12795
12818
  class EditorBlocks {
12796
12819
  constructor(editor) {
12797
12820
  __publicField(this, "blocks", /* @__PURE__ */ new Map());
@@ -12800,12 +12823,12 @@ var __publicField = (obj, key, value) => {
12800
12823
  registerBlockClass(blockClass) {
12801
12824
  const type = blockClass.blockType;
12802
12825
  const exists = this.blocks.get(type);
12803
- assert(logger$4s, !exists, `duplicated block type: ${type}`);
12826
+ assert(logger$4t, !exists, `duplicated block type: ${type}`);
12804
12827
  this.blocks.set(type, blockClass);
12805
12828
  }
12806
12829
  getBlockClass(type) {
12807
12830
  const exists = this.blocks.get(type);
12808
- assert(logger$4s, exists, `unknown block type: ${type}`);
12831
+ assert(logger$4t, exists, `unknown block type: ${type}`);
12809
12832
  return exists;
12810
12833
  }
12811
12834
  hasBlock(type) {
@@ -12821,7 +12844,7 @@ var __publicField = (obj, key, value) => {
12821
12844
  }
12822
12845
  const content = blockClass.createBlockContent(this.editor, path, container, blockElement, block);
12823
12846
  if (content.parentElement !== blockElement) {
12824
- logger$4s.warn("content parent is not block");
12847
+ logger$4t.warn("content parent is not block");
12825
12848
  blockElement.appendChild(content);
12826
12849
  }
12827
12850
  this.editor.blockHooks.forEach((hook) => {
@@ -12842,7 +12865,7 @@ var __publicField = (obj, key, value) => {
12842
12865
  return newBlock;
12843
12866
  }
12844
12867
  }
12845
- const logger$4r = getLogger("editor-embeds");
12868
+ const logger$4s = getLogger("editor-embeds");
12846
12869
  class EditorEmbeds {
12847
12870
  constructor(editor) {
12848
12871
  __publicField(this, "objects", /* @__PURE__ */ new Map());
@@ -12851,12 +12874,12 @@ var __publicField = (obj, key, value) => {
12851
12874
  registerEmbedClass(embedClass) {
12852
12875
  const type = embedClass.embedType;
12853
12876
  const exists = this.objects.get(type);
12854
- assert(logger$4r, !exists, `duplicated embed object type: ${type}`);
12877
+ assert(logger$4s, !exists, `duplicated embed object type: ${type}`);
12855
12878
  this.objects.set(type, embedClass);
12856
12879
  }
12857
12880
  getEmbedClass(type) {
12858
12881
  const exists = this.objects.get(type);
12859
- assert(logger$4r, exists, `unknown embed type: ${type}`);
12882
+ assert(logger$4s, exists, `unknown embed type: ${type}`);
12860
12883
  return exists;
12861
12884
  }
12862
12885
  getEmbedClassFromBlock(block) {
@@ -12866,12 +12889,12 @@ var __publicField = (obj, key, value) => {
12866
12889
  this.objects.forEach(callback);
12867
12890
  }
12868
12891
  }
12869
- const logger$4q = getLogger("embed-block");
12892
+ const logger$4r = getLogger("embed-block");
12870
12893
  function createBlockContent$6(editor, path, container, blockElement, blockData) {
12871
12894
  const content = createBlockContentElement(blockElement, "div");
12872
- assert(logger$4q, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
12895
+ assert(logger$4r, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
12873
12896
  const embedBlockData = blockData;
12874
- assert(logger$4q, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
12897
+ assert(logger$4r, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
12875
12898
  const embedClass = editor.editorEmbeds.getEmbedClass(embedBlockData.embedType);
12876
12899
  embedClass.createEmbedContent(editor, content, embedBlockData, path, container, blockElement);
12877
12900
  blockElement.setAttribute("data-embed-type", embedBlockData.embedType);
@@ -12899,7 +12922,7 @@ var __publicField = (obj, key, value) => {
12899
12922
  function getCaretRect$4(block, pos) {
12900
12923
  const content = getBlockContent(block);
12901
12924
  const rect = content.getBoundingClientRect();
12902
- assert(logger$4q, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
12925
+ assert(logger$4r, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
12903
12926
  if (pos.offset === 1) {
12904
12927
  return new DOMRect(rect.right, rect.top, 0, rect.height);
12905
12928
  }
@@ -13039,18 +13062,18 @@ var __publicField = (obj, key, value) => {
13039
13062
  toStandardDoc: toStandardDoc$2,
13040
13063
  getResources: getResources$2
13041
13064
  };
13042
- const logger$4p = getLogger("complex-block-helper");
13065
+ const logger$4q = getLogger("complex-block-helper");
13043
13066
  function complexBlockGetAllChildContainers(editor, block, options) {
13044
13067
  const blockClass = getComplexBlockClass(editor, block);
13045
13068
  return blockClass.getChildContainers(editor, block, options);
13046
13069
  }
13047
13070
  function complexBlockGetSelectedContainers(editor, block, start, end) {
13048
13071
  if (start.isSimple()) {
13049
- assert(logger$4p, end.isSimple(), "invalid start and end position");
13072
+ assert(logger$4q, end.isSimple(), "invalid start and end position");
13050
13073
  return complexBlockGetAllChildContainers(editor, block);
13051
13074
  }
13052
- assert(logger$4p, !start.isSimple(), "invalid start pos");
13053
- assert(logger$4p, !end.isSimple(), "invalid end pos");
13075
+ assert(logger$4q, !start.isSimple(), "invalid start pos");
13076
+ assert(logger$4q, !end.isSimple(), "invalid end pos");
13054
13077
  const blockClass = getComplexBlockClass(editor, block);
13055
13078
  return blockClass.getSelectedContainers(editor, block, start, end);
13056
13079
  }
@@ -13061,11 +13084,11 @@ var __publicField = (obj, key, value) => {
13061
13084
  const parentComplexBlock = getParentBlock(getParentContainer(childBlock));
13062
13085
  if (!parentComplexBlock)
13063
13086
  return false;
13064
- assert(logger$4p, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13087
+ assert(logger$4q, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13065
13088
  const childContainer = getParentContainer(childBlock);
13066
13089
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
13067
13090
  const index2 = childContainers.indexOf(childContainer);
13068
- assert(logger$4p, index2 >= 0, "not valid child container");
13091
+ assert(logger$4q, index2 >= 0, "not valid child container");
13069
13092
  return index2 === 0;
13070
13093
  }
13071
13094
  function complexBlockGetFirstSimpleChild(editor, complexBlock, options) {
@@ -13118,13 +13141,13 @@ var __publicField = (obj, key, value) => {
13118
13141
  return block;
13119
13142
  }
13120
13143
  function findPrevSimpleBlockBeforeChildContainer(editor, childContainer, options) {
13121
- assert(logger$4p, isChildContainer(childContainer), "not a child container");
13144
+ assert(logger$4q, isChildContainer(childContainer), "not a child container");
13122
13145
  const parentComplexBlock = getParentBlock(childContainer);
13123
- assert(logger$4p, parentComplexBlock, "no parent block");
13124
- assert(logger$4p, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13146
+ assert(logger$4q, parentComplexBlock, "no parent block");
13147
+ assert(logger$4q, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13125
13148
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock, options);
13126
13149
  const containerIndex = childContainers.indexOf(childContainer);
13127
- assert(logger$4p, containerIndex !== -1, "child container not found");
13150
+ assert(logger$4q, containerIndex !== -1, "child container not found");
13128
13151
  if (containerIndex === 0) {
13129
13152
  const prevBlock = getPrevBlock(parentComplexBlock);
13130
13153
  if (!prevBlock)
@@ -13142,9 +13165,9 @@ var __publicField = (obj, key, value) => {
13142
13165
  return lastBlock2;
13143
13166
  }
13144
13167
  function complexBlockGetTopChildContainers(editor, complexBlock) {
13145
- assert(logger$4p, isComplexKindBlock(editor, complexBlock), "not a complex block");
13168
+ assert(logger$4q, isComplexKindBlock(editor, complexBlock), "not a complex block");
13146
13169
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
13147
- assert(logger$4p, childContainers.length > 0, "no child container");
13170
+ assert(logger$4q, childContainers.length > 0, "no child container");
13148
13171
  if (childContainers.length === 1) {
13149
13172
  return childContainers;
13150
13173
  }
@@ -13169,9 +13192,9 @@ var __publicField = (obj, key, value) => {
13169
13192
  return ret;
13170
13193
  }
13171
13194
  function complexBlockGetBottomChildContainers(editor, complexBlock) {
13172
- assert(logger$4p, isComplexKindBlock(editor, complexBlock), "not a complex block");
13195
+ assert(logger$4q, isComplexKindBlock(editor, complexBlock), "not a complex block");
13173
13196
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
13174
- assert(logger$4p, childContainers.length > 0, "no child container");
13197
+ assert(logger$4q, childContainers.length > 0, "no child container");
13175
13198
  if (childContainers.length === 1) {
13176
13199
  return childContainers;
13177
13200
  }
@@ -13276,11 +13299,11 @@ var __publicField = (obj, key, value) => {
13276
13299
  return result;
13277
13300
  }
13278
13301
  const anchor = "";
13279
- const logger$4o = getLogger("text-range");
13302
+ const logger$4p = getLogger("text-range");
13280
13303
  function getBlockRangeInfo(block, blockOffset) {
13281
13304
  const getChildRange = (child, offset) => {
13282
13305
  if (isTextBlockContentInsertionChild(child)) {
13283
- assert(logger$4o, offset === 0, `invalid offset for insertion child: ${offset}`);
13306
+ assert(logger$4p, offset === 0, `invalid offset for insertion child: ${offset}`);
13284
13307
  const childOffset = 2;
13285
13308
  return {
13286
13309
  child,
@@ -13289,7 +13312,7 @@ var __publicField = (obj, key, value) => {
13289
13312
  };
13290
13313
  }
13291
13314
  if (isTextBlockContentBoxChild(child)) {
13292
- assert(logger$4o, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
13315
+ assert(logger$4p, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
13293
13316
  const childOffset = offset === 0 ? 1 : 2;
13294
13317
  return {
13295
13318
  child,
@@ -13298,17 +13321,17 @@ var __publicField = (obj, key, value) => {
13298
13321
  };
13299
13322
  }
13300
13323
  const textNode = child.firstChild;
13301
- assert(logger$4o, textNode, "no child node for text child");
13302
- assert(logger$4o, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
13324
+ assert(logger$4p, textNode, "no child node for text child");
13325
+ assert(logger$4p, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
13303
13326
  if (textNode instanceof HTMLBRElement) {
13304
- assert(logger$4o, offset >= 0 && offset <= 0, "invalid offset for text child");
13327
+ assert(logger$4p, offset >= 0 && offset <= 0, "invalid offset for text child");
13305
13328
  return {
13306
13329
  child,
13307
13330
  container: textNode,
13308
13331
  offset
13309
13332
  };
13310
13333
  }
13311
- assert(logger$4o, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
13334
+ assert(logger$4p, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
13312
13335
  return {
13313
13336
  child,
13314
13337
  container: textNode,
@@ -13337,38 +13360,38 @@ var __publicField = (obj, key, value) => {
13337
13360
  }
13338
13361
  start += childLength;
13339
13362
  }
13340
- assert(logger$4o, false, "failed to get range info");
13363
+ assert(logger$4p, false, "failed to get range info");
13341
13364
  }
13342
13365
  function createChildRange(child, start, end) {
13343
13366
  if (start === end) {
13344
- assert(logger$4o, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
13367
+ assert(logger$4p, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
13345
13368
  } else {
13346
- assert(logger$4o, start < end, `invalid start & end: ${start}, ${end}`);
13369
+ assert(logger$4p, start < end, `invalid start & end: ${start}, ${end}`);
13347
13370
  }
13348
13371
  if (isTextBlockContentInsertionChild(child)) {
13349
- assert(logger$4o, start === end, `invalid insertion child range offset: ${start}, ${end}`);
13350
- assert(logger$4o, start === 0, `invalid insertion child range start: ${start}`);
13372
+ assert(logger$4p, start === end, `invalid insertion child range offset: ${start}, ${end}`);
13373
+ assert(logger$4p, start === 0, `invalid insertion child range start: ${start}`);
13351
13374
  const insertionElem = child;
13352
- assert(logger$4o, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
13375
+ assert(logger$4p, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
13353
13376
  const range = createExpandedRange(insertionElem, 1, insertionElem, 2);
13354
13377
  return range;
13355
13378
  }
13356
13379
  if (isTextBlockContentBoxChild(child)) {
13357
- assert(logger$4o, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
13358
- assert(logger$4o, start === 0, `invalid box child range start: ${start}`);
13380
+ assert(logger$4p, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
13381
+ assert(logger$4p, start === 0, `invalid box child range start: ${start}`);
13359
13382
  const box = child;
13360
- assert(logger$4o, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
13383
+ assert(logger$4p, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
13361
13384
  const range = createExpandedRange(box, 1, box, 2);
13362
13385
  return range;
13363
13386
  }
13364
13387
  const length = getTextBlockContentChildTextLength(child);
13365
- assert(logger$4o, end <= length, `invalid child end: ${end}, ${length}`);
13388
+ assert(logger$4p, end <= length, `invalid child end: ${end}, ${length}`);
13366
13389
  const textNode = child.firstChild;
13367
- assert(logger$4o, textNode instanceof Text, "invalid block text child");
13368
- assert(logger$4o, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
13390
+ assert(logger$4p, textNode instanceof Text, "invalid block text child");
13391
+ assert(logger$4p, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
13369
13392
  return createExpandedRange(textNode, start, textNode, end);
13370
13393
  }
13371
- const logger$4n = getLogger("caret-rect");
13394
+ const logger$4o = getLogger("caret-rect");
13372
13395
  function getChildClientRects(block, child) {
13373
13396
  if (isBox(child)) {
13374
13397
  const box = child;
@@ -13377,7 +13400,7 @@ var __publicField = (obj, key, value) => {
13377
13400
  const blockContent = getBlockContent(block);
13378
13401
  const lineHeight = Number.parseFloat(window.getComputedStyle(blockContent).lineHeight) || boxContent.getBoundingClientRect().height;
13379
13402
  const rects = Array.from(boxContent.getClientRects());
13380
- assert(logger$4n, rects.length > 0, "no box client rects");
13403
+ assert(logger$4o, rects.length > 0, "no box client rects");
13381
13404
  const blockRect = blockContent.getBoundingClientRect();
13382
13405
  const firstRect = rects[0];
13383
13406
  const lastRect = new DOMRect(blockRect.left, firstRect.bottom, 1, lineHeight);
@@ -13397,22 +13420,22 @@ var __publicField = (obj, key, value) => {
13397
13420
  const rect2 = getLastClientRect(ranges[0].child);
13398
13421
  return new DOMRect(rect2.right, rect2.top, 1, rect2.height);
13399
13422
  }
13400
- assert(logger$4n, ranges[1], "invalid ranges");
13423
+ assert(logger$4o, ranges[1], "invalid ranges");
13401
13424
  const rect = getFirstClientRect(ranges[1].child);
13402
13425
  return new DOMRect(rect.left, rect.top, 1, rect.height);
13403
13426
  }
13404
13427
  let rangeInfo = ranges[0];
13405
- assert(logger$4n, ranges.length >= 1, "failed to get block range");
13428
+ assert(logger$4o, ranges.length >= 1, "failed to get block range");
13406
13429
  if (ranges.length === 1) {
13407
13430
  rangeInfo = ranges[0];
13408
13431
  } else {
13409
- assert(logger$4n, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
13432
+ assert(logger$4o, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
13410
13433
  if (isTextBlockContentInsertionChild(ranges[ranges.length - 1].child)) {
13411
13434
  rangeInfo = ranges[ranges.length - 1];
13412
13435
  const child = rangeInfo.child;
13413
13436
  const content = getInsertionContent(child);
13414
13437
  const rects2 = content.getClientRects();
13415
- assert(logger$4n, rects2.length >= 1, "no client rects for box content");
13438
+ assert(logger$4o, rects2.length >= 1, "no client rects for box content");
13416
13439
  const rect = rects2[rects2.length - 1];
13417
13440
  return new DOMRect(rect.right, rect.y, 1, rect.height);
13418
13441
  }
@@ -13429,9 +13452,9 @@ var __publicField = (obj, key, value) => {
13429
13452
  }
13430
13453
  }
13431
13454
  if (rangeInfo.container instanceof HTMLBRElement) {
13432
- assert(logger$4n, pos.offset === 0, "invalid offset for empty block text");
13455
+ assert(logger$4o, pos.offset === 0, "invalid offset for empty block text");
13433
13456
  const parent = rangeInfo.container.parentElement;
13434
- assert(logger$4n, parent, "invalid br parent");
13457
+ assert(logger$4o, parent, "invalid br parent");
13435
13458
  const rect = parent.getBoundingClientRect();
13436
13459
  const ret = new DOMRect(rect.left, rect.top, 1, rect.height);
13437
13460
  return ret;
@@ -13439,11 +13462,11 @@ var __publicField = (obj, key, value) => {
13439
13462
  const range = createRange(rangeInfo.container, rangeInfo.offset);
13440
13463
  const rects = Array.from(range.getClientRects());
13441
13464
  if (rects.length === 0) {
13442
- assert(logger$4n, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
13443
- assert(logger$4n, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
13465
+ assert(logger$4o, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
13466
+ assert(logger$4o, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
13444
13467
  const child = rangeInfo.child;
13445
13468
  const rects2 = getChildClientRects(block, child);
13446
- assert(logger$4n, rects2.length >= 1, "no client rects for box content");
13469
+ assert(logger$4o, rects2.length >= 1, "no client rects for box content");
13447
13470
  if (rangeInfo.offset === 1) {
13448
13471
  const rect2 = rects2[0];
13449
13472
  return new DOMRect(rect2.x, rect2.y, 1, rect2.height);
@@ -13489,7 +13512,7 @@ var __publicField = (obj, key, value) => {
13489
13512
  });
13490
13513
  }
13491
13514
  }
13492
- assert(logger$4n, rects.length > 0, "no client rects for range");
13515
+ assert(logger$4o, rects.length > 0, "no client rects for range");
13493
13516
  if (pos.type === "home") {
13494
13517
  return rects[rects.length - 1];
13495
13518
  }
@@ -13569,13 +13592,13 @@ var __publicField = (obj, key, value) => {
13569
13592
  };
13570
13593
  }
13571
13594
  }
13572
- const logger$4m = getLogger("selection-range");
13595
+ const logger$4n = getLogger("selection-range");
13573
13596
  function createEditorSelectionRange(editor, options) {
13574
13597
  const { anchor: anchor2, focus } = options;
13575
13598
  if (anchor2 instanceof EditorSimpleBlockPosition && focus instanceof EditorSimpleBlockPosition) {
13576
13599
  return new EditorSimpleSelectionRange(editor, { anchor: anchor2, focus });
13577
13600
  }
13578
- assert(logger$4m, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
13601
+ assert(logger$4n, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
13579
13602
  return new EditorComplexSelectionRange(editor, { anchor: anchor2, focus });
13580
13603
  }
13581
13604
  function createBlockSimpleRange(editor, block, anchor2, focus) {
@@ -13597,7 +13620,7 @@ var __publicField = (obj, key, value) => {
13597
13620
  const focus = createSimpleBlockPosition(range.focus.blockId, range.focus.offset, "normal");
13598
13621
  return createEditorSelectionRange(editor, { anchor: anchor2, focus });
13599
13622
  }
13600
- const logger$4l = getLogger("range-from-point");
13623
+ const logger$4m = getLogger("range-from-point");
13601
13624
  function getBlockRangeFromPoint(editor, pointX, pointY, dragging) {
13602
13625
  const yOffsets = [0, -12, 12];
13603
13626
  let x = pointX;
@@ -13629,7 +13652,7 @@ var __publicField = (obj, key, value) => {
13629
13652
  const rect = elem.getBoundingClientRect();
13630
13653
  if (rect.width && rect.top && i === 0) {
13631
13654
  if (rect.left + rect.width < x || rect.top + rect.height < y) {
13632
- logger$4l.debug("click on scrollbar, out of element rect");
13655
+ logger$4m.debug("click on scrollbar, out of element rect");
13633
13656
  return null;
13634
13657
  }
13635
13658
  }
@@ -13667,7 +13690,7 @@ var __publicField = (obj, key, value) => {
13667
13690
  let block = getLastChildBlock(container);
13668
13691
  if (!isVisibleBlock(block)) {
13669
13692
  const preBlock = getPrevVisibleBlock(block);
13670
- assert(logger$4l, preBlock, "container must have visible block");
13693
+ assert(logger$4m, preBlock, "container must have visible block");
13671
13694
  block = preBlock;
13672
13695
  }
13673
13696
  const range = getBlockClass(editor, block).getRangeFromPoint(editor, block, x, block.getBoundingClientRect().bottom - 4);
@@ -13686,7 +13709,7 @@ var __publicField = (obj, key, value) => {
13686
13709
  if (range instanceof EditorSimpleSelectionRange) {
13687
13710
  return range;
13688
13711
  }
13689
- assert(logger$4l, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
13712
+ assert(logger$4m, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
13690
13713
  const complexRange = range;
13691
13714
  const container2 = editor.getContainerById(complexRange.start.childContainerId);
13692
13715
  return getRangeInContainer(editor, container2, x, y);
@@ -13709,7 +13732,7 @@ var __publicField = (obj, key, value) => {
13709
13732
  });
13710
13733
  return getRangeInContainer(editor, container, x, y);
13711
13734
  }
13712
- const logger$4k = getLogger("adjust-selection-pos");
13735
+ const logger$4l = getLogger("adjust-selection-pos");
13713
13736
  function getParentContainers(block) {
13714
13737
  const containers = [];
13715
13738
  while (block) {
@@ -13719,10 +13742,10 @@ var __publicField = (obj, key, value) => {
13719
13742
  return containers;
13720
13743
  }
13721
13744
  const newBlock = getParentBlock(container);
13722
- assert(logger$4k, newBlock, "child container has not parent container");
13745
+ assert(logger$4l, newBlock, "child container has not parent container");
13723
13746
  block = newBlock;
13724
13747
  }
13725
- assert(logger$4k, false, "should not come here: getParentContainers");
13748
+ assert(logger$4l, false, "should not come here: getParentContainers");
13726
13749
  }
13727
13750
  function getParentBlockInContainer(container, block) {
13728
13751
  while (block) {
@@ -13731,16 +13754,16 @@ var __publicField = (obj, key, value) => {
13731
13754
  return block;
13732
13755
  }
13733
13756
  const newBlock = getParentBlock(parent);
13734
- assert(logger$4k, newBlock, "could not find parent block for a child container");
13757
+ assert(logger$4l, newBlock, "could not find parent block for a child container");
13735
13758
  block = newBlock;
13736
13759
  }
13737
- assert(logger$4k, false, "no parent block in specified container");
13760
+ assert(logger$4l, false, "no parent block in specified container");
13738
13761
  }
13739
13762
  function getClosestParentBlock(block1, block2) {
13740
13763
  const containers1 = getParentContainers(block1);
13741
13764
  const containers2 = getParentContainers(block2);
13742
- assert(logger$4k, containers1.length > 0 && containers2.length > 0, "block has not parent container");
13743
- assert(logger$4k, containers1[0] === containers2[0], "root container does not equal");
13765
+ assert(logger$4l, containers1.length > 0 && containers2.length > 0, "block has not parent container");
13766
+ assert(logger$4l, containers1[0] === containers2[0], "root container does not equal");
13744
13767
  let parentContainer = containers1[0];
13745
13768
  for (let i = 1; i < containers1.length || containers2.length; i++) {
13746
13769
  if (containers1[i] === containers2[i]) {
@@ -13759,23 +13782,23 @@ var __publicField = (obj, key, value) => {
13759
13782
  }
13760
13783
  function getParentContainerInComplexBlock(parentComplexBlock, element) {
13761
13784
  let block = getParentBlock(element);
13762
- assert(logger$4k, block, "element is not in a block");
13785
+ assert(logger$4l, block, "element is not in a block");
13763
13786
  while (block) {
13764
13787
  const container = getParentContainer(block);
13765
- assert(logger$4k, isChildContainer(container), "not a child container");
13788
+ assert(logger$4l, isChildContainer(container), "not a child container");
13766
13789
  const parentBlock = getParentBlock(container);
13767
- assert(logger$4k, parentBlock, "child container has not parent block");
13790
+ assert(logger$4l, parentBlock, "child container has not parent block");
13768
13791
  if (parentBlock === parentComplexBlock) {
13769
13792
  return container;
13770
13793
  }
13771
13794
  block = parentBlock;
13772
13795
  }
13773
- assert(logger$4k, false, "failed to find parent container in complex block");
13796
+ assert(logger$4l, false, "failed to find parent container in complex block");
13774
13797
  }
13775
13798
  function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
13776
13799
  const blockId = getBlockId(complexBlock);
13777
- assert(logger$4k, blockId === anchor2.blockId, "invalid start pos");
13778
- assert(logger$4k, blockId === focus.blockId, "invalid end pos");
13800
+ assert(logger$4l, blockId === anchor2.blockId, "invalid start pos");
13801
+ assert(logger$4l, blockId === focus.blockId, "invalid end pos");
13779
13802
  const blockClass = getComplexBlockClass(editor, complexBlock);
13780
13803
  if (blockClass.adjustSelectionPos) {
13781
13804
  return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
@@ -13809,8 +13832,8 @@ var __publicField = (obj, key, value) => {
13809
13832
  if (focus instanceof EditorComplexBlockPosition) {
13810
13833
  focus = createSimpleBlockPosition(focusBlock, getBlockTextLength$6(editor, focusBlock), "end");
13811
13834
  }
13812
- assert(logger$4k, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
13813
- assert(logger$4k, focus instanceof EditorSimpleBlockPosition, "not valid position type");
13835
+ assert(logger$4l, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
13836
+ assert(logger$4l, focus instanceof EditorSimpleBlockPosition, "not valid position type");
13814
13837
  return {
13815
13838
  anchor: anchor2,
13816
13839
  focus
@@ -13864,7 +13887,7 @@ var __publicField = (obj, key, value) => {
13864
13887
  focus
13865
13888
  };
13866
13889
  }
13867
- const logger$4j = getLogger("core");
13890
+ const logger$4k = getLogger("core");
13868
13891
  function createBlockAnchor(editor, block, id, refClientRect) {
13869
13892
  const tools = getBlockTools(block);
13870
13893
  let elem = tools.querySelector(`.block-anchor[data-id=${id}]`);
@@ -13882,7 +13905,7 @@ var __publicField = (obj, key, value) => {
13882
13905
  return elem;
13883
13906
  }
13884
13907
  function createBlockCaretAnchor(editor, block, offset, id) {
13885
- assert(logger$4j, isTextKindBlock(editor, block), "not a text kind block");
13908
+ assert(logger$4k, isTextKindBlock(editor, block), "not a text kind block");
13886
13909
  const caretRect = getTextCaretRect(block, createSimpleBlockPosition(block, offset, "normal"));
13887
13910
  const blockRect = block.getBoundingClientRect();
13888
13911
  const tools = getBlockTools(block);
@@ -14241,19 +14264,19 @@ var __publicField = (obj, key, value) => {
14241
14264
  return result + (index2 ? "-" : "") + word.toLowerCase();
14242
14265
  });
14243
14266
  const kebabCase$1 = kebabCase;
14244
- const logger$4i = getLogger("box");
14267
+ const logger$4j = getLogger("box");
14245
14268
  function isBoxOp(op) {
14246
14269
  if (!op.attributes)
14247
14270
  return false;
14248
14271
  if (!op.attributes.box)
14249
14272
  return false;
14250
- assert(logger$4i, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
14251
- assert(logger$4i, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
14273
+ assert(logger$4j, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
14274
+ assert(logger$4j, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
14252
14275
  return true;
14253
14276
  }
14254
- const logger$4h = getLogger("text-op");
14277
+ const logger$4i = getLogger("text-op");
14255
14278
  function getOpLength(op) {
14256
- assert(logger$4h, typeof op.insert === "string", "invalid op, no insert");
14279
+ assert(logger$4i, typeof op.insert === "string", "invalid op, no insert");
14257
14280
  return op.insert.length;
14258
14281
  }
14259
14282
  function getOpAt(text2, offset) {
@@ -14261,7 +14284,7 @@ var __publicField = (obj, key, value) => {
14261
14284
  let pos = 0;
14262
14285
  for (let i = 0; i < ops.length; i++) {
14263
14286
  const op = ops[i];
14264
- assert(logger$4h, typeof op.insert === "string", "invalid text op, no insert");
14287
+ assert(logger$4i, typeof op.insert === "string", "invalid text op, no insert");
14265
14288
  const end = pos + getOpLength(op);
14266
14289
  if (end > offset) {
14267
14290
  return [op];
@@ -14277,22 +14300,22 @@ var __publicField = (obj, key, value) => {
14277
14300
  }
14278
14301
  return [];
14279
14302
  }
14280
- const logger$4g = getLogger("rich-text-length");
14303
+ const logger$4h = getLogger("rich-text-length");
14281
14304
  function getTextOpLength(op) {
14282
- assert(logger$4g, typeof op.insert === "string", "op.insert is not string");
14305
+ assert(logger$4h, typeof op.insert === "string", "op.insert is not string");
14283
14306
  return op.insert.length;
14284
14307
  }
14285
14308
  function getTextLength(ops) {
14286
14309
  let count = 0;
14287
14310
  ops.forEach((op) => {
14288
14311
  if (op.insert) {
14289
- assert(logger$4g, typeof op.insert === "string", "op.insert is not string");
14312
+ assert(logger$4h, typeof op.insert === "string", "op.insert is not string");
14290
14313
  count += getTextOpLength(op);
14291
14314
  }
14292
14315
  });
14293
14316
  return count;
14294
14317
  }
14295
- const logger$4f = getLogger("split-text");
14318
+ const logger$4g = getLogger("split-text");
14296
14319
  function splitText(ops, offset, splitResult) {
14297
14320
  ops = cloneDeep__default.default(ops);
14298
14321
  if (offset === 0) {
@@ -14310,8 +14333,8 @@ var __publicField = (obj, key, value) => {
14310
14333
  let counted = 0;
14311
14334
  for (let i = 0; i < ops.length; i++) {
14312
14335
  const op = ops[i];
14313
- assert(logger$4f, typeof op === "object", `invalid op type, ${typeof op}`);
14314
- assert(logger$4f, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
14336
+ assert(logger$4g, typeof op === "object", `invalid op type, ${typeof op}`);
14337
+ assert(logger$4g, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
14315
14338
  const subLen = getTextOpLength(op);
14316
14339
  if (counted + subLen < offset) {
14317
14340
  counted += subLen;
@@ -14321,18 +14344,18 @@ var __publicField = (obj, key, value) => {
14321
14344
  right: ops.slice(i + 1)
14322
14345
  };
14323
14346
  } else {
14324
- assert(logger$4f, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
14347
+ assert(logger$4g, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
14325
14348
  const splitIndex = offset - counted;
14326
14349
  const copied = cloneDeep__default.default(op);
14327
- assert(logger$4f, copied.insert, "no copied.insert");
14328
- assert(logger$4f, typeof copied.insert === "string", "invalid copied.insert type");
14350
+ assert(logger$4g, copied.insert, "no copied.insert");
14351
+ assert(logger$4g, typeof copied.insert === "string", "invalid copied.insert type");
14329
14352
  copied.insert = copied.insert.substr(0, splitIndex);
14330
14353
  op.insert = op.insert.substr(splitIndex);
14331
14354
  if (copied.insert === "") {
14332
- assert(logger$4f, false, "invalid copied.insert, is empty string");
14355
+ assert(logger$4g, false, "invalid copied.insert, is empty string");
14333
14356
  }
14334
14357
  if (op.insert === "") {
14335
- assert(logger$4f, false, "invalid op.insert, is empty string");
14358
+ assert(logger$4g, false, "invalid op.insert, is empty string");
14336
14359
  }
14337
14360
  const right = [
14338
14361
  op,
@@ -14351,9 +14374,9 @@ var __publicField = (obj, key, value) => {
14351
14374
  throw new Error(`invalid split offset: ${offset}, ${JSON.stringify(ops)}`);
14352
14375
  }
14353
14376
  function splitToThree(text2, offset, length) {
14354
- assert(logger$4f, offset >= 0, "invalid offset, < 0");
14355
- assert(logger$4f, length > 0, "invalid length, <= 0");
14356
- assert(logger$4f, offset + length <= getTextLength(text2), "invalid offset + length < text length");
14377
+ assert(logger$4g, offset >= 0, "invalid offset, < 0");
14378
+ assert(logger$4g, length > 0, "invalid length, <= 0");
14379
+ assert(logger$4g, offset + length <= getTextLength(text2), "invalid offset + length < text length");
14357
14380
  const { left: temp, right } = splitText(text2, offset + length);
14358
14381
  const { left, right: middle } = splitText(temp, offset);
14359
14382
  return { left, middle, right };
@@ -14576,9 +14599,9 @@ var __publicField = (obj, key, value) => {
14576
14599
  }
14577
14600
  return [color, backgroundColor];
14578
14601
  }
14579
- const logger$4e = getLogger("text-block-content");
14602
+ const logger$4f = getLogger("text-block-content");
14580
14603
  function updateBlockContentCore(editor, blockPath, content, blockText, insertions) {
14581
- assert(logger$4e, blockText, "no text for block");
14604
+ assert(logger$4f, blockText, "no text for block");
14582
14605
  if (blockText.length === 0 && (!insertions || insertions.size === 0)) {
14583
14606
  content.innerHTML = "<span><br></span>";
14584
14607
  return;
@@ -14610,9 +14633,9 @@ var __publicField = (obj, key, value) => {
14610
14633
  for (let i2 = 0; i2 < text2.length; i2++) {
14611
14634
  const op = text2[i2];
14612
14635
  if (isBoxOp(op)) {
14613
- assert(logger$4e, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
14636
+ assert(logger$4f, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
14614
14637
  const span2 = editor.editorBoxes.createBox(content, op.attributes);
14615
- assert(logger$4e, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
14638
+ assert(logger$4f, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
14616
14639
  const ret = editor.editorBlockRenders.renderBox(blockPath, op.attributes);
14617
14640
  if (ret.classes) {
14618
14641
  addClass(span2, ...ret.classes);
@@ -14630,7 +14653,7 @@ var __publicField = (obj, key, value) => {
14630
14653
  fragment.appendChild(span2);
14631
14654
  continue;
14632
14655
  }
14633
- assert(logger$4e, op.insert, `no insert in op: ${JSON.stringify(op)}`);
14656
+ assert(logger$4f, op.insert, `no insert in op: ${JSON.stringify(op)}`);
14634
14657
  const span = createElement("span", ["text"], fragment, op.insert);
14635
14658
  if (op.attributes) {
14636
14659
  const ret = editor.editorBlockRenders.renderText(blockPath, op.attributes);
@@ -14661,7 +14684,7 @@ var __publicField = (obj, key, value) => {
14661
14684
  const compositionText = editor.compositingText;
14662
14685
  if (compositionText) {
14663
14686
  const pos = editor.selection.range.start;
14664
- assert(logger$4e, pos.isSimple(), "not an simple position while compositing");
14687
+ assert(logger$4f, pos.isSimple(), "not an simple position while compositing");
14665
14688
  if (pos.blockId === blockId) {
14666
14689
  const attributes = getAttributesAt(text2, 0);
14667
14690
  insertions.set(pos.offset, [{
@@ -14677,11 +14700,11 @@ var __publicField = (obj, key, value) => {
14677
14700
  function clearAllTempCompositionText(editor) {
14678
14701
  const children = editor.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');
14679
14702
  if (children.length) {
14680
- logger$4e.debug(`remove ${children.length} temp composition span`);
14703
+ logger$4f.debug(`remove ${children.length} temp composition span`);
14681
14704
  }
14682
14705
  Array.from(children).forEach((c) => c.remove());
14683
14706
  }
14684
- const logger$4d = getLogger("client-rects");
14707
+ const logger$4e = getLogger("client-rects");
14685
14708
  function getChildrenOffsets(block) {
14686
14709
  const children = getTextBlockContentChildren(block);
14687
14710
  let start = 0;
@@ -14699,15 +14722,15 @@ var __publicField = (obj, key, value) => {
14699
14722
  return ret;
14700
14723
  }
14701
14724
  function getChildrenInRange(editor, block, from, to) {
14702
- assert(logger$4d, from < to, `invalid from & to: ${from}, ${to}`);
14725
+ assert(logger$4e, from < to, `invalid from & to: ${from}, ${to}`);
14703
14726
  const blockLength = getBlockTextLength$6(editor, block);
14704
- assert(logger$4d, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
14727
+ assert(logger$4e, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
14705
14728
  const offsets = getChildrenOffsets(block);
14706
14729
  const startIndex = offsets.findIndex((c) => c.startBlockOffset <= from && from < c.endBlockOffset);
14707
14730
  const endIndex = offsets.findIndex((c) => c.startBlockOffset < to && to <= c.endBlockOffset);
14708
- assert(logger$4d, startIndex !== -1, "failed to find start child");
14709
- assert(logger$4d, endIndex !== -1, "failed to find end child");
14710
- assert(logger$4d, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
14731
+ assert(logger$4e, startIndex !== -1, "failed to find start child");
14732
+ assert(logger$4e, endIndex !== -1, "failed to find end child");
14733
+ assert(logger$4e, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
14711
14734
  if (startIndex === endIndex) {
14712
14735
  const child = offsets[startIndex];
14713
14736
  return [{
@@ -14789,16 +14812,16 @@ var __publicField = (obj, key, value) => {
14789
14812
  return rects;
14790
14813
  }
14791
14814
  function getRangeClientRects(editor, block, range) {
14792
- assert(logger$4d, range instanceof EditorSimpleSelectionRange, "invalid range");
14815
+ assert(logger$4e, range instanceof EditorSimpleSelectionRange, "invalid range");
14793
14816
  const start = range.start;
14794
14817
  const end = range.end;
14795
- assert(logger$4d, start.isSimple(), "text block only allow simple position");
14796
- assert(logger$4d, end.isSimple(), "text block only allow simple position");
14797
- assert(logger$4d, start.blockId === end.blockId, "only allow update one text block selection");
14798
- assert(logger$4d, start.blockId === getBlockId(block), "only allow update one text block selection");
14818
+ assert(logger$4e, start.isSimple(), "text block only allow simple position");
14819
+ assert(logger$4e, end.isSimple(), "text block only allow simple position");
14820
+ assert(logger$4e, start.blockId === end.blockId, "only allow update one text block selection");
14821
+ assert(logger$4e, start.blockId === getBlockId(block), "only allow update one text block selection");
14799
14822
  return getClientRects$2(editor, block, start, end);
14800
14823
  }
14801
- const logger$4c = getLogger("selection-background");
14824
+ const logger$4d = getLogger("selection-background");
14802
14825
  function getLineHeight(elem) {
14803
14826
  const style2 = window.getComputedStyle(elem);
14804
14827
  const lineHeightStyle = style2.getPropertyValue("line-height");
@@ -14818,9 +14841,9 @@ var __publicField = (obj, key, value) => {
14818
14841
  return lineHeight;
14819
14842
  }
14820
14843
  function updateSelection$4(editor, block, start, end) {
14821
- assert(logger$4c, start.isSimple(), "text block only allow simple position");
14822
- assert(logger$4c, end.isSimple(), "text block only allow simple position");
14823
- assert(logger$4c, start.blockId === end.blockId, "only allow update one text block selection");
14844
+ assert(logger$4d, start.isSimple(), "text block only allow simple position");
14845
+ assert(logger$4d, end.isSimple(), "text block only allow simple position");
14846
+ assert(logger$4d, start.blockId === end.blockId, "only allow update one text block selection");
14824
14847
  const from = start.offset;
14825
14848
  const to = end.offset;
14826
14849
  if (from === to) {
@@ -14879,7 +14902,7 @@ var __publicField = (obj, key, value) => {
14879
14902
  }
14880
14903
  });
14881
14904
  }
14882
- const logger$4b = getLogger("line-breaker");
14905
+ const logger$4c = getLogger("line-breaker");
14883
14906
  function mergeTextRects(rects) {
14884
14907
  const result = [];
14885
14908
  let lastRect = null;
@@ -15006,7 +15029,7 @@ var __publicField = (obj, key, value) => {
15006
15029
  }
15007
15030
  const textChild = child;
15008
15031
  const rects = mergeTextRects(textChild.getClientRects());
15009
- assert(logger$4b, rects.length > 0, "invalid text child dom");
15032
+ assert(logger$4c, rects.length > 0, "invalid text child dom");
15010
15033
  if (rects.length === 1) {
15011
15034
  const nextChild = children[i + 1];
15012
15035
  if (!nextChild) {
@@ -15031,10 +15054,10 @@ var __publicField = (obj, key, value) => {
15031
15054
  continue;
15032
15055
  }
15033
15056
  const textNode = textChild.firstChild;
15034
- assert(logger$4b, textNode, "invalid text child, no text node");
15035
- assert(logger$4b, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
15057
+ assert(logger$4c, textNode, "invalid text child, no text node");
15058
+ assert(logger$4c, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
15036
15059
  const textChildLength = getTextBlockContentChildTextLength(textChild);
15037
- assert(logger$4b, textNode.data.length === textChildLength, "text node data length not equal child text length");
15060
+ assert(logger$4c, textNode.data.length === textChildLength, "text node data length not equal child text length");
15038
15061
  const textRects = getTextRects(textNode);
15039
15062
  for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
15040
15063
  const rect = textRects[rIndex];
@@ -15076,7 +15099,7 @@ var __publicField = (obj, key, value) => {
15076
15099
  }
15077
15100
  }
15078
15101
  }
15079
- assert(logger$4b, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
15102
+ assert(logger$4c, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
15080
15103
  return {
15081
15104
  lineIndex: lineBreaks.length,
15082
15105
  lineBreaks
@@ -23849,7 +23872,7 @@ var __publicField = (obj, key, value) => {
23849
23872
  const Graphemer_1 = __importDefault(Graphemer$1);
23850
23873
  var _default = lib$1.default = Graphemer_1.default;
23851
23874
  const splitter = new _default();
23852
- const logger$4a = getLogger("text-offset");
23875
+ const logger$4b = getLogger("text-offset");
23853
23876
  function getChildOffset(block, child) {
23854
23877
  const children = getTextBlockContentChildren(block);
23855
23878
  let start = 0;
@@ -23865,26 +23888,26 @@ var __publicField = (obj, key, value) => {
23865
23888
  }
23866
23889
  start += testLength;
23867
23890
  }
23868
- assert(logger$4a, false, "can not find child in children");
23891
+ assert(logger$4b, false, "can not find child in children");
23869
23892
  }
23870
23893
  function isValidOffset(block, blockOffset) {
23871
- assert(logger$4a, blockOffset >= 0, `invalid offset: ${blockOffset}`);
23894
+ assert(logger$4b, blockOffset >= 0, `invalid offset: ${blockOffset}`);
23872
23895
  const childInfo = getTextBlockChild(block, blockOffset);
23873
23896
  const { prev, next: next2, offset } = childInfo;
23874
23897
  if (!prev && !next2) {
23875
- assert(logger$4a, false, "invalid offset, no prev & next child at offset");
23898
+ assert(logger$4b, false, "invalid offset, no prev & next child at offset");
23876
23899
  }
23877
23900
  if (prev !== next2) {
23878
23901
  return true;
23879
23902
  }
23880
23903
  const child = prev;
23881
- assert(logger$4a, child, "no child");
23904
+ assert(logger$4b, child, "no child");
23882
23905
  if (isTextBlockContentBoxChild(child)) {
23883
- assert(logger$4a, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
23906
+ assert(logger$4b, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
23884
23907
  return true;
23885
23908
  }
23886
23909
  const text2 = child.textContent;
23887
- assert(logger$4a, text2, "no content for text child");
23910
+ assert(logger$4b, text2, "no content for text child");
23888
23911
  const chars = splitter.splitGraphemes(text2);
23889
23912
  const validOffsets = /* @__PURE__ */ new Set();
23890
23913
  let start = 0;
@@ -23914,7 +23937,7 @@ var __publicField = (obj, key, value) => {
23914
23937
  }
23915
23938
  function getNextValidOffset(block, blockOffset) {
23916
23939
  const length = getTextBlockLength(block);
23917
- assert(logger$4a, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
23940
+ assert(logger$4b, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
23918
23941
  if (blockOffset === length) {
23919
23942
  return length;
23920
23943
  }
@@ -23928,7 +23951,7 @@ var __publicField = (obj, key, value) => {
23928
23951
  }
23929
23952
  return ret;
23930
23953
  }
23931
- const logger$49 = getLogger("line-offset");
23954
+ const logger$4a = getLogger("line-offset");
23932
23955
  function getLineOffsets(block) {
23933
23956
  const lineBreaks = getLineBreaks(block);
23934
23957
  const ret = [];
@@ -23949,7 +23972,7 @@ var __publicField = (obj, key, value) => {
23949
23972
  }
23950
23973
  function getLineOffset(block, lineIndex) {
23951
23974
  const lines = getLineOffsets(block);
23952
- assert(logger$49, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
23975
+ assert(logger$4a, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
23953
23976
  return lines[lineIndex];
23954
23977
  }
23955
23978
  function getLineOffsetByPos(block, pos) {
@@ -24006,7 +24029,7 @@ var __publicField = (obj, key, value) => {
24006
24029
  function getLineCount(block) {
24007
24030
  return getLineOffsets(block).length;
24008
24031
  }
24009
- const logger$48 = getLogger("find-text-position");
24032
+ const logger$49 = getLogger("find-text-position");
24010
24033
  function isWrappedLine(block, lineIndex) {
24011
24034
  const { start, end } = getLineOffset(block, lineIndex);
24012
24035
  const blockId = getBlockId(block);
@@ -24017,13 +24040,13 @@ var __publicField = (obj, key, value) => {
24017
24040
  return false;
24018
24041
  }
24019
24042
  const childInfo = getTextBlockChild(block, start);
24020
- assert(logger$48, childInfo.next, "no next child at offset");
24021
- assert(logger$48, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
24043
+ assert(logger$49, childInfo.next, "no next child at offset");
24044
+ assert(logger$49, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
24022
24045
  return true;
24023
24046
  }
24024
24047
  function getWrappedLineOffsets(block, lineIndex) {
24025
24048
  const blockId = getBlockId(block);
24026
- assert(logger$48, isWrappedLine(block, lineIndex), "line is not wrapped");
24049
+ assert(logger$49, isWrappedLine(block, lineIndex), "line is not wrapped");
24027
24050
  const { start, end } = getLineOffset(block, lineIndex);
24028
24051
  const homePos = createSimpleBlockPosition(blockId, start, "home");
24029
24052
  for (let offset = start + 1; offset <= end; offset += 1) {
@@ -24038,11 +24061,11 @@ var __publicField = (obj, key, value) => {
24038
24061
  return offset - 1;
24039
24062
  }
24040
24063
  }
24041
- assert(logger$48, false, "failed to find wrapped offset");
24064
+ assert(logger$49, false, "failed to find wrapped offset");
24042
24065
  return 0;
24043
24066
  }
24044
24067
  function findTextPositionInLine(editor, block, lineIndex, sourceBlock, pos, findDirection, suggestedX) {
24045
- assert(logger$48, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
24068
+ assert(logger$49, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
24046
24069
  const { start, end } = getLineOffset(block, lineIndex);
24047
24070
  let from = start;
24048
24071
  const blockId = getBlockId(block);
@@ -24084,11 +24107,11 @@ var __publicField = (obj, key, value) => {
24084
24107
  return retPos;
24085
24108
  }
24086
24109
  function findPrevTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
24087
- assert(logger$48, isTextKindBlock(editor, block), "not a text block");
24110
+ assert(logger$49, isTextKindBlock(editor, block), "not a text block");
24088
24111
  return findTextPositionInLine(editor, block, getLineCount(block) - 1, sourceBlock, pos, "up", suggestedX);
24089
24112
  }
24090
24113
  function findNextTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
24091
- assert(logger$48, isTextKindBlock(editor, block), "not a text block");
24114
+ assert(logger$49, isTextKindBlock(editor, block), "not a text block");
24092
24115
  return findTextPositionInLine(editor, block, 0, sourceBlock, pos, "down", suggestedX);
24093
24116
  }
24094
24117
  function moveDown(editor, block, position, suggestedX) {
@@ -24196,7 +24219,7 @@ var __publicField = (obj, key, value) => {
24196
24219
  }
24197
24220
  return pos;
24198
24221
  }
24199
- const logger$47 = getLogger("move-caret");
24222
+ const logger$48 = getLogger("move-caret");
24200
24223
  function moveTextCaret(editor, block, position, direction) {
24201
24224
  if (direction === "ArrowLeft") {
24202
24225
  const ret = moveLeft(block, position);
@@ -24226,9 +24249,9 @@ var __publicField = (obj, key, value) => {
24226
24249
  }
24227
24250
  return createSimpleBlockPosition(getBlockId(block), ret.offset, ret.type);
24228
24251
  }
24229
- assert(logger$47, false, `invalid navigation direction: ${direction}`);
24252
+ assert(logger$48, false, `invalid navigation direction: ${direction}`);
24230
24253
  }
24231
- const logger$46 = getLogger("text-range");
24254
+ const logger$47 = getLogger("text-range");
24232
24255
  function getBlockRects(block) {
24233
24256
  const ret = [];
24234
24257
  const children = getTextBlockContentChildren(block);
@@ -24286,9 +24309,9 @@ var __publicField = (obj, key, value) => {
24286
24309
  return null;
24287
24310
  }
24288
24311
  const children = getTextBlockContentChildren(block);
24289
- assert(logger$46, children.indexOf(child) !== -1, "failed to find child in children");
24312
+ assert(logger$47, children.indexOf(child) !== -1, "failed to find child in children");
24290
24313
  const offsetInfo = getChildOffset(block, child);
24291
- assert(logger$46, offsetInfo, "failed to get child offset");
24314
+ assert(logger$47, offsetInfo, "failed to get child offset");
24292
24315
  const { start } = offsetInfo;
24293
24316
  let offset;
24294
24317
  let length;
@@ -24304,7 +24327,7 @@ var __publicField = (obj, key, value) => {
24304
24327
  }
24305
24328
  length = 0;
24306
24329
  } else {
24307
- assert(logger$46, child.firstChild instanceof Text, "child is not text");
24330
+ assert(logger$47, child.firstChild instanceof Text, "child is not text");
24308
24331
  offset = start + textNodeOffsetFromPoint(child.firstChild, x, y);
24309
24332
  length = 0;
24310
24333
  }
@@ -24328,9 +24351,9 @@ var __publicField = (obj, key, value) => {
24328
24351
  }
24329
24352
  return new EditorSimpleSelectionRange(editor, { anchor: startPos, focus: endPos != null ? endPos : startPos });
24330
24353
  }
24331
- const logger$45 = getLogger("create-text-op");
24354
+ const logger$46 = getLogger("create-text-op");
24332
24355
  function createTextOp(text2, attributes) {
24333
- assert(logger$45, text2, "text is empty");
24356
+ assert(logger$46, text2, "text is empty");
24334
24357
  const ret = {
24335
24358
  insert: text2
24336
24359
  };
@@ -24353,7 +24376,7 @@ var __publicField = (obj, key, value) => {
24353
24376
  }
24354
24377
  return result;
24355
24378
  }
24356
- const logger$44 = getLogger("merge-ops");
24379
+ const logger$45 = getLogger("merge-ops");
24357
24380
  function mergeOps(text2) {
24358
24381
  if (text2.length <= 1) {
24359
24382
  return text2;
@@ -24375,10 +24398,10 @@ var __publicField = (obj, key, value) => {
24375
24398
  return false;
24376
24399
  }
24377
24400
  if (op1.attributes === void 0) {
24378
- assert(logger$44, op2.attributes === void 0, "op2.attributes is not undefined");
24401
+ assert(logger$45, op2.attributes === void 0, "op2.attributes is not undefined");
24379
24402
  return true;
24380
24403
  }
24381
- assert(logger$44, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
24404
+ assert(logger$45, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
24382
24405
  return isEqual__default.default(op1.attributes, op2.attributes);
24383
24406
  };
24384
24407
  const newOps = [];
@@ -24387,8 +24410,8 @@ var __publicField = (obj, key, value) => {
24387
24410
  for (let i = 1; i < text2.length; i += 1) {
24388
24411
  const op = text2[i];
24389
24412
  if (isSameTypeOp(before, op)) {
24390
- assert(logger$44, typeof before.insert === "string", "before.insert is not string");
24391
- assert(logger$44, typeof op.insert === "string", "op.insert is not string");
24413
+ assert(logger$45, typeof before.insert === "string", "before.insert is not string");
24414
+ assert(logger$45, typeof op.insert === "string", "op.insert is not string");
24392
24415
  before.insert += op.insert;
24393
24416
  } else {
24394
24417
  newOps.push(op);
@@ -24416,15 +24439,15 @@ var __publicField = (obj, key, value) => {
24416
24439
  }
24417
24440
  return text2.slice(0, i + 1);
24418
24441
  }
24419
- const logger$43 = getLogger("delete-text");
24442
+ const logger$44 = getLogger("delete-text");
24420
24443
  function deleteText(richText2, offset, count) {
24421
24444
  const { left, right } = splitToThree(richText2, offset, count);
24422
24445
  const result = [...left, ...right];
24423
24446
  return mergeOps(result);
24424
24447
  }
24425
24448
  function createDeleteOps(offset, count) {
24426
- assert(logger$43, offset >= 0, `invalid offset: ${offset}`);
24427
- assert(logger$43, count >= 1, `invalid delete count: ${count}`);
24449
+ assert(logger$44, offset >= 0, `invalid offset: ${offset}`);
24450
+ assert(logger$44, count >= 1, `invalid delete count: ${count}`);
24428
24451
  const ops = [];
24429
24452
  if (offset !== 0) {
24430
24453
  ops.push({
@@ -24436,7 +24459,7 @@ var __publicField = (obj, key, value) => {
24436
24459
  });
24437
24460
  return ops;
24438
24461
  }
24439
- const logger$42 = getLogger("delta");
24462
+ const logger$43 = getLogger("delta");
24440
24463
  function diffRichText(oldText, newText) {
24441
24464
  const delta1D = new Delta__default.default(oldText);
24442
24465
  const delta2D = new Delta__default.default(newText);
@@ -24446,7 +24469,7 @@ var __publicField = (obj, key, value) => {
24446
24469
  return new Delta__default.default(ops).transformPosition(cursor, !isLocalOp);
24447
24470
  }
24448
24471
  function isValidDocText(text2) {
24449
- assert(logger$42, text2, "ops is null or undefined");
24472
+ assert(logger$43, text2, "ops is null or undefined");
24450
24473
  for (let i = 0; i < text2.length; i++) {
24451
24474
  const op = text2[i];
24452
24475
  if (op.insert === null || op.insert === void 0) {
@@ -24466,7 +24489,7 @@ var __publicField = (obj, key, value) => {
24466
24489
  }
24467
24490
  class RichText {
24468
24491
  static ensureValidText(text2) {
24469
- assert(logger$42, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
24492
+ assert(logger$43, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
24470
24493
  }
24471
24494
  static diff(oldText, newText) {
24472
24495
  this.ensureValidText(oldText);
@@ -24488,9 +24511,9 @@ var __publicField = (obj, key, value) => {
24488
24511
  return resultText;
24489
24512
  }
24490
24513
  }
24491
- const logger$41 = getLogger("insert-text");
24514
+ const logger$42 = getLogger("insert-text");
24492
24515
  function insertText(richText2, offset, text2, attributes) {
24493
- assert(logger$41, text2, `invalid text to insert: ${text2}`);
24516
+ assert(logger$42, text2, `invalid text to insert: ${text2}`);
24494
24517
  const { left, right } = splitText(richText2, offset);
24495
24518
  const insertedText = typeof text2 === "string" ? [createTextOp(text2, attributes)] : text2;
24496
24519
  const result = [...left, ...insertedText, ...right];
@@ -24503,7 +24526,7 @@ var __publicField = (obj, key, value) => {
24503
24526
  };
24504
24527
  }
24505
24528
  function createInsertOps(offset, text2, attributes) {
24506
- assert(logger$41, offset >= 0, `invalid offset: ${offset}`);
24529
+ assert(logger$42, offset >= 0, `invalid offset: ${offset}`);
24507
24530
  if (text2.length === 0) {
24508
24531
  return [];
24509
24532
  }
@@ -24533,7 +24556,7 @@ var __publicField = (obj, key, value) => {
24533
24556
  function cloneText(text2) {
24534
24557
  return cloneDeep__default.default(text2);
24535
24558
  }
24536
- const logger$40 = getLogger("update-op-attribute");
24559
+ const logger$41 = getLogger("update-op-attribute");
24537
24560
  function updateOpAttributes(orgOps, key, value, newAttributes) {
24538
24561
  const ops = cloneText(orgOps);
24539
24562
  const index2 = ops.findIndex((op2) => {
@@ -24541,7 +24564,7 @@ var __publicField = (obj, key, value) => {
24541
24564
  return false;
24542
24565
  return op2.attributes[key] === value;
24543
24566
  });
24544
- assert(logger$40, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
24567
+ assert(logger$41, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
24545
24568
  const op = ops[index2];
24546
24569
  op.attributes = {
24547
24570
  ...op.attributes,
@@ -24623,11 +24646,11 @@ var __publicField = (obj, key, value) => {
24623
24646
  ]);
24624
24647
  }
24625
24648
  const FILL_CHAR = "\u200B";
24626
- const logger$3$ = getLogger("to-plain-text");
24649
+ const logger$40 = getLogger("to-plain-text");
24627
24650
  function toPlainText(ops, options) {
24628
24651
  let text2 = "";
24629
24652
  ops.forEach((op) => {
24630
- assert(logger$3$, typeof op.insert === "string", "invalid op");
24653
+ assert(logger$40, typeof op.insert === "string", "invalid op");
24631
24654
  if (op.attributes && op.attributes.box === true) {
24632
24655
  if (options == null ? void 0 : options.boxReplacement) {
24633
24656
  text2 += options.boxReplacement;
@@ -24682,11 +24705,11 @@ var __publicField = (obj, key, value) => {
24682
24705
  focus: pos
24683
24706
  };
24684
24707
  }
24685
- const logger$3_ = getLogger("block-to-text");
24708
+ const logger$3$ = getLogger("block-to-text");
24686
24709
  function textBlockToText$1(editor, ops, doc2) {
24687
24710
  let text2 = "";
24688
24711
  ops.forEach((op) => {
24689
- assert(logger$3_, typeof op.insert === "string", "invalid op");
24712
+ assert(logger$3$, typeof op.insert === "string", "invalid op");
24690
24713
  if (op.attributes && op.attributes.box === true) {
24691
24714
  const box = op.attributes;
24692
24715
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -24704,11 +24727,11 @@ var __publicField = (obj, key, value) => {
24704
24727
  });
24705
24728
  return text2;
24706
24729
  }
24707
- const logger$3Z = getLogger("block-to-text");
24730
+ const logger$3_ = getLogger("block-to-text");
24708
24731
  function textToMarkdownText(editor, ops, doc2) {
24709
24732
  let text2 = "";
24710
24733
  ops.forEach((op) => {
24711
- assert(logger$3Z, typeof op.insert === "string", "invalid op");
24734
+ assert(logger$3_, typeof op.insert === "string", "invalid op");
24712
24735
  if (op.attributes && op.attributes.box === true) {
24713
24736
  const box = op.attributes;
24714
24737
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -24831,12 +24854,12 @@ var __publicField = (obj, key, value) => {
24831
24854
  return void 0;
24832
24855
  }
24833
24856
  }
24834
- const logger$3Y = getLogger("block-to-text");
24857
+ const logger$3Z = getLogger("block-to-text");
24835
24858
  function textBlockToHtml(editor, blockData, doc2) {
24836
24859
  let html = "";
24837
24860
  const ops = blockData.text || [];
24838
24861
  ops.forEach((op) => {
24839
- assert(logger$3Y, typeof op.insert === "string", "invalid op");
24862
+ assert(logger$3Z, typeof op.insert === "string", "invalid op");
24840
24863
  if (op.attributes && op.attributes.box === true) {
24841
24864
  const box = op.attributes;
24842
24865
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -24912,16 +24935,16 @@ var __publicField = (obj, key, value) => {
24912
24935
  }
24913
24936
  return `<p>${html}</p>`;
24914
24937
  }
24915
- const logger$3X = getLogger("text-block");
24938
+ const logger$3Y = getLogger("text-block");
24916
24939
  function createBlockContent$5(editor, path, container, blockElement, blockData) {
24917
24940
  const { text: text2 } = blockData;
24918
- assert(logger$3X, text2, "no text for text block");
24941
+ assert(logger$3Y, text2, "no text for text block");
24919
24942
  const content = createBlockContentElement(blockElement, "div");
24920
24943
  updateBlockContent$1(editor, path, blockData.id, content, text2);
24921
24944
  return content;
24922
24945
  }
24923
24946
  function updateBlockText$1(editor, block, text2) {
24924
- assert(logger$3X, text2, "no text to update");
24947
+ assert(logger$3Y, text2, "no text to update");
24925
24948
  const newContent = createBlockContentElement(null, "div");
24926
24949
  updateBlockContent$1(editor, getBlockPath(block), getBlockId(block), newContent, text2);
24927
24950
  const oldContent = getBlockContent(block);
@@ -24931,7 +24954,7 @@ var __publicField = (obj, key, value) => {
24931
24954
  return getRangeClientRects(editor, block, range);
24932
24955
  }
24933
24956
  function convertTo$k(editor, blockData, doc2, type) {
24934
- assert(logger$3X, blockData.text, "no text for text block");
24957
+ assert(logger$3Y, blockData.text, "no text for text block");
24935
24958
  if (type === "text") {
24936
24959
  return textBlockToText$1(editor, blockData.text, doc2);
24937
24960
  }
@@ -24945,7 +24968,7 @@ var __publicField = (obj, key, value) => {
24945
24968
  blockData.id = genId();
24946
24969
  info == null ? void 0 : info.blockIdMap.set(srcBlockData.id, blockData.id);
24947
24970
  const { text: text2 } = blockData;
24948
- assert(logger$3X, text2, "no text for text block");
24971
+ assert(logger$3Y, text2, "no text for text block");
24949
24972
  text2.forEach((op) => {
24950
24973
  if (op.insert && op.attributes && op.attributes.box === true) {
24951
24974
  const boxId = genId();
@@ -24977,7 +25000,7 @@ var __publicField = (obj, key, value) => {
24977
25000
  blockToDoc: blockToDoc$1
24978
25001
  };
24979
25002
  const updateTextBlockContent = updateBlockContent$1;
24980
- const logger$3W = getLogger("action-helper");
25003
+ const logger$3X = getLogger("action-helper");
24981
25004
  function editorGetBlockData(editor, block) {
24982
25005
  const container = getParentContainer(block);
24983
25006
  const containerId = getContainerId(container);
@@ -24985,10 +25008,10 @@ var __publicField = (obj, key, value) => {
24985
25008
  return editor.doc.getBlockData(containerId, blockIndex);
24986
25009
  }
24987
25010
  function editorGetBlockText(editor, block) {
24988
- assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25011
+ assert(logger$3X, isTextKindBlock(editor, block), "not a text kind block");
24989
25012
  const data2 = editorGetBlockData(editor, block);
24990
25013
  const text2 = data2.text;
24991
- assert(logger$3W, text2, "no text in block");
25014
+ assert(logger$3X, text2, "no text in block");
24992
25015
  return text2;
24993
25016
  }
24994
25017
  function editorGetBlockTextEx(editor, block, length) {
@@ -24996,7 +25019,7 @@ var __publicField = (obj, key, value) => {
24996
25019
  }
24997
25020
  function editorGetBoxData(editor, box) {
24998
25021
  const block = getParentBlock(box);
24999
- assert(logger$3W, block, "no parent block");
25022
+ assert(logger$3X, block, "no parent block");
25000
25023
  const text2 = editorGetBlockText(editor, block);
25001
25024
  const id = getBoxId(box);
25002
25025
  const op = text2.find((op2) => {
@@ -25006,60 +25029,60 @@ var __publicField = (obj, key, value) => {
25006
25029
  }
25007
25030
  return false;
25008
25031
  });
25009
- assert(logger$3W, op, "failed to find box");
25032
+ assert(logger$3X, op, "failed to find box");
25010
25033
  return op.attributes;
25011
25034
  }
25012
- const logger$3V = getLogger("block-text");
25035
+ const logger$3W = getLogger("block-text");
25013
25036
  function getTextAfterOffset(editor, block, offset) {
25014
- assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
25015
- assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
25016
- assert(logger$3V, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25037
+ assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25038
+ assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
25039
+ assert(logger$3W, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25017
25040
  const newOffset = getNextValidOffset(block, offset);
25018
25041
  const length = newOffset - offset;
25019
25042
  if (length === 0) {
25020
- assert(logger$3V, false, `no text after offset: ${offset}`);
25043
+ assert(logger$3W, false, `no text after offset: ${offset}`);
25021
25044
  }
25022
25045
  const text2 = editorGetBlockText(editor, block);
25023
25046
  const { middle } = splitToThree(text2, offset, length);
25024
- assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
25047
+ assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
25025
25048
  const op = middle[0];
25026
25049
  if (isBoxOp(op)) {
25027
25050
  return " ";
25028
25051
  }
25029
- assert(logger$3V, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25052
+ assert(logger$3W, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25030
25053
  return op.insert;
25031
25054
  }
25032
25055
  function getTextBeforeOffset(editor, block, offset) {
25033
- assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
25034
- assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
25035
- assert(logger$3V, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25056
+ assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25057
+ assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
25058
+ assert(logger$3W, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25036
25059
  const newOffset = getPrevValidOffset(block, offset);
25037
25060
  const length = offset - newOffset;
25038
25061
  if (length === 0) {
25039
- assert(logger$3V, false, `no text before offset: ${offset}`);
25062
+ assert(logger$3W, false, `no text before offset: ${offset}`);
25040
25063
  }
25041
25064
  const text2 = editorGetBlockText(editor, block);
25042
25065
  const { middle } = splitToThree(text2, newOffset, length);
25043
- assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
25066
+ assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
25044
25067
  const op = middle[0];
25045
25068
  if (isBoxOp(op)) {
25046
25069
  return " ";
25047
25070
  }
25048
- assert(logger$3V, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25071
+ assert(logger$3W, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25049
25072
  return op.insert;
25050
25073
  }
25051
25074
  function getOffsetInfoBefore(editor, block, offset) {
25052
- assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
25053
- assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
25054
- assert(logger$3V, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25075
+ assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25076
+ assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
25077
+ assert(logger$3W, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25055
25078
  const newOffset = getPrevValidOffset(block, offset);
25056
25079
  const length = offset - newOffset;
25057
25080
  if (length === 0) {
25058
- assert(logger$3V, false, `no text before offset: ${offset}`);
25081
+ assert(logger$3W, false, `no text before offset: ${offset}`);
25059
25082
  }
25060
25083
  const text2 = editorGetBlockText(editor, block);
25061
25084
  const { middle } = splitToThree(text2, newOffset, length);
25062
- assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
25085
+ assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
25063
25086
  const op = middle[0];
25064
25087
  if (isBoxOp(op)) {
25065
25088
  return {
@@ -25069,25 +25092,33 @@ var __publicField = (obj, key, value) => {
25069
25092
  length: 1
25070
25093
  };
25071
25094
  }
25095
+ let charType = "text";
25096
+ if (isSpace(op.insert)) {
25097
+ charType = "space";
25098
+ } else if (isCJKPunctuation(op.insert)) {
25099
+ charType = "cjk_punctuation";
25100
+ } else if (isCJK(op.insert)) {
25101
+ charType = "cjk";
25102
+ }
25072
25103
  return {
25073
25104
  op,
25074
- charType: isSpace(op.insert) ? "space" : "text",
25105
+ charType,
25075
25106
  offset: newOffset,
25076
25107
  length: op.insert.length
25077
25108
  };
25078
25109
  }
25079
25110
  function getOffsetInfoAfter(editor, block, offset) {
25080
- assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
25081
- assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
25082
- assert(logger$3V, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25111
+ assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25112
+ assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
25113
+ assert(logger$3W, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25083
25114
  const newOffset = getNextValidOffset(block, offset);
25084
25115
  const length = newOffset - offset;
25085
25116
  if (length === 0) {
25086
- assert(logger$3V, false, `no text after offset: ${offset}`);
25117
+ assert(logger$3W, false, `no text after offset: ${offset}`);
25087
25118
  }
25088
25119
  const text2 = editorGetBlockText(editor, block);
25089
25120
  const { middle } = splitToThree(text2, offset, length);
25090
- assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
25121
+ assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
25091
25122
  const op = middle[0];
25092
25123
  if (isBoxOp(op)) {
25093
25124
  return {
@@ -25097,9 +25128,17 @@ var __publicField = (obj, key, value) => {
25097
25128
  length: 1
25098
25129
  };
25099
25130
  }
25131
+ let charType = "text";
25132
+ if (isSpace(op.insert)) {
25133
+ charType = "space";
25134
+ } else if (isCJKPunctuation(op.insert)) {
25135
+ charType = "cjk_punctuation";
25136
+ } else if (isCJK(op.insert)) {
25137
+ charType = "cjk";
25138
+ }
25100
25139
  return {
25101
25140
  op,
25102
- charType: isSpace(op.insert) ? "space" : "text",
25141
+ charType,
25103
25142
  offset,
25104
25143
  length: op.insert.length
25105
25144
  };
@@ -25151,7 +25190,7 @@ var __publicField = (obj, key, value) => {
25151
25190
  return null;
25152
25191
  }
25153
25192
  function findWordLeft(editor, block, offset) {
25154
- assert(logger$3V, isTextKindBlock(editor, block), "invalid blok type");
25193
+ assert(logger$3W, isTextKindBlock(editor, block), "invalid blok type");
25155
25194
  if (isEmptyTextBlock(editor, block)) {
25156
25195
  return 0;
25157
25196
  }
@@ -25160,6 +25199,7 @@ var __publicField = (obj, key, value) => {
25160
25199
  return offset - 1;
25161
25200
  }
25162
25201
  let start = offset;
25202
+ let find = offsetInfo.charType;
25163
25203
  if (offsetInfo.charType === "space") {
25164
25204
  const startInfo2 = findPrevOffsetNotType(editor, block, start, "space");
25165
25205
  if (!startInfo2) {
@@ -25172,14 +25212,15 @@ var __publicField = (obj, key, value) => {
25172
25212
  return startInfo2.offset;
25173
25213
  }
25174
25214
  start = startInfo2.offset;
25215
+ find = getOffsetInfoBefore(editor, block, start).charType;
25175
25216
  }
25176
- const startInfo = findPrevOffsetNotType(editor, block, start, "text");
25217
+ const startInfo = findPrevOffsetNotType(editor, block, start, find);
25177
25218
  if (!startInfo)
25178
25219
  return 0;
25179
25220
  return startInfo.offset + startInfo.length;
25180
25221
  }
25181
25222
  function findWordEnd(editor, block, offset) {
25182
- assert(logger$3V, isTextKindBlock(editor, block), "invalid blok type");
25223
+ assert(logger$3W, isTextKindBlock(editor, block), "invalid blok type");
25183
25224
  if (isEmptyTextBlock(editor, block)) {
25184
25225
  return 0;
25185
25226
  }
@@ -25188,6 +25229,7 @@ var __publicField = (obj, key, value) => {
25188
25229
  return offset + 1;
25189
25230
  }
25190
25231
  let start = offset;
25232
+ let find = offsetInfo.charType;
25191
25233
  if (offsetInfo.charType === "space") {
25192
25234
  const startInfo2 = findAfterOffsetNotType(editor, block, start, "space");
25193
25235
  if (!startInfo2) {
@@ -25200,16 +25242,17 @@ var __publicField = (obj, key, value) => {
25200
25242
  return startInfo2.offset;
25201
25243
  }
25202
25244
  start = startInfo2.offset;
25245
+ find = getOffsetInfoAfter(editor, block, start).charType;
25203
25246
  }
25204
- const startInfo = findAfterOffsetNotType(editor, block, start, "text");
25247
+ const startInfo = findAfterOffsetNotType(editor, block, start, find);
25205
25248
  if (!startInfo)
25206
25249
  return getBlockTextLength$6(editor, block);
25207
25250
  return startInfo.offset;
25208
25251
  }
25209
- const logger$3U = getLogger("text-box");
25252
+ const logger$3V = getLogger("text-box");
25210
25253
  function updateBoxContent$8(editor, boxElement, boxContent, boxData) {
25211
- assert(logger$3U, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
25212
- assert(logger$3U, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
25254
+ assert(logger$3V, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
25255
+ assert(logger$3V, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
25213
25256
  createElement("span", [], boxContent, boxData.text);
25214
25257
  }
25215
25258
  function convertTo$j(editor, boxData, doc2, type) {
@@ -25243,7 +25286,7 @@ var __publicField = (obj, key, value) => {
25243
25286
  updateBoxContent: updateBoxContent$7,
25244
25287
  convertTo: convertTo$i
25245
25288
  };
25246
- const logger$3T = getLogger("editor-boxes");
25289
+ const logger$3U = getLogger("editor-boxes");
25247
25290
  class EditorBoxes {
25248
25291
  constructor(editor) {
25249
25292
  __publicField(this, "boxes", /* @__PURE__ */ new Map());
@@ -25252,12 +25295,12 @@ var __publicField = (obj, key, value) => {
25252
25295
  registerBoxClass(boxClass) {
25253
25296
  const type = boxClass.boxType;
25254
25297
  const exists = this.boxes.get(type);
25255
- assert(logger$3T, !exists, `duplicated box type: ${type}`);
25298
+ assert(logger$3U, !exists, `duplicated box type: ${type}`);
25256
25299
  this.boxes.set(type, boxClass);
25257
25300
  }
25258
25301
  getBoxClass(type) {
25259
25302
  const exists = this.boxes.get(type);
25260
- assert(logger$3T, exists, `unknown box type: ${type}`);
25303
+ assert(logger$3U, exists, `unknown box type: ${type}`);
25261
25304
  return exists;
25262
25305
  }
25263
25306
  createBox(blockContent, box) {
@@ -25614,15 +25657,12 @@ var __publicField = (obj, key, value) => {
25614
25657
  if (key === "inline-style-background-color") {
25615
25658
  newStyles.backgroundColor = value;
25616
25659
  }
25617
- if (key === "inline-style-font-size") {
25618
- newStyles.fontSize = value;
25619
- }
25620
25660
  }
25621
25661
  });
25622
25662
  return { classes, attributes: newAttributes, styles: newStyles };
25623
25663
  }
25624
25664
  }
25625
- const logger$3S = getLogger("editor-insertion");
25665
+ const logger$3T = getLogger("editor-insertion");
25626
25666
  class EditorInsertions {
25627
25667
  constructor(editor) {
25628
25668
  __publicField(this, "insertions", /* @__PURE__ */ new Map());
@@ -25631,12 +25671,12 @@ var __publicField = (obj, key, value) => {
25631
25671
  registerInsertionClass(insertionClass) {
25632
25672
  const type = insertionClass.insertionType;
25633
25673
  const exists = this.insertions.get(type);
25634
- assert(logger$3S, !exists, `duplicated insertion type: ${type}`);
25674
+ assert(logger$3T, !exists, `duplicated insertion type: ${type}`);
25635
25675
  this.insertions.set(type, insertionClass);
25636
25676
  }
25637
25677
  getInsertionClass(type) {
25638
25678
  const exists = this.insertions.get(type);
25639
- assert(logger$3S, exists, `unknown insertion type: ${type}`);
25679
+ assert(logger$3T, exists, `unknown insertion type: ${type}`);
25640
25680
  return exists;
25641
25681
  }
25642
25682
  createInsertionElement(type, id, attributes) {
@@ -25756,7 +25796,7 @@ var __publicField = (obj, key, value) => {
25756
25796
  };
25757
25797
  }
25758
25798
  }
25759
- const logger$3R = getLogger("editor-input");
25799
+ const logger$3S = getLogger("editor-input");
25760
25800
  class EditorInput$1 {
25761
25801
  constructor(editor, callbacks) {
25762
25802
  __publicField(this, "editor");
@@ -25878,7 +25918,7 @@ var __publicField = (obj, key, value) => {
25878
25918
  return;
25879
25919
  }
25880
25920
  this.callbacks.onCut(event);
25881
- logger$3R.debug("on cut");
25921
+ logger$3S.debug("on cut");
25882
25922
  });
25883
25923
  __publicField(this, "handlePaste", (event) => {
25884
25924
  if (event.isTrusted) {
@@ -25993,11 +26033,11 @@ var __publicField = (obj, key, value) => {
25993
26033
  this.callbacks.removeHandler(handler);
25994
26034
  }
25995
26035
  defaultInsertText(editor, containerId, blockIndex, offset, text2) {
25996
- assert(logger$3R, editor === this.editor, "invalid editor");
26036
+ assert(logger$3S, editor === this.editor, "invalid editor");
25997
26037
  this.callbacks.defaultInsertText(editor, containerId, blockIndex, offset, text2);
25998
26038
  }
25999
26039
  defaultHandleKeydown(editor, event) {
26000
- assert(logger$3R, editor === this.editor, "invalid editor");
26040
+ assert(logger$3S, editor === this.editor, "invalid editor");
26001
26041
  return this.callbacks.defaultHandleKeydown(editor, event);
26002
26042
  }
26003
26043
  forEach(callback) {
@@ -26022,7 +26062,7 @@ var __publicField = (obj, key, value) => {
26022
26062
  input2.style.left = `${x / scale}px`;
26023
26063
  input2.style.top = `${y / scale}px`;
26024
26064
  }
26025
- const logger$3Q = getLogger("editor-caret");
26065
+ const logger$3R = getLogger("editor-caret");
26026
26066
  function getFirefoxVersion() {
26027
26067
  const userAgent = window.navigator.userAgent;
26028
26068
  const match = userAgent.match(/Firefox\/(\d+)\./);
@@ -26085,11 +26125,11 @@ var __publicField = (obj, key, value) => {
26085
26125
  return;
26086
26126
  }
26087
26127
  const { range } = this.editor.selection;
26088
- assert(logger$3Q, range.isCollapsed, "range is not collapsed");
26128
+ assert(logger$3R, range.isCollapsed, "range is not collapsed");
26089
26129
  const pos = range.start;
26090
- assert(logger$3Q, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
26130
+ assert(logger$3R, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
26091
26131
  const block = this.editor.getBlockById(pos.blockId);
26092
- assert(logger$3Q, isTextKindBlock(this.editor, block), "only text kind block can has caret");
26132
+ assert(logger$3R, isTextKindBlock(this.editor, block), "only text kind block can has caret");
26093
26133
  let rect;
26094
26134
  const compositionSpan = block.querySelector("span.inputting-insertion");
26095
26135
  if (compositionSpan) {
@@ -26127,7 +26167,7 @@ var __publicField = (obj, key, value) => {
26127
26167
  clearAllSelection(editor);
26128
26168
  editor.selection.range.getSelectedBlocks().forEach((s) => updateBlockSelection(editor, s.block, s.start, s.end));
26129
26169
  }
26130
- const logger$3P = getLogger("editor-dom");
26170
+ const logger$3Q = getLogger("editor-dom");
26131
26171
  function editorGetClientHeight(editor) {
26132
26172
  const scrollContainer = getScrollContainer$1(editor.rootContainer);
26133
26173
  return scrollContainer.clientHeight;
@@ -26215,7 +26255,7 @@ var __publicField = (obj, key, value) => {
26215
26255
  }
26216
26256
  function editorScrollIntoView(editor) {
26217
26257
  if (!isElementVisible(editor.rootContainer)) {
26218
- logger$3P.warn("editorScrollIntoView: editor is not visible");
26258
+ logger$3Q.warn("editorScrollIntoView: editor is not visible");
26219
26259
  return;
26220
26260
  }
26221
26261
  const rootClientRect = editor.rootContainer.getBoundingClientRect();
@@ -26280,7 +26320,7 @@ var __publicField = (obj, key, value) => {
26280
26320
  const { start, end } = range;
26281
26321
  return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
26282
26322
  }
26283
- const logger$3O = getLogger("range-in-block");
26323
+ const logger$3P = getLogger("range-in-block");
26284
26324
  function rangeInBlock(block, range) {
26285
26325
  const editor = range.getEditor();
26286
26326
  const start = editor.getBlockById(range.start.blockId);
@@ -26301,16 +26341,16 @@ var __publicField = (obj, key, value) => {
26301
26341
  while (prevBlock && !blocks.has(getBlockId(prevBlock))) {
26302
26342
  prevBlock = getPrevVisibleBlock(prevBlock);
26303
26343
  }
26304
- assert(logger$3O, prevBlock, "no prev block while deleting a block");
26344
+ assert(logger$3P, prevBlock, "no prev block while deleting a block");
26305
26345
  newRange = createBlockSimpleRange(editor, prevBlock, getBlockTextLength$6(editor, prevBlock));
26306
26346
  } else {
26307
26347
  const nextBlock = getNextVisibleBlock(block);
26308
- assert(logger$3O, nextBlock, "no prev and next block while deleting a block");
26348
+ assert(logger$3P, nextBlock, "no prev and next block while deleting a block");
26309
26349
  newRange = createBlockSimpleRange(editor, nextBlock, 0);
26310
26350
  }
26311
26351
  return newRange;
26312
26352
  }
26313
- const logger$3N = getLogger("block-to-html");
26353
+ const logger$3O = getLogger("block-to-html");
26314
26354
  function blockToHtml(editor, blockData, doc2, path) {
26315
26355
  const blockClass = getBlockClassByType(editor, blockData.type);
26316
26356
  if (blockClass.convertTo) {
@@ -26319,15 +26359,15 @@ var __publicField = (obj, key, value) => {
26319
26359
  if (blockClass.blockKind !== "text") {
26320
26360
  return `[${blockData.type}]`;
26321
26361
  }
26322
- assert(logger$3N, blockData.text, "no text");
26362
+ assert(logger$3O, blockData.text, "no text");
26323
26363
  const plainText = toPlainText(blockData.text);
26324
26364
  return `<div>${escapeHtmlText(plainText)}</div>`;
26325
26365
  }
26326
- const logger$3M = getLogger("block-to-text");
26366
+ const logger$3N = getLogger("block-to-text");
26327
26367
  function textBlockToText(editor, ops, doc2) {
26328
26368
  let text2 = "";
26329
26369
  ops.forEach((op) => {
26330
- assert(logger$3M, typeof op.insert === "string", "invalid op");
26370
+ assert(logger$3N, typeof op.insert === "string", "invalid op");
26331
26371
  if (op.attributes && op.attributes.box === true) {
26332
26372
  const box = op.attributes;
26333
26373
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -26353,7 +26393,7 @@ var __publicField = (obj, key, value) => {
26353
26393
  if (blockClass.blockKind !== "text") {
26354
26394
  return `[${blockData.type}]`;
26355
26395
  }
26356
- assert(logger$3M, blockData.text, "no text");
26396
+ assert(logger$3N, blockData.text, "no text");
26357
26397
  const plainText = textBlockToText(editor, blockData.text, doc2);
26358
26398
  return plainText;
26359
26399
  }
@@ -26386,11 +26426,11 @@ var __publicField = (obj, key, value) => {
26386
26426
  const markdown = lines.join("\n");
26387
26427
  return markdown;
26388
26428
  }
26389
- const logger$3L = getLogger("get-text-position");
26429
+ const logger$3M = getLogger("get-text-position");
26390
26430
  function editorGetTextPosition(editor, insertPos) {
26391
26431
  const pos = insertPos != null ? insertPos : editor.selection.range.start;
26392
26432
  if (!(pos instanceof EditorSimpleBlockPosition)) {
26393
- assert(logger$3L, false, `invalid insert pos type: ${typeof pos}`);
26433
+ assert(logger$3M, false, `invalid insert pos type: ${typeof pos}`);
26394
26434
  }
26395
26435
  const { blockId } = pos;
26396
26436
  const block = editor.getBlockById(blockId);
@@ -26478,14 +26518,14 @@ var __publicField = (obj, key, value) => {
26478
26518
  return attributes;
26479
26519
  }
26480
26520
  }
26481
- const logger$3K = getLogger("insert-text");
26521
+ const logger$3L = getLogger("insert-text");
26482
26522
  function getTextAttributes(editor, containerId, blockIndex, offset) {
26483
26523
  var _a, _b;
26484
26524
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26485
- assert(logger$3K, blockData, "no block data");
26486
- assert(logger$3K, blockData.text, "no block text");
26525
+ assert(logger$3L, blockData, "no block data");
26526
+ assert(logger$3L, blockData.text, "no block text");
26487
26527
  if (getTextLength(blockData.text) === 0) {
26488
- assert(logger$3K, offset === 0, "invalid text offset");
26528
+ assert(logger$3L, offset === 0, "invalid text offset");
26489
26529
  return BlockAttributesHandler.get(editor).getEmptyBlockTextAttributes(blockData.id);
26490
26530
  }
26491
26531
  if (offset === 0) {
@@ -26532,7 +26572,7 @@ var __publicField = (obj, key, value) => {
26532
26572
  }
26533
26573
  for (let i = 0; i < text2.length; i++) {
26534
26574
  const op = text2[i];
26535
- assert(logger$3K, typeof op.insert === "string", "invalid text op, no insert");
26575
+ assert(logger$3L, typeof op.insert === "string", "invalid text op, no insert");
26536
26576
  const endPos = pos + getOpLength(op);
26537
26577
  if (endPos === start) {
26538
26578
  return false;
@@ -26546,8 +26586,8 @@ var __publicField = (obj, key, value) => {
26546
26586
  }
26547
26587
  function editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset) {
26548
26588
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26549
- assert(logger$3K, blockData, "no block data");
26550
- assert(logger$3K, blockData.text, "no block text");
26589
+ assert(logger$3L, blockData, "no block data");
26590
+ assert(logger$3L, blockData.text, "no block text");
26551
26591
  const attributes = getTextAttributes(editor, containerId, blockIndex, offset);
26552
26592
  if (attributes && Object.keys(attributes).includes("link")) {
26553
26593
  const inOp = checkRangeInOp(blockData.text, offset);
@@ -26566,21 +26606,21 @@ var __publicField = (obj, key, value) => {
26566
26606
  const { containerId, blockIndex, offset } = editorGetTextPosition(editor);
26567
26607
  editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset);
26568
26608
  }
26569
- const logger$3J = getLogger("update-composition-text");
26609
+ const logger$3K = getLogger("update-composition-text");
26570
26610
  function editorUpdateCompositionText(editor) {
26571
26611
  const pos = editor.selection.range.start;
26572
26612
  if (!(pos instanceof EditorSimpleBlockPosition)) {
26573
- assert(logger$3J, false, `invalid insert pos type: ${typeof pos}`);
26613
+ assert(logger$3K, false, `invalid insert pos type: ${typeof pos}`);
26574
26614
  }
26575
26615
  const { blockId } = pos;
26576
26616
  const block = editor.getBlockById(blockId);
26577
- assert(logger$3J, isTextKindBlock(editor, block), "not a text kind block");
26617
+ assert(logger$3K, isTextKindBlock(editor, block), "not a text kind block");
26578
26618
  const container = getParentContainer(block);
26579
26619
  const containerId = getContainerId(container);
26580
26620
  const blockIndex = getBlockIndex(block);
26581
26621
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26582
- assert(logger$3J, blockData, "no block data in doc");
26583
- assert(logger$3J, blockData.text, "no text data in text block");
26622
+ assert(logger$3K, blockData, "no block data in doc");
26623
+ assert(logger$3K, blockData.text, "no text data in text block");
26584
26624
  const blockContent = getBlockContent(block);
26585
26625
  updateBlockContent$1(editor, getBlockPath(block), blockId, blockContent, blockData.text);
26586
26626
  }
@@ -26592,25 +26632,25 @@ var __publicField = (obj, key, value) => {
26592
26632
  const block = editor.getBlockById(blockData.id);
26593
26633
  return block;
26594
26634
  }
26595
- const logger$3I = getLogger("delete-block-text");
26635
+ const logger$3J = getLogger("delete-block-text");
26596
26636
  function editorDeleteBlockText(editor, block, offset, count, options) {
26597
26637
  if (!editor.isBlockWritable(block)) {
26598
- logger$3I.error("block is not writable");
26638
+ logger$3J.error("block is not writable");
26599
26639
  return 0;
26600
26640
  }
26601
- assert(logger$3I, isTextKindBlock(editor, block), "block is not a text kind block");
26641
+ assert(logger$3J, isTextKindBlock(editor, block), "block is not a text kind block");
26602
26642
  const container = getParentContainer(block);
26603
26643
  const containerId = getContainerId(container);
26604
26644
  const blockIndex = getBlockIndex(block);
26605
26645
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26606
- assert(logger$3I, blockData, "no block data in doc");
26607
- assert(logger$3I, blockData.text, "no text data in text block");
26646
+ assert(logger$3J, blockData, "no block data in doc");
26647
+ assert(logger$3J, blockData.text, "no text data in text block");
26608
26648
  let from = offset;
26609
26649
  if (!isValidOffset(block, offset)) {
26610
26650
  from = getPrevValidOffset(block, from);
26611
26651
  }
26612
26652
  let to = offset + count;
26613
- assert(logger$3I, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
26653
+ assert(logger$3J, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
26614
26654
  if (!isValidOffset(block, to)) {
26615
26655
  to = getNextValidOffset(block, to);
26616
26656
  }
@@ -26619,7 +26659,7 @@ var __publicField = (obj, key, value) => {
26619
26659
  editor.doc.localUpdateBlockText(containerId, blockIndex, actions2, options);
26620
26660
  return deleteCount;
26621
26661
  }
26622
- const logger$3H = getLogger("break-text-block");
26662
+ const logger$3I = getLogger("break-text-block");
26623
26663
  function copyBlockAttributes(editor, block) {
26624
26664
  const blockData = editor.getBlockData(block);
26625
26665
  const quoted = blockData.quoted;
@@ -26631,8 +26671,8 @@ var __publicField = (obj, key, value) => {
26631
26671
  return {};
26632
26672
  }
26633
26673
  function editorBreakTextBlock(editor, block, offset, options) {
26634
- assert(logger$3H, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
26635
- assert(logger$3H, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
26674
+ assert(logger$3I, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
26675
+ assert(logger$3I, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
26636
26676
  const container = getParentContainer(block);
26637
26677
  const containerId = getContainerId(container);
26638
26678
  const blockIndex = getBlockIndex(block);
@@ -26662,7 +26702,7 @@ var __publicField = (obj, key, value) => {
26662
26702
  };
26663
26703
  }
26664
26704
  }
26665
- assert(logger$3H, isValidOffset(block, offset), "not a valid offset");
26705
+ assert(logger$3I, isValidOffset(block, offset), "not a valid offset");
26666
26706
  const text2 = editorGetBlockText(editor, block);
26667
26707
  const { right } = splitText(text2, offset);
26668
26708
  const rightLength = getTextLength(right);
@@ -26688,12 +26728,12 @@ var __publicField = (obj, key, value) => {
26688
26728
  newBlock
26689
26729
  };
26690
26730
  }
26691
- const logger$3G = getLogger("prepare-insert-new-block");
26731
+ const logger$3H = getLogger("prepare-insert-new-block");
26692
26732
  function editorPrepareInsertNewBlock(editor, containerId, blockIndex) {
26693
26733
  if (containerId && blockIndex !== void 0 && blockIndex !== null) {
26694
26734
  const container = editor.getContainerById(containerId);
26695
26735
  const blocks = getChildBlocks(container);
26696
- assert(logger$3G, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
26736
+ assert(logger$3H, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
26697
26737
  return {
26698
26738
  containerId,
26699
26739
  blockIndex
@@ -26727,15 +26767,15 @@ var __publicField = (obj, key, value) => {
26727
26767
  blockIndex: getBlockIndex(newBlock)
26728
26768
  };
26729
26769
  }
26730
- const logger$3F = getLogger("auto-insert-block");
26770
+ const logger$3G = getLogger("auto-insert-block");
26731
26771
  function editorAutoInsertBlock(editor, blockData, containerId, blockIndex, newRange, insertBlockOptions) {
26732
26772
  const result = editorPrepareInsertNewBlock(editor, containerId, blockIndex);
26733
- assert(logger$3F, result, `not an valid insert position: ${editor.selection.range}`);
26773
+ assert(logger$3G, result, `not an valid insert position: ${editor.selection.range}`);
26734
26774
  const defaultPos = { blockId: blockData.id, offset: 0 };
26735
26775
  const defaultRange = { anchor: defaultPos, focus: defaultPos };
26736
26776
  return editorInsertBlock(editor, result.containerId, result.blockIndex, blockData, newRange != null ? newRange : defaultRange, insertBlockOptions);
26737
26777
  }
26738
- const logger$3E = getLogger("delete-block");
26778
+ const logger$3F = getLogger("delete-block");
26739
26779
  function getAllChildContainers(editor, blockData, containerIds) {
26740
26780
  if (blockData.children) {
26741
26781
  containerIds.push(...blockData.children);
@@ -26752,7 +26792,7 @@ var __publicField = (obj, key, value) => {
26752
26792
  const containerId = getContainerId(container);
26753
26793
  const blockIndex = getBlockIndex(block);
26754
26794
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26755
- assert(logger$3E, blockData, "no block data in doc");
26795
+ assert(logger$3F, blockData, "no block data in doc");
26756
26796
  editor.doc.localDeleteBlock(containerId, blockIndex, createEditorSelectionRange(editor, { anchor: newRange.start, focus: newRange.end }));
26757
26797
  return blockData;
26758
26798
  }
@@ -26798,15 +26838,15 @@ var __publicField = (obj, key, value) => {
26798
26838
  });
26799
26839
  editor.doc.localDeleteChildContainers(containerIds);
26800
26840
  }
26801
- const logger$3D = getLogger("merge-text-block");
26841
+ const logger$3E = getLogger("merge-text-block");
26802
26842
  function editorMergeTextBlock(editor, block1, block2) {
26803
- assert(logger$3D, isTextKindBlock(editor, block1), "only text block can be merged");
26804
- assert(logger$3D, isTextKindBlock(editor, block2), "only text block can be merged");
26843
+ assert(logger$3E, isTextKindBlock(editor, block1), "only text block can be merged");
26844
+ assert(logger$3E, isTextKindBlock(editor, block2), "only text block can be merged");
26805
26845
  const data1 = editorGetBlockData(editor, block1);
26806
26846
  const data2 = editorGetBlockData(editor, block2);
26807
26847
  const text1 = data1.text;
26808
26848
  const text2 = data2.text;
26809
- assert(logger$3D, text1 && text2, "block data has no text");
26849
+ assert(logger$3E, text1 && text2, "block data has no text");
26810
26850
  const container = getParentContainer(block1);
26811
26851
  const containerId = getContainerId(container);
26812
26852
  const blockIndex = getBlockIndex(block1);
@@ -26816,15 +26856,15 @@ var __publicField = (obj, key, value) => {
26816
26856
  editorDeleteBlock(editor, block2, newRange);
26817
26857
  return block;
26818
26858
  }
26819
- const logger$3C = getLogger("clear-selected-contents");
26859
+ const logger$3D = getLogger("clear-selected-contents");
26820
26860
  function deleteTextBlockSelection(editor, selectedBlock) {
26821
- assert(logger$3C, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
26861
+ assert(logger$3D, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
26822
26862
  const { start, end } = selectedBlock;
26823
- assert(logger$3C, start.isSimple(), "not a simple block position");
26824
- assert(logger$3C, end.isSimple(), "not a simple block position");
26863
+ assert(logger$3D, start.isSimple(), "not a simple block position");
26864
+ assert(logger$3D, end.isSimple(), "not a simple block position");
26825
26865
  const startOffset = start.offset;
26826
26866
  const endOffset = end.offset;
26827
- assert(logger$3C, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
26867
+ assert(logger$3D, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
26828
26868
  if (startOffset === endOffset) {
26829
26869
  return;
26830
26870
  }
@@ -26849,7 +26889,7 @@ var __publicField = (obj, key, value) => {
26849
26889
  return;
26850
26890
  }
26851
26891
  if (isEmbedBlock(block) || start.isSimple()) {
26852
- assert(logger$3C, end.isSimple(), "invalid range");
26892
+ assert(logger$3D, end.isSimple(), "invalid range");
26853
26893
  const container = getParentContainer(block);
26854
26894
  const blockIndex = getBlockIndex(block);
26855
26895
  const newBlock = editor.insertTextBlock("", getContainerId(container), blockIndex);
@@ -26857,8 +26897,8 @@ var __publicField = (obj, key, value) => {
26857
26897
  editor.deleteBlock(block);
26858
26898
  return;
26859
26899
  }
26860
- assert(logger$3C, isComplexKindBlock(editor, block), "invalid block kind");
26861
- assert(logger$3C, !start.isSimple() && !end.isSimple(), "invalid range");
26900
+ assert(logger$3D, isComplexKindBlock(editor, block), "invalid block kind");
26901
+ assert(logger$3D, !start.isSimple() && !end.isSimple(), "invalid range");
26862
26902
  complexBlockGetSelectedContainers(editor, block, start, end);
26863
26903
  const containers = editor.selection.range.getSelectedContainers();
26864
26904
  containers.forEach((container, index2) => {
@@ -26875,7 +26915,7 @@ var __publicField = (obj, key, value) => {
26875
26915
  return;
26876
26916
  }
26877
26917
  const selectedBlocks = range.getSelectedBlocks();
26878
- assert(logger$3C, selectedBlocks.length > 0, "no selected block");
26918
+ assert(logger$3D, selectedBlocks.length > 0, "no selected block");
26879
26919
  if (selectedBlocks.length === 1) {
26880
26920
  clearOneBlock(editor, selectedBlocks[0]);
26881
26921
  return;
@@ -26883,7 +26923,7 @@ var __publicField = (obj, key, value) => {
26883
26923
  const firstSelectedBlock = selectedBlocks[0];
26884
26924
  const firstBlock = firstSelectedBlock.block;
26885
26925
  const container = getParentContainer(firstBlock);
26886
- assert(logger$3C, selectedBlocks.length > 1, "no selected block");
26926
+ assert(logger$3D, selectedBlocks.length > 1, "no selected block");
26887
26927
  const lastSelectedBlock = selectedBlocks[selectedBlocks.length - 1];
26888
26928
  const lastBlock2 = lastSelectedBlock.block;
26889
26929
  if (isTextKindBlock(editor, firstBlock)) {
@@ -26913,7 +26953,7 @@ var __publicField = (obj, key, value) => {
26913
26953
  }
26914
26954
  const prevBlock = getPrevBlock(firstBlock);
26915
26955
  const nextBlock = getNextBlock(lastBlock2);
26916
- assert(logger$3C, prevBlock || nextBlock, "no prev or next block");
26956
+ assert(logger$3D, prevBlock || nextBlock, "no prev or next block");
26917
26957
  selectedBlocks.forEach((selectedBlock) => editor.deleteBlock(selectedBlock.block));
26918
26958
  }
26919
26959
  function editorClearSelectedContents(editor, selectionRange) {
@@ -26932,7 +26972,7 @@ var __publicField = (obj, key, value) => {
26932
26972
  editor.emit("afterClearSelection", editor);
26933
26973
  });
26934
26974
  }
26935
- const logger$3B = getLogger("core");
26975
+ const logger$3C = getLogger("core");
26936
26976
  function editorUpdateBlockText(editor, block, ops, options) {
26937
26977
  const container = getParentContainer(block);
26938
26978
  const containerId = getContainerId(container);
@@ -26945,7 +26985,7 @@ var __publicField = (obj, key, value) => {
26945
26985
  }
26946
26986
  function editorSetBlockText(editor, block, newText, options) {
26947
26987
  if (!editor.isBlockWritable(block)) {
26948
- logger$3B.error("block is not writable");
26988
+ logger$3C.error("block is not writable");
26949
26989
  return;
26950
26990
  }
26951
26991
  const oldText = editor.getBlockText(block);
@@ -26958,7 +26998,7 @@ var __publicField = (obj, key, value) => {
26958
26998
  const ops = RichText.diff(oldText, newText);
26959
26999
  return editorUpdateBlockText(editor, block, ops);
26960
27000
  }
26961
- const logger$3A = getLogger("update-block-data");
27001
+ const logger$3B = getLogger("update-block-data");
26962
27002
  function editorUpdateBlockData(editor, block, data2, newRange, options) {
26963
27003
  const container = getParentContainer(block);
26964
27004
  const containerId = getContainerId(container);
@@ -26975,17 +27015,17 @@ var __publicField = (obj, key, value) => {
26975
27015
  if (oldKey === "id" || oldKey === "type" || oldKey === "text") {
26976
27016
  return;
26977
27017
  }
26978
- logger$3A.debug(`delete key: ${oldKey}`);
27018
+ logger$3B.debug(`delete key: ${oldKey}`);
26979
27019
  delta.delete.push(oldKey);
26980
27020
  }
26981
27021
  });
26982
27022
  const entries = Object.entries(data2);
26983
27023
  entries.forEach(([key, value]) => {
26984
- assert(logger$3A, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
27024
+ assert(logger$3B, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
26985
27025
  const oldValue = oldData[key];
26986
27026
  if (value === null || value === void 0) {
26987
27027
  if (oldValue !== null && oldValue !== void 0) {
26988
- logger$3A.debug(`delete key: ${key}`);
27028
+ logger$3B.debug(`delete key: ${key}`);
26989
27029
  delta.delete.push(key);
26990
27030
  }
26991
27031
  return;
@@ -27003,10 +27043,10 @@ var __publicField = (obj, key, value) => {
27003
27043
  }
27004
27044
  }
27005
27045
  if (oldKeys.has(key)) {
27006
- logger$3A.debug(`replace key: ${key}`);
27046
+ logger$3B.debug(`replace key: ${key}`);
27007
27047
  delta.delete.push(key);
27008
27048
  } else {
27009
- logger$3A.debug(`insert key: ${key}`);
27049
+ logger$3B.debug(`insert key: ${key}`);
27010
27050
  }
27011
27051
  delta.insert[key] = value;
27012
27052
  });
@@ -27051,13 +27091,13 @@ var __publicField = (obj, key, value) => {
27051
27091
  comments: {}
27052
27092
  };
27053
27093
  }
27054
- const logger$3z = getLogger("clone-block");
27094
+ const logger$3A = getLogger("clone-block");
27055
27095
  function cloneBlock(editorBlocks, oldDoc, data2, info) {
27056
27096
  var _a;
27057
27097
  const blockClass = editorBlocks.getBlockClass(data2.type);
27058
27098
  if (blockClass.blockToDoc) {
27059
27099
  return blockClass.blockToDoc(oldDoc, data2, (oldDoc2, childBlock) => {
27060
- assert(logger$3z, data2 !== childBlock, "invalid child block");
27100
+ assert(logger$3A, data2 !== childBlock, "invalid child block");
27061
27101
  return cloneBlock(editorBlocks, oldDoc2, data2, info);
27062
27102
  }, info);
27063
27103
  }
@@ -27070,7 +27110,7 @@ var __publicField = (obj, key, value) => {
27070
27110
  }
27071
27111
  const newChildContainerId = genId();
27072
27112
  const childBlocks = oldDoc.blocks[oldChildContainerId];
27073
- assert(logger$3z, Array.isArray(childBlocks), "invalid child blocks");
27113
+ assert(logger$3A, Array.isArray(childBlocks), "invalid child blocks");
27074
27114
  const newDocs = childBlocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
27075
27115
  const newDoc = mergeDocs(newDocs);
27076
27116
  const { root: root2, ...childContainersData } = newDoc.blocks;
@@ -27099,7 +27139,7 @@ var __publicField = (obj, key, value) => {
27099
27139
  if (key.startsWith(prefix1)) {
27100
27140
  const keyContent = key.substring(prefix1.length);
27101
27141
  const newKey = `${newContainerId}/${keyContent}`;
27102
- logger$3z.debug(`replace key: ${key} -> ${newKey}`);
27142
+ logger$3A.debug(`replace key: ${key} -> ${newKey}`);
27103
27143
  return newKey;
27104
27144
  }
27105
27145
  }
@@ -27108,7 +27148,7 @@ var __publicField = (obj, key, value) => {
27108
27148
  if (key.startsWith(prefix2)) {
27109
27149
  const keyContent = key.substring(prefix2.length);
27110
27150
  const newKey = `${newContainerId}_${keyContent}`;
27111
- logger$3z.debug(`replace key: ${key} -> ${newKey}`);
27151
+ logger$3A.debug(`replace key: ${key} -> ${newKey}`);
27112
27152
  return newKey;
27113
27153
  }
27114
27154
  }
@@ -27138,7 +27178,7 @@ var __publicField = (obj, key, value) => {
27138
27178
  }
27139
27179
  function cloneChildContainer(editorBlocks, oldDoc, containerId, info) {
27140
27180
  const blocks = oldDoc.blocks[containerId];
27141
- assert(logger$3z, Array.isArray(blocks), "invalid child blocks");
27181
+ assert(logger$3A, Array.isArray(blocks), "invalid child blocks");
27142
27182
  const newDocs = blocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
27143
27183
  const newDoc = mergeDocs(newDocs);
27144
27184
  return newDoc;
@@ -27147,19 +27187,24 @@ var __publicField = (obj, key, value) => {
27147
27187
  const docs = doc2.blocks.root.map((b) => cloneBlock(editor.editorBlocks, doc2, b, info));
27148
27188
  return cloneDeep__default.default(mergeDocs(docs));
27149
27189
  }
27150
- const logger$3y = getLogger("insert-doc");
27190
+ const logger$3z = getLogger("insert-doc");
27151
27191
  function editorInsertDoc(editor, block, offset, insertedDoc, cloneDocResult) {
27192
+ var _a;
27152
27193
  if (isComplexKindBlock(editor, block)) {
27153
- logger$3y.warn("failed to insert doc into a complex block");
27194
+ logger$3z.warn("failed to insert doc into a complex block");
27154
27195
  return;
27155
27196
  }
27156
27197
  const doc2 = cloneDoc(editor, insertedDoc, cloneDocResult);
27157
27198
  const container = getParentContainer(block);
27158
27199
  const blockIndex = getBlockIndex(block);
27159
27200
  const containerId = getContainerId(container);
27201
+ if (doc2.blocks.root.length === 1 && isTextKindBlockType(editor, doc2.blocks.root[0].type)) {
27202
+ editor.insertTextToBlock(block, offset, (_a = doc2.blocks.root[0].text) != null ? _a : []);
27203
+ return;
27204
+ }
27160
27205
  editor.doc.beginBatchUpdate();
27161
27206
  editor.undoManager.runInGroup(() => {
27162
- var _a, _b, _c;
27207
+ var _a2, _b, _c;
27163
27208
  const childContainers = [];
27164
27209
  Object.entries(doc2.blocks).forEach(([containerId2, blocks2]) => {
27165
27210
  if (containerId2 === "root")
@@ -27184,7 +27229,7 @@ var __publicField = (obj, key, value) => {
27184
27229
  }
27185
27230
  return;
27186
27231
  }
27187
- assert(logger$3y, isTextKindBlock(editor, block), "not a text block");
27232
+ assert(logger$3z, isTextKindBlock(editor, block), "not a text block");
27188
27233
  if (isEmptyTextBlock(editor, block)) {
27189
27234
  const blockIndex2 = getBlockIndex(block);
27190
27235
  let lastBlock22;
@@ -27224,7 +27269,7 @@ var __publicField = (obj, key, value) => {
27224
27269
  if (blocks.length === 1) {
27225
27270
  const newBlock2 = blocks[0];
27226
27271
  if (isTextKindBlockType(editor, newBlock2.type)) {
27227
- editor.insertTextToBlock(block, offset, (_a = newBlock2.text) != null ? _a : []);
27272
+ editor.insertTextToBlock(block, offset, (_a2 = newBlock2.text) != null ? _a2 : []);
27228
27273
  return;
27229
27274
  }
27230
27275
  editor.breakTextBlock(block, offset);
@@ -27316,11 +27361,11 @@ var __publicField = (obj, key, value) => {
27316
27361
  editor.deleteBlock(block);
27317
27362
  }
27318
27363
  }
27319
- const logger$3x = getLogger("add-text-attribute");
27364
+ const logger$3y = getLogger("add-text-attribute");
27320
27365
  function editorRemoveTextAttribute(editor, block, range, attributeName) {
27321
27366
  const { start, end } = range;
27322
- assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27323
- assert(logger$3x, attributeName, "invalid attribute name");
27367
+ assert(logger$3y, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27368
+ assert(logger$3y, attributeName, "invalid attribute name");
27324
27369
  const oldText = editor.getBlockText(block);
27325
27370
  const newText = rangeRemoveAttribute(start.offset, end.offset - start.offset, oldText, attributeName, void 0, { ignoreValue: true });
27326
27371
  editor.setBlockText(block, newText);
@@ -27328,8 +27373,8 @@ var __publicField = (obj, key, value) => {
27328
27373
  }
27329
27374
  function editorAddTextAttribute(editor, block, range, attributeName, value) {
27330
27375
  const { start, end } = range;
27331
- assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27332
- assert(logger$3x, attributeName, "invalid attribute name");
27376
+ assert(logger$3y, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27377
+ assert(logger$3y, attributeName, "invalid attribute name");
27333
27378
  const oldText = editor.getBlockText(block);
27334
27379
  const newText = rangeAddAttribute(start.offset, end.offset - start.offset, oldText, attributeName, value);
27335
27380
  editor.setBlockText(block, newText);
@@ -27337,7 +27382,7 @@ var __publicField = (obj, key, value) => {
27337
27382
  }
27338
27383
  function editorSetTextColor(editor, block, range, type, value) {
27339
27384
  const { start, end } = range;
27340
- assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27385
+ assert(logger$3y, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27341
27386
  const oldText = editor.getBlockText(block);
27342
27387
  const newText = rangeSetTextColor(start.offset, end.offset - start.offset, oldText, type, value);
27343
27388
  editor.setBlockText(block, newText);
@@ -27426,10 +27471,10 @@ var __publicField = (obj, key, value) => {
27426
27471
  });
27427
27472
  return [color, backgroundColor];
27428
27473
  }
27429
- const logger$3w = getLogger("move-complex-block-position");
27474
+ const logger$3x = getLogger("move-complex-block-position");
27430
27475
  function moveComplexBlockPosition(editor, old, type) {
27431
27476
  const block = editor.getBlockById(old.blockId);
27432
- assert(logger$3w, isComplexKindBlock(editor, block), "is not a complex block");
27477
+ assert(logger$3x, isComplexKindBlock(editor, block), "is not a complex block");
27433
27478
  const blockClass = getComplexBlockClass(editor, block);
27434
27479
  const focusedContainer = editor.getContainerById(old.childContainerId);
27435
27480
  const nextContainer = blockClass.getNextContainer(editor, block, focusedContainer, type, { noWrap: true });
@@ -27438,24 +27483,24 @@ var __publicField = (obj, key, value) => {
27438
27483
  }
27439
27484
  return createComplexBlockPosition(block, getContainerId(nextContainer));
27440
27485
  }
27441
- const logger$3v = getLogger("move-simple-block-position");
27486
+ const logger$3w = getLogger("move-simple-block-position");
27442
27487
  function getFirstChildBlockInComplexBlock(editor, complexBlock) {
27443
27488
  const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
27444
27489
  if (containers.length === 0) {
27445
- logger$3v.warn("complex block has not any child container, not loaded?");
27490
+ logger$3w.warn("complex block has not any child container, not loaded?");
27446
27491
  return null;
27447
27492
  }
27448
- assert(logger$3v, containers.length > 0, "complex block has not any child container");
27493
+ assert(logger$3w, containers.length > 0, "complex block has not any child container");
27449
27494
  const container = containers[0];
27450
27495
  return getFirstChildBlock(container);
27451
27496
  }
27452
27497
  function getLastChildBlockInComplexBlock(editor, complexBlock) {
27453
27498
  const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
27454
27499
  if (containers.length === 0) {
27455
- logger$3v.warn("complex block has not any child container, not loaded?");
27500
+ logger$3w.warn("complex block has not any child container, not loaded?");
27456
27501
  return null;
27457
27502
  }
27458
- assert(logger$3v, containers.length > 0, "complex block has not any child container");
27503
+ assert(logger$3w, containers.length > 0, "complex block has not any child container");
27459
27504
  const container = containers[containers.length - 1];
27460
27505
  return getLastChildBlock(container);
27461
27506
  }
@@ -27500,8 +27545,8 @@ var __publicField = (obj, key, value) => {
27500
27545
  return null;
27501
27546
  }
27502
27547
  const parentComplexBlock = getParentBlock(container);
27503
- assert(logger$3v, parentComplexBlock, "child container has not parent block");
27504
- assert(logger$3v, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
27548
+ assert(logger$3w, parentComplexBlock, "child container has not parent block");
27549
+ assert(logger$3w, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
27505
27550
  const nextContainer = getComplexBlockClass(editor, parentComplexBlock).getNextContainer(editor, parentComplexBlock, container, type);
27506
27551
  if (nextContainer) {
27507
27552
  if (isFindPrev(type)) {
@@ -27523,7 +27568,7 @@ var __publicField = (obj, key, value) => {
27523
27568
  return null;
27524
27569
  }
27525
27570
  const parentBlock = getParentBlock(container);
27526
- assert(logger$3v, parentBlock, "child container has not parent block");
27571
+ assert(logger$3w, parentBlock, "child container has not parent block");
27527
27572
  if (isFindPrev(type)) {
27528
27573
  const prev = getPrevBlock(parentBlock);
27529
27574
  if (prev) {
@@ -27578,7 +27623,7 @@ var __publicField = (obj, key, value) => {
27578
27623
  }
27579
27624
  if (!targetBlock) {
27580
27625
  if (isComplexKindBlock(editor, block) && complexBlockGetAllChildContainers(editor, block).length === 0) {
27581
- logger$3v.warn("complex block has not any child container, not loaded?");
27626
+ logger$3w.warn("complex block has not any child container, not loaded?");
27582
27627
  targetBlock = direction === "ArrowDown" || direction === "ArrowRight" ? getNextVisibleBlock(block) : getPrevVisibleBlock(block);
27583
27628
  }
27584
27629
  }
@@ -27725,10 +27770,10 @@ var __publicField = (obj, key, value) => {
27725
27770
  editorAdjustSelection(editor, "ArrowUp", "select");
27726
27771
  return true;
27727
27772
  }
27728
- const logger$3u = getLogger("word-offset");
27773
+ const logger$3v = getLogger("word-offset");
27729
27774
  function editorGetWordLeftPos(editor, type) {
27730
27775
  const old = editor.selection.range.focus;
27731
- assert(logger$3u, old.isSimple(), "invalid range type");
27776
+ assert(logger$3v, old.isSimple(), "invalid range type");
27732
27777
  const block = editor.getBlockById(old.blockId);
27733
27778
  if (isEmptyTextBlock(editor, block)) {
27734
27779
  return createSimpleBlockPosition(block, 0, "home");
@@ -27753,7 +27798,7 @@ var __publicField = (obj, key, value) => {
27753
27798
  }
27754
27799
  function editorGetWordRightPos(editor, type) {
27755
27800
  const old = editor.selection.range.focus;
27756
- assert(logger$3u, old.isSimple(), "invalid range type");
27801
+ assert(logger$3v, old.isSimple(), "invalid range type");
27757
27802
  const block = editor.getBlockById(old.blockId);
27758
27803
  if (isEmptyTextBlock(editor, block)) {
27759
27804
  return createSimpleBlockPosition(block, 0, "end");
@@ -27865,10 +27910,10 @@ var __publicField = (obj, key, value) => {
27865
27910
  editor.selection.setSelection(editor.selection.getAnchorPos(), pos);
27866
27911
  return true;
27867
27912
  }
27868
- const logger$3t = getLogger("line-offset");
27913
+ const logger$3u = getLogger("line-offset");
27869
27914
  function editorGetLineHomePos(editor) {
27870
27915
  const old = editor.selection.range.focus;
27871
- assert(logger$3t, old.isSimple(), "invalid range type");
27916
+ assert(logger$3u, old.isSimple(), "invalid range type");
27872
27917
  const block = editor.getBlockById(old.blockId);
27873
27918
  if (old.offset === 0 || !isTextKindBlock(editor, block)) {
27874
27919
  const newPos2 = createSimpleBlockPosition(block, 0, "home");
@@ -27885,7 +27930,7 @@ var __publicField = (obj, key, value) => {
27885
27930
  }
27886
27931
  function editorGetLineEndPos(editor) {
27887
27932
  const old = editor.selection.range.focus;
27888
- assert(logger$3t, old.isSimple(), "invalid range type");
27933
+ assert(logger$3u, old.isSimple(), "invalid range type");
27889
27934
  const block = editor.getBlockById(old.blockId);
27890
27935
  if (old.offset === getBlockTextLength$6(editor, block) || !isTextKindBlock(editor, block)) {
27891
27936
  const newPos2 = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
@@ -27985,7 +28030,7 @@ var __publicField = (obj, key, value) => {
27985
28030
  editorPageDownScroll(editor);
27986
28031
  return true;
27987
28032
  }
27988
- const logger$3s = getLogger("table-scroll");
28033
+ const logger$3t = getLogger("table-scroll");
27989
28034
  class DomEventHandler {
27990
28035
  constructor(editor, dom, name, handler, data2, options) {
27991
28036
  __publicField(this, "handleEvent", (event) => {
@@ -28017,7 +28062,7 @@ var __publicField = (obj, key, value) => {
28017
28062
  const existsHandlers = this.handlers.get(element);
28018
28063
  if (existsHandlers) {
28019
28064
  if (existsHandlers.find((handler) => handler.handler === eventHandler && handler.name === eventName)) {
28020
- logger$3s.warn(`event has already registered: ${eventName}`);
28065
+ logger$3t.warn(`event has already registered: ${eventName}`);
28021
28066
  return;
28022
28067
  }
28023
28068
  existsHandlers.push(new DomEventHandler(this.editor, element, eventName, eventHandler, data2, options));
@@ -28127,7 +28172,7 @@ var __publicField = (obj, key, value) => {
28127
28172
  });
28128
28173
  return true;
28129
28174
  }
28130
- const logger$3r = getLogger("select-all");
28175
+ const logger$3s = getLogger("select-all");
28131
28176
  function isContainerSelectedAllChildBlocks(container, range) {
28132
28177
  const firstBlock = getFirstChildBlock(container);
28133
28178
  const lastBlock2 = getLastChildBlock(container);
@@ -28142,8 +28187,8 @@ var __publicField = (obj, key, value) => {
28142
28187
  return range.start.blockId === blockId && range.start.childContainerId === getContainerId(first) && range.end.blockId === blockId && range.end.childContainerId === getContainerId(last);
28143
28188
  }
28144
28189
  function selectComplexBlock(editor, block) {
28145
- assert(logger$3r, block, "no parent block");
28146
- assert(logger$3r, isComplexKindBlock(editor, block), "not a complex block");
28190
+ assert(logger$3s, block, "no parent block");
28191
+ assert(logger$3s, isComplexKindBlock(editor, block), "not a complex block");
28147
28192
  const containers = getComplexBlockClass(editor, block).getChildContainers(editor, block);
28148
28193
  const first = containers[0];
28149
28194
  const last = containers[containers.length - 1];
@@ -28179,13 +28224,13 @@ var __publicField = (obj, key, value) => {
28179
28224
  selectParentContainer(editor, getFirstChildBlock(editor.rootContainer));
28180
28225
  return false;
28181
28226
  }
28182
- assert(logger$3r, !range.isSimple(), "invalid range type");
28227
+ assert(logger$3s, !range.isSimple(), "invalid range type");
28183
28228
  if (isComplexBlockSelectedAllChildContainer(focusedBlock, range)) {
28184
28229
  selectParentContainer(editor, focusedBlock);
28185
28230
  return false;
28186
28231
  }
28187
- assert(logger$3r, focusedBlock, "no parent block");
28188
- assert(logger$3r, isComplexKindBlock(editor, focusedBlock), "not a complex block");
28232
+ assert(logger$3s, focusedBlock, "no parent block");
28233
+ assert(logger$3s, isComplexKindBlock(editor, focusedBlock), "not a complex block");
28189
28234
  selectComplexBlock(editor, focusedBlock);
28190
28235
  return true;
28191
28236
  }
@@ -28221,6 +28266,30 @@ var __publicField = (obj, key, value) => {
28221
28266
  }
28222
28267
  editor.selection.setSelection(newStartPos, newEndPos);
28223
28268
  }
28269
+ function editorMoveBlockStart(editor) {
28270
+ const focus = editor.selection.range.focus;
28271
+ const block = editor.getBlockById(focus.blockId);
28272
+ if (!block)
28273
+ return false;
28274
+ if (!isSimpleBlock(editor, block))
28275
+ return false;
28276
+ const newPos = createSimpleBlockPosition(block, 0, "home");
28277
+ editor.selection.setSelection(newPos);
28278
+ editor.selection.updateLastCaretRect();
28279
+ return true;
28280
+ }
28281
+ function editorMoveBlockEnd(editor) {
28282
+ const focus = editor.selection.range.focus;
28283
+ const block = editor.getBlockById(focus.blockId);
28284
+ if (!block)
28285
+ return false;
28286
+ if (!isSimpleBlock(editor, block))
28287
+ return false;
28288
+ const newPos = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
28289
+ editor.selection.setSelection(newPos);
28290
+ editor.selection.updateLastCaretRect();
28291
+ return true;
28292
+ }
28224
28293
  function editorFocusToEnd(editor) {
28225
28294
  editorSelectEnd(editor);
28226
28295
  editor.focus();
@@ -28300,7 +28369,7 @@ var __publicField = (obj, key, value) => {
28300
28369
  }
28301
28370
  return cloned;
28302
28371
  }
28303
- const logger$3q = getLogger("selected-block-to-doc");
28372
+ const logger$3r = getLogger("selected-block-to-doc");
28304
28373
  function appendBlockChildren(editor, data2, doc2) {
28305
28374
  if (!data2.children)
28306
28375
  return;
@@ -28321,7 +28390,7 @@ var __publicField = (obj, key, value) => {
28321
28390
  if (isTextKindBlock(editor, selectedBlock.block)) {
28322
28391
  const start = selectedBlock.start;
28323
28392
  const end = selectedBlock.end;
28324
- assert(logger$3q, data2.text, "no block text");
28393
+ assert(logger$3r, data2.text, "no block text");
28325
28394
  if (start.offset === end.offset) {
28326
28395
  return {
28327
28396
  blocks: {
@@ -28355,8 +28424,8 @@ var __publicField = (obj, key, value) => {
28355
28424
  comments: {}
28356
28425
  };
28357
28426
  }
28358
- assert(logger$3q, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
28359
- assert(logger$3q, data2.children, "no children");
28427
+ assert(logger$3r, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
28428
+ assert(logger$3r, data2.children, "no children");
28360
28429
  const ret = {
28361
28430
  blocks: {
28362
28431
  root: [
@@ -28374,9 +28443,9 @@ var __publicField = (obj, key, value) => {
28374
28443
  const end = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
28375
28444
  return selectedBlockToDoc(editor, { block, start, end });
28376
28445
  }
28377
- const logger$3p = getLogger("block-to-doc");
28446
+ const logger$3q = getLogger("block-to-doc");
28378
28447
  function blocksToDoc(editor, blocks) {
28379
- assert(logger$3p, blocks.length > 0, "invalid params, no blocks");
28448
+ assert(logger$3q, blocks.length > 0, "invalid params, no blocks");
28380
28449
  const docs = blocks.map((b) => blockToDoc(editor, b));
28381
28450
  return mergeDocs(docs);
28382
28451
  }
@@ -28396,7 +28465,7 @@ var __publicField = (obj, key, value) => {
28396
28465
  const newDocs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s));
28397
28466
  return mergeDocs(newDocs);
28398
28467
  }
28399
- const logger$3o = getLogger("ensure-block-visible");
28468
+ const logger$3p = getLogger("ensure-block-visible");
28400
28469
  function ensureBlockVisible(editor, block) {
28401
28470
  var _a;
28402
28471
  while (block) {
@@ -28406,16 +28475,16 @@ var __publicField = (obj, key, value) => {
28406
28475
  return;
28407
28476
  }
28408
28477
  const parentComplexBlock = getParentBlock(container);
28409
- assert(logger$3o, parentComplexBlock, "no parent block");
28478
+ assert(logger$3p, parentComplexBlock, "no parent block");
28410
28479
  const parentComplexBlockClass = getBlockClass(editor, parentComplexBlock);
28411
28480
  if (parentComplexBlockClass.isChildContainerVisible && !((_a = parentComplexBlockClass.isChildContainerVisible) == null ? void 0 : _a.call(parentComplexBlockClass, editor, parentComplexBlock, container))) {
28412
- assert(logger$3o, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
28481
+ assert(logger$3p, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
28413
28482
  parentComplexBlockClass.showChildContainer(editor, parentComplexBlock, container);
28414
28483
  }
28415
28484
  block = parentComplexBlock;
28416
28485
  }
28417
28486
  }
28418
- const logger$3n = getLogger("editor-selection");
28487
+ const logger$3o = getLogger("editor-selection");
28419
28488
  class EditorSelection {
28420
28489
  constructor(editor) {
28421
28490
  __publicField(this, "editor");
@@ -28428,7 +28497,7 @@ var __publicField = (obj, key, value) => {
28428
28497
  }
28429
28498
  const range = this.range;
28430
28499
  if (rangeInBlock(deletedBlock, range)) {
28431
- logger$3n.debug("adjust selection because remote deleted current block");
28500
+ logger$3o.debug("adjust selection because remote deleted current block");
28432
28501
  const newRange = moveSelectionBeforeDeleteBlock(editor, deletedBlock);
28433
28502
  this.setRange(newRange, { noScroll: true });
28434
28503
  }
@@ -28553,14 +28622,14 @@ var __publicField = (obj, key, value) => {
28553
28622
  if (pos.isSimple()) {
28554
28623
  const ok = pos.offset >= 0 && pos.offset <= getBlockTextLength$6(this.editor, block);
28555
28624
  if (!ok) {
28556
- assert(logger$3n, false, "invalid block position, out of range");
28625
+ assert(logger$3o, false, "invalid block position, out of range");
28557
28626
  }
28558
28627
  } else {
28559
28628
  const childContainerId = pos.childContainerId;
28560
28629
  const container = this.editor.getContainerById(childContainerId);
28561
28630
  const ok = !!container;
28562
28631
  if (!ok) {
28563
- assert(logger$3n, false, "invalid complex block position, no container found");
28632
+ assert(logger$3o, false, "invalid complex block position, no container found");
28564
28633
  }
28565
28634
  }
28566
28635
  }
@@ -28621,7 +28690,7 @@ var __publicField = (obj, key, value) => {
28621
28690
  let container = getParentContainer(block);
28622
28691
  while (isChildContainer(container)) {
28623
28692
  const parentBlock = getParentBlock(container);
28624
- assert(logger$3n, parentBlock, "parent block not found");
28693
+ assert(logger$3o, parentBlock, "parent block not found");
28625
28694
  addClass(parentBlock, "child-focused");
28626
28695
  container = getParentContainer(parentBlock);
28627
28696
  }
@@ -28731,15 +28800,15 @@ var __publicField = (obj, key, value) => {
28731
28800
  editor.undoManager.redo();
28732
28801
  return true;
28733
28802
  }
28734
- const logger$3m = getLogger("delete-text");
28803
+ const logger$3n = getLogger("delete-text");
28735
28804
  function editorDeleteText(editor, type, count, insertPos) {
28736
28805
  const pos = insertPos != null ? insertPos : editor.selection.range.start;
28737
28806
  if (!(pos instanceof EditorSimpleBlockPosition)) {
28738
- assert(logger$3m, false, `invalid insert pos type: ${typeof pos}`);
28807
+ assert(logger$3n, false, `invalid insert pos type: ${typeof pos}`);
28739
28808
  }
28740
28809
  const { blockId } = pos;
28741
28810
  const block = editor.getBlockById(blockId);
28742
- assert(logger$3m, isTextKindBlock(editor, block), "block is not a text kind block");
28811
+ assert(logger$3n, isTextKindBlock(editor, block), "block is not a text kind block");
28743
28812
  let { offset } = pos;
28744
28813
  if (type === "backward") {
28745
28814
  if (offset - count < 0) {
@@ -28769,7 +28838,7 @@ var __publicField = (obj, key, value) => {
28769
28838
  }
28770
28839
  return false;
28771
28840
  }
28772
- const logger$3l = getLogger("handle-backspace");
28841
+ const logger$3m = getLogger("handle-backspace");
28773
28842
  function tryDeleteEmptyBlock(editor, block) {
28774
28843
  if (!isEmptyTextBlock(editor, block)) {
28775
28844
  return;
@@ -28809,7 +28878,7 @@ var __publicField = (obj, key, value) => {
28809
28878
  }
28810
28879
  } else {
28811
28880
  tryDeleteEmptyBlock(editor, block);
28812
- assert(logger$3l, isEmbedBlock(prevBlock), "prev block is not embed block");
28881
+ assert(logger$3m, isEmbedBlock(prevBlock), "prev block is not embed block");
28813
28882
  editor.selection.selectBlock(prevBlock, 1);
28814
28883
  }
28815
28884
  } else {
@@ -28836,6 +28905,7 @@ var __publicField = (obj, key, value) => {
28836
28905
  editor.deleteBlock(block);
28837
28906
  }
28838
28907
  }
28908
+ const logger$3l = getLogger("word-offset");
28839
28909
  function handleEditorDelete(editor, event) {
28840
28910
  if (!editor.selection.range.isCollapsed()) {
28841
28911
  editor.clearSelectedContents();
@@ -28870,6 +28940,130 @@ var __publicField = (obj, key, value) => {
28870
28940
  editor.deleteBlock(block);
28871
28941
  }
28872
28942
  }
28943
+ function handleEditorDeleteLeftWord(editor, event) {
28944
+ const old = editor.selection.range.focus;
28945
+ assert(logger$3l, old.isSimple(), "invalid range type");
28946
+ const block = editor.getBlockById(old.blockId);
28947
+ if (!isTextKindBlock(editor, block)) {
28948
+ editor.deleteBlock(block);
28949
+ return true;
28950
+ }
28951
+ if (old.offset === 0) {
28952
+ const matchNonEmptyTextBlockOrOtherBlock = (block2) => {
28953
+ if (!isTextKindBlock(editor, block2))
28954
+ return true;
28955
+ return !isEmptyTextBlock(editor, block2);
28956
+ };
28957
+ const prevBlock = getPrevVisibleBlock(block, matchNonEmptyTextBlockOrOtherBlock);
28958
+ if (!prevBlock)
28959
+ return false;
28960
+ const matchEmptyTextBlock = (block2) => isEmptyTextBlock(editor, block2);
28961
+ const emptyTextBlocks = getBlocksBetween(prevBlock, block, matchEmptyTextBlock);
28962
+ emptyTextBlocks.forEach((b) => {
28963
+ editor.deleteBlock(b);
28964
+ });
28965
+ if (!isTextKindBlock(editor, prevBlock)) {
28966
+ editor.deleteBlock(prevBlock);
28967
+ return true;
28968
+ }
28969
+ const textBlockLen = getBlockTextLength$6(editor, prevBlock);
28970
+ const newOffset2 = findWordLeft(editor, prevBlock, textBlockLen);
28971
+ editor.deleteTextFromBlock(prevBlock, newOffset2, textBlockLen - newOffset2);
28972
+ const currentBlockText = editor.getBlockText(block);
28973
+ editor.insertTextToBlock(prevBlock, newOffset2, currentBlockText);
28974
+ editor.deleteBlock(block);
28975
+ const pos = createSimpleBlockPosition(prevBlock, newOffset2, "normal");
28976
+ editor.selection.setSelection(pos);
28977
+ editor.selection.updateLastCaretRect();
28978
+ return true;
28979
+ }
28980
+ const newOffset = findWordLeft(editor, block, old.offset);
28981
+ const deletedCount = old.offset - newOffset;
28982
+ editor.deleteTextFromBlock(block, newOffset, deletedCount);
28983
+ return true;
28984
+ }
28985
+ function handleEditorDeleteRightWord(editor, event) {
28986
+ const old = editor.selection.range.focus;
28987
+ assert(logger$3l, old.isSimple(), "invalid range type");
28988
+ const block = editor.getBlockById(old.blockId);
28989
+ if (!isTextKindBlock(editor, block)) {
28990
+ editor.deleteBlock(block);
28991
+ return true;
28992
+ }
28993
+ if (old.offset === getTextBlockLength(block)) {
28994
+ const matchNonEmptyTextBlockOrOtherBlock = (block2) => {
28995
+ if (!isTextKindBlock(editor, block2))
28996
+ return true;
28997
+ return !isEmptyTextBlock(editor, block2);
28998
+ };
28999
+ const nextBlock = getNextVisibleBlock(block, matchNonEmptyTextBlockOrOtherBlock);
29000
+ if (!nextBlock)
29001
+ return false;
29002
+ const matchEmptyTextBlock = (block2) => isEmptyTextBlock(editor, block2);
29003
+ const emptyTextBlocks = getBlocksBetween(block, nextBlock, matchEmptyTextBlock);
29004
+ emptyTextBlocks.forEach((b) => {
29005
+ editor.deleteBlock(b);
29006
+ });
29007
+ if (!isTextKindBlock(editor, nextBlock)) {
29008
+ editor.deleteBlock(nextBlock);
29009
+ return true;
29010
+ }
29011
+ const newOffset = findWordEnd(editor, nextBlock, 0);
29012
+ editor.deleteTextFromBlock(nextBlock, 0, newOffset);
29013
+ const nextBlockText = editor.getBlockText(nextBlock);
29014
+ editor.insertTextToBlock(block, old.offset, nextBlockText);
29015
+ editor.deleteBlock(nextBlock);
29016
+ const pos = createSimpleBlockPosition(block, old.offset, "normal");
29017
+ editor.selection.setSelection(pos);
29018
+ editor.selection.updateLastCaretRect();
29019
+ return true;
29020
+ }
29021
+ const endOffset = findWordEnd(editor, block, old.offset);
29022
+ const deletedCount = endOffset - old.offset;
29023
+ editor.deleteTextFromBlock(block, old.offset, deletedCount);
29024
+ return true;
29025
+ }
29026
+ function handleEditorDeleteAfterWords(editor) {
29027
+ const old = editor.selection.range.focus;
29028
+ assert(logger$3l, old.isSimple(), "invalid range type");
29029
+ const block = editor.getBlockById(old.blockId);
29030
+ if (!isTextKindBlock(editor, block)) {
29031
+ editor.deleteBlock(block);
29032
+ return;
29033
+ }
29034
+ const needDeleteCount = getTextBlockLength(block) - old.offset;
29035
+ if (needDeleteCount === 0)
29036
+ return;
29037
+ editor.deleteTextFromBlock(block, old.offset, needDeleteCount);
29038
+ }
29039
+ function handleEditorDeleteRightChar(editor) {
29040
+ const old = editor.selection.range.focus;
29041
+ assert(logger$3l, old.isSimple(), "invalid range type");
29042
+ const block = editor.getBlockById(old.blockId);
29043
+ if (!isTextKindBlock(editor, block)) {
29044
+ editor.deleteBlock(block);
29045
+ return;
29046
+ }
29047
+ if (old.offset === getBlockTextLength$6(editor, block)) {
29048
+ const nextVisibleBlock = getNextVisibleBlock(block);
29049
+ if (!nextVisibleBlock)
29050
+ return;
29051
+ if (!isTextKindBlock(editor, nextVisibleBlock))
29052
+ return;
29053
+ if (isEmptyTextBlock(editor, nextVisibleBlock)) {
29054
+ editor.deleteBlock(nextVisibleBlock);
29055
+ return;
29056
+ }
29057
+ const nextBlockText = editor.getBlockText(nextVisibleBlock);
29058
+ editor.deleteBlock(nextVisibleBlock);
29059
+ editor.insertTextToBlock(block, old.offset, nextBlockText);
29060
+ const pos = createSimpleBlockPosition(block, old.offset, "normal");
29061
+ editor.selection.setSelection(pos);
29062
+ editor.selection.updateLastCaretRect();
29063
+ return;
29064
+ }
29065
+ editorDeleteText(editor, "forward", 1, null);
29066
+ }
28873
29067
  function handleEditorEnterEvent$1(editor, event) {
28874
29068
  if (isFullSelectedOneComplexBlock(editor)) {
28875
29069
  const focusedBlock2 = editor.getFocusedBlock();
@@ -29091,6 +29285,42 @@ var __publicField = (obj, key, value) => {
29091
29285
  return true;
29092
29286
  });
29093
29287
  }
29288
+ function editorHandleDeleteLeftWord(editor, event) {
29289
+ if (editor.readonly || !editor.isWritable()) {
29290
+ return false;
29291
+ }
29292
+ return editor.undoManager.runInGroup(() => {
29293
+ handleEditorDeleteLeftWord(editor);
29294
+ return true;
29295
+ });
29296
+ }
29297
+ function editorHandleDeleteRightWord(editor, event) {
29298
+ if (editor.readonly || !editor.isWritable()) {
29299
+ return false;
29300
+ }
29301
+ return editor.undoManager.runInGroup(() => {
29302
+ handleEditorDeleteRightWord(editor);
29303
+ return true;
29304
+ });
29305
+ }
29306
+ function editorHandleDeleteAfterWords(editor, event) {
29307
+ if (editor.readonly || !editor.isWritable()) {
29308
+ return false;
29309
+ }
29310
+ return editor.undoManager.runInGroup(() => {
29311
+ handleEditorDeleteAfterWords(editor);
29312
+ return true;
29313
+ });
29314
+ }
29315
+ function editorHandleDeleteRightChar(editor, event) {
29316
+ if (editor.readonly || !editor.isWritable()) {
29317
+ return false;
29318
+ }
29319
+ return editor.undoManager.runInGroup(() => {
29320
+ handleEditorDeleteRightChar(editor);
29321
+ return true;
29322
+ });
29323
+ }
29094
29324
  function editorHandleBackspace(editor, event) {
29095
29325
  if (editor.readonly || !editor.isWritable()) {
29096
29326
  return false;
@@ -29184,6 +29414,10 @@ ${codeText}
29184
29414
  __proto__: null,
29185
29415
  editorHandleEnter,
29186
29416
  editorHandleDelete,
29417
+ editorHandleDeleteLeftWord,
29418
+ editorHandleDeleteRightWord,
29419
+ editorHandleDeleteAfterWords,
29420
+ editorHandleDeleteRightChar,
29187
29421
  editorHandleBackspace,
29188
29422
  editorHandleInsertBr,
29189
29423
  editorHandlePastePlainText,
@@ -29191,6 +29425,41 @@ ${codeText}
29191
29425
  getSelectedCodeBlockMarkdown,
29192
29426
  editorHandleCopyMarkdown
29193
29427
  }, Symbol.toStringTag, { value: "Module" }));
29428
+ const MacShortcuts = {
29429
+ "Cmd+ArrowLeft": editorMoveLineHome,
29430
+ "Cmd+ArrowRight": editorMoveLineEnd,
29431
+ "Option+ArrowLeft": editorMoveWordLeft,
29432
+ "Option+ArrowRight": editorMoveWordEnd,
29433
+ "Option+Shift+ArrowLeft": editorSelectWordLeft,
29434
+ "Option+Shift+ArrowRight": editorSelectWordEnd,
29435
+ "Cmd+Shift+ArrowLeft": editorSelectLineHome,
29436
+ "Cmd+Shift+ArrowRight": editorSelectLineEnd,
29437
+ "Ctrl+A": editorMoveBlockStart,
29438
+ "Ctrl+E": editorMoveBlockEnd,
29439
+ "Option+Delete": editorHandleDeleteRightWord,
29440
+ "Option+Backspace": editorHandleDeleteLeftWord,
29441
+ "Ctrl+B": editorMoveLeft,
29442
+ "Ctrl+F": editorMoveRight,
29443
+ "Ctrl+N": editorMoveDown,
29444
+ "Ctrl+P": editorMoveUp,
29445
+ "Ctrl+K": editorHandleDeleteAfterWords,
29446
+ "Ctrl+H": editorHandleBackspace,
29447
+ "Ctrl+D": editorHandleDeleteRightChar
29448
+ };
29449
+ const WinLinuxShortcuts = {
29450
+ "Home": editorMoveLineHome,
29451
+ "End": editorMoveLineEnd,
29452
+ "Shift+Home": editorSelectLineHome,
29453
+ "Shift+End": editorSelectLineEnd,
29454
+ "Ctrl+Delete": editorHandleDeleteRightWord,
29455
+ "Ctrl+Backspace": editorHandleDeleteLeftWord,
29456
+ "Ctrl+ArrowLeft": editorMoveWordLeft,
29457
+ "Ctrl+ArrowRight": editorMoveWordEnd,
29458
+ "Ctrl+Shift+ArrowLeft": editorSelectWordLeft,
29459
+ "Ctrl+Shift+ArrowRight": editorSelectWordEnd
29460
+ };
29461
+ const isMac = clientType.isMac;
29462
+ const CustomShortcuts = isMac ? MacShortcuts : WinLinuxShortcuts;
29194
29463
  const DefaultShortcuts = {
29195
29464
  "ArrowDown": editorMoveDown,
29196
29465
  "ArrowUp": editorMoveUp,
@@ -29200,19 +29469,11 @@ ${codeText}
29200
29469
  "Shift+ArrowUp": editorSelectUp,
29201
29470
  "Shift+ArrowLeft": editorSelectLeft,
29202
29471
  "Shift+ArrowRight": editorSelectRight,
29203
- "CtrlOrCmd+ArrowLeft": editorMoveWordLeft,
29204
- "CtrlOrCmd+ArrowRight": editorMoveWordEnd,
29205
- "CtrlOrCmd+Shift+ArrowLeft": editorSelectWordLeft,
29206
- "CtrlOrCmd+Shift+ArrowRight": editorSelectWordEnd,
29207
29472
  "CtrlOrCmd+ArrowUp": editorMoveHome,
29208
29473
  "CtrlOrCmd+ArrowDown": editorMoveEnd,
29209
29474
  "CtrlOrCmd+Shift+ArrowUp": editorSelectHome,
29210
29475
  "CtrlOrCmd+Shift+ArrowDown": editorSelectEnd,
29211
29476
  "CtrlOrCmd+A": editorSelectAll,
29212
- "Home": editorMoveLineHome,
29213
- "End": editorMoveLineEnd,
29214
- "Shift+Home": editorSelectLineHome,
29215
- "Shift+End": editorSelectLineEnd,
29216
29477
  "PageUp": editorMovePageUp,
29217
29478
  "PageDown": editorMovePageDown,
29218
29479
  "Shift+PageUp": editorSelectPageUp,
@@ -29224,7 +29485,8 @@ ${codeText}
29224
29485
  "Backspace": editorHandleBackspace,
29225
29486
  "Shift+Enter": editorHandleInsertBr,
29226
29487
  "CtrlOrCmd+Shift+V": editorHandlePastePlainText,
29227
- "CtrlOrCmd+Shift+C": editorHandleCopyMarkdown
29488
+ "CtrlOrCmd+Shift+C": editorHandleCopyMarkdown,
29489
+ ...CustomShortcuts
29228
29490
  };
29229
29491
  function editorHandleKeyboardEvent(editor, event) {
29230
29492
  const result = editor.shortcuts.handleKeyboardEvents(editor, event);
@@ -42451,6 +42713,7 @@ ${codeText}
42451
42713
  this.options.onClickItem(this, item);
42452
42714
  }, 300, { leading: true, trailing: false }));
42453
42715
  __publicField(this, "handleShow", (menu) => {
42716
+ this.menu.content.classList.add("auto-suggest-menu");
42454
42717
  });
42455
42718
  __publicField(this, "handleShown", () => {
42456
42719
  var _a, _b;
@@ -43002,8 +43265,21 @@ ${codeText}
43002
43265
  const textColorItem = "";
43003
43266
  const DEFAULT_BG_COLOR = 2;
43004
43267
  const NULLABLE_COLOR = -1;
43268
+ const STORAGE_NAME = "color-item";
43269
+ function getColorsFromLocalStorage(editor) {
43270
+ const colors = [null, null];
43271
+ const color = Number.parseInt(editor.settingsProvider.getItem(`${STORAGE_NAME}-color`) || "", 10);
43272
+ const backgroundColor = Number.parseInt(editor.settingsProvider.getItem(`${STORAGE_NAME}-backgroundColor`) || `${DEFAULT_BG_COLOR}`, 10);
43273
+ if (!Number.isNaN(color)) {
43274
+ colors[0] = color;
43275
+ }
43276
+ if (!Number.isNaN(backgroundColor)) {
43277
+ colors[1] = backgroundColor;
43278
+ }
43279
+ return colors;
43280
+ }
43005
43281
  class TextColorItem extends tinyTypedEmitter.TypedEmitter {
43006
- constructor(editor, storageName = "color-item") {
43282
+ constructor(editor, storageName = STORAGE_NAME) {
43007
43283
  super();
43008
43284
  __publicField(this, "id", "text-color-item");
43009
43285
  __publicField(this, "name", i18n$1.t("colorPalette.name"));
@@ -43494,6 +43770,32 @@ ${codeText}
43494
43770
  }
43495
43771
  return this.menu.handleKeydown(event);
43496
43772
  }
43773
+ async handleBeforePasteDoc(editor, doc2) {
43774
+ var _a;
43775
+ if (!((_a = this.menu) == null ? void 0 : _a.isVisible)) {
43776
+ return false;
43777
+ }
43778
+ const shouldCancelAutoSuggest = () => {
43779
+ var _a2;
43780
+ const blocks = doc2.blocks.root;
43781
+ if (blocks.length !== 1) {
43782
+ return true;
43783
+ }
43784
+ const block = blocks[0];
43785
+ if (((_a2 = editor.editorBlocks.getBlockClass(block.type)) == null ? void 0 : _a2.blockKind) !== "text") {
43786
+ return true;
43787
+ }
43788
+ const text2 = toPlainText(block.text || []);
43789
+ if (text2.length > 50) {
43790
+ return true;
43791
+ }
43792
+ return false;
43793
+ };
43794
+ if (shouldCancelAutoSuggest()) {
43795
+ this.menu.close();
43796
+ }
43797
+ return false;
43798
+ }
43497
43799
  popup(block, offset, leftText, trigger) {
43498
43800
  this.anchor = {
43499
43801
  blockId: getBlockId(block),
@@ -43549,6 +43851,13 @@ ${codeText}
43549
43851
  }
43550
43852
  return this.triggerPopup(editor, containerId, blockIndex, insertOffset, text2);
43551
43853
  }
43854
+ async handleAfterPasteDoc(editor, doc2, cloneDocResult) {
43855
+ var _a;
43856
+ if ((_a = this.menu) == null ? void 0 : _a.isVisible) {
43857
+ this.resetItems();
43858
+ }
43859
+ return false;
43860
+ }
43552
43861
  handleUpdateCompositionText(editor, containerId, blockIndex, offset, end) {
43553
43862
  var _a;
43554
43863
  const start = editor.selection.range.start;
@@ -50698,7 +51007,7 @@ ${codeText}
50698
51007
  }
50699
51008
  return handleDragList(editor, draggedBlock, targetBlock, insertPos);
50700
51009
  }
50701
- function executeShortcut$1(editor, type) {
51010
+ function executeShortcut$3(editor, type) {
50702
51011
  if (!editor.isWritable()) {
50703
51012
  return false;
50704
51013
  }
@@ -50712,8 +51021,8 @@ ${codeText}
50712
51021
  return true;
50713
51022
  }
50714
51023
  const ListBlockShortcuts = {
50715
- "Shift+CtrlOrCmd+L": (editor) => executeShortcut$1(editor, "ordered-list"),
50716
- "Shift+CtrlOrCmd+U": (editor) => executeShortcut$1(editor, "unordered-list")
51024
+ "Shift+CtrlOrCmd+L": (editor) => executeShortcut$3(editor, "ordered-list"),
51025
+ "Shift+CtrlOrCmd+U": (editor) => executeShortcut$3(editor, "unordered-list")
50717
51026
  };
50718
51027
  function getBlockPadding$1(block) {
50719
51028
  const padding = block.getAttribute("block-padding-level");
@@ -61223,6 +61532,31 @@ $$${mathData.mathjaxText}$$
61223
61532
  return editor.addCustom("overflow-tooltip-helper", () => new OverflowTooltipHelper(editor));
61224
61533
  }
61225
61534
  }
61535
+ function executeShortcut$2(editor, style2) {
61536
+ if (!editor.isWritable()) {
61537
+ return false;
61538
+ }
61539
+ const range = editor.selection.range;
61540
+ const allCommands = editor.editorCommandProviders.getCommands(range);
61541
+ const alignCommands = allCommands.flatMap((command2) => {
61542
+ if (command2.id === "align") {
61543
+ return command2.children;
61544
+ }
61545
+ return [];
61546
+ });
61547
+ const command = alignCommands.find((c) => c.id === `align-${style2}`);
61548
+ if (!command) {
61549
+ return false;
61550
+ }
61551
+ editor.editorCommandProviders.executeCommand(range, command, {});
61552
+ OnesEditorToolbar.get(editor).update("selectionChange");
61553
+ return true;
61554
+ }
61555
+ const AlignShortcuts = {
61556
+ "CtrlOrCmd+Shift+E": (editor) => executeShortcut$2(editor, "center"),
61557
+ "CtrlOrCmd+Shift+O": (editor) => executeShortcut$2(editor, "left"),
61558
+ "CtrlOrCmd+Shift+R": (editor) => executeShortcut$2(editor, "right")
61559
+ };
61226
61560
  const TextCommands = {
61227
61561
  "text/style-bold": "bold",
61228
61562
  "text/style-italic": "italic",
@@ -61231,14 +61565,15 @@ $$${mathData.mathjaxText}$$
61231
61565
  "text/style-code": "code",
61232
61566
  "text/style-sub": "subscript",
61233
61567
  "text/style-super": "superscript",
61234
- link: "link"
61568
+ link: "link",
61569
+ "insert-link": "link"
61235
61570
  };
61236
61571
  function getTextCommands(editor, blockCommands) {
61237
61572
  const styleCommandsSet = new Set(Object.keys(TextCommands));
61238
61573
  const styleCommands = blockCommands.filter((command) => styleCommandsSet.has(command.id));
61239
61574
  return styleCommands;
61240
61575
  }
61241
- function executeShortcut(editor, style2) {
61576
+ function executeShortcut$1(editor, style2) {
61242
61577
  if (!editor.isWritable()) {
61243
61578
  return false;
61244
61579
  }
@@ -61248,7 +61583,7 @@ $$${mathData.mathjaxText}$$
61248
61583
  const range = editor.selection.range;
61249
61584
  const allCommands = editor.editorCommandProviders.getCommands(range);
61250
61585
  const textCommands = getTextCommands(editor, allCommands);
61251
- const command = textCommands.find((c) => c.id === `text/${style2}` || c.id === "link");
61586
+ const command = textCommands.find((c) => c.id === `text/${style2}` || c.id === "link" || c.id === "insert-link");
61252
61587
  if (!command) {
61253
61588
  return false;
61254
61589
  }
@@ -61283,13 +61618,37 @@ $$${mathData.mathjaxText}$$
61283
61618
  return shortcuts2;
61284
61619
  };
61285
61620
  const TextStyleShortcuts = {
61286
- "CtrlOrCmd+B": (editor) => executeShortcut(editor, "style-bold"),
61287
- "CtrlOrCmd+I": (editor) => executeShortcut(editor, "style-italic"),
61288
- "CtrlOrCmd+U": (editor) => executeShortcut(editor, "style-underline"),
61289
- "CtrlOrCmd+D": (editor) => executeShortcut(editor, "style-strikethrough"),
61290
- "CtrlOrCmd+K": (editor) => executeShortcut(editor, "link"),
61621
+ "CtrlOrCmd+B": (editor) => executeShortcut$1(editor, "style-bold"),
61622
+ "CtrlOrCmd+I": (editor) => executeShortcut$1(editor, "style-italic"),
61623
+ "CtrlOrCmd+U": (editor) => executeShortcut$1(editor, "style-underline"),
61624
+ "CtrlOrCmd+D": (editor) => executeShortcut$1(editor, "style-strikethrough"),
61625
+ "CtrlOrCmd+K": (editor) => executeShortcut$1(editor, "insert-link"),
61291
61626
  ...headingShortcut()
61292
61627
  };
61628
+ function executeShortcut(editor) {
61629
+ if (!editor.isWritable()) {
61630
+ return false;
61631
+ }
61632
+ const range = editor.selection.range;
61633
+ if (range.isCollapsed()) {
61634
+ return false;
61635
+ }
61636
+ editor.undoManager.runInGroup(() => {
61637
+ const colors = getColorsFromLocalStorage(editor);
61638
+ colors.forEach((color, idx) => {
61639
+ if (color === null) {
61640
+ return;
61641
+ }
61642
+ const type = idx === 0 ? "color" : "backgroundColor";
61643
+ editorRangeSetColor(editor, type, color, () => {
61644
+ });
61645
+ });
61646
+ });
61647
+ return true;
61648
+ }
61649
+ const TextColorShortcuts = {
61650
+ "CtrlOrCmd+Alt+KeyH": (editor) => executeShortcut(editor)
61651
+ };
61293
61652
  const zhCN$p = {
61294
61653
  quickMenu: {
61295
61654
  basic: {
@@ -62048,7 +62407,7 @@ $$${mathData.mathjaxText}$$
62048
62407
  __publicField(this, "updateButtonColor", (range) => {
62049
62408
  const currentTextColor = editorRangeGetColor(this.editor, range, this.getEmptyTextBlockColor);
62050
62409
  this.colorItem.setCurrentTextColors(currentTextColor);
62051
- const lastButtonColor = this.colorItem.getColorsFromLocalStorage();
62410
+ const lastButtonColor = getColorsFromLocalStorage(this.editor);
62052
62411
  this.colorItem.setCurrentButtonColor(lastButtonColor);
62053
62412
  });
62054
62413
  __publicField(this, "setActiveAttribute", (type, value) => {
@@ -65830,7 +66189,7 @@ ${codeText}
65830
66189
  const blocks = editor.doc.getContainerBlocks(getContainerId(editor.rootContainer));
65831
66190
  assert(logger$1o, blocks.length > 0, "root container is empty");
65832
66191
  const firstBlock = blocks[0];
65833
- if (firstBlock.type !== "text" && !this.options.hideTitle) {
66192
+ if (!isTextKindBlockType(editor, firstBlock.type) && !this.options.hideTitle) {
65834
66193
  const blockData = createTextBlockData("", { heading: (_a = this.options.headingLevel) != null ? _a : 1 });
65835
66194
  const newBlock = editor.insertBlock(getContainerId(editor.rootContainer), 0, blockData, editor.selection.range.toDocRange());
65836
66195
  newBlock.setAttribute("data-document-title", "");
@@ -65839,7 +66198,7 @@ ${codeText}
65839
66198
  if (!this.options.hideTitle) {
65840
66199
  assert(logger$1o, firstBlock.text, "invalid text block");
65841
66200
  const block = editor.getBlockById(firstBlock.id);
65842
- if (hasAttributes(firstBlock.text) || firstBlock.quoted || firstBlock.heading !== this.options.headingLevel) {
66201
+ if (hasAttributes(firstBlock.text) || firstBlock.quoted || firstBlock.heading !== this.options.headingLevel || firstBlock.type !== "text") {
65843
66202
  const text2 = editor.getBlockString(block);
65844
66203
  const blockData = createTextBlockData(text2, { heading: (_b = this.options.headingLevel) != null ? _b : 1, quoted: false });
65845
66204
  const focusedBlock = editor.selection.focusedBlock;
@@ -73435,6 +73794,16 @@ ${codeText}
73435
73794
  return false;
73436
73795
  }
73437
73796
  }
73797
+ const existsAutoSuggest = document.querySelector(".auto-suggest-menu");
73798
+ if (existsAutoSuggest) {
73799
+ const root2 = existsAutoSuggest.closest("[data-tippy-root]");
73800
+ if (root2) {
73801
+ const visibility = window.getComputedStyle(root2).visibility;
73802
+ if (visibility === "visible") {
73803
+ return false;
73804
+ }
73805
+ }
73806
+ }
73438
73807
  this.button.clearCheckedState();
73439
73808
  this.button.show(docs);
73440
73809
  this.event = event;
@@ -73670,12 +74039,16 @@ ${codeText}
73670
74039
  });
73671
74040
  }
73672
74041
  const StyleTags = {
74042
+ i: "style-italic",
74043
+ b: "style-bold",
73673
74044
  u: "style-underline",
73674
74045
  strong: "style-bold",
73675
74046
  em: "style-italic",
73676
74047
  del: "style-strikethrough",
73677
74048
  superscript: "style-superscript",
73678
- subscript: "style-subscript"
74049
+ sup: "style-superscript",
74050
+ subscript: "style-subscript",
74051
+ sub: "style-subscript"
73679
74052
  };
73680
74053
  function applyHtmlToText(htm, attributes) {
73681
74054
  const html = htm.toLowerCase();
@@ -73823,6 +74196,18 @@ ${codeText}
73823
74196
  }
73824
74197
  if (token.type === "html") {
73825
74198
  const html = token.text;
74199
+ const testBr = html.trim().toLowerCase();
74200
+ if (testBr === "<br>" || testBr === "<br/>" || testBr === "<br />") {
74201
+ return [{
74202
+ insert: " ",
74203
+ attributes: {
74204
+ id: genId(),
74205
+ created: Date.now(),
74206
+ box: true,
74207
+ type: "br"
74208
+ }
74209
+ }];
74210
+ }
73826
74211
  applyHtmlToText(html, attributes);
73827
74212
  applyColorTagToText(html, attributes);
73828
74213
  applyFontSizeTagToText(html, attributes);
@@ -73857,6 +74242,22 @@ ${codeText}
73857
74242
  }
73858
74243
  }];
73859
74244
  }
74245
+ if (token.type === "image") {
74246
+ const href = token.href || "";
74247
+ if (href) {
74248
+ const boxData = {
74249
+ id: genId(),
74250
+ created: Date.now(),
74251
+ box: true,
74252
+ type: "image",
74253
+ src: href
74254
+ };
74255
+ return [{
74256
+ insert: " ",
74257
+ attributes: boxData
74258
+ }];
74259
+ }
74260
+ }
73860
74261
  logger$Q.warn(`unknown token in text: ${JSON.stringify(token)}`);
73861
74262
  return [];
73862
74263
  });
@@ -73873,6 +74274,15 @@ ${codeText}
73873
74274
  }
73874
74275
  function paragraphToBlocks(token, options) {
73875
74276
  const { text: text2, children } = options.tokensToTextWithChildren(token.tokens, options);
74277
+ if (text2.length > 0 && toPlainText(text2).trim().toUpperCase() === "[TOC]") {
74278
+ const tocBlock = {
74279
+ id: genId(),
74280
+ type: "embed",
74281
+ embedType: "toc",
74282
+ embedData: {}
74283
+ };
74284
+ return [tocBlock];
74285
+ }
73876
74286
  const blocks = [];
73877
74287
  if (text2.length > 0) {
73878
74288
  blocks.push({
@@ -74198,15 +74608,24 @@ ${codeText}
74198
74608
  children: []
74199
74609
  };
74200
74610
  const groups = groupTokens(tokens);
74201
- groups.forEach((tokens2, index2) => {
74202
- const token = tokens2[0];
74611
+ groups.forEach((childTokens, index2) => {
74203
74612
  if (index2 === 0) {
74613
+ const token = childTokens[0];
74204
74614
  if (isInlineToken(token)) {
74205
- ret.text = tokensToText(tokens2, {}, options);
74615
+ ret.text = tokensToText(childTokens, {}, options);
74206
74616
  return;
74207
74617
  }
74208
74618
  }
74209
- ret.children.push(...tokensToBlocks(tokens2, options));
74619
+ if (childTokens.every((token) => isInlineToken(token))) {
74620
+ const blockText = tokensToText(childTokens, {}, options);
74621
+ ret.children.push({
74622
+ id: genId(),
74623
+ type: "text",
74624
+ text: blockText
74625
+ });
74626
+ return;
74627
+ }
74628
+ ret.children.push(...tokensToBlocks(childTokens, options));
74210
74629
  });
74211
74630
  return ret;
74212
74631
  }
@@ -74257,7 +74676,11 @@ ${codeText}
74257
74676
  };
74258
74677
  const rootBlocks = tokensToBlocks(tokens, tokenToBlockOptions);
74259
74678
  if (rootBlocks.length === 0) {
74260
- return null;
74679
+ rootBlocks.push({
74680
+ id: genId(),
74681
+ type: "text",
74682
+ text: []
74683
+ });
74261
74684
  }
74262
74685
  doc2.blocks.root.push(...rootBlocks);
74263
74686
  return doc2;
@@ -75519,8 +75942,8 @@ ${content}
75519
75942
  const container = document.createElement("div");
75520
75943
  container.classList.add("highlight-text-wizdoc");
75521
75944
  const code = document.createElement("pre");
75945
+ code.textContent = base64;
75522
75946
  container.appendChild(code);
75523
- code.innerText = base64;
75524
75947
  node.insertAdjacentElement("beforebegin", container);
75525
75948
  node.remove();
75526
75949
  return;
@@ -77547,7 +77970,7 @@ ${docStr}
77547
77970
  async function downloadImageToFile$1(src) {
77548
77971
  try {
77549
77972
  const res = await fetch(src, {
77550
- credentials: "same-origin"
77973
+ credentials: "include"
77551
77974
  });
77552
77975
  const blob = await res.blob();
77553
77976
  const contentType = getContentTypeFromHeaders$1(res.headers).toLocaleLowerCase();
@@ -85138,6 +85561,9 @@ ${data2.flowchartText}
85138
85561
  async function plantumlUrlToResourceId(editor, url) {
85139
85562
  try {
85140
85563
  const plantumlImgFile = await downloadObjectToFile(editor, url);
85564
+ if (!plantumlImgFile) {
85565
+ return await Promise.resolve(url);
85566
+ }
85141
85567
  const uploadResourceResult = await editor.doc.uploadResource(plantumlImgFile);
85142
85568
  return uploadResourceResult.resourceId;
85143
85569
  } catch (error2) {
@@ -90446,9 +90872,6 @@ ${data2.plantumlText}
90446
90872
  return void 0;
90447
90873
  }
90448
90874
  function hasBorder(block) {
90449
- if (block.type === "embed" && block.embedType && embedTypeHasImage(block.embedType) && block.embedData && block.embedData.src) {
90450
- return true;
90451
- }
90452
90875
  return false;
90453
90876
  }
90454
90877
  async function getBlockObject(block, md5Func, textsByBox) {
@@ -90461,7 +90884,7 @@ ${data2.plantumlText}
90461
90884
  texts: await getBlockTextObjects(block, textsByBox),
90462
90885
  list: getBlockListObject(block),
90463
90886
  images: getBlockImageObject(block, md5Func),
90464
- border: hasBorder(block)
90887
+ border: hasBorder()
90465
90888
  };
90466
90889
  }
90467
90890
  async function getCodeObject(block, data2, md5Func, textsByBox) {
@@ -91903,9 +92326,11 @@ ${data2.plantumlText}
91903
92326
  FindReplaceShortcuts,
91904
92327
  BlockPaddingShortcuts,
91905
92328
  TextStyleShortcuts,
92329
+ AlignShortcuts,
91906
92330
  AutoLinkShortcuts,
91907
92331
  DefaultShortcuts,
91908
92332
  ListBlockShortcuts,
92333
+ TextColorShortcuts,
91909
92334
  ...options.shortcuts || []
91910
92335
  ],
91911
92336
  colors: [
@@ -92114,7 +92539,7 @@ ${data2.plantumlText}
92114
92539
  }
92115
92540
  }
92116
92541
  });
92117
- editor.version = "2.7.1-beta.1";
92542
+ editor.version = "2.8.0";
92118
92543
  return editor;
92119
92544
  }
92120
92545
  function isDoc(doc2) {
@@ -92227,7 +92652,7 @@ ${data2.plantumlText}
92227
92652
  }
92228
92653
  });
92229
92654
  OnesEditorToolbar.register(editor);
92230
- editor.version = "2.7.1-beta.1";
92655
+ editor.version = "2.8.0";
92231
92656
  return editor;
92232
92657
  }
92233
92658
  async function showDocVersions(editor, options, serverUrl) {
@@ -138013,6 +138438,7 @@ ${data2.plantumlText}
138013
138438
  exports2.AlignProvider = AlignProvider;
138014
138439
  exports2.AlignRightIcon = AlignRightIcon;
138015
138440
  exports2.AlignRightItem = AlignRightItem;
138441
+ exports2.AlignShortcuts = AlignShortcuts;
138016
138442
  exports2.AnchorBox = AnchorBox;
138017
138443
  exports2.ArrowDownIcon = ArrowDownIcon$1;
138018
138444
  exports2.ArrowLeftIcon = arrowLeft;
@@ -138269,6 +138695,7 @@ ${data2.plantumlText}
138269
138695
  exports2.TextBox = TextBox;
138270
138696
  exports2.TextColorIcon = TextColorIcon;
138271
138697
  exports2.TextColorItem = TextColorItem;
138698
+ exports2.TextColorShortcuts = TextColorShortcuts;
138272
138699
  exports2.TextCommandProvider = TextCommandProvider;
138273
138700
  exports2.TextGroupIcon = TextGroupIcon;
138274
138701
  exports2.TextIcon = TextIcon;
@@ -138438,6 +138865,8 @@ ${data2.plantumlText}
138438
138865
  exports2.editorInsertTextToBlock = editorInsertTextToBlock;
138439
138866
  exports2.editorInsertTextToBlockEx = editorInsertTextToBlockEx;
138440
138867
  exports2.editorMergeTextBlock = editorMergeTextBlock;
138868
+ exports2.editorMoveBlockEnd = editorMoveBlockEnd;
138869
+ exports2.editorMoveBlockStart = editorMoveBlockStart;
138441
138870
  exports2.editorMoveDown = editorMoveDown;
138442
138871
  exports2.editorMoveEnd = editorMoveEnd;
138443
138872
  exports2.editorMoveHome = editorMoveHome;
@@ -138542,6 +138971,7 @@ ${data2.plantumlText}
138542
138971
  exports2.getBlockTextLength = getBlockTextLength$6;
138543
138972
  exports2.getBlockTools = getBlockTools;
138544
138973
  exports2.getBlockType = getBlockType;
138974
+ exports2.getBlocksBetween = getBlocksBetween;
138545
138975
  exports2.getBlocksWidth = getBlocksWidth;
138546
138976
  exports2.getBoxContent = getBoxContent;
138547
138977
  exports2.getBoxId = getBoxId;
@@ -138554,6 +138984,7 @@ ${data2.plantumlText}
138554
138984
  exports2.getClosestContainerByCondition = getClosestContainerByCondition;
138555
138985
  exports2.getColorFromAttributes = getColorFromAttributes;
138556
138986
  exports2.getColorFromContent = getColorFromContent;
138987
+ exports2.getColorsFromLocalStorage = getColorsFromLocalStorage;
138557
138988
  exports2.getComplexBlockClass = getComplexBlockClass;
138558
138989
  exports2.getContainerBlockOverrideOptions = getContainerBlockOverrideOptions;
138559
138990
  exports2.getContainerBlockPath = getContainerBlockPath;
@@ -138656,6 +139087,7 @@ ${data2.plantumlText}
138656
139087
  exports2.isBox = isBox;
138657
139088
  exports2.isBoxOp = isBoxOp;
138658
139089
  exports2.isCJK = isCJK;
139090
+ exports2.isCJKPunctuation = isCJKPunctuation;
138659
139091
  exports2.isChildContainer = isChildContainer;
138660
139092
  exports2.isChildNode = isChildNode;
138661
139093
  exports2.isClipboardEmpty = isClipboardEmpty$1;
@@ -138728,7 +139160,7 @@ ${data2.plantumlText}
138728
139160
  exports2.loadJs = loadJs;
138729
139161
  exports2.loadJsPromise = loadJsPromise;
138730
139162
  exports2.lockers = lockers;
138731
- exports2.logger = logger$4p;
139163
+ exports2.logger = logger$4q;
138732
139164
  exports2.markdownToDoc = markdownToDoc;
138733
139165
  exports2.mergeCommands = mergeCommands;
138734
139166
  exports2.mergeDocs = mergeDocs;