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,17 +1,8 @@
1
- /**
2
- * @fileoverview Offset class
3
- */
4
-
5
- import CoreInjector from '../../editorInjector/_core';
6
- import { getParentElement } from '../../helper/dom/domQuery';
7
- import { isWysiwygFrame, isElement } from '../../helper/dom/domCheck';
8
- import { hasClass, addClass, removeClass, getClientSize } from '../../helper/dom/domUtils';
9
- import { numbers } from '../../helper';
10
- import { _w, _d } from '../../helper/env';
11
-
12
- /**
13
- * @typedef {Omit<Offset & Partial<__se__EditorInjector>, 'offset'>} OffsetThis
14
- */
1
+ import { getParentElement } from '../../../helper/dom/domQuery';
2
+ import { isWysiwygFrame, isElement } from '../../../helper/dom/domCheck';
3
+ import { hasClass, addClass, removeClass, getClientSize } from '../../../helper/dom/domUtils';
4
+ import { numbers } from '../../../helper';
5
+ import { _w, _d } from '../../../helper/env';
15
6
 
16
7
  /**
17
8
  * @typedef {Object} RectsInfo Bounding rectangle information of the selection range.
@@ -37,16 +28,17 @@ import { _w, _d } from '../../helper/env';
37
28
  * @property {number} right - The right position of the node relative to the WYSIWYG editor.
38
29
  * @property {number} scrollX - The horizontal scroll offset inside the WYSIWYG editor.
39
30
  * @property {number} scrollY - The vertical scroll offset inside the WYSIWYG editor.
31
+ * @property {number} scrollH - The vertical scroll height inside the WYSIWYG editor.
40
32
  */
41
33
 
42
34
  /**
43
35
  * @typedef {Object} OffsetGlobalInfo
44
36
  * @property {number} top - The top position of the element relative to the entire document.
45
37
  * @property {number} left - The left position of the element relative to the entire document.
38
+ * @property {number} fixedTop - The top position within the current viewport, without taking scrolling into account.
39
+ * @property {number} fixedLeft - The left position within the current viewport, without taking scrolling into account.
46
40
  * @property {number} width - The total width of the element, including its content, padding, and border.
47
41
  * @property {number} height - The total height of the element, including its content, padding, and border.
48
- * @property {number} scrollTop - The amount of vertical scrolling applied to the element.
49
- * @property {number} scrollLeft - The amount of horizontal scrolling applied to the element.
50
42
  */
51
43
 
52
44
  /**
@@ -74,45 +66,55 @@ import { _w, _d } from '../../helper/env';
74
66
  * @property {number} width - The total width of the WYSIWYG editor's scrollable area.
75
67
  * @property {number} height - The total height of the WYSIWYG editor's scrollable area.
76
68
  * @property {number} bottom - The sum of `top` and `height`, representing the bottom-most scrollable position.
77
- * @property {RectsInfo} rects - The bounding rectangle of the editor's visible area.
78
69
  */
79
70
 
80
71
  /**
81
- * @constructor
82
- * @this {OffsetThis}
83
72
  * @description Offset class, get the position of the element
84
- * @param {__se__EditorCore} editor - The root editor instance
85
73
  */
86
- function Offset(editor) {
87
- CoreInjector.call(this, editor);
88
-
89
- // members
90
- this._scrollEvent = null;
91
- this._elTop = 0;
92
- this._scrollY = 0;
93
- this._isFixed = false;
94
- }
74
+ class Offset {
75
+ #$;
76
+ #store;
77
+
78
+ #shadowRoot;
79
+ #carrierWrapper;
80
+ #context;
81
+ #frameContext;
82
+ #options;
83
+ #frameOptions;
84
+
85
+ /**
86
+ * @constructor
87
+ * @param {SunEditor.Kernel} kernel
88
+ */
89
+ constructor(kernel) {
90
+ this.#$ = kernel.$;
91
+ this.#store = kernel.store;
92
+
93
+ this.#shadowRoot = this.#$.contextProvider.shadowRoot;
94
+ this.#carrierWrapper = this.#$.contextProvider.carrierWrapper;
95
+ this.#context = this.#$.context;
96
+ this.#frameContext = this.#$.frameContext;
97
+ this.#options = this.#$.options;
98
+ this.#frameOptions = this.#$.frameOptions;
99
+ }
95
100
 
96
- Offset.prototype = {
97
101
  /**
98
- * @this {OffsetThis}
99
102
  * @description Gets the position just outside the argument's internal editor (wysiwygFrame).
100
103
  * @param {Node} node Target node.
101
104
  * @returns {OffsetInfo} Position relative to the editor frame.
102
105
  */
103
106
  get(node) {
104
- const wFrame = this.editor.frameContext.get('wysiwygFrame');
107
+ const wFrame = this.#frameContext.get('wysiwygFrame');
105
108
  const iframe = /iframe/i.test(wFrame?.nodeName);
106
109
  const off = this.getLocal(node);
107
110
 
108
111
  return {
109
112
  left: off.left + (iframe ? wFrame.parentElement.offsetLeft : 0),
110
- top: off.top + (iframe ? wFrame.parentElement.offsetTop : 0)
113
+ top: off.top + (iframe ? wFrame.parentElement.offsetTop : 0),
111
114
  };
112
- },
115
+ }
113
116
 
114
117
  /**
115
- * @this {OffsetThis}
116
118
  * @description Gets the position inside the internal editor of the argument.
117
119
  * @param {Node} node Target node.
118
120
  * @returns {OffsetLocalInfo} Position relative to the WYSIWYG editor.
@@ -135,89 +137,79 @@ Offset.prototype = {
135
137
  offsetElement = /** @type {HTMLElement} */ (offsetElement.offsetParent);
136
138
  }
137
139
 
