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
@@ -49,6 +49,14 @@ export type AudioPluginOptions = {
49
49
  audioTagAttributes?: {
50
50
  [x: string]: string;
51
51
  };
52
+ /**
53
+ * - Component insertion behavior for selection and cursor placement. [default: options.get('componentInsertBehavior')]
54
+ * - `auto`: Move cursor to the next line if possible, otherwise select the component.
55
+ * - `select`: Always select the inserted component.
56
+ * - `line`: Move cursor to the next line if possible, or create a new line and move there.
57
+ * - `none`: Do nothing.
58
+ */
59
+ insertBehavior?: __se__ComponentInsertBehaviorType;
52
60
  };
53
61
  /**
54
62
  * @typedef {import('../../events').AudioInfo} AudioInfo_audio
@@ -66,6 +74,11 @@ export type AudioPluginOptions = {
66
74
  * @property {boolean} [allowMultiple] - Whether to allow multiple file uploads.
67
75
  * @property {string} [acceptedFormats="audio/*"] - Accepted file formats (default is "audio/*").
68
76
  * @property {Object<string, string>} [audioTagAttributes] - Additional attributes to set on the audio tag.
77
+ * @property {__se__ComponentInsertBehaviorType} [insertBehavior] - Component insertion behavior for selection and cursor placement. [default: options.get('componentInsertBehavior')]
78
+ * - `auto`: Move cursor to the next line if possible, otherwise select the component.
79
+ * - `select`: Always select the inserted component.
80
+ * - `line`: Move cursor to the next line if possible, or create a new line and move there.
81
+ * - `none`: Do nothing.
69
82
  */
70
83
  /**
71
84
  * @class
@@ -105,6 +118,7 @@ declare class Audio_ extends EditorInjector {
105
118
  audioTagAttributes: {
106
119
  [x: string]: string;
107
120
  };
121
+ insertBehavior: __se__ComponentInsertBehaviorType;
108
122
  };
109
123
  modal: Modal;
110
124
  controller: Controller;
@@ -118,11 +132,6 @@ declare class Audio_ extends EditorInjector {
118
132
  audioUrlFile: HTMLInputElement;
119
133
  /** @type {HTMLElement} */
120
134
  preview: HTMLElement;
121
- /** @type {HTMLAudioElement} */
122
- _element: HTMLAudioElement;
123
- defaultWidth: string;
124
- defaultHeight: string;
125
- urlValue: string;
126
135
  /**
127
136
  * @editorMethod Modules.Modal
128
137
  * @description Executes the method that is called when a "Modal" module's is opened.
@@ -182,14 +191,6 @@ declare class Audio_ extends EditorInjector {
182
191
  * @param {HTMLElement} target Target component element
183
192
  */
184
193
  select(target: HTMLElement): void;
185
- /**
186
- * @private
187
- * @description Prepares the component for selection.
188
- * - Ensures that the controller is properly positioned and initialized.
189
- * - Prevents duplicate event handling if the component is already selected.
190
- * @param {HTMLElement} target - The selected element.
191
- */
192
- private _ready;
193
194
  /**
194
195
  * @editorMethod Editor.Component
195
196
  * @description Method to delete a component of a plugin, called by the "FileManager", "Controller" module.
@@ -197,14 +198,6 @@ declare class Audio_ extends EditorInjector {
197
198
  * @returns {Promise<void>}
198
199
  */
199
200
  destroy(target?: HTMLElement | undefined): Promise<void>;
200
- /**
201
- * @private
202
- * @description Registers uploaded audio files and creates the corresponding audio elements.
203
- * - Iterates through the uploaded files and inserts them into the editor.
204
- * @param {AudioInfo_audio} info - Upload metadata, including `isUpdate` flag and `element`.
205
- * @param {Object<string, *>} response - Server response containing uploaded file details.
206
- */
207
- private _register;
208
201
  /**
209
202
  * @description Create an "audio" component using the provided files.
210
203
  * @param {FileList|File[]} fileList File object list
@@ -218,7 +211,6 @@ declare class Audio_ extends EditorInjector {
218
211
  */
219
212
  submitURL(url: string): Promise<boolean>;
