@ones-editor/editor 2.1.1-beta.32 → 2.1.1-beta.34

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.
@@ -1,4 +1,4 @@
1
- import { CommandItem, BlockOptions, OnesEditor, BlockElement } from '../../../../@ones-editor/core';
1
+ import { CommandItem, BlockOptions, OnesEditor, BlockElement, SelectionRange } from '../../../../@ones-editor/core';
2
2
  export interface QuickMenuItem extends CommandItem {
3
3
  itemType: 'insert-block';
4
4
  blockType?: string;
@@ -26,6 +26,7 @@ export interface QuickMenuCommandBetween extends QuickMenuCommandParams {
26
26
  export interface QuickMenuCommandProvider {
27
27
  getCommands: (editor: OnesEditor, params: QuickMenuCommandParams) => CommandItem[];
28
28
  executeCommand: (editor: OnesEditor, item: CommandItem, params: QuickMenuCommandInline | QuickMenuCommandBetween | AddMenuCommand) => Promise<BlockElement | null>;
29
+ filterCommands?: (editor: OnesEditor, items: CommandItem[], range: SelectionRange) => CommandItem[];
29
30
  }
30
31
  export interface QuickMenuOptions {
31
32
  id?: string;
@@ -16,7 +16,7 @@ declare class EditorInput {
16
16
  private options;
17
17
  private unbindKeyDownEvent;
18
18
  constructor(parent: HTMLElement, options: EditorInputOptions);
19
- private get container();
19
+ private container;
20
20
  private get errorContent();
21
21
  private get input();
22
22
  private get suffix();
@@ -30,7 +30,7 @@ declare class EditorInput {
30
30
  hideSuffix: () => void;
31
31
  handleInput: (e: Event) => void;
32
32
  handleClose: (e: Event) => void;
33
- init(): HTMLInputElement;
33
+ init(): HTMLDivElement;
34
34
  destroy(): void;
35
35
  }
36
36
  export declare function createInput(parent: HTMLElement, options: EditorInputOptions): EditorInput;
package/dist/index.js CHANGED
@@ -40818,6 +40818,7 @@ ${codeText}
40818
40818
  class EditorInput {
40819
40819
  constructor(parent, options) {
40820
40820
  __publicField(this, "unbindKeyDownEvent");
40821
+ __publicField(this, "container");
40821
40822
  __publicField(this, "getField", () => this.input);
40822
40823
  __publicField(this, "getInputValue", () => this.input.value);
40823
40824
  __publicField(this, "setFieldError", (error2) => {
@@ -40872,24 +40873,21 @@ ${codeText}
40872
40873
  });
40873
40874
  this.parent = parent;
40874
40875
  this.options = options;
40875
- this.init();
40876
+ this.container = this.init();
40876
40877
  this.input.addEventListener("input", this.handleInput);
40877
40878
  this.unbindKeyDownEvent = bindKeyDownEvent(this.input, this.handleKeyDown);
40878
40879
  }
40879
- get container() {
40880
- return this.parent.querySelector(".editor-input-wrap");
40881
- }
40882
40880
  get errorContent() {
40883
- return this.parent.querySelector(".editor-input-error");
40881
+ return this.container.querySelector(".editor-input-error");
40884
40882
  }
40885
40883
  get input() {
40886
- return this.parent.querySelector(".editor-input");
40884
+ return this.container.querySelector(".editor-input");
40887
40885
  }
40888
40886
  get suffix() {
40889
- return this.parent.querySelector(".editor-input-suffix");
40887
+ return this.container.querySelector(".editor-input-suffix");
40890
40888
  }
40891
40889
  get prefix() {
40892
- return this.parent.querySelector(".editor-input-prefix");
40890
+ return this.container.querySelector(".editor-input-prefix");
40893
40891
  }
40894
40892
  init() {
40895
40893
  const options = this.options;
@@ -40936,7 +40934,7 @@ ${codeText}
40936
40934
  }
40937
40935
  inputContainer.appendChild(input2);
40938
40936
  createElement("div", ["editor-input-error"], container);
40939
- return input2;
40937
+ return container;
40940
40938
  }
40941
40939
  destroy() {
40942
40940
  this.input.removeEventListener("input", this.handleInput);
@@ -77764,17 +77762,32 @@ ${codeText}
77764
77762
  return items;
77765
77763
  if (getBlockType(parentBlock) !== "callout")
77766
77764
  return items;
77767
- function checkIsAllowMenuItems(item) {
77768
- if (item.group === "basics")
77769
- return true;
77770
- if (item.group === "system")
77771
- return true;
77772
- if (item.group === "common") {
77773
- return item.type === "section" || ["insert-link", "insert-status", "insert-math"].includes(item.id);
77765
+ const deep = (items2) => {
77766
+ var _a;
77767
+ const filterItems = [];
77768
+ items2.forEach((item) => {
77769
+ var _a2, _b;
77770
+ const lastItem = filterItems[filterItems.length - 1];
77771
+ if ((lastItem == null ? void 0 : lastItem.type) === "section" && item.type === "section")
77772
+ return;
77773
+ if (item.blockOptions)
77774
+ return;
77775
+ const ret = (_b = (_a2 = item.commandProvider) == null ? void 0 : _a2.filterCommands) == null ? void 0 : _b.call(_a2, editor, items2, range);
77776
+ if (ret) {
77777
+ filterItems.push(...ret);
77778
+ return;
77779
+ }
77780
+ filterItems.push(item);
77781
+ if (item.children) {
77782
+ item.children = deep(item.children);
77783
+ }
77784
+ });
77785
+ if (((_a = filterItems[filterItems.length - 1]) == null ? void 0 : _a.type) === "section") {
77786
+ filterItems.pop();
77774
77787
  }
77775
- return false;
77776
- }
77777
- return items.filter(checkIsAllowMenuItems);
77788
+ return filterItems;
77789
+ };
77790
+ return deep(items);
77778
77791
  }
77779
77792
  destroy() {
77780
77793
  }
@@ -84967,7 +84980,7 @@ ${data2.flowchartText}
84967
84980
  }
84968
84981
  }
84969
84982
  });
84970
- editor.version = "2.1.1-beta.32";
84983
+ editor.version = "2.1.1-beta.34";
84971
84984
  if (Logger$2.level === LogLevel.DEBUG) {
84972
84985
  window.setReauthFail = (fail) => {
84973
84986
  window.isReauthError = fail;
@@ -85066,7 +85079,7 @@ ${data2.flowchartText}
85066
85079
  });
85067
85080
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
85068
85081
  OnesEditorToolbar.register(editor);
85069
- editor.version = "2.1.1-beta.32";
85082
+ editor.version = "2.1.1-beta.34";
85070
85083
  return editor;
85071
85084
  }
85072
85085
  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.32",
3
+ "version": "2.1.1-beta.34",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",