suneditor 3.0.0-beta.3 → 3.0.0-beta.30

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 (241) hide show
  1. package/CONTRIBUTING.md +8 -8
  2. package/README.md +44 -49
  3. package/dist/suneditor.min.css +1 -1
  4. package/dist/suneditor.min.js +1 -1
  5. package/package.json +95 -53
  6. package/src/assets/design/color.css +2 -2
  7. package/src/assets/design/size.css +2 -0
  8. package/src/assets/icons/defaultIcons.js +16 -1
  9. package/src/assets/suneditor-contents.css +9 -8
  10. package/src/assets/suneditor.css +29 -26
  11. package/src/core/{section → base}/actives.js +20 -12
  12. package/src/core/base/history.js +4 -4
  13. package/src/core/class/char.js +10 -10
  14. package/src/core/class/component.js +146 -57
  15. package/src/core/class/format.js +94 -2458
  16. package/src/core/class/html.js +187 -129
  17. package/src/core/class/inline.js +1853 -0
  18. package/src/core/class/listFormat.js +582 -0
  19. package/src/core/class/menu.js +14 -3
  20. package/src/core/class/nodeTransform.js +9 -14
  21. package/src/core/class/offset.js +162 -197
  22. package/src/core/class/selection.js +137 -34
  23. package/src/core/class/toolbar.js +73 -52
  24. package/src/core/class/ui.js +11 -11
  25. package/src/core/class/viewer.js +56 -55
  26. package/src/core/config/context.js +122 -0
  27. package/src/core/config/frameContext.js +204 -0
  28. package/src/core/config/options.js +639 -0
  29. package/src/core/editor.js +181 -108
  30. package/src/core/event/actions/index.js +229 -0
  31. package/src/core/event/effects/common.registry.js +60 -0
  32. package/src/core/event/effects/keydown.registry.js +551 -0
  33. package/src/core/event/effects/ruleHelpers.js +145 -0
  34. package/src/core/{base → event}/eventManager.js +119 -201
  35. package/src/core/event/executor.js +21 -0
  36. package/src/core/{base/eventHandlers → event/handlers}/handler_toolbar.js +4 -4
  37. package/src/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.js +2 -2
  38. package/src/core/event/handlers/handler_ww_input.js +77 -0
  39. package/src/core/event/handlers/handler_ww_key.js +228 -0
  40. package/src/core/{base/eventHandlers → event/handlers}/handler_ww_mouse.js +3 -3
  41. package/src/core/event/ports.js +211 -0
  42. package/src/core/event/reducers/keydown.reducer.js +89 -0
  43. package/src/core/event/rules/keydown.rule.arrow.js +54 -0
  44. package/src/core/event/rules/keydown.rule.backspace.js +202 -0
  45. package/src/core/event/rules/keydown.rule.delete.js +126 -0
  46. package/src/core/event/rules/keydown.rule.enter.js +144 -0
  47. package/src/core/event/rules/keydown.rule.tab.js +29 -0
  48. package/src/core/section/constructor.js +79 -388
  49. package/src/core/section/documentType.js +47 -26
  50. package/src/core/util/instanceCheck.js +59 -0
  51. package/src/editorInjector/_classes.js +4 -0
  52. package/src/editorInjector/_core.js +17 -7
  53. package/src/editorInjector/index.js +10 -2
  54. package/src/events.js +6 -0
  55. package/src/helper/clipboard.js +24 -10
  56. package/src/helper/converter.js +17 -12
  57. package/src/helper/dom/domCheck.js +22 -3
  58. package/src/helper/dom/domQuery.js +91 -45
  59. package/src/helper/dom/domUtils.js +93 -19
  60. package/src/helper/dom/index.js +4 -0
  61. package/src/helper/env.js +11 -7
  62. package/src/helper/keyCodeMap.js +4 -3
  63. package/src/langs/ckb.js +1 -1
  64. package/src/langs/cs.js +1 -1
  65. package/src/langs/da.js +1 -1
  66. package/src/langs/de.js +1 -1
  67. package/src/langs/en.js +1 -1
  68. package/src/langs/es.js +1 -1
  69. package/src/langs/fa.js +1 -1
  70. package/src/langs/fr.js +1 -1
  71. package/src/langs/he.js +1 -1
  72. package/src/langs/hu.js +1 -1
  73. package/src/langs/it.js +1 -1
  74. package/src/langs/ja.js +1 -1
  75. package/src/langs/km.js +1 -1
  76. package/src/langs/ko.js +1 -1
  77. package/src/langs/lv.js +1 -1
  78. package/src/langs/nl.js +1 -1
  79. package/src/langs/pl.js +1 -1
  80. package/src/langs/pt_br.js +10 -10
  81. package/src/langs/ro.js +1 -1
  82. package/src/langs/ru.js +1 -1
  83. package/src/langs/se.js +1 -1
  84. package/src/langs/tr.js +1 -1
  85. package/src/langs/uk.js +1 -1
  86. package/src/langs/ur.js +1 -1
  87. package/src/langs/zh_cn.js +1 -1
  88. package/src/modules/ApiManager.js +25 -18
  89. package/src/modules/Browser.js +52 -61
  90. package/src/modules/ColorPicker.js +37 -38
  91. package/src/modules/Controller.js +85 -79
  92. package/src/modules/Figure.js +275 -187
  93. package/src/modules/FileManager.js +86 -92
  94. package/src/modules/HueSlider.js +67 -35
  95. package/src/modules/Modal.js +84 -77
  96. package/src/modules/ModalAnchorEditor.js +62 -79
  97. package/src/modules/SelectMenu.js +89 -86
  98. package/src/plugins/browser/audioGallery.js +9 -5
  99. package/src/plugins/browser/fileBrowser.js +10 -6
  100. package/src/plugins/browser/fileGallery.js +9 -5
  101. package/src/plugins/browser/imageGallery.js +9 -5
  102. package/src/plugins/browser/videoGallery.js +11 -6
  103. package/src/plugins/command/blockquote.js +1 -0
  104. package/src/plugins/command/exportPDF.js +11 -8
  105. package/src/plugins/command/fileUpload.js +41 -29
  106. package/src/plugins/command/list_bulleted.js +2 -1
  107. package/src/plugins/command/list_numbered.js +2 -1
  108. package/src/plugins/dropdown/align.js +8 -2
  109. package/src/plugins/dropdown/backgroundColor.js +19 -11
  110. package/src/plugins/dropdown/font.js +15 -9
  111. package/src/plugins/dropdown/fontColor.js +19 -11
  112. package/src/plugins/dropdown/formatBlock.js +7 -2
  113. package/src/plugins/dropdown/hr.js +7 -3
  114. package/src/plugins/dropdown/layout.js +6 -2
  115. package/src/plugins/dropdown/lineHeight.js +8 -3
  116. package/src/plugins/dropdown/list.js +2 -1
  117. package/src/plugins/dropdown/paragraphStyle.js +15 -11
  118. package/src/plugins/dropdown/{table.js → table/index.js} +514 -362
  119. package/src/plugins/dropdown/template.js +6 -2
  120. package/src/plugins/dropdown/textStyle.js +7 -3
  121. package/src/plugins/field/mention.js +33 -27
  122. package/src/plugins/input/fontSize.js +44 -37
  123. package/src/plugins/input/pageNavigator.js +3 -2
  124. package/src/plugins/modal/audio.js +90 -85
  125. package/src/plugins/modal/drawing.js +58 -66
  126. package/src/plugins/modal/embed.js +193 -180
  127. package/src/plugins/modal/image.js +441 -439
  128. package/src/plugins/modal/link.js +31 -8
  129. package/src/plugins/modal/math.js +23 -22
  130. package/src/plugins/modal/video.js +233 -230
  131. package/src/plugins/popup/anchor.js +24 -18
  132. package/src/suneditor.js +69 -24
  133. package/src/typedef.js +42 -19
  134. package/types/assets/icons/defaultIcons.d.ts +8 -0
  135. package/types/core/class/char.d.ts +1 -1
  136. package/types/core/class/component.d.ts +29 -7
  137. package/types/core/class/format.d.ts +4 -354
  138. package/types/core/class/html.d.ts +13 -4
  139. package/types/core/class/inline.d.ts +263 -0
  140. package/types/core/class/listFormat.d.ts +135 -0
  141. package/types/core/class/menu.d.ts +10 -2
  142. package/types/core/class/offset.d.ts +24 -26
  143. package/types/core/class/selection.d.ts +2 -0
  144. package/types/core/class/toolbar.d.ts +24 -11
  145. package/types/core/class/ui.d.ts +1 -1
  146. package/types/core/class/viewer.d.ts +1 -1
  147. package/types/core/config/context.d.ts +157 -0
  148. package/types/core/config/frameContext.d.ts +367 -0
  149. package/types/core/config/options.d.ts +1119 -0
  150. package/types/core/editor.d.ts +101 -66
  151. package/types/core/event/actions/index.d.ts +47 -0
  152. package/types/core/event/effects/common.registry.d.ts +50 -0
  153. package/types/core/event/effects/keydown.registry.d.ts +73 -0
  154. package/types/core/event/effects/ruleHelpers.d.ts +31 -0
  155. package/types/core/{base → event}/eventManager.d.ts +15 -46
  156. package/types/core/event/executor.d.ts +6 -0
  157. package/types/core/event/handlers/handler_ww_input.d.ts +41 -0
  158. package/types/core/{base/eventHandlers/handler_ww_key_input.d.ts → event/handlers/handler_ww_key.d.ts} +4 -6
  159. package/types/core/event/ports.d.ts +255 -0
  160. package/types/core/event/reducers/keydown.reducer.d.ts +75 -0
  161. package/types/core/event/rules/keydown.rule.arrow.d.ts +8 -0
  162. package/types/core/event/rules/keydown.rule.backspace.d.ts +9 -0
  163. package/types/core/event/rules/keydown.rule.delete.d.ts +9 -0
  164. package/types/core/event/rules/keydown.rule.enter.d.ts +9 -0
  165. package/types/core/event/rules/keydown.rule.tab.d.ts +9 -0
  166. package/types/core/section/constructor.d.ts +101 -631
  167. package/types/core/section/documentType.d.ts +14 -4
  168. package/types/core/util/instanceCheck.d.ts +50 -0
  169. package/types/editorInjector/_classes.d.ts +4 -0
  170. package/types/editorInjector/_core.d.ts +17 -7
  171. package/types/editorInjector/index.d.ts +10 -2
  172. package/types/events.d.ts +1 -0
  173. package/types/helper/clipboard.d.ts +2 -2
  174. package/types/helper/converter.d.ts +6 -9
  175. package/types/helper/dom/domCheck.d.ts +7 -0
  176. package/types/helper/dom/domQuery.d.ts +19 -8
  177. package/types/helper/dom/domUtils.d.ts +24 -2
  178. package/types/helper/dom/index.d.ts +86 -1
  179. package/types/helper/env.d.ts +6 -1
  180. package/types/helper/index.d.ts +7 -1
  181. package/types/helper/keyCodeMap.d.ts +3 -3
  182. package/types/index.d.ts +23 -117
  183. package/types/langs/index.d.ts +2 -2
  184. package/types/modules/ApiManager.d.ts +1 -8
  185. package/types/modules/Browser.d.ts +4 -62
  186. package/types/modules/ColorPicker.d.ts +4 -21
  187. package/types/modules/Controller.d.ts +8 -64
  188. package/types/modules/Figure.d.ts +54 -50
  189. package/types/modules/FileManager.d.ts +1 -13
  190. package/types/modules/HueSlider.d.ts +13 -3
  191. package/types/modules/Modal.d.ts +0 -43
  192. package/types/modules/ModalAnchorEditor.d.ts +0 -73
  193. package/types/modules/SelectMenu.d.ts +0 -85
  194. package/types/modules/index.d.ts +3 -3
  195. package/types/plugins/browser/audioGallery.d.ts +29 -18
  196. package/types/plugins/browser/fileBrowser.d.ts +38 -27
  197. package/types/plugins/browser/fileGallery.d.ts +29 -18
  198. package/types/plugins/browser/imageGallery.d.ts +24 -16
  199. package/types/plugins/browser/videoGallery.d.ts +29 -18
  200. package/types/plugins/command/blockquote.d.ts +1 -0
  201. package/types/plugins/command/exportPDF.d.ts +18 -18
  202. package/types/plugins/command/fileUpload.d.ts +65 -45
  203. package/types/plugins/command/list_bulleted.d.ts +1 -0
  204. package/types/plugins/command/list_numbered.d.ts +1 -0
  205. package/types/plugins/dropdown/align.d.ts +13 -8
  206. package/types/plugins/dropdown/backgroundColor.d.ts +30 -19
  207. package/types/plugins/dropdown/font.d.ts +13 -12
  208. package/types/plugins/dropdown/fontColor.d.ts +30 -19
  209. package/types/plugins/dropdown/formatBlock.d.ts +13 -8
  210. package/types/plugins/dropdown/hr.d.ts +15 -11
  211. package/types/plugins/dropdown/layout.d.ts +15 -11
  212. package/types/plugins/dropdown/lineHeight.d.ts +16 -11
  213. package/types/plugins/dropdown/list.d.ts +1 -0
  214. package/types/plugins/dropdown/paragraphStyle.d.ts +31 -27
  215. package/types/plugins/dropdown/table/index.d.ts +582 -0
  216. package/types/plugins/dropdown/table.d.ts +41 -86
  217. package/types/plugins/dropdown/template.d.ts +15 -11
  218. package/types/plugins/dropdown/textStyle.d.ts +19 -11
  219. package/types/plugins/field/mention.d.ts +58 -56
  220. package/types/plugins/index.d.ts +38 -38
  221. package/types/plugins/input/fontSize.d.ts +46 -50
  222. package/types/plugins/modal/audio.d.ts +26 -56
  223. package/types/plugins/modal/drawing.d.ts +0 -85
  224. package/types/plugins/modal/embed.d.ts +15 -79
  225. package/types/plugins/modal/image.d.ts +24 -136
  226. package/types/plugins/modal/link.d.ts +34 -15
  227. package/types/plugins/modal/math.d.ts +0 -16
  228. package/types/plugins/modal/video.d.ts +17 -86
  229. package/types/plugins/popup/anchor.d.ts +1 -8
  230. package/types/suneditor.d.ts +70 -19
  231. package/types/typedef.d.ts +60 -46
  232. package/src/core/base/eventHandlers/handler_ww_key_input.js +0 -1200
  233. package/src/core/section/context.js +0 -102
  234. package/types/core/section/context.d.ts +0 -45
  235. package/types/langs/_Lang.d.ts +0 -194
  236. /package/src/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.js +0 -0
  237. /package/types/core/{section → base}/actives.d.ts +0 -0
  238. /package/types/core/{base/eventHandlers → event/handlers}/handler_toolbar.d.ts +0 -0
  239. /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.d.ts +0 -0
  240. /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.d.ts +0 -0
  241. /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_mouse.d.ts +0 -0
