@ones-editor/editor 5.0.6-beta.DNP8216.3 → 5.0.6-beta.p8216.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/@ones-editor/core/src/core/doc/doc.d.ts +2 -72
  2. package/@ones-editor/core/src/core/doc/index.d.ts +1 -0
  3. package/@ones-editor/core/src/core/doc/wiki-macro.d.ts +15 -0
  4. package/@ones-editor/core/src/core/doc/wiki-macro.test.d.ts +1 -0
  5. package/@ones-editor/core/src/core/editor/index.d.ts +0 -1
  6. package/@ones-editor/core/src/core/editor-doc/editor-doc.d.ts +0 -6
  7. package/@ones-editor/core/src/core/types.d.ts +9 -23
  8. package/@ones-editor/core/src/core/undo-manager/actions/async-action.d.ts +4 -7
  9. package/@ones-editor/core/src/core/undo-manager/undo-manager.d.ts +9 -15
  10. package/@ones-editor/core/src/local-doc/index.d.ts +1 -7
  11. package/@ones-editor/server-tools/src/to-markdown/embeds/wiki-macro.d.ts +1 -1
  12. package/@ones-editor/sharedb-doc/src/doc/auth-connection.d.ts +0 -12
  13. package/@ones-editor/sharedb-doc/src/doc/sharedb-client.d.ts +1 -2
  14. package/@ones-editor/sharedb-doc/src/doc/sharedb-doc.d.ts +1 -6
  15. package/@ones-editor/sharedb-doc/src/doc/sharedb-local-doc.d.ts +0 -1
  16. package/@ones-editor/sharedb-doc/src/types.d.ts +0 -4
  17. package/@ones-editor/sharedb-doc/src/versions/sharedb-server.d.ts +0 -2
  18. package/@ones-editor/sharedb-doc/src/versions/simple-client.d.ts +1 -2
  19. package/@ones-editor/tsconfig.tsbuildinfo +1 -1
  20. package/@ones-editor/ui/src/block-menu/index.d.ts +0 -1
  21. package/@ones-editor/versions/src/history-diff.d.ts +0 -1
  22. package/@ones-editor/versions/src/history-doc/history-doc.d.ts +1 -6
  23. package/dist/index.js +679 -1119
  24. package/package.json +1 -1
  25. package/@ones-editor/core/src/core/composition/clipboard/resources/doc-resource-hooks.d.ts +0 -6
  26. package/@ones-editor/core/src/core/editor/wiki-macro-locks.d.ts +0 -9
  27. package/@ones-editor/core/src/core/undo-manager/actions/macro-edit-action.d.ts +0 -4
package/dist/index.js CHANGED
@@ -9342,7 +9342,7 @@ var __publicField = (obj, key, value) => {
9342
9342
  imageExportFailed: "Bild konnte nicht geladen werden"
9343
9343
  }
9344
9344
  };
