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,20 +1,17 @@
1
- /**
2
- * @fileoverview clipboard helper
3
- */
4
1
  import { isClipboardSupported } from './env';
5
2
  import { isElement } from './dom/domCheck';
6
3
 
7
4
  /**
8
5
  * @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.
6
+ * - Iframe is replaced with a placeholder : `<div data-se-iframe-holder-src="iframe.src">[iframe: iframe.src]</div>`
7
+ * - `iframe placeholder` is re-rendered in `html.clean` when pasted into the editor.
11
8
  * @param {Element|Text|string} content Content to be copied to the clipboard
12
- * @returns {Promise<void>}
9
+ * @returns {Promise<void|false>} If it fails, it returns `false`.
13
10
  */
14
11
  export async function write(content) {
15
12
  if (!isClipboardSupported) {
16
13
  console.error('Clipboard is not supported in this browser.');
17
- return;
14
+ return false;
18
15
  }
19
16
 
20
17
  let htmlString = '';
@@ -44,16 +41,30 @@ export async function write(content) {
44
41
  plainText = content.textContent;
45
42
  }
46
43
 
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
- ]);
44
+ try {
45
+ await navigator.clipboard.write([
46
+ /* eslint-disable-next-line compat/compat */
47
+ new ClipboardItem({
48
+ 'text/html': new Blob([htmlString], { type: 'text/html' }),
49
+ 'text/plain': new Blob([plainText], { type: 'text/plain' }),
50
+ }),
51
+ ]);
52
+ } catch {
53
+ console.warn('[SUNEDITOR.copy.warn] This browser is not supported Clipboard API');
54
+ try {
55
+ await navigator.clipboard.writeText(plainText || stripHtml(htmlString));
56
+ } catch (err) {
57
+ console.error('[SUNEDITOR.copy.fail] ' + err);
58
+ }
59
+ }
60
+ }
61
+
62
+ function stripHtml(html) {
63
+ const div = document.createElement('div');
64
+ div.innerHTML = html;
65
+ return div.textContent || div.innerText || '';
55
66
  }
56
67
 
57
68
  export default {
58
- write
69
+ write,
59
70
  };
@@ -1,6 +1,12 @@
1
1
  import { _d, _w } from './env';
2
2
 
