@ones-editor/editor 2.1.1-beta.15 → 2.1.1-beta.17

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.
@@ -11,7 +11,7 @@ export default class ColorStyleProvider implements OnesEditorCommandProvider {
11
11
  private updateButtonColor;
12
12
  private setActiveAttribute;
13
13
  private handleChangeColor;
14
- getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange): CommandItem[];
14
+ getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange, params?: CommandParams): CommandItem[];
15
15
  getInsertCommands(): CommandItem[];
16
16
  executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItem, params: CommandParams, result?: CommandResult): boolean;
17
17
  executeInsertCommand: () => boolean;
@@ -3,7 +3,7 @@ export default class InlineStyleProvider implements OnesEditorCommandProvider {
3
3
  private editor;
4
4
  id: string;
5
5
  constructor(editor: OnesEditor);
6
- getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange): CommandItem[];
6
+ getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange, params?: CommandParams): CommandItem[];
7
7
  getInsertCommands(): CommandItem[];
8
8
  executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItem, params: CommandParams, result?: CommandResult): boolean;
9
9
  executeInsertCommand: () => boolean;
@@ -3,12 +3,12 @@ import { ProxyProvider } from './proxy-provider';
3
3
  import { QuickMenuCommandProvider } from '../quick-menu/types';
4
4
  export default class InsertMenuProvider extends ProxyProvider {
5
5
  private editor;
6
- private withPlainText;
6
+ private options?;
7
7
  id: string;
8
8
  providersMap: Map<string, OnesEditorCommandProvider>;
9
9
  providers: OnesEditorCommandProvider[];
10
10
  quickProviders: QuickMenuCommandProvider[];
11
- constructor(editor: OnesEditor, withPlainText?: boolean);
11
+ constructor(editor: OnesEditor, options?: CommandParams | undefined);
12
12
  getInsertCommands: (editor: OnesEditor, containerId: string) => CommandItem[];
13
13
  getAvailableCommands: (editor: OnesEditor, block: BlockElement, range: SelectionRange) => CommandItem[];
14
14
  executeInsertCommand: (editor: OnesEditor, containerId: string, blockIndex: number, item: CommandItem, params: CommandParams) => boolean;
@@ -1,9 +1,9 @@
1
- import { BlockElement, CommandItem, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
1
+ import { BlockElement, CommandItem, CommandParams, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
2
2
  import { ProxyProvider } from './proxy-provider';
3
3
  export default class ScriptDropdownProvider extends ProxyProvider implements OnesEditorCommandProvider {
4
4
  private editor;
5
5
  id: string;
6
6
  constructor(editor: OnesEditor);
7
7
  getInsertCommands: () => never[];
8
- getAvailableCommands: (editor: OnesEditor, block: BlockElement, range: SelectionRange) => CommandItem[];
8
+ getAvailableCommands: (editor: OnesEditor, block: BlockElement, range: SelectionRange, params?: CommandParams) => CommandItem[];
9
9
  }
@@ -1,10 +1,11 @@
1
1
  import { BlockAttributesHandler, BlockElement, CommandItem, CommandParams, CommandResult, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
2
2
  export default class TextCommandProvider implements OnesEditorCommandProvider {
3
3
  private editor;
4
+ private options?;
4
5
  id: string;
5
6
  groupIndex: number;
6
7
  private providers;
7
- constructor(editor: OnesEditor);
8
+ constructor(editor: OnesEditor, options?: CommandParams | undefined);
8
9
  getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange): CommandItem[];
9
10
  executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItem, params: CommandParams, result?: CommandResult): boolean;
10
11
  get blockAttributesHandler(): BlockAttributesHandler;
@@ -3,7 +3,7 @@ export default class TextScriptProvider implements OnesEditorCommandProvider {
3
3
  private editor;
4
4
  id: string;
5
5
  constructor(editor: OnesEditor);
6
- getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange): CommandItem[];
6
+ getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange, params?: CommandParams): CommandItem[];
7
7
  getInsertCommands(): CommandItem[];
8
8
  executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItem, params: CommandParams, result?: CommandResult): boolean;
9
9
  executeInsertCommand: () => boolean;
package/dist/index.js CHANGED
@@ -29753,8 +29753,16 @@ ${codeText}
29753
29753
  function getBlockCommands(providers, editor, block, range, source) {
29754
29754
  const commandsMap = /* @__PURE__ */ new Map();
29755
29755
  setBlockCommandsMap(providers, editor, block, range, commandsMap);
29756
- const commands = flatCommands(commandsMap);
29756
+ let commands = flatCommands(commandsMap);
29757
29757
  injectSource(commands, [source]);
29758
+ providers.forEach((provider) => {
29759
+ if (provider.filterCommands) {
29760
+ const ret = provider.filterCommands(editor, block, range, commands);
29761
+ if (ret) {
29762
+ commands = ret;
29763
+ }
29764
+ }
29765
+ });
29758
29766
  return commands;
29759
29767
  }
29760
29768
  const logger$2W = getLogger("abstract-command-providers");
@@ -56776,8 +56784,8 @@ $$${mathData.mathjaxText}$$
56776
56784
  });
