@ones-editor/editor 2.1.1-beta.16 → 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
@@ -56784,8 +56784,8 @@ $$${mathData.mathjaxText}$$
56784
56784
  });
56785
56785
  };
56786
56786
  class InsertMenuProvider$1 extends ProxyProvider {
56787
- constructor(editor, withPlainText = true) {
56788
- var _a, _b, _c;
56787
+ constructor(editor, options) {
56788
+ var _a, _b, _c, _d, _e, _f, _g;
56789
56789
  super();
56790
56790
  __publicField(this, "id", "InsertMenuProvider");
56791
56791
  __publicField(this, "providersMap", /* @__PURE__ */ new Map());
@@ -56926,10 +56926,13 @@ $$${mathData.mathjaxText}$$
56926
56926
  return false;
56927
56927
  });
56928
56928
  this.editor = editor;
56929
- this.withPlainText = withPlainText;
56930
- 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
+ }
56931
56934
  this.providersMap.set("common", new InlineBoxCommandProvider(this.editor));
56932
- 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 : [];
56933
56936
  commandProviders.forEach((provider) => {
56934
56937
  if (provider.getAvailableCommands) {
56935
56938
  this.providers.push(provider);
@@ -56955,7 +56958,7 @@ $$${mathData.mathjaxText}$$
56955
56958
  return {};
56956
56959
  });
56957
56960
  this.editor = editor;
56958
- this.registerCommandProvider(new InsertMenuProvider$1(editor, false));
56961
+ this.registerCommandProvider(new InsertMenuProvider$1(editor, { withPlainText: false }));
56959
56962
  }
56960
56963
  getCommands(range) {
56961
56964
  var _a, _b;
@@ -58001,11 +58004,9 @@ $$${mathData.mathjaxText}$$
58001
58004
  __publicField(this, "executeInsertCommand", () => false);
58002
58005
  this.editor = editor;
58003
58006
  }
58004
- getAvailableCommands(editor, block, range) {
58005
- if (!isTextKindBlock(editor, block)) {
58006
- return [];
58007
- }
58008
- 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)) {
58009
58010
  return [];
58010
58011
  }
58011
58012
  let commands;
@@ -58015,6 +58016,11 @@ $$${mathData.mathjaxText}$$
58015
58016
  const subText2 = getSubText(editor, block, range);
58016
58017
  commands = getCommands$1(subText2);
58017
58018
  }
58019
+ if (!(params == null ? void 0 : params.isFilter)) {
58020
+ commands.forEach((item) => {
58021
+ item.states = disable ? ["disabled"] : [];
58022
+ });
58023
+ }
58018
58024
  return commands;
58019
58025
  }
58020
58026
  getInsertCommands() {
@@ -58089,15 +58095,13 @@ $$${mathData.mathjaxText}$$
58089
58095
  get blockAttributesHandler() {
58090
58096
  return this.editor.getCustom("block-attributes-handler");
58091
58097
  }
58092
- getAvailableCommands(editor, block, range) {
58093
- if (!isTextKindBlock(editor, block)) {
58094
- return [];
58095
- }
58096
- 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)) {
58097
58101
  return [];
58098
58102
  }
58099
58103
  this.updateButtonColor(range);
58100
- return [{ ...this.colorItem }];
58104
+ return [{ ...this.colorItem, states: disable ? ["disabled"] : [] }];
58101
58105
  }
58102
58106
  getInsertCommands() {
58103
58107
  return [];
@@ -58143,11 +58147,9 @@ $$${mathData.mathjaxText}$$
58143
58147
  __publicField(this, "executeInsertCommand", () => false);
58144
58148
  this.editor = editor;
58145
58149
  }
58146
- getAvailableCommands(editor, block, range) {
58147
- if (!isTextKindBlock(editor, block)) {
58148
- return [];
58149
- }
58150
- 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)) {
58151
58153
  return [];
58152
58154
  }
58153
58155
  let commands;
@@ -58157,6 +58159,11 @@ $$${mathData.mathjaxText}$$
58157
58159
  const subText2 = getSubText(editor, block, range);
58158
58160
  commands = getCommands(subText2);
58159
58161
  }
58162
+ if (!(params == null ? void 0 : params.isFilter)) {
58163
+ commands.forEach((item) => {
58164
+ item.states = disable ? ["disabled"] : [];
58165
+ });
58166
+ }
58160
58167
  return commands;
58161
58168
  }