9345
- const logger$4Y = getLogger("i18n");
9345
+ const logger$4X = getLogger("i18n");
9346
9346
  const langs$3 = {
9347
9347
  "en-US": enUS$y,
9348
9348
  "zh-CN": zhCN$y,
@@ -9364,7 +9364,7 @@ var __publicField = (obj, key, value) => {
9364
9364
  function t$8(key, args) {
9365
9365
  const ret = i18n.get(key, args);
9366
9366
  if (ret === key) {
9367
- logger$4Y.warn(`no locale value for key ${key}`);
9367
+ logger$4X.warn(`no locale value for key ${key}`);
9368
9368
  }
9369
9369
  return ret;
9370
9370
  }
@@ -9982,7 +9982,7 @@ var __publicField = (obj, key, value) => {
9982
9982
  this._callbacks.clear();
9983
9983
  }
9984
9984
  }
9985
- const logger$4X = getLogger("await-locker");
9985
+ const logger$4W = getLogger("await-locker");
9986
9986
  class AwaitLock {
9987
9987
  constructor() {
9988
9988
  __publicField(this, "_acquired", false);
@@ -10024,7 +10024,7 @@ var __publicField = (obj, key, value) => {
10024
10024
  }
10025
10025
  if (this._waitingResolvers.length > 0) {
10026
10026
  const resolve = this._waitingResolvers.shift();
10027
- assert(logger$4X, resolve, "Resolver missing");
10027
+ assert(logger$4W, resolve, "Resolver missing");
10028
10028
  resolve(void 0);
10029
10029
  } else {
10030
10030
  this._acquired = false;
@@ -10107,7 +10107,7 @@ var __publicField = (obj, key, value) => {
10107
10107
  isMobileSafari: false
10108
10108
  };
10109
10109
  clientType.isMobileSafari = clientType.isMobile && clientType.isSafari;
10110
- const logger$4W = getLogger("dom-utils");
10110
+ const logger$4V = getLogger("dom-utils");
10111
10111
  function addClass(dom, ...className) {
10112
10112
  if (dom && dom.nodeType === Node.ELEMENT_NODE) {
10113
10113
  dom.classList.add(...className);
@@ -10164,7 +10164,7 @@ var __publicField = (obj, key, value) => {
10164
10164
  range.setStart(node, offset);
10165
10165
  return range;
10166
10166
  } catch (err) {
10167
- assert(logger$4W, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
10167
+ assert(logger$4V, false, `failed to create range: ${node.childNodes.length}, ${offset}, ${err.message}`);
10168
10168
  }
10169
10169
  }
10170
10170
  function createExpandedRange(startNode, startOffset, endNode, endOffset) {
@@ -10174,17 +10174,17 @@ var __publicField = (obj, key, value) => {
10174
10174
  range.setEnd(endNode, endOffset);
10175
10175
  return range;
10176
10176
  } catch (err) {
10177
- assert(logger$4W, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
10177
+ assert(logger$4V, false, `failed to create expanded range: ${startNode.childNodes.length}, ${startOffset}, ${endNode.childNodes.length}, ${endOffset}, ${err.message}`);
10178
10178
  }
10179
10179
  }
10180
10180
  function getFirstClientRect(elem) {
10181
10181
  const rects = elem.getClientRects();
10182
- assert(logger$4W, rects.length >= 1, "getFirstClientRect: no rects");
10182
+ assert(logger$4V, rects.length >= 1, "getFirstClientRect: no rects");
10183
10183
  return rects[0];
10184
10184
  }
10185
10185
  function getLastClientRect(elem) {
10186
10186
  const rects = elem.getClientRects();
10187
- assert(logger$4W, rects.length >= 1, "getLastClientRect: no rects");
10187
+ assert(logger$4V, rects.length >= 1, "getLastClientRect: no rects");
10188
10188
  return rects[rects.length - 1];
10189
10189
  }
10190
10190
  function getDistanceSquare(rect, x, y) {
@@ -10231,7 +10231,7 @@ var __publicField = (obj, key, value) => {
10231
10231
  return 0;
10232
10232
  }
10233
10233
  if (!elem1.parentElement || !elem2.parentElement) {
10234
- assert(logger$4W, false, "invalid dom node to compare");
10234
+ assert(logger$4V, false, "invalid dom node to compare");
10235
10235
  }
10236
10236
  if (elem1.parentElement === elem2.parentElement) {
10237
10237
  const children = Array.from(elem1.parentElement.children);
@@ -10248,7 +10248,7 @@ var __publicField = (obj, key, value) => {
10248
10248
  const parents1 = getParents(elem1);
10249
10249
  const parents2 = getParents(elem2);
10250
10250
  if (parents1[0] !== parents2[0]) {
10251
- assert(logger$4W, false, "invalid dom node to compare, different tree");
10251
+ assert(logger$4V, false, "invalid dom node to compare, different tree");
10252
10252
  }
10253
10253
  for (let i = 1; ; i++) {
10254
10254
  const parent1 = parents1[i];
@@ -10848,7 +10848,7 @@ var __publicField = (obj, key, value) => {
10848
10848
  }
10849
10849
  }
10850
10850
  const MIN_DISTANCE_THRESHOLD$3 = 3;
10851
- const logger$4V = getLogger("drag-drop");
10851
+ const logger$4U = getLogger("drag-drop");
10852
10852
  class DragDrop {
10853
10853
  constructor(options) {
10854
10854
  __publicField(this, "dragStarted", false);
@@ -10869,7 +10869,7 @@ var __publicField = (obj, key, value) => {
10869
10869
  var _a;
10870
10870
  event.preventDefault();
10871
10871
  event.stopPropagation();
10872
- assert(logger$4V, this.mouseDownEvent, "no mouse down event");
10872
+ assert(logger$4U, this.mouseDownEvent, "no mouse down event");
10873
10873
  const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
10874
10874
  const newPos = DragDrop.getEventPosition(event);
10875
10875
  const deltaX = newPos.x - oldPos.x;
@@ -10885,7 +10885,7 @@ var __publicField = (obj, key, value) => {
10885
10885
  });
10886
10886
  __publicField(this, "handleMouseUp", (event) => {
10887
10887
  if (event instanceof MouseEvent && event.button === 0 || event instanceof TouchEvent) {
10888
- assert(logger$4V, this.mouseDownEvent, "no mouse down event");
10888
+ assert(logger$4U, this.mouseDownEvent, "no mouse down event");
10889
10889
  const oldPos = DragDrop.getEventPosition(this.mouseDownEvent);
10890
10890
  const newPos = DragDrop.getEventPosition(event);
10891
10891
  const deltaX = newPos.x - oldPos.x;
@@ -10994,7 +10994,7 @@ var __publicField = (obj, key, value) => {
10994
10994
  const dragDrop = new DragDrop(options);
10995
10995
  return dragDrop;
10996
10996
  }
10997
- const logger$4U = getLogger("character");
10997
+ const logger$4T = getLogger("character");
10998
10998
  function checkChar(charCode, rangeList) {
10999
10999
  for (let i = 0; i < rangeList.length; i++) {
11000
11000
  const start = rangeList[i][0];
@@ -11045,7 +11045,7 @@ var __publicField = (obj, key, value) => {
11045
11045
  }
11046
11046
  function trimChar(s, char) {
11047
11047
  let c = char;
11048
- assert(logger$4U, c.length === 1, "invalid char length");
11048
+ assert(logger$4T, c.length === 1, "invalid char length");
11049
11049
  if (c === "]")
11050
11050
  c = "\\]";
11051
11051
  if (c === "\\")
@@ -11403,7 +11403,7 @@ var __publicField = (obj, key, value) => {
11403
11403
  return 200;
11404
11404
  }
11405
11405
  }
11406
- const logger$4T = getLogger("editor-clipboard");
11406
+ const logger$4S = getLogger("editor-clipboard");
11407
11407
  async function setClipboardDataByEvent(items, event) {
11408
11408
  if (event.clipboardData) {
11409
11409
  const data2 = event.clipboardData;
@@ -11461,7 +11461,7 @@ var __publicField = (obj, key, value) => {
11461
11461
  document.body.removeChild(textarea2);
11462
11462
  return true;
11463
11463
  } catch (ex) {
11464
- logger$4T.error(ex);
11464
+ logger$4S.error(ex);
11465
11465
  document.body.removeChild(textarea2);
11466
11466
  return false;
11467
11467
  }
@@ -11482,7 +11482,7 @@ var __publicField = (obj, key, value) => {
11482
11482
  document.body.removeChild(div);
11483
11483
  return true;
11484
11484
  } catch (ex) {
11485
- logger$4T.error(ex);
11485
+ logger$4S.error(ex);
11486
11486
  document.body.removeChild(div);
11487
11487
  return false;
11488
11488
  }
@@ -11509,7 +11509,7 @@ var __publicField = (obj, key, value) => {
11509
11509
  await navigator.clipboard.write([clipboardItems]);
11510
11510
  return true;
11511
11511
  } catch (err) {
11512
- logger$4T.error(err);
11512
+ logger$4S.error(err);
11513
11513
  return await execCommandCopy(items);
11514
11514
  }
11515
11515
  }
@@ -11565,7 +11565,7 @@ var __publicField = (obj, key, value) => {
11565
11565
  a.click();
11566
11566
  a.remove();
11567
11567
  }
11568
- const logger$4S = getLogger("auto-scroll");
11568
+ const logger$4R = getLogger("auto-scroll");
11569
11569
  function scrollable(scrollElement, direction) {
11570
11570
  if (scrollElement.scrollHeight === scrollElement.clientHeight) {
11571
11571
  return false;
@@ -11589,7 +11589,7 @@ var __publicField = (obj, key, value) => {
11589
11589
  const isHorizontal = direction === "left" || direction === "right";
11590
11590
  const scroll = () => {
11591
11591
  if (!scrollable(scrollElement, direction)) {
11592
- logger$4S.debug("No need for scroll");
11592
+ logger$4R.debug("No need for scroll");
11593
11593
  return null;
11594
11594
  }
11595
11595
  if (isHorizontal) {
@@ -11646,7 +11646,7 @@ var __publicField = (obj, key, value) => {
11646
11646
  if (this.scrolling) {
11647
11647
  return;
11648
11648
  }
11649
- logger$4S.debug(`scroll direction: ${direction}`);
11649
+ logger$4R.debug(`scroll direction: ${direction}`);
11650
11650
  this.cancelScroll = continuousScroll(scrollElement, {
11651
11651
  direction,
11652
11652
  step
@@ -11984,7 +11984,7 @@ var __publicField = (obj, key, value) => {
11984
11984
  var _a;
11985
11985
  (_a = pendingEditors.get(editor)) == null ? void 0 : _a.renderId(id);
11986
11986
  }
11987
- const logger$4R = getLogger("container");
11987
+ const logger$4Q = getLogger("container");
11988
11988
  function isContainer(elem) {
11989
11989
  return elem.getAttribute("data-type") === "editor-container";
11990
11990
  }
@@ -11996,9 +11996,9 @@ var __publicField = (obj, key, value) => {
11996
11996
  }
11997
11997
  function getContainerId(container) {
11998
11998
  const id = container.getAttribute("data-container-id");
11999
- assert(logger$4R, id, "no id for container");
11999
+ assert(logger$4Q, id, "no id for container");
12000
12000
  if (isRootContainer(container)) {
12001
- assert(logger$4R, id === "root", `invalid root container id, : ${id}`);
12001
+ assert(logger$4Q, id === "root", `invalid root container id, : ${id}`);
12002
12002
  }
12003
12003
  return id;
12004
12004
  }
@@ -12009,7 +12009,7 @@ var __publicField = (obj, key, value) => {
12009
12009
  function generateEditorContainerId(containerId) {
12010
12010
  return `ones-editor-container-${containerId}`;
12011
12011
  }
12012
- const logger$4Q = getLogger("element");
12012
+ const logger$4P = getLogger("element");
12013
12013
  function createContainerElement(parent, type, containerId) {
12014
12014
  const container = createElement("div", [type], parent);
12015
12015
  container.setAttribute("data-type", "editor-container");
@@ -12024,7 +12024,7 @@ var __publicField = (obj, key, value) => {
12024
12024
  renderDeferredId(editor, containerId);
12025
12025
  container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
12026
12026
  }
12027
- assert(logger$4Q, container, `no container: ${containerId}`);
12027
+ assert(logger$4P, container, `no container: ${containerId}`);
12028
12028
  return container;
12029
12029
  }
12030
12030
  function getExistsContainerById(editor, containerId) {
@@ -12033,7 +12033,7 @@ var __publicField = (obj, key, value) => {
12033
12033
  }
12034
12034
  function getContainerBlocksElement(container) {
12035
12035
  const blocks = container.querySelector(":scope > .container-blocks");
12036
- assert(logger$4Q, blocks, "no container blocks element");
12036
+ assert(logger$4P, blocks, "no container blocks element");
12037
12037
  return blocks;
12038
12038
  }
12039
12039
  function getContainerToolsElement(container) {
@@ -12046,11 +12046,11 @@ var __publicField = (obj, key, value) => {
12046
12046
  function isContainerBlocksElement(element) {
12047
12047
  return element.classList.contains("container-blocks");
12048
12048
  }
12049
- const logger$4P = getLogger("container-children");
12049
+ const logger$4O = getLogger("container-children");
12050
12050
  function getChildBlocks(container, traverseChild) {
12051
12051
  const content = getContainerBlocksElement(container);
12052
12052
  const blocks = Array.from(content.children);
12053
- assert(logger$4P, blocks.length > 0, "container have not any child block");
12053
+ assert(logger$4O, blocks.length > 0, "container have not any child block");
12054
12054
  if (traverseChild) {
12055
12055
  const { condition, editor } = traverseChild;
12056
12056
  return blocks.reduce((result, block) => {
@@ -12073,7 +12073,7 @@ var __publicField = (obj, key, value) => {
12073
12073
  }
12074
12074
  function getFirstChildBlock(container) {
12075
12075
  const block = container.querySelector(":scope > .container-blocks > div[data-type=editor-block]");
12076
- assert(logger$4P, block, "container have not any child block");
12076
+ assert(logger$4O, block, "container have not any child block");
12077
12077
  return block;
12078
12078
  }
12079
12079
  function getLastChildBlock(container) {
@@ -12085,14 +12085,14 @@ var __publicField = (obj, key, value) => {
12085
12085
  }
12086
12086
  function getBlockByIndex(container, blockIndex) {
12087
12087
  const block = getChildBlocks(container)[blockIndex];
12088
- assert(logger$4P, block, `container have not block at index ${blockIndex}`);
12088
+ assert(logger$4O, block, `container have not block at index ${blockIndex}`);
12089
12089
  return block;
12090
12090
  }
12091
12091
  function findBlockByIndex(container, blockIndex) {
12092
12092
  var _a;
12093
12093
  return (_a = getChildBlocks(container)[blockIndex]) != null ? _a : null;
12094
12094
  }
12095
- const logger$4O = getLogger("block-dom");
12095
+ const logger$4N = getLogger("block-dom");
12096
12096
  function isBlock$1(node) {
12097
12097
  if (!(node instanceof HTMLDivElement)) {
12098
12098
  return false;
@@ -12113,12 +12113,12 @@ var __publicField = (obj, key, value) => {
12113
12113
  }
12114
12114
  function getBlockId(block) {
12115
12115
  const { id } = block;
12116
- assert(logger$4O, id, "no block id");
12116
+ assert(logger$4N, id, "no block id");
12117
12117
  return id;
12118
12118
  }
12119
12119
  function getBlockType(block) {
12120
12120
  const type = block.getAttribute("data-block-type");
12121
- assert(logger$4O, type, "invalid block dom, no data-type");
12121
+ assert(logger$4N, type, "invalid block dom, no data-type");
12122
12122
  return type;
12123
12123
  }
12124
12124
  function getParentBlock(node) {
@@ -12141,12 +12141,12 @@ var __publicField = (obj, key, value) => {
12141
12141
  }
12142
12142
  function getParentContainer(block) {
12143
12143
  const container = block.closest("div[data-type=editor-container]");
12144
- assert(logger$4O, container, "failed to get block container");
12144
+ assert(logger$4N, container, "failed to get block container");
12145
12145
  return container;
12146
12146
  }
12147
12147
  function getBlockContent(block) {
12148
12148
  const content = block.querySelector(":scope >div[data-type=block-content]");
12149
- assert(logger$4O, content, "no block content");
12149
+ assert(logger$4N, content, "no block content");
12150
12150
  return content;
12151
12151
  }
12152
12152
  function getBlockTools(block) {
@@ -12155,7 +12155,7 @@ var __publicField = (obj, key, value) => {
12155
12155
  tools = createElement("div", [], block);
12156
12156
  tools.setAttribute("data-type", "block-tools");
12157
12157
  }
12158
- assert(logger$4O, tools, "no block tools");
12158
+ assert(logger$4N, tools, "no block tools");
12159
12159
  return tools;
12160
12160
  }
12161
12161
  function getExistsBlockTools(block) {
@@ -12176,7 +12176,7 @@ var __publicField = (obj, key, value) => {
12176
12176
  function createBlockElement(editor, path, data2) {
12177
12177
  const blockData = editor.editorDecorators.decorateBlock(path, data2);
12178
12178
  const { id, type } = blockData;
12179
- assert(logger$4O, id, "no block id");
12179
+ assert(logger$4N, id, "no block id");
12180
12180
  const elem = createElement("div", [`${type}-block`], null);
12181
12181
  elem.id = id;
12182
12182
  elem.setAttribute("data-type", "editor-block");
@@ -12214,7 +12214,7 @@ var __publicField = (obj, key, value) => {
12214
12214
  }
12215
12215
  function getBoxTypeFromElement(box) {
12216
12216
  const type = box.getAttribute("data-box-type");
12217
- assert(logger$4O, type, "not a valid box element, no type");
12217
+ assert(logger$4N, type, "not a valid box element, no type");
12218
12218
  return type;
12219
12219
  }
12220
12220
  function isBox(node) {
@@ -12225,7 +12225,7 @@ var __publicField = (obj, key, value) => {
12225
12225
  }
12226
12226
  function getBoxId(box) {
12227
12227
  const { id } = box;
12228
- assert(logger$4O, id, "no box id");
12228
+ assert(logger$4N, id, "no box id");
12229
12229
  return id;
12230
12230
  }
12231
12231
  function getParentBox(node) {
@@ -12247,7 +12247,7 @@ var __publicField = (obj, key, value) => {
12247
12247
  }
12248
12248
  function getBoxContent(box) {
12249
12249
  const content = box.querySelector("span[data-type=box-content]");
12250
- assert(logger$4O, content, "invalid box dom, no content");
12250
+ assert(logger$4N, content, "invalid box dom, no content");
12251
12251
  return content;
12252
12252
  }
12253
12253
  function createInsertionElement(type, id, attributes) {
@@ -12269,7 +12269,7 @@ var __publicField = (obj, key, value) => {
12269
12269
  }
12270
12270
  function getInsertionContent(insertion) {
12271
12271
  const content = insertion.querySelector("span[data-type=insertion-content]");
12272
- assert(logger$4O, content, "invalid insertion-child dom, no content");
12272
+ assert(logger$4N, content, "invalid insertion-child dom, no content");
12273
12273
  return content;
12274
12274
  }
12275
12275
  function getPrevBlock(block) {
@@ -12329,7 +12329,7 @@ var __publicField = (obj, key, value) => {
12329
12329
  const container = getParentContainer(block);
12330
12330
  const children = getChildBlocks(container);
12331
12331
  const index2 = children.indexOf(block);
12332
- assert(logger$4O, index2 !== -1, "invalid block & container dom, failed to get block index");
12332
+ assert(logger$4N, index2 !== -1, "invalid block & container dom, failed to get block index");
12333
12333
  return index2;
12334
12334
  }
12335
12335
  function isInBlock(target) {
@@ -12354,18 +12354,18 @@ var __publicField = (obj, key, value) => {
12354
12354
  function isTitleBlock$2(block) {
12355
12355
  return block.hasAttribute("data-document-title");
12356
12356
  }
12357
- const logger$4N = getLogger("block-class");
12357
+ const logger$4M = getLogger("block-class");
12358
12358
  function getBlockClass(editor, block) {
12359
12359
  return editor.editorBlocks.getBlockClass(getBlockType(block));
12360
12360
  }
12361
12361
  function getTextBlockClass(editor, block) {
12362
12362
  const text2 = editor.editorBlocks.getBlockClass(getBlockType(block));
12363
- assert(logger$4N, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
12363
+ assert(logger$4M, text2.blockKind === "text", `is not a text block, ${text2.blockType}`);
12364
12364
  return text2;
12365
12365
  }
12366
12366
  function getComplexBlockClass(editor, block) {
12367
12367
  const complex = editor.editorBlocks.getBlockClass(getBlockType(block));
12368
- assert(logger$4N, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
12368
+ assert(logger$4M, complex.blockKind === "complex", `is not a text block, ${complex.blockType}`);
12369
12369
  return complex;
12370
12370
  }
12371
12371
  function getBlockClassByType(editor, type) {
@@ -12386,7 +12386,7 @@ var __publicField = (obj, key, value) => {
12386
12386
  function getBlockKind(editor, block) {
12387
12387
  return getBlockClass(editor, block).blockKind;
12388
12388
  }
12389
- const logger$4M = getLogger("text-block-child");
12389
+ const logger$4L = getLogger("text-block-child");
12390
12390
  function isTextBlockContentChild(elem) {
12391
12391
  if (elem.tagName !== "SPAN") {
12392
12392
  return false;
@@ -12394,14 +12394,14 @@ var __publicField = (obj, key, value) => {
12394
12394
  return true;
12395
12395
  }
12396
12396
  function isTextBlockContentBoxChild(elem) {
12397
- assert(logger$4M, isTextBlockContentChild(elem), "not a valid text child");
12397
+ assert(logger$4L, isTextBlockContentChild(elem), "not a valid text child");
12398
12398
  if (elem.getAttribute("data-type") === "editor-box") {
12399
12399
  return true;
12400
12400
  }
12401
12401
  return false;
12402
12402
  }
12403
12403
  function isTextBlockContentInsertionChild(elem) {
12404
- assert(logger$4M, isTextBlockContentChild(elem), "not a valid text child");
12404
+ assert(logger$4L, isTextBlockContentChild(elem), "not a valid text child");
12405
12405
  if (elem.getAttribute("data-type") === "editor-insertion") {
12406
12406
  return true;
12407
12407
  }
@@ -12411,7 +12411,7 @@ var __publicField = (obj, key, value) => {
12411
12411
  return !isTextBlockContentBoxChild(elem) && !isTextBlockContentInsertionChild(elem);
12412
12412
  }
12413
12413
  function getTextBlockContentChildType(child) {
12414
- assert(logger$4M, isTextBlockContentChild(child), "not a valid text child");
12414
+ assert(logger$4L, isTextBlockContentChild(child), "not a valid text child");
12415
12415
  if (isTextBlockContentBoxChild(child)) {
12416
12416
  return "box";
12417
12417
  }
@@ -12426,15 +12426,15 @@ var __publicField = (obj, key, value) => {
12426
12426
  return 0;
12427
12427
  if (type === "box")
12428
12428
  return 1;
12429
- assert(logger$4M, child.textContent !== null, "text block content is undefined");
12430
- assert(logger$4M, child.textContent.length >= 0, "text block content length is negative");
12429
+ assert(logger$4L, child.textContent !== null, "text block content is undefined");
12430
+ assert(logger$4L, child.textContent.length >= 0, "text block content length is negative");
12431
12431
  return child.textContent.length;
12432
12432
  }
12433
12433
  function getTextBlockContentChildren(block) {
12434
12434
  const content = getBlockContent(block);
12435
12435
  const children = Array.from(content.children);
12436
12436
  children.forEach((child) => {
12437
- assert(logger$4M, isTextBlockContentChild(child), "not a valid text child");
12437
+ assert(logger$4L, isTextBlockContentChild(child), "not a valid text child");
12438
12438
  });
12439
12439
  return children;
12440
12440
  }
@@ -12463,17 +12463,17 @@ var __publicField = (obj, key, value) => {
12463
12463
  };
12464
12464
  }
12465
12465
  const offset = blockOffset - start;
12466
- assert(logger$4M, offset > 0, "invalid offset value");
12467
- assert(logger$4M, !isTextBlockContentBoxChild(child), "invalid box child");
12466
+ assert(logger$4L, offset > 0, "invalid offset value");
12467
+ assert(logger$4L, !isTextBlockContentBoxChild(child), "invalid box child");
12468
12468
  return {
12469
12469
  prev: child,
12470
12470
  next: child,
12471
12471
  offset
12472
12472
  };
12473
12473
  }
12474
- assert(logger$4M, false, `invalid block child at position: ${blockOffset}`);
12474
+ assert(logger$4L, false, `invalid block child at position: ${blockOffset}`);
12475
12475
  }
12476
- const logger$4L = getLogger("block-path");
12476
+ const logger$4K = getLogger("block-path");
12477
12477
  function getBlockPath(block) {
12478
12478
  const ret = [];
12479
12479
  let current = block;
@@ -12487,26 +12487,26 @@ var __publicField = (obj, key, value) => {
12487
12487
  return ret;
12488
12488
  }
12489
12489
  const parentBlock = getParentBlock(container);
12490
- assert(logger$4L, parentBlock, "no parent block");
12490
+ assert(logger$4K, parentBlock, "no parent block");
12491
12491
  current = parentBlock;
12492
12492
  }
12493
- assert(logger$4L, false, "no parent block");
12493
+ assert(logger$4K, false, "no parent block");
12494
12494
  return [];
12495
12495
  }
12496
- const logger$4K = getLogger("child-container-path");
12496
+ const logger$4J = getLogger("child-container-path");
12497
12497
  function getContainerBlockPath(container) {
12498
12498
  if (isRootContainer(container)) {
12499
12499
  return [];
12500
12500
  }
12501
12501
  const parentBlock = getParentBlock(container);
12502
- assert(logger$4K, parentBlock, "no parent block");
12502
+ assert(logger$4J, parentBlock, "no parent block");
12503
12503
  return getBlockPath(parentBlock);
12504
12504
  }
12505
- const logger$4J = getLogger("load-blocks");
12505
+ const logger$4I = getLogger("load-blocks");
12506
12506
  function loadBlocks(editor, container, path) {
12507
12507
  const containerId = getContainerId(container);
12508
12508
  const blocks = getContainerBlocks$1(container, editor.doc);
12509
- assert(logger$4J, blocks.length > 0, "no blocks in container");
12509
+ assert(logger$4I, blocks.length > 0, "no blocks in container");
12510
12510
  const fragment = document.createDocumentFragment();
12511
12511
  blocks.forEach((b, index2) => {
12512
12512
  const block = editor.editorBlocks.createBlock([...path, { containerId, blockIndex: index2 }], container, b);
@@ -12522,7 +12522,7 @@ var __publicField = (obj, key, value) => {
12522
12522
  return block;
12523
12523
  }
12524
12524
  const blocks = getChildBlocks(container);
12525
- assert(logger$4J, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
12525
+ assert(logger$4I, blockIndex >= 0 && blockIndex <= blocks.length, "invalid block index");
12526
12526
  if (blockIndex === blocks.length) {
12527
12527
  containerBlocksElement.appendChild(block);
12528
12528
  } else {
@@ -12540,7 +12540,7 @@ var __publicField = (obj, key, value) => {
12540
12540
  insertBlockAt(container, blockIndex, block);
12541
12541
  return block;
12542
12542
  }
12543
- const logger$4I = getLogger("root-container");
12543
+ const logger$4H = getLogger("root-container");
12544
12544
  const MIN_DISTANCE_THRESHOLD$2 = 3;
12545
12545
  class RootContainer {
12546
12546
  constructor(editor, rootContainer) {
@@ -12568,7 +12568,7 @@ var __publicField = (obj, key, value) => {
12568
12568
  this.editor.selection.updateSelection(null);
12569
12569
  this.editor.emit("resize", this.editor);
12570
12570
  } catch (err) {
12571
- logger$4I.warn(`failed to update selection while container resizing: ${err.message}`);
12571
+ logger$4H.warn(`failed to update selection while container resizing: ${err.message}`);
12572
12572
  }
12573
12573
  });
12574
12574
  __publicField(this, "handleClick", (event) => {
@@ -12602,7 +12602,7 @@ var __publicField = (obj, key, value) => {
12602
12602
  const box = getParentBox(elem);
12603
12603
  if (box && isChildNode(box, eTarget)) {
12604
12604
  const block2 = getParentBlock(box);
12605
- assert(logger$4I, block2, "no parent block");
12605
+ assert(logger$4H, block2, "no parent block");
12606
12606
  (_b = (_a = this.editor.editorBoxes.getBoxClass(getBoxTypeFromElement(box))) == null ? void 0 : _a.handleClickBox) == null ? void 0 : _b.call(_a, this.editor, box, event);
12607
12607
  return;
12608
12608
  }
@@ -12658,7 +12658,7 @@ var __publicField = (obj, key, value) => {
12658
12658
  this.editor.input.focus({ preventScroll: true });
12659
12659
  });
12660
12660
  __publicField(this, "handleMouseMove", (event) => {
12661
- assert(logger$4I, this.mouseDownEvent, "no mouse down event");
12661
+ assert(logger$4H, this.mouseDownEvent, "no mouse down event");
12662
12662
  if (ensureIsMobileEvent(this.mouseDownEvent))
12663
12663
  return;
12664
12664
  const deltaX = event.x - this.mouseDownEvent.x;
@@ -12774,7 +12774,7 @@ var __publicField = (obj, key, value) => {
12774
12774
  loadBlocks(editor, container, path);
12775
12775
  return container;
12776
12776
  }
12777
- const logger$4H = getLogger("block");
12777
+ const logger$4G = getLogger("block");
12778
12778
  function getBlockTextLength$6(editor, block) {
12779
12779
  return getBlockClass(editor, block).getBlockTextLength(block);
12780
12780
  }
@@ -12793,7 +12793,7 @@ var __publicField = (obj, key, value) => {
12793
12793
  return block;
12794
12794
  }
12795
12795
  const parent = getParentBlock(container);
12796
- assert(logger$4H, parent, "no parent block exists for child container");
12796
+ assert(logger$4G, parent, "no parent block exists for child container");
12797
12797
  block = parent;
12798
12798
  }
12799
12799
  }
@@ -12829,7 +12829,7 @@ var __publicField = (obj, key, value) => {
12829
12829
  }
12830
12830
  return fun(editor, block, options);
12831
12831
  } catch (err) {
12832
- logger$4H.debug(`unsupported block type: ${type}`);
12832
+ logger$4G.debug(`unsupported block type: ${type}`);
12833
12833
  return null;
12834
12834
  }
12835
12835
  }
@@ -12849,7 +12849,7 @@ var __publicField = (obj, key, value) => {
12849
12849
  const styles2 = Object.fromEntries(Object.entries(data2).filter(([key]) => key.startsWith("style-")));
12850
12850
  Object.entries(styles2).forEach(([, value]) => {
12851
12851
  const type = typeof value;
12852
- assert(logger$4H, type === "string" || type === "number" || type === "boolean", "invalid style value");
12852
+ assert(logger$4G, type === "string" || type === "number" || type === "boolean", "invalid style value");
12853
12853
  });
12854
12854
  return styles2;
12855
12855
  }
@@ -12974,7 +12974,7 @@ var __publicField = (obj, key, value) => {
12974
12974
  }
12975
12975
  return { element: null, blockCommands: [], boxCommands: [] };
12976
12976
  }
12977
- const logger$4G = getLogger("embed-block-common");
12977
+ const logger$4F = getLogger("embed-block-common");
12978
12978
  function isColumnsBlock(block) {
12979
12979
  return getBlockType(block) === "layout";
12980
12980
  }
@@ -12982,9 +12982,9 @@ var __publicField = (obj, key, value) => {
12982
12982
  return getBlockType(block) === "embed";
12983
12983
  }
12984
12984
  function getEmbedType(block) {
12985
- assert(logger$4G, isEmbedBlock(block), "not an embed block");
12985
+ assert(logger$4F, isEmbedBlock(block), "not an embed block");
12986
12986
  const type = block.getAttribute("data-embed-type");
12987
- assert(logger$4G, type, "no embed data type");
12987
+ assert(logger$4F, type, "no embed data type");
12988
12988
  return type;
12989
12989
  }
12990
12990
  function getEmbedClassFromBlock(editor, block) {
@@ -13050,10 +13050,10 @@ var __publicField = (obj, key, value) => {
13050
13050
  data: (_c = overrideOptions == null ? void 0 : overrideOptions.data) != null ? _c : data2
13051
13051
  });
13052
13052
  }
13053
- const logger$4F = getLogger("execute-block-command");
13053
+ const logger$4E = getLogger("execute-block-command");
13054
13054
  function executeEmbedBlockCommand(editor, block, commandGroup, item) {
13055
13055
  var _a;
13056
- assert(logger$4F, isEmbedBlock(block), "not a embed block");
13056
+ assert(logger$4E, isEmbedBlock(block), "not a embed block");
13057
13057
  const embedType = getEmbedType(block);
13058
13058
  const embed = getEmbedClassByType(editor, embedType);
13059
13059
  if (!embed.getOptions) {
@@ -13086,14 +13086,14 @@ var __publicField = (obj, key, value) => {
13086
13086
  }
13087
13087
  return void 0;
13088
13088
  }
13089
- const logger$4E = getLogger("block-class");
13089
+ const logger$4D = getLogger("block-class");
13090
13090
  function isHeadingBlock$1(block) {
13091
13091
  return !!block.getAttribute("data-style-heading");
13092
13092
  }
13093
13093
  function getBlockHeading(block) {
13094
13094
  var _a;
13095
13095
  const heading = Number.parseInt((_a = block.getAttribute("data-style-heading")) != null ? _a : "", 10);
13096
- assert(logger$4E, heading, "not a heading block");
13096
+ assert(logger$4D, heading, "not a heading block");
13097
13097
  return heading;
13098
13098
  }
13099
13099
  function isExpandedHeadingBlock(block) {
@@ -13104,7 +13104,7 @@ var __publicField = (obj, key, value) => {
13104
13104
  }
13105
13105
  function getHeadingBlockChildren(block, oldHeading) {
13106
13106
  if (!oldHeading) {
13107
- assert(logger$4E, isHeadingBlock$1(block), "not a heading block");
13107
+ assert(logger$4D, isHeadingBlock$1(block), "not a heading block");
13108
13108
  }
13109
13109
  const children = [];
13110
13110
  const heading = oldHeading != null ? oldHeading : getBlockHeading(block);
@@ -13134,7 +13134,7 @@ var __publicField = (obj, key, value) => {
13134
13134
  }
13135
13135
  return children;
13136
13136
  }
13137
- const logger$4D = getLogger("complex-block-position");
13137
+ const logger$4C = getLogger("complex-block-position");
13138
13138
  class EditorComplexBlockPosition {
13139
13139
  constructor(block, childContainerId, custom) {
13140
13140
  __publicField(this, "blockId");
@@ -13143,7 +13143,7 @@ var __publicField = (obj, key, value) => {
13143
13143
  if (block instanceof HTMLElement) {
13144
13144
  this.blockId = getBlockId(block);
13145
13145
  } else {
13146
- assert(logger$4D, typeof block === "string", `not a valid block id: ${block}`);
13146
+ assert(logger$4C, typeof block === "string", `not a valid block id: ${block}`);
13147
13147
  this.blockId = block;
13148
13148
  }
13149
13149
  this.childContainerId = childContainerId;
@@ -13155,7 +13155,7 @@ var __publicField = (obj, key, value) => {
13155
13155
  return false;
13156
13156
  }
13157
13157
  }
13158
- const logger$4C = getLogger("simple-block-position");
13158
+ const logger$4B = getLogger("simple-block-position");
13159
13159
  class EditorSimpleBlockPosition {
13160
13160
  constructor(block, offset, type) {
13161
13161
  __publicField(this, "blockId");
@@ -13164,7 +13164,7 @@ var __publicField = (obj, key, value) => {
13164
13164
  if (block instanceof HTMLElement) {
13165
13165
  this.blockId = getBlockId(block);
13166
13166
  } else {
13167
- assert(logger$4C, typeof block === "string", `not a valid block id: ${block}`);
13167
+ assert(logger$4B, typeof block === "string", `not a valid block id: ${block}`);
13168
13168
  this.blockId = block;
13169
13169
  }
13170
13170
  this.offset = offset;
@@ -13174,7 +13174,7 @@ var __publicField = (obj, key, value) => {
13174
13174
  return true;
13175
13175
  }
13176
13176
  }
13177
- const logger$4B = getLogger("editor-position");
13177
+ const logger$4A = getLogger("editor-position");
13178
13178
  function createSimpleBlockPosition(block, offset, type) {
13179
13179
  return new EditorSimpleBlockPosition(block, offset, type);
13180
13180
  }
@@ -13196,7 +13196,7 @@ var __publicField = (obj, key, value) => {
13196
13196
  }
13197
13197
  const block1 = editor.getBlockById(pos1.blockId);
13198
13198
  const block2 = editor.getBlockById(pos2.blockId);
13199
- assert(logger$4B, block1 !== block2, "comparePosition: blocks are the same");
13199
+ assert(logger$4A, block1 !== block2, "comparePosition: blocks are the same");
13200
13200
  return compareElement(block1, block2);
13201
13201
  }
13202
13202
  if (isComplexBlockPosition(pos1) && isComplexBlockPosition(pos2)) {
@@ -13207,13 +13207,13 @@ var __publicField = (obj, key, value) => {
13207
13207
  }
13208
13208
  const container1 = editor.getContainerById(p1.childContainerId);
13209
13209
  const container2 = editor.getContainerById(p2.childContainerId);
13210
- assert(logger$4B, container1 !== container2, "comparePosition: containers are the same");
13210
+ assert(logger$4A, container1 !== container2, "comparePosition: containers are the same");
13211
13211
  return compareElement(container1, container2);
13212
13212
  }
13213
- assert(logger$4B, false, "invalid ");
13213
+ assert(logger$4A, false, "invalid ");
13214
13214
  return 0;
13215
13215
  }
13216
- const logger$4A = getLogger("simple-range");
13216
+ const logger$4z = getLogger("simple-range");
13217
13217
  class EditorSimpleSelectionRange {
13218
13218
  constructor(editor, options) {
13219
13219
  __publicField(this, "editor");
@@ -13262,11 +13262,11 @@ var __publicField = (obj, key, value) => {
13262
13262
  const { editor } = this;
13263
13263
  const startBlock = editor.getBlockById(this.start.blockId);
13264
13264
  const endBlock = editor.getBlockById(this.end.blockId);
13265
- assert(logger$4A, startBlock, "no start block");
13266
- assert(logger$4A, endBlock, "no end block");
13265
+ assert(logger$4z, startBlock, "no start block");
13266
+ assert(logger$4z, endBlock, "no end block");
13267
13267
  const startContainer = getParentContainer(startBlock);
13268
13268
  const endContainer = getParentContainer(endBlock);
13269
- assert(logger$4A, startContainer === endContainer, "invalid range");
13269
+ assert(logger$4z, startContainer === endContainer, "invalid range");
13270
13270
  const ret = [];
13271
13271
  if (startBlock === endBlock) {
13272
13272
  ret.push({
@@ -13277,7 +13277,7 @@ var __publicField = (obj, key, value) => {
13277
13277
  } else {
13278
13278
  const startIndex = getBlockIndex(startBlock);
13279
13279
  const endIndex = getBlockIndex(endBlock);
13280
- assert(logger$4A, startIndex < endIndex, "invalid range, start > index");
13280
+ assert(logger$4z, startIndex < endIndex, "invalid range, start > index");
13281
13281
  ret.push({
13282
13282
  block: startBlock,
13283
13283
  start: this.start,
@@ -13377,7 +13377,7 @@ var __publicField = (obj, key, value) => {
13377
13377
  clearSelection: clearSelection$6,
13378
13378
  convertTo: convertTo$m
13379
13379
  };
13380
- const logger$4z = getLogger("editor-blocks");
13380
+ const logger$4y = getLogger("editor-blocks");
13381
13381
  class EditorBlocks {
13382
13382
  constructor(editor) {
13383
13383
  __publicField(this, "blocks", /* @__PURE__ */ new Map());
@@ -13386,12 +13386,12 @@ var __publicField = (obj, key, value) => {
13386
13386
  registerBlockClass(blockClass) {
13387
13387
  const type = blockClass.blockType;
13388
13388
  const exists = this.blocks.get(type);
13389
- assert(logger$4z, !exists, `duplicated block type: ${type}`);
13389
+ assert(logger$4y, !exists, `duplicated block type: ${type}`);
13390
13390
  this.blocks.set(type, blockClass);
13391
13391
  }
13392
13392
  getBlockClass(type) {
13393
13393
  const exists = this.blocks.get(type);
13394
- assert(logger$4z, exists, `unknown block type: ${type}`);
13394
+ assert(logger$4y, exists, `unknown block type: ${type}`);
13395
13395
  return exists;
13396
13396
  }
13397
13397
  hasBlock(type) {
@@ -13407,7 +13407,7 @@ var __publicField = (obj, key, value) => {
13407
13407
  }
13408
13408
  const content = blockClass.createBlockContent(this.editor, path, container, blockElement, block);
13409
13409
  if (content.parentElement !== blockElement) {
13410
- logger$4z.warn("content parent is not block");
13410
+ logger$4y.warn("content parent is not block");
13411
13411
  blockElement.appendChild(content);
13412
13412
  }
13413
13413
  this.editor.blockHooks.forEach((hook) => {
@@ -13428,7 +13428,7 @@ var __publicField = (obj, key, value) => {
13428
13428
  return newBlock;
13429
13429
  }
13430
13430
  }
13431
- const logger$4y = getLogger("editor-embeds");
13431
+ const logger$4x = getLogger("editor-embeds");
13432
13432
  class EditorEmbeds {
13433
13433
  constructor(editor) {
13434
13434
  __publicField(this, "objects", /* @__PURE__ */ new Map());
@@ -13437,12 +13437,12 @@ var __publicField = (obj, key, value) => {
13437
13437
  registerEmbedClass(embedClass) {
13438
13438
  const type = embedClass.embedType;
13439
13439
  const exists = this.objects.get(type);
13440
- assert(logger$4y, !exists, `duplicated embed object type: ${type}`);
13440
+ assert(logger$4x, !exists, `duplicated embed object type: ${type}`);
13441
13441
  this.objects.set(type, embedClass);
13442
13442
  }
13443
13443
  getEmbedClass(type) {
13444
13444
  const exists = this.objects.get(type);
13445
- assert(logger$4y, exists, `unknown embed type: ${type}`);
13445
+ assert(logger$4x, exists, `unknown embed type: ${type}`);
13446
13446
  return exists;
13447
13447
  }
13448
13448
  getEmbedClassFromBlock(block) {
@@ -13452,12 +13452,12 @@ var __publicField = (obj, key, value) => {
13452
13452
  this.objects.forEach(callback);
13453
13453
  }
13454
13454
  }
13455
- const logger$4x = getLogger("embed-block");
13455
+ const logger$4w = getLogger("embed-block");
13456
13456
  function createBlockContent$6(editor, path, container, blockElement, blockData) {
13457
13457
  const content = createBlockContentElement(blockElement, "div");
13458
- assert(logger$4x, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
13458
+ assert(logger$4w, blockData.type === "embed", `not an embed data: ${JSON.stringify(blockData)}`);
13459
13459
  const embedBlockData = blockData;
13460
- assert(logger$4x, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
13460
+ assert(logger$4w, embedBlockData.embedType && embedBlockData.embedData, `not an embed data: ${JSON.stringify(embedBlockData)}`);
13461
13461
  const embedClass = editor.editorEmbeds.getEmbedClass(embedBlockData.embedType);
13462
13462
  embedClass.createEmbedContent(editor, content, embedBlockData, path, container, blockElement);
13463
13463
  blockElement.setAttribute("data-embed-type", embedBlockData.embedType);
@@ -13485,7 +13485,7 @@ var __publicField = (obj, key, value) => {
13485
13485
  function getCaretRect$4(block, pos) {
13486
13486
  const content = getBlockContent(block);
13487
13487
  const rect = content.getBoundingClientRect();
13488
- assert(logger$4x, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
13488
+ assert(logger$4w, pos.offset === 0 || pos.offset === 1, `invalid offset: ${pos.offset}`);
13489
13489
  if (pos.offset === 1) {
13490
13490
  return new DOMRect(rect.right, rect.top, 0, rect.height);
13491
13491
  }
@@ -13625,18 +13625,18 @@ var __publicField = (obj, key, value) => {
13625
13625
  toStandardDoc: toStandardDoc$2,
13626
13626
  getResources: getResources$2
13627
13627
  };
13628
- const logger$4w = getLogger("complex-block-helper");
13628
+ const logger$4v = getLogger("complex-block-helper");
13629
13629
  function complexBlockGetAllChildContainers(editor, block, options) {
13630
13630
  const blockClass = getComplexBlockClass(editor, block);
13631
13631
  return blockClass.getChildContainers(editor, block, options);
13632
13632
  }
13633
13633
  function complexBlockGetSelectedContainers(editor, block, start, end) {
13634
13634
  if (start.isSimple()) {
13635
- assert(logger$4w, end.isSimple(), "invalid start and end position");
13635
+ assert(logger$4v, end.isSimple(), "invalid start and end position");
13636
13636
  return complexBlockGetAllChildContainers(editor, block);
13637
13637
  }
13638
- assert(logger$4w, !start.isSimple(), "invalid start pos");
13639
- assert(logger$4w, !end.isSimple(), "invalid end pos");
13638
+ assert(logger$4v, !start.isSimple(), "invalid start pos");
13639
+ assert(logger$4v, !end.isSimple(), "invalid end pos");
13640
13640
  const blockClass = getComplexBlockClass(editor, block);
13641
13641
  return blockClass.getSelectedContainers(editor, block, start, end);
13642
13642
  }
@@ -13647,11 +13647,11 @@ var __publicField = (obj, key, value) => {
13647
13647
  const parentComplexBlock = getParentBlock(getParentContainer(childBlock));
13648
13648
  if (!parentComplexBlock)
13649
13649
  return false;
13650
- assert(logger$4w, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13650
+ assert(logger$4v, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13651
13651
  const childContainer = getParentContainer(childBlock);
13652
13652
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock);
13653
13653
  const index2 = childContainers.indexOf(childContainer);
13654
- assert(logger$4w, index2 >= 0, "not valid child container");
13654
+ assert(logger$4v, index2 >= 0, "not valid child container");
13655
13655
  return index2 === 0;
13656
13656
  }
13657
13657
  function complexBlockGetFirstSimpleChild(editor, complexBlock, options) {
@@ -13704,13 +13704,13 @@ var __publicField = (obj, key, value) => {
13704
13704
  return block;
13705
13705
  }
13706
13706
  function findPrevSimpleBlockBeforeChildContainer(editor, childContainer, options) {
13707
- assert(logger$4w, isChildContainer(childContainer), "not a child container");
13707
+ assert(logger$4v, isChildContainer(childContainer), "not a child container");
13708
13708
  const parentComplexBlock = getParentBlock(childContainer);
13709
- assert(logger$4w, parentComplexBlock, "no parent block");
13710
- assert(logger$4w, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13709
+ assert(logger$4v, parentComplexBlock, "no parent block");
13710
+ assert(logger$4v, isComplexKindBlock(editor, parentComplexBlock), "not a complex block");
13711
13711
  const childContainers = complexBlockGetAllChildContainers(editor, parentComplexBlock, options);
13712
13712
  const containerIndex = childContainers.indexOf(childContainer);
13713
- assert(logger$4w, containerIndex !== -1, "child container not found");
13713
+ assert(logger$4v, containerIndex !== -1, "child container not found");
13714
13714
  if (containerIndex === 0) {
13715
13715
  const prevBlock = getPrevBlock(parentComplexBlock);
13716
13716
  if (!prevBlock)
@@ -13728,9 +13728,9 @@ var __publicField = (obj, key, value) => {
13728
13728
  return lastBlock2;
13729
13729
  }
13730
13730
  function complexBlockGetTopChildContainers(editor, complexBlock) {
13731
- assert(logger$4w, isComplexKindBlock(editor, complexBlock), "not a complex block");
13731
+ assert(logger$4v, isComplexKindBlock(editor, complexBlock), "not a complex block");
13732
13732
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
13733
- assert(logger$4w, childContainers.length > 0, "no child container");
13733
+ assert(logger$4v, childContainers.length > 0, "no child container");
13734
13734
  if (childContainers.length === 1) {
13735
13735
  return childContainers;
13736
13736
  }
@@ -13755,9 +13755,9 @@ var __publicField = (obj, key, value) => {
13755
13755
  return ret;
13756
13756
  }
13757
13757
  function complexBlockGetBottomChildContainers(editor, complexBlock) {
13758
- assert(logger$4w, isComplexKindBlock(editor, complexBlock), "not a complex block");
13758
+ assert(logger$4v, isComplexKindBlock(editor, complexBlock), "not a complex block");
13759
13759
  const childContainers = complexBlockGetAllChildContainers(editor, complexBlock);
13760
- assert(logger$4w, childContainers.length > 0, "no child container");
13760
+ assert(logger$4v, childContainers.length > 0, "no child container");
13761
13761
  if (childContainers.length === 1) {
13762
13762
  return childContainers;
13763
13763
  }
@@ -13862,11 +13862,11 @@ var __publicField = (obj, key, value) => {
13862
13862
  return result;
13863
13863
  }
13864
13864
  const anchor = "";
13865
- const logger$4v = getLogger("text-range");
13865
+ const logger$4u = getLogger("text-range");
13866
13866
  function getBlockRangeInfo(block, blockOffset) {
13867
13867
  const getChildRange = (child, offset) => {
13868
13868
  if (isTextBlockContentInsertionChild(child)) {
13869
- assert(logger$4v, offset === 0, `invalid offset for insertion child: ${offset}`);
13869
+ assert(logger$4u, offset === 0, `invalid offset for insertion child: ${offset}`);
13870
13870
  const childOffset = 2;
13871
13871
  return {
13872
13872
  child,
@@ -13875,7 +13875,7 @@ var __publicField = (obj, key, value) => {
13875
13875
  };
13876
13876
  }
13877
13877
  if (isTextBlockContentBoxChild(child)) {
13878
- assert(logger$4v, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
13878
+ assert(logger$4u, offset === 0 || offset === 1, `invalid offset for box: ${offset}`);
13879
13879
  const childOffset = offset === 0 ? 1 : 2;
13880
13880
  return {
13881
13881
  child,
@@ -13884,17 +13884,17 @@ var __publicField = (obj, key, value) => {
13884
13884
  };
13885
13885
  }
13886
13886
  const textNode = child.firstChild;
13887
- assert(logger$4v, textNode, "no child node for text child");
13888
- assert(logger$4v, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
13887
+ assert(logger$4u, textNode, "no child node for text child");
13888
+ assert(logger$4u, textNode instanceof Text || textNode instanceof HTMLBRElement, `invalid child for text child, ${textNode.nodeName}`);
13889
13889
  if (textNode instanceof HTMLBRElement) {
13890
- assert(logger$4v, offset >= 0 && offset <= 0, "invalid offset for text child");
13890
+ assert(logger$4u, offset >= 0 && offset <= 0, "invalid offset for text child");
13891
13891
  return {
13892
13892
  child,
13893
13893
  container: textNode,
13894
13894
  offset
13895
13895
  };
13896
13896
  }
13897
- assert(logger$4v, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
13897
+ assert(logger$4u, offset >= 0 && offset <= textNode.data.length, "invalid offset for text child");
13898
13898
  return {
13899
13899
  child,
13900
13900
  container: textNode,
@@ -13923,38 +13923,38 @@ var __publicField = (obj, key, value) => {
13923
13923
  }
13924
13924
  start += childLength;
13925
13925
  }
13926
- assert(logger$4v, false, "failed to get range info");
13926
+ assert(logger$4u, false, "failed to get range info");
13927
13927
  }
13928
13928
  function createChildRange(child, start, end) {
13929
13929
  if (start === end) {
13930
- assert(logger$4v, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
13930
+ assert(logger$4u, isTextBlockContentInsertionChild(child), "only insertion child can be zero offset");
13931
13931
  } else {
13932
- assert(logger$4v, start < end, `invalid start & end: ${start}, ${end}`);
13932
+ assert(logger$4u, start < end, `invalid start & end: ${start}, ${end}`);
13933
13933
  }
13934
13934
  if (isTextBlockContentInsertionChild(child)) {
13935
- assert(logger$4v, start === end, `invalid insertion child range offset: ${start}, ${end}`);
13936
- assert(logger$4v, start === 0, `invalid insertion child range start: ${start}`);
13935
+ assert(logger$4u, start === end, `invalid insertion child range offset: ${start}, ${end}`);
13936
+ assert(logger$4u, start === 0, `invalid insertion child range start: ${start}`);
13937
13937
  const insertionElem = child;
13938
- assert(logger$4v, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
13938
+ assert(logger$4u, insertionElem.children.length === 3, `invalid insertion dom, children.length = ${insertionElem.children.length}`);
13939
13939
  const range = createExpandedRange(insertionElem, 1, insertionElem, 2);
13940
13940
  return range;
13941
13941
  }
13942
13942
  if (isTextBlockContentBoxChild(child)) {
13943
- assert(logger$4v, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
13944
- assert(logger$4v, start === 0, `invalid box child range start: ${start}`);
13943
+ assert(logger$4u, start + 1 === end, `invalid box child range offset: ${start}, ${end}`);
13944
+ assert(logger$4u, start === 0, `invalid box child range start: ${start}`);
13945
13945
  const box = child;
13946
- assert(logger$4v, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
13946
+ assert(logger$4u, box.children.length === 3, `invalid box dom, children.length = ${box.children.length}`);
13947
13947
  const range = createExpandedRange(box, 1, box, 2);
13948
13948
  return range;
13949
13949
  }
13950
13950
  const length = getTextBlockContentChildTextLength(child);
13951
- assert(logger$4v, end <= length, `invalid child end: ${end}, ${length}`);
13951
+ assert(logger$4u, end <= length, `invalid child end: ${end}, ${length}`);
13952
13952
  const textNode = child.firstChild;
13953
- assert(logger$4v, textNode instanceof Text, "invalid block text child");
13954
- assert(logger$4v, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
13953
+ assert(logger$4u, textNode instanceof Text, "invalid block text child");
13954
+ assert(logger$4u, textNode.data.length >= end, `invalid range end: ${end}, ${textNode.data.length}`);
13955
13955
  return createExpandedRange(textNode, start, textNode, end);
13956
13956
  }
13957
- const logger$4u = getLogger("caret-rect");
13957
+ const logger$4t = getLogger("caret-rect");
13958
13958
  function getChildClientRects(block, child) {
13959
13959
  if (isBox(child)) {
13960
13960
  const box = child;
@@ -13963,7 +13963,7 @@ var __publicField = (obj, key, value) => {
13963
13963
  const blockContent = getBlockContent(block);
13964
13964
  const lineHeight = Number.parseFloat(window.getComputedStyle(blockContent).lineHeight) || boxContent.getBoundingClientRect().height;
13965
13965
  const rects = Array.from(boxContent.getClientRects());
13966
- assert(logger$4u, rects.length > 0, "no box client rects");
13966
+ assert(logger$4t, rects.length > 0, "no box client rects");
13967
13967
  const blockRect = blockContent.getBoundingClientRect();
13968
13968
  const firstRect = rects[0];
13969
13969
  const lastRect = new DOMRect(blockRect.left, firstRect.bottom, 1, lineHeight);
@@ -13983,22 +13983,22 @@ var __publicField = (obj, key, value) => {
13983
13983
  const rect2 = getLastClientRect(ranges[0].child);
13984
13984
  return new DOMRect(rect2.right, rect2.top, 1, rect2.height);
13985
13985
  }
13986
- assert(logger$4u, ranges[1], "invalid ranges");
13986
+ assert(logger$4t, ranges[1], "invalid ranges");
13987
13987
  const rect = getFirstClientRect(ranges[1].child);
13988
13988
  return new DOMRect(rect.left, rect.top, 1, rect.height);
13989
13989
  }
13990
13990
  let rangeInfo = ranges[0];
13991
- assert(logger$4u, ranges.length >= 1, "failed to get block range");
13991
+ assert(logger$4t, ranges.length >= 1, "failed to get block range");
13992
13992
  if (ranges.length === 1) {
13993
13993
  rangeInfo = ranges[0];
13994
13994
  } else {
13995
- assert(logger$4u, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
13995
+ assert(logger$4t, ranges.length >= 2, `invalid range info length: ${ranges.length}`);
13996
13996
  if (isTextBlockContentInsertionChild(ranges[ranges.length - 1].child)) {
13997
13997
  rangeInfo = ranges[ranges.length - 1];
13998
13998
  const child = rangeInfo.child;
13999
13999
  const content = getInsertionContent(child);
14000
14000
  const rects2 = content.getClientRects();
14001
- assert(logger$4u, rects2.length >= 1, "no client rects for box content");
14001
+ assert(logger$4t, rects2.length >= 1, "no client rects for box content");
14002
14002
  const rect = rects2[rects2.length - 1];
14003
14003
  return new DOMRect(rect.right, rect.y, 1, rect.height);
14004
14004
  }
@@ -14015,9 +14015,9 @@ var __publicField = (obj, key, value) => {
14015
14015
  }
14016
14016
  }
14017
14017
  if (rangeInfo.container instanceof HTMLBRElement) {
14018
- assert(logger$4u, pos.offset === 0, "invalid offset for empty block text");
14018
+ assert(logger$4t, pos.offset === 0, "invalid offset for empty block text");
14019
14019
  const parent = rangeInfo.container.parentElement;
14020
- assert(logger$4u, parent, "invalid br parent");
14020
+ assert(logger$4t, parent, "invalid br parent");
14021
14021
  const rect = parent.getBoundingClientRect();
14022
14022
  const ret = new DOMRect(rect.left, rect.top, 1, rect.height);
14023
14023
  return ret;
@@ -14025,11 +14025,11 @@ var __publicField = (obj, key, value) => {
14025
14025
  const range = createRange(rangeInfo.container, rangeInfo.offset);
14026
14026
  const rects = Array.from(range.getClientRects());
14027
14027
  if (rects.length === 0) {
14028
- assert(logger$4u, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
14029
- assert(logger$4u, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
14028
+ assert(logger$4t, !isTextBlockContentTextChild(rangeInfo.child), "only box or insertion child range has zero client rect");
14029
+ assert(logger$4t, rangeInfo.offset === 1 || rangeInfo.offset === 2, "invalid offset for box or insertion child");
14030
14030
  const child = rangeInfo.child;
14031
14031
  const rects2 = getChildClientRects(block, child);
14032
- assert(logger$4u, rects2.length >= 1, "no client rects for box content");
14032
+ assert(logger$4t, rects2.length >= 1, "no client rects for box content");
14033
14033
  if (rangeInfo.offset === 1) {
14034
14034
  const rect2 = rects2[0];
14035
14035
  return new DOMRect(rect2.x, rect2.y, 1, rect2.height);
@@ -14075,7 +14075,7 @@ var __publicField = (obj, key, value) => {
14075
14075
  });
14076
14076
  }
14077
14077
  }
14078
- assert(logger$4u, rects.length > 0, "no client rects for range");
14078
+ assert(logger$4t, rects.length > 0, "no client rects for range");
14079
14079
  if (pos.type === "home") {
14080
14080
  return rects[rects.length - 1];
14081
14081
  }
@@ -14155,13 +14155,13 @@ var __publicField = (obj, key, value) => {
14155
14155
  };
14156
14156
  }
14157
14157
  }
14158
- const logger$4t = getLogger("selection-range");
14158
+ const logger$4s = getLogger("selection-range");
14159
14159
  function createEditorSelectionRange(editor, options) {
14160
14160
  const { anchor: anchor2, focus } = options;
14161
14161
  if (anchor2 instanceof EditorSimpleBlockPosition && focus instanceof EditorSimpleBlockPosition) {
14162
14162
  return new EditorSimpleSelectionRange(editor, { anchor: anchor2, focus });
14163
14163
  }
14164
- assert(logger$4t, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
14164
+ assert(logger$4s, anchor2 instanceof EditorComplexBlockPosition && focus instanceof EditorComplexBlockPosition, "start position type does not math end type");
14165
14165
  return new EditorComplexSelectionRange(editor, { anchor: anchor2, focus });
14166
14166
  }
14167
14167
  function createBlockSimpleRange(editor, block, anchor2, focus) {
@@ -14183,7 +14183,7 @@ var __publicField = (obj, key, value) => {
14183
14183
  const focus = createSimpleBlockPosition(range.focus.blockId, range.focus.offset, "normal");
14184
14184
  return createEditorSelectionRange(editor, { anchor: anchor2, focus });
14185
14185
  }
14186
- const logger$4s = getLogger("range-from-point");
14186
+ const logger$4r = getLogger("range-from-point");
14187
14187
  function getBlockRangeFromPoint(editor, pointX, pointY, dragging) {
14188
14188
  const yOffsets = [0, -12, 12];
14189
14189
  let x = pointX;
@@ -14215,7 +14215,7 @@ var __publicField = (obj, key, value) => {
14215
14215
  const rect = elem.getBoundingClientRect();
14216
14216
  if (rect.width && rect.top && i === 0) {
14217
14217
  if (rect.left + rect.width < x || rect.top + rect.height < y) {
14218
- logger$4s.debug("click on scrollbar, out of element rect");
14218
+ logger$4r.debug("click on scrollbar, out of element rect");
14219
14219
  return null;
14220
14220
  }
14221
14221
  }
@@ -14253,7 +14253,7 @@ var __publicField = (obj, key, value) => {
14253
14253
  let block = getLastChildBlock(container);
14254
14254
  if (!isVisibleBlock(block)) {
14255
14255
  const preBlock = getPrevVisibleBlock(block);
14256
- assert(logger$4s, preBlock, "container must have visible block");
14256
+ assert(logger$4r, preBlock, "container must have visible block");
14257
14257
  block = preBlock;
14258
14258
  }
14259
14259
  const range = getBlockClass(editor, block).getRangeFromPoint(editor, block, x, block.getBoundingClientRect().bottom - 4);
@@ -14272,7 +14272,7 @@ var __publicField = (obj, key, value) => {
14272
14272
  if (range instanceof EditorSimpleSelectionRange) {
14273
14273
  return range;
14274
14274
  }
14275
- assert(logger$4s, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
14275
+ assert(logger$4r, range instanceof EditorComplexSelectionRange, `invalid range type: ${typeof range}`);
14276
14276
  const complexRange = range;
14277
14277
  const container2 = editor.getContainerById(complexRange.start.childContainerId);
14278
14278
  return getRangeInContainer(editor, container2, x, y);
@@ -14295,7 +14295,7 @@ var __publicField = (obj, key, value) => {
14295
14295
  });
14296
14296
  return getRangeInContainer(editor, container, x, y);
14297
14297
  }
14298
- const logger$4r = getLogger("adjust-selection-pos");
14298
+ const logger$4q = getLogger("adjust-selection-pos");
14299
14299
  function getParentContainers(block) {
14300
14300
  const containers = [];
14301
14301
  while (block) {
@@ -14305,10 +14305,10 @@ var __publicField = (obj, key, value) => {
14305
14305
  return containers;
14306
14306
  }
14307
14307
  const newBlock = getParentBlock(container);
14308
- assert(logger$4r, newBlock, "child container has not parent container");
14308
+ assert(logger$4q, newBlock, "child container has not parent container");
14309
14309
  block = newBlock;
14310
14310
  }
14311
- assert(logger$4r, false, "should not come here: getParentContainers");
14311
+ assert(logger$4q, false, "should not come here: getParentContainers");
14312
14312
  }
14313
14313
  function getParentBlockInContainer(container, block) {
14314
14314
  while (block) {
@@ -14317,16 +14317,16 @@ var __publicField = (obj, key, value) => {
14317
14317
  return block;
14318
14318
  }
14319
14319
  const newBlock = getParentBlock(parent);
14320
- assert(logger$4r, newBlock, "could not find parent block for a child container");
14320
+ assert(logger$4q, newBlock, "could not find parent block for a child container");
14321
14321
  block = newBlock;
14322
14322
  }
14323
- assert(logger$4r, false, "no parent block in specified container");
14323
+ assert(logger$4q, false, "no parent block in specified container");
14324
14324
  }
14325
14325
  function getClosestParentBlock(block1, block2) {
14326
14326
  const containers1 = getParentContainers(block1);
14327
14327
  const containers2 = getParentContainers(block2);
14328
- assert(logger$4r, containers1.length > 0 && containers2.length > 0, "block has not parent container");
14329
- assert(logger$4r, containers1[0] === containers2[0], "root container does not equal");
14328
+ assert(logger$4q, containers1.length > 0 && containers2.length > 0, "block has not parent container");
14329
+ assert(logger$4q, containers1[0] === containers2[0], "root container does not equal");
14330
14330
  let parentContainer = containers1[0];
14331
14331
  for (let i = 1; i < containers1.length || containers2.length; i++) {
14332
14332
  if (containers1[i] === containers2[i]) {
@@ -14345,23 +14345,23 @@ var __publicField = (obj, key, value) => {
14345
14345
  }
14346
14346
  function getParentContainerInComplexBlock(parentComplexBlock, element) {
14347
14347
  let block = getParentBlock(element);
14348
- assert(logger$4r, block, "element is not in a block");
14348
+ assert(logger$4q, block, "element is not in a block");
14349
14349
  while (block) {
14350
14350
  const container = getParentContainer(block);
14351
- assert(logger$4r, isChildContainer(container), "not a child container");
14351
+ assert(logger$4q, isChildContainer(container), "not a child container");
14352
14352
  const parentBlock = getParentBlock(container);
14353
- assert(logger$4r, parentBlock, "child container has not parent block");
14353
+ assert(logger$4q, parentBlock, "child container has not parent block");
14354
14354
  if (parentBlock === parentComplexBlock) {
14355
14355
  return container;
14356
14356
  }
14357
14357
  block = parentBlock;
14358
14358
  }
14359
- assert(logger$4r, false, "failed to find parent container in complex block");
14359
+ assert(logger$4q, false, "failed to find parent container in complex block");
14360
14360
  }
14361
14361
  function complexBlockAdjustSelectionPos(editor, complexBlock, anchor2, focus) {
14362
14362
  const blockId = getBlockId(complexBlock);
14363
- assert(logger$4r, blockId === anchor2.blockId, "invalid start pos");
14364
- assert(logger$4r, blockId === focus.blockId, "invalid end pos");
14363
+ assert(logger$4q, blockId === anchor2.blockId, "invalid start pos");
14364
+ assert(logger$4q, blockId === focus.blockId, "invalid end pos");
14365
14365
  const blockClass = getComplexBlockClass(editor, complexBlock);
14366
14366
  if (blockClass.adjustSelectionPos) {
14367
14367
  return blockClass.adjustSelectionPos(editor, complexBlock, anchor2, focus);
@@ -14395,8 +14395,8 @@ var __publicField = (obj, key, value) => {
14395
14395
  if (focus instanceof EditorComplexBlockPosition) {
14396
14396
  focus = createSimpleBlockPosition(focusBlock, getBlockTextLength$6(editor, focusBlock), "end");
14397
14397
  }
14398
- assert(logger$4r, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
14399
- assert(logger$4r, focus instanceof EditorSimpleBlockPosition, "not valid position type");
14398
+ assert(logger$4q, anchor2 instanceof EditorSimpleBlockPosition, "not valid position type");
14399
+ assert(logger$4q, focus instanceof EditorSimpleBlockPosition, "not valid position type");
14400
14400
  return {
14401
14401
  anchor: anchor2,
14402
14402
  focus
@@ -14450,7 +14450,7 @@ var __publicField = (obj, key, value) => {
14450
14450
  focus
14451
14451
  };
14452
14452
  }
14453
- const logger$4q = getLogger("core");
14453
+ const logger$4p = getLogger("core");
14454
14454
  function createBlockAnchor(editor, block, id, refClientRect) {
14455
14455
  const tools = getBlockTools(block);
14456
14456
  let elem = tools.querySelector(`.block-anchor[data-id=${id}]`);
@@ -14468,7 +14468,7 @@ var __publicField = (obj, key, value) => {
14468
14468
  return elem;
14469
14469
  }
14470
14470
  function createBlockCaretAnchor(editor, block, offset, id) {
14471
- assert(logger$4q, isTextKindBlock(editor, block), "not a text kind block");
14471
+ assert(logger$4p, isTextKindBlock(editor, block), "not a text kind block");
14472
14472
  const caretRect = getTextCaretRect(block, createSimpleBlockPosition(block, offset, "normal"));
14473
14473
  const blockRect = block.getBoundingClientRect();
14474
14474
  const tools = getBlockTools(block);
@@ -14827,19 +14827,19 @@ var __publicField = (obj, key, value) => {
14827
14827
  return result + (index2 ? "-" : "") + word.toLowerCase();
14828
14828
  });
14829
14829
  const kebabCase$1 = kebabCase;
14830
- const logger$4p = getLogger("box");
14830
+ const logger$4o = getLogger("box");
14831
14831
  function isBoxOp(op) {
14832
14832
  if (!op.attributes)
14833
14833
  return false;
14834
14834
  if (!op.attributes.box)
14835
14835
  return false;
14836
- assert(logger$4p, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
14837
- assert(logger$4p, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
14836
+ assert(logger$4o, typeof op.attributes.box === "string" && op.attributes.box === "true" || op.attributes.box === true, `invalid op attribute box property, ${op.attributes.box}`);
14837
+ assert(logger$4o, op.attributes.type, `no box type: ${JSON.stringify(op)}`);
14838
14838
  return true;
14839
14839
  }
14840
- const logger$4o = getLogger("text-op");
14840
+ const logger$4n = getLogger("text-op");
14841
14841
  function getOpLength(op) {
14842
- assert(logger$4o, typeof op.insert === "string", "invalid op, no insert");
14842
+ assert(logger$4n, typeof op.insert === "string", "invalid op, no insert");
14843
14843
  return op.insert.length;
14844
14844
  }
14845
14845
  function getOpAt(text2, offset) {
@@ -14847,7 +14847,7 @@ var __publicField = (obj, key, value) => {
14847
14847
  let pos = 0;
14848
14848
  for (let i = 0; i < ops.length; i++) {
14849
14849
  const op = ops[i];
14850
- assert(logger$4o, typeof op.insert === "string", "invalid text op, no insert");
14850
+ assert(logger$4n, typeof op.insert === "string", "invalid text op, no insert");
14851
14851
  const end = pos + getOpLength(op);
14852
14852
  if (end > offset) {
14853
14853
  return [op];
@@ -14863,22 +14863,22 @@ var __publicField = (obj, key, value) => {
14863
14863
  }
14864
14864
  return [];
14865
14865
  }
14866
- const logger$4n = getLogger("rich-text-length");
14866
+ const logger$4m = getLogger("rich-text-length");
14867
14867
  function getTextOpLength(op) {
14868
- assert(logger$4n, typeof op.insert === "string", "op.insert is not string");
14868
+ assert(logger$4m, typeof op.insert === "string", "op.insert is not string");
14869
14869
  return op.insert.length;
14870
14870
  }
14871
14871
  function getTextLength(ops) {
14872
14872
  let count = 0;
14873
14873
  ops.forEach((op) => {
14874
14874
  if (op.insert) {
14875
- assert(logger$4n, typeof op.insert === "string", "op.insert is not string");
14875
+ assert(logger$4m, typeof op.insert === "string", "op.insert is not string");
14876
14876
  count += getTextOpLength(op);
14877
14877
  }
14878
14878
  });
14879
14879
  return count;
14880
14880
  }
14881
- const logger$4m = getLogger("split-text");
14881
+ const logger$4l = getLogger("split-text");
14882
14882
  function splitText(ops, offset, splitResult) {
14883
14883
  ops = cloneDeep__default.default(ops);
14884
14884
  if (offset === 0) {
@@ -14896,8 +14896,8 @@ var __publicField = (obj, key, value) => {
14896
14896
  let counted = 0;
14897
14897
  for (let i = 0; i < ops.length; i++) {
14898
14898
  const op = ops[i];
14899
- assert(logger$4m, typeof op === "object", `invalid op type, ${typeof op}`);
14900
- assert(logger$4m, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
14899
+ assert(logger$4l, typeof op === "object", `invalid op type, ${typeof op}`);
14900
+ assert(logger$4l, typeof op.insert === "string", `invalid op.insert type, ${typeof op.insert}`);
14901
14901
  const subLen = getTextOpLength(op);
14902
14902
  if (counted + subLen < offset) {
14903
14903
  counted += subLen;
@@ -14907,18 +14907,18 @@ var __publicField = (obj, key, value) => {
14907
14907
  right: ops.slice(i + 1)
14908
14908
  };
14909
14909
  } else {
14910
- assert(logger$4m, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
14910
+ assert(logger$4l, counted + subLen > offset, `invalid offset, ${counted}, ${subLen}, ${offset}`);
14911
14911
  const splitIndex = offset - counted;
14912
14912
  const copied = cloneDeep__default.default(op);
14913
- assert(logger$4m, copied.insert, "no copied.insert");
14914
- assert(logger$4m, typeof copied.insert === "string", "invalid copied.insert type");
14913
+ assert(logger$4l, copied.insert, "no copied.insert");
14914
+ assert(logger$4l, typeof copied.insert === "string", "invalid copied.insert type");
14915
14915
  copied.insert = copied.insert.substr(0, splitIndex);
14916
14916
  op.insert = op.insert.substr(splitIndex);
14917
14917
  if (copied.insert === "") {
14918
- assert(logger$4m, false, "invalid copied.insert, is empty string");
14918
+ assert(logger$4l, false, "invalid copied.insert, is empty string");
14919
14919
  }
14920
14920
  if (op.insert === "") {
14921
- assert(logger$4m, false, "invalid op.insert, is empty string");
14921
+ assert(logger$4l, false, "invalid op.insert, is empty string");
14922
14922
  }
14923
14923
  const right = [
14924
14924
  op,
@@ -14937,9 +14937,9 @@ var __publicField = (obj, key, value) => {
14937
14937
  throw new Error(`invalid split offset: ${offset}, ${JSON.stringify(ops)}`);
14938
14938
  }
14939
14939
  function splitToThree(text2, offset, length) {
14940
- assert(logger$4m, offset >= 0, "invalid offset, < 0");
14941
- assert(logger$4m, length > 0, "invalid length, <= 0");
14942
- assert(logger$4m, offset + length <= getTextLength(text2), "invalid offset + length < text length");
14940
+ assert(logger$4l, offset >= 0, "invalid offset, < 0");
14941
+ assert(logger$4l, length > 0, "invalid length, <= 0");
14942
+ assert(logger$4l, offset + length <= getTextLength(text2), "invalid offset + length < text length");
14943
14943
  const { left: temp, right } = splitText(text2, offset + length);
14944
14944
  const { left, right: middle } = splitText(temp, offset);
14945
14945
  return { left, middle, right };
@@ -15162,9 +15162,9 @@ var __publicField = (obj, key, value) => {
15162
15162
  }
15163
15163
  return [color, backgroundColor];
15164
15164
  }
15165
- const logger$4l = getLogger("text-block-content");
15165
+ const logger$4k = getLogger("text-block-content");
15166
15166
  function updateBlockContentCore(editor, blockPath, content, blockText, insertions) {
15167
- assert(logger$4l, blockText, "no text for block");
15167
+ assert(logger$4k, blockText, "no text for block");
15168
15168
  if (blockText.length === 0 && (!insertions || insertions.size === 0)) {
15169
15169
  content.innerHTML = "<span><br></span>";
15170
15170
  return;
@@ -15196,9 +15196,9 @@ var __publicField = (obj, key, value) => {
15196
15196
  for (let i2 = 0; i2 < text2.length; i2++) {
15197
15197
  const op = text2[i2];
15198
15198
  if (isBoxOp(op)) {
15199
- assert(logger$4l, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
15199
+ assert(logger$4k, op.attributes, `op is not an valid box: ${JSON.stringify(op)}`);
15200
15200
  const span2 = editor.editorBoxes.createBox(content, op.attributes);
15201
- assert(logger$4l, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
15201
+ assert(logger$4k, span2 instanceof HTMLSpanElement, `invalid box element: ${span2.tagName}`);
15202
15202
  const ret = editor.editorBlockRenders.renderBox(blockPath, op.attributes);
15203
15203
  if (ret.classes) {
15204
15204
  addClass(span2, ...ret.classes);
@@ -15216,7 +15216,7 @@ var __publicField = (obj, key, value) => {
15216
15216
  fragment.appendChild(span2);
15217
15217
  continue;
15218
15218
  }
15219
- assert(logger$4l, op.insert, `no insert in op: ${JSON.stringify(op)}`);
15219
+ assert(logger$4k, op.insert, `no insert in op: ${JSON.stringify(op)}`);
15220
15220
  const span = createElement("span", ["text"], fragment, op.insert);
15221
15221
  if (op.attributes) {
15222
15222
  const ret = editor.editorBlockRenders.renderText(blockPath, op.attributes);
@@ -15247,7 +15247,7 @@ var __publicField = (obj, key, value) => {
15247
15247
  const compositionText = editor.compositingText;
15248
15248
  if (compositionText) {
15249
15249
  const pos = editor.selection.range.start;
15250
- assert(logger$4l, pos.isSimple(), "not an simple position while compositing");
15250
+ assert(logger$4k, pos.isSimple(), "not an simple position while compositing");
15251
15251
  if (pos.blockId === blockId) {
15252
15252
  const attributes = getAttributesAt(text2, 0);
15253
15253
  insertions.set(pos.offset, [{
@@ -15263,11 +15263,11 @@ var __publicField = (obj, key, value) => {
15263
15263
  function clearAllTempCompositionText(editor) {
15264
15264
  const children = editor.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');
15265
15265
  if (children.length) {
15266
- logger$4l.debug(`remove ${children.length} temp composition span`);
15266
+ logger$4k.debug(`remove ${children.length} temp composition span`);
15267
15267
  }
15268
15268
  Array.from(children).forEach((c) => c.remove());
15269
15269
  }
15270
- const logger$4k = getLogger("client-rects");
15270
+ const logger$4j = getLogger("client-rects");
15271
15271
  function getChildrenOffsets(block) {
15272
15272
  const children = getTextBlockContentChildren(block);
15273
15273
  let start = 0;
@@ -15285,15 +15285,15 @@ var __publicField = (obj, key, value) => {
15285
15285
  return ret;
15286
15286
  }
15287
15287
  function getChildrenInRange(editor, block, from, to) {
15288
- assert(logger$4k, from < to, `invalid from & to: ${from}, ${to}`);
15288
+ assert(logger$4j, from < to, `invalid from & to: ${from}, ${to}`);
15289
15289
  const blockLength = getBlockTextLength$6(editor, block);
15290
- assert(logger$4k, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
15290
+ assert(logger$4j, from >= 0 && to >= 0 && from <= blockLength && to <= blockLength, `invalid offset: ${from}, ${to}, length: ${blockLength}`);
15291
15291
  const offsets = getChildrenOffsets(block);
15292
15292
  const startIndex = offsets.findIndex((c) => c.startBlockOffset <= from && from < c.endBlockOffset);
15293
15293
  const endIndex = offsets.findIndex((c) => c.startBlockOffset < to && to <= c.endBlockOffset);
15294
- assert(logger$4k, startIndex !== -1, "failed to find start child");
15295
- assert(logger$4k, endIndex !== -1, "failed to find end child");
15296
- assert(logger$4k, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
15294
+ assert(logger$4j, startIndex !== -1, "failed to find start child");
15295
+ assert(logger$4j, endIndex !== -1, "failed to find end child");
15296
+ assert(logger$4j, startIndex <= endIndex, `invalid start index & end index: ${startIndex}, ${endIndex}`);
15297
15297
  if (startIndex === endIndex) {
15298
15298
  const child = offsets[startIndex];
15299
15299
  return [{
@@ -15375,16 +15375,16 @@ var __publicField = (obj, key, value) => {
15375
15375
  return rects;
15376
15376
  }
15377
15377
  function getRangeClientRects(editor, block, range) {
15378
- assert(logger$4k, range instanceof EditorSimpleSelectionRange, "invalid range");
15378
+ assert(logger$4j, range instanceof EditorSimpleSelectionRange, "invalid range");
15379
15379
  const start = range.start;
15380
15380
  const end = range.end;
15381
- assert(logger$4k, start.isSimple(), "text block only allow simple position");
15382
- assert(logger$4k, end.isSimple(), "text block only allow simple position");
15383
- assert(logger$4k, start.blockId === end.blockId, "only allow update one text block selection");
15384
- assert(logger$4k, start.blockId === getBlockId(block), "only allow update one text block selection");
15381
+ assert(logger$4j, start.isSimple(), "text block only allow simple position");
15382
+ assert(logger$4j, end.isSimple(), "text block only allow simple position");
15383
+ assert(logger$4j, start.blockId === end.blockId, "only allow update one text block selection");
15384
+ assert(logger$4j, start.blockId === getBlockId(block), "only allow update one text block selection");
15385
15385
  return getClientRects$2(editor, block, start, end);
15386
15386
  }
15387
- const logger$4j = getLogger("selection-background");
15387
+ const logger$4i = getLogger("selection-background");
15388
15388
  function getLineHeight(elem) {
15389
15389
  const style2 = window.getComputedStyle(elem);
15390
15390
  const lineHeightStyle = style2.getPropertyValue("line-height");
@@ -15404,9 +15404,9 @@ var __publicField = (obj, key, value) => {
15404
15404
  return lineHeight;
15405
15405
  }
15406
15406
  function updateSelection$4(editor, block, start, end) {
15407
- assert(logger$4j, start.isSimple(), "text block only allow simple position");
15408
- assert(logger$4j, end.isSimple(), "text block only allow simple position");
15409
- assert(logger$4j, start.blockId === end.blockId, "only allow update one text block selection");
15407
+ assert(logger$4i, start.isSimple(), "text block only allow simple position");
15408
+ assert(logger$4i, end.isSimple(), "text block only allow simple position");
15409
+ assert(logger$4i, start.blockId === end.blockId, "only allow update one text block selection");
15410
15410
  const from = start.offset;
15411
15411
  const to = end.offset;
15412
15412
  if (from === to) {
@@ -15465,7 +15465,7 @@ var __publicField = (obj, key, value) => {
15465
15465
  }
15466
15466
  });
15467
15467
  }
15468
- const logger$4i = getLogger("line-breaker");
15468
+ const logger$4h = getLogger("line-breaker");
15469
15469
  function mergeTextRects(rects) {
15470
15470
  const result = [];
15471
15471
  let lastRect = null;
@@ -15592,7 +15592,7 @@ var __publicField = (obj, key, value) => {
15592
15592
  }
15593
15593
  const textChild = child;
15594
15594
  const rects = mergeTextRects(textChild.getClientRects());
15595
- assert(logger$4i, rects.length > 0, "invalid text child dom");
15595
+ assert(logger$4h, rects.length > 0, "invalid text child dom");
15596
15596
  if (rects.length === 1) {
15597
15597
  const nextChild = children[i + 1];
15598
15598
  if (!nextChild) {
@@ -15617,10 +15617,10 @@ var __publicField = (obj, key, value) => {
15617
15617
  continue;
15618
15618
  }
15619
15619
  const textNode = textChild.firstChild;
15620
- assert(logger$4i, textNode, "invalid text child, no text node");
15621
- assert(logger$4i, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
15620
+ assert(logger$4h, textNode, "invalid text child, no text node");
15621
+ assert(logger$4h, textNode instanceof Text, `invalid text child, not a valid text node: ${typeof textNode}`);
15622
15622
  const textChildLength = getTextBlockContentChildTextLength(textChild);
15623
- assert(logger$4i, textNode.data.length === textChildLength, "text node data length not equal child text length");
15623
+ assert(logger$4h, textNode.data.length === textChildLength, "text node data length not equal child text length");
15624
15624
  const textRects = getTextRects(textNode);
15625
15625
  for (let rIndex = 0; rIndex < textRects.length - 1; rIndex++) {
15626
15626
  const rect = textRects[rIndex];
@@ -15662,7 +15662,7 @@ var __publicField = (obj, key, value) => {
15662
15662
  }
15663
15663
  }
15664
15664
  }
15665
- assert(logger$4i, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
15665
+ assert(logger$4h, position.offset <= getTextBlockLength(block), "invalid position, offset > block length");
15666
15666
  return {
15667
15667
  lineIndex: lineBreaks.length,
15668
15668
  lineBreaks
@@ -24435,7 +24435,7 @@ var __publicField = (obj, key, value) => {
24435
24435
  const Graphemer_1 = __importDefault(Graphemer$1);
24436
24436
  var _default = lib$1.default = Graphemer_1.default;
24437
24437
  const splitter = new _default();
24438
- const logger$4h = getLogger("text-offset");
24438
+ const logger$4g = getLogger("text-offset");
24439
24439
  function getChildOffset(block, child) {
24440
24440
  const children = getTextBlockContentChildren(block);
24441
24441
  let start = 0;
@@ -24451,26 +24451,26 @@ var __publicField = (obj, key, value) => {
24451
24451
  }
24452
24452
  start += testLength;
24453
24453
  }
24454
- assert(logger$4h, false, "can not find child in children");
24454
+ assert(logger$4g, false, "can not find child in children");
24455
24455
  }
24456
24456
  function isValidOffset(block, blockOffset) {
24457
- assert(logger$4h, blockOffset >= 0, `invalid offset: ${blockOffset}`);
24457
+ assert(logger$4g, blockOffset >= 0, `invalid offset: ${blockOffset}`);
24458
24458
  const childInfo = getTextBlockChild(block, blockOffset);
24459
24459
  const { prev, next: next2, offset } = childInfo;
24460
24460
  if (!prev && !next2) {
24461
- assert(logger$4h, false, "invalid offset, no prev & next child at offset");
24461
+ assert(logger$4g, false, "invalid offset, no prev & next child at offset");
24462
24462
  }
24463
24463
  if (prev !== next2) {
24464
24464
  return true;
24465
24465
  }
24466
24466
  const child = prev;
24467
- assert(logger$4h, child, "no child");
24467
+ assert(logger$4g, child, "no child");
24468
24468
  if (isTextBlockContentBoxChild(child)) {
24469
- assert(logger$4h, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
24469
+ assert(logger$4g, offset === 0 || offset === 1, `invalid box child offset: ${offset}`);
24470
24470
  return true;
24471
24471
  }
24472
24472
  const text2 = child.textContent;
24473
- assert(logger$4h, text2, "no content for text child");
24473
+ assert(logger$4g, text2, "no content for text child");
24474
24474
  const chars = splitter.splitGraphemes(text2);
24475
24475
  const validOffsets = /* @__PURE__ */ new Set();
24476
24476
  let start = 0;
@@ -24500,7 +24500,7 @@ var __publicField = (obj, key, value) => {
24500
24500
  }
24501
24501
  function getNextValidOffset(block, blockOffset) {
24502
24502
  const length = getTextBlockLength(block);
24503
- assert(logger$4h, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
24503
+ assert(logger$4g, blockOffset >= 0 && blockOffset <= length, `invalid offset: ${blockOffset}, ${length}`);
24504
24504
  if (blockOffset === length) {
24505
24505
  return length;
24506
24506
  }
@@ -24514,7 +24514,7 @@ var __publicField = (obj, key, value) => {
24514
24514
  }
24515
24515
  return ret;
24516
24516
  }
24517
- const logger$4g = getLogger("line-offset");
24517
+ const logger$4f = getLogger("line-offset");
24518
24518
  function getLineOffsets(block) {
24519
24519
  const lineBreaks = getLineBreaks(block);
24520
24520
  const ret = [];
@@ -24535,7 +24535,7 @@ var __publicField = (obj, key, value) => {
24535
24535
  }
24536
24536
  function getLineOffset(block, lineIndex) {
24537
24537
  const lines = getLineOffsets(block);
24538
- assert(logger$4g, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
24538
+ assert(logger$4f, lineIndex >= 0 && lineIndex < lines.length, `invalid line index: ${lineIndex}, ${lines.length}`);
24539
24539
  return lines[lineIndex];
24540
24540
  }
24541
24541
  function getLineOffsetByPos(block, pos) {
@@ -24592,7 +24592,7 @@ var __publicField = (obj, key, value) => {
24592
24592
  function getLineCount(block) {
24593
24593
  return getLineOffsets(block).length;
24594
24594
  }
24595
- const logger$4f = getLogger("find-text-position");
24595
+ const logger$4e = getLogger("find-text-position");
24596
24596
  function isWrappedLine(block, lineIndex) {
24597
24597
  const { start, end } = getLineOffset(block, lineIndex);
24598
24598
  const blockId = getBlockId(block);
@@ -24603,13 +24603,13 @@ var __publicField = (obj, key, value) => {
24603
24603
  return false;
24604
24604
  }
24605
24605
  const childInfo = getTextBlockChild(block, start);
24606
- assert(logger$4f, childInfo.next, "no next child at offset");
24607
- assert(logger$4f, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
24606
+ assert(logger$4e, childInfo.next, "no next child at offset");
24607
+ assert(logger$4e, !isTextBlockContentTextChild(childInfo.next), "next child is not text child");
24608
24608
  return true;
24609
24609
  }
24610
24610
  function getWrappedLineOffsets(block, lineIndex) {
24611
24611
  const blockId = getBlockId(block);
24612
- assert(logger$4f, isWrappedLine(block, lineIndex), "line is not wrapped");
24612
+ assert(logger$4e, isWrappedLine(block, lineIndex), "line is not wrapped");
24613
24613
  const { start, end } = getLineOffset(block, lineIndex);
24614
24614
  const homePos = createSimpleBlockPosition(blockId, start, "home");
24615
24615
  for (let offset = start + 1; offset <= end; offset += 1) {
@@ -24624,11 +24624,11 @@ var __publicField = (obj, key, value) => {
24624
24624
  return offset - 1;
24625
24625
  }
24626
24626
  }
24627
- assert(logger$4f, false, "failed to find wrapped offset");
24627
+ assert(logger$4e, false, "failed to find wrapped offset");
24628
24628
  return 0;
24629
24629
  }
24630
24630
  function findTextPositionInLine(editor, block, lineIndex, sourceBlock, pos, findDirection, suggestedX) {
24631
- assert(logger$4f, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
24631
+ assert(logger$4e, isTextKindBlock(editor, block), `not a text kind block: ${getBlockType(block)}`);
24632
24632
  const { start, end } = getLineOffset(block, lineIndex);
24633
24633
  let from = start;
24634
24634
  const blockId = getBlockId(block);
@@ -24670,11 +24670,11 @@ var __publicField = (obj, key, value) => {
24670
24670
  return retPos;
24671
24671
  }
24672
24672
  function findPrevTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
24673
- assert(logger$4f, isTextKindBlock(editor, block), "not a text block");
24673
+ assert(logger$4e, isTextKindBlock(editor, block), "not a text block");
24674
24674
  return findTextPositionInLine(editor, block, getLineCount(block) - 1, sourceBlock, pos, "up", suggestedX);
24675
24675
  }
24676
24676
  function findNextTextBlockPosition(editor, block, sourceBlock, pos, suggestedX) {
24677
- assert(logger$4f, isTextKindBlock(editor, block), "not a text block");
24677
+ assert(logger$4e, isTextKindBlock(editor, block), "not a text block");
24678
24678
  return findTextPositionInLine(editor, block, 0, sourceBlock, pos, "down", suggestedX);
24679
24679
  }
24680
24680
  function moveDown(editor, block, position, suggestedX) {
@@ -24782,7 +24782,7 @@ var __publicField = (obj, key, value) => {
24782
24782
  }
24783
24783
  return pos;
24784
24784
  }
24785
- const logger$4e = getLogger("move-caret");
24785
+ const logger$4d = getLogger("move-caret");
24786
24786
  function moveTextCaret(editor, block, position, direction) {
24787
24787
  if (direction === "ArrowLeft") {
24788
24788
  const ret = moveLeft(block, position);
@@ -24812,9 +24812,9 @@ var __publicField = (obj, key, value) => {
24812
24812
  }
24813
24813
  return createSimpleBlockPosition(getBlockId(block), ret.offset, ret.type);
24814
24814
  }
24815
- assert(logger$4e, false, `invalid navigation direction: ${direction}`);
24815
+ assert(logger$4d, false, `invalid navigation direction: ${direction}`);
24816
24816
  }
24817
- const logger$4d = getLogger("text-range");
24817
+ const logger$4c = getLogger("text-range");
24818
24818
  function getBlockRects(block) {
24819
24819
  const ret = [];
24820
24820
  const children = getTextBlockContentChildren(block);
@@ -24872,9 +24872,9 @@ var __publicField = (obj, key, value) => {
24872
24872
  return null;
24873
24873
  }
24874
24874
  const children = getTextBlockContentChildren(block);
24875
- assert(logger$4d, children.indexOf(child) !== -1, "failed to find child in children");
24875
+ assert(logger$4c, children.indexOf(child) !== -1, "failed to find child in children");
24876
24876
  const offsetInfo = getChildOffset(block, child);
24877
- assert(logger$4d, offsetInfo, "failed to get child offset");
24877
+ assert(logger$4c, offsetInfo, "failed to get child offset");
24878
24878
  const { start } = offsetInfo;
24879
24879
  let offset;
24880
24880
  let length;
@@ -24890,7 +24890,7 @@ var __publicField = (obj, key, value) => {
24890
24890
  }
24891
24891
  length = 0;
24892
24892
  } else {
24893
- assert(logger$4d, child.firstChild instanceof Text, "child is not text");
24893
+ assert(logger$4c, child.firstChild instanceof Text, "child is not text");
24894
24894
  offset = start + textNodeOffsetFromPoint(child.firstChild, x, y);
24895
24895
  length = 0;
24896
24896
  }
@@ -24923,22 +24923,9 @@ var __publicField = (obj, key, value) => {
24923
24923
  }
24924
24924
  return versions;
24925
24925
  }
24926
- class WikiMacroError extends Error {
24927
- constructor(details, requestId) {
24928
- super(details.message || details.code);
24929
- __publicField(this, "code");
24930
- __publicField(this, "sizeBytes");
24931
- __publicField(this, "limitBytes");
24932
- this.requestId = requestId;
24933
- this.name = "WikiMacroError";
24934
- this.code = details.code;
24935
- this.sizeBytes = details.sizeBytes;
24936
- this.limitBytes = details.limitBytes;
24937
- }
24938
- }
24939
- const logger$4c = getLogger("create-text-op");
24926
+ const logger$4b = getLogger("create-text-op");
24940
24927
  function createTextOp(text2, attributes) {
24941
- assert(logger$4c, text2, "text is empty");
24928
+ assert(logger$4b, text2, "text is empty");
24942
24929
  const ret = {
24943
24930
  insert: text2
24944
24931
  };
@@ -24961,7 +24948,7 @@ var __publicField = (obj, key, value) => {
24961
24948
  }
24962
24949
  return result;
24963
24950
  }
24964
- const logger$4b = getLogger("merge-ops");
24951
+ const logger$4a = getLogger("merge-ops");
24965
24952
  function mergeOps(text2) {
24966
24953
  if (text2.length <= 1) {
24967
24954
  return text2;
@@ -24983,10 +24970,10 @@ var __publicField = (obj, key, value) => {
24983
24970
  return false;
24984
24971
  }
24985
24972
  if (op1.attributes === void 0) {
24986
- assert(logger$4b, op2.attributes === void 0, "op2.attributes is not undefined");
24973
+ assert(logger$4a, op2.attributes === void 0, "op2.attributes is not undefined");
24987
24974
  return true;
24988
24975
  }
24989
- assert(logger$4b, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
24976
+ assert(logger$4a, op1.attributes && op2.attributes, "op1.attributes && op2.attributes is undefined");
24990
24977
  return isEqual__default.default(op1.attributes, op2.attributes);
24991
24978
  };
24992
24979
  const newOps = [];
@@ -24995,8 +24982,8 @@ var __publicField = (obj, key, value) => {
24995
24982
  for (let i = 1; i < text2.length; i += 1) {
24996
24983
  const op = text2[i];
24997
24984
  if (isSameTypeOp(before, op)) {
24998
- assert(logger$4b, typeof before.insert === "string", "before.insert is not string");
24999
- assert(logger$4b, typeof op.insert === "string", "op.insert is not string");
24985
+ assert(logger$4a, typeof before.insert === "string", "before.insert is not string");
24986
+ assert(logger$4a, typeof op.insert === "string", "op.insert is not string");
25000
24987
  before.insert += op.insert;
25001
24988
  } else {
25002
24989
  newOps.push(op);
@@ -25024,15 +25011,15 @@ var __publicField = (obj, key, value) => {
25024
25011
  }
25025
25012
  return text2.slice(0, i + 1);
25026
25013
  }
25027
- const logger$4a = getLogger("delete-text");
25014
+ const logger$49 = getLogger("delete-text");
25028
25015
  function deleteText(richText2, offset, count) {
25029
25016
  const { left, right } = splitToThree(richText2, offset, count);
25030
25017
  const result = [...left, ...right];
25031
25018
  return mergeOps(result);
25032
25019
  }
25033
25020
  function createDeleteOps(offset, count) {
25034
- assert(logger$4a, offset >= 0, `invalid offset: ${offset}`);
25035
- assert(logger$4a, count >= 1, `invalid delete count: ${count}`);
25021
+ assert(logger$49, offset >= 0, `invalid offset: ${offset}`);
25022
+ assert(logger$49, count >= 1, `invalid delete count: ${count}`);
25036
25023
  const ops = [];
25037
25024
  if (offset !== 0) {
25038
25025
  ops.push({
@@ -25044,7 +25031,7 @@ var __publicField = (obj, key, value) => {
25044
25031
  });
25045
25032
  return ops;
25046
25033
  }
25047
- const logger$49 = getLogger("delta");
25034
+ const logger$48 = getLogger("delta");
25048
25035
  function diffRichText(oldText, newText) {
25049
25036
  const delta1D = new Delta__default.default(oldText);
25050
25037
  const delta2D = new Delta__default.default(newText);
@@ -25054,7 +25041,7 @@ var __publicField = (obj, key, value) => {
25054
25041
  return new Delta__default.default(ops).transformPosition(cursor, !isLocalOp);
25055
25042
  }
25056
25043
  function isValidDocText(text2) {
25057
- assert(logger$49, text2, "ops is null or undefined");
25044
+ assert(logger$48, text2, "ops is null or undefined");
25058
25045
  for (let i = 0; i < text2.length; i++) {
25059
25046
  const op = text2[i];
25060
25047
  if (op.insert === null || op.insert === void 0) {
@@ -25074,7 +25061,7 @@ var __publicField = (obj, key, value) => {
25074
25061
  }
25075
25062
  class RichText {
25076
25063
  static ensureValidText(text2) {
25077
- assert(logger$49, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
25064
+ assert(logger$48, isValidDocText(text2), `text is not a valid text, ${JSON.stringify(text2)}`);
25078
25065
  }
25079
25066
  static diff(oldText, newText) {
25080
25067
  this.ensureValidText(oldText);
@@ -25096,9 +25083,9 @@ var __publicField = (obj, key, value) => {
25096
25083
  return resultText;
25097
25084
  }
25098
25085
  }
25099
- const logger$48 = getLogger("insert-text");
25086
+ const logger$47 = getLogger("insert-text");
25100
25087
  function insertText(richText2, offset, text2, attributes) {
25101
- assert(logger$48, text2, `invalid text to insert: ${text2}`);
25088
+ assert(logger$47, text2, `invalid text to insert: ${text2}`);
25102
25089
  const { left, right } = splitText(richText2, offset);
25103
25090
  const insertedText = typeof text2 === "string" ? [createTextOp(text2, attributes)] : text2;
25104
25091
  const result = [...left, ...insertedText, ...right];
@@ -25111,7 +25098,7 @@ var __publicField = (obj, key, value) => {
25111
25098
  };
25112
25099
  }
25113
25100
  function createInsertOps(offset, text2, attributes) {
25114
- assert(logger$48, offset >= 0, `invalid offset: ${offset}`);
25101
+ assert(logger$47, offset >= 0, `invalid offset: ${offset}`);
25115
25102
  if (text2.length === 0) {
25116
25103
  return [];
25117
25104
  }
@@ -25141,7 +25128,7 @@ var __publicField = (obj, key, value) => {
25141
25128
  function cloneText(text2) {
25142
25129
  return cloneDeep__default.default(text2);
25143
25130
  }
25144
- const logger$47 = getLogger("update-op-attribute");
25131
+ const logger$46 = getLogger("update-op-attribute");
25145
25132
  function updateOpAttributes(orgOps, key, value, newAttributes) {
25146
25133
  const ops = cloneText(orgOps);
25147
25134
  const index2 = ops.findIndex((op2) => {
@@ -25149,7 +25136,7 @@ var __publicField = (obj, key, value) => {
25149
25136
  return false;
25150
25137
  return op2.attributes[key] === value;
25151
25138
  });
25152
- assert(logger$47, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
25139
+ assert(logger$46, index2 !== -1, `can not find op by key: ${key}, value: ${value}`);
25153
25140
  const op = ops[index2];
25154
25141
  op.attributes = {
25155
25142
  ...op.attributes,
@@ -25224,11 +25211,11 @@ var __publicField = (obj, key, value) => {
25224
25211
  ]);
25225
25212
  }
25226
25213
  const FILL_CHAR = "\u200B";
25227
- const logger$46 = getLogger("to-plain-text");
25214
+ const logger$45 = getLogger("to-plain-text");
25228
25215
  function toPlainText(ops, options) {
25229
25216
  let text2 = "";
25230
25217
  ops.forEach((op) => {
25231
- assert(logger$46, typeof op.insert === "string", "invalid op");
25218
+ assert(logger$45, typeof op.insert === "string", "invalid op");
25232
25219
  if (op.attributes && op.attributes.box === true) {
25233
25220
  if (options == null ? void 0 : options.boxReplacement) {
25234
25221
  text2 += options.boxReplacement;
@@ -25283,7 +25270,64 @@ var __publicField = (obj, key, value) => {
25283
25270
  focus: pos
25284
25271
  };
25285
25272
  }
25286
- const logger$45 = getLogger("repair-duplicated-block-ids");
25273
+ const WIKI_MACRO_TYPE = "ones-open-wiki-macro";
25274
+ function getWikiMacroExportSpec(data2) {
25275
+ if (!data2 || data2.protocolVersion !== 2 || !Array.isArray(data2.exportSpec))
25276
+ return [];
25277
+ return data2.exportSpec.filter((spec) => {
25278
+ if (!spec || typeof spec !== "object")
25279
+ return false;
25280
+ if (spec.type === "text")
25281
+ return typeof spec.data === "string";
25282
+ if (spec.type === "image")
25283
+ return typeof spec.data === "string" && !!spec.data;
25284
+ return spec.type === "link" && spec.data && typeof spec.data.title === "string" && typeof spec.data.url === "string" && /^(https?:\/\/|mailto:)/i.test(spec.data.url.trim());
25285
+ });
25286
+ }
25287
+ function getWikiMacroResources(data2) {
25288
+ if (!data2 || data2.protocolVersion !== 2)
25289
+ return [];
25290
+ const resources = /* @__PURE__ */ new Set();
25291
+ if (Array.isArray(data2.resources)) {
25292
+ data2.resources.forEach((resource) => {
25293
+ if (typeof resource === "string" && resource)
25294
+ resources.add(resource);
25295
+ });
25296
+ }
25297
+ getWikiMacroExportSpec(data2).forEach((spec) => {
25298
+ if (spec.type === "image" && typeof spec.data === "string" && spec.data)
25299
+ resources.add(spec.data);
25300
+ });
25301
+ return Array.from(resources);
25302
+ }
25303
+ function replaceWikiMacroResources(data2, resources) {
25304
+ if (!data2 || data2.protocolVersion !== 2)
25305
+ return;
25306
+ if (Array.isArray(data2.resources)) {
25307
+ data2.resources = data2.resources.map((resource) => {
25308
+ var _a;
25309
+ return (_a = resources.get(resource)) != null ? _a : resource;
25310
+ });
25311
+ }
25312
+ getWikiMacroExportSpec(data2).forEach((spec) => {
25313
+ var _a;
25314
+ if (spec.type === "image" && typeof spec.data === "string")
25315
+ spec.data = (_a = resources.get(spec.data)) != null ? _a : spec.data;
25316
+ });
25317
+ }
25318
+ function wikiMacroToText(data2) {
25319
+ return getWikiMacroExportSpec(data2).map((spec) => {
25320
+ if (spec.type === "text" && typeof spec.data === "string")
25321
+ return spec.data;
25322
+ if (spec.type === "link" && spec.data && typeof spec.data === "object") {
25323
+ const link2 = spec.data;
25324
+ if (typeof link2.title === "string" && typeof link2.url === "string")
25325
+ return `${link2.title} ${link2.url}`;
25326
+ }
25327
+ return "";
25328
+ }).filter(Boolean).join("\n");
25329
+ }
25330
+ const logger$44 = getLogger("repair-duplicated-block-ids");
25287
25331
  const ROOT_CONTAINER_ID = "root";
25288
25332
  function buildChildContainersDelta(doc2, block) {
25289
25333
  const children = block.children;
@@ -25335,10 +25379,10 @@ var __publicField = (obj, key, value) => {
25335
25379
  if (seenBlockIds.has(block.id)) {
25336
25380
  duplicatedIds.push(block.id);
25337
25381
  if (readonly) {
25338
- logger$45.warn(`duplicated block id ${block.id} at ${containerId}[${blockIndex}], readonly, skip repairing`);
25382
+ logger$44.warn(`duplicated block id ${block.id} at ${containerId}[${blockIndex}], readonly, skip repairing`);
25339
25383
  } else {
25340
25384
  const newId = genId();
25341
- logger$45.warn(`repair duplicated block id ${block.id} -> ${newId} at ${containerId}[${blockIndex}]`);
25385
+ logger$44.warn(`repair duplicated block id ${block.id} -> ${newId} at ${containerId}[${blockIndex}]`);
25342
25386
  const childDelta = buildChildContainersDelta(doc2, block);
25343
25387
  doc2.localUpdateBlockData(
25344
25388
  containerId,
@@ -25362,17 +25406,17 @@ var __publicField = (obj, key, value) => {
25362
25406
  };
25363
25407
  visitContainer(ROOT_CONTAINER_ID);
25364
25408
  if (duplicatedIds.length > 0) {
25365
- logger$45.error(
25409
+ logger$44.error(
25366
25410
  `found ${duplicatedIds.length} duplicated block id(s): ${duplicatedIds.join(", ")}, repaired ${repaired}`
25367
25411
  );
25368
25412
  }
25369
25413
  return { repaired, duplicatedIds };
25370
25414
  }
25371
- const logger$44 = getLogger("block-to-text");
25415
+ const logger$43 = getLogger("block-to-text");
25372
25416
  function textBlockToText$1(editor, ops, doc2) {
25373
25417
  let text2 = "";
25374
25418
  ops.forEach((op) => {
25375
- assert(logger$44, typeof op.insert === "string", "invalid op");
25419
+ assert(logger$43, typeof op.insert === "string", "invalid op");
25376
25420
  if (op.attributes && op.attributes.box === true) {
25377
25421
  const box = op.attributes;
25378
25422
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -25390,11 +25434,11 @@ var __publicField = (obj, key, value) => {
25390
25434
  });
25391
25435
  return text2;
25392
25436
  }
25393
- const logger$43 = getLogger("block-to-text");
25437
+ const logger$42 = getLogger("block-to-text");
25394
25438
  function textToMarkdownText(editor, ops, doc2) {
25395
25439
  let text2 = "";
25396
25440
  ops.forEach((op) => {
25397
- assert(logger$43, typeof op.insert === "string", "invalid op");
25441
+ assert(logger$42, typeof op.insert === "string", "invalid op");
25398
25442
  if (op.attributes && op.attributes.box === true) {
25399
25443
  const box = op.attributes;
25400
25444
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -25517,12 +25561,12 @@ var __publicField = (obj, key, value) => {
25517
25561
  return void 0;
25518
25562
  }
25519
25563
  }
25520
- const logger$42 = getLogger("block-to-text");
25564
+ const logger$41 = getLogger("block-to-text");
25521
25565
  function textBlockToHtml(editor, blockData, doc2) {
25522
25566
  let html = "";
25523
25567
  const ops = blockData.text || [];
25524
25568
  ops.forEach((op) => {
25525
- assert(logger$42, typeof op.insert === "string", "invalid op");
25569
+ assert(logger$41, typeof op.insert === "string", "invalid op");
25526
25570
  if (op.attributes && op.attributes.box === true) {
25527
25571
  const box = op.attributes;
25528
25572
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -25598,16 +25642,16 @@ var __publicField = (obj, key, value) => {
25598
25642
  }
25599
25643
  return `<p>${html}</p>`;
25600
25644
  }
25601
- const logger$41 = getLogger("text-block");
25645
+ const logger$40 = getLogger("text-block");
25602
25646
  function createBlockContent$5(editor, path, container, blockElement, blockData) {
25603
25647
  const { text: text2 } = blockData;
25604
- assert(logger$41, text2, "no text for text block");
25648
+ assert(logger$40, text2, "no text for text block");
25605
25649
  const content = createBlockContentElement(blockElement, "div");
25606
25650
  updateBlockContent$1(editor, path, blockData.id, content, text2);
25607
25651
  return content;
25608
25652
  }
25609
25653
  function updateBlockText$1(editor, block, text2) {
25610
- assert(logger$41, text2, "no text to update");
25654
+ assert(logger$40, text2, "no text to update");
25611
25655
  const newContent = createBlockContentElement(null, "div");
25612
25656
  updateBlockContent$1(editor, getBlockPath(block), getBlockId(block), newContent, text2);
25613
25657
  const oldContent = getBlockContent(block);
@@ -25617,7 +25661,7 @@ var __publicField = (obj, key, value) => {
25617
25661
  return getRangeClientRects(editor, block, range);
25618
25662
  }
25619
25663
  function convertTo$k(editor, blockData, doc2, type) {
25620
- assert(logger$41, blockData.text, "no text for text block");
25664
+ assert(logger$40, blockData.text, "no text for text block");
25621
25665
  if (type === "text") {
25622
25666
  return textBlockToText$1(editor, blockData.text, doc2);
25623
25667
  }
@@ -25631,7 +25675,7 @@ var __publicField = (obj, key, value) => {
25631
25675
  blockData.id = genId();
25632
25676
  info == null ? void 0 : info.blockIdMap.set(srcBlockData.id, blockData.id);
25633
25677
  const { text: text2 } = blockData;
25634
- assert(logger$41, text2, "no text for text block");
25678
+ assert(logger$40, text2, "no text for text block");
25635
25679
  text2.forEach((op) => {
25636
25680
  if (op.insert && op.attributes && op.attributes.box === true) {
25637
25681
  const boxId = genId();
@@ -25664,7 +25708,7 @@ var __publicField = (obj, key, value) => {
25664
25708
  blockToDoc: blockToDoc$1
25665
25709
  };
25666
25710
  const updateTextBlockContent = updateBlockContent$1;
25667
- const logger$40 = getLogger("action-helper");
25711
+ const logger$3$ = getLogger("action-helper");
25668
25712
  function editorGetBlockData(editor, block) {
25669
25713
  const container = getParentContainer(block);
25670
25714
  const containerId = getContainerId(container);
@@ -25672,10 +25716,10 @@ var __publicField = (obj, key, value) => {
25672
25716
  return editor.doc.getBlockData(containerId, blockIndex);
25673
25717
  }
25674
25718
  function editorGetBlockText(editor, block) {
25675
- assert(logger$40, isTextKindBlock(editor, block), "not a text kind block");
25719
+ assert(logger$3$, isTextKindBlock(editor, block), "not a text kind block");
25676
25720
  const data2 = editorGetBlockData(editor, block);
25677
25721
  const text2 = data2.text;
25678
- assert(logger$40, text2, "no text in block");
25722
+ assert(logger$3$, text2, "no text in block");
25679
25723
  return text2;
25680
25724
  }
25681
25725
  function editorGetBlockTextEx(editor, block, length) {
@@ -25683,7 +25727,7 @@ var __publicField = (obj, key, value) => {
25683
25727
  }
25684
25728
  function editorGetBoxData(editor, box) {
25685
25729
  const block = getParentBlock(box);
25686
- assert(logger$40, block, "no parent block");
25730
+ assert(logger$3$, block, "no parent block");
25687
25731
  const text2 = editorGetBlockText(editor, block);
25688
25732
  const id = getBoxId(box);
25689
25733
  const op = text2.find((op2) => {
@@ -25693,60 +25737,60 @@ var __publicField = (obj, key, value) => {
25693
25737
  }
25694
25738
  return false;
25695
25739
  });
25696
- assert(logger$40, op, "failed to find box");
25740
+ assert(logger$3$, op, "failed to find box");
25697
25741
  return op.attributes;
25698
25742
  }
25699
- const logger$3$ = getLogger("block-text");
25743
+ const logger$3_ = getLogger("block-text");
25700
25744
  function getTextAfterOffset(editor, block, offset) {
25701
- assert(logger$3$, isTextKindBlock(editor, block), "not a text kind block");
25702
- assert(logger$3$, isValidOffset(block, offset), "not a valid offset");
25703
- assert(logger$3$, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25745
+ assert(logger$3_, isTextKindBlock(editor, block), "not a text kind block");
25746
+ assert(logger$3_, isValidOffset(block, offset), "not a valid offset");
25747
+ assert(logger$3_, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25704
25748
  const newOffset = getNextValidOffset(block, offset);
25705
25749
  const length = newOffset - offset;
25706
25750
  if (length === 0) {
25707
- assert(logger$3$, false, `no text after offset: ${offset}`);
25751
+ assert(logger$3_, false, `no text after offset: ${offset}`);
25708
25752
  }
25709
25753
  const text2 = editorGetBlockText(editor, block);
25710
25754
  const { middle } = splitToThree(text2, offset, length);
25711
- assert(logger$3$, middle.length === 1, "failed to split text to 3 parts");
25755
+ assert(logger$3_, middle.length === 1, "failed to split text to 3 parts");
25712
25756
  const op = middle[0];
25713
25757
  if (isBoxOp(op)) {
25714
25758
  return " ";
25715
25759
  }
25716
- assert(logger$3$, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25760
+ assert(logger$3_, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25717
25761
  return op.insert;
25718
25762
  }
25719
25763
  function getTextBeforeOffset(editor, block, offset) {
25720
- assert(logger$3$, isTextKindBlock(editor, block), "not a text kind block");
25721
- assert(logger$3$, isValidOffset(block, offset), "not a valid offset");
25722
- assert(logger$3$, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25764
+ assert(logger$3_, isTextKindBlock(editor, block), "not a text kind block");
25765
+ assert(logger$3_, isValidOffset(block, offset), "not a valid offset");
25766
+ assert(logger$3_, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25723
25767
  const newOffset = getPrevValidOffset(block, offset);
25724
25768
  const length = offset - newOffset;
25725
25769
  if (length === 0) {
25726
- assert(logger$3$, false, `no text before offset: ${offset}`);
25770
+ assert(logger$3_, false, `no text before offset: ${offset}`);
25727
25771
  }
25728
25772
  const text2 = editorGetBlockText(editor, block);
25729
25773
  const { middle } = splitToThree(text2, newOffset, length);
25730
- assert(logger$3$, middle.length === 1, "failed to split text to 3 parts");
25774
+ assert(logger$3_, middle.length === 1, "failed to split text to 3 parts");
25731
25775
  const op = middle[0];
25732
25776
  if (isBoxOp(op)) {
25733
25777
  return " ";
25734
25778
  }
25735
- assert(logger$3$, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25779
+ assert(logger$3_, op.insert.length === 1 || op.insert.length === 2, "invalid op");
25736
25780
  return op.insert;
25737
25781
  }
25738
25782
  function getOffsetInfoBefore(editor, block, offset) {
25739
- assert(logger$3$, isTextKindBlock(editor, block), "not a text kind block");
25740
- assert(logger$3$, isValidOffset(block, offset), "not a valid offset");
25741
- assert(logger$3$, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25783
+ assert(logger$3_, isTextKindBlock(editor, block), "not a text kind block");
25784
+ assert(logger$3_, isValidOffset(block, offset), "not a valid offset");
25785
+ assert(logger$3_, offset > 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25742
25786
  const newOffset = getPrevValidOffset(block, offset);
25743
25787
  const length = offset - newOffset;
25744
25788
  if (length === 0) {
25745
- assert(logger$3$, false, `no text before offset: ${offset}`);
25789
+ assert(logger$3_, false, `no text before offset: ${offset}`);
25746
25790
  }
25747
25791
  const text2 = editorGetBlockText(editor, block);
25748
25792
  const { middle } = splitToThree(text2, newOffset, length);
25749
- assert(logger$3$, middle.length === 1, "failed to split text to 3 parts");
25793
+ assert(logger$3_, middle.length === 1, "failed to split text to 3 parts");
25750
25794
  const op = middle[0];
25751
25795
  if (isBoxOp(op)) {
25752
25796
  return {
@@ -25772,17 +25816,17 @@ var __publicField = (obj, key, value) => {
25772
25816
  };
25773
25817
  }
25774
25818
  function getOffsetInfoAfter(editor, block, offset) {
25775
- assert(logger$3$, isTextKindBlock(editor, block), "not a text kind block");
25776
- assert(logger$3$, isValidOffset(block, offset), "not a valid offset");
25777
- assert(logger$3$, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25819
+ assert(logger$3_, isTextKindBlock(editor, block), "not a text kind block");
25820
+ assert(logger$3_, isValidOffset(block, offset), "not a valid offset");
25821
+ assert(logger$3_, offset >= 0 && offset < getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
25778
25822
  const newOffset = getNextValidOffset(block, offset);
25779
25823
  const length = newOffset - offset;
25780
25824
  if (length === 0) {
25781
- assert(logger$3$, false, `no text after offset: ${offset}`);
25825
+ assert(logger$3_, false, `no text after offset: ${offset}`);
25782
25826
  }
25783
25827
  const text2 = editorGetBlockText(editor, block);
25784
25828
  const { middle } = splitToThree(text2, offset, length);
25785
- assert(logger$3$, middle.length === 1, "failed to split text to 3 parts");
25829
+ assert(logger$3_, middle.length === 1, "failed to split text to 3 parts");
25786
25830
  const op = middle[0];
25787
25831
  if (isBoxOp(op)) {
25788
25832
  return {
@@ -25854,7 +25898,7 @@ var __publicField = (obj, key, value) => {
25854
25898
  return null;
25855
25899
  }
25856
25900
  function findWordLeft(editor, block, offset) {
25857
- assert(logger$3$, isTextKindBlock(editor, block), "invalid blok type");
25901
+ assert(logger$3_, isTextKindBlock(editor, block), "invalid blok type");
25858
25902
  if (isEmptyTextBlock(editor, block)) {
25859
25903
  return 0;
25860
25904
  }
@@ -25884,7 +25928,7 @@ var __publicField = (obj, key, value) => {
25884
25928
  return startInfo.offset + startInfo.length;
25885
25929
  }
25886
25930
  function findWordEnd(editor, block, offset) {
25887
- assert(logger$3$, isTextKindBlock(editor, block), "invalid blok type");
25931
+ assert(logger$3_, isTextKindBlock(editor, block), "invalid blok type");
25888
25932
  if (isEmptyTextBlock(editor, block)) {
25889
25933
  return 0;
25890
25934
  }
@@ -25913,10 +25957,10 @@ var __publicField = (obj, key, value) => {
25913
25957
  return getBlockTextLength$6(editor, block);
25914
25958
  return startInfo.offset;
25915
25959
  }
25916
- const logger$3_ = getLogger("text-box");
25960
+ const logger$3Z = getLogger("text-box");
25917
25961
  function updateBoxContent$8(editor, boxElement, boxContent, boxData) {
25918
- assert(logger$3_, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
25919
- assert(logger$3_, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
25962
+ assert(logger$3Z, boxData.text, `no text for text box data: ${JSON.stringify(boxData)}`);
25963
+ assert(logger$3Z, typeof boxData.text === "string", `invalid text type for text box data: ${JSON.stringify(boxData)}`);
25920
25964
  createElement("span", [], boxContent, boxData.text);
25921
25965
  }
25922
25966
  function convertTo$j(editor, boxData, doc2, type) {
@@ -25950,7 +25994,7 @@ var __publicField = (obj, key, value) => {
25950
25994
  updateBoxContent: updateBoxContent$7,
25951
25995
  convertTo: convertTo$i
25952
25996
  };
25953
- const logger$3Z = getLogger("editor-boxes");
25997
+ const logger$3Y = getLogger("editor-boxes");
25954
25998
  class EditorBoxes {
25955
25999
  constructor(editor) {
25956
26000
  __publicField(this, "boxes", /* @__PURE__ */ new Map());
@@ -25959,12 +26003,12 @@ var __publicField = (obj, key, value) => {
25959
26003
  registerBoxClass(boxClass) {
25960
26004
  const type = boxClass.boxType;
25961
26005
  const exists = this.boxes.get(type);
25962
- assert(logger$3Z, !exists, `duplicated box type: ${type}`);
26006
+ assert(logger$3Y, !exists, `duplicated box type: ${type}`);
25963
26007
  this.boxes.set(type, boxClass);
25964
26008
  }
25965
26009
  getBoxClass(type) {
25966
26010
  const exists = this.boxes.get(type);
25967
- assert(logger$3Z, exists, `unknown box type: ${type}`);
26011
+ assert(logger$3Y, exists, `unknown box type: ${type}`);
25968
26012
  return exists;
25969
26013
  }
25970
26014
  createBox(blockContent, box) {
@@ -26368,7 +26412,7 @@ var __publicField = (obj, key, value) => {
26368
26412
  return { classes, attributes: newAttributes, styles: newStyles };
26369
26413
  }
26370
26414
  }
26371
- const logger$3Y = getLogger("editor-insertion");
26415
+ const logger$3X = getLogger("editor-insertion");
26372
26416
  class EditorInsertions {
26373
26417
  constructor(editor) {
26374
26418
  __publicField(this, "insertions", /* @__PURE__ */ new Map());
@@ -26377,12 +26421,12 @@ var __publicField = (obj, key, value) => {
26377
26421
  registerInsertionClass(insertionClass) {
26378
26422
  const type = insertionClass.insertionType;
26379
26423
  const exists = this.insertions.get(type);
26380
- assert(logger$3Y, !exists, `duplicated insertion type: ${type}`);
26424
+ assert(logger$3X, !exists, `duplicated insertion type: ${type}`);
26381
26425
  this.insertions.set(type, insertionClass);
26382
26426
  }
26383
26427
  getInsertionClass(type) {
26384
26428
  const exists = this.insertions.get(type);
26385
- assert(logger$3Y, exists, `unknown insertion type: ${type}`);
26429
+ assert(logger$3X, exists, `unknown insertion type: ${type}`);
26386
26430
  return exists;
26387
26431
  }
26388
26432
  createInsertionElement(type, id, attributes) {
@@ -26502,7 +26546,7 @@ var __publicField = (obj, key, value) => {
26502
26546
  };
26503
26547
  }
26504
26548
  }
26505
- const logger$3X = getLogger("editor-input");
26549
+ const logger$3W = getLogger("editor-input");
26506
26550
  class EditorInput$1 {
26507
26551
  constructor(editor, callbacks) {
26508
26552
  __publicField(this, "editor");
@@ -26639,7 +26683,7 @@ var __publicField = (obj, key, value) => {
26639
26683
  return;
26640
26684
  }
26641
26685
  this.callbacks.onCut(event);
26642
- logger$3X.debug("on cut");
26686
+ logger$3W.debug("on cut");
26643
26687
  });
26644
26688
  __publicField(this, "handlePaste", (event) => {
26645
26689
  if (event.isTrusted) {
@@ -26760,11 +26804,11 @@ var __publicField = (obj, key, value) => {
26760
26804
  this.callbacks.removeHandler(handler);
26761
26805
  }
26762
26806
  defaultInsertText(editor, containerId, blockIndex, offset, text2) {
26763
- assert(logger$3X, editor === this.editor, "invalid editor");
26807
+ assert(logger$3W, editor === this.editor, "invalid editor");
26764
26808
  this.callbacks.defaultInsertText(editor, containerId, blockIndex, offset, text2);
26765
26809
  }
26766
26810
  defaultHandleKeydown(editor, event) {
26767
- assert(logger$3X, editor === this.editor, "invalid editor");
26811
+ assert(logger$3W, editor === this.editor, "invalid editor");
26768
26812
  return this.callbacks.defaultHandleKeydown(editor, event);
26769
26813
  }
26770
26814
  forEach(callback) {
@@ -26790,7 +26834,7 @@ var __publicField = (obj, key, value) => {
26790
26834
  input2.style.left = `${x}px`;
26791
26835
  input2.style.top = `${y}px`;
26792
26836
  }
26793
- const logger$3W = getLogger("editor-caret");
26837
+ const logger$3V = getLogger("editor-caret");
26794
26838
  function getFirefoxVersion() {
26795
26839
  const userAgent = window.navigator.userAgent;
26796
26840
  const match = userAgent.match(/Firefox\/(\d+)\./);
@@ -26858,11 +26902,11 @@ var __publicField = (obj, key, value) => {
26858
26902
  }
26859
26903
  try {
26860
26904
  const { range } = this.editor.selection;
26861
- assert(logger$3W, range.isCollapsed, "range is not collapsed");
26905
+ assert(logger$3V, range.isCollapsed, "range is not collapsed");
26862
26906
  const pos = range.start;
26863
- assert(logger$3W, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
26907
+ assert(logger$3V, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
26864
26908
  const block = this.editor.getBlockById(pos.blockId);
26865
- assert(logger$3W, isTextKindBlock(this.editor, block), "only text kind block can has caret");
26909
+ assert(logger$3V, isTextKindBlock(this.editor, block), "only text kind block can has caret");
26866
26910
  let rect;
26867
26911
  const compositionSpan = block.querySelector("span.inputting-insertion");
26868
26912
  if (compositionSpan) {
@@ -26895,7 +26939,7 @@ var __publicField = (obj, key, value) => {
26895
26939
  cursor.style.display = "";
26896
26940
  }
26897
26941
  } catch (err) {
26898
- logger$3W.error(err);
26942
+ logger$3V.error(err);
26899
26943
  }
26900
26944
  }
26901
26945
  }
@@ -26919,7 +26963,7 @@ var __publicField = (obj, key, value) => {
26919
26963
  updateBlockSelection(editor, s.block, s.start, s.end);
26920
26964
  });
26921
26965
  }
26922
- const logger$3V = getLogger("editor-dom");
26966
+ const logger$3U = getLogger("editor-dom");
26923
26967
  function editorGetClientHeight(editor) {
26924
26968
  const scrollContainer = getScrollContainer$1(editor.rootContainer);
26925
26969
  return scrollContainer.clientHeight;
@@ -27010,7 +27054,7 @@ var __publicField = (obj, key, value) => {
27010
27054
  return;
27011
27055
  }
27012
27056
  if (!isElementVisible(editor.rootContainer)) {
27013
- logger$3V.warn("editorScrollIntoView: editor is not visible");
27057
+ logger$3U.warn("editorScrollIntoView: editor is not visible");
27014
27058
  return;
27015
27059
  }
27016
27060
  const rootClientRect = editor.rootContainer.getBoundingClientRect();
@@ -27066,7 +27110,7 @@ var __publicField = (obj, key, value) => {
27066
27110
  anchorElem.remove();
27067
27111
  }, 200);
27068
27112
  }
27069
- const logger$3U = getLogger("range-in-block");
27113
+ const logger$3T = getLogger("range-in-block");
27070
27114
  function rangeInBlock(block, range) {
27071
27115
  const editor = range.getEditor();
27072
27116
  const start = editor.getBlockById(range.start.blockId);
@@ -27093,11 +27137,11 @@ var __publicField = (obj, key, value) => {
27093
27137
  }
27094
27138
  }
27095
27139
  const nextBlock = getNextVisibleBlock(block);
27096
- assert(logger$3U, nextBlock, "no prev and next block while deleting a block");
27140
+ assert(logger$3T, nextBlock, "no prev and next block while deleting a block");
27097
27141
  newRange = createBlockSimpleRange(editor, nextBlock, 0);
27098
27142
  return newRange;
27099
27143
  }
27100
- const logger$3T = getLogger("block-to-html");
27144
+ const logger$3S = getLogger("block-to-html");
27101
27145
  function blockToHtml(editor, blockData, doc2, path) {
27102
27146
  const blockClass = getBlockClassByType(editor, blockData.type);
27103
27147
  if (blockClass.convertTo) {
@@ -27106,15 +27150,15 @@ var __publicField = (obj, key, value) => {
27106
27150
  if (blockClass.blockKind !== "text") {
27107
27151
  return `[${blockData.type}]`;
27108
27152
  }
27109
- assert(logger$3T, blockData.text, "no text");
27153
+ assert(logger$3S, blockData.text, "no text");
27110
27154
  const plainText = toPlainText(blockData.text);
27111
27155
  return `<div>${escapeHtmlText(plainText)}</div>`;
27112
27156
  }
27113
- const logger$3S = getLogger("block-to-text");
27157
+ const logger$3R = getLogger("block-to-text");
27114
27158
  function textBlockToText(editor, ops, doc2) {
27115
27159
  let text2 = "";
27116
27160
  ops.forEach((op) => {
27117
- assert(logger$3S, typeof op.insert === "string", "invalid op");
27161
+ assert(logger$3R, typeof op.insert === "string", "invalid op");
27118
27162
  if (op.attributes && op.attributes.box === true) {
27119
27163
  const box = op.attributes;
27120
27164
  const boxClass = editor.editorBoxes.getBoxClass(box.type);
@@ -27140,7 +27184,7 @@ var __publicField = (obj, key, value) => {
27140
27184
  if (blockClass.blockKind !== "text") {
27141
27185
  return `[${blockData.type}]`;
27142
27186
  }
27143
- assert(logger$3S, blockData.text, "no text");
27187
+ assert(logger$3R, blockData.text, "no text");
27144
27188
  const plainText = textBlockToText(editor, blockData.text, doc2);
27145
27189
  return plainText;
27146
27190
  }
@@ -27173,11 +27217,11 @@ var __publicField = (obj, key, value) => {
27173
27217
  const markdown2 = lines.join("\n");
27174
27218
  return markdown2;
27175
27219
  }
27176
- const logger$3R = getLogger("get-text-position");
27220
+ const logger$3Q = getLogger("get-text-position");
27177
27221
  function editorGetTextPosition(editor, insertPos) {
27178
27222
  const pos = insertPos != null ? insertPos : editor.selection.range.start;
27179
27223
  if (!(pos instanceof EditorSimpleBlockPosition)) {
27180
- assert(logger$3R, false, `invalid insert pos type: ${typeof pos}`);
27224
+ assert(logger$3Q, false, `invalid insert pos type: ${typeof pos}`);
27181
27225
  }
27182
27226
  const { blockId } = pos;
27183
27227
  const block = editor.getBlockById(blockId);
@@ -27265,14 +27309,14 @@ var __publicField = (obj, key, value) => {
27265
27309
  return attributes;
27266
27310
  }
27267
27311
  }
27268
- const logger$3Q = getLogger("insert-text");
27312
+ const logger$3P = getLogger("insert-text");
27269
27313
  function getTextAttributes(editor, containerId, blockIndex, offset) {
27270
27314
  var _a, _b;
27271
27315
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
27272
- assert(logger$3Q, blockData, "no block data");
27273
- assert(logger$3Q, blockData.text, "no block text");
27316
+ assert(logger$3P, blockData, "no block data");
27317
+ assert(logger$3P, blockData.text, "no block text");
27274
27318
  if (getTextLength(blockData.text) === 0) {
27275
- assert(logger$3Q, offset === 0, "invalid text offset");
27319
+ assert(logger$3P, offset === 0, "invalid text offset");
27276
27320
  return BlockAttributesHandler.get(editor).getEmptyBlockTextAttributes(blockData.id);
27277
27321
  }
27278
27322
  if (offset === 0) {
@@ -27319,7 +27363,7 @@ var __publicField = (obj, key, value) => {
27319
27363
  }
27320
27364
  for (let i = 0; i < text2.length; i++) {
27321
27365
  const op = text2[i];
27322
- assert(logger$3Q, typeof op.insert === "string", "invalid text op, no insert");
27366
+ assert(logger$3P, typeof op.insert === "string", "invalid text op, no insert");
27323
27367
  const endPos = pos + getOpLength(op);
27324
27368
  if (endPos === start) {
27325
27369
  return false;
@@ -27333,8 +27377,8 @@ var __publicField = (obj, key, value) => {
27333
27377
  }
27334
27378
  function editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset) {
27335
27379
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
27336
- assert(logger$3Q, blockData, "no block data");
27337
- assert(logger$3Q, blockData.text, "no block text");
27380
+ assert(logger$3P, blockData, "no block data");
27381
+ assert(logger$3P, blockData.text, "no block text");
27338
27382
  const attributes = getTextAttributes(editor, containerId, blockIndex, offset);
27339
27383
  if (attributes && Object.keys(attributes).includes("link")) {
27340
27384
  const inOp = checkRangeInOp(blockData.text, offset);
@@ -27353,21 +27397,21 @@ var __publicField = (obj, key, value) => {
27353
27397
  const { containerId, blockIndex, offset } = editorGetTextPosition(editor);
27354
27398
  editorInsertTextToBlockEx(editor, text2, containerId, blockIndex, offset);
27355
27399
  }
27356
- const logger$3P = getLogger("update-composition-text");
27400
+ const logger$3O = getLogger("update-composition-text");
27357
27401
  function editorUpdateCompositionText(editor) {
27358
27402
  const pos = editor.selection.range.start;
27359
27403
  if (!(pos instanceof EditorSimpleBlockPosition)) {
27360
- assert(logger$3P, false, `invalid insert pos type: ${typeof pos}`);
27404
+ assert(logger$3O, false, `invalid insert pos type: ${typeof pos}`);
27361
27405
  }
27362
27406
  const { blockId } = pos;
27363
27407
  const block = editor.getBlockById(blockId);
27364
- assert(logger$3P, isTextKindBlock(editor, block), "not a text kind block");
27408
+ assert(logger$3O, isTextKindBlock(editor, block), "not a text kind block");
27365
27409
  const container = getParentContainer(block);
27366
27410
  const containerId = getContainerId(container);
27367
27411
  const blockIndex = getBlockIndex(block);
27368
27412
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
27369
- assert(logger$3P, blockData, "no block data in doc");
27370
- assert(logger$3P, blockData.text, "no text data in text block");
27413
+ assert(logger$3O, blockData, "no block data in doc");
27414
+ assert(logger$3O, blockData.text, "no text data in text block");
27371
27415
  const blockContent = getBlockContent(block);
27372
27416
  updateBlockContent$1(editor, getBlockPath(block), blockId, blockContent, blockData.text);
27373
27417
  }
@@ -27379,25 +27423,25 @@ var __publicField = (obj, key, value) => {
27379
27423
  const block = editor.getBlockById(blockData.id);
27380
27424
  return block;
27381
27425
  }
27382
- const logger$3O = getLogger("delete-block-text");
27426
+ const logger$3N = getLogger("delete-block-text");
27383
27427
  function editorDeleteBlockText(editor, block, offset, count, options) {
27384
27428
  if (!editor.isBlockWritable(block)) {
27385
- logger$3O.error("block is not writable");
27429
+ logger$3N.error("block is not writable");
27386
27430
  return 0;
27387
27431
  }
27388
- assert(logger$3O, isTextKindBlock(editor, block), "block is not a text kind block");
27432
+ assert(logger$3N, isTextKindBlock(editor, block), "block is not a text kind block");
27389
27433
  const container = getParentContainer(block);
27390
27434
  const containerId = getContainerId(container);
27391
27435
  const blockIndex = getBlockIndex(block);
27392
27436
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
27393
- assert(logger$3O, blockData, "no block data in doc");
27394
- assert(logger$3O, blockData.text, "no text data in text block");
27437
+ assert(logger$3N, blockData, "no block data in doc");
27438
+ assert(logger$3N, blockData.text, "no text data in text block");
27395
27439
  let from = offset;
27396
27440
  if (!isValidOffset(block, offset)) {
27397
27441
  from = getPrevValidOffset(block, from);
27398
27442
  }
27399
27443
  let to = offset + count;
27400
- assert(logger$3O, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
27444
+ assert(logger$3N, to <= getBlockTextLength$6(editor, block), `invalid offset and count: ${offset}, ${count}`);
27401
27445
  if (!isValidOffset(block, to)) {
27402
27446
  to = getNextValidOffset(block, to);
27403
27447
  }
@@ -27406,7 +27450,7 @@ var __publicField = (obj, key, value) => {
27406
27450
  editor.doc.localUpdateBlockText(containerId, blockIndex, actions2, options);
27407
27451
  return deleteCount;
27408
27452
  }
27409
- const logger$3N = getLogger("break-text-block");
27453
+ const logger$3M = getLogger("break-text-block");
27410
27454
  function copyBlockAttributes(editor, block, options) {
27411
27455
  const blockData = editor.getBlockData(block);
27412
27456
  const quoted = blockData.quoted;
@@ -27423,8 +27467,8 @@ var __publicField = (obj, key, value) => {
27423
27467
  return ret;
27424
27468
  }
27425
27469
  function editorBreakTextBlock(editor, block, offset, options) {
27426
- assert(logger$3N, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
27427
- assert(logger$3N, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
27470
+ assert(logger$3M, isTextKindBlock(editor, block), `block is not a text kind block: ${getBlockType(block)}`);
27471
+ assert(logger$3M, offset >= 0 && offset <= getBlockTextLength$6(editor, block), `invalid offset: ${offset}`);
27428
27472
  const container = getParentContainer(block);
27429
27473
  const containerId = getContainerId(container);
27430
27474
  const blockIndex = getBlockIndex(block);
@@ -27454,7 +27498,7 @@ var __publicField = (obj, key, value) => {
27454
27498
  };
27455
27499
  }
27456
27500
  }
27457
- assert(logger$3N, isValidOffset(block, offset), "not a valid offset");
27501
+ assert(logger$3M, isValidOffset(block, offset), "not a valid offset");
27458
27502
  const text2 = editorGetBlockText(editor, block);
27459
27503
  const { right } = splitText(text2, offset);
27460
27504
  const rightLength = getTextLength(right);
@@ -27480,12 +27524,12 @@ var __publicField = (obj, key, value) => {
27480
27524
  newBlock
27481
27525
  };
27482
27526
  }
27483
- const logger$3M = getLogger("prepare-insert-new-block");
27527
+ const logger$3L = getLogger("prepare-insert-new-block");
27484
27528
  function editorPrepareInsertNewBlock(editor, containerId, blockIndex) {
27485
27529
  if (containerId && blockIndex !== void 0 && blockIndex !== null) {
27486
27530
  const container = editor.getContainerById(containerId);
27487
27531
  const blocks = getChildBlocks(container);
27488
- assert(logger$3M, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
27532
+ assert(logger$3L, blockIndex >= 0 && blockIndex <= blocks.length, `invalid blockIndex: ${blockIndex}`);
27489
27533
  return {
27490
27534
  containerId,
27491
27535
  blockIndex
@@ -27519,92 +27563,15 @@ var __publicField = (obj, key, value) => {
27519
27563
  blockIndex: getBlockIndex(newBlock)
27520
27564
  };
27521
27565
  }
27522
- const logger$3L = getLogger("auto-insert-block");
27566
+ const logger$3K = getLogger("auto-insert-block");
27523
27567
  function editorAutoInsertBlock(editor, blockData, containerId, blockIndex, newRange, insertBlockOptions) {
27524
27568
  const result = editorPrepareInsertNewBlock(editor, containerId, blockIndex);
27525
- assert(logger$3L, result, `not an valid insert position: ${editor.selection.range}`);
27569
+ assert(logger$3K, result, `not an valid insert position: ${editor.selection.range}`);
27526
27570
  const defaultPos = { blockId: blockData.id, offset: 0 };
27527
27571
  const defaultRange = { anchor: defaultPos, focus: defaultPos };
27528
27572
  return editorInsertBlock(editor, result.containerId, result.blockIndex, blockData, newRange != null ? newRange : defaultRange, insertBlockOptions);
27529
27573
  }
27530
- const editorLeases = /* @__PURE__ */ new WeakMap();
27531
- function getLeaseState(editor) {
27532
- let state = editorLeases.get(editor);
27533
- if (!state) {
27534
- state = { locks: /* @__PURE__ */ new Map(), activeSessions: /* @__PURE__ */ new Set(), known: true };
27535
- editorLeases.set(editor, state);
27536
- }
27537
- return state;
27538
- }
27539
- function initializeWikiMacroLocks(editor) {
27540
- getLeaseState(editor).known = false;
27541
- }
27542
- function updateWikiMacroLocks(editor, locks) {
27543
- const state = getLeaseState(editor);
27544
- state.known = true;
27545
- state.locks.clear();
27546
- locks.forEach((lock) => state.locks.set(lock.blockId, lock));
27547
- }
27548
- function setWikiMacroLockSession(editor, sessionId, active) {
27549
- const state = getLeaseState(editor);
27550
- if (active) {
27551
- state.activeSessions.add(sessionId);
27552
- } else {
27553
- state.activeSessions.delete(sessionId);
27554
- }
27555
- }
27556
- function isWikiMacroBlockLocked(editor, block, macroSessionId) {
27557
- var _a;
27558
- const state = editorLeases.get(editor);
27559
- if (!state || state.known && state.locks.size === 0)
27560
- return false;
27561
- const mayOwnLease = !!macroSessionId && state.activeSessions.has(macroSessionId);
27562
- if (!((_a = block.children) == null ? void 0 : _a.length)) {
27563
- if (block.type !== "embed" || block.embedType !== "ones-open-wiki-macro")
27564
- return false;
27565
- if (!state.known)
27566
- return true;
27567
- const lease = state.locks.get(block.id);
27568
- return !!lease && (!mayOwnLease || lease.sessionId !== macroSessionId);
27569
- }
27570
- const visited = /* @__PURE__ */ new Set();
27571
- const hasLockedDescendant = (data2) => {
27572
- if (visited.has(data2.id))
27573
- return false;
27574
- visited.add(data2.id);
27575
- if (data2.type === "embed" && data2.embedType === "ones-open-wiki-macro") {
27576
- if (!state.known)
27577
- return true;
27578
- const lease = state.locks.get(data2.id);
27579
- if (lease && (!mayOwnLease || lease.sessionId !== macroSessionId))
27580
- return true;
27581
- }
27582
- for (const containerId of data2.children || []) {
27583
- const children = editor.doc.findContainerBlocks(containerId) || [];
27584
- if (children.some(hasLockedDescendant))
27585
- return true;
27586
- }
27587
- return false;
27588
- };
27589
- return hasLockedDescendant(block);
27590
- }
27591
- function isWikiMacroElementLocked(editor, block, macroSessionId) {
27592
- const state = editorLeases.get(editor);
27593
- if (!state || state.known && state.locks.size === 0)
27594
- return false;
27595
- if (isWikiMacroBlockLocked(editor, editor.getBlockData(block), macroSessionId))
27596
- return true;
27597
- return isHeadingBlock$1(block) && isCollapsedHeadingBlock(block) && getHeadingBlockChildren(block).some(
27598
- (child) => isWikiMacroBlockLocked(editor, editor.getBlockData(child), macroSessionId)
27599
- );
27600
- }
27601
- function clearWikiMacroLocks(editor) {
27602
- const state = editorLeases.get(editor);
27603
- state == null ? void 0 : state.locks.clear();
27604
- state == null ? void 0 : state.activeSessions.clear();
27605
- editorLeases.delete(editor);
27606
- }
27607
- const logger$3K = getLogger("delete-block");
27574
+ const logger$3J = getLogger("delete-block");
27608
27575
  function getAllChildContainers(editor, blockData, containerIds) {
27609
27576
  if (blockData.children) {
27610
27577
  blockData.children.forEach((childContainerId) => {
@@ -27613,7 +27580,7 @@ var __publicField = (obj, key, value) => {
27613
27580
  }
27614
27581
  const childBlocks = editor.doc.findContainerBlocks(childContainerId);
27615
27582
  if (!Array.isArray(childBlocks)) {
27616
- logger$3K.warn(`skip invalid child container while deleting: parentBlock=${blockData.id}, container=${childContainerId}`);
27583
+ logger$3J.warn(`skip invalid child container while deleting: parentBlock=${blockData.id}, container=${childContainerId}`);
27617
27584
  return;
27618
27585
  }
27619
27586
  containerIds.add(childContainerId);
@@ -27628,13 +27595,11 @@ var __publicField = (obj, key, value) => {
27628
27595
  const containerId = getContainerId(container);
27629
27596
  const blockIndex = getBlockIndex(block);
27630
27597
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
27631
- assert(logger$3K, blockData, "no block data in doc");
27598
+ assert(logger$3J, blockData, "no block data in doc");
27632
27599
  editor.doc.localDeleteBlock(containerId, blockIndex, createEditorSelectionRange(editor, { anchor: newRange.start, focus: newRange.end }));
27633
27600
  return blockData;
27634
27601
  }
27635
27602
  function editorDeleteBlock(editor, block, newDocRange) {
27636
- if (isWikiMacroElementLocked(editor, block))
27637
- throw new WikiMacroError({ code: "LOCK_CONFLICT" });
27638
27603
  return editor.undoManager.runInGroup(() => {
27639
27604
  const container = getParentContainer(block);
27640
27605
  if (getChildBlockCount(container) === 1) {
@@ -27676,15 +27641,15 @@ var __publicField = (obj, key, value) => {
27676
27641
  });
27677
27642
  editor.doc.localDeleteChildContainers(Array.from(containerIds));
27678
27643
  }
27679
- const logger$3J = getLogger("merge-text-block");
27644
+ const logger$3I = getLogger("merge-text-block");
27680
27645
  function editorMergeTextBlock(editor, block1, block2) {
27681
- assert(logger$3J, isTextKindBlock(editor, block1), "only text block can be merged");
27682
- assert(logger$3J, isTextKindBlock(editor, block2), "only text block can be merged");
27646
+ assert(logger$3I, isTextKindBlock(editor, block1), "only text block can be merged");
27647
+ assert(logger$3I, isTextKindBlock(editor, block2), "only text block can be merged");
27683
27648
  const data1 = editorGetBlockData(editor, block1);
27684
27649
  const data2 = editorGetBlockData(editor, block2);
27685
27650
  const text1 = data1.text;
27686
27651
  const text2 = data2.text;
27687
- assert(logger$3J, text1 && text2, "block data has no text");
27652
+ assert(logger$3I, text1 && text2, "block data has no text");
27688
27653
  const container = getParentContainer(block1);
27689
27654
  const containerId = getContainerId(container);
27690
27655
  const blockIndex = getBlockIndex(block1);
@@ -27694,15 +27659,15 @@ var __publicField = (obj, key, value) => {
27694
27659
  editorDeleteBlock(editor, block2, newRange);
27695
27660
  return block;
27696
27661
  }
27697
- const logger$3I = getLogger("clear-selected-contents");
27662
+ const logger$3H = getLogger("clear-selected-contents");
27698
27663
  function deleteTextBlockSelection(editor, selectedBlock) {
27699
- assert(logger$3I, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
27664
+ assert(logger$3H, isTextKindBlock(editor, selectedBlock.block), "not a text kind block");
27700
27665
  const { start, end } = selectedBlock;
27701
- assert(logger$3I, start.isSimple(), "not a simple block position");
27702
- assert(logger$3I, end.isSimple(), "not a simple block position");
27666
+ assert(logger$3H, start.isSimple(), "not a simple block position");
27667
+ assert(logger$3H, end.isSimple(), "not a simple block position");
27703
27668
  const startOffset = start.offset;
27704
27669
  const endOffset = end.offset;
27705
- assert(logger$3I, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
27670
+ assert(logger$3H, startOffset <= endOffset, `invalid delete text offset: ${startOffset}, ${endOffset}`);
27706
27671
  if (startOffset === endOffset) {
27707
27672
  return;
27708
27673
  }
@@ -27727,7 +27692,7 @@ var __publicField = (obj, key, value) => {
27727
27692
  return;
27728
27693
  }
27729
27694
  if (isEmbedBlock(block) || start.isSimple()) {
27730
- assert(logger$3I, end.isSimple(), "invalid range");
27695
+ assert(logger$3H, end.isSimple(), "invalid range");
27731
27696
  const container = getParentContainer(block);
27732
27697
  const blockIndex = getBlockIndex(block);
27733
27698
  const newBlock = editor.insertTextBlock("", getContainerId(container), blockIndex);
@@ -27735,8 +27700,8 @@ var __publicField = (obj, key, value) => {
27735
27700
  editor.deleteBlock(block);
27736
27701
  return;
27737
27702
  }
27738
- assert(logger$3I, isComplexKindBlock(editor, block), "invalid block kind");
27739
- assert(logger$3I, !start.isSimple() && !end.isSimple(), "invalid range");
27703
+ assert(logger$3H, isComplexKindBlock(editor, block), "invalid block kind");
27704
+ assert(logger$3H, !start.isSimple() && !end.isSimple(), "invalid range");
27740
27705
  complexBlockGetSelectedContainers(editor, block, start, end);
27741
27706
  const containers = editor.selection.range.getSelectedContainers();
27742
27707
  containers.forEach((container, index2) => {
@@ -27753,7 +27718,7 @@ var __publicField = (obj, key, value) => {
27753
27718
  return;
27754
27719
  }
27755
27720
  const selectedBlocks = range.getSelectedBlocks();
27756
- assert(logger$3I, selectedBlocks.length > 0, "no selected block");
27721
+ assert(logger$3H, selectedBlocks.length > 0, "no selected block");
27757
27722
  if (selectedBlocks.length === 1) {
27758
27723
  clearOneBlock(editor, selectedBlocks[0]);
27759
27724
  return;
@@ -27761,7 +27726,7 @@ var __publicField = (obj, key, value) => {
27761
27726
  const firstSelectedBlock = selectedBlocks[0];
27762
27727
  const firstBlock = firstSelectedBlock.block;
27763
27728
  const container = getParentContainer(firstBlock);
27764
- assert(logger$3I, selectedBlocks.length > 1, "no selected block");
27729
+ assert(logger$3H, selectedBlocks.length > 1, "no selected block");
27765
27730
  const lastSelectedBlock = selectedBlocks[selectedBlocks.length - 1];
27766
27731
  const lastBlock2 = lastSelectedBlock.block;
27767
27732
  if (isTextKindBlock(editor, firstBlock)) {
@@ -27791,7 +27756,7 @@ var __publicField = (obj, key, value) => {
27791
27756
  }
27792
27757
  const prevBlock = getPrevBlock(firstBlock);
27793
27758
  const nextBlock = getNextBlock(lastBlock2);
27794
- assert(logger$3I, prevBlock || nextBlock, "no prev or next block");
27759
+ assert(logger$3H, prevBlock || nextBlock, "no prev or next block");
27795
27760
  selectedBlocks.forEach((selectedBlock) => editor.deleteBlock(selectedBlock.block));
27796
27761
  }
27797
27762
  function editorClearSelectedContents(editor, selectionRange) {
@@ -27810,7 +27775,7 @@ var __publicField = (obj, key, value) => {
27810
27775
  editor.emit("afterClearSelection", editor);
27811
27776
  });
27812
27777
  }
27813
- const logger$3H = getLogger("core");
27778
+ const logger$3G = getLogger("core");
27814
27779
  function editorUpdateBlockText(editor, block, ops, options) {
27815
27780
  const container = getParentContainer(block);
27816
27781
  const containerId = getContainerId(container);
@@ -27823,7 +27788,7 @@ var __publicField = (obj, key, value) => {
27823
27788
  }
27824
27789
  function editorSetBlockText(editor, block, newText, options) {
27825
27790
  if (!editor.isBlockWritable(block)) {
27826
- logger$3H.error("block is not writable");
27791
+ logger$3G.error("block is not writable");
27827
27792
  return;
27828
27793
  }
27829
27794
  const oldText = editor.getBlockText(block);
@@ -27836,7 +27801,7 @@ var __publicField = (obj, key, value) => {
27836
27801
  const ops = RichText.diff(oldText, newText);
27837
27802
  return editorUpdateBlockText(editor, block, ops);
27838
27803
  }
27839
- const logger$3G = getLogger("update-block-data");
27804
+ const logger$3F = getLogger("update-block-data");
27840
27805
  function editorUpdateBlockData(editor, block, data2, newRange, options) {
27841
27806
  const container = getParentContainer(block);
27842
27807
  const containerId = getContainerId(container);
@@ -27853,17 +27818,17 @@ var __publicField = (obj, key, value) => {
27853
27818
  if (oldKey === "id" || oldKey === "type" || oldKey === "text") {
27854
27819
  return;
27855
27820
  }
27856
- logger$3G.debug(`delete key: ${oldKey}`);
27821
+ logger$3F.debug(`delete key: ${oldKey}`);
27857
27822
  delta.delete.push(oldKey);
27858
27823
  }
27859
27824
  });
27860
27825
  const entries = Object.entries(data2);
27861
27826
  entries.forEach(([key, value]) => {
27862
- assert(logger$3G, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
27827
+ assert(logger$3F, key !== "id" && key !== "type", `invalid block data delta, ${key}`);
27863
27828
  const oldValue = oldData[key];
27864
27829
  if (value === null || value === void 0) {
27865
27830
  if (oldValue !== null && oldValue !== void 0) {
27866
- logger$3G.debug(`delete key: ${key}`);
27831
+ logger$3F.debug(`delete key: ${key}`);
27867
27832
  delta.delete.push(key);
27868
27833
  }
27869
27834
  return;
@@ -27881,10 +27846,10 @@ var __publicField = (obj, key, value) => {
27881
27846
  }
27882
27847
  }
27883
27848
  if (oldKeys.has(key)) {
27884
- logger$3G.debug(`replace key: ${key}`);
27849
+ logger$3F.debug(`replace key: ${key}`);
27885
27850
  delta.delete.push(key);
27886
27851
  } else {
27887
- logger$3G.debug(`insert key: ${key}`);
27852
+ logger$3F.debug(`insert key: ${key}`);
27888
27853
  }
27889
27854
  delta.insert[key] = value;
27890
27855
  });
@@ -27929,13 +27894,13 @@ var __publicField = (obj, key, value) => {
27929
27894
  comments: {}
27930
27895
  };
27931
27896
  }
27932
- const logger$3F = getLogger("clone-block");
27897
+ const logger$3E = getLogger("clone-block");
27933
27898
  function cloneBlock(editorBlocks, oldDoc, data2, info) {
27934
27899
  var _a;
27935
27900
  const blockClass = editorBlocks.getBlockClass(data2.type);
27936
27901
  if (blockClass.blockToDoc) {
27937
27902
  return blockClass.blockToDoc(oldDoc, data2, (oldDoc2, childBlock) => {
27938
- assert(logger$3F, data2 !== childBlock, "invalid child block");
27903
+ assert(logger$3E, data2 !== childBlock, "invalid child block");
27939
27904
  return cloneBlock(editorBlocks, oldDoc2, data2, info);
27940
27905
  }, info);
27941
27906
  }
@@ -27948,7 +27913,7 @@ var __publicField = (obj, key, value) => {
27948
27913
  }
27949
27914
  const newChildContainerId = genId();
27950
27915
  const childBlocks = oldDoc.blocks[oldChildContainerId];
27951
- assert(logger$3F, Array.isArray(childBlocks), "invalid child blocks");
27916
+ assert(logger$3E, Array.isArray(childBlocks), "invalid child blocks");
27952
27917
  const newDocs = childBlocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
27953
27918
  const newDoc = mergeDocs(newDocs);
27954
27919
  const { root: root2, ...childContainersData } = newDoc.blocks;
@@ -27977,7 +27942,7 @@ var __publicField = (obj, key, value) => {
27977
27942
  if (key.startsWith(prefix1)) {
27978
27943
  const keyContent = key.substring(prefix1.length);
27979
27944
  const newKey = `${newContainerId}/${keyContent}`;
27980
- logger$3F.debug(`replace key: ${key} -> ${newKey}`);
27945
+ logger$3E.debug(`replace key: ${key} -> ${newKey}`);
27981
27946
  return newKey;
27982
27947
  }
27983
27948
  }
@@ -27986,7 +27951,7 @@ var __publicField = (obj, key, value) => {
27986
27951
  if (key.startsWith(prefix2)) {
27987
27952
  const keyContent = key.substring(prefix2.length);
27988
27953
  const newKey = `${newContainerId}_${keyContent}`;
27989
- logger$3F.debug(`replace key: ${key} -> ${newKey}`);
27954
+ logger$3E.debug(`replace key: ${key} -> ${newKey}`);
27990
27955
  return newKey;
27991
27956
  }
27992
27957
  }
@@ -28001,9 +27966,6 @@ var __publicField = (obj, key, value) => {
28001
27966
  blockData[newKey] = value;
28002
27967
  });
28003
27968
  blockData.id = genId();
28004
- if (blockData.type === "embed" && blockData.embedType === "ones-open-wiki-macro") {
28005
- blockData.macroRevision = 1;
28006
- }
28007
27969
  if (info) {
28008
27970
  info.blockIdMap.set(data2.id, blockData.id);
28009
27971
  childContainerIdMap.forEach((newId, oldId) => info.containerIdMap.set(oldId, newId));
@@ -28019,7 +27981,7 @@ var __publicField = (obj, key, value) => {
28019
27981
  }
28020
27982
  function cloneChildContainer(editorBlocks, oldDoc, containerId, info) {
28021
27983
  const blocks = oldDoc.blocks[containerId];
28022
- assert(logger$3F, Array.isArray(blocks), "invalid child blocks");
27984
+ assert(logger$3E, Array.isArray(blocks), "invalid child blocks");
28023
27985
  const newDocs = blocks.map((c) => cloneBlock(editorBlocks, oldDoc, c, info));
28024
27986
  const newDoc = mergeDocs(newDocs);
28025
27987
  return newDoc;
@@ -28028,11 +27990,11 @@ var __publicField = (obj, key, value) => {
28028
27990
  const docs = doc2.blocks.root.map((b) => cloneBlock(editor.editorBlocks, doc2, b, info));
28029
27991
  return cloneDeep__default.default(mergeDocs(docs));
28030
27992
  }
28031
- const logger$3E = getLogger("insert-doc");
27993
+ const logger$3D = getLogger("insert-doc");
28032
27994
  function editorInsertDoc(editor, block, offset, insertedDoc, cloneDocResult) {
28033
27995
  var _a;
28034
27996
  if (isComplexKindBlock(editor, block)) {
28035
- logger$3E.warn("failed to insert doc into a complex block");
27997
+ logger$3D.warn("failed to insert doc into a complex block");
28036
27998
  return;
28037
27999
  }
28038
28000
  const doc2 = cloneDoc(editor, insertedDoc, cloneDocResult);
@@ -28070,7 +28032,7 @@ var __publicField = (obj, key, value) => {
28070
28032
  }
28071
28033
  return;
28072
28034
  }
28073
- assert(logger$3E, isTextKindBlock(editor, block), "not a text block");
28035
+ assert(logger$3D, isTextKindBlock(editor, block), "not a text block");
28074
28036
  if (isEmptyTextBlock(editor, block)) {
28075
28037
  const blockIndex2 = getBlockIndex(block);
28076
28038
  let lastBlock22;
@@ -28202,11 +28164,11 @@ var __publicField = (obj, key, value) => {
28202
28164
  editor.deleteBlock(block);
28203
28165
  }
28204
28166
  }
28205
- const logger$3D = getLogger("add-text-attribute");
28167
+ const logger$3C = getLogger("add-text-attribute");
28206
28168
  function editorRemoveTextAttribute(editor, block, range, attributeName) {
28207
28169
  const { start, end } = range;
28208
- assert(logger$3D, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
28209
- assert(logger$3D, attributeName, "invalid attribute name");
28170
+ assert(logger$3C, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
28171
+ assert(logger$3C, attributeName, "invalid attribute name");
28210
28172
  const oldText = editor.getBlockText(block);
28211
28173
  const newText = rangeRemoveAttribute(start.offset, end.offset - start.offset, oldText, attributeName, void 0, { ignoreValue: true });
28212
28174
  editor.setBlockText(block, newText);
@@ -28214,8 +28176,8 @@ var __publicField = (obj, key, value) => {
28214
28176
  }
28215
28177
  function editorAddTextAttribute(editor, block, range, attributeName, value) {
28216
28178
  const { start, end } = range;
28217
- assert(logger$3D, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
28218
- assert(logger$3D, attributeName, "invalid attribute name");
28179
+ assert(logger$3C, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
28180
+ assert(logger$3C, attributeName, "invalid attribute name");
28219
28181
  const oldText = editor.getBlockText(block);
28220
28182
  const newText = rangeAddAttribute(start.offset, end.offset - start.offset, oldText, attributeName, value);
28221
28183
  editor.setBlockText(block, newText);
@@ -28223,7 +28185,7 @@ var __publicField = (obj, key, value) => {
28223
28185
  }
28224
28186
  function editorSetTextColor(editor, block, range, type, value) {
28225
28187
  const { start, end } = range;
28226
- assert(logger$3D, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
28188
+ assert(logger$3C, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
28227
28189
  const oldText = editor.getBlockText(block);
28228
28190
  const newText = rangeSetTextColor(start.offset, end.offset - start.offset, oldText, type, value);
28229
28191
  editor.setBlockText(block, newText);
@@ -28312,10 +28274,10 @@ var __publicField = (obj, key, value) => {
28312
28274
  });
28313
28275
  return [color, backgroundColor];
28314
28276
  }
28315
- const logger$3C = getLogger("move-complex-block-position");
28277
+ const logger$3B = getLogger("move-complex-block-position");
28316
28278
  function moveComplexBlockPosition(editor, old, type) {
28317
28279
  const block = editor.getBlockById(old.blockId);
28318
- assert(logger$3C, isComplexKindBlock(editor, block), "is not a complex block");
28280
+ assert(logger$3B, isComplexKindBlock(editor, block), "is not a complex block");
28319
28281
  const blockClass = getComplexBlockClass(editor, block);
28320
28282
  const focusedContainer = editor.getContainerById(old.childContainerId);
28321
28283
  const nextContainer = blockClass.getNextContainer(editor, block, focusedContainer, type, { noWrap: true });
@@ -28324,24 +28286,24 @@ var __publicField = (obj, key, value) => {
28324
28286
  }
28325
28287
  return createComplexBlockPosition(block, getContainerId(nextContainer));
28326
28288
  }
28327
- const logger$3B = getLogger("move-simple-block-position");
28289
+ const logger$3A = getLogger("move-simple-block-position");
28328
28290
  function getFirstChildBlockInComplexBlock(editor, complexBlock) {
28329
28291
  const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
28330
28292
  if (containers.length === 0) {
28331
- logger$3B.warn("complex block has not any child container, not loaded?");
28293
+ logger$3A.warn("complex block has not any child container, not loaded?");
28332
28294
  return null;
28333
28295
  }
28334
- assert(logger$3B, containers.length > 0, "complex block has not any child container");
28296
+ assert(logger$3A, containers.length > 0, "complex block has not any child container");
28335
28297
  const container = containers[0];
28336
28298
  return getFirstChildBlock(container);
28337
28299
  }
28338
28300
  function getLastChildBlockInComplexBlock(editor, complexBlock) {
28339
28301
  const containers = complexBlockGetAllChildContainers(editor, complexBlock, { visibleOnly: true });
28340
28302
  if (containers.length === 0) {
28341
- logger$3B.warn("complex block has not any child container, not loaded?");
28303
+ logger$3A.warn("complex block has not any child container, not loaded?");
28342
28304
  return null;
28343
28305
  }
28344
- assert(logger$3B, containers.length > 0, "complex block has not any child container");
28306
+ assert(logger$3A, containers.length > 0, "complex block has not any child container");
28345
28307
  const container = containers[containers.length - 1];
28346
28308
  return getLastChildBlock(container);
28347
28309
  }
@@ -28386,8 +28348,8 @@ var __publicField = (obj, key, value) => {
28386
28348
  return null;
28387
28349
  }
28388
28350
  const parentComplexBlock = getParentBlock(container);
28389
- assert(logger$3B, parentComplexBlock, "child container has not parent block");
28390
- assert(logger$3B, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
28351
+ assert(logger$3A, parentComplexBlock, "child container has not parent block");
28352
+ assert(logger$3A, isComplexKindBlock(editor, parentComplexBlock), "is not a complex block");
28391
28353
  const nextContainer = getComplexBlockClass(editor, parentComplexBlock).getNextContainer(editor, parentComplexBlock, container, type);
28392
28354
  if (nextContainer) {
28393
28355
  if (isFindPrev(type)) {
@@ -28409,7 +28371,7 @@ var __publicField = (obj, key, value) => {
28409
28371
  return null;
28410
28372
  }
28411
28373
  const parentBlock = getParentBlock(container);
28412
- assert(logger$3B, parentBlock, "child container has not parent block");
28374
+ assert(logger$3A, parentBlock, "child container has not parent block");
28413
28375
  if (isFindPrev(type)) {
28414
28376
  const prev = getPrevBlock(parentBlock);
28415
28377
  if (prev) {
@@ -28464,7 +28426,7 @@ var __publicField = (obj, key, value) => {
28464
28426
  }
28465
28427
  if (!targetBlock) {
28466
28428
  if (isComplexKindBlock(editor, block) && complexBlockGetAllChildContainers(editor, block).length === 0) {
28467
- logger$3B.warn("complex block has not any child container, not loaded?");
28429
+ logger$3A.warn("complex block has not any child container, not loaded?");
28468
28430
  targetBlock = direction === "ArrowDown" || direction === "ArrowRight" ? getNextVisibleBlock(block) : getPrevVisibleBlock(block);
28469
28431
  }
28470
28432
  }
@@ -28611,10 +28573,10 @@ var __publicField = (obj, key, value) => {
28611
28573
  editorAdjustSelection(editor, "ArrowUp", "select");
28612
28574
  return true;
28613
28575
  }
28614
- const logger$3A = getLogger("word-offset");
28576
+ const logger$3z = getLogger("word-offset");
28615
28577
  function editorGetWordLeftPos(editor, type) {
28616
28578
  const old = editor.selection.range.focus;
28617
- assert(logger$3A, old.isSimple(), "invalid range type");
28579
+ assert(logger$3z, old.isSimple(), "invalid range type");
28618
28580
  const block = editor.getBlockById(old.blockId);
28619
28581
  if (isEmptyTextBlock(editor, block)) {
28620
28582
  return createSimpleBlockPosition(block, 0, "home");
@@ -28639,7 +28601,7 @@ var __publicField = (obj, key, value) => {
28639
28601
  }
28640
28602
  function editorGetWordRightPos(editor, type) {
28641
28603
  const old = editor.selection.range.focus;
28642
- assert(logger$3A, old.isSimple(), "invalid range type");
28604
+ assert(logger$3z, old.isSimple(), "invalid range type");
28643
28605
  const block = editor.getBlockById(old.blockId);
28644
28606
  if (isEmptyTextBlock(editor, block)) {
28645
28607
  return createSimpleBlockPosition(block, 0, "end");
@@ -28751,10 +28713,10 @@ var __publicField = (obj, key, value) => {
28751
28713
  editor.selection.setSelection(editor.selection.getAnchorPos(), pos);
28752
28714
  return true;
28753
28715
  }
28754
- const logger$3z = getLogger("line-offset");
28716
+ const logger$3y = getLogger("line-offset");
28755
28717
  function editorGetLineHomePos(editor) {
28756
28718
  const old = editor.selection.range.focus;
28757
- assert(logger$3z, old.isSimple(), "invalid range type");
28719
+ assert(logger$3y, old.isSimple(), "invalid range type");
28758
28720
  const block = editor.getBlockById(old.blockId);
28759
28721
  if (old.offset === 0 || !isTextKindBlock(editor, block)) {
28760
28722
  const newPos2 = createSimpleBlockPosition(block, 0, "home");
@@ -28771,7 +28733,7 @@ var __publicField = (obj, key, value) => {
28771
28733
  }
28772
28734
  function editorGetLineEndPos(editor) {
28773
28735
  const old = editor.selection.range.focus;
28774
- assert(logger$3z, old.isSimple(), "invalid range type");
28736
+ assert(logger$3y, old.isSimple(), "invalid range type");
28775
28737
  const block = editor.getBlockById(old.blockId);
28776
28738
  if (old.offset === getBlockTextLength$6(editor, block) || !isTextKindBlock(editor, block)) {
28777
28739
  const newPos2 = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
@@ -28871,7 +28833,7 @@ var __publicField = (obj, key, value) => {
28871
28833
  editorPageDownScroll(editor);
28872
28834
  return true;
28873
28835
  }
28874
- const logger$3y = getLogger("table-scroll");
28836
+ const logger$3x = getLogger("table-scroll");
28875
28837
  class DomEventHandler {
28876
28838
  constructor(editor, dom, name, handler, data2, options) {
28877
28839
  __publicField(this, "handleEvent", (event) => {
@@ -28903,7 +28865,7 @@ var __publicField = (obj, key, value) => {
28903
28865
  const existsHandlers = this.handlers.get(element);
28904
28866
  if (existsHandlers) {
28905
28867
  if (existsHandlers.find((handler) => handler.handler === eventHandler && handler.name === eventName)) {
28906
- logger$3y.warn(`event has already registered: ${eventName}`);
28868
+ logger$3x.warn(`event has already registered: ${eventName}`);
28907
28869
  return;
28908
28870
  }
28909
28871
  existsHandlers.push(new DomEventHandler(this.editor, element, eventName, eventHandler, data2, options));
@@ -29013,7 +28975,7 @@ var __publicField = (obj, key, value) => {
29013
28975
  });
29014
28976
  return true;
29015
28977
  }
29016
- const logger$3x = getLogger("select-all");
28978
+ const logger$3w = getLogger("select-all");
29017
28979
  function isContainerSelectedAllChildBlocks(container, range) {
29018
28980
  const firstBlock = getFirstChildBlock(container);
29019
28981
  const lastBlock2 = getLastChildBlock(container);
@@ -29028,8 +28990,8 @@ var __publicField = (obj, key, value) => {
29028
28990
  return range.start.blockId === blockId && range.start.childContainerId === getContainerId(first) && range.end.blockId === blockId && range.end.childContainerId === getContainerId(last);
29029
28991
  }
29030
28992
  function selectComplexBlock(editor, block) {
29031
- assert(logger$3x, block, "no parent block");
29032
- assert(logger$3x, isComplexKindBlock(editor, block), "not a complex block");
28993
+ assert(logger$3w, block, "no parent block");
28994
+ assert(logger$3w, isComplexKindBlock(editor, block), "not a complex block");
29033
28995
  const containers = getComplexBlockClass(editor, block).getChildContainers(editor, block);
29034
28996
  const first = containers[0];
29035
28997
  const last = containers[containers.length - 1];
@@ -29065,13 +29027,13 @@ var __publicField = (obj, key, value) => {
29065
29027
  selectParentContainer(editor, getFirstChildBlock(editor.rootContainer));
29066
29028
  return false;
29067
29029
  }
29068
- assert(logger$3x, !range.isSimple(), "invalid range type");
29030
+ assert(logger$3w, !range.isSimple(), "invalid range type");
29069
29031
  if (isComplexBlockSelectedAllChildContainer(focusedBlock, range)) {
29070
29032
  selectParentContainer(editor, focusedBlock);
29071
29033
  return false;
29072
29034
  }
29073
- assert(logger$3x, focusedBlock, "no parent block");
29074
- assert(logger$3x, isComplexKindBlock(editor, focusedBlock), "not a complex block");
29035
+ assert(logger$3w, focusedBlock, "no parent block");
29036
+ assert(logger$3w, isComplexKindBlock(editor, focusedBlock), "not a complex block");
29075
29037
  selectComplexBlock(editor, focusedBlock);
29076
29038
  return true;
29077
29039
  }
@@ -29219,7 +29181,7 @@ var __publicField = (obj, key, value) => {
29219
29181
  }
29220
29182
  return cloned;
29221
29183
  }
29222
- const logger$3w = getLogger("selected-block-to-doc");
29184
+ const logger$3v = getLogger("selected-block-to-doc");
29223
29185
  function appendBlockChildren(editor, data2, doc2) {
29224
29186
  if (!data2.children)
29225
29187
  return;
@@ -29240,7 +29202,7 @@ var __publicField = (obj, key, value) => {
29240
29202
  if (isTextKindBlock(editor, selectedBlock.block)) {
29241
29203
  const start = selectedBlock.start;
29242
29204
  const end = selectedBlock.end;
29243
- assert(logger$3w, data2.text, "no block text");
29205
+ assert(logger$3v, data2.text, "no block text");
29244
29206
  if (start.offset === end.offset) {
29245
29207
  return {
29246
29208
  blocks: {
@@ -29274,8 +29236,8 @@ var __publicField = (obj, key, value) => {
29274
29236
  comments: {}
29275
29237
  };
29276
29238
  }
29277
- assert(logger$3w, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
29278
- assert(logger$3w, data2.children, "no children");
29239
+ assert(logger$3v, isComplexKindBlock(editor, selectedBlock.block), "not complex block");
29240
+ assert(logger$3v, data2.children, "no children");
29279
29241
  const ret = {
29280
29242
  blocks: {
29281
29243
  root: [
@@ -29293,9 +29255,9 @@ var __publicField = (obj, key, value) => {
29293
29255
  const end = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
29294
29256
  return selectedBlockToDoc(editor, { block, start, end });
29295
29257
  }
29296
- const logger$3v = getLogger("block-to-doc");
29258
+ const logger$3u = getLogger("block-to-doc");
29297
29259
  function blocksToDoc(editor, blocks) {
29298
- assert(logger$3v, blocks.length > 0, "invalid params, no blocks");
29260
+ assert(logger$3u, blocks.length > 0, "invalid params, no blocks");
29299
29261
  const docs = blocks.map((b) => blockToDoc(editor, b));
29300
29262
  return mergeDocs(docs);
29301
29263
  }
@@ -29320,7 +29282,7 @@ var __publicField = (obj, key, value) => {
29320
29282
  const newDocs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s));
29321
29283
  return mergeDocs(newDocs);
29322
29284
  }
29323
- const logger$3u = getLogger("ensure-block-visible");
29285
+ const logger$3t = getLogger("ensure-block-visible");
29324
29286
  function ensureBlockVisible(editor, block) {
29325
29287
  var _a;
29326
29288
  while (block) {
@@ -29330,16 +29292,16 @@ var __publicField = (obj, key, value) => {
29330
29292
  return;
29331
29293
  }
29332
29294
  const parentComplexBlock = getParentBlock(container);
29333
- assert(logger$3u, parentComplexBlock, "no parent block");
29295
+ assert(logger$3t, parentComplexBlock, "no parent block");
29334
29296
  const parentComplexBlockClass = getBlockClass(editor, parentComplexBlock);
29335
29297
  if (parentComplexBlockClass.isChildContainerVisible && !((_a = parentComplexBlockClass.isChildContainerVisible) == null ? void 0 : _a.call(parentComplexBlockClass, editor, parentComplexBlock, container))) {
29336
- assert(logger$3u, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
29298
+ assert(logger$3t, parentComplexBlockClass.showChildContainer, "no showChildContainer method");
29337
29299
  parentComplexBlockClass.showChildContainer(editor, parentComplexBlock, container);
29338
29300
  }
29339
29301
  block = parentComplexBlock;
29340
29302
  }
29341
29303
  }
29342
- const logger$3t = getLogger("editor-selection");
29304
+ const logger$3s = getLogger("editor-selection");
29343
29305
  class EditorSelection {
29344
29306
  constructor(editor) {
29345
29307
  __publicField(this, "editor");
@@ -29352,7 +29314,7 @@ var __publicField = (obj, key, value) => {
29352
29314
  }
29353
29315
  const range = this.range;
29354
29316
  if (rangeInBlock(deletedBlock, range)) {
29355
- logger$3t.debug("adjust selection because remote deleted current block");
29317
+ logger$3s.debug("adjust selection because remote deleted current block");
29356
29318
  const newRange = moveSelectionBeforeDeleteBlock(editor, deletedBlock);
29357
29319
  this.setRange(newRange, { noScroll: true, local: false });
29358
29320
  }
@@ -29492,14 +29454,14 @@ var __publicField = (obj, key, value) => {
29492
29454
  if (pos.isSimple()) {
29493
29455
  const ok = pos.offset >= 0 && pos.offset <= getBlockTextLength$6(this.editor, block);
29494
29456
  if (!ok) {
29495
- assert(logger$3t, false, "invalid block position, out of range");
29457
+ assert(logger$3s, false, "invalid block position, out of range");
29496
29458
  }
29497
29459
  } else {
29498
29460
  const childContainerId = pos.childContainerId;
29499
29461
  const container = this.editor.getContainerById(childContainerId);
29500
29462
  const ok = !!container;
29501
29463
  if (!ok) {
29502
- assert(logger$3t, false, "invalid complex block position, no container found");
29464
+ assert(logger$3s, false, "invalid complex block position, no container found");
29503
29465
  }
29504
29466
  }
29505
29467
  }
@@ -29560,7 +29522,7 @@ var __publicField = (obj, key, value) => {
29560
29522
  let container = getParentContainer(block);
29561
29523
  while (isChildContainer(container)) {
29562
29524
  const parentBlock = getParentBlock(container);
29563
- assert(logger$3t, parentBlock, "parent block not found");
29525
+ assert(logger$3s, parentBlock, "parent block not found");
29564
29526
  addClass(parentBlock, "child-focused");
29565
29527
  container = getParentContainer(parentBlock);
29566
29528
  }
@@ -29678,15 +29640,15 @@ var __publicField = (obj, key, value) => {
29678
29640
  editor.undoManager.redo();
29679
29641
  return true;
29680
29642
  }
29681
- const logger$3s = getLogger("delete-text");
29643
+ const logger$3r = getLogger("delete-text");
29682
29644
  function editorDeleteText(editor, type, count, insertPos) {
29683
29645
  const pos = insertPos != null ? insertPos : editor.selection.range.start;
29684
29646
  if (!(pos instanceof EditorSimpleBlockPosition)) {
29685
- assert(logger$3s, false, `invalid insert pos type: ${typeof pos}`);
29647
+ assert(logger$3r, false, `invalid insert pos type: ${typeof pos}`);
29686
29648
  }
29687
29649
  const { blockId } = pos;
29688
29650
  const block = editor.getBlockById(blockId);
29689
- assert(logger$3s, isTextKindBlock(editor, block), "block is not a text kind block");
29651
+ assert(logger$3r, isTextKindBlock(editor, block), "block is not a text kind block");
29690
29652
  let { offset } = pos;
29691
29653
  if (type === "backward") {
29692
29654
  if (offset - count < 0) {
@@ -29716,7 +29678,7 @@ var __publicField = (obj, key, value) => {
29716
29678
  }
29717
29679
  return false;
29718
29680
  }
29719
- const logger$3r = getLogger("handle-backspace");
29681
+ const logger$3q = getLogger("handle-backspace");
29720
29682
  function tryDeleteEmptyBlock(editor, block) {
29721
29683
  if (!isEmptyTextBlock(editor, block)) {
29722
29684
  return;
@@ -29756,7 +29718,7 @@ var __publicField = (obj, key, value) => {
29756
29718
  }
29757
29719
  } else {
29758
29720
  tryDeleteEmptyBlock(editor, block);
29759
- assert(logger$3r, isEmbedBlock(prevBlock), "prev block is not embed block");
29721
+ assert(logger$3q, isEmbedBlock(prevBlock), "prev block is not embed block");
29760
29722
  editor.selection.selectBlock(prevBlock, 1);
29761
29723
  }
29762
29724
  } else {
@@ -29790,7 +29752,7 @@ var __publicField = (obj, key, value) => {
29790
29752
  editor.deleteBlock(block);
29791
29753
  }
29792
29754
  }
29793
- const logger$3q = getLogger("word-offset");
29755
+ const logger$3p = getLogger("word-offset");
29794
29756
  function handleEditorDelete(editor, event) {
29795
29757
  if (!editor.selection.range.isCollapsed()) {
29796
29758
  editor.clearSelectedContents();
@@ -29827,7 +29789,7 @@ var __publicField = (obj, key, value) => {
29827
29789
  }
29828
29790
  function handleEditorDeleteLeftWord(editor, event) {
29829
29791
  const old = editor.selection.range.focus;
29830
- assert(logger$3q, old.isSimple(), "invalid range type");
29792
+ assert(logger$3p, old.isSimple(), "invalid range type");
29831
29793
  const block = editor.getBlockById(old.blockId);
29832
29794
  if (!isTextKindBlock(editor, block)) {
29833
29795
  editor.deleteBlock(block);
@@ -29869,7 +29831,7 @@ var __publicField = (obj, key, value) => {
29869
29831
  }
29870
29832
  function handleEditorDeleteRightWord(editor, event) {
29871
29833
  const old = editor.selection.range.focus;
29872
- assert(logger$3q, old.isSimple(), "invalid range type");
29834
+ assert(logger$3p, old.isSimple(), "invalid range type");
29873
29835
  const block = editor.getBlockById(old.blockId);
29874
29836
  if (!isTextKindBlock(editor, block)) {
29875
29837
  editor.deleteBlock(block);
@@ -29910,7 +29872,7 @@ var __publicField = (obj, key, value) => {
29910
29872
  }
29911
29873
  function handleEditorDeleteAfterWords(editor) {
29912
29874
  const old = editor.selection.range.focus;
29913
- assert(logger$3q, old.isSimple(), "invalid range type");
29875
+ assert(logger$3p, old.isSimple(), "invalid range type");
29914
29876
  const block = editor.getBlockById(old.blockId);
29915
29877
  if (!isTextKindBlock(editor, block)) {
29916
29878
  editor.deleteBlock(block);
@@ -29923,7 +29885,7 @@ var __publicField = (obj, key, value) => {
29923
29885
  }
29924
29886
  function handleEditorDeleteRightChar(editor) {
29925
29887
  const old = editor.selection.range.focus;
29926
- assert(logger$3q, old.isSimple(), "invalid range type");
29888
+ assert(logger$3p, old.isSimple(), "invalid range type");
29927
29889
  const block = editor.getBlockById(old.blockId);
29928
29890
  if (!isTextKindBlock(editor, block)) {
29929
29891
  editor.deleteBlock(block);
@@ -29994,59 +29956,13 @@ var __publicField = (obj, key, value) => {
29994
29956
  });
29995
29957
  return true;
29996
29958
  }
29997
- const editorHooks = /* @__PURE__ */ new WeakMap();
29998
- function registerDocResourceHook(editor, hook) {
29999
- if (editor.destroyed) {
30000
- throw new Error("Cannot register a document resource hook on a destroyed editor");
30001
- }
30002
- const registration = { hook, collect: hook.collect, rewrite: hook.rewrite };
30003
- let hooks = editorHooks.get(editor);
30004
- if (!hooks) {
30005
- hooks = /* @__PURE__ */ new Set();
30006
- editorHooks.set(editor, hooks);
30007
- }
30008
- const registrations = hooks;
30009
- registrations.add(registration);
30010
- return () => {
30011
- if (!registrations.delete(registration)) {
30012
- return;
30013
- }
30014
- if (registrations.size === 0 && editorHooks.get(editor) === registrations) {
30015
- editorHooks.delete(editor);
30016
- }
30017
- };
30018
- }
30019
- function collectDocResourceHooks(editor, doc2, resources) {
30020
- const hooks = editorHooks.get(editor);
30021
- if (!hooks) {
30022
- return;
30023
- }
30024
- for (const registration of hooks) {
30025
- const ids = registration.collect.call(registration.hook, doc2);
30026
- for (const id of ids) {
30027
- resources.add(id);
30028
- }
30029
- }
30030
- }
30031
- function rewriteDocResourceHooks(editor, doc2, resources) {
30032
- const hooks = editorHooks.get(editor);
30033
- if (!hooks) {
30034
- return;
30035
- }
30036
- for (const registration of hooks) {
30037
- registration.rewrite.call(registration.hook, doc2, resources);
30038
- }
30039
- }
30040
- function clearDocResourceHooks(editor) {
30041
- const hooks = editorHooks.get(editor);
30042
- if (hooks) {
30043
- hooks.clear();
30044
- editorHooks.delete(editor);
30045
- }
30046
- }
30047
29959
  function defaultGetResourceFromBlock(editor, doc2, block, resources) {
30048
29960
  if (block.type === "embed") {
30049
29961
  const embedData = block.embedData;
29962
+ if (block.embedType === WIKI_MACRO_TYPE) {
29963
+ getWikiMacroResources(embedData).forEach((resource) => resources.add(resource));
29964
+ return;
29965
+ }
30050
29966
  const src = embedData.src;
30051
29967
  if (src && typeof src === "string") {
30052
29968
  for (const item of src.split("|")) {
@@ -30118,7 +30034,6 @@ var __publicField = (obj, key, value) => {
30118
30034
  defaultGetResourceFromBlock(editor, doc2, block, resources);
30119
30035
  }
30120
30036
  });
30121
- collectDocResourceHooks(editor, doc2, resources);
30122
30037
  return Array.from(resources);
30123
30038
  }
30124
30039
  function injectDocToHtmlFragment(htmlFragment, doc2) {
@@ -30202,7 +30117,7 @@ var __publicField = (obj, key, value) => {
30202
30117
  const doc2 = blockToDoc(editor, block);
30203
30118
  editorCopyDoc(editor, doc2);
30204
30119
  }
30205
- const logger$3p = getLogger("input-handler-actions");
30120
+ const logger$3o = getLogger("input-handler-actions");
30206
30121
  function editorHandleEnter(editor, event) {
30207
30122
  if (editor.readonly || !editor.isWritable()) {
30208
30123
  return false;
@@ -30284,7 +30199,7 @@ var __publicField = (obj, key, value) => {
30284
30199
  toPlainText: true
30285
30200
  });
30286
30201
  }).catch((err) => {
30287
- logger$3p.error(err);
30202
+ logger$3o.error(err);
30288
30203
  });
30289
30204
  return true;
30290
30205
  }
@@ -30434,6 +30349,10 @@ ${codeText}
30434
30349
  function defaultReplaceBlockResources(doc2, block, resources) {
30435
30350
  if (block.type === "embed") {
30436
30351
  const embedData = block.embedData;
30352
+ if (block.embedType === WIKI_MACRO_TYPE) {
30353
+ replaceWikiMacroResources(embedData, resources);
30354
+ return;
30355
+ }
30437
30356
  const src = embedData.src;
30438
30357
  if (src && typeof src === "string") {
30439
30358
  const newSrc = resources.get(src);
@@ -30491,7 +30410,6 @@ ${codeText}
30491
30410
  defaultReplaceBlockResources(doc2, block, resources);
30492
30411
  }
30493
30412
  });
30494
- rewriteDocResourceHooks(editor, doc2, resources);
30495
30413
  }
30496
30414
  async function addLocalResourcesToDoc(editor, resources) {
30497
30415
  let localResources = resources.filter((res) => res.indexOf(":") === -1);
@@ -31130,14 +31048,14 @@ ${codeText}
31130
31048
  editor.selection.updateSelection(null, { focusBlockChanged: true });
31131
31049
  });
31132
31050
  }
31133
- const logger$3o = getLogger("transform-selection");
31051
+ const logger$3n = getLogger("transform-selection");
31134
31052
  function transformSelection(editor, blockId, delta, local) {
31135
31053
  const { range } = editor.selection;
31136
31054
  const { anchor: anchor2, focus } = range;
31137
31055
  if (anchor2.blockId !== blockId && focus.blockId !== blockId) {
31138
31056
  return range;
31139
31057
  }
31140
- assert(logger$3o, anchor2.isSimple() && focus.isSimple(), "invalid text pos type");
31058
+ assert(logger$3n, anchor2.isSimple() && focus.isSimple(), "invalid text pos type");
31141
31059
  let newAnchor = anchor2;
31142
31060
  if (anchor2.blockId === blockId) {
31143
31061
  const newOffset = RichText.transformCursor(anchor2.offset, delta, local);
@@ -31150,12 +31068,12 @@ ${codeText}
31150
31068
  }
31151
31069
  return createEditorSelectionRange(editor, { anchor: newAnchor, focus: newFocus });
31152
31070
  }
31153
- const logger$3n = getLogger("handle-block-text-changed");
31071
+ const logger$3m = getLogger("handle-block-text-changed");
31154
31072
  function onBlockTextChanged(editor, containerId, blockIndex, actions2, local) {
31155
31073
  const container = editor.getContainerById(containerId);
31156
31074
  const block = getBlockByIndex(container, blockIndex);
31157
31075
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
31158
- assert(logger$3n, blockData.text, "no block text");
31076
+ assert(logger$3m, blockData.text, "no block text");
31159
31077
  getTextBlockClass(editor, block).setBlockText(editor, block, blockData.text);
31160
31078
  if (!local) {
31161
31079
  const newRange = transformSelection(editor, blockData.id, actions2, local);
@@ -31187,43 +31105,15 @@ ${codeText}
31187
31105
  });
31188
31106
  handleDeleteBlock$8(editor, block, local, { child: false });
31189
31107
  }
31190
- const logger$3m = getLogger("editor-doc");
31108
+ const logger$3l = getLogger("editor-doc");
31191
31109
  class EditorDoc extends EventCallbacks {
31192
31110
  constructor(editor, externalDoc, localEvents) {
31193
31111
  super();
31194
31112
  __publicField(this, "localEvents", []);
31195
- __publicField(this, "unsubscribeMacroLocks");
31196
31113
  this.editor = editor;
31197
31114
  this.externalDoc = externalDoc;
31198
31115
  this.externalDoc.registerCallback(this);
31199
31116
  this.registerLocalEvents(localEvents);
31200
- this.subscribeMacroLocks();
31201
- }
31202
- subscribeMacroLocks() {
31203
- initializeWikiMacroLocks(this.editor);
31204
- try {
31205
- this.unsubscribeMacroLocks = this.externalDoc.onWikiMacroLocks((locks) => {
31206
- updateWikiMacroLocks(this.editor, locks);
31207
- this.editor.emit("wikiMacroLocksChanged", this.editor);
31208
- });
31209
- } catch (error2) {
31210
- clearWikiMacroLocks(this.editor);
31211
- if (!(error2 instanceof WikiMacroError) || error2.code !== "READ_ONLY")
31212
- throw error2;
31213
- }
31214
- }
31215
- requestWikiMacro(message) {
31216
- if (this.editor.readonly && message.operation !== "locks" && message.operation !== "getEditResult" && message.operation !== "cancelEdit") {
31217
- return Promise.reject(new WikiMacroError({ code: "READ_ONLY" }));
31218
- }
31219
- return this.externalDoc.requestWikiMacro(message);
31220
- }
31221
- onWikiMacroLocks(listener) {
31222
- return this.externalDoc.onWikiMacroLocks(listener);
31223
- }
31224
- getDocumentVersion() {
31225
- var _a, _b;
31226
- return (_b = (_a = this.externalDoc).getDocumentVersion) == null ? void 0 : _b.call(_a);
31227
31117
  }
31228
31118
  beginBatchUpdate() {
31229
31119
  return this.externalDoc.beginBatchUpdate();
@@ -31258,14 +31148,12 @@ ${codeText}
31258
31148
  }
31259
31149
  verifyBlockWritable(containerId, blockIndex) {
31260
31150
  const block = this.editor.getBlockByIndex(containerId, blockIndex);
31261
- assert(logger$3m, this.editor.isBlockWritable(block), `block is not writable, ${containerId}, ${blockIndex}`);
31151
+ assert(logger$3l, this.editor.isBlockWritable(block), `block is not writable, ${containerId}, ${blockIndex}`);
31262
31152
  }
31263
31153
  localUpdateBlockText(containerId, blockIndex, actions2, options) {
31264
31154
  const blockData = this.getBlockData(containerId, blockIndex);
31265
- if (isWikiMacroBlockLocked(this.editor, blockData))
31266
- throw new WikiMacroError({ code: "LOCK_CONFLICT" });
31267
31155
  const oldText = blockData.text;
31268
- assert(logger$3m, oldText, `no text, ${containerId}, ${blockIndex}`);
31156
+ assert(logger$3l, oldText, `no text, ${containerId}, ${blockIndex}`);
31269
31157
  const newRange = transformSelection(this.editor, blockData.id, actions2, true);
31270
31158
  const newText = RichText.apply(oldText, actions2);
31271
31159
  this.localEvents.forEach((event) => event.onBeforeUpdateBlockText(containerId, blockData.id, oldText, newText, newRange.toDocRange()));
@@ -31275,15 +31163,11 @@ ${codeText}
31275
31163
  }
31276
31164
  localUpdateBlockData(containerId, blockIndex, delta, newRange, options) {
31277
31165
  const block = this.editor.getBlockByIndex(containerId, blockIndex);
31278
- const blockedByMacroLease = isWikiMacroBlockLocked(this.editor, this.getBlockData(containerId, blockIndex));
31279
- if (blockedByMacroLease && (delta.delete.some((key) => key !== "comments") || Object.keys(delta.insert).some((key) => key !== "comments"))) {
31280
- throw new WikiMacroError({ code: "LOCK_CONFLICT" });
31281
- }
31282
31166
  if (!this.editor.isBlockWritable(block)) {
31283
31167
  const deletedKeys = Array.from(delta.delete).filter((key) => key !== "comments");
31284
31168
  const insertedKeys = Object.keys(delta.insert).filter((key) => key !== "comments");
31285
31169
  if (deletedKeys.length > 0 || insertedKeys.length > 0) {
31286
- assert(logger$3m, false, `block is not writable, comment supported only, ${JSON.stringify(delta)}}`);
31170
+ assert(logger$3l, false, `block is not writable, comment supported only, ${JSON.stringify(delta)}}`);
31287
31171
  }
31288
31172
  }
31289
31173
  const oldData = cloneDeep__default.default(this.getBlockData(containerId, blockIndex));
@@ -31294,9 +31178,7 @@ ${codeText}
31294
31178
  return ret;
31295
31179
  }
31296
31180
  localInsertBlock(containerId, blockIndex, data2, newRange, options) {
31297
- assert(logger$3m, !this.editor.readonly, "editor is readonly");
31298
- if (isWikiMacroBlockLocked(this.editor, data2))
31299
- throw new WikiMacroError({ code: "LOCK_CONFLICT" });
31181
+ assert(logger$3l, !this.editor.readonly, "editor is readonly");
31300
31182
  this.localEvents.forEach((event) => event.onBeforeInsertBlock(containerId, blockIndex, data2, newRange));
31301
31183
  const ret = this.externalDoc.localInsertBlock(containerId, blockIndex, data2, newRange);
31302
31184
  if (!(options == null ? void 0 : options.noFocus)) {
@@ -31305,7 +31187,7 @@ ${codeText}
31305
31187
  return ret;
31306
31188
  }
31307
31189
  localDeleteBlock(containerId, blockIndex, newRange) {
31308
- assert(logger$3m, !this.editor.readonly, "editor is readonly");
31190
+ assert(logger$3l, !this.editor.readonly, "editor is readonly");
31309
31191
  this.verifyBlockWritable(containerId, blockIndex);
31310
31192
  const blockData = cloneDeep__default.default(this.getBlockData(containerId, blockIndex));
31311
31193
  this.localEvents.forEach((event) => event.onBeforeDeleteBlock(containerId, blockIndex, blockData, newRange));
@@ -31314,10 +31196,7 @@ ${codeText}
31314
31196
  return ret;
31315
31197
  }
31316
31198
  localDeleteChildContainers(containerIds) {
31317
- assert(logger$3m, !this.editor.readonly, "editor is readonly");
31318
- if (containerIds.some((containerId) => this.getContainerBlocks(containerId).some((block) => isWikiMacroBlockLocked(this.editor, block)))) {
31319
- throw new WikiMacroError({ code: "LOCK_CONFLICT" });
31320
- }
31199
+ assert(logger$3l, !this.editor.readonly, "editor is readonly");
31321
31200
  containerIds.forEach((containerId) => {
31322
31201
  const blocks = cloneDeep__default.default(this.getContainerBlocks(containerId));
31323
31202
  this.localEvents.forEach((event) => event.onBeforeDeleteChildContainer(containerId, blocks));
@@ -31325,10 +31204,7 @@ ${codeText}
31325
31204
  return this.externalDoc.localDeleteChildContainers(containerIds);
31326
31205
  }
31327
31206
  localInsertChildContainers(containers) {
31328
- assert(logger$3m, !this.editor.readonly, "editor is readonly");
31329
- if (containers.some((container) => container.blocks.some((block) => isWikiMacroBlockLocked(this.editor, block)))) {
31330
- throw new WikiMacroError({ code: "LOCK_CONFLICT" });
31331
- }
31207
+ assert(logger$3l, !this.editor.readonly, "editor is readonly");
31332
31208
  const data2 = cloneDeep__default.default(containers);
31333
31209
  data2.forEach((item) => {
31334
31210
  this.localEvents.forEach((event) => event.onBeforeInsertChildContainer(item.containerId, item.blocks));
@@ -31336,7 +31212,7 @@ ${codeText}
31336
31212
  this.externalDoc.localInsertChildContainers(data2);
31337
31213
  }
31338
31214
  onRequestReload(reason) {
31339
- logger$3m.debug(`reload doc: ${reason}`);
31215
+ logger$3l.debug(`reload doc: ${reason}`);
31340
31216
  this.editor.reload();
31341
31217
  this.callbacks.forEach((c) => {
31342
31218
  var _a;
@@ -31437,11 +31313,6 @@ ${codeText}
31437
31313
  (_b = (_a = this.externalDoc).triggerReAuth) == null ? void 0 : _b.call(_a, auto);
31438
31314
  }
31439
31315
  destroy() {
31440
- var _a;
31441
- this.editor.undoManager.destroy();
31442
- (_a = this.unsubscribeMacroLocks) == null ? void 0 : _a.call(this);
31443
- this.unsubscribeMacroLocks = void 0;
31444
- clearWikiMacroLocks(this.editor);
31445
31316
  this.externalDoc.destroy();
31446
31317
  this.clearCallbacks();
31447
31318
  }
@@ -31450,18 +31321,25 @@ ${codeText}
31450
31321
  return (_c = (_b = (_a = this.externalDoc).getServerMeta) == null ? void 0 : _b.call(_a)) != null ? _c : {};
31451
31322
  }
31452
31323
  reset(doc2) {
31453
- var _a;
31454
- logger$3m.log("reset doc");
31455
- (_a = this.unsubscribeMacroLocks) == null ? void 0 : _a.call(this);
31456
- clearWikiMacroLocks(this.editor);
31324
+ logger$3l.log("reset doc");
31457
31325
  this.externalDoc = doc2;
31458
31326
  this.externalDoc.registerCallback(this);
31459
- initializeWikiMacroLocks(this.editor);
31460
31327
  this.editor.reload();
31461
- this.subscribeMacroLocks();
31462
31328
  }
31463
31329
  }
31464
- const logger$3l = getLogger("undo-action");
31330
+ function addActions(actions2, action) {
31331
+ if (actions2.length === 0) {
31332
+ actions2.push(action);
31333
+ return;
31334
+ }
31335
+ const last = actions2[actions2.length - 1];
31336
+ if (!last.combinable(action)) {
31337
+ actions2.push(action);
31338
+ return;
31339
+ }
31340
+ last.combine(action);
31341
+ }
31342
+ const logger$3k = getLogger("undo-action");
31465
31343
  class Action {
31466
31344
  constructor(editor, containerId, afterRange, batchActionId) {
31467
31345
  __publicField(this, "beforeRange");
@@ -31483,18 +31361,18 @@ ${codeText}
31483
31361
  return false;
31484
31362
  }
31485
31363
  combinable(other) {
31486
- assert(logger$3l, other, "no other action");
31364
+ assert(logger$3k, other, "no other action");
31487
31365
  return false;
31488
31366
  }
31489
31367
  combine(other) {
31490
- assert(logger$3l, false, "no other");
31368
+ assert(logger$3k, false, "no other");
31491
31369
  }
31492
31370
  getBatchActionId() {
31493
31371
  return this.batchActionId;
31494
31372
  }
31495
31373
  setAfterRange(range) {
31496
31374
  if (this.afterRange) {
31497
- logger$3l.warn("after range has already set");
31375
+ logger$3k.warn("after range has already set");
31498
31376
  }
31499
31377
  this.afterRange = range;
31500
31378
  }
@@ -31516,7 +31394,7 @@ ${codeText}
31516
31394
  const containerId = blockData.children[i];
31517
31395
  const container = doc2.blocks[containerId];
31518
31396
  if (!container) {
31519
- logger$3l.warn(`container (${containerId}) not found, deleted by others?`);
31397
+ logger$3k.warn(`container (${containerId}) not found, deleted by others?`);
31520
31398
  return false;
31521
31399
  }
31522
31400
  }
@@ -31524,45 +31402,6 @@ ${codeText}
31524
31402
  return true;
31525
31403
  }
31526
31404
  }
31527
- const logger$3k = getLogger("async-undo-action");
31528
- class AsyncAction extends Action {
31529
- constructor(editor, operation) {
31530
- super(editor, "", editor.selection.range.toDocRange());
31531
- __publicField(this, "operation");
31532
- this.operation = operation;
31533
- }
31534
- apply(direction) {
31535
- if (!this.operation)
31536
- return Promise.reject(Object.assign(new Error("Async history action disposed"), { code: "SESSION_EXPIRED" }));
31537
- return this.operation[direction]();
31538
- }
31539
- reportError(error2) {
31540
- var _a, _b;
31541
- (_b = (_a = this.operation) == null ? void 0 : _a.onError) == null ? void 0 : _b.call(_a, error2);
31542
- }
31543
- dispose() {
31544
- var _a;
31545
- const operation = this.operation;
31546
- this.operation = null;
31547
- try {
31548
- (_a = operation == null ? void 0 : operation.onDiscard) == null ? void 0 : _a.call(operation);
31549
- } catch {
31550
- logger$3k.error("Async history discard callback failed");
31551
- }
31552
- }
31553
- }
31554
- function addActions(actions2, action) {
31555
- if (actions2.length === 0) {
31556
- actions2.push(action);
31557
- return;
31558
- }
31559
- const last = actions2[actions2.length - 1];
31560
- if (!last.combinable(action)) {
31561
- actions2.push(action);
31562
- return;
31563
- }
31564
- last.combine(action);
31565
- }
31566
31405
  const logger$3j = getLogger("block-action");
31567
31406
  class BlockAction extends Action {
31568
31407
  constructor(editor, containerId, blockIndex, data2, afterRange) {
@@ -31620,32 +31459,10 @@ ${codeText}
31620
31459
  }
31621
31460
  class DeleteBlockAction$1 extends BlockAction {
31622
31461
  undo(editor) {
31623
- if (this.blockData.type !== "embed" || this.blockData.embedType !== "ones-open-wiki-macro") {
31624
- return this.insertBlock(editor, this.beforeRange);
31625
- }
31626
- const revision = this.blockData.macroRevision;
31627
- this.blockData.macroRevision = revision + 1;
31628
- let inserted = false;
31629
- try {
31630
- inserted = this.insertBlock(editor, this.beforeRange);
31631
- return inserted;
31632
- } finally {
31633
- if (!inserted)
31634
- this.blockData.macroRevision = revision;
31635
- }
31462
+ return this.insertBlock(editor, this.beforeRange);
31636
31463
  }
31637
31464
  redo(editor) {
31638
- if (this.blockData.type !== "embed" || this.blockData.embedType !== "ones-open-wiki-macro") {
31639
- return this.deleteBlock(editor, this.afterRange);
31640
- }
31641
- const block = editor.findBlockById(this.blockData.id);
31642
- if (!block)
31643
- return false;
31644
- const deletedSnapshot = cloneDeep__default.default(editor.getBlockData(block));
31645
- const deleted = this.deleteBlock(editor, this.afterRange);
31646
- if (deleted)
31647
- this.blockData = deletedSnapshot;
31648
- return deleted;
31465
+ return this.deleteBlock(editor, this.afterRange);
31649
31466
  }
31650
31467
  }
31651
31468
  class GroupAction extends Action {
@@ -31912,6 +31729,12 @@ ${codeText}
31912
31729
  return this.deleteChildContainer(editor);
31913
31730
  }
31914
31731
  }
31732
+ class AsyncAction extends Action {
31733
+ constructor(editor, operation) {
31734
+ super(editor, "", editor.selection.range.toDocRange());
31735
+ this.operation = operation;
31736
+ }
31737
+ }
31915
31738
  const BATCH_ACTION_TS = 1e3 * 3;
31916
31739
  const logger$3f = getLogger("undo");
31917
31740
  class UndoManager {
@@ -31922,13 +31745,9 @@ ${codeText}
31922
31745
  __publicField(this, "currentGroup", null);
31923
31746
  __publicField(this, "groupCounter", 0);
31924
31747
  __publicField(this, "undoRedoing", false);
31925
- __publicField(this, "macroSessions", /* @__PURE__ */ new Set());
31926
- __publicField(this, "macroActionIds", /* @__PURE__ */ new Set());
31927
- __publicField(this, "pendingMacroAction", null);
31928
- __publicField(this, "pendingAsyncPromise", null);
31929
31748
  __publicField(this, "undoLocks", /* @__PURE__ */ new Set());
31930
- __publicField(this, "macroGeneration", 0);
31931
- __publicField(this, "destroyed", false);
31749
+ __publicField(this, "pendingAction");
31750
+ __publicField(this, "resetVersion", 0);
31932
31751
  __publicField(this, "handleSelectionChange", (editor) => {
31933
31752
  if (this.currentGroup) {
31934
31753
  this.currentGroup.setAfterRange(editor.selection.range.toDocRange());
@@ -31944,155 +31763,107 @@ ${codeText}
31944
31763
  this.editor = editor;
31945
31764
  this.undoCursor = -1;
31946
31765
  this.editor.addListener("selectionChanged", this.handleSelectionChange);
31766
+ this.editor.addListener("destroy", () => this.reset());
31767
+ }
31768
+ reset() {
31769
+ this.resetVersion += 1;
31770
+ this.actions.forEach((action) => this.discard(action));
31771
+ this.actions = [];
31772
+ this.undoCursor = -1;
31947
31773
  }
31948
- registerMacroEditAction(options) {
31949
- if (this.destroyed) {
31950
- throw new WikiMacroError({ code: "SESSION_EXPIRED", message: "Editor destroyed" });
31774
+ prepareSaveUndoState() {
31775
+ if (this.pendingAction)
31776
+ throw new Error("An asynchronous undo action is pending");
31777
+ if (this.undoCursor !== -1) {
31778
+ this.actions.splice(this.undoCursor).forEach((action) => this.discard(action));
31779
+ this.undoCursor = -1;
31780
+ }
31781
+ }
31782
+ addAction(action) {
31783
+ if (this.pendingAction)
31784
+ throw new Error("An asynchronous undo action is pending");
31785
+ if (this.currentGroup) {
31786
+ this.currentGroup.addAction(action);
31787
+ } else {
31788
+ addActions(this.actions, action);
31789
+ setTimeout(() => {
31790
+ this.editor.input.handleChanged(action);
31791
+ });
31951
31792
  }
31952
- if (this.macroActionIds.has(options.actionId))
31953
- return;
31954
- this.addAsyncAction(options);
31955
- this.macroActionIds.add(options.actionId);
31956
31793
  }
31957
31794
  addAsyncAction(operation) {
31958
- if (this.destroyed)
31959
- throw new Error("Editor destroyed");
31960
31795
  if (this.currentGroup)
31961
- throw new Error("Async actions require an independent undo boundary");
31796
+ throw new Error("An asynchronous undo action cannot join a synchronous group");
31962
31797
  this.prepareSaveUndoState();
31963
31798
  const action = new AsyncAction(this.editor, operation);
31964
- this.actions.push(action);
31965
- try {
31966
- this.editor.input.handleChanged(action);
31967
- } catch {
31968
- logger$3f.error("Async history change observer failed");
31969
- }
31799
+ this.addAction(action);
31800
+ return () => {
31801
+ const index2 = this.actions.indexOf(action);
31802
+ if (index2 === -1)
31803
+ return;
31804
+ this.actions.splice(index2, 1);
31805
+ if (this.undoCursor !== -1 && index2 < this.undoCursor)
31806
+ this.undoCursor -= 1;
31807
+ this.discard(action);
31808
+ };
31809
+ }
31810
+ discard(action) {
31811
+ var _a, _b;
31812
+ if (action instanceof AsyncAction)
31813
+ (_b = (_a = action.operation).onDiscard) == null ? void 0 : _b.call(_a);
31970
31814
  }
31971
31815
  acquireUndoLock() {
31972
- const lock = Symbol("pending-undo-session");
31816
+ const lock = Symbol("macro-edit-session");
31973
31817
  this.undoLocks.add(lock);
31974
31818
  return () => {
31975
31819
  this.undoLocks.delete(lock);
31976
31820
  };
31977
31821
  }
31978
31822
  async undoAsync() {
31979
- var _a;
31980
- if (this.pendingMacroAction)
31823
+ if (this.pendingAction)
31981
31824
  return false;
31982
31825
  const accepted = this.undo();
31983
- return (_a = this.pendingAsyncPromise) != null ? _a : accepted;
31826
+ return this.pendingAction || accepted;
31984
31827
  }
31985
31828
  async redoAsync() {
31986
- var _a;
31987
- if (this.pendingMacroAction)
31829
+ if (this.pendingAction)
31988
31830
  return false;
31989
31831
  const accepted = this.redo();
31990
- return (_a = this.pendingAsyncPromise) != null ? _a : accepted;
31832
+ return this.pendingAction || accepted;
31991
31833
  }
31992
- setMacroEditSessionActive(sessionId, active) {
31993
- if (this.destroyed)
31994
- return;
31995
- setWikiMacroLockSession(this.editor, sessionId, active);
31996
- if (active) {
31997
- this.macroSessions.add(sessionId);
31998
- } else {
31999
- this.macroSessions.delete(sessionId);
32000
- }
32001
- }
32002
- destroy() {
32003
- this.destroyed = true;
32004
- this.reset();
32005
- this.macroSessions.clear();
32006
- this.undoLocks.clear();
32007
- this.editor.removeListener("selectionChanged", this.handleSelectionChange);
32008
- }
32009
- applyMacroAction(action, direction) {
32010
- const generation = this.macroGeneration;
32011
- const cursor = this.undoCursor;
32012
- const historyLength = this.actions.length;
32013
- this.pendingMacroAction = action;
32014
- this.pendingAsyncPromise = Promise.resolve().then(() => action.apply(direction)).then(() => {
32015
- if (generation !== this.macroGeneration || this.destroyed)
31834
+ runAsyncAction(action, index2, direction) {
31835
+ const release = this.editor.acquireReadonly();
31836
+ const resetVersion = this.resetVersion;
31837
+ this.pendingAction = Promise.resolve().then(() => action.operation[direction]()).then((success) => {
31838
+ if (!success)
32016
31839
  return false;
32017
- const index2 = this.actions.indexOf(action);
32018
- if (direction === "undo") {
32019
- if (index2 < 0)
32020
- return false;
32021
- if (this.undoCursor === cursor && this.actions.length === historyLength) {
32022
- this.undoCursor = index2;
32023
- } else {
32024
- this.actions.splice(index2, 1);
32025
- this.actions.push(action);
32026
- this.undoCursor = this.actions.length - 1;
31840
+ if (this.resetVersion !== resetVersion || this.actions[index2] !== action)
31841
+ return false;
31842
+ this.undoCursor = direction === "undo" ? index2 : index2 + 1;
31843
+ const range = direction === "undo" ? action.beforeRange : action.afterRange;
31844
+ if (range) {
31845
+ try {
31846
+ this.editor.selection.setRange(fromDocRange(this.editor, range));
31847
+ } catch (error2) {
31848
+ logger$3f.warn(`failed to restore selection after asynchronous ${direction}`);
32027
31849
  }
32028
- } else if (index2 >= 0 && this.undoCursor === cursor && this.actions.length === historyLength) {
32029
- this.undoCursor = index2 + 1;
32030
- } else {
32031
- if (index2 >= 0)
32032
- this.actions.splice(index2, 1);
32033
- this.actions.push(action);
32034
- this.undoCursor = -1;
32035
- }
32036
- try {
32037
- this.editor.input.handleChanged(action);
32038
- } catch (error2) {
32039
- logger$3f.error("Macro history change observer failed");
32040
31850
  }
31851
+ this.editor.input.handleChanged(action);
32041
31852
  return true;
32042
31853
  }).catch((error2) => {
32043
- if (generation !== this.macroGeneration || this.destroyed)
32044
- return false;
32045
- const failure = error2 instanceof Error ? error2 : new Error("Macro history action failed");
32046
31854
  try {
32047
- action.reportError(failure);
32048
- } catch (callbackError) {
32049
- logger$3f.error("Macro history error callback failed");
31855
+ action.operation.onError(error2);
31856
+ } catch (notificationError) {
31857
+ logger$3f.warn("failed to report asynchronous undo error");
32050
31858
  }
32051
31859
  return false;
32052
31860
  }).finally(() => {
32053
- if (generation === this.macroGeneration) {
32054
- this.pendingMacroAction = null;
32055
- this.pendingAsyncPromise = null;
32056
- if (!this.actions.includes(action))
32057
- action.dispose();
32058
- }
31861
+ this.pendingAction = void 0;
31862
+ release();
31863
+ this.checkRange();
32059
31864
  });
32060
31865
  return true;
32061
31866
  }
32062
- reset() {
32063
- var _a;
32064
- this.macroGeneration += 1;
32065
- (_a = this.pendingMacroAction) == null ? void 0 : _a.dispose();
32066
- this.pendingMacroAction = null;
32067
- this.pendingAsyncPromise = null;
32068
- this.actions.forEach((action) => {
32069
- if (action instanceof AsyncAction)
32070
- action.dispose();
32071
- });
32072
- this.macroActionIds.clear();
32073
- this.actions = [];
32074
- this.undoCursor = -1;
32075
- }
32076
- prepareSaveUndoState() {
32077
- if (this.undoCursor !== -1) {
32078
- const removed = this.actions.splice(this.undoCursor);
32079
- removed.forEach((action) => {
32080
- if (action instanceof AsyncAction && action !== this.pendingMacroAction)
32081
- action.dispose();
32082
- });
32083
- this.undoCursor = -1;
32084
- }
32085
- }
32086
- addAction(action) {
32087
- if (this.currentGroup) {
32088
- this.currentGroup.addAction(action);
32089
- } else {
32090
- addActions(this.actions, action);
32091
- setTimeout(() => {
32092
- this.editor.input.handleChanged(action);
32093
- });
32094
- }
32095
- }
32096
31867
  beginGroup() {
32097
31868
  if (this.groupCounter === 0) {
32098
31869
  assert(logger$3f, !this.currentGroup, "current group already exists");
@@ -32161,22 +31932,19 @@ ${codeText}
32161
31932
  }
32162
31933
  }
32163
31934
  undo() {
32164
- if (this.destroyed || this.macroSessions.size > 0 || this.undoLocks.size > 0 || this.pendingMacroAction)
31935
+ if (this.pendingAction || this.undoLocks.size)
32165
31936
  return false;
32166
- const candidate = this.actions[(this.undoCursor === -1 ? this.actions.length : this.undoCursor) - 1];
32167
- if (candidate instanceof AsyncAction)
32168
- return this.applyMacroAction(candidate, "undo");
32169
31937
  if (this.undoCursor === -1) {
32170
31938
  this.undoCursor = this.actions.length;
32171
31939
  }
32172
31940
  try {
32173
31941
  this.undoRedoing = true;
32174
31942
  while (this.undoCursor > 0) {
32175
- const action = this.actions[this.undoCursor - 1];
32176
- if (action instanceof AsyncAction) {
32177
- return this.applyMacroAction(action, "undo");
32178
- }
31943
+ const candidate = this.actions[this.undoCursor - 1];
31944
+ if (candidate instanceof AsyncAction)
31945
+ return this.runAsyncAction(candidate, this.undoCursor - 1, "undo");
32179
31946
  this.undoCursor -= 1;
31947
+ const action = this.actions[this.undoCursor];
32180
31948
  if (action.undo(this.editor)) {
32181
31949
  try {
32182
31950
  this.editor.selection.setRange(fromDocRange(this.editor, action.beforeRange));
@@ -32202,11 +31970,8 @@ ${codeText}
32202
31970
  }
32203
31971
  }
32204
31972
  redo() {
32205
- if (this.destroyed || this.macroSessions.size > 0 || this.undoLocks.size > 0 || this.pendingMacroAction)
31973
+ if (this.pendingAction || this.undoLocks.size)
32206
31974
  return false;
32207
- const candidate = this.actions[this.undoCursor];
32208
- if (candidate instanceof AsyncAction)
32209
- return this.applyMacroAction(candidate, "redo");
32210
31975
  if (this.undoCursor === -1) {
32211
31976
  this.undoCursor = this.actions.length;
32212
31977
  }
@@ -32214,9 +31979,8 @@ ${codeText}
32214
31979
  this.undoRedoing = true;
32215
31980
  while (this.undoCursor < this.actions.length) {
32216
31981
  const action = this.actions[this.undoCursor];
32217
- if (action instanceof AsyncAction) {
32218
- return this.applyMacroAction(action, "redo");
32219
- }
31982
+ if (action instanceof AsyncAction)
31983
+ return this.runAsyncAction(action, this.undoCursor, "redo");
32220
31984
  this.undoCursor += 1;
32221
31985
  if (action.redo(this.editor)) {
32222
31986
  try {
@@ -32245,7 +32009,7 @@ ${codeText}
32245
32009
  }
32246
32010
  }
32247
32011
  canUndo() {
32248
- if (this.destroyed || this.macroSessions.size > 0 || this.undoLocks.size > 0 || this.pendingMacroAction)
32012
+ if (this.pendingAction || this.undoLocks.size)
32249
32013
  return false;
32250
32014
  if (this.actions.length === 0) {
32251
32015
  return false;
@@ -32256,7 +32020,7 @@ ${codeText}
32256
32020
  return true;
32257
32021
  }
32258
32022
  canRedo() {
32259
- if (this.destroyed || this.macroSessions.size > 0 || this.undoLocks.size > 0 || this.pendingMacroAction)
32023
+ if (this.pendingAction || this.undoLocks.size)
32260
32024
  return false;
32261
32025
  if (this.actions.length === 0) {
32262
32026
  return false;
@@ -32283,10 +32047,8 @@ ${codeText}
32283
32047
  if (lastAction === action) {
32284
32048
  return true;
32285
32049
  }
32286
- if (this.pendingMacroAction || lastAction instanceof AsyncAction) {
32287
- this.undo();
32050
+ if (lastAction instanceof AsyncAction)
32288
32051
  return false;
32289
- }
32290
32052
  if (!this.undo()) {
32291
32053
  return false;
32292
32054
  }
@@ -32860,6 +32622,7 @@ ${codeText}
32860
32622
  __publicField(this, "_readonly", false);
32861
32623
  __publicField(this, "_scrollable", true);
32862
32624
  __publicField(this, "_destroyed", false);
32625
+ __publicField(this, "readonlyLocks", /* @__PURE__ */ new Set());
32863
32626
  __publicField(this, "getColor", (index2) => {
32864
32627
  const colors = this.options.colors;
32865
32628
  if (colors.length === 0) {
@@ -32915,11 +32678,21 @@ ${codeText}
32915
32678
  this.emit("load", this, false);
32916
32679
  }
32917
32680
  get readonly() {
32918
- return this._readonly;
32681
+ return this._readonly || this.readonlyLocks.size > 0;
32682
+ }
32683
+ acquireReadonly() {
32684
+ const lock = Symbol("pending-document-action");
32685
+ this.readonlyLocks.add(lock);
32686
+ this.readonly = this._readonly;
32687
+ return () => {
32688
+ if (!this.readonlyLocks.delete(lock))
32689
+ return;
32690
+ this.readonly = this._readonly;
32691
+ };
32919
32692
  }
32920
32693
  set readonly(val) {
32921
32694
  this._readonly = val;
32922
- if (val) {
32695
+ if (this.readonly) {
32923
32696
  addClass(this.rootElement, "readonly");
32924
32697
  } else {
32925
32698
  removeClass(this.rootElement, "readonly");
@@ -32993,21 +32766,9 @@ ${codeText}
32993
32766
  createInsertion(blockContent, insertion) {
32994
32767
  return this.editorInsertions.createInsertion(blockContent, insertion);
32995
32768
  }
32996
- addDocResourceHook(hook) {
32997
- return registerDocResourceHook(this, hook);
32998
- }
32999
- registerMacroEditAction(options) {
33000
- this.undoManager.registerMacroEditAction(options);
33001
- }
33002
- setMacroEditSessionActive(sessionId, active) {
33003
- if (this.destroyed)
33004
- return;
33005
- this.undoManager.setMacroEditSessionActive(sessionId, active);
33006
- }
33007
32769
  destroy() {
33008
32770
  logger$3b.debug("destroy editor");
33009
32771
  this.emit("destroy", this);
33010
- this.undoManager.destroy();
33011
32772
  this.input.destroy();
33012
32773
  this.rootContainerObject.destroy();
33013
32774
  this.rootElement.remove();
@@ -33018,7 +32779,6 @@ ${codeText}
33018
32779
  this.domEvents.destroy();
33019
32780
  this.removeAllListeners();
33020
32781
  this.inputHandlers.destroy();
33021
- clearDocResourceHooks(this);
33022
32782
  this._destroyed = true;
33023
32783
  }
33024
32784
  get destroyed() {
@@ -33033,15 +32793,7 @@ ${codeText}
33033
32793
  isWritable() {
33034
32794
  return editorIsWritable(this);
33035
32795
  }
33036
- isBlockWritable(block, macroSessionId) {
33037
- if (macroSessionId && this.readonly)
33038
- return false;
33039
- if (Array.isArray(block)) {
33040
- if (block.some((item) => isWikiMacroElementLocked(this, item, macroSessionId)))
33041
- return false;
33042
- } else if (isWikiMacroElementLocked(this, block, macroSessionId)) {
33043
- return false;
33044
- }
32796
+ isBlockWritable(block) {
33045
32797
  return editorIsBlockWritable(this, block);
33046
32798
  }
33047
32799
  getChildContainerData(childContainerId) {
@@ -33390,7 +33142,6 @@ ${codeText}
33390
33142
  super();
33391
33143
  __publicField(this, "doc");
33392
33144
  __publicField(this, "serviceUrl");
33393
- __publicField(this, "documentVersion");
33394
33145
  if (doc2) {
33395
33146
  this.doc = doc2;
33396
33147
  } else {
@@ -33405,16 +33156,6 @@ ${codeText}
33405
33156
  };
33406
33157
  }
33407
33158
  this.serviceUrl = (options == null ? void 0 : options.serverUrl) || "";
33408
- this.documentVersion = options == null ? void 0 : options.documentVersion;
33409
- }
33410
- requestWikiMacro(message) {
33411
- return Promise.reject(new WikiMacroError({ code: "READ_ONLY", message: "Local and history documents cannot edit Wiki macros" }));
33412
- }
33413
- onWikiMacroLocks(listener) {
33414
- throw new WikiMacroError({ code: "READ_ONLY", message: "Local and history documents have no macro lock channel" });
33415
- }
33416
- getDocumentVersion() {
33417
- return this.documentVersion;
33418
33159
  }
33419
33160
  beginBatchUpdate() {
33420
33161
  return 0;
@@ -33553,9 +33294,8 @@ ${codeText}
33553
33294
  getRemoteUsers() {
33554
33295
  return new RemoteUsers();
33555
33296
  }
33556
- setDoc(doc2, documentVersion) {
33297
+ setDoc(doc2) {
33557
33298
  this.doc = cloneDeep__default.default(doc2);
33558
- this.documentVersion = documentVersion;
33559
33299
  this.callbacks.forEach((c) => {
33560
33300
  var _a;
33561
33301
  return (_a = c.onRequestReload) == null ? void 0 : _a.call(c, "change doc");
@@ -39099,11 +38839,6 @@ ${codeText}
39099
38839
  __publicField(this, "connectionStatus", null);
39100
38840
  __publicField(this, "reauthing", false);
39101
38841
  __publicField(this, "ready", false);
39102
- __publicField(this, "macroRequests", /* @__PURE__ */ new Map());
39103
- __publicField(this, "macroLocksListeners", /* @__PURE__ */ new Set());
39104
- __publicField(this, "macroLocks", []);
39105
- __publicField(this, "macroLocksKnown", false);
39106
- __publicField(this, "macroLocksLoading", false);
39107
38842
  __publicField(this, "pingOptions", { interval: 5e4, timeout: 15e4 });
39108
38843
  __publicField(this, "handleAuthError", (err) => {
39109
38844
  if (!this.renewTokenFunc) {
@@ -39151,7 +38886,6 @@ ${codeText}
39151
38886
  });
39152
38887
  __publicField(this, "handleDisconnected", (reason) => {
39153
38888
  this.connectionDisconnected = true;
39154
- this.clearWikiMacroRequests("Document disconnected; query the original request before retrying");
39155
38889
  this.emit("disconnected", reason);
39156
38890
  });
39157
38891
  __publicField(this, "handleVisibilityChange", () => {
@@ -39169,111 +38903,6 @@ ${codeText}
39169
38903
  this.renewTokenFunc = renewTokenFunc;
39170
38904
  this.authMessage = authMessage;
39171
38905
  }
39172
- loadWikiMacroLocks() {
39173
- if (this.closed || this.macroLocksLoading || this.macroLocksListeners.size === 0)
39174
- return;
39175
- this.macroLocksLoading = true;
39176
- this.requestWikiMacro({ operation: "locks" }).then((result) => {
39177
- if (this.closed)
39178
- return;
39179
- if (!Array.isArray(result.locks)) {
39180
- throw new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Macro lock snapshot unavailable" });
39181
- }
39182
- this.notifyWikiMacroLocks(result.locks);
39183
- }).catch(() => {
39184
- if (!this.closed)
39185
- logger$31.warn("Macro lock snapshot unavailable");
39186
- }).finally(() => {
39187
- this.macroLocksLoading = false;
39188
- });
39189
- }
39190
- requestWikiMacro(message) {
39191
- var _a;
39192
- const requestId = genId();
39193
- if (this.closed || ((_a = this.connection) == null ? void 0 : _a.state) !== "connected" || this.reauthing || this.connectionDisconnected) {
39194
- return Promise.reject(new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Document connection unavailable" }, requestId));
39195
- }
39196
- return new Promise((resolve, reject) => {
39197
- const timeout = window.setTimeout(() => {
39198
- this.macroRequests.delete(requestId);
39199
- reject(new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Macro result unknown; query the original request" }, requestId));
39200
- }, 6e4);
39201
- this.macroRequests.set(requestId, { resolve, reject, timeout });
39202
- try {
39203
- this.connection.send({
39204
- a: "wikiMacro",
39205
- requestId,
39206
- operation: message.operation,
39207
- blockId: message.blockId,
39208
- sessionId: message.sessionId,
39209
- fence: message.fence,
39210
- expectedRevision: message.expectedRevision,
39211
- content: message.content,
39212
- actionId: message.actionId,
39213
- direction: message.direction,
39214
- targetRequestId: message.targetRequestId
39215
- });
39216
- } catch (error2) {
39217
- this.macroRequests.delete(requestId);
39218
- window.clearTimeout(timeout);
39219
- reject(new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Unable to send macro request" }, requestId));
39220
- }
39221
- });
39222
- }
39223
- onWikiMacroLocks(listener) {
39224
- if (this.closed) {
39225
- throw new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Document connection closed" });
39226
- }
39227
- this.macroLocksListeners.add(listener);
39228
- try {
39229
- if (this.macroLocksKnown)
39230
- listener(this.macroLocks || []);
39231
- } catch (error2) {
39232
- this.macroLocksListeners.delete(listener);
39233
- throw error2;
39234
- }
39235
- this.loadWikiMacroLocks();
39236
- return () => {
39237
- this.macroLocksListeners.delete(listener);
39238
- };
39239
- }
39240
- handleWikiMacroReply(message) {
39241
- if (message.operation === "locks" && Array.isArray(message.locks)) {
39242
- this.notifyWikiMacroLocks(message.locks);
39243
- }
39244
- if (!message.requestId)
39245
- return;
39246
- const pending = this.macroRequests.get(message.requestId);
39247
- if (!pending)
39248
- return;
39249
- this.macroRequests.delete(message.requestId);
39250
- window.clearTimeout(pending.timeout);
39251
- if (message.error) {
39252
- pending.reject(new WikiMacroError(message.error, message.requestId));
39253
- } else if (message.result) {
39254
- pending.resolve({ ...message.result, requestId: message.requestId });
39255
- } else {
39256
- pending.reject(new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Invalid macro acknowledgement" }, message.requestId));
39257
- }
39258
- }
39259
- clearWikiMacroRequests(message) {
39260
- this.macroRequests.forEach((pending, requestId) => {
39261
- window.clearTimeout(pending.timeout);
39262
- pending.reject(new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message }, requestId));
39263
- });
39264
- this.macroRequests.clear();
39265
- }
39266
- notifyWikiMacroLocks(locks) {
39267
- this.macroLocks = locks;
39268
- this.macroLocksKnown = true;
39269
- this.macroLocksListeners.forEach((listener) => {
39270
- try {
39271
- listener(locks);
39272
- } catch (error2) {
39273
- logger$31.error("Wiki macro lock listener failed");
39274
- }
39275
- });
39276
- }
39277
38906
  getBaseURL() {
39278
38907
  const parsedURL = new URL(this.url);
39279
38908
  const protocol = parsedURL.protocol === "wss:" ? "https:" : "http:";
@@ -39368,10 +38997,6 @@ ${codeText}
39368
38997
  const msg = message;
39369
38998
  if (this.connection)
39370
38999
  this.connection.lastReceiveTime = Date.now();
39371
- if (msg.a === "wikiMacro") {
39372
- this.handleWikiMacroReply(msg);
39373
- return;
39374
- }
39375
39000
  if ("err" in msg || msg.a === "pong") {
39376
39001
  this.handleMessage(msg);
39377
39002
  } else {
@@ -39388,7 +39013,6 @@ ${codeText}
39388
39013
  this.emit("ready");
39389
39014
  this.ready = true;
39390
39015
  this.connectionDisconnected = false;
39391
- this.loadWikiMacroLocks();
39392
39016
  }
39393
39017
  }
39394
39018
  try {
@@ -39466,10 +39090,6 @@ ${codeText}
39466
39090
  end(logout) {
39467
39091
  var _a, _b, _c, _d, _e;
39468
39092
  this.closed = true;
39469
- this.clearWikiMacroRequests("Document connection closed");
39470
- this.macroLocksListeners.clear();
39471
- this.macroLocks = [];
39472
- this.macroLocksKnown = false;
39473
39093
  this.renewTokenFunc = void 0;
39474
39094
  this.removeAllListeners();
39475
39095
  (_a = this.autoRenewToken) == null ? void 0 : _a.destroy();
@@ -39764,16 +39384,10 @@ ${codeText}
39764
39384
  return versions;
39765
39385
  }
39766
39386
  async getVersion(ver) {
39767
- return (await this.getVersionSnapshot(ver)).doc;
39768
- }
39769
- async getVersionSnapshot(ver) {
39770
39387
  const server = this.apiServer();
39771
39388
  const api = `${server}/versions/${ver}`;
39772
39389
  const ret = await this.request(api);
39773
- return {
39774
- doc: JSON.parse(ret.data.data),
39775
- documentVersion: typeof ret.data.documentVersion === "number" ? ret.data.documentVersion : void 0
39776
- };
39390
+ return JSON.parse(ret.data.data);
39777
39391
  }
39778
39392
  async getLatestVersion() {
39779
39393
  const server = this.apiServer();
@@ -40784,21 +40398,6 @@ ${codeText}
40784
40398
  this.editStatus = new EditStatus(options);
40785
40399
  this.client.connection.addListener("opReceived", this.handleOpReceived);
40786
40400
  }
40787
- requestWikiMacro(message) {
40788
- if (this.destroyed) {
40789
- return Promise.reject(new WikiMacroError({ code: "RESOURCE_SERVICE_UNAVAILABLE", message: "Document destroyed" }));
40790
- }
40791
- if (this.getUser().permission !== "w" && message.operation !== "locks" && message.operation !== "getEditResult" && message.operation !== "cancelEdit") {
40792
- return Promise.reject(new WikiMacroError({ code: "READ_ONLY" }));
40793
- }
40794
- return this.client.connection.requestWikiMacro(message);
40795
- }
40796
- onWikiMacroLocks(listener) {
40797
- return this.client.connection.onWikiMacroLocks(listener);
40798
- }
40799
- getDocumentVersion() {
40800
- return typeof this.doc.version === "number" ? this.doc.version : void 0;
40801
- }
40802
40401
  beginBatchUpdate() {
40803
40402
  this.doc.preventCompose = false;
40804
40403
  this.batching++;
@@ -40926,6 +40525,10 @@ ${codeText}
40926
40525
  });
40927
40526
  });
40928
40527
  }
40528
+ getDocumentVersion() {
40529
+ var _a;
40530
+ return (_a = this.doc.version) != null ? _a : void 0;
40531
+ }
40929
40532
  toJSON() {
40930
40533
  return editorDoc2DocObject(this.data());
40931
40534
  }
@@ -41216,10 +40819,6 @@ ${codeText}
41216
40819
  const data2 = await this.client.getVersion(ver);
41217
40820
  return editorDoc2DocObject(data2);
41218
40821
  }
41219
- async getVersionSnapshot(ver) {
41220
- const snapshot2 = await this.client.getVersionSnapshot(ver);
41221
- return { doc: editorDoc2DocObject(snapshot2.doc), documentVersion: snapshot2.documentVersion };
41222
- }
41223
40822
  async getLatestVersion() {
41224
40823
  const doc2 = await this.client.getLatestVersion();
41225
40824
  return editorDoc2DocObject(doc2);
@@ -41566,8 +41165,7 @@ ${codeText}
41566
41165
  class ShareDBLocalDoc extends LocalDoc {
41567
41166
  constructor(docObject, _options) {
41568
41167
  super(docObject, {
41569
- serverUrl: _options.serverUrl,
41570
- documentVersion: _options.documentVersion
41168
+ serverUrl: _options.serverUrl
41571
41169
  });
41572
41170
  __publicField(this, "_client");
41573
41171
  this._options = _options;
@@ -41674,16 +41272,10 @@ ${codeText}
41674
41272
  return versions;
41675
41273
  }
41676
41274
  async getVersion(ver) {
41677
- return (await this.getVersionSnapshot(ver)).doc;
41678
- }
41679
- async getVersionSnapshot(ver) {
41680
41275
  const server = this.apiServer();
41681
41276
  const api = `${server}/versions/${ver}`;
41682
41277
  const ret = await this.request(api);
41683
- return {
41684
- doc: JSON.parse(ret.data.data),
41685
- documentVersion: typeof ret.data.documentVersion === "number" ? ret.data.documentVersion : void 0
41686
- };
41278
+ return JSON.parse(ret.data.data);
41687
41279
  }
41688
41280
  async getLatestVersion() {
41689
41281
  const server = this.apiServer();
@@ -41807,10 +41399,6 @@ ${codeText}
41807
41399
  const data2 = await this.client.getVersion(ver);
41808
41400
  return editorDoc2DocObject(data2);
41809
41401
  }
41810
- async getVersionSnapshot(ver) {
41811
- const snapshot2 = await this.client.getVersionSnapshot(ver);
41812
- return { doc: editorDoc2DocObject(snapshot2.doc), documentVersion: snapshot2.documentVersion };
41813
- }
41814
41402
  async getLatestVersion() {
41815
41403
  const doc2 = await this.client.getLatestVersion();
41816
41404
  return editorDoc2DocObject(doc2);
@@ -64400,8 +63988,6 @@ $$${mathData.mathjaxText}$$
64400
63988
  const blockId = item.data;
64401
63989
  try {
64402
63990
  const block = editor.getBlockById(blockId);
64403
- if ((item.id === "delete" || item.id === "cut") && isWikiMacroElementLocked(editor, block))
64404
- return;
64405
63991
  if (item.id === "delete") {
64406
63992
  this.deleteBlock(editor, block);
64407
63993
  return;
@@ -64421,7 +64007,6 @@ $$${mathData.mathjaxText}$$
64421
64007
  commands(editor, blockElement) {
64422
64008
  const locked = isBlockLocked(editor, blockElement);
64423
64009
  const lockedBySelf = locked && isBlockLockedBySelf(editor, blockElement);
64424
- const macroLeased = isWikiMacroElementLocked(editor, blockElement);
64425
64010
  const data2 = getBlockId(blockElement);
64426
64011
  const isEnvSecure = window.isSecureContext;
64427
64012
  const isBlockExclusive = isExclusiveBlock(blockElement);
@@ -64443,7 +64028,7 @@ $$${mathData.mathjaxText}$$
64443
64028
  data: data2,
64444
64029
  icon: CutIcon,
64445
64030
  order: 20,
64446
- states: macroLeased || locked && !lockedBySelf || !isEnvSecure || isBlockExclusive ? ["disabled"] : [],
64031
+ states: locked && !lockedBySelf || !isEnvSecure || isBlockExclusive ? ["disabled"] : [],
64447
64032
  disableReason: !isEnvSecure ? i18n$1.t("copyCutProperty.unsafeEnvTips", {
64448
64033
  shortCut: shortcutToDisplayText("CtrlOrCmd+X"),
64449
64034
  operation: i18n$1.t("copyCutProperty.cut")
@@ -64455,7 +64040,7 @@ $$${mathData.mathjaxText}$$
64455
64040
  data: data2,
64456
64041
  icon: DeleteIcon,
64457
64042
  order: 30,
64458
- states: macroLeased || locked && !lockedBySelf || isBlockExclusive ? ["disabled"] : []
64043
+ states: locked && !lockedBySelf || isBlockExclusive ? ["disabled"] : []
64459
64044
  };
64460
64045
  return {
64461
64046
  group: "standard-block-actions",
@@ -64496,15 +64081,6 @@ $$${mathData.mathjaxText}$$
64496
64081
  this.menu.updateItems(items);
64497
64082
  this.commandBlock = this.currentBlock;
64498
64083
  });
64499
- __publicField(this, "handleMacroLocksChanged", () => {
64500
- if (!this.menu.isVisible)
64501
- return;
64502
- if (!this.currentBlock || !this.editor.contains(this.currentBlock)) {
64503
- this.close();
64504
- return;
64505
- }
64506
- this.handleShow();
64507
- });
64508
64084
  __publicField(this, "handleClose", () => {
64509
64085
  if (shouldFocusToEditor(this.editor)) {
64510
64086
  this.editor.focus();
@@ -64530,7 +64106,6 @@ $$${mathData.mathjaxText}$$
64530
64106
  this.menu.on("close", this.handleClose);
64531
64107
  this.menu.on("click", this.handleItemClick);
64532
64108
  editor.blockHooks.push(new StandardBlockActionHook());
64533
- editor.addListener("wikiMacroLocksChanged", this.handleMacroLocksChanged);
64534
64109
  }
64535
64110
  addFilter(id, filter) {
64536
64111
  var _a, _b;
@@ -64552,7 +64127,6 @@ $$${mathData.mathjaxText}$$
64552
64127
  return this.menu.isVisible;
64553
64128
  }
64554
64129
  destroy() {
64555
- this.editor.removeListener("wikiMacroLocksChanged", this.handleMacroLocksChanged);
64556
64130
  this.menu.destroy();
64557
64131
  }
64558
64132
  }
@@ -84090,21 +83664,11 @@ ${docStr}
84090
83664
  assert(logger$C, false, "no local actions for history doc");
84091
83665
  }
84092
83666
  class HistoryDoc extends EventCallbacks {
84093
- constructor(server, docObject, editorOptions, documentVersion) {
83667
+ constructor(server, docObject, editorOptions) {
84094
83668
  super();
84095
83669
  this.server = server;
84096
83670
  this.docObject = docObject;
84097
83671
  this.editorOptions = editorOptions;
84098
- this.documentVersion = documentVersion;
84099
- }
84100
- requestWikiMacro(message) {
84101
- return Promise.reject(new WikiMacroError({ code: "READ_ONLY", message: "History documents cannot edit Wiki macros" }));
84102
- }
84103
- onWikiMacroLocks(listener) {
84104
- throw new WikiMacroError({ code: "READ_ONLY", message: "History documents have no macro lock channel" });
84105
- }
84106
- getDocumentVersion() {
84107
- return this.documentVersion;
84108
83672
  }
84109
83673
  beginBatchUpdate() {
84110
83674
  return 0;
@@ -85097,7 +84661,6 @@ ${docStr}
85097
84661
  const forceRequestVersionAsLatest = !!((_d = this.versionOptions) == null ? void 0 : _d.forceRequestVersionAsLatest);
85098
84662
  let docObject;
85099
84663
  let historyData;
85100
- let snapshotVersion;
85101
84664
  if (from) {
85102
84665
  const requestVersion = forceRequestVersionAsLatest ? -1 : Math.max(version.version, from);
85103
84666
  const requestFrom = forceRequestVersionAsLatest ? from : Math.min(version.version, from);
@@ -85105,18 +84668,12 @@ ${docStr}
85105
84668
  docObject = ret.doc;
85106
84669
  historyData = ret.historyData;
85107
84670
  } else {
85108
- if (this.versionHelper.getVersionSnapshot) {
85109
- const snapshot2 = await this.versionHelper.getVersionSnapshot(version.version);
85110
- docObject = snapshot2.doc;
85111
- snapshotVersion = snapshot2.documentVersion;
85112
- } else {
85113
- docObject = await this.versionHelper.getVersion(version.version);
85114
- }
84671
+ docObject = await this.versionHelper.getVersion(version.version);
85115
84672
  historyData = [];
85116
84673
  }
85117
84674
  const { editorContainer: editorElement } = this.components;
85118
84675
  editorElement.innerHTML = "";
85119
- const historyDoc = new HistoryDoc(this.server, docObject, this.editorOptions, snapshotVersion);
84676
+ const historyDoc = new HistoryDoc(this.server, docObject, this.editorOptions);
85120
84677
  const viewer = this.provider.createHistoryEditor(editorElement, historyDoc);
85121
84678
  viewer.editorBlockRenders.registerRender(new OnesEditorHistoryRender());
85122
84679
  viewer.editorBoxes.registerBoxClass(HistoryDeletedTextBox);
@@ -85323,7 +84880,7 @@ ${docStr}
85323
84880
  }
85324
84881
  async function createOnesEditorHistoryDiff(parent, options) {
85325
84882
  var _a;
85326
- const historyDoc = new HistoryDoc(options.server, options.doc, options.editorOptions, options.documentVersion);
84883
+ const historyDoc = new HistoryDoc(options.server, options.doc, options.editorOptions);
85327
84884
  const viewer = options.provider.createHistoryEditor(parent, historyDoc);
85328
84885
  viewer.editorBlockRenders.registerRender(new OnesEditorHistoryRender());
85329
84886
  viewer.editorBoxes.registerBoxClass(HistoryDeletedTextBox);
@@ -98489,7 +98046,7 @@ ${JSON.stringify(error2, null, 2)}`);
98489
98046
  }
98490
98047
  }
98491
98048
  });
98492
- editor.version = "5.0.6-beta.DNP8216.3";
98049
+ editor.version = "5.0.6-beta.p8216.2";
98493
98050
  return editor;
98494
98051
  }
98495
98052
  function isDoc(doc2) {
@@ -98625,7 +98182,7 @@ ${JSON.stringify(error2, null, 2)}`);
98625
98182
  OnesEditorDropTarget.register(editor);
98626
98183
  OnesEditorTocProvider.register(editor);
98627
98184
  OnesEditorExclusiveBlock.register(editor);
98628
- editor.version = "5.0.6-beta.DNP8216.3";
98185
+ editor.version = "5.0.6-beta.p8216.2";
98629
98186
  return editor;
98630
98187
  } catch (error2) {
98631
98188
  try {
@@ -98768,7 +98325,7 @@ ${JSON.stringify(error2, null, 2)}`);
98768
98325
  }
98769
98326
  }
98770
98327
  });
98771
- editor.version = "5.0.6-beta.DNP8216.3";
98328
+ editor.version = "5.0.6-beta.p8216.2";
98772
98329
  return editor;
98773
98330
  }
98774
98331
  const emojis$1 = {
@@ -144786,10 +144343,10 @@ ${JSON.stringify(error2, null, 2)}`);
144786
144343
  exports2.UnorderedListIcon = UnorderedListIcon;
144787
144344
  exports2.UnorderedListItem = UnorderedListItem;
144788
144345
  exports2.VideoIcon = VideoIcon;
144346
+ exports2.WIKI_MACRO_TYPE = WIKI_MACRO_TYPE;
144789
144347
  exports2.WarningFilledIcon = WarningFilledIcon;
144790
144348
  exports2.WarningIcon = WarningIcon;
144791
144349
  exports2.WebPageIcon = WebPageIcon;
144792
- exports2.WikiMacroError = WikiMacroError;
144793
144350
  exports2.YoukuIcon = YoukuIcon;
144794
144351
  exports2.ZERO_WIDTH_SPACE_CHAR = ZERO_WIDTH_SPACE_CHAR;
144795
144352
  exports2.abbreviation = abbreviation;
@@ -145142,6 +144699,8 @@ ${JSON.stringify(error2, null, 2)}`);
145142
144699
  exports2.getTextWidth = getTextWidth;
145143
144700
  exports2.getToolbar = getToolbar;
145144
144701
  exports2.getToolbarDefaultItems = getToolbarDefaultItems;
144702
+ exports2.getWikiMacroExportSpec = getWikiMacroExportSpec;
144703
+ exports2.getWikiMacroResources = getWikiMacroResources;
145145
144704
  exports2.groupEachCommand = groupEachCommand;
145146
144705
  exports2.handleBlockElementUpdated = handleBlockElementUpdated$1;
145147
144706
  exports2.hasAltOnly = hasAltOnly;
@@ -145244,12 +144803,11 @@ ${JSON.stringify(error2, null, 2)}`);
145244
144803
  exports2.isToday = isToday;
145245
144804
  exports2.isValidOffset = isValidOffset;
145246
144805
  exports2.isVisibleBlock = isVisibleBlock;
145247
- exports2.isWikiMacroElementLocked = isWikiMacroElementLocked;
145248
144806
  exports2.isYesterday = isYesterday;
145249
144807
  exports2.loadJs = loadJs;
145250
144808
  exports2.loadJsPromise = loadJsPromise;
145251
144809
  exports2.lockers = lockers;
145252
- exports2.logger = logger$4w;
144810
+ exports2.logger = logger$4v;
145253
144811
  exports2.markdownToDoc = markdownToDoc;
145254
144812
  exports2.mergeCommands = mergeCommands;
145255
144813
  exports2.mergeDocs = mergeDocs;
@@ -145281,6 +144839,7 @@ ${JSON.stringify(error2, null, 2)}`);
145281
144839
  exports2.replaceAllCaseInsensitive = replaceAllCaseInsensitive;
145282
144840
  exports2.replaceAllText = replaceAllText;
145283
144841
  exports2.replaceText = replaceText;
144842
+ exports2.replaceWikiMacroResources = replaceWikiMacroResources;
145284
144843
  exports2.requestDownload = requestDownload;
145285
144844
  exports2.resetListStart = resetListStart;
145286
144845
  exports2.saveAs = saveAs$1;
@@ -145329,6 +144888,7 @@ ${JSON.stringify(error2, null, 2)}`);
145329
144888
  exports2.updateOpAttributes = updateOpAttributes;
145330
144889
  exports2.updateTextBlockContent = updateTextBlockContent;
145331
144890
  exports2.updateUrl = updateUrl;
144891
+ exports2.wikiMacroToText = wikiMacroToText;
145332
144892
  for (const k in tinyTypedEmitter) {
145333
144893
  if (k !== "default" && !exports2.hasOwnProperty(k))
145334
144894
  Object.defineProperty(exports2, k, {