forked from codex-team/editor.js
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathblock-tool.d.ts
More file actions
133 lines (114 loc) · 2.91 KB
/
block-tool.d.ts
File metadata and controls
133 lines (114 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import { ConversionConfig, PasteConfig, SanitizerConfig } from '../configs';
import { BlockToolData } from './block-tool-data';
import {BaseTool, BaseToolConstructable} from './tool';
import { ToolConfig } from './tool-config';
import {API, BlockAPI} from '../index';
import { PasteEvent } from './paste-events';
import { MoveEvent } from './hook-events';
/**
* Describe Block Tool object
* @see {@link docs/tools.md}
*/
export interface BlockTool extends BaseTool {
/**
* Sanitizer rules description
*/
sanitize?: SanitizerConfig;
/**
* Process Tool's element in DOM and return raw data
* @param {HTMLElement} block - element created by {@link BlockTool#render} function
* @return {BlockToolData}
*/
save(block: HTMLElement): BlockToolData;
/**
* Create Block's settings block
* @return {HTMLElement}
*/
renderSettings?(): HTMLElement;
/**
* Validate Block's data
* @param {BlockToolData} blockData
* @return {boolean}
*/
validate?(blockData: BlockToolData): boolean;
/**
* Method that specified how to merge two Blocks with same type.
* Called by backspace at the beginning of the Block
* @param {BlockToolData} blockData
*/
merge?(blockData: BlockToolData): void;
/**
* On paste callback. Fired when pasted content can be substituted by a Tool
* @param {PasteEvent} event
*/
onPaste?(event: PasteEvent): void;
/**
* Cleanup resources used by your tool here
* Called when the editor is destroyed
*/
destroy?(): void;
/**
* Lifecycle hooks
*/
/**
* Called after block content added to the page
*/
rendered?(): void;
/**
* Called each time block content is updated
*/
updated?(): void;
/**
* Called after block removed from the page but before instance is deleted
*/
removed?(): void;
/**
* Called after block was moved
*/
moved?(event: MoveEvent): void;
}
/**
* Describe constructor parameters
*/
export interface BlockToolConstructorOptions<D extends object = any, C extends object = any> {
api: API;
data: BlockToolData<D>;
config?: ToolConfig<C>;
block?: BlockAPI;
readOnly: boolean;
}
export interface BlockToolConstructable extends BaseToolConstructable {
/**
* Tool's Toolbox settings
*/
toolbox?: {
/**
* HTML string with an icon for Toolbox
*/
icon: string;
/**
* Tool title for Toolbox
*/
title?: string;
};
/**
* Paste substitutions configuration
*/
pasteConfig?: PasteConfig | false;
/**
* Rules that specified how this Tool can be converted into/from another Tool
*/
conversionConfig?: ConversionConfig;
/**
* Is Tool supports read-only mode, this property should return true
*/
isReadOnlySupported?: boolean;
/**
* @constructor
*
* @param {BlockToolConstructorOptions} config - constructor parameters
*
* @return {BlockTool}
*/
new(config: BlockToolConstructorOptions): BlockTool;
}