suneditor 3.0.0-alpha.2 → 3.0.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/.eslintrc.json +4 -3
  2. package/CONTRIBUTING.md +4 -2
  3. package/README.md +19 -11
  4. package/README_V3_TEMP.md +705 -0
  5. package/dist/suneditor.min.css +1 -0
  6. package/dist/suneditor.min.js +1 -0
  7. package/example.md +587 -0
  8. package/package.json +15 -9
  9. package/src/assets/icons/_default.js +166 -131
  10. package/src/assets/{suneditor-content.css → suneditor-contents.css} +182 -45
  11. package/src/assets/suneditor.css +1195 -556
  12. package/src/assets/variables.css +138 -0
  13. package/src/core/base/eventHandlers/handler_toolbar.js +35 -14
  14. package/src/core/base/eventHandlers/handler_ww_clipboard.js +29 -4
  15. package/src/core/base/eventHandlers/handler_ww_dragDrop.js +59 -15
  16. package/src/core/base/eventHandlers/handler_ww_key_input.js +426 -212
  17. package/src/core/base/eventHandlers/handler_ww_mouse.js +108 -32
  18. package/src/core/base/eventManager.js +540 -209
  19. package/src/core/base/events.js +616 -320
  20. package/src/core/base/history.js +93 -39
  21. package/src/core/class/char.js +29 -13
  22. package/src/core/class/component.js +332 -145
  23. package/src/core/class/format.js +671 -509
  24. package/src/core/class/html.js +504 -290
  25. package/src/core/class/menu.js +114 -47
  26. package/src/core/class/nodeTransform.js +111 -66
  27. package/src/core/class/offset.js +409 -105
  28. package/src/core/class/selection.js +220 -108
  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 +330 -0
  32. package/src/core/class/viewer.js +178 -74
  33. package/src/core/editor.js +489 -384
  34. package/src/core/section/actives.js +118 -22
  35. package/src/core/section/constructor.js +504 -170
  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/helper/converter.js +137 -19
  42. package/src/helper/dom/domCheck.js +294 -0
  43. package/src/helper/dom/domQuery.js +609 -0
  44. package/src/helper/dom/domUtils.js +533 -0
  45. package/src/helper/dom/index.js +12 -0
  46. package/src/helper/env.js +42 -19
  47. package/src/helper/index.js +7 -4
  48. package/src/helper/keyCodeMap.js +183 -0
  49. package/src/helper/numbers.js +8 -8
  50. package/src/helper/unicode.js +5 -5
  51. package/src/langs/ckb.js +69 -3
  52. package/src/langs/cs.js +67 -1
  53. package/src/langs/da.js +68 -2
  54. package/src/langs/de.js +68 -3
  55. package/src/langs/en.js +29 -1
  56. package/src/langs/es.js +68 -3
  57. package/src/langs/fa.js +70 -2
  58. package/src/langs/fr.js +68 -2
  59. package/src/langs/he.js +68 -3
  60. package/src/langs/hu.js +226 -0
  61. package/src/langs/index.js +3 -2
  62. package/src/langs/it.js +65 -0
  63. package/src/langs/ja.js +68 -3
  64. package/src/langs/ko.js +66 -1
  65. package/src/langs/lv.js +68 -3
  66. package/src/langs/nl.js +68 -3
  67. package/src/langs/pl.js +68 -3
  68. package/src/langs/pt_br.js +65 -0
  69. package/src/langs/ro.js +69 -4
  70. package/src/langs/ru.js +68 -3
  71. package/src/langs/se.js +68 -3
  72. package/src/langs/tr.js +68 -0
  73. package/src/langs/ua.js +68 -3
  74. package/src/langs/ur.js +71 -6
  75. package/src/langs/zh_cn.js +69 -4
  76. package/src/modules/ApiManager.js +77 -54
  77. package/src/modules/Browser.js +667 -0
  78. package/src/modules/ColorPicker.js +162 -102
  79. package/src/modules/Controller.js +233 -136
  80. package/src/modules/Figure.js +913 -489
  81. package/src/modules/FileManager.js +141 -72
  82. package/src/modules/HueSlider.js +113 -61
  83. package/src/modules/Modal.js +292 -113
  84. package/src/modules/ModalAnchorEditor.js +380 -230
  85. package/src/modules/SelectMenu.js +270 -168
  86. package/src/modules/_DragHandle.js +2 -1
  87. package/src/modules/index.js +3 -3
  88. package/src/plugins/browser/audioGallery.js +83 -0
  89. package/src/plugins/browser/fileBrowser.js +103 -0
  90. package/src/plugins/browser/fileGallery.js +83 -0
  91. package/src/plugins/browser/imageGallery.js +81 -0
  92. package/src/plugins/browser/videoGallery.js +103 -0
  93. package/src/plugins/command/blockquote.js +40 -27
  94. package/src/plugins/command/exportPDF.js +134 -0
  95. package/src/plugins/command/fileUpload.js +226 -158
  96. package/src/plugins/command/list_bulleted.js +93 -47
  97. package/src/plugins/command/list_numbered.js +93 -47
  98. package/src/plugins/dropdown/align.js +66 -54
  99. package/src/plugins/dropdown/backgroundColor.js +76 -45
  100. package/src/plugins/dropdown/font.js +71 -47
  101. package/src/plugins/dropdown/fontColor.js +78 -46
  102. package/src/plugins/dropdown/formatBlock.js +74 -33
  103. package/src/plugins/dropdown/hr.js +102 -51
  104. package/src/plugins/dropdown/layout.js +37 -26
  105. package/src/plugins/dropdown/lineHeight.js +54 -38
  106. package/src/plugins/dropdown/list.js +60 -45
  107. package/src/plugins/dropdown/paragraphStyle.js +51 -30
  108. package/src/plugins/dropdown/table.js +1269 -777
  109. package/src/plugins/dropdown/template.js +38 -26
  110. package/src/plugins/dropdown/textStyle.js +43 -31
  111. package/src/plugins/field/mention.js +144 -82
  112. package/src/plugins/index.js +32 -6
  113. package/src/plugins/input/fontSize.js +161 -108
  114. package/src/plugins/input/pageNavigator.js +70 -0
  115. package/src/plugins/modal/audio.js +341 -169
  116. package/src/plugins/modal/drawing.js +530 -0
  117. package/src/plugins/modal/embed.js +886 -0
  118. package/src/plugins/modal/image.js +673 -358
  119. package/src/plugins/modal/link.js +100 -71
  120. package/src/plugins/modal/math.js +384 -168
  121. package/src/plugins/modal/video.js +693 -336
  122. package/src/plugins/popup/anchor.js +222 -0
  123. package/src/suneditor.js +54 -12
  124. package/src/themes/dark.css +85 -0
  125. package/src/typedef.js +86 -0
  126. package/types/assets/icons/_default.d.ts +152 -0
  127. package/types/core/base/eventHandlers/handler_toolbar.d.ts +41 -0
  128. package/types/core/base/eventHandlers/handler_ww_clipboard.d.ts +40 -0
  129. package/types/core/base/eventHandlers/handler_ww_dragDrop.d.ts +35 -0
  130. package/types/core/base/eventHandlers/handler_ww_key_input.d.ts +45 -0
  131. package/types/core/base/eventHandlers/handler_ww_mouse.d.ts +39 -0
  132. package/types/core/base/eventManager.d.ts +377 -0
  133. package/types/core/base/events.d.ts +297 -0
  134. package/types/core/base/history.d.ts +81 -0
  135. package/types/core/class/char.d.ts +60 -0
  136. package/types/core/class/component.d.ts +259 -0
  137. package/types/core/class/format.d.ts +615 -0
  138. package/types/core/class/html.d.ts +377 -0
  139. package/types/core/class/menu.d.ts +118 -0
  140. package/types/core/class/nodeTransform.d.ts +93 -0
  141. package/types/core/class/offset.d.ts +512 -0
  142. package/types/core/class/selection.d.ts +188 -0
  143. package/types/core/class/shortcuts.d.ts +142 -0
  144. package/types/core/class/toolbar.d.ts +189 -0
  145. package/types/core/class/ui.d.ts +144 -0
  146. package/types/core/class/viewer.d.ts +140 -0
  147. package/types/core/editor.d.ts +606 -0
  148. package/types/core/section/actives.d.ts +46 -0
  149. package/types/core/section/constructor.d.ts +748 -0
  150. package/types/core/section/context.d.ts +45 -0
  151. package/types/core/section/documentType.d.ts +178 -0
  152. package/types/editorInjector/_classes.d.ts +41 -0
  153. package/types/editorInjector/_core.d.ts +92 -0
  154. package/types/editorInjector/index.d.ts +71 -0
  155. package/types/helper/converter.d.ts +150 -0
  156. package/types/helper/dom/domCheck.d.ts +182 -0
  157. package/types/helper/dom/domQuery.d.ts +214 -0
  158. package/types/helper/dom/domUtils.d.ts +211 -0
  159. package/types/helper/dom/index.d.ts +9 -0
  160. package/types/helper/env.d.ts +149 -0
  161. package/types/helper/index.d.ts +163 -0
  162. package/types/helper/keyCodeMap.d.ts +110 -0
  163. package/types/helper/numbers.d.ts +43 -0
  164. package/types/helper/unicode.d.ts +28 -0
  165. package/types/index.d.ts +0 -0
  166. package/{typings/Lang.d.ts → types/langs/_Lang.d.ts} +170 -103
  167. package/types/langs/ckb.d.ts +384 -0
  168. package/types/langs/cs.d.ts +384 -0
  169. package/types/langs/da.d.ts +384 -0
  170. package/types/langs/de.d.ts +384 -0
  171. package/types/langs/en.d.ts +384 -0
  172. package/types/langs/es.d.ts +384 -0
  173. package/types/langs/fa.d.ts +384 -0
  174. package/types/langs/fr.d.ts +384 -0
  175. package/types/langs/he.d.ts +384 -0
  176. package/types/langs/hu.d.ts +384 -0
  177. package/types/langs/index.d.ts +48 -0
  178. package/types/langs/it.d.ts +384 -0
  179. package/types/langs/ja.d.ts +384 -0
  180. package/types/langs/ko.d.ts +384 -0
  181. package/types/langs/lv.d.ts +384 -0
  182. package/types/langs/nl.d.ts +384 -0
  183. package/types/langs/pl.d.ts +384 -0
  184. package/types/langs/pt_br.d.ts +384 -0
  185. package/types/langs/ro.d.ts +384 -0
  186. package/types/langs/ru.d.ts +384 -0
  187. package/types/langs/se.d.ts +384 -0
  188. package/types/langs/tr.d.ts +384 -0
  189. package/types/langs/ua.d.ts +384 -0
  190. package/types/langs/ur.d.ts +384 -0
  191. package/types/langs/zh_cn.d.ts +384 -0
  192. package/types/modules/ApiManager.d.ts +125 -0
  193. package/types/modules/Browser.d.ts +326 -0
  194. package/types/modules/ColorPicker.d.ts +131 -0
  195. package/types/modules/Controller.d.ts +231 -0
  196. package/types/modules/Figure.d.ts +504 -0
  197. package/types/modules/FileManager.d.ts +202 -0
  198. package/types/modules/HueSlider.d.ts +136 -0
  199. package/types/modules/Modal.d.ts +117 -0
  200. package/types/modules/ModalAnchorEditor.d.ts +236 -0
  201. package/types/modules/SelectMenu.d.ts +194 -0
  202. package/types/modules/_DragHandle.d.ts +7 -0
  203. package/types/modules/index.d.ts +26 -0
  204. package/types/plugins/browser/audioGallery.d.ts +55 -0
  205. package/types/plugins/browser/fileBrowser.d.ts +64 -0
  206. package/types/plugins/browser/fileGallery.d.ts +55 -0
  207. package/types/plugins/browser/imageGallery.d.ts +51 -0
  208. package/types/plugins/browser/videoGallery.d.ts +57 -0
  209. package/types/plugins/command/blockquote.d.ts +28 -0
  210. package/types/plugins/command/exportPDF.d.ts +46 -0
  211. package/types/plugins/command/fileUpload.d.ts +156 -0
  212. package/types/plugins/command/list_bulleted.d.ts +56 -0
  213. package/types/plugins/command/list_numbered.d.ts +56 -0
  214. package/types/plugins/dropdown/align.d.ts +60 -0
  215. package/types/plugins/dropdown/backgroundColor.d.ts +63 -0
  216. package/types/plugins/dropdown/font.d.ts +54 -0
  217. package/types/plugins/dropdown/fontColor.d.ts +63 -0
  218. package/types/plugins/dropdown/formatBlock.d.ts +58 -0
  219. package/types/plugins/dropdown/hr.d.ts +81 -0
  220. package/types/plugins/dropdown/layout.d.ts +40 -0
  221. package/types/plugins/dropdown/lineHeight.d.ts +50 -0
  222. package/types/plugins/dropdown/list.d.ts +39 -0
  223. package/types/plugins/dropdown/paragraphStyle.d.ts +54 -0
  224. package/types/plugins/dropdown/table.d.ts +579 -0
  225. package/types/plugins/dropdown/template.d.ts +40 -0
  226. package/types/plugins/dropdown/textStyle.d.ts +41 -0
  227. package/types/plugins/field/mention.d.ts +102 -0
  228. package/types/plugins/index.d.ts +107 -0
  229. package/types/plugins/input/fontSize.d.ts +170 -0
  230. package/types/plugins/input/pageNavigator.d.ts +28 -0
  231. package/types/plugins/modal/audio.d.ts +269 -0
  232. package/types/plugins/modal/drawing.d.ts +246 -0
  233. package/types/plugins/modal/embed.d.ts +387 -0
  234. package/types/plugins/modal/image.d.ts +451 -0
  235. package/types/plugins/modal/link.d.ts +128 -0
  236. package/types/plugins/modal/math.d.ts +193 -0
  237. package/types/plugins/modal/video.d.ts +485 -0
  238. package/types/plugins/popup/anchor.d.ts +56 -0
  239. package/types/suneditor.d.ts +51 -0
  240. package/types/typedef-global.d.ts +144 -0
  241. package/src/core/class/notice.js +0 -42
  242. package/src/helper/domUtils.js +0 -1177
  243. package/src/modules/FileBrowser.js +0 -271
  244. package/src/plugins/command/exportPdf.js +0 -168
  245. package/src/plugins/fileBrowser/imageGallery.js +0 -81
  246. package/src/themes/test.css +0 -61
  247. package/typings/CommandPlugin.d.ts +0 -8
  248. package/typings/DialogPlugin.d.ts +0 -20
  249. package/typings/FileBrowserPlugin.d.ts +0 -30
  250. package/typings/Module.d.ts +0 -15
  251. package/typings/Plugin.d.ts +0 -42
  252. package/typings/SubmenuPlugin.d.ts +0 -8
  253. package/typings/_classes.d.ts +0 -17
  254. package/typings/_colorPicker.d.ts +0 -60
  255. package/typings/_core.d.ts +0 -55
  256. package/typings/align.d.ts +0 -5
  257. package/typings/audio.d.ts +0 -5
  258. package/typings/backgroundColor.d.ts +0 -5
  259. package/typings/blockquote.d.ts +0 -5
  260. package/typings/char.d.ts +0 -39
  261. package/typings/component.d.ts +0 -38
  262. package/typings/context.d.ts +0 -39
  263. package/typings/converter.d.ts +0 -33
  264. package/typings/dialog.d.ts +0 -28
  265. package/typings/domUtils.d.ts +0 -361
  266. package/typings/editor.d.ts +0 -7
  267. package/typings/editor.ts +0 -542
  268. package/typings/env.d.ts +0 -70
  269. package/typings/eventManager.d.ts +0 -37
  270. package/typings/events.d.ts +0 -262
  271. package/typings/fileBrowser.d.ts +0 -42
  272. package/typings/fileManager.d.ts +0 -67
  273. package/typings/font.d.ts +0 -5
  274. package/typings/fontColor.d.ts +0 -5
  275. package/typings/fontSize.d.ts +0 -5
  276. package/typings/format.d.ts +0 -191
  277. package/typings/formatBlock.d.ts +0 -5
  278. package/typings/history.d.ts +0 -48
  279. package/typings/horizontalRule.d.ts +0 -5
  280. package/typings/image.d.ts +0 -5
  281. package/typings/imageGallery.d.ts +0 -5
  282. package/typings/index.d.ts +0 -21
  283. package/typings/index.modules.d.ts +0 -11
  284. package/typings/index.plugins.d.ts +0 -58
  285. package/typings/lineHeight.d.ts +0 -5
  286. package/typings/link.d.ts +0 -5
  287. package/typings/list.d.ts +0 -5
  288. package/typings/math.d.ts +0 -5
  289. package/typings/mediaContainer.d.ts +0 -25
  290. package/typings/mention.d.ts +0 -5
  291. package/typings/node.d.ts +0 -57
  292. package/typings/notice.d.ts +0 -16
  293. package/typings/numbers.d.ts +0 -29
  294. package/typings/offset.d.ts +0 -24
  295. package/typings/options.d.ts +0 -589
  296. package/typings/paragraphStyle.d.ts +0 -5
  297. package/typings/resizing.d.ts +0 -141
  298. package/typings/selection.d.ts +0 -94
  299. package/typings/shortcuts.d.ts +0 -13
  300. package/typings/suneditor.d.ts +0 -9
  301. package/typings/table.d.ts +0 -5
  302. package/typings/template.d.ts +0 -5
  303. package/typings/textStyle.d.ts +0 -5
  304. package/typings/toolbar.d.ts +0 -32
  305. package/typings/unicode.d.ts +0 -25
  306. package/typings/video.d.ts +0 -5
