suneditor 2.47.5 → 2.47.7

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 (141) hide show
  1. package/LICENSE.txt +20 -20
  2. package/README.md +1625 -1613
  3. package/dist/css/suneditor.min.css +1 -1
  4. package/dist/suneditor.min.js +2 -2
  5. package/example.md +586 -586
  6. package/package.json +71 -71
  7. package/src/assets/css/suneditor-contents.css +561 -561
  8. package/src/assets/css/suneditor.css +2 -2
  9. package/src/assets/defaultIcons.js +103 -103
  10. package/src/lang/Lang.d.ts +143 -143
  11. package/src/lang/ckb.d.ts +4 -4
  12. package/src/lang/ckb.js +187 -187
  13. package/src/lang/cs.d.ts +4 -4
  14. package/src/lang/cs.js +187 -187
  15. package/src/lang/da.d.ts +4 -4
  16. package/src/lang/da.js +191 -191
  17. package/src/lang/de.d.ts +4 -4
  18. package/src/lang/de.js +188 -188
  19. package/src/lang/en.d.ts +4 -4
  20. package/src/lang/en.js +187 -187
  21. package/src/lang/es.d.ts +4 -4
  22. package/src/lang/es.js +187 -187
  23. package/src/lang/fa.d.ts +4 -4
  24. package/src/lang/fa.js +187 -187
  25. package/src/lang/fr.d.ts +4 -4
  26. package/src/lang/fr.js +188 -188
  27. package/src/lang/he.d.ts +4 -4
  28. package/src/lang/he.js +188 -188
  29. package/src/lang/hu.d.ts +5 -5
  30. package/src/lang/hu.js +188 -188
  31. package/src/lang/index.d.ts +25 -24
  32. package/src/lang/index.js +30 -27
  33. package/src/lang/it.d.ts +4 -4
  34. package/src/lang/it.js +188 -188
  35. package/src/lang/ja.d.ts +4 -4
  36. package/src/lang/ja.js +187 -187
  37. package/src/lang/km.d.ts +5 -0
  38. package/src/lang/km.js +188 -0
  39. package/src/lang/ko.d.ts +4 -4
  40. package/src/lang/ko.js +187 -187
  41. package/src/lang/lv.d.ts +4 -4
  42. package/src/lang/lv.js +187 -187
  43. package/src/lang/nl.d.ts +4 -4
  44. package/src/lang/nl.js +187 -187
  45. package/src/lang/pl.d.ts +4 -4
  46. package/src/lang/pl.js +187 -187
  47. package/src/lang/pt_br.d.ts +4 -4
  48. package/src/lang/pt_br.js +189 -189
  49. package/src/lang/ro.d.ts +4 -4
  50. package/src/lang/ro.js +187 -187
  51. package/src/lang/ru.d.ts +4 -4
  52. package/src/lang/ru.js +187 -187
  53. package/src/lang/se.d.ts +4 -4
  54. package/src/lang/se.js +191 -191
  55. package/src/lang/tr.d.ts +5 -5
  56. package/src/lang/tr.js +191 -191
  57. package/src/lang/ua.d.ts +5 -5
  58. package/src/lang/ua.js +188 -188
  59. package/src/lang/ur.d.ts +4 -4
  60. package/src/lang/ur.js +187 -187
  61. package/src/lang/zh_cn.d.ts +4 -4
  62. package/src/lang/zh_cn.js +187 -187
  63. package/src/lib/constructor.js +0 -0
  64. package/src/lib/context.d.ts +42 -42
  65. package/src/lib/context.js +0 -0
  66. package/src/lib/core.d.ts +1135 -1135
  67. package/src/lib/core.js +9 -3
  68. package/src/lib/history.d.ts +48 -48
  69. package/src/lib/history.js +218 -218
  70. package/src/lib/util.d.ts +677 -677
  71. package/src/lib/util.js +1 -1
  72. package/src/options.d.ts +621 -620
  73. package/src/plugins/CommandPlugin.d.ts +7 -7
  74. package/src/plugins/DialogPlugin.d.ts +19 -19
  75. package/src/plugins/FileBrowserPlugin.d.ts +29 -29
  76. package/src/plugins/Module.d.ts +14 -14
  77. package/src/plugins/Plugin.d.ts +41 -41
  78. package/src/plugins/SubmenuPlugin.d.ts +7 -7
  79. package/src/plugins/command/blockquote.d.ts +4 -4
  80. package/src/plugins/command/blockquote.js +46 -46
  81. package/src/plugins/dialog/audio.d.ts +4 -4
  82. package/src/plugins/dialog/audio.js +557 -558
  83. package/src/plugins/dialog/image.d.ts +4 -4
  84. package/src/plugins/dialog/image.js +1126 -1127
  85. package/src/plugins/dialog/link.d.ts +4 -4
  86. package/src/plugins/dialog/link.js +223 -223
  87. package/src/plugins/dialog/math.d.ts +4 -4
  88. package/src/plugins/dialog/math.js +300 -300
  89. package/src/plugins/dialog/video.d.ts +4 -4
  90. package/src/plugins/dialog/video.js +989 -989
  91. package/src/plugins/fileBrowser/imageGallery.d.ts +4 -4
  92. package/src/plugins/fileBrowser/imageGallery.js +64 -64
  93. package/src/plugins/index.d.ts +79 -79
  94. package/src/plugins/index.js +32 -32
  95. package/src/plugins/modules/_anchor.js +461 -461
  96. package/src/plugins/modules/_colorPicker.d.ts +59 -59
  97. package/src/plugins/modules/_colorPicker.js +0 -0
  98. package/src/plugins/modules/_notice.d.ts +20 -20
  99. package/src/plugins/modules/_notice.js +72 -72
  100. package/src/plugins/modules/_selectMenu.js +118 -118
  101. package/src/plugins/modules/component.d.ts +24 -24
  102. package/src/plugins/modules/component.js +80 -80
  103. package/src/plugins/modules/dialog.d.ts +27 -27
  104. package/src/plugins/modules/dialog.js +174 -174
  105. package/src/plugins/modules/fileBrowser.d.ts +41 -41
  106. package/src/plugins/modules/fileBrowser.js +377 -377
  107. package/src/plugins/modules/fileManager.d.ts +66 -66
  108. package/src/plugins/modules/fileManager.js +325 -325
  109. package/src/plugins/modules/index.d.ts +10 -10
  110. package/src/plugins/modules/index.js +8 -8
  111. package/src/plugins/modules/resizing.d.ts +153 -153
  112. package/src/plugins/modules/resizing.js +902 -902
  113. package/src/plugins/submenu/align.d.ts +4 -4
  114. package/src/plugins/submenu/align.js +160 -160
  115. package/src/plugins/submenu/font.d.ts +4 -4
  116. package/src/plugins/submenu/font.js +123 -123
  117. package/src/plugins/submenu/fontColor.d.ts +4 -4
  118. package/src/plugins/submenu/fontColor.js +0 -0
  119. package/src/plugins/submenu/fontSize.d.ts +4 -4
  120. package/src/plugins/submenu/fontSize.js +112 -112
  121. package/src/plugins/submenu/formatBlock.d.ts +4 -4
  122. package/src/plugins/submenu/formatBlock.js +273 -273
  123. package/src/plugins/submenu/hiliteColor.d.ts +4 -4
  124. package/src/plugins/submenu/hiliteColor.js +0 -0
  125. package/src/plugins/submenu/horizontalRule.d.ts +4 -4
  126. package/src/plugins/submenu/horizontalRule.js +98 -98
  127. package/src/plugins/submenu/lineHeight.d.ts +4 -4
  128. package/src/plugins/submenu/lineHeight.js +104 -104
  129. package/src/plugins/submenu/list.d.ts +4 -4
  130. package/src/plugins/submenu/list.js +456 -456
  131. package/src/plugins/submenu/paragraphStyle.d.ts +4 -4
  132. package/src/plugins/submenu/paragraphStyle.js +135 -135
  133. package/src/plugins/submenu/table.d.ts +4 -4
  134. package/src/plugins/submenu/template.d.ts +4 -4
  135. package/src/plugins/submenu/template.js +71 -71
  136. package/src/plugins/submenu/textStyle.d.ts +4 -4
  137. package/src/plugins/submenu/textStyle.js +167 -167
  138. package/src/suneditor.d.ts +9 -9
  139. package/src/suneditor.js +75 -75
  140. package/src/suneditor_build.js +20 -17
  141. package/README_V3_TEMP.md +0 -630
