@ones-editor/editor 2.1.2-beta.10 → 2.1.2-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -50732,7 +50732,307 @@ ${codeText}
50732
50732
  return false;
50733
50733
  }
50734
50734
  }
50735
- const logger$1T = getLogger("toolbar-handler");
50735
+ class MobileLinkProvider {
50736
+ constructor(editor, options) {
50737
+ __publicField(this, "id", "MobileLinkProvider");
50738
+ __publicField(this, "insertProvider");
50739
+ __publicField(this, "editProvider");
50740
+ __publicField(this, "getSelectedLinkChild", (editor, range) => {
50741
+ if (!range.isSimple()) {
50742
+ return null;
50743
+ }
50744
+ const { start, end } = range;
50745
+ if (start.blockId !== end.blockId) {
50746
+ return null;
50747
+ }
50748
+ const block = editor.getBlockById(start.blockId);
50749
+ const startChild = getTextBlockChild(block, start.offset);
50750
+ const endChild = getTextBlockChild(block, end.offset);
50751
+ if (startChild.next !== endChild.prev) {
50752
+ return null;
50753
+ }
50754
+ if (startChild.next && hasClass(startChild.next, "link")) {
50755
+ return startChild.next;
50756
+ }
50757
+ return null;
50758
+ });
50759
+ __publicField(this, "getAvailableCommands", (editor, block, range, params) => {
50760
+ var _a, _b;
50761
+ const editorRange = editor.selection.range;
50762
+ const child = this.getSelectedLinkChild(editor, editorRange);
50763
+ if (child && ((_a = this.options) == null ? void 0 : _a.linkMode) === "edit") {
50764
+ return this.editProvider.getAvailableCommands(editor, block, range, { child });
50765
+ }
50766
+ if (((_b = this.options) == null ? void 0 : _b.linkMode) === "insert" && !child) {
50767
+ const commands = this.insertProvider.getAvailableCommands(editor, block, range, { ...params, isFilter: true });
50768
+ commands.forEach((command) => {
50769
+ if (command.id === "insert-link") {
50770
+ command.name = i18n$1.t("link.title");
50771
+ }
50772
+ });
50773
+ return commands;
50774
+ }
50775
+ return [];
50776
+ });
50777
+ __publicField(this, "executeCommand", (editor, block, range, item, params, result) => {
50778
+ var _a, _b, _c, _d, _e, _f;
50779
+ const editorRange = editor.selection.range;
50780
+ const child = this.getSelectedLinkChild(editor, editorRange);
50781
+ if (child) {
50782
+ return (_c = (_b = (_a = this.editProvider) == null ? void 0 : _a.executeCommand) == null ? void 0 : _b.call(_a, editor, block, range, item, { child }, result)) != null ? _c : false;
50783
+ }
50784
+ return (_f = (_e = (_d = this.insertProvider) == null ? void 0 : _d.executeCommand) == null ? void 0 : _e.call(_d, editor, block, range, item, params, result)) != null ? _f : false;
50785
+ });
50786
+ this.options = options;
50787
+ this.insertProvider = new LinkProvider(editor);
50788
+ this.editProvider = new EditLinkProvider();
50789
+ }
50790
+ }
50791
+ const logger$1T = getLogger("readonly-toolbar");
50792
+ const SEP = {
50793
+ id: "",
50794
+ name: "",
50795
+ type: "separator"
50796
+ };
50797
+ function isCodeTextBlock$1(editor, block) {
50798
+ if (!isTextKindBlock(editor, block)) {
50799
+ return false;
50800
+ }
50801
+ const container = getParentContainer(block);
50802
+ const parentBlock = getParentBlock(container);
50803
+ if (!parentBlock) {
50804
+ return false;
50805
+ }
50806
+ return getBlockType(parentBlock) === "code";
50807
+ }
50808
+ class ReadonlyToolbar {
50809
+ constructor(editor) {
50810
+ __publicField(this, "toolbar");
50811
+ __publicField(this, "toolbarType", "text");
50812
+ __publicField(this, "mouseDown", false);
50813
+ __publicField(this, "hoveringBlock", null);
50814
+ __publicField(this, "hoveringTextChild", null);
50815
+ __publicField(this, "oldRange", null);
50816
+ __publicField(this, "providers", []);
50817
+ __publicField(this, "handleButtonClick", (toolbar2, item) => {
50818
+ const tooltip = this.editor.getCustom("editor-tooltip");
50819
+ tooltip.lastClickButtonId = item.id;
50820
+ const commandProvider = item.commandProvider;
50821
+ commandProvider.executeCommand(this.editor, item, {
50822
+ hoveringBlock: this.hoveringBlock,
50823
+ hoveringTextChild: this.hoveringTextChild,
50824
+ bar: this.toolbar
50825
+ });
50826
+ });
50827
+ __publicField(this, "handleClose", () => {
50828
+ if (shouldFocusToEditor(this.editor)) {
50829
+ this.editor.focus({
50830
+ preventScroll: true
50831
+ });
50832
+ }
50833
+ });
50834
+ __publicField(this, "handleClosing", (bar2, event) => {
50835
+ return true;
50836
+ });
50837
+ __publicField(this, "handleDocumentMouseDown", (event) => {
50838
+ if (event.button === 0) {
50839
+ document.addEventListener("mouseup", this.handleDocumentMouseUp);
50840
+ this.mouseDown = true;
50841
+ }
50842
+ });
50843
+ __publicField(this, "handleDocumentMouseUp", () => {
50844
+ document.removeEventListener("mouseup", this.handleDocumentMouseUp);
50845
+ this.mouseDown = false;
50846
+ const selectedItem = this.toolbar.getSelectedItem();
50847
+ if (this.toolbarType === "object" && ((selectedItem == null ? void 0 : selectedItem.dropdown) || (selectedItem == null ? void 0 : selectedItem.clickToClose) === false)) {
50848
+ return;
50849
+ }
50850
+ this.handleSelectionChange(this.editor);
50851
+ });
50852
+ __publicField(this, "handleSelectionChange", debounce__default.default((editor) => {
50853
+ var _a;
50854
+ assert(logger$1T, editor === this.editor, "editor mismatch");
50855
+ if (!editor.readonly) {
50856
+ this.toolbar.close("selectionChange");
50857
+ return;
50858
+ }
50859
+ if (editor.selection.range.isCollapsed() || this.mouseDown) {
50860
+ if (this.toolbarType === "object") {
50861
+ const element = (_a = this.toolbar.tippyInstance) == null ? void 0 : _a.reference;
50862
+ const focusedBlock = this.editor.selection.focusedBlock;
50863
+ const selectedItem = this.toolbar.getSelectedItem();
50864
+ if (element && isChildNode(element, focusedBlock) || (selectedItem == null ? void 0 : selectedItem.dropdown)) {
50865
+ return;
50866
+ }
50867
+ }
50868
+ this.toolbar.close("selectionChange");
50869
+ this.oldRange = null;
50870
+ return;
50871
+ }
50872
+ const selectedBlocks = editor.selection.range.getSelectedBlocks();
50873
+ if (selectedBlocks.length === 0) {
50874
+ this.toolbar.close("selectionChange");
50875
+ this.oldRange = null;
50876
+ return;
50877
+ }
50878
+ if (this.oldRange) {
50879
+ if (this.oldRange.isEqual(editor.selection.range)) {
50880
+ return;
50881
+ }
50882
+ }
50883
+ this.oldRange = editor.selection.range;
50884
+ this.showTextToolbar("selectionChange");
50885
+ }, 50));
50886
+ __publicField(this, "handleHoveringBlockChildChange", (block, child, old, event) => {
50887
+ var _a;
50888
+ if (this.toolbarType === "object" && ((_a = this.toolbar.subBar) == null ? void 0 : _a.isVisible)) {
50889
+ return;
50890
+ }
50891
+ if (this.hoveringBlock === block && this.hoveringTextChild === child) {
50892
+ return;
50893
+ }
50894
+ this.hoveringBlock = block;
50895
+ this.hoveringTextChild = child;
50896
+ if (this.toolbarType === "text" && this.toolbar.isVisible) {
50897
+ return;
50898
+ }
50899
+ if (!block) {
50900
+ this.toolbar.close("fromHover");
50901
+ }
50902
+ });
50903
+ __publicField(this, "groupCommands", (allCommands) => {
50904
+ var _a, _b;
50905
+ const allCommandsMap = /* @__PURE__ */ new Map();
50906
+ for (let i = 0; i < allCommands.length; i++) {
50907
+ const groupOrder = (_a = allCommands[i].groupOrder) != null ? _a : 0;
50908
+ if (allCommandsMap.has(groupOrder)) {
50909
+ (_b = allCommandsMap.get(groupOrder)) == null ? void 0 : _b.push(allCommands[i]);
50910
+ } else {
50911
+ allCommandsMap.set(groupOrder, [allCommands[i]]);
50912
+ }
50913
+ }
50914
+ const commandsChunk = [];
50915
+ allCommandsMap.forEach((value) => {
50916
+ commandsChunk.push(value.sort((item1, item2) => {
50917
+ var _a2, _b2;
50918
+ return ((_a2 = item1.order) != null ? _a2 : 0) - ((_b2 = item2.order) != null ? _b2 : 0);
50919
+ }));
50920
+ });
50921
+ if (commandsChunk.length === 0) {
50922
+ return [];
50923
+ }
50924
+ const commands = commandsChunk.reduce((prev, curr) => prev.concat([SEP, ...curr]), []);
50925
+ commands.shift();
50926
+ return commands;
50927
+ });
50928
+ this.editor = editor;
50929
+ const popover = editor.options.componentsOptions.popover;
50930
+ this.toolbar = new ManualToolbar([], void 0, {
50931
+ tooltipId: editor.clientId,
50932
+ id: "editor-readonly-toolbar",
50933
+ overflowBoundary: popover == null ? void 0 : popover.overflowBoundary,
50934
+ refuseOverflow: true,
50935
+ padding: 20
50936
+ });
50937
+ this.toolbar.on("click", this.handleButtonClick);
50938
+ this.toolbar.on("close", this.handleClose);
50939
+ this.toolbar.on("closing", this.handleClosing);
50940
+ this.bindEvents();
50941
+ editor.addListener("selectionChanged", this.handleSelectionChange);
50942
+ OnesEditorHoveringBlock.get(editor).addListener("childChange", this.handleHoveringBlockChildChange);
50943
+ OnesEditorHoveringBlock.get(editor).addFilter(this);
50944
+ }
50945
+ destroy() {
50946
+ this.unbindEvents();
50947
+ this.toolbar.destroy();
50948
+ this.editor.removeListener("selectionChanged", this.handleSelectionChange);
50949
+ OnesEditorHoveringBlock.get(this.editor).removeListener("childChange", this.handleHoveringBlockChildChange);
50950
+ this.providers.forEach((provider) => {
50951
+ var _a;
50952
+ (_a = provider.destroy) == null ? void 0 : _a.call(provider);
50953
+ });
50954
+ }
50955
+ addProvider(provider) {
50956
+ this.providers.push(provider);
50957
+ }
50958
+ isInBlock(block, event) {
50959
+ var _a, _b;
50960
+ if (block !== this.hoveringBlock) {
50961
+ return false;
50962
+ }
50963
+ if (event.target && event.target instanceof Node && (this.toolbar.popper && isChildNode(this.toolbar.popper, event.target) || ((_a = this.toolbar.subBar) == null ? void 0 : _a.popper) && isChildNode((_b = this.toolbar.subBar) == null ? void 0 : _b.popper, event.target))) {
50964
+ return true;
50965
+ }
50966
+ return false;
50967
+ }
50968
+ bindEvents() {
50969
+ document.addEventListener("mousedown", this.handleDocumentMouseDown);
50970
+ }
50971
+ unbindEvents() {
50972
+ document.removeEventListener("mousedown", this.handleDocumentMouseDown);
50973
+ }
50974
+ showTextToolbar(reason) {
50975
+ var _a, _b;
50976
+ let commands = [];
50977
+ const range = this.editor.selection.range;
50978
+ this.providers.forEach((provider) => {
50979
+ if (provider.getTextCommands) {
50980
+ const textCommands = provider.getTextCommands(this.editor, range).map((command) => {
50981
+ const item = {
50982
+ ...command,
50983
+ commandProvider: provider
50984
+ };
50985
+ return item;
50986
+ });
50987
+ commands.push(...textCommands);
50988
+ }
50989
+ });
50990
+ commands = this.groupCommands(commands);
50991
+ if (commands.length === 0) {
50992
+ this.toolbar.close("cancelBar");
50993
+ return;
50994
+ }
50995
+ const selectedBlocks = range.getSelectedBlocks();
50996
+ if (selectedBlocks.length === 0) {
50997
+ return;
50998
+ }
50999
+ const firstBlock = selectedBlocks[0];
51000
+ if (!firstBlock) {
51001
+ return;
51002
+ }
51003
+ if (isCodeTextBlock$1(this.editor, firstBlock.block)) {
51004
+ return;
51005
+ }
51006
+ if (selectedBlocks.length === 1) {
51007
+ if (isEmbedBlock(firstBlock.block)) {
51008
+ return;
51009
+ }
51010
+ if (isComplexKindBlock(this.editor, firstBlock.block) && range.isSimple()) {
51011
+ return;
51012
+ }
51013
+ }
51014
+ if (isTitleBlock$2(firstBlock.block)) {
51015
+ this.toolbar.close("selectionChange");
51016
+ return;
51017
+ }
51018
+ this.toolbar.updateItems(commands);
51019
+ const lastBlock2 = selectedBlocks[selectedBlocks.length - 1];
51020
+ const reverseToolbar = !this.editor.selection.range.isReverse() && lastBlock2 !== firstBlock;
51021
+ const selectedBlock = reverseToolbar ? lastBlock2 : firstBlock;
51022
+ const rect = getReferenceClientRect(this.editor, selectedBlock);
51023
+ const anchor2 = createBlockAnchor(this.editor, selectedBlock.block, "editor-readonly-toolbar", rect);
51024
+ this.toolbar.manualShow(anchor2, {
51025
+ placement: reverseToolbar ? "bottom" : "top",
51026
+ offset: [0, reverseToolbar ? 5 : 10]
51027
+ });
51028
+ (_b = (_a = this.toolbar.tippyInstance) == null ? void 0 : _a.popperInstance) == null ? void 0 : _b.update();
51029
+ }
51030
+ static isVisible() {
51031
+ const visible = !!document.querySelector('[data-command-bar-id="editor-readonly-toolbar"]');
51032
+ return visible;
51033
+ }
51034
+ }
51035
+ const logger$1S = getLogger("toolbar-handler");
50736
51036
  class OnesEditorToolbar {
50737
51037
  constructor(editor) {
50738
51038
  __publicField(this, "id", "editor-toolbar");
@@ -50819,7 +51119,7 @@ ${codeText}
50819
51119
  });
