@ones-editor/editor 2.1.0-beta.4 → 2.1.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3433,9 +3433,6 @@ div.editor-root.readonly div.editor-content div[data-type=editor-container] div[
3433
3433
  }
3434
3434
  .comment-item-root:hover:not(.comment-item-editing) .item-head-tools {
3435
3435
  visibility: visible;
3436
- }
3437
- .comment-item-root.readonly .item-head-tools {
3438
- display: none;
3439
3436
  }.mobile-comment-item {
3440
3437
  margin-top: 4px;
3441
3438
  background-color: var(--editor-comment-layer-bg-color);
@@ -3691,9 +3688,6 @@ div.editor-root.readonly div.editor-content div[data-type=editor-container] div[
3691
3688
  .editor-web-comment-root .comment-groups-container .comment-group-item-root.active .item-head-switch {
3692
3689
  visibility: visible;
3693
3690
  }
3694
- .editor-web-comment-root .comment-groups-container .comment-group-item-root.readonly .comment-quick-reply {
3695
- display: none;
3696
- }
3697
3691
  .editor-mobile-comments-root {
3698
3692
  position: fixed;
3699
3693
  left: 0;
@@ -7358,7 +7352,7 @@ var __publicField = (obj, key, value) => {
7358
7352
  imageExportFailed: "\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F"
7359
7353
  }
7360
7354
  };
7361
- const logger$4z = getLogger("i18n");
7355
+ const logger$4A = getLogger("i18n");
7362
7356
  const langs$3 = {
7363
7357
  "en-US": enUS$x,
7364
7358
  "zh-CN": zhCN$x,
@@ -7378,7 +7372,7 @@ var __publicField = (obj, key, value) => {
7378
7372
  function t$8(key, args) {
7379
7373
  const ret = i18n.get(key, args);
7380
7374
  if (ret === key) {
7381
- logger$4z.warn(`no locale value for key ${key}`);
7375
+ logger$4A.warn(`no locale value for key ${key}`);
7382
7376
  }
7383
7377
  return ret;
7384
7378
  }
@@ -7991,7 +7985,7 @@ var __publicField = (obj, key, value) => {
7991
7985
  this._callbacks.clear();
7992
7986
  }
7993
7987
  }
7994
- const logger$4y = getLogger("await-locker");
7988
+ const logger$4z = getLogger("await-locker");
7995
7989
  class AwaitLock {
7996
7990
  constructor() {
7997
7991
  __publicField(this, "_acquired", false);
@@ -8033,7 +8027,7 @@ var __publicField = (obj, key, value) => {
8033
8027
  }
8034
8028
  if (this._waitingResolvers.length > 0) {
8035
8029
  const resolve = this._waitingResolvers.shift();
8036
- assert(logger$4y, resolve, "Resolver missing");
8030
+ assert(logger$4z, resolve, "Resolver missing");
8037
8031
  resolve(void 0);
8038
8032
  } else {
8039
8033
  this._acquired = false;
@@ -8116,7 +8110,7 @@ var __publicField = (obj, key, value) => {
8116
8110
  isMobileSafari: false
8117
8111
  };
8118
8112
  clientType.isMobileSafari = clientType.isMobile && clientType.isSafari;
8119
- const logger$4x = getLogger("dom-utils");
8113
+ const logger$4y = getLogger("dom-utils");
8120
8114
  function addClass(dom, ...className) {
8121
8115
  if (dom && dom.nodeType === Node.ELEMENT_NODE) {
8122
8116
  dom.classList.add(...className);
@@ -8170,7 +8164,7 @@ var __publicField = (obj, key, value) => {
8170
8164
  range.setStart(node, offset);
8171
8165
  return range;
8172
8166
  } catch (err) {
8173
- assert(logger$4x, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
8167
+ assert(logger$4y, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
8174
8168
  }
8175
8169
  }
8176
8170
  function createExpandedRange(startNode, startOffset, endNode, endOffset) {
@@ -8180,17 +8174,17 @@ var __publicField = (obj, key, value) => {
8180
8174
  range.setEnd(endNode, endOffset);
8181
8175
  return range;
8182
8176
  } catch (err) {
8183
- assert(logger$4x, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
8177
+ assert(logger$4y, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
8184
8178
  }
8185
8179
  }
8186
8180
  function getFirstClientRect(elem) {
8187
8181
  const rects = elem.getClientRects();
8188
- assert(logger$4x, rects.length >= 1, "getFirstClientRect: no rects");
8182
+ assert(logger$4y, rects.length >= 1, "getFirstClientRect: no rects");
8189
8183
  return rects[0];
8190
8184
  }
8191
8185
  function getLastClientRect(elem) {
8192
8186
  const rects = elem.getClientRects();
8193
- assert(logger$4x, rects.length >= 1, "getLastClientRect: no rects");
8187
+ assert(logger$4y, rects.length >= 1, "getLastClientRect: no rects");
8194
8188
  return rects[rects.length - 1];
8195
8189
  }
8196
8190
  function getDistanceSquare(rect, x, y) {
@@ -8237,7 +8231,7 @@ var __publicField = (obj, key, value) => {
8237
8231
  return 0;
8238
8232
  }
8239
8233
  if (!elem1.parentElement || !elem2.parentElement) {
8240
- assert(logger$4x, false, "invalid dom node to compare");
8234
+ assert(logger$4y, false, "invalid dom node to compare");
8241
8235
  }
8242
8236
  if (elem1.parentElement === elem2.parentElement) {
8243
8237
  const children = Array.from(elem1.parentElement.children);
@@ -8254,7 +8248,7 @@ var __publicField = (obj, key, value) => {
8254
8248
  const parents1 = getParents(elem1);
8255
8249
  const parents2 = getParents(elem2);
8256
8250
  if (parents1[0] !== parents2[0]) {
8257
- assert(logger$4x, false, "invalid dom node to compare, different tree");
8251
+ assert(logger$4y, false, "invalid dom node to compare, different tree");
8258
8252
  }
8259
8253
  for (let i = 1; ; i++) {
8260
8254
  const parent1 = parents1[i];
@@ -8797,7 +8791,7 @@ var __publicField = (obj, key, value) => {
8797
8791
  }
8798
8792
  }
8799
8793
  const MIN_DISTANCE_THRESHOLD$1 = 3;
8800
- const logger$4w = getLogger("drag-drop");
8794
+ const logger$4x = getLogger("drag-drop");
8801
8795
  class DragDrop {
8802
8796
  constructor(options) {
8803
8797
  __publicField(this, "dragStarted", false);
@@ -8817,7 +8811,7 @@ var __publicField = (obj, key, value) => {
8817
8811
  var _a;
8818
8812
  event.preventDefault();
8819
8813
  event.stopPropagation();
8820
- assert(logger$4w, this.mouseDownEvent, "no mouse down event");
8814
+ assert(logger$4x, this.mouseDownEvent, "no mouse down event");
8821
8815
  const deltaX = event.x - this.mouseDownEvent.x;
8822
8816
  const deltaY = event.y - this.mouseDownEvent.y;
8823
8817
  if (this.dragStarted) {
@@ -8831,7 +8825,7 @@ var __publicField = (obj, key, value) => {
8831
8825
  });
8832
8826
  __publicField(this, "handleMouseUp", (event) => {
8833
8827
  if (event.button === 0) {
8834
- assert(logger$4w, this.mouseDownEvent, "no mouse down event");
8828
+ assert(logger$4x, this.mouseDownEvent, "no mouse down event");
8835
8829
  const deltaX = event.x - this.mouseDownEvent.x;
8836
8830
  const deltaY = event.y - this.mouseDownEvent.y;
8837
8831
  this.onDragEnd(event, deltaX, deltaY);
@@ -8904,7 +8898,7 @@ var __publicField = (obj, key, value) => {
8904
8898
  const dragDrop = new DragDrop(options);
8905
8899
  return dragDrop;
8906
8900
  }
8907
- const logger$4v = getLogger("character");
8901
+ const logger$4w = getLogger("character");
8908
8902
  function checkChar(charCode, rangeList) {
8909
8903
  for (let i = 0; i < rangeList.length; i++) {
8910
8904
  const start = rangeList[i][0];
@@ -8951,7 +8945,7 @@ var __publicField = (obj, key, value) => {
8951
8945
  }
8952
8946
  function trimChar(s, char) {
8953
8947
  let c = char;
8954
- assert(logger$4v, c.length === 1, "invalid char length");
8948
+ assert(logger$4w, c.length === 1, "invalid char length");
8955
8949
  if (c === "]")
8956
8950
  c = "\\]";
8957
8951
  if (c === "\\")
@@ -9285,7 +9279,7 @@ var __publicField = (obj, key, value) => {
9285
9279
  const metrics = context.measureText(text2);
9286
9280
  return metrics.width + 4;
9287
9281
  }
9288
- const logger$4u = getLogger("editor-clipboard");
9282
+ const logger$4v = getLogger("editor-clipboard");
9289
9283
  async function setClipboardDataByEvent(items, event) {
9290
9284
  if (event.clipboardData) {
9291
9285
  const data2 = event.clipboardData;
@@ -9335,7 +9329,7 @@ var __publicField = (obj, key, value) => {
9335
9329
  document.body.removeChild(textarea2);
9336
9330
  return true;
9337
9331
  } catch (ex) {
9338
- logger$4u.error(ex);
9332
+ logger$4v.error(ex);
9339
9333
  document.body.removeChild(textarea2);
9340
9334
  return false;
9341
9335
  }
@@ -9356,7 +9350,7 @@ var __publicField = (obj, key, value) => {
9356
9350
  document.body.removeChild(div);
9357
9351
  return true;
9358
9352
  } catch (ex) {
9359
- logger$4u.error(ex);
9353
+ logger$4v.error(ex);
9360
9354
  document.body.removeChild(div);
9361
9355
  return false;
9362
9356
  }
@@ -9383,7 +9377,7 @@ var __publicField = (obj, key, value) => {
9383
9377
  await navigator.clipboard.write([clipboardItems]);
9384
9378
  return true;
9385
9379
  } catch (err) {
9386
- logger$4u.error(err);
9380
+ logger$4v.error(err);
9387
9381
  return await execCommandCopy(items);
9388
9382
  }
9389
9383
  }
@@ -9439,7 +9433,7 @@ var __publicField = (obj, key, value) => {
9439
9433
  a.click();
9440
9434
  a.remove();
9441
9435
  }
9442
- const logger$4t = getLogger("auto-scroll");
9436
+ const logger$4u = getLogger("auto-scroll");
9443
9437
  function scrollable(scrollElement, direction) {
9444
9438
  if (scrollElement.scrollHeight === scrollElement.clientHeight) {
9445
9439
  return false;
@@ -9463,7 +9457,7 @@ var __publicField = (obj, key, value) => {
9463
9457
  const isHorizontal = direction === "left" || direction === "right";
9464
9458
  const scroll = () => {
9465
9459
  if (!scrollable(scrollElement, direction)) {
9466
- logger$4t.debug("No need for scroll");
9460
+ logger$4u.debug("No need for scroll");
9467
9461
  return null;
9468
9462
  }
9469
9463
  if (isHorizontal) {
@@ -9521,7 +9515,7 @@ var __publicField = (obj, key, value) => {
9521
9515
  if (this.scrolling) {
9522
9516
  return;
9523
9517
  }
9524
- logger$4t.debug(`scroll direction: ${direction}`);
9518
+ logger$4u.debug(`scroll direction: ${direction}`);
9525
9519
  this.cancelScroll = continuousScroll(scrollElement, {
9526
9520
  direction,
9527
9521
  step
@@ -9772,7 +9766,7 @@ var __publicField = (obj, key, value) => {
9772
9766
  const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
9773
9767
  return ColorNames[colorIndex];
9774
9768
  }
9775
- const logger$4s = getLogger("container");
9769
+ const logger$4t = getLogger("container");
9776
9770
  function isContainer(elem) {
9777
9771
  return elem.getAttribute("data-type") === "editor-container";
9778
9772
  }
@@ -9784,9 +9778,9 @@ var __publicField = (obj, key, value) => {
9784
9778
  }
9785
9779
  function getContainerId(container) {
9786
9780
  const id = container.getAttribute("data-container-id");
9787
- assert(logger$4s, id, "no id for container");
9781
+ assert(logger$4t, id, "no id for container");
9788
9782
  if (isRootContainer(container)) {
9789
- assert(logger$4s, id === "root", `invalid root container id, : ${id}`);
9783
+ assert(logger$4t, id === "root", `invalid root container id, : ${id}`);
9790
9784
  }
9791
9785
  return id;
9792
9786
  }
@@ -9797,7 +9791,7 @@ var __publicField = (obj, key, value) => {
9797
9791
  function generateEditorContainerId(containerId) {
9798
9792
  return `ones-editor-container-${containerId}`;
9799
9793
  }
9800
- const logger$4r = getLogger("element");
9794
+ const logger$4s = getLogger("element");
9801
9795
  function createContainerElement(parent, type, containerId) {
9802
9796
  const container = createElement("div", [type], parent);
9803
9797
  container.setAttribute("data-type", "editor-container");
@@ -9808,7 +9802,7 @@ var __publicField = (obj, key, value) => {
9808
9802
  }
9809
9803
  function getContainerById(editor, containerId) {
9810
9804
  const container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
9811
- assert(logger$4r, container, `no container: ${containerId}`);
9805
+ assert(logger$4s, container, `no container: ${containerId}`);
9812
9806
  return container;
9813
9807
  }
9814
9808
  function getExistsContainerById(editor, containerId) {
@@ -9817,7 +9811,7 @@ var __publicField = (obj, key, value) => {
9817
9811
  }
9818
9812
  function getContainerBlocksElement(container) {
9819
9813
  const blocks = container.querySelector(":scope > .container-blocks");
9820
- assert(logger$4r, blocks, "no container blocks element");
9814
+ assert(logger$4s, blocks, "no container blocks element");
9821
9815
  return blocks;
9822
9816
  }
9823
9817
  function getContainerToolsElement(container) {
@@ -9830,11 +9824,11 @@ var __publicField = (obj, key, value) => {
9830
9824
  function isContainerBlocksElement(element) {
9831
9825
  return element.classList.contains("container-blocks");
9832
9826
  }
9833
- const logger$4q = getLogger("container-children");
9827
+ const logger$4r = getLogger("container-children");
9834
9828
  function getChildBlocks(container, traverseChild) {
9835
9829
  const content = getContainerBlocksElement(container);
9836
9830
  const blocks = Array.from(content.children);
9837
- assert(logger$4q, blocks.length > 0, "container have not any child block");
9831
+ assert(logger$4r, blocks.length > 0, "container have not any child block");
9838
9832
  if (traverseChild) {
9839
9833
  const { condition, editor } = traverseChild;
9840
9834
  return blocks.reduce((result, block) => {
@@ -9857,7 +9851,7 @@ var __publicField = (obj, key, value) => {
9857
9851
  }
9858
9852
  function getFirstChildBlock(container) {
9859
9853
  const block = container.querySelector(":scope > .container-blocks > div[data-type=editor-block]");
9860
- assert(logger$4q, block, "container have not any child block");
9854
+ assert(logger$4r, block, "container have not any child block");
9861
9855
  return block;
9862
9856
  }
9863
9857
  function getLastChildBlock(container) {
@@ -9869,7 +9863,7 @@ var __publicField = (obj, key, value) => {
9869
9863
  }
9870
9864
  function getBlockByIndex(container, blockIndex) {
9871
9865
  const block = getChildBlocks(container)[blockIndex];
9872
- assert(logger$4q, block, `container have not block at index ${blockIndex}`);
9866
+ assert(logger$4r, block, `container have not block at index ${blockIndex}`);
9873
9867
  return block;
9874
9868
  }
9875
9869
  function findBlockByIndex(container, blockIndex) {
@@ -9975,18 +9969,18 @@ var __publicField = (obj, key, value) => {
9975
9969
  });
9976
9970
  }
9977
9971
  }
9978
- const logger$4p = getLogger("block-class");
9972
+ const logger$4q = getLogger("block-class");
9979
9973
  function getBlockClass(editor, block) {
9980
9974
  return editor.editorBlocks.getBlockClass(getBlockType(block));
9981
9975
  }
9982
9976
  function getTextBlockClass(editor, block) {
9983
9977
  const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
9984
- assert(logger$4p, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
9978
+ assert(logger$4q, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
9985
9979
  return text2;
9986
9980
  }
9987
9981
  function getComplexBlockClass(editor, block) {
9988
9982
  const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
9989
- assert(logger$4p, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
9983
+ assert(logger$4q, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
9990
9984
  return complex;
9991
9985
  }
9992
9986
  function getBlockClassByType(editor, type) {
@@ -10187,7 +10181,7 @@ var __publicField = (obj, key, value) => {
10187
10181
  return { classes, attributes: newAttributes, styles: newStyles };
10188
10182
  }
10189
10183
  }
10190
- const logger$4o = getLogger("block-dom");
10184
+ const logger$4p = getLogger("block-dom");
10191
10185
  function isBlock(node) {
10192
10186
  if (!(node instanceof HTMLDivElement)) {
10193
10187
  return false;
@@ -10208,12 +10202,12 @@ var __publicField = (obj, key, value) => {
10208
10202
  }
10209
10203
  function getBlockId(block) {
10210
10204
  const { id } = block;
10211
- assert(logger$4o, id, "no block id");
10205
+ assert(logger$4p, id, "no block id");
10212
10206
  return id;
10213
10207
  }
10214
10208
  function getBlockType(block) {
10215
10209
  const type = block.getAttribute("data-block-type");
10216
- assert(logger$4o, type, "invalid block dom, no data-type");
10210
+ assert(logger$4p, type, "invalid block dom, no data-type");
10217
10211
  return type;
10218
10212
  }
10219
10213
  function getParentBlock(node) {
@@ -10236,12 +10230,12 @@ var __publicField = (obj, key, value) => {
10236
10230
  }
10237
10231
  function getParentContainer(block) {
10238
10232
  const container = block.closest("div[data-type=editor-container]");
10239
- assert(logger$4o, container, "failed to get block container");
10233
+ assert(logger$4p, container, "failed to get block container");
10240
10234
  return container;
10241
10235
  }
10242
10236
  function getBlockContent(block) {
10243
10237
  const content = block.querySelector(":scope >div[data-type=block-content]");
10244
- assert(logger$4o, content, "no block content");
10238
+ assert(logger$4p, content, "no block content");
10245
10239
  return content;
10246
10240
  }
10247
10241
  function getBlockTools(block) {
@@ -10250,7 +10244,7 @@ var __publicField = (obj, key, value) => {
10250
10244
  tools = createElement("div", [], block);
10251
10245
  tools.setAttribute("data-type", "block-tools");
10252
10246
  }
10253
- assert(logger$4o, tools, "no block tools");
10247
+ assert(logger$4p, tools, "no block tools");
10254
10248
  return tools;
10255
10249
  }
10256
10250
  function getExistsBlockTools(block) {
@@ -10271,7 +10265,7 @@ var __publicField = (obj, key, value) => {
10271
10265
  function createBlockElement(editor, path, data2) {
10272
10266
  const blockData = editor.editorDecorators.decorateBlock(path, data2);
10273
10267
  const { id, type } = blockData;
10274
- assert(logger$4o, id, "no block id");
10268
+ assert(logger$4p, id, "no block id");
10275
10269
  const elem = createElement("div", [`${type}-block`], null);
10276
10270
  elem.id = id;
10277
10271
  elem.setAttribute("data-type", "editor-block");
@@ -10309,7 +10303,7 @@ var __publicField = (obj, key, value) => {
10309
10303
  }
10310
10304
  function getBoxTypeFromElement(box) {
10311
10305
  const type = box.getAttribute("data-box-type");
10312
- assert(logger$4o, type, "not a valid box element, no type");
10306
+ assert(logger$4p, type, "not a valid box element, no type");
10313
10307
  return type;
10314
10308
  }
10315
10309
  function isBox(node) {
@@ -10320,7 +10314,7 @@ var __publicField = (obj, key, value) => {
10320
10314
  }
10321
10315
  function getBoxId(box) {
10322
10316
  const { id } = box;
10323
- assert(logger$4o, id, "no box id");
10317
+ assert(logger$4p, id, "no box id");
10324
10318
  return id;
10325
10319
  }
10326
10320
  function getParentBox(node) {
@@ -10342,7 +10336,7 @@ var __publicField = (obj, key, value) => {
10342
10336
  }
10343
10337
  function getBoxContent(box) {
10344
10338
  const content = box.querySelector("span[data-type=box-content]");
10345
- assert(logger$4o, content, "invalid box dom, no content");
10339
+ assert(logger$4p, content, "invalid box dom, no content");
10346
10340
  return content;
10347
10341
  }
10348
10342
  function createInsertionElement(type, id, attributes) {
@@ -10374,7 +10368,7 @@ var __publicField = (obj, key, value) => {
10374
10368
  }
10375
10369
  function getInsertionContent(insertion) {
10376
10370
  const content = insertion.querySelector("span[data-type=insertion-content]");
10377
- assert(logger$4o, content, "invalid insertion-child dom, no content");
10371
+ assert(logger$4p, content, "invalid insertion-child dom, no content");
10378
10372
  return content;
10379
10373
  }
10380
10374
  function getPrevBlock(block) {
@@ -10421,7 +10415,7 @@ var __publicField = (obj, key, value) => {
10421
10415
  const container = getParentContainer(block);
10422
10416
  const children = getChildBlocks(container);
10423
10417
  const index2 = children.indexOf(block);
10424
- assert(logger$4o, index2 !== -1, "invalid block & container dom, failed to get block index");
10418
+ assert(logger$4p, index2 !== -1, "invalid block & container dom, failed to get block index");
10425
10419
  return index2;
10426
10420
  }
10427
10421
  function isInBlock(target) {
@@ -10446,7 +10440,7 @@ var __publicField = (obj, key, value) => {
10446
10440
  function isTitleBlock$2(block) {
10447
10441
  return block.hasAttribute("data-document-title");
10448
10442
  }
10449
- const logger$4n = getLogger("text-block-child");
10443
+ const logger$4o = getLogger("text-block-child");
10450
10444
  function isTextBlockContentChild(elem) {
10451
10445
  if (elem.tagName !== "SPAN") {
10452
10446
  return false;
@@ -10454,14 +10448,14 @@ var __publicField = (obj, key, value) => {
10454
10448
  return true;
10455
10449
  }
10456
10450
  function isTextBlockContentBoxChild(elem) {
10457
- assert(logger$4n, isTextBlockContentChild(elem), "not a valid text child");
10451
+ assert(logger$4o, isTextBlockContentChild(elem), "not a valid text child");
10458
10452
  if (elem.getAttribute("data-type") === "editor-box") {
10459
10453
  return true;
10460
10454
  }
10461
10455
  return false;
10462
10456
  }
10463
10457
  function isTextBlockContentInsertionChild(elem) {
10464
- assert(logger$4n, isTextBlockContentChild(elem), "not a valid text child");
10458
+ assert(logger$4o, isTextBlockContentChild(elem), "not a valid text child");
10465
10459
  if (elem.getAttribute("data-type") === "editor-insertion") {
10466
10460
  return true;
10467
10461
  }
@@ -10471,7 +10465,7 @@ var __publicField = (obj, key, value) => {
10471
10465
  return !isTextBlockContentBoxChild(elem) && !isTextBlockContentInsertionChild(elem);
10472
10466
  }
10473
10467
  function getTextBlockContentChildType(child) {
10474
- assert(logger$4n, isTextBlockContentChild(child), "not a valid text child");
10468
+ assert(logger$4o, isTextBlockContentChild(child), "not a valid text child");
10475
10469
  if (isTextBlockContentBoxChild(child)) {
10476
10470
  return "box";
10477
10471
  }
@@ -10486,15 +10480,15 @@ var __publicField = (obj, key, value) => {
10486
10480
  return 0;
10487
10481
  if (type === "box")
10488
10482
  return 1;
10489
- assert(logger$4n, child.textContent !== null, "text block content is undefined");
10490
- assert(logger$4n, child.textContent.length >= 0, "text block content length is negative");
10483
+ assert(logger$4o, child.textContent !== null, "text block content is undefined");
10484
+ assert(logger$4o, child.textContent.length >= 0, "text block content length is negative");
10491
10485
  return child.textContent.length;
10492
10486
  }
10493
10487
  function getTextBlockContentChildren(block) {
10494
10488
  const content = getBlockContent(block);
10495
10489
  const children = Array.from(content.children);
10496
10490
  children.forEach((child) => {
10497
- assert(logger$4n, isTextBlockContentChild(child), "not a valid text child");
10491
+ assert(logger$4o, isTextBlockContentChild(child), "not a valid text child");
10498
10492
  });
10499
10493
  return children;
10500
10494
  }
@@ -10523,17 +10517,17 @@ var __publicField = (obj, key, value) => {
10523
10517
  };
10524
10518
  }
10525
10519
  const offset = blockOffset - start;
10526
- assert(logger$4n, offset > 0, "invalid offset value");
10527
- assert(logger$4n, !isTextBlockContentBoxChild(child), "invalid box child");
10520
+ assert(logger$4o, offset > 0, "invalid offset value");
10521
+ assert(logger$4o, !isTextBlockContentBoxChild(child), "invalid box child");
10528
10522
  return {
10529
10523
  prev: child,
10530
10524
  next: child,
10531
10525
  offset
10532
10526
  };
10533
10527
  }
10534
- assert(logger$4n, false, `invalid block child at position: ${blockOffset}`);
10528
+ assert(logger$4o, false, `invalid block child at position: ${blockOffset}`);
10535
10529
  }
10536
- const logger$4m = getLogger("block-path");
10530
+ const logger$4n = getLogger("block-path");
10537
10531
  function getBlockPath(block) {
10538
10532
  const ret = [];
10539
10533
  let current = block;
@@ -10547,26 +10541,26 @@ var __publicField = (obj, key, value) => {
10547
10541
  return ret;
10548
10542
  }
10549
10543
  const parentBlock = getParentBlock(container);
10550
- assert(logger$4m, parentBlock, "no parent block");
10544
+ assert(logger$4n, parentBlock, "no parent block");
10551
10545
  current = parentBlock;
10552
10546
  }
10553
- assert(logger$4m, false, "no parent block");
10547
+ assert(logger$4n, false, "no parent block");
10554
10548
  return [];
10555
10549
  }
10556
- const logger$4l = getLogger("child-container-path");
10550
+ const logger$4m = getLogger("child-container-path");
10557
10551
  function getContainerBlockPath(container) {
10558
10552
  if (isRootContainer(container)) {
10559
10553
  return [];
10560
10554
  }
10561
10555
  const parentBlock = getParentBlock(container);
10562
- assert(logger$4l, parentBlock, "no parent block");
10556
+ assert(logger$4m, parentBlock, "no parent block");
10563
10557
  return getBlockPath(parentBlock);
10564
10558
  }
10565
- const logger$4k = getLogger("load-blocks");
10559
+ const logger$4l = getLogger("load-blocks");
10566
10560
  function loadBlocks(editor, container, path) {
10567
10561
  const containerId = getContainerId(container);
10568
10562
  const blocks = getContainerBlocks$1(container, editor.doc);
10569
- assert(logger$4k, blocks.length > 0, "no blocks in container");
10563
+ assert(logger$4l, blocks.length > 0, "no blocks in container");
10570
10564
  const fragment = document.createDocumentFragment();
10571
10565
  blocks.forEach((b, index2) => {
10572
10566
  const block = editor.editorBlocks.createBlock([...path, { containerId, blockIndex: index2 }], container, b);
@@ -10582,7 +10576,7 @@ var __publicField = (obj, key, value) => {
10582
10576
  return block;
10583
10577
  }
10584
10578
  const blocks = getChildBlocks(container);
10585
- assert(logger$4k, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
10579
+ assert(logger$4l, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
10586
10580
  if (blockIndex === blocks.length) {
10587
10581
  containerBlocksElement.appendChild(block);
10588
10582
  } else {
@@ -10600,7 +10594,7 @@ var __publicField = (obj, key, value) => {
10600
10594
  insertBlockAt(container, blockIndex, block);
10601
10595
  return block;
10602
10596
  }
10603
- const logger$4j = getLogger("root-container");
10597
+ const logger$4k = getLogger("root-container");
10604
10598
  const MIN_DISTANCE_THRESHOLD = 3;
10605
10599
  class RootContainer {
10606
10600
  constructor(editor, rootContainer) {
@@ -10620,7 +10614,7 @@ var __publicField = (obj, key, value) => {
10620
10614
  this.editor.selection.updateSelection(null);
10621
10615
  this.editor.emit("resize", this.editor);
10622
10616
  } catch (err) {
10623
- logger$4j.warn(`failed to update selection while container resizing: ${err.message}`);
10617
+ logger$4k.warn(`failed to update selection while container resizing: ${err.message}`);
10624
10618
  }
10625
10619
  });
10626
10620
  __publicField(this, "handleClick", (event) => {
@@ -10653,7 +10647,7 @@ var __publicField = (obj, key, value) => {
10653
10647
  const box = getParentBox(elem);
10654
10648
  if (box) {
10655
10649
  const block2 = getParentBlock(box);
10656
- assert(logger$4j, block2, "no parent block");
10650
+ assert(logger$4k, block2, "no parent block");
10657
10651
  (_b = (_a = this.editor.editorBoxes.getBoxClass(getBoxTypeFromElement(box))) == null ? void 0 : _a.handleClickBox) == null ? void 0 : _b.call(_a, this.editor, box, event);
10658
10652
  return;
10659
10653
  }
@@ -10705,7 +10699,7 @@ var __publicField = (obj, key, value) => {
10705
10699
  }
10706
10700
  });
10707
10701
  __publicField(this, "handleMouseMove", (event) => {
10708
- assert(logger$4j, this.mouseDownEvent, "no mouse down event");
10702
+ assert(logger$4k, this.mouseDownEvent, "no mouse down event");
10709
10703
  const deltaX = event.x - this.mouseDownEvent.x;
10710
10704
  const deltaY = event.y - this.mouseDownEvent.y;
10711
10705
  if (Math.abs(deltaX) >= MIN_DISTANCE_THRESHOLD || Math.abs(deltaY) >= MIN_DISTANCE_THRESHOLD) {
@@ -10792,7 +10786,7 @@ var __publicField = (obj, key, value) => {
10792
10786
  loadBlocks(editor, container, path);
10793
10787
  return container;
10794
10788
  }
10795
- const logger$4i = getLogger("block");
10789
+ const logger$4j = getLogger("block");
10796
10790
  function getBlockTextLength$6(editor, block) {
10797
10791
  return getBlockClass(editor, block).getBlockTextLength(block);
10798
10792
  }
@@ -10811,7 +10805,7 @@ var __publicField = (obj, key, value) => {
10811
10805
  return block;
10812
10806
  }
10813
10807
  const parent = getParentBlock(container);
10814
- assert(logger$4i, parent, "no parent block exists for child container");
10808
+ assert(logger$4j, parent, "no parent block exists for child container");
10815
10809
  block = parent;
10816
10810
  }
10817
10811
  }
@@ -10847,7 +10841,7 @@ var __publicField = (obj, key, value) => {
10847
10841
  }
10848
10842
  return fun(editor, block, options);
10849
10843
  } catch (err) {
10850
- logger$4i.debug(`unsupported block type: ${type}`);
10844
+ logger$4j.debug(`unsupported block type: ${type}`);
10851
10845
  return null;
10852
10846
  }
10853
10847
  }
@@ -10867,7 +10861,7 @@ var __publicField = (obj, key, value) => {
10867
10861
  const styles = Object.fromEntries(Object.entries(data2).filter(([key]) => key.startsWith("style-")));
10868
10862
  Object.entries(styles).forEach(([, value]) => {
10869
10863
  const type = typeof value;
10870
- assert(logger$4i, type === "string" || type === "number" || type === "boolean", "invalid style value");
10864
+ assert(logger$4j, type === "string" || type === "number" || type === "boolean", "invalid style value");
10871
10865
  });
10872
10866
  return styles;
10873
10867
  }
@@ -10992,7 +10986,7 @@ var __publicField = (obj, key, value) => {
10992
10986
  }
10993
10987
  return { element: null, blockCommands: [], boxCommands: [] };
10994
10988
  }
10995
- const logger$4h = getLogger("embed-block-common");
10989
+ const logger$4i = getLogger("embed-block-common");
10996
10990
  function isColumnsBlock(block) {
10997
10991
  return getBlockType(block) === "layout";
10998
10992
  }
@@ -11000,9 +10994,9 @@ var __publicField = (obj, key, value) => {
11000
10994
  return getBlockType(block) === "embed";
11001
10995
  }
11002
10996
  function getEmbedType(block) {
11003
- assert(logger$4h, isEmbedBlock(block), "not an embed block");
10997
+ assert(logger$4i, isEmbedBlock(block), "not an embed block");
11004
10998
  const type = block.getAttribute("data-embed-type");
11005
- assert(logger$4h, type, "no embed data type");
10999
+ assert(logger$4i, type, "no embed data type");
11006
11000
  return type;
11007
11001
  }
11008
11002
  function getEmbedClassFromBlock(editor, block) {
@@ -11068,10 +11062,10 @@ var __publicField = (obj, key, value) => {
11068
11062
  data: (_c = overrideOptions == null ? void 0 : overrideOptions.data) != null ? _c : data2
11069
11063
  });
11070
11064
  }
11071
- const logger$4g = getLogger("execute-block-command");
11065
+ const logger$4h = getLogger("execute-block-command");
11072
11066
  function executeEmbedBlockCommand(editor, block, commandGroup, item) {
11073
11067
  var _a;
11074
- assert(logger$4g, isEmbedBlock(block), "not a embed block");
11068
+ assert(logger$4h, isEmbedBlock(block), "not a embed block");
11075
11069
  const embedType = getEmbedType(block);
11076
11070
  const embed = getEmbedClassByType(editor, embedType);
11077
11071
  if (!embed.getOptions) {
@@ -11104,14 +11098,14 @@ var __publicField = (obj, key, value) => {
11104
11098
  }
11105
11099
  return void 0;
11106
11100
  }
11107
- const logger$4f = getLogger("block-class");
11101
+ const logger$4g = getLogger("block-class");
11108
11102
  function isHeadingBlock$1(block) {
11109
11103
  return !!block.getAttribute("data-style-heading");
11110
11104
  }
11111
11105
  function getBlockHeading(block) {
11112
11106
  var _a;
11113
11107
  const heading = Number.parseInt((_a = block.getAttribute("data-style-heading")) != null ? _a : "", 10);
11114
- assert(logger$4f, heading, "not a heading block");
11108
+ assert(logger$4g, heading, "not a heading block");
11115
11109
  return heading;
11116
11110
  }
11117
11111
  function isExpandedHeadingBlock(block) {
@@ -11122,7 +11116,7 @@ var __publicField = (obj, key, value) => {
11122
11116
  }
11123
11117
  function getHeadingBlockChildren(block, oldHeading) {
11124
11118
  if (!oldHeading) {
11125
- assert(logger$4f, isHeadingBlock$1(block), "not a heading block");
11119
+ assert(logger$4g, isHeadingBlock$1(block), "not a heading block");
11126
11120
  }
11127
11121
  const children = [];
11128
11122
  const heading = oldHeading != null ? oldHeading : getBlockHeading(block);
@@ -11152,7 +11146,7 @@ var __publicField = (obj, key, value) => {
11152
11146
  }
11153
11147
  return children;
11154
11148
  }
11155
- const logger$4e = getLogger("complex-block-position");
11149
+ const logger$4f = getLogger("complex-block-position");
11156
11150
  class EditorComplexBlockPosition {
11157
11151
  constructor(block, childContainerId, custom) {
11158
11152
  __publicField(this, "blockId");
@@ -11161,7 +11155,7 @@ var __publicField = (obj, key, value) => {
11161
11155
  if (block instanceof HTMLElement) {
11162
11156
  this.blockId = getBlockId(block);
11163
11157
  } else {
11164
- assert(logger$4e, typeof block === "string", `not a valid block id: ${block}`);
11158
+ assert(logger$4f, typeof block === "string", `not a valid block id: ${block}`);
11165
11159
  this.blockId = block;
11166
11160
  }
11167
11161
  this.childContainerId = childContainerId;
@@ -11173,7 +11167,7 @@ var __publicField = (obj, key, value) => {
11173
11167
  return false;
11174
11168
  }
11175
11169
  }
11176
- const logger$4d = getLogger("simple-block-position");
11170
+ const logger$4e = getLogger("simple-block-position");
11177
11171
  class EditorSimpleBlockPosition {
11178
11172
  constructor(block, offset, type) {
11179
11173
  __publicField(this, "blockId");
@@ -11182,7 +11176,7 @@ var __publicField = (obj, key, value) => {
11182
11176
  if (block instanceof HTMLElement) {
11183
11177
  this.blockId = getBlockId(block);
11184
11178
  } else {
11185
- assert(logger$4d, typeof block === "string", `not a valid block id: ${block}`);
11179
+ assert(logger$4e, typeof block === "string", `not a valid block id: ${block}`);
11186
11180
  this.blockId = block;
11187
11181
  }
11188
11182
  this.offset = offset;
@@ -11192,7 +11186,7 @@ var __publicField = (obj, key, value) => {
11192
11186
  return true;
11193
11187
  }
11194
11188
  }
11195
- const logger$4c = getLogger("editor-position");
11189
+ const logger$4d = getLogger("editor-position");
11196
11190
  function createSimpleBlockPosition(block, offset, type) {
11197
11191
  return new EditorSimpleBlockPosition(block, offset, type);
11198
11192
  }
@@ -11214,7 +11208,7 @@ var __publicField = (obj, key, value) => {
11214
11208
  }
11215
11209
  const block1 = editor.getBlockById(pos1.blockId);
11216
11210
  const block2 = editor.getBlockById(pos2.blockId);
11217
- assert(logger$4c, block1 !== block2, "comparePosition: blocks are the same");
11211
+ assert(logger$4d, block1 !== block2, "comparePosition: blocks are the same");
11218
11212
  return compareElement(block1, block2);
11219
11213
  }
11220
11214
  if (isComplexBlockPosition(pos1) && isComplexBlockPosition(pos2)) {
@@ -11225,13 +11219,13 @@ var __publicField = (obj, key, value) => {
11225
11219
  }
11226
11220
  const container1 = editor.getContainerById(p1.childContainerId);
11227
11221
  const container2 = editor.getContainerById(p2.childContainerId);
11228
- assert(logger$4c, container1 !== container2, "comparePosition: containers are the same");
11222
+ assert(logger$4d, container1 !== container2, "comparePosition: containers are the same");
11229
11223
  return compareElement(container1, container2);
11230
11224
  }
11231
- assert(logger$4c, false, "invalid ");
11225
+ assert(logger$4d, false, "invalid ");
11232
11226
  return 0;
11233
11227
  }
11234
- const logger$4b = getLogger("simple-range");
11228
+ const logger$4c = getLogger("simple-range");
11235
11229
  class EditorSimpleSelectionRange {
11236
11230
  constructor(editor, options) {
11237
11231
  __publicField(this, "editor");
@@ -11280,11 +11274,11 @@ var __publicField = (obj, key, value) => {
11280
11274
  const { editor } = this;
11281
11275
  const startBlock = editor.getBlockById(this.start.blockId);
11282
11276
  const endBlock = editor.getBlockById(this.end.blockId);
11283
- assert(logger$4b, startBlock, "no start block");
11284
- assert(logger$4b, endBlock, "no end block");
11277
+ assert(logger$4c, startBlock, "no start block");
11278
+ assert(logger$4c, endBlock, "no end block");
11285
11279
  const startContainer = getParentContainer(startBlock);
11286
11280
  const endContainer = getParentContainer(endBlock);
11287
- assert(logger$4b, startContainer === endContainer, "invalid range");
11281
+ assert(logger$4c, startContainer === endContainer, "invalid range");
11288
11282
  const ret = [];
11289
11283
  if (startBlock === endBlock) {
11290
11284
  ret.push({
@@ -11295,7 +11289,7 @@ var __publicField = (obj, key, value) => {
11295
11289
  } else {
11296
11290
  const startIndex = getBlockIndex(startBlock);
11297
11291
  const endIndex = getBlockIndex(endBlock);
11298
- assert(logger$4b, startIndex < endIndex, "invalid range, start > index");
11292
+ assert(logger$4c, startIndex < endIndex, "invalid range, start > index");
11299
11293
  ret.push({
11300
11294
  block: startBlock,
11301
11295
  start: this.start,
@@ -11394,7 +11388,7 @@ var __publicField = (obj, key, value) => {
11394
11388
  clearSelection: clearSelection$6,
11395
11389
  convertTo: convertTo$m
11396
11390
  };
11397
- const logger$4a = getLogger("editor-blocks");
11391
+ const logger$4b = getLogger("editor-blocks");
11398
11392
  class EditorBlocks {
11399
11393
  constructor(editor) {
11400
11394
  __publicField(this, "blocks", /* @__PURE__ */ new Map());
@@ -11403,12 +11397,12 @@ var __publicField = (obj, key, value) => {
11403
11397
  registerBlockClass(blockClass) {
11404
11398
  const type = blockClass.blockType;
11405
11399
  const exists = this.blocks.get(type);
11406
- assert(logger$4a, !exists, `duplicated block type: ${type}`);
11400
+ assert(logger$4b, !exists, `duplicated block type: ${type}`);
11407
11401
  this.blocks.set(type, blockClass);
11408
11402
  }
11409
11403
  getBlockClass(type) {
11410
11404
  const exists = this.blocks.get(type);
11411
- assert(logger$4a, exists, `unknown block type: ${type}`);
11405
+ assert(logger$4b, exists, `unknown block type: ${type}`);
11412
11406
  return exists;
11413
11407
  }
11414
11408
  hasBlock(type) {
@@ -11424,7 +11418,7 @@ var __publicField = (obj, key, value) => {
11424
11418
  }
11425
11419
  const content = blockClass.createBlockContent(this.editor, path, container, blockElement, block);
11426
11420
  if (content.parentElement !== blockElement) {
11427
- logger$4a.warn("content parent is not block");
11421
+ logger$4b.warn("content parent is not block");
11428
11422
  blockElement.appendChild(content);
11429
11423
  }
11430
11424
  this.editor.blockHooks.forEach((hook) => {
@@ -11445,7 +11439,7 @@ var __publicField = (obj, key, value) => {
11445
11439
  return newBlock;
11446
11440
  }
11447
11441
  }
11448
- const logger$49 = getLogger("editor-embeds");
11442
+ const logger$4a = getLogger("editor-embeds");
11449
11443
  class EditorEmbeds {
11450
11444
  constructor(editor) {
11451
11445
  __publicField(this, "objects", /* @__PURE__ */ new Map());
@@ -11454,12 +11448,12 @@ var __publicField = (obj, key, value) => {
11454
11448
  registerEmbedClass(embedClass) {
11455
11449
  const type = embedClass.embedType;
11456
11450
  const exists = this.objects.get(type);
11457
- assert(logger$49, !exists, `duplicated embed object type: ${type}`);
11451
+ assert(logger$4a, !exists, `duplicated embed object type: ${type}`);
11458
11452
  this.objects.set(type, embedClass);
11459
11453
  }
11460
11454
  getEmbedClass(type) {
11461
11455
  const exists = this.objects.get(type);
11462
- assert(logger$49, exists, `unknown embed type: ${type}`);
11456
+ assert(logger$4a, exists, `unknown embed type: ${type}`);
11463
11457
  return exists;
11464
11458
  }
11465
11459
  getEmbedClassFromBlock(block) {
@@ -11469,12 +11463,12 @@ var __publicField = (obj, key, value) => {
11469
11463
  this.objects.forEach(callback);
11470
11464
  }
11471
11465
  }
11472
- const logger$48 = getLogger("embed-block");
11466
+ const logger$49 = getLogger("embed-block");
11473
11467
  function createBlockContent$6(editor, path, container, blockElement, blockData) {
11474
11468
  const content = createBlockContentElement(blockElement, "div");
11475
- assert(logger$48, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
11469
+ assert(logger$49, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
11476
11470
  const embedBlockData = blockData;
11477
- assert(logger$48, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
11471
+ assert(logger$49, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
11478
11472
  const embedClass = editor.editorEmbeds.getEmbedClass(embedBlockData.embedType);
11479
11473
  embedClass.createEmbedContent(editor, content, embedBlockData, path, container, blockElement);
11480
11474
  blockElement.setAttribute("data-embed-type", embedBlockData.embedType);
@@ -11638,18 +11632,18 @@ var __publicField = (obj, key, value) => {
11638
11632
  toStandardDoc: toStandardDoc$2,
11639
11633
  getResources: getResources$2
11640
11634
  };
11641
- const logger$47 = getLogger("complex-block-helper");
11635
+ const logger$48 = getLogger("complex-block-helper");
11642
11636
  function complexBlockGetAllChildContainers(editor, block, options) {
11643
11637
  const blockClass = getComplexBlockClass(editor, block);
11644
11638
  return blockClass.getChildContainers(editor, block, options);
11645
11639
  }
11646
11640
  function complexBlockGetSelectedContainers(editor, block, start, end) {
11647
11641
  if (start.isSimple()) {
11648
- assert(logger$47, end.isSimple(), "invalid start and end position");
11642
+ assert(logger$48, end.isSimple(), "invalid start and end position");
11649
11643
  return complexBlockGetAllChildContainers(editor, block);
11650
11644
  }
11651
- assert(logger$47, !start.isSimple(), "invalid start pos");
11652
- assert(logger$47, !end.isSimple(), "invalid end pos");
11645
+ assert(logger$48, !start.isSimple(), "invalid start pos");
11646
+ assert(logger$48, !end.isSimple(), "invalid end pos");
11653
11647
  const blockClass = getComplexBlockClass(editor, block);
11654
11648
  return blockClass.getSelectedContainers(editor, block, start, end);
11655
11649
  }
@@ -11660,11 +11654,11 @@ var __publicField = (obj, key, value) => {
11660
11654
  const parentComplexBlock = getParentBlock(getParentContainer(childBlock));
11661
11655
  if (!parentComplexBlock)
11662
11656
  return false;
11663
- assert(logger$47, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
11657
+ assert(logger$48, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
11664
11658
  const childContainer = getParentContainer(childBlock);
11665
11659
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
11666
11660
  const index2 = childContainers.indexOf(childContainer);
11667
- assert(logger$47, index2 >= 0, "not valid child container");
11661
+ assert(logger$48, index2 >= 0, "not valid child container");
11668
11662
  return index2 === 0;
11669
11663
  }
11670
11664
  function complexBlockGetFirstSimpleChild(editor, complexBlock, options) {
@@ -11717,13 +11711,13 @@ var __publicField = (obj, key, value) => {
11717
11711
  return block;
11718
11712
  }
11719
11713
  function findPrevSimpleBlockBeforeChildContainer(editor, childContainer, options) {
11720
- assert(logger$47, isChildContainer(childContainer), "not a child container");
11714
+ assert(logger$48, isChildContainer(childContainer), "not a child container");
11721
11715
  const parentComplexBlock = getParentBlock(childContainer);
11722
- assert(logger$47, parentComplexBlock, "no parent block");
11723
- assert(logger$47, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
11716
+ assert(logger$48, parentComplexBlock, "no parent block");
11717
+ assert(logger$48, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
11724
11718
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock, options);
11725
11719
  const containerIndex = childContainers.indexOf(childContainer);
11726
- assert(logger$47, containerIndex !== -1, "child container not found");
11720
+ assert(logger$48, containerIndex !== -1, "child container not found");
11727
11721
  if (containerIndex === 0) {
11728
11722
  const prevBlock = getPrevBlock(parentComplexBlock);
11729
11723
  if (!prevBlock)
@@ -11741,9 +11735,9 @@ var __publicField = (obj, key, value) => {
11741
11735
  return lastBlock2;
11742
11736
  }
11743
11737
  function complexBlockGetTopChildContainers(editor, complexBlock) {
11744
- assert(logger$47, isComplexKindBlock(editor, complexBlock), "not a complex block");
11738
+ assert(logger$48, isComplexKindBlock(editor, complexBlock), "not a complex block");
11745
11739
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
11746
- assert(logger$47, childContainers.length > 0, "no child container");
11740
+ assert(logger$48, childContainers.length > 0, "no child container");
11747
11741
  if (childContainers.length === 1) {
11748
11742
  return childContainers;
11749
11743
  }
@@ -11768,9 +11762,9 @@ var __publicField = (obj, key, value) => {
11768
11762
  return ret;
11769
11763
  }
11770
11764
  function complexBlockGetBottomChildContainers(editor, complexBlock) {
11771
- assert(logger$47, isComplexKindBlock(editor, complexBlock), "not a complex block");
11765
+ assert(logger$48, isComplexKindBlock(editor, complexBlock), "not a complex block");
11772
11766
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
11773
- assert(logger$47, childContainers.length > 0, "no child container");
11767
+ assert(logger$48, childContainers.length > 0, "no child container");
11774
11768
  if (childContainers.length === 1) {
11775
11769
  return childContainers;
11776
11770
  }
@@ -11813,8 +11807,8 @@ var __publicField = (obj, key, value) => {
11813
11807
  }
11814
11808
  function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
11815
11809
  const blockId = getBlockId(complexBlock);
11816
- assert(logger$47, blockId === anchor2.blockId, "invalid start pos");
11817
- assert(logger$47, blockId === focus.blockId, "invalid end pos");
11810
+ assert(logger$48, blockId === anchor2.blockId, "invalid start pos");
11811
+ assert(logger$48, blockId === focus.blockId, "invalid end pos");
11818
11812
  const blockClass = getComplexBlockClass(editor, complexBlock);
11819
11813
  if (blockClass.adjustSelectionPos) {
11820
11814
  return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
@@ -11897,13 +11891,13 @@ var __publicField = (obj, key, value) => {
11897
11891
  };
11898
11892
  }
11899
11893
  }
11900
- const logger$46 = getLogger("selection-range");
11894
+ const logger$47 = getLogger("selection-range");
11901
11895
  function createEditorSelectionRange(editor, options) {
11902
11896
  const { anchor: anchor2, focus } = options;
11903
11897
  if (anchor2 instanceof EditorSimpleBlockPosition && focus instanceof EditorSimpleBlockPosition) {
11904
11898
  return new EditorSimpleSelectionRange(editor, { anchor: anchor2, focus });
11905
11899
  }
11906
- assert(logger$46, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
11900
+ assert(logger$47, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
11907
11901
  return new EditorComplexSelectionRange(editor, { anchor: anchor2, focus });
11908
11902
  }
11909
11903
  function createBlockSimpleRange(editor, block, anchor2, focus) {
@@ -11925,7 +11919,7 @@ var __publicField = (obj, key, value) => {
11925
11919
  const focus = createSimpleBlockPosition(range.focus.blockId, range.focus.offset, "normal");
11926
11920
  return createEditorSelectionRange(editor, { anchor: anchor2, focus });
11927
11921
  }
11928
- const logger$45 = getLogger("range-from-point");
11922
+ const logger$46 = getLogger("range-from-point");
11929
11923
  function getBlockRangeFromPoint(editor, pointX, pointY) {
11930
11924
  const yOffsets = [0, -12, 12];
11931
11925
  let x = pointX;
@@ -11956,7 +11950,7 @@ var __publicField = (obj, key, value) => {
11956
11950
  const rect = elem.getBoundingClientRect();
11957
11951
  if (rect.width && rect.top && i === 0) {
11958
11952
  if (rect.left + rect.width < x || rect.top + rect.height < y) {
11959
- logger$45.debug("click on scrollbar, out of element rect");
11953
+ logger$46.debug("click on scrollbar, out of element rect");
11960
11954
  return null;
11961
11955
  }
11962
11956
  }
@@ -11994,7 +11988,7 @@ var __publicField = (obj, key, value) => {
11994
11988
  let block = getLastChildBlock(container);
11995
11989
  if (!isVisibleBlock(block)) {
11996
11990
  const preBlock = getPrevVisibleBlock(block);
11997
- assert(logger$45, preBlock, "container must have visible block");
11991
+ assert(logger$46, preBlock, "container must have visible block");
11998
11992
  block = preBlock;
11999
11993
  }
12000
11994
  const range = getBlockClass(editor, block).getRangeFromPoint(editor, block, x, block.getBoundingClientRect().bottom - 4);
@@ -12013,7 +12007,7 @@ var __publicField = (obj, key, value) => {
12013
12007
  if (range instanceof EditorSimpleSelectionRange) {
12014
12008
  return range;
12015
12009
  }
12016
- assert(logger$45, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
12010
+ assert(logger$46, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
12017
12011
  const complexRange = range;
12018
12012
  const container2 = editor.getContainerById(complexRange.start.childContainerId);
12019
12013
  return getRangeInContainer(editor, container2, x, y);
@@ -12082,11 +12076,11 @@ var __publicField = (obj, key, value) => {
12082
12076
  return result;
12083
12077
  }
12084
12078
  const anchor = "";
12085
- const logger$44 = getLogger("text-range");
12079
+ const logger$45 = getLogger("text-range");
12086
12080
  function getBlockRangeInfo(block, blockOffset) {
12087
12081
  const getChildRange = (child, offset) => {
12088
12082
  if (isTextBlockContentInsertionChild(child)) {
12089
- assert(logger$44, offset === 0, `invalid offset for insertion child: ${offset}`);
12083
+ assert(logger$45, offset === 0, `invalid offset for insertion child: ${offset}`);
12090
12084
  const childOffset = 2;
12091
12085
  return {
12092
12086
  child,
@@ -12095,7 +12089,7 @@ var __publicField = (obj, key, value) => {
12095
12089
  };
12096
12090
  }
12097
12091
  if (isTextBlockContentBoxChild(child)) {
12098
- assert(logger$44, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
12092
+ assert(logger$45, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
12099
12093
  const childOffset = offset === 0 ? 1 : 2;
12100
12094
  return {
12101
12095
  child,
@@ -12104,17 +12098,17 @@ var __publicField = (obj, key, value) => {
12104
12098
  };
12105
12099
  }
12106
12100
  const textNode = child.firstChild;
12107
- assert(logger$44, textNode, "no child node for text child");
12108
- assert(logger$44, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
12101
+ assert(logger$45, textNode, "no child node for text child");
12102
+ assert(logger$45, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
12109
12103
  if (textNode instanceof HTMLBRElement) {
12110
- assert(logger$44, offset >= 0 && offset <= 0, "invalid offset for text child");
12104
+ assert(logger$45, offset >= 0 && offset <= 0, "invalid offset for text child");
12111
12105
  return {
12112
12106
  child,
12113
12107
  container: textNode,
12114
12108
  offset
12115
12109
  };
12116
12110
  }
12117
- assert(logger$44, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
12111
+ assert(logger$45, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
12118
12112
  return {
12119
12113
  child,
12120
12114
  container: textNode,
@@ -12143,38 +12137,38 @@ var __publicField = (obj, key, value) => {
12143
12137
  }
12144
12138
  start += childLength;
12145
12139
  }
12146
- assert(logger$44, false, "failed to get range info");
12140
+ assert(logger$45, false, "failed to get range info");
12147
12141
  }
12148
12142
  function createChildRange(child, start, end) {
12149
12143
  if (start === end) {
12150
- assert(logger$44, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
12144
+ assert(logger$45, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
12151
12145
  } else {
12152
- assert(logger$44, start < end, `invalid start & end: ${start}, ${end}`);
12146
+ assert(logger$45, start < end, `invalid start & end: ${start}, ${end}`);
12153
12147
  }
12154
12148
  if (isTextBlockContentInsertionChild(child)) {
12155
- assert(logger$44, start === end, `invalid insertion child range offset: ${start}, ${end}`);
12156
- assert(logger$44, start === 0, `invalid insertion child range start: ${start}`);
12149
+ assert(logger$45, start === end, `invalid insertion child range offset: ${start}, ${end}`);
12150
+ assert(logger$45, start === 0, `invalid insertion child range start: ${start}`);
12157
12151
  const insertionElem = child;
12158
- assert(logger$44, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
12152
+ assert(logger$45, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
12159
12153
  const range = createExpandedRange(insertionElem, 1, insertionElem, 2);
12160
12154
  return range;
12161
12155
  }
12162
12156
  if (isTextBlockContentBoxChild(child)) {
12163
- assert(logger$44, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
12164
- assert(logger$44, start === 0, `invalid box child range start: ${start}`);
12157
+ assert(logger$45, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
12158
+ assert(logger$45, start === 0, `invalid box child range start: ${start}`);
12165
12159
  const box = child;
12166
- assert(logger$44, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
12160
+ assert(logger$45, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
12167
12161
  const range = createExpandedRange(box, 1, box, 2);
12168
12162
  return range;
12169
12163
  }
12170
12164
  const length = getTextBlockContentChildTextLength(child);
12171
- assert(logger$44, end <= length, `invalid child end: ${end}, ${length}`);
12165
+ assert(logger$45, end <= length, `invalid child end: ${end}, ${length}`);
12172
12166
  const textNode = child.firstChild;
12173
- assert(logger$44, textNode instanceof Text, "invalid block text child");
12174
- assert(logger$44, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
12167
+ assert(logger$45, textNode instanceof Text, "invalid block text child");
12168
+ assert(logger$45, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
12175
12169
  return createExpandedRange(textNode, start, textNode, end);
12176
12170
  }
12177
- const logger$43 = getLogger("caret-rect");
12171
+ const logger$44 = getLogger("caret-rect");
12178
12172
  function getChildClientRects(block, child) {
12179
12173
  if (isBox(child)) {
12180
12174
  const box = child;
@@ -12183,7 +12177,7 @@ var __publicField = (obj, key, value) => {
12183
12177
  const blockContent = getBlockContent(block);
12184
12178
  const lineHeight = Number.parseFloat(window.getComputedStyle(blockContent).lineHeight) || boxContent.getBoundingClientRect().height;
12185
12179
  const rects = Array.from(boxContent.getClientRects());
12186
- assert(logger$43, rects.length > 0, "no box client rects");
12180
+ assert(logger$44, rects.length > 0, "no box client rects");
12187
12181
  const blockRect = blockContent.getBoundingClientRect();
12188
12182
  const firstRect = rects[0];
12189
12183
  const lastRect = new DOMRect(blockRect.left, firstRect.bottom, 1, lineHeight);
@@ -12203,22 +12197,22 @@ var __publicField = (obj, key, value) => {
12203
12197
  const rect2 = getLastClientRect(ranges[0].child);
12204
12198
  return new DOMRect(rect2.right, rect2.top, 1, rect2.height);
12205
12199
  }
12206
- assert(logger$43, ranges[1], "invalid ranges");
12200
+ assert(logger$44, ranges[1], "invalid ranges");
12207
12201
  const rect = getFirstClientRect(ranges[1].child);
12208
12202
  return new DOMRect(rect.left, rect.top, 1, rect.height);
12209
12203
  }
12210
12204
  let rangeInfo = ranges[0];
12211
- assert(logger$43, ranges.length >= 1, "failed to get block range");
12205
+ assert(logger$44, ranges.length >= 1, "failed to get block range");
12212
12206
  if (ranges.length === 1) {
12213
12207
  rangeInfo = ranges[0];
12214
12208
  } else {
12215
- assert(logger$43, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
12209
+ assert(logger$44, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
12216
12210
  if (isTextBlockContentInsertionChild(ranges[ranges.length - 1].child)) {
12217
12211
  rangeInfo = ranges[ranges.length - 1];
12218
12212
  const child = rangeInfo.child;
12219
12213
  const content = getInsertionContent(child);
12220
12214
  const rects2 = content.getClientRects();
12221
- assert(logger$43, rects2.length >= 1, "no client rects for box content");
12215
+ assert(logger$44, rects2.length >= 1, "no client rects for box content");
12222
12216
  const rect = rects2[rects2.length - 1];
12223
12217
  return new DOMRect(rect.right, rect.y, 1, rect.height);
12224
12218
  }
@@ -12235,9 +12229,9 @@ var __publicField = (obj, key, value) => {
12235
12229
  }
12236
12230
  }
12237
12231
  if (rangeInfo.container instanceof HTMLBRElement) {
12238
- assert(logger$43, pos.offset === 0, "invalid offset for empty block text");
12232
+ assert(logger$44, pos.offset === 0, "invalid offset for empty block text");
12239
12233
  const parent = rangeInfo.container.parentElement;
12240
- assert(logger$43, parent, "invalid br parent");
12234
+ assert(logger$44, parent, "invalid br parent");
12241
12235
  const rect = parent.getBoundingClientRect();
12242
12236
  const ret = new DOMRect(rect.left, rect.top, 1, rect.height);
12243
12237
  return ret;
@@ -12245,11 +12239,11 @@ var __publicField = (obj, key, value) => {
12245
12239
  const range = createRange(rangeInfo.container, rangeInfo.offset);
12246
12240
  const rects = Array.from(range.getClientRects());
12247
12241
  if (rects.length === 0) {
12248
- assert(logger$43, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
12249
- assert(logger$43, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
12242
+ assert(logger$44, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
12243
+ assert(logger$44, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
12250
12244
  const child = rangeInfo.child;
12251
12245
  const rects2 = getChildClientRects(block, child);
12252
- assert(logger$43, rects2.length >= 1, "no client rects for box content");
12246
+ assert(logger$44, rects2.length >= 1, "no client rects for box content");
12253
12247
  if (rangeInfo.offset === 1) {
12254
12248
  const rect2 = rects2[0];
12255
12249
  return new DOMRect(rect2.x, rect2.y, 1, rect2.height);
@@ -12295,13 +12289,13 @@ var __publicField = (obj, key, value) => {
12295
12289
  });
12296
12290
  }
12297
12291
  }
12298
- assert(logger$43, rects.length > 0, "no client rects for range");
12292
+ assert(logger$44, rects.length > 0, "no client rects for range");
12299
12293
  if (pos.type === "home") {
12300
12294
  return rects[rects.length - 1];
12301
12295
  }
12302
12296
  return rects[0];
12303
12297
  }
12304
- const logger$42 = getLogger("core");
12298
+ const logger$43 = getLogger("core");
12305
12299
  function createBlockAnchor(editor, block, id, refClientRect) {
12306
12300
  const tools = getBlockTools(block);
12307
12301
  let elem = tools.querySelector(`.block-anchor[data-id=${id}]`);
@@ -12319,7 +12313,7 @@ var __publicField = (obj, key, value) => {
12319
12313
  return elem;
12320
12314
  }
12321
12315
  function createBlockCaretAnchor(editor, block, offset, id) {
12322
- assert(logger$42, isTextKindBlock(editor, block), "not a text kind block");
12316
+ assert(logger$43, isTextKindBlock(editor, block), "not a text kind block");
12323
12317
  const caretRect = getTextCaretRect(block, createSimpleBlockPosition(block, offset, "normal"));
12324
12318
  const blockRect = block.getBoundingClientRect();
12325
12319
  const tools = getBlockTools(block);
@@ -12678,19 +12672,19 @@ var __publicField = (obj, key, value) => {
12678
12672
  return result + (index2 ? "-" : "") + word.toLowerCase();
12679
12673
  });
12680
12674
  const kebabCase$1 = kebabCase;
12681
- const logger$41 = getLogger("box");
12675
+ const logger$42 = getLogger("box");
12682
12676
  function isBoxOp(op) {
12683
12677
  if (!op.attributes)
12684
12678
  return false;
12685
12679
  if (!op.attributes.box)
12686
12680
  return false;
12687
- assert(logger$41, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
12688
- assert(logger$41, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
12681
+ assert(logger$42, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
12682
+ assert(logger$42, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
12689
12683
  return true;
12690
12684
  }
12691
- const logger$40 = getLogger("text-op");
12685
+ const logger$41 = getLogger("text-op");
12692
12686
  function getOpLength(op) {
12693
- assert(logger$40, typeof op.insert === "string", "invalid op, no insert");
12687
+ assert(logger$41, typeof op.insert === "string", "invalid op, no insert");
12694
12688
  return op.insert.length;
12695
12689
  }
12696
12690
  function getOpAt(text2, offset) {
@@ -12698,7 +12692,7 @@ var __publicField = (obj, key, value) => {
12698
12692
  let pos = 0;
12699
12693
  for (let i = 0; i < ops.length; i++) {
12700
12694
  const op = ops[i];
12701
- assert(logger$40, typeof op.insert === "string", "invalid text op, no insert");
12695
+ assert(logger$41, typeof op.insert === "string", "invalid text op, no insert");
12702
12696
  const end = pos + getOpLength(op);
12703
12697
  if (end > offset) {
12704
12698
  return [op];
@@ -12714,22 +12708,22 @@ var __publicField = (obj, key, value) => {
12714
12708
  }
12715
12709
  return [];
12716
12710
  }
12717
- const logger$3$ = getLogger("rich-text-length");
12711
+ const logger$40 = getLogger("rich-text-length");
12718
12712
  function getTextOpLength(op) {
12719
- assert(logger$3$, typeof op.insert === "string", "op.insert is not string");
12713
+ assert(logger$40, typeof op.insert === "string", "op.insert is not string");
12720
12714
  return op.insert.length;
12721
12715
  }
12722
12716
  function getTextLength(ops) {
12723
12717
  let count = 0;
12724
12718
  ops.forEach((op) => {
12725
12719
  if (op.insert) {
12726
- assert(logger$3$, typeof op.insert === "string", "op.insert is not string");
12720
+ assert(logger$40, typeof op.insert === "string", "op.insert is not string");
12727
12721
  count += getTextOpLength(op);
12728
12722
  }
12729
12723
  });
12730
12724
  return count;
12731
12725
  }
12732
- const logger$3_ = getLogger("split-text");
12726
+ const logger$3$ = getLogger("split-text");
12733
12727
  function splitText(ops, offset, splitResult) {
12734
12728
  ops = cloneDeep__default.default(ops);
12735
12729
  if (offset === 0) {
@@ -12747,8 +12741,8 @@ var __publicField = (obj, key, value) => {
12747
12741
  let counted = 0;
12748
12742
  for (let i = 0; i < ops.length; i++) {
12749
12743
  const op = ops[i];
12750
- assert(logger$3_, typeof op === "object", `invalid op type, ${typeof op}`);
12751
- assert(logger$3_, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
12744
+ assert(logger$3$, typeof op === "object", `invalid op type, ${typeof op}`);
12745
+ assert(logger$3$, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
12752
12746
  const subLen = getTextOpLength(op);
12753
12747
  if (counted + subLen < offset) {
12754
12748
  counted += subLen;
@@ -12758,18 +12752,18 @@ var __publicField = (obj, key, value) => {
12758
12752
  right: ops.slice(i + 1)
12759
12753
  };
12760
12754
  } else {
12761
- assert(logger$3_, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
12755
+ assert(logger$3$, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
12762
12756
  const splitIndex = offset - counted;
12763
12757
  const copied = cloneDeep__default.default(op);
12764
- assert(logger$3_, copied.insert, "no copied.insert");
12765
- assert(logger$3_, typeof copied.insert === "string", "invalid copied.insert type");
12758
+ assert(logger$3$, copied.insert, "no copied.insert");
12759
+ assert(logger$3$, typeof copied.insert === "string", "invalid copied.insert type");
12766
12760
  copied.insert = copied.insert.substr(0, splitIndex);
12767
12761
  op.insert = op.insert.substr(splitIndex);
12768
12762
  if (copied.insert === "") {
12769
- assert(logger$3_, false, "invalid copied.insert, is empty string");
12763
+ assert(logger$3$, false, "invalid copied.insert, is empty string");
12770
12764
  }
12771
12765
  if (op.insert === "") {
12772
- assert(logger$3_, false, "invalid op.insert, is empty string");
12766
+ assert(logger$3$, false, "invalid op.insert, is empty string");
12773
12767
  }
12774
12768
  const right = [
12775
12769
  op,
@@ -12788,9 +12782,9 @@ var __publicField = (obj, key, value) => {
12788
12782
  throw new Error(`invalid split offset: ${offset}, ${JSON.stringify(ops)}`);
12789
12783
  }
12790
12784
  function splitToThree(text2, offset, length) {
12791
- assert(logger$3_, offset >= 0, "invalid offset, < 0");
12792
- assert(logger$3_, length > 0, "invalid length, <= 0");
12793
- assert(logger$3_, offset + length <= getTextLength(text2), "invalid offset + length < text length");
12785
+ assert(logger$3$, offset >= 0, "invalid offset, < 0");
12786
+ assert(logger$3$, length > 0, "invalid length, <= 0");
12787
+ assert(logger$3$, offset + length <= getTextLength(text2), "invalid offset + length < text length");
12794
12788
  const { left: temp, right } = splitText(text2, offset + length);
12795
12789
  const { left, right: middle } = splitText(temp, offset);
12796
12790
  return { left, middle, right };
@@ -13013,9 +13007,9 @@ var __publicField = (obj, key, value) => {
13013
13007
  }
13014
13008
  return [color, backgroundColor];
13015
13009
  }
13016
- const logger$3Z = getLogger("text-block-content");
13010
+ const logger$3_ = getLogger("text-block-content");
13017
13011
  function updateBlockContentCore(editor, blockPath, content, blockText, insertions) {
13018
- assert(logger$3Z, blockText, "no text for block");
13012
+ assert(logger$3_, blockText, "no text for block");
13019
13013
  if (blockText.length === 0 && (!insertions || insertions.size === 0)) {
13020
13014
  content.innerHTML = "<span><br></span>";
13021
13015
  return;
@@ -13047,9 +13041,9 @@ var __publicField = (obj, key, value) => {
13047
13041
  for (let i2 = 0; i2 < text2.length; i2++) {
13048
13042
  const op = text2[i2];
13049
13043
  if (isBoxOp(op)) {
13050
- assert(logger$3Z, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
13044
+ assert(logger$3_, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
13051
13045
  const span2 = editor.editorBoxes.createBox(content, op.attributes);
13052
- assert(logger$3Z, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
13046
+ assert(logger$3_, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
13053
13047
  const ret = editor.editorBlockRenders.renderBox(blockPath, op.attributes);
13054
13048
  if (ret.classes) {
13055
13049
  addClass(span2, ...ret.classes);
@@ -13067,7 +13061,7 @@ var __publicField = (obj, key, value) => {
13067
13061
  fragment.appendChild(span2);
13068
13062
  continue;
13069
13063
  }
13070
- assert(logger$3Z, op.insert, `no insert in op: ${JSON.stringify(op)}`);
13064
+ assert(logger$3_, op.insert, `no insert in op: ${JSON.stringify(op)}`);
13071
13065
  const span = createElement("span", ["text"], fragment, op.insert);
13072
13066
  if (op.attributes) {
13073
13067
  const ret = editor.editorBlockRenders.renderText(blockPath, op.attributes);
@@ -13098,7 +13092,7 @@ var __publicField = (obj, key, value) => {
13098
13092
  const compositionText = editor.compositingText;
13099
13093
  if (compositionText) {
13100
13094
  const pos = editor.selection.range.start;
13101
- assert(logger$3Z, pos.isSimple(), "not an simple position while compositing");
13095
+ assert(logger$3_, pos.isSimple(), "not an simple position while compositing");
13102
13096
  if (pos.blockId === blockId) {
13103
13097
  const attributes = getAttributesAt(text2, 0);
13104
13098
  insertions.set(pos.offset, [{
@@ -13114,11 +13108,11 @@ var __publicField = (obj, key, value) => {
13114
13108
  function clearAllTempCompositionText(editor) {
13115
13109
  const children = editor.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');
13116
13110
  if (children.length) {
13117
- logger$3Z.debug(`remove ${children.length} temp composition span`);
13111
+ logger$3_.debug(`remove ${children.length} temp composition span`);
13118
13112
  }
13119
13113
  Array.from(children).forEach((c) => c.remove());
13120
13114
  }
13121
- const logger$3Y = getLogger("client-rects");
13115
+ const logger$3Z = getLogger("client-rects");
13122
13116
  function getChildrenOffsets(block) {
13123
13117
  const children = getTextBlockContentChildren(block);
13124
13118
  let start = 0;
@@ -13136,15 +13130,15 @@ var __publicField = (obj, key, value) => {
13136
13130
  return ret;
13137
13131
  }
13138
13132
  function getChildrenInRange(editor, block, from, to) {
13139
- assert(logger$3Y, from < to, `invalid from & to: ${from}, ${to}`);
13133
+ assert(logger$3Z, from < to, `invalid from & to: ${from}, ${to}`);
13140
13134
  const blockLength = getBlockTextLength$6(editor, block);
13141
- assert(logger$3Y, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
13135
+ assert(logger$3Z, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
13142
13136
  const offsets = getChildrenOffsets(block);
13143
13137
  const startIndex = offsets.findIndex((c) => c.startBlockOffset <= from && from < c.endBlockOffset);
13144
13138
  const endIndex = offsets.findIndex((c) => c.startBlockOffset < to && to <= c.endBlockOffset);
13145
- assert(logger$3Y, startIndex !== -1, "failed to find start child");
13146
- assert(logger$3Y, endIndex !== -1, "failed to find end child");
13147
- assert(logger$3Y, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
13139
+ assert(logger$3Z, startIndex !== -1, "failed to find start child");
13140
+ assert(logger$3Z, endIndex !== -1, "failed to find end child");
13141
+ assert(logger$3Z, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
13148
13142
  if (startIndex === endIndex) {
13149
13143
  const child = offsets[startIndex];
13150
13144
  return [{
@@ -13219,20 +13213,20 @@ var __publicField = (obj, key, value) => {
13219
13213
  return rects;
13220
13214
  }
13221
13215
  function getRangeClientRects(editor, block, range) {
13222
- assert(logger$3Y, range instanceof EditorSimpleSelectionRange, "invalid range");
13216
+ assert(logger$3Z, range instanceof EditorSimpleSelectionRange, "invalid range");
13223
13217
  const start = range.start;
13224
13218
  const end = range.end;
13225
- assert(logger$3Y, start.isSimple(), "text block only allow simple position");
13226
- assert(logger$3Y, end.isSimple(), "text block only allow simple position");
13227
- assert(logger$3Y, start.blockId === end.blockId, "only allow update one text block selection");
13228
- assert(logger$3Y, start.blockId === getBlockId(block), "only allow update one text block selection");
13219
+ assert(logger$3Z, start.isSimple(), "text block only allow simple position");
13220
+ assert(logger$3Z, end.isSimple(), "text block only allow simple position");
13221
+ assert(logger$3Z, start.blockId === end.blockId, "only allow update one text block selection");
13222
+ assert(logger$3Z, start.blockId === getBlockId(block), "only allow update one text block selection");
13229
13223
  return getClientRects$2(editor, block, start, end);
13230
13224
  }
13231
- const logger$3X = getLogger("selection-background");
13225
+ const logger$3Y = getLogger("selection-background");
13232
13226
  function updateSelection$4(editor, block, start, end) {
13233
- assert(logger$3X, start.isSimple(), "text block only allow simple position");
13234
- assert(logger$3X, end.isSimple(), "text block only allow simple position");
13235
- assert(logger$3X, start.blockId === end.blockId, "only allow update one text block selection");
13227
+ assert(logger$3Y, start.isSimple(), "text block only allow simple position");
13228
+ assert(logger$3Y, end.isSimple(), "text block only allow simple position");
13229
+ assert(logger$3Y, start.blockId === end.blockId, "only allow update one text block selection");
13236
13230
  const from = start.offset;
13237
13231
  const to = end.offset;
13238
13232
  if (from === to) {
@@ -13280,7 +13274,7 @@ var __publicField = (obj, key, value) => {
13280
13274
  }
13281
13275
  });
13282
13276
  }
13283
- const logger$3W = getLogger("line-breaker");
13277
+ const logger$3X = getLogger("line-breaker");
13284
13278
  function mergeTextRects(rects) {
13285
13279
  const result = [];
13286
13280
  let lastRect = null;
@@ -13407,7 +13401,7 @@ var __publicField = (obj, key, value) => {
13407
13401
  }
13408
13402
  const textChild = child;
13409
13403
  const rects = mergeTextRects(textChild.getClientRects());
13410
- assert(logger$3W, rects.length > 0, "invalid text child dom");
13404
+ assert(logger$3X, rects.length > 0, "invalid text child dom");
13411
13405
  if (rects.length === 1) {
13412
13406
  const nextChild = children[i + 1];
13413
13407
  if (!nextChild) {
@@ -13432,10 +13426,10 @@ var __publicField = (obj, key, value) => {
13432
13426
  continue;
13433
13427
  }
13434
13428
  const textNode = textChild.firstChild;
13435
- assert(logger$3W, textNode, "invalid text child, no text node");
13436
- assert(logger$3W, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
13429
+ assert(logger$3X, textNode, "invalid text child, no text node");
13430
+ assert(logger$3X, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
13437
13431
  const textChildLength = getTextBlockContentChildTextLength(textChild);
13438
- assert(logger$3W, textNode.data.length === textChildLength, "text node data length not equal child text length");
13432
+ assert(logger$3X, textNode.data.length === textChildLength, "text node data length not equal child text length");
13439
13433
  const textRects = getTextRects(textNode);
13440
13434
  for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
13441
13435
  const rect = textRects[rIndex];
@@ -13477,7 +13471,7 @@ var __publicField = (obj, key, value) => {
13477
13471
  }
13478
13472
  }
13479
13473
  }
13480
- assert(logger$3W, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
13474
+ assert(logger$3X, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
13481
13475
  return {
13482
13476
  lineIndex: lineBreaks.length,
13483
13477
  lineBreaks
@@ -22250,7 +22244,7 @@ var __publicField = (obj, key, value) => {
22250
22244
  const Graphemer_1 = __importDefault(Graphemer$1);
22251
22245
  var _default = lib$1.default = Graphemer_1.default;
22252
22246
  const splitter = new _default();
22253
- const logger$3V = getLogger("text-offset");
22247
+ const logger$3W = getLogger("text-offset");
22254
22248
  function getChildOffset(block, child) {
22255
22249
  const children = getTextBlockContentChildren(block);
22256
22250
  let start = 0;
@@ -22266,26 +22260,26 @@ var __publicField = (obj, key, value) => {
22266
22260
  }
22267
22261
  start += testLength;
22268
22262
  }
22269
- assert(logger$3V, false, "can not find child in children");
22263
+ assert(logger$3W, false, "can not find child in children");
22270
22264
  }
22271
22265
  function isValidOffset(block, blockOffset) {
22272
- assert(logger$3V, blockOffset >= 0, `invalid offset: ${blockOffset}`);
22266
+ assert(logger$3W, blockOffset >= 0, `invalid offset: ${blockOffset}`);
22273
22267
  const childInfo = getTextBlockChild(block, blockOffset);
22274
22268
  const { prev, next, offset } = childInfo;
22275
22269
  if (!prev && !next) {
22276
- assert(logger$3V, false, "invalid offset, no prev & next child at offset");
22270
+ assert(logger$3W, false, "invalid offset, no prev & next child at offset");
22277
22271
  }
22278
22272
  if (prev !== next) {
22279
22273
  return true;
22280
22274
  }
22281
22275
  const child = prev;
22282
- assert(logger$3V, child, "no child");
22276
+ assert(logger$3W, child, "no child");
22283
22277
  if (isTextBlockContentBoxChild(child)) {
22284
- assert(logger$3V, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
22278
+ assert(logger$3W, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
22285
22279
  return true;
22286
22280
  }
22287
22281
  const text2 = child.textContent;
22288
- assert(logger$3V, text2, "no content for text child");
22282
+ assert(logger$3W, text2, "no content for text child");
22289
22283
  const chars = splitter.splitGraphemes(text2);
22290
22284
  const validOffsets = /* @__PURE__ */ new Set();
22291
22285
  let start = 0;
@@ -22315,7 +22309,7 @@ var __publicField = (obj, key, value) => {
22315
22309
  }
22316
22310
  function getNextValidOffset(block, blockOffset) {
22317
22311
  const length = getTextBlockLength(block);
22318
- assert(logger$3V, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
22312
+ assert(logger$3W, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
22319
22313
  if (blockOffset === length) {
22320
22314
  return length;
22321
22315
  }
@@ -22329,7 +22323,7 @@ var __publicField = (obj, key, value) => {
22329
22323
  }
22330
22324
  return ret;
22331
22325
  }
22332
- const logger$3U = getLogger("line-offset");
22326
+ const logger$3V = getLogger("line-offset");
22333
22327
  function getLineOffsets(block) {
22334
22328
  const lineBreaks = getLineBreaks(block);
22335
22329
  const ret = [];
@@ -22350,7 +22344,7 @@ var __publicField = (obj, key, value) => {
22350
22344
  }
22351
22345
  function getLineOffset(block, lineIndex) {
22352
22346
  const lines = getLineOffsets(block);
22353
- assert(logger$3U, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
22347
+ assert(logger$3V, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
22354
22348
  return lines[lineIndex];
22355
22349
  }
22356
22350
  function getLineOffsetByPos(block, pos) {
@@ -22407,7 +22401,7 @@ var __publicField = (obj, key, value) => {
22407
22401
  function getLineCount(block) {
22408
22402
  return getLineOffsets(block).length;
22409
22403
  }
22410
- const logger$3T = getLogger("find-text-position");
22404
+ const logger$3U = getLogger("find-text-position");
22411
22405
  function isWrappedLine(block, lineIndex) {
22412
22406
  const { start, end } = getLineOffset(block, lineIndex);
22413
22407
  const blockId = getBlockId(block);
@@ -22418,13 +22412,13 @@ var __publicField = (obj, key, value) => {
22418
22412
  return false;
22419
22413
  }
22420
22414
  const childInfo = getTextBlockChild(block, start);
22421
- assert(logger$3T, childInfo.next, "no next child at offset");
22422
- assert(logger$3T, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
22415
+ assert(logger$3U, childInfo.next, "no next child at offset");
22416
+ assert(logger$3U, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
22423
22417
  return true;
22424
22418
  }
22425
22419
  function getWrappedLineOffsets(block, lineIndex) {
22426
22420
  const blockId = getBlockId(block);
22427
- assert(logger$3T, isWrappedLine(block, lineIndex), "line is not wrapped");
22421
+ assert(logger$3U, isWrappedLine(block, lineIndex), "line is not wrapped");
22428
22422
  const { start, end } = getLineOffset(block, lineIndex);
22429
22423
  const homePos = createSimpleBlockPosition(blockId, start, "home");
22430
22424
  for (let offset = start + 1; offset <= end; offset += 1) {
@@ -22439,11 +22433,11 @@ var __publicField = (obj, key, value) => {
22439
22433
  return offset - 1;
22440
22434
  }
22441
22435
  }
22442
- assert(logger$3T, false, "failed to find wrapped offset");
22436
+ assert(logger$3U, false, "failed to find wrapped offset");
22443
22437
  return 0;
22444
22438
  }
22445
22439
  function findTextPositionInLine(editor, block, lineIndex, sourceBlock, pos, findDirection, suggestedX) {
22446
- assert(logger$3T, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
22440
+ assert(logger$3U, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
22447
22441
  const { start, end } = getLineOffset(block, lineIndex);
22448
22442
  let from = start;
22449
22443
  const blockId = getBlockId(block);
@@ -22485,11 +22479,11 @@ var __publicField = (obj, key, value) => {
22485
22479
  return retPos;
22486
22480
  }
22487
22481
  function findPrevTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
22488
- assert(logger$3T, isTextKindBlock(editor, block), "not a text block");
22482
+ assert(logger$3U, isTextKindBlock(editor, block), "not a text block");
22489
22483
  return findTextPositionInLine(editor, block, getLineCount(block) - 1, sourceBlock, pos, "up", suggestedX);
22490
22484
  }
22491
22485
  function findNextTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
22492
- assert(logger$3T, isTextKindBlock(editor, block), "not a text block");
22486
+ assert(logger$3U, isTextKindBlock(editor, block), "not a text block");
22493
22487
  return findTextPositionInLine(editor, block, 0, sourceBlock, pos, "down", suggestedX);
22494
22488
  }
22495
22489
  function moveDown(editor, block, position, suggestedX) {
@@ -22597,7 +22591,7 @@ var __publicField = (obj, key, value) => {
22597
22591
  }
22598
22592
  return pos;
22599
22593
  }
22600
- const logger$3S = getLogger("move-caret");
22594
+ const logger$3T = getLogger("move-caret");
22601
22595
  function moveTextCaret(editor, block, position, direction) {
22602
22596
  if (direction === "ArrowLeft") {
22603
22597
  const ret = moveLeft(block, position);
@@ -22627,9 +22621,9 @@ var __publicField = (obj, key, value) => {
22627
22621
  }
22628
22622
  return createSimpleBlockPosition(getBlockId(block), ret.offset, ret.type);
22629
22623
  }
22630
- assert(logger$3S, false, `invalid navigation direction: ${direction}`);
22624
+ assert(logger$3T, false, `invalid navigation direction: ${direction}`);
22631
22625
  }
22632
- const logger$3R = getLogger("text-range");
22626
+ const logger$3S = getLogger("text-range");
22633
22627
  function getBlockRects(block) {
22634
22628
  const ret = [];
22635
22629
  const children = getTextBlockContentChildren(block);
@@ -22705,9 +22699,9 @@ var __publicField = (obj, key, value) => {
22705
22699
  return null;
22706
22700
  }
22707
22701
  const children = getTextBlockContentChildren(block);
22708
- assert(logger$3R, children.indexOf(child) !== -1, "failed to find child in children");
22702
+ assert(logger$3S, children.indexOf(child) !== -1, "failed to find child in children");
22709
22703
  const offsetInfo = getChildOffset(block, child);
22710
- assert(logger$3R, offsetInfo, "failed to get child offset");
22704
+ assert(logger$3S, offsetInfo, "failed to get child offset");
22711
22705
  const { start } = offsetInfo;
22712
22706
  let offset;
22713
22707
  let length;
@@ -22718,7 +22712,7 @@ var __publicField = (obj, key, value) => {
22718
22712
  offset = start;
22719
22713
  length = 0;
22720
22714
  } else {
22721
- assert(logger$3R, child.firstChild instanceof Text, "child is not text");
22715
+ assert(logger$3S, child.firstChild instanceof Text, "child is not text");
22722
22716
  offset = start + textNodeOffsetFromPoint(child.firstChild, x, y);
22723
22717
  length = 0;
22724
22718
  }
@@ -22742,9 +22736,9 @@ var __publicField = (obj, key, value) => {
22742
22736
  }
22743
22737
  return new EditorSimpleSelectionRange(editor, { anchor: startPos, focus: endPos != null ? endPos : startPos });
22744
22738
  }
22745
- const logger$3Q = getLogger("create-text-op");
22739
+ const logger$3R = getLogger("create-text-op");
22746
22740
  function createTextOp(text2, attributes) {
22747
- assert(logger$3Q, text2, "text is empty");
22741
+ assert(logger$3R, text2, "text is empty");
22748
22742
  const ret = {
22749
22743
  insert: text2
22750
22744
  };
@@ -22767,7 +22761,7 @@ var __publicField = (obj, key, value) => {
22767
22761
  }
22768
22762
  return result;
22769
22763
  }
22770
- const logger$3P = getLogger("merge-ops");
22764
+ const logger$3Q = getLogger("merge-ops");
22771
22765
  function mergeOps(text2) {
22772
22766
  if (text2.length <= 1) {
22773
22767
  return text2;
@@ -22789,10 +22783,10 @@ var __publicField = (obj, key, value) => {
22789
22783
  return false;
22790
22784
  }
22791
22785
  if (op1.attributes === void 0) {
22792
- assert(logger$3P, op2.attributes === void 0, "op2.attributes is not undefined");
22786
+ assert(logger$3Q, op2.attributes === void 0, "op2.attributes is not undefined");
22793
22787
  return true;
22794
22788
  }
22795
- assert(logger$3P, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
22789
+ assert(logger$3Q, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
22796
22790
  return isEqual__default.default(op1.attributes, op2.attributes);
22797
22791
  };
22798
22792
  const newOps = [];
@@ -22801,8 +22795,8 @@ var __publicField = (obj, key, value) => {
22801
22795
  for (let i = 1; i < text2.length; i += 1) {
22802
22796
  const op = text2[i];
22803
22797
  if (isSameTypeOp(before, op)) {
22804
- assert(logger$3P, typeof before.insert === "string", "before.insert is not string");
22805
- assert(logger$3P, typeof op.insert === "string", "op.insert is not string");
22798
+ assert(logger$3Q, typeof before.insert === "string", "before.insert is not string");
22799
+ assert(logger$3Q, typeof op.insert === "string", "op.insert is not string");
22806
22800
  before.insert += op.insert;
22807
22801
  } else {
22808
22802
  newOps.push(op);
@@ -22830,15 +22824,15 @@ var __publicField = (obj, key, value) => {
22830
22824
  }
22831
22825
  return text2.slice(0, i + 1);
22832
22826
  }
22833
- const logger$3O = getLogger("delete-text");
22827
+ const logger$3P = getLogger("delete-text");
22834
22828
  function deleteText(richText2, offset, count) {
22835
22829
  const { left, right } = splitToThree(richText2, offset, count);
22836
22830
  const result = [...left, ...right];
22837
22831
  return mergeOps(result);
22838
22832
  }
22839
22833
  function createDeleteOps(offset, count) {
22840
- assert(logger$3O, offset >= 0, `invalid offset: ${offset}`);
22841
- assert(logger$3O, count >= 1, `invalid delete count: ${count}`);
22834
+ assert(logger$3P, offset >= 0, `invalid offset: ${offset}`);
22835
+ assert(logger$3P, count >= 1, `invalid delete count: ${count}`);
22842
22836
  const ops = [];
22843
22837
  if (offset !== 0) {
22844
22838
  ops.push({
@@ -22850,7 +22844,7 @@ var __publicField = (obj, key, value) => {
22850
22844
  });
22851
22845
  return ops;
22852
22846
  }
22853
- const logger$3N = getLogger("delta");
22847
+ const logger$3O = getLogger("delta");
22854
22848
  function diffRichText(oldText, newText) {
22855
22849
  const delta1D = new Delta__default.default(oldText);
22856
22850
  const delta2D = new Delta__default.default(newText);
@@ -22860,7 +22854,7 @@ var __publicField = (obj, key, value) => {
22860
22854
  return new Delta__default.default(ops).transformPosition(cursor, !isLocalOp);
22861
22855
  }
22862
22856
  function isValidDocText(text2) {
22863
- assert(logger$3N, text2, "ops is null or undefined");
22857
+ assert(logger$3O, text2, "ops is null or undefined");
22864
22858
  for (let i = 0; i < text2.length; i++) {
22865
22859
  const op = text2[i];
22866
22860
  if (op.insert === null || op.insert === void 0) {
@@ -22880,7 +22874,7 @@ var __publicField = (obj, key, value) => {
22880
22874
  }
22881
22875
  class RichText {
22882
22876
  static ensureValidText(text2) {
22883
- assert(logger$3N, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
22877
+ assert(logger$3O, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
22884
22878
  }
22885
22879
  static diff(oldText, newText) {
22886
22880
  this.ensureValidText(oldText);
@@ -22902,9 +22896,9 @@ var __publicField = (obj, key, value) => {
22902
22896
  return resultText;
22903
22897
  }
22904
22898
  }
22905
- const logger$3M = getLogger("insert-text");
22899
+ const logger$3N = getLogger("insert-text");
22906
22900
  function insertText(richText2, offset, text2, attributes) {
22907
- assert(logger$3M, text2, `invalid text to insert: ${text2}`);
22901
+ assert(logger$3N, text2, `invalid text to insert: ${text2}`);
22908
22902
  const { left, right } = splitText(richText2, offset);
22909
22903
  const insertedText = typeof text2 === "string" ? [createTextOp(text2, attributes)] : text2;
22910
22904
  const result = [...left, ...insertedText, ...right];
@@ -22917,7 +22911,7 @@ var __publicField = (obj, key, value) => {
22917
22911
  };
22918
22912
  }
22919
22913
  function createInsertOps(offset, text2, attributes) {
22920
- assert(logger$3M, offset >= 0, `invalid offset: ${offset}`);
22914
+ assert(logger$3N, offset >= 0, `invalid offset: ${offset}`);
22921
22915
  if (text2.length === 0) {
22922
22916
  return [];
22923
22917
  }
@@ -22947,7 +22941,7 @@ var __publicField = (obj, key, value) => {
22947
22941
  function cloneText(text2) {
22948
22942
  return cloneDeep__default.default(text2);
22949
22943
  }
22950
- const logger$3L = getLogger("update-op-attribute");
22944
+ const logger$3M = getLogger("update-op-attribute");
22951
22945
  function updateOpAttributes(orgOps, key, value, newAttributes) {
22952
22946
  const ops = cloneText(orgOps);
22953
22947
  const index2 = ops.findIndex((op2) => {
@@ -22955,7 +22949,7 @@ var __publicField = (obj, key, value) => {
22955
22949
  return false;
22956
22950
  return op2.attributes[key] === value;
22957
22951
  });
22958
- assert(logger$3L, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
22952
+ assert(logger$3M, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
22959
22953
  const op = ops[index2];
22960
22954
  op.attributes = {
22961
22955
  ...op.attributes,
@@ -23037,11 +23031,11 @@ var __publicField = (obj, key, value) => {
23037
23031
  ]);
23038
23032
  }
23039
23033
  const FILL_CHAR = "\u200B";
23040
- const logger$3K = getLogger("to-plain-text");
23034
+ const logger$3L = getLogger("to-plain-text");
23041
23035
  function toPlainText(ops, options) {
23042
23036
  let text2 = "";
23043
23037
  ops.forEach((op) => {
23044
- assert(logger$3K, typeof op.insert === "string", "invalid op");
23038
+ assert(logger$3L, typeof op.insert === "string", "invalid op");
23045
23039
  if (op.attributes && op.attributes.box === true) {
23046
23040
  if (options == null ? void 0 : options.boxReplacement) {
23047
23041
  text2 += options.boxReplacement;
@@ -23096,11 +23090,11 @@ var __publicField = (obj, key, value) => {
23096
23090
  focus: pos
23097
23091
  };
23098
23092
  }
23099
- const logger$3J = getLogger("block-to-text");
23093
+ const logger$3K = getLogger("block-to-text");
23100
23094
  function textBlockToText$1(editor, ops, doc2) {
23101
23095
  let text2 = "";
23102
23096
  ops.forEach((op) => {
23103
- assert(logger$3J, typeof op.insert === "string", "invalid op");
23097
+ assert(logger$3K, typeof op.insert === "string", "invalid op");
23104
23098
  if (op.attributes && op.attributes.box === true) {
23105
23099
  const box = op.attributes;
23106
23100
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -23118,11 +23112,11 @@ var __publicField = (obj, key, value) => {
23118
23112
  });
23119
23113
  return text2;
23120
23114
  }
23121
- const logger$3I = getLogger("block-to-text");
23115
+ const logger$3J = getLogger("block-to-text");
23122
23116
  function textToMarkdownText(editor, ops, doc2) {
23123
23117
  let text2 = "";
23124
23118
  ops.forEach((op) => {
23125
- assert(logger$3I, typeof op.insert === "string", "invalid op");
23119
+ assert(logger$3J, typeof op.insert === "string", "invalid op");
23126
23120
  if (op.attributes && op.attributes.box === true) {
23127
23121
  const box = op.attributes;
23128
23122
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -23245,11 +23239,11 @@ var __publicField = (obj, key, value) => {
23245
23239
  return void 0;
23246
23240
  }
23247
23241
  }
23248
- const logger$3H = getLogger("block-to-text");
23242
+ const logger$3I = getLogger("block-to-text");
23249
23243
  function textBlockToHtml(editor, ops, doc2) {
23250
23244
  let html = "";
23251
23245
  ops.forEach((op) => {
23252
- assert(logger$3H, typeof op.insert === "string", "invalid op");
23246
+ assert(logger$3I, typeof op.insert === "string", "invalid op");
23253
23247
  if (op.attributes && op.attributes.box === true) {
23254
23248
  const box = op.attributes;
23255
23249
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -23318,16 +23312,16 @@ var __publicField = (obj, key, value) => {
23318
23312
  }
23319
23313
  return `<p>${html}</p>`;
23320
23314
  }
23321
- const logger$3G = getLogger("text-block");
23315
+ const logger$3H = getLogger("text-block");
23322
23316
  function createBlockContent$5(editor, path, container, blockElement, blockData) {
23323
23317
  const { text: text2 } = blockData;
23324
- assert(logger$3G, text2, "no text for text block");
23318
+ assert(logger$3H, text2, "no text for text block");
23325
23319
  const content = createBlockContentElement(blockElement, "div");
23326
23320
  updateBlockContent$1(editor, path, blockData.id, content, text2);
23327
23321
  return content;
23328
23322
  }
23329
23323
  function updateBlockText$1(editor, block, text2) {
23330
- assert(logger$3G, text2, "no text to update");
23324
+ assert(logger$3H, text2, "no text to update");
23331
23325
  const newContent = createBlockContentElement(null, "div");
23332
23326
  updateBlockContent$1(editor, getBlockPath(block), getBlockId(block), newContent, text2);
23333
23327
  const oldContent = getBlockContent(block);
@@ -23354,7 +23348,7 @@ var __publicField = (obj, key, value) => {
23354
23348
  return res.trim();
23355
23349
  }
23356
23350
  function getBlockProperties$c(editor, block) {
23357
- assert(logger$3G, isTextKindBlock(editor, block), "block in not textBlock");
23351
+ assert(logger$3H, isTextKindBlock(editor, block), "block in not textBlock");
23358
23352
  const range = editor.selection.range;
23359
23353
  let abstract = "";
23360
23354
  if (range.isCollapsed()) {
@@ -23364,7 +23358,7 @@ var __publicField = (obj, key, value) => {
23364
23358
  const blockId = getBlockId(block);
23365
23359
  const selectedBlock = getAllSelectedBlocks(editor, { simpleBlockOnly: true }).find((b) => getBlockId(b.block) === blockId);
23366
23360
  if (selectedBlock && !isEmptyTextBlock(editor, selectedBlock.block)) {
23367
- assert(logger$3G, selectedBlock.block === block, "block not match");
23361
+ assert(logger$3H, selectedBlock.block === block, "block not match");
23368
23362
  const blockOps = editor.getBlockText(block);
23369
23363
  const { start, end } = selectedBlock;
23370
23364
  const offset = start.offset;
@@ -23380,7 +23374,7 @@ var __publicField = (obj, key, value) => {
23380
23374
  };
23381
23375
  }
23382
23376
  function convertTo$k(editor, blockData, doc2, type) {
23383
- assert(logger$3G, blockData.text, "no text for text block");
23377
+ assert(logger$3H, blockData.text, "no text for text block");
23384
23378
  if (type === "text") {
23385
23379
  return textBlockToText$1(editor, blockData.text, doc2);
23386
23380
  }
@@ -23394,7 +23388,7 @@ var __publicField = (obj, key, value) => {
23394
23388
  blockData.id = genId();
23395
23389
  info == null ? void 0 : info.blockIdMap.set(srcBlockData.id, blockData.id);
23396
23390
  const { text: text2 } = blockData;
23397
- assert(logger$3G, text2, "no text for text block");
23391
+ assert(logger$3H, text2, "no text for text block");
23398
23392
  text2.forEach((op) => {
23399
23393
  if (op.insert && op.attributes && op.attributes.box === true) {
23400
23394
  const boxId = genId();
@@ -23427,7 +23421,7 @@ var __publicField = (obj, key, value) => {
23427
23421
  blockToDoc: blockToDoc$1
23428
23422
  };
23429
23423
  const updateTextBlockContent = updateBlockContent$1;
23430
- const logger$3F = getLogger("action-helper");
23424
+ const logger$3G = getLogger("action-helper");
23431
23425
  function editorGetBlockData(editor, block) {
23432
23426
  const container = getParentContainer(block);
23433
23427
  const containerId = getContainerId(container);
@@ -23435,10 +23429,10 @@ var __publicField = (obj, key, value) => {
23435
23429
  return editor.doc.getBlockData(containerId, blockIndex);
23436
23430
  }
23437
23431
  function editorGetBlockText(editor, block) {
23438
- assert(logger$3F, isTextKindBlock(editor, block), "not a text kind block");
23432
+ assert(logger$3G, isTextKindBlock(editor, block), "not a text kind block");
23439
23433
  const data2 = editorGetBlockData(editor, block);
23440
23434
  const text2 = data2.text;
23441
- assert(logger$3F, text2, "no text in block");
23435
+ assert(logger$3G, text2, "no text in block");
23442
23436
  return text2;
23443
23437
  }
23444
23438
  function editorGetBlockTextEx(editor, block, length) {
@@ -23446,7 +23440,7 @@ var __publicField = (obj, key, value) => {
23446
23440
  }
23447
23441
  function editorGetBoxData(editor, box) {
23448
23442
  const block = getParentBlock(box);
23449
- assert(logger$3F, block, "no parent block");
23443
+ assert(logger$3G, block, "no parent block");
23450
23444
  const text2 = editorGetBlockText(editor, block);
23451
23445
  const id = getBoxId(box);
23452
23446
  const op = text2.find((op2) => {
@@ -23456,60 +23450,60 @@ var __publicField = (obj, key, value) => {
23456
23450
  }
23457
23451
  return false;
23458
23452
  });
23459
- assert(logger$3F, op, "failed to find box");
23453
+ assert(logger$3G, op, "failed to find box");
23460
23454
  return op.attributes;
23461
23455
  }
23462
- const logger$3E = getLogger("block-text");
23456
+ const logger$3F = getLogger("block-text");
23463
23457
  function getTextAfterOffset(editor, block, offset) {
23464
- assert(logger$3E, isTextKindBlock(editor, block), "not a text kind block");
23465
- assert(logger$3E, isValidOffset(block, offset), "not a valid offset");
23466
- assert(logger$3E, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
23458
+ assert(logger$3F, isTextKindBlock(editor, block), "not a text kind block");
23459
+ assert(logger$3F, isValidOffset(block, offset), "not a valid offset");
23460
+ assert(logger$3F, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
23467
23461
  const newOffset = getNextValidOffset(block, offset);
23468
23462
  const length = newOffset - offset;
23469
23463
  if (length === 0) {
23470
- assert(logger$3E, false, `no text after offset: ${offset}`);
23464
+ assert(logger$3F, false, `no text after offset: ${offset}`);
23471
23465
  }
23472
23466
  const text2 = editorGetBlockText(editor, block);
23473
23467
  const { middle } = splitToThree(text2, offset, length);
23474
- assert(logger$3E, middle.length === 1, "failed to split text to 3 parts");
23468
+ assert(logger$3F, middle.length === 1, "failed to split text to 3 parts");
23475
23469
  const op = middle[0];
23476
23470
  if (isBoxOp(op)) {
23477
23471
  return " ";
23478
23472
  }
23479
- assert(logger$3E, op.insert.length === 1 || op.insert.length === 2, "invalid op");
23473
+ assert(logger$3F, op.insert.length === 1 || op.insert.length === 2, "invalid op");
23480
23474
  return op.insert;
23481
23475
  }
23482
23476
  function getTextBeforeOffset(editor, block, offset) {
23483
- assert(logger$3E, isTextKindBlock(editor, block), "not a text kind block");
23484
- assert(logger$3E, isValidOffset(block, offset), "not a valid offset");
23485
- assert(logger$3E, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
23477
+ assert(logger$3F, isTextKindBlock(editor, block), "not a text kind block");
23478
+ assert(logger$3F, isValidOffset(block, offset), "not a valid offset");
23479
+ assert(logger$3F, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
23486
23480
  const newOffset = getPrevValidOffset(block, offset);
23487
23481
  const length = offset - newOffset;
23488
23482
  if (length === 0) {
23489
- assert(logger$3E, false, `no text before offset: ${offset}`);
23483
+ assert(logger$3F, false, `no text before offset: ${offset}`);
23490
23484
  }
23491
23485
  const text2 = editorGetBlockText(editor, block);
23492
23486
  const { middle } = splitToThree(text2, newOffset, length);
23493
- assert(logger$3E, middle.length === 1, "failed to split text to 3 parts");
23487
+ assert(logger$3F, middle.length === 1, "failed to split text to 3 parts");
23494
23488
  const op = middle[0];
23495
23489
  if (isBoxOp(op)) {
23496
23490
  return " ";
23497
23491
  }
23498
- assert(logger$3E, op.insert.length === 1 || op.insert.length === 2, "invalid op");
23492
+ assert(logger$3F, op.insert.length === 1 || op.insert.length === 2, "invalid op");
23499
23493
  return op.insert;
23500
23494
  }
23501
23495
  function getOffsetInfoBefore(editor, block, offset) {
23502
- assert(logger$3E, isTextKindBlock(editor, block), "not a text kind block");
23503
- assert(logger$3E, isValidOffset(block, offset), "not a valid offset");
23504
- assert(logger$3E, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
23496
+ assert(logger$3F, isTextKindBlock(editor, block), "not a text kind block");
23497
+ assert(logger$3F, isValidOffset(block, offset), "not a valid offset");
23498
+ assert(logger$3F, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
23505
23499
  const newOffset = getPrevValidOffset(block, offset);
23506
23500
  const length = offset - newOffset;
23507
23501
  if (length === 0) {
23508
- assert(logger$3E, false, `no text before offset: ${offset}`);
23502
+ assert(logger$3F, false, `no text before offset: ${offset}`);
23509
23503
  }
23510
23504
  const text2 = editorGetBlockText(editor, block);
23511
23505
  const { middle } = splitToThree(text2, newOffset, length);
23512
- assert(logger$3E, middle.length === 1, "failed to split text to 3 parts");
23506
+ assert(logger$3F, middle.length === 1, "failed to split text to 3 parts");
23513
23507
  const op = middle[0];
23514
23508
  if (isBoxOp(op)) {
23515
23509
  return {
@@ -23527,17 +23521,17 @@ var __publicField = (obj, key, value) => {
23527
23521
  };
23528
23522
  }
23529
23523
  function getOffsetInfoAfter(editor, block, offset) {
23530
- assert(logger$3E, isTextKindBlock(editor, block), "not a text kind block");
23531
- assert(logger$3E, isValidOffset(block, offset), "not a valid offset");
23532
- assert(logger$3E, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
23524
+ assert(logger$3F, isTextKindBlock(editor, block), "not a text kind block");
23525
+ assert(logger$3F, isValidOffset(block, offset), "not a valid offset");
23526
+ assert(logger$3F, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
23533
23527
  const newOffset = getNextValidOffset(block, offset);
23534
23528
  const length = newOffset - offset;
23535
23529
  if (length === 0) {
23536
- assert(logger$3E, false, `no text after offset: ${offset}`);
23530
+ assert(logger$3F, false, `no text after offset: ${offset}`);
23537
23531
  }
23538
23532
  const text2 = editorGetBlockText(editor, block);
23539
23533
  const { middle } = splitToThree(text2, offset, length);
23540
- assert(logger$3E, middle.length === 1, "failed to split text to 3 parts");
23534
+ assert(logger$3F, middle.length === 1, "failed to split text to 3 parts");
23541
23535
  const op = middle[0];
23542
23536
  if (isBoxOp(op)) {
23543
23537
  return {
@@ -23601,7 +23595,7 @@ var __publicField = (obj, key, value) => {
23601
23595
  return null;
23602
23596
  }
23603
23597
  function findWordLeft(editor, block, offset) {
23604
- assert(logger$3E, isTextKindBlock(editor, block), "invalid blok type");
23598
+ assert(logger$3F, isTextKindBlock(editor, block), "invalid blok type");
23605
23599
  if (isEmptyTextBlock(editor, block)) {
23606
23600
  return 0;
23607
23601
  }
@@ -23629,7 +23623,7 @@ var __publicField = (obj, key, value) => {
23629
23623
  return startInfo.offset + startInfo.length;
23630
23624
  }
23631
23625
  function findWordEnd(editor, block, offset) {
23632
- assert(logger$3E, isTextKindBlock(editor, block), "invalid blok type");
23626
+ assert(logger$3F, isTextKindBlock(editor, block), "invalid blok type");
23633
23627
  if (isEmptyTextBlock(editor, block)) {
23634
23628
  return 0;
23635
23629
  }
@@ -23656,10 +23650,10 @@ var __publicField = (obj, key, value) => {
23656
23650
  return getBlockTextLength$6(editor, block);
23657
23651
  return startInfo.offset;
23658
23652
  }
23659
- const logger$3D = getLogger("text-box");
23653
+ const logger$3E = getLogger("text-box");
23660
23654
  function updateBoxContent$8(editor, boxElement, boxContent, boxData) {
23661
- assert(logger$3D, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
23662
- assert(logger$3D, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
23655
+ assert(logger$3E, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
23656
+ assert(logger$3E, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
23663
23657
  createElement("span", [], boxContent, boxData.text);
23664
23658
  }
23665
23659
  function convertTo$j(editor, boxData, doc2, type) {
@@ -23693,7 +23687,7 @@ var __publicField = (obj, key, value) => {
23693
23687
  updateBoxContent: updateBoxContent$7,
23694
23688
  convertTo: convertTo$i
23695
23689
  };
23696
- const logger$3C = getLogger("editor-boxes");
23690
+ const logger$3D = getLogger("editor-boxes");
23697
23691
  class EditorBoxes {
23698
23692
  constructor(editor) {
23699
23693
  __publicField(this, "boxes", /* @__PURE__ */ new Map());
@@ -23702,12 +23696,12 @@ var __publicField = (obj, key, value) => {
23702
23696
  registerBoxClass(boxClass) {
23703
23697
  const type = boxClass.boxType;
23704
23698
  const exists = this.boxes.get(type);
23705
- assert(logger$3C, !exists, `duplicated box type: ${type}`);
23699
+ assert(logger$3D, !exists, `duplicated box type: ${type}`);
23706
23700
  this.boxes.set(type, boxClass);
23707
23701
  }
23708
23702
  getBoxClass(type) {
23709
23703
  const exists = this.boxes.get(type);
23710
- assert(logger$3C, exists, `unknown box type: ${type}`);
23704
+ assert(logger$3D, exists, `unknown box type: ${type}`);
23711
23705
  return exists;
23712
23706
  }
23713
23707
  createBox(blockContent, box) {
@@ -23758,7 +23752,7 @@ var __publicField = (obj, key, value) => {
23758
23752
  insertionType: "inputting",
23759
23753
  updateInsertionContent: updateInsertionContent$1
23760
23754
  };
23761
- const logger$3B = getLogger("editor-insertion");
23755
+ const logger$3C = getLogger("editor-insertion");
23762
23756
  class EditorInsertions {
23763
23757
  constructor(editor) {
23764
23758
  __publicField(this, "insertions", /* @__PURE__ */ new Map());
@@ -23767,12 +23761,12 @@ var __publicField = (obj, key, value) => {
23767
23761
  registerInsertionClass(insertionClass) {
23768
23762
  const type = insertionClass.insertionType;
23769
23763
  const exists = this.insertions.get(type);
23770
- assert(logger$3B, !exists, `duplicated insertion type: ${type}`);
23764
+ assert(logger$3C, !exists, `duplicated insertion type: ${type}`);
23771
23765
  this.insertions.set(type, insertionClass);
23772
23766
  }
23773
23767
  getInsertionClass(type) {
23774
23768
  const exists = this.insertions.get(type);
23775
- assert(logger$3B, exists, `unknown insertion type: ${type}`);
23769
+ assert(logger$3C, exists, `unknown insertion type: ${type}`);
23776
23770
  return exists;
23777
23771
  }
23778
23772
  createInsertion(blockContent, insertion) {
@@ -23878,7 +23872,7 @@ var __publicField = (obj, key, value) => {
23878
23872
  };
23879
23873
  }
23880
23874
  }
23881
- const logger$3A = getLogger("editor-input");
23875
+ const logger$3B = getLogger("editor-input");
23882
23876
  class EditorInput {
23883
23877
  constructor(editor, callbacks) {
23884
23878
  __publicField(this, "editor");
@@ -24000,7 +23994,7 @@ var __publicField = (obj, key, value) => {
24000
23994
  return;
24001
23995
  }
24002
23996
  this.callbacks.onCut(event);
24003
- logger$3A.debug("on cut");
23997
+ logger$3B.debug("on cut");
24004
23998
  });
24005
23999
  __publicField(this, "handlePaste", (event) => {
24006
24000
  if (event.isTrusted) {
@@ -24107,11 +24101,11 @@ var __publicField = (obj, key, value) => {
24107
24101
  this.callbacks.removeHandler(handler);
24108
24102
  }
24109
24103
  defaultInsertText(editor, containerId, blockIndex, offset, text2) {
24110
- assert(logger$3A, editor === this.editor, "invalid editor");
24104
+ assert(logger$3B, editor === this.editor, "invalid editor");
24111
24105
  this.callbacks.defaultInsertText(editor, containerId, blockIndex, offset, text2);
24112
24106
  }
24113
24107
  defaultHandleKeydown(editor, event) {
24114
- assert(logger$3A, editor === this.editor, "invalid editor");
24108
+ assert(logger$3B, editor === this.editor, "invalid editor");
24115
24109
  return this.callbacks.defaultHandleKeydown(editor, event);
24116
24110
  }
24117
24111
  forEach(callback) {
@@ -24136,7 +24130,7 @@ var __publicField = (obj, key, value) => {
24136
24130
  input2.style.left = `${x / scale}px`;
24137
24131
  input2.style.top = `${y / scale}px`;
24138
24132
  }
24139
- const logger$3z = getLogger("editor-caret");
24133
+ const logger$3A = getLogger("editor-caret");
24140
24134
  function getFirefoxVersion() {
24141
24135
  const userAgent = window.navigator.userAgent;
24142
24136
  const match = userAgent.match(/Firefox\/(\d+)\./);
@@ -24199,11 +24193,11 @@ var __publicField = (obj, key, value) => {
24199
24193
  return;
24200
24194
  }
24201
24195
  const { range } = this.editor.selection;
24202
- assert(logger$3z, range.isCollapsed, "range is not collapsed");
24196
+ assert(logger$3A, range.isCollapsed, "range is not collapsed");
24203
24197
  const pos = range.start;
24204
- assert(logger$3z, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
24198
+ assert(logger$3A, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
24205
24199
  const block = this.editor.getBlockById(pos.blockId);
24206
- assert(logger$3z, isTextKindBlock(this.editor, block), "only text kind block can has caret");
24200
+ assert(logger$3A, isTextKindBlock(this.editor, block), "only text kind block can has caret");
24207
24201
  let rect;
24208
24202
  const compositionSpan = block.querySelector("span.inputting-insertion");
24209
24203
  if (compositionSpan) {
@@ -24241,7 +24235,7 @@ var __publicField = (obj, key, value) => {
24241
24235
  clearAllSelection(editor);
24242
24236
  editor.selection.range.getSelectedBlocks().forEach((s) => updateBlockSelection(editor, s.block, s.start, s.end));
24243
24237
  }
24244
- const logger$3y = getLogger("editor-dom");
24238
+ const logger$3z = getLogger("editor-dom");
24245
24239
  function editorGetClientHeight(editor) {
24246
24240
  const scrollContainer = getScrollContainer$1(editor.rootContainer);
24247
24241
  return scrollContainer.clientHeight;
@@ -24322,7 +24316,7 @@ var __publicField = (obj, key, value) => {
24322
24316
  }
24323
24317
  function editorScrollIntoView(editor) {
24324
24318
  if (!isElementVisible(editor.rootContainer)) {
24325
- logger$3y.warn("editorScrollIntoView: editor is not visible");
24319
+ logger$3z.warn("editorScrollIntoView: editor is not visible");
24326
24320
  return;
24327
24321
  }
24328
24322
  const rootClientRect = editor.rootContainer.getBoundingClientRect();
@@ -24387,7 +24381,7 @@ var __publicField = (obj, key, value) => {
24387
24381
  const { start, end } = range;
24388
24382
  return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
24389
24383
  }
24390
- const logger$3x = getLogger("range-in-block");
24384
+ const logger$3y = getLogger("range-in-block");
24391
24385
  function rangeInBlock(block, range) {
24392
24386
  const editor = range.getEditor();
24393
24387
  const start = editor.getBlockById(range.start.blockId);
@@ -24408,16 +24402,16 @@ var __publicField = (obj, key, value) => {
24408
24402
  while (prevBlock && !blocks.has(getBlockId(prevBlock))) {
24409
24403
  prevBlock = getPrevVisibleBlock(prevBlock);
24410
24404
  }
24411
- assert(logger$3x, prevBlock, "no prev block while deleting a block");
24405
+ assert(logger$3y, prevBlock, "no prev block while deleting a block");
24412
24406
  newRange = createBlockSimpleRange(editor, prevBlock, getBlockTextLength$6(editor, prevBlock));
24413
24407
  } else {
24414
24408
  const nextBlock = getNextVisibleBlock(block);
24415
- assert(logger$3x, nextBlock, "no prev and next block while deleting a block");
24409
+ assert(logger$3y, nextBlock, "no prev and next block while deleting a block");
24416
24410
  newRange = createBlockSimpleRange(editor, nextBlock, 0);
24417
24411
  }
24418
24412
  return newRange;
24419
24413
  }
24420
- const logger$3w = getLogger("block-to-html");
24414
+ const logger$3x = getLogger("block-to-html");
24421
24415
  function blockToHtml(editor, blockData, doc2, path) {
24422
24416
  const blockClass = getBlockClassByType(editor, blockData.type);
24423
24417
  if (blockClass.convertTo) {
@@ -24426,15 +24420,15 @@ var __publicField = (obj, key, value) => {
24426
24420
  if (blockClass.blockKind !== "text") {
24427
24421
  return `[${blockData.type}]`;
24428
24422
  }
24429
- assert(logger$3w, blockData.text, "no text");
24423
+ assert(logger$3x, blockData.text, "no text");
24430
24424
  const plainText = toPlainText(blockData.text);
24431
24425
  return `<div>${escapeHtmlText(plainText)}</div>`;
24432
24426
  }
24433
- const logger$3v = getLogger("block-to-text");
24427
+ const logger$3w = getLogger("block-to-text");
24434
24428
  function textBlockToText(editor, ops, doc2) {
24435
24429
  let text2 = "";
24436
24430
  ops.forEach((op) => {
24437
- assert(logger$3v, typeof op.insert === "string", "invalid op");
24431
+ assert(logger$3w, typeof op.insert === "string", "invalid op");
24438
24432
  if (op.attributes && op.attributes.box === true) {
24439
24433
  const box = op.attributes;
24440
24434
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -24460,7 +24454,7 @@ var __publicField = (obj, key, value) => {
24460
24454
  if (blockClass.blockKind !== "text") {
24461
24455
  return `[${blockData.type}]`;
24462
24456
  }
24463
- assert(logger$3v, blockData.text, "no text");
24457
+ assert(logger$3w, blockData.text, "no text");
24464
24458
  const plainText = textBlockToText(editor, blockData.text, doc2);
24465
24459
  return plainText;
24466
24460
  }
@@ -24493,11 +24487,11 @@ var __publicField = (obj, key, value) => {
24493
24487
  const markdown = lines.join("\n");
24494
24488
  return markdown;
24495
24489
  }
24496
- const logger$3u = getLogger("get-text-position");
24490
+ const logger$3v = getLogger("get-text-position");
24497
24491
  function editorGetTextPosition(editor, insertPos) {
24498
24492
  const pos = insertPos != null ? insertPos : editor.selection.range.start;
24499
24493
  if (!(pos instanceof EditorSimpleBlockPosition)) {
24500
- assert(logger$3u, false, `invalid insert pos type: ${typeof pos}`);
24494
+ assert(logger$3v, false, `invalid insert pos type: ${typeof pos}`);
24501
24495
  }
24502
24496
  const { blockId } = pos;
24503
24497
  const block = editor.getBlockById(blockId);
@@ -24513,14 +24507,14 @@ var __publicField = (obj, key, value) => {
24513
24507
  offset
24514
24508
  };
24515
24509
  }
24516
- const logger$3t = getLogger("insert-text");
24510
+ const logger$3u = getLogger("insert-text");
24517
24511
  function getTextAttributes(editor, containerId, blockIndex, offset) {
24518
24512
  var _a;
24519
24513
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
24520
- assert(logger$3t, blockData, "no block data");
24521
- assert(logger$3t, blockData.text, "no block text");
24514
+ assert(logger$3u, blockData, "no block data");
24515
+ assert(logger$3u, blockData.text, "no block text");
24522
24516
  if (getTextLength(blockData.text) === 0) {
24523
- assert(logger$3t, offset === 0, "invalid text offset");
24517
+ assert(logger$3u, offset === 0, "invalid text offset");
24524
24518
  return editor.editorCommandProviders.getEmptyBlockTextAttributes(editor, blockData.id);
24525
24519
  }
24526
24520
  if (offset === 0) {
@@ -24562,7 +24556,7 @@ var __publicField = (obj, key, value) => {
24562
24556
  }
24563
24557
  for (let i = 0; i < text2.length; i++) {
24564
24558
  const op = text2[i];
24565
- assert(logger$3t, typeof op.insert === "string", "invalid text op, no insert");
24559
+ assert(logger$3u, typeof op.insert === "string", "invalid text op, no insert");
24566
24560
  const endPos = pos + getOpLength(op);
24567
24561
  if (endPos === start) {
24568
24562
  return false;
@@ -24576,8 +24570,8 @@ var __publicField = (obj, key, value) => {
24576
24570
  }
24577
24571
  function editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset) {
24578
24572
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
24579
- assert(logger$3t, blockData, "no block data");
24580
- assert(logger$3t, blockData.text, "no block text");
24573
+ assert(logger$3u, blockData, "no block data");
24574
+ assert(logger$3u, blockData.text, "no block text");
24581
24575
  const attributes = getTextAttributes(editor, containerId, blockIndex, offset);
24582
24576
  if (attributes && Object.keys(attributes).includes("link")) {
24583
24577
  const inOp = checkRangeInOp(blockData.text, offset);
@@ -24596,21 +24590,21 @@ var __publicField = (obj, key, value) => {
24596
24590
  const { containerId, blockIndex, offset } = editorGetTextPosition(editor);
24597
24591
  editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset);
24598
24592
  }
24599
- const logger$3s = getLogger("update-composition-text");
24593
+ const logger$3t = getLogger("update-composition-text");
24600
24594
  function editorUpdateCompositionText(editor) {
24601
24595
  const pos = editor.selection.range.start;
24602
24596
  if (!(pos instanceof EditorSimpleBlockPosition)) {
24603
- assert(logger$3s, false, `invalid insert pos type: ${typeof pos}`);
24597
+ assert(logger$3t, false, `invalid insert pos type: ${typeof pos}`);
24604
24598
  }
24605
24599
  const { blockId } = pos;
24606
24600
  const block = editor.getBlockById(blockId);
24607
- assert(logger$3s, isTextKindBlock(editor, block), "not a text kind block");
24601
+ assert(logger$3t, isTextKindBlock(editor, block), "not a text kind block");
24608
24602
  const container = getParentContainer(block);
24609
24603
  const containerId = getContainerId(container);
24610
24604
  const blockIndex = getBlockIndex(block);
24611
24605
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
24612
- assert(logger$3s, blockData, "no block data in doc");
24613
- assert(logger$3s, blockData.text, "no text data in text block");
24606
+ assert(logger$3t, blockData, "no block data in doc");
24607
+ assert(logger$3t, blockData.text, "no text data in text block");
24614
24608
  const blockContent = getBlockContent(block);
24615
24609
  updateBlockContent$1(editor, getBlockPath(block), blockId, blockContent, blockData.text);
24616
24610
  }
@@ -24622,25 +24616,25 @@ var __publicField = (obj, key, value) => {
24622
24616
  const block = editor.getBlockById(blockData.id);
24623
24617
  return block;
24624
24618
  }
24625
- const logger$3r = getLogger("delete-block-text");
24619
+ const logger$3s = getLogger("delete-block-text");
24626
24620
  function editorDeleteBlockText(editor, block, offset, count, options) {
24627
24621
  if (!editor.isBlockWritable(block)) {
24628
- logger$3r.error("block is not writable");
24622
+ logger$3s.error("block is not writable");
24629
24623
  return 0;
24630
24624
  }
24631
- assert(logger$3r, isTextKindBlock(editor, block), "block is not a text kind block");
24625
+ assert(logger$3s, isTextKindBlock(editor, block), "block is not a text kind block");
24632
24626
  const container = getParentContainer(block);
24633
24627
  const containerId = getContainerId(container);
24634
24628
  const blockIndex = getBlockIndex(block);
24635
24629
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
24636
- assert(logger$3r, blockData, "no block data in doc");
24637
- assert(logger$3r, blockData.text, "no text data in text block");
24630
+ assert(logger$3s, blockData, "no block data in doc");
24631
+ assert(logger$3s, blockData.text, "no text data in text block");
24638
24632
  let from = offset;
24639
24633
  if (!isValidOffset(block, offset)) {
24640
24634
  from = getPrevValidOffset(block, from);
24641
24635
  }
24642
24636
  let to = offset + count;
24643
- assert(logger$3r, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
24637
+ assert(logger$3s, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
24644
24638
  if (!isValidOffset(block, to)) {
24645
24639
  to = getNextValidOffset(block, to);
24646
24640
  }
@@ -24649,7 +24643,7 @@ var __publicField = (obj, key, value) => {
24649
24643
  editor.doc.localUpdateBlockText(containerId, blockIndex, actions2, options);
24650
24644
  return deleteCount;
24651
24645
  }
24652
- const logger$3q = getLogger("break-text-block");
24646
+ const logger$3r = getLogger("break-text-block");
24653
24647
  function copyBlockAttributes(editor, block) {
24654
24648
  const blockData = editor.getBlockData(block);
24655
24649
  const quoted = blockData.quoted;
@@ -24661,8 +24655,8 @@ var __publicField = (obj, key, value) => {
24661
24655
  return {};
24662
24656
  }
24663
24657
  function editorBreakTextBlock(editor, block, offset, options) {
24664
- assert(logger$3q, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
24665
- assert(logger$3q, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
24658
+ assert(logger$3r, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
24659
+ assert(logger$3r, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
24666
24660
  const container = getParentContainer(block);
24667
24661
  const containerId = getContainerId(container);
24668
24662
  const blockIndex = getBlockIndex(block);
@@ -24692,7 +24686,7 @@ var __publicField = (obj, key, value) => {
24692
24686
  };
24693
24687
  }
24694
24688
  }
24695
- assert(logger$3q, isValidOffset(block, offset), "not a valid offset");
24689
+ assert(logger$3r, isValidOffset(block, offset), "not a valid offset");
24696
24690
  const text2 = editorGetBlockText(editor, block);
24697
24691
  const { right } = splitText(text2, offset);
24698
24692
  const rightLength = getTextLength(right);
@@ -24718,12 +24712,12 @@ var __publicField = (obj, key, value) => {
24718
24712
  newBlock
24719
24713
  };
24720
24714
  }
24721
- const logger$3p = getLogger("prepare-insert-new-block");
24715
+ const logger$3q = getLogger("prepare-insert-new-block");
24722
24716
  function editorPrepareInsertNewBlock(editor, containerId, blockIndex) {
24723
24717
  if (containerId && blockIndex !== void 0 && blockIndex !== null) {
24724
24718
  const container = editor.getContainerById(containerId);
24725
24719
  const blocks = getChildBlocks(container);
24726
- assert(logger$3p, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
24720
+ assert(logger$3q, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
24727
24721
  return {
24728
24722
  containerId,
24729
24723
  blockIndex
@@ -24757,15 +24751,15 @@ var __publicField = (obj, key, value) => {
24757
24751
  blockIndex: getBlockIndex(newBlock)
24758
24752
  };
24759
24753
  }
24760
- const logger$3o = getLogger("auto-insert-block");
24754
+ const logger$3p = getLogger("auto-insert-block");
24761
24755
  function editorAutoInsertBlock(editor, blockData, containerId, blockIndex, newRange, insertBlockOptions) {
24762
24756
  const result = editorPrepareInsertNewBlock(editor, containerId, blockIndex);
24763
- assert(logger$3o, result, `not an valid insert position: ${editor.selection.range}`);
24757
+ assert(logger$3p, result, `not an valid insert position: ${editor.selection.range}`);
24764
24758
  const defaultPos = { blockId: blockData.id, offset: 0 };
24765
24759
  const defaultRange = { anchor: defaultPos, focus: defaultPos };
24766
24760
  return editorInsertBlock(editor, result.containerId, result.blockIndex, blockData, newRange != null ? newRange : defaultRange, insertBlockOptions);
24767
24761
  }
24768
- const logger$3n = getLogger("delete-block");
24762
+ const logger$3o = getLogger("delete-block");
24769
24763
  function getAllChildContainers(editor, blockData, containerIds) {
24770
24764
  if (blockData.children) {
24771
24765
  containerIds.push(...blockData.children);
@@ -24782,7 +24776,7 @@ var __publicField = (obj, key, value) => {
24782
24776
  const containerId = getContainerId(container);
24783
24777
  const blockIndex = getBlockIndex(block);
24784
24778
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
24785
- assert(logger$3n, blockData, "no block data in doc");
24779
+ assert(logger$3o, blockData, "no block data in doc");
24786
24780
  editor.doc.localDeleteBlock(containerId, blockIndex, createEditorSelectionRange(editor, { anchor: newRange.start, focus: newRange.end }));
24787
24781
  return blockData;
24788
24782
  }
@@ -24828,15 +24822,15 @@ var __publicField = (obj, key, value) => {
24828
24822
  });
24829
24823
  editor.doc.localDeleteChildContainers(containerIds);
24830
24824
  }
24831
- const logger$3m = getLogger("merge-text-block");
24825
+ const logger$3n = getLogger("merge-text-block");
24832
24826
  function editorMergeTextBlock(editor, block1, block2) {
24833
- assert(logger$3m, isTextKindBlock(editor, block1), "only text block can be merged");
24834
- assert(logger$3m, isTextKindBlock(editor, block2), "only text block can be merged");
24827
+ assert(logger$3n, isTextKindBlock(editor, block1), "only text block can be merged");
24828
+ assert(logger$3n, isTextKindBlock(editor, block2), "only text block can be merged");
24835
24829
  const data1 = editorGetBlockData(editor, block1);
24836
24830
  const data2 = editorGetBlockData(editor, block2);
24837
24831
  const text1 = data1.text;
24838
24832
  const text2 = data2.text;
24839
- assert(logger$3m, text1 && text2, "block data has no text");
24833
+ assert(logger$3n, text1 && text2, "block data has no text");
24840
24834
  const container = getParentContainer(block1);
24841
24835
  const containerId = getContainerId(container);
24842
24836
  const blockIndex = getBlockIndex(block1);
@@ -24846,15 +24840,15 @@ var __publicField = (obj, key, value) => {
24846
24840
  editorDeleteBlock(editor, block2, newRange);
24847
24841
  return block;
24848
24842
  }
24849
- const logger$3l = getLogger("clear-selected-contents");
24843
+ const logger$3m = getLogger("clear-selected-contents");
24850
24844
  function deleteTextBlockSelection(editor, selectedBlock) {
24851
- assert(logger$3l, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
24845
+ assert(logger$3m, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
24852
24846
  const { start, end } = selectedBlock;
24853
- assert(logger$3l, start.isSimple(), "not a simple block position");
24854
- assert(logger$3l, end.isSimple(), "not a simple block position");
24847
+ assert(logger$3m, start.isSimple(), "not a simple block position");
24848
+ assert(logger$3m, end.isSimple(), "not a simple block position");
24855
24849
  const startOffset = start.offset;
24856
24850
  const endOffset = end.offset;
24857
- assert(logger$3l, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
24851
+ assert(logger$3m, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
24858
24852
  if (startOffset === endOffset) {
24859
24853
  return;
24860
24854
  }
@@ -24879,7 +24873,7 @@ var __publicField = (obj, key, value) => {
24879
24873
  return;
24880
24874
  }
24881
24875
  if (isEmbedBlock(block) || start.isSimple()) {
24882
- assert(logger$3l, end.isSimple(), "invalid range");
24876
+ assert(logger$3m, end.isSimple(), "invalid range");
24883
24877
  const container = getParentContainer(block);
24884
24878
  const blockIndex = getBlockIndex(block);
24885
24879
  const newBlock = editor.insertTextBlock("", getContainerId(container), blockIndex);
@@ -24887,8 +24881,8 @@ var __publicField = (obj, key, value) => {
24887
24881
  editor.deleteBlock(block);
24888
24882
  return;
24889
24883
  }
24890
- assert(logger$3l, isComplexKindBlock(editor, block), "invalid block kind");
24891
- assert(logger$3l, !start.isSimple() && !end.isSimple(), "invalid range");
24884
+ assert(logger$3m, isComplexKindBlock(editor, block), "invalid block kind");
24885
+ assert(logger$3m, !start.isSimple() && !end.isSimple(), "invalid range");
24892
24886
  complexBlockGetSelectedContainers(editor, block, start, end);
24893
24887
  const containers = editor.selection.range.getSelectedContainers();
24894
24888
  containers.forEach((container, index2) => {
@@ -24906,7 +24900,7 @@ var __publicField = (obj, key, value) => {
24906
24900
  return;
24907
24901
  }
24908
24902
  const selectedBlocks = range.getSelectedBlocks();
24909
- assert(logger$3l, selectedBlocks.length > 0, "no selected block");
24903
+ assert(logger$3m, selectedBlocks.length > 0, "no selected block");
24910
24904
  if (selectedBlocks.length === 1) {
24911
24905
  clearOneBlock(editor, selectedBlocks[0]);
24912
24906
  return;
@@ -24914,7 +24908,7 @@ var __publicField = (obj, key, value) => {
24914
24908
  const firstSelectedBlock = selectedBlocks[0];
24915
24909
  const firstBlock = firstSelectedBlock.block;
24916
24910
  const container = getParentContainer(firstBlock);
24917
- assert(logger$3l, selectedBlocks.length > 1, "no selected block");
24911
+ assert(logger$3m, selectedBlocks.length > 1, "no selected block");
24918
24912
  const lastSelectedBlock = selectedBlocks[selectedBlocks.length - 1];
24919
24913
  const lastBlock2 = lastSelectedBlock.block;
24920
24914
  if (isTextKindBlock(editor, firstBlock)) {
@@ -24944,7 +24938,7 @@ var __publicField = (obj, key, value) => {
24944
24938
  }
24945
24939
  const prevBlock = getPrevBlock(firstBlock);
24946
24940
  const nextBlock = getNextBlock(lastBlock2);
24947
- assert(logger$3l, prevBlock || nextBlock, "no prev or next block");
24941
+ assert(logger$3m, prevBlock || nextBlock, "no prev or next block");
24948
24942
  selectedBlocks.forEach((selectedBlock) => editor.deleteBlock(selectedBlock.block));
24949
24943
  }
24950
24944
  function editorClearSelectedContents(editor) {
@@ -24963,7 +24957,7 @@ var __publicField = (obj, key, value) => {
24963
24957
  editor.emit("afterClearSelection", editor);
24964
24958
  });
24965
24959
  }
24966
- const logger$3k = getLogger("core");
24960
+ const logger$3l = getLogger("core");
24967
24961
  function editorUpdateBlockText(editor, block, ops, options) {
24968
24962
  const container = getParentContainer(block);
24969
24963
  const containerId = getContainerId(container);
@@ -24976,7 +24970,7 @@ var __publicField = (obj, key, value) => {
24976
24970
  }
24977
24971
  function editorSetBlockText(editor, block, newText, options) {
24978
24972
  if (!editor.isBlockWritable(block)) {
24979
- logger$3k.error("block is not writable");
24973
+ logger$3l.error("block is not writable");
24980
24974
  return;
24981
24975
  }
24982
24976
  const oldText = editor.getBlockText(block);
@@ -24989,7 +24983,7 @@ var __publicField = (obj, key, value) => {
24989
24983
  const ops = RichText.diff(oldText, newText);
24990
24984
  return editorUpdateBlockText(editor, block, ops);
24991
24985
  }
24992
- const logger$3j = getLogger("update-block-data");
24986
+ const logger$3k = getLogger("update-block-data");
24993
24987
  function editorUpdateBlockData(editor, block, data2, newRange, options) {
24994
24988
  const container = getParentContainer(block);
24995
24989
  const containerId = getContainerId(container);
@@ -25006,17 +25000,17 @@ var __publicField = (obj, key, value) => {
25006
25000
  if (oldKey === "id" || oldKey === "type" || oldKey === "text") {
25007
25001
  return;
25008
25002
  }
25009
- logger$3j.debug(`delete key: ${oldKey}`);
25003
+ logger$3k.debug(`delete key: ${oldKey}`);
25010
25004
  delta.delete.push(oldKey);
25011
25005
  }
25012
25006
  });
25013
25007
  const entries = Object.entries(data2);
25014
25008
  entries.forEach(([key, value]) => {
25015
- assert(logger$3j, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
25009
+ assert(logger$3k, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
25016
25010
  const oldValue = oldData[key];
25017
25011
  if (value === null || value === void 0) {
25018
25012
  if (oldValue !== null && oldValue !== void 0) {
25019
- logger$3j.debug(`delete key: ${key}`);
25013
+ logger$3k.debug(`delete key: ${key}`);
25020
25014
  delta.delete.push(key);
25021
25015
  }
25022
25016
  return;
@@ -25034,10 +25028,10 @@ var __publicField = (obj, key, value) => {
25034
25028
  }
25035
25029
  }
25036
25030
  if (oldKeys.has(key)) {
25037
- logger$3j.debug(`replace key: ${key}`);
25031
+ logger$3k.debug(`replace key: ${key}`);
25038
25032
  delta.delete.push(key);
25039
25033
  } else {
25040
- logger$3j.debug(`insert key: ${key}`);
25034
+ logger$3k.debug(`insert key: ${key}`);
25041
25035
  }
25042
25036
  delta.insert[key] = value;
25043
25037
  });
@@ -25082,13 +25076,13 @@ var __publicField = (obj, key, value) => {
25082
25076
  comments: {}
25083
25077
  };
25084
25078
  }
25085
- const logger$3i = getLogger("clone-block");
25079
+ const logger$3j = getLogger("clone-block");
25086
25080
  function cloneBlock(editorBlocks, oldDoc, data2, info) {
25087
25081
  var _a;
25088
25082
  const blockClass = editorBlocks.getBlockClass(data2.type);
25089
25083
  if (blockClass.blockToDoc) {
25090
25084
  return blockClass.blockToDoc(oldDoc, data2, (oldDoc2, childBlock) => {
25091
- assert(logger$3i, data2 !== childBlock, "invalid child block");
25085
+ assert(logger$3j, data2 !== childBlock, "invalid child block");
25092
25086
  return cloneBlock(editorBlocks, oldDoc2, data2, info);
25093
25087
  }, info);
25094
25088
  }
@@ -25101,7 +25095,7 @@ var __publicField = (obj, key, value) => {
25101
25095
  }
25102
25096
  const newChildContainerId = genId();
25103
25097
  const childBlocks = oldDoc.blocks[oldChildContainerId];
25104
- assert(logger$3i, Array.isArray(childBlocks), "invalid child blocks");
25098
+ assert(logger$3j, Array.isArray(childBlocks), "invalid child blocks");
25105
25099
  const newDocs = childBlocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
25106
25100
  const newDoc = mergeDocs(newDocs);
25107
25101
  const { root: root2, ...childContainersData } = newDoc.blocks;
@@ -25130,7 +25124,7 @@ var __publicField = (obj, key, value) => {
25130
25124
  if (key.startsWith(prefix1)) {
25131
25125
  const keyContent = key.substring(prefix1.length);
25132
25126
  const newKey = `${newContainerId}/${keyContent}`;
25133
- logger$3i.debug(`replace key: ${key} -> ${newKey}`);
25127
+ logger$3j.debug(`replace key: ${key} -> ${newKey}`);
25134
25128
  return newKey;
25135
25129
  }
25136
25130
  }
@@ -25139,7 +25133,7 @@ var __publicField = (obj, key, value) => {
25139
25133
  if (key.startsWith(prefix2)) {
25140
25134
  const keyContent = key.substring(prefix2.length);
25141
25135
  const newKey = `${newContainerId}_${keyContent}`;
25142
- logger$3i.debug(`replace key: ${key} -> ${newKey}`);
25136
+ logger$3j.debug(`replace key: ${key} -> ${newKey}`);
25143
25137
  return newKey;
25144
25138
  }
25145
25139
  }
@@ -25169,7 +25163,7 @@ var __publicField = (obj, key, value) => {
25169
25163
  }
25170
25164
  function cloneChildContainer(editorBlocks, oldDoc, containerId, info) {
25171
25165
  const blocks = oldDoc.blocks[containerId];
25172
- assert(logger$3i, Array.isArray(blocks), "invalid child blocks");
25166
+ assert(logger$3j, Array.isArray(blocks), "invalid child blocks");
25173
25167
  const newDocs = blocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
25174
25168
  const newDoc = mergeDocs(newDocs);
25175
25169
  return newDoc;
@@ -25178,10 +25172,10 @@ var __publicField = (obj, key, value) => {
25178
25172
  const docs = doc2.blocks.root.map((b) => cloneBlock(editor.editorBlocks, doc2, b, info));
25179
25173
  return cloneDeep__default.default(mergeDocs(docs));
25180
25174
  }
25181
- const logger$3h = getLogger("insert-doc");
25175
+ const logger$3i = getLogger("insert-doc");
25182
25176
  function editorInsertDoc(editor, block, offset, insertedDoc, cloneDocResult) {
25183
25177
  if (isComplexKindBlock(editor, block)) {
25184
- logger$3h.warn("failed to insert doc into a complex block");
25178
+ logger$3i.warn("failed to insert doc into a complex block");
25185
25179
  return;
25186
25180
  }
25187
25181
  const doc2 = cloneDoc(editor, insertedDoc, cloneDocResult);
@@ -25215,7 +25209,7 @@ var __publicField = (obj, key, value) => {
25215
25209
  }
25216
25210
  return;
25217
25211
  }
25218
- assert(logger$3h, isTextKindBlock(editor, block), "not a text block");
25212
+ assert(logger$3i, isTextKindBlock(editor, block), "not a text block");
25219
25213
  if (isEmptyTextBlock(editor, block)) {
25220
25214
  const blockIndex2 = getBlockIndex(block);
25221
25215
  let lastBlock22;
@@ -25347,11 +25341,11 @@ var __publicField = (obj, key, value) => {
25347
25341
  editor.deleteBlock(block);
25348
25342
  }
25349
25343
  }
25350
- const logger$3g = getLogger("add-text-attribute");
25344
+ const logger$3h = getLogger("add-text-attribute");
25351
25345
  function editorRemoveTextAttribute(editor, block, range, attributeName) {
25352
25346
  const { start, end } = range;
25353
- assert(logger$3g, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
25354
- assert(logger$3g, attributeName, "invalid attribute name");
25347
+ assert(logger$3h, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
25348
+ assert(logger$3h, attributeName, "invalid attribute name");
25355
25349
  const oldText = editor.getBlockText(block);
25356
25350
  const newText = rangeRemoveAttribute(start.offset, end.offset - start.offset, oldText, attributeName, void 0, { ignoreValue: true });
25357
25351
  editor.setBlockText(block, newText);
@@ -25359,8 +25353,8 @@ var __publicField = (obj, key, value) => {
25359
25353
  }
25360
25354
  function editorAddTextAttribute(editor, block, range, attributeName, value) {
25361
25355
  const { start, end } = range;
25362
- assert(logger$3g, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
25363
- assert(logger$3g, attributeName, "invalid attribute name");
25356
+ assert(logger$3h, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
25357
+ assert(logger$3h, attributeName, "invalid attribute name");
25364
25358
  const oldText = editor.getBlockText(block);
25365
25359
  const newText = rangeAddAttribute(start.offset, end.offset - start.offset, oldText, attributeName, value);
25366
25360
  editor.setBlockText(block, newText);
@@ -25368,7 +25362,7 @@ var __publicField = (obj, key, value) => {
25368
25362
  }
25369
25363
  function editorSetTextColor(editor, block, range, type, value) {
25370
25364
  const { start, end } = range;
25371
- assert(logger$3g, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
25365
+ assert(logger$3h, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
25372
25366
  const oldText = editor.getBlockText(block);
25373
25367
  const newText = rangeSetTextColor(start.offset, end.offset - start.offset, oldText, type, value);
25374
25368
  editor.setBlockText(block, newText);
@@ -25457,7 +25451,7 @@ var __publicField = (obj, key, value) => {
25457
25451
  });
25458
25452
  return [color, backgroundColor];
25459
25453
  }
25460
- const logger$3f = getLogger("adjust-selection-pos");
25454
+ const logger$3g = getLogger("adjust-selection-pos");
25461
25455
  function getParentContainers(block) {
25462
25456
  const containers = [];
25463
25457
  while (block) {
@@ -25467,10 +25461,10 @@ var __publicField = (obj, key, value) => {
25467
25461
  return containers;
25468
25462
  }
25469
25463
  const newBlock = getParentBlock(container);
25470
- assert(logger$3f, newBlock, "child container has not parent container");
25464
+ assert(logger$3g, newBlock, "child container has not parent container");
25471
25465
  block = newBlock;
25472
25466
  }
25473
- assert(logger$3f, false, "should not come here: getParentContainers");
25467
+ assert(logger$3g, false, "should not come here: getParentContainers");
25474
25468
  }
25475
25469
  function getParentBlockInContainer(container, block) {
25476
25470
  while (block) {
@@ -25479,16 +25473,16 @@ var __publicField = (obj, key, value) => {
25479
25473
  return block;
25480
25474
  }
25481
25475
  const newBlock = getParentBlock(parent);
25482
- assert(logger$3f, newBlock, "could not find parent block for a child container");
25476
+ assert(logger$3g, newBlock, "could not find parent block for a child container");
25483
25477
  block = newBlock;
25484
25478
  }
25485
- assert(logger$3f, false, "no parent block in specified container");
25479
+ assert(logger$3g, false, "no parent block in specified container");
25486
25480
  }
25487
25481
  function getClosestParentBlock(block1, block2) {
25488
25482
  const containers1 = getParentContainers(block1);
25489
25483
  const containers2 = getParentContainers(block2);
25490
- assert(logger$3f, containers1.length > 0 && containers2.length > 0, "block has not parent container");
25491
- assert(logger$3f, containers1[0] === containers2[0], "root container does not equal");
25484
+ assert(logger$3g, containers1.length > 0 && containers2.length > 0, "block has not parent container");
25485
+ assert(logger$3g, containers1[0] === containers2[0], "root container does not equal");
25492
25486
  let parentContainer = containers1[0];
25493
25487
  for (let i = 1; i < containers1.length || containers2.length; i++) {
25494
25488
  if (containers1[i] === containers2[i]) {
@@ -25507,18 +25501,18 @@ var __publicField = (obj, key, value) => {
25507
25501
  }
25508
25502
  function getParentContainerInComplexBlock(parentComplexBlock, element) {
25509
25503
  let block = getParentBlock(element);
25510
- assert(logger$3f, block, "element is not in a block");
25504
+ assert(logger$3g, block, "element is not in a block");
25511
25505
  while (block) {
25512
25506
  const container = getParentContainer(block);
25513
- assert(logger$3f, isChildContainer(container), "not a child container");
25507
+ assert(logger$3g, isChildContainer(container), "not a child container");
25514
25508
  const parentBlock = getParentBlock(container);
25515
- assert(logger$3f, parentBlock, "child container has not parent block");
25509
+ assert(logger$3g, parentBlock, "child container has not parent block");
25516
25510
  if (parentBlock === parentComplexBlock) {
25517
25511
  return container;
25518
25512
  }
25519
25513
  block = parentBlock;
25520
25514
  }
25521
- assert(logger$3f, false, "failed to find parent container in complex block");
25515
+ assert(logger$3g, false, "failed to find parent container in complex block");
25522
25516
  }
25523
25517
  function adjustSelectionPos$1(editor, anchor2, focus) {
25524
25518
  const anchorBlock = editor.getBlockById(anchor2.blockId);
@@ -25544,8 +25538,8 @@ var __publicField = (obj, key, value) => {
25544
25538
  if (focus instanceof EditorComplexBlockPosition) {
25545
25539
  focus = createSimpleBlockPosition(focusBlock, getBlockTextLength$6(editor, focusBlock), "end");
25546
25540
  }
25547
- assert(logger$3f, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
25548
- assert(logger$3f, focus instanceof EditorSimpleBlockPosition, "not valid position type");
25541
+ assert(logger$3g, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
25542
+ assert(logger$3g, focus instanceof EditorSimpleBlockPosition, "not valid position type");
25549
25543
  return {
25550
25544
  anchor: anchor2,
25551
25545
  focus
@@ -25580,7 +25574,7 @@ var __publicField = (obj, key, value) => {
25580
25574
  const focusChildContainer = getParentContainerInComplexBlock(parentComplexBlock, focusBlock);
25581
25575
  anchor2 = createComplexBlockPosition(newAnchorBlock, getContainerId(anchorChildContainer));
25582
25576
  focus = createComplexBlockPosition(newAnchorBlock, getContainerId(focusChildContainer));
25583
- logger$3f.debug(`select in complex block: ${anchorChildContainer.id}, ${focusChildContainer.id}`);
25577
+ logger$3g.debug(`select in complex block: ${anchorChildContainer.id}, ${focusChildContainer.id}`);
25584
25578
  return complexBlockAdjustSelectionPos(editor, parentComplexBlock, anchor2, focus);
25585
25579
  }
25586
25580
  let anchorOffsetNormal = reverse ? getBlockTextLength$6(editor, newAnchorBlock) : 0;
@@ -25600,10 +25594,10 @@ var __publicField = (obj, key, value) => {
25600
25594
  focus
25601
25595
  };
25602
25596
  }
25603
- const logger$3e = getLogger("move-complex-block-position");
25597
+ const logger$3f = getLogger("move-complex-block-position");
25604
25598
  function moveComplexBlockPosition(editor, old, type) {
25605
25599
  const block = editor.getBlockById(old.blockId);
25606
- assert(logger$3e, isComplexKindBlock(editor, block), "is not a complex block");
25600
+ assert(logger$3f, isComplexKindBlock(editor, block), "is not a complex block");
25607
25601
  const blockClass = getComplexBlockClass(editor, block);
25608
25602
  const focusedContainer = editor.getContainerById(old.childContainerId);
25609
25603
  const nextContainer = blockClass.getNextContainer(editor, block, focusedContainer, type, { noWrap: true });
@@ -25612,24 +25606,24 @@ var __publicField = (obj, key, value) => {
25612
25606
  }
25613
25607
  return createComplexBlockPosition(block, getContainerId(nextContainer));
25614
25608
  }
25615
- const logger$3d = getLogger("move-simple-block-position");
25609
+ const logger$3e = getLogger("move-simple-block-position");
25616
25610
  function getFirstChildBlockInComplexBlock(editor, complexBlock) {
25617
25611
  const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
25618
25612
  if (containers.length === 0) {
25619
- logger$3d.warn("complex block has not any child container, not loaded?");
25613
+ logger$3e.warn("complex block has not any child container, not loaded?");
25620
25614
  return null;
25621
25615
  }
25622
- assert(logger$3d, containers.length > 0, "complex block has not any child container");
25616
+ assert(logger$3e, containers.length > 0, "complex block has not any child container");
25623
25617
  const container = containers[0];
25624
25618
  return getFirstChildBlock(container);
25625
25619
  }
25626
25620
  function getLastChildBlockInComplexBlock(editor, complexBlock) {
25627
25621
  const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
25628
25622
  if (containers.length === 0) {
25629
- logger$3d.warn("complex block has not any child container, not loaded?");
25623
+ logger$3e.warn("complex block has not any child container, not loaded?");
25630
25624
  return null;
25631
25625
  }
25632
- assert(logger$3d, containers.length > 0, "complex block has not any child container");
25626
+ assert(logger$3e, containers.length > 0, "complex block has not any child container");
25633
25627
  const container = containers[containers.length - 1];
25634
25628
  return getLastChildBlock(container);
25635
25629
  }
@@ -25674,8 +25668,8 @@ var __publicField = (obj, key, value) => {
25674
25668
  return null;
25675
25669
  }
25676
25670
  const parentComplexBlock = getParentBlock(container);
25677
- assert(logger$3d, parentComplexBlock, "child container has not parent block");
25678
- assert(logger$3d, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
25671
+ assert(logger$3e, parentComplexBlock, "child container has not parent block");
25672
+ assert(logger$3e, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
25679
25673
  const nextContainer = getComplexBlockClass(editor, parentComplexBlock).getNextContainer(editor, parentComplexBlock, container, type);
25680
25674
  if (nextContainer) {
25681
25675
  if (isFindPrev(type)) {
@@ -25693,7 +25687,7 @@ var __publicField = (obj, key, value) => {
25693
25687
  return null;
25694
25688
  }
25695
25689
  const parentBlock = getParentBlock(container);
25696
- assert(logger$3d, parentBlock, "child container has not parent block");
25690
+ assert(logger$3e, parentBlock, "child container has not parent block");
25697
25691
  if (isFindPrev(type)) {
25698
25692
  const prev = getPrevBlock(parentBlock);
25699
25693
  if (prev) {
@@ -25748,7 +25742,7 @@ var __publicField = (obj, key, value) => {
25748
25742
  }
25749
25743
  if (!targetBlock) {
25750
25744
  if (isComplexKindBlock(editor, block) && complexBlockGetAllChildContainers(editor, block).length === 0) {
25751
- logger$3d.warn("complex block has not any child container, not loaded?");
25745
+ logger$3e.warn("complex block has not any child container, not loaded?");
25752
25746
  targetBlock = direction === "ArrowDown" || direction === "ArrowRight" ? getNextVisibleBlock(block) : getPrevVisibleBlock(block);
25753
25747
  }
25754
25748
  }
@@ -25895,10 +25889,10 @@ var __publicField = (obj, key, value) => {
25895
25889
  editorAdjustSelection(editor, "ArrowUp", "select");
25896
25890
  return true;
25897
25891
  }
25898
- const logger$3c = getLogger("word-offset");
25892
+ const logger$3d = getLogger("word-offset");
25899
25893
  function editorGetWordLeftPos(editor, type) {
25900
25894
  const old = editor.selection.range.focus;
25901
- assert(logger$3c, old.isSimple(), "invalid range type");
25895
+ assert(logger$3d, old.isSimple(), "invalid range type");
25902
25896
  const block = editor.getBlockById(old.blockId);
25903
25897
  if (isEmptyTextBlock(editor, block)) {
25904
25898
  return createSimpleBlockPosition(block, 0, "home");
@@ -25923,7 +25917,7 @@ var __publicField = (obj, key, value) => {
25923
25917
  }
25924
25918
  function editorGetWordRightPos(editor, type) {
25925
25919
  const old = editor.selection.range.focus;
25926
- assert(logger$3c, old.isSimple(), "invalid range type");
25920
+ assert(logger$3d, old.isSimple(), "invalid range type");
25927
25921
  const block = editor.getBlockById(old.blockId);
25928
25922
  if (isEmptyTextBlock(editor, block)) {
25929
25923
  return createSimpleBlockPosition(block, 0, "end");
@@ -26035,10 +26029,10 @@ var __publicField = (obj, key, value) => {
26035
26029
  editor.selection.setSelection(editor.selection.getAnchorPos(), pos);
26036
26030
  return true;
26037
26031
  }
26038
- const logger$3b = getLogger("line-offset");
26032
+ const logger$3c = getLogger("line-offset");
26039
26033
  function editorGetLineHomePos(editor) {
26040
26034
  const old = editor.selection.range.focus;
26041
- assert(logger$3b, old.isSimple(), "invalid range type");
26035
+ assert(logger$3c, old.isSimple(), "invalid range type");
26042
26036
  const block = editor.getBlockById(old.blockId);
26043
26037
  if (old.offset === 0 || !isTextKindBlock(editor, block)) {
26044
26038
  const newPos2 = createSimpleBlockPosition(block, 0, "home");
@@ -26055,7 +26049,7 @@ var __publicField = (obj, key, value) => {
26055
26049
  }
26056
26050
  function editorGetLineEndPos(editor) {
26057
26051
  const old = editor.selection.range.focus;
26058
- assert(logger$3b, old.isSimple(), "invalid range type");
26052
+ assert(logger$3c, old.isSimple(), "invalid range type");
26059
26053
  const block = editor.getBlockById(old.blockId);
26060
26054
  if (old.offset === getBlockTextLength$6(editor, block) || !isTextKindBlock(editor, block)) {
26061
26055
  const newPos2 = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
@@ -26155,7 +26149,7 @@ var __publicField = (obj, key, value) => {
26155
26149
  editorPageDownScroll(editor);
26156
26150
  return true;
26157
26151
  }
26158
- const logger$3a = getLogger("table-scroll");
26152
+ const logger$3b = getLogger("table-scroll");
26159
26153
  class DomEventHandler {
26160
26154
  constructor(editor, dom, name, handler, data2) {
26161
26155
  __publicField(this, "handleEvent", (event) => {
@@ -26187,7 +26181,7 @@ var __publicField = (obj, key, value) => {
26187
26181
  const existsHandlers = this.handlers.get(element);
26188
26182
  if (existsHandlers) {
26189
26183
  if (existsHandlers.find((handler) => handler.handler === eventHandler && handler.name === eventName)) {
26190
- logger$3a.warn(`event has already registered: ${eventName}`);
26184
+ logger$3b.warn(`event has already registered: ${eventName}`);
26191
26185
  return;
26192
26186
  }
26193
26187
  existsHandlers.push(new DomEventHandler(this.editor, element, eventName, eventHandler, data2));
@@ -26297,7 +26291,7 @@ var __publicField = (obj, key, value) => {
26297
26291
  });
26298
26292
  return true;
26299
26293
  }
26300
- const logger$39 = getLogger("select-all");
26294
+ const logger$3a = getLogger("select-all");
26301
26295
  function isContainerSelectedAllChildBlocks(container, range) {
26302
26296
  const firstBlock = getFirstChildBlock(container);
26303
26297
  const lastBlock2 = getLastChildBlock(container);
@@ -26312,8 +26306,8 @@ var __publicField = (obj, key, value) => {
26312
26306
  return range.start.blockId === blockId && range.start.childContainerId === getContainerId(first) && range.end.blockId === blockId && range.end.childContainerId === getContainerId(last);
26313
26307
  }
26314
26308
  function selectComplexBlock(editor, block) {
26315
- assert(logger$39, block, "no parent block");
26316
- assert(logger$39, isComplexKindBlock(editor, block), "not a complex block");
26309
+ assert(logger$3a, block, "no parent block");
26310
+ assert(logger$3a, isComplexKindBlock(editor, block), "not a complex block");
26317
26311
  const containers = getComplexBlockClass(editor, block).getChildContainers(editor, block);
26318
26312
  const first = containers[0];
26319
26313
  const last = containers[containers.length - 1];
@@ -26349,13 +26343,13 @@ var __publicField = (obj, key, value) => {
26349
26343
  selectParentContainer(editor, getFirstChildBlock(editor.rootContainer));
26350
26344
  return false;
26351
26345
  }
26352
- assert(logger$39, !range.isSimple(), "invalid range type");
26346
+ assert(logger$3a, !range.isSimple(), "invalid range type");
26353
26347
  if (isComplexBlockSelectedAllChildContainer(focusedBlock, range)) {
26354
26348
  selectParentContainer(editor, focusedBlock);
26355
26349
  return false;
26356
26350
  }
26357
- assert(logger$39, focusedBlock, "no parent block");
26358
- assert(logger$39, isComplexKindBlock(editor, focusedBlock), "not a complex block");
26351
+ assert(logger$3a, focusedBlock, "no parent block");
26352
+ assert(logger$3a, isComplexKindBlock(editor, focusedBlock), "not a complex block");
26359
26353
  selectComplexBlock(editor, focusedBlock);
26360
26354
  return true;
26361
26355
  }
@@ -26446,7 +26440,7 @@ var __publicField = (obj, key, value) => {
26446
26440
  }
26447
26441
  return cloned;
26448
26442
  }
26449
- const logger$38 = getLogger("selected-block-to-doc");
26443
+ const logger$39 = getLogger("selected-block-to-doc");
26450
26444
  function appendBlockChildren(editor, data2, doc2) {
26451
26445
  if (!data2.children)
26452
26446
  return;
@@ -26467,7 +26461,7 @@ var __publicField = (obj, key, value) => {
26467
26461
  if (isTextKindBlock(editor, selectedBlock.block)) {
26468
26462
  const start = selectedBlock.start;
26469
26463
  const end = selectedBlock.end;
26470
- assert(logger$38, data2.text, "no block text");
26464
+ assert(logger$39, data2.text, "no block text");
26471
26465
  if (start.offset === end.offset) {
26472
26466
  return {
26473
26467
  blocks: {
@@ -26501,8 +26495,8 @@ var __publicField = (obj, key, value) => {
26501
26495
  comments: {}
26502
26496
  };
26503
26497
  }
26504
- assert(logger$38, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
26505
- assert(logger$38, data2.children, "no children");
26498
+ assert(logger$39, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
26499
+ assert(logger$39, data2.children, "no children");
26506
26500
  const ret = {
26507
26501
  blocks: {
26508
26502
  root: [
@@ -26520,9 +26514,9 @@ var __publicField = (obj, key, value) => {
26520
26514
  const end = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
26521
26515
  return selectedBlockToDoc(editor, { block, start, end });
26522
26516
  }
26523
- const logger$37 = getLogger("block-to-doc");
26517
+ const logger$38 = getLogger("block-to-doc");
26524
26518
  function blocksToDoc(editor, blocks) {
26525
- assert(logger$37, blocks.length > 0, "invalid params, no blocks");
26519
+ assert(logger$38, blocks.length > 0, "invalid params, no blocks");
26526
26520
  const docs = blocks.map((b) => blockToDoc(editor, b));
26527
26521
  return mergeDocs(docs);
26528
26522
  }
@@ -26542,7 +26536,7 @@ var __publicField = (obj, key, value) => {
26542
26536
  const newDocs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s));
26543
26537
  return mergeDocs(newDocs);
26544
26538
  }
26545
- const logger$36 = getLogger("ensure-block-visible");
26539
+ const logger$37 = getLogger("ensure-block-visible");
26546
26540
  function ensureBlockVisible(editor, block) {
26547
26541
  var _a;
26548
26542
  while (block) {
@@ -26552,16 +26546,16 @@ var __publicField = (obj, key, value) => {
26552
26546
  return;
26553
26547
  }
26554
26548
  const parentComplexBlock = getParentBlock(container);
26555
- assert(logger$36, parentComplexBlock, "no parent block");
26549
+ assert(logger$37, parentComplexBlock, "no parent block");
26556
26550
  const parentComplexBlockClass = getBlockClass(editor, parentComplexBlock);
26557
26551
  if (parentComplexBlockClass.isChildContainerVisible && !((_a = parentComplexBlockClass.isChildContainerVisible) == null ? void 0 : _a.call(parentComplexBlockClass, editor, parentComplexBlock, container))) {
26558
- assert(logger$36, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
26552
+ assert(logger$37, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
26559
26553
  parentComplexBlockClass.showChildContainer(editor, parentComplexBlock, container);
26560
26554
  }
26561
26555
  block = parentComplexBlock;
26562
26556
  }
26563
26557
  }
26564
- const logger$35 = getLogger("editor-selection");
26558
+ const logger$36 = getLogger("editor-selection");
26565
26559
  class EditorSelection {
26566
26560
  constructor(editor) {
26567
26561
  __publicField(this, "editor");
@@ -26574,7 +26568,7 @@ var __publicField = (obj, key, value) => {
26574
26568
  }
26575
26569
  const range = this.range;
26576
26570
  if (rangeInBlock(deletedBlock, range)) {
26577
- logger$35.debug("adjust selection because remote deleted current block");
26571
+ logger$36.debug("adjust selection because remote deleted current block");
26578
26572
  const newRange = moveSelectionBeforeDeleteBlock(editor, deletedBlock);
26579
26573
  this.setRange(newRange, { noScroll: true });
26580
26574
  }
@@ -26699,14 +26693,14 @@ var __publicField = (obj, key, value) => {
26699
26693
  if (pos.isSimple()) {
26700
26694
  const ok = pos.offset >= 0 && pos.offset <= getBlockTextLength$6(this.editor, block);
26701
26695
  if (!ok) {
26702
- assert(logger$35, false, "invalid block position, out of range");
26696
+ assert(logger$36, false, "invalid block position, out of range");
26703
26697
  }
26704
26698
  } else {
26705
26699
  const childContainerId = pos.childContainerId;
26706
26700
  const container = this.editor.getContainerById(childContainerId);
26707
26701
  const ok = !!container;
26708
26702
  if (!ok) {
26709
- assert(logger$35, false, "invalid complex block position, no container found");
26703
+ assert(logger$36, false, "invalid complex block position, no container found");
26710
26704
  }
26711
26705
  }
26712
26706
  }
@@ -26767,7 +26761,7 @@ var __publicField = (obj, key, value) => {
26767
26761
  let container = getParentContainer(block);
26768
26762
  while (isChildContainer(container)) {
26769
26763
  const parentBlock = getParentBlock(container);
26770
- assert(logger$35, parentBlock, "parent block not found");
26764
+ assert(logger$36, parentBlock, "parent block not found");
26771
26765
  addClass(parentBlock, "child-focused");
26772
26766
  container = getParentContainer(parentBlock);
26773
26767
  }
@@ -26904,15 +26898,15 @@ var __publicField = (obj, key, value) => {
26904
26898
  editor.undoManager.redo();
26905
26899
  return true;
26906
26900
  }
26907
- const logger$34 = getLogger("delete-text");
26901
+ const logger$35 = getLogger("delete-text");
26908
26902
  function editorDeleteText(editor, type, count, insertPos) {
26909
26903
  const pos = insertPos != null ? insertPos : editor.selection.range.start;
26910
26904
  if (!(pos instanceof EditorSimpleBlockPosition)) {
26911
- assert(logger$34, false, `invalid insert pos type: ${typeof pos}`);
26905
+ assert(logger$35, false, `invalid insert pos type: ${typeof pos}`);
26912
26906
  }
26913
26907
  const { blockId } = pos;
26914
26908
  const block = editor.getBlockById(blockId);
26915
- assert(logger$34, isTextKindBlock(editor, block), "block is not a text kind block");
26909
+ assert(logger$35, isTextKindBlock(editor, block), "block is not a text kind block");
26916
26910
  let { offset } = pos;
26917
26911
  if (type === "backward") {
26918
26912
  if (offset - count < 0) {
@@ -26942,7 +26936,7 @@ var __publicField = (obj, key, value) => {
26942
26936
  }
26943
26937
  return false;
26944
26938
  }
26945
- const logger$33 = getLogger("handle-backspace");
26939
+ const logger$34 = getLogger("handle-backspace");
26946
26940
  function tryDeleteEmptyBlock(editor, block) {
26947
26941
  if (!isEmptyTextBlock(editor, block)) {
26948
26942
  return;
@@ -26982,7 +26976,7 @@ var __publicField = (obj, key, value) => {
26982
26976
  }
26983
26977
  } else {
26984
26978
  tryDeleteEmptyBlock(editor, block);
26985
- assert(logger$33, isEmbedBlock(prevBlock), "prev block is not embed block");
26979
+ assert(logger$34, isEmbedBlock(prevBlock), "prev block is not embed block");
26986
26980
  editor.selection.selectBlock(prevBlock, 1);
26987
26981
  }
26988
26982
  } else {
@@ -27263,7 +27257,7 @@ var __publicField = (obj, key, value) => {
27263
27257
  const doc2 = blockToDoc(editor, block);
27264
27258
  editorCopyDoc(editor, doc2);
27265
27259
  }
27266
- const logger$32 = getLogger("input-handler-actions");
27260
+ const logger$33 = getLogger("input-handler-actions");
27267
27261
  function editorHandleEnter(editor, event) {
27268
27262
  if (editor.readonly || !editor.isWritable()) {
27269
27263
  return false;
@@ -27309,7 +27303,7 @@ var __publicField = (obj, key, value) => {
27309
27303
  toPlainText: true
27310
27304
  });
27311
27305
  }).catch((err) => {
27312
- logger$32.error(err);
27306
+ logger$33.error(err);
27313
27307
  });
27314
27308
  return true;
27315
27309
  }
@@ -28051,14 +28045,14 @@ ${codeText}
28051
28045
  editor.selection.updateSelection(null, { focusBlockChanged: true });
28052
28046
  });
28053
28047
  }
28054
- const logger$31 = getLogger("transform-selection");
28048
+ const logger$32 = getLogger("transform-selection");
28055
28049
  function transformSelection(editor, blockId, delta, local) {
28056
28050
  const { range } = editor.selection;
28057
28051
  const { anchor: anchor2, focus } = range;
28058
28052
  if (anchor2.blockId !== blockId && focus.blockId !== blockId) {
28059
28053
  return range;
28060
28054
  }
28061
- assert(logger$31, anchor2.isSimple() && focus.isSimple(), "invalid text pos type");
28055
+ assert(logger$32, anchor2.isSimple() && focus.isSimple(), "invalid text pos type");
28062
28056
  let newAnchor = anchor2;
28063
28057
  if (anchor2.blockId === blockId) {
28064
28058
  const newOffset = RichText.transformCursor(anchor2.offset, delta, local);
@@ -28071,12 +28065,12 @@ ${codeText}
28071
28065
  }
28072
28066
  return createEditorSelectionRange(editor, { anchor: newAnchor, focus: newFocus });
28073
28067
  }
28074
- const logger$30 = getLogger("handle-block-text-changed");
28068
+ const logger$31 = getLogger("handle-block-text-changed");
28075
28069
  function onBlockTextChanged(editor, containerId, blockIndex, actions2, local) {
28076
28070
  const container = editor.getContainerById(containerId);
28077
28071
  const block = getBlockByIndex(container, blockIndex);
28078
28072
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
28079
- assert(logger$30, blockData.text, "no block text");
28073
+ assert(logger$31, blockData.text, "no block text");
28080
28074
  getTextBlockClass(editor, block).setBlockText(editor, block, blockData.text);
28081
28075
  if (!local) {
28082
28076
  const newRange = transformSelection(editor, blockData.id, actions2, local);
@@ -28108,7 +28102,7 @@ ${codeText}
28108
28102
  });
28109
28103
  handleDeleteBlock$4(editor, block, local, { child: false });
28110
28104
  }
28111
- const logger$2$ = getLogger("editor-doc");
28105
+ const logger$30 = getLogger("editor-doc");
28112
28106
  class EditorDoc extends EventCallbacks {
28113
28107
  constructor(editor, externalDoc, localEvents) {
28114
28108
  super();
@@ -28147,14 +28141,14 @@ ${codeText}
28147
28141
  }
28148
28142
  verifyBlockWritable(containerId, blockIndex) {
28149
28143
  const block = this.editor.getBlockByIndex(containerId, blockIndex);
28150
- assert(logger$2$, this.editor.isBlockWritable(block), `block is not writable, ${containerId}, ${blockIndex}`);
28144
+ assert(logger$30, this.editor.isBlockWritable(block), `block is not writable, ${containerId}, ${blockIndex}`);
28151
28145
  }
28152
28146
  localUpdateBlockText(containerId, blockIndex, actions2, options) {
28153
- assert(logger$2$, !this.editor.readonly, "editor is readonly");
28147
+ assert(logger$30, !this.editor.readonly, "editor is readonly");
28154
28148
  this.verifyBlockWritable(containerId, blockIndex);
28155
28149
  const blockData = this.getBlockData(containerId, blockIndex);
28156
28150
  const oldText = blockData.text;
28157
- assert(logger$2$, oldText, `no text, ${containerId}, ${blockIndex}`);
28151
+ assert(logger$30, oldText, `no text, ${containerId}, ${blockIndex}`);
28158
28152
  const newRange = transformSelection(this.editor, blockData.id, actions2, true);
28159
28153
  const newText = RichText.apply(oldText, actions2);
28160
28154
  this.localEvents.forEach((event) => event.onBeforeUpdateBlockText(containerId, blockData.id, oldText, newText, newRange.toDocRange()));
@@ -28163,13 +28157,13 @@ ${codeText}
28163
28157
  return ret;
28164
28158
  }
28165
28159
  localUpdateBlockData(containerId, blockIndex, delta, newRange, options) {
28166
- assert(logger$2$, !this.editor.readonly, "editor is readonly");
28160
+ assert(logger$30, !this.editor.readonly, "editor is readonly");
28167
28161
  const block = this.editor.getBlockByIndex(containerId, blockIndex);
28168
28162
  if (!this.editor.isBlockWritable(block)) {
28169
28163
  const deletedKeys = Array.from(delta.delete).filter((key) => key !== "comments");
28170
28164
  const insertedKeys = Object.keys(delta.insert).filter((key) => key !== "comments");
28171
28165
  if (deletedKeys.length > 0 || insertedKeys.length > 0) {
28172
- assert(logger$2$, false, `block is not writable, comment supported only, ${JSON.stringify(delta)}}`);
28166
+ assert(logger$30, false, `block is not writable, comment supported only, ${JSON.stringify(delta)}}`);
28173
28167
  }
28174
28168
  }
28175
28169
  const oldData = cloneDeep__default.default(this.getBlockData(containerId, blockIndex));
@@ -28180,7 +28174,7 @@ ${codeText}
28180
28174
  return ret;
28181
28175
  }
28182
28176
  localInsertBlock(containerId, blockIndex, data2, newRange, options) {
28183
- assert(logger$2$, !this.editor.readonly, "editor is readonly");
28177
+ assert(logger$30, !this.editor.readonly, "editor is readonly");
28184
28178
  this.localEvents.forEach((event) => event.onBeforeInsertBlock(containerId, blockIndex, data2, newRange));
28185
28179
  const ret = this.externalDoc.localInsertBlock(containerId, blockIndex, data2, newRange);
28186
28180
  if (!(options == null ? void 0 : options.noFocus)) {
@@ -28189,7 +28183,7 @@ ${codeText}
28189
28183
  return ret;
28190
28184
  }
28191
28185
  localDeleteBlock(containerId, blockIndex, newRange) {
28192
- assert(logger$2$, !this.editor.readonly, "editor is readonly");
28186
+ assert(logger$30, !this.editor.readonly, "editor is readonly");
28193
28187
  this.verifyBlockWritable(containerId, blockIndex);
28194
28188
  const blockData = cloneDeep__default.default(this.getBlockData(containerId, blockIndex));
28195
28189
  this.localEvents.forEach((event) => event.onBeforeDeleteBlock(containerId, blockIndex, blockData, newRange));
@@ -28198,7 +28192,7 @@ ${codeText}
28198
28192
  return ret;
28199
28193
  }
28200
28194
  localDeleteChildContainers(containerIds) {
28201
- assert(logger$2$, !this.editor.readonly, "editor is readonly");
28195
+ assert(logger$30, !this.editor.readonly, "editor is readonly");
28202
28196
  containerIds.forEach((containerId) => {
28203
28197
  const blocks = cloneDeep__default.default(this.getContainerBlocks(containerId));
28204
28198
  this.localEvents.forEach((event) => event.onBeforeDeleteChildContainer(containerId, blocks));
@@ -28206,7 +28200,7 @@ ${codeText}
28206
28200
  return this.externalDoc.localDeleteChildContainers(containerIds);
28207
28201
  }
28208
28202
  localInsertChildContainers(containers) {
28209
- assert(logger$2$, !this.editor.readonly, "editor is readonly");
28203
+ assert(logger$30, !this.editor.readonly, "editor is readonly");
28210
28204
  const data2 = cloneDeep__default.default(containers);
28211
28205
  data2.forEach((item) => {
28212
28206
  this.localEvents.forEach((event) => event.onBeforeInsertChildContainer(item.containerId, item.blocks));
@@ -28214,7 +28208,7 @@ ${codeText}
28214
28208
  this.externalDoc.localInsertChildContainers(data2);
28215
28209
  }
28216
28210
  onRequestReload(reason) {
28217
- logger$2$.debug(`reload doc: ${reason}`);
28211
+ logger$30.debug(`reload doc: ${reason}`);
28218
28212
  this.editor.reload();
28219
28213
  this.callbacks.forEach((c) => {
28220
28214
  var _a;
@@ -28328,7 +28322,7 @@ ${codeText}
28328
28322
  return (_c = (_b = (_a = this.externalDoc).getServerMeta) == null ? void 0 : _b.call(_a)) != null ? _c : {};
28329
28323
  }
28330
28324
  reset(doc2) {
28331
- logger$2$.log("reset doc");
28325
+ logger$30.log("reset doc");
28332
28326
  this.externalDoc = doc2;
28333
28327
  this.externalDoc.registerCallback(this);
28334
28328
  this.editor.reload();
@@ -28346,7 +28340,7 @@ ${codeText}
28346
28340
  }
28347
28341
  last.combine(action);
28348
28342
  }
28349
- const logger$2_ = getLogger("undo-action");
28343
+ const logger$2$ = getLogger("undo-action");
28350
28344
  class Action {
28351
28345
  constructor(editor, containerId, afterRange) {
28352
28346
  __publicField(this, "beforeRange");
@@ -28362,15 +28356,15 @@ ${codeText}
28362
28356
  return false;
28363
28357
  }
28364
28358
  combinable(other) {
28365
- assert(logger$2_, other, "no other action");
28359
+ assert(logger$2$, other, "no other action");
28366
28360
  return false;
28367
28361
  }
28368
28362
  combine(other) {
28369
- assert(logger$2_, false, "no other");
28363
+ assert(logger$2$, false, "no other");
28370
28364
  }
28371
28365
  setAfterRange(range) {
28372
28366
  if (this.afterRange) {
28373
- logger$2_.warn("after range has already set");
28367
+ logger$2$.warn("after range has already set");
28374
28368
  }
28375
28369
  this.afterRange = range;
28376
28370
  }
@@ -28392,7 +28386,7 @@ ${codeText}
28392
28386
  const containerId = blockData.children[i];
28393
28387
  const container = doc2.blocks[containerId];
28394
28388
  if (!container) {
28395
- logger$2_.warn(`container (${containerId}) not found, deleted by others?`);
28389
+ logger$2$.warn(`container (${containerId}) not found, deleted by others?`);
28396
28390
  return false;
28397
28391
  }
28398
28392
  }
@@ -28400,7 +28394,7 @@ ${codeText}
28400
28394
  return true;
28401
28395
  }
28402
28396
  }
28403
- const logger$2Z = getLogger("block-action");
28397
+ const logger$2_ = getLogger("block-action");
28404
28398
  class BlockAction extends Action {
28405
28399
  constructor(editor, containerId, blockIndex, data2, afterRange) {
28406
28400
  super(editor, containerId, afterRange);
@@ -28411,7 +28405,7 @@ ${codeText}
28411
28405
  }
28412
28406
  deleteBlock(editor, newRange) {
28413
28407
  if (!this.hasDocContainerId(editor, this.containerId)) {
28414
- logger$2Z.warn(`container (${this.containerId}) not found, deleted by others?`);
28408
+ logger$2_.warn(`container (${this.containerId}) not found, deleted by others?`);
28415
28409
  return false;
28416
28410
  }
28417
28411
  const container = editor.getContainerById(this.containerId);
@@ -28425,18 +28419,18 @@ ${codeText}
28425
28419
  }
28426
28420
  insertBlock(editor, newRange) {
28427
28421
  if (!this.hasDocContainerId(editor, this.containerId)) {
28428
- logger$2Z.warn(`container (${this.containerId}) not found, deleted by others?`);
28422
+ logger$2_.warn(`container (${this.containerId}) not found, deleted by others?`);
28429
28423
  return false;
28430
28424
  }
28431
28425
  if (!this.checkBlockData(editor, this.blockData)) {
28432
28426
  return false;
28433
28427
  }
28434
28428
  if (!editor.findBlockByIndex(this.containerId, Math.max(0, this.blockIndex - 1))) {
28435
- logger$2Z.warn(`block (${Math.max(0, this.blockIndex - 1)}) not found, deleted by others?`);
28429
+ logger$2_.warn(`block (${Math.max(0, this.blockIndex - 1)}) not found, deleted by others?`);
28436
28430
  return false;
28437
28431
  }
28438
28432
  if (editor.findBlockById(this.blockData.id)) {
28439
- logger$2Z.warn(`block (${this.blockData.id}) already exists, inserted by others?`);
28433
+ logger$2_.warn(`block (${this.blockData.id}) already exists, inserted by others?`);
28440
28434
  return false;
28441
28435
  }
28442
28436
  editorInsertBlock(editor, this.containerId, this.blockIndex, cloneDeep__default.default(this.blockData), newRange);
@@ -28503,7 +28497,7 @@ ${codeText}
28503
28497
  }
28504
28498
  }
28505
28499
  }
28506
- const logger$2Y = getLogger("update-block-data-action");
28500
+ const logger$2Z = getLogger("update-block-data-action");
28507
28501
  class UpdateBlockDataAction extends Action {
28508
28502
  constructor(editor, containerId, blockId, oldData, newData, newRange) {
28509
28503
  super(editor, containerId, newRange);
@@ -28511,15 +28505,15 @@ ${codeText}
28511
28505
  __publicField(this, "afterBlockData");
28512
28506
  __publicField(this, "blockId");
28513
28507
  this.blockId = blockId;
28514
- assert(logger$2Y, this.blockId === oldData.id, "invalid block id");
28515
- assert(logger$2Y, this.blockId === newData.id, "invalid block id");
28508
+ assert(logger$2Z, this.blockId === oldData.id, "invalid block id");
28509
+ assert(logger$2Z, this.blockId === newData.id, "invalid block id");
28516
28510
  this.beforeBlockData = cloneDeep__default.default(oldData);
28517
28511
  this.afterBlockData = cloneDeep__default.default(newData);
28518
- assert(logger$2Y, this.beforeBlockData.type === this.afterBlockData.type, "invalid block type");
28512
+ assert(logger$2Z, this.beforeBlockData.type === this.afterBlockData.type, "invalid block type");
28519
28513
  }
28520
28514
  undo(editor) {
28521
28515
  if (!editor.findBlockById(this.blockId)) {
28522
- logger$2Y.warn(`block (${this.blockId}) not found, deleted by others?`);
28516
+ logger$2Z.warn(`block (${this.blockId}) not found, deleted by others?`);
28523
28517
  return false;
28524
28518
  }
28525
28519
  const block = editor.getBlockById(this.blockId);
@@ -28529,16 +28523,16 @@ ${codeText}
28529
28523
  return false;
28530
28524
  }
28531
28525
  const container = editor.getContainerById(this.containerId);
28532
- assert(logger$2Y, container, "no container");
28526
+ assert(logger$2Z, container, "no container");
28533
28527
  editorUpdateBlockData(editor, block, UpdateBlockDataAction.toAttributes(this.beforeBlockData), this.beforeRange);
28534
28528
  return true;
28535
28529
  }
28536
28530
  redo(editor) {
28537
28531
  if (!editor.findBlockById(this.blockId)) {
28538
- logger$2Y.warn(`block (${this.blockId}) not found, deleted by others?`);
28532
+ logger$2Z.warn(`block (${this.blockId}) not found, deleted by others?`);
28539
28533
  return false;
28540
28534
  }
28541
- assert(logger$2Y, editor, "no editor");
28535
+ assert(logger$2Z, editor, "no editor");
28542
28536
  const block = editor.getBlockById(this.blockId);
28543
28537
  if (!block)
28544
28538
  return false;
@@ -28546,7 +28540,7 @@ ${codeText}
28546
28540
  return false;
28547
28541
  }
28548
28542
  const container = editor.getContainerById(this.containerId);
28549
- assert(logger$2Y, container, "no container");
28543
+ assert(logger$2Z, container, "no container");
28550
28544
  editorUpdateBlockData(editor, block, UpdateBlockDataAction.toAttributes(this.afterBlockData), this.afterRange);
28551
28545
  return true;
28552
28546
  }
@@ -28557,7 +28551,7 @@ ${codeText}
28557
28551
  return attributes;
28558
28552
  }
28559
28553
  }
28560
- const logger$2X = getLogger("update-block-text-action");
28554
+ const logger$2Y = getLogger("update-block-text-action");
28561
28555
  class UpdateBlockTextAction extends Action {
28562
28556
  constructor(editor, container, blockId, oldData, newData, newRange) {
28563
28557
  super(editor, container, newRange);
@@ -28571,8 +28565,8 @@ ${codeText}
28571
28565
  this.type = UpdateBlockTextAction.calType(oldData, newData);
28572
28566
  }
28573
28567
  static calType(oldData, newData) {
28574
- assert(logger$2X, oldData, "no old data");
28575
- assert(logger$2X, newData, "no new data");
28568
+ assert(logger$2Y, oldData, "no old data");
28569
+ assert(logger$2Y, newData, "no new data");
28576
28570
  const diff = RichText.diff(oldData, newData);
28577
28571
  const ops = diff;
28578
28572
  const type = /* @__PURE__ */ new Set();
@@ -28615,11 +28609,11 @@ ${codeText}
28615
28609
  }
28616
28610
  undo(editor) {
28617
28611
  if (!this.hasDocContainerId(editor, this.containerId)) {
28618
- logger$2X.warn(`container (${this.containerId}) not found, deleted by others?`);
28612
+ logger$2Y.warn(`container (${this.containerId}) not found, deleted by others?`);
28619
28613
  return false;
28620
28614
  }
28621
28615
  if (!this.findDocBlockById(editor, this.blockId)) {
28622
- logger$2X.warn(`block (${this.blockId}) not found, deleted by others?`);
28616
+ logger$2Y.warn(`block (${this.blockId}) not found, deleted by others?`);
28623
28617
  return false;
28624
28618
  }
28625
28619
  const container = editor.getContainerById(this.containerId);
@@ -28633,11 +28627,11 @@ ${codeText}
28633
28627
  }
28634
28628
  redo(editor) {
28635
28629
  if (!this.hasDocContainerId(editor, this.containerId)) {
28636
- logger$2X.warn(`container (${this.containerId}) not found, deleted by others?`);
28630
+ logger$2Y.warn(`container (${this.containerId}) not found, deleted by others?`);
28637
28631
  return false;
28638
28632
  }
28639
28633
  if (!this.findDocBlockById(editor, this.blockId)) {
28640
- logger$2X.warn(`block (${this.blockId}) not found, deleted by others?`);
28634
+ logger$2Y.warn(`block (${this.blockId}) not found, deleted by others?`);
28641
28635
  return false;
28642
28636
  }
28643
28637
  const container = editor.getContainerById(this.containerId);
@@ -28676,13 +28670,13 @@ ${codeText}
28676
28670
  return true;
28677
28671
  }
28678
28672
  combine(other) {
28679
- assert(logger$2X, other instanceof UpdateBlockTextAction, "invalid action type");
28673
+ assert(logger$2Y, other instanceof UpdateBlockTextAction, "invalid action type");
28680
28674
  const last = other;
28681
28675
  this.afterRichTextData = last.afterRichTextData;
28682
28676
  this.afterRange = other.afterRange;
28683
28677
  }
28684
28678
  }
28685
- const logger$2W = getLogger("child-container-action");
28679
+ const logger$2X = getLogger("child-container-action");
28686
28680
  class ChildContainerAction extends Action {
28687
28681
  constructor(editor, containerId, blocks) {
28688
28682
  super(editor, containerId, editor.selection.range.toDocRange());
@@ -28690,7 +28684,7 @@ ${codeText}
28690
28684
  }
28691
28685
  deleteChildContainer(editor) {
28692
28686
  if (!this.hasDocContainerId(editor, this.containerId)) {
28693
- logger$2W.warn(`container (${this.containerId}) not found, deleted by others?`);
28687
+ logger$2X.warn(`container (${this.containerId}) not found, deleted by others?`);
28694
28688
  return false;
28695
28689
  }
28696
28690
  editor.doc.localDeleteChildContainers([this.containerId]);
@@ -28698,7 +28692,7 @@ ${codeText}
28698
28692
  }
28699
28693
  insertChildContainer(editor) {
28700
28694
  if (this.hasDocContainerId(editor, this.containerId)) {
28701
- logger$2W.warn(`container (${this.containerId}) already exists`);
28695
+ logger$2X.warn(`container (${this.containerId}) already exists`);
28702
28696
  return false;
28703
28697
  }
28704
28698
  editor.doc.localInsertChildContainers([{ containerId: this.containerId, blocks: cloneDeep__default.default(this.blocks) }]);
@@ -28721,7 +28715,7 @@ ${codeText}
28721
28715
  return this.deleteChildContainer(editor);
28722
28716
  }
28723
28717
  }
28724
- const logger$2V = getLogger("undo");
28718
+ const logger$2W = getLogger("undo");
28725
28719
  class UndoManager {
28726
28720
  constructor(editor) {
28727
28721
  __publicField(this, "editor");
@@ -28768,21 +28762,21 @@ ${codeText}
28768
28762
  }
28769
28763
  beginGroup() {
28770
28764
  if (this.groupCounter === 0) {
28771
- assert(logger$2V, !this.currentGroup, "current group already exists");
28765
+ assert(logger$2W, !this.currentGroup, "current group already exists");
28772
28766
  this.currentGroup = new GroupAction(this.editor);
28773
28767
  this.groupCounter = 1;
28774
28768
  } else {
28775
- assert(logger$2V, this.currentGroup, "current group not exists");
28769
+ assert(logger$2W, this.currentGroup, "current group not exists");
28776
28770
  this.groupCounter += 1;
28777
28771
  }
28778
28772
  }
28779
28773
  endGroup() {
28780
- assert(logger$2V, this.currentGroup, "current group not exists");
28781
- assert(logger$2V, this.groupCounter > 0, "group counter === 0");
28774
+ assert(logger$2W, this.currentGroup, "current group not exists");
28775
+ assert(logger$2W, this.groupCounter > 0, "group counter === 0");
28782
28776
  this.groupCounter -= 1;
28783
28777
  if (this.groupCounter === 0) {
28784
28778
  if (this.currentGroup.actions.length === 0) {
28785
- logger$2V.warn("empty undo group, skip it");
28779
+ logger$2W.warn("empty undo group, skip it");
28786
28780
  } else {
28787
28781
  this.actions.push(this.currentGroup);
28788
28782
  this.editor.input.handleChanged(this.currentGroup);
@@ -28800,7 +28794,7 @@ ${codeText}
28800
28794
  setTimeout(() => this.editor.selection.caret.update());
28801
28795
  return ret;
28802
28796
  } catch (err) {
28803
- logger$2V.error(`failed to run action: ${err.message}`);
28797
+ logger$2W.error(`failed to run action: ${err.message}`);
28804
28798
  throw err;
28805
28799
  } finally {
28806
28800
  this.endGroup();
@@ -28811,14 +28805,14 @@ ${codeText}
28811
28805
  if (pos.isSimple()) {
28812
28806
  const ok = pos.offset >= 0 && pos.offset <= getBlockTextLength$6(this.editor, block);
28813
28807
  if (!ok) {
28814
- assert(logger$2V, false, "invalid block position, out of range");
28808
+ assert(logger$2W, false, "invalid block position, out of range");
28815
28809
  }
28816
28810
  } else {
28817
28811
  const childContainerId = pos.childContainerId;
28818
28812
  const container = this.editor.getContainerById(childContainerId);
28819
28813
  const ok = !!container;
28820
28814
  if (!ok) {
28821
- assert(logger$2V, false, "invalid complex block position, no container found");
28815
+ assert(logger$2W, false, "invalid complex block position, no container found");
28822
28816
  }
28823
28817
  }
28824
28818
  }
@@ -28828,7 +28822,7 @@ ${codeText}
28828
28822
  this.verifyPos(start);
28829
28823
  this.verifyPos(end);
28830
28824
  } catch (err) {
28831
- logger$2V.error(`undo: failed to restore caret pos: ${err.message}`);
28825
+ logger$2W.error(`undo: failed to restore caret pos: ${err.message}`);
28832
28826
  const firstBlock = this.editor.getFirstBlock();
28833
28827
  this.editor.selection.setRange(createBlockSimpleRange(this.editor, firstBlock, 0), { noScroll: true });
28834
28828
  }
@@ -28846,7 +28840,7 @@ ${codeText}
28846
28840
  try {
28847
28841
  this.editor.selection.setRange(fromDocRange(this.editor, action.beforeRange));
28848
28842
  } catch (err) {
28849
- logger$2V.error(`undo: failed to restore caret pos: ${err.message}`);
28843
+ logger$2W.error(`undo: failed to restore caret pos: ${err.message}`);
28850
28844
  }
28851
28845
  this.editor.input.handleChanged(action);
28852
28846
  return true;
@@ -28854,7 +28848,7 @@ ${codeText}
28854
28848
  }
28855
28849
  return false;
28856
28850
  } catch (error2) {
28857
- logger$2V.error(`failed to undo: ${error2.message}`);
28851
+ logger$2W.error(`failed to undo: ${error2.message}`);
28858
28852
  return false;
28859
28853
  } finally {
28860
28854
  this.undoRedoing = false;
@@ -28876,10 +28870,10 @@ ${codeText}
28876
28870
  if (afterRange) {
28877
28871
  this.editor.selection.setRange(fromDocRange(this.editor, afterRange));
28878
28872
  } else {
28879
- logger$2V.warn("no after range");
28873
+ logger$2W.warn("no after range");
28880
28874
  }
28881
28875
  } catch (err) {
28882
- logger$2V.error(`redo: failed to set caret pos after redo: ${err.message}`);
28876
+ logger$2W.error(`redo: failed to set caret pos after redo: ${err.message}`);
28883
28877
  }
28884
28878
  this.editor.input.handleChanged(action);
28885
28879
  return true;
@@ -28954,8 +28948,8 @@ ${codeText}
28954
28948
  return;
28955
28949
  }
28956
28950
  this.prepareSaveUndoState();
28957
- assert(logger$2V, blockIndex >= 0, "invalid block index");
28958
- assert(logger$2V, blockData, "no block data");
28951
+ assert(logger$2W, blockIndex >= 0, "invalid block index");
28952
+ assert(logger$2W, blockData, "no block data");
28959
28953
  this.addAction(new InsertBlockAction(this.editor, containerId, blockIndex, blockData, newRange));
28960
28954
  }
28961
28955
  onBeforeDeleteBlock(containerId, blockIndex, blockData, newRange) {
@@ -29060,7 +29054,7 @@ ${codeText}
29060
29054
  components.textRenders.forEach((r) => editor.editorBlockRenders.registerRender(r));
29061
29055
  }
29062
29056
  }
29063
- const logger$2U = getLogger("range-commands");
29057
+ const logger$2V = getLogger("range-commands");
29064
29058
  function addItemSource(items, source) {
29065
29059
  items.forEach((item) => {
29066
29060
  item.source = source;
@@ -29079,8 +29073,8 @@ ${codeText}
29079
29073
  }
29080
29074
  function getBlockCommands(editor, block, range, source) {
29081
29075
  const blockId = getBlockId(block);
29082
- assert(logger$2U, blockId === range.start.blockId, "invalid start range");
29083
- assert(logger$2U, blockId === range.end.blockId, "invalid end range");
29076
+ assert(logger$2V, blockId === range.start.blockId, "invalid start range");
29077
+ assert(logger$2V, blockId === range.end.blockId, "invalid end range");
29084
29078
  const providers = editor.editorCommandProviders.getCommandProviders();
29085
29079
  let allCommands = [];
29086
29080
  providers.forEach((provider) => {
@@ -29101,8 +29095,8 @@ ${codeText}
29101
29095
  if (!isComplexBlockPosition(range.start)) {
29102
29096
  return allCommands;
29103
29097
  }
29104
- assert(logger$2U, !range.start.isSimple(), "invalid start pos");
29105
- assert(logger$2U, !range.end.isSimple(), "invalid end pos");
29098
+ assert(logger$2V, !range.start.isSimple(), "invalid start pos");
29099
+ assert(logger$2V, !range.end.isSimple(), "invalid end pos");
29106
29100
  const focusedContainerId = range.start.childContainerId;
29107
29101
  const focusedContainer = getContainerById(editor, focusedContainerId);
29108
29102
  const blocks = getChildBlocks(focusedContainer);
@@ -29181,7 +29175,7 @@ ${codeText}
29181
29175
  editor.focus();
29182
29176
  return rangeResult;
29183
29177
  }
29184
- const logger$2T = getLogger("command-providers");
29178
+ const logger$2U = getLogger("command-providers");
29185
29179
  class EditorCommandProviders {
29186
29180
  constructor(editor) {
29187
29181
  __publicField(this, "providers", []);
@@ -29195,7 +29189,7 @@ ${codeText}
29195
29189
  }
29196
29190
  getCommandProvider(id) {
29197
29191
  const ret = this.providers.find((provider) => provider.id === id);
29198
- assert(logger$2T, ret, `no command provider, id=${id}`);
29192
+ assert(logger$2U, ret, `no command provider, id=${id}`);
29199
29193
  return ret;
29200
29194
  }
29201
29195
  getCommands(range, source) {
@@ -29229,12 +29223,12 @@ ${codeText}
29229
29223
  const blockIndex = getBlockIndex(block);
29230
29224
  onBlockDataChanged(editor, containerId, blockIndex);
29231
29225
  }
29232
- const logger$2S = getLogger("update-block-text");
29226
+ const logger$2T = getLogger("update-block-text");
29233
29227
  function editorUpdateBoxData(editor, boxData, options) {
29234
29228
  const boxElem = editor.getBoxById(boxData.id);
29235
29229
  const block = getParentBlock(boxElem);
29236
- assert(logger$2S, block, "no parent block");
29237
- assert(logger$2S, isTextKindBlock(editor, block), "not a text block");
29230
+ assert(logger$2T, block, "no parent block");
29231
+ assert(logger$2T, isTextKindBlock(editor, block), "not a text block");
29238
29232
  const text2 = editor.getBlockText(block);
29239
29233
  const newText = updateOpAttributes(text2, "id", boxData.id, boxData);
29240
29234
  editorSetBlockText(editor, block, newText, options);
@@ -29301,7 +29295,7 @@ ${codeText}
29301
29295
  return void 0;
29302
29296
  }
29303
29297
  }
29304
- const logger$2R = getLogger("editor");
29298
+ const logger$2S = getLogger("editor");
29305
29299
  class Editor extends tinyTypedEmitter.TypedEmitter {
29306
29300
  constructor(parent, doc2, optionalOptions) {
29307
29301
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
@@ -29343,7 +29337,7 @@ ${codeText}
29343
29337
  }
29344
29338
  return colors[index2 % colors.length];
29345
29339
  });
29346
- logger$2R.debug("create editor");
29340
+ logger$2S.debug("create editor");
29347
29341
  this.setMaxListeners(100);
29348
29342
  this.options = {
29349
29343
  colors: (_a = optionalOptions == null ? void 0 : optionalOptions.colors) != null ? _a : ["#0064FF", "#EB3723", "#F59300", "#00A865", "#F25A0A", "#70A310", "#009CAD", "#0990D9", "#8851ED", "#D62069"],
@@ -29411,7 +29405,7 @@ ${codeText}
29411
29405
  }
29412
29406
  getCustom(name) {
29413
29407
  const exists = this.customs.get(name);
29414
- assert(logger$2R, exists, `${name} does not exists`);
29408
+ assert(logger$2S, exists, `${name} does not exists`);
29415
29409
  return exists;
29416
29410
  }
29417
29411
  replaceCustom(name, newCustom) {
@@ -29462,7 +29456,7 @@ ${codeText}
29462
29456
  return this.editorInsertions.createInsertion(blockContent, insertion);
29463
29457
  }
29464
29458
  destroy() {
29465
- logger$2R.debug("destroy editor");
29459
+ logger$2S.debug("destroy editor");
29466
29460
  this.emit("destroy", this);
29467
29461
  this.input.destroy();
29468
29462
  this.rootContainerObject.destroy();
@@ -29490,8 +29484,8 @@ ${codeText}
29490
29484
  getChildContainerData(childContainerId) {
29491
29485
  const blocks = this.doc.getContainerBlocks(childContainerId);
29492
29486
  if (!blocks || !Array.isArray(blocks)) {
29493
- assert(logger$2R, blocks, `no child container data: ${childContainerId}, ${JSON.stringify(this.doc)}`);
29494
- assert(logger$2R, Array.isArray(blocks), `container data is not an array: ${JSON.stringify(blocks)}`);
29487
+ assert(logger$2S, blocks, `no child container data: ${childContainerId}, ${JSON.stringify(this.doc)}`);
29488
+ assert(logger$2S, Array.isArray(blocks), `container data is not an array: ${JSON.stringify(blocks)}`);
29495
29489
  }
29496
29490
  return blocks;
29497
29491
  }
@@ -29512,25 +29506,25 @@ ${codeText}
29512
29506
  findBlockById(id) {
29513
29507
  const block = this.rootContainer.querySelector(`#${id}`);
29514
29508
  if (block) {
29515
- assert(logger$2R, isBlock(block), "not an valid block element");
29509
+ assert(logger$2S, isBlock(block), "not an valid block element");
29516
29510
  }
29517
29511
  return block != null ? block : null;
29518
29512
  }
29519
29513
  findBoxById(id) {
29520
29514
  const box = this.rootContainer.querySelector(`#${id}`);
29521
29515
  if (box) {
29522
- assert(logger$2R, isBox(box), "not an valid box element");
29516
+ assert(logger$2S, isBox(box), "not an valid box element");
29523
29517
  }
29524
29518
  return box != null ? box : null;
29525
29519
  }
29526
29520
  getBlockById(id) {
29527
29521
  const block = this.findBlockById(id);
29528
- assert(logger$2R, block, `no block, id=${id}`);
29522
+ assert(logger$2S, block, `no block, id=${id}`);
29529
29523
  return block;
29530
29524
  }
29531
29525
  getBoxById(id) {
29532
29526
  const box = this.findBoxById(id);
29533
- assert(logger$2R, box, `no box, id=${id}`);
29527
+ assert(logger$2S, box, `no box, id=${id}`);
29534
29528
  return box;
29535
29529
  }
29536
29530
  getBlockByIndex(containerId, blockIndex) {
@@ -29851,7 +29845,7 @@ ${codeText}
29851
29845
  this.removeAllListeners();
29852
29846
  }
29853
29847
  }
29854
- const logger$2Q = getLogger("local-doc");
29848
+ const logger$2R = getLogger("local-doc");
29855
29849
  class LocalDoc extends EventCallbacks {
29856
29850
  constructor(doc2, options) {
29857
29851
  super();
@@ -29891,17 +29885,17 @@ ${codeText}
29891
29885
  }
29892
29886
  getBlockData(containerId, blockIndex) {
29893
29887
  const blocks = this.getContainerBlocks(containerId);
29894
- assert(logger$2Q, blocks, `no container data: ${containerId}`);
29888
+ assert(logger$2R, blocks, `no container data: ${containerId}`);
29895
29889
  const blockData = blocks[blockIndex];
29896
- assert(logger$2Q, blockData, `no block data: ${blockIndex}`);
29890
+ assert(logger$2R, blockData, `no block data: ${blockIndex}`);
29897
29891
  return blockData;
29898
29892
  }
29899
29893
  localUpdateBlockText(containerId, blockIndex, actions2) {
29900
29894
  const blockData = this.getBlockData(containerId, blockIndex);
29901
- assert(logger$2Q, blockData.text, "no text for data");
29895
+ assert(logger$2R, blockData.text, "no text for data");
29902
29896
  const newText = RichText.apply(blockData.text, actions2);
29903
29897
  blockData.text = newText;
29904
- assert(logger$2Q, this.callbacks.length > 0, "no callbacks");
29898
+ assert(logger$2R, this.callbacks.length > 0, "no callbacks");
29905
29899
  this.callbacks.forEach((cb) => {
29906
29900
  var _a;
29907
29901
  return (_a = cb.onUpdateBlockText) == null ? void 0 : _a.call(cb, containerId, blockIndex, actions2, true);
@@ -29914,7 +29908,7 @@ ${codeText}
29914
29908
  Object.entries(delta.insert).forEach(([key, value]) => {
29915
29909
  blockData[key] = value;
29916
29910
  });
29917
- assert(logger$2Q, this.callbacks.length > 0, "no callbacks");
29911
+ assert(logger$2R, this.callbacks.length > 0, "no callbacks");
29918
29912
  this.callbacks.forEach((cb) => {
29919
29913
  var _a;
29920
29914
  return (_a = cb.onUpdateBlockData) == null ? void 0 : _a.call(cb, containerId, blockIndex, delta, true);
@@ -29923,10 +29917,10 @@ ${codeText}
29923
29917
  }
29924
29918
  localInsertBlock(containerId, blockIndex, data2) {
29925
29919
  const blocks = this.getContainerBlocks(containerId);
29926
- assert(logger$2Q, blocks, `no container data: ${containerId}`);
29927
- assert(logger$2Q, blockIndex >= 0 && blockIndex <= blocks.length, `invalid block index: ${blockIndex}, ${blocks.length}`);
29920
+ assert(logger$2R, blocks, `no container data: ${containerId}`);
29921
+ assert(logger$2R, blockIndex >= 0 && blockIndex <= blocks.length, `invalid block index: ${blockIndex}, ${blocks.length}`);
29928
29922
  blocks.splice(blockIndex, 0, data2);
29929
- assert(logger$2Q, this.callbacks.length > 0, "no callbacks");
29923
+ assert(logger$2R, this.callbacks.length > 0, "no callbacks");
29930
29924
  this.callbacks.forEach((cb) => {
29931
29925
  var _a;
29932
29926
  return (_a = cb.onInsertBlock) == null ? void 0 : _a.call(cb, containerId, blockIndex, data2, true);
@@ -29935,11 +29929,11 @@ ${codeText}
29935
29929
  }
29936
29930
  localDeleteBlock(containerId, blockIndex) {
29937
29931
  const blocks = this.getContainerBlocks(containerId);
29938
- assert(logger$2Q, blocks, `no container data: ${containerId}`);
29939
- assert(logger$2Q, blockIndex >= 0 && blockIndex <= blocks.length, `invalid block index: ${blockIndex}, ${blocks.length}`);
29932
+ assert(logger$2R, blocks, `no container data: ${containerId}`);
29933
+ assert(logger$2R, blockIndex >= 0 && blockIndex <= blocks.length, `invalid block index: ${blockIndex}, ${blocks.length}`);
29940
29934
  const data2 = blocks[blockIndex];
29941
29935
  blocks.splice(blockIndex, 1);
29942
- assert(logger$2Q, this.callbacks.length > 0, "no callbacks");
29936
+ assert(logger$2R, this.callbacks.length > 0, "no callbacks");
29943
29937
  this.callbacks.forEach((cb) => {
29944
29938
  var _a;
29945
29939
  return (_a = cb.onDeleteBlock) == null ? void 0 : _a.call(cb, containerId, blockIndex, true);
@@ -29949,7 +29943,7 @@ ${codeText}
29949
29943
  localInsertChildContainers(containers) {
29950
29944
  containers.forEach(({ containerId, blocks }) => {
29951
29945
  this.doc.blocks[containerId] = blocks;
29952
- assert(logger$2Q, this.callbacks.length > 0, "no callbacks");
29946
+ assert(logger$2R, this.callbacks.length > 0, "no callbacks");
29953
29947
  this.callbacks.forEach((cb) => {
29954
29948
  var _a;
29955
29949
  return (_a = cb.onInsertChildContainer) == null ? void 0 : _a.call(cb, containerId, blocks, true);
@@ -29957,13 +29951,13 @@ ${codeText}
29957
29951
  });
29958
29952
  }
29959
29953
  localDeleteChildContainers(containerIds) {
29960
- logger$2Q.debug(`delete child containers: ${containerIds}`);
29954
+ logger$2R.debug(`delete child containers: ${containerIds}`);
29961
29955
  containerIds.forEach((id) => {
29962
- assert(logger$2Q, this.doc.blocks[id], `no child container: ${id}`);
29956
+ assert(logger$2R, this.doc.blocks[id], `no child container: ${id}`);
29963
29957
  delete this.doc.blocks[id];
29964
29958
  });
29965
29959
  containerIds.forEach((id) => {
29966
- assert(logger$2Q, this.callbacks.length > 0, "no callbacks");
29960
+ assert(logger$2R, this.callbacks.length > 0, "no callbacks");
29967
29961
  this.callbacks.forEach((cb) => {
29968
29962
  var _a;
29969
29963
  return (_a = cb.onDeleteChildContainer) == null ? void 0 : _a.call(cb, id, true);
@@ -29971,7 +29965,7 @@ ${codeText}
29971
29965
  });
29972
29966
  }
29973
29967
  uploadResource(file2, options) {
29974
- assert(logger$2Q, false, "not implemented");
29968
+ assert(logger$2R, false, "not implemented");
29975
29969
  }
29976
29970
  async addResources(resourceIds) {
29977
29971
  return resourceIds;
@@ -29980,7 +29974,7 @@ ${codeText}
29980
29974
  return src;
29981
29975
  }
29982
29976
  request(url, opt) {
29983
- assert(logger$2Q, false, "not implemented");
29977
+ assert(logger$2R, false, "not implemented");
29984
29978
  }
29985
29979
  broadcastMessage(data2) {
29986
29980
  }
@@ -30031,7 +30025,7 @@ ${codeText}
30031
30025
  return custom;
30032
30026
  });
30033
30027
  }
30034
- const logger$2P = getLogger("find-block");
30028
+ const logger$2Q = getLogger("find-block");
30035
30029
  function findPrevVisibleSimpleBlock(editor, block) {
30036
30030
  const prevVisibleBlock = getPrevVisibleBlock(block);
30037
30031
  if (!prevVisibleBlock) {
@@ -30039,7 +30033,7 @@ ${codeText}
30039
30033
  return null;
30040
30034
  }
30041
30035
  const parent = getParentBlockExcludeSelf(block);
30042
- assert(logger$2P, parent, "no parent block");
30036
+ assert(logger$2Q, parent, "no parent block");
30043
30037
  return findPrevVisibleSimpleBlock(editor, parent);
30044
30038
  }
30045
30039
  if (!isComplexKindBlock(editor, prevVisibleBlock)) {
@@ -30054,7 +30048,7 @@ ${codeText}
30054
30048
  return null;
30055
30049
  }
30056
30050
  const parent = getParentBlockExcludeSelf(block);
30057
- assert(logger$2P, parent, "no parent block");
30051
+ assert(logger$2Q, parent, "no parent block");
30058
30052
  return findNextVisibleSimpleBlock(editor, parent);
30059
30053
  }
30060
30054
  if (!isComplexKindBlock(editor, nextVisibleBlock)) {
@@ -30062,7 +30056,7 @@ ${codeText}
30062
30056
  }
30063
30057
  return complexBlockGetFirstSimpleChild(editor, nextVisibleBlock, { visibleOnly: true });
30064
30058
  }
30065
- const logger$2O = getLogger("remote-cursor");
30059
+ const logger$2P = getLogger("remote-cursor");
30066
30060
  class RemoteCaretsHandler {
30067
30061
  constructor() {
30068
30062
  __publicField(this, "remoteUsers", new RemoteUsers());
@@ -30075,7 +30069,7 @@ ${codeText}
30075
30069
  } else if (message.type === "caret") {
30076
30070
  this.handleUpdateCaret(message);
30077
30071
  } else {
30078
- logger$2O.debug(`unknown remote message received: ${msg}`);
30072
+ logger$2P.debug(`unknown remote message received: ${msg}`);
30079
30073
  }
30080
30074
  }
30081
30075
  handleUpdateUsers(users) {
@@ -30202,7 +30196,7 @@ ${codeText}
30202
30196
  });
30203
30197
  this.setMethods(defaultMethods);
30204
30198
  }
30205
- var logger$2N = Logger$1;
30199
+ var logger$2O = Logger$1;
30206
30200
  Logger$1.prototype.setMethods = function(overrides) {
30207
30201
  overrides = overrides || {};
30208
30202
  var logger2 = this;
@@ -30212,9 +30206,9 @@ ${codeText}
30212
30206
  }
30213
30207
  });
30214
30208
  };
30215
- var Logger = logger$2N;
30216
- var logger$2M = new Logger();
30217
- var logger_1 = logger$2M;
30209
+ var Logger = logger$2O;
30210
+ var logger$2N = new Logger();
30211
+ var logger_1 = logger$2N;
30218
30212
  function ShareDBError$3(code, message) {
30219
30213
  this.code = code;
30220
30214
  this.message = message || "";
@@ -31133,7 +31127,7 @@ ${codeText}
31133
31127
  presenceRequest: "pr"
31134
31128
  };
31135
31129
  var emitter$5 = emitter$6;
31136
- var logger$2L = logger_1;
31130
+ var logger$2M = logger_1;
31137
31131
  var ShareDBError$2 = error;
31138
31132
  var types$2 = types$3;
31139
31133
  var util$9 = util$a;
@@ -31735,7 +31729,7 @@ ${codeText}
31735
31729
  if (this.inflightOp.create) {
31736
31730
  this.version = message.v;
31737
31731
  } else if (message.v !== this.version) {
31738
- logger$2L.warn("Invalid version from server. Expected: " + this.version + " Received: " + message.v, message);
31732
+ logger$2M.warn("Invalid version from server. Expected: " + this.version + " Received: " + message.v, message);
31739
31733
  return this.fetch();
31740
31734
  }
31741
31735
  if (message[ACTIONS$6.fixup]) {
@@ -34827,7 +34821,7 @@ ${codeText}
34827
34821
  var ACTIONS = messageActions.ACTIONS;
34828
34822
  var types$1 = types$3;
34829
34823
  var util = util$a;
34830
- var logger$2K = logger_1;
34824
+ var logger$2L = logger_1;
34831
34825
  var DocPresenceEmitter = docPresenceEmitter;
34832
34826
  var ERROR_CODE = ShareDBError.CODES;
34833
34827
  function connectionState(socket) {
@@ -34871,11 +34865,11 @@ ${codeText}
34871
34865
  try {
34872
34866
  var data2 = typeof event.data === "string" ? JSON.parse(event.data) : event.data;
34873
34867
  } catch (err) {
34874
- logger$2K.warn("Failed to parse message", event);
34868
+ logger$2L.warn("Failed to parse message", event);
34875
34869
  return;
34876
34870
  }
34877
34871
  if (connection2.debug)
34878
- logger$2K.info("RECV", JSON.stringify(data2));
34872
+ logger$2L.info("RECV", JSON.stringify(data2));
34879
34873
  var request = { data: data2 };
34880
34874
  connection2.emit("receive", request);
34881
34875
  if (!request.data)
@@ -34977,7 +34971,7 @@ ${codeText}
34977
34971
  case ACTIONS.pingPong:
34978
34972
  return this._handlePingPong(err);
34979
34973
  default:
34980
- logger$2K.warn("Ignoring unrecognized message", message);
34974
+ logger$2L.warn("Ignoring unrecognized message", message);
34981
34975
  }
34982
34976
  };
34983
34977
  function wrapErrorData(errorData, fullMessage) {
@@ -35017,7 +35011,7 @@ ${codeText}
35017
35011
  doc2[method](err);
35018
35012
  }
35019
35013
  } else {
35020
- logger$2K.error("Invalid bulk message", message);
35014
+ logger$2L.error("Invalid bulk message", message);
35021
35015
  }
35022
35016
  };
35023
35017
  Connection$1.prototype._reset = function() {
@@ -35150,7 +35144,7 @@ ${codeText}
35150
35144
  };
35151
35145
  Connection$1.prototype.send = function(message) {
35152
35146
  if (this.debug)
35153
- logger$2K.info("SEND", JSON.stringify(message));
35147
+ logger$2L.info("SEND", JSON.stringify(message));
35154
35148
  this.emit("send", message);
35155
35149
  this.socket.send(JSON.stringify(message));
35156
35150
  };
@@ -35427,12 +35421,12 @@ ${codeText}
35427
35421
  };
35428
35422
  const AuthHeader = "x-live-editor-token";
35429
35423
  const BaseURLHeader = "x-live-editor-base-url";
35430
- const logger$2J = getLogger("auth-connection");
35424
+ const logger$2K = getLogger("auth-connection");
35431
35425
  function silentTry(fn) {
35432
35426
  try {
35433
35427
  fn();
35434
35428
  } catch (e2) {
35435
- logger$2J.error(e2);
35429
+ logger$2K.error(e2);
35436
35430
  }
35437
35431
  }
35438
35432
  class AuthConnection {
@@ -35472,7 +35466,7 @@ ${codeText}
35472
35466
  return toBase64URL(this.getBaseURL());
35473
35467
  }
35474
35468
  async auth(auth) {
35475
- assert(logger$2J, auth.token, "no auth token");
35469
+ assert(logger$2K, auth.token, "no auth token");
35476
35470
  const authURL = `${this.getBaseURL()}/auth`;
35477
35471
  const ret = await window.fetch(authURL, {
35478
35472
  method: "GET",
@@ -35517,7 +35511,7 @@ ${codeText}
35517
35511
  minReconnectionDelay: 1e3
35518
35512
  });
35519
35513
  this.connection = Object.create(Connection.prototype);
35520
- assert(logger$2J, this.connection, "no this.connection");
35514
+ assert(logger$2K, this.connection, "no this.connection");
35521
35515
  const thatWs = this.ws;
35522
35516
  const pingOptions = this.pingOptions;
35523
35517
  this.connection._initializeHandshake = function handshake() {
@@ -35554,7 +35548,7 @@ ${codeText}
35554
35548
  if (!recoverFlag) {
35555
35549
  recoverFlag = true;
35556
35550
  } else {
35557
- logger$2J.info("retrying re-auth success");
35551
+ logger$2K.info("retrying re-auth success");
35558
35552
  recoverFlag = false;
35559
35553
  this.emitAuthRecover();
35560
35554
  }
@@ -35598,13 +35592,13 @@ ${codeText}
35598
35592
  }
35599
35593
  async _autoReAuth() {
35600
35594
  this.retryCount += 1;
35601
- logger$2J.info(`retrying re-auth attempt no. ${this.retryCount}`);
35595
+ logger$2K.info(`retrying re-auth attempt no. ${this.retryCount}`);
35602
35596
  try {
35603
35597
  await this.reAuth();
35604
35598
  } catch (err) {
35605
- logger$2J.error(err);
35599
+ logger$2K.error(err);
35606
35600
  if (this.retryCount >= 5) {
35607
- logger$2J.warn("retry auth times exceed 5, broadcast auth error");
35601
+ logger$2K.warn("retry auth times exceed 5, broadcast auth error");
35608
35602
  this.emitAuthError();
35609
35603
  }
35610
35604
  const maxInterval = 30 * 1e3;
@@ -35618,13 +35612,13 @@ ${codeText}
35618
35612
  async autoReAuth() {
35619
35613
  var _a, _b;
35620
35614
  if (!this.enabled || this.retryCount > 0) {
35621
- logger$2J.debug("autoReAuth: not enabled or retryCount > 0");
35615
+ logger$2K.debug("autoReAuth: not enabled or retryCount > 0");
35622
35616
  return;
35623
35617
  }
35624
- logger$2J.log("autoReAuth begin!");
35618
+ logger$2K.log("autoReAuth begin!");
35625
35619
  (_a = this.ws) == null ? void 0 : _a.close();
35626
35620
  await this._autoReAuth();
35627
- logger$2J.log("autoReAuth end!");
35621
+ logger$2K.log("autoReAuth end!");
35628
35622
  (_b = this.ws) == null ? void 0 : _b.reconnect();
35629
35623
  }
35630
35624
  async handleAuthError() {
@@ -35663,36 +35657,36 @@ ${codeText}
35663
35657
  }
35664
35658
  const err = msg.err;
35665
35659
  if (err === AuthError.err) {
35666
- logger$2J.warn("auth error");
35660
+ logger$2K.warn("auth error");
35667
35661
  this.handleAuthError();
35668
35662
  } else if (err === MaxUserError.err) {
35669
- logger$2J.warn(MaxUserError.msg);
35663
+ logger$2K.warn(MaxUserError.msg);
35670
35664
  this.emitMaxUsersError();
35671
35665
  } else if (err === RequestReloadError.err) {
35672
- logger$2J.warn(RequestReloadError.msg);
35666
+ logger$2K.warn(RequestReloadError.msg);
35673
35667
  try {
35674
35668
  this.emitRequestReloadError();
35675
35669
  } catch (errTemp) {
35676
- logger$2J.error(`error occurred while process reload error: ${JSON.stringify(errTemp)}`);
35670
+ logger$2K.error(`error occurred while process reload error: ${JSON.stringify(errTemp)}`);
35677
35671
  } finally {
35678
35672
  this.end(false);
35679
35673
  }
35680
35674
  } else if (err === PermissionError.err) {
35681
35675
  this.emitPermissionError();
35682
35676
  } else {
35683
- logger$2J.error(`unknown message received: ${JSON.stringify(msg)}`);
35677
+ logger$2K.error(`unknown message received: ${JSON.stringify(msg)}`);
35684
35678
  this.emitAuthError();
35685
35679
  }
35686
35680
  }
35687
35681
  get(collectionName, documentID) {
35688
- assert(logger$2J, this.connection, "no this.connection");
35682
+ assert(logger$2K, this.connection, "no this.connection");
35689
35683
  return this.connection.get(collectionName, documentID);
35690
35684
  }
35691
35685
  addEventListener(event, callback) {
35692
35686
  if (event === "error") {
35693
35687
  this.events.addListener(event, callback);
35694
35688
  } else {
35695
- assert(logger$2J, this.ws, "no this.ws");
35689
+ assert(logger$2K, this.ws, "no this.ws");
35696
35690
  this.ws.addEventListener(event, callback);
35697
35691
  }
35698
35692
  }
@@ -35706,11 +35700,11 @@ ${codeText}
35706
35700
  this.events.addListener("writeConflictError", callback);
35707
35701
  }
35708
35702
  onMaxUsersError(callback) {
35709
- assert(logger$2J, this.events.listenerCount("maxUsersError") === 0, "too many maxUserError listener");
35703
+ assert(logger$2K, this.events.listenerCount("maxUsersError") === 0, "too many maxUserError listener");
35710
35704
  this.events.addListener("maxUsersError", callback);
35711
35705
  }
35712
35706
  onRequestReloadError(callback) {
35713
- assert(logger$2J, this.events.listenerCount("requestReloadError") === 0, "to many requestReloadError listener");
35707
+ assert(logger$2K, this.events.listenerCount("requestReloadError") === 0, "to many requestReloadError listener");
35714
35708
  this.events.addListener("requestReloadError", callback);
35715
35709
  }
35716
35710
  end(logout) {
@@ -35765,7 +35759,7 @@ ${codeText}
35765
35759
  const result = hasher.digest();
35766
35760
  return toBase64URL(result);
35767
35761
  }
35768
- const logger$2I = getLogger("sharedb-doc/client");
35762
+ const logger$2J = getLogger("sharedb-doc/client");
35769
35763
  const axiosInstance$1 = axios__default.default.create();
35770
35764
  class ShareDBClient {
35771
35765
  constructor(auth, serverUrl, reauthFunc) {
@@ -35783,12 +35777,12 @@ ${codeText}
35783
35777
  resolve();
35784
35778
  });
35785
35779
  });
35786
- assert(logger$2I, !this.doc, "This websocket has opened a doc.");
35780
+ assert(logger$2J, !this.doc, "This websocket has opened a doc.");
35787
35781
  await this.connection.init(this.auth);
35788
35782
  const doc2 = this.connection.get(this.auth.appId, this.auth.docId);
35789
35783
  this.doc = doc2;
35790
35784
  await fetchDoc(doc2);
35791
- logger$2I.debug(doc2);
35785
+ logger$2J.debug(doc2);
35792
35786
  return doc2;
35793
35787
  });
35794
35788
  this.auth = auth;
@@ -35797,10 +35791,19 @@ ${codeText}
35797
35791
  this.connection = new AuthConnection(url, reauthFunc);
35798
35792
  this.reauthFunc = reauthFunc;
35799
35793
  }
35794
+ token() {
35795
+ return this.connection.token;
35796
+ }
35797
+ resourceToken() {
35798
+ return this.connection.resourceToken || this.token();
35799
+ }
35800
+ docId() {
35801
+ return this.auth.docId;
35802
+ }
35800
35803
  editorServer() {
35801
35804
  const apiServer = this.apiServer();
35802
35805
  const last = `/${this.auth.appId}/${this.auth.docId}`;
35803
- assert(logger$2I, apiServer.endsWith(last), `invalid api server: ${apiServer}, ${last}`);
35806
+ assert(logger$2J, apiServer.endsWith(last), `invalid api server: ${apiServer}, ${last}`);
35804
35807
  return apiServer.substr(0, apiServer.length - last.length);
35805
35808
  }
35806
35809
  close(logout) {
@@ -35898,7 +35901,7 @@ ${codeText}
35898
35901
  }
35899
35902
  max += 500;
35900
35903
  const handleUploadProgress = (event) => {
35901
- logger$2I.info(`on progress: ${event.loaded}`);
35904
+ logger$2J.info(`on progress: ${event.loaded}`);
35902
35905
  let value = event.loaded * 100 / max;
35903
35906
  if (value > 100)
35904
35907
  value = 100;
@@ -35927,7 +35930,7 @@ ${codeText}
35927
35930
  },
35928
35931
  onUploadProgress: handleUploadProgress
35929
35932
  });
35930
- logger$2I.info(result);
35933
+ logger$2J.info(result);
35931
35934
  onProgress(100);
35932
35935
  return Array.isArray(result.data) ? result.data[0] : result.data;
35933
35936
  }
@@ -35935,11 +35938,11 @@ ${codeText}
35935
35938
  }, options) {
35936
35939
  const server = this.apiServer();
35937
35940
  const api = `${server}/resources`;
35938
- assert(logger$2I, this.connection.token, "no connection token");
35941
+ assert(logger$2J, this.connection.token, "no connection token");
35939
35942
  const ret = await this.uploadFile(api, file2, {
35940
35943
  [AuthHeader]: this.connection.token
35941
35944
  }, onProgress, options);
35942
- assert(logger$2I, ret, "no result");
35945
+ assert(logger$2J, ret, "no result");
35943
35946
  return ret;
35944
35947
  }
35945
35948
  async request(url, opt) {
@@ -35952,7 +35955,7 @@ ${codeText}
35952
35955
  if (!options.headers) {
35953
35956
  options.headers = {};
35954
35957
  }
35955
- assert(logger$2I, token, "no token");
35958
+ assert(logger$2J, token, "no token");
35956
35959
  options.headers = {
35957
35960
  ...options.headers,
35958
35961
  [AuthHeader]: token,
@@ -35981,7 +35984,7 @@ ${codeText}
35981
35984
  throw err;
35982
35985
  }
35983
35986
  }
35984
- assert(logger$2I, lastErr, "no error");
35987
+ assert(logger$2J, lastErr, "no error");
35985
35988
  throw lastErr;
35986
35989
  }
35987
35990
  async getVersions() {
@@ -36024,7 +36027,7 @@ ${codeText}
36024
36027
  }
36025
36028
  let doc2;
36026
36029
  if (createdDoc) {
36027
- assert(logger$2I, createdDoc.create, "no createDoc.create");
36030
+ assert(logger$2J, createdDoc.create, "no createDoc.create");
36028
36031
  doc2 = createdDoc.create.data;
36029
36032
  } else {
36030
36033
  doc2 = JSON.parse(ret.data.data);
@@ -36145,7 +36148,7 @@ ${codeText}
36145
36148
  const id = genId();
36146
36149
  return { blocks: [{ id, type: "text", text: [] }], comments: {}, meta: {} };
36147
36150
  }
36148
- const logger$2H = getLogger("block-ids");
36151
+ const logger$2I = getLogger("block-ids");
36149
36152
  class BlockIds {
36150
36153
  constructor() {
36151
36154
  __publicField(this, "ids", /* @__PURE__ */ new Map());
@@ -36156,7 +36159,7 @@ ${codeText}
36156
36159
  const index2 = indexes[i];
36157
36160
  if (index2 >= blockIndex) {
36158
36161
  const oldId = this.ids.get(index2);
36159
- assert(logger$2H, oldId !== void 0, "old id is not exists");
36162
+ assert(logger$2I, oldId !== void 0, "old id is not exists");
36160
36163
  this.ids.delete(index2);
36161
36164
  this.ids.set(index2 + 1, oldId);
36162
36165
  }
@@ -36171,7 +36174,7 @@ ${codeText}
36171
36174
  const index2 = indexes[i];
36172
36175
  if (index2 > blockIndex) {
36173
36176
  const oldId = this.ids.get(index2);
36174
- assert(logger$2H, oldId !== void 0, "old id is not exists");
36177
+ assert(logger$2I, oldId !== void 0, "old id is not exists");
36175
36178
  this.ids.delete(index2);
36176
36179
  this.ids.set(index2 - 1, oldId);
36177
36180
  }
@@ -36222,7 +36225,7 @@ ${codeText}
36222
36225
  };
36223
36226
  }
36224
36227
  }
36225
- assert(logger$2H, false, "fault error: failed to get block index");
36228
+ assert(logger$2I, false, "fault error: failed to get block index");
36226
36229
  return { containerId: "error", blockIndex: -1 };
36227
36230
  }
36228
36231
  }
@@ -36248,7 +36251,7 @@ ${codeText}
36248
36251
  };
36249
36252
  }
36250
36253
  }
36251
- const logger$2G = getLogger("op-parse-handler");
36254
+ const logger$2H = getLogger("op-parse-handler");
36252
36255
  class ParseHandler {
36253
36256
  constructor(outerHandler, local) {
36254
36257
  __publicField(this, "actions", []);
@@ -36356,7 +36359,7 @@ ${codeText}
36356
36359
  blockIds.onDeleteBlock(a.containerId, a.blockIndex);
36357
36360
  const ignoreObjectData = updatingBlockDataDeltaMap.get(blockId);
36358
36361
  if (ignoreObjectData) {
36359
- logger$2G.debug(`ignore update object data before delete block: ${JSON.stringify(ignoreObjectData)}`);
36362
+ logger$2H.debug(`ignore update object data before delete block: ${JSON.stringify(ignoreObjectData)}`);
36360
36363
  updatingBlockDataDeltaMap.delete(blockId);
36361
36364
  }
36362
36365
  const deletesBlockKey = `${a.containerId}-${a.blockIndex}`;
@@ -36366,7 +36369,7 @@ ${codeText}
36366
36369
  const a = action;
36367
36370
  const deletesBlockKey = `${a.containerId}-${a.blockIndex}`;
36368
36371
  if (deletedBlocks.has(deletesBlockKey)) {
36369
- logger$2G.warn("delete block data after delete block, ignore it");
36372
+ logger$2H.warn("delete block data after delete block, ignore it");
36370
36373
  continue;
36371
36374
  }
36372
36375
  const blockId = blockIds.getBlockId(a.containerId, a.blockIndex);
@@ -36377,7 +36380,7 @@ ${codeText}
36377
36380
  }
36378
36381
  delta.delete(a.key);
36379
36382
  } else {
36380
- assert(logger$2G, false, `invalid action type, ${action.type}`);
36383
+ assert(logger$2H, false, `invalid action type, ${action.type}`);
36381
36384
  }
36382
36385
  }
36383
36386
  this.actions.forEach((action) => {
@@ -36425,7 +36428,7 @@ ${codeText}
36425
36428
  });
36426
36429
  }
36427
36430
  }
36428
- const logger$2F = getLogger("op-parser");
36431
+ const logger$2G = getLogger("op-parser");
36429
36432
  class DeleteBlockAction {
36430
36433
  }
36431
36434
  class DeleteBlockDataAction {
@@ -36472,8 +36475,8 @@ ${codeText}
36472
36475
  }
36473
36476
  }
36474
36477
  const blockData = firstOp.i;
36475
- assert(logger$2F, blockData.id, "block id is required");
36476
- assert(logger$2F, blockData.type, "block type is required");
36478
+ assert(logger$2G, blockData.id, "block id is required");
36479
+ assert(logger$2G, blockData.type, "block type is required");
36477
36480
  for (let i = 1; i < ops.length; i++) {
36478
36481
  const nextOp = ops[i];
36479
36482
  const key = nextOp[0];
@@ -36487,7 +36490,7 @@ ${codeText}
36487
36490
  if (processType === "upsert" && parseInsertBlockOnlyOp(containerId, orgOps, processor)) {
36488
36491
  return;
36489
36492
  }
36490
- assert(logger$2F, Array.isArray(orgOps), `invalid block op: ${containerId}, ${JSON.stringify(orgOps)}`);
36493
+ assert(logger$2G, Array.isArray(orgOps), `invalid block op: ${containerId}, ${JSON.stringify(orgOps)}`);
36491
36494
  const ops = orgOps.concat();
36492
36495
  const blockIndex = ops[0];
36493
36496
  ops.shift();
@@ -36496,22 +36499,22 @@ ${codeText}
36496
36499
  const data2 = ops[0];
36497
36500
  if (data2 === "text") {
36498
36501
  const opData = ops[1];
36499
- assert(logger$2F, typeof opData === "object", `invalid block op: ${containerId}, ${JSON.stringify(orgOps)}`);
36500
- assert(logger$2F, opData.et === "rich-text", `invalid block op: ${containerId}, ${JSON.stringify(orgOps)}`);
36502
+ assert(logger$2G, typeof opData === "object", `invalid block op: ${containerId}, ${JSON.stringify(orgOps)}`);
36503
+ assert(logger$2G, opData.et === "rich-text", `invalid block op: ${containerId}, ${JSON.stringify(orgOps)}`);
36501
36504
  ops.splice(0, 2);
36502
36505
  if (processType === "upsert") {
36503
36506
  const deltaOps = opData.e;
36504
36507
  const richTextData = deltaOps;
36505
36508
  processor.onUpdateBlockText(containerId, blockIndex, richTextData);
36506
36509
  }
36507
- assert(logger$2F, ops.length === 0, `invalid block ops.length !== 0, ${JSON.stringify(ops)}`);
36510
+ assert(logger$2G, ops.length === 0, `invalid block ops.length !== 0, ${JSON.stringify(ops)}`);
36508
36511
  } else if (Array.isArray(data2)) {
36509
- assert(logger$2F, data2.length === 2, `invalid block op: data.length !== 2, ${JSON.stringify(data2)}`);
36512
+ assert(logger$2G, data2.length === 2, `invalid block op: data.length !== 2, ${JSON.stringify(data2)}`);
36510
36513
  const key = data2[0];
36511
- assert(logger$2F, typeof key === "string", `invalid block op: key ${JSON.stringify(key)}`);
36514
+ assert(logger$2G, typeof key === "string", `invalid block op: key ${JSON.stringify(key)}`);
36512
36515
  const opData = data2[1];
36513
36516
  if (key === "text") {
36514
- assert(logger$2F, typeof opData === "object", `invalid opData type, ${JSON.stringify(opData)}`);
36517
+ assert(logger$2G, typeof opData === "object", `invalid opData type, ${JSON.stringify(opData)}`);
36515
36518
  if (opData.i) {
36516
36519
  if (processType === "upsert") {
36517
36520
  processor.onInsertBlockData(containerId, blockIndex, key, opData.i);
@@ -36556,9 +36559,9 @@ ${codeText}
36556
36559
  }
36557
36560
  ops.shift();
36558
36561
  } else {
36559
- assert(logger$2F, typeof data2 === "string", "data is not string");
36560
- assert(logger$2F, data2 !== "text", "data !== 'text'");
36561
- assert(logger$2F, ops.length === 2, `invalid block op: ops.length !== 2, ${JSON.stringify(ops)}`);
36562
+ assert(logger$2G, typeof data2 === "string", "data is not string");
36563
+ assert(logger$2G, data2 !== "text", "data !== 'text'");
36564
+ assert(logger$2G, ops.length === 2, `invalid block op: ops.length !== 2, ${JSON.stringify(ops)}`);
36562
36565
  const key = data2;
36563
36566
  const opData = ops[1];
36564
36567
  if (processType === "remove") {
@@ -36581,20 +36584,20 @@ ${codeText}
36581
36584
  } else if (a instanceof DeleteBlockDataAction) {
36582
36585
  processor.onDeleteBlockData(containerId, blockIndex, a.key);
36583
36586
  } else {
36584
- assert(logger$2F, false, `invalid action type: ${typeof a}, ${JSON.stringify(a)}`);
36587
+ assert(logger$2G, false, `invalid action type: ${typeof a}, ${JSON.stringify(a)}`);
36585
36588
  }
36586
36589
  });
36587
36590
  }
36588
36591
  function parseMetaOp(ops, parseType, handler) {
36589
- logger$2F.warn(`unsupported meta op, ${JSON.stringify(ops)}`);
36592
+ logger$2G.warn(`unsupported meta op, ${JSON.stringify(ops)}`);
36590
36593
  }
36591
36594
  function parseCommentsOp(ops, parseType, handler) {
36592
36595
  const commentId = ops[1];
36593
36596
  const actions2 = ops[2];
36594
- assert(logger$2F, commentId, `invalid comment op, no commentId: ${JSON.stringify(ops)}`);
36595
- assert(logger$2F, actions2, `invalid comment op, no actions: ${JSON.stringify(ops)}`);
36597
+ assert(logger$2G, commentId, `invalid comment op, no commentId: ${JSON.stringify(ops)}`);
36598
+ assert(logger$2G, actions2, `invalid comment op, no actions: ${JSON.stringify(ops)}`);
36596
36599
  if (typeof actions2 === "string") {
36597
- logger$2F.error(`unknown comment op, ${JSON.stringify(ops)}`);
36600
+ logger$2G.error(`unknown comment op, ${JSON.stringify(ops)}`);
36598
36601
  } else {
36599
36602
  if (actions2.i && actions2.r) {
36600
36603
  if (parseType === "upsert") {
@@ -36609,7 +36612,7 @@ ${codeText}
36609
36612
  handler.onDeleteComment(commentId);
36610
36613
  }
36611
36614
  } else {
36612
- logger$2F.error(`unknown comment op, ${JSON.stringify(ops)}`);
36615
+ logger$2G.error(`unknown comment op, ${JSON.stringify(ops)}`);
36613
36616
  }
36614
36617
  }
36615
36618
  }
@@ -36622,7 +36625,7 @@ ${codeText}
36622
36625
  return;
36623
36626
  }
36624
36627
  const rootKey = firstOp;
36625
- assert(logger$2F, typeof rootKey === "string", `invalid container id: ${JSON.stringify(ops)}`);
36628
+ assert(logger$2G, typeof rootKey === "string", `invalid container id: ${JSON.stringify(ops)}`);
36626
36629
  if (rootKey === "meta") {
36627
36630
  parseMetaOp(ops);
36628
36631
  return;
@@ -36656,7 +36659,7 @@ ${codeText}
36656
36659
  }
36657
36660
  }
36658
36661
  } else {
36659
- assert(logger$2F, typeof ops[1] === "number", `invalid ops[1], not a number: ${JSON.stringify(ops)}`);
36662
+ assert(logger$2G, typeof ops[1] === "number", `invalid ops[1], not a number: ${JSON.stringify(ops)}`);
36660
36663
  parseBlockOp(containerId, ops.slice(1), parseType, handler);
36661
36664
  }
36662
36665
  }
@@ -36677,10 +36680,10 @@ ${codeText}
36677
36680
  }
36678
36681
  innerHandler.end();
36679
36682
  }
36680
- const logger$2E = getLogger("sharedb-comments");
36683
+ const logger$2F = getLogger("sharedb-comments");
36681
36684
  function shareDBCommentToDocObject(comment) {
36682
36685
  const root2 = comment.blocks;
36683
- assert(logger$2E, root2, "no comment blocks");
36686
+ assert(logger$2F, root2, "no comment blocks");
36684
36687
  const doc2 = {
36685
36688
  blocks: {
36686
36689
  root: root2
@@ -36729,7 +36732,7 @@ ${codeText}
36729
36732
  delete ret.children;
36730
36733
  return ret;
36731
36734
  }
36732
- const logger$2D = getLogger("sharedb-doc/doc-container");
36735
+ const logger$2E = getLogger("sharedb-doc/doc-container");
36733
36736
  const JSON1_TYPE_NAME = "ot-json1";
36734
36737
  json1__namespace.type.registerSubtype(richText.type);
36735
36738
  json1__namespace.type.name = JSON1_TYPE_NAME;
@@ -36833,22 +36836,22 @@ ${codeText}
36833
36836
  __publicField(this, "data", () => this.doc.data);
36834
36837
  __publicField(this, "submitOp", async (ops) => new Promise((resolve, reject) => {
36835
36838
  if (this.destroyed) {
36836
- logger$2D.warn("submit op after destroyed");
36839
+ logger$2E.warn("submit op after destroyed");
36837
36840
  return;
36838
36841
  }
36839
36842
  this.setStatus("dirty");
36840
36843
  this.doc.submitOp(ops, {}, (err) => {
36841
36844
  if (err) {
36842
- logger$2D.error(`invalid op, ${err.message}, ${JSON.stringify(ops)}`);
36845
+ logger$2E.error(`invalid op, ${err.message}, ${JSON.stringify(ops)}`);
36843
36846
  reject(err);
36844
- logger$2D.error("Transform detected write conflict, reload editor");
36847
+ logger$2E.error("Transform detected write conflict, reload editor");
36845
36848
  this.handleReset("write conflict");
36846
36849
  } else {
36847
36850
  resolve();
36848
36851
  }
36849
36852
  });
36850
36853
  if (!this.doc.data) {
36851
- logger$2D.error("no data after submit op, may be the submitted op is invalid");
36854
+ logger$2E.error("no data after submit op, may be the submitted op is invalid");
36852
36855
  this.handleReset(`invalid op, ${JSON.stringify(ops)}`);
36853
36856
  }
36854
36857
  }));
@@ -36912,18 +36915,18 @@ ${codeText}
36912
36915
  });
36913
36916
  __publicField(this, "handleOp", (ops, source, clientId) => {
36914
36917
  if (!ops) {
36915
- logger$2D.warn("handleOp: no ops");
36918
+ logger$2E.warn("handleOp: no ops");
36916
36919
  return;
36917
36920
  }
36918
36921
  if (this.destroyed) {
36919
- logger$2D.warn("handleOp: destroyed");
36922
+ logger$2E.warn("handleOp: destroyed");
36920
36923
  return;
36921
36924
  }
36922
36925
  try {
36923
36926
  const local = !!source;
36924
36927
  parseOps(ops, this, local);
36925
36928
  } catch (err) {
36926
- logger$2D.error(err);
36929
+ logger$2E.error(err);
36927
36930
  throw err;
36928
36931
  }
36929
36932
  });
@@ -36940,7 +36943,7 @@ ${codeText}
36940
36943
  }
36941
36944
  endBatchUpdate() {
36942
36945
  this.batching--;
36943
- assert(logger$2D, this.batching >= 0, "invalid call beginBatchUpdate/endBatchUpdate");
36946
+ assert(logger$2E, this.batching >= 0, "invalid call beginBatchUpdate/endBatchUpdate");
36944
36947
  if (this.batching === 0) {
36945
36948
  this.doc.preventCompose = true;
36946
36949
  }
@@ -36968,8 +36971,8 @@ ${codeText}
36968
36971
  shareDBDoc.initEvents();
36969
36972
  return shareDBDoc;
36970
36973
  } catch (err) {
36971
- logger$2D.error(err);
36972
- logger$2D.error(`failed to load doc: ${JSON.stringify(err)}`);
36974
+ logger$2E.error(err);
36975
+ logger$2E.error(`failed to load doc: ${JSON.stringify(err)}`);
36973
36976
  throw err;
36974
36977
  }
36975
36978
  }
@@ -37043,24 +37046,24 @@ ${codeText}
37043
37046
  }
37044
37047
  getContainerBlocks(containerId) {
37045
37048
  const doc2 = this.data();
37046
- assert(logger$2D, doc2, "no doc data");
37049
+ assert(logger$2E, doc2, "no doc data");
37047
37050
  const blocks = doc2[docObjectContainerId2EditorDocContainerId(containerId)];
37048
- assert(logger$2D, blocks, `no container data: ${containerId}`);
37051
+ assert(logger$2E, blocks, `no container data: ${containerId}`);
37049
37052
  return cloneDeep__default.default(blocks);
37050
37053
  }
37051
37054
  findContainerBlocks(containerId) {
37052
37055
  const doc2 = this.data();
37053
- assert(logger$2D, doc2, "no doc data");
37056
+ assert(logger$2E, doc2, "no doc data");
37054
37057
  const blocks = doc2[docObjectContainerId2EditorDocContainerId(containerId)];
37055
37058
  return blocks != null ? blocks : null;
37056
37059
  }
37057
37060
  getBlockData(containerId, blockIndex) {
37058
37061
  const doc2 = this.data();
37059
- assert(logger$2D, doc2, "no doc data");
37062
+ assert(logger$2E, doc2, "no doc data");
37060
37063
  const blocks = doc2[docObjectContainerId2EditorDocContainerId(containerId)];
37061
- assert(logger$2D, blocks, `no container data: ${containerId}`);
37064
+ assert(logger$2E, blocks, `no container data: ${containerId}`);
37062
37065
  const blockData = blocks[blockIndex];
37063
- assert(logger$2D, blockData, `no block data: ${blockIndex}`);
37066
+ assert(logger$2E, blockData, `no block data: ${blockIndex}`);
37064
37067
  return cloneDeep__default.default(blockData);
37065
37068
  }
37066
37069
  localInsertBlock(containerId, blockIndex, data2) {
@@ -37074,11 +37077,11 @@ ${codeText}
37074
37077
  }
37075
37078
  localUpdateBlockText(containerId, blockIndex, actions2) {
37076
37079
  const oldBlockData = this.getBlockData(containerId, blockIndex);
37077
- assert(logger$2D, oldBlockData.text, "no block text");
37080
+ assert(logger$2E, oldBlockData.text, "no block text");
37078
37081
  const oldText = cloneDeep__default.default(oldBlockData.text);
37079
37082
  this.submitUpdateRichText(containerId, blockIndex, actions2);
37080
37083
  const newText = RichText.apply(oldText, actions2);
37081
- assert(logger$2D, newText, "no block text");
37084
+ assert(logger$2E, newText, "no block text");
37082
37085
  return newText;
37083
37086
  }
37084
37087
  localUpdateBlockData(containerId, blockIndex, delta) {
@@ -37135,65 +37138,65 @@ ${codeText}
37135
37138
  this.remoteCaretHandler.destroy();
37136
37139
  }
37137
37140
  onDeleteBlock(containerId, blockIndex, local) {
37138
- assert(logger$2D, this.callbacks.length > 0, "no callbacks");
37141
+ assert(logger$2E, this.callbacks.length > 0, "no callbacks");
37139
37142
  this.callbacks.forEach((cb) => {
37140
37143
  var _a;
37141
37144
  return (_a = cb.onDeleteBlock) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, local);
37142
37145
  });
37143
37146
  }
37144
37147
  onInsertBlock(containerId, blockIndex, data2, local) {
37145
- assert(logger$2D, this.callbacks.length > 0, "no callbacks");
37148
+ assert(logger$2E, this.callbacks.length > 0, "no callbacks");
37146
37149
  this.callbacks.forEach((cb) => {
37147
37150
  var _a;
37148
37151
  return (_a = cb.onInsertBlock) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, data2, local);
37149
37152
  });
37150
37153
  }
37151
37154
  onUpdateBlockData(containerId, blockIndex, delta, local) {
37152
- assert(logger$2D, this.callbacks.length > 0, "no callbacks");
37155
+ assert(logger$2E, this.callbacks.length > 0, "no callbacks");
37153
37156
  this.callbacks.forEach((cb) => {
37154
37157
  var _a;
37155
37158
  return (_a = cb.onUpdateBlockData) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, delta, local);
37156
37159
  });
37157
37160
  }
37158
37161
  onUpdateBlockText(containerId, blockIndex, actions2, local) {
37159
- assert(logger$2D, this.callbacks.length > 0, "no callbacks");
37162
+ assert(logger$2E, this.callbacks.length > 0, "no callbacks");
37160
37163
  this.callbacks.forEach((cb) => {
37161
37164
  var _a;
37162
37165
  return (_a = cb.onUpdateBlockText) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, actions2, local);
37163
37166
  });
37164
37167
  }
37165
37168
  onDeleteContainer(containerId, local) {
37166
- assert(logger$2D, this.callbacks.length > 0, "no callbacks");
37167
- assert(logger$2D, containerId !== "root", "should not delete root container in doc");
37169
+ assert(logger$2E, this.callbacks.length > 0, "no callbacks");
37170
+ assert(logger$2E, containerId !== "root", "should not delete root container in doc");
37168
37171
  this.callbacks.forEach((cb) => {
37169
37172
  var _a;
37170
37173
  return (_a = cb.onDeleteChildContainer) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), local);
37171
37174
  });
37172
37175
  }
37173
37176
  onCreateContainer(containerId, blocks, local) {
37174
- assert(logger$2D, this.callbacks.length > 0, "no callbacks");
37175
- assert(logger$2D, containerId !== "root", "should not create root container in doc");
37177
+ assert(logger$2E, this.callbacks.length > 0, "no callbacks");
37178
+ assert(logger$2E, containerId !== "root", "should not create root container in doc");
37176
37179
  this.callbacks.forEach((cb) => {
37177
37180
  var _a;
37178
37181
  return (_a = cb.onInsertChildContainer) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blocks, local);
37179
37182
  });
37180
37183
  }
37181
37184
  onDeleteComment(commentId, local) {
37182
- assert(logger$2D, this.callbacks.length > 0, "no callbacks");
37185
+ assert(logger$2E, this.callbacks.length > 0, "no callbacks");
37183
37186
  this.callbacks.forEach((cb) => {
37184
37187
  var _a;
37185
37188
  return (_a = cb.onDeleteComment) == null ? void 0 : _a.call(cb, commentId, local);
37186
37189
  });
37187
37190
  }
37188
37191
  onCreateComment(commentId, local) {
37189
- assert(logger$2D, this.callbacks.length > 0, "no callbacks");
37192
+ assert(logger$2E, this.callbacks.length > 0, "no callbacks");
37190
37193
  this.callbacks.forEach((cb) => {
37191
37194
  var _a;
37192
37195
  return (_a = cb.onCreateComment) == null ? void 0 : _a.call(cb, commentId, local);
37193
37196
  });
37194
37197
  }
37195
37198
  onUpdateComment(commentId, local) {
37196
- assert(logger$2D, this.callbacks.length > 0, "no callbacks");
37199
+ assert(logger$2E, this.callbacks.length > 0, "no callbacks");
37197
37200
  this.callbacks.forEach((cb) => {
37198
37201
  var _a;
37199
37202
  return (_a = cb.onUpdateComment) == null ? void 0 : _a.call(cb, commentId, local);
@@ -37361,7 +37364,7 @@ ${codeText}
37361
37364
  this.editor.doc.getRemoteUsers().removeListener("remote-carets-change", this.handleRemoteCaretsChanged);
37362
37365
  }
37363
37366
  }
37364
- const logger$2C = getLogger("remote-cursor-decorator");
37367
+ const logger$2D = getLogger("remote-cursor-decorator");
37365
37368
  class RemoteCaretsDecorator {
37366
37369
  decorateText(editor, path, blockText) {
37367
37370
  const remoteUsers = editor.doc.getRemoteUsers();
@@ -37370,8 +37373,8 @@ ${codeText}
37370
37373
  }
37371
37374
  const insertions = /* @__PURE__ */ new Map();
37372
37375
  const { containerId, blockIndex } = path[path.length - 1];
37373
- assert(logger$2C, typeof containerId === "string", "invalid path containerId");
37374
- assert(logger$2C, typeof blockIndex === "number", "invalid path blockIndex");
37376
+ assert(logger$2D, typeof containerId === "string", "invalid path containerId");
37377
+ assert(logger$2D, typeof blockIndex === "number", "invalid path blockIndex");
37375
37378
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
37376
37379
  const length = getTextLength(blockText);
37377
37380
  const cursorMessages = remoteUsers.getSimpleCursors(blockData.id);
@@ -37401,6 +37404,221 @@ ${codeText}
37401
37404
  };
37402
37405
  }
37403
37406
  }
37407
+ const logger$2C = getLogger("sharedb-server");
37408
+ class ShareDBClientBase {
37409
+ async getFileUrlByHash(uploadFileUrl, hash, name, size, headers) {
37410
+ try {
37411
+ const url = `${uploadFileUrl}/${hash}`;
37412
+ const ret = await this.request(url, {
37413
+ method: "post",
37414
+ headers: {
37415
+ ...headers
37416
+ },
37417
+ data: {
37418
+ name,
37419
+ size
37420
+ }
37421
+ });
37422
+ if (ret.data && Array.isArray(ret.data) && ret.data.length === 1) {
37423
+ return ret.data[0];
37424
+ }
37425
+ return "";
37426
+ } catch (err) {
37427
+ return "";
37428
+ }
37429
+ }
37430
+ async getFileUrlsByHashes(resourceHashes) {
37431
+ const server = this.apiServer();
37432
+ const api = `${server}/resources`;
37433
+ try {
37434
+ const url = `${api}/hash`;
37435
+ const ret = await this.request(url, {
37436
+ method: "post",
37437
+ headers: {
37438
+ [AuthHeader]: this.token()
37439
+ },
37440
+ data: {
37441
+ resources: resourceHashes
37442
+ }
37443
+ });
37444
+ if (ret.data && Array.isArray(ret.data)) {
37445
+ return ret.data;
37446
+ }
37447
+ return [];
37448
+ } catch (err) {
37449
+ return [];
37450
+ }
37451
+ }
37452
+ async uploadFile(url, file2, headers, onProgress, options) {
37453
+ let max = file2.size;
37454
+ if (max === 0) {
37455
+ throw new Error("file is empty");
37456
+ }
37457
+ max += 500;
37458
+ const handleUploadProgress = (event) => {
37459
+ logger$2C.info(`on progress: ${event.loaded}`);
37460
+ let value = event.loaded * 100 / max;
37461
+ if (value > 100)
37462
+ value = 100;
37463
+ onProgress(value);
37464
+ };
37465
+ const hash = await hashFile(file2);
37466
+ const existsUrl = await this.getFileUrlByHash(url, hash, file2.name, file2.size, headers);
37467
+ if (existsUrl) {
37468
+ onProgress(-1);
37469
+ return existsUrl;
37470
+ }
37471
+ let newUrl = url;
37472
+ if (options == null ? void 0 : options.thumbnail) {
37473
+ newUrl += "/thumbnail";
37474
+ }
37475
+ const data2 = new FormData();
37476
+ data2.append("file-size", `${file2.size}`);
37477
+ data2.append("file-hash", hash);
37478
+ data2.append("file", file2, file2.name);
37479
+ const result = await this.request(newUrl, {
37480
+ method: "post",
37481
+ data: data2,
37482
+ withCredentials: true,
37483
+ headers: {
37484
+ ...headers
37485
+ },
37486
+ onUploadProgress: handleUploadProgress
37487
+ });
37488
+ logger$2C.info(result);
37489
+ onProgress(100);
37490
+ return Array.isArray(result.data) ? result.data[0] : result.data;
37491
+ }
37492
+ async uploadResource(file2, onProgress = () => {
37493
+ }, options) {
37494
+ const server = this.apiServer();
37495
+ const api = `${server}/resources`;
37496
+ const token = this.token();
37497
+ assert(logger$2C, token, "no connection token");
37498
+ const ret = await this.uploadFile(api, file2, {
37499
+ [AuthHeader]: token
37500
+ }, onProgress, options);
37501
+ assert(logger$2C, ret, "no result");
37502
+ return ret;
37503
+ }
37504
+ getResourceId(url) {
37505
+ const regex = /\/resources\/([^?]+)/;
37506
+ const matchResult = url.match(regex);
37507
+ if (matchResult && matchResult.length >= 2) {
37508
+ const resourceId = matchResult[1];
37509
+ return resourceId;
37510
+ }
37511
+ return "";
37512
+ }
37513
+ buildResourceUrl(resourceId, options) {
37514
+ var _a, _b;
37515
+ if (!resourceId) {
37516
+ return "";
37517
+ }
37518
+ if (resourceId.startsWith("file:") || resourceId.startsWith("data:") || resourceId.startsWith("blob:")) {
37519
+ return resourceId;
37520
+ }
37521
+ const apiServer = this.apiServer();
37522
+ if (resourceId.startsWith("http:") || resourceId.startsWith("https:")) {
37523
+ const connectionUrlWithoutDocId = apiServer.replace(/\/[^/]*$/, "");
37524
+ if (connectionUrlWithoutDocId && resourceId.includes(connectionUrlWithoutDocId)) {
37525
+ const currentDocId = this.docId();
37526
+ const startMarker = `${connectionUrlWithoutDocId}/`;
37527
+ const endMarker = "/resources";
37528
+ const startIndex = resourceId.indexOf(startMarker);
37529
+ const endIndex = resourceId.indexOf(endMarker, startIndex + startMarker.length);
37530
+ if (startIndex !== -1 && endIndex !== -1) {
37531
+ const resourceDocId = resourceId.substring(startIndex + startMarker.length, endIndex);
37532
+ if (resourceDocId !== currentDocId) {
37533
+ let newResourceUrl = resourceId.replace(resourceDocId, currentDocId);
37534
+ const url = new URL(newResourceUrl);
37535
+ const paramNameToRemove = "token";
37536
+ (_a = url.searchParams) == null ? void 0 : _a.delete(paramNameToRemove);
37537
+ newResourceUrl = url.toString();
37538
+ const syncResourceId = this.getResourceId(newResourceUrl);
37539
+ if (options == null ? void 0 : options.syncNewResources) {
37540
+ (_b = options == null ? void 0 : options.syncNewResources) == null ? void 0 : _b.call(options, syncResourceId, newResourceUrl);
37541
+ }
37542
+ return newResourceUrl;
37543
+ }
37544
+ return resourceId;
37545
+ }
37546
+ return resourceId;
37547
+ }
37548
+ return resourceId;
37549
+ }
37550
+ let ret = `${apiServer}/resources/${encodeURIComponent(resourceId)}`;
37551
+ const params = [];
37552
+ if (options == null ? void 0 : options.withToken) {
37553
+ params.push(`token=${this.resourceToken()}`);
37554
+ }
37555
+ if (options == null ? void 0 : options.downloadFileName) {
37556
+ params.push(`&fileName=${encodeURIComponent(options.downloadFileName)}`);
37557
+ }
37558
+ if (params.length > 0) {
37559
+ const query2 = params.join("&");
37560
+ ret += `?${query2}`;
37561
+ }
37562
+ return ret;
37563
+ }
37564
+ }
37565
+ class ShareDBLocalClient extends ShareDBClientBase {
37566
+ constructor(_options) {
37567
+ super();
37568
+ this._options = _options;
37569
+ }
37570
+ token() {
37571
+ return this._options.token;
37572
+ }
37573
+ apiServer() {
37574
+ return this._options.serverUrl;
37575
+ }
37576
+ resourceToken() {
37577
+ return this._options.resourceToken || this._options.token;
37578
+ }
37579
+ docId() {
37580
+ return this._options.docId;
37581
+ }
37582
+ request(url, opt) {
37583
+ return axios__default.default(url, {
37584
+ ...opt,
37585
+ headers: {
37586
+ "x-live-editor-token": this.token()
37587
+ }
37588
+ });
37589
+ }
37590
+ }
37591
+ class ShareDBLocalDoc extends LocalDoc {
37592
+ constructor(docObject, _options) {
37593
+ super(docObject, {
37594
+ serverUrl: _options.serverUrl
37595
+ });
37596
+ __publicField(this, "_client");
37597
+ this._options = _options;
37598
+ this._client = new ShareDBLocalClient(_options);
37599
+ }
37600
+ buildResourceUrl(src) {
37601
+ return this._client.buildResourceUrl(src);
37602
+ }
37603
+ getUser() {
37604
+ const localUser = {
37605
+ ...this._options.user,
37606
+ permission: "r"
37607
+ };
37608
+ return localUser;
37609
+ }
37610
+ request(url, opt) {
37611
+ return this._client.request(url, opt);
37612
+ }
37613
+ async uploadResource(file2, options) {
37614
+ var _a;
37615
+ const ret = await this._client.uploadResource(file2, (_a = options == null ? void 0 : options.onProgress) != null ? _a : () => {
37616
+ });
37617
+ return {
37618
+ resourceId: ret
37619
+ };
37620
+ }
37621
+ }
37404
37622
  const logger$2B = getLogger("sharedb-doc/share-db-server");
37405
37623
  const axiosInstance = axios__default.default.create();
37406
37624
  class ShareDBSimpleClient {
@@ -48004,7 +48222,7 @@ ${codeText}
48004
48222
  }
48005
48223
  }
48006
48224
  const logger$1S = getLogger("toolbar-handler");
48007
- const SEP$1 = {
48225
+ const SEP = {
48008
48226
  id: "",
48009
48227
  name: "",
48010
48228
  type: "separator"
@@ -48279,7 +48497,7 @@ ${codeText}
48279
48497
  });
48280
48498
  toolbarCommands.push(...sortCommands);
48281
48499
  if (index2 !== toolbarCommandsChunk.length - 1) {
48282
- toolbarCommands.push(SEP$1);
48500
+ toolbarCommands.push(SEP);
48283
48501
  }
48284
48502
  });
48285
48503
  if (toolbarCommands.length === 0) {
@@ -55931,11 +56149,6 @@ $$${mathData.mathjaxText}$$
55931
56149
  "ja-JP": jaJP$s
55932
56150
  });
55933
56151
  const logger$1K = getLogger("readonly-toolbar");
55934
- const SEP = {
55935
- id: "",
55936
- name: "",
55937
- type: "separator"
55938
- };
55939
56152
  class ReadonlyToolbar {
55940
56153
  constructor(editor) {
55941
56154
  __publicField(this, "toolbar");
@@ -56033,35 +56246,6 @@ $$${mathData.mathjaxText}$$
56033
56246
  }
56034
56247
  this.showObjectToolbar(event);
56035
56248
  });
56036
- __publicField(this, "groupCommands", (allCommands) => {
56037
- var _a, _b;
56038
- const allCommandsMap = /* @__PURE__ */ new Map([["common", []]]);
56039
- for (let i = 0; i < allCommands.length; i++) {
56040
- const group = allCommands[i].group;
56041
- if (!group) {
56042
- (_a = allCommandsMap.get("common")) == null ? void 0 : _a.push(allCommands[i]);
56043
- continue;
56044
- }
56045
- if (allCommandsMap.has(group)) {
56046
- (_b = allCommandsMap.get(group)) == null ? void 0 : _b.push(allCommands[i]);
56047
- } else {
56048
- allCommandsMap.set(group, [allCommands[i]]);
56049
- }
56050
- }
56051
- const commandsChunk = [];
56052
- allCommandsMap.forEach((value) => {
56053
- commandsChunk.push(value.sort((item1, item2) => {
56054
- var _a2, _b2;
56055
- return ((_a2 = item1.order) != null ? _a2 : 0) - ((_b2 = item2.order) != null ? _b2 : 0);
56056
- }));
56057
- });
56058
- if (commandsChunk.length === 0) {
56059
- return [];
56060
- }
56061
- const commands = commandsChunk.reduce((prev, curr) => prev.concat([SEP, ...curr]), []);
56062
- commands.shift();
56063
- return commands;
56064
- });
56065
56249
  this.editor = editor;
56066
56250
  const popover = editor.options.componentsOptions.popover;
56067
56251
  this.toolbar = new ManualToolbar([], void 0, {
@@ -56110,7 +56294,7 @@ $$${mathData.mathjaxText}$$
56110
56294
  }
56111
56295
  showTextToolbar(reason) {
56112
56296
  var _a, _b;
56113
- let commands = [];
56297
+ const commands = [];
56114
56298
  const range = this.editor.selection.range;
56115
56299
  this.providers.forEach((provider) => {
56116
56300
  if (provider.getTextCommands) {
@@ -56124,7 +56308,6 @@ $$${mathData.mathjaxText}$$
56124
56308
  commands.push(...textCommands);
56125
56309
  }
56126
56310
  });
56127
- commands = this.groupCommands(commands);
56128
56311
  if (commands.length === 0) {
56129
56312
  this.toolbar.close("cancelBar");
56130
56313
  return;
@@ -63353,8 +63536,8 @@ ${codeText}
63353
63536
  createItem() {
63354
63537
  var _a, _b;
63355
63538
  const { comment, commentsProvider, mainEditor: editor, groupItem } = this.options;
63356
- const canShowReply = !((_a = this.commentOptions) == null ? void 0 : _a.disableReply) && !editor.readonly;
63357
- const canShowEdit = !((_b = this.commentOptions) == null ? void 0 : _b.disableEdit) && !editor.readonly && commentsProvider.allowEdit(comment);
63539
+ const canShowReply = !((_a = this.commentOptions) == null ? void 0 : _a.disableReply);
63540
+ const canShowEdit = !((_b = this.commentOptions) == null ? void 0 : _b.disableEdit) && commentsProvider.allowEdit(comment);
63358
63541
  const canShowMore = canShowEdit && canShowReply;
63359
63542
  const head = createElement("div", ["item-head"], this.root);
63360
63543
  this.createAvatar(head, comment);
@@ -65460,31 +65643,6 @@ ${codeText}
65460
65643
  comments.commentProvider.addListener(this);
65461
65644
  editor.blockHooks.push(this);
65462
65645
  }
65463
- getTextCommands(editor, range) {
65464
- return [{
65465
- id: "add-comment-to-old-doc/text",
65466
- name: "Add Comment"
65467
- }];
65468
- }
65469
- executeCommand(editor, command, options) {
65470
- if (command.id === "add-comment-to-old-doc/text") {
65471
- const comments = editor.getCustom("editor-comments");
65472
- if (!comments) {
65473
- return;
65474
- }
65475
- const range = editor.selection.range;
65476
- if (!range.isSimple()) {
65477
- return;
65478
- }
65479
- comments.showCommentList();
65480
- editor.readonly = false;
65481
- addCommentToTextBlocks(editor, range, comments.commentProvider);
65482
- setTimeout(() => {
65483
- editor.readonly = true;
65484
- }, 100);
65485
- }
65486
- options.bar.close("clickItem");
65487
- }
65488
65646
  async onCreateComment(commentId, local) {
65489
65647
  if (local) {
65490
65648
  const comments = this.editor.getCustom("editor-comments");
@@ -65550,7 +65708,8 @@ ${codeText}
65550
65708
  group: "hovering-toolbar",
65551
65709
  commands: [{
65552
65710
  id: "add-comment-to-old-doc/child",
65553
- name: "Add Comment"
65711
+ name: i18n$1.t("comment.quickMenuCommand"),
65712
+ icon: CommentIcon$1
65554
65713
  }],
65555
65714
  executeCommand: (editor2, block, item, child2) => {
65556
65715
  if (!child2) {
@@ -65584,7 +65743,8 @@ ${codeText}
65584
65743
  group: "hovering-toolbar",
65585
65744
  commands: [{
65586
65745
  id: "add-comment-to-old-doc",
65587
- name: "Add Comment"
65746
+ name: i18n$1.t("comment.quickMenuCommand"),
65747
+ icon: CommentIcon$1
65588
65748
  }],
65589
65749
  executeCommand: (editor2, block, item) => {
65590
65750
  if (item.id === "add-comment-to-old-doc") {
@@ -65602,6 +65762,32 @@ ${codeText}
65602
65762
  }
65603
65763
  };
65604
65764
  }
65765
+ getTextCommands(editor, range) {
65766
+ return [{
65767
+ id: "add-comment-to-old-doc/text",
65768
+ name: i18n$1.t("comment.quickMenuCommand"),
65769
+ icon: CommentIcon$1
65770
+ }];
65771
+ }
65772
+ executeCommand(editor, command, options) {
65773
+ if (command.id === "add-comment-to-old-doc/text") {
65774
+ const comments = editor.getCustom("editor-comments");
65775
+ if (!comments) {
65776
+ return;
65777
+ }
65778
+ const range = editor.selection.range;
65779
+ if (!range.isSimple()) {
65780
+ return;
65781
+ }
65782
+ comments.showCommentList();
65783
+ editor.readonly = false;
65784
+ addCommentToTextBlocks(editor, range, comments.commentProvider);
65785
+ setTimeout(() => {
65786
+ editor.readonly = true;
65787
+ }, 100);
65788
+ }
65789
+ options.bar.close("clickItem");
65790
+ }
65605
65791
  }
65606
65792
  const index$8 = "";
65607
65793
  function createTextButton(parent, ...args) {
@@ -82900,7 +83086,7 @@ ${data2.flowchartText}
82900
83086
  }
82901
83087
  }
82902
83088
  });
82903
- editor.version = "2.1.0-beta.4";
83089
+ editor.version = "2.1.1-beta.1";
82904
83090
  if (Logger$2.level === LogLevel.DEBUG) {
82905
83091
  window.setReauthFail = (fail) => {
82906
83092
  window.isReauthError = fail;
@@ -82995,7 +83181,7 @@ ${data2.flowchartText}
82995
83181
  if (!clientType.isMobile) {
82996
83182
  OnesEditorToolbar.register(editor);
82997
83183
  }
82998
- editor.version = "2.1.0-beta.4";
83184
+ editor.version = "2.1.1-beta.1";
82999
83185
  return editor;
83000
83186
  }
83001
83187
  async function showDocVersions(editor, options, serverUrl) {
@@ -128806,8 +128992,10 @@ ${data2.flowchartText}
128806
128992
  exports2.RemoteUsers = RemoteUsers;
128807
128993
  exports2.RequestReloadError = RequestReloadError;
128808
128994
  exports2.RichText = RichText;
128995
+ exports2.ShareDBClientBase = ShareDBClientBase;
128809
128996
  exports2.ShareDBDoc = ShareDBDoc;
128810
128997
  exports2.ShareDBDocVersionsProvider = ShareDBDocVersionsProvider;
128998
+ exports2.ShareDBLocalDoc = ShareDBLocalDoc;
128811
128999
  exports2.ShareDBServer = ShareDBServer;
128812
129000
  exports2.SimpleCache = SimpleCache;
128813
129001
  exports2.StandardEmbedBlockCommands = StandardEmbedBlockCommands;