suneditor 2.44.2 → 2.44.4

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 (131) hide show
  1. package/LICENSE.txt +20 -20
  2. package/README.md +1585 -1585
  3. package/dist/css/suneditor.min.css +1 -1
  4. package/dist/suneditor.min.js +2 -2
  5. package/package.json +71 -71
  6. package/src/assets/css/suneditor-contents.css +556 -556
  7. package/src/assets/css/suneditor.css +0 -0
  8. package/src/assets/defaultIcons.js +103 -103
  9. package/src/lang/Lang.d.ts +143 -143
  10. package/src/lang/ckb.d.ts +4 -4
  11. package/src/lang/ckb.js +187 -187
  12. package/src/lang/da.d.ts +4 -4
  13. package/src/lang/da.js +191 -191
  14. package/src/lang/de.d.ts +4 -4
  15. package/src/lang/de.js +187 -187
  16. package/src/lang/en.d.ts +4 -4
  17. package/src/lang/en.js +187 -187
  18. package/src/lang/es.d.ts +4 -4
  19. package/src/lang/es.js +187 -187
  20. package/src/lang/fr.d.ts +4 -4
  21. package/src/lang/fr.js +188 -188
  22. package/src/lang/he.d.ts +4 -4
  23. package/src/lang/he.js +188 -188
  24. package/src/lang/index.d.ts +22 -21
  25. package/src/lang/index.js +25 -24
  26. package/src/lang/it.d.ts +4 -4
  27. package/src/lang/it.js +188 -188
  28. package/src/lang/ja.d.ts +4 -4
  29. package/src/lang/ja.js +187 -187
  30. package/src/lang/ko.d.ts +4 -4
  31. package/src/lang/ko.js +187 -187
  32. package/src/lang/lv.d.ts +4 -4
  33. package/src/lang/lv.js +187 -187
  34. package/src/lang/nl.d.ts +4 -4
  35. package/src/lang/nl.js +187 -187
  36. package/src/lang/pl.d.ts +4 -4
  37. package/src/lang/pl.js +187 -187
  38. package/src/lang/pt_br.d.ts +4 -4
  39. package/src/lang/pt_br.js +189 -189
  40. package/src/lang/ro.d.ts +4 -4
  41. package/src/lang/ro.js +187 -187
  42. package/src/lang/ru.d.ts +4 -4
  43. package/src/lang/ru.js +187 -187
  44. package/src/lang/se.d.ts +4 -4
  45. package/src/lang/se.js +191 -191
  46. package/src/lang/ua.d.ts +5 -5
  47. package/src/lang/ua.js +188 -188
  48. package/src/lang/ur.d.ts +5 -0
  49. package/src/lang/ur.js +188 -0
  50. package/src/lang/zh_cn.d.ts +4 -4
  51. package/src/lang/zh_cn.js +187 -187
  52. package/src/lib/constructor.js +1 -2
  53. package/src/lib/context.d.ts +42 -42
  54. package/src/lib/context.js +0 -0
  55. package/src/lib/core.d.ts +1101 -1101
  56. package/src/lib/core.js +220 -99
  57. package/src/lib/history.d.ts +48 -48
  58. package/src/lib/history.js +218 -218
  59. package/src/lib/util.d.ts +677 -677
  60. package/src/lib/util.js +38 -12
  61. package/src/options.d.ts +608 -608
  62. package/src/plugins/CommandPlugin.d.ts +7 -7
  63. package/src/plugins/DialogPlugin.d.ts +19 -19
  64. package/src/plugins/FileBrowserPlugin.d.ts +29 -29
  65. package/src/plugins/Module.d.ts +14 -14
  66. package/src/plugins/Plugin.d.ts +41 -41
  67. package/src/plugins/SubmenuPlugin.d.ts +7 -7
  68. package/src/plugins/command/blockquote.d.ts +4 -4
  69. package/src/plugins/command/blockquote.js +46 -46
  70. package/src/plugins/dialog/audio.d.ts +4 -4
  71. package/src/plugins/dialog/audio.js +556 -554
  72. package/src/plugins/dialog/image.d.ts +4 -4
  73. package/src/plugins/dialog/image.js +1122 -1107
  74. package/src/plugins/dialog/link.d.ts +4 -4
  75. package/src/plugins/dialog/link.js +223 -223
  76. package/src/plugins/dialog/math.d.ts +4 -4
  77. package/src/plugins/dialog/math.js +294 -294
  78. package/src/plugins/dialog/mention.d.ts +5 -5
  79. package/src/plugins/dialog/mention.js +242 -242
  80. package/src/plugins/dialog/video.d.ts +4 -4
  81. package/src/plugins/dialog/video.js +983 -981
  82. package/src/plugins/fileBrowser/imageGallery.d.ts +4 -4
  83. package/src/plugins/fileBrowser/imageGallery.js +63 -63
  84. package/src/plugins/index.d.ts +79 -79
  85. package/src/plugins/index.js +32 -32
  86. package/src/plugins/modules/_anchor.js +461 -462
  87. package/src/plugins/modules/_colorPicker.d.ts +59 -59
  88. package/src/plugins/modules/_colorPicker.js +0 -0
  89. package/src/plugins/modules/_notice.d.ts +20 -20
  90. package/src/plugins/modules/_notice.js +72 -72
  91. package/src/plugins/modules/_selectMenu.js +118 -118
  92. package/src/plugins/modules/component.d.ts +24 -24
  93. package/src/plugins/modules/component.js +82 -82
  94. package/src/plugins/modules/dialog.d.ts +27 -27
  95. package/src/plugins/modules/dialog.js +174 -174
  96. package/src/plugins/modules/fileBrowser.d.ts +41 -41
  97. package/src/plugins/modules/fileBrowser.js +373 -373
  98. package/src/plugins/modules/fileManager.d.ts +66 -66
  99. package/src/plugins/modules/fileManager.js +325 -324
  100. package/src/plugins/modules/index.d.ts +10 -10
  101. package/src/plugins/modules/index.js +8 -8
  102. package/src/plugins/modules/resizing.d.ts +153 -153
  103. package/src/plugins/modules/resizing.js +895 -895
  104. package/src/plugins/submenu/align.d.ts +4 -4
  105. package/src/plugins/submenu/align.js +160 -160
  106. package/src/plugins/submenu/font.d.ts +4 -4
  107. package/src/plugins/submenu/font.js +120 -120
  108. package/src/plugins/submenu/fontColor.d.ts +4 -4
  109. package/src/plugins/submenu/fontColor.js +0 -0
  110. package/src/plugins/submenu/fontSize.d.ts +4 -4
  111. package/src/plugins/submenu/fontSize.js +112 -112
  112. package/src/plugins/submenu/formatBlock.d.ts +4 -4
  113. package/src/plugins/submenu/formatBlock.js +273 -273
  114. package/src/plugins/submenu/hiliteColor.d.ts +4 -4
  115. package/src/plugins/submenu/hiliteColor.js +0 -0
  116. package/src/plugins/submenu/horizontalRule.d.ts +4 -4
  117. package/src/plugins/submenu/horizontalRule.js +98 -98
  118. package/src/plugins/submenu/lineHeight.d.ts +4 -4
  119. package/src/plugins/submenu/lineHeight.js +104 -104
  120. package/src/plugins/submenu/list.d.ts +4 -4
  121. package/src/plugins/submenu/list.js +456 -455
  122. package/src/plugins/submenu/paragraphStyle.d.ts +4 -4
  123. package/src/plugins/submenu/paragraphStyle.js +135 -135
  124. package/src/plugins/submenu/table.d.ts +4 -4
  125. package/src/plugins/submenu/template.d.ts +4 -4
  126. package/src/plugins/submenu/template.js +71 -71
  127. package/src/plugins/submenu/textStyle.d.ts +4 -4
  128. package/src/plugins/submenu/textStyle.js +167 -167
  129. package/src/suneditor.d.ts +9 -9
  130. package/src/suneditor.js +75 -75
  131. package/src/suneditor_build.js +17 -17