50820
51120
  __publicField(this, "handleSelectionChange", debounce__default.default((editor) => {
50821
51121
  var _a;
50822
- assert(logger$1T, editor === this.editor, "editor mismatch");
51122
+ assert(logger$1S, editor === this.editor, "editor mismatch");
50823
51123
  if (editor.selection.range.isCollapsed() || this.mouseDown) {
50824
51124
  if (this.toolbarType === "object") {
50825
51125
  const element = (_a = this.toolbar.tippyInstance) == null ? void 0 : _a.reference;
@@ -51021,6 +51321,9 @@ ${codeText}
51021
51321
  if (this.mouseDown) {
51022
51322
  return;
51023
51323
  }
51324
+ if (ReadonlyToolbar.isVisible()) {
51325
+ return;
51326
+ }
51024
51327
  const block = this.hoveringBlock;
51025
51328
  const child = this.hoveringTextChild;
51026
51329
  const { commands, element } = getObjectCommands(this.editor, block, child);
@@ -51131,7 +51434,7 @@ ${codeText}
51131
51434
  this.error = error2;
51132
51435
  }
51133
51436
  }
51134
- const logger$1S = getLogger("mathjax-converter");
51437
+ const logger$1R = getLogger("mathjax-converter");
51135
51438
  const MATHJAX_SCRIPT_ID = "MathJax-script";
51136
51439
  const MATHJAX_BUFFER = 30;
51137
51440
  const REDUCED_UNIT = 8;
@@ -51180,7 +51483,7 @@ ${codeText}
51180
51483
  const svg = result.querySelector("svg");
51181
51484
  return svg.outerHTML;
51182
51485
  } catch (err) {
51183
- logger$1S.error(err);
51486
+ logger$1R.error(err);
51184
51487
  throw err;
51185
51488
  } finally {
51186
51489
  lockers.release(lockId);
@@ -51228,7 +51531,7 @@ ${codeText}
51228
51531
  ...perfectState
51229
51532
  };
51230
51533
  }
51231
- const logger$1R = getLogger("edit-mathjax");
51534
+ const logger$1Q = getLogger("edit-mathjax");
51232
51535
  class MathjaxEditor {
51233
51536
  constructor() {
51234
51537
  __publicField(this, "editMathjaxPopup", null);
@@ -51299,9 +51602,9 @@ ${codeText}
51299
51602
  this.observer.observe(textarea2);
51300
51603
  }
51301
51604
  getTextarea() {
51302
- assert(logger$1R, this.editMathjaxPopup, "no exists mathjax editor popup");
51605
+ assert(logger$1Q, this.editMathjaxPopup, "no exists mathjax editor popup");
51303
51606
  const textarea2 = this.editMathjaxPopup.content.querySelector("textarea");
51304
- assert(logger$1R, textarea2, "no textarea");
51607
+ assert(logger$1Q, textarea2, "no textarea");
51305
51608
  return textarea2;
51306
51609
  }
51307
51610
  destroy() {
@@ -51371,7 +51674,7 @@ ${codeText}
51371
51674
  };
51372
51675
  editMathjax(editor, box, data2.tex, update2);
51373
51676
  }
51374
- const logger$1Q = getLogger("mathjax-box");
51677
+ const logger$1P = getLogger("mathjax-box");
51375
51678
  function updateCaret(editor, event) {
51376
51679
  editor.selection.updateSelection(null);
51377
51680
  const target = event.target;
@@ -51462,7 +51765,7 @@ ${codeText}
51462
51765
  };
51463
51766
  editor.updateBoxData(newData);
51464
51767
  }).catch((err) => {
51465
- logger$1Q.error(`failed to convert and upload mathjax: ${JSON.stringify(err)}`);
51768
+ logger$1P.error(`failed to convert and upload mathjax: ${JSON.stringify(err)}`);
51466
51769
  });
