@ones-editor/editor 2.4.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -44,7 +44,6 @@ div.editor-root {
44
44
  box-sizing: border-box;
45
45
  min-height: 100%;
46
46
  width: 100%;
47
- z-index: 1;
48
47
  }
49
48
  div.editor-root.readonly div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] span.text.link {
50
49
  cursor: pointer;
@@ -8901,7 +8900,7 @@ var __publicField = (obj, key, value) => {
8901
8900
  imageExportFailed: "\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F"
8902
8901
  }
8903
8902
  };
8904
- const logger$4R = getLogger("i18n");
8903
+ const logger$4S = getLogger("i18n");
8905
8904
  const langs$3 = {
8906
8905
  "en-US": enUS$x,
8907
8906
  "zh-CN": zhCN$x,
@@ -8921,7 +8920,7 @@ var __publicField = (obj, key, value) => {
8921
8920
  function t$8(key, args) {
8922
8921
  const ret = i18n.get(key, args);
8923
8922
  if (ret === key) {
8924
- logger$4R.warn(`no locale value for key ${key}`);
8923
+ logger$4S.warn(`no locale value for key ${key}`);
8925
8924
  }
8926
8925
  return ret;
8927
8926
  }
@@ -9534,7 +9533,7 @@ var __publicField = (obj, key, value) => {
9534
9533
  this._callbacks.clear();
9535
9534
  }
9536
9535
  }
9537
- const logger$4Q = getLogger("await-locker");
9536
+ const logger$4R = getLogger("await-locker");
9538
9537
  class AwaitLock {
9539
9538
  constructor() {
9540
9539
  __publicField(this, "_acquired", false);
@@ -9576,7 +9575,7 @@ var __publicField = (obj, key, value) => {
9576
9575
  }
9577
9576
  if (this._waitingResolvers.length > 0) {
9578
9577
  const resolve = this._waitingResolvers.shift();
9579
- assert(logger$4Q, resolve, "Resolver missing");
9578
+ assert(logger$4R, resolve, "Resolver missing");
9580
9579
  resolve(void 0);
9581
9580
  } else {
9582
9581
  this._acquired = false;
@@ -9659,7 +9658,7 @@ var __publicField = (obj, key, value) => {
9659
9658
  isMobileSafari: false
9660
9659
  };
9661
9660
  clientType.isMobileSafari = clientType.isMobile && clientType.isSafari;
9662
- const logger$4P = getLogger("dom-utils");
9661
+ const logger$4Q = getLogger("dom-utils");
9663
9662
  function addClass(dom, ...className) {
9664
9663
  if (dom && dom.nodeType === Node.ELEMENT_NODE) {
9665
9664
  dom.classList.add(...className);
@@ -9713,7 +9712,7 @@ var __publicField = (obj, key, value) => {
9713
9712
  range.setStart(node, offset);
9714
9713
  return range;
9715
9714
  } catch (err) {
9716
- assert(logger$4P, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
9715
+ assert(logger$4Q, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
9717
9716
  }
9718
9717
  }
9719
9718
  function createExpandedRange(startNode, startOffset, endNode, endOffset) {
@@ -9723,17 +9722,17 @@ var __publicField = (obj, key, value) => {
9723
9722
  range.setEnd(endNode, endOffset);
9724
9723
  return range;
9725
9724
  } catch (err) {
9726
- assert(logger$4P, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
9725
+ assert(logger$4Q, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
9727
9726
  }
9728
9727
  }
9729
9728
  function getFirstClientRect(elem) {
9730
9729
  const rects = elem.getClientRects();
9731
- assert(logger$4P, rects.length >= 1, "getFirstClientRect: no rects");
9730
+ assert(logger$4Q, rects.length >= 1, "getFirstClientRect: no rects");
9732
9731
  return rects[0];
9733
9732
  }
9734
9733
  function getLastClientRect(elem) {
9735
9734
  const rects = elem.getClientRects();
9736
- assert(logger$4P, rects.length >= 1, "getLastClientRect: no rects");
9735
+ assert(logger$4Q, rects.length >= 1, "getLastClientRect: no rects");
9737
9736
  return rects[rects.length - 1];
9738
9737
  }
9739
9738
  function getDistanceSquare(rect, x, y) {
@@ -9780,7 +9779,7 @@ var __publicField = (obj, key, value) => {
9780
9779
  return 0;
9781
9780
  }
9782
9781
  if (!elem1.parentElement || !elem2.parentElement) {
9783
- assert(logger$4P, false, "invalid dom node to compare");
9782
+ assert(logger$4Q, false, "invalid dom node to compare");
9784
9783
  }
9785
9784
  if (elem1.parentElement === elem2.parentElement) {
9786
9785
  const children = Array.from(elem1.parentElement.children);
@@ -9797,7 +9796,7 @@ var __publicField = (obj, key, value) => {
9797
9796
  const parents1 = getParents(elem1);
9798
9797
  const parents2 = getParents(elem2);
9799
9798
  if (parents1[0] !== parents2[0]) {
9800
- assert(logger$4P, false, "invalid dom node to compare, different tree");
9799
+ assert(logger$4Q, false, "invalid dom node to compare, different tree");
9801
9800
  }
9802
9801
  for (let i = 1; ; i++) {
9803
9802
  const parent1 = parents1[i];
@@ -10397,7 +10396,7 @@ var __publicField = (obj, key, value) => {
10397
10396
  }
10398
10397
  }
10399
10398
  const MIN_DISTANCE_THRESHOLD$3 = 3;
10400
- const logger$4O = getLogger("drag-drop");
10399
+ const logger$4P = getLogger("drag-drop");
10401
10400
  class DragDrop {
10402
10401
  constructor(options) {
10403
10402
  __publicField(this, "dragStarted", false);
@@ -10418,7 +10417,7 @@ var __publicField = (obj, key, value) => {
10418
10417
  var _a;
10419
10418
  event.preventDefault();
10420
10419
  event.stopPropagation();
10421
- assert(logger$4O, this.mouseDownEvent, "no mouse down event");
10420
+ assert(logger$4P, this.mouseDownEvent, "no mouse down event");
10422
10421
  const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
10423
10422
  const newPos = DragDrop.getEventPosition(event);
10424
10423
  const deltaX = newPos.x - oldPos.x;
@@ -10434,7 +10433,7 @@ var __publicField = (obj, key, value) => {
10434
10433
  });
10435
10434
  __publicField(this, "handleMouseUp", (event) => {
10436
10435
  if (event instanceof MouseEvent && event.button === 0 || event instanceof TouchEvent) {
10437
- assert(logger$4O, this.mouseDownEvent, "no mouse down event");
10436
+ assert(logger$4P, this.mouseDownEvent, "no mouse down event");
10438
10437
  const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
10439
10438
  const newPos = DragDrop.getEventPosition(event);
10440
10439
  const deltaX = newPos.x - oldPos.x;
@@ -10543,7 +10542,7 @@ var __publicField = (obj, key, value) => {
10543
10542
  const dragDrop = new DragDrop(options);
10544
10543
  return dragDrop;
10545
10544
  }
10546
- const logger$4N = getLogger("character");
10545
+ const logger$4O = getLogger("character");
10547
10546
  function checkChar(charCode, rangeList) {
10548
10547
  for (let i = 0; i < rangeList.length; i++) {
10549
10548
  const start = rangeList[i][0];
@@ -10588,9 +10587,13 @@ var __publicField = (obj, key, value) => {
10588
10587
  ];
10589
10588
  return checkChar(str.charCodeAt(0), CJKRange);
10590
10589
  }
10590
+ function isCJKPunctuation(char) {
10591
+ const reg = /[\u3000-\u303F\uFF00-\uFFEF\u2000-\u206F\u2E00-\u2E7F]/;
10592
+ return reg.test(char);
10593
+ }
10591
10594
  function trimChar(s, char) {
10592
10595
  let c = char;
10593
- assert(logger$4N, c.length === 1, "invalid char length");
10596
+ assert(logger$4O, c.length === 1, "invalid char length");
10594
10597
  if (c === "]")
10595
10598
  c = "\\]";
10596
10599
  if (c === "\\")
@@ -10924,7 +10927,7 @@ var __publicField = (obj, key, value) => {
10924
10927
  const metrics = context.measureText(text2);
10925
10928
  return metrics.width + 4;
10926
10929
  }
10927
- const logger$4M = getLogger("editor-clipboard");
10930
+ const logger$4N = getLogger("editor-clipboard");
10928
10931
  async function setClipboardDataByEvent(items, event) {
10929
10932
  if (event.clipboardData) {
10930
10933
  const data2 = event.clipboardData;
@@ -10982,7 +10985,7 @@ var __publicField = (obj, key, value) => {
10982
10985
  document.body.removeChild(textarea2);
10983
10986
  return true;
10984
10987
  } catch (ex) {
10985
- logger$4M.error(ex);
10988
+ logger$4N.error(ex);
10986
10989
  document.body.removeChild(textarea2);
10987
10990
  return false;
10988
10991
  }
@@ -11003,7 +11006,7 @@ var __publicField = (obj, key, value) => {
11003
11006
  document.body.removeChild(div);
11004
11007
  return true;
11005
11008
  } catch (ex) {
11006
- logger$4M.error(ex);
11009
+ logger$4N.error(ex);
11007
11010
  document.body.removeChild(div);
11008
11011
  return false;
11009
11012
  }
@@ -11030,7 +11033,7 @@ var __publicField = (obj, key, value) => {
11030
11033
  await navigator.clipboard.write([clipboardItems]);
11031
11034
  return true;
11032
11035
  } catch (err) {
11033
- logger$4M.error(err);
11036
+ logger$4N.error(err);
11034
11037
  return await execCommandCopy(items);
11035
11038
  }
11036
11039
  }
@@ -11086,7 +11089,7 @@ var __publicField = (obj, key, value) => {
11086
11089
  a.click();
11087
11090
  a.remove();
11088
11091
  }
11089
- const logger$4L = getLogger("auto-scroll");
11092
+ const logger$4M = getLogger("auto-scroll");
11090
11093
  function scrollable(scrollElement, direction) {
11091
11094
  if (scrollElement.scrollHeight === scrollElement.clientHeight) {
11092
11095
  return false;
@@ -11110,7 +11113,7 @@ var __publicField = (obj, key, value) => {
11110
11113
  const isHorizontal = direction === "left" || direction === "right";
11111
11114
  const scroll = () => {
11112
11115
  if (!scrollable(scrollElement, direction)) {
11113
- logger$4L.debug("No need for scroll");
11116
+ logger$4M.debug("No need for scroll");
11114
11117
  return null;
11115
11118
  }
11116
11119
  if (isHorizontal) {
@@ -11140,11 +11143,10 @@ var __publicField = (obj, key, value) => {
11140
11143
  constructor(options) {
11141
11144
  __publicField(this, "cancelScroll", null);
11142
11145
  __publicField(this, "options");
11143
- __publicField(this, "scrollDomInfo");
11144
11146
  __publicField(this, "scrolling", false);
11145
11147
  __publicField(this, "getScrollingDirection", (e2) => {
11146
11148
  const { x, y } = e2;
11147
- const { top, bottom, left, right } = this.scrollDomInfo;
11149
+ const { top, bottom, left, right } = this.getScrollDomInfo();
11148
11150
  const { edge } = this.options;
11149
11151
  if (edge.top && y <= edge.top + top) {
11150
11152
  return "top";
@@ -11168,7 +11170,7 @@ var __publicField = (obj, key, value) => {
11168
11170
  if (this.scrolling) {
11169
11171
  return;
11170
11172
  }
11171
- logger$4L.debug(`scroll direction: ${direction}`);
11173
+ logger$4M.debug(`scroll direction: ${direction}`);
11172
11174
  this.cancelScroll = continuousScroll(scrollElement, {
11173
11175
  direction,
11174
11176
  step
@@ -11181,7 +11183,6 @@ var __publicField = (obj, key, value) => {
11181
11183
  }
11182
11184
  });
11183
11185
  this.options = options;
11184
- this.scrollDomInfo = this.getScrollDomInfo();
11185
11186
  }
11186
11187
  getScrollDomInfo() {
11187
11188
  const { scrollElement } = this.options;
@@ -11419,7 +11420,7 @@ var __publicField = (obj, key, value) => {
11419
11420
  const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
11420
11421
  return ColorNames[colorIndex];
11421
11422
  }
11422
- const logger$4K = getLogger("container");
11423
+ const logger$4L = getLogger("container");
11423
11424
  function isContainer(elem) {
11424
11425
  return elem.getAttribute("data-type") === "editor-container";
11425
11426
  }
@@ -11431,9 +11432,9 @@ var __publicField = (obj, key, value) => {
11431
11432
  }
11432
11433
  function getContainerId(container) {
11433
11434
  const id = container.getAttribute("data-container-id");
11434
- assert(logger$4K, id, "no id for container");
11435
+ assert(logger$4L, id, "no id for container");
11435
11436
  if (isRootContainer(container)) {
11436
- assert(logger$4K, id === "root", `invalid root container id, : ${id}`);
11437
+ assert(logger$4L, id === "root", `invalid root container id, : ${id}`);
11437
11438
  }
11438
11439
  return id;
11439
11440
  }
@@ -11444,7 +11445,7 @@ var __publicField = (obj, key, value) => {
11444
11445
  function generateEditorContainerId(containerId) {
11445
11446
  return `ones-editor-container-${containerId}`;
11446
11447
  }
11447
- const logger$4J = getLogger("element");
11448
+ const logger$4K = getLogger("element");
11448
11449
  function createContainerElement(parent, type, containerId) {
11449
11450
  const container = createElement("div", [type], parent);
11450
11451
  container.setAttribute("data-type", "editor-container");
@@ -11455,7 +11456,7 @@ var __publicField = (obj, key, value) => {
11455
11456
  }
11456
11457
  function getContainerById(editor, containerId) {
11457
11458
  const container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
11458
- assert(logger$4J, container, `no container: ${containerId}`);
11459
+ assert(logger$4K, container, `no container: ${containerId}`);
11459
11460
  return container;
11460
11461
  }
11461
11462
  function getExistsContainerById(editor, containerId) {
@@ -11464,7 +11465,7 @@ var __publicField = (obj, key, value) => {
11464
11465
  }
11465
11466
  function getContainerBlocksElement(container) {
11466
11467
  const blocks = container.querySelector(":scope > .container-blocks");
11467
- assert(logger$4J, blocks, "no container blocks element");
11468
+ assert(logger$4K, blocks, "no container blocks element");
11468
11469
  return blocks;
11469
11470
  }
11470
11471
  function getContainerToolsElement(container) {
@@ -11477,11 +11478,11 @@ var __publicField = (obj, key, value) => {
11477
11478
  function isContainerBlocksElement(element) {
11478
11479
  return element.classList.contains("container-blocks");
11479
11480
  }
11480
- const logger$4I = getLogger("container-children");
11481
+ const logger$4J = getLogger("container-children");
11481
11482
  function getChildBlocks(container, traverseChild) {
11482
11483
  const content = getContainerBlocksElement(container);
11483
11484
  const blocks = Array.from(content.children);
11484
- assert(logger$4I, blocks.length > 0, "container have not any child block");
11485
+ assert(logger$4J, blocks.length > 0, "container have not any child block");
11485
11486
  if (traverseChild) {
11486
11487
  const { condition, editor } = traverseChild;
11487
11488
  return blocks.reduce((result, block) => {
@@ -11504,7 +11505,7 @@ var __publicField = (obj, key, value) => {
11504
11505
  }
11505
11506
  function getFirstChildBlock(container) {
11506
11507
  const block = container.querySelector(":scope > .container-blocks > div[data-type=editor-block]");
11507
- assert(logger$4I, block, "container have not any child block");
11508
+ assert(logger$4J, block, "container have not any child block");
11508
11509
  return block;
11509
11510
  }
11510
11511
  function getLastChildBlock(container) {
@@ -11516,14 +11517,14 @@ var __publicField = (obj, key, value) => {
11516
11517
  }
11517
11518
  function getBlockByIndex(container, blockIndex) {
11518
11519
  const block = getChildBlocks(container)[blockIndex];
11519
- assert(logger$4I, block, `container have not block at index ${blockIndex}`);
11520
+ assert(logger$4J, block, `container have not block at index ${blockIndex}`);
11520
11521
  return block;
11521
11522
  }
11522
11523
  function findBlockByIndex(container, blockIndex) {
11523
11524
  var _a;
11524
11525
  return (_a = getChildBlocks(container)[blockIndex]) != null ? _a : null;
11525
11526
  }
11526
- const logger$4H = getLogger("block-dom");
11527
+ const logger$4I = getLogger("block-dom");
11527
11528
  function isBlock$1(node) {
11528
11529
  if (!(node instanceof HTMLDivElement)) {
11529
11530
  return false;
@@ -11544,12 +11545,12 @@ var __publicField = (obj, key, value) => {
11544
11545
  }
11545
11546
  function getBlockId(block) {
11546
11547
  const { id } = block;
11547
- assert(logger$4H, id, "no block id");
11548
+ assert(logger$4I, id, "no block id");
11548
11549
  return id;
11549
11550
  }
11550
11551
  function getBlockType(block) {
11551
11552
  const type = block.getAttribute("data-block-type");
11552
- assert(logger$4H, type, "invalid block dom, no data-type");
11553
+ assert(logger$4I, type, "invalid block dom, no data-type");
11553
11554
  return type;
11554
11555
  }
11555
11556
  function getParentBlock(node) {
@@ -11572,12 +11573,12 @@ var __publicField = (obj, key, value) => {
11572
11573
  }
11573
11574
  function getParentContainer(block) {
11574
11575
  const container = block.closest("div[data-type=editor-container]");
11575
- assert(logger$4H, container, "failed to get block container");
11576
+ assert(logger$4I, container, "failed to get block container");
11576
11577
  return container;
11577
11578
  }
11578
11579
  function getBlockContent(block) {
11579
11580
  const content = block.querySelector(":scope >div[data-type=block-content]");
11580
- assert(logger$4H, content, "no block content");
11581
+ assert(logger$4I, content, "no block content");
11581
11582
  return content;
11582
11583
  }
11583
11584
  function getBlockTools(block) {
@@ -11586,7 +11587,7 @@ var __publicField = (obj, key, value) => {
11586
11587
  tools = createElement("div", [], block);
11587
11588
  tools.setAttribute("data-type", "block-tools");
11588
11589
  }
11589
- assert(logger$4H, tools, "no block tools");
11590
+ assert(logger$4I, tools, "no block tools");
11590
11591
  return tools;
11591
11592
  }
11592
11593
  function getExistsBlockTools(block) {
@@ -11607,7 +11608,7 @@ var __publicField = (obj, key, value) => {
11607
11608
  function createBlockElement(editor, path, data2) {
11608
11609
  const blockData = editor.editorDecorators.decorateBlock(path, data2);
11609
11610
  const { id, type } = blockData;
11610
- assert(logger$4H, id, "no block id");
11611
+ assert(logger$4I, id, "no block id");
11611
11612
  const elem = createElement("div", [`${type}-block`], null);
11612
11613
  elem.id = id;
11613
11614
  elem.setAttribute("data-type", "editor-block");
@@ -11645,7 +11646,7 @@ var __publicField = (obj, key, value) => {
11645
11646
  }
11646
11647
  function getBoxTypeFromElement(box) {
11647
11648
  const type = box.getAttribute("data-box-type");
11648
- assert(logger$4H, type, "not a valid box element, no type");
11649
+ assert(logger$4I, type, "not a valid box element, no type");
11649
11650
  return type;
11650
11651
  }
11651
11652
  function isBox(node) {
@@ -11656,7 +11657,7 @@ var __publicField = (obj, key, value) => {
11656
11657
  }
11657
11658
  function getBoxId(box) {
11658
11659
  const { id } = box;
11659
- assert(logger$4H, id, "no box id");
11660
+ assert(logger$4I, id, "no box id");
11660
11661
  return id;
11661
11662
  }
11662
11663
  function getParentBox(node) {
@@ -11678,7 +11679,7 @@ var __publicField = (obj, key, value) => {
11678
11679
  }
11679
11680
  function getBoxContent(box) {
11680
11681
  const content = box.querySelector("span[data-type=box-content]");
11681
- assert(logger$4H, content, "invalid box dom, no content");
11682
+ assert(logger$4I, content, "invalid box dom, no content");
11682
11683
  return content;
11683
11684
  }
11684
11685
  function createInsertionElement(type, id, attributes) {
@@ -11700,7 +11701,7 @@ var __publicField = (obj, key, value) => {
11700
11701
  }
11701
11702
  function getInsertionContent(insertion) {
11702
11703
  const content = insertion.querySelector("span[data-type=insertion-content]");
11703
- assert(logger$4H, content, "invalid insertion-child dom, no content");
11704
+ assert(logger$4I, content, "invalid insertion-child dom, no content");
11704
11705
  return content;
11705
11706
  }
11706
11707
  function getPrevBlock(block) {
@@ -11723,31 +11724,44 @@ var __publicField = (obj, key, value) => {
11723
11724
  }
11724
11725
  return null;
11725
11726
  }
11726
- function getPrevVisibleBlock(block) {
11727
+ function getPrevVisibleBlock(block, matcher) {
11728
+ const mergedMatcher = matcher || (() => true);
11727
11729
  let prev = block.previousElementSibling;
11728
11730
  while (prev) {
11729
- if (isBlock$1(prev) && isVisibleBlock(prev)) {
11731
+ if (isBlock$1(prev) && isVisibleBlock(prev) && mergedMatcher(prev)) {
11730
11732
  return prev;
11731
11733
  }
11732
11734
  prev = prev.previousElementSibling;
11733
11735
  }
11734
11736
  return null;
11735
11737
  }
11736
- function getNextVisibleBlock(block) {
11738
+ function getNextVisibleBlock(block, matcher) {
11739
+ const mergedMatcher = matcher || (() => true);
11737
11740
  let next2 = block.nextElementSibling;
11738
11741
  while (next2) {
11739
- if (isBlock$1(next2) && isVisibleBlock(next2)) {
11742
+ if (isBlock$1(next2) && isVisibleBlock(next2) && mergedMatcher(next2)) {
11740
11743
  return next2;
11741
11744
  }
11742
11745
  next2 = next2.nextElementSibling;
11743
11746
  }
11744
11747
  return null;
11745
11748
  }
11749
+ function getBlocksBetween(start, end, matcher) {
11750
+ const blocks = [];
11751
+ let cur = start;
11752
+ while (cur !== end) {
11753
+ if (isBlock$1(cur) && matcher(cur)) {
11754
+ blocks.push(cur);
11755
+ }
11756
+ cur = cur.nextElementSibling;
11757
+ }
11758
+ return blocks;
11759
+ }
11746
11760
  function getBlockIndex(block) {
11747
11761
  const container = getParentContainer(block);
11748
11762
  const children = getChildBlocks(container);
11749
11763
  const index2 = children.indexOf(block);
11750
- assert(logger$4H, index2 !== -1, "invalid block & container dom, failed to get block index");
11764
+ assert(logger$4I, index2 !== -1, "invalid block & container dom, failed to get block index");
11751
11765
  return index2;
11752
11766
  }
11753
11767
  function isInBlock(target) {
@@ -11772,18 +11786,18 @@ var __publicField = (obj, key, value) => {
11772
11786
  function isTitleBlock$2(block) {
11773
11787
  return block.hasAttribute("data-document-title");
11774
11788
  }
11775
- const logger$4G = getLogger("block-class");
11789
+ const logger$4H = getLogger("block-class");
11776
11790
  function getBlockClass(editor, block) {
11777
11791
  return editor.editorBlocks.getBlockClass(getBlockType(block));
11778
11792
  }
11779
11793
  function getTextBlockClass(editor, block) {
11780
11794
  const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
11781
- assert(logger$4G, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
11795
+ assert(logger$4H, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
11782
11796
  return text2;
11783
11797
  }
11784
11798
  function getComplexBlockClass(editor, block) {
11785
11799
  const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
11786
- assert(logger$4G, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
11800
+ assert(logger$4H, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
11787
11801
  return complex;
11788
11802
  }
11789
11803
  function getBlockClassByType(editor, type) {
@@ -11804,7 +11818,7 @@ var __publicField = (obj, key, value) => {
11804
11818
  function getBlockKind(editor, block) {
11805
11819
  return getBlockClass(editor, block).blockKind;
11806
11820
  }
11807
- const logger$4F = getLogger("text-block-child");
11821
+ const logger$4G = getLogger("text-block-child");
11808
11822
  function isTextBlockContentChild(elem) {
11809
11823
  if (elem.tagName !== "SPAN") {
11810
11824
  return false;
@@ -11812,14 +11826,14 @@ var __publicField = (obj, key, value) => {
11812
11826
  return true;
11813
11827
  }
11814
11828
  function isTextBlockContentBoxChild(elem) {
11815
- assert(logger$4F, isTextBlockContentChild(elem), "not a valid text child");
11829
+ assert(logger$4G, isTextBlockContentChild(elem), "not a valid text child");
11816
11830
  if (elem.getAttribute("data-type") === "editor-box") {
11817
11831
  return true;
11818
11832
  }
11819
11833
  return false;
11820
11834
  }
11821
11835
  function isTextBlockContentInsertionChild(elem) {
11822
- assert(logger$4F, isTextBlockContentChild(elem), "not a valid text child");
11836
+ assert(logger$4G, isTextBlockContentChild(elem), "not a valid text child");
11823
11837
  if (elem.getAttribute("data-type") === "editor-insertion") {
11824
11838
  return true;
11825
11839
  }
@@ -11829,7 +11843,7 @@ var __publicField = (obj, key, value) => {
11829
11843
  return !isTextBlockContentBoxChild(elem) && !isTextBlockContentInsertionChild(elem);
11830
11844
  }
11831
11845
  function getTextBlockContentChildType(child) {
11832
- assert(logger$4F, isTextBlockContentChild(child), "not a valid text child");
11846
+ assert(logger$4G, isTextBlockContentChild(child), "not a valid text child");
11833
11847
  if (isTextBlockContentBoxChild(child)) {
11834
11848
  return "box";
11835
11849
  }
@@ -11844,15 +11858,15 @@ var __publicField = (obj, key, value) => {
11844
11858
  return 0;
11845
11859
  if (type === "box")
11846
11860
  return 1;
11847
- assert(logger$4F, child.textContent !== null, "text block content is undefined");
11848
- assert(logger$4F, child.textContent.length >= 0, "text block content length is negative");
11861
+ assert(logger$4G, child.textContent !== null, "text block content is undefined");
11862
+ assert(logger$4G, child.textContent.length >= 0, "text block content length is negative");
11849
11863
  return child.textContent.length;
11850
11864
  }
11851
11865
  function getTextBlockContentChildren(block) {
11852
11866
  const content = getBlockContent(block);
11853
11867
  const children = Array.from(content.children);
11854
11868
  children.forEach((child) => {
11855
- assert(logger$4F, isTextBlockContentChild(child), "not a valid text child");
11869
+ assert(logger$4G, isTextBlockContentChild(child), "not a valid text child");
11856
11870
  });
11857
11871
  return children;
11858
11872
  }
@@ -11881,17 +11895,17 @@ var __publicField = (obj, key, value) => {
11881
11895
  };
11882
11896
  }
11883
11897
  const offset = blockOffset - start;
11884
- assert(logger$4F, offset > 0, "invalid offset value");
11885
- assert(logger$4F, !isTextBlockContentBoxChild(child), "invalid box child");
11898
+ assert(logger$4G, offset > 0, "invalid offset value");
11899
+ assert(logger$4G, !isTextBlockContentBoxChild(child), "invalid box child");
11886
11900
  return {
11887
11901
  prev: child,
11888
11902
  next: child,
11889
11903
  offset
11890
11904
  };
11891
11905
  }
11892
- assert(logger$4F, false, `invalid block child at position: ${blockOffset}`);
11906
+ assert(logger$4G, false, `invalid block child at position: ${blockOffset}`);
11893
11907
  }
11894
- const logger$4E = getLogger("block-path");
11908
+ const logger$4F = getLogger("block-path");
11895
11909
  function getBlockPath(block) {
11896
11910
  const ret = [];
11897
11911
  let current = block;
@@ -11905,26 +11919,26 @@ var __publicField = (obj, key, value) => {
11905
11919
  return ret;
11906
11920
  }
11907
11921
  const parentBlock = getParentBlock(container);
11908
- assert(logger$4E, parentBlock, "no parent block");
11922
+ assert(logger$4F, parentBlock, "no parent block");
11909
11923
  current = parentBlock;
11910
11924
  }
11911
- assert(logger$4E, false, "no parent block");
11925
+ assert(logger$4F, false, "no parent block");
11912
11926
  return [];
11913
11927
  }
11914
- const logger$4D = getLogger("child-container-path");
11928
+ const logger$4E = getLogger("child-container-path");
11915
11929
  function getContainerBlockPath(container) {
11916
11930
  if (isRootContainer(container)) {
11917
11931
  return [];
11918
11932
  }
11919
11933
  const parentBlock = getParentBlock(container);
11920
- assert(logger$4D, parentBlock, "no parent block");
11934
+ assert(logger$4E, parentBlock, "no parent block");
11921
11935
  return getBlockPath(parentBlock);
11922
11936
  }
11923
- const logger$4C = getLogger("load-blocks");
11937
+ const logger$4D = getLogger("load-blocks");
11924
11938
  function loadBlocks(editor, container, path) {
11925
11939
  const containerId = getContainerId(container);
11926
11940
  const blocks = getContainerBlocks$1(container, editor.doc);
11927
- assert(logger$4C, blocks.length > 0, "no blocks in container");
11941
+ assert(logger$4D, blocks.length > 0, "no blocks in container");
11928
11942
  const fragment = document.createDocumentFragment();
11929
11943
  blocks.forEach((b, index2) => {
11930
11944
  const block = editor.editorBlocks.createBlock([...path, { containerId, blockIndex: index2 }], container, b);
@@ -11940,7 +11954,7 @@ var __publicField = (obj, key, value) => {
11940
11954
  return block;
11941
11955
  }
11942
11956
  const blocks = getChildBlocks(container);
11943
- assert(logger$4C, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
11957
+ assert(logger$4D, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
11944
11958
  if (blockIndex === blocks.length) {
11945
11959
  containerBlocksElement.appendChild(block);
11946
11960
  } else {
@@ -11958,7 +11972,7 @@ var __publicField = (obj, key, value) => {
11958
11972
  insertBlockAt(container, blockIndex, block);
11959
11973
  return block;
11960
11974
  }
11961
- const logger$4B = getLogger("root-container");
11975
+ const logger$4C = getLogger("root-container");
11962
11976
  const MIN_DISTANCE_THRESHOLD$2 = 3;
11963
11977
  class RootContainer {
11964
11978
  constructor(editor, rootContainer) {
@@ -11986,7 +12000,7 @@ var __publicField = (obj, key, value) => {
11986
12000
  this.editor.selection.updateSelection(null);
11987
12001
  this.editor.emit("resize", this.editor);
11988
12002
  } catch (err) {
11989
- logger$4B.warn(`failed to update selection while container resizing: ${err.message}`);
12003
+ logger$4C.warn(`failed to update selection while container resizing: ${err.message}`);
11990
12004
  }
11991
12005
  });
11992
12006
  __publicField(this, "handleClick", (event) => {
@@ -12019,7 +12033,7 @@ var __publicField = (obj, key, value) => {
12019
12033
  const box = getParentBox(elem);
12020
12034
  if (box) {
12021
12035
  const block2 = getParentBlock(box);
12022
- assert(logger$4B, block2, "no parent block");
12036
+ assert(logger$4C, block2, "no parent block");
12023
12037
  (_b = (_a = this.editor.editorBoxes.getBoxClass(getBoxTypeFromElement(box))) == null ? void 0 : _a.handleClickBox) == null ? void 0 : _b.call(_a, this.editor, box, event);
12024
12038
  return;
12025
12039
  }
@@ -12074,7 +12088,7 @@ var __publicField = (obj, key, value) => {
12074
12088
  this.editor.input.focus({ preventScroll: true });
12075
12089
  });
12076
12090
  __publicField(this, "handleMouseMove", (event) => {
12077
- assert(logger$4B, this.mouseDownEvent, "no mouse down event");
12091
+ assert(logger$4C, this.mouseDownEvent, "no mouse down event");
12078
12092
  if (ensureIsMobileEvent(this.mouseDownEvent))
12079
12093
  return;
12080
12094
  const deltaX = event.x - this.mouseDownEvent.x;
@@ -12190,7 +12204,7 @@ var __publicField = (obj, key, value) => {
12190
12204
  loadBlocks(editor, container, path);
12191
12205
  return container;
12192
12206
  }
12193
- const logger$4A = getLogger("block");
12207
+ const logger$4B = getLogger("block");
12194
12208
  function getBlockTextLength$6(editor, block) {
12195
12209
  return getBlockClass(editor, block).getBlockTextLength(block);
12196
12210
  }
@@ -12209,7 +12223,7 @@ var __publicField = (obj, key, value) => {
12209
12223
  return block;
12210
12224
  }
12211
12225
  const parent = getParentBlock(container);
12212
- assert(logger$4A, parent, "no parent block exists for child container");
12226
+ assert(logger$4B, parent, "no parent block exists for child container");
12213
12227
  block = parent;
12214
12228
  }
12215
12229
  }
@@ -12245,7 +12259,7 @@ var __publicField = (obj, key, value) => {
12245
12259
  }
12246
12260
  return fun(editor, block, options);
12247
12261
  } catch (err) {
12248
- logger$4A.debug(`unsupported block type: ${type}`);
12262
+ logger$4B.debug(`unsupported block type: ${type}`);
12249
12263
  return null;
12250
12264
  }
12251
12265
  }
@@ -12265,7 +12279,7 @@ var __publicField = (obj, key, value) => {
12265
12279
  const styles = Object.fromEntries(Object.entries(data2).filter(([key]) => key.startsWith("style-")));
12266
12280
  Object.entries(styles).forEach(([, value]) => {
12267
12281
  const type = typeof value;
12268
- assert(logger$4A, type === "string" || type === "number" || type === "boolean", "invalid style value");
12282
+ assert(logger$4B, type === "string" || type === "number" || type === "boolean", "invalid style value");
12269
12283
  });
12270
12284
  return styles;
12271
12285
  }
@@ -12390,7 +12404,7 @@ var __publicField = (obj, key, value) => {
12390
12404
  }
12391
12405
  return { element: null, blockCommands: [], boxCommands: [] };
12392
12406
  }
12393
- const logger$4z = getLogger("embed-block-common");
12407
+ const logger$4A = getLogger("embed-block-common");
12394
12408
  function isColumnsBlock(block) {
12395
12409
  return getBlockType(block) === "layout";
12396
12410
  }
@@ -12398,9 +12412,9 @@ var __publicField = (obj, key, value) => {
12398
12412
  return getBlockType(block) === "embed";
12399
12413
  }
12400
12414
  function getEmbedType(block) {
12401
- assert(logger$4z, isEmbedBlock(block), "not an embed block");
12415
+ assert(logger$4A, isEmbedBlock(block), "not an embed block");
12402
12416
  const type = block.getAttribute("data-embed-type");
12403
- assert(logger$4z, type, "no embed data type");
12417
+ assert(logger$4A, type, "no embed data type");
12404
12418
  return type;
12405
12419
  }
12406
12420
  function getEmbedClassFromBlock(editor, block) {
@@ -12466,10 +12480,10 @@ var __publicField = (obj, key, value) => {
12466
12480
  data: (_c = overrideOptions == null ? void 0 : overrideOptions.data) != null ? _c : data2
12467
12481
  });
12468
12482
  }
12469
- const logger$4y = getLogger("execute-block-command");
12483
+ const logger$4z = getLogger("execute-block-command");
12470
12484
  function executeEmbedBlockCommand(editor, block, commandGroup, item) {
12471
12485
  var _a;
12472
- assert(logger$4y, isEmbedBlock(block), "not a embed block");
12486
+ assert(logger$4z, isEmbedBlock(block), "not a embed block");
12473
12487
  const embedType = getEmbedType(block);
12474
12488
  const embed = getEmbedClassByType(editor, embedType);
12475
12489
  if (!embed.getOptions) {
@@ -12502,14 +12516,14 @@ var __publicField = (obj, key, value) => {
12502
12516
  }
12503
12517
  return void 0;
12504
12518
  }
12505
- const logger$4x = getLogger("block-class");
12519
+ const logger$4y = getLogger("block-class");
12506
12520
  function isHeadingBlock$1(block) {
12507
12521
  return !!block.getAttribute("data-style-heading");
12508
12522
  }
12509
12523
  function getBlockHeading(block) {
12510
12524
  var _a;
12511
12525
  const heading = Number.parseInt((_a = block.getAttribute("data-style-heading")) != null ? _a : "", 10);
12512
- assert(logger$4x, heading, "not a heading block");
12526
+ assert(logger$4y, heading, "not a heading block");
12513
12527
  return heading;
12514
12528
  }
12515
12529
  function isExpandedHeadingBlock(block) {
@@ -12520,7 +12534,7 @@ var __publicField = (obj, key, value) => {
12520
12534
  }
12521
12535
  function getHeadingBlockChildren(block, oldHeading) {
12522
12536
  if (!oldHeading) {
12523
- assert(logger$4x, isHeadingBlock$1(block), "not a heading block");
12537
+ assert(logger$4y, isHeadingBlock$1(block), "not a heading block");
12524
12538
  }
12525
12539
  const children = [];
12526
12540
  const heading = oldHeading != null ? oldHeading : getBlockHeading(block);
@@ -12550,7 +12564,7 @@ var __publicField = (obj, key, value) => {
12550
12564
  }
12551
12565
  return children;
12552
12566
  }
12553
- const logger$4w = getLogger("complex-block-position");
12567
+ const logger$4x = getLogger("complex-block-position");
12554
12568
  class EditorComplexBlockPosition {
12555
12569
  constructor(block, childContainerId, custom) {
12556
12570
  __publicField(this, "blockId");
@@ -12559,7 +12573,7 @@ var __publicField = (obj, key, value) => {
12559
12573
  if (block instanceof HTMLElement) {
12560
12574
  this.blockId = getBlockId(block);
12561
12575
  } else {
12562
- assert(logger$4w, typeof block === "string", `not a valid block id: ${block}`);
12576
+ assert(logger$4x, typeof block === "string", `not a valid block id: ${block}`);
12563
12577
  this.blockId = block;
12564
12578
  }
12565
12579
  this.childContainerId = childContainerId;
@@ -12571,7 +12585,7 @@ var __publicField = (obj, key, value) => {
12571
12585
  return false;
12572
12586
  }
12573
12587
  }
12574
- const logger$4v = getLogger("simple-block-position");
12588
+ const logger$4w = getLogger("simple-block-position");
12575
12589
  class EditorSimpleBlockPosition {
12576
12590
  constructor(block, offset, type) {
12577
12591
  __publicField(this, "blockId");
@@ -12580,7 +12594,7 @@ var __publicField = (obj, key, value) => {
12580
12594
  if (block instanceof HTMLElement) {
12581
12595
  this.blockId = getBlockId(block);
12582
12596
  } else {
12583
- assert(logger$4v, typeof block === "string", `not a valid block id: ${block}`);
12597
+ assert(logger$4w, typeof block === "string", `not a valid block id: ${block}`);
12584
12598
  this.blockId = block;
12585
12599
  }
12586
12600
  this.offset = offset;
@@ -12590,7 +12604,7 @@ var __publicField = (obj, key, value) => {
12590
12604
  return true;
12591
12605
  }
12592
12606
  }
12593
- const logger$4u = getLogger("editor-position");
12607
+ const logger$4v = getLogger("editor-position");
12594
12608
  function createSimpleBlockPosition(block, offset, type) {
12595
12609
  return new EditorSimpleBlockPosition(block, offset, type);
12596
12610
  }
@@ -12612,7 +12626,7 @@ var __publicField = (obj, key, value) => {
12612
12626
  }
12613
12627
  const block1 = editor.getBlockById(pos1.blockId);
12614
12628
  const block2 = editor.getBlockById(pos2.blockId);
12615
- assert(logger$4u, block1 !== block2, "comparePosition: blocks are the same");
12629
+ assert(logger$4v, block1 !== block2, "comparePosition: blocks are the same");
12616
12630
  return compareElement(block1, block2);
12617
12631
  }
12618
12632
  if (isComplexBlockPosition(pos1) && isComplexBlockPosition(pos2)) {
@@ -12623,13 +12637,13 @@ var __publicField = (obj, key, value) => {
12623
12637
  }
12624
12638
  const container1 = editor.getContainerById(p1.childContainerId);
12625
12639
  const container2 = editor.getContainerById(p2.childContainerId);
12626
- assert(logger$4u, container1 !== container2, "comparePosition: containers are the same");
12640
+ assert(logger$4v, container1 !== container2, "comparePosition: containers are the same");
12627
12641
  return compareElement(container1, container2);
12628
12642
  }
12629
- assert(logger$4u, false, "invalid ");
12643
+ assert(logger$4v, false, "invalid ");
12630
12644
  return 0;
12631
12645
  }
12632
- const logger$4t = getLogger("simple-range");
12646
+ const logger$4u = getLogger("simple-range");
12633
12647
  class EditorSimpleSelectionRange {
12634
12648
  constructor(editor, options) {
12635
12649
  __publicField(this, "editor");
@@ -12678,11 +12692,11 @@ var __publicField = (obj, key, value) => {
12678
12692
  const { editor } = this;
12679
12693
  const startBlock = editor.getBlockById(this.start.blockId);
12680
12694
  const endBlock = editor.getBlockById(this.end.blockId);
12681
- assert(logger$4t, startBlock, "no start block");
12682
- assert(logger$4t, endBlock, "no end block");
12695
+ assert(logger$4u, startBlock, "no start block");
12696
+ assert(logger$4u, endBlock, "no end block");
12683
12697
  const startContainer = getParentContainer(startBlock);
12684
12698
  const endContainer = getParentContainer(endBlock);
12685
- assert(logger$4t, startContainer === endContainer, "invalid range");
12699
+ assert(logger$4u, startContainer === endContainer, "invalid range");
12686
12700
  const ret = [];
12687
12701
  if (startBlock === endBlock) {
12688
12702
  ret.push({
@@ -12693,7 +12707,7 @@ var __publicField = (obj, key, value) => {
12693
12707
  } else {
12694
12708
  const startIndex = getBlockIndex(startBlock);
12695
12709
  const endIndex = getBlockIndex(endBlock);
12696
- assert(logger$4t, startIndex < endIndex, "invalid range, start > index");
12710
+ assert(logger$4u, startIndex < endIndex, "invalid range, start > index");
12697
12711
  ret.push({
12698
12712
  block: startBlock,
12699
12713
  start: this.start,
@@ -12793,7 +12807,7 @@ var __publicField = (obj, key, value) => {
12793
12807
  clearSelection: clearSelection$6,
12794
12808
  convertTo: convertTo$m
12795
12809
  };
12796
- const logger$4s = getLogger("editor-blocks");
12810
+ const logger$4t = getLogger("editor-blocks");
12797
12811
  class EditorBlocks {
12798
12812
  constructor(editor) {
12799
12813
  __publicField(this, "blocks", /* @__PURE__ */ new Map());
@@ -12802,12 +12816,12 @@ var __publicField = (obj, key, value) => {
12802
12816
  registerBlockClass(blockClass) {
12803
12817
  const type = blockClass.blockType;
12804
12818
  const exists = this.blocks.get(type);
12805
- assert(logger$4s, !exists, `duplicated block type: ${type}`);
12819
+ assert(logger$4t, !exists, `duplicated block type: ${type}`);
12806
12820
  this.blocks.set(type, blockClass);
12807
12821
  }
12808
12822
  getBlockClass(type) {
12809
12823
  const exists = this.blocks.get(type);
12810
- assert(logger$4s, exists, `unknown block type: ${type}`);
12824
+ assert(logger$4t, exists, `unknown block type: ${type}`);
12811
12825
  return exists;
12812
12826
  }
12813
12827
  hasBlock(type) {
@@ -12823,7 +12837,7 @@ var __publicField = (obj, key, value) => {
12823
12837
  }
12824
12838
  const content = blockClass.createBlockContent(this.editor, path, container, blockElement, block);
12825
12839
  if (content.parentElement !== blockElement) {
12826
- logger$4s.warn("content parent is not block");
12840
+ logger$4t.warn("content parent is not block");
12827
12841
  blockElement.appendChild(content);
12828
12842
  }
12829
12843
  this.editor.blockHooks.forEach((hook) => {
@@ -12844,7 +12858,7 @@ var __publicField = (obj, key, value) => {
12844
12858
  return newBlock;
12845
12859
  }
12846
12860
  }
12847
- const logger$4r = getLogger("editor-embeds");
12861
+ const logger$4s = getLogger("editor-embeds");
12848
12862
  class EditorEmbeds {
12849
12863
  constructor(editor) {
12850
12864
  __publicField(this, "objects", /* @__PURE__ */ new Map());
@@ -12853,12 +12867,12 @@ var __publicField = (obj, key, value) => {
12853
12867
  registerEmbedClass(embedClass) {
12854
12868
  const type = embedClass.embedType;
12855
12869
  const exists = this.objects.get(type);
12856
- assert(logger$4r, !exists, `duplicated embed object type: ${type}`);
12870
+ assert(logger$4s, !exists, `duplicated embed object type: ${type}`);
12857
12871
  this.objects.set(type, embedClass);
12858
12872
  }
12859
12873
  getEmbedClass(type) {
12860
12874
  const exists = this.objects.get(type);
12861
- assert(logger$4r, exists, `unknown embed type: ${type}`);
12875
+ assert(logger$4s, exists, `unknown embed type: ${type}`);
12862
12876
  return exists;
12863
12877
  }
12864
12878
  getEmbedClassFromBlock(block) {
@@ -12868,12 +12882,12 @@ var __publicField = (obj, key, value) => {
12868
12882
  this.objects.forEach(callback);
12869
12883
  }
12870
12884
  }
12871
- const logger$4q = getLogger("embed-block");
12885
+ const logger$4r = getLogger("embed-block");
12872
12886
  function createBlockContent$6(editor, path, container, blockElement, blockData) {
12873
12887
  const content = createBlockContentElement(blockElement, "div");
12874
- assert(logger$4q, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
12888
+ assert(logger$4r, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
12875
12889
  const embedBlockData = blockData;
12876
- assert(logger$4q, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
12890
+ assert(logger$4r, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
12877
12891
  const embedClass = editor.editorEmbeds.getEmbedClass(embedBlockData.embedType);
12878
12892
  embedClass.createEmbedContent(editor, content, embedBlockData, path, container, blockElement);
12879
12893
  blockElement.setAttribute("data-embed-type", embedBlockData.embedType);
@@ -12901,7 +12915,7 @@ var __publicField = (obj, key, value) => {
12901
12915
  function getCaretRect$4(block, pos) {
12902
12916
  const content = getBlockContent(block);
12903
12917
  const rect = content.getBoundingClientRect();
12904
- assert(logger$4q, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
12918
+ assert(logger$4r, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
12905
12919
  if (pos.offset === 1) {
12906
12920
  return new DOMRect(rect.right, rect.top, 0, rect.height);
12907
12921
  }
@@ -13041,18 +13055,18 @@ var __publicField = (obj, key, value) => {
13041
13055
  toStandardDoc: toStandardDoc$2,
13042
13056
  getResources: getResources$2
13043
13057
  };
13044
- const logger$4p = getLogger("complex-block-helper");
13058
+ const logger$4q = getLogger("complex-block-helper");
13045
13059
  function complexBlockGetAllChildContainers(editor, block, options) {
13046
13060
  const blockClass = getComplexBlockClass(editor, block);
13047
13061
  return blockClass.getChildContainers(editor, block, options);
13048
13062
  }
13049
13063
  function complexBlockGetSelectedContainers(editor, block, start, end) {
13050
13064
  if (start.isSimple()) {
13051
- assert(logger$4p, end.isSimple(), "invalid start and end position");
13065
+ assert(logger$4q, end.isSimple(), "invalid start and end position");
13052
13066
  return complexBlockGetAllChildContainers(editor, block);
13053
13067
  }
13054
- assert(logger$4p, !start.isSimple(), "invalid start pos");
13055
- assert(logger$4p, !end.isSimple(), "invalid end pos");
13068
+ assert(logger$4q, !start.isSimple(), "invalid start pos");
13069
+ assert(logger$4q, !end.isSimple(), "invalid end pos");
13056
13070
  const blockClass = getComplexBlockClass(editor, block);
13057
13071
  return blockClass.getSelectedContainers(editor, block, start, end);
13058
13072
  }
@@ -13063,11 +13077,11 @@ var __publicField = (obj, key, value) => {
13063
13077
  const parentComplexBlock = getParentBlock(getParentContainer(childBlock));
13064
13078
  if (!parentComplexBlock)
13065
13079
  return false;
13066
- assert(logger$4p, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13080
+ assert(logger$4q, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13067
13081
  const childContainer = getParentContainer(childBlock);
13068
13082
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
13069
13083
  const index2 = childContainers.indexOf(childContainer);
13070
- assert(logger$4p, index2 >= 0, "not valid child container");
13084
+ assert(logger$4q, index2 >= 0, "not valid child container");
13071
13085
  return index2 === 0;
13072
13086
  }
13073
13087
  function complexBlockGetFirstSimpleChild(editor, complexBlock, options) {
@@ -13120,13 +13134,13 @@ var __publicField = (obj, key, value) => {
13120
13134
  return block;
13121
13135
  }
13122
13136
  function findPrevSimpleBlockBeforeChildContainer(editor, childContainer, options) {
13123
- assert(logger$4p, isChildContainer(childContainer), "not a child container");
13137
+ assert(logger$4q, isChildContainer(childContainer), "not a child container");
13124
13138
  const parentComplexBlock = getParentBlock(childContainer);
13125
- assert(logger$4p, parentComplexBlock, "no parent block");
13126
- assert(logger$4p, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13139
+ assert(logger$4q, parentComplexBlock, "no parent block");
13140
+ assert(logger$4q, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13127
13141
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock, options);
13128
13142
  const containerIndex = childContainers.indexOf(childContainer);
13129
- assert(logger$4p, containerIndex !== -1, "child container not found");
13143
+ assert(logger$4q, containerIndex !== -1, "child container not found");
13130
13144
  if (containerIndex === 0) {
13131
13145
  const prevBlock = getPrevBlock(parentComplexBlock);
13132
13146
  if (!prevBlock)
@@ -13144,9 +13158,9 @@ var __publicField = (obj, key, value) => {
13144
13158
  return lastBlock2;
13145
13159
  }
13146
13160
  function complexBlockGetTopChildContainers(editor, complexBlock) {
13147
- assert(logger$4p, isComplexKindBlock(editor, complexBlock), "not a complex block");
13161
+ assert(logger$4q, isComplexKindBlock(editor, complexBlock), "not a complex block");
13148
13162
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
13149
- assert(logger$4p, childContainers.length > 0, "no child container");
13163
+ assert(logger$4q, childContainers.length > 0, "no child container");
13150
13164
  if (childContainers.length === 1) {
13151
13165
  return childContainers;
13152
13166
  }
@@ -13171,9 +13185,9 @@ var __publicField = (obj, key, value) => {
13171
13185
  return ret;
13172
13186
  }
13173
13187
  function complexBlockGetBottomChildContainers(editor, complexBlock) {
13174
- assert(logger$4p, isComplexKindBlock(editor, complexBlock), "not a complex block");
13188
+ assert(logger$4q, isComplexKindBlock(editor, complexBlock), "not a complex block");
13175
13189
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
13176
- assert(logger$4p, childContainers.length > 0, "no child container");
13190
+ assert(logger$4q, childContainers.length > 0, "no child container");
13177
13191
  if (childContainers.length === 1) {
13178
13192
  return childContainers;
13179
13193
  }
@@ -13278,11 +13292,11 @@ var __publicField = (obj, key, value) => {
13278
13292
  return result;
13279
13293
  }
13280
13294
  const anchor = "";
13281
- const logger$4o = getLogger("text-range");
13295
+ const logger$4p = getLogger("text-range");
13282
13296
  function getBlockRangeInfo(block, blockOffset) {
13283
13297
  const getChildRange = (child, offset) => {
13284
13298
  if (isTextBlockContentInsertionChild(child)) {
13285
- assert(logger$4o, offset === 0, `invalid offset for insertion child: ${offset}`);
13299
+ assert(logger$4p, offset === 0, `invalid offset for insertion child: ${offset}`);
13286
13300
  const childOffset = 2;
13287
13301
  return {
13288
13302
  child,
@@ -13291,7 +13305,7 @@ var __publicField = (obj, key, value) => {
13291
13305
  };
13292
13306
  }
13293
13307
  if (isTextBlockContentBoxChild(child)) {
13294
- assert(logger$4o, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
13308
+ assert(logger$4p, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
13295
13309
  const childOffset = offset === 0 ? 1 : 2;
13296
13310
  return {
13297
13311
  child,
@@ -13300,17 +13314,17 @@ var __publicField = (obj, key, value) => {
13300
13314
  };
13301
13315
  }
13302
13316
  const textNode = child.firstChild;
13303
- assert(logger$4o, textNode, "no child node for text child");
13304
- assert(logger$4o, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
13317
+ assert(logger$4p, textNode, "no child node for text child");
13318
+ assert(logger$4p, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
13305
13319
  if (textNode instanceof HTMLBRElement) {
13306
- assert(logger$4o, offset >= 0 && offset <= 0, "invalid offset for text child");
13320
+ assert(logger$4p, offset >= 0 && offset <= 0, "invalid offset for text child");
13307
13321
  return {
13308
13322
  child,
13309
13323
  container: textNode,
13310
13324
  offset
13311
13325
  };
13312
13326
  }
13313
- assert(logger$4o, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
13327
+ assert(logger$4p, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
13314
13328
  return {
13315
13329
  child,
13316
13330
  container: textNode,
@@ -13339,38 +13353,38 @@ var __publicField = (obj, key, value) => {
13339
13353
  }
13340
13354
  start += childLength;
13341
13355
  }
13342
- assert(logger$4o, false, "failed to get range info");
13356
+ assert(logger$4p, false, "failed to get range info");
13343
13357
  }
13344
13358
  function createChildRange(child, start, end) {
13345
13359
  if (start === end) {
13346
- assert(logger$4o, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
13360
+ assert(logger$4p, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
13347
13361
  } else {
13348
- assert(logger$4o, start < end, `invalid start & end: ${start}, ${end}`);
13362
+ assert(logger$4p, start < end, `invalid start & end: ${start}, ${end}`);
13349
13363
  }
13350
13364
  if (isTextBlockContentInsertionChild(child)) {
13351
- assert(logger$4o, start === end, `invalid insertion child range offset: ${start}, ${end}`);
13352
- assert(logger$4o, start === 0, `invalid insertion child range start: ${start}`);
13365
+ assert(logger$4p, start === end, `invalid insertion child range offset: ${start}, ${end}`);
13366
+ assert(logger$4p, start === 0, `invalid insertion child range start: ${start}`);
13353
13367
  const insertionElem = child;
13354
- assert(logger$4o, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
13368
+ assert(logger$4p, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
13355
13369
  const range = createExpandedRange(insertionElem, 1, insertionElem, 2);
13356
13370
  return range;
13357
13371
  }
13358
13372
  if (isTextBlockContentBoxChild(child)) {
13359
- assert(logger$4o, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
13360
- assert(logger$4o, start === 0, `invalid box child range start: ${start}`);
13373
+ assert(logger$4p, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
13374
+ assert(logger$4p, start === 0, `invalid box child range start: ${start}`);
13361
13375
  const box = child;
13362
- assert(logger$4o, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
13376
+ assert(logger$4p, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
13363
13377
  const range = createExpandedRange(box, 1, box, 2);
13364
13378
  return range;
13365
13379
  }
13366
13380
  const length = getTextBlockContentChildTextLength(child);
13367
- assert(logger$4o, end <= length, `invalid child end: ${end}, ${length}`);
13381
+ assert(logger$4p, end <= length, `invalid child end: ${end}, ${length}`);
13368
13382
  const textNode = child.firstChild;
13369
- assert(logger$4o, textNode instanceof Text, "invalid block text child");
13370
- assert(logger$4o, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
13383
+ assert(logger$4p, textNode instanceof Text, "invalid block text child");
13384
+ assert(logger$4p, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
13371
13385
  return createExpandedRange(textNode, start, textNode, end);
13372
13386
  }
13373
- const logger$4n = getLogger("caret-rect");
13387
+ const logger$4o = getLogger("caret-rect");
13374
13388
  function getChildClientRects(block, child) {
13375
13389
  if (isBox(child)) {
13376
13390
  const box = child;
@@ -13379,7 +13393,7 @@ var __publicField = (obj, key, value) => {
13379
13393
  const blockContent = getBlockContent(block);
13380
13394
  const lineHeight = Number.parseFloat(window.getComputedStyle(blockContent).lineHeight) || boxContent.getBoundingClientRect().height;
13381
13395
  const rects = Array.from(boxContent.getClientRects());
13382
- assert(logger$4n, rects.length > 0, "no box client rects");
13396
+ assert(logger$4o, rects.length > 0, "no box client rects");
13383
13397
  const blockRect = blockContent.getBoundingClientRect();
13384
13398
  const firstRect = rects[0];
13385
13399
  const lastRect = new DOMRect(blockRect.left, firstRect.bottom, 1, lineHeight);
@@ -13399,22 +13413,22 @@ var __publicField = (obj, key, value) => {
13399
13413
  const rect2 = getLastClientRect(ranges[0].child);
13400
13414
  return new DOMRect(rect2.right, rect2.top, 1, rect2.height);
13401
13415
  }
13402
- assert(logger$4n, ranges[1], "invalid ranges");
13416
+ assert(logger$4o, ranges[1], "invalid ranges");
13403
13417
  const rect = getFirstClientRect(ranges[1].child);
13404
13418
  return new DOMRect(rect.left, rect.top, 1, rect.height);
13405
13419
  }
13406
13420
  let rangeInfo = ranges[0];
13407
- assert(logger$4n, ranges.length >= 1, "failed to get block range");
13421
+ assert(logger$4o, ranges.length >= 1, "failed to get block range");
13408
13422
  if (ranges.length === 1) {
13409
13423
  rangeInfo = ranges[0];
13410
13424
  } else {
13411
- assert(logger$4n, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
13425
+ assert(logger$4o, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
13412
13426
  if (isTextBlockContentInsertionChild(ranges[ranges.length - 1].child)) {
13413
13427
  rangeInfo = ranges[ranges.length - 1];
13414
13428
  const child = rangeInfo.child;
13415
13429
  const content = getInsertionContent(child);
13416
13430
  const rects2 = content.getClientRects();
13417
- assert(logger$4n, rects2.length >= 1, "no client rects for box content");
13431
+ assert(logger$4o, rects2.length >= 1, "no client rects for box content");
13418
13432
  const rect = rects2[rects2.length - 1];
13419
13433
  return new DOMRect(rect.right, rect.y, 1, rect.height);
13420
13434
  }
@@ -13431,9 +13445,9 @@ var __publicField = (obj, key, value) => {
13431
13445
  }
13432
13446
  }
13433
13447
  if (rangeInfo.container instanceof HTMLBRElement) {
13434
- assert(logger$4n, pos.offset === 0, "invalid offset for empty block text");
13448
+ assert(logger$4o, pos.offset === 0, "invalid offset for empty block text");
13435
13449
  const parent = rangeInfo.container.parentElement;
13436
- assert(logger$4n, parent, "invalid br parent");
13450
+ assert(logger$4o, parent, "invalid br parent");
13437
13451
  const rect = parent.getBoundingClientRect();
13438
13452
  const ret = new DOMRect(rect.left, rect.top, 1, rect.height);
13439
13453
  return ret;
@@ -13441,11 +13455,11 @@ var __publicField = (obj, key, value) => {
13441
13455
  const range = createRange(rangeInfo.container, rangeInfo.offset);
13442
13456
  const rects = Array.from(range.getClientRects());
13443
13457
  if (rects.length === 0) {
13444
- assert(logger$4n, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
13445
- assert(logger$4n, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
13458
+ assert(logger$4o, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
13459
+ assert(logger$4o, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
13446
13460
  const child = rangeInfo.child;
13447
13461
  const rects2 = getChildClientRects(block, child);
13448
- assert(logger$4n, rects2.length >= 1, "no client rects for box content");
13462
+ assert(logger$4o, rects2.length >= 1, "no client rects for box content");
13449
13463
  if (rangeInfo.offset === 1) {
13450
13464
  const rect2 = rects2[0];
13451
13465
  return new DOMRect(rect2.x, rect2.y, 1, rect2.height);
@@ -13491,7 +13505,7 @@ var __publicField = (obj, key, value) => {
13491
13505
  });
13492
13506
  }
13493
13507
  }
13494
- assert(logger$4n, rects.length > 0, "no client rects for range");
13508
+ assert(logger$4o, rects.length > 0, "no client rects for range");
13495
13509
  if (pos.type === "home") {
13496
13510
  return rects[rects.length - 1];
13497
13511
  }
@@ -13571,13 +13585,13 @@ var __publicField = (obj, key, value) => {
13571
13585
  };
13572
13586
  }
13573
13587
  }
13574
- const logger$4m = getLogger("selection-range");
13588
+ const logger$4n = getLogger("selection-range");
13575
13589
  function createEditorSelectionRange(editor, options) {
13576
13590
  const { anchor: anchor2, focus } = options;
13577
13591
  if (anchor2 instanceof EditorSimpleBlockPosition && focus instanceof EditorSimpleBlockPosition) {
13578
13592
  return new EditorSimpleSelectionRange(editor, { anchor: anchor2, focus });
13579
13593
  }
13580
- assert(logger$4m, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
13594
+ assert(logger$4n, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
13581
13595
  return new EditorComplexSelectionRange(editor, { anchor: anchor2, focus });
13582
13596
  }
13583
13597
  function createBlockSimpleRange(editor, block, anchor2, focus) {
@@ -13599,7 +13613,7 @@ var __publicField = (obj, key, value) => {
13599
13613
  const focus = createSimpleBlockPosition(range.focus.blockId, range.focus.offset, "normal");
13600
13614
  return createEditorSelectionRange(editor, { anchor: anchor2, focus });
13601
13615
  }
13602
- const logger$4l = getLogger("range-from-point");
13616
+ const logger$4m = getLogger("range-from-point");
13603
13617
  function getBlockRangeFromPoint(editor, pointX, pointY, dragging) {
13604
13618
  const yOffsets = [0, -12, 12];
13605
13619
  let x = pointX;
@@ -13631,7 +13645,7 @@ var __publicField = (obj, key, value) => {
13631
13645
  const rect = elem.getBoundingClientRect();
13632
13646
  if (rect.width && rect.top && i === 0) {
13633
13647
  if (rect.left + rect.width < x || rect.top + rect.height < y) {
13634
- logger$4l.debug("click on scrollbar, out of element rect");
13648
+ logger$4m.debug("click on scrollbar, out of element rect");
13635
13649
  return null;
13636
13650
  }
13637
13651
  }
@@ -13669,7 +13683,7 @@ var __publicField = (obj, key, value) => {
13669
13683
  let block = getLastChildBlock(container);
13670
13684
  if (!isVisibleBlock(block)) {
13671
13685
  const preBlock = getPrevVisibleBlock(block);
13672
- assert(logger$4l, preBlock, "container must have visible block");
13686
+ assert(logger$4m, preBlock, "container must have visible block");
13673
13687
  block = preBlock;
13674
13688
  }
13675
13689
  const range = getBlockClass(editor, block).getRangeFromPoint(editor, block, x, block.getBoundingClientRect().bottom - 4);
@@ -13688,7 +13702,7 @@ var __publicField = (obj, key, value) => {
13688
13702
  if (range instanceof EditorSimpleSelectionRange) {
13689
13703
  return range;
13690
13704
  }
13691
- assert(logger$4l, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
13705
+ assert(logger$4m, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
13692
13706
  const complexRange = range;
13693
13707
  const container2 = editor.getContainerById(complexRange.start.childContainerId);
13694
13708
  return getRangeInContainer(editor, container2, x, y);
@@ -13711,7 +13725,7 @@ var __publicField = (obj, key, value) => {
13711
13725
  });
13712
13726
  return getRangeInContainer(editor, container, x, y);
13713
13727
  }
13714
- const logger$4k = getLogger("adjust-selection-pos");
13728
+ const logger$4l = getLogger("adjust-selection-pos");
13715
13729
  function getParentContainers(block) {
13716
13730
  const containers = [];
13717
13731
  while (block) {
@@ -13721,10 +13735,10 @@ var __publicField = (obj, key, value) => {
13721
13735
  return containers;
13722
13736
  }
13723
13737
  const newBlock = getParentBlock(container);
13724
- assert(logger$4k, newBlock, "child container has not parent container");
13738
+ assert(logger$4l, newBlock, "child container has not parent container");
13725
13739
  block = newBlock;
13726
13740
  }
13727
- assert(logger$4k, false, "should not come here: getParentContainers");
13741
+ assert(logger$4l, false, "should not come here: getParentContainers");
13728
13742
  }
13729
13743
  function getParentBlockInContainer(container, block) {
13730
13744
  while (block) {
@@ -13733,16 +13747,16 @@ var __publicField = (obj, key, value) => {
13733
13747
  return block;
13734
13748
  }
13735
13749
  const newBlock = getParentBlock(parent);
13736
- assert(logger$4k, newBlock, "could not find parent block for a child container");
13750
+ assert(logger$4l, newBlock, "could not find parent block for a child container");
13737
13751
  block = newBlock;
13738
13752
  }
13739
- assert(logger$4k, false, "no parent block in specified container");
13753
+ assert(logger$4l, false, "no parent block in specified container");
13740
13754
  }
13741
13755
  function getClosestParentBlock(block1, block2) {
13742
13756
  const containers1 = getParentContainers(block1);
13743
13757
  const containers2 = getParentContainers(block2);
13744
- assert(logger$4k, containers1.length > 0 && containers2.length > 0, "block has not parent container");
13745
- assert(logger$4k, containers1[0] === containers2[0], "root container does not equal");
13758
+ assert(logger$4l, containers1.length > 0 && containers2.length > 0, "block has not parent container");
13759
+ assert(logger$4l, containers1[0] === containers2[0], "root container does not equal");
13746
13760
  let parentContainer = containers1[0];
13747
13761
  for (let i = 1; i < containers1.length || containers2.length; i++) {
13748
13762
  if (containers1[i] === containers2[i]) {
@@ -13761,23 +13775,23 @@ var __publicField = (obj, key, value) => {
13761
13775
  }
13762
13776
  function getParentContainerInComplexBlock(parentComplexBlock, element) {
13763
13777
  let block = getParentBlock(element);
13764
- assert(logger$4k, block, "element is not in a block");
13778
+ assert(logger$4l, block, "element is not in a block");
13765
13779
  while (block) {
13766
13780
  const container = getParentContainer(block);
13767
- assert(logger$4k, isChildContainer(container), "not a child container");
13781
+ assert(logger$4l, isChildContainer(container), "not a child container");
13768
13782
  const parentBlock = getParentBlock(container);
13769
- assert(logger$4k, parentBlock, "child container has not parent block");
13783
+ assert(logger$4l, parentBlock, "child container has not parent block");
13770
13784
  if (parentBlock === parentComplexBlock) {
13771
13785
  return container;
13772
13786
  }
13773
13787
  block = parentBlock;
13774
13788
  }
13775
- assert(logger$4k, false, "failed to find parent container in complex block");
13789
+ assert(logger$4l, false, "failed to find parent container in complex block");
13776
13790
  }
13777
13791
  function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
13778
13792
  const blockId = getBlockId(complexBlock);
13779
- assert(logger$4k, blockId === anchor2.blockId, "invalid start pos");
13780
- assert(logger$4k, blockId === focus.blockId, "invalid end pos");
13793
+ assert(logger$4l, blockId === anchor2.blockId, "invalid start pos");
13794
+ assert(logger$4l, blockId === focus.blockId, "invalid end pos");
13781
13795
  const blockClass = getComplexBlockClass(editor, complexBlock);
13782
13796
  if (blockClass.adjustSelectionPos) {
13783
13797
  return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
@@ -13811,8 +13825,8 @@ var __publicField = (obj, key, value) => {
13811
13825
  if (focus instanceof EditorComplexBlockPosition) {
13812
13826
  focus = createSimpleBlockPosition(focusBlock, getBlockTextLength$6(editor, focusBlock), "end");
13813
13827
  }
13814
- assert(logger$4k, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
13815
- assert(logger$4k, focus instanceof EditorSimpleBlockPosition, "not valid position type");
13828
+ assert(logger$4l, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
13829
+ assert(logger$4l, focus instanceof EditorSimpleBlockPosition, "not valid position type");
13816
13830
  return {
13817
13831
  anchor: anchor2,
13818
13832
  focus
@@ -13866,7 +13880,7 @@ var __publicField = (obj, key, value) => {
13866
13880
  focus
13867
13881
  };
13868
13882
  }
13869
- const logger$4j = getLogger("core");
13883
+ const logger$4k = getLogger("core");
13870
13884
  function createBlockAnchor(editor, block, id, refClientRect) {
13871
13885
  const tools = getBlockTools(block);
13872
13886
  let elem = tools.querySelector(`.block-anchor[data-id=${id}]`);
@@ -13884,7 +13898,7 @@ var __publicField = (obj, key, value) => {
13884
13898
  return elem;
13885
13899
  }
13886
13900
  function createBlockCaretAnchor(editor, block, offset, id) {
13887
- assert(logger$4j, isTextKindBlock(editor, block), "not a text kind block");
13901
+ assert(logger$4k, isTextKindBlock(editor, block), "not a text kind block");
13888
13902
  const caretRect = getTextCaretRect(block, createSimpleBlockPosition(block, offset, "normal"));
13889
13903
  const blockRect = block.getBoundingClientRect();
13890
13904
  const tools = getBlockTools(block);
@@ -14243,19 +14257,19 @@ var __publicField = (obj, key, value) => {
14243
14257
  return result + (index2 ? "-" : "") + word.toLowerCase();
14244
14258
  });
14245
14259
  const kebabCase$1 = kebabCase;
14246
- const logger$4i = getLogger("box");
14260
+ const logger$4j = getLogger("box");
14247
14261
  function isBoxOp(op) {
14248
14262
  if (!op.attributes)
14249
14263
  return false;
14250
14264
  if (!op.attributes.box)
14251
14265
  return false;
14252
- assert(logger$4i, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
14253
- assert(logger$4i, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
14266
+ assert(logger$4j, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
14267
+ assert(logger$4j, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
14254
14268
  return true;
14255
14269
  }
14256
- const logger$4h = getLogger("text-op");
14270
+ const logger$4i = getLogger("text-op");
14257
14271
  function getOpLength(op) {
14258
- assert(logger$4h, typeof op.insert === "string", "invalid op, no insert");
14272
+ assert(logger$4i, typeof op.insert === "string", "invalid op, no insert");
14259
14273
  return op.insert.length;
14260
14274
  }
14261
14275
  function getOpAt(text2, offset) {
@@ -14263,7 +14277,7 @@ var __publicField = (obj, key, value) => {
14263
14277
  let pos = 0;
14264
14278
  for (let i = 0; i < ops.length; i++) {
14265
14279
  const op = ops[i];
14266
- assert(logger$4h, typeof op.insert === "string", "invalid text op, no insert");
14280
+ assert(logger$4i, typeof op.insert === "string", "invalid text op, no insert");
14267
14281
  const end = pos + getOpLength(op);
14268
14282
  if (end > offset) {
14269
14283
  return [op];
@@ -14279,22 +14293,22 @@ var __publicField = (obj, key, value) => {
14279
14293
  }
14280
14294
  return [];
14281
14295
  }
14282
- const logger$4g = getLogger("rich-text-length");
14296
+ const logger$4h = getLogger("rich-text-length");
14283
14297
  function getTextOpLength(op) {
14284
- assert(logger$4g, typeof op.insert === "string", "op.insert is not string");
14298
+ assert(logger$4h, typeof op.insert === "string", "op.insert is not string");
14285
14299
  return op.insert.length;
14286
14300
  }
14287
14301
  function getTextLength(ops) {
14288
14302
  let count = 0;
14289
14303
  ops.forEach((op) => {
14290
14304
  if (op.insert) {
14291
- 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");
14292
14306
  count += getTextOpLength(op);
14293
14307
  }
14294
14308
  });
14295
14309
  return count;
14296
14310
  }
14297
- const logger$4f = getLogger("split-text");
14311
+ const logger$4g = getLogger("split-text");
14298
14312
  function splitText(ops, offset, splitResult) {
14299
14313
  ops = cloneDeep__default.default(ops);
14300
14314
  if (offset === 0) {
@@ -14312,8 +14326,8 @@ var __publicField = (obj, key, value) => {
14312
14326
  let counted = 0;
14313
14327
  for (let i = 0; i < ops.length; i++) {
14314
14328
  const op = ops[i];
14315
- assert(logger$4f, typeof op === "object", `invalid op type, ${typeof op}`);
14316
- assert(logger$4f, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
14329
+ assert(logger$4g, typeof op === "object", `invalid op type, ${typeof op}`);
14330
+ assert(logger$4g, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
14317
14331
  const subLen = getTextOpLength(op);
14318
14332
  if (counted + subLen < offset) {
14319
14333
  counted += subLen;
@@ -14323,18 +14337,18 @@ var __publicField = (obj, key, value) => {
14323
14337
  right: ops.slice(i + 1)
14324
14338
  };
14325
14339
  } else {
14326
- assert(logger$4f, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
14340
+ assert(logger$4g, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
14327
14341
  const splitIndex = offset - counted;
14328
14342
  const copied = cloneDeep__default.default(op);
14329
- assert(logger$4f, copied.insert, "no copied.insert");
14330
- assert(logger$4f, typeof copied.insert === "string", "invalid copied.insert type");
14343
+ assert(logger$4g, copied.insert, "no copied.insert");
14344
+ assert(logger$4g, typeof copied.insert === "string", "invalid copied.insert type");
14331
14345
  copied.insert = copied.insert.substr(0, splitIndex);
14332
14346
  op.insert = op.insert.substr(splitIndex);
14333
14347
  if (copied.insert === "") {
14334
- assert(logger$4f, false, "invalid copied.insert, is empty string");
14348
+ assert(logger$4g, false, "invalid copied.insert, is empty string");
14335
14349
  }
14336
14350
  if (op.insert === "") {
14337
- assert(logger$4f, false, "invalid op.insert, is empty string");
14351
+ assert(logger$4g, false, "invalid op.insert, is empty string");
14338
14352
  }
14339
14353
  const right = [
14340
14354
  op,
@@ -14353,9 +14367,9 @@ var __publicField = (obj, key, value) => {
14353
14367
  throw new Error(`invalid split offset: ${offset}, ${JSON.stringify(ops)}`);
14354
14368
  }
14355
14369
  function splitToThree(text2, offset, length) {
14356
- assert(logger$4f, offset >= 0, "invalid offset, < 0");
14357
- assert(logger$4f, length > 0, "invalid length, <= 0");
14358
- assert(logger$4f, offset + length <= getTextLength(text2), "invalid offset + length < text length");
14370
+ assert(logger$4g, offset >= 0, "invalid offset, < 0");
14371
+ assert(logger$4g, length > 0, "invalid length, <= 0");
14372
+ assert(logger$4g, offset + length <= getTextLength(text2), "invalid offset + length < text length");
14359
14373
  const { left: temp, right } = splitText(text2, offset + length);
14360
14374
  const { left, right: middle } = splitText(temp, offset);
14361
14375
  return { left, middle, right };
@@ -14578,9 +14592,9 @@ var __publicField = (obj, key, value) => {
14578
14592
  }
14579
14593
  return [color, backgroundColor];
14580
14594
  }
14581
- const logger$4e = getLogger("text-block-content");
14595
+ const logger$4f = getLogger("text-block-content");
14582
14596
  function updateBlockContentCore(editor, blockPath, content, blockText, insertions) {
14583
- assert(logger$4e, blockText, "no text for block");
14597
+ assert(logger$4f, blockText, "no text for block");
14584
14598
  if (blockText.length === 0 && (!insertions || insertions.size === 0)) {
14585
14599
  content.innerHTML = "<span><br></span>";
14586
14600
  return;
@@ -14612,9 +14626,9 @@ var __publicField = (obj, key, value) => {
14612
14626
  for (let i2 = 0; i2 < text2.length; i2++) {
14613
14627
  const op = text2[i2];
14614
14628
  if (isBoxOp(op)) {
14615
- assert(logger$4e, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
14629
+ assert(logger$4f, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
14616
14630
  const span2 = editor.editorBoxes.createBox(content, op.attributes);
14617
- assert(logger$4e, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
14631
+ assert(logger$4f, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
14618
14632
  const ret = editor.editorBlockRenders.renderBox(blockPath, op.attributes);
14619
14633
  if (ret.classes) {
14620
14634
  addClass(span2, ...ret.classes);
@@ -14632,7 +14646,7 @@ var __publicField = (obj, key, value) => {
14632
14646
  fragment.appendChild(span2);
14633
14647
  continue;
14634
14648
  }
14635
- assert(logger$4e, op.insert, `no insert in op: ${JSON.stringify(op)}`);
14649
+ assert(logger$4f, op.insert, `no insert in op: ${JSON.stringify(op)}`);
14636
14650
  const span = createElement("span", ["text"], fragment, op.insert);
14637
14651
  if (op.attributes) {
14638
14652
  const ret = editor.editorBlockRenders.renderText(blockPath, op.attributes);
@@ -14663,7 +14677,7 @@ var __publicField = (obj, key, value) => {
14663
14677
  const compositionText = editor.compositingText;
14664
14678
  if (compositionText) {
14665
14679
  const pos = editor.selection.range.start;
14666
- assert(logger$4e, pos.isSimple(), "not an simple position while compositing");
14680
+ assert(logger$4f, pos.isSimple(), "not an simple position while compositing");
14667
14681
  if (pos.blockId === blockId) {
14668
14682
  const attributes = getAttributesAt(text2, 0);
14669
14683
  insertions.set(pos.offset, [{
@@ -14679,11 +14693,11 @@ var __publicField = (obj, key, value) => {
14679
14693
  function clearAllTempCompositionText(editor) {
14680
14694
  const children = editor.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');
14681
14695
  if (children.length) {
14682
- logger$4e.debug(`remove ${children.length} temp composition span`);
14696
+ logger$4f.debug(`remove ${children.length} temp composition span`);
14683
14697
  }
14684
14698
  Array.from(children).forEach((c) => c.remove());
14685
14699
  }
14686
- const logger$4d = getLogger("client-rects");
14700
+ const logger$4e = getLogger("client-rects");
14687
14701
  function getChildrenOffsets(block) {
14688
14702
  const children = getTextBlockContentChildren(block);
14689
14703
  let start = 0;
@@ -14701,15 +14715,15 @@ var __publicField = (obj, key, value) => {
14701
14715
  return ret;
14702
14716
  }
14703
14717
  function getChildrenInRange(editor, block, from, to) {
14704
- assert(logger$4d, from < to, `invalid from & to: ${from}, ${to}`);
14718
+ assert(logger$4e, from < to, `invalid from & to: ${from}, ${to}`);
14705
14719
  const blockLength = getBlockTextLength$6(editor, block);
14706
- assert(logger$4d, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
14720
+ assert(logger$4e, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
14707
14721
  const offsets = getChildrenOffsets(block);
14708
14722
  const startIndex = offsets.findIndex((c) => c.startBlockOffset <= from && from < c.endBlockOffset);
14709
14723
  const endIndex = offsets.findIndex((c) => c.startBlockOffset < to && to <= c.endBlockOffset);
14710
- assert(logger$4d, startIndex !== -1, "failed to find start child");
14711
- assert(logger$4d, endIndex !== -1, "failed to find end child");
14712
- assert(logger$4d, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
14724
+ assert(logger$4e, startIndex !== -1, "failed to find start child");
14725
+ assert(logger$4e, endIndex !== -1, "failed to find end child");
14726
+ assert(logger$4e, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
14713
14727
  if (startIndex === endIndex) {
14714
14728
  const child = offsets[startIndex];
14715
14729
  return [{
@@ -14791,16 +14805,16 @@ var __publicField = (obj, key, value) => {
14791
14805
  return rects;
14792
14806
  }
14793
14807
  function getRangeClientRects(editor, block, range) {
14794
- assert(logger$4d, range instanceof EditorSimpleSelectionRange, "invalid range");
14808
+ assert(logger$4e, range instanceof EditorSimpleSelectionRange, "invalid range");
14795
14809
  const start = range.start;
14796
14810
  const end = range.end;
14797
- assert(logger$4d, start.isSimple(), "text block only allow simple position");
14798
- assert(logger$4d, end.isSimple(), "text block only allow simple position");
14799
- assert(logger$4d, start.blockId === end.blockId, "only allow update one text block selection");
14800
- assert(logger$4d, start.blockId === getBlockId(block), "only allow update one text block selection");
14811
+ assert(logger$4e, start.isSimple(), "text block only allow simple position");
14812
+ assert(logger$4e, end.isSimple(), "text block only allow simple position");
14813
+ assert(logger$4e, start.blockId === end.blockId, "only allow update one text block selection");
14814
+ assert(logger$4e, start.blockId === getBlockId(block), "only allow update one text block selection");
14801
14815
  return getClientRects$2(editor, block, start, end);
14802
14816
  }
14803
- const logger$4c = getLogger("selection-background");
14817
+ const logger$4d = getLogger("selection-background");
14804
14818
  function getLineHeight(elem) {
14805
14819
  const style2 = window.getComputedStyle(elem);
14806
14820
  const lineHeightStyle = style2.getPropertyValue("line-height");
@@ -14820,9 +14834,9 @@ var __publicField = (obj, key, value) => {
14820
14834
  return lineHeight;
14821
14835
  }
14822
14836
  function updateSelection$4(editor, block, start, end) {
14823
- assert(logger$4c, start.isSimple(), "text block only allow simple position");
14824
- assert(logger$4c, end.isSimple(), "text block only allow simple position");
14825
- assert(logger$4c, start.blockId === end.blockId, "only allow update one text block selection");
14837
+ assert(logger$4d, start.isSimple(), "text block only allow simple position");
14838
+ assert(logger$4d, end.isSimple(), "text block only allow simple position");
14839
+ assert(logger$4d, start.blockId === end.blockId, "only allow update one text block selection");
14826
14840
  const from = start.offset;
14827
14841
  const to = end.offset;
14828
14842
  if (from === to) {
@@ -14881,7 +14895,7 @@ var __publicField = (obj, key, value) => {
14881
14895
  }
14882
14896
  });
14883
14897
  }
14884
- const logger$4b = getLogger("line-breaker");
14898
+ const logger$4c = getLogger("line-breaker");
14885
14899
  function mergeTextRects(rects) {
14886
14900
  const result = [];
14887
14901
  let lastRect = null;
@@ -15008,7 +15022,7 @@ var __publicField = (obj, key, value) => {
15008
15022
  }
15009
15023
  const textChild = child;
15010
15024
  const rects = mergeTextRects(textChild.getClientRects());
15011
- assert(logger$4b, rects.length > 0, "invalid text child dom");
15025
+ assert(logger$4c, rects.length > 0, "invalid text child dom");
15012
15026
  if (rects.length === 1) {
15013
15027
  const nextChild = children[i + 1];
15014
15028
  if (!nextChild) {
@@ -15033,10 +15047,10 @@ var __publicField = (obj, key, value) => {
15033
15047
  continue;
15034
15048
  }
15035
15049
  const textNode = textChild.firstChild;
15036
- assert(logger$4b, textNode, "invalid text child, no text node");
15037
- assert(logger$4b, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
15050
+ assert(logger$4c, textNode, "invalid text child, no text node");
15051
+ assert(logger$4c, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
15038
15052
  const textChildLength = getTextBlockContentChildTextLength(textChild);
15039
- assert(logger$4b, textNode.data.length === textChildLength, "text node data length not equal child text length");
15053
+ assert(logger$4c, textNode.data.length === textChildLength, "text node data length not equal child text length");
15040
15054
  const textRects = getTextRects(textNode);
15041
15055
  for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
15042
15056
  const rect = textRects[rIndex];
@@ -15078,7 +15092,7 @@ var __publicField = (obj, key, value) => {
15078
15092
  }
15079
15093
  }
15080
15094
  }
15081
- assert(logger$4b, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
15095
+ assert(logger$4c, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
15082
15096
  return {
15083
15097
  lineIndex: lineBreaks.length,
15084
15098
  lineBreaks
@@ -23851,7 +23865,7 @@ var __publicField = (obj, key, value) => {
23851
23865
  const Graphemer_1 = __importDefault(Graphemer$1);
23852
23866
  var _default = lib$1.default = Graphemer_1.default;
23853
23867
  const splitter = new _default();
23854
- const logger$4a = getLogger("text-offset");
23868
+ const logger$4b = getLogger("text-offset");
23855
23869
  function getChildOffset(block, child) {
23856
23870
  const children = getTextBlockContentChildren(block);
23857
23871
  let start = 0;
@@ -23867,26 +23881,26 @@ var __publicField = (obj, key, value) => {
23867
23881
  }
23868
23882
  start += testLength;
23869
23883
  }
23870
- assert(logger$4a, false, "can not find child in children");
23884
+ assert(logger$4b, false, "can not find child in children");
23871
23885
  }
23872
23886
  function isValidOffset(block, blockOffset) {
23873
- assert(logger$4a, blockOffset >= 0, `invalid offset: ${blockOffset}`);
23887
+ assert(logger$4b, blockOffset >= 0, `invalid offset: ${blockOffset}`);
23874
23888
  const childInfo = getTextBlockChild(block, blockOffset);
23875
23889
  const { prev, next: next2, offset } = childInfo;
23876
23890
  if (!prev && !next2) {
23877
- assert(logger$4a, false, "invalid offset, no prev & next child at offset");
23891
+ assert(logger$4b, false, "invalid offset, no prev & next child at offset");
23878
23892
  }
23879
23893
  if (prev !== next2) {
23880
23894
  return true;
23881
23895
  }
23882
23896
  const child = prev;
23883
- assert(logger$4a, child, "no child");
23897
+ assert(logger$4b, child, "no child");
23884
23898
  if (isTextBlockContentBoxChild(child)) {
23885
- assert(logger$4a, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
23899
+ assert(logger$4b, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
23886
23900
  return true;
23887
23901
  }
23888
23902
  const text2 = child.textContent;
23889
- assert(logger$4a, text2, "no content for text child");
23903
+ assert(logger$4b, text2, "no content for text child");
23890
23904
  const chars = splitter.splitGraphemes(text2);
23891
23905
  const validOffsets = /* @__PURE__ */ new Set();
23892
23906
  let start = 0;
@@ -23916,7 +23930,7 @@ var __publicField = (obj, key, value) => {
23916
23930
  }
23917
23931
  function getNextValidOffset(block, blockOffset) {
23918
23932
  const length = getTextBlockLength(block);
23919
- assert(logger$4a, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
23933
+ assert(logger$4b, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
23920
23934
  if (blockOffset === length) {
23921
23935
  return length;
23922
23936
  }
@@ -23930,7 +23944,7 @@ var __publicField = (obj, key, value) => {
23930
23944
  }
23931
23945
  return ret;
23932
23946
  }
23933
- const logger$49 = getLogger("line-offset");
23947
+ const logger$4a = getLogger("line-offset");
23934
23948
  function getLineOffsets(block) {
23935
23949
  const lineBreaks = getLineBreaks(block);
23936
23950
  const ret = [];
@@ -23951,7 +23965,7 @@ var __publicField = (obj, key, value) => {
23951
23965
  }
23952
23966
  function getLineOffset(block, lineIndex) {
23953
23967
  const lines = getLineOffsets(block);
23954
- assert(logger$49, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
23968
+ assert(logger$4a, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
23955
23969
  return lines[lineIndex];
23956
23970
  }
23957
23971
  function getLineOffsetByPos(block, pos) {
@@ -24008,7 +24022,7 @@ var __publicField = (obj, key, value) => {
24008
24022
  function getLineCount(block) {
24009
24023
  return getLineOffsets(block).length;
24010
24024
  }
24011
- const logger$48 = getLogger("find-text-position");
24025
+ const logger$49 = getLogger("find-text-position");
24012
24026
  function isWrappedLine(block, lineIndex) {
24013
24027
  const { start, end } = getLineOffset(block, lineIndex);
24014
24028
  const blockId = getBlockId(block);
@@ -24019,13 +24033,13 @@ var __publicField = (obj, key, value) => {
24019
24033
  return false;
24020
24034
  }
24021
24035
  const childInfo = getTextBlockChild(block, start);
24022
- assert(logger$48, childInfo.next, "no next child at offset");
24023
- assert(logger$48, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
24036
+ assert(logger$49, childInfo.next, "no next child at offset");
24037
+ assert(logger$49, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
24024
24038
  return true;
24025
24039
  }
24026
24040
  function getWrappedLineOffsets(block, lineIndex) {
24027
24041
  const blockId = getBlockId(block);
24028
- assert(logger$48, isWrappedLine(block, lineIndex), "line is not wrapped");
24042
+ assert(logger$49, isWrappedLine(block, lineIndex), "line is not wrapped");
24029
24043
  const { start, end } = getLineOffset(block, lineIndex);
24030
24044
  const homePos = createSimpleBlockPosition(blockId, start, "home");
24031
24045
  for (let offset = start + 1; offset <= end; offset += 1) {
@@ -24040,11 +24054,11 @@ var __publicField = (obj, key, value) => {
24040
24054
  return offset - 1;
24041
24055
  }
24042
24056
  }
24043
- assert(logger$48, false, "failed to find wrapped offset");
24057
+ assert(logger$49, false, "failed to find wrapped offset");
24044
24058
  return 0;
24045
24059
  }
24046
24060
  function findTextPositionInLine(editor, block, lineIndex, sourceBlock, pos, findDirection, suggestedX) {
24047
- assert(logger$48, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
24061
+ assert(logger$49, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
24048
24062
  const { start, end } = getLineOffset(block, lineIndex);
24049
24063
  let from = start;
24050
24064
  const blockId = getBlockId(block);
@@ -24086,11 +24100,11 @@ var __publicField = (obj, key, value) => {
24086
24100
  return retPos;
24087
24101
  }
24088
24102
  function findPrevTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
24089
- assert(logger$48, isTextKindBlock(editor, block), "not a text block");
24103
+ assert(logger$49, isTextKindBlock(editor, block), "not a text block");
24090
24104
  return findTextPositionInLine(editor, block, getLineCount(block) - 1, sourceBlock, pos, "up", suggestedX);
24091
24105
  }
24092
24106
  function findNextTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
24093
- assert(logger$48, isTextKindBlock(editor, block), "not a text block");
24107
+ assert(logger$49, isTextKindBlock(editor, block), "not a text block");
24094
24108
  return findTextPositionInLine(editor, block, 0, sourceBlock, pos, "down", suggestedX);
24095
24109
  }
24096
24110
  function moveDown(editor, block, position, suggestedX) {
@@ -24198,7 +24212,7 @@ var __publicField = (obj, key, value) => {
24198
24212
  }
24199
24213
  return pos;
24200
24214
  }
24201
- const logger$47 = getLogger("move-caret");
24215
+ const logger$48 = getLogger("move-caret");
24202
24216
  function moveTextCaret(editor, block, position, direction) {
24203
24217
  if (direction === "ArrowLeft") {
24204
24218
  const ret = moveLeft(block, position);
@@ -24228,9 +24242,9 @@ var __publicField = (obj, key, value) => {
24228
24242
  }
24229
24243
  return createSimpleBlockPosition(getBlockId(block), ret.offset, ret.type);
24230
24244
  }
24231
- assert(logger$47, false, `invalid navigation direction: ${direction}`);
24245
+ assert(logger$48, false, `invalid navigation direction: ${direction}`);
24232
24246
  }
24233
- const logger$46 = getLogger("text-range");
24247
+ const logger$47 = getLogger("text-range");
24234
24248
  function getBlockRects(block) {
24235
24249
  const ret = [];
24236
24250
  const children = getTextBlockContentChildren(block);
@@ -24288,9 +24302,9 @@ var __publicField = (obj, key, value) => {
24288
24302
  return null;
24289
24303
  }
24290
24304
  const children = getTextBlockContentChildren(block);
24291
- assert(logger$46, children.indexOf(child) !== -1, "failed to find child in children");
24305
+ assert(logger$47, children.indexOf(child) !== -1, "failed to find child in children");
24292
24306
  const offsetInfo = getChildOffset(block, child);
24293
- assert(logger$46, offsetInfo, "failed to get child offset");
24307
+ assert(logger$47, offsetInfo, "failed to get child offset");
24294
24308
  const { start } = offsetInfo;
24295
24309
  let offset;
24296
24310
  let length;
@@ -24306,7 +24320,7 @@ var __publicField = (obj, key, value) => {
24306
24320
  }
24307
24321
  length = 0;
24308
24322
  } else {
24309
- assert(logger$46, child.firstChild instanceof Text, "child is not text");
24323
+ assert(logger$47, child.firstChild instanceof Text, "child is not text");
24310
24324
  offset = start + textNodeOffsetFromPoint(child.firstChild, x, y);
24311
24325
  length = 0;
24312
24326
  }
@@ -24330,9 +24344,9 @@ var __publicField = (obj, key, value) => {
24330
24344
  }
24331
24345
  return new EditorSimpleSelectionRange(editor, { anchor: startPos, focus: endPos != null ? endPos : startPos });
24332
24346
  }
24333
- const logger$45 = getLogger("create-text-op");
24347
+ const logger$46 = getLogger("create-text-op");
24334
24348
  function createTextOp(text2, attributes) {
24335
- assert(logger$45, text2, "text is empty");
24349
+ assert(logger$46, text2, "text is empty");
24336
24350
  const ret = {
24337
24351
  insert: text2
24338
24352
  };
@@ -24355,7 +24369,7 @@ var __publicField = (obj, key, value) => {
24355
24369
  }
24356
24370
  return result;
24357
24371
  }
24358
- const logger$44 = getLogger("merge-ops");
24372
+ const logger$45 = getLogger("merge-ops");
24359
24373
  function mergeOps(text2) {
24360
24374
  if (text2.length <= 1) {
24361
24375
  return text2;
@@ -24377,10 +24391,10 @@ var __publicField = (obj, key, value) => {
24377
24391
  return false;
24378
24392
  }
24379
24393
  if (op1.attributes === void 0) {
24380
- assert(logger$44, op2.attributes === void 0, "op2.attributes is not undefined");
24394
+ assert(logger$45, op2.attributes === void 0, "op2.attributes is not undefined");
24381
24395
  return true;
24382
24396
  }
24383
- assert(logger$44, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
24397
+ assert(logger$45, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
24384
24398
  return isEqual__default.default(op1.attributes, op2.attributes);
24385
24399
  };
24386
24400
  const newOps = [];
@@ -24389,8 +24403,8 @@ var __publicField = (obj, key, value) => {
24389
24403
  for (let i = 1; i < text2.length; i += 1) {
24390
24404
  const op = text2[i];
24391
24405
  if (isSameTypeOp(before, op)) {
24392
- assert(logger$44, typeof before.insert === "string", "before.insert is not string");
24393
- assert(logger$44, typeof op.insert === "string", "op.insert is not string");
24406
+ assert(logger$45, typeof before.insert === "string", "before.insert is not string");
24407
+ assert(logger$45, typeof op.insert === "string", "op.insert is not string");
24394
24408
  before.insert += op.insert;
24395
24409
  } else {
24396
24410
  newOps.push(op);
@@ -24418,15 +24432,15 @@ var __publicField = (obj, key, value) => {
24418
24432
  }
24419
24433
  return text2.slice(0, i + 1);
24420
24434
  }
24421
- const logger$43 = getLogger("delete-text");
24435
+ const logger$44 = getLogger("delete-text");
24422
24436
  function deleteText(richText2, offset, count) {
24423
24437
  const { left, right } = splitToThree(richText2, offset, count);
24424
24438
  const result = [...left, ...right];
24425
24439
  return mergeOps(result);
24426
24440
  }
24427
24441
  function createDeleteOps(offset, count) {
24428
- assert(logger$43, offset >= 0, `invalid offset: ${offset}`);
24429
- assert(logger$43, count >= 1, `invalid delete count: ${count}`);
24442
+ assert(logger$44, offset >= 0, `invalid offset: ${offset}`);
24443
+ assert(logger$44, count >= 1, `invalid delete count: ${count}`);
24430
24444
  const ops = [];
24431
24445
  if (offset !== 0) {
24432
24446
  ops.push({
@@ -24438,7 +24452,7 @@ var __publicField = (obj, key, value) => {
24438
24452
  });
24439
24453
  return ops;
24440
24454
  }
24441
- const logger$42 = getLogger("delta");
24455
+ const logger$43 = getLogger("delta");
24442
24456
  function diffRichText(oldText, newText) {
24443
24457
  const delta1D = new Delta__default.default(oldText);
24444
24458
  const delta2D = new Delta__default.default(newText);
@@ -24448,7 +24462,7 @@ var __publicField = (obj, key, value) => {
24448
24462
  return new Delta__default.default(ops).transformPosition(cursor, !isLocalOp);
24449
24463
  }
24450
24464
  function isValidDocText(text2) {
24451
- assert(logger$42, text2, "ops is null or undefined");
24465
+ assert(logger$43, text2, "ops is null or undefined");
24452
24466
  for (let i = 0; i < text2.length; i++) {
24453
24467
  const op = text2[i];
24454
24468
  if (op.insert === null || op.insert === void 0) {
@@ -24468,7 +24482,7 @@ var __publicField = (obj, key, value) => {
24468
24482
  }
24469
24483
  class RichText {
24470
24484
  static ensureValidText(text2) {
24471
- assert(logger$42, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
24485
+ assert(logger$43, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
24472
24486
  }
24473
24487
  static diff(oldText, newText) {
24474
24488
  this.ensureValidText(oldText);
@@ -24490,9 +24504,9 @@ var __publicField = (obj, key, value) => {
24490
24504
  return resultText;
24491
24505
  }
24492
24506
  }
24493
- const logger$41 = getLogger("insert-text");
24507
+ const logger$42 = getLogger("insert-text");
24494
24508
  function insertText(richText2, offset, text2, attributes) {
24495
- assert(logger$41, text2, `invalid text to insert: ${text2}`);
24509
+ assert(logger$42, text2, `invalid text to insert: ${text2}`);
24496
24510
  const { left, right } = splitText(richText2, offset);
24497
24511
  const insertedText = typeof text2 === "string" ? [createTextOp(text2, attributes)] : text2;
24498
24512
  const result = [...left, ...insertedText, ...right];
@@ -24505,7 +24519,7 @@ var __publicField = (obj, key, value) => {
24505
24519
  };
24506
24520
  }
24507
24521
  function createInsertOps(offset, text2, attributes) {
24508
- assert(logger$41, offset >= 0, `invalid offset: ${offset}`);
24522
+ assert(logger$42, offset >= 0, `invalid offset: ${offset}`);
24509
24523
  if (text2.length === 0) {
24510
24524
  return [];
24511
24525
  }
@@ -24535,7 +24549,7 @@ var __publicField = (obj, key, value) => {
24535
24549
  function cloneText(text2) {
24536
24550
  return cloneDeep__default.default(text2);
24537
24551
  }
24538
- const logger$40 = getLogger("update-op-attribute");
24552
+ const logger$41 = getLogger("update-op-attribute");
24539
24553
  function updateOpAttributes(orgOps, key, value, newAttributes) {
24540
24554
  const ops = cloneText(orgOps);
24541
24555
  const index2 = ops.findIndex((op2) => {
@@ -24543,7 +24557,7 @@ var __publicField = (obj, key, value) => {
24543
24557
  return false;
24544
24558
  return op2.attributes[key] === value;
24545
24559
  });
24546
- assert(logger$40, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
24560
+ assert(logger$41, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
24547
24561
  const op = ops[index2];
24548
24562
  op.attributes = {
24549
24563
  ...op.attributes,
@@ -24625,11 +24639,11 @@ var __publicField = (obj, key, value) => {
24625
24639
  ]);
24626
24640
  }
24627
24641
  const FILL_CHAR = "\u200B";
24628
- const logger$3$ = getLogger("to-plain-text");
24642
+ const logger$40 = getLogger("to-plain-text");
24629
24643
  function toPlainText(ops, options) {
24630
24644
  let text2 = "";
24631
24645
  ops.forEach((op) => {
24632
- assert(logger$3$, typeof op.insert === "string", "invalid op");
24646
+ assert(logger$40, typeof op.insert === "string", "invalid op");
24633
24647
  if (op.attributes && op.attributes.box === true) {
24634
24648
  if (options == null ? void 0 : options.boxReplacement) {
24635
24649
  text2 += options.boxReplacement;
@@ -24684,11 +24698,11 @@ var __publicField = (obj, key, value) => {
24684
24698
  focus: pos
24685
24699
  };
24686
24700
  }
24687
- const logger$3_ = getLogger("block-to-text");
24701
+ const logger$3$ = getLogger("block-to-text");
24688
24702
  function textBlockToText$1(editor, ops, doc2) {
24689
24703
  let text2 = "";
24690
24704
  ops.forEach((op) => {
24691
- assert(logger$3_, typeof op.insert === "string", "invalid op");
24705
+ assert(logger$3$, typeof op.insert === "string", "invalid op");
24692
24706
  if (op.attributes && op.attributes.box === true) {
24693
24707
  const box = op.attributes;
24694
24708
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -24706,11 +24720,11 @@ var __publicField = (obj, key, value) => {
24706
24720
  });
24707
24721
  return text2;
24708
24722
  }
24709
- const logger$3Z = getLogger("block-to-text");
24723
+ const logger$3_ = getLogger("block-to-text");
24710
24724
  function textToMarkdownText(editor, ops, doc2) {
24711
24725
  let text2 = "";
24712
24726
  ops.forEach((op) => {
24713
- assert(logger$3Z, typeof op.insert === "string", "invalid op");
24727
+ assert(logger$3_, typeof op.insert === "string", "invalid op");
24714
24728
  if (op.attributes && op.attributes.box === true) {
24715
24729
  const box = op.attributes;
24716
24730
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -24833,12 +24847,12 @@ var __publicField = (obj, key, value) => {
24833
24847
  return void 0;
24834
24848
  }
24835
24849
  }
24836
- const logger$3Y = getLogger("block-to-text");
24850
+ const logger$3Z = getLogger("block-to-text");
24837
24851
  function textBlockToHtml(editor, blockData, doc2) {
24838
24852
  let html = "";
24839
24853
  const ops = blockData.text || [];
24840
24854
  ops.forEach((op) => {
24841
- assert(logger$3Y, typeof op.insert === "string", "invalid op");
24855
+ assert(logger$3Z, typeof op.insert === "string", "invalid op");
24842
24856
  if (op.attributes && op.attributes.box === true) {
24843
24857
  const box = op.attributes;
24844
24858
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -24914,16 +24928,16 @@ var __publicField = (obj, key, value) => {
24914
24928
  }
24915
24929
  return `<p>${html}</p>`;
24916
24930
  }
24917
- const logger$3X = getLogger("text-block");
24931
+ const logger$3Y = getLogger("text-block");
24918
24932
  function createBlockContent$5(editor, path, container, blockElement, blockData) {
24919
24933
  const { text: text2 } = blockData;
24920
- assert(logger$3X, text2, "no text for text block");
24934
+ assert(logger$3Y, text2, "no text for text block");
24921
24935
  const content = createBlockContentElement(blockElement, "div");
24922
24936
  updateBlockContent$1(editor, path, blockData.id, content, text2);
24923
24937
  return content;
24924
24938
  }
24925
24939
  function updateBlockText$1(editor, block, text2) {
24926
- assert(logger$3X, text2, "no text to update");
24940
+ assert(logger$3Y, text2, "no text to update");
24927
24941
  const newContent = createBlockContentElement(null, "div");
24928
24942
  updateBlockContent$1(editor, getBlockPath(block), getBlockId(block), newContent, text2);
24929
24943
  const oldContent = getBlockContent(block);
@@ -24933,7 +24947,7 @@ var __publicField = (obj, key, value) => {
24933
24947
  return getRangeClientRects(editor, block, range);
24934
24948
  }
24935
24949
  function convertTo$k(editor, blockData, doc2, type) {
24936
- assert(logger$3X, blockData.text, "no text for text block");
24950
+ assert(logger$3Y, blockData.text, "no text for text block");
24937
24951
  if (type === "text") {
24938
24952
  return textBlockToText$1(editor, blockData.text, doc2);
24939
24953
  }
@@ -24947,7 +24961,7 @@ var __publicField = (obj, key, value) => {
24947
24961
  blockData.id = genId();
24948
24962
  info == null ? void 0 : info.blockIdMap.set(srcBlockData.id, blockData.id);
24949
24963
  const { text: text2 } = blockData;
24950
- assert(logger$3X, text2, "no text for text block");
24964
+ assert(logger$3Y, text2, "no text for text block");
24951
24965
  text2.forEach((op) => {
24952
24966
  if (op.insert && op.attributes && op.attributes.box === true) {
24953
24967
  const boxId = genId();
@@ -24979,7 +24993,7 @@ var __publicField = (obj, key, value) => {
24979
24993
  blockToDoc: blockToDoc$1
24980
24994
  };
24981
24995
  const updateTextBlockContent = updateBlockContent$1;
24982
- const logger$3W = getLogger("action-helper");
24996
+ const logger$3X = getLogger("action-helper");
24983
24997
  function editorGetBlockData(editor, block) {
24984
24998
  const container = getParentContainer(block);
24985
24999
  const containerId = getContainerId(container);
@@ -24987,10 +25001,10 @@ var __publicField = (obj, key, value) => {
24987
25001
  return editor.doc.getBlockData(containerId, blockIndex);
24988
25002
  }
24989
25003
  function editorGetBlockText(editor, block) {
24990
- assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25004
+ assert(logger$3X, isTextKindBlock(editor, block), "not a text kind block");
24991
25005
  const data2 = editorGetBlockData(editor, block);
24992
25006
  const text2 = data2.text;
24993
- assert(logger$3W, text2, "no text in block");
25007
+ assert(logger$3X, text2, "no text in block");
24994
25008
  return text2;
24995
25009
  }
24996
25010
  function editorGetBlockTextEx(editor, block, length) {
@@ -24998,7 +25012,7 @@ var __publicField = (obj, key, value) => {
24998
25012
  }
24999
25013
  function editorGetBoxData(editor, box) {
25000
25014
  const block = getParentBlock(box);
25001
- assert(logger$3W, block, "no parent block");
25015
+ assert(logger$3X, block, "no parent block");
25002
25016
  const text2 = editorGetBlockText(editor, block);
25003
25017
  const id = getBoxId(box);
25004
25018
  const op = text2.find((op2) => {
@@ -25008,60 +25022,60 @@ var __publicField = (obj, key, value) => {
25008
25022
  }
25009
25023
  return false;
25010
25024
  });
25011
- assert(logger$3W, op, "failed to find box");
25025
+ assert(logger$3X, op, "failed to find box");
25012
25026
  return op.attributes;
25013
25027
  }
25014
- const logger$3V = getLogger("block-text");
25028
+ const logger$3W = getLogger("block-text");
25015
25029
  function getTextAfterOffset(editor, block, offset) {
25016
- assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
25017
- assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
25018
- assert(logger$3V, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25030
+ assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25031
+ assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
25032
+ assert(logger$3W, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25019
25033
  const newOffset = getNextValidOffset(block, offset);
25020
25034
  const length = newOffset - offset;
25021
25035
  if (length === 0) {
25022
- assert(logger$3V, false, `no text after offset: ${offset}`);
25036
+ assert(logger$3W, false, `no text after offset: ${offset}`);
25023
25037
  }
25024
25038
  const text2 = editorGetBlockText(editor, block);
25025
25039
  const { middle } = splitToThree(text2, offset, length);
25026
- assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
25040
+ assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
25027
25041
  const op = middle[0];
25028
25042
  if (isBoxOp(op)) {
25029
25043
  return " ";
25030
25044
  }
25031
- assert(logger$3V, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25045
+ assert(logger$3W, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25032
25046
  return op.insert;
25033
25047
  }
25034
25048
  function getTextBeforeOffset(editor, block, offset) {
25035
- assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
25036
- assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
25037
- assert(logger$3V, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25049
+ assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25050
+ assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
25051
+ assert(logger$3W, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25038
25052
  const newOffset = getPrevValidOffset(block, offset);
25039
25053
  const length = offset - newOffset;
25040
25054
  if (length === 0) {
25041
- assert(logger$3V, false, `no text before offset: ${offset}`);
25055
+ assert(logger$3W, false, `no text before offset: ${offset}`);
25042
25056
  }
25043
25057
  const text2 = editorGetBlockText(editor, block);
25044
25058
  const { middle } = splitToThree(text2, newOffset, length);
25045
- assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
25059
+ assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
25046
25060
  const op = middle[0];
25047
25061
  if (isBoxOp(op)) {
25048
25062
  return " ";
25049
25063
  }
25050
- assert(logger$3V, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25064
+ assert(logger$3W, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25051
25065
  return op.insert;
25052
25066
  }
25053
25067
  function getOffsetInfoBefore(editor, block, offset) {
25054
- assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
25055
- assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
25056
- assert(logger$3V, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25068
+ assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25069
+ assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
25070
+ assert(logger$3W, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25057
25071
  const newOffset = getPrevValidOffset(block, offset);
25058
25072
  const length = offset - newOffset;
25059
25073
  if (length === 0) {
25060
- assert(logger$3V, false, `no text before offset: ${offset}`);
25074
+ assert(logger$3W, false, `no text before offset: ${offset}`);
25061
25075
  }
25062
25076
  const text2 = editorGetBlockText(editor, block);
25063
25077
  const { middle } = splitToThree(text2, newOffset, length);
25064
- assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
25078
+ assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
25065
25079
  const op = middle[0];
25066
25080
  if (isBoxOp(op)) {
25067
25081
  return {
@@ -25071,25 +25085,33 @@ var __publicField = (obj, key, value) => {
25071
25085
  length: 1
25072
25086
  };
25073
25087
  }
25088
+ let charType = "text";
25089
+ if (isSpace(op.insert)) {
25090
+ charType = "space";
25091
+ } else if (isCJKPunctuation(op.insert)) {
25092
+ charType = "cjk_punctuation";
25093
+ } else if (isCJK(op.insert)) {
25094
+ charType = "cjk";
25095
+ }
25074
25096
  return {
25075
25097
  op,
25076
- charType: isSpace(op.insert) ? "space" : "text",
25098
+ charType,
25077
25099
  offset: newOffset,
25078
25100
  length: op.insert.length
25079
25101
  };
25080
25102
  }
25081
25103
  function getOffsetInfoAfter(editor, block, offset) {
25082
- assert(logger$3V, isTextKindBlock(editor, block), "not a text kind block");
25083
- assert(logger$3V, isValidOffset(block, offset), "not a valid offset");
25084
- assert(logger$3V, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25104
+ assert(logger$3W, isTextKindBlock(editor, block), "not a text kind block");
25105
+ assert(logger$3W, isValidOffset(block, offset), "not a valid offset");
25106
+ assert(logger$3W, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25085
25107
  const newOffset = getNextValidOffset(block, offset);
25086
25108
  const length = newOffset - offset;
25087
25109
  if (length === 0) {
25088
- assert(logger$3V, false, `no text after offset: ${offset}`);
25110
+ assert(logger$3W, false, `no text after offset: ${offset}`);
25089
25111
  }
25090
25112
  const text2 = editorGetBlockText(editor, block);
25091
25113
  const { middle } = splitToThree(text2, offset, length);
25092
- assert(logger$3V, middle.length === 1, "failed to split text to 3 parts");
25114
+ assert(logger$3W, middle.length === 1, "failed to split text to 3 parts");
25093
25115
  const op = middle[0];
25094
25116
  if (isBoxOp(op)) {
25095
25117
  return {
@@ -25099,9 +25121,17 @@ var __publicField = (obj, key, value) => {
25099
25121
  length: 1
25100
25122
  };
25101
25123
  }
25124
+ let charType = "text";
25125
+ if (isSpace(op.insert)) {
25126
+ charType = "space";
25127
+ } else if (isCJKPunctuation(op.insert)) {
25128
+ charType = "cjk_punctuation";
25129
+ } else if (isCJK(op.insert)) {
25130
+ charType = "cjk";
25131
+ }
25102
25132
  return {
25103
25133
  op,
25104
- charType: isSpace(op.insert) ? "space" : "text",
25134
+ charType,
25105
25135
  offset,
25106
25136
  length: op.insert.length
25107
25137
  };
@@ -25153,7 +25183,7 @@ var __publicField = (obj, key, value) => {
25153
25183
  return null;
25154
25184
  }
25155
25185
  function findWordLeft(editor, block, offset) {
25156
- assert(logger$3V, isTextKindBlock(editor, block), "invalid blok type");
25186
+ assert(logger$3W, isTextKindBlock(editor, block), "invalid blok type");
25157
25187
  if (isEmptyTextBlock(editor, block)) {
25158
25188
  return 0;
25159
25189
  }
@@ -25162,6 +25192,7 @@ var __publicField = (obj, key, value) => {
25162
25192
  return offset - 1;
25163
25193
  }
25164
25194
  let start = offset;
25195
+ let find = offsetInfo.charType;
25165
25196
  if (offsetInfo.charType === "space") {
25166
25197
  const startInfo2 = findPrevOffsetNotType(editor, block, start, "space");
25167
25198
  if (!startInfo2) {
@@ -25174,14 +25205,15 @@ var __publicField = (obj, key, value) => {
25174
25205
  return startInfo2.offset;
25175
25206
  }
25176
25207
  start = startInfo2.offset;
25208
+ find = getOffsetInfoBefore(editor, block, start).charType;
25177
25209
  }
25178
- const startInfo = findPrevOffsetNotType(editor, block, start, "text");
25210
+ const startInfo = findPrevOffsetNotType(editor, block, start, find);
25179
25211
  if (!startInfo)
25180
25212
  return 0;
25181
25213
  return startInfo.offset + startInfo.length;
25182
25214
  }
25183
25215
  function findWordEnd(editor, block, offset) {
25184
- assert(logger$3V, isTextKindBlock(editor, block), "invalid blok type");
25216
+ assert(logger$3W, isTextKindBlock(editor, block), "invalid blok type");
25185
25217
  if (isEmptyTextBlock(editor, block)) {
25186
25218
  return 0;
25187
25219
  }
@@ -25190,6 +25222,7 @@ var __publicField = (obj, key, value) => {
25190
25222
  return offset + 1;
25191
25223
  }
25192
25224
  let start = offset;
25225
+ let find = offsetInfo.charType;
25193
25226
  if (offsetInfo.charType === "space") {
25194
25227
  const startInfo2 = findAfterOffsetNotType(editor, block, start, "space");
25195
25228
  if (!startInfo2) {
@@ -25202,16 +25235,17 @@ var __publicField = (obj, key, value) => {
25202
25235
  return startInfo2.offset;
25203
25236
  }
25204
25237
  start = startInfo2.offset;
25238
+ find = getOffsetInfoAfter(editor, block, start).charType;
25205
25239
  }
25206
- const startInfo = findAfterOffsetNotType(editor, block, start, "text");
25240
+ const startInfo = findAfterOffsetNotType(editor, block, start, find);
25207
25241
  if (!startInfo)
25208
25242
  return getBlockTextLength$6(editor, block);
25209
25243
  return startInfo.offset;
25210
25244
  }
25211
- const logger$3U = getLogger("text-box");
25245
+ const logger$3V = getLogger("text-box");
25212
25246
  function updateBoxContent$8(editor, boxElement, boxContent, boxData) {
25213
- assert(logger$3U, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
25214
- assert(logger$3U, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
25247
+ assert(logger$3V, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
25248
+ assert(logger$3V, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
25215
25249
  createElement("span", [], boxContent, boxData.text);
25216
25250
  }
25217
25251
  function convertTo$j(editor, boxData, doc2, type) {
@@ -25245,7 +25279,7 @@ var __publicField = (obj, key, value) => {
25245
25279
  updateBoxContent: updateBoxContent$7,
25246
25280
  convertTo: convertTo$i
25247
25281
  };
25248
- const logger$3T = getLogger("editor-boxes");
25282
+ const logger$3U = getLogger("editor-boxes");
25249
25283
  class EditorBoxes {
25250
25284
  constructor(editor) {
25251
25285
  __publicField(this, "boxes", /* @__PURE__ */ new Map());
@@ -25254,12 +25288,12 @@ var __publicField = (obj, key, value) => {
25254
25288
  registerBoxClass(boxClass) {
25255
25289
  const type = boxClass.boxType;
25256
25290
  const exists = this.boxes.get(type);
25257
- assert(logger$3T, !exists, `duplicated box type: ${type}`);
25291
+ assert(logger$3U, !exists, `duplicated box type: ${type}`);
25258
25292
  this.boxes.set(type, boxClass);
25259
25293
  }
25260
25294
  getBoxClass(type) {
25261
25295
  const exists = this.boxes.get(type);
25262
- assert(logger$3T, exists, `unknown box type: ${type}`);
25296
+ assert(logger$3U, exists, `unknown box type: ${type}`);
25263
25297
  return exists;
25264
25298
  }
25265
25299
  createBox(blockContent, box) {
@@ -25624,7 +25658,7 @@ var __publicField = (obj, key, value) => {
25624
25658
  return { classes, attributes: newAttributes, styles: newStyles };
25625
25659
  }
25626
25660
  }
25627
- const logger$3S = getLogger("editor-insertion");
25661
+ const logger$3T = getLogger("editor-insertion");
25628
25662
  class EditorInsertions {
25629
25663
  constructor(editor) {
25630
25664
  __publicField(this, "insertions", /* @__PURE__ */ new Map());
@@ -25633,12 +25667,12 @@ var __publicField = (obj, key, value) => {
25633
25667
  registerInsertionClass(insertionClass) {
25634
25668
  const type = insertionClass.insertionType;
25635
25669
  const exists = this.insertions.get(type);
25636
- assert(logger$3S, !exists, `duplicated insertion type: ${type}`);
25670
+ assert(logger$3T, !exists, `duplicated insertion type: ${type}`);
25637
25671
  this.insertions.set(type, insertionClass);
25638
25672
  }
25639
25673
  getInsertionClass(type) {
25640
25674
  const exists = this.insertions.get(type);
25641
- assert(logger$3S, exists, `unknown insertion type: ${type}`);
25675
+ assert(logger$3T, exists, `unknown insertion type: ${type}`);
25642
25676
  return exists;
25643
25677
  }
25644
25678
  createInsertionElement(type, id, attributes) {
@@ -25758,7 +25792,7 @@ var __publicField = (obj, key, value) => {
25758
25792
  };
25759
25793
  }
25760
25794
  }
25761
- const logger$3R = getLogger("editor-input");
25795
+ const logger$3S = getLogger("editor-input");
25762
25796
  class EditorInput$1 {
25763
25797
  constructor(editor, callbacks) {
25764
25798
  __publicField(this, "editor");
@@ -25880,7 +25914,7 @@ var __publicField = (obj, key, value) => {
25880
25914
  return;
25881
25915
  }
25882
25916
  this.callbacks.onCut(event);
25883
- logger$3R.debug("on cut");
25917
+ logger$3S.debug("on cut");
25884
25918
  });
25885
25919
  __publicField(this, "handlePaste", (event) => {
25886
25920
  if (event.isTrusted) {
@@ -25995,11 +26029,11 @@ var __publicField = (obj, key, value) => {
25995
26029
  this.callbacks.removeHandler(handler);
25996
26030
  }
25997
26031
  defaultInsertText(editor, containerId, blockIndex, offset, text2) {
25998
- assert(logger$3R, editor === this.editor, "invalid editor");
26032
+ assert(logger$3S, editor === this.editor, "invalid editor");
25999
26033
  this.callbacks.defaultInsertText(editor, containerId, blockIndex, offset, text2);
26000
26034
  }
26001
26035
  defaultHandleKeydown(editor, event) {
26002
- assert(logger$3R, editor === this.editor, "invalid editor");
26036
+ assert(logger$3S, editor === this.editor, "invalid editor");
26003
26037
  return this.callbacks.defaultHandleKeydown(editor, event);
26004
26038
  }
26005
26039
  forEach(callback) {
@@ -26024,7 +26058,7 @@ var __publicField = (obj, key, value) => {
26024
26058
  input2.style.left = `${x / scale}px`;
26025
26059
  input2.style.top = `${y / scale}px`;
26026
26060
  }
26027
- const logger$3Q = getLogger("editor-caret");
26061
+ const logger$3R = getLogger("editor-caret");
26028
26062
  function getFirefoxVersion() {
26029
26063
  const userAgent = window.navigator.userAgent;
26030
26064
  const match = userAgent.match(/Firefox\/(\d+)\./);
@@ -26087,11 +26121,11 @@ var __publicField = (obj, key, value) => {
26087
26121
  return;
26088
26122
  }
26089
26123
  const { range } = this.editor.selection;
26090
- assert(logger$3Q, range.isCollapsed, "range is not collapsed");
26124
+ assert(logger$3R, range.isCollapsed, "range is not collapsed");
26091
26125
  const pos = range.start;
26092
- assert(logger$3Q, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
26126
+ assert(logger$3R, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
26093
26127
  const block = this.editor.getBlockById(pos.blockId);
26094
- assert(logger$3Q, isTextKindBlock(this.editor, block), "only text kind block can has caret");
26128
+ assert(logger$3R, isTextKindBlock(this.editor, block), "only text kind block can has caret");
26095
26129
  let rect;
26096
26130
  const compositionSpan = block.querySelector("span.inputting-insertion");
26097
26131
  if (compositionSpan) {
@@ -26129,7 +26163,7 @@ var __publicField = (obj, key, value) => {
26129
26163
  clearAllSelection(editor);
26130
26164
  editor.selection.range.getSelectedBlocks().forEach((s) => updateBlockSelection(editor, s.block, s.start, s.end));
26131
26165
  }
26132
- const logger$3P = getLogger("editor-dom");
26166
+ const logger$3Q = getLogger("editor-dom");
26133
26167
  function editorGetClientHeight(editor) {
26134
26168
  const scrollContainer = getScrollContainer$1(editor.rootContainer);
26135
26169
  return scrollContainer.clientHeight;
@@ -26217,7 +26251,7 @@ var __publicField = (obj, key, value) => {
26217
26251
  }
26218
26252
  function editorScrollIntoView(editor) {
26219
26253
  if (!isElementVisible(editor.rootContainer)) {
26220
- logger$3P.warn("editorScrollIntoView: editor is not visible");
26254
+ logger$3Q.warn("editorScrollIntoView: editor is not visible");
26221
26255
  return;
26222
26256
  }
26223
26257
  const rootClientRect = editor.rootContainer.getBoundingClientRect();
@@ -26282,7 +26316,7 @@ var __publicField = (obj, key, value) => {
26282
26316
  const { start, end } = range;
26283
26317
  return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
26284
26318
  }
26285
- const logger$3O = getLogger("range-in-block");
26319
+ const logger$3P = getLogger("range-in-block");
26286
26320
  function rangeInBlock(block, range) {
26287
26321
  const editor = range.getEditor();
26288
26322
  const start = editor.getBlockById(range.start.blockId);
@@ -26303,16 +26337,16 @@ var __publicField = (obj, key, value) => {
26303
26337
  while (prevBlock && !blocks.has(getBlockId(prevBlock))) {
26304
26338
  prevBlock = getPrevVisibleBlock(prevBlock);
26305
26339
  }
26306
- assert(logger$3O, prevBlock, "no prev block while deleting a block");
26340
+ assert(logger$3P, prevBlock, "no prev block while deleting a block");
26307
26341
  newRange = createBlockSimpleRange(editor, prevBlock, getBlockTextLength$6(editor, prevBlock));
26308
26342
  } else {
26309
26343
  const nextBlock = getNextVisibleBlock(block);
26310
- assert(logger$3O, nextBlock, "no prev and next block while deleting a block");
26344
+ assert(logger$3P, nextBlock, "no prev and next block while deleting a block");
26311
26345
  newRange = createBlockSimpleRange(editor, nextBlock, 0);
26312
26346
  }
26313
26347
  return newRange;
26314
26348
  }
26315
- const logger$3N = getLogger("block-to-html");
26349
+ const logger$3O = getLogger("block-to-html");
26316
26350
  function blockToHtml(editor, blockData, doc2, path) {
26317
26351
  const blockClass = getBlockClassByType(editor, blockData.type);
26318
26352
  if (blockClass.convertTo) {
@@ -26321,15 +26355,15 @@ var __publicField = (obj, key, value) => {
26321
26355
  if (blockClass.blockKind !== "text") {
26322
26356
  return `[${blockData.type}]`;
26323
26357
  }
26324
- assert(logger$3N, blockData.text, "no text");
26358
+ assert(logger$3O, blockData.text, "no text");
26325
26359
  const plainText = toPlainText(blockData.text);
26326
26360
  return `<div>${escapeHtmlText(plainText)}</div>`;
26327
26361
  }
26328
- const logger$3M = getLogger("block-to-text");
26362
+ const logger$3N = getLogger("block-to-text");
26329
26363
  function textBlockToText(editor, ops, doc2) {
26330
26364
  let text2 = "";
26331
26365
  ops.forEach((op) => {
26332
- assert(logger$3M, typeof op.insert === "string", "invalid op");
26366
+ assert(logger$3N, typeof op.insert === "string", "invalid op");
26333
26367
  if (op.attributes && op.attributes.box === true) {
26334
26368
  const box = op.attributes;
26335
26369
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -26355,7 +26389,7 @@ var __publicField = (obj, key, value) => {
26355
26389
  if (blockClass.blockKind !== "text") {
26356
26390
  return `[${blockData.type}]`;
26357
26391
  }
26358
- assert(logger$3M, blockData.text, "no text");
26392
+ assert(logger$3N, blockData.text, "no text");
26359
26393
  const plainText = textBlockToText(editor, blockData.text, doc2);
26360
26394
  return plainText;
26361
26395
  }
@@ -26388,11 +26422,11 @@ var __publicField = (obj, key, value) => {
26388
26422
  const markdown = lines.join("\n");
26389
26423
  return markdown;
26390
26424
  }
26391
- const logger$3L = getLogger("get-text-position");
26425
+ const logger$3M = getLogger("get-text-position");
26392
26426
  function editorGetTextPosition(editor, insertPos) {
26393
26427
  const pos = insertPos != null ? insertPos : editor.selection.range.start;
26394
26428
  if (!(pos instanceof EditorSimpleBlockPosition)) {
26395
- assert(logger$3L, false, `invalid insert pos type: ${typeof pos}`);
26429
+ assert(logger$3M, false, `invalid insert pos type: ${typeof pos}`);
26396
26430
  }
26397
26431
  const { blockId } = pos;
26398
26432
  const block = editor.getBlockById(blockId);
@@ -26480,14 +26514,14 @@ var __publicField = (obj, key, value) => {
26480
26514
  return attributes;
26481
26515
  }
26482
26516
  }
26483
- const logger$3K = getLogger("insert-text");
26517
+ const logger$3L = getLogger("insert-text");
26484
26518
  function getTextAttributes(editor, containerId, blockIndex, offset) {
26485
26519
  var _a, _b;
26486
26520
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26487
- assert(logger$3K, blockData, "no block data");
26488
- assert(logger$3K, blockData.text, "no block text");
26521
+ assert(logger$3L, blockData, "no block data");
26522
+ assert(logger$3L, blockData.text, "no block text");
26489
26523
  if (getTextLength(blockData.text) === 0) {
26490
- assert(logger$3K, offset === 0, "invalid text offset");
26524
+ assert(logger$3L, offset === 0, "invalid text offset");
26491
26525
  return BlockAttributesHandler.get(editor).getEmptyBlockTextAttributes(blockData.id);
26492
26526
  }
26493
26527
  if (offset === 0) {
@@ -26534,7 +26568,7 @@ var __publicField = (obj, key, value) => {
26534
26568
  }
26535
26569
  for (let i = 0; i < text2.length; i++) {
26536
26570
  const op = text2[i];
26537
- assert(logger$3K, typeof op.insert === "string", "invalid text op, no insert");
26571
+ assert(logger$3L, typeof op.insert === "string", "invalid text op, no insert");
26538
26572
  const endPos = pos + getOpLength(op);
26539
26573
  if (endPos === start) {
26540
26574
  return false;
@@ -26548,8 +26582,8 @@ var __publicField = (obj, key, value) => {
26548
26582
  }
26549
26583
  function editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset) {
26550
26584
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26551
- assert(logger$3K, blockData, "no block data");
26552
- assert(logger$3K, blockData.text, "no block text");
26585
+ assert(logger$3L, blockData, "no block data");
26586
+ assert(logger$3L, blockData.text, "no block text");
26553
26587
  const attributes = getTextAttributes(editor, containerId, blockIndex, offset);
26554
26588
  if (attributes && Object.keys(attributes).includes("link")) {
26555
26589
  const inOp = checkRangeInOp(blockData.text, offset);
@@ -26568,21 +26602,21 @@ var __publicField = (obj, key, value) => {
26568
26602
  const { containerId, blockIndex, offset } = editorGetTextPosition(editor);
26569
26603
  editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset);
26570
26604
  }
26571
- const logger$3J = getLogger("update-composition-text");
26605
+ const logger$3K = getLogger("update-composition-text");
26572
26606
  function editorUpdateCompositionText(editor) {
26573
26607
  const pos = editor.selection.range.start;
26574
26608
  if (!(pos instanceof EditorSimpleBlockPosition)) {
26575
- assert(logger$3J, false, `invalid insert pos type: ${typeof pos}`);
26609
+ assert(logger$3K, false, `invalid insert pos type: ${typeof pos}`);
26576
26610
  }
26577
26611
  const { blockId } = pos;
26578
26612
  const block = editor.getBlockById(blockId);
26579
- assert(logger$3J, isTextKindBlock(editor, block), "not a text kind block");
26613
+ assert(logger$3K, isTextKindBlock(editor, block), "not a text kind block");
26580
26614
  const container = getParentContainer(block);
26581
26615
  const containerId = getContainerId(container);
26582
26616
  const blockIndex = getBlockIndex(block);
26583
26617
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26584
- assert(logger$3J, blockData, "no block data in doc");
26585
- assert(logger$3J, blockData.text, "no text data in text block");
26618
+ assert(logger$3K, blockData, "no block data in doc");
26619
+ assert(logger$3K, blockData.text, "no text data in text block");
26586
26620
  const blockContent = getBlockContent(block);
26587
26621
  updateBlockContent$1(editor, getBlockPath(block), blockId, blockContent, blockData.text);
26588
26622
  }
@@ -26594,25 +26628,25 @@ var __publicField = (obj, key, value) => {
26594
26628
  const block = editor.getBlockById(blockData.id);
26595
26629
  return block;
26596
26630
  }
26597
- const logger$3I = getLogger("delete-block-text");
26631
+ const logger$3J = getLogger("delete-block-text");
26598
26632
  function editorDeleteBlockText(editor, block, offset, count, options) {
26599
26633
  if (!editor.isBlockWritable(block)) {
26600
- logger$3I.error("block is not writable");
26634
+ logger$3J.error("block is not writable");
26601
26635
  return 0;
26602
26636
  }
26603
- assert(logger$3I, isTextKindBlock(editor, block), "block is not a text kind block");
26637
+ assert(logger$3J, isTextKindBlock(editor, block), "block is not a text kind block");
26604
26638
  const container = getParentContainer(block);
26605
26639
  const containerId = getContainerId(container);
26606
26640
  const blockIndex = getBlockIndex(block);
26607
26641
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26608
- assert(logger$3I, blockData, "no block data in doc");
26609
- assert(logger$3I, blockData.text, "no text data in text block");
26642
+ assert(logger$3J, blockData, "no block data in doc");
26643
+ assert(logger$3J, blockData.text, "no text data in text block");
26610
26644
  let from = offset;
26611
26645
  if (!isValidOffset(block, offset)) {
26612
26646
  from = getPrevValidOffset(block, from);
26613
26647
  }
26614
26648
  let to = offset + count;
26615
- assert(logger$3I, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
26649
+ assert(logger$3J, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
26616
26650
  if (!isValidOffset(block, to)) {
26617
26651
  to = getNextValidOffset(block, to);
26618
26652
  }
@@ -26621,7 +26655,7 @@ var __publicField = (obj, key, value) => {
26621
26655
  editor.doc.localUpdateBlockText(containerId, blockIndex, actions2, options);
26622
26656
  return deleteCount;
26623
26657
  }
26624
- const logger$3H = getLogger("break-text-block");
26658
+ const logger$3I = getLogger("break-text-block");
26625
26659
  function copyBlockAttributes(editor, block) {
26626
26660
  const blockData = editor.getBlockData(block);
26627
26661
  const quoted = blockData.quoted;
@@ -26633,8 +26667,8 @@ var __publicField = (obj, key, value) => {
26633
26667
  return {};
26634
26668
  }
26635
26669
  function editorBreakTextBlock(editor, block, offset, options) {
26636
- assert(logger$3H, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
26637
- assert(logger$3H, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
26670
+ assert(logger$3I, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
26671
+ assert(logger$3I, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
26638
26672
  const container = getParentContainer(block);
26639
26673
  const containerId = getContainerId(container);
26640
26674
  const blockIndex = getBlockIndex(block);
@@ -26664,7 +26698,7 @@ var __publicField = (obj, key, value) => {
26664
26698
  };
26665
26699
  }
26666
26700
  }
26667
- assert(logger$3H, isValidOffset(block, offset), "not a valid offset");
26701
+ assert(logger$3I, isValidOffset(block, offset), "not a valid offset");
26668
26702
  const text2 = editorGetBlockText(editor, block);
26669
26703
  const { right } = splitText(text2, offset);
26670
26704
  const rightLength = getTextLength(right);
@@ -26690,12 +26724,12 @@ var __publicField = (obj, key, value) => {
26690
26724
  newBlock
26691
26725
  };
26692
26726
  }
26693
- const logger$3G = getLogger("prepare-insert-new-block");
26727
+ const logger$3H = getLogger("prepare-insert-new-block");
26694
26728
  function editorPrepareInsertNewBlock(editor, containerId, blockIndex) {
26695
26729
  if (containerId && blockIndex !== void 0 && blockIndex !== null) {
26696
26730
  const container = editor.getContainerById(containerId);
26697
26731
  const blocks = getChildBlocks(container);
26698
- assert(logger$3G, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
26732
+ assert(logger$3H, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
26699
26733
  return {
26700
26734
  containerId,
26701
26735
  blockIndex
@@ -26729,15 +26763,15 @@ var __publicField = (obj, key, value) => {
26729
26763
  blockIndex: getBlockIndex(newBlock)
26730
26764
  };
26731
26765
  }
26732
- const logger$3F = getLogger("auto-insert-block");
26766
+ const logger$3G = getLogger("auto-insert-block");
26733
26767
  function editorAutoInsertBlock(editor, blockData, containerId, blockIndex, newRange, insertBlockOptions) {
26734
26768
  const result = editorPrepareInsertNewBlock(editor, containerId, blockIndex);
26735
- assert(logger$3F, result, `not an valid insert position: ${editor.selection.range}`);
26769
+ assert(logger$3G, result, `not an valid insert position: ${editor.selection.range}`);
26736
26770
  const defaultPos = { blockId: blockData.id, offset: 0 };
26737
26771
  const defaultRange = { anchor: defaultPos, focus: defaultPos };
26738
26772
  return editorInsertBlock(editor, result.containerId, result.blockIndex, blockData, newRange != null ? newRange : defaultRange, insertBlockOptions);
26739
26773
  }
26740
- const logger$3E = getLogger("delete-block");
26774
+ const logger$3F = getLogger("delete-block");
26741
26775
  function getAllChildContainers(editor, blockData, containerIds) {
26742
26776
  if (blockData.children) {
26743
26777
  containerIds.push(...blockData.children);
@@ -26754,7 +26788,7 @@ var __publicField = (obj, key, value) => {
26754
26788
  const containerId = getContainerId(container);
26755
26789
  const blockIndex = getBlockIndex(block);
26756
26790
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
26757
- assert(logger$3E, blockData, "no block data in doc");
26791
+ assert(logger$3F, blockData, "no block data in doc");
26758
26792
  editor.doc.localDeleteBlock(containerId, blockIndex, createEditorSelectionRange(editor, { anchor: newRange.start, focus: newRange.end }));
26759
26793
  return blockData;
26760
26794
  }
@@ -26800,15 +26834,15 @@ var __publicField = (obj, key, value) => {
26800
26834
  });
26801
26835
  editor.doc.localDeleteChildContainers(containerIds);
26802
26836
  }
26803
- const logger$3D = getLogger("merge-text-block");
26837
+ const logger$3E = getLogger("merge-text-block");
26804
26838
  function editorMergeTextBlock(editor, block1, block2) {
26805
- assert(logger$3D, isTextKindBlock(editor, block1), "only text block can be merged");
26806
- assert(logger$3D, isTextKindBlock(editor, block2), "only text block can be merged");
26839
+ assert(logger$3E, isTextKindBlock(editor, block1), "only text block can be merged");
26840
+ assert(logger$3E, isTextKindBlock(editor, block2), "only text block can be merged");
26807
26841
  const data1 = editorGetBlockData(editor, block1);
26808
26842
  const data2 = editorGetBlockData(editor, block2);
26809
26843
  const text1 = data1.text;
26810
26844
  const text2 = data2.text;
26811
- assert(logger$3D, text1 && text2, "block data has no text");
26845
+ assert(logger$3E, text1 && text2, "block data has no text");
26812
26846
  const container = getParentContainer(block1);
26813
26847
  const containerId = getContainerId(container);
26814
26848
  const blockIndex = getBlockIndex(block1);
@@ -26818,15 +26852,15 @@ var __publicField = (obj, key, value) => {
26818
26852
  editorDeleteBlock(editor, block2, newRange);
26819
26853
  return block;
26820
26854
  }
26821
- const logger$3C = getLogger("clear-selected-contents");
26855
+ const logger$3D = getLogger("clear-selected-contents");
26822
26856
  function deleteTextBlockSelection(editor, selectedBlock) {
26823
- assert(logger$3C, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
26857
+ assert(logger$3D, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
26824
26858
  const { start, end } = selectedBlock;
26825
- assert(logger$3C, start.isSimple(), "not a simple block position");
26826
- assert(logger$3C, end.isSimple(), "not a simple block position");
26859
+ assert(logger$3D, start.isSimple(), "not a simple block position");
26860
+ assert(logger$3D, end.isSimple(), "not a simple block position");
26827
26861
  const startOffset = start.offset;
26828
26862
  const endOffset = end.offset;
26829
- assert(logger$3C, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
26863
+ assert(logger$3D, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
26830
26864
  if (startOffset === endOffset) {
26831
26865
  return;
26832
26866
  }
@@ -26851,7 +26885,7 @@ var __publicField = (obj, key, value) => {
26851
26885
  return;
26852
26886
  }
26853
26887
  if (isEmbedBlock(block) || start.isSimple()) {
26854
- assert(logger$3C, end.isSimple(), "invalid range");
26888
+ assert(logger$3D, end.isSimple(), "invalid range");
26855
26889
  const container = getParentContainer(block);
26856
26890
  const blockIndex = getBlockIndex(block);
26857
26891
  const newBlock = editor.insertTextBlock("", getContainerId(container), blockIndex);
@@ -26859,8 +26893,8 @@ var __publicField = (obj, key, value) => {
26859
26893
  editor.deleteBlock(block);
26860
26894
  return;
26861
26895
  }
26862
- assert(logger$3C, isComplexKindBlock(editor, block), "invalid block kind");
26863
- assert(logger$3C, !start.isSimple() && !end.isSimple(), "invalid range");
26896
+ assert(logger$3D, isComplexKindBlock(editor, block), "invalid block kind");
26897
+ assert(logger$3D, !start.isSimple() && !end.isSimple(), "invalid range");
26864
26898
  complexBlockGetSelectedContainers(editor, block, start, end);
26865
26899
  const containers = editor.selection.range.getSelectedContainers();
26866
26900
  containers.forEach((container, index2) => {
@@ -26877,7 +26911,7 @@ var __publicField = (obj, key, value) => {
26877
26911
  return;
26878
26912
  }
26879
26913
  const selectedBlocks = range.getSelectedBlocks();
26880
- assert(logger$3C, selectedBlocks.length > 0, "no selected block");
26914
+ assert(logger$3D, selectedBlocks.length > 0, "no selected block");
26881
26915
  if (selectedBlocks.length === 1) {
26882
26916
  clearOneBlock(editor, selectedBlocks[0]);
26883
26917
  return;
@@ -26885,7 +26919,7 @@ var __publicField = (obj, key, value) => {
26885
26919
  const firstSelectedBlock = selectedBlocks[0];
26886
26920
  const firstBlock = firstSelectedBlock.block;
26887
26921
  const container = getParentContainer(firstBlock);
26888
- assert(logger$3C, selectedBlocks.length > 1, "no selected block");
26922
+ assert(logger$3D, selectedBlocks.length > 1, "no selected block");
26889
26923
  const lastSelectedBlock = selectedBlocks[selectedBlocks.length - 1];
26890
26924
  const lastBlock2 = lastSelectedBlock.block;
26891
26925
  if (isTextKindBlock(editor, firstBlock)) {
@@ -26915,7 +26949,7 @@ var __publicField = (obj, key, value) => {
26915
26949
  }
26916
26950
  const prevBlock = getPrevBlock(firstBlock);
26917
26951
  const nextBlock = getNextBlock(lastBlock2);
26918
- assert(logger$3C, prevBlock || nextBlock, "no prev or next block");
26952
+ assert(logger$3D, prevBlock || nextBlock, "no prev or next block");
26919
26953
  selectedBlocks.forEach((selectedBlock) => editor.deleteBlock(selectedBlock.block));
26920
26954
  }
26921
26955
  function editorClearSelectedContents(editor, selectionRange) {
@@ -26934,7 +26968,7 @@ var __publicField = (obj, key, value) => {
26934
26968
  editor.emit("afterClearSelection", editor);
26935
26969
  });
26936
26970
  }
26937
- const logger$3B = getLogger("core");
26971
+ const logger$3C = getLogger("core");
26938
26972
  function editorUpdateBlockText(editor, block, ops, options) {
26939
26973
  const container = getParentContainer(block);
26940
26974
  const containerId = getContainerId(container);
@@ -26947,7 +26981,7 @@ var __publicField = (obj, key, value) => {
26947
26981
  }
26948
26982
  function editorSetBlockText(editor, block, newText, options) {
26949
26983
  if (!editor.isBlockWritable(block)) {
26950
- logger$3B.error("block is not writable");
26984
+ logger$3C.error("block is not writable");
26951
26985
  return;
26952
26986
  }
26953
26987
  const oldText = editor.getBlockText(block);
@@ -26960,7 +26994,7 @@ var __publicField = (obj, key, value) => {
26960
26994
  const ops = RichText.diff(oldText, newText);
26961
26995
  return editorUpdateBlockText(editor, block, ops);
26962
26996
  }
26963
- const logger$3A = getLogger("update-block-data");
26997
+ const logger$3B = getLogger("update-block-data");
26964
26998
  function editorUpdateBlockData(editor, block, data2, newRange, options) {
26965
26999
  const container = getParentContainer(block);
26966
27000
  const containerId = getContainerId(container);
@@ -26977,17 +27011,17 @@ var __publicField = (obj, key, value) => {
26977
27011
  if (oldKey === "id" || oldKey === "type" || oldKey === "text") {
26978
27012
  return;
26979
27013
  }
26980
- logger$3A.debug(`delete key: ${oldKey}`);
27014
+ logger$3B.debug(`delete key: ${oldKey}`);
26981
27015
  delta.delete.push(oldKey);
26982
27016
  }
26983
27017
  });
26984
27018
  const entries = Object.entries(data2);
26985
27019
  entries.forEach(([key, value]) => {
26986
- assert(logger$3A, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
27020
+ assert(logger$3B, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
26987
27021
  const oldValue = oldData[key];
26988
27022
  if (value === null || value === void 0) {
26989
27023
  if (oldValue !== null && oldValue !== void 0) {
26990
- logger$3A.debug(`delete key: ${key}`);
27024
+ logger$3B.debug(`delete key: ${key}`);
26991
27025
  delta.delete.push(key);
26992
27026
  }
26993
27027
  return;
@@ -27005,10 +27039,10 @@ var __publicField = (obj, key, value) => {
27005
27039
  }
27006
27040
  }
27007
27041
  if (oldKeys.has(key)) {
27008
- logger$3A.debug(`replace key: ${key}`);
27042
+ logger$3B.debug(`replace key: ${key}`);
27009
27043
  delta.delete.push(key);
27010
27044
  } else {
27011
- logger$3A.debug(`insert key: ${key}`);
27045
+ logger$3B.debug(`insert key: ${key}`);
27012
27046
  }
27013
27047
  delta.insert[key] = value;
27014
27048
  });
@@ -27053,13 +27087,13 @@ var __publicField = (obj, key, value) => {
27053
27087
  comments: {}
27054
27088
  };
27055
27089
  }
27056
- const logger$3z = getLogger("clone-block");
27090
+ const logger$3A = getLogger("clone-block");
27057
27091
  function cloneBlock(editorBlocks, oldDoc, data2, info) {
27058
27092
  var _a;
27059
27093
  const blockClass = editorBlocks.getBlockClass(data2.type);
27060
27094
  if (blockClass.blockToDoc) {
27061
27095
  return blockClass.blockToDoc(oldDoc, data2, (oldDoc2, childBlock) => {
27062
- assert(logger$3z, data2 !== childBlock, "invalid child block");
27096
+ assert(logger$3A, data2 !== childBlock, "invalid child block");
27063
27097
  return cloneBlock(editorBlocks, oldDoc2, data2, info);
27064
27098
  }, info);
27065
27099
  }
@@ -27072,7 +27106,7 @@ var __publicField = (obj, key, value) => {
27072
27106
  }
27073
27107
  const newChildContainerId = genId();
27074
27108
  const childBlocks = oldDoc.blocks[oldChildContainerId];
27075
- assert(logger$3z, Array.isArray(childBlocks), "invalid child blocks");
27109
+ assert(logger$3A, Array.isArray(childBlocks), "invalid child blocks");
27076
27110
  const newDocs = childBlocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
27077
27111
  const newDoc = mergeDocs(newDocs);
27078
27112
  const { root: root2, ...childContainersData } = newDoc.blocks;
@@ -27101,7 +27135,7 @@ var __publicField = (obj, key, value) => {
27101
27135
  if (key.startsWith(prefix1)) {
27102
27136
  const keyContent = key.substring(prefix1.length);
27103
27137
  const newKey = `${newContainerId}/${keyContent}`;
27104
- logger$3z.debug(`replace key: ${key} -> ${newKey}`);
27138
+ logger$3A.debug(`replace key: ${key} -> ${newKey}`);
27105
27139
  return newKey;
27106
27140
  }
27107
27141
  }
@@ -27110,7 +27144,7 @@ var __publicField = (obj, key, value) => {
27110
27144
  if (key.startsWith(prefix2)) {
27111
27145
  const keyContent = key.substring(prefix2.length);
27112
27146
  const newKey = `${newContainerId}_${keyContent}`;
27113
- logger$3z.debug(`replace key: ${key} -> ${newKey}`);
27147
+ logger$3A.debug(`replace key: ${key} -> ${newKey}`);
27114
27148
  return newKey;
27115
27149
  }
27116
27150
  }
@@ -27140,7 +27174,7 @@ var __publicField = (obj, key, value) => {
27140
27174
  }
27141
27175
  function cloneChildContainer(editorBlocks, oldDoc, containerId, info) {
27142
27176
  const blocks = oldDoc.blocks[containerId];
27143
- assert(logger$3z, Array.isArray(blocks), "invalid child blocks");
27177
+ assert(logger$3A, Array.isArray(blocks), "invalid child blocks");
27144
27178
  const newDocs = blocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
27145
27179
  const newDoc = mergeDocs(newDocs);
27146
27180
  return newDoc;
@@ -27149,10 +27183,10 @@ var __publicField = (obj, key, value) => {
27149
27183
  const docs = doc2.blocks.root.map((b) => cloneBlock(editor.editorBlocks, doc2, b, info));
27150
27184
  return cloneDeep__default.default(mergeDocs(docs));
27151
27185
  }
27152
- const logger$3y = getLogger("insert-doc");
27186
+ const logger$3z = getLogger("insert-doc");
27153
27187
  function editorInsertDoc(editor, block, offset, insertedDoc, cloneDocResult) {
27154
27188
  if (isComplexKindBlock(editor, block)) {
27155
- logger$3y.warn("failed to insert doc into a complex block");
27189
+ logger$3z.warn("failed to insert doc into a complex block");
27156
27190
  return;
27157
27191
  }
27158
27192
  const doc2 = cloneDoc(editor, insertedDoc, cloneDocResult);
@@ -27186,7 +27220,7 @@ var __publicField = (obj, key, value) => {
27186
27220
  }
27187
27221
  return;
27188
27222
  }
27189
- assert(logger$3y, isTextKindBlock(editor, block), "not a text block");
27223
+ assert(logger$3z, isTextKindBlock(editor, block), "not a text block");
27190
27224
  if (isEmptyTextBlock(editor, block)) {
27191
27225
  const blockIndex2 = getBlockIndex(block);
27192
27226
  let lastBlock22;
@@ -27318,11 +27352,11 @@ var __publicField = (obj, key, value) => {
27318
27352
  editor.deleteBlock(block);
27319
27353
  }
27320
27354
  }
27321
- const logger$3x = getLogger("add-text-attribute");
27355
+ const logger$3y = getLogger("add-text-attribute");
27322
27356
  function editorRemoveTextAttribute(editor, block, range, attributeName) {
27323
27357
  const { start, end } = range;
27324
- assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27325
- assert(logger$3x, attributeName, "invalid attribute name");
27358
+ assert(logger$3y, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27359
+ assert(logger$3y, attributeName, "invalid attribute name");
27326
27360
  const oldText = editor.getBlockText(block);
27327
27361
  const newText = rangeRemoveAttribute(start.offset, end.offset - start.offset, oldText, attributeName, void 0, { ignoreValue: true });
27328
27362
  editor.setBlockText(block, newText);
@@ -27330,8 +27364,8 @@ var __publicField = (obj, key, value) => {
27330
27364
  }
27331
27365
  function editorAddTextAttribute(editor, block, range, attributeName, value) {
27332
27366
  const { start, end } = range;
27333
- assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27334
- 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");
27335
27369
  const oldText = editor.getBlockText(block);
27336
27370
  const newText = rangeAddAttribute(start.offset, end.offset - start.offset, oldText, attributeName, value);
27337
27371
  editor.setBlockText(block, newText);
@@ -27339,7 +27373,7 @@ var __publicField = (obj, key, value) => {
27339
27373
  }
27340
27374
  function editorSetTextColor(editor, block, range, type, value) {
27341
27375
  const { start, end } = range;
27342
- assert(logger$3x, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27376
+ assert(logger$3y, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
27343
27377
  const oldText = editor.getBlockText(block);
27344
27378
  const newText = rangeSetTextColor(start.offset, end.offset - start.offset, oldText, type, value);
27345
27379
  editor.setBlockText(block, newText);
@@ -27428,10 +27462,10 @@ var __publicField = (obj, key, value) => {
27428
27462
  });
27429
27463
  return [color, backgroundColor];
27430
27464
  }
27431
- const logger$3w = getLogger("move-complex-block-position");
27465
+ const logger$3x = getLogger("move-complex-block-position");
27432
27466
  function moveComplexBlockPosition(editor, old, type) {
27433
27467
  const block = editor.getBlockById(old.blockId);
27434
- assert(logger$3w, isComplexKindBlock(editor, block), "is not a complex block");
27468
+ assert(logger$3x, isComplexKindBlock(editor, block), "is not a complex block");
27435
27469
  const blockClass = getComplexBlockClass(editor, block);
27436
27470
  const focusedContainer = editor.getContainerById(old.childContainerId);
27437
27471
  const nextContainer = blockClass.getNextContainer(editor, block, focusedContainer, type, { noWrap: true });
@@ -27440,24 +27474,24 @@ var __publicField = (obj, key, value) => {
27440
27474
  }
27441
27475
  return createComplexBlockPosition(block, getContainerId(nextContainer));
27442
27476
  }
27443
- const logger$3v = getLogger("move-simple-block-position");
27477
+ const logger$3w = getLogger("move-simple-block-position");
27444
27478
  function getFirstChildBlockInComplexBlock(editor, complexBlock) {
27445
27479
  const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
27446
27480
  if (containers.length === 0) {
27447
- logger$3v.warn("complex block has not any child container, not loaded?");
27481
+ logger$3w.warn("complex block has not any child container, not loaded?");
27448
27482
  return null;
27449
27483
  }
27450
- assert(logger$3v, containers.length > 0, "complex block has not any child container");
27484
+ assert(logger$3w, containers.length > 0, "complex block has not any child container");
27451
27485
  const container = containers[0];
27452
27486
  return getFirstChildBlock(container);
27453
27487
  }
27454
27488
  function getLastChildBlockInComplexBlock(editor, complexBlock) {
27455
27489
  const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
27456
27490
  if (containers.length === 0) {
27457
- logger$3v.warn("complex block has not any child container, not loaded?");
27491
+ logger$3w.warn("complex block has not any child container, not loaded?");
27458
27492
  return null;
27459
27493
  }
27460
- assert(logger$3v, containers.length > 0, "complex block has not any child container");
27494
+ assert(logger$3w, containers.length > 0, "complex block has not any child container");
27461
27495
  const container = containers[containers.length - 1];
27462
27496
  return getLastChildBlock(container);
27463
27497
  }
@@ -27502,8 +27536,8 @@ var __publicField = (obj, key, value) => {
27502
27536
  return null;
27503
27537
  }
27504
27538
  const parentComplexBlock = getParentBlock(container);
27505
- assert(logger$3v, parentComplexBlock, "child container has not parent block");
27506
- assert(logger$3v, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
27539
+ assert(logger$3w, parentComplexBlock, "child container has not parent block");
27540
+ assert(logger$3w, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
27507
27541
  const nextContainer = getComplexBlockClass(editor, parentComplexBlock).getNextContainer(editor, parentComplexBlock, container, type);
27508
27542
  if (nextContainer) {
27509
27543
  if (isFindPrev(type)) {
@@ -27525,7 +27559,7 @@ var __publicField = (obj, key, value) => {
27525
27559
  return null;
27526
27560
  }
27527
27561
  const parentBlock = getParentBlock(container);
27528
- assert(logger$3v, parentBlock, "child container has not parent block");
27562
+ assert(logger$3w, parentBlock, "child container has not parent block");
27529
27563
  if (isFindPrev(type)) {
27530
27564
  const prev = getPrevBlock(parentBlock);
27531
27565
  if (prev) {
@@ -27580,7 +27614,7 @@ var __publicField = (obj, key, value) => {
27580
27614
  }
27581
27615
  if (!targetBlock) {
27582
27616
  if (isComplexKindBlock(editor, block) && complexBlockGetAllChildContainers(editor, block).length === 0) {
27583
- logger$3v.warn("complex block has not any child container, not loaded?");
27617
+ logger$3w.warn("complex block has not any child container, not loaded?");
27584
27618
  targetBlock = direction === "ArrowDown" || direction === "ArrowRight" ? getNextVisibleBlock(block) : getPrevVisibleBlock(block);
27585
27619
  }
27586
27620
  }
@@ -27727,10 +27761,10 @@ var __publicField = (obj, key, value) => {
27727
27761
  editorAdjustSelection(editor, "ArrowUp", "select");
27728
27762
  return true;
27729
27763
  }
27730
- const logger$3u = getLogger("word-offset");
27764
+ const logger$3v = getLogger("word-offset");
27731
27765
  function editorGetWordLeftPos(editor, type) {
27732
27766
  const old = editor.selection.range.focus;
27733
- assert(logger$3u, old.isSimple(), "invalid range type");
27767
+ assert(logger$3v, old.isSimple(), "invalid range type");
27734
27768
  const block = editor.getBlockById(old.blockId);
27735
27769
  if (isEmptyTextBlock(editor, block)) {
27736
27770
  return createSimpleBlockPosition(block, 0, "home");
@@ -27755,7 +27789,7 @@ var __publicField = (obj, key, value) => {
27755
27789
  }
27756
27790
  function editorGetWordRightPos(editor, type) {
27757
27791
  const old = editor.selection.range.focus;
27758
- assert(logger$3u, old.isSimple(), "invalid range type");
27792
+ assert(logger$3v, old.isSimple(), "invalid range type");
27759
27793
  const block = editor.getBlockById(old.blockId);
27760
27794
  if (isEmptyTextBlock(editor, block)) {
27761
27795
  return createSimpleBlockPosition(block, 0, "end");
@@ -27867,10 +27901,10 @@ var __publicField = (obj, key, value) => {
27867
27901
  editor.selection.setSelection(editor.selection.getAnchorPos(), pos);
27868
27902
  return true;
27869
27903
  }
27870
- const logger$3t = getLogger("line-offset");
27904
+ const logger$3u = getLogger("line-offset");
27871
27905
  function editorGetLineHomePos(editor) {
27872
27906
  const old = editor.selection.range.focus;
27873
- assert(logger$3t, old.isSimple(), "invalid range type");
27907
+ assert(logger$3u, old.isSimple(), "invalid range type");
27874
27908
  const block = editor.getBlockById(old.blockId);
27875
27909
  if (old.offset === 0 || !isTextKindBlock(editor, block)) {
27876
27910
  const newPos2 = createSimpleBlockPosition(block, 0, "home");
@@ -27887,7 +27921,7 @@ var __publicField = (obj, key, value) => {
27887
27921
  }
27888
27922
  function editorGetLineEndPos(editor) {
27889
27923
  const old = editor.selection.range.focus;
27890
- assert(logger$3t, old.isSimple(), "invalid range type");
27924
+ assert(logger$3u, old.isSimple(), "invalid range type");
27891
27925
  const block = editor.getBlockById(old.blockId);
27892
27926
  if (old.offset === getBlockTextLength$6(editor, block) || !isTextKindBlock(editor, block)) {
27893
27927
  const newPos2 = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
@@ -27987,7 +28021,7 @@ var __publicField = (obj, key, value) => {
27987
28021
  editorPageDownScroll(editor);
27988
28022
  return true;
27989
28023
  }
27990
- const logger$3s = getLogger("table-scroll");
28024
+ const logger$3t = getLogger("table-scroll");
27991
28025
  class DomEventHandler {
27992
28026
  constructor(editor, dom, name, handler, data2, options) {
27993
28027
  __publicField(this, "handleEvent", (event) => {
@@ -28019,7 +28053,7 @@ var __publicField = (obj, key, value) => {
28019
28053
  const existsHandlers = this.handlers.get(element);
28020
28054
  if (existsHandlers) {
28021
28055
  if (existsHandlers.find((handler) => handler.handler === eventHandler && handler.name === eventName)) {
28022
- logger$3s.warn(`event has already registered: ${eventName}`);
28056
+ logger$3t.warn(`event has already registered: ${eventName}`);
28023
28057
  return;
28024
28058
  }
28025
28059
  existsHandlers.push(new DomEventHandler(this.editor, element, eventName, eventHandler, data2, options));
@@ -28129,7 +28163,7 @@ var __publicField = (obj, key, value) => {
28129
28163
  });
28130
28164
  return true;
28131
28165
  }
28132
- const logger$3r = getLogger("select-all");
28166
+ const logger$3s = getLogger("select-all");
28133
28167
  function isContainerSelectedAllChildBlocks(container, range) {
28134
28168
  const firstBlock = getFirstChildBlock(container);
28135
28169
  const lastBlock2 = getLastChildBlock(container);
@@ -28144,8 +28178,8 @@ var __publicField = (obj, key, value) => {
28144
28178
  return range.start.blockId === blockId && range.start.childContainerId === getContainerId(first) && range.end.blockId === blockId && range.end.childContainerId === getContainerId(last);
28145
28179
  }
28146
28180
  function selectComplexBlock(editor, block) {
28147
- assert(logger$3r, block, "no parent block");
28148
- assert(logger$3r, isComplexKindBlock(editor, block), "not a complex block");
28181
+ assert(logger$3s, block, "no parent block");
28182
+ assert(logger$3s, isComplexKindBlock(editor, block), "not a complex block");
28149
28183
  const containers = getComplexBlockClass(editor, block).getChildContainers(editor, block);
28150
28184
  const first = containers[0];
28151
28185
  const last = containers[containers.length - 1];
@@ -28181,13 +28215,13 @@ var __publicField = (obj, key, value) => {
28181
28215
  selectParentContainer(editor, getFirstChildBlock(editor.rootContainer));
28182
28216
  return false;
28183
28217
  }
28184
- assert(logger$3r, !range.isSimple(), "invalid range type");
28218
+ assert(logger$3s, !range.isSimple(), "invalid range type");
28185
28219
  if (isComplexBlockSelectedAllChildContainer(focusedBlock, range)) {
28186
28220
  selectParentContainer(editor, focusedBlock);
28187
28221
  return false;
28188
28222
  }
28189
- assert(logger$3r, focusedBlock, "no parent block");
28190
- assert(logger$3r, isComplexKindBlock(editor, focusedBlock), "not a complex block");
28223
+ assert(logger$3s, focusedBlock, "no parent block");
28224
+ assert(logger$3s, isComplexKindBlock(editor, focusedBlock), "not a complex block");
28191
28225
  selectComplexBlock(editor, focusedBlock);
28192
28226
  return true;
28193
28227
  }
@@ -28223,6 +28257,30 @@ var __publicField = (obj, key, value) => {
28223
28257
  }
28224
28258
  editor.selection.setSelection(newStartPos, newEndPos);
28225
28259
  }
28260
+ function editorMoveBlockStart(editor) {
28261
+ const focus = editor.selection.range.focus;
28262
+ const block = editor.getBlockById(focus.blockId);
28263
+ if (!block)
28264
+ return false;
28265
+ if (!isSimpleBlock(editor, block))
28266
+ return false;
28267
+ const newPos = createSimpleBlockPosition(block, 0, "home");
28268
+ editor.selection.setSelection(newPos);
28269
+ editor.selection.updateLastCaretRect();
28270
+ return true;
28271
+ }
28272
+ function editorMoveBlockEnd(editor) {
28273
+ const focus = editor.selection.range.focus;
28274
+ const block = editor.getBlockById(focus.blockId);
28275
+ if (!block)
28276
+ return false;
28277
+ if (!isSimpleBlock(editor, block))
28278
+ return false;
28279
+ const newPos = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
28280
+ editor.selection.setSelection(newPos);
28281
+ editor.selection.updateLastCaretRect();
28282
+ return true;
28283
+ }
28226
28284
  function editorFocusToEnd(editor) {
28227
28285
  editorSelectEnd(editor);
28228
28286
  editor.focus();
@@ -28302,7 +28360,7 @@ var __publicField = (obj, key, value) => {
28302
28360
  }
28303
28361
  return cloned;
28304
28362
  }
28305
- const logger$3q = getLogger("selected-block-to-doc");
28363
+ const logger$3r = getLogger("selected-block-to-doc");
28306
28364
  function appendBlockChildren(editor, data2, doc2) {
28307
28365
  if (!data2.children)
28308
28366
  return;
@@ -28323,7 +28381,7 @@ var __publicField = (obj, key, value) => {
28323
28381
  if (isTextKindBlock(editor, selectedBlock.block)) {
28324
28382
  const start = selectedBlock.start;
28325
28383
  const end = selectedBlock.end;
28326
- assert(logger$3q, data2.text, "no block text");
28384
+ assert(logger$3r, data2.text, "no block text");
28327
28385
  if (start.offset === end.offset) {
28328
28386
  return {
28329
28387
  blocks: {
@@ -28357,8 +28415,8 @@ var __publicField = (obj, key, value) => {
28357
28415
  comments: {}
28358
28416
  };
28359
28417
  }
28360
- assert(logger$3q, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
28361
- assert(logger$3q, data2.children, "no children");
28418
+ assert(logger$3r, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
28419
+ assert(logger$3r, data2.children, "no children");
28362
28420
  const ret = {
28363
28421
  blocks: {
28364
28422
  root: [
@@ -28376,9 +28434,9 @@ var __publicField = (obj, key, value) => {
28376
28434
  const end = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
28377
28435
  return selectedBlockToDoc(editor, { block, start, end });
28378
28436
  }
28379
- const logger$3p = getLogger("block-to-doc");
28437
+ const logger$3q = getLogger("block-to-doc");
28380
28438
  function blocksToDoc(editor, blocks) {
28381
- assert(logger$3p, blocks.length > 0, "invalid params, no blocks");
28439
+ assert(logger$3q, blocks.length > 0, "invalid params, no blocks");
28382
28440
  const docs = blocks.map((b) => blockToDoc(editor, b));
28383
28441
  return mergeDocs(docs);
28384
28442
  }
@@ -28398,7 +28456,7 @@ var __publicField = (obj, key, value) => {
28398
28456
  const newDocs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s));
28399
28457
  return mergeDocs(newDocs);
28400
28458
  }
28401
- const logger$3o = getLogger("ensure-block-visible");
28459
+ const logger$3p = getLogger("ensure-block-visible");
28402
28460
  function ensureBlockVisible(editor, block) {
28403
28461
  var _a;
28404
28462
  while (block) {
@@ -28408,16 +28466,16 @@ var __publicField = (obj, key, value) => {
28408
28466
  return;
28409
28467
  }
28410
28468
  const parentComplexBlock = getParentBlock(container);
28411
- assert(logger$3o, parentComplexBlock, "no parent block");
28469
+ assert(logger$3p, parentComplexBlock, "no parent block");
28412
28470
  const parentComplexBlockClass = getBlockClass(editor, parentComplexBlock);
28413
28471
  if (parentComplexBlockClass.isChildContainerVisible && !((_a = parentComplexBlockClass.isChildContainerVisible) == null ? void 0 : _a.call(parentComplexBlockClass, editor, parentComplexBlock, container))) {
28414
- assert(logger$3o, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
28472
+ assert(logger$3p, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
28415
28473
  parentComplexBlockClass.showChildContainer(editor, parentComplexBlock, container);
28416
28474
  }
28417
28475
  block = parentComplexBlock;
28418
28476
  }
28419
28477
  }
28420
- const logger$3n = getLogger("editor-selection");
28478
+ const logger$3o = getLogger("editor-selection");
28421
28479
  class EditorSelection {
28422
28480
  constructor(editor) {
28423
28481
  __publicField(this, "editor");
@@ -28430,7 +28488,7 @@ var __publicField = (obj, key, value) => {
28430
28488
  }
28431
28489
  const range = this.range;
28432
28490
  if (rangeInBlock(deletedBlock, range)) {
28433
- logger$3n.debug("adjust selection because remote deleted current block");
28491
+ logger$3o.debug("adjust selection because remote deleted current block");
28434
28492
  const newRange = moveSelectionBeforeDeleteBlock(editor, deletedBlock);
28435
28493
  this.setRange(newRange, { noScroll: true });
28436
28494
  }
@@ -28555,14 +28613,14 @@ var __publicField = (obj, key, value) => {
28555
28613
  if (pos.isSimple()) {
28556
28614
  const ok = pos.offset >= 0 && pos.offset <= getBlockTextLength$6(this.editor, block);
28557
28615
  if (!ok) {
28558
- assert(logger$3n, false, "invalid block position, out of range");
28616
+ assert(logger$3o, false, "invalid block position, out of range");
28559
28617
  }
28560
28618
  } else {
28561
28619
  const childContainerId = pos.childContainerId;
28562
28620
  const container = this.editor.getContainerById(childContainerId);
28563
28621
  const ok = !!container;
28564
28622
  if (!ok) {
28565
- assert(logger$3n, false, "invalid complex block position, no container found");
28623
+ assert(logger$3o, false, "invalid complex block position, no container found");
28566
28624
  }
28567
28625
  }
28568
28626
  }
@@ -28623,7 +28681,7 @@ var __publicField = (obj, key, value) => {
28623
28681
  let container = getParentContainer(block);
28624
28682
  while (isChildContainer(container)) {
28625
28683
  const parentBlock = getParentBlock(container);
28626
- assert(logger$3n, parentBlock, "parent block not found");
28684
+ assert(logger$3o, parentBlock, "parent block not found");
28627
28685
  addClass(parentBlock, "child-focused");
28628
28686
  container = getParentContainer(parentBlock);
28629
28687
  }
@@ -28733,15 +28791,15 @@ var __publicField = (obj, key, value) => {
28733
28791
  editor.undoManager.redo();
28734
28792
  return true;
28735
28793
  }
28736
- const logger$3m = getLogger("delete-text");
28794
+ const logger$3n = getLogger("delete-text");
28737
28795
  function editorDeleteText(editor, type, count, insertPos) {
28738
28796
  const pos = insertPos != null ? insertPos : editor.selection.range.start;
28739
28797
  if (!(pos instanceof EditorSimpleBlockPosition)) {
28740
- assert(logger$3m, false, `invalid insert pos type: ${typeof pos}`);
28798
+ assert(logger$3n, false, `invalid insert pos type: ${typeof pos}`);
28741
28799
  }
28742
28800
  const { blockId } = pos;
28743
28801
  const block = editor.getBlockById(blockId);
28744
- assert(logger$3m, isTextKindBlock(editor, block), "block is not a text kind block");
28802
+ assert(logger$3n, isTextKindBlock(editor, block), "block is not a text kind block");
28745
28803
  let { offset } = pos;
28746
28804
  if (type === "backward") {
28747
28805
  if (offset - count < 0) {
@@ -28771,7 +28829,7 @@ var __publicField = (obj, key, value) => {
28771
28829
  }
28772
28830
  return false;
28773
28831
  }
28774
- const logger$3l = getLogger("handle-backspace");
28832
+ const logger$3m = getLogger("handle-backspace");
28775
28833
  function tryDeleteEmptyBlock(editor, block) {
28776
28834
  if (!isEmptyTextBlock(editor, block)) {
28777
28835
  return;
@@ -28811,7 +28869,7 @@ var __publicField = (obj, key, value) => {
28811
28869
  }
28812
28870
  } else {
28813
28871
  tryDeleteEmptyBlock(editor, block);
28814
- assert(logger$3l, isEmbedBlock(prevBlock), "prev block is not embed block");
28872
+ assert(logger$3m, isEmbedBlock(prevBlock), "prev block is not embed block");
28815
28873
  editor.selection.selectBlock(prevBlock, 1);
28816
28874
  }
28817
28875
  } else {
@@ -28838,6 +28896,7 @@ var __publicField = (obj, key, value) => {
28838
28896
  editor.deleteBlock(block);
28839
28897
  }
28840
28898
  }
28899
+ const logger$3l = getLogger("word-offset");
28841
28900
  function handleEditorDelete(editor, event) {
28842
28901
  if (!editor.selection.range.isCollapsed()) {
28843
28902
  editor.clearSelectedContents();
@@ -28872,6 +28931,130 @@ var __publicField = (obj, key, value) => {
28872
28931
  editor.deleteBlock(block);
28873
28932
  }
28874
28933
  }
28934
+ function handleEditorDeleteLeftWord(editor, event) {
28935
+ const old = editor.selection.range.focus;
28936
+ assert(logger$3l, old.isSimple(), "invalid range type");
28937
+ const block = editor.getBlockById(old.blockId);
28938
+ if (!isTextKindBlock(editor, block)) {
28939
+ editor.deleteBlock(block);
28940
+ return true;
28941
+ }
28942
+ if (old.offset === 0) {
28943
+ const matchNonEmptyTextBlockOrOtherBlock = (block2) => {
28944
+ if (!isTextKindBlock(editor, block2))
28945
+ return true;
28946
+ return !isEmptyTextBlock(editor, block2);
28947
+ };
28948
+ const prevBlock = getPrevVisibleBlock(block, matchNonEmptyTextBlockOrOtherBlock);
28949
+ if (!prevBlock)
28950
+ return false;
28951
+ const matchEmptyTextBlock = (block2) => isEmptyTextBlock(editor, block2);
28952
+ const emptyTextBlocks = getBlocksBetween(prevBlock, block, matchEmptyTextBlock);
28953
+ emptyTextBlocks.forEach((b) => {
28954
+ editor.deleteBlock(b);
28955
+ });
28956
+ if (!isTextKindBlock(editor, prevBlock)) {
28957
+ editor.deleteBlock(prevBlock);
28958
+ return true;
28959
+ }
28960
+ const textBlockLen = getBlockTextLength$6(editor, prevBlock);
28961
+ const newOffset2 = findWordLeft(editor, prevBlock, textBlockLen);
28962
+ editor.deleteTextFromBlock(prevBlock, newOffset2, textBlockLen - newOffset2);
28963
+ const currentBlockText = editor.getBlockText(block);
28964
+ editor.insertTextToBlock(prevBlock, newOffset2, currentBlockText);
28965
+ editor.deleteBlock(block);
28966
+ const pos = createSimpleBlockPosition(prevBlock, newOffset2, "normal");
28967
+ editor.selection.setSelection(pos);
28968
+ editor.selection.updateLastCaretRect();
28969
+ return true;
28970
+ }
28971
+ const newOffset = findWordLeft(editor, block, old.offset);
28972
+ const deletedCount = old.offset - newOffset;
28973
+ editor.deleteTextFromBlock(block, newOffset, deletedCount);
28974
+ return true;
28975
+ }
28976
+ function handleEditorDeleteRightWord(editor, event) {
28977
+ const old = editor.selection.range.focus;
28978
+ assert(logger$3l, old.isSimple(), "invalid range type");
28979
+ const block = editor.getBlockById(old.blockId);
28980
+ if (!isTextKindBlock(editor, block)) {
28981
+ editor.deleteBlock(block);
28982
+ return true;
28983
+ }
28984
+ if (old.offset === getTextBlockLength(block)) {
28985
+ const matchNonEmptyTextBlockOrOtherBlock = (block2) => {
28986
+ if (!isTextKindBlock(editor, block2))
28987
+ return true;
28988
+ return !isEmptyTextBlock(editor, block2);
28989
+ };
28990
+ const nextBlock = getNextVisibleBlock(block, matchNonEmptyTextBlockOrOtherBlock);
28991
+ if (!nextBlock)
28992
+ return false;
28993
+ const matchEmptyTextBlock = (block2) => isEmptyTextBlock(editor, block2);
28994
+ const emptyTextBlocks = getBlocksBetween(block, nextBlock, matchEmptyTextBlock);
28995
+ emptyTextBlocks.forEach((b) => {
28996
+ editor.deleteBlock(b);
28997
+ });
28998
+ if (!isTextKindBlock(editor, nextBlock)) {
28999
+ editor.deleteBlock(nextBlock);
29000
+ return true;
29001
+ }
29002
+ const newOffset = findWordEnd(editor, nextBlock, 0);
29003
+ editor.deleteTextFromBlock(nextBlock, 0, newOffset);
29004
+ const nextBlockText = editor.getBlockText(nextBlock);
29005
+ editor.insertTextToBlock(block, old.offset, nextBlockText);
29006
+ editor.deleteBlock(nextBlock);
29007
+ const pos = createSimpleBlockPosition(block, old.offset, "normal");
29008
+ editor.selection.setSelection(pos);
29009
+ editor.selection.updateLastCaretRect();
29010
+ return true;
29011
+ }
29012
+ const endOffset = findWordEnd(editor, block, old.offset);
29013
+ const deletedCount = endOffset - old.offset;
29014
+ editor.deleteTextFromBlock(block, old.offset, deletedCount);
29015
+ return true;
29016
+ }
29017
+ function handleEditorDeleteAfterWords(editor) {
29018
+ const old = editor.selection.range.focus;
29019
+ assert(logger$3l, old.isSimple(), "invalid range type");
29020
+ const block = editor.getBlockById(old.blockId);
29021
+ if (!isTextKindBlock(editor, block)) {
29022
+ editor.deleteBlock(block);
29023
+ return;
29024
+ }
29025
+ const needDeleteCount = getTextBlockLength(block) - old.offset;
29026
+ if (needDeleteCount === 0)
29027
+ return;
29028
+ editor.deleteTextFromBlock(block, old.offset, needDeleteCount);
29029
+ }
29030
+ function handleEditorDeleteRightChar(editor) {
29031
+ const old = editor.selection.range.focus;
29032
+ assert(logger$3l, old.isSimple(), "invalid range type");
29033
+ const block = editor.getBlockById(old.blockId);
29034
+ if (!isTextKindBlock(editor, block)) {
29035
+ editor.deleteBlock(block);
29036
+ return;
29037
+ }
29038
+ if (old.offset === getBlockTextLength$6(editor, block)) {
29039
+ const nextVisibleBlock = getNextVisibleBlock(block);
29040
+ if (!nextVisibleBlock)
29041
+ return;
29042
+ if (!isTextKindBlock(editor, nextVisibleBlock))
29043
+ return;
29044
+ if (isEmptyTextBlock(editor, nextVisibleBlock)) {
29045
+ editor.deleteBlock(nextVisibleBlock);
29046
+ return;
29047
+ }
29048
+ const nextBlockText = editor.getBlockText(nextVisibleBlock);
29049
+ editor.deleteBlock(nextVisibleBlock);
29050
+ editor.insertTextToBlock(block, old.offset, nextBlockText);
29051
+ const pos = createSimpleBlockPosition(block, old.offset, "normal");
29052
+ editor.selection.setSelection(pos);
29053
+ editor.selection.updateLastCaretRect();
29054
+ return;
29055
+ }
29056
+ editorDeleteText(editor, "forward", 1, null);
29057
+ }
28875
29058
  function handleEditorEnterEvent$1(editor, event) {
28876
29059
  if (isFullSelectedOneComplexBlock(editor)) {
28877
29060
  const focusedBlock2 = editor.getFocusedBlock();
@@ -29093,6 +29276,42 @@ var __publicField = (obj, key, value) => {
29093
29276
  return true;
29094
29277
  });
29095
29278
  }
29279
+ function editorHandleDeleteLeftWord(editor, event) {
29280
+ if (editor.readonly || !editor.isWritable()) {
29281
+ return false;
29282
+ }
29283
+ return editor.undoManager.runInGroup(() => {
29284
+ handleEditorDeleteLeftWord(editor);
29285
+ return true;
29286
+ });
29287
+ }
29288
+ function editorHandleDeleteRightWord(editor, event) {
29289
+ if (editor.readonly || !editor.isWritable()) {
29290
+ return false;
29291
+ }
29292
+ return editor.undoManager.runInGroup(() => {
29293
+ handleEditorDeleteRightWord(editor);
29294
+ return true;
29295
+ });
29296
+ }
29297
+ function editorHandleDeleteAfterWords(editor, event) {
29298
+ if (editor.readonly || !editor.isWritable()) {
29299
+ return false;
29300
+ }
29301
+ return editor.undoManager.runInGroup(() => {
29302
+ handleEditorDeleteAfterWords(editor);
29303
+ return true;
29304
+ });
29305
+ }
29306
+ function editorHandleDeleteRightChar(editor, event) {
29307
+ if (editor.readonly || !editor.isWritable()) {
29308
+ return false;
29309
+ }
29310
+ return editor.undoManager.runInGroup(() => {
29311
+ handleEditorDeleteRightChar(editor);
29312
+ return true;
29313
+ });
29314
+ }
29096
29315
  function editorHandleBackspace(editor, event) {
29097
29316
  if (editor.readonly || !editor.isWritable()) {
29098
29317
  return false;
@@ -29186,6 +29405,10 @@ ${codeText}
29186
29405
  __proto__: null,
29187
29406
  editorHandleEnter,
29188
29407
  editorHandleDelete,
29408
+ editorHandleDeleteLeftWord,
29409
+ editorHandleDeleteRightWord,
29410
+ editorHandleDeleteAfterWords,
29411
+ editorHandleDeleteRightChar,
29189
29412
  editorHandleBackspace,
29190
29413
  editorHandleInsertBr,
29191
29414
  editorHandlePastePlainText,
@@ -29193,6 +29416,41 @@ ${codeText}
29193
29416
  getSelectedCodeBlockMarkdown,
29194
29417
  editorHandleCopyMarkdown
29195
29418
  }, Symbol.toStringTag, { value: "Module" }));
29419
+ const MacShortcuts = {
29420
+ "Cmd+ArrowLeft": editorMoveLineHome,
29421
+ "Cmd+ArrowRight": editorMoveLineEnd,
29422
+ "Option+ArrowLeft": editorMoveWordLeft,
29423
+ "Option+ArrowRight": editorMoveWordEnd,
29424
+ "Option+Shift+ArrowLeft": editorSelectWordLeft,
29425
+ "Option+Shift+ArrowRight": editorSelectWordEnd,
29426
+ "Cmd+Shift+ArrowLeft": editorSelectLineHome,
29427
+ "Cmd+Shift+ArrowRight": editorSelectLineEnd,
29428
+ "Ctrl+A": editorMoveBlockStart,
29429
+ "Ctrl+E": editorMoveBlockEnd,
29430
+ "Option+Delete": editorHandleDeleteRightWord,
29431
+ "Option+Backspace": editorHandleDeleteLeftWord,
29432
+ "Ctrl+B": editorMoveLeft,
29433
+ "Ctrl+F": editorMoveRight,
29434
+ "Ctrl+N": editorMoveDown,
29435
+ "Ctrl+P": editorMoveUp,
29436
+ "Ctrl+K": editorHandleDeleteAfterWords,
29437
+ "Ctrl+H": editorHandleBackspace,
29438
+ "Ctrl+D": editorHandleDeleteRightChar
29439
+ };
29440
+ const WinLinuxShortcuts = {
29441
+ "Home": editorMoveLineHome,
29442
+ "End": editorMoveLineEnd,
29443
+ "Shift+Home": editorSelectLineHome,
29444
+ "Shift+End": editorSelectLineEnd,
29445
+ "Ctrl+Delete": editorHandleDeleteRightWord,
29446
+ "Ctrl+Backspace": editorHandleDeleteLeftWord,
29447
+ "Ctrl+ArrowLeft": editorMoveWordLeft,
29448
+ "Ctrl+ArrowRight": editorMoveWordEnd,
29449
+ "Ctrl+Shift+ArrowLeft": editorSelectWordLeft,
29450
+ "Ctrl+Shift+ArrowRight": editorSelectWordEnd
29451
+ };
29452
+ const isMac = clientType.isMac;
29453
+ const CustomShortcuts = isMac ? MacShortcuts : WinLinuxShortcuts;
29196
29454
  const DefaultShortcuts = {
29197
29455
  "ArrowDown": editorMoveDown,
29198
29456
  "ArrowUp": editorMoveUp,
@@ -29202,19 +29460,11 @@ ${codeText}
29202
29460
  "Shift+ArrowUp": editorSelectUp,
29203
29461
  "Shift+ArrowLeft": editorSelectLeft,
29204
29462
  "Shift+ArrowRight": editorSelectRight,
29205
- "CtrlOrCmd+ArrowLeft": editorMoveWordLeft,
29206
- "CtrlOrCmd+ArrowRight": editorMoveWordEnd,
29207
- "CtrlOrCmd+Shift+ArrowLeft": editorSelectWordLeft,
29208
- "CtrlOrCmd+Shift+ArrowRight": editorSelectWordEnd,
29209
29463
  "CtrlOrCmd+ArrowUp": editorMoveHome,
29210
29464
  "CtrlOrCmd+ArrowDown": editorMoveEnd,
29211
29465
  "CtrlOrCmd+Shift+ArrowUp": editorSelectHome,
29212
29466
  "CtrlOrCmd+Shift+ArrowDown": editorSelectEnd,
29213
29467
  "CtrlOrCmd+A": editorSelectAll,
29214
- "Home": editorMoveLineHome,
29215
- "End": editorMoveLineEnd,
29216
- "Shift+Home": editorSelectLineHome,
29217
- "Shift+End": editorSelectLineEnd,
29218
29468
  "PageUp": editorMovePageUp,
29219
29469
  "PageDown": editorMovePageDown,
29220
29470
  "Shift+PageUp": editorSelectPageUp,
@@ -29226,7 +29476,8 @@ ${codeText}
29226
29476
  "Backspace": editorHandleBackspace,
29227
29477
  "Shift+Enter": editorHandleInsertBr,
29228
29478
  "CtrlOrCmd+Shift+V": editorHandlePastePlainText,
29229
- "CtrlOrCmd+Shift+C": editorHandleCopyMarkdown
29479
+ "CtrlOrCmd+Shift+C": editorHandleCopyMarkdown,
29480
+ ...CustomShortcuts
29230
29481
  };
29231
29482
  function editorHandleKeyboardEvent(editor, event) {
29232
29483
  const result = editor.shortcuts.handleKeyboardEvents(editor, event);
@@ -43004,8 +43255,21 @@ ${codeText}
43004
43255
  const textColorItem = "";
43005
43256
  const DEFAULT_BG_COLOR = 2;
43006
43257
  const NULLABLE_COLOR = -1;
43258
+ const STORAGE_NAME = "color-item";
43259
+ function getColorsFromLocalStorage(editor) {
43260
+ const colors = [null, null];
43261
+ const color = Number.parseInt(editor.settingsProvider.getItem(`${STORAGE_NAME}-color`) || "", 10);
43262
+ const backgroundColor = Number.parseInt(editor.settingsProvider.getItem(`${STORAGE_NAME}-backgroundColor`) || `${DEFAULT_BG_COLOR}`, 10);
43263
+ if (!Number.isNaN(color)) {
43264
+ colors[0] = color;
43265
+ }
43266
+ if (!Number.isNaN(backgroundColor)) {
43267
+ colors[1] = backgroundColor;
43268
+ }
43269
+ return colors;
43270
+ }
43007
43271
  class TextColorItem extends tinyTypedEmitter.TypedEmitter {
43008
- constructor(editor, storageName = "color-item") {
43272
+ constructor(editor, storageName = STORAGE_NAME) {
43009
43273
  super();
43010
43274
  __publicField(this, "id", "text-color-item");
43011
43275
  __publicField(this, "name", i18n$1.t("colorPalette.name"));
@@ -50700,7 +50964,7 @@ ${codeText}
50700
50964
  }
50701
50965
  return handleDragList(editor, draggedBlock, targetBlock, insertPos);
50702
50966
  }
50703
- function executeShortcut$1(editor, type) {
50967
+ function executeShortcut$3(editor, type) {
50704
50968
  if (!editor.isWritable()) {
50705
50969
  return false;
50706
50970
  }
@@ -50714,8 +50978,8 @@ ${codeText}
50714
50978
  return true;
50715
50979
  }
50716
50980
  const ListBlockShortcuts = {
50717
- "Shift+CtrlOrCmd+L": (editor) => executeShortcut$1(editor, "ordered-list"),
50718
- "Shift+CtrlOrCmd+U": (editor) => executeShortcut$1(editor, "unordered-list")
50981
+ "Shift+CtrlOrCmd+L": (editor) => executeShortcut$3(editor, "ordered-list"),
50982
+ "Shift+CtrlOrCmd+U": (editor) => executeShortcut$3(editor, "unordered-list")
50719
50983
  };
50720
50984
  function getBlockPadding$1(block) {
50721
50985
  const padding = block.getAttribute("block-padding-level");
@@ -61225,6 +61489,31 @@ $$${mathData.mathjaxText}$$
61225
61489
  return editor.addCustom("overflow-tooltip-helper", () => new OverflowTooltipHelper(editor));
61226
61490
  }
61227
61491
  }
61492
+ function executeShortcut$2(editor, style2) {
61493
+ if (!editor.isWritable()) {
61494
+ return false;
61495
+ }
61496
+ const range = editor.selection.range;
61497
+ const allCommands = editor.editorCommandProviders.getCommands(range);
61498
+ const alignCommands = allCommands.flatMap((command2) => {
61499
+ if (command2.id === "align") {
61500
+ return command2.children;
61501
+ }
61502
+ return [];
61503
+ });
61504
+ const command = alignCommands.find((c) => c.id === `align-${style2}`);
61505
+ if (!command) {
61506
+ return false;
61507
+ }
61508
+ editor.editorCommandProviders.executeCommand(range, command, {});
61509
+ OnesEditorToolbar.get(editor).update("selectionChange");
61510
+ return true;
61511
+ }
61512
+ const AlignShortcuts = {
61513
+ "CtrlOrCmd+Shift+E": (editor) => executeShortcut$2(editor, "center"),
61514
+ "CtrlOrCmd+Shift+O": (editor) => executeShortcut$2(editor, "left"),
61515
+ "CtrlOrCmd+Shift+R": (editor) => executeShortcut$2(editor, "right")
61516
+ };
61228
61517
  const TextCommands = {
61229
61518
  "text/style-bold": "bold",
61230
61519
  "text/style-italic": "italic",
@@ -61233,14 +61522,15 @@ $$${mathData.mathjaxText}$$
61233
61522
  "text/style-code": "code",
61234
61523
  "text/style-sub": "subscript",
61235
61524
  "text/style-super": "superscript",
61236
- link: "link"
61525
+ link: "link",
61526
+ "insert-link": "link"
61237
61527
  };
61238
61528
  function getTextCommands(editor, blockCommands) {
61239
61529
  const styleCommandsSet = new Set(Object.keys(TextCommands));
61240
61530
  const styleCommands = blockCommands.filter((command) => styleCommandsSet.has(command.id));
61241
61531
  return styleCommands;
61242
61532
  }
61243
- function executeShortcut(editor, style2) {
61533
+ function executeShortcut$1(editor, style2) {
61244
61534
  if (!editor.isWritable()) {
61245
61535
  return false;
61246
61536
  }
@@ -61250,7 +61540,7 @@ $$${mathData.mathjaxText}$$
61250
61540
  const range = editor.selection.range;
61251
61541
  const allCommands = editor.editorCommandProviders.getCommands(range);
61252
61542
  const textCommands = getTextCommands(editor, allCommands);
61253
- const command = textCommands.find((c) => c.id === `text/${style2}` || c.id === "link");
61543
+ const command = textCommands.find((c) => c.id === `text/${style2}` || c.id === "link" || c.id === "insert-link");
61254
61544
  if (!command) {
61255
61545
  return false;
61256
61546
  }
@@ -61285,13 +61575,37 @@ $$${mathData.mathjaxText}$$
61285
61575
  return shortcuts2;
61286
61576
  };
61287
61577
  const TextStyleShortcuts = {
61288
- "CtrlOrCmd+B": (editor) => executeShortcut(editor, "style-bold"),
61289
- "CtrlOrCmd+I": (editor) => executeShortcut(editor, "style-italic"),
61290
- "CtrlOrCmd+U": (editor) => executeShortcut(editor, "style-underline"),
61291
- "CtrlOrCmd+D": (editor) => executeShortcut(editor, "style-strikethrough"),
61292
- "CtrlOrCmd+K": (editor) => executeShortcut(editor, "link"),
61578
+ "CtrlOrCmd+B": (editor) => executeShortcut$1(editor, "style-bold"),
61579
+ "CtrlOrCmd+I": (editor) => executeShortcut$1(editor, "style-italic"),
61580
+ "CtrlOrCmd+U": (editor) => executeShortcut$1(editor, "style-underline"),
61581
+ "CtrlOrCmd+D": (editor) => executeShortcut$1(editor, "style-strikethrough"),
61582
+ "CtrlOrCmd+K": (editor) => executeShortcut$1(editor, "insert-link"),
61293
61583
  ...headingShortcut()
61294
61584
  };
61585
+ function executeShortcut(editor) {
61586
+ if (!editor.isWritable()) {
61587
+ return false;
61588
+ }
61589
+ const range = editor.selection.range;
61590
+ if (range.isCollapsed()) {
61591
+ return false;
61592
+ }
61593
+ editor.undoManager.runInGroup(() => {
61594
+ const colors = getColorsFromLocalStorage(editor);
61595
+ colors.forEach((color, idx) => {
61596
+ if (color === null) {
61597
+ return;
61598
+ }
61599
+ const type = idx === 0 ? "color" : "backgroundColor";
61600
+ editorRangeSetColor(editor, type, color, () => {
61601
+ });
61602
+ });
61603
+ });
61604
+ return true;
61605
+ }
61606
+ const TextColorShortcuts = {
61607
+ "CtrlOrCmd+Alt+KeyH": (editor) => executeShortcut(editor)
61608
+ };
61295
61609
  const zhCN$p = {
61296
61610
  quickMenu: {
61297
61611
  basic: {
@@ -62050,7 +62364,7 @@ $$${mathData.mathjaxText}$$
62050
62364
  __publicField(this, "updateButtonColor", (range) => {
62051
62365
  const currentTextColor = editorRangeGetColor(this.editor, range, this.getEmptyTextBlockColor);
62052
62366
  this.colorItem.setCurrentTextColors(currentTextColor);
62053
- const lastButtonColor = this.colorItem.getColorsFromLocalStorage();
62367
+ const lastButtonColor = getColorsFromLocalStorage(this.editor);
62054
62368
  this.colorItem.setCurrentButtonColor(lastButtonColor);
62055
62369
  });
62056
62370
  __publicField(this, "setActiveAttribute", (type, value) => {
@@ -84816,10 +85130,11 @@ ${data2.flowchartText}
84816
85130
  checker: () => !!(window.mxUtils && window.mxGraph && window.mxCodec),
84817
85131
  maxRetryTime: 5e3
84818
85132
  })).then(() => {
84819
- const { mxUtils, mxGraph: MxGraph, mxCodec: MxCodec } = window;
85133
+ const { mxUtils, mxGraph: MxGraph, mxCodec: MxCodec, Graph } = window;
84820
85134
  assert(logger$i, mxUtils, "External resource loading exception: mxUtils");
84821
85135
  assert(logger$i, MxGraph, "External resource loading exception: MxGraph");
84822
85136
  assert(logger$i, MxCodec, "External resource loading exception: MxCodec");
85137
+ assert(logger$i, Graph, "External resource loading exception: Graph");
84823
85138
  const file2 = mxUtils.parseXml(mxFile);
84824
85139
  embed.innerHTML = "";
84825
85140
  const node = file2.documentElement;
@@ -84841,7 +85156,7 @@ ${data2.flowchartText}
84841
85156
  const xml = new XMLSerializer().serializeToString(data2.firstElementChild);
84842
85157
  xmlDoc = mxUtils.parseXml(xml);
84843
85158
  }
84844
- const graph = new MxGraph(embed);
85159
+ const graph = new Graph(embed);
84845
85160
  graph.resetViewOnRootChange = false;
84846
85161
  graph.foldingEnabled = false;
84847
85162
  graph.setTooltips(false);
@@ -85094,7 +85409,7 @@ ${data2.flowchartText}
85094
85409
  const block = blocks[i];
85095
85410
  if (block.type === "embed" && block.embedType === "drawio") {
85096
85411
  const src = ((_a = block.embedData) == null ? void 0 : _a.src) || "";
85097
- if (!this.isSameOrigin(editor, doc2, src)) {
85412
+ if (src && !this.isSameOrigin(editor, doc2, src)) {
85098
85413
  blocks.splice(i, 1);
85099
85414
  }
85100
85415
  }
@@ -91904,9 +92219,11 @@ ${data2.plantumlText}
91904
92219
  FindReplaceShortcuts,
91905
92220
  BlockPaddingShortcuts,
91906
92221
  TextStyleShortcuts,
92222
+ AlignShortcuts,
91907
92223
  AutoLinkShortcuts,
91908
92224
  DefaultShortcuts,
91909
92225
  ListBlockShortcuts,
92226
+ TextColorShortcuts,
91910
92227
  ...options.shortcuts || []
91911
92228
  ],
91912
92229
  colors: [
@@ -92115,7 +92432,7 @@ ${data2.plantumlText}
92115
92432
  }
92116
92433
  }
92117
92434
  });
92118
- editor.version = "2.4.1";
92435
+ editor.version = "2.5.0";
92119
92436
  return editor;
92120
92437
  }
92121
92438
  function isDoc(doc2) {
@@ -92228,7 +92545,7 @@ ${data2.plantumlText}
92228
92545
  }
92229
92546
  });
92230
92547
  OnesEditorToolbar.register(editor);
92231
- editor.version = "2.4.1";
92548
+ editor.version = "2.5.0";
92232
92549
  return editor;
92233
92550
  }
92234
92551
  async function showDocVersions(editor, options, serverUrl) {
@@ -138014,6 +138331,7 @@ ${data2.plantumlText}
138014
138331
  exports2.AlignProvider = AlignProvider;
138015
138332
  exports2.AlignRightIcon = AlignRightIcon;
138016
138333
  exports2.AlignRightItem = AlignRightItem;
138334
+ exports2.AlignShortcuts = AlignShortcuts;
138017
138335
  exports2.AnchorBox = AnchorBox;
138018
138336
  exports2.ArrowDownIcon = ArrowDownIcon$1;
138019
138337
  exports2.ArrowLeftIcon = arrowLeft;
@@ -138270,6 +138588,7 @@ ${data2.plantumlText}
138270
138588
  exports2.TextBox = TextBox;
138271
138589
  exports2.TextColorIcon = TextColorIcon;
138272
138590
  exports2.TextColorItem = TextColorItem;
138591
+ exports2.TextColorShortcuts = TextColorShortcuts;
138273
138592
  exports2.TextCommandProvider = TextCommandProvider;
138274
138593
  exports2.TextGroupIcon = TextGroupIcon;
138275
138594
  exports2.TextIcon = TextIcon;
@@ -138439,6 +138758,8 @@ ${data2.plantumlText}
138439
138758
  exports2.editorInsertTextToBlock = editorInsertTextToBlock;
138440
138759
  exports2.editorInsertTextToBlockEx = editorInsertTextToBlockEx;
138441
138760
  exports2.editorMergeTextBlock = editorMergeTextBlock;
138761
+ exports2.editorMoveBlockEnd = editorMoveBlockEnd;
138762
+ exports2.editorMoveBlockStart = editorMoveBlockStart;
138442
138763
  exports2.editorMoveDown = editorMoveDown;
138443
138764
  exports2.editorMoveEnd = editorMoveEnd;
138444
138765
  exports2.editorMoveHome = editorMoveHome;
@@ -138543,6 +138864,7 @@ ${data2.plantumlText}
138543
138864
  exports2.getBlockTextLength = getBlockTextLength$6;
138544
138865
  exports2.getBlockTools = getBlockTools;
138545
138866
  exports2.getBlockType = getBlockType;
138867
+ exports2.getBlocksBetween = getBlocksBetween;
138546
138868
  exports2.getBlocksWidth = getBlocksWidth;
138547
138869
  exports2.getBoxContent = getBoxContent;
138548
138870
  exports2.getBoxId = getBoxId;
@@ -138555,6 +138877,7 @@ ${data2.plantumlText}
138555
138877
  exports2.getClosestContainerByCondition = getClosestContainerByCondition;
138556
138878
  exports2.getColorFromAttributes = getColorFromAttributes;
138557
138879
  exports2.getColorFromContent = getColorFromContent;
138880
+ exports2.getColorsFromLocalStorage = getColorsFromLocalStorage;
138558
138881
  exports2.getComplexBlockClass = getComplexBlockClass;
138559
138882
  exports2.getContainerBlockOverrideOptions = getContainerBlockOverrideOptions;
138560
138883
  exports2.getContainerBlockPath = getContainerBlockPath;
@@ -138657,6 +138980,7 @@ ${data2.plantumlText}
138657
138980
  exports2.isBox = isBox;
138658
138981
  exports2.isBoxOp = isBoxOp;
138659
138982
  exports2.isCJK = isCJK;
138983
+ exports2.isCJKPunctuation = isCJKPunctuation;
138660
138984
  exports2.isChildContainer = isChildContainer;
138661
138985
  exports2.isChildNode = isChildNode;
138662
138986
  exports2.isClipboardEmpty = isClipboardEmpty$1;
@@ -138729,7 +139053,7 @@ ${data2.plantumlText}
138729
139053
  exports2.loadJs = loadJs;
138730
139054
  exports2.loadJsPromise = loadJsPromise;
138731
139055
  exports2.lockers = lockers;
138732
- exports2.logger = logger$4p;
139056
+ exports2.logger = logger$4q;
138733
139057
  exports2.markdownToDoc = markdownToDoc;
138734
139058
  exports2.mergeCommands = mergeCommands;
138735
139059
  exports2.mergeDocs = mergeDocs;