@@ -0,0 +1,157 @@
1
+ /**
2
+ * ================================================================================================================================
3
+ * === CONTEXT TYPES : Store
4
+ * =================================================================================================================================
5
+ */
6
+ /**
7
+ * ================================================================================================================================
8
+ * @typedef {Object} ContextStore
9
+ *
10
+ * This object stores **global editor-level UI references** for a SunEditor instance.
11
+ *
12
+ * - Primarily manages **toolbar, menu tray, and status bar containers**.
13
+ * - Used by the editor to control **sticky behavior, sub-toolbars, and global layout**.
14
+ * - Shared across all frames in a multi-frame editor (unlike FrameContextStore which is per-frame).
15
+ * -----------------
16
+ *
17
+ * === Main UI Containers ===
18
+ * @property {HTMLElement} menuTray - The **top menu tray** that holds buttons, dropdowns, or custom menus.
19
+ * @property {HTMLElement} toolbar_main - The **main toolbar** element containing editor actions.
20
+ * @property {HTMLElement} toolbar_buttonTray - The **container for main toolbar buttons**.
21
+ * @property {HTMLElement} toolbar_arrow - The **arrow indicator** in the toolbar (used for dropdown/tool menu navigation).
22
+ * @property {HTMLElement} [toolbar_wrapper] - The **wrapper for the main toolbar and editor frame** (groups UI together).
23
+ *
24
+ * === Sub-Toolbar (Contextual/Balloon) ===
25
+ * @property {HTMLElement} [toolbar_sub_main] - The **sub-toolbar** element (used for contextual or balloon toolbars).
26
+ * @property {HTMLElement} [toolbar_sub_buttonTray] - The **container for sub-toolbar buttons**.
27
+ * @property {HTMLElement} [toolbar_sub_arrow] - The **arrow indicator** in the sub-toolbar.
28
+ * @property {HTMLElement} [toolbar_sub_wrapper] - The **wrapper for the sub-toolbar**, containing its structure.
29
+ *
30
+ * === Status Bar ===
31
+ * @property {HTMLElement} [statusbar_wrapper] - The **wrapper for the status bar** (footer area for resize handles, info, etc.).
32
+ *
33
+ * === Sticky Mode Helpers ===
34
+ * @property {HTMLElement} [_stickyDummy] - A **dummy placeholder** used when the toolbar is in sticky mode (to prevent layout shift).
35
+ * ================================================================================================================================
36
+ */
37
+ /** --+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-- */
38
+ /**
39
+ * ================================================================================================================================
40
+ * === UTILITIES : Manage Context Map
41
+ * =================================================================================================================================
42
+ */
43
+ /**
44
+ * @description Creates a context map of commonly accessed DOM elements for the editor.
45
+ * @param {Element} toolbar - Main toolbar element.
46
+ * @param {Element|null} toolbarContainer - Container element for the toolbar.
47
+ * @param {Element} menuTray - Main menu tray element.
48
+ * @param {Element|null} subbar - Sub-toolbar element.
49
+ * @param {Element|null} statusbarContainer - Status bar container element.
50
+ * @returns {__se__Context} - A map of key DOM nodes used throughout the editor.
51
+ */
52
+ export function CreateContext(toolbar: Element, toolbarContainer: Element | null, menuTray: Element, subbar: Element | null, statusbarContainer: Element | null): __se__Context;
53
+ /**
54
+ * @typedef {Object} ContextUtil
55
+ * @property {(k: keyof ContextStore) => HTMLElement|null} get - Get a DOM element from the context by key.
56
+ * @property {(k: keyof ContextStore, v: HTMLElement) => void} set - Set a DOM element in the context by key.
57
+ * @property {(k: keyof ContextStore) => boolean} has - Check if a key exists in the context.
58
+ * @property {(k: keyof ContextStore) => boolean} delete - Delete a key from the context.
59
+ * @property {() => Object<keyof ContextStore, HTMLElement|null>} [getAll] - Get all DOM elements in the context as an object.
60
+ * @property {() => void} clear - Clear all elements in the context.
61
+ */
62
+ /**
63
+ * @description Creates a utility wrapper for editor base options.
64
+ * - Provides get, set, has, getAll, and setMany methods with internal Map support.
65
+ * @param {*} editor - The editor instance
66
+ * @returns {ContextUtil}
67
+ */
68
+ export function ContextUtil(editor: any): ContextUtil;
69
+ export type ContextUtil = {
70
+ /**
71
+ * - Get a DOM element from the context by key.
72
+ */
73
+ get: (k: keyof ContextStore) => HTMLElement | null;
74
+ /**
75
+ * - Set a DOM element in the context by key.
76
+ */
77
+ set: (k: keyof ContextStore, v: HTMLElement) => void;
78
+ /**
79
+ * - Check if a key exists in the context.
80
+ */
81
+ has: (k: keyof ContextStore) => boolean;
82
+ /**
83
+ * - Delete a key from the context.
84
+ */
85
+ delete: (k: keyof ContextStore) => boolean;
86
+ /**
87
+ * - Get all DOM elements in the context as an object.
88
+ */
89
+ getAll?: () => any;
90
+ /**
91
+ * - Clear all elements in the context.
92
+ */
93
+ clear: () => void;
94
+ };
95
+ /**
96
+ * This object stores **global editor-level UI references** for a SunEditor instance.
97
+ *
98
+ * - Primarily manages **toolbar, menu tray, and status bar containers**.
99
+ * - Used by the editor to control **sticky behavior, sub-toolbars, and global layout**.
100
+ * - Shared across all frames in a multi-frame editor (unlike FrameContextStore which is per-frame).
101
+ * -----------------
102
+ *
103
+ * === Main UI Containers ===
104
+ */
105
+ export type ContextStore = {
106
+ /**
107
+ * - The **top menu tray** that holds buttons, dropdowns, or custom menus.
108
+ */
109
+ menuTray: HTMLElement;
110
+ /**
111
+ * - The **main toolbar** element containing editor actions.
112
+ */
113
+ toolbar_main: HTMLElement;
114
+ /**
115
+ * - The **container for main toolbar buttons**.
116
+ */
117
+ toolbar_buttonTray: HTMLElement;
118
+ /**
119
+ * - The **arrow indicator** in the toolbar (used for dropdown/tool menu navigation).
120
+ */
121
+ toolbar_arrow: HTMLElement;
122
+ /**
123
+ * - The **wrapper for the main toolbar and editor frame** (groups UI together).
124
+ *
125
+ * === Sub-Toolbar (Contextual/Balloon) ===
126
+ */
127
+ toolbar_wrapper?: HTMLElement;
128
+ /**
129
+ * - The **sub-toolbar** element (used for contextual or balloon toolbars).
130
+ */
131
+ toolbar_sub_main?: HTMLElement;
132
+ /**
133
+ * - The **container for sub-toolbar buttons**.
134
+ */
135
+ toolbar_sub_buttonTray?: HTMLElement;
136
+ /**
137
+ * - The **arrow indicator** in the sub-toolbar.
138
+ */
139
+ toolbar_sub_arrow?: HTMLElement;
140
+ /**
141
+ * - The **wrapper for the sub-toolbar**, containing its structure.
142
+ *
143
+ * === Status Bar ===
144
+ */
145
+ toolbar_sub_wrapper?: HTMLElement;
146
+ /**
147
+ * - The **wrapper for the status bar** (footer area for resize handles, info, etc.).
148
+ *
149
+ * === Sticky Mode Helpers ===
150
+ */
151
+ statusbar_wrapper?: HTMLElement;
152
+ /**
153
+ * - A **dummy placeholder** used when the toolbar is in sticky mode (to prevent layout shift).
154
+ * ================================================================================================================================
155
+ */
156
+ _stickyDummy?: HTMLElement;
157
+ };
@@ -0,0 +1,367 @@
1
+ /**
2
+ * ================================================================================================================================
3
+ * === FRAME CONTEXT TYPES : Store
4
+ * =================================================================================================================================
5
+ */
6
+ /**
7
+ * ================================================================================================================================
8
+ * @typedef {Object} FrameContextStore
9
+ *
10
+ * This object stores **all frame-specific states and DOM references** for a SunEditor instance.
11
+ *
12
+ * - Used to manage **multi-root editors** (each frame has its own context).
13
+ * - Holds references to all **key DOM nodes** (WYSIWYG area, toolbars, status bar, code view, etc.).
14
+ * - Maintains **editor state flags** (fullscreen, readonly, code view, content changes).
15
+ * - Provides storage for **document-type editing features** (page layout, headers, etc.).
16
+ * - Keeps **history positions** and other runtime values for undo/redo operations.
17
+ *
18
+ * This structure is **core to how SunEditor manages each editing frame** and is accessed throughout
19
+ * the editor modules (history, toolbar actions, plugins, etc.).
20
+ * -----------------
21
+ *
22
+ * === Identification ===
23
+ * @property {*} key - Unique key identifying this editor instance (useful for multi-root editors).
24
+ * @property {__se__FrameOptions} options - Frame-specific options (toolbar, plugins, behaviors, etc.).
25
+ *
26
+ * === Core DOM References ===
27
+ * @property {Element} originElement - The original source element (usually a <textarea> or target element).
28
+ * @property {HTMLElement} topArea - The outermost container wrapping the entire editor (toolbar + editor + status bar).
29
+ * @property {HTMLElement} container - The `.se-container` element that holds the editor's UI.
30
+ * @property {HTMLElement} wrapper - The `.se-wrapper` element containing the editable area and internal components.
31
+ * @property {HTMLElement} wysiwygFrame - The WYSIWYG frame element (either an <iframe> or a div in inline mode).
32
+ * @property {HTMLElement} wysiwyg - The actual editable content area (usually the iframe’s <body> or a contentEditable div).
33
+ * @property {HTMLElement} eventWysiwyg - Internal reference for wysiwyg events (set on initialization).
34
+ * @property {HTMLElement} codeWrapper - Wrapper element for the code-view mode.
35
+ * @property {HTMLElement} code - Code view editing element (a <textarea> or <pre>).
36
+ * @property {HTMLTextAreaElement} codeNumbers - Element displaying line numbers in code view mode.
37
+ * @property {HTMLElement} placeholder - Placeholder element shown when the editor is empty.
38
+ * @property {HTMLElement} statusbar - Editor status bar element (for resizing, info, etc.).
39
+ * @property {HTMLElement} navigation - Navigation element (e.g., for outline or bookmarks).
40
+ * @property {HTMLElement} charWrapper - Wrapper for the character counter element.
41
+ * @property {HTMLElement} charCounter - Element showing the character counter.
42
+ * @property {Window} [_ww] - The window object of the WYSIWYG frame (iframe window).
43
+ * @property {Document} [_wd] - The document object of the WYSIWYG frame (iframe document).
44
+ *
45
+ * === UI Utilities & Visual Components ===
46
+ * @property {HTMLElement} lineBreaker_t - Top floating line-breaker UI element (for line insertion).
47
+ * @property {HTMLElement} lineBreaker_b - Bottom floating line-breaker UI element (for line insertion).
48
+ * @property {HTMLElement} [_stickyDummy] - Placeholder element used for sticky toolbar behavior.
49
+ * @property {HTMLElement} [_toolbarShadow] - Shadow element below the toolbar for visual effects.
50
+ * @property {HTMLElement} [_figure] - Current active figure component (image, table, etc.).
51
+ *
52
+ * === State Flags ===
53
+ * @property {boolean} isCodeView - Whether the editor is currently in code view mode.
54
+ * @property {boolean} isFullScreen - Whether the editor is currently in fullscreen mode.
55
+ * @property {boolean} isReadOnly - Whether the editor is set to readonly mode.
56
+ * @property {boolean} isDisabled - Whether the editor is currently disabled.
57
+ * @property {boolean} [isShowBlocks] - Whether block structure visualization is enabled.
58
+ * @property {number} isChanged - Whether the content has been changed (-1 means initial state).
59
+ *
60
+ * === History Tracking ===
61
+ * @property {number} historyIndex - Current index in the history stack (undo/redo).
62
+ * @property {number} savedIndex - Last saved index in the history stack.
63
+ *
64
+ * === DocumentType Editing (Optional) ===
65
+ * @property {*} [documentType] - Document-type specific configuration or module reference.
66
+ * @property {HTMLElement} [documentTypeInner] - Inner container for document-type editors.
67
+ * @property {HTMLElement} [documentTypePage] - Page wrapper for paginated editing mode.
68
+ * @property {HTMLElement} [documentTypePageMirror] - Mirror page element used for selection/layout adjustments.
69
+ * @property {boolean} [documentType_use_header] - Whether headers are used in document-type mode.
70
+ * @property {boolean} [documentType_use_page] - Whether page layout is enabled in document-type mode.
71
+ *
72
+ * === Runtime / Computed Values ===
73
+ * @property {number} _minHeight - Minimum height of the wysiwyg area (parsed from inline style or options).
74
+ * @property {*} [wwComputedStyle] - Cached computed styles for the wysiwyg frame.
75
+ * @property {HTMLIFrameElement} [_iframeAuto] - Auto-resizing helper iframe (used for dynamic sizing).
76
+ * @property {number} [_editorHeight] - Current height of the editor.
77
+ * ================================================================================================================================
78
+ */
79
+ /** @typedef {Map<keyof FrameContextStore|null, *>} FrameContextMap */
80
+ /** --+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-- */
81
+ /**
82
+ * ================================================================================================================================
83
+ * === UTILITIES : Manage Frame Context Map
84
+ * =================================================================================================================================
85
+ */
86
+ /**
87
+ * @typedef {Object} FrameContextUtil
88
+ * @property {(k: keyof FrameContextStore) => *} get - Get a DOM element from the context by key.
89
+ * @property {(k: keyof FrameContextStore, v: *) => void} set - Set a DOM element in the context by key.
90
+ * @property {(k: keyof FrameContextStore) => boolean} has - Check if a key exists in the context.
91
+ * @property {(k: keyof FrameContextStore) => boolean} delete - Delete a key from the context.
92
+ * @property {() => Object<keyof FrameContextStore, *>} [getAll] - Get all DOM elements in the context as an object.
93
+ * @property {(newMap: *) => void} [reset] - Reset the context with a new Map.
94
+ * @property {() => void} clear - Clear all elements in the context.
95
+ */
96
+ /**
97
+ * @description Elements and variables you should have
98
+ * @param {{target: Element, key: *, options: __se__FrameOptions}} editorTarget Target textarea
99
+ * @param {HTMLElement} top Editor top area
100
+ * @param {HTMLElement} wwFrame Editor wysiwyg frame
101
+ * @param {HTMLElement} codeWrapper Editor code view wrapper
102
+ * @param {HTMLElement} codeFrame Editor code view frame
103
+ * @param {{inner: HTMLElement, page: HTMLElement, pageMirror: HTMLElement}} documentTypeInner Document type elements
104
+ * @param {?HTMLElement} statusbar Editor statusbar
105
+ * @param {*} key root key
106
+ * @returns {FrameContextMap}
107
+ */
108
+ export function CreateFrameContext(
109
+ editorTarget: {
110
+ target: Element;
111
+ key: any;
112
+ options: __se__FrameOptions;
113
+ },
114
+ top: HTMLElement,
115
+ wwFrame: HTMLElement,
116
+ codeWrapper: HTMLElement,
117
+ codeFrame: HTMLElement,
118
+ statusbar: HTMLElement | null,
119
+ documentTypeInner: {
120
+ inner: HTMLElement;
121
+ page: HTMLElement;
122
+ pageMirror: HTMLElement;
123
+ },
124
+ key: any
125
+ ): FrameContextMap;
126
+ /**
127
+ * @description Update statusbar context
128
+ * @param {HTMLElement} statusbar Statusbar element
129
+ * @param {FrameContextMap|FrameContextUtil} mapper FrameContext map
130
+ */
131
+ export function UpdateStatusbarContext(statusbar: HTMLElement, mapper: FrameContextMap | FrameContextUtil): void;
132
+ /**
133
+ * @description Creates a utility wrapper for editor base options.
134
+ * - Provides get, set, has, getAll, and setMany methods with internal Map support.
135
+ * @param {*} editor - The editor instance
136
+ * @returns {FrameContextUtil}
137
+ */
138
+ export function FrameContextUtil(editor: any): FrameContextUtil;
139
+ export type FrameContextUtil = {
140
+ /**
141
+ * - Get a DOM element from the context by key.
142
+ */
143
+ get: (k: keyof FrameContextStore) => any;
144
+ /**
145
+ * - Set a DOM element in the context by key.
146
+ */
147
+ set: (k: keyof FrameContextStore, v: any) => void;
148
+ /**
149
+ * - Check if a key exists in the context.
150
+ */
151
+ has: (k: keyof FrameContextStore) => boolean;
152
+ /**
153
+ * - Delete a key from the context.
154
+ */
155
+ delete: (k: keyof FrameContextStore) => boolean;
156
+ /**
157
+ * - Get all DOM elements in the context as an object.
158
+ */
159
+ getAll?: () => any;
160
+ /**
161
+ * - Reset the context with a new Map.
162
+ */
163
+ reset?: (newMap: any) => void;
164
+ /**
165
+ * - Clear all elements in the context.
166
+ */
167
+ clear: () => void;
168
+ };
169
+ /**
170
+ * This object stores **all frame-specific states and DOM references** for a SunEditor instance.
171
+ *
172
+ * - Used to manage **multi-root editors** (each frame has its own context).
173
+ * - Holds references to all **key DOM nodes** (WYSIWYG area, toolbars, status bar, code view, etc.).
174
+ * - Maintains **editor state flags** (fullscreen, readonly, code view, content changes).
175
+ * - Provides storage for **document-type editing features** (page layout, headers, etc.).
176
+ * - Keeps **history positions** and other runtime values for undo/redo operations.
177
+ *
178
+ * This structure is **core to how SunEditor manages each editing frame** and is accessed throughout
179
+ * the editor modules (history, toolbar actions, plugins, etc.).
180
+ * -----------------
181
+ *
182
+ * === Identification ===
183
+ */
184
+ export type FrameContextStore = {
185
+ /**
186
+ * - Unique key identifying this editor instance (useful for multi-root editors).
187
+ */
188
+ key: any;
189
+ /**
190
+ * - Frame-specific options (toolbar, plugins, behaviors, etc.).
191
+ *
192
+ * === Core DOM References ===
193
+ */
194
+ options: __se__FrameOptions;
195
+ /**
196
+ * - The original source element (usually a <textarea> or target element).
197
+ */
198
+ originElement: Element;
199
+ /**
200
+ * - The outermost container wrapping the entire editor (toolbar + editor + status bar).
201
+ */
202
+ topArea: HTMLElement;
203
+ /**
204
+ * - The `.se-container` element that holds the editor's UI.
205
+ */
206
+ container: HTMLElement;
207
+ /**
208
+ * - The `.se-wrapper` element containing the editable area and internal components.
209
+ */
210
+ wrapper: HTMLElement;
211
+ /**
212
+ * - The WYSIWYG frame element (either an <iframe> or a div in inline mode).
213
+ */
214
+ wysiwygFrame: HTMLElement;
215
+ /**
216
+ * - The actual editable content area (usually the iframe’s <body> or a contentEditable div).
217
+ */
218
+ wysiwyg: HTMLElement;
219
+ /**
220
+ * - Internal reference for wysiwyg events (set on initialization).
221
+ */
222
+ eventWysiwyg: HTMLElement;
223
+ /**
224
+ * - Wrapper element for the code-view mode.
225
+ */
226
+ codeWrapper: HTMLElement;
227
+ /**
228
+ * - Code view editing element (a <textarea> or <pre>).
229
+ */
230
+ code: HTMLElement;
231
+ /**
232
+ * - Element displaying line numbers in code view mode.
233
+ */
234
+ codeNumbers: HTMLTextAreaElement;
235
+ /**
236
+ * - Placeholder element shown when the editor is empty.
237
+ */
238
+ placeholder: HTMLElement;
239
+ /**
240
+ * - Editor status bar element (for resizing, info, etc.).
241
+ */
242
+ statusbar: HTMLElement;
243
+ /**
244
+ * - Navigation element (e.g., for outline or bookmarks).
245
+ */
246
+ navigation: HTMLElement;
247
+ /**
248
+ * - Wrapper for the character counter element.
249
+ */
250
+ charWrapper: HTMLElement;
251
+ /**
252
+ * - Element showing the character counter.
253
+ */
254
+ charCounter: HTMLElement;
255
+ /**
256
+ * - The window object of the WYSIWYG frame (iframe window).
257
+ */
258
+ _ww?: Window;
259
+ /**
260
+ * - The document object of the WYSIWYG frame (iframe document).
261
+ *
262
+ * === UI Utilities & Visual Components ===
263
+ */
264
+ _wd?: Document;
265
+ /**
266
+ * - Top floating line-breaker UI element (for line insertion).
267
+ */
268
+ lineBreaker_t: HTMLElement;
269
+ /**
270
+ * - Bottom floating line-breaker UI element (for line insertion).
271
+ */
272
+ lineBreaker_b: HTMLElement;
273
+ /**
274
+ * - Placeholder element used for sticky toolbar behavior.
275
+ */
276
+ _stickyDummy?: HTMLElement;
277
+ /**
278
+ * - Shadow element below the toolbar for visual effects.
279
+ */
280
+ _toolbarShadow?: HTMLElement;
281
+ /**
282
+ * - Current active figure component (image, table, etc.).
283
+ *
284
+ * === State Flags ===
285
+ */
286
+ _figure?: HTMLElement;
287
+ /**
288
+ * - Whether the editor is currently in code view mode.
289
+ */
290
+ isCodeView: boolean;
291
+ /**
292
+ * - Whether the editor is currently in fullscreen mode.
293
+ */
294
+ isFullScreen: boolean;
295
+ /**
296
+ * - Whether the editor is set to readonly mode.
297
+ */
298
+ isReadOnly: boolean;
299
+ /**
300
+ * - Whether the editor is currently disabled.
301
+ */
302
+ isDisabled: boolean;
303
+ /**
304
+ * - Whether block structure visualization is enabled.
305
+ */
306
+ isShowBlocks?: boolean;
307
+ /**
308
+ * - Whether the content has been changed (-1 means initial state).
309
+ *
310
+ * === History Tracking ===
311
+ */
312
+ isChanged: number;
313
+ /**
314
+ * - Current index in the history stack (undo/redo).
315
+ */
316
+ historyIndex: number;
317
+ /**
318
+ * - Last saved index in the history stack.
319
+ *
320
+ * === DocumentType Editing (Optional) ===
321
+ */
322
+ savedIndex: number;
323
+ /**
324
+ * - Document-type specific configuration or module reference.
325
+ */
326
+ documentType?: any;
327
+ /**
328
+ * - Inner container for document-type editors.
329
+ */
330
+ documentTypeInner?: HTMLElement;
331
+ /**
332
+ * - Page wrapper for paginated editing mode.
333
+ */
334
+ documentTypePage?: HTMLElement;
335
+ /**
336
+ * - Mirror page element used for selection/layout adjustments.
337
+ */
338
+ documentTypePageMirror?: HTMLElement;
339
+ /**
340
+ * - Whether headers are used in document-type mode.
341
+ */
342
+ documentType_use_header?: boolean;
343
+ /**
344
+ * - Whether page layout is enabled in document-type mode.
345
+ *
346
+ * === Runtime / Computed Values ===
347
+ */
348
+ documentType_use_page?: boolean;
349
+ /**
350
+ * - Minimum height of the wysiwyg area (parsed from inline style or options).
351
+ */
352
+ _minHeight: number;
353
+ /**
354
+ * - Cached computed styles for the wysiwyg frame.
355
+ */
356
+ wwComputedStyle?: any;
357
+ /**
358
+ * - Auto-resizing helper iframe (used for dynamic sizing).
359
+ */
360
+ _iframeAuto?: HTMLIFrameElement;
361
+ /**
362
+ * - Current height of the editor.
363
+ * ================================================================================================================================
364
+ */
365
+ _editorHeight?: number;
366
+ };
367
+ export type FrameContextMap = Map<keyof FrameContextStore | null, any>;