138
- const wwFrame = this.editor.frameContext.get('wysiwygFrame');
139
- if (this.editor.frameContext.get('wysiwyg').contains(target)) {
140
+ const wwFrame = this.#frameContext.get('wysiwygFrame');
141
+ if (this.#frameContext.get('wysiwyg').contains(target)) {
140
142
  l = wwFrame.offsetLeft;
141
143
  t = wwFrame.offsetTop;
142
144
  r = wwFrame.parentElement.offsetWidth - (wwFrame.offsetLeft + wwFrame.offsetWidth);
143
145
  }
144
146
 
145
- const eventWysiwyg = this.editor.frameContext.get('eventWysiwyg');
146
- offsetLeft += l;
147
+ const eventWysiwyg = this.#frameContext.get('eventWysiwyg');
148
+ offsetLeft += l - (wysiwyg ? wysiwyg.scrollLeft : 0);
147
149
  offsetTop += t - (wysiwyg ? wysiwyg.scrollTop : 0);
148
150
  return {
149
151
  left: offsetLeft,
150
152
  top: offsetTop,
151
153
  right: offsetElement?.offsetWidth ? offsetElement.offsetWidth - (offsetLeft - l + targetWidth) + r : 0,
152
- scrollX: eventWysiwyg.scrollX || eventWysiwyg.scrollLeft || 0,
153
- scrollY: eventWysiwyg.scrollY || eventWysiwyg.scrollTop || 0
154
+ scrollX: eventWysiwyg.scrollLeft || eventWysiwyg.scrollX || 0,
155
+ scrollY: eventWysiwyg.scrollTop || eventWysiwyg.scrollY || 0,
156
+ scrollH: this.#frameContext.get('wysiwyg').scrollHeight || 0,
154
157
  };
155
- },
158
+ }
156
159
 
157
160
  /**
158
- * @this {OffsetThis}
159
161
  * @description Returns the position of the argument relative to the global document.
160
- * @param {?Node=} node Target element.
162
+ * This is a refactored version using getBoundingClientRect for better performance and accuracy.
163
+ * @param {?Node} [node] Target element.
161
164
  * @returns {OffsetGlobalInfo} Global position and scroll values.
162
165
  */
