forked from JiHong88/suneditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontracts.js
More file actions
228 lines (203 loc) · 7.1 KB
/
contracts.js
File metadata and controls
228 lines (203 loc) · 7.1 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/**
* @fileoverview Contract interfaces for SunEditor plugins.
* These interfaces define callback methods that modules and editor core call on plugin instances.
* Use `@implements` to get type hints for these hooks in your plugin.
*/
// =====================================================================================================================================================
// Modal Module Hooks
// =====================================================================================================================================================
/**
* Modal plugin hook methods interface.
* `modalAction` is required, other methods are optional.
* @interface
*/
export class ModuleModal {
/**
* @abstract
* This function is called when a form within a modal window is `submit`.
* @returns {Promise<boolean>}
* - `true`: modal and loading are closed
* - `false`: only loading is closed
* - `undefined`: only modal is closed
*/
async modalAction() {
return true;
}
/**
* @optional
* Executes the method that is called when a plugin's modal is opened.
* @param {boolean} isUpdate - Whether the modal is for editing (`true`) or creating a new one (`false`).
* @returns {void}
*/
modalOn(isUpdate) {}
/**
* @optional
* This function is called before the modal window opens or closes.
* @returns {void}
*/
modalInit() {}
/**
* @optional
* Modal off callback.
* @param {boolean} isUpdate - Whether the modal is for editing (`true`) or creating a new one (`false`).
* @returns {void}
*/
modalOff(isUpdate) {}
/**
* @optional
* Modal resize callback (optional).
* @returns {void}
*/
modalResize() {}
}
// =====================================================================================================================================================
// Controller Module Hooks
// =====================================================================================================================================================
/**
* Controller plugin hook methods interface.
* `controllerAction` is required, other methods are optional.
* @interface
*/
export class ModuleController {
/**
* @abstract
* Executes the method that is called when a button is clicked in the `controller`.
* @param {HTMLButtonElement} target Action button element
* @returns {void}
*/
controllerAction(target) {}
/**
* @optional
* This function is called after the `controller` is opened.
* @param {HTMLFormElement} form Controller form element
* @param {Node|Range} target Controller target element
* @returns {void}
*/
controllerOn(form, target) {}
/**
* @optional
* This function is called before the `controller` is closed.
* @returns {void}
*/
controllerClose() {}
}
// =====================================================================================================================================================
// Browser Module Hooks
// =====================================================================================================================================================
/**
* Browser plugin hook methods interface.
* All methods are optional - implement only what you need.
* @interface
*/
export class ModuleBrowser {
/**
* @optional
* Executes the method that is called when a `Browser` module is opened.
* @returns {void}
*/
browserInit() {}
}
// =====================================================================================================================================================
// ColorPicker Module Hooks
// =====================================================================================================================================================
/**
* ColorPicker plugin hook methods interface.
* All methods are optional - implement only what you need.
* @interface
*/
export class ModuleColorPicker {
/**
* @optional
* Executes the method called when a button of `ColorPicker` module is clicked.
* - When applying the `ColorPicker` module globally to the `dropdown` menu,
* - the default `action` method is not called.
* @param {SunEditor.Module.HueSlider.Color} color - Selected color information
* @returns {void}
*/
colorPickerAction(color) {}
/**
* @optional
* Executes the method called when the `HueSlider` module is opened.
* @returns {void}
*/
colorPickerHueSliderOpen() {}
/**
* @optional
* Executes the method called when the `HueSlider` module is closed.
* @returns {void}
*/
colorPickerHueSliderClose() {}
}
// =====================================================================================================================================================
// HueSlider Module Hooks
// =====================================================================================================================================================
/**
* HueSlider plugin hook methods interface.
* All methods are optional - implement only what you need.
* @interface
*/
export class ModuleHueSlider {
/**
* @abstract
* This method is called when the color is selected in the hue slider.
* @returns {void}
*/
hueSliderAction() {}
/**
* @optional
* This method is called when the hue slider is closed.
* @returns {void}
*/
hueSliderCancelAction() {}
}
// =====================================================================================================================================================
// Editor Component Hooks
// =====================================================================================================================================================
/**
* Component plugin hook methods interface.
* `componentSelect` is required, other methods are optional.
*
* **`inst._element` Requirement:**
* Plugins with `static component` method must define a public `_element` property
* that references the currently controlled DOM element.
* - Used to detect clicks on the target element and prevent accidental `controller` closure.
*
* @interface
*/
export class EditorComponent {
/**
* @abstract
* Executes the method that is called when a component of a plugin is selected.
* @param {HTMLElement} target - Target component element
* @returns {void|boolean} - If return `true`, Special components that are not wrapping as `figure`
*/
componentSelect(target) {}
/**
* @optional
* Called when a container is deselected.
* @param {HTMLElement} target - Target element
* @returns {void}
*/
componentDeselect(target) {}
/**
* @optional
* Executes the method that is called when a component is being edited.
* @param {HTMLElement} target - Target element
* @returns {void}
*/
componentEdit(target) {}
/**
* @optional
* Method to delete a component of a plugin, called by the `FileManager`, `Controller` module.
* @param {HTMLElement} target - Target element
* @returns {Promise<void>}
*/
async componentDestroy(target) {}
/**
* @optional
* Executes the method that is called when a component copy is requested.
* @param {SunEditor.HookParams.CopyComponent} params - Copy component event information
* @returns {boolean|void} - If return `false`, the copy will be canceled
*/
componentCopy(params) {}
}