@ones-editor/editor 2.1.1-beta.33 → 2.1.1-beta.35

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
@@ -29685,7 +29685,7 @@ ${codeText}
29685
29685
  });
29686
29686
  return allCommands;
29687
29687
  }
29688
- const SEP$1 = {
29688
+ const SEP$2 = {
29689
29689
  id: "",
29690
29690
  name: "",
29691
29691
  type: "separator"
@@ -29710,7 +29710,7 @@ ${codeText}
29710
29710
  if (commandsChunk.length === 0) {
29711
29711
  return [];
29712
29712
  }
29713
- const commands = commandsChunk.reduce((prev, curr) => prev.concat([SEP$1, ...curr]), []);
29713
+ const commands = commandsChunk.reduce((prev, curr) => prev.concat([SEP$2, ...curr]), []);
29714
29714
  commands.shift();
29715
29715
  return commands;
29716
29716
  };
@@ -45762,6 +45762,48 @@ ${codeText}
45762
45762
  return rects[0];
45763
45763
  }
45764
45764
  const logger$22 = getLogger("object-commands");
45765
+ const SEP$1 = {
45766
+ id: "",
45767
+ name: "",
45768
+ type: "separator"
45769
+ };
45770
+ const groupCommands = (allCommands) => {
45771
+ var _a, _b;
45772
+ const allCommandsMap = /* @__PURE__ */ new Map();
45773
+ for (let i = 0; i < allCommands.length; i++) {
45774
+ const groupOrder = (_a = allCommands[i].groupOrder) != null ? _a : 0;
45775
+ if (allCommandsMap.has(groupOrder)) {
45776
+ (_b = allCommandsMap.get(groupOrder)) == null ? void 0 : _b.push(allCommands[i]);
45777
+ } else {
45778
+ allCommandsMap.set(groupOrder, [allCommands[i]]);
45779
+ }
45780
+ }
45781
+ const commandsChunk = [];
45782
+ allCommandsMap.forEach((value) => {
45783
+ commandsChunk.push(value.sort((item1, item2) => {
45784
+ var _a2, _b2;
45785
+ return ((_a2 = item1.order) != null ? _a2 : 0) - ((_b2 = item2.order) != null ? _b2 : 0);
45786
+ }));
45787
+ });
45788
+ if (commandsChunk.length === 0) {
45789
+ return [];
45790
+ }
45791
+ const commands = commandsChunk.reduce((prev, curr) => prev.concat([SEP$1, ...curr]), []);
45792
+ commands.shift();
45793
+ let start = 0;
45794
+ return commands.filter((item, index2) => {
45795
+ if (item.type === "separator") {
45796
+ if (index2 === 0 || index2 === commands.length - 1) {
45797
+ return false;
45798
+ }
45799
+ if (index2 - start === 1) {
45800
+ return false;
45801
+ }
45802
+ start = index2;
45803
+ }
45804
+ return true;
45805
+ });
45806
+ };
45765
45807
  function getObjectCommands(editor, block, child) {
45766
45808
  const result = getSpecialBlockCommands(editor, block, child, "hovering-toolbar");
45767
45809
  const { element: targetElement, boxCommands, blockCommands } = result;
@@ -45793,7 +45835,7 @@ ${codeText}
45793
45835
  element = element || block;
45794
45836
  return {
45795
45837
  element,
45796
- commands
45838
+ commands: groupCommands(commands)
45797
45839
  };
45798
45840
  }
