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
@@ -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._range = this.selection.getRange()));
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._element = target;
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._init();
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._element;
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, { skipCharCount: false, skipSelection: true, skipHistory: false });
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
- this._init();
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._range) {
129
- this.selection.setRange(this._range);
134
+ if (this.#range) {
135
+ this.selection.setRange(this.#range);
130
136
  }
131
137
 
132
- this._init();
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._init();
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
- _init() {
169
- this._element = null;
170
- this._range = null;
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 EditorInjector from './editorInjector';
4
- import Plugins from './plugins';
5
- import Langs from './langs';
6
- import Modules from './modules';
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
- * @typedef {import('./core/section/constructor').EditorFrameOptions} EditorFrameOptions_suneditor
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
- * @typedef {import('./core/section/constructor').EditorInitOptions} EditorInitOptions_suneditor
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
- * Editor Injector module, Inject "editor" and basic frequently used objects by calling it with "call(this, editor)".
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
- * Available editor plugins
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
- * Editor modules
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
- * Language packs for the editor
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
- * Helper functions for the editor
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
- export { Helper };
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 {EditorInitOptions_suneditor} init_options - Initialization options
55
- * @returns {{create: (targets: Element|Object<string, {target: Element, options: EditorFrameOptions_suneditor}>, options: EditorInitOptions_suneditor) => Editor}}}
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: EditorFrameOptions_suneditor}>} target - Target element or multi-root object
66
- * @param {EditorInitOptions_suneditor} options - Initialization options
67
- * @param {EditorInitOptions_suneditor} [_init_options] - Optional preset initialization options
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("[SUNEDITOR.create.fail] suneditor requires textarea's element");
131
+ if (!target) throw Error('[SUNEDITOR.create.fail] The first parameter "target" is missing.');
91
132
 
92
133
  const multiTargets = [];
93
- if (target.nodeType === 1) {
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('./editorInjector').default} __se__EditorInjector
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 {import('./editorInjector/_core').default} __se__CoreInjector
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 {Object} __se__EditorStatus
39
- * @property {boolean} hasFocus Boolean value of whether the editor has focus
40
- * @property {number} tabSize Indent size of tab (4)
41
- * @property {number} indentSize Indent size (25)px
42
- * @property {number} codeIndentSize Indent size of Code view mode (2)
43
- * @property {Array<string>} currentNodes An element array of the current cursor's node structure
44
- * @property {Array<string>} currentNodesMap An element name array of the current cursor's node structure
45
- * @property {boolean} onSelected Boolean value of whether component is selected
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
- // --------------------------------------------------------- [Context] ---------------------------------------------------------------------------------------------------
134
+ // --------------------------------------------------------- [Options Map] ---------------------------------------------------------------------------------------------------
115
135
  /**
116
- * @typedef {Map<string, *>} __se__FrameOptions
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 {Map<string, *>} __se__FrameContext
142
+ * @typedef {import('./core/class/offset').OffsetGlobalInfo} __se__Class_OffsetGlobalInfo
121
143
  */
122
144
 
145
+ // --------------------------------------------------------- [event.reducer/action] ------------------------------------------------------------------------------------------
123
146
  /**
124
- * @typedef {Map<string, *>} __se__Context
147
+ * @typedef {import('./core/event/reducers/keydown.reducer').KeydownReducerCtx} __se__EventKeydownCtx
125
148
  */
126
149
 
127
- // --------------------------------------------------------- [core.class] ---------------------------------------------------------------------------------------------------
128
150
  /**
129
- * @typedef {import('./core/class/offset').OffsetGlobalInfo} __se__Class_OffsetGlobalInfo
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.editor.frameContext.get('wysiwyg'))
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
- skipSelection,
88
- skipHistory
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}