@@ -0,0 +1,504 @@
1
+ export default Figure;
2
+ export type FigureParams = {
3
+ /**
4
+ * Size unit
5
+ */
6
+ sizeUnit?: string;
7
+ /**
8
+ * Auto ratio { current: '00%', default: '00%' }
9
+ */
10
+ autoRatio?: {
11
+ current: string;
12
+ default: string;
13
+ };
14
+ };
15
+ export type FigureInfo = {
16
+ /**
17
+ * Target element (img, iframe, video, audio, table, etc.)
18
+ */
19
+ target: HTMLElement;
20
+ /**
21
+ * Container element (div.se-component|span.se-component.se-inline-component)
22
+ */
23
+ container: HTMLElement;
24
+ /**
25
+ * Cover element (FIGURE|null)
26
+ */
27
+ cover: HTMLElement | null;
28
+ /**
29
+ * Inline cover element (span.se-inline-component)
30
+ */
31
+ inlineCover: HTMLElement | null;
32
+ /**
33
+ * Caption element (FIGCAPTION)
34
+ */
35
+ caption: HTMLElement | null;
36
+ };
37
+ export type FigureTargetInfo = {
38
+ /**
39
+ * Container element (div.se-component|span.se-component.se-inline-component)
40
+ */
41
+ container: HTMLElement;
42
+ /**
43
+ * Cover element (FIGURE|null)
44
+ */
45
+ cover?: (HTMLElement | null) | undefined;
46
+ /**
47
+ * Caption element (FIGCAPTION)
48
+ */
49
+ caption?: (HTMLElement | null) | undefined;
50
+ /**
51
+ * - Alignment of the element.
52
+ */
53
+ align?: string;
54
+ /**
55
+ * - The aspect ratio of the element.
56
+ */
57
+ ratio?: {
58
+ w: number;
59
+ h: number;
60
+ };
61
+ /**
62
+ * - Width of the element.
63
+ */
64
+ w?: string | number;
65
+ /**
66
+ * - Height of the element.
67
+ */
68
+ h?: string | number;
69
+ /**
70
+ * - Top position.
71
+ */
72
+ t?: number;
73
+ /**
74
+ * - Left position.
75
+ */
76
+ l?: number;
77
+ /**
78
+ * - Width, can be a number or 'auto'.
79
+ */
80
+ width: string | number;
81
+ /**
82
+ * - Height, can be a number or 'auto'.
83
+ */
84
+ height: string | number;
85
+ /**
86
+ * - Original width from `naturalWidth` or `offsetWidth`.
87
+ */
88
+ originWidth?: number;
89
+ /**
90
+ * - Original height from `naturalHeight` or `offsetHeight`.
91
+ */
92
+ originHeight?: number;
93
+ };
94
+ export type FigureControls = Array<
95
+ Array<
96
+ | string
97
+ | {
98
+ action: (element: Node, value: string, target: Node) => void;
99
+ command: string;
100
+ value: string;
101
+ title: string;
102
+ icon: string;
103
+ }
104
+ >
105
+ >;
106
+ /**
107
+ * @typedef {Object} FigureParams
108
+ * @property {string} [sizeUnit="px"] Size unit
109
+ * @property {{ current: string, default: string }} [autoRatio=null] Auto ratio { current: '00%', default: '00%' }
110
+ */
111
+ /**
112
+ * @typedef {Object} FigureInfo
113
+ * @property {HTMLElement} target Target element (img, iframe, video, audio, table, etc.)
114
+ * @property {HTMLElement} container Container element (div.se-component|span.se-component.se-inline-component)
115
+ * @property {?HTMLElement} cover Cover element (FIGURE|null)
116
+ * @property {?HTMLElement} inlineCover Inline cover element (span.se-inline-component)
117
+ * @property {?HTMLElement} caption Caption element (FIGCAPTION)
118
+ */
119
+ /**
120
+ * @typedef {Object} FigureTargetInfo
121
+ * @property {HTMLElement} container Container element (div.se-component|span.se-component.se-inline-component)
122
+ * @property {?HTMLElement=} cover Cover element (FIGURE|null)
123
+ * @property {?HTMLElement=} caption Caption element (FIGCAPTION)
124
+ * @property {string} [align] - Alignment of the element.
125
+ * @property {{w:number, h:number}} [ratio] - The aspect ratio of the element.
126
+ * @property {string|number} [w] - Width of the element.
127
+ * @property {string|number} [h] - Height of the element.
128
+ * @property {number} [t] - Top position.
129
+ * @property {number} [l] - Left position.
130
+ * @property {string|number} width - Width, can be a number or 'auto'.
131
+ * @property {string|number} height - Height, can be a number or 'auto'.
132
+ * @property {number} [originWidth] - Original width from `naturalWidth` or `offsetWidth`.
133
+ * @property {number} [originHeight] - Original height from `naturalHeight` or `offsetHeight`.
134
+ */
135
+ /**
136
+ * @typedef {Array<Array<string|{action: (element: Node, value: string, target: Node) => void, command: string, value: string, title: string, icon: string}>>} FigureControls
137
+ */
138
+ /**
139
+ * @class
140
+ * @description Controller module class
141
+ */
142
+ declare class Figure extends EditorInjector {
143
+ /**
144
+ * @description Create a container for the resizing component and insert the element.
145
+ * @param {Node} element Target element
146
+ * @param {string=} className Class name of container (fixed: se-component)
147
+ * @returns {FigureInfo} {target, container, cover, inlineCover, caption}
148
+ */
149
+ static CreateContainer(element: Node, className?: string | undefined): FigureInfo;
150
+ /**
151
+ * @description Create a container for the inline resizing component and insert the element.
152
+ * @param {Node} element Target element
153
+ * @param {string} [className] Class name of container (fixed: se-component se-inline-component)
154
+ * @returns {FigureInfo} {target, container, cover, inlineCover, caption}
155
+ */
156
+ static CreateInlineContainer(element: Node, className?: string): FigureInfo;
157
+ /**
158
+ * @description Return HTML string of caption(FIGCAPTION) element
159
+ * @param {Node} cover Cover element(FIGURE). "CreateContainer().cover"
160
+ * @returns {HTMLElement} caption element
161
+ */
162
+ static CreateCaption(cover: Node, text: any): HTMLElement;
163
+ /**
164
+ * @description Get the element's container(.se-component) info.
165
+ * @param {Node} element Target element
166
+ * @returns {FigureInfo} {target, container, cover, inlineCover, caption}
167
+ */
168
+ static GetContainer(element: Node): FigureInfo;
169
+ /**
170
+ * @description Ratio calculation
171
+ * @param {string|number} w Width size
172
+ * @param {string|number} h Height size
173
+ * @param {?string=} [defaultSizeUnit="px"] Default size unit (default: "px")
174
+ * @return {{w: number, h: number}}
175
+ */
176
+ static GetRatio(
177
+ w: string | number,
178
+ h: string | number,
179
+ defaultSizeUnit?: (string | null) | undefined
180
+ ): {
181
+ w: number;
182
+ h: number;
183
+ };
184
+ /**
185
+ * @description Ratio calculation
186
+ * @param {string|number} w Width size
187
+ * @param {string|number} h Height size
188
+ * @param {string} defaultSizeUnit Default size unit (default: "px")
189
+ * @param {{w: number, h: number}} ratio Ratio size (Figure.GetRatio)
190
+ * @return {{w: string|number, h: string|number}}
191
+ */
192
+ static CalcRatio(
193
+ w: string | number,
194
+ h: string | number,
195
+ defaultSizeUnit: string,
196
+ ratio: {
197
+ w: number;
198
+ h: number;
199
+ }
200
+ ): {
201
+ w: string | number;
202
+ h: string | number;
203
+ };
204
+ /**
205
+ * @description It is judged whether it is the component[img, iframe, video, audio, table] cover(class="se-component") and table, hr
206
+ * @param {Node} element Target element
207
+ * @returns {boolean}
208
+ */
209
+ static is(element: Node): boolean;
210
+ /**
211
+ * @constructor
212
+ * @param {*} inst The instance object that called the constructor.
213
+ * @param {FigureControls} controls Controller button array
214
+ * @param {FigureParams} params Figure options
215
+ */
216
+ constructor(inst: any, controls: FigureControls, params: FigureParams);
217
+ kind: any;
218
+ _alignIcons: {
219
+ none: string;
220
+ left: string;
221
+ right: string;
222
+ center: string;
223
+ };
224
+ /** @type {Object<string, *>} */
225
+ _action: {
226
+ [x: string]: any;
227
+ };
228
+ controller: Controller;
229
+ alignButton: Element;
230
+ selectMenu_align: SelectMenu;
231
+ asButton: Element;
232
+ selectMenu_as: SelectMenu;
233
+ resizeButton: Element;
234
+ selectMenu_resize: SelectMenu;
235
+ inst: any;
236
+ sizeUnit: string;
237
+ autoRatio: {
238
+ current: string;
239
+ default: string;
240
+ };
241
+ isVertical: boolean;
242
+ percentageButtons: NodeListOf<Element>;
243
+ captionButton: Element;
244
+ align: string;
245
+ as: string;
246
+ _element: HTMLElement;
247
+ _cover: HTMLElement;
248
+ _inlineCover: HTMLElement;
249
+ _container: HTMLElement;
250
+ _caption: any;
251
+ _width: string;
252
+ _height: string;
253
+ _resize_w: number;
254
+ _resize_h: number;
255
+ _element_w: number;
256
+ _element_h: number;
257
+ _element_l: number;
258
+ _element_t: number;
259
+ _resizeClientX: number;
260
+ _resizeClientY: number;
261
+ _resize_direction: string;
262
+ _floatClassStr: string;
263
+ __preventSizechange: boolean;
264
+ __revertSize: {
265
+ w: string;
266
+ h: string;
267
+ };
268
+ /** @type {{left?: number, top?: number}} */
269
+ __offset: {
270
+ left?: number;
271
+ top?: number;
272
+ };
273
+ __offContainer: any;
274
+ __containerResizing: any;
275
+ __containerResizingOff: any;
276
+ __containerResizingESC: any;
277
+ __onContainerEvent: any;
278
+ __offContainerEvent: any;
279
+ __onResizeESCEvent: __se__GlobalEventInfo;
280
+ __fileManagerInfo: boolean;
281
+ /**
282
+ * @description Close the figure's controller
283
+ */
284
+ close(): void;
285
+ /**
286
+ * @description Open the figure's controller
287
+ * @param {Node} targetNode Target element
288
+ * @param {Object} params params
289
+ * @param {boolean} [params.nonResizing=false] Do not display the resizing button
290
+ * @param {boolean} [params.nonSizeInfo=false] Do not display the size information
291
+ * @param {boolean} [params.nonBorder=false] Do not display the selected style line
292
+ * @param {boolean} [params.figureTarget=false] If true, the target is a figure element
293
+ * @param {boolean} [params.__fileManagerInfo=false] If true, the file manager is called
294
+ * @returns {FigureTargetInfo|undefined} figure target info
295
+ */
296
+ open(
297
+ targetNode: Node,
298
+ {
299
+ nonResizing,
300
+ nonSizeInfo,
301
+ nonBorder,
302
+ figureTarget,
303
+ __fileManagerInfo
304
+ }: {
305
+ nonResizing?: boolean;
306
+ nonSizeInfo?: boolean;
307
+ nonBorder?: boolean;
308
+ figureTarget?: boolean;
309
+ __fileManagerInfo?: boolean;
310
+ }
311
+ ): FigureTargetInfo | undefined;
312
+ /**
313
+ * @description Hide the controller
314
+ */
315
+ controllerHide(): void;
316
+ /**
317
+ * @description Hide the controller
318
+ */
319
+ controllerShow(): void;
320
+ /**
321
+ * @description Open the figure's controller
322
+ * @param {Node} target Target element
323
+ * @param {Object} [params={}] params
324
+ * @param {boolean=} params.isWWTarget If the controller is in the WYSIWYG area, set it to true.
325
+ * @param {() => void=} params.initMethod Method to be called when the controller is closed.
326
+ * @param {boolean=} params.disabled If true, the controller is disabled.
327
+ * @param {{left: number, top: number}=} params.addOffset Additional offset values
328
+ */
329
+ controllerOpen(
330
+ target: Node,
331
+ params?: {
332
+ isWWTarget?: boolean | undefined;
333
+ initMethod?: (() => void) | undefined;
334
+ disabled?: boolean | undefined;
335
+ addOffset?:
336
+ | {
337
+ left: number;
338
+ top: number;
339
+ }
340
+ | undefined;
341
+ }
342
+ ): void;
343
+ /**
344
+ * @description Set the element's container size
345
+ * @param {string|number} w Width size
346
+ * @param {string|number} h Height size
347
+ */
348
+ setSize(w: string | number, h: string | number): void;
349
+ /**
350
+ * @description Gets the Figure size
351
+ * @param {?Node=} targetNode Target element, default is the current element
352
+ * @returns {{w: string, h: string}}
353
+ */
354
+ getSize(targetNode?: (Node | null) | undefined): {
355
+ w: string;
356
+ h: string;
357
+ };
358
+ /**
359
+ * @description Align the container.
360
+ * @param {?Node} targetNode Target element
361
+ * @param {string} align "none"|"left"|"center"|"right"
362
+ */
363
+ setAlign(targetNode: Node | null, align: string): void;
364
+ /**
365
+ * @description As style[block, inline] the component
366
+ * @param {?Node} targetNode Target element
367
+ * @param {"block"|"inline"} formatStyle Format style
368
+ */
369
+ convertAsFormat(targetNode: Node | null, formatStyle: 'block' | 'inline'): void;
370
+ /**
371
+ * @private
372
+ * @description Handles format conversion (block/inline) for the figure component and applies size changes.
373
+ * @param {FigureInfo} figureinfo {target, container, cover, inlineCover, caption}
374
+ * @param {string|number} w Width value.
375
+ * @param {string|number} h Height value.
376
+ */
377
+ private _asFormatChange;
378
+ /**
379
+ * @description Controller button action
380
+ * @param {HTMLButtonElement} target Target button element
381
+ * @returns
382
+ */
383
+ controllerAction(target: HTMLButtonElement): void;
384
+ /**
385
+ * @description Inspect the figure component format and change it to the correct format.
386
+ * @param {Node} container - The container element of the figure component.
387
+ * @param {Node} originEl - The original element of the figure component.
388
+ * @param {Node} anchorCover - The anchor cover element of the figure component.
389
+ * @param {import('./FileManager').default} [fileManagerInst=null] - FileManager module instance, if used.
390
+ */
391
+ retainFigureFormat(container: Node, originEl: Node, anchorCover: Node, fileManagerInst?: import('./FileManager').default): void;
392
+ /**
393
+ * @description Initialize the transform style (rotation) of the element.
394
+ * @param {?Node=} node Target element, default is the current element
395
+ */
396
+ deleteTransform(node?: (Node | null) | undefined): void;
397
+ /**
398
+ * @description Set the transform style (rotation) of the element.
399
+ * @param {Node} node Target element
400
+ * @param {?string|number} width Element's width size
401
+ * @param {?string|number} height Element's height size
402
+ */
403
+ setTransform(node: Node, width: (string | number) | null, height: (string | number) | null, deg: any): void;
404
+ /**
405
+ * @private
406
+ * @description Sets figure component properties such as cover, container, caption, and alignment.
407
+ * @param {FigureInfo} figureInfo - {target, container, cover, inlineCover, caption}
408
+ */
409
+ private _setFigureInfo;
410
+ /**
411
+ * @private
412
+ * @description Applies rotation transformation to the target element.
413
+ * @param {HTMLElement} element Target element.
414
+ * @param {number} r Rotation degree.
415
+ * @param {number} x X-axis rotation value.
416
+ * @param {number} y Y-axis rotation value.
417
+ */
418
+ private _setRotate;
419
+ /**
420
+ * @private
421
+ * @description Applies size adjustments to the figure element.
422
+ * @param {string|number} w Width value.
423
+ * @param {string|number} h Height value.
424
+ * @param {string} direction Resize direction.
425
+ */
426
+ private _applySize;
427
+ /**
428
+ * @private
429
+ * @description Sets padding-bottom for cover elements based on width and height.
430
+ * @param {string} w Width value.
431
+ * @param {string} h Height value.
432
+ */
433
+ private __setCoverPaddingBottom;
434
+ /**
435
+ * @private
436
+ * @description Sets the figure element to its auto size.
437
+ */
438
+ private _setAutoSize;
439
+ /**
440
+ * @private
441
+ * @description Sets the figure element's size in percentage.
442
+ * @param {string|number} w Width percentage.
443
+ * @param {string|number} h Height percentage.
444
+ */
445
+ private _setPercentSize;
446
+ /**
447
+ * @private
448
+ * @description Deletes percentage-based sizing from the figure element.
449
+ */
450
+ private _deletePercentSize;
451
+ /**
452
+ * @private
453
+ * @description Reverts the figure element to its previously saved size.
454
+ */
455
+ private _setRevert;
456
+ /**
457
+ * @private
458
+ * @description Updates the figure's alignment icon.
459
+ */
460
+ private _setAlignIcon;
461
+ /**
462
+ * @private
463
+ * @description Updates the figure's block/inline format icon.
464
+ */
465
+ private _setAsIcon;
466
+ /**
467
+ * @private
468
+ * @description Saves the current size of the figure component.
469
+ */
470
+ private _saveCurrentSize;
471
+ /**
472
+ * @private
473
+ * @description Adjusts the position of the caption within the figure.
474
+ * @param {HTMLElement} element Target element.
475
+ */
476
+ private _setCaptionPosition;
477
+ /**
478
+ * @private
479
+ * @description Removes the margin top property from the figure caption.
480
+ * @param {HTMLElement} element Target element.
481
+ */
482
+ private _deleteCaptionPosition;
483
+ /**
484
+ * @private
485
+ * @description Displays or hides the resize handles of the figure component.
486
+ * @param {boolean} display Whether to display resize handles.
487
+ */
488
+ private _displayResizeHandles;
489
+ /**
490
+ * @private
491
+ * @description Removes the resize event listeners.
492
+ */
493
+ private _offResizeEvent;
494
+ /**
495
+ * @private
496
+ * @description Sets up drag event handling for the figure component.
497
+ * @param {Node} figureMain The main figure container element.
498
+ */
499
+ private _setDragEvent;
500
+ #private;
501
+ }
502
+ import EditorInjector from '../editorInjector';
503
+ import { Controller } from '../modules';
504
+ import { SelectMenu } from '../modules';
@@ -0,0 +1,202 @@
1
+ export default FileManager;
2
+ export type FileStateInfo = {
3
+ /**
4
+ * File source
5
+ */
6
+ src: string;
7
+ /**
8
+ * File index
9
+ */
10
+ index: number;
11
+ /**
12
+ * File name
13
+ */
14
+ name: string;
15
+ /**
16
+ * File size
17
+ */
18
+ size: number;
19
+ };
20
+ export type FileStateParams = {
21
+ /**
22
+ * - The root editor instance
23
+ */
24
+ editor: __se__EditorCore;
25
+ /**
26
+ * File element
27
+ */
28
+ element: Node;
29
+ /**
30
+ * File index
31
+ */
32
+ index: number;
33
+ /**
34
+ * File state ("create"|"update"|"delete")
35
+ */
36
+ state: string;
37
+ /**
38
+ * File information
39
+ */
40
+ info: FileStateInfo;
41
+ /**
42
+ * Remaining file count
43
+ */
44
+ remainingFilesCount: number;
45
+ /**
46
+ * Plugin name
47
+ */
48
+ pluginName: string;
49
+ };
50
+ export type FileManagerParams = {
51
+ /**
52
+ * The query selector used to find file elements in the editor
53
+ */
54
+ query: string;
55
+ /**
56
+ * A function to handle the loaded file information
57
+ */
58
+ loadHandler?: ((params: Array<FileStateInfo>) => void) | undefined;
59
+ /**
60
+ * A function to handle file-related events
61
+ */
62
+ eventHandler?: ((info: FileStateParams) => void) | undefined;
63
+ };
64
+ /**
65
+ * @typedef {Object} FileStateInfo
66
+ * @property {string} src File source
67
+ * @property {number} index File index
68
+ * @property {string} name File name
69
+ * @property {number} size File size
70
+ */
71
+ /**
72
+ * @typedef {Object} FileStateParams
73
+ * @property {__se__EditorCore} editor - The root editor instance
74
+ * @property {Node} element File element
75
+ * @property {number} index File index
76
+ * @property {string} state File state ("create"|"update"|"delete")
77
+ * @property {FileStateInfo} info File information
78
+ * @property {number} remainingFilesCount Remaining file count
79
+ * @property {string} pluginName Plugin name
80
+ */
81
+ /**
82
+ * @typedef {Object} FileManagerParams
83
+ * @property {string} query The query selector used to find file elements in the editor
84
+ * @property {(params: Array<FileStateInfo>) => void=} loadHandler A function to handle the loaded file information
85
+ * @property {(info: FileStateParams) => void=} eventHandler A function to handle file-related events
86
+ */
87
+ /**
88
+ * @class
89
+ * @description This module manages the file information of the editor.
90
+ */
91
+ declare class FileManager extends CoreInjector {
92
+ /**
93
+ * @constructor
94
+ * @param {*} inst The instance object that called the constructor.
95
+ * @param {FileManagerParams} params FileManager options
96
+ */
97
+ constructor(inst: any, params: FileManagerParams);
98
+ ui: import('../core/class/ui').default;
99
+ kind: any;
100
+ inst: any;
101
+ component: any;
102
+ query: string;
103
+ loadHandler: (params: Array<FileStateInfo>) => void;
104
+ eventHandler: (info: FileStateParams) => void;
105
+ infoList: any[];
106
+ infoIndex: number;
107
+ uploadFileLength: number;
108
+ __updateTags: any[];
109
+ apiManager: ApiManager;
110
+ /**
111
+ * @description Upload the file to the server.
112
+ * @param {string} uploadUrl Upload server url
113
+ * @param {?Object<string, string>} uploadHeader Request header
114
+ * @param {FileList|File[]|{formData: FormData, size: number}} data FormData in body or Files array
115
+ * @param {?(xmlHttp: XMLHttpRequest) => boolean=} callBack Success call back function
116
+ * @param {?(res: *, xmlHttp: XMLHttpRequest) => string=} errorCallBack Error call back function
117
+ */
118
+ upload(
119
+ uploadUrl: string,
120
+ uploadHeader: {
121
+ [x: string]: string;
122
+ } | null,
123
+ data:
124
+ | FileList
125
+ | File[]
126
+ | {
127
+ formData: FormData;
128
+ size: number;
129
+ },
130
+ callBack?: (((xmlHttp: XMLHttpRequest) => boolean) | null) | undefined,
131
+ errorCallBack?: (((res: any, xmlHttp: XMLHttpRequest) => string) | null) | undefined
132
+ ): void;
133
+ /**
134
+ * @description Upload the file to the server.
135
+ * @param {string} uploadUrl Upload server url
136
+ * @param {?Object<string, string>} uploadHeader Request header
137
+ * @param {FileList|File[]|{formData: FormData, size: number}} data FormData in body or Files array
138
+ * @returns {Promise<XMLHttpRequest>}
139
+ */
140
+ asyncUpload(
141
+ uploadUrl: string,
142
+ uploadHeader: {
143
+ [x: string]: string;
144
+ } | null,
145
+ data:
146
+ | FileList
147
+ | File[]
148
+ | {
149
+ formData: FormData;
150
+ size: number;
151
+ }
152
+ ): Promise<XMLHttpRequest>;
153
+ /**
154
+ * @description Set the file information to the element.
155
+ * @param {Node} element File information element
156
+ * @param {Object} params
157
+ * @param {string} params.name File name
158
+ * @param {number} params.size File size
159
+ * @returns
160
+ */
161
+ setFileData(
162
+ element: Node,
163
+ {
164
+ name,
165
+ size
166
+ }: {
167
+ name: string;
168
+ size: number;
169
+ }
170
+ ): void;
171
+ /**
172
+ * @private
173
+ * @description Create info object of file and add it to "infoList"
174
+ * @param {HTMLMediaElement} element
175
+ * @param {{name: string, size: number}|null} file File information
176
+ */
177
+ private _setInfo;
178
+ /**
179
+ * @description Gets the sum of the sizes of the currently saved files.
180
+ * @returns {number} Size
181
+ */
182
+ getSize(): number;
183
+ /**
184
+ * @private
185
+ * @description Checke the file's information and modify the tag that does not fit the format.
186
+ * @param {boolean} loaded Whether the editor is loaded
187
+ */
188
+ private _checkInfo;
189
+ /**
190
+ * @private
191
+ * @description Reset info object and "infoList = []", "infoIndex = 0"
192
+ */
193
+ private _resetInfo;
194
+ /**
195
+ * @private
196
+ * @description Delete info object at "infoList"
197
+ * @param {number} index index of info object infoList[].index)
198
+ */
199
+ private _deleteInfo;
200
+ }
201
+ import CoreInjector from '../editorInjector/_core';
202
+ import ApiManager from './ApiManager';