suneditor 3.1.2 → 3.1.4
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/README.md +1 -1
- package/dist/suneditor.min.css +1 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +9 -6
- package/src/assets/suneditor.css +28 -2
- package/src/core/event/handlers/handler_ww_dragDrop.js +20 -0
- package/src/core/logic/dom/html.js +7 -15
- package/src/core/logic/panel/menu.js +4 -0
- package/src/core/logic/shell/ui.js +13 -2
- package/src/core/schema/options.js +16 -16
- package/src/core/section/constructor.js +29 -22
- package/src/core/section/documentType.js +55 -29
- package/src/modules/contract/Browser.js +15 -11
- package/src/modules/contract/Controller.js +3 -0
- package/src/modules/contract/Figure.js +26 -4
- package/src/modules/contract/Modal.js +14 -1
- package/src/modules/ui/ModalAnchorEditor.js +8 -3
- package/src/plugins/browser/audioGallery.js +6 -0
- package/src/plugins/browser/fileBrowser.js +6 -0
- package/src/plugins/browser/fileGallery.js +6 -0
- package/src/plugins/browser/imageGallery.js +6 -0
- package/src/plugins/browser/videoGallery.js +6 -0
- package/src/plugins/dropdown/table/services/table.style.js +21 -12
- package/src/plugins/modal/embed.js +41 -1
- package/src/plugins/modal/image/index.js +2 -1
- package/types/core/schema/options.d.ts +29 -37
- package/types/core/section/documentType.d.ts +17 -1
- package/types/modules/contract/Browser.d.ts +7 -7
- package/types/modules/ui/ModalAnchorEditor.d.ts +6 -1
- package/types/plugins/browser/audioGallery.d.ts +16 -0
- package/types/plugins/browser/fileBrowser.d.ts +16 -0
- package/types/plugins/browser/fileGallery.d.ts +16 -0
- package/types/plugins/browser/imageGallery.d.ts +16 -0
- package/types/plugins/browser/videoGallery.d.ts +16 -0
- package/types/plugins/modal/embed.d.ts +34 -0
|
@@ -774,7 +774,7 @@ class Image_ extends PluginModal {
|
|
|
774
774
|
|
|
775
775
|
// link
|
|
776
776
|
let isNewAnchor = null;
|
|
777
|
-
const anchor = this.anchor.create(true);
|
|
777
|
+
const anchor = this.anchor.create(true, dom.check.isAnchor(this.#element.parentElement) ? this.#element.parentElement.href : null);
|
|
778
778
|
if (anchor) {
|
|
779
779
|
if (this.#linkElement !== anchor || (isNewContainer && !container.contains(anchor))) {
|
|
780
780
|
this.#linkElement = anchor.cloneNode(false);
|
|
@@ -839,6 +839,7 @@ class Image_ extends PluginModal {
|
|
|
839
839
|
*/
|
|
840
840
|
#setAnchor(imgTag, anchor) {
|
|
841
841
|
if (anchor) {
|
|
842
|
+
/** @type {HTMLAnchorElement} */ (anchor).setAttribute('data-se-non-link', 'true');
|
|
842
843
|
anchor.appendChild(imgTag);
|
|
843
844
|
return anchor;
|
|
844
845
|
}
|
|
@@ -25,6 +25,8 @@ export namespace DEFAULTS {
|
|
|
25
25
|
};
|
|
26
26
|
let CONTENT_STYLES: string;
|
|
27
27
|
let TAG_STYLES: {
|
|
28
|
+
'@text': string;
|
|
29
|
+
'@line': string;
|
|
28
30
|
'table|th|td': string;
|
|
29
31
|
'table|td': string;
|
|
30
32
|
tr: string;
|
|
@@ -36,8 +38,6 @@ export namespace DEFAULTS {
|
|
|
36
38
|
'img|video|iframe': string;
|
|
37
39
|
hr: string;
|
|
38
40
|
};
|
|
39
|
-
let SPAN_STYLES: string;
|
|
40
|
-
let LINE_STYLES: string;
|
|
41
41
|
let RETAIN_STYLE_MODE: string[];
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
@@ -263,7 +263,7 @@ export namespace DEFAULTS {
|
|
|
263
263
|
* - `classFilter`: Filters disallowed CSS class names (`allowedClassName`)
|
|
264
264
|
* - `textStyleTagFilter`: Filters text style tags (b, i, u, span, etc.)
|
|
265
265
|
* - `attrFilter`: Filters disallowed HTML attributes (`attributeWhitelist`/`attributeBlacklist`)
|
|
266
|
-
* - `styleFilter`: Filters disallowed inline styles (`
|
|
266
|
+
* - `styleFilter`: Filters disallowed inline styles (per-tag from `tagStyles`)
|
|
267
267
|
* ```js
|
|
268
268
|
* // disable only attribute and style filters
|
|
269
269
|
* {
|
|
@@ -309,7 +309,7 @@ export namespace DEFAULTS {
|
|
|
309
309
|
* attributeWhitelist: {
|
|
310
310
|
* a: 'href|target',
|
|
311
311
|
* img: 'src|alt',
|
|
312
|
-
* '*': 'id|data
|
|
312
|
+
* '*': 'id|data-[^\s]+'
|
|
313
313
|
* }
|
|
314
314
|
* }
|
|
315
315
|
* ```
|
|
@@ -339,19 +339,23 @@ export namespace DEFAULTS {
|
|
|
339
339
|
* ```js
|
|
340
340
|
* { allUsedStyles: 'color|background-color|text-shadow' }
|
|
341
341
|
* ```
|
|
342
|
-
* @property {Object<string, string>} [tagStyles={}] - Specifies allowed styles
|
|
342
|
+
* @property {Object<string, string>} [tagStyles={}] - Specifies allowed CSS styles per HTML tag.
|
|
343
|
+
* - Key is a tag name, multiple tags joined with `|`, or a category sentinel (`@text`, `@line`).
|
|
344
|
+
* - Value is a pipe-delimited list of allowed style names.
|
|
345
|
+
* - Resolution order when filtering an element: explicit tag entry → `@line` (for formatLine elements) → `@text` (for textStyleTags).
|
|
346
|
+
* - An explicit tag entry **replaces** the category default — include category styles in the value if you want both.
|
|
347
|
+
* - Merged with {@link DEFAULTS.TAG_STYLES}; user-supplied keys win.
|
|
343
348
|
* ```js
|
|
344
349
|
* {
|
|
345
350
|
* tagStyles: {
|
|
346
|
-
* '
|
|
347
|
-
*
|
|
351
|
+
* '@text': 'color|font-size|background-color', // default for span, b, i, em, ...
|
|
352
|
+
* '@line': 'text-align|margin|line-height', // default for p, h1-h6, div, li, ...
|
|
353
|
+
* 'table|td': 'border|color|background-color', // per-tag whitelist
|
|
354
|
+
* div: 'color', // explicit override; ignores `@line` default
|
|
355
|
+
* hr: 'border-top',
|
|
348
356
|
* }
|
|
349
357
|
* }
|
|
350
358
|
* ```
|
|
351
|
-
* @property {string} [spanStyles=CONSTANTS.SPAN_STYLES] - Specifies allowed styles for the `span` tag.
|
|
352
|
-
* - The default follows {@link DEFAULTS.SPAN_STYLES}
|
|
353
|
-
* @property {string} [lineStyles=CONSTANTS.LINE_STYLES] - Specifies allowed styles for the `line` element (p..).
|
|
354
|
-
* - The default follows {@link DEFAULTS.LINE_STYLES}
|
|
355
359
|
* @property {Array<string>} [fontSizeUnits=CONSTANTS.SIZE_UNITS] - Allowed font size units.
|
|
356
360
|
* - The default follows {@link DEFAULTS.SIZE_UNITS}
|
|
357
361
|
* @property {"repeat"|"always"|"none"} [retainStyleMode="repeat"] - Determines how inline elements (e.g. `<span>`, `<strong>`) are handled when deleting text.
|
|
@@ -570,8 +574,6 @@ export namespace DEFAULTS {
|
|
|
570
574
|
* @property {string[]} [_reverseCommandArray] - Internal key shortcut matcher for reverse commands.
|
|
571
575
|
* @property {string} [_subMode] - Sub toolbar mode (e.g., `balloon`).
|
|
572
576
|
* @property {string[]} [_textStyleTags] - Tag names used for text styling, plus span/li.
|
|
573
|
-
* @property {RegExp} [_textStylesRegExp] - Regex to match inline styles (e.g., fontSize, color).
|
|
574
|
-
* @property {RegExp} [_lineStylesRegExp] - Regex to match line styles (e.g., text-align, padding).
|
|
575
577
|
* @property {Object<string, string>} [_defaultStyleTagMap] - Mapping HTML tag => standard tag.
|
|
576
578
|
* @property {Object<string, string>} [_styleCommandMap] - Mapping HTML tag => command (e.g., bold, underline).
|
|
577
579
|
* @property {Object<string, string>} [_defaultTagCommand] - Mapping command => preferred tag.
|
|
@@ -985,7 +987,7 @@ export type EditorBaseOptions = {
|
|
|
985
987
|
* - `classFilter`: Filters disallowed CSS class names (`allowedClassName`)
|
|
986
988
|
* - `textStyleTagFilter`: Filters text style tags (b, i, u, span, etc.)
|
|
987
989
|
* - `attrFilter`: Filters disallowed HTML attributes (`attributeWhitelist`/`attributeBlacklist`)
|
|
988
|
-
* - `styleFilter`: Filters disallowed inline styles (`
|
|
990
|
+
* - `styleFilter`: Filters disallowed inline styles (per-tag from `tagStyles`)
|
|
989
991
|
* ```js
|
|
990
992
|
* // disable only attribute and style filters
|
|
991
993
|
* {
|
|
@@ -1055,7 +1057,7 @@ export type EditorBaseOptions = {
|
|
|
1055
1057
|
* attributeWhitelist: {
|
|
1056
1058
|
* a: 'href|target',
|
|
1057
1059
|
* img: 'src|alt',
|
|
1058
|
-
* '*': 'id|data
|
|
1060
|
+
* '*': 'id|data-[^\s]+'
|
|
1059
1061
|
* }
|
|
1060
1062
|
* }
|
|
1061
1063
|
* ```
|
|
@@ -1106,12 +1108,20 @@ export type EditorBaseOptions = {
|
|
|
1106
1108
|
*/
|
|
1107
1109
|
allUsedStyles?: string;
|
|
1108
1110
|
/**
|
|
1109
|
-
* - Specifies allowed styles
|
|
1111
|
+
* - Specifies allowed CSS styles per HTML tag.
|
|
1112
|
+
* - Key is a tag name, multiple tags joined with `|`, or a category sentinel (`@text`, `@line`).
|
|
1113
|
+
* - Value is a pipe-delimited list of allowed style names.
|
|
1114
|
+
* - Resolution order when filtering an element: explicit tag entry → `@line` (for formatLine elements) → `@text` (for textStyleTags).
|
|
1115
|
+
* - An explicit tag entry **replaces** the category default — include category styles in the value if you want both.
|
|
1116
|
+
* - Merged with {@link DEFAULTS.TAG_STYLES}; user-supplied keys win.
|
|
1110
1117
|
* ```js
|
|
1111
1118
|
* {
|
|
1112
1119
|
* tagStyles: {
|
|
1113
|
-
* '
|
|
1114
|
-
*
|
|
1120
|
+
* '@text': 'color|font-size|background-color', // default for span, b, i, em, ...
|
|
1121
|
+
* '@line': 'text-align|margin|line-height', // default for p, h1-h6, div, li, ...
|
|
1122
|
+
* 'table|td': 'border|color|background-color', // per-tag whitelist
|
|
1123
|
+
* div: 'color', // explicit override; ignores `@line` default
|
|
1124
|
+
* hr: 'border-top',
|
|
1115
1125
|
* }
|
|
1116
1126
|
* }
|
|
1117
1127
|
* ```
|
|
@@ -1119,16 +1129,6 @@ export type EditorBaseOptions = {
|
|
|
1119
1129
|
tagStyles?: {
|
|
1120
1130
|
[x: string]: string;
|
|
1121
1131
|
};
|
|
1122
|
-
/**
|
|
1123
|
-
* - Specifies allowed styles for the `span` tag.
|
|
1124
|
-
* - The default follows {@link DEFAULTS.SPAN_STYLES}
|
|
1125
|
-
*/
|
|
1126
|
-
spanStyles?: string;
|
|
1127
|
-
/**
|
|
1128
|
-
* - Specifies allowed styles for the `line` element (p..).
|
|
1129
|
-
* - The default follows {@link DEFAULTS.LINE_STYLES}
|
|
1130
|
-
*/
|
|
1131
|
-
lineStyles?: string;
|
|
1132
1132
|
/**
|
|
1133
1133
|
* - Allowed font size units.
|
|
1134
1134
|
* - The default follows {@link DEFAULTS.SIZE_UNITS}
|
|
@@ -1501,14 +1501,6 @@ export type InternalBaseOptions = {
|
|
|
1501
1501
|
* - Tag names used for text styling, plus span/li.
|
|
1502
1502
|
*/
|
|
1503
1503
|
_textStyleTags?: string[];
|
|
1504
|
-
/**
|
|
1505
|
-
* - Regex to match inline styles (e.g., fontSize, color).
|
|
1506
|
-
*/
|
|
1507
|
-
_textStylesRegExp?: RegExp;
|
|
1508
|
-
/**
|
|
1509
|
-
* - Regex to match line styles (e.g., text-align, padding).
|
|
1510
|
-
*/
|
|
1511
|
-
_lineStylesRegExp?: RegExp;
|
|
1512
1504
|
/**
|
|
1513
1505
|
* - Mapping HTML tag => standard tag.
|
|
1514
1506
|
*/
|
|
@@ -1602,7 +1594,7 @@ export type StrictModeOptions = {
|
|
|
1602
1594
|
*/
|
|
1603
1595
|
attrFilter: boolean;
|
|
1604
1596
|
/**
|
|
1605
|
-
* - Filters disallowed inline styles (`
|
|
1597
|
+
* - Filters disallowed inline styles (per-tag from `tagStyles`)
|
|
1606
1598
|
*/
|
|
1607
1599
|
styleFilter: boolean;
|
|
1608
1600
|
};
|
|
@@ -30,9 +30,19 @@ declare class DocumentType {
|
|
|
30
30
|
* @param {number} t - The initial top position value to be adjusted.
|
|
31
31
|
* @param {HTMLCollection} chr - The elements array in the current (main) page.
|
|
32
32
|
* @param {HTMLCollection} mChr - The elements array in the mirrored page.
|
|
33
|
+
* @param {Array.<{number: number, top: number, isBreak?: boolean}>} [pages] - The pages array containing page break info.
|
|
33
34
|
* @returns {number|null} The adjusted top value.
|
|
34
35
|
*/
|
|
35
|
-
_calcPageBreakTop(
|
|
36
|
+
_calcPageBreakTop(
|
|
37
|
+
t: number,
|
|
38
|
+
chr: HTMLCollection,
|
|
39
|
+
mChr: HTMLCollection,
|
|
40
|
+
pages?: Array<{
|
|
41
|
+
number: number;
|
|
42
|
+
top: number;
|
|
43
|
+
isBreak?: boolean;
|
|
44
|
+
}>,
|
|
45
|
+
): number | null;
|
|
36
46
|
/**
|
|
37
47
|
* @internal
|
|
38
48
|
* @description Initializes the cache for document elements.
|
|
@@ -44,6 +54,7 @@ declare class DocumentType {
|
|
|
44
54
|
* @description Retrieves the element at a given position.
|
|
45
55
|
* @param {number} pageTop - The vertical position to check.
|
|
46
56
|
* @param {HTMLCollection} mChr - List of mirrored elements.
|
|
57
|
+
* @param {Array.<{number: number, top: number, isBreak?: boolean}>} [pages] - The pages array containing page break info for skipping break elements.
|
|
47
58
|
* @returns {{ci: number, cm: number, ch: number}} The closest element and its related data.
|
|
48
59
|
* - ci: The index of the closest element.
|
|
49
60
|
* - cm: The distance between the top of the closest element and the given position.
|
|
@@ -52,6 +63,11 @@ declare class DocumentType {
|
|
|
52
63
|
_getElementAtPosition(
|
|
53
64
|
pageTop: number,
|
|
54
65
|
mChr: HTMLCollection,
|
|
66
|
+
pages?: Array<{
|
|
67
|
+
number: number;
|
|
68
|
+
top: number;
|
|
69
|
+
isBreak?: boolean;
|
|
70
|
+
}>,
|
|
55
71
|
): {
|
|
56
72
|
ci: number;
|
|
57
73
|
cm: number;
|
|
@@ -102,7 +102,7 @@ export type BrowserParams = {
|
|
|
102
102
|
/**
|
|
103
103
|
* - File server search http header. Optional. Can be overridden in browser.
|
|
104
104
|
*/
|
|
105
|
-
|
|
105
|
+
searchHeaders?: {
|
|
106
106
|
[x: string]: string;
|
|
107
107
|
};
|
|
108
108
|
/**
|
|
@@ -172,7 +172,7 @@ export type BrowserParams = {
|
|
|
172
172
|
* ]
|
|
173
173
|
* }
|
|
174
174
|
* ```
|
|
175
|
-
* @property {Object<string, string>} [
|
|
175
|
+
* @property {Object<string, string>} [searchHeaders] - File server search http header. Optional. Can be overridden in browser.
|
|
176
176
|
* @property {string} [listClass] - Class name of list div. Required. Can be overridden in browser.
|
|
177
177
|
* @property {(item: BrowserFile) => string} [drawItemHandler] - Function that returns HTML string for rendering each file item. Required. Can be overridden in browser.
|
|
178
178
|
* ```js
|
|
@@ -227,11 +227,11 @@ declare class Browser {
|
|
|
227
227
|
[x: string]: any;
|
|
228
228
|
};
|
|
229
229
|
url: string;
|
|
230
|
-
|
|
230
|
+
headers: {
|
|
231
231
|
[x: string]: string;
|
|
232
232
|
};
|
|
233
233
|
searchUrl: string;
|
|
234
|
-
|
|
234
|
+
searchHeaders: {
|
|
235
235
|
[x: string]: string;
|
|
236
236
|
};
|
|
237
237
|
drawItemHandler: any;
|
|
@@ -276,7 +276,7 @@ declare class Browser {
|
|
|
276
276
|
* @param {string} [params.listClass] - Class name of list div. If not, use `this.listClass`.
|
|
277
277
|
* @param {string} [params.title] - File browser window title. If not, use `this.title`.
|
|
278
278
|
* @param {string} [params.url] - File server url. If not, use `this.url`.
|
|
279
|
-
* @param {Object<string, string>} [params.
|
|
279
|
+
* @param {Object<string, string>} [params.headers] - File server http header. If not, use `this.headers`.
|
|
280
280
|
* @example
|
|
281
281
|
* // Open with default settings (configured at construction):
|
|
282
282
|
* this.browser.open();
|
|
@@ -285,14 +285,14 @@ declare class Browser {
|
|
|
285
285
|
* this.browser.open({
|
|
286
286
|
* title: 'Select a video',
|
|
287
287
|
* url: '/api/videos',
|
|
288
|
-
*
|
|
288
|
+
* headers: { Authorization: 'Bearer token' },
|
|
289
289
|
* });
|
|
290
290
|
*/
|
|
291
291
|
open(params?: {
|
|
292
292
|
listClass?: string;
|
|
293
293
|
title?: string;
|
|
294
294
|
url?: string;
|
|
295
|
-
|
|
295
|
+
headers?: {
|
|
296
296
|
[x: string]: string;
|
|
297
297
|
};
|
|
298
298
|
}): void;
|
|
@@ -196,6 +196,8 @@ declare class ModalAnchorEditor {
|
|
|
196
196
|
/**
|
|
197
197
|
* @description Creates an anchor (`<a>`) element with the specified attributes.
|
|
198
198
|
* @param {boolean} notText - If `true`, the anchor will not contain text content.
|
|
199
|
+
* @param {?string} [urlOverride] - Fallback URL used when the modal's `linkValue` is empty
|
|
200
|
+
* - (e.g., when called outside the modal lifecycle such as from `retainFormat`)
|
|
199
201
|
* @returns {HTMLElement|null} - The newly created anchor element, or `null` if the URL is empty.
|
|
200
202
|
* @example
|
|
201
203
|
* // In a link plugin — create anchor with text content:
|
|
@@ -208,8 +210,11 @@ declare class ModalAnchorEditor {
|
|
|
208
210
|
* if (anchor) {
|
|
209
211
|
* anchor.appendChild(imgElement);
|
|
210
212
|
* }
|
|
213
|
+
*
|
|
214
|
+
* // Preserve an existing parent anchor's href when rebuilding outside the modal:
|
|
215
|
+
* const anchor = this.anchor.create(true, parentAnchor.href);
|
|
211
216
|
*/
|
|
212
|
-
create(notText: boolean): HTMLElement | null;
|
|
217
|
+
create(notText: boolean, urlOverride?: string | null): HTMLElement | null;
|
|
213
218
|
/**
|
|
214
219
|
* @description Resets the ModalAnchorEditor to its initial state.
|
|
215
220
|
*/
|
|
@@ -28,6 +28,18 @@ export type AudioGalleryPluginOptions = {
|
|
|
28
28
|
headers?: {
|
|
29
29
|
[x: string]: string;
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* - Server-side search URL. When set, the keyword is sent to this URL
|
|
33
|
+
* as `?keyword=<value>` and the server response replaces the list. When not set, search filters the
|
|
34
|
+
* already-loaded items locally.
|
|
35
|
+
*/
|
|
36
|
+
searchUrl?: string;
|
|
37
|
+
/**
|
|
38
|
+
* - Server-side search request headers
|
|
39
|
+
*/
|
|
40
|
+
searchHeaders?: {
|
|
41
|
+
[x: string]: string;
|
|
42
|
+
};
|
|
31
43
|
/**
|
|
32
44
|
* - Default thumbnail
|
|
33
45
|
*/
|
|
@@ -51,6 +63,10 @@ export type AudioGalleryPluginOptions = {
|
|
|
51
63
|
* }
|
|
52
64
|
* ```
|
|
53
65
|
* @property {Object<string, string>} [headers] - Server request headers
|
|
66
|
+
* @property {string} [searchUrl] - Server-side search URL. When set, the keyword is sent to this URL
|
|
67
|
+
* as `?keyword=<value>` and the server response replaces the list. When not set, search filters the
|
|
68
|
+
* already-loaded items locally.
|
|
69
|
+
* @property {Object<string, string>} [searchHeaders] - Server-side search request headers
|
|
54
70
|
* @property {string|((item: SunEditor.Module.Browser.File) => string)} [thumbnail] - Default thumbnail
|
|
55
71
|
*/
|
|
56
72
|
/**
|
|
@@ -39,6 +39,18 @@ export type FileBrowserPluginOptions = {
|
|
|
39
39
|
headers?: {
|
|
40
40
|
[x: string]: string;
|
|
41
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* - Server-side search URL. When set, the keyword is sent to this URL
|
|
44
|
+
* as `?keyword=<value>` and the server response replaces the list. When not set, search filters the
|
|
45
|
+
* already-loaded items locally.
|
|
46
|
+
*/
|
|
47
|
+
searchUrl?: string;
|
|
48
|
+
/**
|
|
49
|
+
* - Server-side search request headers
|
|
50
|
+
*/
|
|
51
|
+
searchHeaders?: {
|
|
52
|
+
[x: string]: string;
|
|
53
|
+
};
|
|
42
54
|
/**
|
|
43
55
|
* - Default thumbnail URL or a function that returns a thumbnail URL per item.
|
|
44
56
|
*/
|
|
@@ -80,6 +92,10 @@ export type FileBrowserPluginOptions = {
|
|
|
80
92
|
* }
|
|
81
93
|
* ```
|
|
82
94
|
* @property {Object<string, string>} [headers] - Server request headers
|
|
95
|
+
* @property {string} [searchUrl] - Server-side search URL. When set, the keyword is sent to this URL
|
|
96
|
+
* as `?keyword=<value>` and the server response replaces the list. When not set, search filters the
|
|
97
|
+
* already-loaded items locally.
|
|
98
|
+
* @property {Object<string, string>} [searchHeaders] - Server-side search request headers
|
|
83
99
|
* @property {string|((item: SunEditor.Module.Browser.File) => string)} [thumbnail] - Default thumbnail URL or a function that returns a thumbnail URL per item.
|
|
84
100
|
* @property {number} [expand=1] - Initial folder expand depth. `1` expands the first level, `Infinity` expands all. Default: `1`.
|
|
85
101
|
* @property {Array<string>} [props] - Additional tag names
|
|
@@ -29,6 +29,18 @@ export type FileGalleryPluginOptions = {
|
|
|
29
29
|
headers?: {
|
|
30
30
|
[x: string]: string;
|
|
31
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* - Server-side search URL. When set, the keyword is sent to this URL
|
|
34
|
+
* as `?keyword=<value>` and the server response replaces the list. When not set, search filters the
|
|
35
|
+
* already-loaded items locally.
|
|
36
|
+
*/
|
|
37
|
+
searchUrl?: string;
|
|
38
|
+
/**
|
|
39
|
+
* - Server-side search request headers
|
|
40
|
+
*/
|
|
41
|
+
searchHeaders?: {
|
|
42
|
+
[x: string]: string;
|
|
43
|
+
};
|
|
32
44
|
/**
|
|
33
45
|
* - Default thumbnail
|
|
34
46
|
*/
|
|
@@ -53,6 +65,10 @@ export type FileGalleryPluginOptions = {
|
|
|
53
65
|
* }
|
|
54
66
|
* ```
|
|
55
67
|
* @property {Object<string, string>} [headers] - Server request headers
|
|
68
|
+
* @property {string} [searchUrl] - Server-side search URL. When set, the keyword is sent to this URL
|
|
69
|
+
* as `?keyword=<value>` and the server response replaces the list. When not set, search filters the
|
|
70
|
+
* already-loaded items locally.
|
|
71
|
+
* @property {Object<string, string>} [searchHeaders] - Server-side search request headers
|
|
56
72
|
* @property {string|((item: SunEditor.Module.Browser.File) => string)} [thumbnail] - Default thumbnail
|
|
57
73
|
*/
|
|
58
74
|
/**
|
|
@@ -29,6 +29,18 @@ export type ImageGalleryPluginOptions = {
|
|
|
29
29
|
headers?: {
|
|
30
30
|
[x: string]: string;
|
|
31
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* - Server-side search URL. When set, the keyword is sent to this URL
|
|
34
|
+
* as `?keyword=<value>` and the server response replaces the list. When not set, search filters the
|
|
35
|
+
* already-loaded items locally.
|
|
36
|
+
*/
|
|
37
|
+
searchUrl?: string;
|
|
38
|
+
/**
|
|
39
|
+
* - Server-side search request headers
|
|
40
|
+
*/
|
|
41
|
+
searchHeaders?: {
|
|
42
|
+
[x: string]: string;
|
|
43
|
+
};
|
|
32
44
|
};
|
|
33
45
|
/**
|
|
34
46
|
* @typedef ImageGalleryPluginOptions
|
|
@@ -49,6 +61,10 @@ export type ImageGalleryPluginOptions = {
|
|
|
49
61
|
* }
|
|
50
62
|
* ```
|
|
51
63
|
* @property {Object<string, string>} [headers] - Server request headers
|
|
64
|
+
* @property {string} [searchUrl] - Server-side search URL. When set, the keyword is sent to this URL
|
|
65
|
+
* as `?keyword=<value>` and the server response replaces the list. When not set, search filters the
|
|
66
|
+
* already-loaded items locally.
|
|
67
|
+
* @property {Object<string, string>} [searchHeaders] - Server-side search request headers
|
|
52
68
|
*/
|
|
53
69
|
/**
|
|
54
70
|
* @class
|
|
@@ -29,6 +29,18 @@ export type VideoGalleryPluginOptions = {
|
|
|
29
29
|
headers?: {
|
|
30
30
|
[x: string]: string;
|
|
31
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* - Server-side search URL. When set, the keyword is sent to this URL
|
|
34
|
+
* as `?keyword=<value>` and the server response replaces the list. When not set, search filters the
|
|
35
|
+
* already-loaded items locally.
|
|
36
|
+
*/
|
|
37
|
+
searchUrl?: string;
|
|
38
|
+
/**
|
|
39
|
+
* - Server-side search request headers
|
|
40
|
+
*/
|
|
41
|
+
searchHeaders?: {
|
|
42
|
+
[x: string]: string;
|
|
43
|
+
};
|
|
32
44
|
/**
|
|
33
45
|
* - Default thumbnail
|
|
34
46
|
*/
|
|
@@ -53,6 +65,10 @@ export type VideoGalleryPluginOptions = {
|
|
|
53
65
|
* }
|
|
54
66
|
* ```
|
|
55
67
|
* @property {Object<string, string>} [headers] - Server request headers
|
|
68
|
+
* @property {string} [searchUrl] - Server-side search URL. When set, the keyword is sent to this URL
|
|
69
|
+
* as `?keyword=<value>` and the server response replaces the list. When not set, search filters the
|
|
70
|
+
* already-loaded items locally.
|
|
71
|
+
* @property {Object<string, string>} [searchHeaders] - Server-side search request headers
|
|
56
72
|
* @property {string|((item: SunEditor.Module.Browser.File) => string)} [thumbnail] - Default thumbnail
|
|
57
73
|
*/
|
|
58
74
|
/**
|
|
@@ -78,6 +78,20 @@ export type EmbedPluginOptions = {
|
|
|
78
78
|
* - Additional URL patterns to recognize as embeddable content.
|
|
79
79
|
*/
|
|
80
80
|
urlPatterns?: Array<RegExp>;
|
|
81
|
+
/**
|
|
82
|
+
* - Allowed `<script src=...>` patterns for raw embed HTML
|
|
83
|
+
* - (e.g. Twitter blockquote + `widgets.js`). Each entry is a `RegExp` (tested against the full src) or a `string` (matched via `startsWith`).
|
|
84
|
+
* - Defaults to `[]` — all script tags are rejected.** Inline scripts (no `src`) are always rejected.
|
|
85
|
+
* ```js
|
|
86
|
+
* {
|
|
87
|
+
* scriptSrcWhitelist: [
|
|
88
|
+
* /^https:\/\/platform\.x\.com\/widgets\.js$/,
|
|
89
|
+
* /^https:\/\/www\.instagram\.com\/embed\.js$/,
|
|
90
|
+
* ]
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
scriptSrcWhitelist?: Array<RegExp | string>;
|
|
81
95
|
/**
|
|
82
96
|
* - Custom embed service definitions.
|
|
83
97
|
* Each key is a service name, with `pattern` to match the URL, `action` to transform it into an embed URL, and `tag` for the output element.
|
|
@@ -150,6 +164,17 @@ export type EmbedPluginOptions = {
|
|
|
150
164
|
* { query_vimeo: 'autoplay=1' }
|
|
151
165
|
* ```
|
|
152
166
|
* @property {Array<RegExp>} [urlPatterns] - Additional URL patterns to recognize as embeddable content.
|
|
167
|
+
* @property {Array<RegExp|string>} [scriptSrcWhitelist] - Allowed `<script src=...>` patterns for raw embed HTML
|
|
168
|
+
* - (e.g. Twitter blockquote + `widgets.js`). Each entry is a `RegExp` (tested against the full src) or a `string` (matched via `startsWith`).
|
|
169
|
+
* - Defaults to `[]` — all script tags are rejected.** Inline scripts (no `src`) are always rejected.
|
|
170
|
+
* ```js
|
|
171
|
+
* {
|
|
172
|
+
* scriptSrcWhitelist: [
|
|
173
|
+
* /^https:\/\/platform\.x\.com\/widgets\.js$/,
|
|
174
|
+
* /^https:\/\/www\.instagram\.com\/embed\.js$/,
|
|
175
|
+
* ]
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
153
178
|
* @property {Object<string, {pattern: RegExp, action: (url: string) => string, tag: string}>} [embedQuery] - Custom embed service definitions.
|
|
154
179
|
* Each key is a service name, with `pattern` to match the URL, `action` to transform it into an embed URL, and `tag` for the output element.
|
|
155
180
|
* ```js
|
|
@@ -189,6 +214,14 @@ declare class Embed extends PluginModal {
|
|
|
189
214
|
* @returns {boolean} `true` if the URL matches a known pattern; otherwise, `false`.
|
|
190
215
|
*/
|
|
191
216
|
static #checkContentType(url: string): boolean;
|
|
217
|
+
/**
|
|
218
|
+
* @description Validate a `<script src>` against the configured whitelist for raw embed HTML.
|
|
219
|
+
* Inline scripts (no `src`) are always rejected.
|
|
220
|
+
* @param {string} src
|
|
221
|
+
* @param {Array<RegExp|string>} whitelist
|
|
222
|
+
* @returns {boolean}
|
|
223
|
+
*/
|
|
224
|
+
static #isAllowedScriptSrc(src: string, whitelist: Array<RegExp | string>): boolean;
|
|
192
225
|
/** @type {Array<RegExp>} */
|
|
193
226
|
static #urlPatterns: Array<RegExp>;
|
|
194
227
|
/**
|
|
@@ -215,6 +248,7 @@ declare class Embed extends PluginModal {
|
|
|
215
248
|
};
|
|
216
249
|
query_youtube: string;
|
|
217
250
|
query_vimeo: string;
|
|
251
|
+
scriptSrcWhitelist: (string | RegExp)[];
|
|
218
252
|
insertBehavior: SunEditor.ComponentInsertType;
|
|
219
253
|
};
|
|
220
254
|
modal: Modal;
|