suneditor 3.0.0-beta.9 → 3.0.0-rc.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 (380) hide show
  1. package/README.md +65 -57
  2. package/dist/suneditor-contents.min.css +1 -0
  3. package/dist/suneditor.min.css +1 -1
  4. package/dist/suneditor.min.js +1 -1
  5. package/package.json +110 -61
  6. package/src/assets/design/color.css +36 -17
  7. package/src/assets/design/size.css +2 -0
  8. package/src/assets/icons/defaultIcons.js +17 -2
  9. package/src/assets/suneditor-contents.css +51 -16
  10. package/src/assets/suneditor.css +116 -43
  11. package/src/core/config/contextProvider.js +288 -0
  12. package/src/core/config/eventManager.js +188 -0
  13. package/src/core/config/instanceCheck.js +59 -0
  14. package/src/core/config/optionProvider.js +452 -0
  15. package/src/core/editor.js +166 -1637
  16. package/src/core/event/actions/index.js +229 -0
  17. package/src/core/event/effects/common.registry.js +74 -0
  18. package/src/core/event/effects/keydown.registry.js +573 -0
  19. package/src/core/event/effects/ruleHelpers.js +148 -0
  20. package/src/core/event/eventOrchestrator.js +944 -0
  21. package/src/core/event/executor.js +27 -0
  22. package/src/core/{base/eventHandlers → event/handlers}/handler_toolbar.js +27 -28
  23. package/src/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.js +10 -8
  24. package/src/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.js +22 -23
  25. package/src/core/event/handlers/handler_ww_input.js +75 -0
  26. package/src/core/event/handlers/handler_ww_key.js +228 -0
  27. package/src/core/event/handlers/handler_ww_mouse.js +166 -0
  28. package/src/core/event/ports.js +211 -0
  29. package/src/core/event/reducers/keydown.reducer.js +97 -0
  30. package/src/core/event/rules/keydown.rule.arrow.js +63 -0
  31. package/src/core/event/rules/keydown.rule.backspace.js +208 -0
  32. package/src/core/event/rules/keydown.rule.delete.js +132 -0
  33. package/src/core/event/rules/keydown.rule.enter.js +150 -0
  34. package/src/core/event/rules/keydown.rule.tab.js +35 -0
  35. package/src/core/event/support/defaultLineManager.js +136 -0
  36. package/src/core/event/support/selectionState.js +204 -0
  37. package/src/core/kernel/coreKernel.js +320 -0
  38. package/src/core/kernel/kernelInjector.js +19 -0
  39. package/src/core/kernel/store.js +173 -0
  40. package/src/core/{class → logic/dom}/char.js +42 -45
  41. package/src/core/logic/dom/format.js +1075 -0
  42. package/src/core/{class → logic/dom}/html.js +743 -624
  43. package/src/core/logic/dom/inline.js +1847 -0
  44. package/src/core/logic/dom/listFormat.js +601 -0
  45. package/src/core/{class → logic/dom}/nodeTransform.js +92 -72
  46. package/src/core/{class → logic/dom}/offset.js +254 -317
  47. package/src/core/logic/dom/selection.js +754 -0
  48. package/src/core/logic/panel/menu.js +389 -0
  49. package/src/core/logic/panel/toolbar.js +449 -0
  50. package/src/core/logic/panel/viewer.js +761 -0
  51. package/src/core/logic/shell/_commandExecutor.js +380 -0
  52. package/src/core/logic/shell/commandDispatcher.js +241 -0
  53. package/src/core/logic/shell/component.js +970 -0
  54. package/src/core/logic/shell/focusManager.js +110 -0
  55. package/src/core/{base → logic/shell}/history.js +110 -60
  56. package/src/core/logic/shell/pluginManager.js +363 -0
  57. package/src/core/logic/shell/shortcuts.js +130 -0
  58. package/src/core/logic/shell/ui.js +904 -0
  59. package/src/core/schema/context.js +66 -0
  60. package/src/core/schema/frameContext.js +160 -0
  61. package/src/core/schema/options.js +628 -0
  62. package/src/core/section/constructor.js +194 -500
  63. package/src/core/section/documentType.js +297 -222
  64. package/src/events.js +808 -543
  65. package/src/helper/clipboard.js +27 -16
  66. package/src/helper/converter.js +100 -78
  67. package/src/helper/dom/domCheck.js +56 -30
  68. package/src/helper/dom/domQuery.js +159 -89
  69. package/src/helper/dom/domUtils.js +114 -49
  70. package/src/helper/dom/index.js +5 -1
  71. package/src/helper/env.js +26 -26
  72. package/src/helper/index.js +1 -1
  73. package/src/helper/keyCodeMap.js +25 -28
  74. package/src/helper/numbers.js +4 -8
  75. package/src/helper/unicode.js +4 -8
  76. package/src/hooks/base.js +307 -0
  77. package/src/hooks/params.js +130 -0
  78. package/src/interfaces/contracts.js +227 -0
  79. package/src/interfaces/index.js +7 -0
  80. package/src/interfaces/plugins.js +239 -0
  81. package/src/langs/ckb.js +4 -4
  82. package/src/langs/cs.js +4 -4
  83. package/src/langs/da.js +4 -4
  84. package/src/langs/de.js +4 -4
  85. package/src/langs/en.js +4 -4
  86. package/src/langs/es.js +4 -4
  87. package/src/langs/fa.js +4 -4
  88. package/src/langs/fr.js +4 -4
  89. package/src/langs/he.js +4 -4
  90. package/src/langs/hu.js +4 -4
  91. package/src/langs/it.js +4 -4
  92. package/src/langs/ja.js +4 -4
  93. package/src/langs/km.js +4 -4
  94. package/src/langs/ko.js +4 -4
  95. package/src/langs/lv.js +4 -4
  96. package/src/langs/nl.js +4 -4
  97. package/src/langs/pl.js +4 -4
  98. package/src/langs/pt_br.js +13 -13
  99. package/src/langs/ro.js +4 -4
  100. package/src/langs/ru.js +4 -4
  101. package/src/langs/se.js +4 -4
  102. package/src/langs/tr.js +4 -4
  103. package/src/langs/uk.js +4 -4
  104. package/src/langs/ur.js +4 -4
  105. package/src/langs/zh_cn.js +4 -4
  106. package/src/modules/{Browser.js → contract/Browser.js} +119 -128
  107. package/src/modules/{ColorPicker.js → contract/ColorPicker.js} +132 -142
  108. package/src/modules/contract/Controller.js +589 -0
  109. package/src/modules/{Figure.js → contract/Figure.js} +591 -411
  110. package/src/modules/{HueSlider.js → contract/HueSlider.js} +125 -86
  111. package/src/modules/contract/Modal.js +357 -0
  112. package/src/modules/contract/index.js +9 -0
  113. package/src/modules/manager/ApiManager.js +197 -0
  114. package/src/modules/{FileManager.js → manager/FileManager.js} +128 -160
  115. package/src/modules/manager/index.js +5 -0
  116. package/src/modules/{ModalAnchorEditor.js → ui/ModalAnchorEditor.js} +108 -138
  117. package/src/modules/{SelectMenu.js → ui/SelectMenu.js} +119 -120
  118. package/src/modules/{_DragHandle.js → ui/_DragHandle.js} +1 -1
  119. package/src/modules/ui/index.js +6 -0
  120. package/src/plugins/browser/audioGallery.js +23 -26
  121. package/src/plugins/browser/fileBrowser.js +25 -28
  122. package/src/plugins/browser/fileGallery.js +20 -23
  123. package/src/plugins/browser/imageGallery.js +24 -23
  124. package/src/plugins/browser/videoGallery.js +27 -29
  125. package/src/plugins/command/blockquote.js +11 -17
  126. package/src/plugins/command/exportPDF.js +26 -26
  127. package/src/plugins/command/fileUpload.js +138 -133
  128. package/src/plugins/command/list_bulleted.js +48 -44
  129. package/src/plugins/command/list_numbered.js +48 -44
  130. package/src/plugins/dropdown/align.js +64 -50
  131. package/src/plugins/dropdown/backgroundColor.js +34 -35
  132. package/src/plugins/dropdown/{formatBlock.js → blockStyle.js} +43 -37
  133. package/src/plugins/dropdown/font.js +50 -36
  134. package/src/plugins/dropdown/fontColor.js +34 -35
  135. package/src/plugins/dropdown/hr.js +55 -50
  136. package/src/plugins/dropdown/layout.js +20 -15
  137. package/src/plugins/dropdown/lineHeight.js +46 -30
  138. package/src/plugins/dropdown/list.js +32 -33
  139. package/src/plugins/dropdown/paragraphStyle.js +40 -34
  140. package/src/plugins/dropdown/table/index.js +915 -0
  141. package/src/plugins/dropdown/table/render/table.html.js +308 -0
  142. package/src/plugins/dropdown/table/render/table.menu.js +121 -0
  143. package/src/plugins/dropdown/table/services/table.cell.js +465 -0
  144. package/src/plugins/dropdown/table/services/table.clipboard.js +414 -0
  145. package/src/plugins/dropdown/table/services/table.grid.js +504 -0
  146. package/src/plugins/dropdown/table/services/table.resize.js +463 -0
  147. package/src/plugins/dropdown/table/services/table.selection.js +466 -0
  148. package/src/plugins/dropdown/table/services/table.style.js +844 -0
  149. package/src/plugins/dropdown/table/shared/table.constants.js +109 -0
  150. package/src/plugins/dropdown/table/shared/table.utils.js +219 -0
  151. package/src/plugins/dropdown/template.js +20 -15
  152. package/src/plugins/dropdown/textStyle.js +28 -22
  153. package/src/plugins/field/mention.js +54 -49
  154. package/src/plugins/index.js +5 -5
  155. package/src/plugins/input/fontSize.js +100 -97
  156. package/src/plugins/input/pageNavigator.js +13 -10
  157. package/src/plugins/modal/audio.js +208 -219
  158. package/src/plugins/modal/drawing.js +99 -104
  159. package/src/plugins/modal/embed.js +323 -312
  160. package/src/plugins/modal/image/index.js +942 -0
  161. package/src/plugins/modal/image/render/image.html.js +150 -0
  162. package/src/plugins/modal/image/services/image.size.js +198 -0
  163. package/src/plugins/modal/image/services/image.upload.js +216 -0
  164. package/src/plugins/modal/image/shared/image.constants.js +20 -0
  165. package/src/plugins/modal/link.js +74 -54
  166. package/src/plugins/modal/math.js +126 -119
  167. package/src/plugins/modal/video/index.js +858 -0
  168. package/src/plugins/modal/video/render/video.html.js +131 -0
  169. package/src/plugins/modal/video/services/video.size.js +281 -0
  170. package/src/plugins/modal/video/services/video.upload.js +92 -0
  171. package/src/plugins/popup/anchor.js +57 -49
  172. package/src/suneditor.js +73 -61
  173. package/src/themes/cobalt.css +155 -0
  174. package/src/themes/dark.css +143 -120
  175. package/src/typedef.js +214 -63
  176. package/types/assets/icons/defaultIcons.d.ts +8 -0
  177. package/types/assets/suneditor-contents.css.d.ts +1 -0
  178. package/types/assets/suneditor.css.d.ts +1 -0
  179. package/types/core/config/contextProvider.d.ts +148 -0
  180. package/types/core/config/eventManager.d.ts +68 -0
  181. package/types/core/config/instanceCheck.d.ts +33 -0
  182. package/types/core/config/optionProvider.d.ts +147 -0
  183. package/types/core/editor.d.ts +27 -586
  184. package/types/core/event/actions/index.d.ts +50 -0
  185. package/types/core/event/effects/common.registry.d.ts +56 -0
  186. package/types/core/event/effects/keydown.registry.d.ts +80 -0
  187. package/types/core/event/effects/ruleHelpers.d.ts +36 -0
  188. package/types/core/event/eventOrchestrator.d.ts +191 -0
  189. package/types/core/event/executor.d.ts +13 -0
  190. package/types/core/event/handlers/handler_toolbar.d.ts +38 -0
  191. package/types/core/event/handlers/handler_ww_clipboard.d.ts +36 -0
  192. package/types/core/event/handlers/handler_ww_dragDrop.d.ts +26 -0
  193. package/types/core/event/handlers/handler_ww_input.d.ts +38 -0
  194. package/types/core/event/handlers/handler_ww_key.d.ts +40 -0
  195. package/types/core/event/handlers/handler_ww_mouse.d.ts +47 -0
  196. package/types/core/event/ports.d.ts +256 -0
  197. package/types/core/event/reducers/keydown.reducer.d.ts +84 -0
  198. package/types/core/event/rules/keydown.rule.arrow.d.ts +19 -0
  199. package/types/core/event/rules/keydown.rule.backspace.d.ts +18 -0
  200. package/types/core/event/rules/keydown.rule.delete.d.ts +18 -0
  201. package/types/core/event/rules/keydown.rule.enter.d.ts +18 -0
  202. package/types/core/event/rules/keydown.rule.tab.d.ts +18 -0
  203. package/types/core/event/support/defaultLineManager.d.ts +22 -0
  204. package/types/core/event/support/selectionState.d.ts +29 -0
  205. package/types/core/kernel/coreKernel.d.ts +219 -0
  206. package/types/core/kernel/kernelInjector.d.ts +16 -0
  207. package/types/core/kernel/store.d.ts +170 -0
  208. package/types/core/logic/dom/char.d.ts +46 -0
  209. package/types/core/logic/dom/format.d.ts +234 -0
  210. package/types/core/logic/dom/html.d.ts +290 -0
  211. package/types/core/logic/dom/inline.d.ts +93 -0
  212. package/types/core/logic/dom/listFormat.d.ts +101 -0
  213. package/types/core/logic/dom/nodeTransform.d.ts +110 -0
  214. package/types/core/logic/dom/offset.d.ts +335 -0
  215. package/types/core/logic/dom/selection.d.ts +165 -0
  216. package/types/core/logic/panel/menu.d.ts +93 -0
  217. package/types/core/logic/panel/toolbar.d.ts +128 -0
  218. package/types/core/logic/panel/viewer.d.ts +89 -0
  219. package/types/core/logic/shell/_commandExecutor.d.ts +18 -0
  220. package/types/core/logic/shell/commandDispatcher.d.ts +65 -0
  221. package/types/core/logic/shell/component.d.ts +182 -0
  222. package/types/core/logic/shell/focusManager.d.ts +31 -0
  223. package/types/core/{base → logic/shell}/history.d.ts +13 -12
  224. package/types/core/logic/shell/pluginManager.d.ts +115 -0
  225. package/types/core/logic/shell/shortcuts.d.ts +131 -0
  226. package/types/core/logic/shell/ui.d.ts +261 -0
  227. package/types/core/schema/context.d.ts +104 -0
  228. package/types/core/schema/frameContext.d.ts +320 -0
  229. package/types/core/schema/options.d.ts +1241 -0
  230. package/types/core/section/constructor.d.ts +117 -652
  231. package/types/core/section/documentType.d.ts +43 -61
  232. package/types/events.d.ts +796 -65
  233. package/types/helper/clipboard.d.ts +5 -4
  234. package/types/helper/converter.d.ts +55 -43
  235. package/types/helper/dom/domCheck.d.ts +27 -19
  236. package/types/helper/dom/domQuery.d.ts +76 -57
  237. package/types/helper/dom/domUtils.d.ts +62 -39
  238. package/types/helper/dom/index.d.ts +87 -1
  239. package/types/helper/env.d.ts +16 -13
  240. package/types/helper/index.d.ts +8 -2
  241. package/types/helper/keyCodeMap.d.ts +24 -23
  242. package/types/helper/numbers.d.ts +4 -6
  243. package/types/helper/unicode.d.ts +4 -3
  244. package/types/hooks/base.d.ts +239 -0
  245. package/types/hooks/params.d.ts +65 -0
  246. package/types/index.d.ts +20 -117
  247. package/types/interfaces/contracts.d.ts +183 -0
  248. package/types/interfaces/index.d.ts +3 -0
  249. package/types/interfaces/plugins.d.ts +168 -0
  250. package/types/langs/_Lang.d.ts +2 -2
  251. package/types/langs/index.d.ts +2 -2
  252. package/types/modules/contract/Browser.d.ts +262 -0
  253. package/types/modules/contract/ColorPicker.d.ts +99 -0
  254. package/types/modules/contract/Controller.d.ts +204 -0
  255. package/types/modules/contract/Figure.d.ts +529 -0
  256. package/types/modules/{HueSlider.d.ts → contract/HueSlider.d.ts} +39 -28
  257. package/types/modules/contract/Modal.d.ts +62 -0
  258. package/types/modules/contract/index.d.ts +7 -0
  259. package/types/modules/manager/ApiManager.d.ts +106 -0
  260. package/types/modules/manager/FileManager.d.ts +124 -0
  261. package/types/modules/manager/index.d.ts +3 -0
  262. package/types/modules/ui/ModalAnchorEditor.d.ts +152 -0
  263. package/types/modules/ui/SelectMenu.d.ts +107 -0
  264. package/types/modules/{_DragHandle.d.ts → ui/_DragHandle.d.ts} +1 -0
  265. package/types/modules/ui/index.d.ts +4 -0
  266. package/types/plugins/browser/audioGallery.d.ts +33 -41
  267. package/types/plugins/browser/fileBrowser.d.ts +42 -50
  268. package/types/plugins/browser/fileGallery.d.ts +33 -41
  269. package/types/plugins/browser/imageGallery.d.ts +30 -37
  270. package/types/plugins/browser/videoGallery.d.ts +33 -41
  271. package/types/plugins/command/blockquote.d.ts +4 -21
  272. package/types/plugins/command/exportPDF.d.ts +23 -33
  273. package/types/plugins/command/fileUpload.d.ts +80 -100
  274. package/types/plugins/command/list_bulleted.d.ts +9 -35
  275. package/types/plugins/command/list_numbered.d.ts +9 -35
  276. package/types/plugins/dropdown/align.d.ts +23 -46
  277. package/types/plugins/dropdown/backgroundColor.d.ts +35 -53
  278. package/types/plugins/dropdown/blockStyle.d.ts +45 -0
  279. package/types/plugins/dropdown/font.d.ts +18 -41
  280. package/types/plugins/dropdown/fontColor.d.ts +35 -53
  281. package/types/plugins/dropdown/hr.d.ts +26 -52
  282. package/types/plugins/dropdown/layout.d.ts +19 -25
  283. package/types/plugins/dropdown/lineHeight.d.ts +21 -39
  284. package/types/plugins/dropdown/list.d.ts +6 -34
  285. package/types/plugins/dropdown/paragraphStyle.d.ts +34 -45
  286. package/types/plugins/dropdown/table/index.d.ts +158 -0
  287. package/types/plugins/dropdown/table/render/table.html.d.ts +71 -0
  288. package/types/plugins/dropdown/table/render/table.menu.d.ts +59 -0
  289. package/types/plugins/dropdown/table/services/table.cell.d.ts +76 -0
  290. package/types/plugins/dropdown/table/services/table.clipboard.d.ts +26 -0
  291. package/types/plugins/dropdown/table/services/table.grid.d.ts +77 -0
  292. package/types/plugins/dropdown/table/services/table.resize.d.ts +72 -0
  293. package/types/plugins/dropdown/table/services/table.selection.d.ts +59 -0
  294. package/types/plugins/dropdown/table/services/table.style.d.ts +162 -0
  295. package/types/plugins/dropdown/table/shared/table.constants.d.ts +134 -0
  296. package/types/plugins/dropdown/table/shared/table.utils.d.ts +91 -0
  297. package/types/plugins/dropdown/template.d.ts +19 -25
  298. package/types/plugins/dropdown/textStyle.d.ts +23 -30
  299. package/types/plugins/field/mention.d.ts +66 -72
  300. package/types/plugins/index.d.ts +41 -40
  301. package/types/plugins/input/fontSize.d.ts +57 -96
  302. package/types/plugins/input/pageNavigator.d.ts +5 -8
  303. package/types/plugins/modal/audio.d.ts +60 -153
  304. package/types/plugins/modal/drawing.d.ts +16 -118
  305. package/types/plugins/modal/embed.d.ts +46 -166
  306. package/types/plugins/modal/image/index.d.ts +281 -0
  307. package/types/plugins/modal/image/render/image.html.d.ts +45 -0
  308. package/types/plugins/modal/image/services/image.size.d.ts +55 -0
  309. package/types/plugins/modal/image/services/image.upload.d.ts +24 -0
  310. package/types/plugins/modal/image/shared/image.constants.d.ts +17 -0
  311. package/types/plugins/modal/link.d.ts +46 -66
  312. package/types/plugins/modal/math.d.ts +17 -86
  313. package/types/plugins/modal/{video.d.ts → video/index.d.ts} +89 -221
  314. package/types/plugins/modal/video/render/video.html.d.ts +37 -0
  315. package/types/plugins/modal/video/services/video.size.d.ts +74 -0
  316. package/types/plugins/modal/video/services/video.upload.d.ts +19 -0
  317. package/types/plugins/popup/anchor.d.ts +8 -38
  318. package/types/suneditor.d.ts +55 -24
  319. package/types/typedef.d.ts +344 -228
  320. package/CONTRIBUTING.md +0 -186
  321. package/src/core/base/eventHandlers/handler_ww_key_input.js +0 -1200
  322. package/src/core/base/eventHandlers/handler_ww_mouse.js +0 -194
  323. package/src/core/base/eventManager.js +0 -1523
  324. package/src/core/class/component.js +0 -856
  325. package/src/core/class/format.js +0 -3433
  326. package/src/core/class/menu.js +0 -346
  327. package/src/core/class/selection.js +0 -610
  328. package/src/core/class/shortcuts.js +0 -98
  329. package/src/core/class/toolbar.js +0 -431
  330. package/src/core/class/ui.js +0 -424
  331. package/src/core/class/viewer.js +0 -750
  332. package/src/core/section/actives.js +0 -266
  333. package/src/core/section/context.js +0 -102
  334. package/src/editorInjector/_classes.js +0 -36
  335. package/src/editorInjector/_core.js +0 -87
  336. package/src/editorInjector/index.js +0 -73
  337. package/src/modules/ApiManager.js +0 -191
  338. package/src/modules/Controller.js +0 -474
  339. package/src/modules/Modal.js +0 -346
  340. package/src/modules/index.js +0 -14
  341. package/src/plugins/dropdown/table.js +0 -4034
  342. package/src/plugins/modal/image.js +0 -1376
  343. package/src/plugins/modal/video.js +0 -1226
  344. package/types/core/base/eventHandlers/handler_toolbar.d.ts +0 -41
  345. package/types/core/base/eventHandlers/handler_ww_clipboard.d.ts +0 -40
  346. package/types/core/base/eventHandlers/handler_ww_dragDrop.d.ts +0 -35
  347. package/types/core/base/eventHandlers/handler_ww_key_input.d.ts +0 -45
  348. package/types/core/base/eventHandlers/handler_ww_mouse.d.ts +0 -39
  349. package/types/core/base/eventManager.d.ts +0 -401
  350. package/types/core/class/char.d.ts +0 -61
  351. package/types/core/class/component.d.ts +0 -213
  352. package/types/core/class/format.d.ts +0 -623
  353. package/types/core/class/html.d.ts +0 -430
  354. package/types/core/class/menu.d.ts +0 -126
  355. package/types/core/class/nodeTransform.d.ts +0 -93
  356. package/types/core/class/offset.d.ts +0 -522
  357. package/types/core/class/selection.d.ts +0 -188
  358. package/types/core/class/shortcuts.d.ts +0 -142
  359. package/types/core/class/toolbar.d.ts +0 -189
  360. package/types/core/class/ui.d.ts +0 -164
  361. package/types/core/class/viewer.d.ts +0 -140
  362. package/types/core/section/actives.d.ts +0 -46
  363. package/types/core/section/context.d.ts +0 -45
  364. package/types/editorInjector/_classes.d.ts +0 -41
  365. package/types/editorInjector/_core.d.ts +0 -87
  366. package/types/editorInjector/index.d.ts +0 -69
  367. package/types/modules/ApiManager.d.ts +0 -125
  368. package/types/modules/Browser.d.ts +0 -326
  369. package/types/modules/ColorPicker.d.ts +0 -135
  370. package/types/modules/Controller.d.ts +0 -251
  371. package/types/modules/Figure.d.ts +0 -517
  372. package/types/modules/FileManager.d.ts +0 -202
  373. package/types/modules/Modal.d.ts +0 -111
  374. package/types/modules/ModalAnchorEditor.d.ts +0 -236
  375. package/types/modules/SelectMenu.d.ts +0 -194
  376. package/types/modules/index.d.ts +0 -26
  377. package/types/plugins/dropdown/formatBlock.d.ts +0 -55
  378. package/types/plugins/dropdown/table.d.ts +0 -627
  379. package/types/plugins/modal/image.d.ts +0 -451
  380. /package/{LICENSE → LICENSE.txt} +0 -0
