@ones-editor/editor 2.1.1-beta.28 → 2.1.1-beta.29

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,10 +1,11 @@
1
- import { BlockElement, CommandItem, DocBlock, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
1
+ import { BlockElement, CommandItem, CommandParams, DocBlock, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
2
2
  export default class AlignProvider implements OnesEditorCommandProvider {
3
3
  private editor;
4
4
  id: string;
5
5
  constructor(editor: OnesEditor);
6
6
  isChecked(blockData: DocBlock, id: string): boolean;
7
- getAvailableCommands(editor: OnesEditor, block: BlockElement): CommandItem[];
7
+ isDisable(block: BlockElement): boolean;
8
+ getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange, params?: CommandParams): CommandItem[];
8
9
  getInsertCommands: () => never[];
9
10
  executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, command: CommandItem): boolean;
10
11
  }
@@ -6,7 +6,7 @@ export default class HeadingProvider implements OnesEditorCommandProvider {
6
6
  constructor(editor: OnesEditor, options?: CommandParams | undefined);
7
7
  getHeadingIndex(): number;
8
8
  createHeadingCommandItem(heading: number): CommandItem[];
9
- getAvailableCommands(editor: OnesEditor, block: BlockElement): CommandItem[];
9
+ getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange, params?: CommandParams): CommandItem[];
10
10
  getInsertCommands(): CommandItem[];
11
11
  executeInsertCommand: (editor: OnesEditor, containerId: string, blockIndex: number, command: CommandItem) => boolean;
12
12
  executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, command: CommandItem): boolean;
package/dist/index.js CHANGED
@@ -45904,7 +45904,7 @@ ${codeText}
45904
45904
  applyHeadingStyle(editor, newBlock, Number.parseInt((_a = command.value) != null ? _a : "1", 10) || 1);
45905
45905
  }
45906
45906
  });
45907
- return false;
45907
+ return true;
45908
45908
  });
45909
45909
  this.editor = editor;
45910
45910
  this.options = options;
@@ -45946,13 +45946,20 @@ ${codeText}
45946
45946
  }
45947
45947
  return children;
45948
45948
  }
45949
- getAvailableCommands(editor, block) {
45950
- if (!isTextKindBlock(editor, block)) {
45949
+ getAvailableCommands(editor, block, range, params) {
45950
+ const disable = !isTextKindBlock(editor, block);
45951
+ if (disable && (params == null ? void 0 : params.isFilter)) {
45951
45952
  return [];
45952
45953
  }
45953
45954
  const blockData = editor.getBlockData(block);
45954
45955
  const heading = blockData.heading;
45955
45956
  const headingItems = this.createHeadingCommandItem(heading || 0);
45957
+ if (disable) {
45958
+ headingItems.forEach((command) => {
45959
+ var _a;
45960
+ return (_a = command.states) == null ? void 0 : _a.push("disabled");
45961
+ });
45962
+ }
45956
45963
  return headingItems;
45957
45964
  }
45958
45965
  getInsertCommands() {
@@ -46048,7 +46055,7 @@ ${codeText}
46048
46055
  childrenPlacement: "bottom-start",
46049
46056
  defaultCheckedChildren: ["text"],
46050
46057
  children: commands,
46051
- childrenType: "toolbar"
46058
+ childrenType: "menu"
46052
46059
  }
46053
46060
  ];
46054
46061
  });
@@ -49075,17 +49082,24 @@ ${codeText}
49075
49082
  }
49076
49083
  return false;
49077
49084
  }
