@jackuait/blok 0.1.1

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 (71) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +23 -0
  3. package/dist/blok.mjs +5 -0
  4. package/dist/blok.umd.js +53 -0
  5. package/dist/bundle-6e604287.mjs +340 -0
  6. package/dist/codex-7de6c88e.mjs +15668 -0
  7. package/dist/vendor.LICENSE.txt +545 -0
  8. package/package.json +108 -0
  9. package/types/api/block.d.ts +87 -0
  10. package/types/api/blocks.d.ts +136 -0
  11. package/types/api/caret.d.ts +67 -0
  12. package/types/api/events.d.ts +28 -0
  13. package/types/api/i18n.d.ts +11 -0
  14. package/types/api/index.d.ts +17 -0
  15. package/types/api/inline-toolbar.d.ts +15 -0
  16. package/types/api/listeners.d.ts +32 -0
  17. package/types/api/notifier.d.ts +14 -0
  18. package/types/api/readonly.d.ts +17 -0
  19. package/types/api/sanitizer.d.ts +14 -0
  20. package/types/api/saver.d.ts +13 -0
  21. package/types/api/selection.d.ts +41 -0
  22. package/types/api/styles.d.ts +44 -0
  23. package/types/api/toolbar.d.ts +26 -0
  24. package/types/api/tools.d.ts +11 -0
  25. package/types/api/tooltip.d.ts +30 -0
  26. package/types/api/ui.d.ts +24 -0
  27. package/types/block-tunes/block-tune-data.d.ts +1 -0
  28. package/types/block-tunes/block-tune.d.ts +60 -0
  29. package/types/block-tunes/index.d.ts +1 -0
  30. package/types/configs/conversion-config.ts +26 -0
  31. package/types/configs/editor-config.d.ts +107 -0
  32. package/types/configs/i18n-config.d.ts +16 -0
  33. package/types/configs/i18n-dictionary.d.ts +93 -0
  34. package/types/configs/index.d.ts +7 -0
  35. package/types/configs/log-levels.d.ts +9 -0
  36. package/types/configs/paste-config.d.ts +38 -0
  37. package/types/configs/sanitizer-config.d.ts +43 -0
  38. package/types/data-formats/block-data.d.ts +23 -0
  39. package/types/data-formats/block-id.ts +4 -0
  40. package/types/data-formats/index.d.ts +2 -0
  41. package/types/data-formats/output-data.d.ts +46 -0
  42. package/types/events/block/Base.ts +11 -0
  43. package/types/events/block/BlockAdded.ts +21 -0
  44. package/types/events/block/BlockChanged.ts +21 -0
  45. package/types/events/block/BlockMoved.ts +26 -0
  46. package/types/events/block/BlockRemoved.ts +21 -0
  47. package/types/events/block/index.ts +44 -0
  48. package/types/index.d.ts +191 -0
  49. package/types/tools/adapters/base-tool-adapter.d.ts +76 -0
  50. package/types/tools/adapters/block-tool-adapter.d.ts +78 -0
  51. package/types/tools/adapters/block-tune-adapter.d.ts +14 -0
  52. package/types/tools/adapters/inline-tool-adapter.d.ts +10 -0
  53. package/types/tools/adapters/tool-factory.d.ts +5 -0
  54. package/types/tools/adapters/tool-type.ts +18 -0
  55. package/types/tools/adapters/tools-collection.d.ts +34 -0
  56. package/types/tools/block-tool-data.d.ts +5 -0
  57. package/types/tools/block-tool.d.ts +121 -0
  58. package/types/tools/hook-events.d.ts +23 -0
  59. package/types/tools/index.d.ts +16 -0
  60. package/types/tools/inline-tool.d.ts +37 -0
  61. package/types/tools/menu-config.d.ts +46 -0
  62. package/types/tools/paste-events.d.ts +52 -0
  63. package/types/tools/tool-config.d.ts +4 -0
  64. package/types/tools/tool-settings.d.ts +79 -0
  65. package/types/tools/tool.d.ts +65 -0
  66. package/types/utils/popover/hint.d.ts +29 -0
  67. package/types/utils/popover/index.d.ts +5 -0
  68. package/types/utils/popover/popover-event.ts +15 -0
  69. package/types/utils/popover/popover-item-type.ts +13 -0
  70. package/types/utils/popover/popover-item.d.ts +253 -0
  71. package/types/utils/popover/popover.d.ts +112 -0