@@ -1,18 +1,18 @@
1
- import EditorInjector from '../../editorInjector';
2
- import { Modal } from '../../modules';
1
+ import { PluginModal } from '../../interfaces';
2
+ import { Modal } from '../../modules/contract';
3
3
  import { dom, env } from '../../helper';
4
4
 
5
- const { _w, isMobile } = env;
5
+ const { _w } = env;
6
6
 
7
7
  /**
8
8
  * @typedef {Object} DrawingPluginOptions
9
- * @property {string} [outputFormat="dataurl"] - The output format of the drawing. Options: "dataurl", "svg".
10
- * @property {boolean} [useFormatType=false] - Whether to enable format type selection (block vs inline).
11
- * @property {string} [defaultFormatType="block"] - The default format type, either "block" or "inline".
9
+ * @property {string} [outputFormat="dataurl"] - The output format of the drawing. Options: `"dataurl"`, `"svg"`.
10
+ * @property {boolean} [useFormatType=false] - Whether to enable format type selection (`block` vs `inline`).
11
+ * @property {string} [defaultFormatType="block"] - The default format type, either `"block"` or `"inline"`.
12
12
  * @property {boolean} [keepFormatType=false] - Whether to maintain the chosen format type after drawing.
13
13
  * @property {number} [lineWidth=5] - The width of the drawing line.
14
14
  * @property {boolean} [lineReconnect=false] - Whether to reconnect lines when drawing.
15
- * @property {CanvasLineCap} [lineCap="round"] - The style of the line cap ("butt", "round", or "square").
15
+ * @property {CanvasLineCap} [lineCap="round"] - The style of the line cap (`"butt"`, `"round"`, or `"square"`).
16
16
  * @property {string} [lineColor=""] - The color of the drawing line.
17
17
  * @property {boolean} [canResize=true] - Whether the modal form can be resized.
18
18
  * @property {boolean} [maintainRatio=true] - Whether to maintain the aspect ratio when resizing.
@@ -29,20 +29,22 @@ const { _w, isMobile } = env;
29
29
  * @class
30
30
  * @description Drawing modal plugin.
31
31
  */
