suneditor 3.0.0-alpha.9 → 3.0.0-beta.2
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 +170 -22
- package/{LICENSE.txt → LICENSE} +9 -9
- package/README.md +168 -30
- package/dist/suneditor.min.css +1 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +47 -21
- package/src/assets/design/color.css +121 -0
- package/src/assets/design/index.css +3 -0
- package/src/assets/design/size.css +35 -0
- package/src/assets/design/typography.css +37 -0
- package/src/assets/icons/defaultIcons.js +232 -0
- package/src/assets/suneditor-contents.css +181 -46
- package/src/assets/suneditor.css +1403 -650
- package/src/core/base/eventHandlers/handler_toolbar.js +35 -14
- package/src/core/base/eventHandlers/handler_ww_clipboard.js +23 -4
- package/src/core/base/eventHandlers/handler_ww_dragDrop.js +49 -10
- package/src/core/base/eventHandlers/handler_ww_key_input.js +422 -224
- package/src/core/base/eventHandlers/handler_ww_mouse.js +83 -36
- package/src/core/base/eventManager.js +520 -179
- package/src/core/base/history.js +95 -41
- package/src/core/class/char.js +26 -11
- package/src/core/class/component.js +345 -137
- package/src/core/class/format.js +683 -519
- package/src/core/class/html.js +485 -305
- package/src/core/class/menu.js +133 -47
- package/src/core/class/nodeTransform.js +90 -71
- package/src/core/class/offset.js +408 -92
- package/src/core/class/selection.js +216 -106
- package/src/core/class/shortcuts.js +68 -8
- package/src/core/class/toolbar.js +106 -116
- package/src/core/class/ui.js +422 -0
- package/src/core/class/viewer.js +178 -74
- package/src/core/editor.js +496 -389
- package/src/core/section/actives.js +123 -27
- package/src/core/section/constructor.js +615 -206
- package/src/core/section/context.js +28 -23
- package/src/core/section/documentType.js +561 -0
- package/src/editorInjector/_classes.js +19 -5
- package/src/editorInjector/_core.js +71 -7
- package/src/editorInjector/index.js +63 -1
- package/src/events.js +622 -0
- package/src/helper/clipboard.js +59 -0
- package/src/helper/converter.js +202 -26
- package/src/helper/dom/domCheck.js +304 -0
- package/src/helper/dom/domQuery.js +669 -0
- package/src/helper/dom/domUtils.js +557 -0
- package/src/helper/dom/index.js +12 -0
- package/src/helper/env.js +46 -56
- package/src/helper/index.js +10 -4
- package/src/helper/keyCodeMap.js +183 -0
- package/src/helper/numbers.js +12 -8
- package/src/helper/unicode.js +9 -5
- package/src/langs/ckb.js +74 -4
- package/src/langs/cs.js +72 -2
- package/src/langs/da.js +73 -3
- package/src/langs/de.js +73 -4
- package/src/langs/en.js +23 -3
- package/src/langs/es.js +73 -4
- package/src/langs/fa.js +75 -3
- package/src/langs/fr.js +73 -3
- package/src/langs/he.js +73 -4
- package/src/langs/hu.js +230 -0
- package/src/langs/index.js +7 -3
- package/src/langs/it.js +70 -1
- package/src/langs/ja.js +72 -4
- package/src/langs/km.js +230 -0
- package/src/langs/ko.js +22 -2
- package/src/langs/lv.js +74 -5
- package/src/langs/nl.js +73 -4
- package/src/langs/pl.js +73 -4
- package/src/langs/pt_br.js +70 -1
- package/src/langs/ro.js +74 -5
- package/src/langs/ru.js +73 -4
- package/src/langs/se.js +73 -4
- package/src/langs/tr.js +73 -1
- package/src/langs/{ua.js → uk.js} +75 -6
- package/src/langs/ur.js +77 -8
- package/src/langs/zh_cn.js +74 -5
- package/src/modules/ApiManager.js +77 -54
- package/src/modules/Browser.js +667 -0
- package/src/modules/ColorPicker.js +162 -102
- package/src/modules/Controller.js +273 -142
- package/src/modules/Figure.js +925 -484
- package/src/modules/FileManager.js +121 -69
- package/src/modules/HueSlider.js +113 -61
- package/src/modules/Modal.js +291 -122
- package/src/modules/ModalAnchorEditor.js +383 -234
- package/src/modules/SelectMenu.js +270 -168
- package/src/modules/_DragHandle.js +2 -1
- package/src/modules/index.js +3 -3
- package/src/plugins/browser/audioGallery.js +83 -0
- package/src/plugins/browser/fileBrowser.js +103 -0
- package/src/plugins/browser/fileGallery.js +83 -0
- package/src/plugins/browser/imageGallery.js +81 -0
- package/src/plugins/browser/videoGallery.js +103 -0
- package/src/plugins/command/blockquote.js +40 -27
- package/src/plugins/command/exportPDF.js +134 -0
- package/src/plugins/command/fileUpload.js +229 -162
- package/src/plugins/command/list_bulleted.js +83 -47
- package/src/plugins/command/list_numbered.js +83 -47
- package/src/plugins/dropdown/align.js +66 -54
- package/src/plugins/dropdown/backgroundColor.js +63 -49
- package/src/plugins/dropdown/font.js +71 -47
- package/src/plugins/dropdown/fontColor.js +63 -48
- package/src/plugins/dropdown/formatBlock.js +70 -33
- package/src/plugins/dropdown/hr.js +92 -51
- package/src/plugins/dropdown/layout.js +37 -26
- package/src/plugins/dropdown/lineHeight.js +54 -38
- package/src/plugins/dropdown/list.js +60 -45
- package/src/plugins/dropdown/paragraphStyle.js +51 -30
- package/src/plugins/dropdown/table.js +2003 -813
- package/src/plugins/dropdown/template.js +38 -26
- package/src/plugins/dropdown/textStyle.js +43 -31
- package/src/plugins/field/mention.js +147 -86
- package/src/plugins/index.js +32 -6
- package/src/plugins/input/fontSize.js +161 -108
- package/src/plugins/input/pageNavigator.js +70 -0
- package/src/plugins/modal/audio.js +358 -173
- package/src/plugins/modal/drawing.js +531 -0
- package/src/plugins/modal/embed.js +886 -0
- package/src/plugins/modal/image.js +674 -362
- package/src/plugins/modal/link.js +100 -71
- package/src/plugins/modal/math.js +367 -167
- package/src/plugins/modal/video.js +691 -335
- package/src/plugins/popup/anchor.js +222 -0
- package/src/suneditor.js +50 -13
- package/src/themes/dark.css +122 -0
- package/src/typedef.js +130 -0
- package/types/assets/icons/defaultIcons.d.ts +153 -0
- package/types/core/base/eventHandlers/handler_toolbar.d.ts +41 -0
- package/types/core/base/eventHandlers/handler_ww_clipboard.d.ts +40 -0
- package/types/core/base/eventHandlers/handler_ww_dragDrop.d.ts +35 -0
- package/types/core/base/eventHandlers/handler_ww_key_input.d.ts +45 -0
- package/types/core/base/eventHandlers/handler_ww_mouse.d.ts +39 -0
- package/types/core/base/eventManager.d.ts +385 -0
- package/types/core/base/history.d.ts +81 -0
- package/types/core/class/char.d.ts +60 -0
- package/types/core/class/component.d.ts +212 -0
- package/types/core/class/format.d.ts +616 -0
- package/types/core/class/html.d.ts +422 -0
- package/types/core/class/menu.d.ts +126 -0
- package/types/core/class/nodeTransform.d.ts +93 -0
- package/types/core/class/offset.d.ts +522 -0
- package/types/core/class/selection.d.ts +188 -0
- package/types/core/class/shortcuts.d.ts +142 -0
- package/types/core/class/toolbar.d.ts +189 -0
- package/types/core/class/ui.d.ts +164 -0
- package/types/core/class/viewer.d.ts +140 -0
- package/types/core/editor.d.ts +610 -0
- package/types/core/section/actives.d.ts +46 -0
- package/types/core/section/constructor.d.ts +777 -0
- package/types/core/section/context.d.ts +45 -0
- package/types/core/section/documentType.d.ts +178 -0
- package/types/editorInjector/_classes.d.ts +41 -0
- package/types/editorInjector/_core.d.ts +92 -0
- package/types/editorInjector/index.d.ts +71 -0
- package/types/events.d.ts +273 -0
- package/types/helper/clipboard.d.ts +12 -0
- package/types/helper/converter.d.ts +197 -0
- package/types/helper/dom/domCheck.d.ts +189 -0
- package/types/helper/dom/domQuery.d.ts +223 -0
- package/types/helper/dom/domUtils.d.ts +226 -0
- package/types/helper/dom/index.d.ts +9 -0
- package/types/helper/env.d.ts +132 -0
- package/types/helper/index.d.ts +174 -0
- package/types/helper/keyCodeMap.d.ts +110 -0
- package/types/helper/numbers.d.ts +46 -0
- package/types/helper/unicode.d.ts +28 -0
- package/types/index.d.ts +120 -0
- package/{typings/Lang.d.ts → types/langs/_Lang.d.ts} +173 -103
- package/types/langs/ckb.d.ts +3 -0
- package/types/langs/cs.d.ts +3 -0
- package/types/langs/da.d.ts +3 -0
- package/types/langs/de.d.ts +3 -0
- package/types/langs/en.d.ts +3 -0
- package/types/langs/es.d.ts +3 -0
- package/types/langs/fa.d.ts +3 -0
- package/types/langs/fr.d.ts +3 -0
- package/types/langs/he.d.ts +3 -0
- package/types/langs/hu.d.ts +3 -0
- package/types/langs/index.d.ts +54 -0
- package/types/langs/it.d.ts +3 -0
- package/types/langs/ja.d.ts +3 -0
- package/types/langs/km.d.ts +3 -0
- package/types/langs/ko.d.ts +3 -0
- package/types/langs/lv.d.ts +3 -0
- package/types/langs/nl.d.ts +3 -0
- package/types/langs/pl.d.ts +3 -0
- package/types/langs/pt_br.d.ts +3 -0
- package/types/langs/ro.d.ts +3 -0
- package/types/langs/ru.d.ts +3 -0
- package/types/langs/se.d.ts +3 -0
- package/types/langs/tr.d.ts +3 -0
- package/types/langs/uk.d.ts +3 -0
- package/types/langs/ur.d.ts +3 -0
- package/types/langs/zh_cn.d.ts +3 -0
- package/types/modules/ApiManager.d.ts +125 -0
- package/types/modules/Browser.d.ts +326 -0
- package/types/modules/ColorPicker.d.ts +131 -0
- package/types/modules/Controller.d.ts +251 -0
- package/types/modules/Figure.d.ts +517 -0
- package/types/modules/FileManager.d.ts +202 -0
- package/types/modules/HueSlider.d.ts +136 -0
- package/types/modules/Modal.d.ts +111 -0
- package/types/modules/ModalAnchorEditor.d.ts +236 -0
- package/types/modules/SelectMenu.d.ts +194 -0
- package/types/modules/_DragHandle.d.ts +7 -0
- package/types/modules/index.d.ts +26 -0
- package/types/plugins/browser/audioGallery.d.ts +55 -0
- package/types/plugins/browser/fileBrowser.d.ts +64 -0
- package/types/plugins/browser/fileGallery.d.ts +55 -0
- package/types/plugins/browser/imageGallery.d.ts +51 -0
- package/types/plugins/browser/videoGallery.d.ts +57 -0
- package/types/plugins/command/blockquote.d.ts +28 -0
- package/types/plugins/command/exportPDF.d.ts +46 -0
- package/types/plugins/command/fileUpload.d.ts +156 -0
- package/types/plugins/command/list_bulleted.d.ts +46 -0
- package/types/plugins/command/list_numbered.d.ts +46 -0
- package/types/plugins/dropdown/align.d.ts +60 -0
- package/types/plugins/dropdown/backgroundColor.d.ts +63 -0
- package/types/plugins/dropdown/font.d.ts +54 -0
- package/types/plugins/dropdown/fontColor.d.ts +63 -0
- package/types/plugins/dropdown/formatBlock.d.ts +54 -0
- package/types/plugins/dropdown/hr.d.ts +71 -0
- package/types/plugins/dropdown/layout.d.ts +40 -0
- package/types/plugins/dropdown/lineHeight.d.ts +50 -0
- package/types/plugins/dropdown/list.d.ts +39 -0
- package/types/plugins/dropdown/paragraphStyle.d.ts +54 -0
- package/types/plugins/dropdown/table.d.ts +627 -0
- package/types/plugins/dropdown/template.d.ts +40 -0
- package/types/plugins/dropdown/textStyle.d.ts +41 -0
- package/types/plugins/field/mention.d.ts +102 -0
- package/types/plugins/index.d.ts +107 -0
- package/types/plugins/input/fontSize.d.ts +170 -0
- package/types/plugins/input/pageNavigator.d.ts +28 -0
- package/types/plugins/modal/audio.d.ts +269 -0
- package/types/plugins/modal/drawing.d.ts +246 -0
- package/types/plugins/modal/embed.d.ts +387 -0
- package/types/plugins/modal/image.d.ts +451 -0
- package/types/plugins/modal/link.d.ts +128 -0
- package/types/plugins/modal/math.d.ts +193 -0
- package/types/plugins/modal/video.d.ts +485 -0
- package/types/plugins/popup/anchor.d.ts +56 -0
- package/types/suneditor.d.ts +51 -0
- package/types/typedef.d.ts +233 -0
- package/.eslintignore +0 -7
- package/.eslintrc.json +0 -64
- package/src/assets/icons/_default.js +0 -194
- package/src/core/base/events.js +0 -320
- package/src/core/class/notice.js +0 -42
- package/src/helper/domUtils.js +0 -1177
- package/src/modules/FileBrowser.js +0 -271
- package/src/plugins/command/exportPdf.js +0 -168
- package/src/plugins/fileBrowser/imageGallery.js +0 -81
- package/src/themes/test.css +0 -61
- package/typings/CommandPlugin.d.ts +0 -8
- package/typings/DialogPlugin.d.ts +0 -20
- package/typings/FileBrowserPlugin.d.ts +0 -30
- package/typings/Module.d.ts +0 -15
- package/typings/Plugin.d.ts +0 -42
- package/typings/SubmenuPlugin.d.ts +0 -8
- package/typings/_classes.d.ts +0 -17
- package/typings/_colorPicker.d.ts +0 -60
- package/typings/_core.d.ts +0 -55
- package/typings/align.d.ts +0 -5
- package/typings/audio.d.ts +0 -5
- package/typings/backgroundColor.d.ts +0 -5
- package/typings/blockquote.d.ts +0 -5
- package/typings/char.d.ts +0 -39
- package/typings/component.d.ts +0 -38
- package/typings/context.d.ts +0 -39
- package/typings/converter.d.ts +0 -33
- package/typings/dialog.d.ts +0 -28
- package/typings/domUtils.d.ts +0 -361
- package/typings/editor.d.ts +0 -7
- package/typings/editor.ts +0 -542
- package/typings/env.d.ts +0 -70
- package/typings/eventManager.d.ts +0 -37
- package/typings/events.d.ts +0 -262
- package/typings/fileBrowser.d.ts +0 -42
- package/typings/fileManager.d.ts +0 -67
- package/typings/font.d.ts +0 -5
- package/typings/fontColor.d.ts +0 -5
- package/typings/fontSize.d.ts +0 -5
- package/typings/format.d.ts +0 -191
- package/typings/formatBlock.d.ts +0 -5
- package/typings/history.d.ts +0 -48
- package/typings/horizontalRule.d.ts +0 -5
- package/typings/image.d.ts +0 -5
- package/typings/imageGallery.d.ts +0 -5
- package/typings/index.d.ts +0 -21
- package/typings/index.modules.d.ts +0 -11
- package/typings/index.plugins.d.ts +0 -58
- package/typings/lineHeight.d.ts +0 -5
- package/typings/link.d.ts +0 -5
- package/typings/list.d.ts +0 -5
- package/typings/math.d.ts +0 -5
- package/typings/mediaContainer.d.ts +0 -25
- package/typings/mention.d.ts +0 -5
- package/typings/node.d.ts +0 -57
- package/typings/notice.d.ts +0 -16
- package/typings/numbers.d.ts +0 -29
- package/typings/offset.d.ts +0 -24
- package/typings/options.d.ts +0 -589
- package/typings/paragraphStyle.d.ts +0 -5
- package/typings/resizing.d.ts +0 -141
- package/typings/selection.d.ts +0 -94
- package/typings/shortcuts.d.ts +0 -13
- package/typings/suneditor.d.ts +0 -9
- package/typings/table.d.ts +0 -5
- package/typings/template.d.ts +0 -5
- package/typings/textStyle.d.ts +0 -5
- package/typings/toolbar.d.ts +0 -32
- package/typings/unicode.d.ts +0 -25
- package/typings/video.d.ts +0 -5
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
export default Image_;
|
|
2
|
+
export type ModalReturns_image = {
|
|
3
|
+
html: HTMLElement;
|
|
4
|
+
alignForm: HTMLElement;
|
|
5
|
+
fileModalWrapper: HTMLElement;
|
|
6
|
+
imgInputFile: HTMLInputElement;
|
|
7
|
+
imgUrlFile: HTMLInputElement;
|
|
8
|
+
altText: HTMLInputElement;
|
|
9
|
+
captionCheckEl: HTMLInputElement;
|
|
10
|
+
previewSrc: HTMLElement;
|
|
11
|
+
tabs: HTMLElement;
|
|
12
|
+
galleryButton: HTMLButtonElement;
|
|
13
|
+
proportion: HTMLInputElement;
|
|
14
|
+
inputX: HTMLInputElement;
|
|
15
|
+
inputY: HTMLInputElement;
|
|
16
|
+
revertBtn: HTMLButtonElement;
|
|
17
|
+
asBlock: HTMLButtonElement;
|
|
18
|
+
asInline: HTMLButtonElement;
|
|
19
|
+
fileRemoveBtn: HTMLButtonElement;
|
|
20
|
+
};
|
|
21
|
+
export type ImageInfo_image = import('../../events').ImageInfo;
|
|
22
|
+
export type FigureControls_image = import('../../modules/Figure').FigureControls;
|
|
23
|
+
export type ImagePluginOptions = {
|
|
24
|
+
/**
|
|
25
|
+
* - Whether the image element can be resized.
|
|
26
|
+
*/
|
|
27
|
+
canResize?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* - Whether to display the height input field.
|
|
30
|
+
*/
|
|
31
|
+
showHeightInput?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* - The default width of the image. If a number is provided, "px" will be appended.
|
|
34
|
+
*/
|
|
35
|
+
defaultWidth?: string;
|
|
36
|
+
/**
|
|
37
|
+
* - The default height of the image. If a number is provided, "px" will be appended.
|
|
38
|
+
*/
|
|
39
|
+
defaultHeight?: string;
|
|
40
|
+
/**
|
|
41
|
+
* - Whether to allow only percentage-based sizing.
|
|
42
|
+
*/
|
|
43
|
+
percentageOnlySize?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* - Whether to create a file input element for image uploads.
|
|
46
|
+
*/
|
|
47
|
+
createFileInput?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* - Whether to create a URL input element for image insertion.
|
|
50
|
+
*/
|
|
51
|
+
createUrlInput?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* - The URL endpoint for image file uploads.
|
|
54
|
+
*/
|
|
55
|
+
uploadUrl?: string;
|
|
56
|
+
/**
|
|
57
|
+
* - Additional headers to include in the file upload request.
|
|
58
|
+
*/
|
|
59
|
+
uploadHeaders?: {
|
|
60
|
+
[x: string]: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* - The total upload size limit in bytes.
|
|
64
|
+
*/
|
|
65
|
+
uploadSizeLimit?: number;
|
|
66
|
+
/**
|
|
67
|
+
* - The single file upload size limit in bytes.
|
|
68
|
+
*/
|
|
69
|
+
uploadSingleSizeLimit?: number;
|
|
70
|
+
/**
|
|
71
|
+
* - Whether multiple image uploads are allowed.
|
|
72
|
+
*/
|
|
73
|
+
allowMultiple?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* - The accepted file formats for image uploads.
|
|
76
|
+
*/
|
|
77
|
+
acceptedFormats?: string;
|
|
78
|
+
/**
|
|
79
|
+
* - Whether to enable format type selection (block or inline).
|
|
80
|
+
*/
|
|
81
|
+
useFormatType?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* - The default image format type ("block" or "inline").
|
|
84
|
+
*/
|
|
85
|
+
defaultFormatType?: string;
|
|
86
|
+
/**
|
|
87
|
+
* - Whether to retain the chosen format type after image insertion.
|
|
88
|
+
*/
|
|
89
|
+
keepFormatType?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* - Whether to enable file uploads for linked images.
|
|
92
|
+
*/
|
|
93
|
+
linkEnableFileUpload?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* - Figure controls.
|
|
96
|
+
*/
|
|
97
|
+
controls?: FigureControls_image;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* @typedef {import('../../events').ImageInfo} ImageInfo_image
|
|
101
|
+
*/
|
|
102
|
+
/**
|
|
103
|
+
* @typedef {import('../../modules/Figure').FigureControls} FigureControls_image
|
|
104
|
+
*/
|
|
105
|
+
/**
|
|
106
|
+
* @typedef {Object} ImagePluginOptions
|
|
107
|
+
* @property {boolean} [canResize=true] - Whether the image element can be resized.
|
|
108
|
+
* @property {boolean} [showHeightInput=true] - Whether to display the height input field.
|
|
109
|
+
* @property {string} [defaultWidth="auto"] - The default width of the image. If a number is provided, "px" will be appended.
|
|
110
|
+
* @property {string} [defaultHeight="auto"] - The default height of the image. If a number is provided, "px" will be appended.
|
|
111
|
+
* @property {boolean} [percentageOnlySize=false] - Whether to allow only percentage-based sizing.
|
|
112
|
+
* @property {boolean} [createFileInput=true] - Whether to create a file input element for image uploads.
|
|
113
|
+
* @property {boolean} [createUrlInput=true] - Whether to create a URL input element for image insertion.
|
|
114
|
+
* @property {string} [uploadUrl] - The URL endpoint for image file uploads.
|
|
115
|
+
* @property {Object<string, string>} [uploadHeaders] - Additional headers to include in the file upload request.
|
|
116
|
+
* @property {number} [uploadSizeLimit] - The total upload size limit in bytes.
|
|
117
|
+
* @property {number} [uploadSingleSizeLimit] - The single file upload size limit in bytes.
|
|
118
|
+
* @property {boolean} [allowMultiple=false] - Whether multiple image uploads are allowed.
|
|
119
|
+
* @property {string} [acceptedFormats="image/*"] - The accepted file formats for image uploads.
|
|
120
|
+
* @property {boolean} [useFormatType=true] - Whether to enable format type selection (block or inline).
|
|
121
|
+
* @property {string} [defaultFormatType="block"] - The default image format type ("block" or "inline").
|
|
122
|
+
* @property {boolean} [keepFormatType=false] - Whether to retain the chosen format type after image insertion.
|
|
123
|
+
* @property {boolean} [linkEnableFileUpload] - Whether to enable file uploads for linked images.
|
|
124
|
+
* @property {FigureControls_image} [controls] - Figure controls.
|
|
125
|
+
*/
|
|
126
|
+
/**
|
|
127
|
+
* @class
|
|
128
|
+
* @description Image plugin.
|
|
129
|
+
* - This plugin provides image insertion functionality within the editor, supporting both file upload and URL input.
|
|
130
|
+
*/
|
|
131
|
+
declare class Image_ extends EditorInjector {
|
|
132
|
+
static key: string;
|
|
133
|
+
static type: string;
|
|
134
|
+
static className: string;
|
|
135
|
+
/**
|
|
136
|
+
* @this {Image_}
|
|
137
|
+
* @param {Element} node - The node to check.
|
|
138
|
+
* @returns {Element|null} Returns a node if the node is a valid component.
|
|
139
|
+
*/
|
|
140
|
+
static component(this: Image_, node: Element): Element | null;
|
|
141
|
+
/**
|
|
142
|
+
* @constructor
|
|
143
|
+
* @param {__se__EditorCore} editor - The root editor instance
|
|
144
|
+
* @param {ImagePluginOptions} pluginOptions
|
|
145
|
+
*/
|
|
146
|
+
constructor(editor: __se__EditorCore, pluginOptions: ImagePluginOptions);
|
|
147
|
+
title: any;
|
|
148
|
+
icon: string;
|
|
149
|
+
pluginOptions: {
|
|
150
|
+
canResize: boolean;
|
|
151
|
+
showHeightInput: boolean;
|
|
152
|
+
defaultWidth: string;
|
|
153
|
+
defaultHeight: string;
|
|
154
|
+
percentageOnlySize: boolean;
|
|
155
|
+
createFileInput: boolean;
|
|
156
|
+
createUrlInput: boolean;
|
|
157
|
+
uploadUrl: string;
|
|
158
|
+
uploadHeaders: {
|
|
159
|
+
[x: string]: string;
|
|
160
|
+
};
|
|
161
|
+
uploadSizeLimit: number;
|
|
162
|
+
uploadSingleSizeLimit: number;
|
|
163
|
+
allowMultiple: boolean;
|
|
164
|
+
acceptedFormats: string;
|
|
165
|
+
useFormatType: boolean;
|
|
166
|
+
defaultFormatType: string;
|
|
167
|
+
keepFormatType: boolean;
|
|
168
|
+
};
|
|
169
|
+
alignForm: HTMLElement;
|
|
170
|
+
anchor: ModalAnchorEditor;
|
|
171
|
+
modal: Modal;
|
|
172
|
+
figure: Figure;
|
|
173
|
+
fileManager: FileManager;
|
|
174
|
+
fileModalWrapper: HTMLElement;
|
|
175
|
+
imgInputFile: HTMLInputElement;
|
|
176
|
+
imgUrlFile: HTMLInputElement;
|
|
177
|
+
focusElement: HTMLInputElement;
|
|
178
|
+
altText: HTMLInputElement;
|
|
179
|
+
captionCheckEl: HTMLInputElement;
|
|
180
|
+
captionEl: HTMLElement;
|
|
181
|
+
previewSrc: HTMLElement;
|
|
182
|
+
sizeUnit: string;
|
|
183
|
+
as: string;
|
|
184
|
+
proportion: HTMLInputElement;
|
|
185
|
+
inputX: HTMLInputElement;
|
|
186
|
+
inputY: HTMLInputElement;
|
|
187
|
+
_linkElement: any;
|
|
188
|
+
_linkValue: string;
|
|
189
|
+
_align: string;
|
|
190
|
+
_svgDefaultSize: string;
|
|
191
|
+
_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
|
+
asBlock: HTMLButtonElement;
|
|
206
|
+
asInline: HTMLButtonElement;
|
|
207
|
+
/**
|
|
208
|
+
* @editorMethod Modules.Modal
|
|
209
|
+
* @description Executes the method that is called when a "Modal" module's is opened.
|
|
210
|
+
*/
|
|
211
|
+
open(): void;
|
|
212
|
+
/**
|
|
213
|
+
* @editorMethod Modules.Controller(Figure)
|
|
214
|
+
* @description Executes the method that is called when a target component is edited.
|
|
215
|
+
*/
|
|
216
|
+
edit(): void;
|
|
217
|
+
/**
|
|
218
|
+
* @editorMethod Modules.Modal
|
|
219
|
+
* @description Executes the method that is called when a plugin's modal is opened.
|
|
220
|
+
* @param {boolean} isUpdate "Indicates whether the modal is for editing an existing component (true) or registering a new one (false)."
|
|
221
|
+
*/
|
|
222
|
+
on(isUpdate: boolean): void;
|
|
223
|
+
/**
|
|
224
|
+
* @editorMethod Editor.EventManager
|
|
225
|
+
* @description Executes the event function of "paste" or "drop".
|
|
226
|
+
* @param {Object} params { frameContext, event, file }
|
|
227
|
+
* @param {__se__FrameContext} params.frameContext Frame context
|
|
228
|
+
* @param {ClipboardEvent} params.event Event object
|
|
229
|
+
* @param {File} params.file File object
|
|
230
|
+
* @returns {boolean} - If return false, the file upload will be canceled
|
|
231
|
+
*/
|
|
232
|
+
onFilePasteAndDrop({ file }: { frameContext: __se__FrameContext; event: ClipboardEvent; file: File }): boolean;
|
|
233
|
+
/**
|
|
234
|
+
* @editorMethod Modules.Modal
|
|
235
|
+
* @description This function is called when a form within a modal window is "submit".
|
|
236
|
+
* @returns {Promise<boolean>} Success or failure
|
|
237
|
+
*/
|
|
238
|
+
modalAction(): Promise<boolean>;
|
|
239
|
+
/**
|
|
240
|
+
* @editorMethod Editor.core
|
|
241
|
+
* @description This method is used to validate and preserve the format of the component within the editor.
|
|
242
|
+
* - It ensures that the structure and attributes of the element are maintained and secure.
|
|
243
|
+
* - The method checks if the element is already wrapped in a valid container and updates its attributes if necessary.
|
|
244
|
+
* - If the element isn't properly contained, a new container is created to retain the format.
|
|
245
|
+
* @returns {{query: string, method: (element: HTMLImageElement) => void}} The format retention object containing the query and method to process the element.
|
|
246
|
+
* - query: The selector query to identify the relevant elements (in this case, 'audio').
|
|
247
|
+
* - method:The function to execute on the element to validate and preserve its format.
|
|
248
|
+
* - The function takes the element as an argument, checks if it is contained correctly, and applies necessary adjustments.
|
|
249
|
+
*/
|
|
250
|
+
retainFormat(): {
|
|
251
|
+
query: string;
|
|
252
|
+
method: (element: HTMLImageElement) => void;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* @editorMethod Modules.Modal
|
|
256
|
+
* @description This function is called before the modal window is opened, but before it is closed.
|
|
257
|
+
*/
|
|
258
|
+
init(): void;
|
|
259
|
+
/**
|
|
260
|
+
* @editorMethod Editor.Component
|
|
261
|
+
* @description Executes the method that is called when a component of a plugin is selected.
|
|
262
|
+
* @param {HTMLElement} target Target component element
|
|
263
|
+
*/
|
|
264
|
+
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
|
+
/**
|
|
274
|
+
* @editorMethod Editor.Component
|
|
275
|
+
* @description Method to delete a component of a plugin, called by the "FileManager", "Controller" module.
|
|
276
|
+
* @param {HTMLElement} target Target element
|
|
277
|
+
* @returns {Promise<void>}
|
|
278
|
+
*/
|
|
279
|
+
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
|
+
/**
|
|
293
|
+
* @description Create an "image" component using the provided files.
|
|
294
|
+
* @param {FileList|File[]} fileList File object list
|
|
295
|
+
* @returns {Promise<boolean>} If return false, the file upload will be canceled
|
|
296
|
+
*/
|
|
297
|
+
submitFile(fileList: FileList | File[]): Promise<boolean>;
|
|
298
|
+
/**
|
|
299
|
+
* @description Create an "image" component using the provided url.
|
|
300
|
+
* @param {string} url File url
|
|
301
|
+
* @returns {Promise<boolean>} If return false, the file upload will be canceled
|
|
302
|
+
*/
|
|
303
|
+
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
|
+
/**
|
|
338
|
+
* @description Creates a new image component, wraps it in a figure container with an optional anchor,
|
|
339
|
+
* - applies size and alignment settings, and inserts it into the editor.
|
|
340
|
+
* @param {string} src - The URL of the image to be inserted.
|
|
341
|
+
* @param {?Node} anchor - An optional anchor element to wrap the image. If provided, a clone is used.
|
|
342
|
+
* @param {string} width - The width value to be applied to the image.
|
|
343
|
+
* @param {string} height - The height value to be applied to the image.
|
|
344
|
+
* @param {string} align - The alignment setting for the image (e.g., 'left', 'center', 'right').
|
|
345
|
+
* @param {{name: string, size: number}} file - File metadata associated with the image
|
|
346
|
+
* @param {string} alt - The alternative text for the image.
|
|
347
|
+
*/
|
|
348
|
+
create(
|
|
349
|
+
src: string,
|
|
350
|
+
anchor: Node | null,
|
|
351
|
+
width: string,
|
|
352
|
+
height: string,
|
|
353
|
+
align: string,
|
|
354
|
+
file: {
|
|
355
|
+
name: string;
|
|
356
|
+
size: number;
|
|
357
|
+
},
|
|
358
|
+
alt: string
|
|
359
|
+
): void;
|
|
360
|
+
/**
|
|
361
|
+
* @description Creates a new inline image component, wraps it in an inline figure container with an optional anchor,
|
|
362
|
+
* - applies size settings, and inserts it into the editor.
|
|
363
|
+
* @param {string} src - The URL of the image to be inserted.
|
|
364
|
+
* @param {?Node} anchor - An optional anchor element to wrap the image. If provided, a clone is used.
|
|
365
|
+
* @param {string} width - The width value to be applied to the image.
|
|
366
|
+
* @param {string} height - The height value to be applied to the image.
|
|
367
|
+
* @param {{name: string, size: number}} file - File metadata associated with the image
|
|
368
|
+
* @param {string} alt - The alternative text for the image.
|
|
369
|
+
*/
|
|
370
|
+
createInline(
|
|
371
|
+
src: string,
|
|
372
|
+
anchor: Node | null,
|
|
373
|
+
width: string,
|
|
374
|
+
height: string,
|
|
375
|
+
file: {
|
|
376
|
+
name: string;
|
|
377
|
+
size: number;
|
|
378
|
+
},
|
|
379
|
+
alt: string
|
|
380
|
+
): 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
|
+
#private;
|
|
446
|
+
}
|
|
447
|
+
import EditorInjector from '../../editorInjector';
|
|
448
|
+
import { ModalAnchorEditor } from '../../modules';
|
|
449
|
+
import { Modal } from '../../modules';
|
|
450
|
+
import { Figure } from '../../modules';
|
|
451
|
+
import { FileManager } from '../../modules';
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export default Link;
|
|
2
|
+
export type LinkPluginOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* - Whether to display the link text.
|
|
5
|
+
*/
|
|
6
|
+
textToDisplay?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* - Whether to display the link title.
|
|
9
|
+
*/
|
|
10
|
+
title?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* - The URL endpoint for file uploads.
|
|
13
|
+
*/
|
|
14
|
+
uploadUrl?: string;
|
|
15
|
+
/**
|
|
16
|
+
* - Additional headers for file upload requests.
|
|
17
|
+
*/
|
|
18
|
+
uploadHeaders?: {
|
|
19
|
+
[x: string]: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* - The total file upload size limit in bytes.
|
|
23
|
+
*/
|
|
24
|
+
uploadSizeLimit?: number;
|
|
25
|
+
/**
|
|
26
|
+
* - The single file upload size limit in bytes.
|
|
27
|
+
*/
|
|
28
|
+
uploadSingleSizeLimit?: number;
|
|
29
|
+
/**
|
|
30
|
+
* - Accepted file formats for link uploads.
|
|
31
|
+
*/
|
|
32
|
+
acceptedFormats?: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {Object} LinkPluginOptions
|
|
36
|
+
* @property {boolean} [textToDisplay=true] - Whether to display the link text.
|
|
37
|
+
* @property {boolean} [title=true] - Whether to display the link title.
|
|
38
|
+
* @property {string} [uploadUrl] - The URL endpoint for file uploads.
|
|
39
|
+
* @property {Object<string, string>} [uploadHeaders] - Additional headers for file upload requests.
|
|
40
|
+
* @property {number} [uploadSizeLimit] - The total file upload size limit in bytes.
|
|
41
|
+
* @property {number} [uploadSingleSizeLimit] - The single file upload size limit in bytes.
|
|
42
|
+
* @property {string} [acceptedFormats] - Accepted file formats for link uploads.
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* @class
|
|
46
|
+
* @description Link plugin.
|
|
47
|
+
* - This plugin provides link insertion and editing functionality within the editor.
|
|
48
|
+
* - It also supports file uploads if an upload URL is provided.
|
|
49
|
+
*/
|
|
50
|
+
declare class Link extends EditorInjector {
|
|
51
|
+
static key: string;
|
|
52
|
+
static type: string;
|
|
53
|
+
static className: string;
|
|
54
|
+
/**
|
|
55
|
+
* @constructor
|
|
56
|
+
* @param {__se__EditorCore} editor - The root editor instance
|
|
57
|
+
* @param {LinkPluginOptions} pluginOptions
|
|
58
|
+
*/
|
|
59
|
+
constructor(editor: __se__EditorCore, pluginOptions: LinkPluginOptions);
|
|
60
|
+
title: any;
|
|
61
|
+
icon: string;
|
|
62
|
+
isUpdateState: boolean;
|
|
63
|
+
pluginOptions: {
|
|
64
|
+
uploadUrl: string;
|
|
65
|
+
uploadHeaders: {
|
|
66
|
+
[x: string]: string;
|
|
67
|
+
};
|
|
68
|
+
uploadSizeLimit: number;
|
|
69
|
+
uploadSingleSizeLimit: number;
|
|
70
|
+
acceptedFormats: string;
|
|
71
|
+
enableFileUpload: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* - Whether to display the link text.
|
|
74
|
+
*/
|
|
75
|
+
textToDisplay?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* - Whether to display the link title.
|
|
78
|
+
*/
|
|
79
|
+
title?: boolean;
|
|
80
|
+
};
|
|
81
|
+
anchor: ModalAnchorEditor;
|
|
82
|
+
modal: Modal;
|
|
83
|
+
controller: Controller;
|
|
84
|
+
/**
|
|
85
|
+
* @editorMethod Editor.EventManager
|
|
86
|
+
* @description Executes the method that is called whenever the cursor position changes.
|
|
87
|
+
* @param {?HTMLElement=} element - Node element where the cursor is currently located
|
|
88
|
+
* @returns {boolean} - Whether the plugin is active
|
|
89
|
+
*/
|
|
90
|
+
active(element?: (HTMLElement | null) | undefined): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* @editorMethod Modules.Modal
|
|
93
|
+
* @description Executes the method that is called when a "Modal" module's is opened.
|
|
94
|
+
*/
|
|
95
|
+
open(): void;
|
|
96
|
+
/**
|
|
97
|
+
* @editorMethod Modules.Modal
|
|
98
|
+
* @description Executes the method that is called when a plugin's modal is opened.
|
|
99
|
+
* @param {boolean} isUpdate "Indicates whether the modal is for editing an existing component (true) or registering a new one (false)."
|
|
100
|
+
*/
|
|
101
|
+
on(isUpdate: boolean): void;
|
|
102
|
+
/**
|
|
103
|
+
* @editorMethod Modules.Modal
|
|
104
|
+
* @description This function is called when a form within a modal window is "submit".
|
|
105
|
+
* @returns {boolean} Success or failure
|
|
106
|
+
*/
|
|
107
|
+
modalAction(): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* @editorMethod Modules.Modal
|
|
110
|
+
* @description This function is called before the modal window is opened, but before it is closed.
|
|
111
|
+
*/
|
|
112
|
+
init(): void;
|
|
113
|
+
/**
|
|
114
|
+
* @editorMethod Modules.Controller
|
|
115
|
+
* @description Executes the method that is called when a button is clicked in the "controller".
|
|
116
|
+
* @param {HTMLButtonElement} target Target button element
|
|
117
|
+
*/
|
|
118
|
+
controllerAction(target: HTMLButtonElement): void;
|
|
119
|
+
/**
|
|
120
|
+
* @editorMethod Modules.Controller
|
|
121
|
+
* @description This function is called before the "controller" before it is closed.
|
|
122
|
+
*/
|
|
123
|
+
close(): void;
|
|
124
|
+
}
|
|
125
|
+
import EditorInjector from '../../editorInjector';
|
|
126
|
+
import { ModalAnchorEditor } from '../../modules';
|
|
127
|
+
import { Modal } from '../../modules';
|
|
128
|
+
import { Controller } from '../../modules';
|