@ones-editor/editor 2.1.0-beta.1 → 2.1.0-beta.3

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.
Files changed (72) hide show
  1. package/@ones-editor/{ui → block-menu}/src/block-menu/index.d.ts +1 -3
  2. package/@ones-editor/block-menu/src/block-menu/items/block-command-items.d.ts +3 -0
  3. package/@ones-editor/block-menu/src/block-menu/items/index.d.ts +5 -0
  4. package/@ones-editor/block-menu/src/block-menu/items/insert-block-items/index.d.ts +5 -0
  5. package/@ones-editor/block-menu/src/block-menu/items/text-styles/text-style-item.d.ts +30 -0
  6. package/@ones-editor/block-menu/src/block-menu/items/types.d.ts +5 -0
  7. package/@ones-editor/block-menu/src/block-menu-button/menu-button/index.d.ts +1 -1
  8. package/@ones-editor/callout-block/src/callout-block/callout-quick-menu-item-filter.d.ts +4 -3
  9. package/@ones-editor/comments/src/comments-helper/old-version-comment.d.ts +17 -0
  10. package/@ones-editor/comments/src/index.d.ts +3 -0
  11. package/@ones-editor/comments/src/text-comments/comments-command-provider.d.ts +3 -4
  12. package/@ones-editor/core/src/core/blocks/common/block-properties.d.ts +9 -9
  13. package/@ones-editor/core/src/core/blocks/common/execute-block-command.d.ts +2 -2
  14. package/@ones-editor/core/src/core/blocks/complex-blocks/child-blocks.d.ts +2 -1
  15. package/@ones-editor/core/src/core/blocks/text-blocks/base/child.d.ts +2 -7
  16. package/@ones-editor/core/src/core/command-providers/commands/index.d.ts +0 -2
  17. package/@ones-editor/core/src/core/command-providers/commands/range-commands.d.ts +3 -3
  18. package/@ones-editor/core/src/core/command-providers/editor-command-providers.d.ts +3 -4
  19. package/@ones-editor/core/src/core/doc/doc.d.ts +1 -0
  20. package/@ones-editor/core/src/core/types.d.ts +31 -23
  21. package/@ones-editor/sharedb-doc/src/index.d.ts +3 -0
  22. package/@ones-editor/table-block/src/commands/table-block-commands.d.ts +3 -4
  23. package/@ones-editor/text-commands/src/text-command-provider.d.ts +3 -4
  24. package/@ones-editor/text-commands/src/text-commands.d.ts +3 -3
  25. package/@ones-editor/tsconfig.tsbuildinfo +1 -1
  26. package/@ones-editor/ui/src/index.d.ts +10 -7
  27. package/@ones-editor/ui/src/{providers/utils → quick-menu}/basic-commands.d.ts +2 -1
  28. package/@ones-editor/ui/src/quick-menu/basic-menu-items.d.ts +16 -0
  29. package/@ones-editor/ui/src/quick-menu/index.d.ts +18 -6
  30. package/@ones-editor/ui/src/quick-menu/inline-box-items.d.ts +8 -0
  31. package/@ones-editor/ui/src/quick-menu/insert-empty-block.d.ts +4 -0
  32. package/@ones-editor/ui/src/quick-menu/order.d.ts +1 -0
  33. package/@ones-editor/ui/src/quick-menu/quick-menu-items.d.ts +9 -0
  34. package/@ones-editor/ui/src/quick-menu/types.d.ts +4 -0
  35. package/@ones-editor/ui/src/readonly-toolbar/add-comment-to-old-doc.d.ts +22 -0
  36. package/@ones-editor/ui/src/readonly-toolbar/index.d.ts +29 -0
  37. package/@ones-editor/ui/src/readonly-toolbar/types.d.ts +12 -0
  38. package/@ones-editor/ui/src/{providers → toolbar/commands}/align.d.ts +4 -4
  39. package/@ones-editor/ui/src/toolbar/commands/paragraph.d.ts +11 -0
  40. package/@ones-editor/ui/src/toolbar/commands/turn-into.d.ts +10 -0
  41. package/@ones-editor/ui/src/toolbar/link-commands.d.ts +7 -0
  42. package/@ones-editor/ui/src/toolbar/merge-commands.d.ts +2 -0
  43. package/@ones-editor/ui/src/toolbar/text-commands.d.ts +2 -2
  44. package/dist/comments/local-doc-comments-provider.d.ts +2 -1
  45. package/dist/index.js +14195 -13588
  46. package/dist/types.d.ts +1 -1
  47. package/package.json +1 -1
  48. package/@ones-editor/core/src/core/command-providers/commands/inject-source.d.ts +0 -3
  49. package/@ones-editor/core/src/core/command-providers/commands/merge-commands.d.ts +0 -3
  50. package/@ones-editor/layout-block/src/command-filter.d.ts +0 -7
  51. package/@ones-editor/ui/src/block-menu/block-command-providers.d.ts +0 -10
  52. package/@ones-editor/ui/src/providers/abstract-providers.d.ts +0 -19
  53. package/@ones-editor/ui/src/providers/align-dropdown.d.ts +0 -10
  54. package/@ones-editor/ui/src/providers/block-hook-provider.d.ts +0 -16
  55. package/@ones-editor/ui/src/providers/heading.d.ts +0 -13
  56. package/@ones-editor/ui/src/providers/insert-above.d.ts +0 -9
  57. package/@ones-editor/ui/src/providers/insert-after.d.ts +0 -9
  58. package/@ones-editor/ui/src/providers/insert-box-provider.d.ts +0 -12
  59. package/@ones-editor/ui/src/providers/insert-group.d.ts +0 -7
  60. package/@ones-editor/ui/src/providers/insert-menu.d.ts +0 -16
  61. package/@ones-editor/ui/src/providers/link.d.ts +0 -17
  62. package/@ones-editor/ui/src/providers/list.d.ts +0 -13
  63. package/@ones-editor/ui/src/providers/paragraph.d.ts +0 -8
  64. package/@ones-editor/ui/src/providers/proxy-provider.d.ts +0 -9
  65. package/@ones-editor/ui/src/providers/quoted.d.ts +0 -10
  66. package/@ones-editor/ui/src/providers/text-fixed-provider.d.ts +0 -16
  67. package/@ones-editor/ui/src/providers/text-styles.d.ts +0 -9
  68. package/@ones-editor/ui/src/providers/turn-into.d.ts +0 -9
  69. package/@ones-editor/ui/src/providers/utils/add-section.d.ts +0 -2
  70. package/@ones-editor/ui/src/providers/utils/inject-block-options.d.ts +0 -5
  71. package/@ones-editor/ui/src/quick-menu/quick-command-providers.d.ts +0 -10
  72. /package/@ones-editor/{ui → block-menu}/src/block-menu/standard-block-actions/hook.d.ts +0 -0
