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
|
@@ -22,6 +22,9 @@ class Anchor extends EditorInjector {
|
|
|
22
22
|
return dom.check.isAnchor(node) && node.hasAttribute('id') && node.hasAttribute('data-se-anchor') ? node : null;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
#element;
|
|
26
|
+
#range;
|
|
27
|
+
|
|
25
28
|
/**
|
|
26
29
|
* @constructor
|
|
27
30
|
* @param {__se__EditorCore} editor - The root editor instance
|
|
@@ -36,8 +39,6 @@ class Anchor extends EditorInjector {
|
|
|
36
39
|
const parser = new DOMParser();
|
|
37
40
|
const svgDoc = parser.parseFromString(this.icons.bookmark_anchor, 'image/svg+xml');
|
|
38
41
|
this.bookmarkIcon = svgDoc.documentElement;
|
|
39
|
-
this._element = null;
|
|
40
|
-
this._range = null;
|
|
41
42
|
|
|
42
43
|
// controller
|
|
43
44
|
const controllerSelectEl = CreateHTML_controller_select(this);
|
|
@@ -47,6 +48,9 @@ class Anchor extends EditorInjector {
|
|
|
47
48
|
const controllerEl = CreateHTML_controller(this);
|
|
48
49
|
this.inputEl = controllerEl.querySelector('input');
|
|
49
50
|
this.controller = new Controller(this, controllerEl, { position: 'bottom', disabled: true, parents: [this.controllerSelect.form], parentsHide: true }, Anchor.key);
|
|
51
|
+
|
|
52
|
+
this.#element = null;
|
|
53
|
+
this.#range = null;
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
/**
|
|
@@ -54,7 +58,7 @@ class Anchor extends EditorInjector {
|
|
|
54
58
|
* @description Displays a popup and gives focus to the input field.
|
|
55
59
|
*/
|
|
56
60
|
show() {
|
|
57
|
-
this.controller.open((this
|
|
61
|
+
this.controller.open((this.#range = this.selection.getRange()));
|
|
58
62
|
_w.setTimeout(() => {
|
|
59
63
|
this.inputEl.focus();
|
|
60
64
|
}, 0);
|
|
@@ -66,7 +70,7 @@ class Anchor extends EditorInjector {
|
|
|
66
70
|
* @param {HTMLElement} target Target component element
|
|
67
71
|
*/
|
|
68
72
|
select(target) {
|
|
69
|
-
this
|
|
73
|
+
this.#element = target;
|
|
70
74
|
this.displayId.textContent = target.getAttribute('id');
|
|
71
75
|
this.controllerSelect.open(target);
|
|
72
76
|
}
|
|
@@ -76,7 +80,7 @@ class Anchor extends EditorInjector {
|
|
|
76
80
|
* @description Called when a container is deselected.
|
|
77
81
|
*/
|
|
78
82
|
deselect() {
|
|
79
|
-
this
|
|
83
|
+
this.#init();
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
/**
|
|
@@ -87,10 +91,12 @@ class Anchor extends EditorInjector {
|
|
|
87
91
|
controllerAction(target) {
|
|
88
92
|
const command = target.getAttribute('data-command');
|
|
89
93
|
if (!command) return;
|
|
90
|
-
const currentElement = this
|
|
94
|
+
const currentElement = this.#element;
|
|
91
95
|
|
|
92
96
|
switch (command) {
|
|
93
97
|
case 'submit': {
|
|
98
|
+
this.controller.close();
|
|
99
|
+
|
|
94
100
|
if (!currentElement) {
|
|
95
101
|
const id = this.inputEl.value.trim();
|
|
96
102
|
if (!id) {
|
|
@@ -106,7 +112,7 @@ class Anchor extends EditorInjector {
|
|
|
106
112
|
class: 'se-component se-inline-component'
|
|
107
113
|
});
|
|
108
114
|
|
|
109
|
-
this.component.insert(a, {
|
|
115
|
+
this.component.insert(a, { insertBehavior: 'none', scrollTo: false });
|
|
110
116
|
|
|
111
117
|
const r = this.selection.getNearRange(a);
|
|
112
118
|
if (r) {
|
|
@@ -114,22 +120,22 @@ class Anchor extends EditorInjector {
|
|
|
114
120
|
} else {
|
|
115
121
|
this.component.select(a, Anchor.key);
|
|
116
122
|
}
|
|
117
|
-
|
|
123
|
+
|
|
124
|
+
this.#init();
|
|
118
125
|
} else {
|
|
119
|
-
this.controller.close();
|
|
120
126
|
currentElement.id = this.inputEl.value;
|
|
121
|
-
this.select(currentElement);
|
|
127
|
+
this.component.select(currentElement, Anchor.key);
|
|
122
128
|
}
|
|
123
129
|
|
|
124
130
|
break;
|
|
125
131
|
}
|
|
126
132
|
case 'cancel': {
|
|
127
133
|
this.controller.close(!currentElement);
|
|
128
|
-
if (this
|
|
129
|
-
this.selection.setRange(this
|
|
134
|
+
if (this.#range) {
|
|
135
|
+
this.selection.setRange(this.#range);
|
|
130
136
|
}
|
|
131
137
|
|
|
132
|
-
this
|
|
138
|
+
this.#init();
|
|
133
139
|
if (currentElement) {
|
|
134
140
|
this.select(currentElement);
|
|
135
141
|
}
|
|
@@ -140,6 +146,7 @@ class Anchor extends EditorInjector {
|
|
|
140
146
|
this.inputEl.value = this.displayId.textContent;
|
|
141
147
|
this.controllerSelect.hide();
|
|
142
148
|
this.controller.open(currentElement);
|
|
149
|
+
this.inputEl.focus();
|
|
143
150
|
|
|
144
151
|
break;
|
|
145
152
|
}
|
|
@@ -153,7 +160,7 @@ class Anchor extends EditorInjector {
|
|
|
153
160
|
this.selection.setRange(r.container, r.offset, r.container, r.offset);
|
|
154
161
|
}
|
|
155
162
|
|
|
156
|
-
this
|
|
163
|
+
this.#init();
|
|
157
164
|
|
|
158
165
|
break;
|
|
159
166
|
}
|
|
@@ -161,13 +168,12 @@ class Anchor extends EditorInjector {
|
|
|
161
168
|
}
|
|
162
169
|
|
|
163
170
|
/**
|
|
164
|
-
* @private
|
|
165
171
|
* @description Initializes state variables.
|
|
166
172
|
* - called when the popup is closed
|
|
167
173
|
*/
|
|
168
|
-
|
|
169
|
-
this
|
|
170
|
-
this
|
|
174
|
+
#init() {
|
|
175
|
+
this.#element = null;
|
|
176
|
+
this.#range = null;
|
|
171
177
|
this.inputEl.value = '';
|
|
172
178
|
this.displayId.textContent = '';
|
|
173
179
|
}
|
package/src/suneditor.js
CHANGED
|
@@ -1,47 +1,85 @@
|
|
|
1
1
|
import Editor from './core/editor';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import Helper from './helper';
|
|
3
|
+
import plugins from './plugins';
|
|
4
|
+
import modules from './modules';
|
|
5
|
+
import helper from './helper';
|
|
6
|
+
import langs from './langs';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* @module SunEditorExports
|
|
11
10
|
*/
|
|
11
|
+
export { plugins, modules, helper, langs };
|
|
12
|
+
|
|
13
|
+
// ================================================================================================================================
|
|
14
|
+
// === TYPE DEFINITIONS
|
|
15
|
+
// ================================================================================================================================
|
|
16
|
+
|
|
17
|
+
// [[ editor root ]]
|
|
18
|
+
/**
|
|
19
|
+
* Editor initialization options.
|
|
20
|
+
* Used when creating a new editor instance via `SunEditor.create()`.
|
|
21
|
+
* @typedef {__se__EditorOptions} SunEditorOptions
|
|
22
|
+
*/
|
|
12
23
|
|
|
13
24
|
/**
|
|
14
|
-
*
|
|
25
|
+
* Frame-specific options for multi-root editors.
|
|
26
|
+
* Each frame can have its own width, height, placeholder, and other frame-level settings.
|
|
27
|
+
* @typedef {__se__EditorFrameOptions} SunEditorFrameOptions
|
|
15
28
|
*/
|
|
16
29
|
|
|
17
30
|
/**
|
|
18
|
-
*
|
|
31
|
+
* Type definition for the SunEditor instance.
|
|
32
|
+
* This is the return type of `SunEditor.create()`.
|
|
33
|
+
* @typedef {__se__EditorCore} SunEditorCore
|
|
19
34
|
*/
|
|
20
35
|
|
|
36
|
+
// [[ component ]]
|
|
21
37
|
/**
|
|
22
|
-
*
|
|
38
|
+
* Information about a component (image, video, table, etc.) in the editor.
|
|
39
|
+
* Contains properties like target element, plugin name, options, and container references.
|
|
40
|
+
* @typedef {__se__ComponentInfo} SunEditorComponentInfo
|
|
23
41
|
*/
|
|
24
|
-
export { EditorInjector };
|
|
25
42
|
|
|
43
|
+
// [[ plugin event ]]
|
|
26
44
|
/**
|
|
27
|
-
*
|
|
45
|
+
* Parameters passed to plugin mouse event handlers.
|
|
46
|
+
* Includes the frame context and the mouse event object.
|
|
47
|
+
* @typedef {__se__PluginMouseEventInfo} SunEditorPluginMouseEvent
|
|
28
48
|
*/
|
|
29
|
-
export { Plugins };
|
|
30
49
|
|
|
31
50
|
/**
|
|
32
|
-
*
|
|
51
|
+
* Parameters passed to plugin keyboard event handlers.
|
|
52
|
+
* Includes the frame context, keyboard event, current range, and line element.
|
|
53
|
+
* @typedef {__se__PluginKeyEventInfo} SunEditorPluginKeyEvent
|
|
33
54
|
*/
|
|
34
|
-
export { Modules };
|
|
35
55
|
|
|
36
56
|
/**
|
|
37
|
-
*
|
|
57
|
+
* Parameters passed when a toolbar input value changes.
|
|
58
|
+
* Includes the target input element, event object, and the new value.
|
|
59
|
+
* @typedef {__se__PluginToolbarInputChangeEventInfo} SunEditorPluginToolbarInputChange
|
|
38
60
|
*/
|
|
39
|
-
export { Langs };
|
|
40
61
|
|
|
41
62
|
/**
|
|
42
|
-
*
|
|
63
|
+
* Information passed to shortcut handlers.
|
|
64
|
+
* Includes range, line element, shortcut info, event object, and key code.
|
|
65
|
+
* @typedef {__se__PluginShortcutInfo} SunEditorPluginShortcut
|
|
43
66
|
*/
|
|
44
|
-
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Parameters passed to plugin paste event handlers.
|
|
70
|
+
* Includes frame context, clipboard event, cleaned HTML data, and parsed document.
|
|
71
|
+
* @typedef {__se__PluginPasteParams} SunEditorPluginPaste
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Parameters passed when copying a component.
|
|
76
|
+
* Includes the clipboard event, cloned container, and component info.
|
|
77
|
+
* @typedef {__se__PluginCopyComponentParams} SunEditorPluginCopyComponent
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
// ================================================================================================================================
|
|
81
|
+
// === SUNEDITOR FACTORY
|
|
82
|
+
// ================================================================================================================================
|
|
45
83
|
|
|
46
84
|
/**
|
|
47
85
|
* SunEditor Factory Object
|
|
@@ -51,8 +89,8 @@ export default {
|
|
|
51
89
|
/**
|
|
52
90
|
* Returns the create function with preset options.
|
|
53
91
|
* If the options overlap, the options of the 'create' function take precedence.
|
|
54
|
-
* @param {
|
|
55
|
-
* @returns {{create: (targets: Element|Object<string, {target: Element, options:
|
|
92
|
+
* @param {SunEditorOptions} init_options - Initialization options
|
|
93
|
+
* @returns {{create: (targets: Element|Object<string, {target: Element, options: SunEditorFrameOptions}>, options: SunEditorOptions) => Editor}}}
|
|
56
94
|
*/
|
|
57
95
|
init(init_options) {
|
|
58
96
|
return {
|
|
@@ -62,9 +100,12 @@ export default {
|
|
|
62
100
|
|
|
63
101
|
/**
|
|
64
102
|
* Creates a new instance of the SunEditor
|
|
65
|
-
* @param {Element|Object<string, {target: Element, options:
|
|
66
|
-
*
|
|
67
|
-
*
|
|
103
|
+
* @param {Element|string|Object<string, {target: Element, options: SunEditorFrameOptions}>} target
|
|
104
|
+
* - Element: The direct DOM element to initialize the editor on.
|
|
105
|
+
* - string: A CSS selector string. The corresponding element is selected using `document.querySelector`.
|
|
106
|
+
* - Object: For multi-root setup. Each key maps to a config with `{target, options}`.
|
|
107
|
+
* @param {SunEditorOptions} options - Initialization options
|
|
108
|
+
* @param {SunEditorOptions} [_init_options] - Optional preset initialization options
|
|
68
109
|
* @returns {Editor} - Instance of the SunEditor
|
|
69
110
|
* @throws {Error} If the target element is not provided or is invalid
|
|
70
111
|
*/
|
|
@@ -87,10 +128,14 @@ export default {
|
|
|
87
128
|
})();
|
|
88
129
|
}
|
|
89
130
|
|
|
90
|
-
if (!target) throw Error(
|
|
131
|
+
if (!target) throw Error('[SUNEDITOR.create.fail] The first parameter "target" is missing.');
|
|
91
132
|
|
|
92
133
|
const multiTargets = [];
|
|
93
|
-
if (target
|
|
134
|
+
if (typeof target === 'string') {
|
|
135
|
+
const t = document.querySelector(target);
|
|
136
|
+
if (!t) throw Error(`[SUNEDITOR.create.fail]-[document.querySelector(${target})] Cannot find target element. Make sure "${target}" is a valid selector and exists in the document.`);
|
|
137
|
+
multiTargets.push({ key: null, target: t });
|
|
138
|
+
} else if (target.nodeType === 1) {
|
|
94
139
|
multiTargets.push({ key: null, target: target });
|
|
95
140
|
} else {
|
|
96
141
|
let props;
|
package/src/typedef.js
CHANGED
|
@@ -10,16 +10,39 @@
|
|
|
10
10
|
// --------------------------------------------------------- [Editor] ---------------------------------------------------------------------------------------------------
|
|
11
11
|
/**
|
|
12
12
|
* @typedef {import('./core/editor').default} __se__EditorCore
|
|
13
|
+
* @typedef {import('./editorInjector').default} __se__EditorInjector
|
|
13
14
|
*/
|
|
14
15
|
|
|
16
|
+
// --------------------------------------------------------- [Options] ---------------------------------------------------------------------------------------------------
|
|
15
17
|
/**
|
|
16
|
-
* @typedef {import('./
|
|
18
|
+
* @typedef {import('./core/config/options').EditorInitOptions} __se__EditorOptions
|
|
19
|
+
* @typedef {import('./core/config/options').EditorFrameOptions} __se__EditorFrameOptions
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// --------------------------------------------------------- [Context] ---------------------------------------------------------------------------------------------------
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {import('./core/config/frameContext').FrameContextUtil} __se__FrameContext
|
|
25
|
+
* @typedef {Map<keyof import('./core/config/context').ContextUtil, *>} __se__Context
|
|
17
26
|
*/
|
|
18
27
|
|
|
28
|
+
// --------------------------------------------------------- [Editor Status] ---------------------------------------------------------------------------------------------------
|
|
19
29
|
/**
|
|
20
|
-
* @typedef {
|
|
30
|
+
* @typedef {Object} __se__EditorStatus
|
|
31
|
+
* @property {boolean} hasFocus Boolean value of whether the editor has focus
|
|
32
|
+
* @property {number} tabSize Indent size of tab (4)
|
|
33
|
+
* @property {number} indentSize Indent size (25)px
|
|
34
|
+
* @property {number} codeIndentSize Indent size of Code view mode (2)
|
|
35
|
+
* @property {Array<string>} currentNodes An element array of the current cursor's node structure
|
|
36
|
+
* @property {Array<string>} currentNodesMap An element name array of the current cursor's node structure
|
|
37
|
+
* @property {number} currentViewportHeight Current visual viewport height size
|
|
38
|
+
* @property {number} initViewportHeight Height of the initial visual viewport height size
|
|
39
|
+
* @property {boolean} onSelected Boolean value of whether component is selected
|
|
40
|
+
* @property {*} rootKey Current root key
|
|
41
|
+
* @property {Range} _range Current range object
|
|
42
|
+
* @property {boolean} _onMousedown Mouse down event status
|
|
21
43
|
*/
|
|
22
44
|
|
|
45
|
+
// --------------------------------------------------------- [component] ---------------------------------------------------------------------------------------------------
|
|
23
46
|
/**
|
|
24
47
|
* @typedef {Object} __se__ComponentInfo
|
|
25
48
|
* @property {HTMLElement} target - The target element associated with the component.
|
|
@@ -35,17 +58,14 @@
|
|
|
35
58
|
*/
|
|
36
59
|
|
|
37
60
|
/**
|
|
38
|
-
* @typedef {
|
|
39
|
-
* @
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* @property {number} rootKey Current root key
|
|
47
|
-
* @property {Range} _range Current range object
|
|
48
|
-
* @property {boolean} _onMousedown Mouse down event status
|
|
61
|
+
* @typedef {"auto"|"select"|"line"|"none"} __se__ComponentInsertBehaviorType
|
|
62
|
+
* @description Component insertion behavior for selection and cursor placement.
|
|
63
|
+
* - For inline components: places the cursor near the inserted component or selects it if no nearby range is available.
|
|
64
|
+
* - For block components: executes behavior based on `selectMode`:
|
|
65
|
+
* - `auto`: Move cursor to the next line if possible, otherwise select the component.
|
|
66
|
+
* - `select`: Always select the inserted component.
|
|
67
|
+
* - `line`: Move cursor to the next line if possible, or create a new line and move there.
|
|
68
|
+
* - `none`: Do nothing.
|
|
49
69
|
*/
|
|
50
70
|
|
|
51
71
|
// --------------------------------------------------------- [Event] ---------------------------------------------------------------------------------------------------
|
|
@@ -111,20 +131,23 @@
|
|
|
111
131
|
* @property {__se__ComponentInfo} info Component information
|
|
112
132
|
*/
|
|
113
133
|
|
|
114
|
-
// --------------------------------------------------------- [
|
|
134
|
+
// --------------------------------------------------------- [Options Map] ---------------------------------------------------------------------------------------------------
|
|
115
135
|
/**
|
|
116
|
-
* @typedef {
|
|
136
|
+
* @typedef {import('./core/config/options').FrameOptionsMap} __se__FrameOptions
|
|
137
|
+
* @typedef {import('./core/config/options').BaseOptionsMap} __se__BaseOptions
|
|
117
138
|
*/
|
|
118
139
|
|
|
140
|
+
// --------------------------------------------------------- [core.class] ---------------------------------------------------------------------------------------------------
|
|
119
141
|
/**
|
|
120
|
-
* @typedef {
|
|
142
|
+
* @typedef {import('./core/class/offset').OffsetGlobalInfo} __se__Class_OffsetGlobalInfo
|
|
121
143
|
*/
|
|
122
144
|
|
|
145
|
+
// --------------------------------------------------------- [event.reducer/action] ------------------------------------------------------------------------------------------
|
|
123
146
|
/**
|
|
124
|
-
* @typedef {
|
|
147
|
+
* @typedef {import('./core/event/reducers/keydown.reducer').KeydownReducerCtx} __se__EventKeydownCtx
|
|
125
148
|
*/
|
|
126
149
|
|
|
127
|
-
// --------------------------------------------------------- [core.class] ---------------------------------------------------------------------------------------------------
|
|
128
150
|
/**
|
|
129
|
-
* @typedef {import('./core/
|
|
151
|
+
* @typedef {import('./core/event/actions').Action[]} __se__EventActions
|
|
152
|
+
* @typedef {import('./core/event/ports').EventReducerPorts} __se__EventPorts
|
|
130
153
|
*/
|
|
@@ -41,6 +41,7 @@ declare namespace _default {
|
|
|
41
41
|
export let background_color: string;
|
|
42
42
|
export let list_bulleted: string;
|
|
43
43
|
export let list_numbered: string;
|
|
44
|
+
export let list_checked: string;
|
|
44
45
|
export let table: string;
|
|
45
46
|
export let table_header: string;
|
|
46
47
|
export let table_properties: string;
|
|
@@ -134,6 +135,13 @@ declare namespace _default {
|
|
|
134
135
|
export let side_menu_item: string;
|
|
135
136
|
export let side_menu_folder_plus: string;
|
|
136
137
|
export let alert_outline: string;
|
|
138
|
+
export let more_media: string;
|
|
139
|
+
export let more_gallery: string;
|
|
140
|
+
export let more_folder: string;
|
|
141
|
+
export let more_list: string;
|
|
142
|
+
export let more_file: string;
|
|
143
|
+
export let more_view: string;
|
|
144
|
+
export let more_page: string;
|
|
137
145
|
export let more_text: string;
|
|
138
146
|
export let more_paragraph: string;
|
|
139
147
|
export let more_plus: string;
|
|
@@ -32,7 +32,7 @@ declare class Char {
|
|
|
32
32
|
* @this {CharThis}
|
|
33
33
|
* @description Get the [content]'s number of characters or binary data size. (frameOptions.get('charCounter_type'))
|
|
34
34
|
* - If [content] is undefined, get the current editor's number of characters or binary data size.
|
|
35
|
-
* @param {string=} content Content to count. (defalut: this.
|
|
35
|
+
* @param {string=} content Content to count. (defalut: this.frameContext.get('wysiwyg'))
|
|
36
36
|
* @returns {number}
|
|
37
37
|
*/
|
|
38
38
|
getLength(this: Omit<Char & Partial<import('../../editorInjector').default>, 'char'>, content?: string | undefined): number;
|
|
@@ -63,8 +63,6 @@ declare class Component {
|
|
|
63
63
|
_bindClose_keydown: __se__GlobalEventInfo | void;
|
|
64
64
|
/** @type {__se__GlobalEventInfo|void} */
|
|
65
65
|
_bindClose_mousedown: __se__GlobalEventInfo | void;
|
|
66
|
-
/** @type {__se__GlobalEventInfo|void} */
|
|
67
|
-
_bindClose_touchstart: __se__GlobalEventInfo | void;
|
|
68
66
|
/** @type {boolean} */
|
|
69
67
|
__selectionSelected: boolean;
|
|
70
68
|
__prevent: boolean;
|
|
@@ -75,8 +73,10 @@ declare class Component {
|
|
|
75
73
|
* @param {Node} element Element to be inserted
|
|
76
74
|
* @param {Object} [options] Options
|
|
77
75
|
* @param {boolean} [options.skipCharCount=false] If true, it will be inserted even if "frameOptions.get('charCounter_max')" is exceeded.
|
|
78
|
-
* @param {boolean} [options.skipSelection=false] If true, do not automatically select the inserted component.
|
|
79
76
|
* @param {boolean} [options.skipHistory=false] If true, do not push to history.
|
|
77
|
+
* @param {boolean} [options.scrollTo=true] true : Scroll to the inserted element, false : Do not scroll.
|
|
78
|
+
* @param {?__se__ComponentInsertBehaviorType} [options.insertBehavior] If true, do not automatically select the inserted component. [default: options.get('componentInsertBehavior')]
|
|
79
|
+
* - If null, noting action is performed after insertion.
|
|
80
80
|
* @returns {HTMLElement} The inserted element or new line (for HR)
|
|
81
81
|
*/
|
|
82
82
|
insert(
|
|
@@ -84,14 +84,24 @@ declare class Component {
|
|
|
84
84
|
element: Node,
|
|
85
85
|
{
|
|
86
86
|
skipCharCount,
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
skipHistory,
|
|
88
|
+
scrollTo,
|
|
89
|
+
insertBehavior
|
|
89
90
|
}?: {
|
|
90
91
|
skipCharCount?: boolean;
|
|
91
|
-
skipSelection?: boolean;
|
|
92
92
|
skipHistory?: boolean;
|
|
93
|
+
scrollTo?: boolean;
|
|
94
|
+
insertBehavior?: __se__ComponentInsertBehaviorType | null;
|
|
93
95
|
}
|
|
94
96
|
): HTMLElement;
|
|
97
|
+
/**
|
|
98
|
+
* @this {ComponentThis}
|
|
99
|
+
* @description Handles post-insertion behavior for a newly created component based on the specified mode.
|
|
100
|
+
* @param {Node} container The inserted component element.
|
|
101
|
+
* @param {Node|null} [oNode] Optional node to use for selection if the component cannot be selected.
|
|
102
|
+
* @param {__se__ComponentInsertBehaviorType} [insertBehavior] Behavior mode after component insertion.
|
|
103
|
+
*/
|
|
104
|
+
applyInsertBehavior(this: Omit<Component & Partial<import('../../editorInjector').default>, 'component'>, container: Node, oNode?: Node | null, insertBehavior?: __se__ComponentInsertBehaviorType): void;
|
|
95
105
|
/**
|
|
96
106
|
* @this {ComponentThis}
|
|
97
107
|
* @description Gets the file component and that plugin name
|
|
@@ -156,7 +166,7 @@ declare class Component {
|
|
|
156
166
|
* - This function is different from the one called when the user presses the "Ctrl + C" key combination.
|
|
157
167
|
* @param {Node} container The DOM node to check.
|
|
158
168
|
*/
|
|
159
|
-
copy(this: Omit<Component & Partial<import('../../editorInjector').default>, 'component'>, container: Node): void
|
|
169
|
+
copy(this: Omit<Component & Partial<import('../../editorInjector').default>, 'component'>, container: Node): Promise<void>;
|
|
160
170
|
/**
|
|
161
171
|
* @private
|
|
162
172
|
* @this {ComponentThis}
|
|
@@ -173,6 +183,18 @@ declare class Component {
|
|
|
173
183
|
* - This method resets the selection state and hides UI elements related to the component selection.
|
|
174
184
|
*/
|
|
175
185
|
__deselect(this: Omit<Component & Partial<import('../../editorInjector').default>, 'component'>): void;
|
|
186
|
+
/**
|
|
187
|
+
* @private
|
|
188
|
+
* @this {ComponentThis}
|
|
189
|
+
* @description
|
|
190
|
+
* Attempts to move the cursor to a valid line after the given container.
|
|
191
|
+
* - If a valid next sibling line exists, moves the selection there.
|
|
192
|
+
* - If no next sibling exists, creates a new line after the container and moves the selection there.
|
|
193
|
+
* - If the next sibling exists but is not a valid line element and cannot create a new line, returns false.
|
|
194
|
+
* @param {Node} container The component container element.
|
|
195
|
+
* @returns {boolean} Returns true if the selection moved to a line (existing or newly created), otherwise false.
|
|
196
|
+
*/
|
|
197
|
+
__moveToNextLineOrAdd(this: Omit<Component & Partial<import('../../editorInjector').default>, 'component'>, container: Node): boolean;
|
|
176
198
|
/**
|
|
177
199
|
* @private
|
|
178
200
|
* @this {ComponentThis}
|