45799
45841
  function executeObjectCommand(editor, block, child, item) {
@@ -64396,7 +64438,9 @@ ${codeText}
64396
64438
  }, {
64397
64439
  id: "add-comment",
64398
64440
  name: i18n$1.t("embedProperties.addComment"),
64399
- icon: CommentIcon$1
64441
+ icon: CommentIcon$1,
64442
+ groupOrder: 1e3,
64443
+ order: 100
64400
64444
  }, {
64401
64445
  id: "separator",
64402
64446
  name: "",
@@ -73718,7 +73762,9 @@ ${codeText}
73718
73762
  {
73719
73763
  id: "add-comment",
73720
73764
  name: i18n$1.t("file.commands.comment"),
73721
- icon: CommentIcon$1
73765
+ icon: CommentIcon$1,
73766
+ groupOrder: 1e3,
73767
+ order: 100
73722
73768
  },
73723
73769
  {
73724
73770
  id: "sep",
@@ -74040,7 +74086,9 @@ ${codeText}
74040
74086
  }, {
74041
74087
  id: "add-comment",
74042
74088
  name: i18n$1.t("file.commands.comment"),
74043
- icon: CommentIcon$1
74089
+ icon: CommentIcon$1,
74090
+ groupOrder: 1e3,
74091
+ order: 100
74044
74092
  }, {
74045
74093
  id: "sep",
74046
74094
  name: "",
@@ -77753,7 +77801,6 @@ ${codeText}
77753
77801
  });
77754
77802
  }
77755
77803
  filter(editor, range, items, source) {
77756
- var _a;
77757
77804
  if (!range.isCollapsed())
77758
77805
  return items;
77759
77806
  const { anchor: anchor2 } = range;
@@ -77763,25 +77810,32 @@ ${codeText}
77763
77810
  return items;
77764
77811
  if (getBlockType(parentBlock) !== "callout")
77765
77812
  return items;
77766
- const filterItems = [];
77767
- items.forEach((item) => {
77768
- var _a2, _b;
77769
- const lastItem = filterItems[filterItems.length - 1];
77770
- if ((lastItem == null ? void 0 : lastItem.type) === "section" && item.type === "section")
77771
- return;
77772
- if (item.blockOptions)
77773
- return;
77774
- const ret = (_b = (_a2 = item.commandProvider) == null ? void 0 : _a2.filterCommands) == null ? void 0 : _b.call(_a2, editor, items, range);
77775
- if (ret) {
77776
- filterItems.push(...ret);
77777
- return;
77813
+ const deep = (items2) => {
77814
+ var _a;
77815
+ const filterItems = [];
77816
+ items2.forEach((item) => {
77817
+ var _a2, _b;
77818
+ const lastItem = filterItems[filterItems.length - 1];
77819
+ if ((lastItem == null ? void 0 : lastItem.type) === "section" && item.type === "section")
77820
+ return;
77821
+ if (item.blockOptions)
77822
+ return;
77823
+ const ret = (_b = (_a2 = item.commandProvider) == null ? void 0 : _a2.filterCommands) == null ? void 0 : _b.call(_a2, editor, items2, range);
77824
+ if (ret) {
77825
+ filterItems.push(...ret);
77826
+ return;
77827
+ }
77828
+ filterItems.push(item);
77829
+ if (item.children) {
77830
+ item.children = deep(item.children);
77831
+ }
77832
+ });
77833
+ if (((_a = filterItems[filterItems.length - 1]) == null ? void 0 : _a.type) === "section") {
77834
+ filterItems.pop();
77778
77835
  }
77779
- filterItems.push(item);
77780
- });
77781
- if (((_a = filterItems[filterItems.length - 1]) == null ? void 0 : _a.type) === "section") {
77782
- filterItems.pop();
77783
- }
77784
- return filterItems;
77836
+ return filterItems;
77837
+ };
77838
+ return deep(items);
77785
77839
  }
77786
77840
  destroy() {
77787
77841
  }
@@ -84974,7 +85028,7 @@ ${data2.flowchartText}
84974
85028
  }
84975
85029
  }
84976
85030
  });
84977
- editor.version = "2.1.1-beta.33";
85031
+ editor.version = "2.1.1-beta.35";
84978
85032
  if (Logger$2.level === LogLevel.DEBUG) {
84979
85033
  window.setReauthFail = (fail) => {
84980
85034
  window.isReauthError = fail;
@@ -85073,7 +85127,7 @@ ${data2.flowchartText}
85073
85127
  });
85074
85128
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
85075
85129
  OnesEditorToolbar.register(editor);
85076
- editor.version = "2.1.1-beta.33";
85130
+ editor.version = "2.1.1-beta.35";
85077
85131
  return editor;
85078
85132
  }
85079
85133
  async function showDocVersions(editor, options, serverUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.1.1-beta.33",
3
+ "version": "2.1.1-beta.35",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",