@@ -0,0 +1,191 @@
1
+ /**
2
+ * For export type there should be one entry point,
3
+ * so we export all types from this file
4
+ * ------------------------------------
5
+ */
6
+
7
+ import {
8
+ Dictionary,
9
+ DictValue,
10
+ EditorConfig,
11
+ I18nConfig,
12
+ I18nDictionary,
13
+ } from './configs';
14
+
15
+ import {
16
+ Blocks,
17
+ Caret,
18
+ Events,
19
+ InlineToolbar,
20
+ Listeners,
21
+ Notifier,
22
+ ReadOnly,
23
+ Sanitizer,
24
+ Saver,
25
+ Selection,
26
+ Styles,
27
+ Toolbar,
28
+ Tooltip,
29
+ I18n,
30
+ Ui,
31
+ Tools,
32
+ } from './api';
33
+
34
+ import { OutputData } from './data-formats';
35
+ import { BlockMutationEvent, BlockMutationEventMap, BlockMutationType } from './events/block';
36
+ import { BlockAddedMutationType, BlockAddedEvent } from './events/block/BlockAdded';
37
+ import { BlockChangedMutationType, BlockChangedEvent } from './events/block/BlockChanged';
38
+ import { BlockMovedMutationType, BlockMovedEvent } from './events/block/BlockMoved';
39
+ import { BlockRemovedMutationType, BlockRemovedEvent } from './events/block/BlockRemoved';
40
+
41
+ /**
42
+ * Interfaces used for development
43
+ */
44
+ export {
45
+ BaseTool,
46
+ BaseToolConstructable,
47
+ InlineTool,
48
+ InlineToolConstructable,
49
+ InlineToolConstructorOptions,
50
+ BlockToolConstructable,
51
+ BlockToolConstructorOptions,
52
+ BlockTool,
53
+ BlockToolData,
54
+ Tool,
55
+ ToolConstructable,
56
+ ToolboxConfig,
57
+ ToolboxConfigEntry,
58
+ ToolSettings,
59
+ ToolConfig,
60
+ PasteEvent,
61
+ PasteEventDetail,
62
+ PatternPasteEvent,
63
+ PatternPasteEventDetail,
64
+ HTMLPasteEvent,
65
+ HTMLPasteEventDetail,
66
+ FilePasteEvent,
67
+ FilePasteEventDetail,
68
+ } from './tools';
69
+ export {BlockTune, BlockTuneConstructable} from './block-tunes';
70
+ export {
71
+ EditorConfig,
72
+ SanitizerConfig,
73
+ SanitizerRule,
74
+ PasteConfig,
75
+ LogLevels,
76
+ ConversionConfig,
77
+ I18nDictionary,
78
+ Dictionary,
79
+ DictValue,
80
+ I18nConfig,
81
+ } from './configs';
82
+
83
+ export * from './utils/popover';
84
+
85
+ export { OutputData, OutputBlockData} from './data-formats/output-data';
86
+ export { BlockId } from './data-formats/block-id';
87
+ export { BlockAPI } from './api'
88
+ export {
89
+ BlockMutationType,
90
+ BlockMutationEvent,
91
+ BlockMutationEventMap,
92
+ BlockAddedMutationType,
93
+ BlockAddedEvent,
94
+ BlockRemovedMutationType,
95
+ BlockRemovedEvent,
96
+ BlockMovedMutationType,
97
+ BlockMovedEvent,
98
+ BlockChangedMutationType,
99
+ BlockChangedEvent,
100
+ }
101
+
102
+ /**
103
+ * We have a namespace API {@link ./api/index.d.ts} (APIMethods) but we can not use it as interface
104
+ * So we should create new interface for exporting API type
105
+ */
106
+ export interface API {
107
+ blocks: Blocks;
108
+ caret: Caret;
109
+ tools: Tools;
110
+ events: Events;
111
+ listeners: Listeners;
112
+ notifier: Notifier;
113
+ sanitizer: Sanitizer;
114
+ saver: Saver;
115
+ selection: Selection;
116
+ styles: Styles;
117
+ toolbar: Toolbar;
118
+ inlineToolbar: InlineToolbar;
119
+ tooltip: Tooltip;
120
+ i18n: I18n;
121
+ readOnly: ReadOnly;
122
+ ui: Ui;
123
+ }
124
+
125
+ /**
126
+ * Main Editor class
127
+ */
128
+ declare class EditorJS {
129
+ public static version: string;
130
+
131
+ public isReady: Promise<void>;
132
+
133
+ public blocks: Blocks;
134
+ public caret: Caret;
135
+ public sanitizer: Sanitizer;
136
+ public saver: Saver;
137
+ public selection: Selection;
138
+ public styles: Styles;
139
+ public toolbar: Toolbar;
140
+ public inlineToolbar: InlineToolbar;
141
+ public tooltip: Tooltip;
142
+ public readOnly: ReadOnly;
143
+ constructor(configuration?: EditorConfig|string);
144
+
145
+ /**
146
+ * API shorthands
147
+ */
148
+
149
+ /**
150
+ * @see Saver.save
151
+ */
152
+ public save(): Promise<OutputData>;
153
+
154
+ /**
155
+ * @see Blocks.clear
156
+ */
157
+ public clear(): void;
158
+
159
+ /**
160
+ * @see Blocks.render
161
+ */
162
+ public render(data: OutputData): Promise<void>;
163
+
164
+ /**
165
+ * @see Caret.focus
166
+ */
167
+ public focus(atEnd?: boolean): boolean;
168
+
169
+ /**
170
+ * @see Events.on
171
+ */
172
+ public on(eventName: string, callback: (data?: any) => void): void;
173
+
174
+ /**
175
+ * @see Events.off
176
+ */
177
+ public off(eventName: string, callback: (data?: any) => void): void;
178
+
179
+ /**
180
+ * @see Events.emit
181
+ */
182
+ public emit(eventName: string, data: any): void;
183
+
184
+ /**
185
+ * Destroy Editor instance and related DOM elements
186
+ */
187
+ public destroy(): void;
188
+ }
189
+
190
+ export as namespace EditorJS;
191
+ export default EditorJS;
@@ -0,0 +1,76 @@
1
+ import { Tool, ToolSettings } from '..';
2
+ import type { SanitizerConfig } from '../..';
3
+
4
+ import { ToolType } from './tool-type';
5
+ import { InlineToolAdapter } from './inline-tool-adapter';
6
+ import { BlockToolAdapter } from './block-tool-adapter';
7
+ import { BlockTuneAdapter } from './block-tune-adapter';
8
+
9
+ export interface BaseToolAdapter<Type extends ToolType, ToolClass extends Tool> {
10
+ /**
11
+ * Tool type: Block, Inline or Tune
12
+ */
13
+ type: Type;
14
+
15
+ /**
16
+ * Tool name specified in EditorJS config
17
+ */
18
+ name: string;
19
+
20
+ /**
21
+ * Flag show is current Tool internal (bundled with EditorJS core) or not
22
+ */
23
+ readonly isInternal: boolean;
24
+
25
+ /**
26
+ * Flag show is current Tool default or not
27
+ */
28
+ readonly isDefault: boolean;
29
+
30
+ /**
31
+ * Returns Tool user configuration
32
+ */
33
+ settings: ToolSettings;
34
+
35
+ /**
36
+ * Calls Tool's reset method
37
+ */
38
+ reset(): void | Promise<void>;
39
+
40
+ /**
41
+ * Calls Tool's prepare method
42
+ */
43
+ prepare(): void | Promise<void>;
44
+
45
+ /**
46
+ * Returns shortcut for Tool (internal or specified by user)
47
+ */
48
+ shortcut: string | undefined;
49
+
50
+ /**
51
+ * Returns Tool's sanitizer configuration
52
+ */
53
+ sanitizeConfig: SanitizerConfig;
54
+
55
+ /**
56
+ * Returns true if Tools is inline
57
+ */
58
+ isInline(): this is InlineToolAdapter;
59
+
60
+ /**
61
+ * Returns true if Tools is block
62
+ */
63
+ isBlock(): this is BlockToolAdapter;
64
+
65
+ /**
66
+ * Returns true if Tools is tune
67
+ */
68
+ isTune(): this is BlockTuneAdapter;
69
+
70
+ /**
71
+ * Constructs new Tool instance from constructable blueprint
72
+ *
73
+ * @param args
74
+ */
75
+ create(...args: any[]): ToolClass;
76
+ }
@@ -0,0 +1,78 @@
1
+ import { ToolsCollection } from './tools-collection';
2
+ import { ToolType } from './tool-type';
3
+ import { InlineToolAdapter } from './inline-tool-adapter';
4
+ import { BlockTuneAdapter } from './block-tune-adapter';
5
+ import { BlockTool } from '../block-tool';
6
+ import { BlockToolData } from '../block-tool-data';
7
+ import { BlockAPI } from '../../api/block';
8
+ import { ToolboxConfigEntry } from '../tool-settings';
9
+ import { ConversionConfig } from '../../configs/conversion-config';
10
+ import { PasteConfig } from '../../configs/paste-config';
11
+ import { SanitizerConfig } from '../../configs/sanitizer-config';
12
+ import { BaseToolAdapter } from './base-tool-adapter';
13
+
14
+ interface BlockToolAdapter extends BaseToolAdapter<ToolType.Block, BlockTool>{
15
+ /**
16
+ * InlineTool collection for current Block Tool
17
+ */
18
+ inlineTools: ToolsCollection<InlineToolAdapter>;
19
+
20
+ /**
21
+ * BlockTune collection for current Block Tool
22
+ */
23
+ tunes: ToolsCollection<BlockTuneAdapter>;
24
+
25
+ /**
26
+ * Creates new Tool instance
27
+ * @param data - Tool data
28
+ * @param block - BlockAPI for current Block
29
+ * @param readOnly - True if Editor is in read-only mode
30
+ */
31
+ create(data: BlockToolData, block: BlockAPI, readOnly: boolean): BlockTool;
32
+
33
+ /**
34
+ * Returns true if read-only mode is supported by Tool
35
+ */
36
+ isReadOnlySupported: boolean;
37
+
38
+ /**
39
+ * Returns true if Tool supports linebreaks
40
+ */
41
+ isLineBreaksEnabled: boolean;
42
+
43
+ /**
44
+ * Returns Tool toolbox configuration (internal or user-specified)
45
+ */
46
+ toolbox: ToolboxConfigEntry[] | undefined;
47
+
48
+ /**
49
+ * Returns Tool conversion configuration
50
+ */
51
+ conversionConfig: ConversionConfig | undefined;
52
+
53
+ /**
54
+ * Returns enabled inline tools for Tool
55
+ */
56
+ enabledInlineTools: boolean | string[];
57
+
58
+ /**
59
+ * Returns enabled tunes for Tool
60
+ */
61
+ enabledBlockTunes: boolean | string[] | undefined;
62
+
63
+ /**
64
+ * Returns Tool paste configuration
65
+ */
66
+ pasteConfig: PasteConfig;
67
+
68
+ /**
69
+ * Returns sanitize configuration for Block Tool including configs from related Inline Tools and Block Tunes
70
+ */
71
+ sanitizeConfig: SanitizerConfig;
72
+
73
+ /**
74
+ * Returns sanitizer configuration composed from sanitize config of Inline Tools enabled for Tool
75
+ */
76
+ baseSanitizeConfig: SanitizerConfig;
77
+ }
78
+
@@ -0,0 +1,14 @@
1
+ import { BlockAPI, BlockTune } from '../..';
2
+ import { BlockTuneData } from '../../block-tunes/block-tune-data';
3
+ import { BaseToolAdapter } from './base-tool-adapter';
4
+ import { ToolType } from './tool-type';
5
+
6
+ interface BlockTuneAdapter extends BaseToolAdapter<ToolType.Tune, BlockTune> {
7
+ /**
8
+ * Constructs new BlockTune instance from constructable
9
+ *
10
+ * @param data - Tune data
11
+ * @param block - Block API object
12
+ */
13
+ create(data: BlockTuneData, block: BlockAPI): BlockTune;
14
+ }
@@ -0,0 +1,10 @@
1
+ import { InlineTool as IInlineTool, InlineTool } from '../..';
2
+ import { BaseToolAdapter } from './base-tool-adapter';
3
+ import { ToolType } from './tool-type';
4
+
5
+ interface InlineToolAdapter extends BaseToolAdapter<ToolType.Inline, InlineTool> {
6
+ /**
7
+ * Constructs new InlineTool instance from constructable
8
+ */
9
+ create(): IInlineTool;
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BlockToolAdapter } from './block-tool-adapter';
2
+ import { BlockTuneAdapter } from './block-tune-adapter';
3
+ import { InlineToolAdapter } from './inline-tool-adapter';
4
+
5
+ export type ToolFactory = BlockToolAdapter | InlineToolAdapter | BlockTuneAdapter;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * What kind of plugins developers can create
3
+ */
4
+ export enum ToolType {
5
+ /**
6
+ * Block tool
7
+ */
8
+ Block,
9
+ /**
10
+ * Inline tool
11
+ */
12
+ Inline,
13
+
14
+ /**
15
+ * Block tune
16
+ */
17
+ Tune,
18
+ }
@@ -0,0 +1,34 @@
1
+ import { BlockToolAdapter } from './block-tool-adapter';
2
+ import { BlockTuneAdapter } from './block-tune-adapter';
3
+ import { InlineToolAdapter } from './inline-tool-adapter';
4
+ import { ToolFactory } from './tool-factory';
5
+
6
+ /**
7
+ * Interface for a collection of tools.
8
+ */
9
+ export interface ToolsCollection<V extends ToolFactory = ToolFactory> {
10
+ /**
11
+ * Returns Block Tools collection
12
+ */
13
+ blockTools: ToolsCollection<BlockToolAdapter>;
14
+
15
+ /**
16
+ * Returns Inline Tools collection
17
+ */
18
+ inlineTools: ToolsCollection<InlineToolAdapter>;
19
+
20
+ /**
21
+ * Returns Block Tunes collection
22
+ */
23
+ blockTunes: ToolsCollection<BlockTuneAdapter>;
24
+
25
+ /**
26
+ * Returns internal Tools collection
27
+ */
28
+ internalTools: ToolsCollection<V>;
29
+
30
+ /**
31
+ * Returns Tools collection provided by user
32
+ */
33
+ externalTools: ToolsCollection<V>;
34
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Object returned by Tool's {@link BlockTool#save} method
3
+ * Specified by Tool developer, so leave it as object
4
+ */
5
+ export type BlockToolData<T extends object = any> = T;
@@ -0,0 +1,121 @@
1
+ import { ConversionConfig, PasteConfig, SanitizerConfig } from '../configs';
2
+ import { BlockToolData } from './block-tool-data';
3
+ import { BaseTool, BaseToolConstructable, BaseToolConstructorOptions } from './tool';
4
+ import { ToolConfig } from './tool-config';
5
+ import { API, BlockAPI, ToolboxConfig } from '../index';
6
+ import { PasteEvent } from './paste-events';
7
+ import { MoveEvent } from './hook-events';
8
+ import { MenuConfig } from './menu-config';
9
+
10
+ /**
11
+ * Describe Block Tool object
12
+ * @see {@link docs/tools.md}
13
+ */
14
+ export interface BlockTool extends BaseTool {
15
+ /**
16
+ * Sanitizer rules description
17
+ */
18
+ sanitize?: SanitizerConfig;
19
+
20
+ /**
21
+ * Process Tool's element in DOM and return raw data
22
+ * @param {HTMLElement} block - element created by {@link BlockTool#render} function
23
+ * @return {BlockToolData}
24
+ */
25
+ save(block: HTMLElement): BlockToolData;
26
+
27
+ /**
28
+ * Create Block's settings block
29
+ */
30
+ renderSettings?(): HTMLElement | MenuConfig;
31
+
32
+ /**
33
+ * Validate Block's data
34
+ * @param {BlockToolData} blockData
35
+ * @return {boolean}
36
+ */
37
+ validate?(blockData: BlockToolData): boolean;
38
+
39
+ /**
40
+ * Method that specified how to merge two Blocks with same type.
41
+ * Called by backspace at the beginning of the Block
42
+ * @param {BlockToolData} blockData
43
+ */
44
+ merge?(blockData: BlockToolData): void;
45
+
46
+ /**
47
+ * On paste callback. Fired when pasted content can be substituted by a Tool
48
+ * @param {PasteEvent} event
49
+ */
50
+ onPaste?(event: PasteEvent): void;
51
+
52
+ /**
53
+ * Cleanup resources used by your tool here
54
+ * Called when the editor is destroyed
55
+ */
56
+ destroy?(): void;
57
+
58
+ /**
59
+ * Lifecycle hooks
60
+ */
61
+
62
+ /**
63
+ * Called after block content added to the page
64
+ */
65
+ rendered?(): void;
66
+
67
+ /**
68
+ * Called each time block content is updated
69
+ */
70
+ updated?(): void;
71
+
72
+ /**
73
+ * Called after block removed from the page but before instance is deleted
74
+ */
75
+ removed?(): void;
76
+
77
+ /**
78
+ * Called after block was moved
79
+ */
80
+ moved?(event: MoveEvent): void;
81
+ }
82
+
83
+ /**
84
+ * Describe constructor parameters
85
+ */
86
+ export interface BlockToolConstructorOptions<D extends object = any, C extends object = any> extends BaseToolConstructorOptions<C> {
87
+ data: BlockToolData<D>;
88
+ block: BlockAPI;
89
+ readOnly: boolean;
90
+ }
91
+
92
+ export interface BlockToolConstructable extends BaseToolConstructable {
93
+ /**
94
+ * Tool's Toolbox settings
95
+ */
96
+ toolbox?: ToolboxConfig;
97
+
98
+ /**
99
+ * Paste substitutions configuration
100
+ */
101
+ pasteConfig?: PasteConfig | false;
102
+
103
+ /**
104
+ * Rules that specified how this Tool can be converted into/from another Tool
105
+ */
106
+ conversionConfig?: ConversionConfig;
107
+
108
+ /**
109
+ * Is Tool supports read-only mode, this property should return true
110
+ */
111
+ isReadOnlySupported?: boolean;
112
+
113
+ /**
114
+ * @constructor
115
+ *
116
+ * @param {BlockToolConstructorOptions} config - constructor parameters
117
+ *
118
+ * @return {BlockTool}
119
+ */
120
+ new(config: BlockToolConstructorOptions): BlockTool;
121
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Event detail for block relocation
3
+ */
4
+ export interface MoveEventDetail {
5
+ /**
6
+ * index the block was moved from
7
+ */
8
+ fromIndex: number;
9
+ /**
10
+ * index the block was moved to
11
+ */
12
+ toIndex: number;
13
+ }
14
+
15
+ /**
16
+ * Move event for block relocation
17
+ */
18
+ export interface MoveEvent extends CustomEvent {
19
+ /**
20
+ * Override detail property of CustomEvent by MoveEvent hook
21
+ */
22
+ readonly detail: MoveEventDetail;
23
+ }
@@ -0,0 +1,16 @@
1
+ import { BlockTool, BlockToolConstructable } from './block-tool';
2
+ import { InlineTool, InlineToolConstructable } from './inline-tool';
3
+ import { BlockTune, BlockTuneConstructable } from '../block-tunes';
4
+
5
+ export * from './block-tool';
6
+ export * from './block-tool-data';
7
+ export * from './inline-tool';
8
+ export * from './tool';
9
+ export * from './tool-config';
10
+ export * from './tool-settings';
11
+ export * from './paste-events';
12
+ export * from './hook-events';
13
+ export * from './menu-config';
14
+
15
+ export type Tool = BlockTool | InlineTool | BlockTune;
16
+ export type ToolConstructable = BlockToolConstructable | InlineToolConstructable | BlockTuneConstructable;
@@ -0,0 +1,37 @@
1
+ import {BaseTool, BaseToolConstructable} from './tool';
2
+ import {API, ToolConfig} from '../index';
3
+ import { MenuConfig } from './menu-config';
4
+ /**
5
+ * Base structure for the Inline Toolbar Tool
6
+ */
7
+ export interface InlineTool extends BaseTool<MenuConfig> {
8
+ /**
9
+ * Shortcut for Tool
10
+ * @type {string}
11
+ */
12
+ shortcut?: string;
13
+ }
14
+
15
+
16
+ /**
17
+ * Describe constructor parameters
18
+ */
19
+ export interface InlineToolConstructorOptions {
20
+ api: API;
21
+ config?: ToolConfig;
22
+ }
23
+
24
+ export interface InlineToolConstructable extends BaseToolConstructable {
25
+ /**
26
+ * Constructor
27
+ *
28
+ * @param {InlineToolConstructorOptions} config - constructor parameters
29
+ */
30
+ new(config: InlineToolConstructorOptions): InlineTool;
31
+
32
+ /**
33
+ * Allows inline tool to be available in read-only mode
34
+ * Can be used, for example, by comments tool
35
+ */
36
+ isReadOnlySupported?: boolean;
37
+ }
@@ -0,0 +1,46 @@
1
+ import { PopoverItemDefaultBaseParams, PopoverItemHtmlParams, PopoverItemSeparatorParams, WithChildren } from '../utils/popover';
2
+
3
+ /**
4
+ * Menu configuration format.
5
+ * Is used for defining Block Tunes Menu items via Block Tool's renderSettings(), Block Tune's render() and Inline Tool's render().
6
+ */
7
+ export type MenuConfig = MenuConfigItem | MenuConfigItem[];
8
+
9
+ /**
10
+ * Common parameters for all kinds of default Menu Config items: with or without confirmation
11
+ */
12
+ type MenuConfigDefaultBaseParams = PopoverItemDefaultBaseParams;
13
+
14
+ /**
15
+ * Menu Config item with confirmation
16
+ */
17
+ type MenuConfigItemDefaultWithConfirmationParams = Omit<MenuConfigDefaultBaseParams, 'onActivate'> & {
18
+ /**
19
+ * Items with confirmation should not have onActivate handler
20
+ */
21
+ onActivate?: never;
22
+
23
+ /**
24
+ * Menu Config item parameters that should be applied on item activation.
25
+ * May be used to ask user for confirmation before executing item activation handler.
26
+ */
27
+ confirmation: MenuConfigDefaultBaseParams;
28
+
29
+ }
30
+
31
+ /**
32
+ * Default, non-separator and non-html Menu Config items type
33
+ */
34
+ type MenuConfigItemDefaultParams =
35
+ MenuConfigItemDefaultWithConfirmationParams |
36
+ MenuConfigDefaultBaseParams |
37
+ WithChildren<MenuConfigDefaultBaseParams>;
38
+
39
+ /**
40
+ * Single Menu Config item
41
+ */
42
+ type MenuConfigItem =
43
+ MenuConfigItemDefaultParams |
44
+ PopoverItemSeparatorParams |
45
+ PopoverItemHtmlParams |
46
+ WithChildren<PopoverItemHtmlParams>;