51467
51770
  return data2;
51468
51771
  }
@@ -51481,7 +51784,7 @@ ${codeText}
51481
51784
  }
51482
51785
  function handleClickBox$3(editor, box, event) {
51483
51786
  const parentBlock = getParentBlock(box);
51484
- assert(logger$1Q, parentBlock, "failed to get block");
51787
+ assert(logger$1P, parentBlock, "failed to get block");
51485
51788
  if (!editor.isBlockWritable(parentBlock)) {
51486
51789
  return;
51487
51790
  }
@@ -57233,7 +57536,7 @@ $$${mathData.mathjaxText}$$
57233
57536
  const docBlockText = { insert: " ", attributes: data2 };
57234
57537
  return docBlockText;
57235
57538
  }
57236
- const logger$1P = getLogger("StatusBoxEditor");
57539
+ const logger$1O = getLogger("StatusBoxEditor");
57237
57540
  class StatusBoxEditor {
57238
57541
  constructor(editor) {
57239
57542
  __publicField(this, "linkPopup", null);
@@ -57256,10 +57559,10 @@ $$${mathData.mathjaxText}$$
57256
57559
  });
57257
57560
  __publicField(this, "handClose", () => {
57258
57561
  var _a;
57259
- assert(logger$1P, this.boxElement, "boxElement not found");
57562
+ assert(logger$1O, this.boxElement, "boxElement not found");
57260
57563
  const boxData = this.editor.getBoxData(this.boxElement);
57261
57564
  const block = getParentBlock(this.boxElement);
57262
- assert(logger$1P, block, "block not found");
57565
+ assert(logger$1O, block, "block not found");
57263
57566
  if (!boxData.title) {
57264
57567
  const offset = getChildOffset(block, this.boxElement);
57265
57568
  this.editor.deleteTextFromBlock(block, offset.start, 1);
@@ -57297,7 +57600,7 @@ $$${mathData.mathjaxText}$$
57297
57600
  return;
57298
57601
  }
57299
57602
  const color = lodash.exports.capitalize(e2.target.getAttribute("data-color"));
57300
- assert(logger$1P, this.boxElement, "boxElement not found");
57603
+ assert(logger$1O, this.boxElement, "boxElement not found");
57301
57604
  const data2 = this.editor.getBoxData(this.boxElement);
57302
57605
  this.statusPalette.changeColor(color);
57303
57606
  const newData = { ...data2, color };
@@ -57314,7 +57617,7 @@ $$${mathData.mathjaxText}$$
57314
57617
  });