package/src/lib/core.d.ts CHANGED
@@ -1,1136 +1,1136 @@
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
- onPasteMath: (e: Event, core: Core) => void;
697
-
698
- /**
699
- * @description Called just after the save was executed.
700
- * @param contents Editor content
701
- * @param core Core object
702
- */
703
- onSave: (contents: string, core: Core) => void;
704
-
705
- /**
706
- * @description Called just before the inline toolbar is positioned and displayed on the screen.
707
- * @param toolbar Toolbar Element
708
- * @param context The editor's context object (editor.getContext())
709
- * @param core Core object
710
- */
711
- showInline: (toolbar: Element, context: Context, core: Core) => void;
712
-
713
- /**
714
- * @description Called just after the controller is positioned and displayed on the screen.
715
- * controller - editing elements displayed on the screen [image resizing, table editor, link editor..]]
716
- * @param name The name of the plugin that called the controller
717
- * @param controllers Array of Controller elements
718
- * @param core Core object
719
- */
720
- showController: (name: String, controllers: Controllers, core: Core) => void;
721
-
722
- /**
723
- * @description It replaces the default callback function of the image upload
724
- * @param xmlHttp xmlHttpRequest object
725
- * @param info Input information
726
- * - linkValue: Link url value
727
- * - linkNewWindow: Open in new window Check Value
728
- * - inputWidth: Value of width input
729
- * - inputHeight: Value of height input
730
- * - align: Align Check Value
731
- * - isUpdate: Update image if true, create image if false
732
- * - element: If isUpdate is true, the currently selected image.
733
- * @param core Core object
734
- */
735
- imageUploadHandler: (xmlHttp: XMLHttpRequest, info: imageInputInformation, core: Core) => void;
736
-
737
- /**
738
- * @description It replaces the default callback function of the video upload
739
- * @param xmlHttp xmlHttpRequest object
740
- * @param info Input information
741
- * - inputWidth: Value of width input
742
- * - inputHeight: Value of height input
743
- * - align: Align Check Value
744
- * - isUpdate: Update video if true, create video if false
745
- * - element: If isUpdate is true, the currently selected video.
746
- * @param core Core object
747
- */
748
- videoUploadHandler: (xmlHttp: XMLHttpRequest, info: videoInputInformation, core: Core) => void;
749
-
750
- /**
751
- * @description It replaces the default callback function of the audio upload
752
- * @param xmlHttp xmlHttpRequest object
753
- * @param info Input information
754
- * - isUpdate: Update audio if true, create audio if false
755
- * - element: If isUpdate is true, the currently selected audio.
756
- * @param core Core object
757
- */
758
- audioUploadHandler: (xmlHttp: XMLHttpRequest, info: audioInputInformation, core: Core) => void;
759
-
760
- /**
761
- * @description An event when toggling between code view and wysiwyg view.
762
- * @param isCodeView Whether the current code view mode
763
- * @param core Core object
764
- */
765
- toggleCodeView: (isCodeView: boolean, core: Core) => void;
766
-
767
- /**
768
- * @description An event when toggling full screen.
769
- * @param isFullScreen Whether the current full screen mode
770
- * @param core Core object
771
- */
772
- toggleFullScreen: (isFullScreen: boolean, core: Core) => void;
773
-
774
- /**
775
- * @description Called before the image is uploaded
776
- * If true is returned, the internal upload process runs normally.
777
- * If false is returned, no image upload is performed.
778
- * If new fileList are returned, replaced the previous fileList
779
- * If undefined is returned, it waits until "uploadHandler" is executed.
780
- * @param files Files array
781
- * @param info Input information
782
- * @param core Core object
783
- * @param uploadHandler If undefined is returned, it waits until "uploadHandler" is executed.
784
- * "uploadHandler" is an upload function with "core" and "info" bound.
785
- * [upload files] : uploadHandler(files or [new File(...),])
786
- * [error] : uploadHandler("Error message")
787
- * [Just finish] : uploadHandler()
788
- * [directly register] : uploadHandler(response) // Same format as "imageUploadUrl" response
789
- * ex) {
790
- * // "errorMessage": "insert error message",
791
- * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
792
- * }
793
- * @returns
794
- */
795
- onImageUploadBefore: (files: any[], info: imageInputInformation, core: Core, uploadHandler: Function) => boolean | any[] | undefined;
796
-
797
- /**
798
- * @description Called before the video is uploaded
799
- * If true is returned, the internal upload process runs normally.
800
- * If false is returned, no video upload is performed.
801
- * If new fileList are returned, replaced the previous fileList
802
- * If undefined is returned, it waits until "uploadHandler" is executed.
803
- * @param files Files array
804
- * @param info Input information
805
- * @param core Core object
806
- * @param uploadHandler If undefined is returned, it waits until "uploadHandler" is executed.
807
- * "uploadHandler" is an upload function with "core" and "info" bound.
808
- * [upload files] : uploadHandler(files or [new File(...),])
809
- * [error] : uploadHandler("Error message")
810
- * [Just finish] : uploadHandler()
811
- * [directly register] : uploadHandler(response) // Same format as "videoUploadUrl" response
812
- * ex) {
813
- * // "errorMessage": "insert error message",
814
- * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
815
- * }
816
- * @returns
817
- */
818
- onVideoUploadBefore: (files: any[], info: videoInputInformation, core: Core, uploadHandler: Function) => boolean | any[] | undefined;
819
-
820
- /**
821
- * @description Called before the audio is uploaded
822
- * If true is returned, the internal upload process runs normally.
823
- * If false is returned, no audio upload is performed.
824
- * If new fileList are returned, replaced the previous fileList
825
- * If undefined is returned, it waits until "uploadHandler" is executed.
826
- * @param files Files array
827
- * @param info Input information
828
- * @param core Core object
829
- * @param uploadHandler If undefined is returned, it waits until "uploadHandler" is executed.
830
- * "uploadHandler" is an upload function with "core" and "info" bound.
831
- * [upload files] : uploadHandler(files or [new File(...),])
832
- * [error] : uploadHandler("Error message")
833
- * [Just finish] : uploadHandler()
834
- * [directly register] : uploadHandler(response) // Same format as "audioUploadUrl" response
835
- * ex) {
836
- * // "errorMessage": "insert error message",
837
- * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
838
- * }
839
- * @returns
840
- */
841
- onAudioUploadBefore: (files: any[], info: audioInputInformation, core: Core, uploadHandler: Function) => boolean | any[] | undefined;
842
-
843
- /**
844
- * @description Called when the image is uploaded, updated, deleted
845
- * @param targetElement Target element
846
- * @param index Uploaded index
847
- * @param state Upload status ('create', 'update', 'delete')
848
- * @param info Info object
849
- * - index: data index
850
- * - name: file name
851
- * - size: file size
852
- * - select: select function
853
- * - delete: delete function
854
- * - element: target element
855
- * - src: src attribute of tag
856
- * @param remainingFilesCount Count of remaining files to upload (0 when added as a url)
857
- * @param core Core object
858
- */
859
- onImageUpload: (targetElement: HTMLImageElement, index: number, state: 'create' | 'update' | 'delete', info: fileInfo, remainingFilesCount: number, core: Core) => void;
860
-
861
- /**
862
- * @description Called when the video(iframe, video) is uploaded, updated, deleted
863
- * @param targetElement Target element
864
- * @param index Uploaded index
865
- * @param state Upload status ('create', 'update', 'delete')
866
- * @param info Info object
867
- * - index: data index
868
- * - name: file name
869
- * - size: file size
870
- * - select: select function
871
- * - delete: delete function
872
- * - element: target element
873
- * - src: src attribute of tag
874
- * @param remainingFilesCount Count of remaining files to upload (0 when added as a url)
875
- * @param core Core object
876
- */
877
- onVideoUpload: (targetElement: HTMLIFrameElement | HTMLVideoElement, index: number, state: 'create' | 'update' | 'delete', info: fileInfo, remainingFilesCount: number, core: Core) => void;
878
-
879
- /**
880
- * @description Called when the audio is uploaded, updated, deleted
881
- * @param targetElement Target element
882
- * @param index Uploaded index
883
- * @param state Upload status ('create', 'update', 'delete')
884
- * @param info Info object
885
- * - index: data index
886
- * - name: file name
887
- * - size: file size
888
- * - select: select function
889
- * - delete: delete function
890
- * - element: target element
891
- * - src: src attribute of tag
892
- * @param remainingFilesCount Count of remaining files to upload (0 when added as a url)
893
- * @param core Core object
894
- */
895
- onAudioUpload: (targetElement: HTMLAudioElement, index: number, state: 'create' | 'update' | 'delete', info: fileInfo, remainingFilesCount: number, core: Core) => void;
896
-
897
- /**
898
- * @description Called when the image is upload failed
899
- * @param errorMessage Error message
900
- * @param result Response Object
901
- * @param core Core object
902
- * @returns
903
- */
904
- onImageUploadError: (errorMessage: string, result: any, core: Core) => boolean;
905
-
906
- /**
907
- * @description Called when the video(iframe, video) upload failed
908
- * @param errorMessage Error message
909
- * @param result Response Object
910
- * @param core Core object
911
- * @returns
912
- */
913
- onVideoUploadError: (errorMessage: string, result: any, core: Core) => boolean;
914
-
915
- /**
916
- * @description Called when the audio upload failed
917
- * @param errorMessage Error message
918
- * @param result Response Object
919
- * @param core Core object
920
- * @returns
921
- */
922
- onAudioUploadError: (errorMessage: string, result: any, core: Core) => boolean;
923
-
924
- /**
925
- * @description Called when the audio image delete before.
926
- * "false" is returned, the event will be aborted.
927
- * @param targetElement target element
928
- * @param container target's container
929
- * @param dataIndex target's dataIndex
930
- * @param core Core object
931
- * @returns {boolean|undefined}
932
- */
933
- onAudioDeleteBefore: (targetElement: Element, container: Element, dataIndex: number, core: Core) => boolean;
934
-
935
- /**
936
- * @description Called when the image image delete before.
937
- * "false" is returned, the event will be aborted.
938
- * @param targetElement target element
939
- * @param container target's container
940
- * @param dataIndex target's dataIndex
941
- * @param core Core object
942
- * @returns {boolean|undefined}
943
- */
944
- onImageDeleteBefore: (targetElement: Element, container: Element, dataIndex: number, core: Core) => boolean;
945
-
946
- /**
947
- * @description Called when the image image delete before.
948
- * "false" is returned, the event will be aborted.
949
- * @param targetElement target element
950
- * @param container target's container
951
- * @param dataIndex target's dataIndex
952
- * @param core Core object
953
- * @returns {boolean|undefined}
954
- */
955
- onVideoDeleteBefore: (targetElement: Element, container: Element, dataIndex: number, core: Core) => boolean;
956
-
957
- /**
958
- * @description Called when the audio upload failed
959
- * @param height Height after resized (px)
960
- * @param prevHeight Prev height before resized (px)
961
- * @param core Core object
962
- * @param resizeObserverEntry ResizeObserverEntry object (This is not provided in IE Browser.)
963
- * @returns
964
- */
965
- onResizeEditor: (height: number, prevHeight: number, core: Core, resizeObserverEntry: ResizeObserverEntry | null) => {};
966
-
967
- /**
968
- * @description Called after the "setToolbarButtons" invocation.
969
- * Can be used to tweak buttons properties (useful for custom buttons)
970
- * @param buttonList Button list
971
- * @param core Core object
972
- */
973
- onSetToolbarButtons: (buttonList: any[], core: Core) => void;
974
-
975
- /**
976
- * @description Reset the buttons on the toolbar. (Editor is not reloaded)
977
- * You cannot set a new plugin for the button.
978
- * @param buttonList Button list
979
- */
980
- setToolbarButtons(buttonList: any[]): void;
981
-
982
- /**
983
- * @description Add or reset option property
984
- * @param options Options
985
- */
986
- setOptions(options: SunEditorOptions): void;
987
-
988
- /**
989
- * @description Set "options.defaultStyle" style.
990
- * Define the style of the edit area
991
- * It can also be defined with the "setOptions" method, but the "setDefaultStyle" method does not render the editor again.
992
- * @param style Style string
993
- */
994
- setDefaultStyle(style: string): void;
995
-
996
- /**
997
- * @description Open a notice area
998
- * @param message Notice message
999
- */
1000
- noticeOpen(message: string): void;
1001
-
1002
- /**
1003
- * @description Close a notice area
1004
- */
1005
- noticeClose(): void;
1006
-
1007
- /**
1008
- * @description Copying the contents of the editor to the original textarea
1009
- */
1010
- save(): void;
1011
-
1012
- /**
1013
- * @description Gets the suneditor's context object. Contains settings, plugins, and cached element objects
1014
- * @returns
1015
- */
1016
- getContext(): Context;
1017
-
1018
- /**
1019
- * @description Gets the contents of the suneditor
1020
- * @param onlyContents - Return only the contents of the body without headers when the "fullPage" option is true
1021
- * @returns
1022
- */
1023
- getContents(onlyContents: boolean): string;
1024
-
1025
- /**
1026
- * @description Gets only the text of the suneditor contents
1027
- * @returns
1028
- */
1029
- getText(): string;
1030
-
1031
- /**
1032
- * @description Get the editor's number of characters or binary data size.
1033
- * You can use the "charCounterType" option format.
1034
- * @param charCounterType options - charCounterType ('char', 'byte', 'byte-html')
1035
- * If argument is no value, the currently set "charCounterType" option is used.
1036
- * @returns
1037
- */
1038
- getCharCount(charCounterType?: string): number;
1039
-
1040
- /**
1041
- * @description Gets uploaded images informations
1042
- * - index: data index
1043
- * - name: file name
1044
- * - size: file size
1045
- * - select: select function
1046
- * - delete: delete function
1047
- * - element: img element
1048
- * - src: src attribute of img tag
1049
- * @returns
1050
- */
1051
- getImagesInfo(): fileInfo[];
1052
-
1053
- /**
1054
- * @description Gets uploaded files(plugin using fileManager) information list.
1055
- * image: [img], video: [video, iframe], audio: [audio]
1056
- * When the argument value is 'image', it is the same function as "getImagesInfo".
1057
- * - index: data index
1058
- * - name: file name
1059
- * - size: file size
1060
- * - select: select function
1061
- * - delete: delete function
1062
- * - element: img element
1063
- * - src: src attribute of img tag
1064
- * @param pluginName Plugin name (image, video, audio)
1065
- * @returns
1066
- */
1067
- getFilesInfo(pluginName: string): fileInfo[];
1068
-
1069
- /**
1070
- * @description Upload images using image plugin
1071
- * @param files FileList
1072
- */
1073
- insertImage(files: FileList): void;
1074
-
1075
- /**
1076
- * @description Inserts an HTML element or HTML string or plain string at the current cursor position
1077
- * @param html HTML Element or HTML string or plain string
1078
- * @param notCleaningData If true, inserts the HTML string without refining it with core.cleanHTML.
1079
- * @param checkCharCount If true, if "options.maxCharCount" is exceeded when "element" is added, null is returned without addition.
1080
- * @param rangeSelection If true, range select the inserted node.
1081
- */
1082
- insertHTML(html: Element | string, notCleaningData?: boolean, checkCharCount?: boolean, rangeSelection?: boolean): void;
1083
-
1084
- /**
1085
- * @description Change the contents of the suneditor
1086
- * @param contents Contents to Input
1087
- */
1088
- setContents(contents: string): void;
1089
-
1090
- /**
1091
- * @description Add contents to the suneditor
1092
- * @param contents Contents to Input
1093
- */
1094
- appendContents(contents: string): void;
1095
-
1096
- /**
1097
- * @description Switch to or off "ReadOnly" mode.
1098
- * @param value "readOnly" boolean value.
1099
- */
1100
- readOnly(value: boolean): void;
1101
-
1102
- /**
1103
- * @description Disable the suneditor
1104
- */
1105
- disable(): void;
1106
-
1107
- /**
1108
- * @description Enable the suneditor
1109
- */
1110
- enable(): void;
1111
-
1112
- /**
1113
- * @description Show the suneditor
1114
- */
1115
- show(): void;
1116
-
1117
- /**
1118
- * @description Hide the suneditor
1119
- */
1120
- hide(): void;
1121
-
1122
- /**
1123
- * @description Destroy the suneditor
1124
- */
1125
- destroy(): void;
1126
-
1127
- /**
1128
- * @description Toolbar methods
1129
- */
1130
- toolbar: Toolbar;
1131
-
1132
- /**
1133
- * @description Wysiwyg methods
1134
- */
1135
- 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
+ onPasteMath: (e: Event, core: Core) => void;
697
+
698
+ /**
699
+ * @description Called just after the save was executed.
700
+ * @param contents Editor content
701
+ * @param core Core object
702
+ */
703
+ onSave: (contents: string, core: Core) => void;
704
+
705
+ /**
706
+ * @description Called just before the inline toolbar is positioned and displayed on the screen.
707
+ * @param toolbar Toolbar Element
708
+ * @param context The editor's context object (editor.getContext())
709
+ * @param core Core object
710
+ */
711
+ showInline: (toolbar: Element, context: Context, core: Core) => void;
712
+
713
+ /**
714
+ * @description Called just after the controller is positioned and displayed on the screen.
715
+ * controller - editing elements displayed on the screen [image resizing, table editor, link editor..]]
716
+ * @param name The name of the plugin that called the controller
717
+ * @param controllers Array of Controller elements
718
+ * @param core Core object
719
+ */
720
+ showController: (name: String, controllers: Controllers, core: Core) => void;
721
+
722
+ /**
723
+ * @description It replaces the default callback function of the image upload
724
+ * @param xmlHttp xmlHttpRequest object
725
+ * @param info Input information
726
+ * - linkValue: Link url value
727
+ * - linkNewWindow: Open in new window Check Value
728
+ * - inputWidth: Value of width input
729
+ * - inputHeight: Value of height input
730
+ * - align: Align Check Value
731
+ * - isUpdate: Update image if true, create image if false
732
+ * - element: If isUpdate is true, the currently selected image.
733
+ * @param core Core object
734
+ */
735
+ imageUploadHandler: (xmlHttp: XMLHttpRequest, info: imageInputInformation, core: Core) => void;
736
+
737
+ /**
738
+ * @description It replaces the default callback function of the video upload
739
+ * @param xmlHttp xmlHttpRequest object
740
+ * @param info Input information
741
+ * - inputWidth: Value of width input
742
+ * - inputHeight: Value of height input
743
+ * - align: Align Check Value
744
+ * - isUpdate: Update video if true, create video if false
745
+ * - element: If isUpdate is true, the currently selected video.
746
+ * @param core Core object
747
+ */
748
+ videoUploadHandler: (xmlHttp: XMLHttpRequest, info: videoInputInformation, core: Core) => void;
749
+
750
+ /**
751
+ * @description It replaces the default callback function of the audio upload
752
+ * @param xmlHttp xmlHttpRequest object
753
+ * @param info Input information
754
+ * - isUpdate: Update audio if true, create audio if false
755
+ * - element: If isUpdate is true, the currently selected audio.
756
+ * @param core Core object
757
+ */
758
+ audioUploadHandler: (xmlHttp: XMLHttpRequest, info: audioInputInformation, core: Core) => void;
759
+
760
+ /**
761
+ * @description An event when toggling between code view and wysiwyg view.
762
+ * @param isCodeView Whether the current code view mode
763
+ * @param core Core object
764
+ */
765
+ toggleCodeView: (isCodeView: boolean, core: Core) => void;
766
+
767
+ /**
768
+ * @description An event when toggling full screen.
769
+ * @param isFullScreen Whether the current full screen mode
770
+ * @param core Core object
771
+ */
772
+ toggleFullScreen: (isFullScreen: boolean, core: Core) => void;
773
+
774
+ /**
775
+ * @description Called before the image is uploaded
776
+ * If true is returned, the internal upload process runs normally.
777
+ * If false is returned, no image upload is performed.
778
+ * If new fileList are returned, replaced the previous fileList
779
+ * If undefined is returned, it waits until "uploadHandler" is executed.
780
+ * @param files Files array
781
+ * @param info Input information
782
+ * @param core Core object
783
+ * @param uploadHandler If undefined is returned, it waits until "uploadHandler" is executed.
784
+ * "uploadHandler" is an upload function with "core" and "info" bound.
785
+ * [upload files] : uploadHandler(files or [new File(...),])
786
+ * [error] : uploadHandler("Error message")
787
+ * [Just finish] : uploadHandler()
788
+ * [directly register] : uploadHandler(response) // Same format as "imageUploadUrl" response
789
+ * ex) {
790
+ * // "errorMessage": "insert error message",
791
+ * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
792
+ * }
793
+ * @returns
794
+ */
795
+ onImageUploadBefore: (files: any[], info: imageInputInformation, core: Core, uploadHandler: Function) => boolean | any[] | undefined;
796
+
797
+ /**
798
+ * @description Called before the video is uploaded
799
+ * If true is returned, the internal upload process runs normally.
800
+ * If false is returned, no video upload is performed.
801
+ * If new fileList are returned, replaced the previous fileList
802
+ * If undefined is returned, it waits until "uploadHandler" is executed.
803
+ * @param files Files array
804
+ * @param info Input information
805
+ * @param core Core object
806
+ * @param uploadHandler If undefined is returned, it waits until "uploadHandler" is executed.
807
+ * "uploadHandler" is an upload function with "core" and "info" bound.
808
+ * [upload files] : uploadHandler(files or [new File(...),])
809
+ * [error] : uploadHandler("Error message")
810
+ * [Just finish] : uploadHandler()
811
+ * [directly register] : uploadHandler(response) // Same format as "videoUploadUrl" response
812
+ * ex) {
813
+ * // "errorMessage": "insert error message",
814
+ * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
815
+ * }
816
+ * @returns
817
+ */
818
+ onVideoUploadBefore: (files: any[], info: videoInputInformation, core: Core, uploadHandler: Function) => boolean | any[] | undefined;
819
+
820
+ /**
821
+ * @description Called before the audio is uploaded
822
+ * If true is returned, the internal upload process runs normally.
823
+ * If false is returned, no audio upload is performed.
824
+ * If new fileList are returned, replaced the previous fileList
825
+ * If undefined is returned, it waits until "uploadHandler" is executed.
826
+ * @param files Files array
827
+ * @param info Input information
828
+ * @param core Core object
829
+ * @param uploadHandler If undefined is returned, it waits until "uploadHandler" is executed.
830
+ * "uploadHandler" is an upload function with "core" and "info" bound.
831
+ * [upload files] : uploadHandler(files or [new File(...),])
832
+ * [error] : uploadHandler("Error message")
833
+ * [Just finish] : uploadHandler()
834
+ * [directly register] : uploadHandler(response) // Same format as "audioUploadUrl" response
835
+ * ex) {
836
+ * // "errorMessage": "insert error message",
837
+ * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
838
+ * }
839
+ * @returns
840
+ */
841
+ onAudioUploadBefore: (files: any[], info: audioInputInformation, core: Core, uploadHandler: Function) => boolean | any[] | undefined;
842
+
843
+ /**
844
+ * @description Called when the image is uploaded, updated, deleted
845
+ * @param targetElement Target element
846
+ * @param index Uploaded index
847
+ * @param state Upload status ('create', 'update', 'delete')
848
+ * @param info Info object
849
+ * - index: data index
850
+ * - name: file name
851
+ * - size: file size
852
+ * - select: select function
853
+ * - delete: delete function
854
+ * - element: target element
855
+ * - src: src attribute of tag
856
+ * @param remainingFilesCount Count of remaining files to upload (0 when added as a url)
857
+ * @param core Core object
858
+ */
859
+ onImageUpload: (targetElement: HTMLImageElement, index: number, state: 'create' | 'update' | 'delete', info: fileInfo, remainingFilesCount: number, core: Core) => void;
860
+
861
+ /**
862
+ * @description Called when the video(iframe, video) is uploaded, updated, deleted
863
+ * @param targetElement Target element
864
+ * @param index Uploaded index
865
+ * @param state Upload status ('create', 'update', 'delete')
866
+ * @param info Info object
867
+ * - index: data index
868
+ * - name: file name
869
+ * - size: file size
870
+ * - select: select function
871
+ * - delete: delete function
872
+ * - element: target element
873
+ * - src: src attribute of tag
874
+ * @param remainingFilesCount Count of remaining files to upload (0 when added as a url)
875
+ * @param core Core object
876
+ */
877
+ onVideoUpload: (targetElement: HTMLIFrameElement | HTMLVideoElement, index: number, state: 'create' | 'update' | 'delete', info: fileInfo, remainingFilesCount: number, core: Core) => void;
878
+
879
+ /**
880
+ * @description Called when the audio is uploaded, updated, deleted
881
+ * @param targetElement Target element
882
+ * @param index Uploaded index
883
+ * @param state Upload status ('create', 'update', 'delete')
884
+ * @param info Info object
885
+ * - index: data index
886
+ * - name: file name
887
+ * - size: file size
888
+ * - select: select function
889
+ * - delete: delete function
890
+ * - element: target element
891
+ * - src: src attribute of tag
892
+ * @param remainingFilesCount Count of remaining files to upload (0 when added as a url)
893
+ * @param core Core object
894
+ */
895
+ onAudioUpload: (targetElement: HTMLAudioElement, index: number, state: 'create' | 'update' | 'delete', info: fileInfo, remainingFilesCount: number, core: Core) => void;
896
+
897
+ /**
898
+ * @description Called when the image is upload failed
899
+ * @param errorMessage Error message
900
+ * @param result Response Object
901
+ * @param core Core object
902
+ * @returns
903
+ */
904
+ onImageUploadError: (errorMessage: string, result: any, core: Core) => boolean;
905
+
906
+ /**
907
+ * @description Called when the video(iframe, video) upload failed
908
+ * @param errorMessage Error message
909
+ * @param result Response Object
910
+ * @param core Core object
911
+ * @returns
912
+ */
913
+ onVideoUploadError: (errorMessage: string, result: any, core: Core) => boolean;
914
+
915
+ /**
916
+ * @description Called when the audio upload failed
917
+ * @param errorMessage Error message
918
+ * @param result Response Object
919
+ * @param core Core object
920
+ * @returns
921
+ */
922
+ onAudioUploadError: (errorMessage: string, result: any, core: Core) => boolean;
923
+
924
+ /**
925
+ * @description Called when the audio image delete before.
926
+ * "false" is returned, the event will be aborted.
927
+ * @param targetElement target element
928
+ * @param container target's container
929
+ * @param dataIndex target's dataIndex
930
+ * @param core Core object
931
+ * @returns {boolean|undefined}
932
+ */
933
+ onAudioDeleteBefore: (targetElement: Element, container: Element, dataIndex: number, core: Core) => boolean;
934
+
935
+ /**
936
+ * @description Called when the image image delete before.
937
+ * "false" is returned, the event will be aborted.
938
+ * @param targetElement target element
939
+ * @param container target's container
940
+ * @param dataIndex target's dataIndex
941
+ * @param core Core object
942
+ * @returns {boolean|undefined}
943
+ */
944
+ onImageDeleteBefore: (targetElement: Element, container: Element, dataIndex: number, core: Core) => boolean;
945
+
946
+ /**
947
+ * @description Called when the image image delete before.
948
+ * "false" is returned, the event will be aborted.
949
+ * @param targetElement target element
950
+ * @param container target's container
951
+ * @param dataIndex target's dataIndex
952
+ * @param core Core object
953
+ * @returns {boolean|undefined}
954
+ */
955
+ onVideoDeleteBefore: (targetElement: Element, container: Element, dataIndex: number, core: Core) => boolean;
956
+
957
+ /**
958
+ * @description Called when the audio upload failed
959
+ * @param height Height after resized (px)
960
+ * @param prevHeight Prev height before resized (px)
961
+ * @param core Core object
962
+ * @param resizeObserverEntry ResizeObserverEntry object (This is not provided in IE Browser.)
963
+ * @returns
964
+ */
965
+ onResizeEditor: (height: number, prevHeight: number, core: Core, resizeObserverEntry: ResizeObserverEntry | null) => {};
966
+
967
+ /**
968
+ * @description Called after the "setToolbarButtons" invocation.
969
+ * Can be used to tweak buttons properties (useful for custom buttons)
970
+ * @param buttonList Button list
971
+ * @param core Core object
972
+ */
973
+ onSetToolbarButtons: (buttonList: any[], core: Core) => void;
974
+
975
+ /**
976
+ * @description Reset the buttons on the toolbar. (Editor is not reloaded)
977
+ * You cannot set a new plugin for the button.
978
+ * @param buttonList Button list
979
+ */
980
+ setToolbarButtons(buttonList: any[]): void;
981
+
982
+ /**
983
+ * @description Add or reset option property
984
+ * @param options Options
985
+ */
986
+ setOptions(options: SunEditorOptions): void;
987
+
988
+ /**
989
+ * @description Set "options.defaultStyle" style.
990
+ * Define the style of the edit area
991
+ * It can also be defined with the "setOptions" method, but the "setDefaultStyle" method does not render the editor again.
992
+ * @param style Style string
993
+ */
994
+ setDefaultStyle(style: string): void;
995
+
996
+ /**
997
+ * @description Open a notice area
998
+ * @param message Notice message
999
+ */
1000
+ noticeOpen(message: string): void;
1001
+
1002
+ /**
1003
+ * @description Close a notice area
1004
+ */
1005
+ noticeClose(): void;
1006
+
1007
+ /**
1008
+ * @description Copying the contents of the editor to the original textarea
1009
+ */
1010
+ save(): void;
1011
+
1012
+ /**
1013
+ * @description Gets the suneditor's context object. Contains settings, plugins, and cached element objects
1014
+ * @returns
1015
+ */
1016
+ getContext(): Context;
1017
+
1018
+ /**
1019
+ * @description Gets the contents of the suneditor
1020
+ * @param onlyContents - Return only the contents of the body without headers when the "fullPage" option is true
1021
+ * @returns
1022
+ */
1023
+ getContents(onlyContents: boolean): string;
1024
+
1025
+ /**
1026
+ * @description Gets only the text of the suneditor contents
1027
+ * @returns
1028
+ */
1029
+ getText(): string;
1030
+
1031
+ /**
1032
+ * @description Get the editor's number of characters or binary data size.
1033
+ * You can use the "charCounterType" option format.
1034
+ * @param charCounterType options - charCounterType ('char', 'byte', 'byte-html')
1035
+ * If argument is no value, the currently set "charCounterType" option is used.
1036
+ * @returns
1037
+ */
1038
+ getCharCount(charCounterType?: string): number;
1039
+
1040
+ /**
1041
+ * @description Gets uploaded images informations
1042
+ * - index: data index
1043
+ * - name: file name
1044
+ * - size: file size
1045
+ * - select: select function
1046
+ * - delete: delete function
1047
+ * - element: img element
1048
+ * - src: src attribute of img tag
1049
+ * @returns
1050
+ */
1051
+ getImagesInfo(): fileInfo[];
1052
+
1053
+ /**
1054
+ * @description Gets uploaded files(plugin using fileManager) information list.
1055
+ * image: [img], video: [video, iframe], audio: [audio]
1056
+ * When the argument value is 'image', it is the same function as "getImagesInfo".
1057
+ * - index: data index
1058
+ * - name: file name
1059
+ * - size: file size
1060
+ * - select: select function
1061
+ * - delete: delete function
1062
+ * - element: img element
1063
+ * - src: src attribute of img tag
1064
+ * @param pluginName Plugin name (image, video, audio)
1065
+ * @returns
1066
+ */
1067
+ getFilesInfo(pluginName: string): fileInfo[];
1068
+
1069
+ /**
1070
+ * @description Upload images using image plugin
1071
+ * @param files FileList
1072
+ */
1073
+ insertImage(files: FileList): void;
1074
+
1075
+ /**
1076
+ * @description Inserts an HTML element or HTML string or plain string at the current cursor position
1077
+ * @param html HTML Element or HTML string or plain string
1078
+ * @param notCleaningData If true, inserts the HTML string without refining it with core.cleanHTML.
1079
+ * @param checkCharCount If true, if "options.maxCharCount" is exceeded when "element" is added, null is returned without addition.
1080
+ * @param rangeSelection If true, range select the inserted node.
1081
+ */
1082
+ insertHTML(html: Element | string, notCleaningData?: boolean, checkCharCount?: boolean, rangeSelection?: boolean): void;
1083
+
1084
+ /**
1085
+ * @description Change the contents of the suneditor
1086
+ * @param contents Contents to Input
1087
+ */
1088
+ setContents(contents: string): void;
1089
+
1090
+ /**
1091
+ * @description Add contents to the suneditor
1092
+ * @param contents Contents to Input
1093
+ */
1094
+ appendContents(contents: string): void;
1095
+
1096
+ /**
1097
+ * @description Switch to or off "ReadOnly" mode.
1098
+ * @param value "readOnly" boolean value.
1099
+ */
1100
+ readOnly(value: boolean): void;
1101
+
1102
+ /**
1103
+ * @description Disable the suneditor
1104
+ */
1105
+ disable(): void;
1106
+
1107
+ /**
1108
+ * @description Enable the suneditor
1109
+ */
1110
+ enable(): void;
1111
+
1112
+ /**
1113
+ * @description Show the suneditor
1114
+ */
1115
+ show(): void;
1116
+
1117
+ /**
1118
+ * @description Hide the suneditor
1119
+ */
1120
+ hide(): void;
1121
+
1122
+ /**
1123
+ * @description Destroy the suneditor
1124
+ */
1125
+ destroy(): void;
1126
+
1127
+ /**
1128
+ * @description Toolbar methods
1129
+ */
1130
+ toolbar: Toolbar;
1131
+
1132
+ /**
1133
+ * @description Wysiwyg methods
1134
+ */
1135
+ wysiwyg: Wysiwyg;
1136
1136
  }