220
213
  /**
221
- * @private
222
214
  * @description Creates or updates an audio component within the editor.
223
215
  * - If `isUpdate` is `true`, updates the existing element's `src`.
224
216
  * - Otherwise, inserts a new audio component with the given file.
@@ -226,40 +218,18 @@ declare class Audio_ extends EditorInjector {
226
218
  * @param {string} src - The source URL of the audio file.
227
219
  * @param {{name: string, size: number}} file - The file metadata (name, size).
228
220
  * @param {boolean} isUpdate - Whether to update an existing element.
229
- */
230
- private _createComp;
231
- /**
232
- * @private
233
- * @description Creates a new `<audio>` element with default attributes.
234
- * - Applies width, height, and additional attributes from plugin options.
235
- * @returns {HTMLAudioElement} - The newly created `<audio>` element.
236
- */
237
- private _createAudioTag;
238
- /**
239
- * @private
240
- * @description Sets attributes on an audio element based on plugin options.
241
- * - Adds the `controls` attribute and applies any custom attributes.
242
- * @param {HTMLElement} element - The `<audio>` element to modify.
243
- */
244
- private _setTagAttrs;
245
- /**
246
- * @private
247
- * @description Uploads audio files to the server.
248
- * - Sends a request to the configured upload URL and processes the response.
249
- * @param {AudioInfo_audio} info - Upload metadata, including `files` and `isUpdate`.
250
- * @param {FileList|File[]} files - The files to be uploaded.
251
- */
252
- private _serverUpload;
253
- /**
254
- * @private
255
- * @description Handles errors that occur during the audio upload process.
256
- * - Triggers the `onAudioUploadError` event to allow custom handling of errors.
257
- * - Displays an error message in the editor's UI.
258
- * - Logs the error to the console for debugging.
259
- * @param {Object<string, *>} response - The error response object from the server or upload process.
260
- * @returns {Promise<void>}
261
- */
262
- private _error;
221
+ * @param {boolean} isLast - Indicates whether this is the last file in the batch (used for scroll and insert actions).
222
+ */
223
+ create(
224
+ element: HTMLAudioElement,
225
+ src: string,
226
+ file: {
227
+ name: string;
228
+ size: number;
229
+ },
230
+ isUpdate: boolean,
231
+ isLast: boolean
232
+ ): void;
263
233
  #private;
264
234
  }
265
235
  import EditorInjector from '../../editorInjector';
@@ -139,27 +139,6 @@ declare class Drawing extends EditorInjector {
139
139
  points: any[];
140
140
  paths: any[];
141
141
  resizeObserver: ResizeObserver;
142
- __events: {
143
- mousedown: any;
144
- mousemove: any;
145
- mouseup: any;
146
- mouseleave: any;
147
- mouseenter: any;
148
- };
149
- __eventsRegister: {
150
- mousedown: any;
151
- mousemove: any;
152
- mouseup: any;
153
- mouseleave: any;
154
- mouseenter: any;
155
- };
156
- __eventNameMap: {
157
- mousedown: string;
158
- mousemove: string;
159
- mouseup: string;
160
- mouseleave: string;
161
- mouseenter: string;
162
- };
163
142
  /**
164
143
  * @editorMethod Modules.Modal
165
144
  * @description Executes the method that is called when a "Modal" module's is opened.
@@ -176,70 +155,6 @@ declare class Drawing extends EditorInjector {
176
155
  * @returns {boolean} Success or failure
177
156
  */
178
157
  modalAction(): boolean;
179
- /**
180
- * @private
181
- * @description Initializes the drawing canvas, sets up event listeners, and configures resize handling.
182
- */
183
- private _initDrawing;
184
- /**
185
- * @private
186
- * @description Destroys the drawing canvas, removes event listeners, and clears stored drawing data.
187
- */
188
- private _destroyDrawing;
189
- /**
190
- * @private
191
- * @description Configures the drawing context (canvas settings like line width, color, etc.).
192
- */
193
- private _setCtx;
194
- /**
195
- * @private
196
- * @description Draws the current stroke based on collected points.
197
- */
198
- private _draw;
199
- /**
200
- * @private
201
- * @description Redraws all stored paths onto the canvas.
202
- */
203
- private _drawAll;
204
- /**
205
- * @private
206
- * @description Adjusts all stored paths to fit new canvas dimensions after a resize event.
207
- * @param {number} prevWidth - The previous width of the canvas.
208
- * @param {number} prevHeight - The previous height of the canvas.
209
- * @param {number} newWidth - The new width of the canvas.
210
- * @param {number} newHeight - The new height of the canvas.
211
- */
212
- private _adjustPathsToNewDimensions;
213
- /**
214
- * @private
215
- * @description Clears the canvas and resets stored drawing paths.
216
- */
217
- private _clearCanvas;
218
- /**
219
- * @private
220
- * @description Generates an SVG representation of the drawn content.
221
- * @returns {*} The generated SVG element.
222
- */
223
- private _getSVG;
224
- /**
225
- * @private
226
- * @description Converts the SVG element into a downloadable file.
227
- * @returns {FileList} A FileList containing the generated SVG file.
228
- */
229
- private _getSVGFileList;
230
- /**
231
- * @private
232
- * @description Retrieves touch coordinates relative to the canvas.
233
- * @param {TouchEvent} e - The touch event.
234
- * @returns {{x: number, y: number}} An object containing the x and y coordinates.
235
- */
236
- private _getCanvasTouchPointer;
237
- /**
238
- * @private
239
- * @description Activates either block or inline format mode for inserted drawings.
240
- * @param {boolean} isInline - Whether the drawing should be inserted as an inline element.
241
- */
242
- private _activeAsInline;
243
158
  #private;
244
159
  }