56777
56785
  };
56778
56786
  class InsertMenuProvider$1 extends ProxyProvider {
56779
- constructor(editor, withPlainText = true) {
56780
- var _a, _b, _c;
56787
+ constructor(editor, options) {
56788
+ var _a, _b, _c, _d, _e, _f, _g;
56781
56789
  super();
56782
56790
  __publicField(this, "id", "InsertMenuProvider");
56783
56791
  __publicField(this, "providersMap", /* @__PURE__ */ new Map());
@@ -56918,10 +56926,13 @@ $$${mathData.mathjaxText}$$
56918
56926
  return false;
56919
56927
  });
56920
56928
  this.editor = editor;
56921
- this.withPlainText = withPlainText;
56922
- this.providersMap.set("basics", new TextStylesProvider(this.editor, this.withPlainText));
56929
+ this.options = options;
56930
+ const withBasics = (_b = (_a = this.options) == null ? void 0 : _a.withBasics) != null ? _b : true;
56931
+ if (withBasics) {
56932
+ this.providersMap.set("basics", new TextStylesProvider(this.editor, (_d = (_c = this.options) == null ? void 0 : _c.withPlainText) != null ? _d : true));
56933
+ }
56923
56934
  this.providersMap.set("common", new InlineBoxCommandProvider(this.editor));
56924
- const commandProviders = (_c = (_b = (_a = editor.options.componentsOptions) == null ? void 0 : _a.quickMenu) == null ? void 0 : _b.commandProviders) != null ? _c : [];
56935
+ const commandProviders = (_g = (_f = (_e = editor.options.componentsOptions) == null ? void 0 : _e.quickMenu) == null ? void 0 : _f.commandProviders) != null ? _g : [];
56925
56936
  commandProviders.forEach((provider) => {
56926
56937
  if (provider.getAvailableCommands) {
56927
56938
  this.providers.push(provider);
@@ -56947,7 +56958,7 @@ $$${mathData.mathjaxText}$$
56947
56958
  return {};
56948
56959
  });
56949
56960
  this.editor = editor;
56950
- this.registerCommandProvider(new InsertMenuProvider$1(editor, false));
56961
+ this.registerCommandProvider(new InsertMenuProvider$1(editor, { withPlainText: false }));
56951
56962
  }
56952
56963
  getCommands(range) {
56953
56964
  var _a, _b;
@@ -57993,11 +58004,9 @@ $$${mathData.mathjaxText}$$
57993
58004
  __publicField(this, "executeInsertCommand", () => false);
57994
58005
  this.editor = editor;
57995
58006
  }
57996
- getAvailableCommands(editor, block, range) {
57997
- if (!isTextKindBlock(editor, block)) {
57998
- return [];
57999
- }
58000
- if (isSelectBoxOnly(editor)) {
58007
+ getAvailableCommands(editor, block, range, params) {
58008
+ const disable = !isTextKindBlock(editor, block) || isSelectBoxOnly(editor);
58009
+ if (disable && (params == null ? void 0 : params.isFilter)) {
58001
58010
  return [];
58002
58011
  }
58003
58012
  let commands;
@@ -58007,6 +58016,11 @@ $$${mathData.mathjaxText}$$
58007
58016
  const subText2 = getSubText(editor, block, range);
58008
58017
  commands = getCommands$1(subText2);
58009
58018
  }
58019
+ if (!(params == null ? void 0 : params.isFilter)) {
58020
+ commands.forEach((item) => {
58021
+ item.states = disable ? ["disabled"] : [];
58022
+ });
58023
+ }
58010
58024
  return commands;
58011
58025
  }
58012
58026
  getInsertCommands() {
@@ -58081,15 +58095,13 @@ $$${mathData.mathjaxText}$$
58081
58095
  get blockAttributesHandler() {
58082
58096
  return this.editor.getCustom("block-attributes-handler");
58083
58097
  }
58084
- getAvailableCommands(editor, block, range) {
58085
- if (!isTextKindBlock(editor, block)) {
58086
- return [];
58087
- }
58088
- if (isSelectBoxOnly(editor)) {
58098
+ getAvailableCommands(editor, block, range, params) {
58099
+ const disable = !isTextKindBlock(editor, block) || isSelectBoxOnly(editor);
58100
+ if (disable && (params == null ? void 0 : params.isFilter)) {
58089
58101
  return [];
58090
58102
  }
58091
58103
  this.updateButtonColor(range);
58092
- return [{ ...this.colorItem }];
58104
+ return [{ ...this.colorItem, states: disable ? ["disabled"] : [] }];
58093
58105
  }
58094
58106
  getInsertCommands() {
58095
58107
  return [];
@@ -58135,11 +58147,9 @@ $$${mathData.mathjaxText}$$
58135
58147
  __publicField(this, "executeInsertCommand", () => false);
58136
58148
  this.editor = editor;
58137
58149
  }
58138
- getAvailableCommands(editor, block, range) {
58139
- if (!isTextKindBlock(editor, block)) {
58140
- return [];
58141
- }
58142
- if (isSelectBoxOnly(editor)) {
58150
+ getAvailableCommands(editor, block, range, params) {
58151
+ const disable = !isTextKindBlock(editor, block) || isSelectBoxOnly(editor);
58152
+ if (disable && (params == null ? void 0 : params.isFilter)) {
58143
58153
  return [];
58144
58154
  }
58145
58155
  let commands;
@@ -58149,6 +58159,11 @@ $$${mathData.mathjaxText}$$
58149
58159
  const subText2 = getSubText(editor, block, range);
58150
58160
  commands = getCommands(subText2);
58151
58161
  }
58162
+ if (!(params == null ? void 0 : params.isFilter)) {
58163
+ commands.forEach((item) => {
58164
+ item.states = disable ? ["disabled"] : [];
58165
+ });
58166
+ }
58152
58167
  return commands;
58153
58168
  }
58154
58169
  getInsertCommands() {
@@ -58173,16 +58188,14 @@ $$${mathData.mathjaxText}$$
58173
58188
  super();
58174
58189
  __publicField(this, "id", "ScriptDropdownProvider");
58175
58190
  __publicField(this, "getInsertCommands", () => []);
58176
- __publicField(this, "getAvailableCommands", (editor, block, range) => {
58177
- if (!isTextKindBlock(editor, block)) {
58178
- return [];
58179
- }
58180
- if (isSelectBoxOnly(editor)) {
58191
+ __publicField(this, "getAvailableCommands", (editor, block, range, params) => {
58192
+ const disable = !isTextKindBlock(editor, block) || isSelectBoxOnly(editor);
58193
+ if (disable && (params == null ? void 0 : params.isFilter)) {
58181
58194
  return [];
58182
58195
  }
58183
58196
  const commands = [];
58184
58197
  for (const provider of this.providers) {
58185
- commands.push(...provider.getAvailableCommands(editor, block, range));
58198
+ commands.push(...provider.getAvailableCommands(editor, block, range, params));
58186
58199
  }
58187
58200
  return [{
58188
58201
  children: commands,
@@ -58250,30 +58263,34 @@ $$${mathData.mathjaxText}$$
58250
58263
  }
58251
58264
  const logger$1F = getLogger("text-command-provider");
58252
58265
  class TextCommandProvider {
58253
- constructor(editor) {
58266
+ constructor(editor, options) {
58254
58267
  __publicField(this, "id", "TextCommandProvider");
58255
58268
  __publicField(this, "groupIndex", 500);
58256
58269
  __publicField(this, "providers");
58257
58270
  this.editor = editor;
58271
+ this.options = options;
58258
58272
  this.providers = [
58259
58273
  new InlineStyleProvider(editor),
58260
58274
  new ColorStyleProvider(editor),
58261
58275
  new InlineCodeProvider(editor)
58262
58276
  ];
58263
58277
  if (!clientType.isMobile) {
58264
- this.providers.push(new ScriptDropdownProvider(editor));
58278
+ if (options == null ? void 0 : options.scriptDropDown) {
58279
+ this.providers.push(new ScriptDropdownProvider(editor));
58280
+ } else {
58281
+ this.providers.push(new TextScriptProvider(editor));
58282
+ }
58265
58283
  }
58266
58284
  }
58267
58285
  getAvailableCommands(editor, block, range) {
58268
- if (!isTextKindBlock(editor, block)) {
58269
- return [];
58270
- }
58271
- if (isSelectBoxOnly(editor)) {
58286
+ var _a;
58287
+ const disable = !isTextKindBlock(editor, block) || isSelectBoxOnly(editor);
58288
+ if (disable && ((_a = this.options) == null ? void 0 : _a.isFilter)) {
58272
58289
  return [];
58273
58290
  }
58274
58291
  const commands = [];
58275
58292
  for (const provider of this.providers) {
58276
- commands.push(...provider.getAvailableCommands(editor, block, range));
58293
+ commands.push(...provider.getAvailableCommands(editor, block, range, this.options));
58277
58294
  }
58278
58295
  if (getBlockTextLength$6(editor, block) === 0) {
58279
58296
  return this.setCommandsStates(commands, block).map(TextCommandProvider.toTextCommand);
@@ -84833,7 +84850,7 @@ ${data2.flowchartText}
84833
84850
  OnesEditorTocProvider.register(editor);
84834
84851
  OnesEditorExclusiveBlock.register(editor);
84835
84852
  if (!clientType.isMobile) {
84836
- editor.editorCommandProviders.registerCommandProvider(new TextCommandProvider(editor));
84853
+ editor.editorCommandProviders.registerCommandProvider(new TextCommandProvider(editor, { scriptDropDown: true, isFilter: true }));
84837
84854
  editor.addCustom("editor-tooltip", () => new OnesEditorTooltip(editor));
84838
84855
  } else {
84839
84856
  editor.addCustom("mobile-helper", () => new OnesEditorMobileHelper(editor));
@@ -84878,7 +84895,7 @@ ${data2.flowchartText}
84878
84895
  }
84879
84896
  }
84880
84897
  });
84881
- editor.version = "2.1.1-beta.15";
84898
+ editor.version = "2.1.1-beta.17";
84882
84899
  if (Logger$2.level === LogLevel.DEBUG) {
84883
84900
  window.setReauthFail = (fail) => {
84884
84901
  window.isReauthError = fail;
@@ -84943,7 +84960,7 @@ ${data2.flowchartText}
84943
84960
  return new OnesEditorQuickMenu(editor, (_a2 = options.componentsOptions) == null ? void 0 : _a2.quickMenu);
84944
84961
  });
84945
84962
  editor.addCustom("block-menu", (editor2) => new OnesEditorBlockMenuButtons(editor2));
84946
- editor.editorCommandProviders.registerCommandProvider(new TextCommandProvider(editor));
84963
+ editor.editorCommandProviders.registerCommandProvider(new TextCommandProvider(editor, { scriptDropDown: true, isFilter: true }));
84947
84964
  editor.addCustom("editor-tooltip", () => new OnesEditorTooltip(editor));
84948
84965
  } else {
84949
84966
  editor.addCustom("mobile-helper", () => new OnesEditorMobileHelper(editor));
@@ -84975,7 +84992,7 @@ ${data2.flowchartText}
84975
84992
  });
84976
84993
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
84977
84994
  OnesEditorToolbar.register(editor);
84978
- editor.version = "2.1.1-beta.15";
84995
+ editor.version = "2.1.1-beta.17";
84979
84996
  return editor;
84980
84997
  }
84981
84998
  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.15",
3
+ "version": "2.1.1-beta.17",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",