163
166
  getGlobal(node) {
164
- const topArea = this.editor.frameContext.get('topArea');
165
- const wFrame = this.editor.frameContext.get('wysiwygFrame');
167
+ const topArea = this.#frameContext.get('topArea');
168
+ const wFrame = this.#frameContext.get('wysiwygFrame');
166
169
 
167
- let isTop = false;
168
- let targetAbs = false;
169
- if (!node) node = topArea;
170
- if (node === topArea) isTop = true;
171
- if (!isTop && isElement(node)) {
172
- targetAbs = _w.getComputedStyle(node).position === 'absolute';
173
- }
170
+ node ||= topArea;
174
171
 
175
- let element = /** @type {HTMLElement} */ (node);
176
- const w = element.offsetWidth;
177
- const h = element.offsetHeight;
178
- let t = 0,
179
- l = 0,
180
- st = 0,
181
- sl = 0;
182
-
183
- while (element) {
184
- t += element.offsetTop;
185
- l += element.offsetLeft;
186
- st += element.scrollTop;
187
- sl += element.scrollLeft;
188
- element = /** @type {HTMLElement} */ (element.offsetParent);
172
+ if (!isElement(node)) {
173
+ return { top: 0, left: 0, fixedTop: 0, fixedLeft: 0, width: 0, height: 0 };
189
174
  }
190
175
 
191
- if (!targetAbs && !isTop && /^iframe$/i.test(wFrame.nodeName) && this.editor.frameContext.get('wysiwyg').contains(element)) {
192
- element = this.editor.frameContext.get('wrapper');
193
- while (element) {
194
- t += element.offsetTop;
195
- l += element.offsetLeft;
196
- element = /** @type {HTMLElement} */ (element.offsetParent);
197
- }
176
+ const element = /** @type {HTMLElement} */ (node);
177
+
178
+ const rect = element.getBoundingClientRect();
179
+
180
+ let top = rect.top;
181
+ let left = rect.left;
182
+
183
+ const isIframe = /^iframe$/i.test(wFrame.nodeName);
184
+ if (isIframe && wFrame.contentDocument.contains(element)) {
185
+ const iframeRect = wFrame.getBoundingClientRect();
186
+ top += iframeRect.top;
187
+ left += iframeRect.left;
198
188
  }
199
189
 
190
+ const wy = _w.scrollY;
191
+ const wx = _w.scrollX;
192
+
200
193
  return {
201
- top: t + st,
202
- left: l + sl,
203
- width: w,
204
- height: h,
205
- scrollTop: st,
206
- scrollLeft: sl
194
+ top: top + wy,
195
+ left: left + wx,
196
+ fixedTop: top,
197
+ fixedLeft: left,
198
+ width: element.offsetWidth,
199
+ height: element.offsetHeight,
207
200
  };
208
- },
201
+ }
209
202
 
210
203
  /**
211
- * @this {OffsetThis}
212
204
  * @description Gets the current editor-relative scroll offset.
213
- * @param {?Node=} node Target element.
205
+ * @param {?Node} [node] Target element.
214
206
  * @returns {OffsetGlobalScrollInfo} Global scroll information.
215
207
  */
216
208
  getGlobalScroll(node) {
217
- const topArea = this.editor.frameContext.get('topArea');
209
+ const topArea = this.#frameContext.get('topArea');
218
210
  let isTop = false;
219
211
  let targetAbs = false;
220
- if (!node) node = topArea;
212
+ node ||= topArea;
221
213
  if (node === topArea) isTop = true;
222
214
  if (!isTop && isElement(node)) {
223
215
  targetAbs = _w.getComputedStyle(node).position === 'absolute';
@@ -246,7 +238,7 @@ Offset.prototype = {
246
238
  if (el.scrollTop > 0) {
247
239
  y += el.offsetTop;
248
240
  }
249
- if (el.scrollHeight > el.clientHeight) {
241
+ if (el.scrollHeight >= el.clientHeight) {
250
242
  oh = /^html$/i.test(el.nodeName) ? oh || el.clientHeight : el.clientHeight + (ohel ? -ohel.clientTop : 0);
251
243
  ohOffsetEl = ohel || ohOffsetEl || el;
252
244
  ohel = el;
@@ -254,7 +246,7 @@ Offset.prototype = {
254
246
  if (el.scrollLeft > 0) {
255
247
  x += el.offsetLeft;
256
248
  }
257
- if (el.scrollWidth > el.clientWidth) {
249
+ if (el.scrollWidth >= el.clientWidth) {
258
250
  ow = /^html$/i.test(el.nodeName) ? ow || el.clientWidth : el.clientWidth + (owel ? -owel.clientLeft : 0);
259
251
  owOffsetEl = owel || owOffsetEl || el;
260
252
  owel = el;
@@ -262,8 +254,8 @@ Offset.prototype = {
262
254
  el = el.parentElement;
263
255
  }
264
256
 
265
- if (!targetAbs && !isTop && /^iframe$/i.test(this.editor.frameContext.get('wysiwygFrame').nodeName)) {
266
- el = this.editor.frameContext.get('wrapper');
257
+ if (!targetAbs && !isTop && /^iframe$/i.test(this.#frameContext.get('wysiwygFrame').nodeName)) {
258
+ el = this.#frameContext.get('wrapper');
267
259
  ohOffsetEl = owOffsetEl = topArea;
268
260
  while (el) {
269
261
  t += el.scrollTop;
@@ -273,14 +265,14 @@ Offset.prototype = {
273
265
  if (el.scrollTop > 0) {
274
266
  y += el.offsetTop;
275
267
  }
276
- if (el.scrollHeight > el.clientHeight) {
268
+ if (el.scrollHeight >= el.clientHeight) {
277
269
  oh = /^html$/i.test(el.nodeName) ? oh || el.clientHeight : el.clientHeight + (ohel ? -ohel.clientTop : 0);
278
270
  ohel = el;
279
271
  }
280
272
  if (el.scrollLeft > 0) {
281
273
  x += el.offsetLeft;
282
274
  }
283
- if (el.scrollWidth > el.clientWidth) {
275
+ if (el.scrollWidth >= el.clientWidth) {
284
276
  ow = /^html$/i.test(el.nodeName) ? ow || el.clientWidth : el.clientWidth + (owel ? -owel.clientLeft : 0);
285
277
  owel = el;
286
278
  }
@@ -288,7 +280,7 @@ Offset.prototype = {
288
280
  }
289
281
  }
290
282
 
291
- el = /** @type {HTMLElement} */ (this.editor._shadowRoot?.host);
283
+ el = /** @type {HTMLElement} */ (this.#shadowRoot?.host);
292
284
  if (el) ohOffsetEl = owOffsetEl = topArea;
293
285
  while (el) {
294
286
  t += el.scrollTop;
@@ -298,14 +290,14 @@ Offset.prototype = {
298
290
  if (el.scrollTop > 0) {
299
291
  y += el.offsetTop;
300
292
  }
301
- if (el.scrollHeight > el.clientHeight) {
293
+ if (el.scrollHeight >= el.clientHeight) {
302
294
  oh = /^html$/i.test(el.nodeName) ? oh || el.clientHeight : el.clientHeight + (ohel ? -ohel.clientTop : 0);
303
295
  ohel = el;
304
296
  }
305
297
  if (el.scrollLeft > 0) {
306
298
  x += el.offsetLeft;
307
299
  }
308
- if (el.scrollWidth > el.clientWidth) {
300
+ if (el.scrollWidth >= el.clientWidth) {
309
301
  ow = /^html$/i.test(el.nodeName) ? ow || el.clientWidth : el.clientWidth + (owel ? -owel.clientLeft : 0);
310
302
  owel = el;
311
303
  }
@@ -322,7 +314,7 @@ Offset.prototype = {
322
314
  oh = heightEditorRefer ? topArea.clientHeight : oh;
323
315
  ow = widthEditorRefer ? topArea.clientWidth : ow;
324
316
 
325
- const clientSize = getClientSize(this.editor.frameContext.get('_wd'));
317
+ const clientSize = getClientSize(this.#frameContext.get('_wd'));
326
318
  return {
327
319
  top: t,
328
320
  left: l,
@@ -337,114 +329,97 @@ Offset.prototype = {
337
329
  oh: targetAbs ? clientSize.h : oh,
338
330
  ow: targetAbs ? clientSize.w : ow,
339
331
  heightEditorRefer: heightEditorRefer,
340
- widthEditorRefer: widthEditorRefer
332
+ widthEditorRefer: widthEditorRefer,
341
333
  };
342
- },
334
+ }
343
335
 
344
336
  /**
345
- * @this {OffsetThis}
346
337
  * @description Get the scroll info of the WYSIWYG area.
347
338
  * @returns {OffsetWWScrollInfo} Scroll information within the editor.
348
339
  */
349
340
  getWWScroll() {
350
- const eventWysiwyg = this.editor.frameContext.get('wysiwyg');
351
- const rects = this.selection.getRects(eventWysiwyg, 'start').rects;
352
- const top = eventWysiwyg.scrollY || eventWysiwyg.scrollTop || 0;
353
- const height = eventWysiwyg.scrollHeight || 0;
341
+ const eventWysiwyg = this.#frameContext.get('eventWysiwyg');
342
+ const top = eventWysiwyg.scrollTop || eventWysiwyg.scrollY || 0;
343
+ const height = eventWysiwyg.scrollHeight || eventWysiwyg.document?.documentElement.scrollHeight || 0;
354
344
 
355
345
  return {
356
346
  top,
357
- left: eventWysiwyg.scrollX || eventWysiwyg.scrollLeft || 0,
358
- width: eventWysiwyg.scrollWidth || 0,
347
+ left: eventWysiwyg.scrollLeft || eventWysiwyg.scrollX || 0,
348
+ width: eventWysiwyg.scrollWidth || eventWysiwyg.document?.documentElement.scrollWidth || 0,
359
349
  height,
360
350
  bottom: top + height,
361
- rects
362
351
  };
363
- },
352
+ }
364
353
 
365
354
  /**
366
- * @this {OffsetThis}
367
355
  * @description Sets the relative position of an element
368
356
  * @param {HTMLElement} element Element to position
369
357
  * @param {HTMLElement} e_container Element's root container
370
358
  * @param {HTMLElement} target Target element to position against
371
359
  * @param {HTMLElement} t_container Target's root container
372
- * @param {boolean} _reload Whether to reload position
373
360
  */
374
- setRelPosition(element, e_container, target, t_container, _reload) {
375
- this._scrollY = _w.scrollY;
376
- let wy = 0;
377
- let tCon = t_container;
378
- do {
379
- if ((this._isFixed = /^fixed$/i.test(_w.getComputedStyle(tCon).position))) {
380
- wy += this._scrollY;
381
- break;
382
- }
383
- } while (!hasClass(tCon, 'sun-editor') && (tCon = tCon.parentElement));
361
+ setRelPosition(element, e_container, target, t_container) {
362
+ const isFixedContainer = /^fixed$/i.test(_w.getComputedStyle(t_container).position);
363
+ const tGlobal = this.getGlobal(target);
364
+
365
+ // top
366
+ if (isFixedContainer) {
367
+ element.style.position = 'fixed';
368
+ element.style.top = `${tGlobal.fixedTop + tGlobal.height}px`;
369
+ } else {
370
+ element.style.position = '';
371
+
372
+ const isSameContainer = t_container.contains(element);
373
+ const containerTop = isSameContainer ? this.getGlobal(e_container).top : 0;
374
+ const elHeight = element.offsetHeight;
375
+ const scrollTop = this.getGlobalScroll().top;
376
+ const bt = tGlobal.top;
377
+
378
+ const menuHeight_bottom = getClientSize(_d).h - (containerTop - scrollTop + bt + target.offsetHeight);
379
+ if (menuHeight_bottom < elHeight) {
380
+ let menuTop = -1 * (elHeight - bt + 3);
381
+ const insTop = containerTop - scrollTop + menuTop;
382
+ const menuHeight_top = elHeight + (insTop < 0 ? insTop : 0);
383
+
384
+ if (menuHeight_top > menuHeight_bottom) {
385
+ element.style.height = `${menuHeight_top}px`;
386
+ menuTop = -1 * (menuHeight_top - bt + 3);
387
+ } else {
388
+ element.style.height = `${menuHeight_bottom}px`;
389
+ menuTop = bt + target.offsetHeight;
390
+ }
384
391
 
385
- if (!_reload) {
386
- this.__removeGlobalEvent();
387
- this._scrollEvent = this.editor.eventManager.addGlobalEvent('scroll', FixedScroll.bind(this, element, e_container, target, t_container), false);
392
+ element.style.top = `${menuTop}px`;
393
+ } else {
394
+ element.style.top = `${bt + target.offsetHeight}px`;
395
+ }
388
396
  }
389
397
 
398
+ // left
390
399
  const ew = element.offsetWidth;
391
400
  const tw = target.offsetWidth;
392
- const tl = this.getGlobal(target).left;
401
+ const tl = tGlobal.left;
393
402
  const tcleft = this.getGlobal(t_container).left;
394
403
 
395
- // left
396
- if (this.options.get('_rtl')) {
404
+ if (this.#options.get('_rtl')) {
397
405
  const rtlW = ew > tw ? ew - tw : 0;
398
406
  const rtlL = rtlW > 0 ? 0 : tw - ew;
399
- element.style.left = `${tl - rtlW + rtlL + tcleft}px`;
407
+ element.style.left = `${tl - rtlW + rtlL}px`;
400
408
  if (tcleft > this.getGlobal(element).left) {
401
409
  element.style.left = tcleft + 'px';
402
410
  }
403
411
  } else {
404
412
  const cw = t_container.offsetWidth + tcleft;
405
413
  const overLeft = cw <= ew ? 0 : cw - (tl + ew);
406
- if (overLeft < 0) element.style.left = `${tl + overLeft + tcleft}px`;
407
- else element.style.left = `${tl}px`;
408
- }
409
-
410
- // top
411
- const isSameContainer = t_container.contains(element);
412
- const containerTop = isSameContainer ? this.getGlobal(e_container).top : 0;
413
- const elHeight = element.offsetHeight;
414
- const scrollTop = this.getGlobalScroll().top;
415
- let bt = wy;
416
- let offsetEl = target;
417
- while (offsetEl && offsetEl !== e_container) {
418
- bt += offsetEl.offsetTop;
419
- offsetEl = /** @type {HTMLElement} */ (offsetEl.offsetParent);
420
- }
421
-
422
- const menuHeight_bottom = getClientSize(_d).h - (containerTop - scrollTop + bt + target.offsetHeight);
423
- if (menuHeight_bottom < elHeight) {
424
- let menuTop = -1 * (elHeight - bt + 3);
425
- const insTop = containerTop - scrollTop + menuTop;
426
- const menuHeight_top = elHeight + (insTop < 0 ? insTop : 0);
427
-
428
- if (menuHeight_top > menuHeight_bottom) {
429
- element.style.height = `${menuHeight_top}px`;
430
- menuTop = -1 * (menuHeight_top - bt + 3);
414
+ if (overLeft < 0) {
415
+ element.style.left = `${tl + overLeft}px`;
431
416
  } else {
432
- element.style.height = `${menuHeight_bottom}px`;
433
- menuTop = bt + target.offsetHeight;
417
+ element.style.left = `${tl}px`;
434
418
  }
435
-
436
- element.style.top = `${menuTop}px`;
437
- } else {
438
- element.style.top = `${bt + target.offsetHeight}px`;
439
419
  }
440
-
441
- if (this._isFixed) {
442
- this._elTop = element.offsetTop;
443
- }
444
- },
420
+ }
445
421
 
446
422
  /**
447
- * @this {OffsetThis}
448
423
  * @description Sets the absolute position of an element
449
424
  * @param {HTMLElement} element Element to position
450
425
  * @param {HTMLElement} target Target element
@@ -453,76 +428,97 @@ Offset.prototype = {
453
428
  * @param {{left:number, top:number}} [params.addOffset={left:0, top:0}] Additional offset
454
429
  * @param {"bottom"|"top"} [params.position="bottom"] Position ('bottom'|'top')
455
430
  * @param {*} params.inst Instance object of caller
431
+ * @param {HTMLElement} [params.sibling=null] The sibling controller element
456
432
  * @returns {{position: "top" | "bottom"} | undefined} Success -> {position: current position}
457
433
  */
458
434
  setAbsPosition(element, target, params) {
459
435
  const addOffset = {
460
436
  left: 0,
461
437
  top: 0,
462
- ...params.addOffset
438
+ ...params.addOffset,
463
439
  };
464
440
  const position = params.position || 'bottom';
465
441
  const inst = params.inst;
466
- const isLTR = !this.options.get('_rtl');
442
+ const isLTR = !this.#options.get('_rtl');
467
443
 
468
444
  if (!isLTR) {
469
445
  addOffset.left *= -1;
470
446
  }
471
447
 
472
- const isWWTarget = this.editor.frameContext.get('wrapper').contains(target) || params.isWWTarget;
473
- const isCtrlTarget = getParentElement(target, '.se-controller');
474
- const isTargetAbs = isWWTarget && !isCtrlTarget;
448
+ const isIframe = this.#frameOptions.get('iframe');
449
+ const isWWTarget = this.#frameContext.get('wrapper').contains(target) || params.isWWTarget || (isIframe ? this.#frameContext.get('wysiwyg').contains(target) : false);
450
+ const isToolbarTarget = Boolean(getParentElement(target, '.se-toolbar'));
451
+ const isElTarget = target.nodeType === 1;
452
+
453
+ const isTextSelection = isWWTarget && !isElTarget;
454
+ const isInlineTarget = isElTarget && /inline/.test(_w.getComputedStyle(target).display);
475
455
  const clientSize = getClientSize(_d);
476
- const wwScroll = isTargetAbs ? this.getWWScroll() : this._getWindowScroll();
477
- const targetRect = isCtrlTarget ? target.getBoundingClientRect() : this.selection.getRects(target, 'start').rects;
456
+ const wwScroll = isTextSelection ? this.getWWScroll() : this.#getWindowScroll();
457
+ const targetRect = !isWWTarget || (!isIframe && isElTarget) ? target.getBoundingClientRect() : this.#$.selection.getRects(target, 'start').rects;
478
458
  const targetOffset = this.getGlobal(target);
479
459
  const arrow = /** @type {HTMLElement} */ (hasClass(element.firstElementChild, 'se-arrow') ? element.firstElementChild : null);
480
460
 
481
461
  // top ----------------------------------------------------------------------------------------------------
462
+ const siblingH = params.sibling?.offsetHeight || 0;
482
463
  const ah = arrow ? arrow.offsetHeight : 0;
483
464
  const elH = element.offsetHeight;
484
465
  const targetH = target.offsetHeight;
485
466
  // margin
486
467
  const tmtw = targetRect.top;
487
468
  const tmbw = clientSize.h - targetRect.bottom;
488
- const toolbarH = !this.editor.toolbar._sticky && (this.editor.isBalloon || this.editor.isInline) ? 0 : this.context.get('toolbar.main').offsetHeight;
469
+ const globalTop = this.getGlobal(this.#frameContext.get('topArea')).top;
470
+ const wScrollY = _w.scrollY;
471
+ const th = this.#context.get('toolbar_main').offsetHeight;
472
+ const containerToolbar = this.#options.get('toolbar_container');
473
+ const headLess = this.#store.mode.isBalloon || this.#store.mode.isInline || containerToolbar;
474
+ const toolbarH = (containerToolbar && globalTop - wScrollY - th > 0) || (!this.#$.toolbar.isSticky && headLess) ? 0 : th + (this.#$.toolbar.isSticky ? this.#options.get('toolbar_sticky') : 0);
475
+ const statusBarH = this.#frameContext.get('statusbar')?.offsetHeight || 0;
489
476
 
490
477
  // check margin
491
- const { rmt, rmb, rt } = this._getVMargin(tmtw, tmbw, toolbarH, clientSize, targetRect, isTargetAbs, wwScroll);
492
- if (isWWTarget && (rmb + targetH <= 0 || rmt + rt + targetH <= 0)) return;
478
+ const { rmt, rmb, bMargin, rt } = this.#getVMargin(tmtw, tmbw, toolbarH, clientSize, targetRect, isTextSelection, isToolbarTarget);
479
+ if ((isWWTarget && (rmb - statusBarH + targetH <= 0 || rmt + rt + targetH - (this.#$.toolbar.isSticky && isInlineTarget ? toolbarH : 0) <= 0)) || rmt + targetH < 0) return;
493
480
 
481
+ const isSticky = this.#$.toolbar.isSticky && this.#context.get('toolbar_main').style.display !== 'none' && (!headLess || this.#frameContext.get('topArea').getBoundingClientRect().top <= th);
494
482
  let t = addOffset.top;
495
483
  let y = 0;
496
484
  let arrowDir = '';
485
+
486
+ // [bottom] position
497
487
  if (position === 'bottom') {
498
488
  arrowDir = 'up';
499
- t += targetRect.bottom + ah + _w.scrollY;
489
+ t += targetRect.bottom + ah + wScrollY;
500
490
  y = rmb - (elH + ah);
501
- if (y < 0) {
491
+ // change to <top> position
492
+ if (y - siblingH < 0) {
502
493
  arrowDir = 'down';
503
494
  t -= targetH + elH + ah * 2;
504
- y = toolbarH + rmt - (elH + ah);
505
- if (y < 0) {
495
+ y = rmt - (elH + ah);
496
+ // sticky the <top> position
497
+ if (y - siblingH < 0) {
506
498
  arrowDir = '';
507
- t -= y;
499
+ t -= y - siblingH - Math.max(1, y + elH + ah);
508
500
  }
509
501
  }
510
- } else {
502
+ }
503
+ // <top> position
504
+ else {
511
505
  arrowDir = 'down';
512
- t += targetRect.top - elH - ah + _w.scrollY;
513
- y = rmt - (elH + ah);
514
- if (y < 0) {
506
+ t += targetRect.top - elH - ah + wScrollY;
507
+ y = (isSticky ? targetRect.top - toolbarH : rmt) - elH - ah;
508
+ // change to [bottom] position
509
+ if (y - siblingH < 0) {
515
510
  arrowDir = 'up';
516
511
  t += targetH + elH + ah * 2;
517
- y = rmb - (elH + ah);
518
- if (y < 0) {
512
+ y = (rmb > 0 ? bMargin : rmb) - (elH + ah) - statusBarH;
513
+ // sticky the [bottom] position
514
+ if (y - siblingH < 0) {
519
515
  arrowDir = '';
520
- t += y;
516
+ t += y - 2;
521
517
  }
522
518
  }
523
519
  }
524
520
 
525
- this._setArrow(arrow, arrowDir);
521
+ this.#setArrow(arrow, arrowDir);
526
522
  element.style.top = `${t}px`;
527
523
 
528
524
  // left ----------------------------------------------------------------------------------------------------
@@ -531,16 +527,8 @@ Offset.prototype = {
531
527
  const elW = element.offsetWidth;
532
528
  const aw = arrow ? arrow.offsetWidth : 0;
533
529
  // margin
534
- const tmlw = targetRect.left;
535
- const tmrw = clientSize.w - targetRect.right;
536
- let rml, rmr;
537
- if (this.editor.frameContext.get('isFullScreen')) {
538
- rml = tmlw;
539
- rmr = tmrw;
540
- } else {
541
- rml = targetRect.left;
542
- rmr = clientSize.w - targetRect.right;
543
- }
530
+ const rml = targetRect.left;
531
+ const rmr = clientSize.w - targetRect.right;
544
532
 
545
533
  if (isWWTarget && (rml + targetW <= 0 || rmr + targetW <= 0)) return;
546
534
  if (arrow) {
@@ -588,14 +576,13 @@ Offset.prototype = {
588
576
  inst.__offset = {
589
577
  left: element.offsetLeft + wwScroll.left,
590
578
  top: element.offsetTop + wwScroll.top,
591
- addOffset: addOffset
579
+ addOffset: addOffset,
592
580
  };
593
581
 
594
582
  return { position: arrowDir === 'up' ? 'bottom' : 'top' };
595
- },
583
+ }
596
584
 
597
585
  /**
598
- * @this {OffsetThis}
599
586
  * @description Sets the position of an element relative to a range
600
587
  * @param {HTMLElement} element Element to position
601
588
  * @param {?Range} range Range to position against.
@@ -611,12 +598,12 @@ Offset.prototype = {
611
598
  element.style.display = 'block';
612
599
 
613
600
  let positionTop = position === 'top';
614
- range = range || this.selection.getRange();
615
- const rectsObj = this.selection.getRects(range, positionTop ? 'start' : 'end');
601
+ range ||= this.#$.selection.getRange();
602
+ const rectsObj = this.#$.selection.getRects(range, positionTop ? 'start' : 'end');
616
603
  positionTop = rectsObj.position === 'start';
617
604
 
618
- const isFullScreen = this.editor.frameContext.get('isFullScreen');
619
- const topArea = this.editor.frameContext.get('topArea');
605
+ const isFullScreen = this.#frameContext.get('isFullScreen');
606
+ const topArea = this.#frameContext.get('topArea');
620
607
  const rects = rectsObj.rects;
621
608
  const scrollLeft = isFullScreen ? 0 : rectsObj.scrollLeft;
622
609
  const scrollTop = isFullScreen ? 0 : rectsObj.scrollTop;
@@ -626,38 +613,33 @@ Offset.prototype = {
626
613
  const toolbarWidth = element.offsetWidth;
627
614
  const toolbarHeight = element.offsetHeight;
628
615
 
629
- this._setOffsetOnRange(positionTop, rects, element, editorLeft, editorWidth, scrollLeft, scrollTop, addTop);
616
+ this.#setOffsetOnRange(positionTop, rects, element, editorLeft, editorWidth, scrollLeft, scrollTop, addTop);
630
617
  if (this.getGlobal(element).top - offsets.top < 0) {
631
618
  positionTop = !positionTop;
632
- this._setOffsetOnRange(positionTop, rects, element, editorLeft, editorWidth, scrollLeft, scrollTop, addTop);
619
+ this.#setOffsetOnRange(positionTop, rects, element, editorLeft, editorWidth, scrollLeft, scrollTop, addTop);
633
620
  }
634
621
 
635
622
  if (toolbarWidth !== element.offsetWidth || toolbarHeight !== element.offsetHeight) {
636
- this._setOffsetOnRange(positionTop, rects, element, editorLeft, editorWidth, scrollLeft, scrollTop, addTop);
623
+ this.#setOffsetOnRange(positionTop, rects, element, editorLeft, editorWidth, scrollLeft, scrollTop, addTop);
637
624
  }
638
625
 
639
626
  // check margin
640
- const isTargetAbs = !this.carrierWrapper.contains(element);
627
+ const isTextSelection = !this.#carrierWrapper.contains(element);
641
628
  const clientSize = getClientSize(_d);
642
- const wwScroll = isTargetAbs ? this.getWWScroll() : this._getWindowScroll();
643
629
  const targetH = rects.height;
644
630
  const tmtw = rects.top;
645
631
  const tmbw = clientSize.h - rects.bottom;
646
- const toolbarH = !this.editor.toolbar._sticky && (this.editor.isBalloon || this.editor.isInline) ? 0 : this.context.get('toolbar.main').offsetHeight;
632
+ const toolbarH = !this.#$.toolbar.isSticky && (this.#store.mode.isBalloon || this.#store.mode.isInline) ? 0 : this.#context.get('toolbar_main').offsetHeight;
647
633
 
648
- const { rmt, rmb, rt } = this._getVMargin(tmtw, tmbw, toolbarH, clientSize, rects, isTargetAbs, wwScroll);
634
+ const { rmt, rmb, rt } = this.#getVMargin(tmtw, tmbw, toolbarH, clientSize, rects, isTextSelection, false);
649
635
  if (rmb + targetH <= 0 || rmt + rt + targetH <= 0) return;
650
636
 
651
- _w.setTimeout(() => {
652
- element.style.visibility = '';
653
- }, 0);
637
+ element.style.visibility = '';
654
638
 
655
639
  return true;
656
- },
640
+ }
657
641
 
658
642
  /**
659
- * @private
660
- * @this {OffsetThis}
661
643
  * @description Sets the position of an element relative to the selection range in the editor.
662
644
  * - This method calculates the top and left offsets for the element, ensuring it
663
645
  * - does not overflow the editor boundaries and adjusts the arrow positioning accordingly.
@@ -670,7 +652,7 @@ Offset.prototype = {
670
652
  * @param {number} scrollTop - The vertical scroll offset.
671
653
  * @param {number} [addTop=0] - Additional top margin adjustment.
672
654
  */
673
- _setOffsetOnRange(isDirTop, rects, element, editorLeft, editorWidth, scrollLeft, scrollTop, addTop = 0) {
655
+ #setOffsetOnRange(isDirTop, rects, element, editorLeft, editorWidth, scrollLeft, scrollTop, addTop = 0) {
674
656
  const padding = 1;
675
657
  const arrow = /** @type {HTMLElement} */ (element.querySelector('.se-arrow '));
676
658
  const arrowMargin = Math.round(arrow.offsetWidth / 2);
@@ -684,8 +666,8 @@ Offset.prototype = {
684
666
  const l = absoluteLeft < 0 ? padding : overRight < 0 ? absoluteLeft : absoluteLeft - overRight - padding - 1;
685
667
 
686
668
  let resetTop = false;
687
- const space = t + (isDirTop ? this.getGlobal(this.editor.frameContext.get('topArea')).top : element.offsetHeight - this.editor.frameContext.get('wysiwyg').offsetHeight);
688
- if (!isDirTop && space > 0 && this._getPageBottomSpace() < space) {
669
+ const space = t + (isDirTop ? this.getGlobal(this.#frameContext.get('topArea')).top : element.offsetHeight - this.#frameContext.get('wysiwyg').offsetHeight);
670
+ if (!isDirTop && space > 0 && this.#getPageBottomSpace() < space) {
689
671
  isDirTop = true;
690
672
  resetTop = true;
691
673
  } else if (isDirTop && _d.documentElement.offsetTop > space) {
@@ -708,22 +690,18 @@ Offset.prototype = {
708
690
 
709
691
  const arrow_left = Math.floor(elW / 2 + (absoluteLeft - l));
710
692
  arrow.style.left = (arrow_left + arrowMargin > element.offsetWidth ? element.offsetWidth - arrowMargin : arrow_left < arrowMargin ? arrowMargin : arrow_left) + 'px';
711
- },
693
+ }
712
694
 
713
695
  /**
714
- * @private
715
- * @this {OffsetThis}
716
696
  * @description Get available space from page bottom
717
697
  * @returns {number} Available space
718
698
  */
719
- _getPageBottomSpace() {
720
- const topArea = this.editor.frameContext.get('topArea');
699
+ #getPageBottomSpace() {
700
+ const topArea = this.#frameContext.get('topArea');
721
701
  return _d.documentElement.scrollHeight - (this.getGlobal(topArea).top + topArea.offsetHeight);
722
- },
702
+ }
723
703
 
724
704
  /**
725
- * @private
726
- * @this {OffsetThis}
727
705
  * @description Calculates the vertical margin offsets for the target element relative to the editor frame.
728
706
  * - This method determines the top and bottom margins based on various conditions such as
729
707
  * - fullscreen mode, iframe usage, toolbar height, and scroll positions.
@@ -732,67 +710,68 @@ Offset.prototype = {
732
710
  * @param {number} toolbarH Toolbar height
733
711
  * @param {{w: number, h: number}} clientSize documentElement.clientWidth, documentElement.clientHeight
734
712
  * @param {RectsInfo} targetRect Target rect object
735
- * @param {boolean} isTargetAbs Is target absolute position
736
- * @param {OffsetWWScrollInfo} wwScroll WYSIWYG scroll info
737
- * @returns {{rmt:number, rmb:number, rt:number}} Margin values (rmt: top margin, rmb: bottom margin, rt: Toolbar height offset adjustment)
713
+ * @param {boolean} isTextSelection Is text selection or Range
714
+ * @param {boolean} isToolbarTarget Indicates if the target is a toolbar element
715
+ * @returns {{rmt:number, rmb:number, rt:number, tMargin:number, bMargin:number}} Margin values
716
+ * - rmt: top margin to frame
717
+ * - rmb: bottom margin to frame
718
+ * - rt: Toolbar height offset adjustment
719
+ * - tMargin: top margin
720
+ * - bMargin: bottom margin
738
721
  */
739
- _getVMargin(tmtw, tmbw, toolbarH, clientSize, targetRect, isTargetAbs, wwScroll) {
722
+ #getVMargin(tmtw, tmbw, toolbarH, clientSize, targetRect, isTextSelection, isToolbarTarget) {
723
+ const wwRects = this.#$.selection.getRects(this.#frameContext.get('wysiwyg'), 'start').rects;
724
+
740
725
  let rmt = 0;
741
726
  let rmb = 0;
742
727
  let rt = 0;
743
- if (this.editor.frameContext.get('isFullScreen')) {
744
- rmt = tmtw - toolbarH;
745
- rmb = tmbw;
728
+ let tMargin = 0;
729
+ let bMargin = 0;
730
+
731
+ const isIframe = this.#frameOptions.get('iframe');
732
+ tMargin = targetRect.top;
733
+ bMargin = clientSize.h - targetRect.bottom;
734
+ const editorOffset = this.getGlobal();
735
+
736
+ if (!isTextSelection) {
737
+ const emt = editorOffset.fixedTop > 0 ? editorOffset.fixedTop : 0;
738
+ const emb = _w.innerHeight - (editorOffset.fixedTop + editorOffset.height);
739
+ rt = !isToolbarTarget && (this.#$.toolbar.isSticky || !this.#$.toolbar.isBalloonMode) ? toolbarH : 0;
740
+ rmt = tMargin - (!isToolbarTarget ? emt : 0) - rt;
741
+ rmb = bMargin - (emb > 0 ? emb : 0);
746
742
  } else {
747
- const isIframe = isTargetAbs && this.editor.frameOptions.get('iframe');
748
- const tMargin = targetRect.top;
749
- const bMargin = clientSize.h - targetRect.bottom;
750
- const editorOffset = this.getGlobal();
751
- const editorScroll = this.getGlobalScroll();
752
- const statusBarH = this.editor.frameContext.get('statusbar')?.offsetHeight || 0;
753
-
754
- if (isIframe) {
755
- const emt = editorOffset.top - editorScroll.top - editorScroll.ts;
756
- const editorH = this.editor.frameContext.get('topArea').offsetHeight;
757
- rmt = targetRect.top - emt;
758
- rmb = bMargin - (editorScroll.oh - (editorH + emt) + statusBarH);
759
- } else {
760
- rt = !this.editor.toolbar._sticky && !this.options.get('toolbar_container') ? toolbarH : 0;
761
- const wst = !isTargetAbs && /\d+/.test(this.editor.frameOptions.get('height')) ? editorOffset.top - _w.scrollY + rt : 0;
762
- const wsb = !isTargetAbs && /\d+/.test(this.editor.frameOptions.get('height')) ? _w.innerHeight - (editorOffset.top + editorOffset.height - _w.scrollY) : 0;
763
- let st = wst;
764
- if (toolbarH > wst) {
765
- if (this.editor.toolbar._sticky) {
766
- st = toolbarH;
767
- toolbarH = 0;
768
- } else {
769
- st = wst + toolbarH;
770
- }
771
- } else if (this.options.get('toolbar_container')) {
772
- toolbarH = 0;
743
+ rt = !isToolbarTarget && !this.#$.toolbar.isSticky && !this.#options.get('toolbar_container') ? toolbarH : 0;
744
+ const wst = !isIframe ? editorOffset.top - _w.scrollY + rt : 0;
745
+ const wsb = !isIframe ? this.#store.get('currentViewportHeight') - (editorOffset.top + editorOffset.height - _w.scrollY) : 0;
746
+ let st = wst;
747
+ if (toolbarH > wst) {
748
+ if (this.#$.toolbar.isSticky) {
749
+ st = toolbarH;
773
750
  } else {
774
- st = wst + (this.editor.toolbar._sticky ? toolbarH : 0);
751
+ st = wst + toolbarH;
775
752
  }
776
-
777
- rmt = targetRect.top - st;
778
- rmb = wwScroll.rects.bottom - targetRect.bottom - wsb - statusBarH;
753
+ } else if (this.#options.get('toolbar_container') && !this.#$.toolbar.isSticky) {
754
+ toolbarH = 0;
755
+ } else {
756
+ st = wst + toolbarH;
779
757
  }
780
758
 
759
+ rmt = targetRect.top - (wwRects.top - st) + toolbarH;
760
+ rmb = wwRects.bottom - (targetRect.bottom - wsb);
781
761
  // display margin
782
- rmt = (rmt > 0 ? tMargin : rmt) - toolbarH;
783
- rmb = rmb > 0 ? bMargin : rmb;
762
+ rmt = rmt > 0 ? rmt : rmt - toolbarH;
784
763
  }
785
764
 
786
765
  return {
787
766
  rmt,
788
767
  rmb,
789
- rt
768
+ rt,
769
+ tMargin,
770
+ bMargin,
790
771
  };
791
- },
772
+ }
792
773
 
793
774
  /**
794
- * @private
795
- * @this {OffsetThis}
796
775
  * @description Sets the visibility and direction of the arrow element.
797
776
  * - This method applies the appropriate class (`se-arrow-up` or `se-arrow-down`)
798
777
  * - based on the specified direction key and adjusts the visibility of the arrow.
@@ -801,7 +780,7 @@ Offset.prototype = {
801
780
  * - Accepts `'up'` for an upward arrow, `'down'` for a downward arrow,
802
781
  * - or any other value to hide the arrow.
803
782
  */
804
- _setArrow(arrow, key) {
783
+ #setArrow(arrow, key) {
805
784
  if (key === 'up') {
806
785
  if (arrow) arrow.style.visibility = '';
807
786
  addClass(arrow, 'se-arrow-up');
@@ -813,11 +792,9 @@ Offset.prototype = {
813
792
  } else {
814
793
  if (arrow) arrow.style.visibility = 'hidden';
815
794
  }
816
- },
795
+ }
817
796
 
818
797
  /**
819
- * @private
820
- * @this {OffsetThis}
821
798
  * @description Retrieves the current window scroll position and viewport size.
822
799
  * - Returns an object containing the scroll offsets, viewport dimensions, and boundary rects.
823
800
  * @returns {{
@@ -829,8 +806,7 @@ Offset.prototype = {
829
806
  * rects: RectsInfo
830
807
  * }} An object with scroll and viewport information.
831
808
  */
832
-
833
- _getWindowScroll() {
809
+ #getWindowScroll() {
834
810
  const viewPort = getClientSize(_d);
835
811
  return {
836
812
  top: _w.scrollY,
@@ -842,50 +818,11 @@ Offset.prototype = {
842
818
  left: 0,
843
819
  top: 0,
844
820
  right: _w.innerWidth,
845
- bottom: _w.innerHeight,
846
- noText: true
847
- }
821
+ bottom: this.#store.get('currentViewportHeight') || _w.innerHeight,
822
+ noText: true,
823
+ },
848
824
  };
849
- },
850
-
851
- /**
852
- * @private
853
- * @this {OffsetThis}
854
- * @description Removes the global scroll event listener from the editor.
855
- * - Resets related scroll tracking properties.
856
- */
857
- __removeGlobalEvent() {
858
- if (this._scrollEvent) {
859
- this._scrollEvent = this.editor.eventManager.removeGlobalEvent(this._scrollEvent);
860
- this._scrollY = 0;
861
- this._elTop = null;
862
- }
863
- },
864
-
865
- constructor: Offset
866
- };
867
-
868
- /**
869
- * @private
870
- * @this {OffsetThis}
871
- * @param {HTMLElement} element - The element to check for a specific class name.
872
- * @param {HTMLElement} e_container - The root container of the element.
873
- * @param {HTMLElement} target - The target element to position against.
874
- * @param {HTMLElement} t_container - The root container of the target element.
875
- */
876
- function FixedScroll(element, e_container, target, t_container) {
877
- const isFixed = /^fixed$/i.test(_w.getComputedStyle(t_container).position);
878
- if (!this._isFixed) {
879
- if (isFixed) {
880
- this.setRelPosition(element, e_container, target, t_container, true);
881
- }
882
- return;
883
- } else if (!isFixed) {
884
- this.setRelPosition(element, e_container, target, t_container, true);
885
- return;
886
825
  }
887
-
888
- element.style.top = `${this._elTop - (this._scrollY - _w.scrollY - t_container.offsetTop)}px`;
889
826
  }
890
827
 
891
828
  export default Offset;