@ones-editor/editor 2.7.1-beta.2 → 2.8.1

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