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.
- package/CONTRIBUTING.md +8 -8
- package/README.md +44 -49
- package/dist/suneditor.min.css +1 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +95 -53
- package/src/assets/design/color.css +2 -2
- package/src/assets/design/size.css +2 -0
- package/src/assets/icons/defaultIcons.js +16 -1
- package/src/assets/suneditor-contents.css +9 -8
- package/src/assets/suneditor.css +29 -26
- package/src/core/{section → base}/actives.js +20 -12
- package/src/core/base/history.js +4 -4
- package/src/core/class/char.js +10 -10
- package/src/core/class/component.js +146 -57
- package/src/core/class/format.js +94 -2458
- package/src/core/class/html.js +187 -129
- package/src/core/class/inline.js +1853 -0
- package/src/core/class/listFormat.js +582 -0
- package/src/core/class/menu.js +14 -3
- package/src/core/class/nodeTransform.js +9 -14
- package/src/core/class/offset.js +162 -197
- package/src/core/class/selection.js +137 -34
- package/src/core/class/toolbar.js +73 -52
- package/src/core/class/ui.js +11 -11
- package/src/core/class/viewer.js +56 -55
- package/src/core/config/context.js +122 -0
- package/src/core/config/frameContext.js +204 -0
- package/src/core/config/options.js +639 -0
- package/src/core/editor.js +181 -108
- package/src/core/event/actions/index.js +229 -0
- package/src/core/event/effects/common.registry.js +60 -0
- package/src/core/event/effects/keydown.registry.js +551 -0
- package/src/core/event/effects/ruleHelpers.js +145 -0
- package/src/core/{base → event}/eventManager.js +119 -201
- package/src/core/event/executor.js +21 -0
- package/src/core/{base/eventHandlers → event/handlers}/handler_toolbar.js +4 -4
- package/src/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.js +2 -2
- package/src/core/event/handlers/handler_ww_input.js +77 -0
- package/src/core/event/handlers/handler_ww_key.js +228 -0
- package/src/core/{base/eventHandlers → event/handlers}/handler_ww_mouse.js +3 -3
- package/src/core/event/ports.js +211 -0
- package/src/core/event/reducers/keydown.reducer.js +89 -0
- package/src/core/event/rules/keydown.rule.arrow.js +54 -0
- package/src/core/event/rules/keydown.rule.backspace.js +202 -0
- package/src/core/event/rules/keydown.rule.delete.js +126 -0
- package/src/core/event/rules/keydown.rule.enter.js +144 -0
- package/src/core/event/rules/keydown.rule.tab.js +29 -0
- package/src/core/section/constructor.js +79 -388
- package/src/core/section/documentType.js +47 -26
- package/src/core/util/instanceCheck.js +59 -0
- package/src/editorInjector/_classes.js +4 -0
- package/src/editorInjector/_core.js +17 -7
- package/src/editorInjector/index.js +10 -2
- package/src/events.js +6 -0
- package/src/helper/clipboard.js +24 -10
- package/src/helper/converter.js +17 -12
- package/src/helper/dom/domCheck.js +22 -3
- package/src/helper/dom/domQuery.js +91 -45
- package/src/helper/dom/domUtils.js +93 -19
- package/src/helper/dom/index.js +4 -0
- package/src/helper/env.js +11 -7
- package/src/helper/keyCodeMap.js +4 -3
- package/src/langs/ckb.js +1 -1
- package/src/langs/cs.js +1 -1
- package/src/langs/da.js +1 -1
- package/src/langs/de.js +1 -1
- package/src/langs/en.js +1 -1
- package/src/langs/es.js +1 -1
- package/src/langs/fa.js +1 -1
- package/src/langs/fr.js +1 -1
- package/src/langs/he.js +1 -1
- package/src/langs/hu.js +1 -1
- package/src/langs/it.js +1 -1
- package/src/langs/ja.js +1 -1
- package/src/langs/km.js +1 -1
- package/src/langs/ko.js +1 -1
- package/src/langs/lv.js +1 -1
- package/src/langs/nl.js +1 -1
- package/src/langs/pl.js +1 -1
- package/src/langs/pt_br.js +10 -10
- package/src/langs/ro.js +1 -1
- package/src/langs/ru.js +1 -1
- package/src/langs/se.js +1 -1
- package/src/langs/tr.js +1 -1
- package/src/langs/uk.js +1 -1
- package/src/langs/ur.js +1 -1
- package/src/langs/zh_cn.js +1 -1
- package/src/modules/ApiManager.js +25 -18
- package/src/modules/Browser.js +52 -61
- package/src/modules/ColorPicker.js +37 -38
- package/src/modules/Controller.js +85 -79
- package/src/modules/Figure.js +275 -187
- package/src/modules/FileManager.js +86 -92
- package/src/modules/HueSlider.js +67 -35
- package/src/modules/Modal.js +84 -77
- package/src/modules/ModalAnchorEditor.js +62 -79
- package/src/modules/SelectMenu.js +89 -86
- package/src/plugins/browser/audioGallery.js +9 -5
- package/src/plugins/browser/fileBrowser.js +10 -6
- package/src/plugins/browser/fileGallery.js +9 -5
- package/src/plugins/browser/imageGallery.js +9 -5
- package/src/plugins/browser/videoGallery.js +11 -6
- package/src/plugins/command/blockquote.js +1 -0
- package/src/plugins/command/exportPDF.js +11 -8
- package/src/plugins/command/fileUpload.js +41 -29
- package/src/plugins/command/list_bulleted.js +2 -1
- package/src/plugins/command/list_numbered.js +2 -1
- package/src/plugins/dropdown/align.js +8 -2
- package/src/plugins/dropdown/backgroundColor.js +19 -11
- package/src/plugins/dropdown/font.js +15 -9
- package/src/plugins/dropdown/fontColor.js +19 -11
- package/src/plugins/dropdown/formatBlock.js +7 -2
- package/src/plugins/dropdown/hr.js +7 -3
- package/src/plugins/dropdown/layout.js +6 -2
- package/src/plugins/dropdown/lineHeight.js +8 -3
- package/src/plugins/dropdown/list.js +2 -1
- package/src/plugins/dropdown/paragraphStyle.js +15 -11
- package/src/plugins/dropdown/{table.js → table/index.js} +514 -362
- package/src/plugins/dropdown/template.js +6 -2
- package/src/plugins/dropdown/textStyle.js +7 -3
- package/src/plugins/field/mention.js +33 -27
- package/src/plugins/input/fontSize.js +44 -37
- package/src/plugins/input/pageNavigator.js +3 -2
- package/src/plugins/modal/audio.js +90 -85
- package/src/plugins/modal/drawing.js +58 -66
- package/src/plugins/modal/embed.js +193 -180
- package/src/plugins/modal/image.js +441 -439
- package/src/plugins/modal/link.js +31 -8
- package/src/plugins/modal/math.js +23 -22
- package/src/plugins/modal/video.js +233 -230
- package/src/plugins/popup/anchor.js +24 -18
- package/src/suneditor.js +69 -24
- package/src/typedef.js +42 -19
- package/types/assets/icons/defaultIcons.d.ts +8 -0
- package/types/core/class/char.d.ts +1 -1
- package/types/core/class/component.d.ts +29 -7
- package/types/core/class/format.d.ts +4 -354
- package/types/core/class/html.d.ts +13 -4
- package/types/core/class/inline.d.ts +263 -0
- package/types/core/class/listFormat.d.ts +135 -0
- package/types/core/class/menu.d.ts +10 -2
- package/types/core/class/offset.d.ts +24 -26
- package/types/core/class/selection.d.ts +2 -0
- package/types/core/class/toolbar.d.ts +24 -11
- package/types/core/class/ui.d.ts +1 -1
- package/types/core/class/viewer.d.ts +1 -1
- package/types/core/config/context.d.ts +157 -0
- package/types/core/config/frameContext.d.ts +367 -0
- package/types/core/config/options.d.ts +1119 -0
- package/types/core/editor.d.ts +101 -66
- package/types/core/event/actions/index.d.ts +47 -0
- package/types/core/event/effects/common.registry.d.ts +50 -0
- package/types/core/event/effects/keydown.registry.d.ts +73 -0
- package/types/core/event/effects/ruleHelpers.d.ts +31 -0
- package/types/core/{base → event}/eventManager.d.ts +15 -46
- package/types/core/event/executor.d.ts +6 -0
- package/types/core/event/handlers/handler_ww_input.d.ts +41 -0
- package/types/core/{base/eventHandlers/handler_ww_key_input.d.ts → event/handlers/handler_ww_key.d.ts} +4 -6
- package/types/core/event/ports.d.ts +255 -0
- package/types/core/event/reducers/keydown.reducer.d.ts +75 -0
- package/types/core/event/rules/keydown.rule.arrow.d.ts +8 -0
- package/types/core/event/rules/keydown.rule.backspace.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.delete.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.enter.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.tab.d.ts +9 -0
- package/types/core/section/constructor.d.ts +101 -631
- package/types/core/section/documentType.d.ts +14 -4
- package/types/core/util/instanceCheck.d.ts +50 -0
- package/types/editorInjector/_classes.d.ts +4 -0
- package/types/editorInjector/_core.d.ts +17 -7
- package/types/editorInjector/index.d.ts +10 -2
- package/types/events.d.ts +1 -0
- package/types/helper/clipboard.d.ts +2 -2
- package/types/helper/converter.d.ts +6 -9
- package/types/helper/dom/domCheck.d.ts +7 -0
- package/types/helper/dom/domQuery.d.ts +19 -8
- package/types/helper/dom/domUtils.d.ts +24 -2
- package/types/helper/dom/index.d.ts +86 -1
- package/types/helper/env.d.ts +6 -1
- package/types/helper/index.d.ts +7 -1
- package/types/helper/keyCodeMap.d.ts +3 -3
- package/types/index.d.ts +23 -117
- package/types/langs/index.d.ts +2 -2
- package/types/modules/ApiManager.d.ts +1 -8
- package/types/modules/Browser.d.ts +4 -62
- package/types/modules/ColorPicker.d.ts +4 -21
- package/types/modules/Controller.d.ts +8 -64
- package/types/modules/Figure.d.ts +54 -50
- package/types/modules/FileManager.d.ts +1 -13
- package/types/modules/HueSlider.d.ts +13 -3
- package/types/modules/Modal.d.ts +0 -43
- package/types/modules/ModalAnchorEditor.d.ts +0 -73
- package/types/modules/SelectMenu.d.ts +0 -85
- package/types/modules/index.d.ts +3 -3
- package/types/plugins/browser/audioGallery.d.ts +29 -18
- package/types/plugins/browser/fileBrowser.d.ts +38 -27
- package/types/plugins/browser/fileGallery.d.ts +29 -18
- package/types/plugins/browser/imageGallery.d.ts +24 -16
- package/types/plugins/browser/videoGallery.d.ts +29 -18
- package/types/plugins/command/blockquote.d.ts +1 -0
- package/types/plugins/command/exportPDF.d.ts +18 -18
- package/types/plugins/command/fileUpload.d.ts +65 -45
- package/types/plugins/command/list_bulleted.d.ts +1 -0
- package/types/plugins/command/list_numbered.d.ts +1 -0
- package/types/plugins/dropdown/align.d.ts +13 -8
- package/types/plugins/dropdown/backgroundColor.d.ts +30 -19
- package/types/plugins/dropdown/font.d.ts +13 -12
- package/types/plugins/dropdown/fontColor.d.ts +30 -19
- package/types/plugins/dropdown/formatBlock.d.ts +13 -8
- package/types/plugins/dropdown/hr.d.ts +15 -11
- package/types/plugins/dropdown/layout.d.ts +15 -11
- package/types/plugins/dropdown/lineHeight.d.ts +16 -11
- package/types/plugins/dropdown/list.d.ts +1 -0
- package/types/plugins/dropdown/paragraphStyle.d.ts +31 -27
- package/types/plugins/dropdown/table/index.d.ts +582 -0
- package/types/plugins/dropdown/table.d.ts +41 -86
- package/types/plugins/dropdown/template.d.ts +15 -11
- package/types/plugins/dropdown/textStyle.d.ts +19 -11
- package/types/plugins/field/mention.d.ts +58 -56
- package/types/plugins/index.d.ts +38 -38
- package/types/plugins/input/fontSize.d.ts +46 -50
- package/types/plugins/modal/audio.d.ts +26 -56
- package/types/plugins/modal/drawing.d.ts +0 -85
- package/types/plugins/modal/embed.d.ts +15 -79
- package/types/plugins/modal/image.d.ts +24 -136
- package/types/plugins/modal/link.d.ts +34 -15
- package/types/plugins/modal/math.d.ts +0 -16
- package/types/plugins/modal/video.d.ts +17 -86
- package/types/plugins/popup/anchor.d.ts +1 -8
- package/types/suneditor.d.ts +70 -19
- package/types/typedef.d.ts +60 -46
- package/src/core/base/eventHandlers/handler_ww_key_input.js +0 -1200
- package/src/core/section/context.js +0 -102
- package/types/core/section/context.d.ts +0 -45
- package/types/langs/_Lang.d.ts +0 -194
- /package/src/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.js +0 -0
- /package/types/core/{section → base}/actives.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_toolbar.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.d.ts +0 -0
- /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>;
|