58162
58169
  getInsertCommands() {
@@ -58181,16 +58188,14 @@ $$${mathData.mathjaxText}$$
58181
58188
  super();
58182
58189
  __publicField(this, "id", "ScriptDropdownProvider");
58183
58190
  __publicField(this, "getInsertCommands", () => []);
58184
- __publicField(this, "getAvailableCommands", (editor, block, range) => {
58185
- if (!isTextKindBlock(editor, block)) {
58186
- return [];
58187
- }
58188
- 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)) {
58189
58194
  return [];
58190
58195
  }
58191
58196
  const commands = [];
58192
58197
  for (const provider of this.providers) {
58193
- commands.push(...provider.getAvailableCommands(editor, block, range));
58198
+ commands.push(...provider.getAvailableCommands(editor, block, range, params));
58194
58199
  }
58195
58200
  return [{
58196
58201
  children: commands,
@@ -58258,30 +58263,34 @@ $$${mathData.mathjaxText}$$
58258
58263
  }
58259
58264
  const logger$1F = getLogger("text-command-provider");
58260
58265
  class TextCommandProvider {
58261
- constructor(editor) {
58266
+ constructor(editor, options) {
58262
58267
  __publicField(this, "id", "TextCommandProvider");
58263
58268
  __publicField(this, "groupIndex", 500);
58264
58269
  __publicField(this, "providers");
58265
58270
  this.editor = editor;
58271
+ this.options = options;
58266
58272
  this.providers = [
58267
58273
  new InlineStyleProvider(editor),
58268
58274
  new ColorStyleProvider(editor),
58269
58275
  new InlineCodeProvider(editor)
58270
58276
  ];
58271
58277
  if (!clientType.isMobile) {
58272
- 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
+ }
58273
58283
  }
58274
58284
  }
58275
58285
  getAvailableCommands(editor, block, range) {
58276
- if (!isTextKindBlock(editor, block)) {
58277
- return [];
58278
- }
58279
- 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)) {
58280
58289
  return [];
58281
58290
  }
58282
58291
  const commands = [];
58283
58292
  for (const provider of this.providers) {
58284
- commands.push(...provider.getAvailableCommands(editor, block, range));
58293
+ commands.push(...provider.getAvailableCommands(editor, block, range, this.options));
58285
58294
  }
58286
58295
  if (getBlockTextLength$6(editor, block) === 0) {
58287
58296
  return this.setCommandsStates(commands, block).map(TextCommandProvider.toTextCommand);
@@ -84841,7 +84850,7 @@ ${data2.flowchartText}
84841
84850
  OnesEditorTocProvider.register(editor);
84842
84851
  OnesEditorExclusiveBlock.register(editor);
84843
84852
  if (!clientType.isMobile) {
84844
- editor.editorCommandProviders.registerCommandProvider(new TextCommandProvider(editor));
84853
+ editor.editorCommandProviders.registerCommandProvider(new TextCommandProvider(editor, { scriptDropDown: true, isFilter: true }));
84845
84854
  editor.addCustom("editor-tooltip", () => new OnesEditorTooltip(editor));
84846
84855
  } else {
84847
84856
  editor.addCustom("mobile-helper", () => new OnesEditorMobileHelper(editor));
@@ -84886,7 +84895,7 @@ ${data2.flowchartText}
84886
84895
  }
84887
84896
  }
84888
84897
  });
84889
- editor.version = "2.1.1-beta.16";
84898
+ editor.version = "2.1.1-beta.17";
84890
84899
  if (Logger$2.level === LogLevel.DEBUG) {
84891
84900
  window.setReauthFail = (fail) => {
84892
84901
  window.isReauthError = fail;
@@ -84951,7 +84960,7 @@ ${data2.flowchartText}
84951
84960
  return new OnesEditorQuickMenu(editor, (_a2 = options.componentsOptions) == null ? void 0 : _a2.quickMenu);
84952
84961
  });
84953
84962
  editor.addCustom("block-menu", (editor2) => new OnesEditorBlockMenuButtons(editor2));
84954
- editor.editorCommandProviders.registerCommandProvider(new TextCommandProvider(editor));
84963
+ editor.editorCommandProviders.registerCommandProvider(new TextCommandProvider(editor, { scriptDropDown: true, isFilter: true }));
84955
84964
  editor.addCustom("editor-tooltip", () => new OnesEditorTooltip(editor));
84956
84965
  } else {
84957
84966
  editor.addCustom("mobile-helper", () => new OnesEditorMobileHelper(editor));
@@ -84983,7 +84992,7 @@ ${data2.flowchartText}
84983
84992
  });
84984
84993
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
84985
84994
  OnesEditorToolbar.register(editor);
84986
- editor.version = "2.1.1-beta.16";
84995
+ editor.version = "2.1.1-beta.17";
84987
84996
  return editor;
84988
84997
  }
84989
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.16",
3
+ "version": "2.1.1-beta.17",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",