245
160
  import EditorInjector from '../../editorInjector';
@@ -90,6 +90,14 @@ export type EmbedPluginOptions = {
90
90
  * - Figure controls.
91
91
  */
92
92
  controls?: FigureControls_embed;
93
+ /**
94
+ * - Component insertion behavior for selection and cursor placement. [default: options.get('componentInsertBehavior')]
95
+ * - `auto`: Move cursor to the next line if possible, otherwise select the component.
96
+ * - `select`: Always select the inserted component.
97
+ * - `line`: Move cursor to the next line if possible, or create a new line and move there.
98
+ * - `none`: Do nothing.
99
+ */
100
+ insertBehavior?: __se__ComponentInsertBehaviorType;
93
101
  };
94
102
  /**
95
103
  * @typedef {import('../../events').ProcessInfo} ProcessInfo_embed
@@ -132,6 +140,11 @@ export type EmbedPluginOptions = {
132
140
  * // Additional services...
133
141
  * }
134
142
  * @property {FigureControls_embed} [controls] - Figure controls.
143
+ * @property {__se__ComponentInsertBehaviorType} [insertBehavior] - Component insertion behavior for selection and cursor placement. [default: options.get('componentInsertBehavior')]
144
+ * - `auto`: Move cursor to the next line if possible, otherwise select the component.
145
+ * - `select`: Always select the inserted component.
146
+ * - `line`: Move cursor to the next line if possible, or create a new line and move there.
147
+ * - `none`: Do nothing.
135
148
  */
136
149
  /**
137
150
  * @class
@@ -173,6 +186,7 @@ declare class Embed extends EditorInjector {
173
186
  };
174
187
  query_youtube: string;
175
188
  query_vimeo: string;
189
+ insertBehavior: __se__ComponentInsertBehaviorType;
176
190
  };
177
191
  modal: Modal;
178
192
  figure: Figure;
@@ -180,26 +194,10 @@ declare class Embed extends EditorInjector {
180
194
  embedInput: HTMLInputElement;
181
195
  focusElement: HTMLInputElement;
182
196
  previewSrc: HTMLElement;
183
- _linkValue: string;
184
- _align: string;
185
- _defaultSizeX: string;
186
- _defaultSizeY: string;
187
197
  sizeUnit: string;
188
198
  proportion: HTMLInputElement;
189
199
  inputX: HTMLInputElement;
190
200
  inputY: HTMLInputElement;
191
- _element: any;
192
- _cover: HTMLElement;
193
- _container: any;
194
- _ratio: {
195
- w: number;
196
- h: number;
197
- };
198
- _origin_w: string;
199
- _origin_h: string;
200
- _resizing: boolean;
201
- _onlyPercentage: boolean;
202
- _nonResizing: boolean;
203
201
  query: {
204
202
  facebook: {
205
203
  pattern: RegExp;
@@ -286,15 +284,6 @@ declare class Embed extends EditorInjector {
286
284
  * @param {HTMLElement} target Target component element
287
285
  */
288
286
  select(target: HTMLElement): void;
