suneditor 3.0.0-alpha.9 → 3.0.0-beta.2

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 (315) hide show
  1. package/CONTRIBUTING.md +170 -22
  2. package/{LICENSE.txt → LICENSE} +9 -9
  3. package/README.md +168 -30
  4. package/dist/suneditor.min.css +1 -1
  5. package/dist/suneditor.min.js +1 -1
  6. package/package.json +47 -21
  7. package/src/assets/design/color.css +121 -0
  8. package/src/assets/design/index.css +3 -0
  9. package/src/assets/design/size.css +35 -0
  10. package/src/assets/design/typography.css +37 -0
  11. package/src/assets/icons/defaultIcons.js +232 -0
  12. package/src/assets/suneditor-contents.css +181 -46
  13. package/src/assets/suneditor.css +1403 -650
  14. package/src/core/base/eventHandlers/handler_toolbar.js +35 -14
  15. package/src/core/base/eventHandlers/handler_ww_clipboard.js +23 -4
  16. package/src/core/base/eventHandlers/handler_ww_dragDrop.js +49 -10
  17. package/src/core/base/eventHandlers/handler_ww_key_input.js +422 -224
  18. package/src/core/base/eventHandlers/handler_ww_mouse.js +83 -36
  19. package/src/core/base/eventManager.js +520 -179
  20. package/src/core/base/history.js +95 -41
  21. package/src/core/class/char.js +26 -11
  22. package/src/core/class/component.js +345 -137
  23. package/src/core/class/format.js +683 -519
  24. package/src/core/class/html.js +485 -305
  25. package/src/core/class/menu.js +133 -47
  26. package/src/core/class/nodeTransform.js +90 -71
  27. package/src/core/class/offset.js +408 -92
  28. package/src/core/class/selection.js +216 -106
  29. package/src/core/class/shortcuts.js +68 -8
  30. package/src/core/class/toolbar.js +106 -116
  31. package/src/core/class/ui.js +422 -0
  32. package/src/core/class/viewer.js +178 -74
  33. package/src/core/editor.js +496 -389
  34. package/src/core/section/actives.js +123 -27
  35. package/src/core/section/constructor.js +615 -206
  36. package/src/core/section/context.js +28 -23
  37. package/src/core/section/documentType.js +561 -0
  38. package/src/editorInjector/_classes.js +19 -5
  39. package/src/editorInjector/_core.js +71 -7
  40. package/src/editorInjector/index.js +63 -1
  41. package/src/events.js +622 -0
  42. package/src/helper/clipboard.js +59 -0
  43. package/src/helper/converter.js +202 -26
  44. package/src/helper/dom/domCheck.js +304 -0
  45. package/src/helper/dom/domQuery.js +669 -0
  46. package/src/helper/dom/domUtils.js +557 -0
  47. package/src/helper/dom/index.js +12 -0
  48. package/src/helper/env.js +46 -56
  49. package/src/helper/index.js +10 -4
  50. package/src/helper/keyCodeMap.js +183 -0
  51. package/src/helper/numbers.js +12 -8
  52. package/src/helper/unicode.js +9 -5
  53. package/src/langs/ckb.js +74 -4
  54. package/src/langs/cs.js +72 -2
  55. package/src/langs/da.js +73 -3
  56. package/src/langs/de.js +73 -4
  57. package/src/langs/en.js +23 -3
  58. package/src/langs/es.js +73 -4
  59. package/src/langs/fa.js +75 -3
  60. package/src/langs/fr.js +73 -3
  61. package/src/langs/he.js +73 -4
  62. package/src/langs/hu.js +230 -0
  63. package/src/langs/index.js +7 -3
  64. package/src/langs/it.js +70 -1
  65. package/src/langs/ja.js +72 -4
  66. package/src/langs/km.js +230 -0
  67. package/src/langs/ko.js +22 -2
  68. package/src/langs/lv.js +74 -5
  69. package/src/langs/nl.js +73 -4
  70. package/src/langs/pl.js +73 -4
  71. package/src/langs/pt_br.js +70 -1
  72. package/src/langs/ro.js +74 -5
  73. package/src/langs/ru.js +73 -4
  74. package/src/langs/se.js +73 -4
  75. package/src/langs/tr.js +73 -1
  76. package/src/langs/{ua.js → uk.js} +75 -6
  77. package/src/langs/ur.js +77 -8
  78. package/src/langs/zh_cn.js +74 -5
  79. package/src/modules/ApiManager.js +77 -54
  80. package/src/modules/Browser.js +667 -0
  81. package/src/modules/ColorPicker.js +162 -102
  82. package/src/modules/Controller.js +273 -142
  83. package/src/modules/Figure.js +925 -484
  84. package/src/modules/FileManager.js +121 -69
  85. package/src/modules/HueSlider.js +113 -61
  86. package/src/modules/Modal.js +291 -122
  87. package/src/modules/ModalAnchorEditor.js +383 -234
  88. package/src/modules/SelectMenu.js +270 -168
  89. package/src/modules/_DragHandle.js +2 -1
  90. package/src/modules/index.js +3 -3
  91. package/src/plugins/browser/audioGallery.js +83 -0
  92. package/src/plugins/browser/fileBrowser.js +103 -0
  93. package/src/plugins/browser/fileGallery.js +83 -0
  94. package/src/plugins/browser/imageGallery.js +81 -0
  95. package/src/plugins/browser/videoGallery.js +103 -0
  96. package/src/plugins/command/blockquote.js +40 -27
  97. package/src/plugins/command/exportPDF.js +134 -0
  98. package/src/plugins/command/fileUpload.js +229 -162
  99. package/src/plugins/command/list_bulleted.js +83 -47
  100. package/src/plugins/command/list_numbered.js +83 -47
  101. package/src/plugins/dropdown/align.js +66 -54
  102. package/src/plugins/dropdown/backgroundColor.js +63 -49
  103. package/src/plugins/dropdown/font.js +71 -47
  104. package/src/plugins/dropdown/fontColor.js +63 -48
  105. package/src/plugins/dropdown/formatBlock.js +70 -33
  106. package/src/plugins/dropdown/hr.js +92 -51
  107. package/src/plugins/dropdown/layout.js +37 -26
  108. package/src/plugins/dropdown/lineHeight.js +54 -38
  109. package/src/plugins/dropdown/list.js +60 -45
  110. package/src/plugins/dropdown/paragraphStyle.js +51 -30
  111. package/src/plugins/dropdown/table.js +2003 -813
  112. package/src/plugins/dropdown/template.js +38 -26
  113. package/src/plugins/dropdown/textStyle.js +43 -31
  114. package/src/plugins/field/mention.js +147 -86
  115. package/src/plugins/index.js +32 -6
  116. package/src/plugins/input/fontSize.js +161 -108
  117. package/src/plugins/input/pageNavigator.js +70 -0
  118. package/src/plugins/modal/audio.js +358 -173
  119. package/src/plugins/modal/drawing.js +531 -0
  120. package/src/plugins/modal/embed.js +886 -0
  121. package/src/plugins/modal/image.js +674 -362
  122. package/src/plugins/modal/link.js +100 -71
  123. package/src/plugins/modal/math.js +367 -167
  124. package/src/plugins/modal/video.js +691 -335
  125. package/src/plugins/popup/anchor.js +222 -0
  126. package/src/suneditor.js +50 -13
  127. package/src/themes/dark.css +122 -0
  128. package/src/typedef.js +130 -0
  129. package/types/assets/icons/defaultIcons.d.ts +153 -0
  130. package/types/core/base/eventHandlers/handler_toolbar.d.ts +41 -0
  131. package/types/core/base/eventHandlers/handler_ww_clipboard.d.ts +40 -0
  132. package/types/core/base/eventHandlers/handler_ww_dragDrop.d.ts +35 -0
  133. package/types/core/base/eventHandlers/handler_ww_key_input.d.ts +45 -0
  134. package/types/core/base/eventHandlers/handler_ww_mouse.d.ts +39 -0
  135. package/types/core/base/eventManager.d.ts +385 -0
  136. package/types/core/base/history.d.ts +81 -0
  137. package/types/core/class/char.d.ts +60 -0
  138. package/types/core/class/component.d.ts +212 -0
  139. package/types/core/class/format.d.ts +616 -0
  140. package/types/core/class/html.d.ts +422 -0
  141. package/types/core/class/menu.d.ts +126 -0
  142. package/types/core/class/nodeTransform.d.ts +93 -0
  143. package/types/core/class/offset.d.ts +522 -0
  144. package/types/core/class/selection.d.ts +188 -0
  145. package/types/core/class/shortcuts.d.ts +142 -0
  146. package/types/core/class/toolbar.d.ts +189 -0
  147. package/types/core/class/ui.d.ts +164 -0
  148. package/types/core/class/viewer.d.ts +140 -0
  149. package/types/core/editor.d.ts +610 -0
  150. package/types/core/section/actives.d.ts +46 -0
  151. package/types/core/section/constructor.d.ts +777 -0
  152. package/types/core/section/context.d.ts +45 -0
  153. package/types/core/section/documentType.d.ts +178 -0
  154. package/types/editorInjector/_classes.d.ts +41 -0
  155. package/types/editorInjector/_core.d.ts +92 -0
  156. package/types/editorInjector/index.d.ts +71 -0
  157. package/types/events.d.ts +273 -0
  158. package/types/helper/clipboard.d.ts +12 -0
  159. package/types/helper/converter.d.ts +197 -0
  160. package/types/helper/dom/domCheck.d.ts +189 -0
  161. package/types/helper/dom/domQuery.d.ts +223 -0
  162. package/types/helper/dom/domUtils.d.ts +226 -0
  163. package/types/helper/dom/index.d.ts +9 -0
  164. package/types/helper/env.d.ts +132 -0
  165. package/types/helper/index.d.ts +174 -0
  166. package/types/helper/keyCodeMap.d.ts +110 -0
  167. package/types/helper/numbers.d.ts +46 -0
  168. package/types/helper/unicode.d.ts +28 -0
  169. package/types/index.d.ts +120 -0
  170. package/{typings/Lang.d.ts → types/langs/_Lang.d.ts} +173 -103
  171. package/types/langs/ckb.d.ts +3 -0
  172. package/types/langs/cs.d.ts +3 -0
  173. package/types/langs/da.d.ts +3 -0
  174. package/types/langs/de.d.ts +3 -0
  175. package/types/langs/en.d.ts +3 -0
  176. package/types/langs/es.d.ts +3 -0
  177. package/types/langs/fa.d.ts +3 -0
  178. package/types/langs/fr.d.ts +3 -0
  179. package/types/langs/he.d.ts +3 -0
  180. package/types/langs/hu.d.ts +3 -0
  181. package/types/langs/index.d.ts +54 -0
  182. package/types/langs/it.d.ts +3 -0
  183. package/types/langs/ja.d.ts +3 -0
  184. package/types/langs/km.d.ts +3 -0
  185. package/types/langs/ko.d.ts +3 -0
  186. package/types/langs/lv.d.ts +3 -0
  187. package/types/langs/nl.d.ts +3 -0
  188. package/types/langs/pl.d.ts +3 -0
  189. package/types/langs/pt_br.d.ts +3 -0
  190. package/types/langs/ro.d.ts +3 -0
  191. package/types/langs/ru.d.ts +3 -0
  192. package/types/langs/se.d.ts +3 -0
  193. package/types/langs/tr.d.ts +3 -0
  194. package/types/langs/uk.d.ts +3 -0
  195. package/types/langs/ur.d.ts +3 -0
  196. package/types/langs/zh_cn.d.ts +3 -0
  197. package/types/modules/ApiManager.d.ts +125 -0
  198. package/types/modules/Browser.d.ts +326 -0
  199. package/types/modules/ColorPicker.d.ts +131 -0
  200. package/types/modules/Controller.d.ts +251 -0
  201. package/types/modules/Figure.d.ts +517 -0
  202. package/types/modules/FileManager.d.ts +202 -0
  203. package/types/modules/HueSlider.d.ts +136 -0
  204. package/types/modules/Modal.d.ts +111 -0
  205. package/types/modules/ModalAnchorEditor.d.ts +236 -0
  206. package/types/modules/SelectMenu.d.ts +194 -0
  207. package/types/modules/_DragHandle.d.ts +7 -0
  208. package/types/modules/index.d.ts +26 -0
  209. package/types/plugins/browser/audioGallery.d.ts +55 -0
  210. package/types/plugins/browser/fileBrowser.d.ts +64 -0
  211. package/types/plugins/browser/fileGallery.d.ts +55 -0
  212. package/types/plugins/browser/imageGallery.d.ts +51 -0
  213. package/types/plugins/browser/videoGallery.d.ts +57 -0
  214. package/types/plugins/command/blockquote.d.ts +28 -0
  215. package/types/plugins/command/exportPDF.d.ts +46 -0
  216. package/types/plugins/command/fileUpload.d.ts +156 -0
  217. package/types/plugins/command/list_bulleted.d.ts +46 -0
  218. package/types/plugins/command/list_numbered.d.ts +46 -0
  219. package/types/plugins/dropdown/align.d.ts +60 -0
  220. package/types/plugins/dropdown/backgroundColor.d.ts +63 -0
  221. package/types/plugins/dropdown/font.d.ts +54 -0
  222. package/types/plugins/dropdown/fontColor.d.ts +63 -0
  223. package/types/plugins/dropdown/formatBlock.d.ts +54 -0
  224. package/types/plugins/dropdown/hr.d.ts +71 -0
  225. package/types/plugins/dropdown/layout.d.ts +40 -0
  226. package/types/plugins/dropdown/lineHeight.d.ts +50 -0
  227. package/types/plugins/dropdown/list.d.ts +39 -0
  228. package/types/plugins/dropdown/paragraphStyle.d.ts +54 -0
  229. package/types/plugins/dropdown/table.d.ts +627 -0
  230. package/types/plugins/dropdown/template.d.ts +40 -0
  231. package/types/plugins/dropdown/textStyle.d.ts +41 -0
  232. package/types/plugins/field/mention.d.ts +102 -0
  233. package/types/plugins/index.d.ts +107 -0
  234. package/types/plugins/input/fontSize.d.ts +170 -0
  235. package/types/plugins/input/pageNavigator.d.ts +28 -0
  236. package/types/plugins/modal/audio.d.ts +269 -0
  237. package/types/plugins/modal/drawing.d.ts +246 -0
  238. package/types/plugins/modal/embed.d.ts +387 -0
  239. package/types/plugins/modal/image.d.ts +451 -0
  240. package/types/plugins/modal/link.d.ts +128 -0
  241. package/types/plugins/modal/math.d.ts +193 -0
  242. package/types/plugins/modal/video.d.ts +485 -0
  243. package/types/plugins/popup/anchor.d.ts +56 -0
  244. package/types/suneditor.d.ts +51 -0
  245. package/types/typedef.d.ts +233 -0
  246. package/.eslintignore +0 -7
  247. package/.eslintrc.json +0 -64
  248. package/src/assets/icons/_default.js +0 -194
  249. package/src/core/base/events.js +0 -320
  250. package/src/core/class/notice.js +0 -42
  251. package/src/helper/domUtils.js +0 -1177
  252. package/src/modules/FileBrowser.js +0 -271
  253. package/src/plugins/command/exportPdf.js +0 -168
  254. package/src/plugins/fileBrowser/imageGallery.js +0 -81
  255. package/src/themes/test.css +0 -61
  256. package/typings/CommandPlugin.d.ts +0 -8
  257. package/typings/DialogPlugin.d.ts +0 -20
  258. package/typings/FileBrowserPlugin.d.ts +0 -30
  259. package/typings/Module.d.ts +0 -15
  260. package/typings/Plugin.d.ts +0 -42
  261. package/typings/SubmenuPlugin.d.ts +0 -8
  262. package/typings/_classes.d.ts +0 -17
  263. package/typings/_colorPicker.d.ts +0 -60
  264. package/typings/_core.d.ts +0 -55
  265. package/typings/align.d.ts +0 -5
  266. package/typings/audio.d.ts +0 -5
  267. package/typings/backgroundColor.d.ts +0 -5
  268. package/typings/blockquote.d.ts +0 -5
  269. package/typings/char.d.ts +0 -39
  270. package/typings/component.d.ts +0 -38
  271. package/typings/context.d.ts +0 -39
  272. package/typings/converter.d.ts +0 -33
  273. package/typings/dialog.d.ts +0 -28
  274. package/typings/domUtils.d.ts +0 -361
  275. package/typings/editor.d.ts +0 -7
  276. package/typings/editor.ts +0 -542
  277. package/typings/env.d.ts +0 -70
  278. package/typings/eventManager.d.ts +0 -37
  279. package/typings/events.d.ts +0 -262
  280. package/typings/fileBrowser.d.ts +0 -42
  281. package/typings/fileManager.d.ts +0 -67
  282. package/typings/font.d.ts +0 -5
  283. package/typings/fontColor.d.ts +0 -5
  284. package/typings/fontSize.d.ts +0 -5
  285. package/typings/format.d.ts +0 -191
  286. package/typings/formatBlock.d.ts +0 -5
  287. package/typings/history.d.ts +0 -48
  288. package/typings/horizontalRule.d.ts +0 -5
  289. package/typings/image.d.ts +0 -5
  290. package/typings/imageGallery.d.ts +0 -5
  291. package/typings/index.d.ts +0 -21
  292. package/typings/index.modules.d.ts +0 -11
  293. package/typings/index.plugins.d.ts +0 -58
  294. package/typings/lineHeight.d.ts +0 -5
  295. package/typings/link.d.ts +0 -5
  296. package/typings/list.d.ts +0 -5
  297. package/typings/math.d.ts +0 -5
  298. package/typings/mediaContainer.d.ts +0 -25
  299. package/typings/mention.d.ts +0 -5
  300. package/typings/node.d.ts +0 -57
  301. package/typings/notice.d.ts +0 -16
  302. package/typings/numbers.d.ts +0 -29
  303. package/typings/offset.d.ts +0 -24
  304. package/typings/options.d.ts +0 -589
  305. package/typings/paragraphStyle.d.ts +0 -5
  306. package/typings/resizing.d.ts +0 -141
  307. package/typings/selection.d.ts +0 -94
  308. package/typings/shortcuts.d.ts +0 -13
  309. package/typings/suneditor.d.ts +0 -9
  310. package/typings/table.d.ts +0 -5
  311. package/typings/template.d.ts +0 -5
  312. package/typings/textStyle.d.ts +0 -5
  313. package/typings/toolbar.d.ts +0 -32
  314. package/typings/unicode.d.ts +0 -25
  315. package/typings/video.d.ts +0 -5