32
- class Drawing extends EditorInjector {
32
+ class Drawing extends PluginModal {
33
33
  static key = 'drawing';
34
- static type = 'modal';
35
34
  static className = '';
36
35
 
36
+ #events;
37
+ #eventsRegister;
38
+
37
39
  /**
38
40
  * @constructor
39
- * @param {__se__EditorCore} editor - The root editor instance
41
+ * @param {SunEditor.Kernel} editor - The core kernel
40
42
  * @param {DrawingPluginOptions} pluginOptions
41
43
  */
42
44
  constructor(editor, pluginOptions) {
43
45
  // plugin basic properties
44
46
  super(editor);
45
- this.title = this.lang.drawing;
47
+ this.title = this.$.lang.drawing;
46
48
  this.icon = 'drawing';
47
49
  this.pluginOptions = {
48
50
  outputFormat: pluginOptions.outputFormat || 'dataurl', // dataurl, svg
@@ -60,31 +62,31 @@ class Drawing extends EditorInjector {
60
62
  maxHeight: '',
61
63
  minWidth: '150px',
62
64
  minHeight: '100px',
63
- ...pluginOptions.formSize
65
+ ...pluginOptions.formSize,
64
66
  },
65
67
  canResize: pluginOptions.canResize ?? true,
66
- maintainRatio: pluginOptions.maintainRatio ?? true
68
+ maintainRatio: pluginOptions.maintainRatio ?? true,
67
69
  };
68
70
 
69
71
  // exception
70
- if (!this.plugins.image) {
72
+ if (!this.$.plugins.image) {
71
73
  console.warn('[SUNEDITOR.plugins.drawing.warn] The drawing plugin must need either "image" plugin. Please add the "image" plugin.');
72
- } else if (this.pluginOptions.outputFormat === 'svg' && !this.plugins.image.pluginOptions.uploadUrl) {
74
+ } else if (this.pluginOptions.outputFormat === 'svg' && !this.$.plugins.image.pluginOptions.uploadUrl) {
73
75
  console.warn('[SUNEDITOR.plugins.drawing.warn] The drawing plugin must need the "image" plugin with the "uploadUrl" option. Please add the "image" plugin with the "uploadUrl" option.');
74
76
  }
75
77
 
76
78
  // create HTML
77
- const modalEl = CreateHTML_modal(this);
79
+ const modalEl = CreateHTML_modal(this.$, this.pluginOptions);
78
80
 
79
81
  // modules
80
- this.modal = new Modal(this, modalEl);
82
+ this.modal = new Modal(this, this.$, modalEl);
81
83
 
82
84
  // members
83
85
  this.as = this.pluginOptions.defaultFormatType;
84
86
  if (this.pluginOptions.useFormatType) {
85
87
  this.asBlock = modalEl.querySelector('[data-command="asBlock"]');
86
88
  this.asInline = modalEl.querySelector('[data-command="asInline"]');
87
- this.eventManager.addEvent([this.asBlock, this.asInline], 'click', this.#OnClickAsButton.bind(this));
89
+ this.$.eventManager.addEvent([this.asBlock, this.asInline], 'click', this.#OnClickAsButton.bind(this));
88
90
  }
89
91
 
90
92
  /**
@@ -96,71 +98,68 @@ class Drawing extends EditorInjector {
96
98
  this.points = [];
97
99
  this.paths = [];
98
100
  this.resizeObserver = null;
99
- this.__events = {
100
- mousedown: isMobile ? this.#OnCanvasTouchStart.bind(this) : this.#OnCanvasMouseDown.bind(this),
101
- mousemove: isMobile ? this.#OnCanvasTouchMove.bind(this) : this.#OnCanvasMouseMove.bind(this),
101
+
102
+ this.#events = {
103
+ touchstart: this.#OnCanvasTouchStart.bind(this),
104
+ touchmove: this.#OnCanvasTouchMove.bind(this),
105
+ mousedown: this.#OnCanvasMouseDown.bind(this),
106
+ mousemove: this.#OnCanvasMouseMove.bind(this),
102
107
  mouseup: this.#OnCanvasMouseUp.bind(this),
103
108
  mouseleave: this.#OnCanvasMouseLeave.bind(this),
104
- mouseenter: this.#OnCanvasMouseEnter.bind(this)
109
+ mouseenter: this.#OnCanvasMouseEnter.bind(this),
105
110
  };
106
- this.__eventsRegister = {
111
+ this.#eventsRegister = {
112
+ touchstart: null,
113
+ touchmove: null,
107
114
  mousedown: null,
108
115
  mousemove: null,
109
116
  mouseup: null,
110
117
  mouseleave: null,
111
- mouseenter: null
112
- };
113
- this.__eventNameMap = {
114
- mousedown: isMobile ? 'touchstart' : 'mousedown',
115
- mousemove: isMobile ? 'touchmove' : 'mousemove',
116
- mouseup: isMobile ? 'touchend' : 'mouseup',
117
- mouseleave: 'mouseleave',
118
- mouseenter: 'mouseenter'
118
+ mouseenter: null,
119
119
  };
120
120
 
121
121
  // init
122
- this.eventManager.addEvent(modalEl.querySelector('[data-command="remove"]'), 'click', this.#OnRemove.bind(this));
122
+ this.$.eventManager.addEvent(modalEl.querySelector('[data-command="remove"]'), 'click', this.#OnRemove.bind(this));
123
123
  }
124
124
 
125
125
  /**
126
- * @editorMethod Modules.Modal
127
- * @description Executes the method that is called when a "Modal" module's is opened.
126
+ * @override
127
+ * @type {PluginModal['open']}
128
128
  */
129
129
  open() {
130
130
  if (this.pluginOptions.useFormatType) {
131
- this._activeAsInline((this.pluginOptions.keepFormatType ? this.as : this.pluginOptions.defaultFormatType) === 'inline');
131
+ this.#activeAsInline((this.pluginOptions.keepFormatType ? this.as : this.pluginOptions.defaultFormatType) === 'inline');
132
132
  }
133
133
  this.modal.open();
134
- this._initDrawing();
134
+ this.#initDrawing();
135
135
  }
136
136
 
137
137
  /**
138
- * @editorMethod Modules.Modal
139
- * @description Executes the method that is called when a plugin's "modal" is closed.
138
+ * @hook Modules.Modal
139
+ * @type {SunEditor.Hook.Modal.Off}
140
140
  */
141
- off() {
142
- this._destroyDrawing();
141
+ modalOff() {
142
+ this.#destroyDrawing();
143
143
  }
144
144
 
145
145
  /**
146
- * @editorMethod Modules.Modal
147
- * @description This function is called when a form within a modal window is "submit".
148
- * @returns {boolean} Success or failure
146
+ * @hook Modules.Modal
147
+ * @type {SunEditor.Hook.Modal.Action}
149
148
  */
150
- modalAction() {
149
+ async modalAction() {
151
150
  if (this.pluginOptions.outputFormat === 'svg') {
152
- const files = this._getSVGFileList();
153
- this.plugins.image.init();
154
- this.plugins.image.submitFile(files);
151
+ const files = this.#getSVGFileList();
152
+ this.$.plugins.image.modalInit();
153
+ this.$.plugins.image.submitFile(files);
155
154
  } else {
156
155
  // dataurl | svg
157
156
  const data = this.canvas.toDataURL();
158
157
  const file = { name: 'drawing', size: 0 };
159
- this.plugins.image.init();
158
+ this.$.plugins.image.modalInit();
160
159
  if (this.as !== 'inline') {
161
- this.plugins.image.create(data, null, 'auto', '', 'none', file, '');
160
+ this.$.plugins.image.create(data, null, 'auto', '', 'none', file, '');
162
161
  } else {
163
- this.plugins.image.createInline(data, null, 'auto', '', 'none', file, '');
162
+ this.$.plugins.image.createInline(data, null, 'auto', '', 'none', file, '');
164
163
  }
165
164
  }
166
165
 
@@ -168,10 +167,9 @@ class Drawing extends EditorInjector {
168
167
  }
169
168
 
170
169
  /**
171
- * @private
172
170
  * @description Initializes the drawing canvas, sets up event listeners, and configures resize handling.
173
171
  */
174
- _initDrawing() {
172
+ #initDrawing() {
175
173
  const canvas = (this.canvas = this.modal.form.querySelector('.se-drawing-canvas'));
176
174
  this.ctx = canvas.getContext('2d');
177
175
  canvas.width = canvas.offsetWidth;
@@ -180,13 +178,15 @@ class Drawing extends EditorInjector {
180
178
  this.points = [];
181
179
  this.paths = [];
182
180
 
183
- this._setCtx();
181
+ this.#setCtx();
184
182
 
185
- this.__eventsRegister.mousedown = this.eventManager.addEvent(canvas, this.__eventNameMap.mousedown, this.__events.mousedown, { passive: false, capture: true });
186
- this.__eventsRegister.mousemove = this.eventManager.addEvent(canvas, this.__eventNameMap.mousemove, this.__events.mousemove, true);
187
- this.__eventsRegister.mouseup = this.eventManager.addEvent(canvas, this.__eventNameMap.mouseup, this.__events.mouseup, true);
188
- this.__eventsRegister.mouseleave = this.eventManager.addEvent(canvas, this.__eventNameMap.mouseleave, this.__events.mouseleave);
189
- this.__eventsRegister.mouseenter = this.eventManager.addEvent(canvas, this.__eventNameMap.mouseenter, this.__events.mouseenter);
183
+ this.#eventsRegister.touchstart = this.$.eventManager.addEvent(canvas, 'touchstart', this.#events.touchstart, { passive: false, capture: true });
184
+ this.#eventsRegister.touchmove = this.$.eventManager.addEvent(canvas, 'touchmove', this.#events.touchmove, true);
185
+ this.#eventsRegister.mousedown = this.$.eventManager.addEvent(canvas, 'mousedown', this.#events.mousedown, { passive: false, capture: true });
186
+ this.#eventsRegister.mousemove = this.$.eventManager.addEvent(canvas, 'mousemove', this.#events.mousemove, true);
187
+ this.#eventsRegister.mouseup = this.$.eventManager.addEvent(canvas, 'mouseup', this.#events.mouseup, true);
188
+ this.#eventsRegister.mouseleave = this.$.eventManager.addEvent(canvas, 'mouseleave', this.#events.mouseleave);
189
+ this.#eventsRegister.mouseenter = this.$.eventManager.addEvent(canvas, 'mouseenter', this.#events.mouseenter);
190
190
 
191
191
  if (this.resizeObserver) {
192
192
  this.resizeObserver.disconnect();
@@ -202,8 +202,8 @@ class Drawing extends EditorInjector {
202
202
  canvas.width = newWidth;
203
203
  canvas.height = newHeight;
204
204
  if (prevWidth !== canvas.width || prevHeight !== canvas.height) {
205
- if (this.pluginOptions.maintainRatio) this._adjustPathsToNewDimensions(prevWidth, prevHeight, newWidth, newHeight);
206
- this._drawAll();
205
+ if (this.pluginOptions.maintainRatio) this.#adjustPathsToNewDimensions(prevWidth, prevHeight, newWidth, newHeight);
206
+ this.#drawAll();
207
207
  }
208
208
  });
209
209
 
@@ -212,21 +212,20 @@ class Drawing extends EditorInjector {
212
212
  }
213
213
 
214
214
  /**
215
- * @private
216
215
  * @description Destroys the drawing canvas, removes event listeners, and clears stored drawing data.
217
216
  */
218
- _destroyDrawing() {
217
+ #destroyDrawing() {
219
218
  if (this.resizeObserver) {
220
219
  this.resizeObserver.disconnect();
221
220
  this.resizeObserver = null;
222
221
  }
223
222
 
224
223
  if (this.canvas) {
225
- this.eventManager.removeEvent(this.__eventsRegister.mousedown);
226
- this.eventManager.removeEvent(this.__eventsRegister.mousemove);
227
- this.eventManager.removeEvent(this.__eventsRegister.mouseup);
228
- this.eventManager.removeEvent(this.__eventsRegister.mouseleave);
229
- this.eventManager.removeEvent(this.__eventsRegister.mouseenter);
224
+ this.$.eventManager.removeEvent(this.#eventsRegister.mousedown);
225
+ this.$.eventManager.removeEvent(this.#eventsRegister.mousemove);
226
+ this.$.eventManager.removeEvent(this.#eventsRegister.mouseup);
227
+ this.$.eventManager.removeEvent(this.#eventsRegister.mouseleave);
228
+ this.$.eventManager.removeEvent(this.#eventsRegister.mouseenter);
230
229
  }
231
230
 
232
231
  this.canvas = null;
@@ -237,21 +236,19 @@ class Drawing extends EditorInjector {
237
236
  }
238
237
 
239
238
  /**
240
- * @private
241
239
  * @description Configures the drawing context (canvas settings like line width, color, etc.).
242
240
  */
243
- _setCtx() {
241
+ #setCtx() {
244
242
  this.ctx.lineWidth = this.pluginOptions.lineWidth;
245
243
  this.ctx.lineCap = this.pluginOptions.lineCap;
246
- this.ctx.strokeStyle = this.pluginOptions.lineColor || _w.getComputedStyle(this.carrierWrapper).color;
244
+ this.ctx.strokeStyle = this.pluginOptions.lineColor || _w.getComputedStyle(this.$.contextProvider.carrierWrapper).color;
247
245
  }
248
246
 
249
247
  /**
250
- * @private
251
248
  * @description Draws the current stroke based on collected points.
252
249
  */
253
- _draw() {
254
- this._setCtx();
250
+ #draw() {
251
+ this.#setCtx();
255
252
  this.ctx.beginPath();
256
253
  this.points.forEach(([x, y], i) => {
257
254
  if (i === 0) {
@@ -264,28 +261,26 @@ class Drawing extends EditorInjector {
264
261
  }
265
262
 
266
263
  /**
267
- * @private
268
264
  * @description Redraws all stored paths onto the canvas.
269
265
  */
270
- _drawAll() {
271
- this._setCtx();
266
+ #drawAll() {
267
+ this.#setCtx();
272
268
  this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
273
269
  this.paths.forEach((path) => {
274
270
  this.points = path;
275
- this._draw();
271
+ this.#draw();
276
272
  });
277
273
  this.points = [];
278
274
  }
279
275
 
280
276
  /**
281
- * @private
282
277
  * @description Adjusts all stored paths to fit new canvas dimensions after a resize event.
283
278
  * @param {number} prevWidth - The previous width of the canvas.
284
279
  * @param {number} prevHeight - The previous height of the canvas.
285
280
  * @param {number} newWidth - The new width of the canvas.
286
281
  * @param {number} newHeight - The new height of the canvas.
287
282
  */
288
- _adjustPathsToNewDimensions(prevWidth, prevHeight, newWidth, newHeight) {
283
+ #adjustPathsToNewDimensions(prevWidth, prevHeight, newWidth, newHeight) {
289
284
  const xRatio = newWidth / prevWidth;
290
285
  const yRatio = newHeight / prevHeight;
291
286
 
@@ -293,21 +288,19 @@ class Drawing extends EditorInjector {
293
288
  }
294
289
 
295
290
  /**
296
- * @private
297
291
  * @description Clears the canvas and resets stored drawing paths.
298
292
  */
299
- _clearCanvas() {
293
+ #clearCanvas() {
300
294
  this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
301
295
  this.points = [];
302
296
  this.paths = [];
303
297
  }
304
298
 
305
299
  /**
306
- * @private
307
300
  * @description Generates an SVG representation of the drawn content.
308
301
  * @returns {*} The generated SVG element.
309
302
  */
310
- _getSVG() {
303
+ #getSVG() {
311
304
  const svgNS = 'http://www.w3.org/2000/svg';
312
305
  const svg = document.createElementNS(svgNS, 'svg');
313
306
  svg.setAttribute('width', this.canvas.width + '');
@@ -331,12 +324,11 @@ class Drawing extends EditorInjector {
331
324
  }
332
325
 
333
326
  /**
334
- * @private
335
327
  * @description Converts the SVG element into a downloadable file.
336
328
  * @returns {FileList} A FileList containing the generated SVG file.
337
329
  */
338
- _getSVGFileList() {
339
- const svgElement = this._getSVG();
330
+ #getSVGFileList() {
331
+ const svgElement = this.#getSVG();
340
332
  const serializer = new XMLSerializer();
341
333
  const svgString = serializer.serializeToString(svgElement);
342
334
  const blob = new Blob([svgString], { type: 'image/svg+xml' });
@@ -350,12 +342,11 @@ class Drawing extends EditorInjector {
350
342
  }
351
343
 
352
344
  /**
353
- * @private
354
345
  * @description Retrieves touch coordinates relative to the canvas.
355
346
  * @param {TouchEvent} e - The touch event.
356
347
  * @returns {{x: number, y: number}} An object containing the x and y coordinates.
357
348
  */
358
- _getCanvasTouchPointer(e) {
349
+ #getCanvasTouchPointer(e) {
359
350
  const { touches } = e;
360
351
  const rect = this.canvas.getBoundingClientRect();
361
352
  const x = touches[0].clientX - rect.left;
@@ -364,11 +355,10 @@ class Drawing extends EditorInjector {
364
355
  }
365
356
 
366
357
  /**
367
- * @private
368
358
  * @description Activates either block or inline format mode for inserted drawings.
369
359
  * @param {boolean} isInline - Whether the drawing should be inserted as an inline element.
370
360
  */
371
- _activeAsInline(isInline) {
361
+ #activeAsInline(isInline) {
372
362
  if (isInline) {
373
363
  dom.utils.addClass(this.asInline, 'on');
374
364
  dom.utils.removeClass(this.asBlock, 'on');
@@ -387,7 +377,7 @@ class Drawing extends EditorInjector {
387
377
  e.preventDefault();
388
378
  this.isDrawing = true;
389
379
  this.points.push([e.offsetX, e.offsetY]);
390
- this._draw();
380
+ this.#draw();
391
381
  }
392
382
 
393
383
  /**
@@ -397,7 +387,7 @@ class Drawing extends EditorInjector {
397
387
  e.preventDefault();
398
388
  if (!this.isDrawing) return;
399
389
  this.points.push([e.offsetX, e.offsetY]);
400
- this._draw();
390
+ this.#draw();
401
391
  }
402
392
 
403
393
  /**
@@ -405,10 +395,10 @@ class Drawing extends EditorInjector {
405
395
  */
406
396
  #OnCanvasTouchStart(e) {
407
397
  e.preventDefault();
408
- const { x, y } = this._getCanvasTouchPointer(e);
398
+ const { x, y } = this.#getCanvasTouchPointer(e);
409
399
  this.isDrawing = true;
410
400
  this.points.push([x, y]);
411
- this._draw();
401
+ this.#draw();
412
402
  }
413
403
 
414
404
  /**
@@ -416,10 +406,10 @@ class Drawing extends EditorInjector {
416
406
  */
417
407
  #OnCanvasTouchMove(e) {
418
408
  e.preventDefault();
419
- const { x, y } = this._getCanvasTouchPointer(e);
409
+ const { x, y } = this.#getCanvasTouchPointer(e);
420
410
  if (!this.isDrawing) return;
421
411
  this.points.push([x, y]);
422
- this._draw();
412
+ this.#draw();
423
413
  }
424
414
 
425
415
  #OnCanvasMouseUp() {
@@ -449,28 +439,33 @@ class Drawing extends EditorInjector {
449
439
  if (!this.pluginOptions.lineReconnect) {
450
440
  this.points.push([e.offsetX, e.offsetY]);
451
441
  } else {
452
- const lastPath = this.paths[this.paths.length - 1];
453
- const lastPoint = lastPath[lastPath.length - 1];
442
+ const lastPath = this.paths.at(-1);
443
+ const lastPoint = lastPath.at(-1);
454
444
  this.points.push([lastPoint[0], lastPoint[1]]);
455
445
  this.points.push([e.offsetX, e.offsetY]);
456
446
  }
457
- this._draw();
447
+ this.#draw();
458
448
  }
459
449
  }
460
450
 
461
451
  #OnRemove() {
462
- this._clearCanvas();
452
+ this.#clearCanvas();
463
453
  }
464
454
 
465
455
  /**
466
456
  * @param {MouseEvent} e - Event object
467
457
  */
468
458
  #OnClickAsButton(e) {
469
- this._activeAsInline(dom.query.getEventTarget(e).getAttribute('data-command') === 'asInline');
459
+ this.#activeAsInline(dom.query.getEventTarget(e).getAttribute('data-command') === 'asInline');
470
460
  }
471
461
  }
472
462
 
473
- function CreateHTML_modal({ lang, icons, pluginOptions }) {
463
+ /**
464
+ * @param {SunEditor.Deps} $ - Kernel dependencies
465
+ * @param {DrawingPluginOptions} pluginOptions - Drawing plugin options
466
+ * @returns {HTMLElement}
467
+ */
468
+ function CreateHTML_modal({ lang, icons }, pluginOptions) {
474
469
  const { width, height, maxWidth, maxHeight, minWidth, minHeight } = pluginOptions.formSize;
475
470
  const html = /*html*/ `
476
471
  <form>
@@ -522,9 +517,9 @@ function CreateHTML_modal({ lang, icons, pluginOptions }) {
522
517
  'DIV',
523
518
  {
524
519
  class: 'se-modal-content se-modal-responsive',
525
- style: `max-width: ${maxWidth}; max-height: ${maxHeight};`
520
+ style: `max-width: ${maxWidth}; max-height: ${maxHeight};`,
526
521
  },
527
- html
522
+ html,
528
523
  );
529
524
  }
530
525