57315
57618
  __publicField(this, "onTitleChange", (e2) => {
57316
57619
  const title = e2.target.value;
57317
- assert(logger$1P, this.boxElement, "boxElement not found");
57620
+ assert(logger$1O, this.boxElement, "boxElement not found");
57318
57621
  const data2 = this.editor.getBoxData(this.boxElement);
57319
57622
  const newData = { ...data2, title: title.trim() };
57320
57623
  this.editor.updateBoxData(newData, { noFocus: true });
@@ -57427,7 +57730,7 @@ $$${mathData.mathjaxText}$$
57427
57730
  toStandardText: toStandardText$1,
57428
57731
  matchText: matchText$1
57429
57732
  };
57430
- const logger$1O = getLogger("status-box-command");
57733
+ const logger$1N = getLogger("status-box-command");
57431
57734
  class StatusBoxCommand {
57432
57735
  static get commands() {
57433
57736
  return [
@@ -57446,7 +57749,7 @@ $$${mathData.mathjaxText}$$
57446
57749
  const block = editor.getBlockByIndex(containerId, blockIndex);
57447
57750
  const boxOp = createEmptyStatusBox();
57448
57751
  const { start } = editor.selection.range;
57449
- assert(logger$1O, isSimpleBlockPosition(start), "invalid block position");
57752
+ assert(logger$1N, isSimpleBlockPosition(start), "invalid block position");
57450
57753
  editor.insertBoxToBlock(block, start.offset, boxOp.attributes);
57451
57754
  const box = editor.getBoxById((_a = boxOp.attributes) == null ? void 0 : _a.id);
57452
57755
  editor.addCustom("status-box", (editor2) => new StatusBoxEditor(editor2)).editorStatus(box);
@@ -57543,7 +57846,7 @@ $$${mathData.mathjaxText}$$
57543
57846
  "ja-JP": jaJP$r
57544
57847
  };
57545
57848
  i18n$1.mergeLang(langs$2);
57546
- const logger$1N = getLogger("inline-box-items");
57849
+ const logger$1M = getLogger("inline-box-items");
57547
57850
  function insertEmptyBlockMath(editor, containerId, blockIndex) {
57548
57851
  return editor.undoManager.runInGroup(() => {
57549
57852
  var _a;
@@ -57554,7 +57857,7 @@ $$${mathData.mathjaxText}$$
57554
57857
  const boxOp = createEmptyMathjaxBox();
57555
57858
  editor.setBlockText(block, [boxOp]);
57556
57859
  const boxId = (_a = boxOp.attributes) == null ? void 0 : _a.id;
57557
- assert(logger$1N, boxId, "mathjax box id is empty");
57860
+ assert(logger$1M, boxId, "mathjax box id is empty");
57558
57861
  setTimeout(() => {
57559
57862
  const box = editor.getBoxById(boxId);
57560
57863
  editMathjaxBox(editor, box);
@@ -57567,11 +57870,11 @@ $$${mathData.mathjaxText}$$
57567
57870
  var _a;
57568
57871
  const block = editor.getBlockByIndex(containerId, blockIndex);
57569
57872
  const range = editor.selection.range;
57570
- assert(logger$1N, isSimpleBlockPosition(range.start), "invalid block position");
57873
+ assert(logger$1M, isSimpleBlockPosition(range.start), "invalid block position");
57571
57874
  const boxOp = createEmptyMathjaxBox();
57572
57875
  editor.insertBoxToBlock(block, range.start.offset, boxOp.attributes);
57573
57876
  const boxId = (_a = boxOp.attributes) == null ? void 0 : _a.id;
57574
- assert(logger$1N, boxId, "mathjax box id is empty");
57877
+ assert(logger$1M, boxId, "mathjax box id is empty");
57575
57878
  setTimeout(() => {
57576
57879
  const box = editor.getBoxById(boxId);
57577
57880
  editMathjaxBox(editor, box);
@@ -57738,7 +58041,7 @@ $$${mathData.mathjaxText}$$
57738
58041
  }
57739
58042
  }
57740
58043
  };
57741
- const logger$1M = getLogger("insert-menu");
58044
+ const logger$1L = getLogger("insert-menu");
57742
58045
  const injectGroup = (commands, group, startIndex) => {
57743
58046
  commands.forEach((command, index2) => {
57744
58047
  command.group = group;
@@ -57877,7 +58180,7 @@ $$${mathData.mathjaxText}$$
57877
58180
  return true;
57878
58181
  }
57879
58182
  const blockId = getBlockId(block);
57880
- assert(logger$1M, range.isSimple(), "invalid range");
58183
+ assert(logger$1L, range.isSimple(), "invalid range");
57881
58184
  const offset = range.start.offset;
57882
58185
  if (quickItem.commandProvider) {
57883
58186
  const params2 = { from: "quick-menu", blockId, offset };
@@ -57913,7 +58216,7 @@ $$${mathData.mathjaxText}$$
57913
58216
  });
57914
58217
  }
57915
58218
  }
57916
- const logger$1L = getLogger("quick-command-providers");
58219
+ const logger$1K = getLogger("quick-command-providers");
57917
58220
  class QuickCommandProviders extends AbstractProvider {
57918
58221
  constructor(editor) {
57919
58222
  super(editor);
@@ -57933,7 +58236,7 @@ $$${mathData.mathjaxText}$$
57933
58236
  }
57934
58237
  getCommands(range) {
57935
58238
  var _a, _b;
57936
- assert(logger$1L, range.start.blockId === range.end.blockId, "invalid range");
58239
+ assert(logger$1K, range.start.blockId === range.end.blockId, "invalid range");
57937
58240
  const commandsMap = /* @__PURE__ */ new Map();
57938
58241
  const block = this.editor.getBlockById(range.anchor.blockId);
57939
58242
  const container = getParentContainer(block);
@@ -58701,7 +59004,7 @@ $$${mathData.mathjaxText}$$
58701
59004
  return false;
58702
59005
  }
58703
59006
  }
58704
- const logger$1K = getLogger("block-command-providers");
59007
+ const logger$1J = getLogger("block-command-providers");
58705
59008
  class BlockCommandProviders extends AbstractProvider {
58706
59009
  constructor(editor, afterCommandCallback) {
58707
59010
  super(editor);
@@ -58722,7 +59025,7 @@ $$${mathData.mathjaxText}$$
58722
59025
  this.registerCommandProvider(new InsertGroupProvider(editor));
58723
59026
  }
58724
59027
  getCommands(range) {
58725
- assert(logger$1K, range.start.blockId === range.end.blockId, "invalid range");
59028
+ assert(logger$1J, range.start.blockId === range.end.blockId, "invalid range");
58726
59029
  const block = this.editor.getBlockById(range.anchor.blockId);
58727
59030
  const commandsMap = /* @__PURE__ */ new Map();
58728
59031
  let startIndex = 100;
@@ -58736,7 +59039,7 @@ $$${mathData.mathjaxText}$$
58736
59039
  return this.filterItems(range, commands);
58737
59040
  }
58738
59041
  }
58739
- const logger$1J = getLogger("standard-block-actions");
59042
+ const logger$1I = getLogger("standard-block-actions");
58740
59043
  class StandardBlockActionHook {
58741
59044
  constructor() {
58742
59045
  __publicField(this, "executeCommand", (editor, bloockElement, item) => {
@@ -58755,7 +59058,7 @@ $$${mathData.mathjaxText}$$
58755
59058
  this.deleteBlock(editor, block);
58756
59059
  }
58757
59060
  } catch (err) {
58758
- logger$1J.error(`failed to execute block command: ${JSON.stringify(err)}`);
59061
+ logger$1I.error(`failed to execute block command: ${JSON.stringify(err)}`);
58759
59062
  }
58760
59063
  });
58761
59064
  }
@@ -58823,7 +59126,7 @@ $$${mathData.mathjaxText}$$
58823
59126
  }
58824
59127
  }
58825
59128
  }
58826
- const logger$1I = getLogger("block-menu");
59129
+ const logger$1H = getLogger("block-menu");
58827
59130
  class BlockMenu {
58828
59131
  constructor(editor) {
58829
59132
  __publicField(this, "menu");
@@ -58831,7 +59134,7 @@ $$${mathData.mathjaxText}$$
58831
59134
  __publicField(this, "commandBlock", null);
58832
59135
  __publicField(this, "blockCommandProviders");
58833
59136
  __publicField(this, "handleShow", () => {
58834
- assert(logger$1I, this.currentBlock, "no target block before show block menu");
59137
+ assert(logger$1H, this.currentBlock, "no target block before show block menu");
58835
59138
  const items = this.blockCommandProviders.getCommands(this.editor.selection.range);
58836
59139
  this.menu.updateItems(items);
58837
59140
  this.commandBlock = this.currentBlock;
@@ -58842,7 +59145,7 @@ $$${mathData.mathjaxText}$$
58842
59145
  }
58843
59146
  });
58844
59147
  __publicField(this, "handleItemClick", (bar2, item) => {
58845
- assert(logger$1I, this.commandBlock, "no command block before show block menu");
59148
+ assert(logger$1H, this.commandBlock, "no command block before show block menu");
58846
59149
  this.blockCommandProviders.executeCommand(this.editor.selection.range, item);
58847
59150
  });
58848
59151
  __publicField(this, "close", () => {
@@ -58882,7 +59185,7 @@ $$${mathData.mathjaxText}$$
58882
59185
  this.menu.destroy();
58883
59186
  }
58884
59187
  }
58885
- const logger$1H = getLogger("text-styles");
59188
+ const logger$1G = getLogger("text-styles");
58886
59189
  function getIntersectionStyles(text2) {
58887
59190
  const getOpStyle = (op) => {
58888
59191
  if (!op.attributes) {
@@ -58916,10 +59219,10 @@ $$${mathData.mathjaxText}$$
58916
59219
  return new Map(Object.entries(attributes));
58917
59220
  }
58918
59221
  function applyTextStyle(editor, block, range, style2, value) {
58919
- assert(logger$1H, range.isSimple(), "invalid range");
59222
+ assert(logger$1G, range.isSimple(), "invalid range");
58920
59223
  const { start, end } = range;
58921
- assert(logger$1H, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
58922
- assert(logger$1H, style2.startsWith("style-"), "invalid style");
59224
+ assert(logger$1G, start.blockId === end.blockId && start.blockId === getBlockId(block), "invalid range");
59225
+ assert(logger$1G, style2.startsWith("style-"), "invalid style");
58923
59226
  const oldText = editor.getBlockText(block);
58924
59227
  let newText = oldText;
58925
59228
  if (style2 === "style-sub") {
@@ -58965,13 +59268,13 @@ $$${mathData.mathjaxText}$$
58965
59268
  return standardItems;
58966
59269
  }
58967
59270
  function getSubText(editor, block, range) {
58968
- assert(logger$1H, range.isSimple(), "nor a simple range");
59271
+ assert(logger$1G, range.isSimple(), "nor a simple range");
58969
59272
  const { start, end } = range;
58970
- assert(logger$1H, start.isSimple(), "is not a simple block position");
58971
- assert(logger$1H, end.isSimple(), "is not a simple block position");
58972
- assert(logger$1H, isTextKindBlock(editor, block), "invalid block type, not a text kind block");
59273
+ assert(logger$1G, start.isSimple(), "is not a simple block position");
59274
+ assert(logger$1G, end.isSimple(), "is not a simple block position");
59275
+ assert(logger$1G, isTextKindBlock(editor, block), "invalid block type, not a text kind block");
58973
59276
  const blockId = getBlockId(block);
58974
- assert(logger$1H, start.blockId === blockId && end.blockId === blockId, "invalid range");
59277
+ assert(logger$1G, start.blockId === blockId && end.blockId === blockId, "invalid range");
58975
59278
  const text2 = editor.getBlockText(block);
58976
59279
  let subText2 = [];
58977
59280
  if (start.offset === end.offset) {
@@ -58983,7 +59286,7 @@ $$${mathData.mathjaxText}$$
58983
59286
  }
58984
59287
  return subText2;
58985
59288
  }
58986
- const logger$1G = getLogger("text-commands");
59289
+ const logger$1F = getLogger("text-commands");
58987
59290
  function getCommands$1(editor, text2) {
58988
59291
  const StandardTextStyles = {
58989
59292
  "style-bold": [i18n$1.t("commands.bold"), shortcutToDisplayText("CtrlOrCmd+B"), BoldIcon],
@@ -59001,13 +59304,13 @@ $$${mathData.mathjaxText}$$
59001
59304
  }
59002
59305
  function executeStyleCommand(editor, block, range, command, params, result) {
59003
59306
  if (!command.startsWith("style-")) {
59004
- logger$1G.warn(`unknown command: ${command}`);
59307
+ logger$1F.warn(`unknown command: ${command}`);
59005
59308
  return false;
59006
59309
  }
59007
59310
  const value = params == null ? void 0 : params.value;
59008
59311
  const type = typeof value;
59009
59312
  if (type !== "string" && type !== "number" && type !== "boolean" && type !== "undefined") {
59010
- logger$1G.warn(`invalid value type, accept string | number | boolean | undefined, current is ${type}`);
59313
+ logger$1F.warn(`invalid value type, accept string | number | boolean | undefined, current is ${type}`);
59011
59314
  return false;
59012
59315
  }
59013
59316
  const newText = applyTextStyle(editor, block, range, command, value);
@@ -59231,7 +59534,7 @@ $$${mathData.mathjaxText}$$
59231
59534
  this.providers = [new TextScriptProvider(editor)];
59232
59535
  }
59233
59536
  }
59234
- const logger$1F = getLogger("text-command-provider");
59537
+ const logger$1E = getLogger("text-command-provider");
59235
59538
  class TextCommandProvider {
59236
59539
  constructor(editor, options) {
59237
59540
  __publicField(this, "id", "TextCommandProvider");
@@ -59351,7 +59654,7 @@ $$${mathData.mathjaxText}$$
59351
59654
  }
59352
59655
  static fromTextCommandId(id) {
59353
59656
  const prefix = "text/";
59354
- assert(logger$1F, id.startsWith(prefix), `invalid item id: ${id}`);
59657
+ assert(logger$1E, id.startsWith(prefix), `invalid item id: ${id}`);
59355
59658
  return id.substring(prefix.length);
59356
59659
  }
59357
59660
  }
@@ -59403,302 +59706,6 @@ $$${mathData.mathjaxText}$$
59403
59706
  return true;
59404
59707
  }
59405
59708
  }
59406
- class MobileLinkProvider {
59407
- constructor(editor, options) {
59408
- __publicField(this, "id", "MobileLinkProvider");
59409
- __publicField(this, "insertProvider");
59410
- __publicField(this, "editProvider");
59411
- __publicField(this, "getSelectedLinkChild", (editor, range) => {
59412
- if (!range.isSimple()) {
59413
- return null;
59414
- }
59415
- const { start, end } = range;
59416
- if (start.blockId !== end.blockId) {
59417
- return null;
59418
- }
59419
- const block = editor.getBlockById(start.blockId);
59420
- const startChild = getTextBlockChild(block, start.offset);
59421
- const endChild = getTextBlockChild(block, end.offset);
59422
- if (startChild.next !== endChild.prev) {
59423
- return null;
59424
- }
59425
- if (startChild.next && hasClass(startChild.next, "link")) {
59426
- return startChild.next;
59427
- }
59428
- return null;
59429
- });
59430
- __publicField(this, "getAvailableCommands", (editor, block, range, params) => {
59431
- var _a, _b;
59432
- const editorRange = editor.selection.range;
59433
- const child = this.getSelectedLinkChild(editor, editorRange);
59434
- if (child && ((_a = this.options) == null ? void 0 : _a.linkMode) === "edit") {
59435
- return this.editProvider.getAvailableCommands(editor, block, range, { child });
59436
- }
59437
- if (((_b = this.options) == null ? void 0 : _b.linkMode) === "insert" && !child) {
59438
- const commands = this.insertProvider.getAvailableCommands(editor, block, range, { ...params, isFilter: true });
59439
- commands.forEach((command) => {
59440
- if (command.id === "insert-link") {
59441
- command.name = i18n$1.t("link.title");
59442
- }
59443
- });
59444
- return commands;
59445
- }
59446
- return [];
59447
- });
59448
- __publicField(this, "executeCommand", (editor, block, range, item, params, result) => {
59449
- var _a, _b, _c, _d, _e, _f;
59450
- const editorRange = editor.selection.range;
59451
- const child = this.getSelectedLinkChild(editor, editorRange);
59452
- if (child) {
59453
- return (_c = (_b = (_a = this.editProvider) == null ? void 0 : _a.executeCommand) == null ? void 0 : _b.call(_a, editor, block, range, item, { child }, result)) != null ? _c : false;
59454
- }
59455
- return (_f = (_e = (_d = this.insertProvider) == null ? void 0 : _d.executeCommand) == null ? void 0 : _e.call(_d, editor, block, range, item, params, result)) != null ? _f : false;
59456
- });
59457
- this.options = options;
59458
- this.insertProvider = new LinkProvider(editor);
59459
- this.editProvider = new EditLinkProvider();
59460
- }
59461
- }
59462
- const logger$1E = getLogger("readonly-toolbar");
59463
- const SEP = {
59464
- id: "",
59465
- name: "",
59466
- type: "separator"
59467
- };
59468
- function isCodeTextBlock$1(editor, block) {
59469
- if (!isTextKindBlock(editor, block)) {
59470
- return false;
59471
- }
59472
- const container = getParentContainer(block);
59473
- const parentBlock = getParentBlock(container);
59474
- if (!parentBlock) {
59475
- return false;
59476
- }
59477
- return getBlockType(parentBlock) === "code";
59478
- }
59479
- class ReadonlyToolbar {
59480
- constructor(editor) {
59481
- __publicField(this, "toolbar");
59482
- __publicField(this, "toolbarType", "text");
59483
- __publicField(this, "mouseDown", false);
59484
- __publicField(this, "hoveringBlock", null);
59485
- __publicField(this, "hoveringTextChild", null);
59486
- __publicField(this, "oldRange", null);
59487
- __publicField(this, "providers", []);
59488
- __publicField(this, "handleButtonClick", (toolbar2, item) => {
59489
- const tooltip = this.editor.getCustom("editor-tooltip");
59490
- tooltip.lastClickButtonId = item.id;
59491
- const commandProvider = item.commandProvider;
59492
- commandProvider.executeCommand(this.editor, item, {
59493
- hoveringBlock: this.hoveringBlock,
59494
- hoveringTextChild: this.hoveringTextChild,
59495
- bar: this.toolbar
59496
- });
59497
- });
59498
- __publicField(this, "handleClose", () => {
59499
- if (shouldFocusToEditor(this.editor)) {
59500
- this.editor.focus({
59501
- preventScroll: true
59502
- });
59503
- }
59504
- });
59505
- __publicField(this, "handleClosing", (bar2, event) => {
59506
- return true;
59507
- });
59508
- __publicField(this, "handleDocumentMouseDown", (event) => {
59509
- if (event.button === 0) {
59510
- document.addEventListener("mouseup", this.handleDocumentMouseUp);
59511
- this.mouseDown = true;
59512
- }
59513
- });
59514
- __publicField(this, "handleDocumentMouseUp", () => {
59515
- document.removeEventListener("mouseup", this.handleDocumentMouseUp);
59516
- this.mouseDown = false;
59517
- const selectedItem = this.toolbar.getSelectedItem();
59518
- if (this.toolbarType === "object" && ((selectedItem == null ? void 0 : selectedItem.dropdown) || (selectedItem == null ? void 0 : selectedItem.clickToClose) === false)) {
59519
- return;
59520
- }
59521
- this.handleSelectionChange(this.editor);
59522
- });
59523
- __publicField(this, "handleSelectionChange", debounce__default.default((editor) => {
59524
- var _a;
59525
- assert(logger$1E, editor === this.editor, "editor mismatch");
59526
- if (!editor.readonly) {
59527
- this.toolbar.close("selectionChange");
59528
- return;
59529
- }
59530
- if (editor.selection.range.isCollapsed() || this.mouseDown) {
59531
- if (this.toolbarType === "object") {
59532
- const element = (_a = this.toolbar.tippyInstance) == null ? void 0 : _a.reference;
59533
- const focusedBlock = this.editor.selection.focusedBlock;
59534
- const selectedItem = this.toolbar.getSelectedItem();
59535
- if (element && isChildNode(element, focusedBlock) || (selectedItem == null ? void 0 : selectedItem.dropdown)) {
59536
- return;
59537
- }
59538
- }
59539
- this.toolbar.close("selectionChange");
59540
- this.oldRange = null;
59541
- return;
59542
- }
59543
- const selectedBlocks = editor.selection.range.getSelectedBlocks();
59544
- if (selectedBlocks.length === 0) {
59545
- this.toolbar.close("selectionChange");
59546
- this.oldRange = null;
59547
- return;
59548
- }
59549
- if (this.oldRange) {
59550
- if (this.oldRange.isEqual(editor.selection.range)) {
59551
- return;
59552
- }
59553
- }
59554
- this.oldRange = editor.selection.range;
59555
- this.showTextToolbar("selectionChange");
59556
- }, 50));
59557
- __publicField(this, "handleHoveringBlockChildChange", (block, child, old, event) => {
59558
- var _a;
59559
- if (this.toolbarType === "object" && ((_a = this.toolbar.subBar) == null ? void 0 : _a.isVisible)) {
59560
- return;
59561
- }
59562
- if (this.hoveringBlock === block && this.hoveringTextChild === child) {
59563
- return;
59564
- }
59565
- this.hoveringBlock = block;
59566
- this.hoveringTextChild = child;
59567
- if (this.toolbarType === "text" && this.toolbar.isVisible) {
59568
- return;
59569
- }
59570
- if (!block) {
59571
- this.toolbar.close("fromHover");
59572
- }
59573
- });
59574
- __publicField(this, "groupCommands", (allCommands) => {
59575
- var _a, _b;
59576
- const allCommandsMap = /* @__PURE__ */ new Map();
59577
- for (let i = 0; i < allCommands.length; i++) {
59578
- const groupOrder = (_a = allCommands[i].groupOrder) != null ? _a : 0;
59579
- if (allCommandsMap.has(groupOrder)) {
59580
- (_b = allCommandsMap.get(groupOrder)) == null ? void 0 : _b.push(allCommands[i]);
59581
- } else {
59582
- allCommandsMap.set(groupOrder, [allCommands[i]]);
59583
- }
59584
- }
59585
- const commandsChunk = [];
59586
- allCommandsMap.forEach((value) => {
59587
- commandsChunk.push(value.sort((item1, item2) => {
59588
- var _a2, _b2;
59589
- return ((_a2 = item1.order) != null ? _a2 : 0) - ((_b2 = item2.order) != null ? _b2 : 0);
59590
- }));
59591
- });
59592
- if (commandsChunk.length === 0) {
59593
- return [];
59594
- }
59595
- const commands = commandsChunk.reduce((prev, curr) => prev.concat([SEP, ...curr]), []);
59596
- commands.shift();
59597
- return commands;
59598
- });
59599
- this.editor = editor;
59600
- const popover = editor.options.componentsOptions.popover;
59601
- this.toolbar = new ManualToolbar([], void 0, {
59602
- tooltipId: editor.clientId,
59603
- id: "editor-toolbar",
59604
- overflowBoundary: popover == null ? void 0 : popover.overflowBoundary,
59605
- refuseOverflow: true,
59606
- padding: 20
59607
- });
59608
- this.toolbar.on("click", this.handleButtonClick);
59609
- this.toolbar.on("close", this.handleClose);
59610
- this.toolbar.on("closing", this.handleClosing);
59611
- this.bindEvents();
59612
- editor.addListener("selectionChanged", this.handleSelectionChange);
59613
- OnesEditorHoveringBlock.get(editor).addListener("childChange", this.handleHoveringBlockChildChange);
59614
- OnesEditorHoveringBlock.get(editor).addFilter(this);
59615
- }
59616
- destroy() {
59617
- this.unbindEvents();
59618
- this.toolbar.destroy();
59619
- this.editor.removeListener("selectionChanged", this.handleSelectionChange);
59620
- OnesEditorHoveringBlock.get(this.editor).removeListener("childChange", this.handleHoveringBlockChildChange);
59621
- this.providers.forEach((provider) => {
59622
- var _a;
59623
- (_a = provider.destroy) == null ? void 0 : _a.call(provider);
59624
- });
59625
- }
59626
- addProvider(provider) {
59627
- this.providers.push(provider);
59628
- }
59629
- isInBlock(block, event) {
59630
- var _a, _b;
59631
- if (block !== this.hoveringBlock) {
59632
- return false;
59633
- }
59634
- if (event.target && event.target instanceof Node && (this.toolbar.popper && isChildNode(this.toolbar.popper, event.target) || ((_a = this.toolbar.subBar) == null ? void 0 : _a.popper) && isChildNode((_b = this.toolbar.subBar) == null ? void 0 : _b.popper, event.target))) {
59635
- return true;
59636
- }
59637
- return false;
59638
- }
59639
- bindEvents() {
59640
- document.addEventListener("mousedown", this.handleDocumentMouseDown);
59641
- }
59642
- unbindEvents() {
59643
- document.removeEventListener("mousedown", this.handleDocumentMouseDown);
59644
- }
59645
- showTextToolbar(reason) {
59646
- var _a, _b;
59647
- let commands = [];
59648
- const range = this.editor.selection.range;
59649
- this.providers.forEach((provider) => {
59650
- if (provider.getTextCommands) {
59651
- const textCommands = provider.getTextCommands(this.editor, range).map((command) => {
59652
- const item = {
59653
- ...command,
59654
- commandProvider: provider
59655
- };
59656
- return item;
59657
- });
59658
- commands.push(...textCommands);
59659
- }
59660
- });
59661
- commands = this.groupCommands(commands);
59662
- if (commands.length === 0) {
59663
- this.toolbar.close("cancelBar");
59664
- return;
59665
- }
59666
- const selectedBlocks = range.getSelectedBlocks();
59667
- if (selectedBlocks.length === 0) {
59668
- return;
59669
- }
59670
- const firstBlock = selectedBlocks[0];
59671
- if (!firstBlock) {
59672
- return;
59673
- }
59674
- if (isCodeTextBlock$1(this.editor, firstBlock.block)) {
59675
- return;
59676
- }
59677
- if (selectedBlocks.length === 1) {
59678
- if (isEmbedBlock(firstBlock.block)) {
59679
- return;
59680
- }
59681
- if (isComplexKindBlock(this.editor, firstBlock.block) && range.isSimple()) {
59682
- return;
59683
- }
59684
- }
59685
- if (isTitleBlock$2(firstBlock.block)) {
59686
- this.toolbar.close("selectionChange");
59687
- return;
59688
- }
59689
- this.toolbar.updateItems(commands);
59690
- const lastBlock2 = selectedBlocks[selectedBlocks.length - 1];
59691
- const reverseToolbar = !this.editor.selection.range.isReverse() && lastBlock2 !== firstBlock;
59692
- const selectedBlock = reverseToolbar ? lastBlock2 : firstBlock;
59693
- const rect = getReferenceClientRect(this.editor, selectedBlock);
59694
- const anchor2 = createBlockAnchor(this.editor, selectedBlock.block, "editor-readonly-toolbar", rect);
59695
- this.toolbar.manualShow(anchor2, {
59696
- placement: reverseToolbar ? "bottom" : "top",
59697
- offset: [0, reverseToolbar ? 5 : 10]
59698
- });
59699
- (_b = (_a = this.toolbar.tippyInstance) == null ? void 0 : _a.popperInstance) == null ? void 0 : _b.update();
59700
- }
59701
- }
59702
59709
  function getCommentAbstract(editor, blocks) {
59703
59710
  return blocks.map((block) => {
59704
59711
  var _a, _b;
@@ -87165,7 +87172,7 @@ ${data2.flowchartText}
87165
87172
  }
87166
87173
  }
87167
87174
  });
87168
- editor.version = "2.1.2-beta.10";
87175
+ editor.version = "2.1.2-beta.11";
87169
87176
  if (Logger$2.level === LogLevel.DEBUG) {
87170
87177
  window.setReauthFail = (fail) => {
87171
87178
  window.isReauthError = fail;
@@ -87266,7 +87273,7 @@ ${data2.flowchartText}
87266
87273
  });
87267
87274
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
87268
87275
  OnesEditorToolbar.register(editor);
87269
- editor.version = "2.1.2-beta.10";
87276
+ editor.version = "2.1.2-beta.11";
87270
87277
  return editor;
87271
87278
  }
87272
87279
  async function showDocVersions(editor, options, serverUrl) {