289
- /**
290
- * @private
291
- * @description Prepares the component for selection.
292
- * - Ensures that the controller is properly positioned and initialized.
293
- * - Prevents duplicate event handling if the component is already selected.
294
- * @param {HTMLElement} target - The selected element.
295
- */
296
- private _ready;
297
- _caption: HTMLElement;
298
287
  /**
299
288
  * @editorMethod Editor.Component
300
289
  * @description Method to delete a component of a plugin, called by the "FileManager", "Controller" module.
@@ -326,60 +315,7 @@ declare class Embed extends EditorInjector {
326
315
  * @returns {Promise<boolean>} A promise that resolves to true on success or false on failure.
327
316
  */
328
317
  submitSRC(src?: string): Promise<boolean>;
329
- /**
330
- * @private
331
- * @description Creates an iframe element for embedding external content.
332
- * @returns {HTMLIFrameElement} The created iframe element.
333
- */
334
- private _createIframeTag;
335
- /**
336
- * @private
337
- * @description Creates an blockquote element for embedding external content.
338
- * @returns {HTMLElement} The created iframe element.
339
- */
340
- private _createEmbedTag;
341
- /**
342
- * @private
343
- * @description Creates an embed component (iframe or blockquote) and inserts it into the editor.
344
- * @param {?ProcessInfo_embed} process - Processed embed information.
345
- * @param {?string} src - The source URL.
346
- * @param {?Node[]} children - The embed elements.
347
- * @param {string} width - The width of the embed component.
348
- * @param {string} height - The height of the embed component.
349
- * @param {string} align - The alignment of the embed component.
350
- * @param {boolean} isUpdate - Whether this is an update to an existing embed component.
351
- */
352
- private _create;
353
- /**
354
- * @private
355
- * @description Updates an existing embed component within the editor.
356
- * @param {HTMLIFrameElement} oFrame - The existing embed element to be updated.
357
- */
358
- private _update;
359
- /**
360
- * @private
361
- * @description Applies width and height to the embed component.
362
- * @param {string|number} w - The width to apply.
363
- * @param {string|number} h - The height to apply.
364
- */
365
- private _applySize;
366
- /**
367
- * @private
368
- * @description Retrieves embed component size and alignment information.
369
- * @returns {{inputWidth: string, inputHeight: string, align: string, isUpdate: boolean, element: Element}} An object containing
370
- * - inputWidth : The width of the embed component.
371
- * - inputHeight : The height of the embed component.
372
- * - align : The alignment of the embed component.
373
- * - isUpdate : Whether the component is being updated.
374
- * - element : The target element.
375
- */
376
- private _getInfo;
377
- /**
378
- * @private
379
- * @description Sets default attributes for an iframe element.
380
- * @param {HTMLIFrameElement} element - The iframe element to modify.
381
- */
382
- private _setIframeAttrs;
318
+ _caption: HTMLElement;
383
319
  #private;
384
320
  }
385
321
  import EditorInjector from '../../editorInjector';
@@ -95,6 +95,16 @@ export type ImagePluginOptions = {
95
95
  * - Figure controls.
96
96
  */
97
97
  controls?: FigureControls_image;
98
+ /**
99
+ * - Component insertion behavior for selection and cursor placement. [default: options.get('componentInsertBehavior')]
100
+ * - For inline components: places the cursor near the inserted component or selects it if no nearby range is available.
101
+ * - For block components: executes behavior based on `selectMode`:
102
+ * - `auto`: Move cursor to the next line if possible, otherwise select the component.
103
+ * - `select`: Always select the inserted component.
104
+ * - `line`: Move cursor to the next line if possible, or create a new line and move there.
105
+ * - `none`: Do nothing.
106
+ */
107
+ insertBehavior?: __se__ComponentInsertBehaviorType;
98
108
  };
99
109
  /**
100
110
  * @typedef {import('../../events').ImageInfo} ImageInfo_image
@@ -122,6 +132,13 @@ export type ImagePluginOptions = {
122
132
  * @property {boolean} [keepFormatType=false] - Whether to retain the chosen format type after image insertion.
123
133
  * @property {boolean} [linkEnableFileUpload] - Whether to enable file uploads for linked images.
124
134
  * @property {FigureControls_image} [controls] - Figure controls.
135
+ * @property {__se__ComponentInsertBehaviorType} [insertBehavior] - Component insertion behavior for selection and cursor placement. [default: options.get('componentInsertBehavior')]
136
+ * - For inline components: places the cursor near the inserted component or selects it if no nearby range is available.
137
+ * - For block components: executes behavior based on `selectMode`:
138
+ * - `auto`: Move cursor to the next line if possible, otherwise select the component.
139
+ * - `select`: Always select the inserted component.
140
+ * - `line`: Move cursor to the next line if possible, or create a new line and move there.
141
+ * - `none`: Do nothing.
125
142
  */