49078
- getAvailableCommands(editor, block) {
49085
+ isDisable(block) {
49079
49086
  const isMedia = isEmbedBlock(block) && ALLOW_ALIGN_EMBED.includes(getEmbedType(block));
49080
49087
  const isSingleBlock = isMedia;
49081
- if (!isTextKindBlock(editor, block) && !isMedia && !isSingleBlock) {
49082
- return [];
49088
+ if (!isTextKindBlock(this.editor, block) && !isMedia && !isSingleBlock) {
49089
+ return true;
49083
49090
  }
49084
- if (isSelectBoxOnly(editor)) {
49091
+ if (isSelectBoxOnly(this.editor)) {
49092
+ return true;
49093
+ }
49094
+ return false;
49095
+ }
49096
+ getAvailableCommands(editor, block, range, params) {
49097
+ const disable = this.isDisable(block);
49098
+ if (disable && (params == null ? void 0 : params.isFilter)) {
49085
49099
  return [];
49086
49100
  }
49087
49101
  const blockData = editor.getBlockData(block);
49088
- return [{
49102
+ const commands = [{
49089
49103
  id: "align-left",
49090
49104
  name: i18n$1.t("commands.alignLeft"),
49091
49105
  icon: AlignLeftIcon,
@@ -49101,12 +49115,16 @@ ${codeText}
49101
49115
  icon: AlignRightIcon,
49102
49116
  states: this.isChecked(blockData, "right") ? ["checked"] : []
49103
49117
  }];
49118
+ if (disable) {
49119
+ commands.forEach((command) => {
49120
+ var _a;
49121
+ return (_a = command.states) == null ? void 0 : _a.push("disabled");
49122
+ });
49123
+ }
49124
+ return commands;
49104
49125
  }
49105
49126
  executeCommand(editor, block, range, command) {
49106
- if (!isTextKindBlock(editor, block)) {
49107
- return false;
49108
- }
49109
- if (isSelectBoxOnly(editor)) {
49127
+ if (this.isDisable(block)) {
49110
49128
  return false;
49111
49129
  }
49112
49130
  if (command.id.startsWith("align")) {
@@ -56936,15 +56954,15 @@ $$${mathData.mathjaxText}$$
56936
56954
  const blockId = getBlockId(block);
56937
56955
  assert(logger$1M, range.isSimple(), "invalid range");
56938
56956
  const offset = range.start.offset;
56939
- for (const provider of this.quickProviders) {
56940
- const params2 = { from: "quick-menu", blockId, offset };
56941
- (_d = provider.executeCommand) == null ? void 0 : _d.call(provider, editor, item, params2);
56942
- }
56943
56957
  for (const [id, provider] of this.providersMap) {
56944
- if ((_e = provider.executeCommand) == null ? void 0 : _e.call(provider, editor, block, range, item, params)) {
56958
+ if ((_d = provider.executeCommand) == null ? void 0 : _d.call(provider, editor, block, range, item, params)) {
56945
56959
  return true;
56946
56960
  }
56947
56961
  }
56962
+ for (const provider of this.quickProviders) {
56963
+ const params2 = { from: "quick-menu", blockId, offset };
56964
+ (_e = provider.executeCommand) == null ? void 0 : _e.call(provider, editor, item, params2);
56965
+ }
56948
56966
  return false;
56949
56967
  });
56950
56968
  this.editor = editor;
@@ -57546,7 +57564,7 @@ $$${mathData.mathjaxText}$$
57546
57564
  this.block = block;
57547
57565
  this.range = range;
57548
57566
  for (const provider of this.providers) {
57549
- this.commands.push(...((_a = provider.getAvailableCommands) == null ? void 0 : _a.call(provider, editor, block, range)) || []);
57567
+ this.commands.push(...((_a = provider.getAvailableCommands) == null ? void 0 : _a.call(provider, editor, block, range, { isFilter: true })) || []);
57550
57568
  }
57551
57569
  const createCommandElement = () => {
57552
57570
  const wrap = createElement("div", ["text-styles"], null);
@@ -84918,7 +84936,7 @@ ${data2.flowchartText}
84918
84936
  }
84919
84937
  }
84920
84938
  });
84921
- editor.version = "2.1.1-beta.28";
84939
+ editor.version = "2.1.1-beta.29";
84922
84940
  if (Logger$2.level === LogLevel.DEBUG) {
84923
84941
  window.setReauthFail = (fail) => {
84924
84942
  window.isReauthError = fail;
@@ -85015,7 +85033,7 @@ ${data2.flowchartText}
85015
85033
  });
85016
85034
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
85017
85035
  OnesEditorToolbar.register(editor);
85018
- editor.version = "2.1.1-beta.28";
85036
+ editor.version = "2.1.1-beta.29";
85019
85037
  return editor;
85020
85038
  }
85021
85039
  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.28",
3
+ "version": "2.1.1-beta.29",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",