3
- const URLPattern = /https?:\/\/[^\s]+/g;
3
+ const _RE_HTML_CHARS = /&|\u00A0|'|"|<|>/g;
4
+ const _RE_HTML_ENTITIES = /&amp;|&nbsp;|&apos;|&quot;|&lt;|&gt;/g;
5
+ const _HTML_TO_ENTITY = { '&': '&amp;', '\u00A0': '&nbsp;', "'": '&apos;', '"': '&quot;', '<': '&lt;', '>': '&gt;' };
6
+ const _ENTITY_TO_HTML = { '&amp;': '&', '&nbsp;': '\u00A0', '&apos;': "'", '&quot;': '"', '&lt;': '<', '&gt;': '>' };
7
+ const _RE_UPPER_CASE = /[A-Z]/g;
8
+ const _RE_KEBAB_CHAR = /-[a-zA-Z]/g;
9
+
4
10
  const FONT_VALUES_MAP = {
5
11
  'xx-small': 0.5625,
6
12
  'x-small': 0.625,
@@ -9,7 +15,7 @@ const FONT_VALUES_MAP = {
9
15
  large: 1.125,
10
16
  'x-large': 1.5,
11
17
  'xx-large': 2,
12
- 'xxx-large': 2.5
18
+ 'xxx-large': 2.5,
13
19
  };
14
20
 
15
21
  function NodeToJson(node) {
@@ -26,7 +32,7 @@ function NodeToJson(node) {
26
32
  type: 'element',
27
33
  tag: node.tagName.toLowerCase(),
28
34
  attributes: {},
29
- children: []
35
+ children: [],
30
36
  };
31
37
 
32
38
  // get attribute
@@ -48,8 +54,13 @@ function NodeToJson(node) {
48
54
 
49
55
  /**
50
56
  * @description Parses an HTML string into a DOM tree, then recursively traverses the nodes to convert them into a structured JSON representation.
51
- * -Each element includes its tag name, attributes, and children.
52
- * -Text nodes are represented as { type: 'text', content: '...' }.
57
+ * - Each element includes its tag name, attributes, and children.
58
+ * - Text nodes are represented as `{ type: 'text', content: '...' }`.
59
+ * @example
60
+ * const json = converter.htmlToJson('<p class="txt">Hello</p>');
61
+ * // { type: 'element', tag: 'p', attributes: { class: 'txt' }, children: [
62
+ * // { type: 'text', content: 'Hello' }
63
+ * // ]}
53
64
  * @param {string} content HTML string
54
65
  * @returns {Object<string, *>} JSON data
55
66
  */
@@ -61,9 +72,15 @@ export function htmlToJson(content) {
61
72
 
62
73
  /**
63
74
  * @description Takes a JSON structure representing HTML elements and recursively serializes it into a valid HTML string.
64
- * -It rebuilds each tag with attributes and inner content.
75
+ * - It rebuilds each tag with attributes and inner content.
65
76
  * Text content and attributes are safely escaped to prevent parsing issues or XSS.
66
77
  * Useful for restoring dynamic HTML from a data format.
78
+ * @example
79
+ * const html = converter.jsonToHtml({
80
+ * type: 'element', tag: 'p', attributes: { class: 'txt' },
81
+ * children: [{ type: 'text', content: 'Hello' }],
82
+ * });
83
+ * // '<p class="txt">Hello</p>'
67
84
  * @param {Object<string, *>} jsonData
68
85
  * @returns {string} HTML string
69
86
  */
@@ -97,19 +114,10 @@ export function jsonToHtml(jsonData) {
97
114
  * @description Convert HTML string to HTML Entity
98
115
  * @param {string} content
99
116
  * @returns {string} Content string
100
- * @private
101
117
  */
102
118
  export function htmlToEntity(content) {
103
- const ec = {
104
- '&': '&amp;',
105
- '\u00A0': '&nbsp;',
106
- "'": '&apos;',
107
- '"': '&quot;',
108
- '<': '&lt;',
109
- '>': '&gt;'
110
- };
111
- return content.replace(/&|\u00A0|'|"|<|>/g, (m) => {
112
- return typeof ec[m] === 'string' ? ec[m] : m;
119
+ return content.replace(_RE_HTML_CHARS, (m) => {
120
+ return _HTML_TO_ENTITY[m] || m;
113
121
  });
114
122
  }
115
123
 
@@ -119,16 +127,8 @@ export function htmlToEntity(content) {
119
127
  * @returns {string}
120
128
  */
121
129
  export function entityToHTML(content) {
122
- const ec = {
123
- '&amp;': '&',
124
- '&nbsp;': '\u00A0',
125
- '&apos;': "'",
126
- '&quot;': '"',
127
- '&lt;': '<',
128
- '&gt;': '>'
129
- };
130
- return content.replace(/&amp;|&nbsp;|&apos;|&quot;|\$lt;|\$gt;/g, (m) => {
131
- return typeof ec[m] === 'string' ? ec[m] : m;
130
+ return content.replace(_RE_HTML_ENTITIES, (m) => {
131
+ return _ENTITY_TO_HTML[m] || m;
132
132
  });
133
133
  }
134
134
 
@@ -200,16 +200,16 @@ export function getValues(obj) {
200
200
  ? []
201
201
  : Object.keys(obj).map(function (i) {
202
202
  return obj[i];
203
- });
203
+ });
204
204
  }
205
205
 
206
206
  /**
207
- * @description Convert the CamelCase To the KebabCase.
207
+ * @description Convert the `CamelCase` To the `KebabCase`.
208
208
  * @param {string|Array<string>} param [Camel string]
209
209
  */
210
210
  export function camelToKebabCase(param) {
211
211
  if (typeof param === 'string') {
212
- return param.replace(/[A-Z]/g, (letter) => '-' + letter.toLowerCase());
212
+ return param.replace(_RE_UPPER_CASE, (letter) => '-' + letter.toLowerCase());
213
213
  } else {
214
214
  return param.map(function (str) {
215
215
  return camelToKebabCase(str);
@@ -219,28 +219,33 @@ export function camelToKebabCase(param) {
219
219
 
220
220
  /**
221
221
  * @overload
222
- * @param {string} param - Kebab-case string.
223
- * @returns {string} CamelCase string.
222
+ * @param {string} param - `Kebab-case` string.
223
+ * @returns {string} `CamelCase` string.
224
224
  */
225
225
  /**
226
226
  * @overload
227
- * @param {Array<string>} param - Array of Kebab-case strings.
228
- * @returns {Array<string>} Array of CamelCase strings.
227
+ * @param {Array<string>} param - Array of `Kebab-case` strings.
228
+ * @returns {Array<string>} Array of `CamelCase` strings.
229
229
  */
230
230
  export function kebabToCamelCase(param) {
231
231
  if (typeof param === 'string') {
232
- return param.replace(/-[a-zA-Z]/g, (letter) => letter.replace('-', '').toUpperCase());
232
+ return param.replace(_RE_KEBAB_CHAR, (letter) => letter.replace('-', '').toUpperCase());
233
233
  } else {
234
234
  return param.map(function (str) {
235
- return camelToKebabCase(str);
235
+ return kebabToCamelCase(str);
236
236
  });
237
237
  }
238
238
  }
239
239
 
240
240
  /**
241
- *
241
+ * @description Converts a font size string from one CSS unit to another.
242
+ * @example
243
+ * converter.toFontUnit('px', '1rem'); // '16px'
244
+ * converter.toFontUnit('em', '16px'); // '1.00em'
245
+ * converter.toFontUnit('pt', '16px'); // '12pt'
246
+ * converter.toFontUnit('%', '16px'); // '100%'
242
247
  * @param {"em"|"rem"|"%"|"pt"|"px"} to Size units to be converted
243
- * @param {string} size siSize to convert with units (ex: "15rem")
248
+ * @param {string} size Size to convert with units (ex: `"15rem"`)
244
249
  * @returns {string}
245
250
  */
246
251
  export function toFontUnit(to, size) {
@@ -273,7 +278,7 @@ export function toFontUnit(to, size) {
273
278
 
274
279
  /**
275
280
  * @description Convert the node list to an array. If not, returns an empty array.
276
- * @param {?__se__NodeCollection} nodeList
281
+ * @param {?SunEditor.NodeCollection} [nodeList]
277
282
  * @returns Array
278
283
  */
279
284
  export function nodeListToArray(nodeList) {
@@ -300,8 +305,8 @@ export function swapKeyValue(obj) {
300
305
  }
301
306
 
302
307
  /**
303
- * @description Create whitelist RegExp object.
304
- * @param {string} list Tags list ("br|p|div|pre...")
308
+ * @description Create whitelist `RegExp` object.
309
+ * @param {string} list Tags list (`"br|p|div|pre..."`)
305
310
  * @returns {RegExp} Return RegExp format: new RegExp("<\\/?\\b(?!" + list + ")\\b[^>^<]*+>", "gi")
306
311
  */
307
312
  export function createElementWhitelist(list) {
@@ -309,8 +314,8 @@ export function createElementWhitelist(list) {
309
314
  }
310
315
 
311
316
  /**
312
- * @description Create blacklist RegExp object.
313
- * @param {string} list Tags list ("br|p|div|pre...")
317
+ * @description Create blacklist `RegExp` object.
318
+ * @param {string} list Tags list (`"br|p|div|pre..."`)
314
319
  * @returns {RegExp} Return RegExp format: new RegExp("<\\/?\\b(?:" + list + ")\\b[^>^<]*+>", "gi")
315
320
  */
316
321
  export function createElementBlacklist(list) {
@@ -326,7 +331,7 @@ export function isHexColor(str) {
326
331
  }
327
332
 
328
333
  /**
329
- * @description Function to convert hex format to a rgb color
334
+ * @description Function to convert hex format to a `rgb` color
330
335
  * @param {string} rgba RGBA color format
331
336
  * @returns {string}
332
337
  */
@@ -342,7 +347,7 @@ export function rgb2hex(rgba) {
342
347
 
343
348
  let a = '';
344
349
  if (rgba.includes('rgba')) {
345
- const alphaMatch = rgba.match(/[\s+]?([\d]+\.?[\d]*)[\s+]?/i);
350
+ const alphaMatch = rgba.match(/,\s*([\d]+\.?[\d]*)\s*\)/);
346
351
  if (alphaMatch) {
347
352
  a = ('0' + Math.round(parseFloat(alphaMatch[1]) * 255).toString(16)).slice(-2);
348
353
  }
@@ -357,7 +362,7 @@ export function rgb2hex(rgba) {
357
362
  /**
358
363
  * @description Computes the width as a percentage of the parent's width, and returns this value rounded to two decimal places.
359
364
  * @param {HTMLElement} target The target element for which to calculate the width percentage.
360
- * @param {?HTMLElement=} parentTarget The parent element to use as the reference for the width calculation. If not provided, the target's parent element is used.
365
+ * @param {?HTMLElement} [parentTarget] The parent element to use as the reference for the width calculation. If not provided, the target's parent element is used.
361
366
  * @returns {number}
362
367
  */
363
368
  export function getWidthInPercentage(target, parentTarget) {
@@ -374,17 +379,19 @@ export function getWidthInPercentage(target, parentTarget) {
374
379
  /**
375
380
  * @description Convert url pattern text node to anchor node
376
381
  * @param {Node} node Text node
377
- * @returns {boolean} Return true if the text node is converted to an anchor node
382
+ * @returns {boolean} Return `true` if the text node is converted to an anchor node
378
383
  */
379
384
  export function textToAnchor(node) {
385
+ const URLPattern = /https?:\/\/[^\s]+/g;
386
+
380
387
  if (node.nodeType === 3 && URLPattern.test(node.textContent) && !/^A$/i.test(node.parentNode?.nodeName)) {
381
388
  const textContent = node.textContent;
382
389
  const fragment = _d.createDocumentFragment();
383
390
 
384
391
  let lastIndex = 0;
385
392
  textContent.replace(URLPattern, (match, offset) => {
386
- if (offset > 0) {
387
- fragment.appendChild(_d.createTextNode(textContent.slice(0, offset)));
393
+ if (offset > lastIndex) {
394
+ fragment.appendChild(_d.createTextNode(textContent.slice(lastIndex, offset)));
388
395
  }
389
396
  const anchor = _d.createElement('a');
390
397
  anchor.href = match;
@@ -392,12 +399,13 @@ export function textToAnchor(node) {
392
399
  anchor.textContent = match;
393
400
  fragment.appendChild(anchor);
394
401
  lastIndex = offset + match.length;
395
- if (lastIndex < textContent.length) {
396
- fragment.appendChild(_d.createTextNode(textContent.slice(lastIndex)));
397
- }
398
402
  return match;
399
403
  });
400
404
 
405
+ if (lastIndex < textContent.length) {
406
+ fragment.appendChild(_d.createTextNode(textContent.slice(lastIndex)));
407
+ }
408
+
401
409
  node.parentNode.replaceChild(fragment, node);
402
410
  return true;
403
411
  }
@@ -406,8 +414,8 @@ export function textToAnchor(node) {
406
414
  }
407
415
 
408
416
  /**
409
- * Converts styles within a <span> tag to corresponding HTML tags (e.g., <strong>, <em>, <u>, <s>).
410
- * Maintains the original <span> tag and wraps its content with the new tags.
417
+ * Converts styles within a `<span>` tag to corresponding HTML tags (e.g., `<strong>`, `<em>`, `<u>`, `<s>`).
418
+ * Maintains the original `<span>` tag and wraps its content with the new tags.
411
419
  * @param {{ regex: RegExp, tag: string }} styleToTag An object mapping style properties to HTML tags. ex) {bold: { regex: /font-weight\s*:\s*bold/i, tag: 'strong' },}
412
420
  * @param {Node} node Node
413
421
  */
@@ -441,10 +449,6 @@ export function spanToStyleNode(styleToTag, node) {
441
449
  currentNode = nextNode;
442
450
  }
443
451
 
444
- while (node.firstChild) {
445
- node.removeChild(node.firstChild);
446
- }
447
-
448
452
  node.appendChild(temp);
449
453
  }
450
454
  }
@@ -468,12 +472,15 @@ export function addUrlQuery(url, query) {
468
472
  return url;
469
473
  }
470
474
 
475
+ /**
476
+ * @typedef {import('../core/schema/options').OptionStyleResult} OptionStyleResult_converter
477
+ */
478
+
471
479
  /**
472
480
  * @description Converts options-related styles and returns them for each frame.
473
- * @param {Map<string, *>} fo editor.frameOptions
481
+ * @param {SunEditor.FrameOptions} fo `editor.frameOptions`
474
482
  * @param {string} cssText Style string
475
- * @returns {{top: string, frame: string, editor: string}}
476
- * @private
483
+ * @returns {OptionStyleResult_converter}
477
484
  */
478
485
  export function _setDefaultOptionStyle(fo, cssText) {
479
486
  let optionStyle = '';
@@ -509,34 +516,49 @@ export function _setDefaultOptionStyle(fo, cssText) {
509
516
  return {
510
517
  top: top,
511
518
  frame: frame,
512
- editor: editor
519
+ editor: editor,
513
520
  };
514
521
  }
515
522
 
516
523
  /**
517
- * @description Set default style tag of the iframe
518
- * @param {Array<string>} linkNames link names array of CSS files
519
- * @returns {string} "<link rel="stylesheet" href=".." />.."
524
+ * @description Set default style tag of the `iframe`
525
+ * @param {Array<string>} linkNames link names array of CSS files or `'*'` for all stylesheets
526
+ * @returns {string} `"<link rel="stylesheet" href=".." />.."`
520
527
  */
521
528
  export function _setIframeStyleLinks(linkNames) {
522
529
  let tagString = '';
523
530
 
524
531
  if (linkNames) {
532
+ const allLinks = _d.getElementsByTagName('link');
533
+
525
534
  for (let f = 0, len = linkNames.length, path; f < len; f++) {
526
535
  path = [];
527
-
528
- if (/(^https?:\/\/)|(^data:text\/css,)/.test(linkNames[f])) {
529
- path.push(linkNames[f]);
530
- } else {
531
- const CSSFileName = new RegExp(`(^|.*[\\/])${linkNames[f]}(\\..+)?.css((\\??.+?)|\\b)$`, 'i');
532
- for (let c = _d.getElementsByTagName('link'), i = 0, cLen = c.length, styleTag; i < cLen; i++) {
533
- styleTag = c[i].href.match(CSSFileName);
536
+ const linkName = linkNames[f];
537
+
538
+ // Wildcard: include all stylesheets
539
+ if (linkName === '*') {
540
+ for (let i = 0, cLen = allLinks.length; i < cLen; i++) {
541
+ if (allLinks[i].rel === 'stylesheet' && allLinks[i].href) {
542
+ path.push(allLinks[i].href);
543
+ }
544
+ }
545
+ }
546
+ // Absolute URL or data URL
547
+ else if (/(^https?:\/\/)|(^data:text\/css,)/.test(linkName)) {
548
+ path.push(linkName);
549
+ }
550
+ // String pattern (convert to regex)
551
+ else {
552
+ const CSSFileName = new RegExp(`(^|.*[\\/])${linkName}(\\..+)?.css((\\??.+?)|\\b)$`, 'i');
553
+ for (let i = 0, cLen = allLinks.length, styleTag; i < cLen; i++) {
554
+ styleTag = allLinks[i].href.match(CSSFileName);
534
555
  if (styleTag) path.push(styleTag[0]);
535
556
  }
536
557
  }
537
558
 
538
- if (!path || path.length === 0)
539
- throw '[SUNEDITOR.constructor.iframe.fail] The suneditor CSS files installation path could not be automatically detected. Please set the option property "iframe_cssFileName" before creating editor instances.';
559
+ if (!path || path.length === 0) {
560
+ throw new Error('[SUNEDITOR.constructor.iframe.fail] The suneditor CSS files installation path could not be automatically detected. Please set the option property "iframe_cssFileName" before creating editor instances.');
561
+ }
540
562
 
541
563
  for (let i = 0, pLen = path.length; i < pLen; i++) {
542
564
  tagString += '<link href="' + path[i] + '" rel="stylesheet">';
@@ -548,9 +570,9 @@ export function _setIframeStyleLinks(linkNames) {
548
570
  }
549
571
 
550
572
  /**
551
- * @description When iframe height options is "auto" return "<style>" tag that required.
552
- * @param {string} frameHeight height
553
- * @returns {string} "<style>...</style>"
573
+ * @description When `iframe` height options is `"auto"` return `"<style>"` tag that required.
574
+ * @param {string|number} frameHeight height
575
+ * @returns {string} `"<style>...</style>"`
554
576
  */
555
577
  export function _setAutoHeightStyle(frameHeight) {
556
578
  return frameHeight === 'auto' ? '<style>\n/** Iframe height auto */\nbody{height: min-content; overflow: hidden;}\n</style>' : '';
@@ -580,7 +602,7 @@ const converter = {
580
602
  addUrlQuery,
581
603
  _setDefaultOptionStyle,
582
604
  _setIframeStyleLinks,
583
- _setAutoHeightStyle
605
+ _setAutoHeightStyle,
584
606
  };
585
607
 
586
608
  export default converter;
@@ -1,18 +1,24 @@
1
- /**
2
- * @fileoverview Implements Helper for checking the node type and attributes.
3
- */
4
-
5
1
  import { onlyZeroWidthRegExp } from '../unicode';
6
- import domUtils from './domUtils';
2
+
3
+ const _RE_EXCLUDE_FORMAT = /(\s|^)(katex|MathJax|se-exclude-format)(\s|$)/;
7
4
 
8
5
  /**
9
- * @description A method that checks If the text is blank or to see if it contains 'ZERO WIDTH SPACE' or empty (unicode.zeroWidthSpace)
6
+ * @description A method that checks If the text is blank or to see if it contains `ZERO WIDTH SPACE` or empty (`unicode.zeroWidthSpace`)
10
7
  * @param {string|Node} text String value or Node
11
8
  * @returns {boolean}
12
9
  */
13
10
  export function isZeroWidth(text) {
14
11
  if (text === null || text === undefined) return false;
15
- if (typeof text !== 'string') text = text.textContent;
12
+ if (typeof text !== 'string') {
13
+ if (isElement(text)) {
14
+ const children = text.children;
15
+ for (let i = 0, len = children.length; i < len; i++) {
16
+ const child = children[i];
17
+ if (!isContentLess(child)) return false;
18
+ }
19
+ }
20
+ text = text.textContent;
21
+ }
16
22
  return text === '' || onlyZeroWidthRegExp.test(text);
17
23
  }
18
24
 
@@ -20,16 +26,16 @@ export function isZeroWidth(text) {
20
26
  * @description Determine if this offset is the edge offset of container
21
27
  * @param {Node} container The node of the selection object. (range.startContainer..)
22
28
  * @param {number} offset The offset of the selection object. (core.getRange().startOffset...)
23
- * @param {?"front"|"end"=} dir Select check point - Both edge, Front edge or End edge. ("front": Front edge, "end": End edge, undefined: Both edge)
29
+ * @param {?("front"|"end")} [dir] Select check point - Both edge, Front edge or End edge. (`"front"`: Front edge, `"end"`: End edge, `undefined`: Both edge)
24
30
  * @returns {boolean}
25
31
  */
26
32
  export function isEdgePoint(container, offset, dir) {
27
- return (dir !== 'end' && offset === 0) || ((!dir || dir !== 'front') && !container.nodeValue && offset === 1) || ((!dir || dir === 'end') && container.nodeValue && offset >= container.nodeValue.length);
33
+ return (dir !== 'end' && offset === 0) || ((!dir || dir !== 'front') && !container.nodeValue && offset <= 1) || ((!dir || dir === 'end') && container.nodeValue && offset >= container.nodeValue.length);
28
34
  }
29
35
 
30
36
  /**
31
37
  * @description Check the node is a text node.
32
- * @param {?Node} node The node to check
38
+ * @param {?*} node The node to check
33
39
  * @returns {node is Text}
34
40
  */
35
41
  export function isText(node) {
@@ -38,7 +44,7 @@ export function isText(node) {
38
44
 
39
45
  /**
40
46
  * @description Check the node is an HTMLElement node.
41
- * @param {?Node} node The node to check
47
+ * @param {?*} node The node to check
42
48
  * @returns {node is HTMLElement}
43
49
  */
44
50
  export function isElement(node) {
@@ -47,7 +53,7 @@ export function isElement(node) {
47
53
 
48
54
  /**
49
55
  * @description It is judged whether it is the input element (INPUT, TEXTAREA)
50
- * @param {?Node} node The node to check
56
+ * @param {?*} node The node to check
51
57
  * @returns {node is HTMLInputElement}
52
58
  */
53
59
  export function isInputElement(node) {
@@ -56,7 +62,7 @@ export function isInputElement(node) {
56
62
 
57
63
  /**
58
64
  * @description It is judged whether it is the button element
59
- * @param {?Node} node The node to check
65
+ * @param {?*} node The node to check
60
66
  * @returns {node is HTMLButtonElement}
61
67
  */
62
68
  export function isButtonElement(node) {
@@ -172,8 +178,8 @@ export function isContentLess(node) {
172
178
  }
173
179
 
174
180
  /**
175
- * @description Check the line element is empty.
176
- * @param {Node} node "line" element node
181
+ * @description Check the `line` element is empty.
182
+ * @param {Node} node `line` element node
177
183
  * @returns {boolean}
178
184
  */
179
185
  export function isEmptyLine(node) {
@@ -183,16 +189,37 @@ export function isEmptyLine(node) {
183
189
  }
184
190
 
185
191
  /**
186
- * @description It is judged whether it is the edit region top div element or iframe's body tag.
192
+ * @description Checks if the given node is a container component (class `se-component-container`).
193
+ * @param {Node} element
194
+ * @returns {boolean} `true` if the node is a container component, otherwise `false`.
195
+ */
196
+ export function isComponentContainer(element) {
197
+ if (element?.nodeType !== 1) return false;
198
+
199
+ const el = /** @type {Element} */ (element);
200
+ const cls = el.classList;
201
+
202
+ if (!cls) return false;
203
+ return cls.contains('se-component') || cls.contains('se-flex-component');
204
+ }
205
+
206
+ /**
207
+ * @description It is judged whether it is the edit region top `div` element or `iframe`'s `body` tag.
187
208
  * @param {?Node} node The node to check
188
209
  * @returns {node is HTMLElement}
189
210
  */
190
211
  export function isWysiwygFrame(node) {
191
- return node?.nodeType === 1 && (domUtils.hasClass(node, 'se-wrapper-wysiwyg|sun-editor-carrier-wrapper|se-wrapper') || /^BODY$/i.test(node.nodeName));
212
+ if (node?.nodeType !== 1) return false;
213
+
214
+ const el = /** @type {Element} */ (node);
215
+ const cls = el.classList;
216
+
217
+ if (!cls) return false;
218
+ return node.nodeName.toUpperCase() === 'BODY' || cls.contains('se-wrapper-wysiwyg') || cls.contains('sun-editor-carrier-wrapper') || cls.contains('se-wrapper');
192
219
  }
193
220
 
194
221
  /**
195
- * @description It is judged whether it is the contenteditable property is false.
222
+ * @description It is judged whether it is the `contenteditable` property is `false`.
196
223
  * @param {?Node} node The node to check
197
224
  * @returns {node is HTMLElement}
198
225
  */
@@ -201,14 +228,14 @@ export function isNonEditable(node) {
201
228
  }
202
229
 
203
230
  /**
204
- * @description Check the span's attributes are empty.
231
+ * @description Check the `span`'s attributes are empty.
205
232
  * @param {?Node} node Element node
206
233
  * @returns {boolean}
207
234
  */
208
235
  export function isSpanWithoutAttr(node) {
209
236
  if (node?.nodeType !== 1) return false;
210
237
  const el = /** @type {HTMLElement} */ (node);
211
- return /^SPAN$/i.test(el.nodeName) && !el.className && !el.style.cssText;
238
+ return /^SPAN$/i.test(el.nodeName) && !el.className && el.style.length === 0;
212
239
  }
213
240
 
214
241
  /**
@@ -234,33 +261,31 @@ export function isSameAttributes(a, b) {
234
261
 
235
262
  const class_a = aEl.classList;
236
263
  const class_b = bEl.classList;
237
- const wRegExp = RegExp;
238
264
  let compClass = 0;
239
-
240
265
  for (let i = 0, len = class_a.length; i < len; i++) {
241
- if (wRegExp('(s|^)' + class_a[i] + '(s|$)').test(class_b.value)) compClass++;
266
+ if (class_b.contains(class_a[i])) compClass++;
242
267
  }
243
268
 
244
269
  return compStyle === style_b.length && compStyle === style_a.length && compClass === class_b.length && compClass === class_a.length;
245
270
  }
246
271
 
247
272
  /**
248
- * @description It is judged whether it is the not checking node. (class="katex", "MathJax", "se-exclude-format")
273
+ * @description It is judged whether it is the not checking node. (class=`katex`, `MathJax`, `se-exclude-format`)
249
274
  * @param {Node} node The node to check
250
275
  * @returns {node is HTMLElement}
251
276
  */
252
277
  export function isExcludeFormat(node) {
253
- return /(\s|^)(katex|MathJax|se-exclude-format)(\s|$)/.test(/** @type {HTMLElement} */ (node)?.className);
278
+ return _RE_EXCLUDE_FORMAT.test(/** @type {HTMLElement} */ (node)?.className);
254
279
  }
255
280
 
256
281
  /**
257
- * @description Checks for "__se__uneditable" in the class list.
258
- * - Components with class "__se__uneditable" cannot be modified.
282
+ * @description Checks for `__se__uneditable` in the class list.
283
+ * - Components with class `__se__uneditable` cannot be modified.
259
284
  * @param {Node} node The element to check
260
285
  * @returns {boolean}
261
286
  */
262
287
  export function isUneditable(node) {
263
- return domUtils.hasClass(node, '__se__uneditable');
288
+ return /** @type {HTMLElement} */ (node)?.classList.contains('__se__uneditable');
264
289
  }
265
290
 
266
291
  /**
@@ -269,7 +294,7 @@ export function isUneditable(node) {
269
294
  * @returns {boolean}
270
295
  */
271
296
  export function isImportantDisabled(node) {
272
- return /** @type {HTMLElement} */ (node).hasAttribute('data-important-disabled');
297
+ return /** @type {HTMLElement} */ (node)?.hasAttribute('data-important-disabled');
273
298
  }
274
299
 
275
300
  const check = {
@@ -292,13 +317,14 @@ const check = {
292
317
  isFigure,
293
318
  isContentLess,
294
319
  isEmptyLine,
320
+ isComponentContainer,
295
321
  isWysiwygFrame,
296
322
  isNonEditable,
297
323
  isSpanWithoutAttr,
298
324
  isSameAttributes,
299
325
  isExcludeFormat,
300
326
  isUneditable,
301
- isImportantDisabled
327
+ isImportantDisabled,
302
328
  };
303
329
 
304
330
  export default check;