126
143
  /**
127
144
  * @class
@@ -165,6 +182,7 @@ declare class Image_ extends EditorInjector {
165
182
  useFormatType: boolean;
166
183
  defaultFormatType: string;
167
184
  keepFormatType: boolean;
185
+ insertBehavior: __se__ComponentInsertBehaviorType;
168
186
  };
169
187
  alignForm: HTMLElement;
170
188
  anchor: ModalAnchorEditor;
@@ -184,24 +202,7 @@ declare class Image_ extends EditorInjector {
184
202
  proportion: HTMLInputElement;
185
203
  inputX: HTMLInputElement;
186
204
  inputY: HTMLInputElement;
187
- _linkElement: any;
188
- _linkValue: string;
189
- _align: string;
190
- _svgDefaultSize: string;
191
205
  _base64RenderIndex: number;
192
- _element: any;
193
- _cover: any;
194
- _container: any;
195
- _caption: HTMLElement;
196
- _ratio: {
197
- w: number;
198
- h: number;
199
- };
200
- _origin_w: string;
201
- _origin_h: string;
202
- _resizing: boolean;
203
- _onlyPercentage: boolean;
204
- _nonResizing: boolean;
205
206
  asBlock: HTMLButtonElement;
206
207
  asInline: HTMLButtonElement;
207
208
  /**
@@ -262,14 +263,6 @@ declare class Image_ extends EditorInjector {
262
263
  * @param {HTMLElement} target Target component element
263
264
  */
264
265
  select(target: HTMLElement): void;
265
- /**
266
- * @private
267
- * @description Prepares the component for selection.
268
- * - Ensures that the controller is properly positioned and initialized.
269
- * - Prevents duplicate event handling if the component is already selected.
270
- * @param {HTMLElement} target - The selected element.
271
- */
272
- private _ready;
273
266
  /**
274
267
  * @editorMethod Editor.Component
275
268
  * @description Method to delete a component of a plugin, called by the "FileManager", "Controller" module.
@@ -277,18 +270,6 @@ declare class Image_ extends EditorInjector {
277
270
  * @returns {Promise<void>}
278
271
  */
279
272
  destroy(target: HTMLElement): Promise<void>;
280
- /**
281
- * @private
282
- * @description Retrieves the current image information.
283
- * @returns {*} - The image data.
284
- */
285
- private _getInfo;
286
- /**
287
- * @private
288
- * @description Toggles between block and inline image format.
289
- * @param {boolean} isInline - Whether the image should be inline.
290
- */
291
- private _activeAsInline;
292
273
  /**
293
274
  * @description Create an "image" component using the provided files.
294
275
  * @param {FileList|File[]} fileList File object list
@@ -301,39 +282,6 @@ declare class Image_ extends EditorInjector {
301
282
  * @returns {Promise<boolean>} If return false, the file upload will be canceled
302
283
  */
303
284
  submitURL(url: string): Promise<boolean>;
304
- /**
305
- * @private
306
- * @description Updates the selected image size, alt text, and caption.
307
- * @param {string} width - New image width.
308
- * @param {string} height - New image height.
309
- */
310
- private _update;
311
- /**
312
- * @private
313
- * @description Validates the image size and applies necessary transformations.
314
- * @param {string} width - The width of the image.
315
- * @param {string} height - The height of the image.
316
- */
317
- private _fileCheck;
318
- /**
319
- * @private
320
- * @description Creates a new image component based on provided parameters.
321
- * @param {string} src - The image source URL.
322
- * @param {?Node} anchor - Optional anchor wrapping the image.
323
- * @param {string} width - Image width.
324
- * @param {string} height - Image height.
325
- * @param {string} align - Image alignment.
326
- * @param {{name: string, size: number}} file - File metadata.
327
- * @param {string} alt - Alternative text.
328
- */
329
- private _produce;
330
- /**
331
- * @private
332
- * @description Applies the specified width and height to the image.
333
- * @param {string} w - Image width.
334
- * @param {string} h - Image height.
335
- */
336
- private _applySize;
337
285
  /**
338
286
  * @description Creates a new image component, wraps it in a figure container with an optional anchor,
339
287
  * - applies size and alignment settings, and inserts it into the editor.
@@ -344,6 +292,7 @@ declare class Image_ extends EditorInjector {
344
292
  * @param {string} align - The alignment setting for the image (e.g., 'left', 'center', 'right').
345
293
  * @param {{name: string, size: number}} file - File metadata associated with the image
346
294
  * @param {string} alt - The alternative text for the image.
295
+ * @param {boolean} isLast - Indicates whether this is the last file in the batch (used for scroll and insert actions).
347
296
  */
