suneditor 3.0.0-beta.2 → 3.0.0-beta.20
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.
- package/CONTRIBUTING.md +186 -184
- package/LICENSE +21 -21
- package/README.md +157 -180
- package/dist/suneditor.min.css +1 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +126 -123
- package/src/assets/design/color.css +131 -121
- package/src/assets/design/index.css +3 -3
- package/src/assets/design/size.css +37 -35
- package/src/assets/design/typography.css +37 -37
- package/src/assets/icons/defaultIcons.js +247 -232
- package/src/assets/suneditor-contents.css +779 -778
- package/src/assets/suneditor.css +43 -35
- package/src/core/base/eventHandlers/handler_toolbar.js +135 -135
- package/src/core/base/eventHandlers/handler_ww_clipboard.js +56 -56
- package/src/core/base/eventHandlers/handler_ww_dragDrop.js +115 -113
- package/src/core/base/eventHandlers/handler_ww_key_input.js +1200 -1200
- package/src/core/base/eventHandlers/handler_ww_mouse.js +194 -194
- package/src/core/base/eventManager.js +1550 -1484
- package/src/core/base/history.js +355 -355
- package/src/core/class/char.js +163 -162
- package/src/core/class/component.js +856 -842
- package/src/core/class/format.js +3433 -3422
- package/src/core/class/html.js +1927 -1890
- package/src/core/class/menu.js +357 -346
- package/src/core/class/nodeTransform.js +424 -424
- package/src/core/class/offset.js +858 -891
- package/src/core/class/selection.js +710 -620
- package/src/core/class/shortcuts.js +98 -98
- package/src/core/class/toolbar.js +438 -430
- package/src/core/class/ui.js +424 -422
- package/src/core/class/viewer.js +750 -750
- package/src/core/editor.js +1810 -1708
- package/src/core/section/actives.js +268 -241
- package/src/core/section/constructor.js +1348 -1661
- package/src/core/section/context.js +102 -102
- package/src/core/section/documentType.js +582 -561
- package/src/core/section/options.js +367 -0
- package/src/core/util/instanceCheck.js +59 -0
- package/src/editorInjector/_classes.js +36 -36
- package/src/editorInjector/_core.js +92 -92
- package/src/editorInjector/index.js +75 -75
- package/src/events.js +634 -622
- package/src/helper/clipboard.js +59 -59
- package/src/helper/converter.js +586 -564
- package/src/helper/dom/domCheck.js +304 -304
- package/src/helper/dom/domQuery.js +677 -669
- package/src/helper/dom/domUtils.js +618 -557
- package/src/helper/dom/index.js +12 -12
- package/src/helper/env.js +249 -240
- package/src/helper/index.js +25 -25
- package/src/helper/keyCodeMap.js +183 -183
- package/src/helper/numbers.js +72 -72
- package/src/helper/unicode.js +47 -47
- package/src/langs/ckb.js +231 -231
- package/src/langs/cs.js +231 -231
- package/src/langs/da.js +231 -231
- package/src/langs/de.js +231 -231
- package/src/langs/en.js +230 -230
- package/src/langs/es.js +231 -231
- package/src/langs/fa.js +231 -231
- package/src/langs/fr.js +231 -231
- package/src/langs/he.js +231 -231
- package/src/langs/hu.js +230 -230
- package/src/langs/index.js +28 -28
- package/src/langs/it.js +231 -231
- package/src/langs/ja.js +230 -230
- package/src/langs/km.js +230 -230
- package/src/langs/ko.js +230 -230
- package/src/langs/lv.js +231 -231
- package/src/langs/nl.js +231 -231
- package/src/langs/pl.js +231 -231
- package/src/langs/pt_br.js +231 -231
- package/src/langs/ro.js +231 -231
- package/src/langs/ru.js +231 -231
- package/src/langs/se.js +231 -231
- package/src/langs/tr.js +231 -231
- package/src/langs/uk.js +231 -231
- package/src/langs/ur.js +231 -231
- package/src/langs/zh_cn.js +231 -231
- package/src/modules/ApiManager.js +191 -191
- package/src/modules/Browser.js +669 -667
- package/src/modules/ColorPicker.js +364 -362
- package/src/modules/Controller.js +474 -454
- package/src/modules/Figure.js +1620 -1617
- package/src/modules/FileManager.js +359 -359
- package/src/modules/HueSlider.js +577 -565
- package/src/modules/Modal.js +346 -346
- package/src/modules/ModalAnchorEditor.js +643 -643
- package/src/modules/SelectMenu.js +549 -549
- package/src/modules/_DragHandle.js +17 -17
- package/src/modules/index.js +14 -14
- package/src/plugins/browser/audioGallery.js +83 -83
- package/src/plugins/browser/fileBrowser.js +103 -103
- package/src/plugins/browser/fileGallery.js +83 -83
- package/src/plugins/browser/imageGallery.js +81 -81
- package/src/plugins/browser/videoGallery.js +103 -103
- package/src/plugins/command/blockquote.js +61 -60
- package/src/plugins/command/exportPDF.js +134 -134
- package/src/plugins/command/fileUpload.js +456 -456
- package/src/plugins/command/list_bulleted.js +149 -148
- package/src/plugins/command/list_numbered.js +152 -151
- package/src/plugins/dropdown/align.js +157 -155
- package/src/plugins/dropdown/backgroundColor.js +108 -104
- package/src/plugins/dropdown/font.js +141 -137
- package/src/plugins/dropdown/fontColor.js +109 -105
- package/src/plugins/dropdown/formatBlock.js +170 -178
- package/src/plugins/dropdown/hr.js +152 -152
- package/src/plugins/dropdown/layout.js +83 -83
- package/src/plugins/dropdown/lineHeight.js +131 -130
- package/src/plugins/dropdown/list.js +123 -122
- package/src/plugins/dropdown/paragraphStyle.js +138 -138
- package/src/plugins/dropdown/table.js +4110 -4000
- package/src/plugins/dropdown/template.js +83 -83
- package/src/plugins/dropdown/textStyle.js +149 -149
- package/src/plugins/field/mention.js +242 -242
- package/src/plugins/index.js +120 -120
- package/src/plugins/input/fontSize.js +414 -410
- package/src/plugins/input/pageNavigator.js +71 -70
- package/src/plugins/modal/audio.js +677 -677
- package/src/plugins/modal/drawing.js +537 -531
- package/src/plugins/modal/embed.js +886 -886
- package/src/plugins/modal/image.js +1377 -1376
- package/src/plugins/modal/link.js +248 -240
- package/src/plugins/modal/math.js +563 -563
- package/src/plugins/modal/video.js +1226 -1226
- package/src/plugins/popup/anchor.js +224 -222
- package/src/suneditor.js +114 -107
- package/src/themes/dark.css +132 -122
- package/src/typedef.js +132 -130
- package/types/assets/icons/defaultIcons.d.ts +8 -0
- package/types/core/base/eventManager.d.ts +29 -4
- package/types/core/class/char.d.ts +2 -1
- package/types/core/class/component.d.ts +1 -2
- package/types/core/class/format.d.ts +8 -1
- package/types/core/class/html.d.ts +8 -0
- package/types/core/class/menu.d.ts +8 -0
- package/types/core/class/offset.d.ts +24 -26
- package/types/core/class/selection.d.ts +2 -0
- package/types/core/class/toolbar.d.ts +6 -0
- package/types/core/class/ui.d.ts +1 -1
- package/types/core/editor.d.ts +34 -12
- package/types/core/section/constructor.d.ts +5 -638
- package/types/core/section/documentType.d.ts +12 -2
- package/types/core/section/options.d.ts +740 -0
- package/types/core/util/instanceCheck.d.ts +50 -0
- package/types/editorInjector/_core.d.ts +5 -5
- package/types/editorInjector/index.d.ts +2 -2
- package/types/events.d.ts +2 -0
- package/types/helper/converter.d.ts +9 -0
- package/types/helper/dom/domQuery.d.ts +5 -5
- package/types/helper/dom/domUtils.d.ts +8 -0
- package/types/helper/env.d.ts +6 -1
- package/types/helper/index.d.ts +4 -1
- package/types/index.d.ts +122 -120
- package/types/langs/_Lang.d.ts +194 -194
- package/types/modules/ColorPicker.d.ts +5 -1
- package/types/modules/Controller.d.ts +8 -4
- package/types/modules/Figure.d.ts +2 -1
- package/types/modules/HueSlider.d.ts +4 -1
- package/types/modules/SelectMenu.d.ts +1 -1
- package/types/plugins/command/blockquote.d.ts +1 -0
- package/types/plugins/command/list_bulleted.d.ts +1 -0
- package/types/plugins/command/list_numbered.d.ts +1 -0
- package/types/plugins/dropdown/align.d.ts +1 -0
- package/types/plugins/dropdown/backgroundColor.d.ts +1 -0
- package/types/plugins/dropdown/font.d.ts +1 -0
- package/types/plugins/dropdown/fontColor.d.ts +1 -0
- package/types/plugins/dropdown/formatBlock.d.ts +3 -2
- package/types/plugins/dropdown/lineHeight.d.ts +1 -0
- package/types/plugins/dropdown/list.d.ts +1 -0
- package/types/plugins/dropdown/table.d.ts +6 -0
- package/types/plugins/input/fontSize.d.ts +1 -0
- package/types/plugins/modal/drawing.d.ts +4 -0
- package/types/plugins/modal/link.d.ts +32 -15
- package/types/suneditor.d.ts +13 -9
- package/types/typedef.d.ts +8 -0
package/src/core/class/ui.js
CHANGED
|
@@ -1,422 +1,424 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview UI class
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import CoreInjector from '../../editorInjector/_core';
|
|
6
|
-
import { dom, converter, keyCodeMap, env } from '../../helper';
|
|
7
|
-
const { _w } = env;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @typedef {Omit<UI & Partial<__se__EditorInjector>, 'ui'>} UIThis
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @constructor
|
|
15
|
-
* @this {UIThis}
|
|
16
|
-
* @description The UI class is a class that handles operations related to the user interface of SunEditor.
|
|
17
|
-
* - This class sets the editor's style, theme, editor mode, etc., and controls the state of various UI elements.
|
|
18
|
-
* @param {__se__EditorCore} editor - The root editor instance
|
|
19
|
-
*/
|
|
20
|
-
function UI(editor) {
|
|
21
|
-
CoreInjector.call(this, editor);
|
|
22
|
-
|
|
23
|
-
// members
|
|
24
|
-
this._controllerOnBtnDisabled = false;
|
|
25
|
-
|
|
26
|
-
// members - modal
|
|
27
|
-
const alertModal = CreateAlertHTML(editor);
|
|
28
|
-
this.alertModal = alertModal;
|
|
29
|
-
this.alertMessage = alertModal.querySelector('span');
|
|
30
|
-
this._alertArea = /** @type {HTMLElement} */ (this.carrierWrapper.querySelector('.se-alert'));
|
|
31
|
-
this._alertInner = /** @type {HTMLElement} */ (this.carrierWrapper.querySelector('.se-alert .se-modal-inner'));
|
|
32
|
-
this._alertInner.appendChild(alertModal);
|
|
33
|
-
|
|
34
|
-
this._closeListener = [CloseListener.bind(this), OnClick_alert.bind(this)];
|
|
35
|
-
this._closeSignal = !this.eventManager.addEvent(alertModal.querySelector('[data-command="close"]'), 'click', this.alertClose.bind(this));
|
|
36
|
-
this._bindClose = null;
|
|
37
|
-
this._backWrapper = /** @type {HTMLElement} */ (this.carrierWrapper.querySelector('.se-back-wrapper'));
|
|
38
|
-
|
|
39
|
-
// members - toast
|
|
40
|
-
const toastPopup = CreateToastHTML();
|
|
41
|
-
this.toastPopup = toastPopup;
|
|
42
|
-
this.toastContainer = toastPopup.querySelector('.se-toast-container');
|
|
43
|
-
this.toastMessage = toastPopup.querySelector('span');
|
|
44
|
-
this.carrierWrapper.appendChild(toastPopup);
|
|
45
|
-
this._toastToggle = null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
UI.prototype = {
|
|
49
|
-
/**
|
|
50
|
-
* @this {UIThis}
|
|
51
|
-
* @description
|
|
52
|
-
* - Define the style of the edit area
|
|
53
|
-
* - It can also be defined with the "setOptions" method, but the "setEditorStyle" method does not render the editor again.
|
|
54
|
-
* @param {string} style Style string
|
|
55
|
-
* @param {__se__FrameContext|null} fc Frame context
|
|
56
|
-
*/
|
|
57
|
-
setEditorStyle(style, fc) {
|
|
58
|
-
fc = fc || this.editor.frameContext;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
code
|
|
70
|
-
code
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
fc.get('wysiwygFrame').style.cssText = newStyles.frame;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
* @
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
o
|
|
91
|
-
o.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
* @
|
|
114
|
-
* @
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
fc.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (this.
|
|
129
|
-
if (this.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
fc.get('
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
* @
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.
|
|
152
|
-
|
|
153
|
-
this.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
* @
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this.
|
|
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
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
* @
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
* @
|
|
262
|
-
* @
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (
|
|
271
|
-
|
|
272
|
-
this.
|
|
273
|
-
|
|
274
|
-
this.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
* @
|
|
294
|
-
* @param {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
this.toastPopup
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
this.
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
* @
|
|
328
|
-
* @
|
|
329
|
-
* @
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
* @
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
* @
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
this.editor.
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
* @
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
* @
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
*
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview UI class
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import CoreInjector from '../../editorInjector/_core';
|
|
6
|
+
import { dom, converter, keyCodeMap, env } from '../../helper';
|
|
7
|
+
const { _w } = env;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Omit<UI & Partial<__se__EditorInjector>, 'ui'>} UIThis
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @constructor
|
|
15
|
+
* @this {UIThis}
|
|
16
|
+
* @description The UI class is a class that handles operations related to the user interface of SunEditor.
|
|
17
|
+
* - This class sets the editor's style, theme, editor mode, etc., and controls the state of various UI elements.
|
|
18
|
+
* @param {__se__EditorCore} editor - The root editor instance
|
|
19
|
+
*/
|
|
20
|
+
function UI(editor) {
|
|
21
|
+
CoreInjector.call(this, editor);
|
|
22
|
+
|
|
23
|
+
// members
|
|
24
|
+
this._controllerOnBtnDisabled = false;
|
|
25
|
+
|
|
26
|
+
// members - modal
|
|
27
|
+
const alertModal = CreateAlertHTML(editor);
|
|
28
|
+
this.alertModal = alertModal;
|
|
29
|
+
this.alertMessage = alertModal.querySelector('span');
|
|
30
|
+
this._alertArea = /** @type {HTMLElement} */ (this.carrierWrapper.querySelector('.se-alert'));
|
|
31
|
+
this._alertInner = /** @type {HTMLElement} */ (this.carrierWrapper.querySelector('.se-alert .se-modal-inner'));
|
|
32
|
+
this._alertInner.appendChild(alertModal);
|
|
33
|
+
|
|
34
|
+
this._closeListener = [CloseListener.bind(this), OnClick_alert.bind(this)];
|
|
35
|
+
this._closeSignal = !this.eventManager.addEvent(alertModal.querySelector('[data-command="close"]'), 'click', this.alertClose.bind(this));
|
|
36
|
+
this._bindClose = null;
|
|
37
|
+
this._backWrapper = /** @type {HTMLElement} */ (this.carrierWrapper.querySelector('.se-back-wrapper'));
|
|
38
|
+
|
|
39
|
+
// members - toast
|
|
40
|
+
const toastPopup = CreateToastHTML();
|
|
41
|
+
this.toastPopup = toastPopup;
|
|
42
|
+
this.toastContainer = toastPopup.querySelector('.se-toast-container');
|
|
43
|
+
this.toastMessage = toastPopup.querySelector('span');
|
|
44
|
+
this.carrierWrapper.appendChild(toastPopup);
|
|
45
|
+
this._toastToggle = null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
UI.prototype = {
|
|
49
|
+
/**
|
|
50
|
+
* @this {UIThis}
|
|
51
|
+
* @description set editor frame styles.
|
|
52
|
+
* - Define the style of the edit area
|
|
53
|
+
* - It can also be defined with the "setOptions" method, but the "setEditorStyle" method does not render the editor again.
|
|
54
|
+
* @param {string} style Style string
|
|
55
|
+
* @param {__se__FrameContext|null} fc Frame context
|
|
56
|
+
*/
|
|
57
|
+
setEditorStyle(style, fc) {
|
|
58
|
+
fc = fc || this.editor.frameContext;
|
|
59
|
+
|
|
60
|
+
const fo = fc.get('options');
|
|
61
|
+
fo.set('editorStyle', style);
|
|
62
|
+
|
|
63
|
+
const newStyles = converter._setDefaultOptionStyle(fo, style);
|
|
64
|
+
fo.set('_defaultStyles', newStyles);
|
|
65
|
+
|
|
66
|
+
// top area
|
|
67
|
+
fc.get('topArea').style.cssText = newStyles.top;
|
|
68
|
+
|
|
69
|
+
// code view
|
|
70
|
+
const code = fc.get('code');
|
|
71
|
+
code.style.cssText = fo.get('_defaultStyles').frame;
|
|
72
|
+
code.style.display = 'none';
|
|
73
|
+
|
|
74
|
+
// wysiwyg frame
|
|
75
|
+
if (!fo.get('iframe')) {
|
|
76
|
+
fc.get('wysiwygFrame').style.cssText = newStyles.frame + newStyles.editor;
|
|
77
|
+
} else {
|
|
78
|
+
fc.get('wysiwygFrame').style.cssText = newStyles.frame;
|
|
79
|
+
fc.get('wysiwyg').style.cssText = newStyles.editor;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @this {UIThis}
|
|
85
|
+
* @description Set the theme to the editor
|
|
86
|
+
* @param {string} theme Theme name
|
|
87
|
+
*/
|
|
88
|
+
setTheme(theme) {
|
|
89
|
+
if (typeof theme !== 'string') return;
|
|
90
|
+
const o = this.options;
|
|
91
|
+
const prevTheme = o.get('_themeClass').trim();
|
|
92
|
+
o.set('theme', theme || '');
|
|
93
|
+
o.set('_themeClass', theme ? ` se-theme-${theme}` : '');
|
|
94
|
+
theme = o.get('_themeClass').trim();
|
|
95
|
+
|
|
96
|
+
const applyTheme = (target) => {
|
|
97
|
+
if (!target) return;
|
|
98
|
+
if (prevTheme) dom.utils.removeClass(target, prevTheme);
|
|
99
|
+
if (theme) dom.utils.addClass(target, theme);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
applyTheme(this.carrierWrapper);
|
|
103
|
+
this.editor.applyFrameRoots((e) => {
|
|
104
|
+
applyTheme(e.get('topArea'));
|
|
105
|
+
applyTheme(e.get('wysiwyg'));
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
applyTheme(this.context.get('statusbar._wrapper'));
|
|
109
|
+
applyTheme(this.context.get('toolbar._wrapper'));
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @this {UIThis}
|
|
114
|
+
* @description Switch to or off "ReadOnly" mode.
|
|
115
|
+
* @param {boolean} value "readOnly" boolean value.
|
|
116
|
+
* @param {string|undefined} rootKey Root key
|
|
117
|
+
*/
|
|
118
|
+
readOnly(value, rootKey) {
|
|
119
|
+
const fc = rootKey ? this.frameRoots.get(rootKey) : this.editor.frameContext;
|
|
120
|
+
|
|
121
|
+
fc.set('isReadOnly', !!value);
|
|
122
|
+
dom.utils.setDisabled(this.editor._controllerOnDisabledButtons, !!value);
|
|
123
|
+
|
|
124
|
+
if (value) {
|
|
125
|
+
this._offCurrentController();
|
|
126
|
+
this._offCurrentModal();
|
|
127
|
+
|
|
128
|
+
if (this.toolbar?.currentMoreLayerActiveButton?.disabled) this.toolbar._moreLayerOff();
|
|
129
|
+
if (this.subToolbar?.currentMoreLayerActiveButton?.disabled) this.subToolbar._moreLayerOff();
|
|
130
|
+
if (this.menu?.currentDropdownActiveButton?.disabled) this.menu.dropdownOff();
|
|
131
|
+
if (this.menu?.currentContainerActiveButton?.disabled) this.menu.containerOff();
|
|
132
|
+
|
|
133
|
+
fc.get('code').setAttribute('readOnly', 'true');
|
|
134
|
+
dom.utils.addClass(fc.get('wysiwyg'), 'se-read-only');
|
|
135
|
+
} else {
|
|
136
|
+
fc.get('code').removeAttribute('readOnly');
|
|
137
|
+
dom.utils.removeClass(fc.get('wysiwyg'), 'se-read-only');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (this.options.get('hasCodeMirror')) {
|
|
141
|
+
this.viewer._codeMirrorEditor('readonly', !!value, rootKey);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @this {UIThis}
|
|
147
|
+
* @description Disable the suneditor
|
|
148
|
+
* @param {string|undefined} rootKey Root key
|
|
149
|
+
*/
|
|
150
|
+
disable(rootKey) {
|
|
151
|
+
const fc = rootKey ? this.frameRoots.get(rootKey) : this.editor.frameContext;
|
|
152
|
+
|
|
153
|
+
this.toolbar.disable();
|
|
154
|
+
this._offCurrentController();
|
|
155
|
+
this._offCurrentModal();
|
|
156
|
+
|
|
157
|
+
fc.get('wysiwyg').setAttribute('contenteditable', false);
|
|
158
|
+
fc.set('isDisabled', true);
|
|
159
|
+
|
|
160
|
+
if (this.options.get('hasCodeMirror')) {
|
|
161
|
+
this.viewer._codeMirrorEditor('readonly', true, rootKey);
|
|
162
|
+
} else {
|
|
163
|
+
fc.get('code').disabled = true;
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @this {UIThis}
|
|
169
|
+
* @description Enable the suneditor
|
|
170
|
+
* @param {string|undefined} rootKey Root key
|
|
171
|
+
*/
|
|
172
|
+
enable(rootKey) {
|
|
173
|
+
const fc = rootKey ? this.frameRoots.get(rootKey) : this.editor.frameContext;
|
|
174
|
+
|
|
175
|
+
this.toolbar.enable();
|
|
176
|
+
fc.get('wysiwyg').setAttribute('contenteditable', true);
|
|
177
|
+
fc.set('isDisabled', false);
|
|
178
|
+
|
|
179
|
+
if (this.options.get('hasCodeMirror')) {
|
|
180
|
+
this.viewer._codeMirrorEditor('readonly', false, rootKey);
|
|
181
|
+
} else {
|
|
182
|
+
fc.get('code').disabled = false;
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @this {UIThis}
|
|
188
|
+
* @description Show the suneditor
|
|
189
|
+
* @param {string|undefined} rootKey Root key
|
|
190
|
+
*/
|
|
191
|
+
show(rootKey) {
|
|
192
|
+
const fc = rootKey ? this.frameRoots.get(rootKey) : this.editor.frameContext;
|
|
193
|
+
const topAreaStyle = fc.get('topArea').style;
|
|
194
|
+
if (topAreaStyle.display === 'none') topAreaStyle.display = 'block';
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @this {UIThis}
|
|
199
|
+
* @description Hide the suneditor
|
|
200
|
+
* @param {string|undefined} rootKey Root key
|
|
201
|
+
*/
|
|
202
|
+
hide(rootKey) {
|
|
203
|
+
const fc = rootKey ? this.frameRoots.get(rootKey) : this.editor.frameContext;
|
|
204
|
+
fc.get('topArea').style.display = 'none';
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* @this {UIThis}
|
|
209
|
+
* @description Show loading box
|
|
210
|
+
* @param {string=} rootKey Root key
|
|
211
|
+
*/
|
|
212
|
+
showLoading(rootKey) {
|
|
213
|
+
(rootKey ? this.frameRoots.get(rootKey).get('container') : this.carrierWrapper).querySelector('.se-loading-box').style.display = 'block';
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @this {UIThis}
|
|
218
|
+
* @description Hide loading box
|
|
219
|
+
* @param {string=} rootKey Root key
|
|
220
|
+
*/
|
|
221
|
+
hideLoading(rootKey) {
|
|
222
|
+
(rootKey ? this.frameRoots.get(rootKey).get('container') : this.carrierWrapper).querySelector('.se-loading-box').style.display = 'none';
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @this {UIThis}
|
|
227
|
+
* @description This method disables or enables the toolbar buttons when the controller is activated or deactivated.
|
|
228
|
+
* - When the controller is activated, the toolbar buttons are disabled; when the controller is deactivated, the buttons are enabled.
|
|
229
|
+
* @param {boolean} active If `true`, the toolbar buttons will be disabled. If `false`, the toolbar buttons will be enabled.
|
|
230
|
+
*/
|
|
231
|
+
setControllerOnDisabledButtons(active) {
|
|
232
|
+
if (active && !this._controllerOnBtnDisabled) {
|
|
233
|
+
dom.utils.setDisabled(this.editor._controllerOnDisabledButtons, true);
|
|
234
|
+
this._controllerOnBtnDisabled = true;
|
|
235
|
+
} else if (!active && this._controllerOnBtnDisabled) {
|
|
236
|
+
dom.utils.setDisabled(this.editor._controllerOnDisabledButtons, false);
|
|
237
|
+
this._controllerOnBtnDisabled = false;
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* @this {UIThis}
|
|
243
|
+
* @description Activate the transparent background "div" so that other elements are not affected during resizing.
|
|
244
|
+
* @param {string} cursor cursor css property
|
|
245
|
+
*/
|
|
246
|
+
enableBackWrapper(cursor) {
|
|
247
|
+
this._backWrapper.style.cursor = cursor;
|
|
248
|
+
this._backWrapper.style.display = 'block';
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* @this {UIThis}
|
|
253
|
+
* @description Disabled background "div"
|
|
254
|
+
*/
|
|
255
|
+
disableBackWrapper() {
|
|
256
|
+
this._backWrapper.style.display = 'none';
|
|
257
|
+
this._backWrapper.style.cursor = 'default';
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @this {UIThis}
|
|
262
|
+
* @description Open the alert panel
|
|
263
|
+
* @param {string} text alert message
|
|
264
|
+
* @param {""|"error"|"success"} type alert type
|
|
265
|
+
*/
|
|
266
|
+
alertOpen(text, type) {
|
|
267
|
+
this.alertMessage.textContent = text;
|
|
268
|
+
|
|
269
|
+
dom.utils.removeClass(this.alertModal, 'se-alert-error|se-alert-success');
|
|
270
|
+
if (type) dom.utils.addClass(this.alertModal, `se-alert-${type}`);
|
|
271
|
+
|
|
272
|
+
if (this._closeSignal) this._alertInner.addEventListener('click', this._closeListener[1]);
|
|
273
|
+
if (this._bindClose) this._bindClose = this.eventManager.removeGlobalEvent(this._bindClose);
|
|
274
|
+
this._bindClose = this.eventManager.addGlobalEvent('keydown', this._closeListener[0]);
|
|
275
|
+
|
|
276
|
+
this._alertArea.style.display = 'block';
|
|
277
|
+
dom.utils.addClass(this.alertModal, 'se-modal-show');
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* @this {UIThis}
|
|
282
|
+
* @description Close the alert panel
|
|
283
|
+
*/
|
|
284
|
+
alertClose() {
|
|
285
|
+
dom.utils.removeClass(this.alertModal, 'se-modal-show');
|
|
286
|
+
dom.utils.removeClass(this.alertModal, 'se-alert-*');
|
|
287
|
+
this._alertArea.style.display = 'none';
|
|
288
|
+
if (this._closeSignal) this._alertInner.removeEventListener('click', this._closeListener[1]);
|
|
289
|
+
if (this._bindClose) this._bindClose = this.eventManager.removeGlobalEvent(this._bindClose);
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* @description Show toast
|
|
294
|
+
* @param {string} message toast message
|
|
295
|
+
* @param {number} [duration=1000] duration time(ms)
|
|
296
|
+
* @param {""|"error"|"success"} [type=""] duration time(ms)
|
|
297
|
+
*/
|
|
298
|
+
showToast(message, duration = 1000, type) {
|
|
299
|
+
if (dom.utils.hasClass(this.toastContainer, 'se-toast-show')) {
|
|
300
|
+
this.closeToast();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
dom.utils.removeClass(this.toastPopup, 'se-toast-error|se-toast-success');
|
|
304
|
+
if (type) dom.utils.addClass(this.toastPopup, `se-toast-${type}`);
|
|
305
|
+
|
|
306
|
+
this.toastPopup.style.display = 'block';
|
|
307
|
+
this.toastMessage.textContent = message;
|
|
308
|
+
dom.utils.addClass(this.toastContainer, 'se-toast-show');
|
|
309
|
+
|
|
310
|
+
// remove after animation
|
|
311
|
+
this._toastToggle = _w.setTimeout(() => {
|
|
312
|
+
this.closeToast();
|
|
313
|
+
}, duration);
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* @description Close toast
|
|
318
|
+
*/
|
|
319
|
+
closeToast() {
|
|
320
|
+
if (this._toastToggle) _w.clearTimeout(this._toastToggle);
|
|
321
|
+
this._toastToggle = null;
|
|
322
|
+
dom.utils.removeClass(this.toastContainer, 'se-toast-show');
|
|
323
|
+
this.toastPopup.style.display = 'none';
|
|
324
|
+
},
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* @private
|
|
328
|
+
* @this {UIThis}
|
|
329
|
+
* @description visible controllers
|
|
330
|
+
* @param {boolean} value hidden/show
|
|
331
|
+
* @param {?boolean=} lineBreakShow Line break hidden/show (default: Follows the value "value".)
|
|
332
|
+
*/
|
|
333
|
+
_visibleControllers(value, lineBreakShow) {
|
|
334
|
+
const visible = value ? '' : 'hidden';
|
|
335
|
+
const breakerVisible = lineBreakShow ?? visible ? '' : 'hidden';
|
|
336
|
+
|
|
337
|
+
const cont = this.editor.opendControllers;
|
|
338
|
+
for (let i = 0, c; i < cont.length; i++) {
|
|
339
|
+
c = cont[i];
|
|
340
|
+
if (c.form) c.form.style.visibility = visible;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
this.editor._lineBreaker_t.style.visibility = breakerVisible;
|
|
344
|
+
this.editor._lineBreaker_b.style.visibility = breakerVisible;
|
|
345
|
+
},
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* @private
|
|
349
|
+
* @this {UIThis}
|
|
350
|
+
* @description Off current controllers
|
|
351
|
+
*/
|
|
352
|
+
_offCurrentController() {
|
|
353
|
+
this.component.__deselect();
|
|
354
|
+
},
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* @private
|
|
358
|
+
* @this {UIThis}
|
|
359
|
+
* @description Off controllers
|
|
360
|
+
*/
|
|
361
|
+
__offControllers() {
|
|
362
|
+
const cont = this.editor.opendControllers;
|
|
363
|
+
const fixedCont = [];
|
|
364
|
+
for (let i = 0, c; i < cont.length; i++) {
|
|
365
|
+
c = cont[i];
|
|
366
|
+
if (c.fixed) {
|
|
367
|
+
fixedCont.push(c);
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
if (typeof c.inst.close === 'function') c.inst.close();
|
|
371
|
+
if (c.form) c.form.style.display = 'none';
|
|
372
|
+
}
|
|
373
|
+
this.editor.opendControllers = fixedCont;
|
|
374
|
+
this.editor.currentControllerName = '';
|
|
375
|
+
this.editor._preventBlur = false;
|
|
376
|
+
},
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* @private
|
|
380
|
+
* @this {UIThis}
|
|
381
|
+
* @description Off current modal
|
|
382
|
+
*/
|
|
383
|
+
_offCurrentModal() {
|
|
384
|
+
if (this.editor.opendModal) {
|
|
385
|
+
this.editor.opendModal.close();
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
constructor: UI
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* @private
|
|
394
|
+
* @this {UIThis}
|
|
395
|
+
* @param {MouseEvent} e - Event object
|
|
396
|
+
*/
|
|
397
|
+
function OnClick_alert(e) {
|
|
398
|
+
const eventTarget = dom.query.getEventTarget(e);
|
|
399
|
+
if (/close/.test(eventTarget.getAttribute('data-command')) || eventTarget === this._alertInner) {
|
|
400
|
+
this.alertClose();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* @private
|
|
406
|
+
* @this {UIThis}
|
|
407
|
+
* @param {KeyboardEvent} e - Event object
|
|
408
|
+
*/
|
|
409
|
+
function CloseListener(e) {
|
|
410
|
+
if (!keyCodeMap.isEsc(e.code)) return;
|
|
411
|
+
this.alertClose();
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function CreateAlertHTML({ lang, icons }) {
|
|
415
|
+
const html = '<div><button class="close" data-command="close" title="' + lang.close + '">' + icons.cancel + '</button></div><div><span></span></div>';
|
|
416
|
+
return dom.utils.createElement('DIV', { class: 'se-alert-content' }, html);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function CreateToastHTML() {
|
|
420
|
+
const html = '<div class="se-toast-container"><span></span></div>';
|
|
421
|
+
return dom.utils.createElement('DIV', { class: 'se-toast' }, html);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export default UI;
|