@@ -1,13 +1,11 @@
1
- import { BlockElement, OnesEditor, CommandFilterId, CommandFilter, CommandItem } from '../../../../@ones-editor/core';
1
+ import { BlockElement, OnesEditor, CommandItem } from '../../../../@ones-editor/core';
2
2
  import type { ManualShowCommandBarOptions } from '../../../../@ones-editor/ui-base';
3
3
  export default class BlockMenu {
4
4
  private editor;
5
5
  private menu;
6
6
  currentBlock: BlockElement | null;
7
7
  private commandBlock;
8
- private blockCommandProviders;
9
8
  constructor(editor: OnesEditor);
10
- addFilter(id: CommandFilterId, filter: CommandFilter): void;
11
9
  show(target: HTMLElement, options?: ManualShowCommandBarOptions): void;
12
10
  isInMenu(eventTarget: EventTarget | null): boolean;
13
11
  handleShow: () => void;
@@ -0,0 +1,3 @@
1
+ import { BlockElement, OnesEditor } from '../../../../../@ones-editor/core';
2
+ import { BlockMenuItem } from './types';
3
+ export declare function getBlockCommandItems(editor: OnesEditor, block: BlockElement, excludes?: Set<string>): BlockMenuItem[];
@@ -0,0 +1,5 @@
1
+ import { BlockElement, OnesEditor } from '../../../../../@ones-editor/core';
2
+ import { TextStyleItemOptions } from './text-styles/text-style-item';
3
+ import { BlockMenuItem } from './types';
4
+ export declare function getBlockMenuItems(editor: OnesEditor, block: BlockElement, options: TextStyleItemOptions): BlockMenuItem[];
5
+ export declare function handleBlockMenuItemClick(editor: OnesEditor, block: BlockElement, item: BlockMenuItem): void;
@@ -0,0 +1,5 @@
1
+ import { BlockElement, OnesEditor } from '../../../../../../@ones-editor/core';
2
+ import type { GetAllQuickMenuItemsOptions } from '../../../../../../@ones-editor/ui';
3
+ import type { BlockMenuItem } from '../types';
4
+ export declare function getAllInsertBlockItems(editor: OnesEditor, block: BlockElement, source: 'insert-block' | 'insert-block-before', options: GetAllQuickMenuItemsOptions): BlockMenuItem[];
5
+ export declare function executeInsertBlockCommand(editor: OnesEditor, block: BlockElement, item: BlockMenuItem, insertAbove?: boolean): Promise<BlockElement | null> | undefined;
@@ -0,0 +1,30 @@
1
+ import { BlockElement, OnesEditor, DocBlock } from '../../../../../../@ones-editor/core';
2
+ import { BlockMenuItem } from '../types';
3
+ export interface ParagraphBlockAttribute extends DocBlock {
4
+ 'heading'?: number;
5
+ quoted?: boolean;
6
+ align?: 'left' | 'center' | 'right';
7
+ checkbox?: 'checked' | 'unchecked';
8
+ ordered?: boolean;
9
+ }
10
+ export type TextStyleItemOptions = {
11
+ fromEmbed?: boolean;
12
+ onAfterStyleItemClick?: () => void;
13
+ };
14
+ export default class TextStyleItem implements BlockMenuItem {
15
+ private editor;
16
+ private block;
17
+ private options;
18
+ source: string;
19
+ id: string;
20
+ name: string;
21
+ element: HTMLElement;
22
+ private textStylesTooltips;
23
+ constructor(editor: OnesEditor, block: BlockElement, options: TextStyleItemOptions);
24
+ createItemElement(editor: OnesEditor, block: BlockElement): HTMLDivElement;
25
+ private createHeadingItemElement;
26
+ private createListItemElement;
27
+ createItem(id: string, icon: string, parent: HTMLElement, active?: boolean): void;
28
+ handleClick: (editor: OnesEditor, event: Event) => void;
29
+ private calcTextStyleItemTooltipsEnum;
30
+ }
@@ -0,0 +1,5 @@
1
+ import { CommandItem } from '../../../../../@ones-editor/core';
2
+ export interface BlockMenuItem extends CommandItem {
3
+ source: string;
4
+ blockMenuItemCustomData?: unknown;
5
+ }
@@ -1,6 +1,6 @@
1
1
  import { BlockElement, OnesEditor } from '../../../../../@ones-editor/core';
2
- import { BlockMenu } from '../../../../../@ones-editor/ui';
3
2
  import EmptyBlockMenu from '../../empty-block-menu';
3
+ import BlockMenu from '../../block-menu';
4
4
  export default class OnesEditorBlockMenuButton {
5
5
  private editor;
6
6
  buttonElement: HTMLButtonElement;
@@ -1,7 +1,8 @@
1
- import { CommandFilter, CommandItemWithSource, OnesEditor, OnesEditorCustom, SelectionRange } from '../../../../@ones-editor/core';
2
- export declare class CalloutQuickMenuItemFilter implements CommandFilter, OnesEditorCustom {
1
+ import { OnesEditor, OnesEditorCustom } from '../../../../@ones-editor/core';
2
+ import type { QuickMenuItem, QuickMenuItemFilter } from '../../../../@ones-editor/ui';
3
+ export declare class CalloutQuickMenuItemFilter implements QuickMenuItemFilter, OnesEditorCustom {
3
4
  constructor(editor: OnesEditor);
4
- filter(editor: OnesEditor, range: SelectionRange, items: CommandItemWithSource[], source: string[]): CommandItemWithSource[];
5
+ filter(editor: OnesEditor, items: QuickMenuItem[], from: string): QuickMenuItem[];
5
6
  destroy(): void;
6
7
  static init(editor: OnesEditor): CalloutQuickMenuItemFilter;
7
8
  }
@@ -0,0 +1,17 @@
1
+ import { DocObject, EditorSimpleSelectionRange, OnesEditor, OnesEditorComment } from '../../../../@ones-editor/core';
2
+ export interface AddCommentToOldVersionBody {
3
+ avatarUrl: string;
4
+ containerId: string;
5
+ startBlockId: string;
6
+ startOffset: number;
7
+ endBlockId: string;
8
+ endOffset: number;
9
+ commentId?: string;
10
+ commentGroupId?: string;
11
+ comment: DocObject;
12
+ abstract?: string;
13
+ }
14
+ export declare function addCommentToOldVersion(editor: OnesEditor, version: number, range: EditorSimpleSelectionRange, comment: OnesEditorComment, commentDoc: DocObject): Promise<void>;
15
+ export declare function replyCommentToOldVersion(editor: OnesEditor, version: number, comment: OnesEditorComment, commentDoc: DocObject): Promise<unknown>;
16
+ export declare function updateCommentToOldDoc(editor: OnesEditor, version: number, commentId: string, commentDoc: DocObject): Promise<unknown>;
17
+ export declare function deleteCommentFromOldDoc(editor: OnesEditor, version: number, commentId: string): Promise<unknown>;
@@ -8,4 +8,7 @@ export { OnesEditorComments };
8
8
  export type { CommentItem } from './comment-item';
9
9
  export type { CommentGroupItem } from './comments-list/group-item';
10
10
  export { removeCommentFromBlock } from './actions/remove-comment-from-block';
11
+ export { addCommentToTextBlocks } from './actions/add-comment-to-text-block';
12
+ export { addCommentToBlock } from './actions/add-comment-to-block';
11
13
  export { editorAddComment } from './actions/editor-add-comment';
14
+ export * from './comments-helper/old-version-comment';
@@ -1,13 +1,12 @@
1
- import { BlockElement, CommandItem, CommandItemWithSource, CommandParams, CommandResult, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
1
+ import { BlockCommandItem, BlockCommandItemWithSource, BlockElement, CommandParams, CommandResult, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
2
2
  import { OnesEditorCommentsProvider } from '../types';
3
3
  import type { OnesEditorComments } from '../comments';
4
4
  export default class CommentsCommandProvider implements OnesEditorCommandProvider {
5
5
  private provider;
6
6
  private editorComments;
7
7
  id: string;
8
- groupIndex: number;
9
8
  constructor(provider: OnesEditorCommentsProvider, editorComments: OnesEditorComments);
10
- getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange): CommandItem[];
9
+ getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange): BlockCommandItem[];
11
10
  hideToolbar(editor: OnesEditor): void;
12
- executeRangeCommand(editor: OnesEditor, range: SelectionRange, command: CommandItemWithSource, params: CommandParams, result?: CommandResult): boolean;
11
+ executeRangeCommand(editor: OnesEditor, range: SelectionRange, command: BlockCommandItemWithSource, params: CommandParams, result: CommandResult): boolean;
13
12
  }
@@ -1,10 +1,10 @@
1
- import { BlockCommands, BlockElement, OnesEditor } from '../../types';
1
+ import { BlockCommands, BlockElement, BoxCommands, OnesEditor, TextBlockContentChild } from '../../types';
2
2
  export declare function getBlockProperties(editor: OnesEditor, block: BlockElement): import("../../types").BlockProperties | undefined;
3
- export declare function getBlockCommandsWithHook(editor: OnesEditor, block: BlockElement): Record<string, BlockCommands>;
4
- export declare function getSpecialBlockCommands(editor: OnesEditor, blockElement: BlockElement, group: string): {
5
- element: import("../../types").BlockContentElement;
6
- commands: import("../../types").CommandItem[];
7
- } | {
8
- element: null;
9
- commands: never[];
10
- };
3
+ export declare function getBlockCommandsWithHook(editor: OnesEditor, block: BlockElement, child: TextBlockContentChild | null): Record<string, BlockCommands>;
4
+ interface SpecialBlockCommands {
5
+ element: HTMLElement | null;
6
+ blockCommands: BlockCommands[];
7
+ boxCommands: BoxCommands[];
8
+ }
9
+ export declare function getSpecialBlockCommands(editor: OnesEditor, blockElement: BlockElement, child: TextBlockContentChild | null, group: string): SpecialBlockCommands;
10
+ export {};
@@ -1,3 +1,3 @@
1
- import { BlockElement, CommandItem, CommandItemWithSource, OnesEditor } from '../../types';
1
+ import { BlockCommandItemWithSource, BlockElement, CommandItem, OnesEditor } from '../../types';
2
2
  export declare function executeEmbedBlockCommand(editor: OnesEditor, block: BlockElement, commandGroup: string, item: CommandItem): unknown;
3
- export declare function executeBlockCommand(editor: OnesEditor, block: BlockElement, commandGroup: string, item: CommandItemWithSource): unknown;
3
+ export declare function executeBlockCommand(editor: OnesEditor, block: BlockElement, commandGroup: string, item: BlockCommandItemWithSource): unknown;
@@ -1,7 +1,8 @@
1
- import { BlockElement, OnesEditor, SelectedBlock } from '../../types';
1
+ import { BlockElement, OnesEditor, SelectedBlock, SelectionRange } from '../../types';
2
2
  export type GetAllChildBlocksOptions = {
3
3
  simpleBlockOnly?: boolean;
4
4
  visibleOnly?: boolean;
5
+ range?: SelectionRange;
5
6
  };
6
7
  export declare function getAllChildBlocks(editor: OnesEditor, options?: GetAllChildBlocksOptions): BlockElement[];
7
8
  export declare function getAllSelectedBlocks(editor: OnesEditor, options?: GetAllChildBlocksOptions): SelectedBlock[];
@@ -1,10 +1,5 @@
1
- import { BlockElement, BoxElement, InsertionElement } from '../../../types';
2
- export type TextBlockContentTextChild = HTMLSpanElement & {
3
- __neverUse: 'TextBlockContentTextChild';
4
- };
5
- export type TextBlockContentInsertionChild = InsertionElement;
6
- export type TextBlockContentBoxChild = BoxElement;
7
- export type TextBlockContentChild = TextBlockContentTextChild | TextBlockContentBoxChild | TextBlockContentInsertionChild;
1
+ import { BlockElement, TextBlockContentTextChild, TextBlockContentBoxChild, TextBlockContentInsertionChild, TextBlockContentChild } from '../../../types';
2
+ export type { TextBlockContentTextChild, TextBlockContentBoxChild, TextBlockContentInsertionChild, TextBlockContentChild };
8
3
  export type TextBlockContentChildren = TextBlockContentChild[];
9
4
  export type TextBlockContentChildType = 'text' | 'box' | 'insertion';
10
5
  export declare function isTextBlockContentChild(elem: Element): boolean;
@@ -1,4 +1,2 @@
1
1
  export * from './intersection-commands';
2
2
  export * from './range-commands';
3
- export * from './merge-commands';
4
- export * from './inject-source';
@@ -1,5 +1,5 @@
1
- import { CommandItemWithSource, CommandParams, CommandResult, SelectionRange } from '../../types';
2
- export declare function getRangeCommands(range: SelectionRange, source: string): CommandItemWithSource[];
3
- export declare function executeRangeCommand(range: SelectionRange, command: CommandItemWithSource, params: CommandParams): {
1
+ import { BlockCommandItemWithSource, CommandParams, CommandResult, SelectionRange } from '../../types';
2
+ export declare function getRangeCommands(range: SelectionRange, source: string): BlockCommandItemWithSource[];
3
+ export declare function executeRangeCommand(range: SelectionRange, command: BlockCommandItemWithSource, params: CommandParams): {
4
4
  [index: string]: CommandResult;
5
5
  };
@@ -1,15 +1,14 @@
1
1
  import { DocBlockTextAttributes } from '../doc';
2
- import { OnesEditor, OnesEditorCommandProviders, OnesEditorCommandProvider, SelectionRange, CommandParams, CommandItemWithSource } from '../types';
2
+ import { OnesEditor, OnesEditorCommandProviders, OnesEditorCommandProvider, SelectionRange, CommandParams, BlockCommandItemWithSource } from '../types';
3
3
  export default class EditorCommandProviders implements OnesEditorCommandProviders {
4
4
  private editor;
5
- id: string;
6
5
  private providers;
7
6
  constructor(editor: OnesEditor);
8
7
  registerCommandProvider(provider: OnesEditorCommandProvider): void;
9
8
  getCommandProviders(): OnesEditorCommandProvider[];
10
9
  getCommandProvider(id: string): OnesEditorCommandProvider;
11
- getCommands(range: SelectionRange): CommandItemWithSource[];
12
- executeCommand(range: SelectionRange, command: CommandItemWithSource, params: CommandParams): {
10
+ getCommands(range: SelectionRange, source: string): BlockCommandItemWithSource[];
11
+ executeCommand(range: SelectionRange, command: BlockCommandItemWithSource, params: CommandParams): {
13
12
  [index: string]: import("../types").CommandResult;
14
13
  };
15
14
  getEmptyBlockTextAttributes(editor: OnesEditor, blockId: string): DocBlockTextAttributes | undefined;
@@ -202,6 +202,7 @@ export interface OnesEditorDocServerMeta {
202
202
  serverId?: string;
203
203
  docId?: string;
204
204
  appId?: string;
205
+ apiServer?: string;
205
206
  }
206
207
  export interface RecognizeLinkResult {
207
208
  type?: 'iframe' | 'video' | 'audio' | 'image';
@@ -1,5 +1,11 @@
1
1
  import { TypedEmitter } from 'tiny-typed-emitter';
2
2
  import { DocBlock, DocBlockAttributes, DocBlockDelta, DocBlocks, DocBlockText, DocBlockTextAttributes, DocBox, DocEmbedBlock, DocEmbedData, DocInsertion, DocObject, InsertBlockOptions, OnesEditorDoc, OnesEditorDocRange, UpdateBlockOptions } from './doc';
3
+ export type TextBlockContentTextChild = HTMLSpanElement & {
4
+ __neverUse: 'TextBlockContentTextChild';
5
+ };
6
+ export type TextBlockContentInsertionChild = InsertionElement;
7
+ export type TextBlockContentBoxChild = BoxElement;
8
+ export type TextBlockContentChild = TextBlockContentTextChild | TextBlockContentBoxChild | TextBlockContentInsertionChild;
3
9
  export type ContainerElement = HTMLDivElement & {
4
10
  __neverUse: 'ContainerElement';
5
11
  };
@@ -52,6 +58,7 @@ export type BlockPosition = SimpleBlockPosition | ComplexBlockPosition;
52
58
  export interface BoxCommands {
53
59
  group: string;
54
60
  commands: CommandItem[];
61
+ startGroup?: boolean;
55
62
  executeCommand: (editor: OnesEditor, block: BlockElement, box: BoxElement, item: CommandItem) => unknown;
56
63
  }
57
64
  export interface BoxProperties {
@@ -119,6 +126,7 @@ export interface Closeable {
119
126
  click: (item: CommandItem, target: HTMLElement) => void;
120
127
  }
121
128
  export type CommandItemChildrenPlacement = 'auto' | 'top' | 'left' | 'right' | 'bottom' | 'auto-start' | 'auto-end' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'right-start' | 'right-end' | 'left-start' | 'left-end';
129
+ export type CommandItemMenuType = 'inline' | 'sibling';
122
130
  export interface CommandItem {
123
131
  id: string;
124
132
  name: string;
@@ -151,8 +159,18 @@ export interface CommandItem {
151
159
  /**
152
160
  * defaults to true
153
161
  */
162
+ shouldShown?: (currentBlock: BlockElement | undefined, menuType: CommandItemMenuType) => boolean;
163
+ /**
164
+ * defaults to true
165
+ */
154
166
  clickToClose?: boolean;
155
167
  }
168
+ export interface BlockCommandItem extends CommandItem {
169
+ blockId: string;
170
+ blockType: string;
171
+ blockKind: BlockKind;
172
+ groupIndex: number;
173
+ }
156
174
  export type StyleType = boolean | string | number;
157
175
  export type BlockStyles = {
158
176
  [index: string]: StyleType;
@@ -163,9 +181,11 @@ export type BlockPathComponent = {
163
181
  };
164
182
  export type BlockPath = BlockPathComponent[];
165
183
  export interface BlockCommands {
184
+ element?: HTMLElement;
166
185
  group: string;
167
186
  commands: CommandItem[];
168
- executeCommand: (editor: OnesEditor, block: BlockElement, item: CommandItem) => unknown;
187
+ startGroup?: boolean;
188
+ executeCommand: (editor: OnesEditor, block: BlockElement, item: CommandItem, child: TextBlockContentChild | null) => unknown;
169
189
  }
170
190
  export interface BlockProperties {
171
191
  blockCommands?: Record<string, BlockCommands>;
@@ -703,41 +723,29 @@ export interface OnesEditorInsertions {
703
723
  }
704
724
  export type CommandParams = {
705
725
  [index: string]: unknown;
706
- } & {
707
- source?: string[];
708
726
  };
709
727
  export type CommandResult = {
710
728
  [index: string]: unknown;
711
729
  };
712
730
  export interface OnesEditorCommandProvider {
713
731
  id: string;
714
- groupIndex?: number;
715
- getAvailableCommands: (editor: OnesEditor, block: BlockElement, range: SelectionRange) => CommandItem[];
716
- getInsertCommands?: (editor: OnesEditor, containerId: string, blockIndex: number) => CommandItem[];
717
- executeInsertCommand?: (editor: OnesEditor, containerId: string, blockIndex: number, item: CommandItem, params: CommandParams, result?: CommandResult) => boolean;
718
- executeRangeCommand?: (editor: OnesEditor, range: SelectionRange, command: CommandItemWithSource, params: CommandParams, result?: CommandResult) => boolean;
719
- executeCommand?: (editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItem, params: CommandParams, result?: CommandResult) => boolean;
720
- filterCommands?: (editor: OnesEditor, block: BlockElement, range: SelectionRange, commands: CommandItemWithSource[]) => CommandItemWithSource[] | undefined;
721
- beforeExecuteCommand?: (editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItem, params: CommandParams) => boolean | undefined;
722
- afterExecuteCommand?: (editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItem, params: CommandParams, result: CommandResult) => void;
732
+ getAvailableCommands: (editor: OnesEditor, block: BlockElement, range: SelectionRange) => BlockCommandItem[];
733
+ executeCommand?: (editor: OnesEditor, block: BlockElement, range: SelectionRange, item: BlockCommandItem, params: CommandParams, result: CommandResult) => boolean;
734
+ filterCommands?: (editor: OnesEditor, block: BlockElement, range: SelectionRange, commands: BlockCommandItemWithSource[]) => BlockCommandItemWithSource[] | undefined;
735
+ beforeExecuteCommand?: (editor: OnesEditor, block: BlockElement, range: SelectionRange, item: BlockCommandItem, params: CommandParams) => boolean | undefined;
736
+ afterExecuteCommand?: (editor: OnesEditor, block: BlockElement, range: SelectionRange, item: BlockCommandItem, params: CommandParams, result: CommandResult) => void;
723
737
  getEmptyBlockTextAttributes?: (editor: OnesEditor, blockId: string) => DocBlockTextAttributes | undefined;
738
+ executeRangeCommand?: (editor: OnesEditor, range: SelectionRange, command: BlockCommandItemWithSource, params: CommandParams, result: CommandResult) => boolean;
724
739
  }
725
- export interface CommandItemWithSource extends CommandItem {
740
+ export interface BlockCommandItemWithSource extends BlockCommandItem {
726
741
  source: string;
727
742
  }
728
- export interface CommandFilter {
729
- filter: (editor: OnesEditor, range: SelectionRange, items: CommandItemWithSource[], source: string[]) => CommandItemWithSource[];
730
- }
731
- export type CommandFilterId = keyof any;
732
743
  export interface OnesEditorCommandProviders {
733
- commandFilters?: Map<CommandFilterId, CommandFilter>;
734
- addFilter?: (id: CommandFilterId, filter: CommandFilter) => void;
735
- filterItems?: (range: SelectionRange, items: CommandItemWithSource[]) => CommandItemWithSource[];
736
744
  registerCommandProvider: (provider: OnesEditorCommandProvider) => void;
737
745
  getCommandProviders: () => OnesEditorCommandProvider[];
738
746
  getCommandProvider: (id: string) => OnesEditorCommandProvider;
739
- getCommands: (range: SelectionRange) => CommandItemWithSource[];
740
- executeCommand: (range: SelectionRange, item: CommandItemWithSource, params: CommandParams) => {
747
+ getCommands: (range: SelectionRange, source: string) => BlockCommandItemWithSource[];
748
+ executeCommand: (range: SelectionRange, item: BlockCommandItemWithSource, params: CommandParams) => {
741
749
  [index: string]: CommandResult;
742
750
  };
743
751
  getEmptyBlockTextAttributes: (editor: OnesEditor, blockId: string) => DocBlockTextAttributes | undefined;
@@ -754,5 +762,5 @@ export interface OnesEditorBlockHook {
754
762
  create?: (editor: OnesEditor, path: BlockPath, container: ContainerElement, blockElement: BlockElement, blockData: DocBlock) => void;
755
763
  update?: (editor: OnesEditor, path: BlockPath, container: ContainerElement, blockElement: BlockElement, blockData: DocBlock) => void;
756
764
  writable?: (editor: OnesEditor, blockElement: BlockElement | BlockElement[]) => boolean | undefined;
757
- commands?: (editor: OnesEditor, blockElement: BlockElement) => BlockCommands;
765
+ commands?: (editor: OnesEditor, blockElement: BlockElement, child: TextBlockContentChild | null) => BlockCommands | undefined;
758
766
  }
@@ -1,6 +1,9 @@
1
+ import axios from 'axios';
1
2
  import ShareDBDoc from './doc/sharedb-doc';
2
3
  import { RemoteCarets, RemoteCaretsDecorator } from './remote-carets';
3
4
  export { ShareDBDoc, RemoteCarets, RemoteCaretsDecorator };
4
5
  export * from './doc/comments';
5
6
  export * from './types';
6
7
  export * from './versions';
8
+ export * from './utils/converter';
9
+ export { axios };
@@ -1,10 +1,9 @@
1
- import { CommandItem, BlockElement, CommandParams, CommandResult, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
1
+ import { BlockCommandItem, BlockElement, CommandParams, CommandResult, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
2
2
  declare const TableCommands: readonly ["table/merge-cells", "table/split-cell", "table/insert-column", "table/insert-row", "table/delete-rows", "table/delete-columns", "table/delete"];
3
3
  export type TableCommand = typeof TableCommands[number];
4
4
  export default class TableBlockCommandProvider implements OnesEditorCommandProvider {
5
5
  id: string;
6
- groupIndex: number;
7
- getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange): CommandItem[];
8
- executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, command: CommandItem, params: CommandParams, result?: CommandResult): boolean;
6
+ getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange): BlockCommandItem[];
7
+ executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, command: BlockCommandItem, params: CommandParams, result: CommandResult): boolean;
9
8
  }
10
9
  export {};
@@ -1,15 +1,14 @@
1
- import { BlockElement, CommandItem, CommandParams, CommandResult, DocBlockTextAttributes, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../@ones-editor/core';
1
+ import { BlockCommandItem, BlockElement, CommandParams, CommandResult, DocBlockTextAttributes, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../@ones-editor/core';
2
2
  export default class TextCommandProvider implements OnesEditorCommandProvider {
3
3
  private editor;
4
4
  id: string;
5
- groupIndex: number;
6
5
  private emptyTextBlockAttributes;
7
6
  private colorItem;
8
7
  constructor(editor: OnesEditor);
9
8
  destroy(): void;
10
9
  private updateButtonColor;
11
- getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange): CommandItem[];
12
- executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItem, params: CommandParams, result?: CommandResult): boolean;
10
+ getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange): BlockCommandItem[];
11
+ executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, item: BlockCommandItem, params: CommandParams, result: CommandResult): boolean;
13
12
  private executeCommandOnEmptyText;
14
13
  private getCommandsOnEmptyText;
15
14
  private setCommandsStates;
@@ -1,4 +1,4 @@
1
- import { CommandItem, BlockElement, CommandParams, CommandResult, OnesEditor, SelectionRange } from '../../../@ones-editor/core';
2
- export declare function getStandardEmptyStyleCommands(editor: OnesEditor, block: BlockElement): CommandItem[];
3
- export declare function getAvailableStyleCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange): CommandItem[];
1
+ import { BlockCommandItem, BlockElement, CommandParams, CommandResult, OnesEditor, SelectionRange } from '../../../@ones-editor/core';
2
+ export declare function getStandardEmptyStyleCommands(editor: OnesEditor, block: BlockElement): BlockCommandItem[];
3
+ export declare function getAvailableStyleCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange): BlockCommandItem[];
4
4
  export declare function executeStyleCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, command: string, params: CommandParams, result: CommandResult): boolean;