348
297
  create(
349
298
  src: string,
@@ -355,7 +304,8 @@ declare class Image_ extends EditorInjector {
355
304
  name: string;
356
305
  size: number;
357
306
  },
358
- alt: string
307
+ alt: string,
308
+ isLast: boolean
359
309
  ): void;
360
310
  /**
361
311
  * @description Creates a new inline image component, wraps it in an inline figure container with an optional anchor,
@@ -366,6 +316,7 @@ declare class Image_ extends EditorInjector {
366
316
  * @param {string} height - The height value to be applied to the image.
367
317
  * @param {{name: string, size: number}} file - File metadata associated with the image
368
318
  * @param {string} alt - The alternative text for the image.
319
+ * @param {boolean} isLast - Indicates whether this is the last file in the batch (used for scroll and insert actions).
369
320
  */
370
321
  createInline(
371
322
  src: string,
@@ -376,72 +327,9 @@ declare class Image_ extends EditorInjector {
376
327
  name: string;
377
328
  size: number;
378
329
  },
379
- alt: string
330
+ alt: string,
331
+ isLast: boolean
380
332
  ): void;
381
- /**
382
- * @private
383
- * @description Updates the image source URL.
384
- * @param {string} src - The new image source.
385
- * @param {HTMLImageElement} element - The image element.
386
- * @param {{ name: string, size: number }} file - File metadata.
387
- */
388
- private _updateSrc;
389
- /**
390
- * @private
391
- * @description Registers the uploaded image and inserts it into the editor.
392
- * @param {ImageInfo_image} info - Image info.
393
- * @param {Object<string, *>} response - Server response data.
394
- */
395
- private _register;
396
- /**
397
- * @private
398
- * @description Uploads the image to the server.
399
- * @param {ImageInfo_image} info - Image upload info.
400
- * @param {FileList} files - List of image files.
401
- */
402
- private _serverUpload;
403
- /**
404
- * @private
405
- * @description Converts an image file to Base64 and inserts it into the editor.
406
- * @param {FileList|File[]} files - List of image files.
407
- * @param {?Node} anchor - Optional anchor wrapping the image.
408
- * @param {string} width - Image width.
409
- * @param {string} height - Image height.
410
- * @param {string} align - Image alignment.
411
- * @param {string} alt - Alternative text.
412
- * @param {boolean} isUpdate - Whether the image is being updated.
413
- */
414
- private _setBase64;
415
- /**
416
- * @private
417
- * @description Inserts an image using a Base64-encoded string.
418
- * @param {boolean} update - Whether the image is being updated.
419
- * @param {Array<{result: string, file: { name: string, size: number }}>} filesStack - Stack of Base64-encoded files.
420
- * - result: Image url or Base64-encoded string
421
- * - file: File metadata ({ name: string, size: number })
422
- * @param {HTMLImageElement} updateElement - The image element being updated.
423
- * @param {?HTMLAnchorElement} anchor - Optional anchor wrapping the image.
424
- * @param {string} width - Image width.
425
- * @param {string} height - Image height.
426
- * @param {string} align - Image alignment.
427
- * @param {string} alt - Alternative text.
428
- */
429
- private _onRenderBase64;
430
- /**
431
- * @private
432
- * @description Wraps an image element with an anchor if provided.
433
- * @param {Node} imgTag - The image element to be wrapped.
434
- * @param {?Node} anchor - The anchor element to wrap around the image. If null, returns the image itself.
435
- * @returns {Node} - The wrapped image inside the anchor or the original image element.
436
- */
437
- private _setAnchor;
438
- /**
439
- * @private
440
- * @description Handles errors during image upload and displays appropriate messages.
441
- * @param {Object<string, *>} response - The error response from the server.
442
- * @returns {Promise<void>}
443
- */
444
- private _error;
445
333
  #private;
446
334
  }
447
335
  import EditorInjector from '../../editorInjector';