package/src/events.js ADDED
@@ -0,0 +1,622 @@
1
+ // Event function collection
2
+ // This is a collection of functions that can be used in the editor's event callback.
3
+ // ---------
4
+
5
+ /**
6
+ * @typedef {import('./modules/Controller').default} ControllerInstance
7
+ */
8
+
9
+ // --- native events
10
+ /**
11
+ * @typedef {Object} BaseEvent
12
+ * @property {__se__EditorCore} editor - The root editor instance
13
+ * @property {__se__FrameContext} frameContext - frame context
14
+ * @property {Event} event - event object
15
+ */
16
+
17
+ /**
18
+ * @typedef {Object} ClipboardEvent
19
+ * @property {__se__EditorCore} editor - The root editor instance
20
+ * @property {__se__FrameContext} frameContext - frame context
21
+ * @property {Event} event - event object
22
+ * @property {string} data - drop data
23
+ * @property {boolean} maxCharCount - is max char count
24
+ * @property {string} from - "SE"|"MS"|"" - source
25
+ */
26
+
27
+ // --- controller
28
+ /**
29
+ * @typedef {import('./modules/Controller').ControllerInfo} ControllerInfo_events
30
+ */
31
+
32
+ // --- media
33
+ /**
34
+ * @typedef {Object} FileManagementInfo
35
+ * @property {string} src - source URL of the image.
36
+ * @property {number} index - index of the image.
37
+ * @property {string} name - name of the file.
38
+ * @property {number} size - size of the file in bytes.
39
+ * @property {HTMLElement} element - target element.
40
+ * @property {() => void} delete - delete function.
41
+ * @property {() => void} select - select function.
42
+ */
43
+
44
+ /**
45
+ * @typedef {Object} ProcessInfo
46
+ * @property {string} origin - origin url
47
+ * @property {string} url - url
48
+ * @property {"video"|"iframe"} tag - tag name
49
+ * @property {?HTMLCollection} children - embed children tags
50
+ */
51
+
52
+ // --- image
53
+ /**
54
+ * @typedef {Object} ImageInfo
55
+ * @property {FileList} files - FileList object
56
+ * @property {HTMLImageElement} element - target element
57
+ * @property {string} inputWidth - width value
58
+ * @property {string} inputHeight - height value
59
+ * @property {string} align - align value
60
+ * @property {boolean} isUpdate - new create or update
61
+ * @property {?HTMLElement} anchor - Anchor element, if it exists
62
+ * @property {string} alt - alt text value
63
+ */
64
+
65
+ // --- video
66
+ /**
67
+ * @typedef {Object} VideoInfo
68
+ * @property {FileList} files - FileList object
69
+ * @property {HTMLIFrameElement|HTMLVideoElement} element - target element
70
+ * @property {string} inputWidth - width value
71
+ * @property {string} inputHeight - height value
72
+ * @property {string} align - align value
73
+ * @property {boolean} isUpdate - new create or update
74
+ * @property {string} url - video url
75
+ * @property {?ProcessInfo} process - video process info
76
+ */
77
+
78
+ // --- audio
79
+ /**
80
+ * @typedef {Object} AudioInfo
81
+ * @property {HTMLAudioElement} element - target element
82
+ * @property {FileList} files - FileList object
83
+ * @property {boolean} isUpdate - new create or update
84
+ */
85
+
86
+ // --- file
87
+ /**
88
+ * @typedef {Object} FileInfo
89
+ * @property {string} url - file url
90
+ * @property {FileList} files - FileList object
91
+ * @property {Object} uploadHeaders - upload headers
92
+ */
93
+
94
+ // --- embed
95
+ /**
96
+ * @typedef {Object} EmbedInfo
97
+ * @property {HTMLElement} element - target element
98
+ * @property {string} inputWidth - width value
99
+ * @property {string} inputHeight - height value
100
+ * @property {string} align - align value
101
+ * @property {boolean} isUpdate - new create or update
102
+ * @property {string} url - embed url
103
+ * @property {?HTMLElement} children - When the input source is stacked in an iframe, etc., the actual embedded DOM
104
+ * @property {?ProcessInfo} process - embed process info
105
+ */
106
+
107
+ // event function collection
108
+ export default {
109
+ /**
110
+ * @description Event call back function
111
+ * @param {Object} params
112
+ * @param {__se__EditorCore} params.editor - The root editor instance
113
+ */
114
+ onload: null,
115
+
116
+ /**
117
+ * @description Event call back function
118
+ * @param {BaseEvent} params
119
+ */
120
+ onScroll: null,
121
+
122
+ /**
123
+ * @description Event call back function
124
+ * @param {BaseEvent} params
125
+ */
126
+ onMouseDown: null,
127
+
128
+ /**
129
+ * @description Event call back function
130
+ * @param {BaseEvent} params
131
+ */
132
+ onClick: null,
133
+
134
+ /**
135
+ * @description Event call back function
136
+ * @param {BaseEvent} params
137
+ */
138
+ onInput: null,
139
+
140
+ /**
141
+ * @description Event call back function
142
+ * @param {BaseEvent} params
143
+ */
144
+ onMouseLeave: null,
145
+
146
+ /**
147
+ * @description Event call back function
148
+ * @param {BaseEvent} params
149
+ */
150
+ onKeyDown: null,
151
+
152
+ /**
153
+ * @description Event call back function
154
+ * @param {BaseEvent} params
155
+ */
156
+ onKeyUp: null,
157
+
158
+ /**
159
+ * @description Event call back function
160
+ * @param {BaseEvent} params
161
+ */
162
+ onFocus: null,
163
+
164
+ /**
165
+ * @description Event call back function
166
+ * @param {BaseEvent} params
167
+ */
168
+ onBlur: null,
169
+
170
+ /**
171
+ * @description Event function on copy
172
+ * @param {Object} params
173
+ * @param {__se__EditorCore} params.editor - The root editor instance
174
+ * @param {__se__FrameContext} params.frameContext - frame context
175
+ * @param {Event} params.event - event object
176
+ * @param {Event} params.clipboardData - clipboardData
177
+ */
178
+ onCopy: null,
179
+
180
+ /**
181
+ * @description Event function on cut
182
+ * @param {Object} params
183
+ * @param {__se__EditorCore} params.editor - The root editor instance
184
+ * @param {__se__FrameContext} params.frameContext - frame context
185
+ * @param {Event} params.event - event object
186
+ * @param {Event} params.clipboardData - clipboardData
187
+ */
188
+ onCut: null,
189
+
190
+ /**
191
+ * @description Event call back function
192
+ * @param {Object} params
193
+ * @param {__se__EditorCore} params.editor - The root editor instance
194
+ * @param {__se__FrameContext} params.frameContext - frame context
195
+ * @param {Event} params.event - event object
196
+ * @param {Event} params.data - editor data
197
+ */
198
+ onChange: null,
199
+
200
+ /**
201
+ * @description Called just before the inline toolbar is positioned and displayed on the screen.
202
+ * @param {HTMLElement} toolbar - Toolbar element
203
+ * @param {string} mode - Toolbar mode
204
+ */
205
+ onShowToolbar: null,
206
+
207
+ /**
208
+ * @description Called just after the controller is positioned and displayed on the screen.
209
+ * - controller : editing elements displayed on the screen [image resizing, table editor, link editor..]]
210
+ * @param {Object} params
211
+ * @param {__se__EditorCore} params.editor - The root editor instance
212
+ * @param {__se__FrameContext} params.frameContext - frame context
213
+ * @param {string} params.caller - caller plugin name
214
+ * @param {ControllerInfo_events} params.info - info object
215
+ */
216
+ onShowController: null,
217
+
218
+ /**
219
+ * @description Called just after the controller is positioned and displayed on the screen.
220
+ * - controller : editing elements displayed on the screen [image resizing, table editor, link editor..]]
221
+ * @param {Object} params
222
+ * @param {__se__EditorCore} params.editor - The root editor instance
223
+ * @param {__se__FrameContext} params.frameContext - frame context
224
+ * @param {string} params.caller - caller plugin name
225
+ * @param {ControllerInfo_events} params.info - info object
226
+ */
227
+ onBeforeShowController: null,
228
+
229
+ /**
230
+ * @description An event when toggling between code view and wysiwyg view.
231
+ * @param {Object} params
232
+ * @param {__se__EditorCore} params.editor - The root editor instance
233
+ * @param {__se__FrameContext} params.frameContext - frame context
234
+ * @param {boolean} params.is - code view status
235
+ */
236
+ onToggleCodeView: null,
237
+
238
+ /**
239
+ * @description An event when toggling full screen.
240
+ * @param {Object} params
241
+ * @param {__se__EditorCore} params.editor - The root editor instance
242
+ * @param {__se__FrameContext} params.frameContext - frame context
243
+ * @param {boolean} params.is - full screen status
244
+ */
245
+ onToggleFullScreen: null,
246
+
247
+ /**
248
+ * @description Called when the editor is resized using the bottom bar
249
+ * @param {Object} params
250
+ * @param {__se__EditorCore} params.editor - The root editor instance
251
+ * @param {__se__FrameContext} params.frameContext - frame context
252
+ * @param {number} params.height - wysiwyg area frame height
253
+ * @param {boolean} params.prevHeight - wysiwyg area previous height
254
+ * @param {ResizeObserverEntry} params.observerEntry - ResizeObserverEntry
255
+ */
256
+ onResizeEditor: null,
257
+
258
+ /**
259
+ * @description Called after the "setToolbarButtons" invocation.
260
+ * - Can be used to tweak buttons properties (useful for custom buttons)
261
+ * @param {Object} params
262
+ * @param {__se__EditorCore} params.editor - The root editor instance
263
+ * @param {__se__FrameContext} params.frameContext - frame context
264
+ * @param {HTMLElement} params.buttonTray - button tray element
265
+ */
266
+ onSetToolbarButtons: null,
267
+
268
+ /**
269
+ * --------------------------------------------------- async function ---------------------------------------------------
270
+ */
271
+
272
+ /**
273
+ * @description Event callback function on save
274
+ * @param {Object} params
275
+ * @param {__se__EditorCore} params.editor - The root editor instance
276
+ * @param {__se__FrameContext} params.frameContext - frame context
277
+ * @param {Event} params.data - editor data
278
+ * @returns {Promise<boolean>}
279
+ */
280
+ onSave: null,
281
+
282
+ /**
283
+ * @description Event function on [drop, paste] before
284
+ * - When false is returned, the default behavior is stopped.
285
+ * - If the string is returned, the cleanData value is modified to the return value.
286
+ * @param {ClipboardEvent} params
287
+ * @returns {Promise<boolean|string>}
288
+ */
289
+ onDrop: null,
290
+
291
+ /**
292
+ * @description Event function on [drop, paste] before
293
+ * - When false is returned, the default behavior is stopped.
294
+ * - If the string is returned, the cleanData value is modified to the return value.
295
+ * @param {ClipboardEvent} params
296
+ * @returns {Promise<boolean|string>}
297
+ */
298
+ onPaste: null,
299
+
300
+ // --- image
301
+ /**
302
+ * @description It replaces the default callback function of the image upload
303
+ * @param {Object} params
304
+ * @param {__se__EditorCore} params.editor - The root editor instance
305
+ * @param {XMLHttpRequest} params.xmlHttp - XMLHttpRequest
306
+ * @param {ImageInfo} params.info - info object
307
+ * @returns {Promise<boolean>}
308
+ */
309
+ imageUploadHandler: null,
310
+
311
+ /**
312
+ * @description Called before the image is uploaded
313
+ * - If true is returned, the internal upload process runs normally.
314
+ * - If false is returned, no image upload is performed.
315
+ * - If new "info" are returned, replaced the previous "params.info"
316
+ * - If undefined is returned, it waits until "uploadHandler" is executed.
317
+ * @param {Object} params
318
+ * @param {__se__EditorCore} params.editor - The root editor instance
319
+ * @param {ImageInfo} params.info - info object
320
+ * @param {(newInfo?: ImageInfo|null) => void} params.handler - handler function
321
+ * @returns {Promise<boolean|undefined|ImageInfo>}
322
+ */
323
+ onImageUploadBefore: null,
324
+
325
+ /**
326
+ * @description Called when the editor loaded, file Current editor value
327
+ * @param {Object} params
328
+ * @param {__se__EditorCore} params.editor - The root editor instance
329
+ * @param {Array<FileManagementInfo>} infoList - info list
330
+ */
331
+ onImageLoad: null,
332
+
333
+ /**
334
+ * @description Called when the image is uploaded, updated, deleted
335
+ * @param {Object} params
336
+ * @param {__se__EditorCore} params.editor - The root editor instance
337
+ * @param {FileManagementInfo} params.info - info object
338
+ * @param {HTMLElement|null} params.element - target element
339
+ * @param {"create"|"update"|"delete"} params.state - state
340
+ * @param {number} params.index - data index
341
+ * @param {number} params.remainingFilesCount - remaining files count
342
+ * @param {string} params.pluginName - plugin name
343
+ */
344
+ onImageAction: null,
345
+
346
+ /**
347
+ * @description Called when the image is upload failed
348
+ * @param {Object} params
349
+ * @param {__se__EditorCore} params.editor - The root editor instance
350
+ * @param {string} params.error - error message
351
+ * @param {number=} params.limitSize - limit size
352
+ * @param {number=} params.uploadSize - upload size
353
+ * @param {number=} params.currentSize - current size
354
+ * @param {File=} params.file - File object
355
+ * @returns {Promise<string|undefined>}
356
+ */
357
+ onImageUploadError: null,
358
+
359
+ /**
360
+ * @description Called before the image is deleted
361
+ * @param {Object} params
362
+ * @param {__se__EditorCore} params.editor - The root editor instance
363
+ * @param {HTMLElement} params.element - target element
364
+ * @param {HTMLElement} params.container - target's container element (div)
365
+ * @param {string} params.align - align value
366
+ * @param {string} params.alt - alt text value
367
+ * @param {?string} params.url - Anchor url, if it exists
368
+ * @returns {Promise<boolean>}
369
+ */
370
+ onImageDeleteBefore: null,
371
+
372
+ // --- video
373
+ /**
374
+ * @description It replaces the default callback function of the video upload
375
+ * @param {Object} params
376
+ * @param {__se__EditorCore} params.editor - The root editor instance
377
+ * @param {XMLHttpRequest} params.xmlHttp - XMLHttpRequest
378
+ * @param {VideoInfo} params.info - info object
379
+ * @returns {Promise<boolean>}
380
+ */
381
+ videoUploadHandler: null,
382
+
383
+ /**
384
+ * @description Called before the video is uploaded
385
+ * - If true is returned, the internal upload process runs normally.
386
+ * - If false is returned, no video(iframe, video) upload is performed.
387
+ * - If new "info" are returned, replaced the previous "params.info"
388
+ * - If undefined is returned, it waits until "uploadHandler" is executed.
389
+ * @param {Object} params
390
+ * @param {__se__EditorCore} params.editor - The root editor instance
391
+ * @param {VideoInfo} params.info - info object
392
+ * @param {(newInfo?: VideoInfo|null) => void} params.handler - handler function
393
+ * @returns {Promise<boolean|undefined|VideoInfo>}
394
+ */
395
+ onVideoUploadBefore: null,
396
+
397
+ /**
398
+ * @description Called when the editor loaded, file Current editor value
399
+ * @param {Object} params
400
+ * @param {__se__EditorCore} params.editor - The root editor instance
401
+ * @param {Array<FileManagementInfo>} infoList - info list
402
+ */
403
+ onVideoLoad: null,
404
+
405
+ /**
406
+ * @description Called when the video(iframe, video) is is uploaded, updated, deleted
407
+ * @param {Object} params
408
+ * @param {__se__EditorCore} params.editor - The root editor instance
409
+ * @param {FileManagementInfo} params.info - info object
410
+ * @param {HTMLElement|null} params.element - target element
411
+ * @param {"create"|"update"|"delete"} params.state - state
412
+ * @param {number} params.index - data index
413
+ * @param {number} params.remainingFilesCount - remaining files count
414
+ * @param {string} params.pluginName - plugin name
415
+ */
416
+ onVideoAction: null,
417
+
418
+ /**
419
+ * @description Called when the video(iframe, video) upload failed
420
+ * @param {Object} params
421
+ * @param {__se__EditorCore} params.editor - The root editor instance
422
+ * @param {string} params.error - error message
423
+ * @param {number=} params.limitSize - limit size
424
+ * @param {number=} params.uploadSize - upload size
425
+ * @param {number=} params.currentSize - current size
426
+ * @param {File=} params.file - File object
427
+ * @returns {Promise<string|undefined>}
428
+ */
429
+ onVideoUploadError: null,
430
+
431
+ /**
432
+ * @description Called before the video is deleted
433
+ * @param {Object} params
434
+ * @param {__se__EditorCore} params.editor - The root editor instance
435
+ * @param {HTMLElement} params.element - target element
436
+ * @param {HTMLElement} params.container - target's container element (div)
437
+ * @param {string} params.align - align value
438
+ * @param {string} params.url - video url
439
+ * @returns {Promise<boolean>}
440
+ */
441
+ onVideoDeleteBefore: null,
442
+
443
+ /**
444
+ * @description It replaces the default callback function of the audio upload
445
+ * @param {Object} params
446
+ * @param {__se__EditorCore} params.editor - The root editor instance
447
+ * @param {XMLHttpRequest} params.xmlHttp - XMLHttpRequest
448
+ * @param {AudioInfo} params.info - info object
449
+ * @returns {Promise<boolean>}
450
+ */
451
+ audioUploadHandler: null,
452
+
453
+ // --- audio
454
+ /**
455
+ * @description Called before the audio is uploaded
456
+ * - If true is returned, the internal upload process runs normally.
457
+ * - If false is returned, no audio upload is performed.
458
+ * - If new "info" are returned, replaced the previous "params.info"
459
+ * - If undefined is returned, it waits until "uploadHandler" is executed.
460
+ * @param {Object} params
461
+ * @param {__se__EditorCore} params.editor - The root editor instance
462
+ * @param {AudioInfo} params.info - info object
463
+ * @param {(newInfo?: AudioInfo|null) => void} params.handler - handler function
464
+ * @returns {Promise<boolean|undefined|AudioInfo>}
465
+ */
466
+ onAudioUploadBefore: null,
467
+
468
+ /**
469
+ * @description Called when the audio upload failed
470
+ * @param {Object} params
471
+ * @param {__se__EditorCore} params.editor - The root editor instance
472
+ * @param {string} params.error - error message
473
+ * @param {number=} params.limitSize - limit size
474
+ * @param {number=} params.uploadSize - upload size
475
+ * @param {number=} params.currentSize - current size
476
+ * @param {File=} params.file - File object
477
+ * @returns {Promise<string|undefined>}
478
+ */
479
+ onAudioUploadError: null,
480
+
481
+ /**
482
+ * @description Called when the editor loaded, file Current editor value
483
+ * @param {Object} params
484
+ * @param {__se__EditorCore} params.editor - The root editor instance
485
+ * @param {Array<FileManagementInfo>} infoList - info list
486
+ */
487
+ onAudioLoad: null,
488
+
489
+ /**
490
+ * @description Called when the audio is is uploaded, updated, deleted
491
+ * @param {Object} params
492
+ * @param {__se__EditorCore} params.editor - The root editor instance
493
+ * @param {FileManagementInfo} params.info - info object
494
+ * @param {HTMLElement|null} params.element - target element
495
+ * @param {"create"|"update"|"delete"} params.state - state
496
+ * @param {number} params.index - data index
497
+ * @param {number} params.remainingFilesCount - remaining files count
498
+ * @param {string} params.pluginName - plugin name
499
+ */
500
+ onAudioAction: null,
501
+
502
+ /**
503
+ * @description Called before the audio is deleted
504
+ * @param {Object} params
505
+ * @param {__se__EditorCore} params.editor - The root editor instance
506
+ * @param {HTMLElement} params.element - target element
507
+ * @param {HTMLElement} params.container - target's container element (div)
508
+ * @param {string} params.url - audio url
509
+ * @returns {Promise<boolean>}
510
+ */
511
+ onAudioDeleteBefore: null,
512
+
513
+ // --- fileUpload
514
+ /**
515
+ * @description Called when the file is uploaded
516
+ * - If true is returned, the internal upload process runs normally.
517
+ * - If false is returned, no image upload is performed.
518
+ * - If new "info" are returned, replaced the previous "params.info"
519
+ * - If undefined is returned, it waits until "uploadHandler" is executed.
520
+ * @param {Object} params
521
+ * @param {__se__EditorCore} params.editor - The root editor instance
522
+ * @param {FileInfo} params.info - info object
523
+ * @param {(newInfo?: FileInfo|null) => void} params.handler - handler function
524
+ * @returns {Promise<boolean|undefined|AudioInfo>}
525
+ */
526
+ onFileUploadBefore: null,
527
+
528
+ /**
529
+ * @description Called when the editor loaded, file Current editor value
530
+ * @param {Object} params
531
+ * @param {__se__EditorCore} params.editor - The root editor instance
532
+ * @param {Array<FileManagementInfo>} infoList - info list
533
+ */
534
+ onFileLoad: null,
535
+
536
+ /**
537
+ * @description Called when the file is is uploaded, updated, deleted
538
+ * @param {Object} params
539
+ * @param {__se__EditorCore} params.editor - The root editor instance
540
+ * @param {FileManagementInfo} params.info - info object
541
+ * @param {HTMLElement|null} params.element - target element
542
+ * @param {"create"|"update"|"delete"} params.state - state
543
+ * @param {number} params.index - data index
544
+ * @param {number} params.remainingFilesCount - remaining files count
545
+ * @param {string} params.pluginName - plugin name
546
+ */
547
+ onFileAction: null,
548
+
549
+ /**
550
+ * @description Called when the file is upload failed
551
+ * @param {Object} params
552
+ * @param {__se__EditorCore} params.editor - The root editor instance
553
+ * @param {string} params.error - error message
554
+ * @param {number=} params.limitSize - limit size
555
+ * @param {number=} params.uploadSize - upload size
556
+ * @param {number=} params.currentSize - current size
557
+ * @param {File=} params.file - File object
558
+ * @returns {Promise<string|undefined>}
559
+ */
560
+ onFileUploadError: null,
561
+
562
+ /**
563
+ * @description Called before the file is deleted
564
+ * @param {Object} params
565
+ * @param {__se__EditorCore} params.editor - The root editor instance
566
+ * @param {HTMLElement} params.element - target element
567
+ * @param {HTMLElement} params.container - target's container element (div)
568
+ * @param {string} params.url - file url
569
+ * @returns {Promise<boolean>}
570
+ */
571
+ onFileDeleteBefore: null,
572
+
573
+ // --- exportPDF
574
+ /**
575
+ * @description Called before the PDF export is started
576
+ * @param {Object} params
577
+ * @param {__se__EditorCore} params.editor - The root editor instance
578
+ * @param {HTMLElement} params.target - wysiwyg editable element
579
+ * @returns {Promise<boolean>}
580
+ */
581
+ onExportPDFBefore: null,
582
+
583
+ // --- fileManager
584
+ /**
585
+ * @description Events that occur when actions such as uploading or deleting all files are performed in the file manager
586
+ * @param {Object} params
587
+ * @param {__se__EditorCore} params.editor - The root editor instance
588
+ * @param {FileManagementInfo} params.info - info object
589
+ * @param {HTMLElement|null} params.element - target element
590
+ * @param {"create"|"update"|"delete"} params.state - state
591
+ * @param {number} params.index - data index
592
+ * @param {number} params.remainingFilesCount - remaining files count
593
+ * @param {string} params.pluginName - plugin name
594
+ */
595
+ onFileManagerAction: null,
596
+
597
+ // --- embed
598
+ /**
599
+ * @description Called before the embed is inserted
600
+ * - If true is returned, the internal upload process runs normally.
601
+ * - If false is returned, no image upload is performed.
602
+ * - If new fileList are returned, replaced the previous fileList
603
+ * - If undefined is returned, it waits until "uploadHandler" is executed.
604
+ * @param {Object} params
605
+ * @param {__se__EditorCore} params.editor - The root editor instance
606
+ * @param {EmbedInfo} params.info - info object
607
+ * @param {(newInfo?: EmbedInfo|null) => void} params.handler - handler function
608
+ */
609
+ onEmbedInputBefore: null,
610
+
611
+ /**
612
+ * @description Called before the embed is deleted
613
+ * @param {Object} params
614
+ * @param {__se__EditorCore} params.editor - The root editor instance
615
+ * @param {HTMLElement} params.element - target element
616
+ * @param {HTMLElement} params.container - target's container element (div)
617
+ * @param {string} params.align - align value
618
+ * @param {string} params.url - embed url
619
+ * @returns {Promise<boolean>}
620
+ */
621
+ onEmbedDeleteBefore: null
622
+ };
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @fileoverview clipboard helper
3
+ */
4
+ import { isClipboardSupported } from './env';
5
+ import { isElement } from './dom/domCheck';
6
+
7
+ /**
8
+ * @description Write the content to the clipboard
9
+ * - Iframe is replaced with a placeholder : <div data-se-iframe-holder-src="iframe.src">[iframe: iframe.src]</div>
10
+ * - "iframe placeholder" is re-rendered in html.clean when pasted into the editor.
11
+ * @param {Element|Text|string} content Content to be copied to the clipboard
12
+ * @returns {Promise<void>}
13
+ */
14
+ export async function write(content) {
15
+ if (!isClipboardSupported) {
16
+ console.error('Clipboard is not supported in this browser.');
17
+ return;
18
+ }
19
+
20
+ let htmlString = '';
21
+ let plainText = '';
22
+
23
+ if (typeof content === 'string') {
24
+ htmlString = content;
25
+ plainText = content;
26
+ } else if (isElement(content)) {
27
+ content.querySelectorAll('iframe').forEach((iframe) => {
28
+ const placeholder = document.createElement('div');
29
+ const iframeAttrs = {};
30
+ for (const attr of Array.from(iframe.attributes)) {
31
+ iframeAttrs[attr.name] = attr.value;
32
+ }
33
+
34
+ placeholder.setAttribute('data-se-iframe-holder', '1');
35
+ placeholder.setAttribute('data-se-iframe-holder-attrs', JSON.stringify(iframeAttrs));
36
+ placeholder.innerText = `[iframe: ${iframe.src}]`;
37
+
38
+ iframe.replaceWith(placeholder);
39
+ });
40
+ htmlString = content.outerHTML;
41
+ plainText = content.textContent;
42
+ } else {
43
+ htmlString = content.textContent;
44
+ plainText = content.textContent;
45
+ }
46
+
47
+ /* eslint-disable-next-line compat/compat */
48
+ await navigator.clipboard.write([
49
+ /* eslint-disable-next-line compat/compat */
50
+ new ClipboardItem({
51
+ 'text/html': new Blob([htmlString], { type: 'text/html' }),
52
+ 'text/plain': new Blob([plainText], { type: 'text/plain' })
53
+ })
54
+ ]);
55
+ }
56
+
57
+ export default {
58
+ write
59
+ };