package/src/lib/core.d.ts CHANGED
@@ -1,1102 +1,1102 @@
1
- import { History } from './history.d';
2
- import { Plugin } from './../plugins/Plugin.d';
3
- import { Lang } from './../lang/Lang.d';
4
- import { SunEditorOptions } from './../options.d';
5
- import { Context } from './context';
6
- import Util from './util';
7
- import { Module } from '../plugins/Module';
8
- import _Notice from '../plugins/modules/_notice';
9
-
10
- type Controllers = Array<string | Function | Element>;
11
- type fileInfo = {
12
- index: number;
13
- name: string;
14
- size: string | number;
15
- select: Function;
16
- delete: Function;
17
- element: Element;
18
- src: string;
19
- };
20
- type seledtedFileInfo = {target: Element; component: Element; pluginName: string;};
21
- type commands = 'selectAll' | 'codeView' | 'fullScreen' | 'indent' | 'outdent' | 'undo' | 'redo' | 'removeFormat' | 'print' | 'preview' | 'showBlocks' | 'save' | 'bold' | 'underline' | 'italic' | 'strike' | 'subscript' | 'superscript' | 'copy' | 'cut' | 'paste';
22
- ​​
23
- interface Core {
24
- /**
25
- * @description Util object
26
- */
27
- util: Util;
28
-
29
- /**
30
- * @description Functions object
31
- */
32
- functions: SunEditor;
33
-
34
- /**
35
- * @description Editor options
36
- */
37
- options: SunEditorOptions;
38
-
39
- /**
40
- * @description Computed style of the wysiwyg area (window.getComputedStyle(context.element.wysiwyg))
41
- */
42
- wwComputedStyle: any;
43
-
44
- /**
45
- * @description Notice object
46
- */
47
- notice: _Notice;
48
-
49
- /**
50
- * @description Default icons object
51
- */
52
- icons: Record<string, string>;
53
-
54
- /**
55
- * @description History object for undo, redo
56
- */
57
- history: History;
58
-
59
- /**
60
- * @description Elements and user options parameters of the suneditor
61
- */
62
- context: Context;
63
-
64
- /**
65
- * @description Plugin buttons
66
- */
67
- pluginCallButtons: Record<string, Element>;
68
-
69
- /**
70
- * @description Loaded plugins
71
- */
72
- plugins: Record<string, Plugin>;
73
-
74
- /**
75
- * @description Whether the plugin is initialized
76
- */
77
- initPlugins: Record<string, boolean>;
78
-
79
- /**
80
- * @description loaded language
81
- */
82
- lang: Lang;
83
-
84
- /**
85
- * @description The selection node (core.getSelectionNode()) to which the effect was last applied
86
- */
87
- effectNode: Node;
88
-
89
- /**
90
- * @description submenu element
91
- */
92
- submenu: Element;
93
-
94
- /**
95
- * @description container element
96
- */
97
- container: Element;
98
-
99
- /**
100
- * @description active button element in submenu
101
- */
102
- submenuActiveButton: Element;
103
-
104
- /**
105
- * @description active button element in container
106
- */
107
- containerActiveButton: Element;
108
-
109
- /**
110
- * @description The elements array to be processed unvisible when the controllersOff function is executed (resizing, link modified button, table controller)
111
- */
112
- controllerArray: Controllers;
113
-
114
- /**
115
- * @description The name of the plugin that called the currently active controller
116
- */
117
- currentControllerName: string;
118
-
119
- /**
120
- * @description The target element of current controller
121
- */
122
- currentControllerTarget: Element;
123
-
124
- /**
125
- * @description The file component object of current selected file tag (getFileComponent(): {target, component, pluginName})
126
- */
127
- currentFileComponentInfo: seledtedFileInfo;
128
-
129
- /**
130
- * @description An array of buttons whose class name is not "se-code-view-enabled"
131
- */
132
- codeViewDisabledButtons: Element[];
133
-
134
- /**
135
- * @description An array of buttons whose class name is not "se-resizing-enabled"
136
- */
137
- resizingDisabledButtons: Element[],
138
-
139
- /**
140
- * @description Editor tags whitelist (RegExp object)
141
- * util.createTagsWhitelist(options._editorTagsWhitelist)
142
- */
143
- editorTagsWhitelistRegExp: RegExp;
144
-
145
- /**
146
- * @description Editor tags blacklist (RegExp object)
147
- * util.createTagsBlacklist(options.tagsBlacklist)
148
- */
149
- editorTagsBlacklistRegExp: RegExp;
150
-
151
- /**
152
- * @description Tag whitelist when pasting (RegExp object)
153
- * util.createTagsWhitelist(options.pasteTagsWhitelist)
154
- */
155
- pasteTagsWhitelistRegExp: RegExp;
156
-
157
- /**
158
- * @description Tag blacklist when pasting (RegExp object)
159
- * util.createTagsBlacklist(options.pasteTagsBlacklist)
160
- */
161
- pasteTagsBlacklistRegExp: RegExp;
162
-
163
- /**
164
- * @description Boolean value of whether the editor has focus
165
- */
166
- hasFocus: boolean;
167
-
168
- /**
169
- * @description Plugins array with "active" method.
170
- * "activePlugins" runs the "add" method when creating the editor.
171
- */
172
- activePlugins: Plugin[];
173
-
174
- /**
175
- * @description Plugins array with "checkFiletInfo" and "resetFileInfo" methods.
176
- * "fileInfoPlugins" runs the "add" method when creating the editor.
177
- * "checkFileInfo" method is always call just before the "change" event.
178
- */
179
- fileInfoPlugins: Function[],
180
-
181
- /**
182
- * @description Elements that need to change text or className for each selection change
183
- * After creating the editor, "activePlugins" are added.
184
- * @property STRONG bold button
185
- * @property U underline button
186
- * @property EM italic button
187
- * @property DEL strike button
188
- * @property SUB subscript button
189
- * @property SUP superscript button
190
- * @property OUTDENT outdent button
191
- * @property INDENT indent button
192
- */
193
- commandMap: Record<string, Element>;
194
-
195
- /**
196
- * @description If the plugin is not added, add the plugin and call the 'add' function.
197
- * If the plugin is added call callBack function.
198
- * @param pluginName The name of the plugin to call
199
- * @param callBackFunction Function to be executed immediately after module call
200
- * @param _target Plugin target button (This is not necessary if you have a button list when creating the editor)
201
- */
202
- callPlugin(pluginName: string, callBackFunction: Function, _target?: Element): void;
203
-
204
- /**
205
- * @description If the module is not added, add the module and call the 'add' function
206
- * @param moduleArray module object's Array [dialog, resizing]
207
- */
208
- addModule(moduleArray: Module[]): void;
209
-
210
- /**
211
- * @description Gets the current editor-relative scroll offset.
212
- */
213
- getGlobalScrollOffset(): {top: number; left: number};
214
-
215
- /**
216
- * @description Method for managing submenu element.
217
- * You must add the "submenu" element using the this method at custom plugin.
218
- * @param pluginName Plugin name
219
- * @param target Target button
220
- * @param menu Submenu element
221
- */
222
- initMenuTarget(pluginName: string, target: Element | null, menu: Element): void;
223
-
224
- /**
225
- * @description Enable submenu
226
- * @param element Submenu's button element to call
227
- */
228
- submenuOn(element: Element): void;
229
-
230
- /**
231
- * @description Disable submenu
232
- */
233
- submenuOff(): void;
234
-
235
- /**
236
- * @description Disable more layer
237
- */
238
- moreLayerOff(): void;
239
-
240
- /**
241
- * @description Enable container
242
- * @param element Container's button element to call
243
- */
244
- containerOn(element: Element): void;
245
-
246
- /**
247
- * @description Disable container
248
- */
249
- containerOff(): void;
250
-
251
- /**
252
- * @description Show controller at editor area (controller elements, function, "controller target element(@Required)", "controller name(@Required)", etc..)
253
- * @param arguments controller elements, functions..
254
- */
255
- controllersOn(...arguments: Controllers): void;
256
-
257
- /**
258
- * @description Hide controller at editor area (link button, image resize button..)
259
- * @param e Event object when called from mousedown and keydown events registered in "core.controllersOn"
260
- */
261
- controllersOff(e?: KeyboardEvent | MouseEvent): void;
262
-
263
- /**
264
- * @description Specify the position of the controller.
265
- * @param controller Controller element.
266
- * @param referEl Element that is the basis of the controller's position.
267
- * @param position Type of position ("top" | "bottom")
268
- * When using the "top" position, there should not be an arrow on the controller.
269
- * When using the "bottom" position there should be an arrow on the controller.
270
- * @param addOffset These are the left and top values that need to be added specially.
271
- * This argument is required. - {left: 0, top: 0}
272
- * Please enter the value based on ltr mode.
273
- * Calculated automatically in rtl mode.
274
- */
275
- setControllerPosition(controller: Element, referEl: Element, position: 'top' | 'bottom', addOffset: {left: number, top: number}): void;
276
-
277
- /**
278
- * @description javascript execCommand
279
- * @param command javascript execCommand function property
280
- * @param showDefaultUI javascript execCommand function property
281
- * @param value javascript execCommand function property
282
- */
283
- execCommand(command: string, showDefaultUI?: boolean, value?: string): void;
284
-
285
- /**
286
- * @description Focus to wysiwyg area using "native focus function"
287
- */
288
- nativeFocus(): void;
289
-
290
- /**
291
- * @description Focus to wysiwyg area
292
- */
293
- focus(): void;
294
-
295
- /**
296
- * @description If "focusEl" is a component, then that component is selected; if it is a format element, the last text is selected
297
- * If "focusEdge" is null, then selected last element
298
- * @param focusEl Focus element
299
- */
300
- focusEdge(focusEl: Element | null): void;
301
-
302
- /**
303
- * @description Focusout to wysiwyg area (.blur())
304
- */
305
- blur(): void;
306
-
307
- /**
308
- * @description Set current editor's range object and return.
309
- * @param startCon The startContainer property of the selection object.
310
- * @param startOff The startOffset property of the selection object.
311
- * @param endCon The endContainer property of the selection object.
312
- * @param endOff The endOffset property of the selection object.
313
- * @returns
314
- */
315
- setRange(startCon: Node, startOff: number, endCon: Node, endOff: number): Range;
316
-
317
- /**
318
- * @description Remove range object and button effect
319
- */
320
- removeRange(): void;
321
-
322
- /**
323
- * @description Get current editor's range object
324
- * @returns
325
- */
326
- getRange(): Range;
327
-
328
- /**
329
- * @description If the "range" object is a non-editable area, add a line at the top of the editor and update the "range" object.
330
- * Returns a new "range" or argument "range".
331
- * @param range core.getRange()
332
- * @param container If there is "container" argument, it creates a line in front of the container.
333
- */
334
- getRange_addLine(range: Range, container?: Element): Range;
335
-
336
- /**
337
- * @description Get window selection obejct
338
- * @returns
339
- */
340
- getSelection(): Selection;
341
-
342
- /**
343
- * @description Get current select node
344
- * @returns
345
- */
346
- getSelectionNode(): Node;
347
-
348
- /**
349
- * @description Returns a "formatElement"(util.isFormatElement) array from the currently selected range.
350
- * @param validation The validation function. (Replaces the default validation function-util.isFormatElement(current))
351
- * @returns
352
- */
353
- getSelectedElements(validation?: Function): Node[];
354
-
355
- /**
356
- * @description Get format elements and components from the selected area. (P, DIV, H[1-6], OL, UL, TABLE..)
357
- * If some of the component are included in the selection, get the entire that component.
358
- * @param removeDuplicate If true, if there is a parent and child tag among the selected elements, the child tag is excluded.
359
- * @returns
360
- */
361
- getSelectedElementsAndComponents(removeDuplicate: boolean): Node[];
362
-
363
- /**
364
- * @description Determine if this offset is the edge offset of container
365
- * @param container The container property of the selection object.
366
- * @param offset The offset property of the selection object.
367
- * @param dir Select check point - Both edge, Front edge or End edge. ("front": Front edge, "end": End edge, undefined: Both edge)
368
- * @returns
369
- */
370
- isEdgePoint(container: Node, offset: number, dir?: 'front' | 'end'): boolean;
371
-
372
- /**
373
- * @description Show loading box
374
- */
375
- showLoading(): void;
376
-
377
- /**
378
- * @description Close loading box
379
- */
380
- closeLoading(): void;
381
-
382
- /**
383
- * @description Append format element to sibling node of argument element.
384
- * If the "formatNodeName" argument value is present, the tag of that argument value is inserted,
385
- * If not, the currently selected format tag is inserted.
386
- * @param element Insert as siblings of that element
387
- * @param formatNode Node name or node obejct to be inserted
388
- * @returns
389
- */
390
- appendFormatTag(element: Element, formatNode?: string | Element): Element;
391
-
392
- /**
393
- * @description The method to insert a element and return. (used elements : table, hr, image, video)
394
- * If "element" is "HR", insert and return the new line.
395
- * @param element Element to be inserted
396
- * @param notHistoryPush When true, it does not update the history stack and the selection object and return EdgeNodes (util.getEdgeChildNodes)
397
- * @param checkCharCount If true, if "options.maxCharCount" is exceeded when "element" is added, null is returned without addition.
398
- * @param notSelect If true, Do not automatically select the inserted component.
399
- * @returns
400
- */
401
- insertComponent(element: Element, notHistoryPush?: boolean, checkCharCount?: boolean, notSelect?:boolean): Element;
402
-
403
- /**
404
- * @description Gets the file component and that plugin name
405
- * return: {target, component, pluginName} | null
406
- * @param element Target element (figure tag, component div, file tag)
407
- * @returns
408
- */
409
- getFileComponent(element: Element): seledtedFileInfo | null;
410
-
411
- /**
412
- * @description The component(image, video) is selected and the resizing module is called.
413
- * @param element Element tag (img, iframe, video)
414
- * @param pluginName Plugin name (image, video)
415
- */
416
- selectComponent(element: Element, pluginName: string): void;
417
-
418
- /**
419
- * @description Delete selected node and insert argument value node and return.
420
- * If the "afterNode" exists, it is inserted after the "afterNode"
421
- * Inserting a text node merges with both text nodes on both sides and returns a new "{ container, startOffset, endOffset }".
422
- * @param oNode Element to be inserted
423
- * @param afterNode If the node exists, it is inserted after the node
424
- * @returns
425
- */
426
- insertNode(oNode: Node, afterNode?: Node, checkCharCount?: boolean): { startOffset: Node, endOffset: number } | Node | null;
427
-
428
- /**
429
- * @description Delete the currently selected nodes and reset selection range
430
- * Returns {container: "the last element after deletion", offset: "offset", prevContainer: "previousElementSibling Of the deleted area"}
431
- * @returns
432
- */
433
- removeNode(): { container: Node; offset: number; prevContainer?: Node };
434
-
435
- /**
436
- * @description Appended all selected format Element to the argument element and insert
437
- * @param rangeElement Element of wrap the arguments (BLOCKQUOTE...)
438
- */
439
- applyRangeFormatElement(rangeElement: Element): void;
440
-
441
- /**
442
- * @description The elements of the "selectedFormats" array are detached from the "rangeElement" element. ("LI" tags are converted to "P" tags)
443
- * When "selectedFormats" is null, all elements are detached and return {cc: parentNode, sc: nextSibling, ec: previousSibling, removeArray: [Array of removed elements]}.
444
- * @param rangeElement Range format element (PRE, BLOCKQUOTE, OL, UL...)
445
- * @param selectedFormats Array of format elements (P, DIV, LI...) to remove.
446
- * If null, Applies to all elements and return {cc: parentNode, sc: nextSibling, ec: previousSibling}
447
- * @param newRangeElement The node(rangeElement) to replace the currently wrapped node.
448
- * @param remove If true, deleted without detached.
449
- * @param notHistoryPush When true, it does not update the history stack and the selection object and return EdgeNodes (util.getEdgeChildNodes)
450
- * @returns
451
- */
452
- detachRangeFormatElement(rangeElement: Element, selectedFormats: Element[] | null, newRangeElement: Element | null, remove: boolean, notHistoryPush: boolean): {cc: Node, sc: Node, ec: Node, removeArray: Element[]}
453
-
454
- /**
455
- * @description "selectedFormats" array are detached from the list element.
456
- * The return value is applied when the first and last lines of "selectedFormats" are "LI" respectively.
457
- * @param selectedFormats Array of format elements (LI, P...) to remove.
458
- * @param remove If true, deleted without detached.
459
- * @returns {sc: <LI>, ec: <LI>}.
460
- */
461
- detachList(selectedFormats: Element[], remove: boolean): {sc: Element, ec: Element};
462
-
463
- /**
464
- * @description Add, update, and delete nodes from selected text.
465
- * 1. If there is a node in the "appendNode" argument, a node with the same tags and attributes as "appendNode" is added to the selection text.
466
- * 2. If it is in the same tag, only the tag's attributes are changed without adding a tag.
467
- * 3. If the "appendNode" argument is null, the node of the selection is update or remove without adding a new node.
468
- * 4. The same style as the style attribute of the "styleArray" argument is deleted.
469
- * (Styles should be put with attribute names from css. ["background-color"])
470
- * 5. The same class name as the class attribute of the "styleArray" argument is deleted.
471
- * (The class name is preceded by "." [".className"])
472
- * 6. Use a list of styles and classes of "appendNode" in "styleArray" to avoid duplicate property values.
473
- * 7. If a node with all styles and classes removed has the same tag name as "appendNode" or "removeNodeArray", or "appendNode" is null, that node is deleted.
474
- * 8. Regardless of the style and class of the node, the tag with the same name as the "removeNodeArray" argument value is deleted.
475
- * 9. If the "strictRemove" argument is true, only nodes with all styles and classes removed from the nodes of "removeNodeArray" are removed.
476
- * 10. It won't work if the parent node has the same class and same value style.
477
- * However, if there is a value in "removeNodeArray", it works and the text node is separated even if there is no node to replace.
478
- * @param appendNode The element to be added to the selection. If it is null, only delete the node.
479
- * @param styleArray The style or className attribute name Array to check (['font-size'], ['.className'], ['font-family', 'color', '.className']...])
480
- * @param removeNodeArray An array of node names to remove types from, remove all formats when "appendNode" is null and there is an empty array or null value. (['span'], ['strong', 'em'] ...])
481
- * @param strictRemove If true, only nodes with all styles and classes removed from the nodes of "removeNodeArray" are removed.
482
- */
483
- nodeChange(appendNode?: Element, styleArray?: string[], removeNodeArray?: string[], strictRemove?: boolean): void;
484
-
485
- /**
486
- * @description Run plugin calls and basic commands.
487
- * @param command Command string
488
- * @param display Display type string ('command', 'submenu', 'dialog', 'container')
489
- * @param target The element of command button
490
- */
491
- actionCall(command: string, display: 'command' | 'submenu' | 'dialog' | 'container', target: Element): void;
492
-
493
- /**
494
- * @description Execute command of command button(All Buttons except submenu and dialog)
495
- * (undo, redo, bold, underline, italic, strikethrough, subscript, superscript, removeFormat, indent, outdent, fullscreen, showBlocks, codeview, preview, print, copy, cut, paste)
496
- * @param target The element of command button
497
- * @param command Property of command button (data-value)
498
- */
499
- commandHandler(target: Element | null, command: commands): void;
500
-
501
- /**
502
- * @description Remove format of the currently selected range
503
- */
504
- removeFormat(): void;
505
-
506
- /**
507
- * @description This method implements indentation to selected range.
508
- * Setted "margin-left" to "25px" in the top "P" tag of the parameter node.
509
- * @param command Separator ("indent" or "outdent")
510
- */
511
- indent(command: 'indent' | 'outdent'): void;
512
-
513
- /**
514
- * @description Add or remove the class name of "body" so that the code block is visible
515
- */
516
- toggleDisplayBlocks(): void;
517
-
518
- /**
519
- * @description Changes to code view or wysiwyg view
520
- */
521
- toggleCodeView(): void;
522
-
523
- /**
524
- * @description Changes to full screen or default screen
525
- * @param element full screen button
526
- */
527
- toggleFullScreen(element: Element | null): void;
528
-
529
- /**
530
- * @description Prints the current contents of the editor.
531
- */
532
- print(): void;
533
-
534
- /**
535
- * @description Open the preview window.
536
- */
537
- preview(): void;
538
-
539
- /**
540
- * @description Set direction to "rtl" or "ltr".
541
- * @param dir "rtl" or "ltr"
542
- */
543
- setDir(dir: 'rtl' | 'ltr'): void;
544
-
545
- /**
546
- * @description Sets the HTML string
547
- * @param html HTML string
548
- */
549
- setContents(html: string): void;
550
-
551
- /**
552
- * @description Sets the contents of the iframe's head tag and body tag when using the "iframe" or "fullPage" option.
553
- * @param ctx { head: HTML string, body: HTML string}
554
- */
555
- setIframeContents(ctx: { head?: string, body?: string }): void;
556
-
557
- /**
558
- * @description Gets the current contents
559
- * @param onlyContents Return only the contents of the body without headers when the "fullPage" option is true
560
- * @returns
561
- */
562
- getContents(onlyContents: boolean): string;
563
-
564
- /**
565
- * @description Gets the current contents with containing parent div(div.sun-editor-editable).
566
- * <div class="sun-editor-editable">{contents}</div>
567
- * @param onlyContents Return only the contents of the body without headers when the "fullPage" option is true
568
- * @returns
569
- */
570
- getFullContents(onlyContents: boolean): string;
571
-
572
- /**
573
- * @description Gets the clean HTML code for editor
574
- * @param html HTML string
575
- * @param whitelist Regular expression of allowed tags.
576
- * RegExp object is create by util.createTagsWhitelist method. (core.pasteTagsWhitelistRegExp)
577
- * @param blacklist Regular expression of disallowed tags.
578
- * RegExp object is create by util.createTagsBlacklist method. (core.pasteTagsBlacklistRegExp)
579
- * @returns
580
- */
581
- cleanHTML(html: string, whitelist?: string | RegExp, blacklist?: string | RegExp): string;
582
-
583
- /**
584
- * @description Converts contents into a format that can be placed in an editor
585
- * @param contents contents
586
- * @returns
587
- */
588
- convertContentsForEditor(contents: string): string;
589
-
590
- /**
591
- * @description Converts wysiwyg area element into a format that can be placed in an editor of code view mode
592
- * @param html WYSIWYG element (context.element.wysiwyg) or HTML string.
593
- * @param comp If true, does not line break and indentation of tags.
594
- * @returns
595
- */
596
- convertHTMLForCodeView(html: Element | string, comp?: boolean): string;
597
-
598
- /**
599
- * @description Add an event to document.
600
- * When created as an Iframe, the same event is added to the document in the Iframe.
601
- * @param type Event type
602
- * @param listener Event listener
603
- * @param useCapture Use event capture
604
- */
605
- addDocEvent(type: string, listener: EventListener, useCapture: boolean): void;
606
-
607
- /**
608
- * @description Remove events from document.
609
-   * When created as an Iframe, the event of the document inside the Iframe is also removed.
610
- * @param type Event type
611
- * @param listener Event listener
612
- */
613
- removeDocEvent(type: string, listener: EventListener): void;
614
-
615
- /**
616
- * @description When "element" is added, if it is greater than "options.maxCharCount", false is returned.
617
- * @param element Element node or String.
618
- * @param charCounterType charCounterType. If it is null, the options.charCounterType
619
- */
620
- checkCharCount(element: Node | string, charCounterType?: string): boolean;
621
-
622
- /**
623
- * @description Get the length of the content.
624
- * Depending on the option, the length of the character is taken. (charCounterType)
625
- * @param content Content to count
626
- * @param charCounterType options.charCounterType
627
- */
628
- getCharLength(content: string, charCounterType: string): number;
629
- }
630
-
631
- interface Toolbar {
632
- /**
633
- * @description Disable the toolbar
634
- */
635
- disable(): void;
636
-
637
- /**
638
- * @description Enable the toolbar
639
- */
640
- enable(): void;
641
-
642
- /**
643
- * @description Show the toolbar
644
- */
645
- show(): void;
646
-
647
- /**
648
- * @description Hide the toolbar
649
- */
650
- hide(): void;
651
- }
652
-
653
- interface Wysiwyg {
654
- /**
655
- * @description Disable the wysiwyg area
656
- */
657
- disable(): void;
658
-
659
- /**
660
- * @description Enable the wysiwyg area
661
- */
662
- enable(): void;
663
- }
664
-
665
- type EventFn = (e: Event, core: Core) => void;
666
-
667
- type imageInputInformation = { linkValue: string, linkNewWindow: Window, inputWidth: number, inputHeight: number, align: string, isUpdate: boolean, element: any };
668
- type videoInputInformation = { inputWidth: number, inputHeight: number, align: string, isUpdate: boolean, element: any };
669
- type audioInputInformation = { isUpdate: boolean, element: any };
670
-
671
- export default class SunEditor {
672
- constructor(context: Context,
673
- pluginCallButtons: Record<string, Element>,
674
- plugins: Record<string, Plugin>,
675
- lang: Lang,
676
- options: SunEditorOptions,
677
- _icons: Record<string, string>)
678
-
679
- core: Core;
680
- util: Util;
681
-
682
- onload: (core: Core, reload: boolean) => void;
683
- onScroll: EventFn;
684
- onFocus: EventFn;
685
- onMouseDown: EventFn;
686
- onClick: EventFn;
687
- onInput: EventFn;
688
- onKeyDown: EventFn;
689
- onKeyUp: EventFn;
690
- onChange: (contents: string, core: Core) => void;
691
- onBlur: (e: FocusEvent, core: Core) => void;
692
- onDrop: (e: Event, cleanData: string, maxCharCount: number, core: Core) => boolean | string;
693
- onPaste: (e: Event, cleanData: string, maxCharCount: number, core: Core) => boolean | string;
694
- onCopy: (e: Event, clipboardData: any, core: Core) => boolean;
695
- onCut: (e: Event, clipboardData: any, core: Core) => boolean;
696
-
697
- /**
698
- * @description Called just after the save was executed.
699
- * @param contents Editor content
700
- * @param core Core object
701
- */
702
- onSave: (contents: string, core: Core) => void;
703
-
704
- /**
705
- * @description Called just before the inline toolbar is positioned and displayed on the screen.
706
- * @param toolbar Toolbar Element
707
- * @param context The editor's context object (editor.getContext())
708
- * @param core Core object
709
- */
710
- showInline: (toolbar: Element, context: Context, core: Core) => void;
711
-
712
- /**
713
- * @description Called just after the controller is positioned and displayed on the screen.
714
- * controller - editing elements displayed on the screen [image resizing, table editor, link editor..]]
715
- * @param name The name of the plugin that called the controller
716
- * @param controllers Array of Controller elements
717
- * @param core Core object
718
- */
719
- showController: (name: String, controllers: Controllers, core: Core) => void;
720
-
721
- /**
722
- * @description It replaces the default callback function of the image upload
723
- * @param xmlHttp xmlHttpRequest object
724
- * @param info Input information
725
- * - linkValue: Link url value
726
- * - linkNewWindow: Open in new window Check Value
727
- * - inputWidth: Value of width input
728
- * - inputHeight: Value of height input
729
- * - align: Align Check Value
730
- * - isUpdate: Update image if true, create image if false
731
- * - element: If isUpdate is true, the currently selected image.
732
- * @param core Core object
733
- */
734
- imageUploadHandler: (xmlHttp: XMLHttpRequest, info: imageInputInformation, core: Core) => void;
735
-
736
- /**
737
- * @description It replaces the default callback function of the video upload
738
- * @param xmlHttp xmlHttpRequest object
739
- * @param info Input information
740
- * - inputWidth: Value of width input
741
- * - inputHeight: Value of height input
742
- * - align: Align Check Value
743
- * - isUpdate: Update video if true, create video if false
744
- * - element: If isUpdate is true, the currently selected video.
745
- * @param core Core object
746
- */
747
- videoUploadHandler: (xmlHttp: XMLHttpRequest, info: videoInputInformation, core: Core) => void;
748
-
749
- /**
750
- * @description It replaces the default callback function of the audio upload
751
- * @param xmlHttp xmlHttpRequest object
752
- * @param info Input information
753
- * - isUpdate: Update audio if true, create audio if false
754
- * - element: If isUpdate is true, the currently selected audio.
755
- * @param core Core object
756
- */
757
- audioUploadHandler: (xmlHttp: XMLHttpRequest, info: audioInputInformation, core: Core) => void;
758
-
759
- /**
760
- * @description An event when toggling between code view and wysiwyg view.
761
- * @param isCodeView Whether the current code view mode
762
- * @param core Core object
763
- */
764
- toggleCodeView: (isCodeView: boolean, core: Core) => void;
765
-
766
- /**
767
- * @description An event when toggling full screen.
768
- * @param isFullScreen Whether the current full screen mode
769
- * @param core Core object
770
- */
771
- toggleFullScreen: (isFullScreen: boolean, core: Core) => void;
772
-
773
- /**
774
- * @description Called before the image is uploaded
775
- * If true is returned, the internal upload process runs normally.
776
- * If false is returned, no image upload is performed.
777
- * If new fileList are returned, replaced the previous fileList
778
- * If undefined is returned, it waits until "uploadHandler" is executed.
779
- * @param files Files array
780
- * @param info Input information
781
- * @param core Core object
782
- * @param uploadHandler If undefined is returned, it waits until "uploadHandler" is executed.
783
- * "uploadHandler" is an upload function with "core" and "info" bound.
784
- * [upload files] : uploadHandler(files or [new File(...),])
785
- * [error] : uploadHandler("Error message")
786
- * [Just finish] : uploadHandler()
787
- * [directly register] : uploadHandler(response) // Same format as "imageUploadUrl" response
788
- * ex) {
789
- * // "errorMessage": "insert error message",
790
- * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
791
- * }
792
- * @returns
793
- */
794
- onImageUploadBefore: (files: any[], info: imageInputInformation, core: Core, uploadHandler: Function) => boolean | any[] | undefined;
795
-
796
- /**
797
- * @description Called before the video is uploaded
798
- * If true is returned, the internal upload process runs normally.
799
- * If false is returned, no video upload is performed.
800
- * If new fileList are returned, replaced the previous fileList
801
- * If undefined is returned, it waits until "uploadHandler" is executed.
802
- * @param files Files array
803
- * @param info Input information
804
- * @param core Core object
805
- * @param uploadHandler If undefined is returned, it waits until "uploadHandler" is executed.
806
- * "uploadHandler" is an upload function with "core" and "info" bound.
807
- * [upload files] : uploadHandler(files or [new File(...),])
808
- * [error] : uploadHandler("Error message")
809
- * [Just finish] : uploadHandler()
810
- * [directly register] : uploadHandler(response) // Same format as "videoUploadUrl" response
811
- * ex) {
812
- * // "errorMessage": "insert error message",
813
- * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
814
- * }
815
- * @returns
816
- */
817
- onVideoUploadBefore: (files: any[], info: videoInputInformation, core: Core, uploadHandler: Function) => boolean | any[] | undefined;
818
-
819
- /**
820
- * @description Called before the audio is uploaded
821
- * If true is returned, the internal upload process runs normally.
822
- * If false is returned, no audio upload is performed.
823
- * If new fileList are returned, replaced the previous fileList
824
- * If undefined is returned, it waits until "uploadHandler" is executed.
825
- * @param files Files array
826
- * @param info Input information
827
- * @param core Core object
828
- * @param uploadHandler If undefined is returned, it waits until "uploadHandler" is executed.
829
- * "uploadHandler" is an upload function with "core" and "info" bound.
830
- * [upload files] : uploadHandler(files or [new File(...),])
831
- * [error] : uploadHandler("Error message")
832
- * [Just finish] : uploadHandler()
833
- * [directly register] : uploadHandler(response) // Same format as "audioUploadUrl" response
834
- * ex) {
835
- * // "errorMessage": "insert error message",
836
- * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
837
- * }
838
- * @returns
839
- */
840
- onAudioUploadBefore: (files: any[], info: audioInputInformation, core: Core, uploadHandler: Function) => boolean | any[] | undefined;
841
-
842
- /**
843
- * @description Called when the image is uploaded, updated, deleted
844
- * @param targetElement Target element
845
- * @param index Uploaded index
846
- * @param state Upload status ('create', 'update', 'delete')
847
- * @param info Info object
848
- * - index: data index
849
- * - name: file name
850
- * - size: file size
851
- * - select: select function
852
- * - delete: delete function
853
- * - element: target element
854
- * - src: src attribute of tag
855
- * @param remainingFilesCount Count of remaining files to upload (0 when added as a url)
856
- * @param core Core object
857
- */
858
- onImageUpload: (targetElement: HTMLImageElement, index: number, state: 'create' | 'update' | 'delete', info: fileInfo, remainingFilesCount: number, core: Core) => void;
859
-
860
- /**
861
- * @description Called when the video(iframe, video) is uploaded, updated, deleted
862
- * @param targetElement Target element
863
- * @param index Uploaded index
864
- * @param state Upload status ('create', 'update', 'delete')
865
- * @param info Info object
866
- * - index: data index
867
- * - name: file name
868
- * - size: file size
869
- * - select: select function
870
- * - delete: delete function
871
- * - element: target element
872
- * - src: src attribute of tag
873
- * @param remainingFilesCount Count of remaining files to upload (0 when added as a url)
874
- * @param core Core object
875
- */
876
- onVideoUpload: (targetElement: HTMLIFrameElement | HTMLVideoElement, index: number, state: 'create' | 'update' | 'delete', info: fileInfo, remainingFilesCount: number, core: Core) => void;
877
-
878
- /**
879
- * @description Called when the audio is uploaded, updated, deleted
880
- * @param targetElement Target element
881
- * @param index Uploaded index
882
- * @param state Upload status ('create', 'update', 'delete')
883
- * @param info Info object
884
- * - index: data index
885
- * - name: file name
886
- * - size: file size
887
- * - select: select function
888
- * - delete: delete function
889
- * - element: target element
890
- * - src: src attribute of tag
891
- * @param remainingFilesCount Count of remaining files to upload (0 when added as a url)
892
- * @param core Core object
893
- */
894
- onAudioUpload: (targetElement: HTMLAudioElement, index: number, state: 'create' | 'update' | 'delete', info: fileInfo, remainingFilesCount: number, core: Core) => void;
895
-
896
- /**
897
- * @description Called when the image is upload failed
898
- * @param errorMessage Error message
899
- * @param result Response Object
900
- * @param core Core object
901
- * @returns
902
- */
903
- onImageUploadError: (errorMessage: string, result: any, core: Core) => boolean;
904
-
905
- /**
906
- * @description Called when the video(iframe, video) upload failed
907
- * @param errorMessage Error message
908
- * @param result Response Object
909
- * @param core Core object
910
- * @returns
911
- */
912
- onVideoUploadError: (errorMessage: string, result: any, core: Core) => boolean;
913
-
914
- /**
915
- * @description Called when the audio upload failed
916
- * @param errorMessage Error message
917
- * @param result Response Object
918
- * @param core Core object
919
- * @returns
920
- */
921
- onAudioUploadError: (errorMessage: string, result: any, core: Core) => boolean;
922
-
923
- /**
924
- * @description Called when the audio upload failed
925
- * @param height Height after resized (px)
926
- * @param prevHeight Prev height before resized (px)
927
- * @param core Core object
928
- * @param resizeObserverEntry ResizeObserverEntry object (This is not provided in IE Browser.)
929
- * @returns
930
- */
931
- onResizeEditor: (height: number, prevHeight: number, core: Core, resizeObserverEntry: ResizeObserverEntry | null) => {};
932
-
933
- /**
934
- * @description Called after the "setToolbarButtons" invocation.
935
- * Can be used to tweak buttons properties (useful for custom buttons)
936
- * @param buttonList Button list
937
- * @param core Core object
938
- */
939
- onSetToolbarButtons: (buttonList: any[], core: Core) => void;
940
-
941
- /**
942
- * @description Reset the buttons on the toolbar. (Editor is not reloaded)
943
- * You cannot set a new plugin for the button.
944
- * @param buttonList Button list
945
- */
946
- setToolbarButtons(buttonList: any[]): void;
947
-
948
- /**
949
- * @description Add or reset option property
950
- * @param options Options
951
- */
952
- setOptions(options: SunEditorOptions): void;
953
-
954
- /**
955
- * @description Set "options.defaultStyle" style.
956
- * Define the style of the edit area
957
- * It can also be defined with the "setOptions" method, but the "setDefaultStyle" method does not render the editor again.
958
- * @param style Style string
959
- */
960
- setDefaultStyle(style: string): void;
961
-
962
- /**
963
- * @description Open a notice area
964
- * @param message Notice message
965
- */
966
- noticeOpen(message: string): void;
967
-
968
- /**
969
- * @description Close a notice area
970
- */
971
- noticeClose(): void;
972
-
973
- /**
974
- * @description Copying the contents of the editor to the original textarea
975
- */
976
- save(): void;
977
-
978
- /**
979
- * @description Gets the suneditor's context object. Contains settings, plugins, and cached element objects
980
- * @returns
981
- */
982
- getContext(): Context;
983
-
984
- /**
985
- * @description Gets the contents of the suneditor
986
- * @param onlyContents - Return only the contents of the body without headers when the "fullPage" option is true
987
- * @returns
988
- */
989
- getContents(onlyContents: boolean): string;
990
-
991
- /**
992
- * @description Gets only the text of the suneditor contents
993
- * @returns
994
- */
995
- getText(): string;
996
-
997
- /**
998
- * @description Get the editor's number of characters or binary data size.
999
- * You can use the "charCounterType" option format.
1000
- * @param charCounterType options - charCounterType ('char', 'byte', 'byte-html')
1001
- * If argument is no value, the currently set "charCounterType" option is used.
1002
- * @returns
1003
- */
1004
- getCharCount(charCounterType?: string): number;
1005
-
1006
- /**
1007
- * @description Gets uploaded images informations
1008
- * - index: data index
1009
- * - name: file name
1010
- * - size: file size
1011
- * - select: select function
1012
- * - delete: delete function
1013
- * - element: img element
1014
- * - src: src attribute of img tag
1015
- * @returns
1016
- */
1017
- getImagesInfo(): fileInfo[];
1018
-
1019
- /**
1020
- * @description Gets uploaded files(plugin using fileManager) information list.
1021
- * image: [img], video: [video, iframe], audio: [audio]
1022
- * When the argument value is 'image', it is the same function as "getImagesInfo".
1023
- * - index: data index
1024
- * - name: file name
1025
- * - size: file size
1026
- * - select: select function
1027
- * - delete: delete function
1028
- * - element: img element
1029
- * - src: src attribute of img tag
1030
- * @param pluginName Plugin name (image, video, audio)
1031
- * @returns
1032
- */
1033
- getFilesInfo(pluginName: string): fileInfo[];
1034
-
1035
- /**
1036
- * @description Upload images using image plugin
1037
- * @param files FileList
1038
- */
1039
- insertImage(files: FileList): void;
1040
-
1041
- /**
1042
- * @description Inserts an HTML element or HTML string or plain string at the current cursor position
1043
- * @param html HTML Element or HTML string or plain string
1044
- * @param notCleaningData If true, inserts the HTML string without refining it with core.cleanHTML.
1045
- * @param checkCharCount If true, if "options.maxCharCount" is exceeded when "element" is added, null is returned without addition.
1046
- * @param rangeSelection If true, range select the inserted node.
1047
- */
1048
- insertHTML(html: Element | string, notCleaningData?: boolean, checkCharCount?: boolean, rangeSelection?: boolean): void;
1049
-
1050
- /**
1051
- * @description Change the contents of the suneditor
1052
- * @param contents Contents to Input
1053
- */
1054
- setContents(contents: string): void;
1055
-
1056
- /**
1057
- * @description Add contents to the suneditor
1058
- * @param contents Contents to Input
1059
- */
1060
- appendContents(contents: string): void;
1061
-
1062
- /**
1063
- * @description Switch to or off "ReadOnly" mode.
1064
- * @param value "readOnly" boolean value.
1065
- */
1066
- readOnly(value: boolean): void;
1067
-
1068
- /**
1069
- * @description Disable the suneditor
1070
- */
1071
- disable(): void;
1072
-
1073
- /**
1074
- * @description Enable the suneditor
1075
- */
1076
- enable(): void;
1077
-
1078
- /**
1079
- * @description Show the suneditor
1080
- */
1081
- show(): void;
1082
-
1083
- /**
1084
- * @description Hide the suneditor
1085
- */
1086
- hide(): void;
1087
-
1088
- /**
1089
- * @description Destroy the suneditor
1090
- */
1091
- destroy(): void;
1092
-
1093
- /**
1094
- * @description Toolbar methods
1095
- */
1096
- toolbar: Toolbar;
1097
-
1098
- /**
1099
- * @description Wysiwyg methods
1100
- */
1101
- wysiwyg: Wysiwyg;
1
+ import { History } from './history.d';
2
+ import { Plugin } from './../plugins/Plugin.d';
3
+ import { Lang } from './../lang/Lang.d';
4
+ import { SunEditorOptions } from './../options.d';
5
+ import { Context } from './context';
6
+ import Util from './util';
7
+ import { Module } from '../plugins/Module';
8
+ import _Notice from '../plugins/modules/_notice';
9
+
10
+ type Controllers = Array<string | Function | Element>;
11
+ type fileInfo = {
12
+ index: number;
13
+ name: string;
14
+ size: string | number;
15
+ select: Function;
16
+ delete: Function;
17
+ element: Element;
18
+ src: string;
19
+ };
20
+ type seledtedFileInfo = {target: Element; component: Element; pluginName: string;};
21
+ type commands = 'selectAll' | 'codeView' | 'fullScreen' | 'indent' | 'outdent' | 'undo' | 'redo' | 'removeFormat' | 'print' | 'preview' | 'showBlocks' | 'save' | 'bold' | 'underline' | 'italic' | 'strike' | 'subscript' | 'superscript' | 'copy' | 'cut' | 'paste';
22
+ ​​
23
+ interface Core {
24
+ /**
25
+ * @description Util object
26
+ */
27
+ util: Util;
28
+
29
+ /**
30
+ * @description Functions object
31
+ */
32
+ functions: SunEditor;
33
+
34
+ /**
35
+ * @description Editor options
36
+ */
37
+ options: SunEditorOptions;
38
+
39
+ /**
40
+ * @description Computed style of the wysiwyg area (window.getComputedStyle(context.element.wysiwyg))
41
+ */
42
+ wwComputedStyle: any;
43
+
44
+ /**
45
+ * @description Notice object
46
+ */
47
+ notice: _Notice;
48
+
49
+ /**
50
+ * @description Default icons object
51
+ */
52
+ icons: Record<string, string>;
53
+
54
+ /**
55
+ * @description History object for undo, redo
56
+ */
57
+ history: History;
58
+
59
+ /**
60
+ * @description Elements and user options parameters of the suneditor
61
+ */
62
+ context: Context;
63
+
64
+ /**
65
+ * @description Plugin buttons
66
+ */
67
+ pluginCallButtons: Record<string, Element>;
68
+
69
+ /**
70
+ * @description Loaded plugins
71
+ */
72
+ plugins: Record<string, Plugin>;
73
+
74
+ /**
75
+ * @description Whether the plugin is initialized
76
+ */
77
+ initPlugins: Record<string, boolean>;
78
+
79
+ /**
80
+ * @description loaded language
81
+ */
82
+ lang: Lang;
83
+
84
+ /**
85
+ * @description The selection node (core.getSelectionNode()) to which the effect was last applied
86
+ */
87
+ effectNode: Node;
88
+
89
+ /**
90
+ * @description submenu element
91
+ */
92
+ submenu: Element;
93
+
94
+ /**
95
+ * @description container element
96
+ */
97
+ container: Element;
98
+
99
+ /**
100
+ * @description active button element in submenu
101
+ */
102
+ submenuActiveButton: Element;
103
+
104
+ /**
105
+ * @description active button element in container
106
+ */
107
+ containerActiveButton: Element;
108
+
109
+ /**
110
+ * @description The elements array to be processed unvisible when the controllersOff function is executed (resizing, link modified button, table controller)
111
+ */
112
+ controllerArray: Controllers;
113
+
114
+ /**
115
+ * @description The name of the plugin that called the currently active controller
116
+ */
117
+ currentControllerName: string;
118
+
119
+ /**
120
+ * @description The target element of current controller
121
+ */
122
+ currentControllerTarget: Element;
123
+
124
+ /**
125
+ * @description The file component object of current selected file tag (getFileComponent(): {target, component, pluginName})
126
+ */
127
+ currentFileComponentInfo: seledtedFileInfo;
128
+
129
+ /**
130
+ * @description An array of buttons whose class name is not "se-code-view-enabled"
131
+ */
132
+ codeViewDisabledButtons: Element[];
133
+
134
+ /**
135
+ * @description An array of buttons whose class name is not "se-resizing-enabled"
136
+ */
137
+ resizingDisabledButtons: Element[],
138
+
139
+ /**
140
+ * @description Editor tags whitelist (RegExp object)
141
+ * util.createTagsWhitelist(options._editorTagsWhitelist)
142
+ */
143
+ editorTagsWhitelistRegExp: RegExp;
144
+
145
+ /**
146
+ * @description Editor tags blacklist (RegExp object)
147
+ * util.createTagsBlacklist(options.tagsBlacklist)
148
+ */
149
+ editorTagsBlacklistRegExp: RegExp;
150
+
151
+ /**
152
+ * @description Tag whitelist when pasting (RegExp object)
153
+ * util.createTagsWhitelist(options.pasteTagsWhitelist)
154
+ */
155
+ pasteTagsWhitelistRegExp: RegExp;
156
+
157
+ /**
158
+ * @description Tag blacklist when pasting (RegExp object)
159
+ * util.createTagsBlacklist(options.pasteTagsBlacklist)
160
+ */
161
+ pasteTagsBlacklistRegExp: RegExp;
162
+
163
+ /**
164
+ * @description Boolean value of whether the editor has focus
165
+ */
166
+ hasFocus: boolean;
167
+
168
+ /**
169
+ * @description Plugins array with "active" method.
170
+ * "activePlugins" runs the "add" method when creating the editor.
171
+ */
172
+ activePlugins: Plugin[];
173
+
174
+ /**
175
+ * @description Plugins array with "checkFiletInfo" and "resetFileInfo" methods.
176
+ * "fileInfoPlugins" runs the "add" method when creating the editor.
177
+ * "checkFileInfo" method is always call just before the "change" event.
178
+ */
179
+ fileInfoPlugins: Function[],
180
+
181
+ /**
182
+ * @description Elements that need to change text or className for each selection change
183
+ * After creating the editor, "activePlugins" are added.
184
+ * @property STRONG bold button
185
+ * @property U underline button
186
+ * @property EM italic button
187
+ * @property DEL strike button
188
+ * @property SUB subscript button
189
+ * @property SUP superscript button
190
+ * @property OUTDENT outdent button
191
+ * @property INDENT indent button
192
+ */
193
+ commandMap: Record<string, Element>;
194
+
195
+ /**
196
+ * @description If the plugin is not added, add the plugin and call the 'add' function.
197
+ * If the plugin is added call callBack function.
198
+ * @param pluginName The name of the plugin to call
199
+ * @param callBackFunction Function to be executed immediately after module call
200
+ * @param _target Plugin target button (This is not necessary if you have a button list when creating the editor)
201
+ */
202
+ callPlugin(pluginName: string, callBackFunction: Function, _target?: Element): void;
203
+
204
+ /**
205
+ * @description If the module is not added, add the module and call the 'add' function
206
+ * @param moduleArray module object's Array [dialog, resizing]
207
+ */
208
+ addModule(moduleArray: Module[]): void;
209
+
210
+ /**
211
+ * @description Gets the current editor-relative scroll offset.
212
+ */
213
+ getGlobalScrollOffset(): {top: number; left: number};
214
+
215
+ /**
216
+ * @description Method for managing submenu element.
217
+ * You must add the "submenu" element using the this method at custom plugin.
218
+ * @param pluginName Plugin name
219
+ * @param target Target button
220
+ * @param menu Submenu element
221
+ */
222
+ initMenuTarget(pluginName: string, target: Element | null, menu: Element): void;
223
+
224
+ /**
225
+ * @description Enable submenu
226
+ * @param element Submenu's button element to call
227
+ */
228
+ submenuOn(element: Element): void;
229
+
230
+ /**
231
+ * @description Disable submenu
232
+ */
233
+ submenuOff(): void;
234
+
235
+ /**
236
+ * @description Disable more layer
237
+ */
238
+ moreLayerOff(): void;
239
+
240
+ /**
241
+ * @description Enable container
242
+ * @param element Container's button element to call
243
+ */
244
+ containerOn(element: Element): void;
245
+
246
+ /**
247
+ * @description Disable container
248
+ */
249
+ containerOff(): void;
250
+
251
+ /**
252
+ * @description Show controller at editor area (controller elements, function, "controller target element(@Required)", "controller name(@Required)", etc..)
253
+ * @param arguments controller elements, functions..
254
+ */
255
+ controllersOn(...arguments: Controllers): void;
256
+
257
+ /**
258
+ * @description Hide controller at editor area (link button, image resize button..)
259
+ * @param e Event object when called from mousedown and keydown events registered in "core.controllersOn"
260
+ */
261
+ controllersOff(e?: KeyboardEvent | MouseEvent): void;
262
+
263
+ /**
264
+ * @description Specify the position of the controller.
265
+ * @param controller Controller element.
266
+ * @param referEl Element that is the basis of the controller's position.
267
+ * @param position Type of position ("top" | "bottom")
268
+ * When using the "top" position, there should not be an arrow on the controller.
269
+ * When using the "bottom" position there should be an arrow on the controller.
270
+ * @param addOffset These are the left and top values that need to be added specially.
271
+ * This argument is required. - {left: 0, top: 0}
272
+ * Please enter the value based on ltr mode.
273
+ * Calculated automatically in rtl mode.
274
+ */
275
+ setControllerPosition(controller: Element, referEl: Element, position: 'top' | 'bottom', addOffset: {left: number, top: number}): void;
276
+
277
+ /**
278
+ * @description javascript execCommand
279
+ * @param command javascript execCommand function property
280
+ * @param showDefaultUI javascript execCommand function property
281
+ * @param value javascript execCommand function property
282
+ */
283
+ execCommand(command: string, showDefaultUI?: boolean, value?: string): void;
284
+
285
+ /**
286
+ * @description Focus to wysiwyg area using "native focus function"
287
+ */
288
+ nativeFocus(): void;
289
+
290
+ /**
291
+ * @description Focus to wysiwyg area
292
+ */
293
+ focus(): void;
294
+
295
+ /**
296
+ * @description If "focusEl" is a component, then that component is selected; if it is a format element, the last text is selected
297
+ * If "focusEdge" is null, then selected last element
298
+ * @param focusEl Focus element
299
+ */
300
+ focusEdge(focusEl: Element | null): void;
301
+
302
+ /**
303
+ * @description Focusout to wysiwyg area (.blur())
304
+ */
305
+ blur(): void;
306
+
307
+ /**
308
+ * @description Set current editor's range object and return.
309
+ * @param startCon The startContainer property of the selection object.
310
+ * @param startOff The startOffset property of the selection object.
311
+ * @param endCon The endContainer property of the selection object.
312
+ * @param endOff The endOffset property of the selection object.
313
+ * @returns
314
+ */
315
+ setRange(startCon: Node, startOff: number, endCon: Node, endOff: number): Range;
316
+
317
+ /**
318
+ * @description Remove range object and button effect
319
+ */
320
+ removeRange(): void;
321
+
322
+ /**
323
+ * @description Get current editor's range object
324
+ * @returns
325
+ */
326
+ getRange(): Range;
327
+
328
+ /**
329
+ * @description If the "range" object is a non-editable area, add a line at the top of the editor and update the "range" object.
330
+ * Returns a new "range" or argument "range".
331
+ * @param range core.getRange()
332
+ * @param container If there is "container" argument, it creates a line in front of the container.
333
+ */
334
+ getRange_addLine(range: Range, container?: Element): Range;
335
+
336
+ /**
337
+ * @description Get window selection obejct
338
+ * @returns
339
+ */
340
+ getSelection(): Selection;
341
+
342
+ /**
343
+ * @description Get current select node
344
+ * @returns
345
+ */
346
+ getSelectionNode(): Node;
347
+
348
+ /**
349
+ * @description Returns a "formatElement"(util.isFormatElement) array from the currently selected range.
350
+ * @param validation The validation function. (Replaces the default validation function-util.isFormatElement(current))
351
+ * @returns
352
+ */
353
+ getSelectedElements(validation?: Function): Node[];
354
+
355
+ /**
356
+ * @description Get format elements and components from the selected area. (P, DIV, H[1-6], OL, UL, TABLE..)
357
+ * If some of the component are included in the selection, get the entire that component.
358
+ * @param removeDuplicate If true, if there is a parent and child tag among the selected elements, the child tag is excluded.
359
+ * @returns
360
+ */
361
+ getSelectedElementsAndComponents(removeDuplicate: boolean): Node[];
362
+
363
+ /**
364
+ * @description Determine if this offset is the edge offset of container
365
+ * @param container The container property of the selection object.
366
+ * @param offset The offset property of the selection object.
367
+ * @param dir Select check point - Both edge, Front edge or End edge. ("front": Front edge, "end": End edge, undefined: Both edge)
368
+ * @returns
369
+ */
370
+ isEdgePoint(container: Node, offset: number, dir?: 'front' | 'end'): boolean;
371
+
372
+ /**
373
+ * @description Show loading box
374
+ */
375
+ showLoading(): void;
376
+
377
+ /**
378
+ * @description Close loading box
379
+ */
380
+ closeLoading(): void;
381
+
382
+ /**
383
+ * @description Append format element to sibling node of argument element.
384
+ * If the "formatNodeName" argument value is present, the tag of that argument value is inserted,
385
+ * If not, the currently selected format tag is inserted.
386
+ * @param element Insert as siblings of that element
387
+ * @param formatNode Node name or node obejct to be inserted
388
+ * @returns
389
+ */
390
+ appendFormatTag(element: Element, formatNode?: string | Element): Element;
391
+
392
+ /**
393
+ * @description The method to insert a element and return. (used elements : table, hr, image, video)
394
+ * If "element" is "HR", insert and return the new line.
395
+ * @param element Element to be inserted
396
+ * @param notHistoryPush When true, it does not update the history stack and the selection object and return EdgeNodes (util.getEdgeChildNodes)
397
+ * @param checkCharCount If true, if "options.maxCharCount" is exceeded when "element" is added, null is returned without addition.
398
+ * @param notSelect If true, Do not automatically select the inserted component.
399
+ * @returns
400
+ */
401
+ insertComponent(element: Element, notHistoryPush?: boolean, checkCharCount?: boolean, notSelect?:boolean): Element;
402
+
403
+ /**
404
+ * @description Gets the file component and that plugin name
405
+ * return: {target, component, pluginName} | null
406
+ * @param element Target element (figure tag, component div, file tag)
407
+ * @returns
408
+ */
409
+ getFileComponent(element: Element): seledtedFileInfo | null;
410
+
411
+ /**
412
+ * @description The component(image, video) is selected and the resizing module is called.
413
+ * @param element Element tag (img, iframe, video)
414
+ * @param pluginName Plugin name (image, video)
415
+ */
416
+ selectComponent(element: Element, pluginName: string): void;
417
+
418
+ /**
419
+ * @description Delete selected node and insert argument value node and return.
420
+ * If the "afterNode" exists, it is inserted after the "afterNode"
421
+ * Inserting a text node merges with both text nodes on both sides and returns a new "{ container, startOffset, endOffset }".
422
+ * @param oNode Element to be inserted
423
+ * @param afterNode If the node exists, it is inserted after the node
424
+ * @returns
425
+ */
426
+ insertNode(oNode: Node, afterNode?: Node, checkCharCount?: boolean): { startOffset: Node, endOffset: number } | Node | null;
427
+
428
+ /**
429
+ * @description Delete the currently selected nodes and reset selection range
430
+ * Returns {container: "the last element after deletion", offset: "offset", prevContainer: "previousElementSibling Of the deleted area"}
431
+ * @returns
432
+ */
433
+ removeNode(): { container: Node; offset: number; prevContainer?: Node };
434
+
435
+ /**
436
+ * @description Appended all selected format Element to the argument element and insert
437
+ * @param rangeElement Element of wrap the arguments (BLOCKQUOTE...)
438
+ */
439
+ applyRangeFormatElement(rangeElement: Element): void;
440
+
441
+ /**
442
+ * @description The elements of the "selectedFormats" array are detached from the "rangeElement" element. ("LI" tags are converted to "P" tags)
443
+ * When "selectedFormats" is null, all elements are detached and return {cc: parentNode, sc: nextSibling, ec: previousSibling, removeArray: [Array of removed elements]}.
444
+ * @param rangeElement Range format element (PRE, BLOCKQUOTE, OL, UL...)
445
+ * @param selectedFormats Array of format elements (P, DIV, LI...) to remove.
446
+ * If null, Applies to all elements and return {cc: parentNode, sc: nextSibling, ec: previousSibling}
447
+ * @param newRangeElement The node(rangeElement) to replace the currently wrapped node.
448
+ * @param remove If true, deleted without detached.
449
+ * @param notHistoryPush When true, it does not update the history stack and the selection object and return EdgeNodes (util.getEdgeChildNodes)
450
+ * @returns
451
+ */
452
+ detachRangeFormatElement(rangeElement: Element, selectedFormats: Element[] | null, newRangeElement: Element | null, remove: boolean, notHistoryPush: boolean): {cc: Node, sc: Node, ec: Node, removeArray: Element[]}
453
+
454
+ /**
455
+ * @description "selectedFormats" array are detached from the list element.
456
+ * The return value is applied when the first and last lines of "selectedFormats" are "LI" respectively.
457
+ * @param selectedFormats Array of format elements (LI, P...) to remove.
458
+ * @param remove If true, deleted without detached.
459
+ * @returns {sc: <LI>, ec: <LI>}.
460
+ */
461
+ detachList(selectedFormats: Element[], remove: boolean): {sc: Element, ec: Element};
462
+
463
+ /**
464
+ * @description Add, update, and delete nodes from selected text.
465
+ * 1. If there is a node in the "appendNode" argument, a node with the same tags and attributes as "appendNode" is added to the selection text.
466
+ * 2. If it is in the same tag, only the tag's attributes are changed without adding a tag.
467
+ * 3. If the "appendNode" argument is null, the node of the selection is update or remove without adding a new node.
468
+ * 4. The same style as the style attribute of the "styleArray" argument is deleted.
469
+ * (Styles should be put with attribute names from css. ["background-color"])
470
+ * 5. The same class name as the class attribute of the "styleArray" argument is deleted.
471
+ * (The class name is preceded by "." [".className"])
472
+ * 6. Use a list of styles and classes of "appendNode" in "styleArray" to avoid duplicate property values.
473
+ * 7. If a node with all styles and classes removed has the same tag name as "appendNode" or "removeNodeArray", or "appendNode" is null, that node is deleted.
474
+ * 8. Regardless of the style and class of the node, the tag with the same name as the "removeNodeArray" argument value is deleted.
475
+ * 9. If the "strictRemove" argument is true, only nodes with all styles and classes removed from the nodes of "removeNodeArray" are removed.
476
+ * 10. It won't work if the parent node has the same class and same value style.
477
+ * However, if there is a value in "removeNodeArray", it works and the text node is separated even if there is no node to replace.
478
+ * @param appendNode The element to be added to the selection. If it is null, only delete the node.
479
+ * @param styleArray The style or className attribute name Array to check (['font-size'], ['.className'], ['font-family', 'color', '.className']...])
480
+ * @param removeNodeArray An array of node names to remove types from, remove all formats when "appendNode" is null and there is an empty array or null value. (['span'], ['strong', 'em'] ...])
481
+ * @param strictRemove If true, only nodes with all styles and classes removed from the nodes of "removeNodeArray" are removed.
482
+ */
483
+ nodeChange(appendNode?: Element, styleArray?: string[], removeNodeArray?: string[], strictRemove?: boolean): void;
484
+
485
+ /**
486
+ * @description Run plugin calls and basic commands.
487
+ * @param command Command string
488
+ * @param display Display type string ('command', 'submenu', 'dialog', 'container')
489
+ * @param target The element of command button
490
+ */
491
+ actionCall(command: string, display: 'command' | 'submenu' | 'dialog' | 'container', target: Element): void;
492
+
493
+ /**
494
+ * @description Execute command of command button(All Buttons except submenu and dialog)
495
+ * (undo, redo, bold, underline, italic, strikethrough, subscript, superscript, removeFormat, indent, outdent, fullscreen, showBlocks, codeview, preview, print, copy, cut, paste)
496
+ * @param target The element of command button
497
+ * @param command Property of command button (data-value)
498
+ */
499
+ commandHandler(target: Element | null, command: commands): void;
500
+
501
+ /**
502
+ * @description Remove format of the currently selected range
503
+ */
504
+ removeFormat(): void;
505
+
506
+ /**
507
+ * @description This method implements indentation to selected range.
508
+ * Setted "margin-left" to "25px" in the top "P" tag of the parameter node.
509
+ * @param command Separator ("indent" or "outdent")
510
+ */
511
+ indent(command: 'indent' | 'outdent'): void;
512
+
513
+ /**
514
+ * @description Add or remove the class name of "body" so that the code block is visible
515
+ */
516
+ toggleDisplayBlocks(): void;
517
+
518
+ /**
519
+ * @description Changes to code view or wysiwyg view
520
+ */
521
+ toggleCodeView(): void;
522
+
523
+ /**
524
+ * @description Changes to full screen or default screen
525
+ * @param element full screen button
526
+ */
527
+ toggleFullScreen(element: Element | null): void;
528
+
529
+ /**
530
+ * @description Prints the current contents of the editor.
531
+ */
532
+ print(): void;
533
+
534
+ /**
535
+ * @description Open the preview window.
536
+ */
537
+ preview(): void;
538
+
539
+ /**
540
+ * @description Set direction to "rtl" or "ltr".
541
+ * @param dir "rtl" or "ltr"
542
+ */
543
+ setDir(dir: 'rtl' | 'ltr'): void;
544
+
545
+ /**
546
+ * @description Sets the HTML string
547
+ * @param html HTML string
548
+ */
549
+ setContents(html: string): void;
550
+
551
+ /**
552
+ * @description Sets the contents of the iframe's head tag and body tag when using the "iframe" or "fullPage" option.
553
+ * @param ctx { head: HTML string, body: HTML string}
554
+ */
555
+ setIframeContents(ctx: { head?: string, body?: string }): void;
556
+
557
+ /**
558
+ * @description Gets the current contents
559
+ * @param onlyContents Return only the contents of the body without headers when the "fullPage" option is true
560
+ * @returns
561
+ */
562
+ getContents(onlyContents: boolean): string;
563
+
564
+ /**
565
+ * @description Gets the current contents with containing parent div(div.sun-editor-editable).
566
+ * <div class="sun-editor-editable">{contents}</div>
567
+ * @param onlyContents Return only the contents of the body without headers when the "fullPage" option is true
568
+ * @returns
569
+ */
570
+ getFullContents(onlyContents: boolean): string;
571
+
572
+ /**
573
+ * @description Gets the clean HTML code for editor
574
+ * @param html HTML string
575
+ * @param whitelist Regular expression of allowed tags.
576
+ * RegExp object is create by util.createTagsWhitelist method. (core.pasteTagsWhitelistRegExp)
577
+ * @param blacklist Regular expression of disallowed tags.
578
+ * RegExp object is create by util.createTagsBlacklist method. (core.pasteTagsBlacklistRegExp)
579
+ * @returns
580
+ */
581
+ cleanHTML(html: string, whitelist?: string | RegExp, blacklist?: string | RegExp): string;
582
+
583
+ /**
584
+ * @description Converts contents into a format that can be placed in an editor
585
+ * @param contents contents
586
+ * @returns
587
+ */
588
+ convertContentsForEditor(contents: string): string;
589
+
590
+ /**
591
+ * @description Converts wysiwyg area element into a format that can be placed in an editor of code view mode
592
+ * @param html WYSIWYG element (context.element.wysiwyg) or HTML string.
593
+ * @param comp If true, does not line break and indentation of tags.
594
+ * @returns
595
+ */
596
+ convertHTMLForCodeView(html: Element | string, comp?: boolean): string;
597
+
598
+ /**
599
+ * @description Add an event to document.
600
+ * When created as an Iframe, the same event is added to the document in the Iframe.
601
+ * @param type Event type
602
+ * @param listener Event listener
603
+ * @param useCapture Use event capture
604
+ */
605
+ addDocEvent(type: string, listener: EventListener, useCapture: boolean): void;
606
+
607
+ /**
608
+ * @description Remove events from document.
609
+   * When created as an Iframe, the event of the document inside the Iframe is also removed.
610
+ * @param type Event type
611
+ * @param listener Event listener
612
+ */
613
+ removeDocEvent(type: string, listener: EventListener): void;
614
+
615
+ /**
616
+ * @description When "element" is added, if it is greater than "options.maxCharCount", false is returned.
617
+ * @param element Element node or String.
618
+ * @param charCounterType charCounterType. If it is null, the options.charCounterType
619
+ */
620
+ checkCharCount(element: Node | string, charCounterType?: string): boolean;
621
+
622
+ /**
623
+ * @description Get the length of the content.
624
+ * Depending on the option, the length of the character is taken. (charCounterType)
625
+ * @param content Content to count
626
+ * @param charCounterType options.charCounterType
627
+ */
628
+ getCharLength(content: string, charCounterType: string): number;
629
+ }
630
+
631
+ interface Toolbar {
632
+ /**
633
+ * @description Disable the toolbar
634
+ */
635
+ disable(): void;
636
+
637
+ /**
638
+ * @description Enable the toolbar
639
+ */
640
+ enable(): void;
641
+
642
+ /**
643
+ * @description Show the toolbar
644
+ */
645
+ show(): void;
646
+
647
+ /**
648
+ * @description Hide the toolbar
649
+ */
650
+ hide(): void;
651
+ }
652
+
653
+ interface Wysiwyg {
654
+ /**
655
+ * @description Disable the wysiwyg area
656
+ */
657
+ disable(): void;
658
+
659
+ /**
660
+ * @description Enable the wysiwyg area
661
+ */
662
+ enable(): void;
663
+ }
664
+
665
+ type EventFn = (e: Event, core: Core) => void;
666
+
667
+ type imageInputInformation = { linkValue: string, linkNewWindow: Window, inputWidth: number, inputHeight: number, align: string, isUpdate: boolean, element: any };
668
+ type videoInputInformation = { inputWidth: number, inputHeight: number, align: string, isUpdate: boolean, element: any };
669
+ type audioInputInformation = { isUpdate: boolean, element: any };
670
+
671
+ export default class SunEditor {
672
+ constructor(context: Context,
673
+ pluginCallButtons: Record<string, Element>,
674
+ plugins: Record<string, Plugin>,
675
+ lang: Lang,
676
+ options: SunEditorOptions,
677
+ _icons: Record<string, string>)
678
+
679
+ core: Core;
680
+ util: Util;
681
+
682
+ onload: (core: Core, reload: boolean) => void;
683
+ onScroll: EventFn;
684
+ onFocus: EventFn;
685
+ onMouseDown: EventFn;
686
+ onClick: EventFn;
687
+ onInput: EventFn;
688
+ onKeyDown: EventFn;
689
+ onKeyUp: EventFn;
690
+ onChange: (contents: string, core: Core) => void;
691
+ onBlur: (e: FocusEvent, core: Core) => void;
692
+ onDrop: (e: Event, cleanData: string, maxCharCount: number, core: Core) => boolean | string;
693
+ onPaste: (e: Event, cleanData: string, maxCharCount: number, core: Core) => boolean | string;
694
+ onCopy: (e: Event, clipboardData: any, core: Core) => boolean;
695
+ onCut: (e: Event, clipboardData: any, core: Core) => boolean;
696
+
697
+ /**
698
+ * @description Called just after the save was executed.
699
+ * @param contents Editor content
700
+ * @param core Core object
701
+ */
702
+ onSave: (contents: string, core: Core) => void;
703
+
704
+ /**
705
+ * @description Called just before the inline toolbar is positioned and displayed on the screen.
706
+ * @param toolbar Toolbar Element
707
+ * @param context The editor's context object (editor.getContext())
708
+ * @param core Core object
709
+ */
710
+ showInline: (toolbar: Element, context: Context, core: Core) => void;
711
+
712
+ /**
713
+ * @description Called just after the controller is positioned and displayed on the screen.
714
+ * controller - editing elements displayed on the screen [image resizing, table editor, link editor..]]
715
+ * @param name The name of the plugin that called the controller
716
+ * @param controllers Array of Controller elements
717
+ * @param core Core object
718
+ */
719
+ showController: (name: String, controllers: Controllers, core: Core) => void;
720
+
721
+ /**
722
+ * @description It replaces the default callback function of the image upload
723
+ * @param xmlHttp xmlHttpRequest object
724
+ * @param info Input information
725
+ * - linkValue: Link url value
726
+ * - linkNewWindow: Open in new window Check Value
727
+ * - inputWidth: Value of width input
728
+ * - inputHeight: Value of height input
729
+ * - align: Align Check Value
730
+ * - isUpdate: Update image if true, create image if false
731
+ * - element: If isUpdate is true, the currently selected image.
732
+ * @param core Core object
733
+ */
734
+ imageUploadHandler: (xmlHttp: XMLHttpRequest, info: imageInputInformation, core: Core) => void;
735
+
736
+ /**
737
+ * @description It replaces the default callback function of the video upload
738
+ * @param xmlHttp xmlHttpRequest object
739
+ * @param info Input information
740
+ * - inputWidth: Value of width input
741
+ * - inputHeight: Value of height input
742
+ * - align: Align Check Value
743
+ * - isUpdate: Update video if true, create video if false
744
+ * - element: If isUpdate is true, the currently selected video.
745
+ * @param core Core object
746
+ */
747
+ videoUploadHandler: (xmlHttp: XMLHttpRequest, info: videoInputInformation, core: Core) => void;
748
+
749
+ /**
750
+ * @description It replaces the default callback function of the audio upload
751
+ * @param xmlHttp xmlHttpRequest object
752
+ * @param info Input information
753
+ * - isUpdate: Update audio if true, create audio if false
754
+ * - element: If isUpdate is true, the currently selected audio.
755
+ * @param core Core object
756
+ */
757
+ audioUploadHandler: (xmlHttp: XMLHttpRequest, info: audioInputInformation, core: Core) => void;
758
+
759
+ /**
760
+ * @description An event when toggling between code view and wysiwyg view.
761
+ * @param isCodeView Whether the current code view mode
762
+ * @param core Core object
763
+ */
764
+ toggleCodeView: (isCodeView: boolean, core: Core) => void;
765
+
766
+ /**
767
+ * @description An event when toggling full screen.
768
+ * @param isFullScreen Whether the current full screen mode
769
+ * @param core Core object
770
+ */
771
+ toggleFullScreen: (isFullScreen: boolean, core: Core) => void;
772
+
773
+ /**
774
+ * @description Called before the image is uploaded
775
+ * If true is returned, the internal upload process runs normally.
776
+ * If false is returned, no image upload is performed.
777
+ * If new fileList are returned, replaced the previous fileList
778
+ * If undefined is returned, it waits until "uploadHandler" is executed.
779
+ * @param files Files array
780
+ * @param info Input information
781
+ * @param core Core object
782
+ * @param uploadHandler If undefined is returned, it waits until "uploadHandler" is executed.
783
+ * "uploadHandler" is an upload function with "core" and "info" bound.
784
+ * [upload files] : uploadHandler(files or [new File(...),])
785
+ * [error] : uploadHandler("Error message")
786
+ * [Just finish] : uploadHandler()
787
+ * [directly register] : uploadHandler(response) // Same format as "imageUploadUrl" response
788
+ * ex) {
789
+ * // "errorMessage": "insert error message",
790
+ * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
791
+ * }
792
+ * @returns
793
+ */
794
+ onImageUploadBefore: (files: any[], info: imageInputInformation, core: Core, uploadHandler: Function) => boolean | any[] | undefined;
795
+
796
+ /**
797
+ * @description Called before the video is uploaded
798
+ * If true is returned, the internal upload process runs normally.
799
+ * If false is returned, no video upload is performed.
800
+ * If new fileList are returned, replaced the previous fileList
801
+ * If undefined is returned, it waits until "uploadHandler" is executed.
802
+ * @param files Files array
803
+ * @param info Input information
804
+ * @param core Core object
805
+ * @param uploadHandler If undefined is returned, it waits until "uploadHandler" is executed.
806
+ * "uploadHandler" is an upload function with "core" and "info" bound.
807
+ * [upload files] : uploadHandler(files or [new File(...),])
808
+ * [error] : uploadHandler("Error message")
809
+ * [Just finish] : uploadHandler()
810
+ * [directly register] : uploadHandler(response) // Same format as "videoUploadUrl" response
811
+ * ex) {
812
+ * // "errorMessage": "insert error message",
813
+ * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
814
+ * }
815
+ * @returns
816
+ */
817
+ onVideoUploadBefore: (files: any[], info: videoInputInformation, core: Core, uploadHandler: Function) => boolean | any[] | undefined;
818
+
819
+ /**
820
+ * @description Called before the audio is uploaded
821
+ * If true is returned, the internal upload process runs normally.
822
+ * If false is returned, no audio upload is performed.
823
+ * If new fileList are returned, replaced the previous fileList
824
+ * If undefined is returned, it waits until "uploadHandler" is executed.
825
+ * @param files Files array
826
+ * @param info Input information
827
+ * @param core Core object
828
+ * @param uploadHandler If undefined is returned, it waits until "uploadHandler" is executed.
829
+ * "uploadHandler" is an upload function with "core" and "info" bound.
830
+ * [upload files] : uploadHandler(files or [new File(...),])
831
+ * [error] : uploadHandler("Error message")
832
+ * [Just finish] : uploadHandler()
833
+ * [directly register] : uploadHandler(response) // Same format as "audioUploadUrl" response
834
+ * ex) {
835
+ * // "errorMessage": "insert error message",
836
+ * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
837
+ * }
838
+ * @returns
839
+ */
840
+ onAudioUploadBefore: (files: any[], info: audioInputInformation, core: Core, uploadHandler: Function) => boolean | any[] | undefined;
841
+
842
+ /**
843
+ * @description Called when the image is uploaded, updated, deleted
844
+ * @param targetElement Target element
845
+ * @param index Uploaded index
846
+ * @param state Upload status ('create', 'update', 'delete')
847
+ * @param info Info object
848
+ * - index: data index
849
+ * - name: file name
850
+ * - size: file size
851
+ * - select: select function
852
+ * - delete: delete function
853
+ * - element: target element
854
+ * - src: src attribute of tag
855
+ * @param remainingFilesCount Count of remaining files to upload (0 when added as a url)
856
+ * @param core Core object
857
+ */
858
+ onImageUpload: (targetElement: HTMLImageElement, index: number, state: 'create' | 'update' | 'delete', info: fileInfo, remainingFilesCount: number, core: Core) => void;
859
+
860
+ /**
861
+ * @description Called when the video(iframe, video) is uploaded, updated, deleted
862
+ * @param targetElement Target element
863
+ * @param index Uploaded index
864
+ * @param state Upload status ('create', 'update', 'delete')
865
+ * @param info Info object
866
+ * - index: data index
867
+ * - name: file name
868
+ * - size: file size
869
+ * - select: select function
870
+ * - delete: delete function
871
+ * - element: target element
872
+ * - src: src attribute of tag
873
+ * @param remainingFilesCount Count of remaining files to upload (0 when added as a url)
874
+ * @param core Core object
875
+ */
876
+ onVideoUpload: (targetElement: HTMLIFrameElement | HTMLVideoElement, index: number, state: 'create' | 'update' | 'delete', info: fileInfo, remainingFilesCount: number, core: Core) => void;
877
+
878
+ /**
879
+ * @description Called when the audio is uploaded, updated, deleted
880
+ * @param targetElement Target element
881
+ * @param index Uploaded index
882
+ * @param state Upload status ('create', 'update', 'delete')
883
+ * @param info Info object
884
+ * - index: data index
885
+ * - name: file name
886
+ * - size: file size
887
+ * - select: select function
888
+ * - delete: delete function
889
+ * - element: target element
890
+ * - src: src attribute of tag
891
+ * @param remainingFilesCount Count of remaining files to upload (0 when added as a url)
892
+ * @param core Core object
893
+ */
894
+ onAudioUpload: (targetElement: HTMLAudioElement, index: number, state: 'create' | 'update' | 'delete', info: fileInfo, remainingFilesCount: number, core: Core) => void;
895
+
896
+ /**
897
+ * @description Called when the image is upload failed
898
+ * @param errorMessage Error message
899
+ * @param result Response Object
900
+ * @param core Core object
901
+ * @returns
902
+ */
903
+ onImageUploadError: (errorMessage: string, result: any, core: Core) => boolean;
904
+
905
+ /**
906
+ * @description Called when the video(iframe, video) upload failed
907
+ * @param errorMessage Error message
908
+ * @param result Response Object
909
+ * @param core Core object
910
+ * @returns
911
+ */
912
+ onVideoUploadError: (errorMessage: string, result: any, core: Core) => boolean;
913
+
914
+ /**
915
+ * @description Called when the audio upload failed
916
+ * @param errorMessage Error message
917
+ * @param result Response Object
918
+ * @param core Core object
919
+ * @returns
920
+ */
921
+ onAudioUploadError: (errorMessage: string, result: any, core: Core) => boolean;
922
+
923
+ /**
924
+ * @description Called when the audio upload failed
925
+ * @param height Height after resized (px)
926
+ * @param prevHeight Prev height before resized (px)
927
+ * @param core Core object
928
+ * @param resizeObserverEntry ResizeObserverEntry object (This is not provided in IE Browser.)
929
+ * @returns
930
+ */
931
+ onResizeEditor: (height: number, prevHeight: number, core: Core, resizeObserverEntry: ResizeObserverEntry | null) => {};
932
+
933
+ /**
934
+ * @description Called after the "setToolbarButtons" invocation.
935
+ * Can be used to tweak buttons properties (useful for custom buttons)
936
+ * @param buttonList Button list
937
+ * @param core Core object
938
+ */
939
+ onSetToolbarButtons: (buttonList: any[], core: Core) => void;
940
+
941
+ /**
942
+ * @description Reset the buttons on the toolbar. (Editor is not reloaded)
943
+ * You cannot set a new plugin for the button.
944
+ * @param buttonList Button list
945
+ */
946
+ setToolbarButtons(buttonList: any[]): void;
947
+
948
+ /**
949
+ * @description Add or reset option property
950
+ * @param options Options
951
+ */
952
+ setOptions(options: SunEditorOptions): void;
953
+
954
+ /**
955
+ * @description Set "options.defaultStyle" style.
956
+ * Define the style of the edit area
957
+ * It can also be defined with the "setOptions" method, but the "setDefaultStyle" method does not render the editor again.
958
+ * @param style Style string
959
+ */
960
+ setDefaultStyle(style: string): void;
961
+
962
+ /**
963
+ * @description Open a notice area
964
+ * @param message Notice message
965
+ */
966
+ noticeOpen(message: string): void;
967
+
968
+ /**
969
+ * @description Close a notice area
970
+ */
971
+ noticeClose(): void;
972
+
973
+ /**
974
+ * @description Copying the contents of the editor to the original textarea
975
+ */
976
+ save(): void;
977
+
978
+ /**
979
+ * @description Gets the suneditor's context object. Contains settings, plugins, and cached element objects
980
+ * @returns
981
+ */
982
+ getContext(): Context;
983
+
984
+ /**
985
+ * @description Gets the contents of the suneditor
986
+ * @param onlyContents - Return only the contents of the body without headers when the "fullPage" option is true
987
+ * @returns
988
+ */
989
+ getContents(onlyContents: boolean): string;
990
+
991
+ /**
992
+ * @description Gets only the text of the suneditor contents
993
+ * @returns
994
+ */
995
+ getText(): string;
996
+
997
+ /**
998
+ * @description Get the editor's number of characters or binary data size.
999
+ * You can use the "charCounterType" option format.
1000
+ * @param charCounterType options - charCounterType ('char', 'byte', 'byte-html')
1001
+ * If argument is no value, the currently set "charCounterType" option is used.
1002
+ * @returns
1003
+ */
1004
+ getCharCount(charCounterType?: string): number;
1005
+
1006
+ /**
1007
+ * @description Gets uploaded images informations
1008
+ * - index: data index
1009
+ * - name: file name
1010
+ * - size: file size
1011
+ * - select: select function
1012
+ * - delete: delete function
1013
+ * - element: img element
1014
+ * - src: src attribute of img tag
1015
+ * @returns
1016
+ */
1017
+ getImagesInfo(): fileInfo[];
1018
+
1019
+ /**
1020
+ * @description Gets uploaded files(plugin using fileManager) information list.
1021
+ * image: [img], video: [video, iframe], audio: [audio]
1022
+ * When the argument value is 'image', it is the same function as "getImagesInfo".
1023
+ * - index: data index
1024
+ * - name: file name
1025
+ * - size: file size
1026
+ * - select: select function
1027
+ * - delete: delete function
1028
+ * - element: img element
1029
+ * - src: src attribute of img tag
1030
+ * @param pluginName Plugin name (image, video, audio)
1031
+ * @returns
1032
+ */
1033
+ getFilesInfo(pluginName: string): fileInfo[];
1034
+
1035
+ /**
1036
+ * @description Upload images using image plugin
1037
+ * @param files FileList
1038
+ */
1039
+ insertImage(files: FileList): void;
1040
+
1041
+ /**
1042
+ * @description Inserts an HTML element or HTML string or plain string at the current cursor position
1043
+ * @param html HTML Element or HTML string or plain string
1044
+ * @param notCleaningData If true, inserts the HTML string without refining it with core.cleanHTML.
1045
+ * @param checkCharCount If true, if "options.maxCharCount" is exceeded when "element" is added, null is returned without addition.
1046
+ * @param rangeSelection If true, range select the inserted node.
1047
+ */
1048
+ insertHTML(html: Element | string, notCleaningData?: boolean, checkCharCount?: boolean, rangeSelection?: boolean): void;
1049
+
1050
+ /**
1051
+ * @description Change the contents of the suneditor
1052
+ * @param contents Contents to Input
1053
+ */
1054
+ setContents(contents: string): void;
1055
+
1056
+ /**
1057
+ * @description Add contents to the suneditor
1058
+ * @param contents Contents to Input
1059
+ */
1060
+ appendContents(contents: string): void;
1061
+
1062
+ /**
1063
+ * @description Switch to or off "ReadOnly" mode.
1064
+ * @param value "readOnly" boolean value.
1065
+ */
1066
+ readOnly(value: boolean): void;
1067
+
1068
+ /**
1069
+ * @description Disable the suneditor
1070
+ */
1071
+ disable(): void;
1072
+
1073
+ /**
1074
+ * @description Enable the suneditor
1075
+ */
1076
+ enable(): void;
1077
+
1078
+ /**
1079
+ * @description Show the suneditor
1080
+ */
1081
+ show(): void;
1082
+
1083
+ /**
1084
+ * @description Hide the suneditor
1085
+ */
1086
+ hide(): void;
1087
+
1088
+ /**
1089
+ * @description Destroy the suneditor
1090
+ */
1091
+ destroy(): void;
1092
+
1093
+ /**
1094
+ * @description Toolbar methods
1095
+ */
1096
+ toolbar: Toolbar;
1097
+
1098
+ /**
1099
+ * @description Wysiwyg methods
1100
+ */
1101
+ wysiwyg: Wysiwyg;
1102
1102
  }