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
|
@@ -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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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';
|