suneditor 3.3.0 → 3.3.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/README.md +18 -1
- package/dist/suneditor.min.css +2 -2
- package/dist/suneditor.min.js +1 -1
- package/package.json +3 -2
- package/src/assets/suneditor.css +5117 -5105
- package/src/core/config/eventManager.js +24 -1
- package/src/core/editor.js +6 -1
- package/src/core/event/effects/keydown.registry.js +14 -9
- package/src/core/event/effects/ruleHelpers.js +119 -1
- package/src/core/event/eventOrchestrator.js +15 -6
- package/src/core/event/rules/keydown.rule.backspace.js +10 -47
- package/src/core/event/rules/keydown.rule.delete.js +28 -66
- package/src/core/logic/dom/format.js +2 -2
- package/src/core/logic/dom/html.js +85 -5
- package/src/core/logic/dom/nodeTransform.js +5 -3
- package/src/core/logic/panel/blockHandle.js +61 -24
- package/src/core/logic/panel/blockResolver.js +41 -4
- package/src/core/logic/shell/pluginManager.js +15 -2
- package/src/core/logic/shell/ui.js +38 -28
- package/src/core/schema/options.js +20 -3
- package/src/core/section/constructor.js +12 -8
- package/src/events.js +1 -1
- package/src/helper/dom/domQuery.js +10 -4
- package/src/helper/googleDocs.js +40 -0
- package/src/helper/index.js +3 -0
- package/src/modules/contract/Figure.js +5 -2
- package/src/modules/ui/CommandMenu.js +47 -5
- package/src/modules/ui/SelectMenu.js +97 -36
- package/src/plugins/dropdown/table/index.js +25 -8
- package/src/plugins/dropdown/table/shared/table.constants.js +2 -0
- package/src/plugins/field/slashCommand.js +59 -12
- package/types/core/event/effects/ruleHelpers.d.ts +56 -0
- package/types/core/logic/panel/blockHandle.d.ts +3 -16
- package/types/core/logic/shell/ui.d.ts +14 -5
- package/types/core/schema/options.d.ts +31 -5
- package/types/events.d.ts +2 -2
- package/types/helper/dom/domQuery.d.ts +4 -2
- package/types/helper/googleDocs.d.ts +19 -0
- package/types/helper/index.d.ts +5 -0
- package/types/modules/ui/CommandMenu.d.ts +11 -0
- package/types/modules/ui/SelectMenu.d.ts +13 -7
- package/types/plugins/dropdown/table/index.d.ts +11 -0
- package/types/plugins/dropdown/table/shared/table.constants.d.ts +1 -0
- package/types/plugins/field/slashCommand.d.ts +43 -2
|
@@ -51,3 +51,59 @@ export function isRtlBidiMismatch(
|
|
|
51
51
|
detectedEdge: 'front' | 'end',
|
|
52
52
|
doc: Document,
|
|
53
53
|
): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* @description Whether the caret sits on a bare `<br>` that stands at the front/end edge of its `line`.
|
|
56
|
+
* @param {Range} range - The current range
|
|
57
|
+
* @param {Node} selectionNode - Current selection node
|
|
58
|
+
* @param {'front'|'end'} edge - Edge to test: `front` for Backspace, `end` for Delete
|
|
59
|
+
* @returns {boolean} `true` if the caret is on an edge `<br>`
|
|
60
|
+
*/
|
|
61
|
+
export function isEdgeBreakCaret(range: Range, selectionNode: Node, edge: 'front' | 'end'): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* @description The previous/next element in document order — crossing in and out of blocks (list, quote).
|
|
64
|
+
* - Out of list-cell ancestors (a nested list), stopping at a closure block (table cell).
|
|
65
|
+
* @param {EventPorts['format']} format - Format module
|
|
66
|
+
* @param {?HTMLElement} line - The caret's `line` element
|
|
67
|
+
* @param {'front'|'end'} edge - `front` for the previous element, `end` for the next one
|
|
68
|
+
* @returns {?HTMLElement} The adjacent element, or `null` at the document edge
|
|
69
|
+
*/
|
|
70
|
+
export function getAdjacentElement(
|
|
71
|
+
format: EventPorts['format'],
|
|
72
|
+
line: HTMLElement | null,
|
|
73
|
+
edge: 'front' | 'end',
|
|
74
|
+
): HTMLElement | null;
|
|
75
|
+
/**
|
|
76
|
+
* @description The previous/next `line` in document order — {@link getAdjacentElement} filtered to lines.
|
|
77
|
+
* - `null` means either the document edge or a non-`line` neighbour (a component); use
|
|
78
|
+
* {@link getAdjacentElement} when the two must be told apart.
|
|
79
|
+
* @param {EventPorts['format']} format - Format module
|
|
80
|
+
* @param {?HTMLElement} line - The caret's `line` element
|
|
81
|
+
* @param {'front'|'end'} edge - `front` for the previous line, `end` for the next one
|
|
82
|
+
* @returns {?HTMLElement} The adjacent line, or `null`
|
|
83
|
+
*/
|
|
84
|
+
export function getAdjacentLine(
|
|
85
|
+
format: EventPorts['format'],
|
|
86
|
+
line: HTMLElement | null,
|
|
87
|
+
edge: 'front' | 'end',
|
|
88
|
+
): HTMLElement | null;
|
|
89
|
+
/**
|
|
90
|
+
* @description The neighbouring `line` an empty line collapses into, or `null` when there is nothing to merge.
|
|
91
|
+
* - A cell owning a nested list belongs to {@link getNestedListTarget} instead.
|
|
92
|
+
* @param {EventPorts['format']} format - Format module
|
|
93
|
+
* @param {?HTMLElement} formatEl - The caret's `line` element
|
|
94
|
+
* @param {'front'|'end'} edge - `front` for Backspace (previous line), `end` for Delete (next line)
|
|
95
|
+
* @returns {?HTMLElement} The neighbouring line to merge into, or `null`
|
|
96
|
+
*/
|
|
97
|
+
export function getEmptyLineMergeTarget(
|
|
98
|
+
format: EventPorts['format'],
|
|
99
|
+
formatEl: HTMLElement | null,
|
|
100
|
+
edge: 'front' | 'end',
|
|
101
|
+
): HTMLElement | null;
|
|
102
|
+
/**
|
|
103
|
+
* @description The nested list a list-cell Backspace/Delete would lift, or `null` when there is none.
|
|
104
|
+
* - The rules gate their list branch on it so the branch can't claim the key with nothing to do.
|
|
105
|
+
* @param {HTMLElement} formatEl - The caret's list cell
|
|
106
|
+
* @param {HTMLElement} rangeEl - The list (`UL`/`OL`) the cell belongs to
|
|
107
|
+
* @returns {?HTMLElement} The element carrying the nested list, or `null`
|
|
108
|
+
*/
|
|
109
|
+
export function getNestedListTarget(formatEl: HTMLElement, rangeEl: HTMLElement): HTMLElement | null;
|
|
@@ -12,9 +12,8 @@ declare class BlockHandle {
|
|
|
12
12
|
* @param {HTMLElement} blockHandle - Handle group (.se-block-handle)
|
|
13
13
|
* @param {HTMLElement} blockHandlePlus - Plus button
|
|
14
14
|
* @param {HTMLElement} blockHandleDrag - Drag button
|
|
15
|
-
* @param {Array
|
|
16
|
-
*
|
|
17
|
-
* define a custom row whose `action` is invoked with the Deps bag and the current block element.
|
|
15
|
+
* @param {Object|Array<*>|null} blockHandleOptions - The `blockHandle` option object (`{ menu, onPlusClick, maxHeight, minWidth }`).
|
|
16
|
+
* - An array is accepted as a shorthand for `{ menu: [...] }`.
|
|
18
17
|
*/
|
|
19
18
|
constructor(
|
|
20
19
|
$: SunEditor.Deps,
|
|
@@ -22,19 +21,7 @@ declare class BlockHandle {
|
|
|
22
21
|
blockHandle: HTMLElement,
|
|
23
22
|
blockHandlePlus: HTMLElement,
|
|
24
23
|
blockHandleDrag: HTMLElement,
|
|
25
|
-
|
|
26
|
-
| string
|
|
27
|
-
| {
|
|
28
|
-
title: string;
|
|
29
|
-
icon?: string;
|
|
30
|
-
action: (
|
|
31
|
-
arg0: SunEditor.Deps,
|
|
32
|
-
arg1: {
|
|
33
|
-
block: HTMLElement;
|
|
34
|
-
},
|
|
35
|
-
) => void;
|
|
36
|
-
}
|
|
37
|
-
> | null,
|
|
24
|
+
blockHandleOptions: any | Array<any> | null,
|
|
38
25
|
);
|
|
39
26
|
/**
|
|
40
27
|
* @description Position the block handle for the given mouse target. Uses rAF throttle.
|
|
@@ -15,11 +15,6 @@ declare class UIManager {
|
|
|
15
15
|
toastPopup: HTMLElement;
|
|
16
16
|
toastContainer: Element;
|
|
17
17
|
toastMessage: HTMLSpanElement;
|
|
18
|
-
/**
|
|
19
|
-
* @description Whether `SelectMenu` is open
|
|
20
|
-
* @type {boolean}
|
|
21
|
-
*/
|
|
22
|
-
selectMenuOn: boolean;
|
|
23
18
|
/**
|
|
24
19
|
* @description Currently open `Controller` info array
|
|
25
20
|
* @type {Array<SunEditor.Module.Controller.Info>}
|
|
@@ -36,6 +31,20 @@ declare class UIManager {
|
|
|
36
31
|
* @type {?HTMLElement}
|
|
37
32
|
*/
|
|
38
33
|
_figureContainer: HTMLElement | null;
|
|
34
|
+
/**
|
|
35
|
+
* @description Whether any `SelectMenu` is currently open.
|
|
36
|
+
* - Read-only: a menu announces itself through {@link setSelectMenuOpen}. Derived from the set of
|
|
37
|
+
* open instances so an unrelated menu closing cannot clear the flag for a menu that is still open.
|
|
38
|
+
* @returns {boolean}
|
|
39
|
+
*/
|
|
40
|
+
get selectMenuOn(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* @internal
|
|
43
|
+
* @description `SelectMenu` open-state notification. Called by `SelectMenu.open()` / `.close()`.
|
|
44
|
+
* @param {*} instance The `SelectMenu` instance changing state
|
|
45
|
+
* @param {boolean} open `true` on open, `false` on close
|
|
46
|
+
*/
|
|
47
|
+
setSelectMenuOpen(instance: any, open: boolean): void;
|
|
39
48
|
/**
|
|
40
49
|
* @description Set editor frame styles.
|
|
41
50
|
* - Define the style of the edit area
|
|
@@ -28,6 +28,7 @@ export namespace DEFAULTS {
|
|
|
28
28
|
'@text': string;
|
|
29
29
|
'@line': string;
|
|
30
30
|
'@component': string;
|
|
31
|
+
li: string;
|
|
31
32
|
'table|th|td': string;
|
|
32
33
|
'table|td': string;
|
|
33
34
|
tr: string;
|
|
@@ -270,9 +271,25 @@ export namespace DEFAULTS {
|
|
|
270
271
|
* menu: [
|
|
271
272
|
* 'p', 'heading', 'blockStyle',
|
|
272
273
|
* { title: 'Duplicate', icon: 'copy', action: ($, { block }) => block.after(block.cloneNode(true)) },
|
|
274
|
+
* // `'table'` as a string opens the size picker; a custom item inserts a default table directly
|
|
275
|
+
* { title: 'Table', icon: 'table', action: ($) => $.plugins.table.insert(3, 3) },
|
|
273
276
|
* ],
|
|
274
277
|
* }
|
|
275
278
|
* ```
|
|
279
|
+
* @property {string} [blockHandle.maxHeight=""] - Max height of the menu list. Any CSS length; the list scrolls past it.
|
|
280
|
+
* - Unset by default: the menu grows with its items and is only clamped when it would overflow the viewport.
|
|
281
|
+
* @property {string} [blockHandle.minWidth="200px"] - Min width of the menu.
|
|
282
|
+
* @property {function(SunEditor.Deps, { block: HTMLElement, openMenu: function(): void }): void} [blockHandle.onPlusClick] - Runs after the plus button inserted a new line.
|
|
283
|
+
* - Adding the line is fixed behavior; this hook decides what happens next. Nothing does by default.
|
|
284
|
+
* - `block` is the new line, already focused. `openMenu()` opens the block handle's own `menu`.
|
|
285
|
+
* ```js
|
|
286
|
+
* blockHandle: {
|
|
287
|
+
* // open the block handle menu
|
|
288
|
+
* onPlusClick: ($, { openMenu }) => openMenu(),
|
|
289
|
+
* // ...or the slash command menu
|
|
290
|
+
* onPlusClick: ($, { block }) => $.plugins.slashCommand.open(block),
|
|
291
|
+
* }
|
|
292
|
+
* ```
|
|
276
293
|
* @property {string} [type=""] - Editor type. Use `"document"` for a document-style layout, with optional sub-types after `:`.
|
|
277
294
|
* ```js
|
|
278
295
|
* // type
|
|
@@ -384,7 +401,7 @@ export namespace DEFAULTS {
|
|
|
384
401
|
* - Value is a pipe-delimited list of allowed style names.
|
|
385
402
|
* - Resolution order when filtering an element: `@component` (for `.se-component` containers) → explicit tag entry → `@line` (for formatLine elements) → `@text` (for textStyleTags).
|
|
386
403
|
* - `@component` guards the inline sizing (`width`/`height`/`min-width`) the editor writes on a media component's container for percentage-based sizes; keep these so a clean() round-trip does not reset the component to full width.
|
|
387
|
-
* - An explicit tag entry **
|
|
404
|
+
* - An explicit tag entry is **merged** with its category default when the tag belongs to one (`@line` for formatLine elements, else `@text` for textStyleTags) — the entry adds styles on top of the category's.
|
|
388
405
|
* - Merged with {@link DEFAULTS.TAG_STYLES}; user-supplied keys win.
|
|
389
406
|
* ```js
|
|
390
407
|
* {
|
|
@@ -392,8 +409,8 @@ export namespace DEFAULTS {
|
|
|
392
409
|
* '@text': 'color|font-size|background-color', // default for span, b, i, em, ...
|
|
393
410
|
* '@line': 'text-align|margin|line-height', // default for p, h1-h6, div, li, ...
|
|
394
411
|
* 'table|td': 'border|color|background-color', // per-tag whitelist
|
|
395
|
-
*
|
|
396
|
-
*
|
|
412
|
+
* div: 'color', // merged with the `@line` default (div is a line element)
|
|
413
|
+
* hr: 'border-top',
|
|
397
414
|
* }
|
|
398
415
|
* }
|
|
399
416
|
* ```
|
|
@@ -1056,6 +1073,15 @@ export type EditorBaseOptions = {
|
|
|
1056
1073
|
) => void;
|
|
1057
1074
|
}
|
|
1058
1075
|
>;
|
|
1076
|
+
maxHeight?: string;
|
|
1077
|
+
minWidth?: string;
|
|
1078
|
+
onPlusClick?: (
|
|
1079
|
+
arg0: SunEditor.Deps,
|
|
1080
|
+
arg1: {
|
|
1081
|
+
block: HTMLElement;
|
|
1082
|
+
openMenu: () => void;
|
|
1083
|
+
},
|
|
1084
|
+
) => void;
|
|
1059
1085
|
};
|
|
1060
1086
|
/**
|
|
1061
1087
|
* - Editor type. Use `"document"` for a document-style layout, with optional sub-types after `:`.
|
|
@@ -1229,7 +1255,7 @@ export type EditorBaseOptions = {
|
|
|
1229
1255
|
* - Value is a pipe-delimited list of allowed style names.
|
|
1230
1256
|
* - Resolution order when filtering an element: `@component` (for `.se-component` containers) → explicit tag entry → `@line` (for formatLine elements) → `@text` (for textStyleTags).
|
|
1231
1257
|
* - `@component` guards the inline sizing (`width`/`height`/`min-width`) the editor writes on a media component's container for percentage-based sizes; keep these so a clean() round-trip does not reset the component to full width.
|
|
1232
|
-
* - An explicit tag entry **
|
|
1258
|
+
* - An explicit tag entry is **merged** with its category default when the tag belongs to one (`@line` for formatLine elements, else `@text` for textStyleTags) — the entry adds styles on top of the category's.
|
|
1233
1259
|
* - Merged with {@link DEFAULTS.TAG_STYLES}; user-supplied keys win.
|
|
1234
1260
|
* ```js
|
|
1235
1261
|
* {
|
|
@@ -1237,7 +1263,7 @@ export type EditorBaseOptions = {
|
|
|
1237
1263
|
* '@text': 'color|font-size|background-color', // default for span, b, i, em, ...
|
|
1238
1264
|
* '@line': 'text-align|margin|line-height', // default for p, h1-h6, div, li, ...
|
|
1239
1265
|
* 'table|td': 'border|color|background-color', // per-tag whitelist
|
|
1240
|
-
* div: 'color',
|
|
1266
|
+
* div: 'color', // merged with the `@line` default (div is a line element)
|
|
1241
1267
|
* hr: 'border-top',
|
|
1242
1268
|
* }
|
|
1243
1269
|
* }
|
package/types/events.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export type ClipboardEvent = {
|
|
|
35
35
|
*/
|
|
36
36
|
maxCharCount: boolean;
|
|
37
37
|
/**
|
|
38
|
-
* - `"SE"`|`"MS"`|`""` - source
|
|
38
|
+
* - `"SE"`|`"MS"`|`"GOOGLE"`|`""` - source
|
|
39
39
|
*/
|
|
40
40
|
from: string;
|
|
41
41
|
};
|
|
@@ -289,7 +289,7 @@ export type EventHandlers = {
|
|
|
289
289
|
* @property {Event} event - event object
|
|
290
290
|
* @property {string} data - drop data
|
|
291
291
|
* @property {boolean} maxCharCount - is max char count
|
|
292
|
-
* @property {string} from - `"SE"`|`"MS"`|`""` - source
|
|
292
|
+
* @property {string} from - `"SE"`|`"MS"`|`"GOOGLE"`|`""` - source
|
|
293
293
|
*/
|
|
294
294
|
/**
|
|
295
295
|
* @typedef {Object} FileManagementInfo
|
|
@@ -198,7 +198,8 @@ export function getEdgeChildNodes(
|
|
|
198
198
|
};
|
|
199
199
|
/**
|
|
200
200
|
* @template {Node} T
|
|
201
|
-
* @description Gets the previous sibling last child. If there is no sibling, then it'll take it from the closest ancestor with child
|
|
201
|
+
* @description Gets the previous sibling last child. If there is no sibling, then it'll take it from the closest ancestor with child.
|
|
202
|
+
* - Components (image, table, etc.) are treated as a single tag and not traversed into.
|
|
202
203
|
* @param {Node} node Reference element
|
|
203
204
|
* @param {?Node} [ceiling] Highest boundary allowed
|
|
204
205
|
* @returns {T|null} Not found: `null`
|
|
@@ -206,7 +207,8 @@ export function getEdgeChildNodes(
|
|
|
206
207
|
export function getPreviousDeepestNode<T extends Node>(node: Node, ceiling?: Node | null): T | null;
|
|
207
208
|
/**
|
|
208
209
|
* @template {Node} T
|
|
209
|
-
* @description Gets the next sibling first child. If there is no sibling, then it'll take it from the closest ancestor with child
|
|
210
|
+
* @description Gets the next sibling first child. If there is no sibling, then it'll take it from the closest ancestor with child.
|
|
211
|
+
* - Components (image, table, etc.) are treated as a single tag and not traversed into.
|
|
210
212
|
* @param {Node} node Reference element
|
|
211
213
|
* @param {?Node} [ceiling] Highest boundary allowed
|
|
212
214
|
* @returns {T|null} Not found: `null`
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type {} from '../typedef';
|
|
2
|
+
/**
|
|
3
|
+
* @description Whether the HTML string is a Google Docs clipboard payload.
|
|
4
|
+
* @param {string} html HTML string
|
|
5
|
+
* @returns {boolean}
|
|
6
|
+
*/
|
|
7
|
+
export function isGoogleDocs(html: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* @description Removes the Google Docs clipboard wrapper tags, keeping their children.
|
|
10
|
+
* - Only the guid-carrying inline wrappers (`b`/`span`) are unwrapped; real formatting tags inside are untouched.
|
|
11
|
+
* @param {string} html HTML string
|
|
12
|
+
* @returns {string} HTML string
|
|
13
|
+
*/
|
|
14
|
+
export function cleanHTML(html: string): string;
|
|
15
|
+
declare namespace _default {
|
|
16
|
+
export { isGoogleDocs };
|
|
17
|
+
export { cleanHTML };
|
|
18
|
+
}
|
|
19
|
+
export default _default;
|
package/types/helper/index.d.ts
CHANGED
|
@@ -178,6 +178,10 @@ export const markdown: {
|
|
|
178
178
|
export const msOffice: {
|
|
179
179
|
cleanHTML: typeof import('./msOffice').cleanHTML;
|
|
180
180
|
};
|
|
181
|
+
export const googleDocs: {
|
|
182
|
+
isGoogleDocs: typeof import('./googleDocs').isGoogleDocs;
|
|
183
|
+
cleanHTML: typeof import('./googleDocs').cleanHTML;
|
|
184
|
+
};
|
|
181
185
|
declare namespace _default {
|
|
182
186
|
export { env };
|
|
183
187
|
export { unicode };
|
|
@@ -188,5 +192,6 @@ declare namespace _default {
|
|
|
188
192
|
export { clipboard };
|
|
189
193
|
export { markdown };
|
|
190
194
|
export { msOffice };
|
|
195
|
+
export { googleDocs };
|
|
191
196
|
}
|
|
192
197
|
export default _default;
|
|
@@ -111,6 +111,13 @@ export type CommandMenuParams = {
|
|
|
111
111
|
icons: any;
|
|
112
112
|
},
|
|
113
113
|
) => string;
|
|
114
|
+
/**
|
|
115
|
+
* - Optional owner hook run once,
|
|
116
|
+
* - immediately before the user commits inside a dropdown-free flyout (SlashCommand uses it to delete the typed `/query`).
|
|
117
|
+
* - A native submenu gets this for free — its commit routes back through `SelectMenu`'s select callback —
|
|
118
|
+
* - but a flyout is the plugin's own DOM, so the moment has to be intercepted.
|
|
119
|
+
*/
|
|
120
|
+
prepareCommit?: () => void;
|
|
114
121
|
};
|
|
115
122
|
/**
|
|
116
123
|
* @typedef {Object} CommandMenuItem
|
|
@@ -148,6 +155,10 @@ export type CommandMenuParams = {
|
|
|
148
155
|
* @property {Object} selectMenuParams - Base SelectMenu params (`position`, `minWidth`, `keydownTarget`, etc.).
|
|
149
156
|
* @property {function(CommandMenuItem, { icons: Object }): string} [renderCustomItem] - Optional renderer
|
|
150
157
|
* applied to custom (object) items only. Plugin-string items always render with `buildRowHTML`.
|
|
158
|
+
* @property {function(): void} [prepareCommit] - Optional owner hook run once,
|
|
159
|
+
* - immediately before the user commits inside a dropdown-free flyout (SlashCommand uses it to delete the typed `/query`).
|
|
160
|
+
* - A native submenu gets this for free — its commit routes back through `SelectMenu`'s select callback —
|
|
161
|
+
* - but a flyout is the plugin's own DOM, so the moment has to be intercepted.
|
|
151
162
|
*/
|
|
152
163
|
/**
|
|
153
164
|
* @class
|
|
@@ -31,11 +31,15 @@ export type SelectMenuParams = {
|
|
|
31
31
|
*/
|
|
32
32
|
closeMethod?: () => void;
|
|
33
33
|
/**
|
|
34
|
-
* Optional owner hook
|
|
35
|
-
* Return `true`
|
|
36
|
-
* closes that sub-panel and keeps the menu open.
|
|
34
|
+
* Optional owner hook that dismisses an owner-managed sub-panel (e.g. CommandMenu's dropdown-free flyout) and puts the cursor back on its row.
|
|
35
|
+
* Return `true` when a sub-panel was actually dismissed.
|
|
37
36
|
*/
|
|
38
37
|
subEscMethod?: () => boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Optional owner hook answering "does the row at `index` own a sub-panel?".
|
|
40
|
+
* - A query only — it must not open anything.
|
|
41
|
+
*/
|
|
42
|
+
subCheckMethod?: (index: number) => boolean;
|
|
39
43
|
/**
|
|
40
44
|
* Optional max-height CSS value (e.g. `"200px"`). Enables scrolling when items exceed this height.
|
|
41
45
|
*/
|
|
@@ -66,9 +70,10 @@ export type SelectMenuParams = {
|
|
|
66
70
|
* @property {number} [splitNum=0] Optional split number for horizontal positioning; defines how many items per row
|
|
67
71
|
* @property {() => void} [openMethod] Optional method to call when the menu is opened
|
|
68
72
|
* @property {() => void} [closeMethod] Optional method to call when the menu is closed
|
|
69
|
-
* @property {() => boolean} [subEscMethod] Optional owner hook
|
|
70
|
-
* Return `true`
|
|
71
|
-
*
|
|
73
|
+
* @property {() => boolean} [subEscMethod] Optional owner hook that dismisses an owner-managed sub-panel (e.g. CommandMenu's dropdown-free flyout) and puts the cursor back on its row.
|
|
74
|
+
* Return `true` when a sub-panel was actually dismissed.
|
|
75
|
+
* @property {(index: number) => boolean} [subCheckMethod] Optional owner hook answering "does the row at `index` own a sub-panel?".
|
|
76
|
+
* - A query only — it must not open anything.
|
|
72
77
|
* @property {string} [maxHeight] Optional max-height CSS value (e.g. `"200px"`). Enables scrolling when items exceed this height.
|
|
73
78
|
* @property {string} [minWidth] Optional min-width CSS value (e.g. `"130px"`).
|
|
74
79
|
* @property {*} [keydownTarget] Optional override for the keyboard navigation target. By default `on()` listens
|
|
@@ -104,6 +109,7 @@ declare class SelectMenu {
|
|
|
104
109
|
openMethod: () => void;
|
|
105
110
|
closeMethod: () => void;
|
|
106
111
|
subEscMethod: () => boolean;
|
|
112
|
+
subCheckMethod: (index: number) => boolean;
|
|
107
113
|
maxHeight: string;
|
|
108
114
|
minWidth: string;
|
|
109
115
|
/**
|
|
@@ -193,6 +199,6 @@ declare class SelectMenu {
|
|
|
193
199
|
* @returns {boolean}
|
|
194
200
|
*/
|
|
195
201
|
hasOpenSubmenu(): boolean;
|
|
196
|
-
_onItem:
|
|
202
|
+
_onItem: any;
|
|
197
203
|
#private;
|
|
198
204
|
}
|
|
@@ -153,6 +153,17 @@ declare class Table extends PluginDropdownFree {
|
|
|
153
153
|
* @description Closes table-related controllers and table figure
|
|
154
154
|
*/
|
|
155
155
|
_closeTableSelectInfo(): void;
|
|
156
|
+
/**
|
|
157
|
+
* @description Insert a table of the given size at the caret and place the caret in its first cell.
|
|
158
|
+
* @param {number} [cols=3] - Column count
|
|
159
|
+
* @param {number} [rows=3] - Row count
|
|
160
|
+
* @returns {boolean} `true` when the table was inserted
|
|
161
|
+
* @example
|
|
162
|
+
* // insert a 3x3 table without going through the size picker
|
|
163
|
+
* editor.plugins.table.insert();
|
|
164
|
+
* editor.plugins.table.insert(4, 2);
|
|
165
|
+
*/
|
|
166
|
+
insert(cols?: number, rows?: number): boolean;
|
|
156
167
|
#private;
|
|
157
168
|
}
|
|
158
169
|
import { PluginDropdownFree } from '../../../interfaces';
|
|
@@ -2,6 +2,7 @@ import type {} from '../../../../typedef';
|
|
|
2
2
|
export const ROW_SELECT_MARGIN: 6;
|
|
3
3
|
export const CELL_SELECT_MARGIN: 6;
|
|
4
4
|
export const CELL_DECIMAL_END: 0;
|
|
5
|
+
export const DEFAULT_SIZE: number[];
|
|
5
6
|
export const RESIZE_CELL_CLASS: '.se-table-resize-line';
|
|
6
7
|
export const RESIZE_CELL_PREV_CLASS: '.se-table-resize-line-prev';
|
|
7
8
|
export const RESIZE_ROW_CLASS: '.se-table-resize-row';
|
|
@@ -54,9 +54,18 @@ export type SlashCommandPluginOptions = {
|
|
|
54
54
|
*/
|
|
55
55
|
delayTime?: number;
|
|
56
56
|
/**
|
|
57
|
-
* - Maximum number of items
|
|
57
|
+
* - Maximum number of items kept after filtering. `0` (default) keeps every match
|
|
58
|
+
* - the list scrolls within `maxHeight`, so a cap only hides matches the user can no longer reach.
|
|
58
59
|
*/
|
|
59
60
|
limitSize?: number;
|
|
61
|
+
/**
|
|
62
|
+
* - Max height of the menu list. Any CSS length; the list scrolls past it.
|
|
63
|
+
*/
|
|
64
|
+
maxHeight?: string;
|
|
65
|
+
/**
|
|
66
|
+
* - Min width of the menu.
|
|
67
|
+
*/
|
|
68
|
+
minWidth?: string;
|
|
60
69
|
/**
|
|
61
70
|
* - Message shown when no items match the query. If unset, the menu closes on no match.
|
|
62
71
|
*/
|
|
@@ -93,6 +102,15 @@ export type SlashCommandPluginOptions = {
|
|
|
93
102
|
* // A container block (BLOCKQUOTE, DIV…): `applyBlock` WRAPS the selected lines → `<blockquote>…</blockquote>`.
|
|
94
103
|
* action: ($) => $.format.applyBlock(document.createElement('BLOCKQUOTE')),
|
|
95
104
|
* },
|
|
105
|
+
* {
|
|
106
|
+
* key: 'table',
|
|
107
|
+
* title: 'Table',
|
|
108
|
+
* icon: 'table',
|
|
109
|
+
* // A plugin-name entry (`'table'`) opens that plugin's own UI — for table, the size picker,
|
|
110
|
+
* // which is driven by the pointer. A custom item skips it and inserts straight away, which
|
|
111
|
+
* // keeps the whole gesture on the keyboard: type the trigger, press Enter, done.
|
|
112
|
+
* action: ($) => $.plugins.table.insert(3, 3),
|
|
113
|
+
* },
|
|
96
114
|
* 'bold',
|
|
97
115
|
* 'image',
|
|
98
116
|
* 'blockStyle',
|
|
@@ -131,7 +149,10 @@ export type SlashCommandPluginOptions = {
|
|
|
131
149
|
* (plugin names, built-in commands like `'bold'`); objects are custom items with their own `action`.
|
|
132
150
|
* Required.
|
|
133
151
|
* @property {number} [delayTime=120] - Debounce delay (ms) before the input is inspected for the trigger.
|
|
134
|
-
* @property {number} [limitSize=
|
|
152
|
+
* @property {number} [limitSize=0] - Maximum number of items kept after filtering. `0` (default) keeps every match
|
|
153
|
+
* - the list scrolls within `maxHeight`, so a cap only hides matches the user can no longer reach.
|
|
154
|
+
* @property {string} [maxHeight='320px'] - Max height of the menu list. Any CSS length; the list scrolls past it.
|
|
155
|
+
* @property {string} [minWidth='200px'] - Min width of the menu.
|
|
135
156
|
* @property {string} [emptyMessage] - Message shown when no items match the query. If unset, the menu closes on no match.
|
|
136
157
|
* @property {function(SlashCommandItem, { icons: Object }): string} [renderItem] - Custom item HTML renderer.
|
|
137
158
|
* Applied only to custom item objects; plugin-name entries always render with the canonical BlockHandle row.
|
|
@@ -164,6 +185,15 @@ export type SlashCommandPluginOptions = {
|
|
|
164
185
|
* // A container block (BLOCKQUOTE, DIV…): `applyBlock` WRAPS the selected lines → `<blockquote>…</blockquote>`.
|
|
165
186
|
* action: ($) => $.format.applyBlock(document.createElement('BLOCKQUOTE')),
|
|
166
187
|
* },
|
|
188
|
+
* {
|
|
189
|
+
* key: 'table',
|
|
190
|
+
* title: 'Table',
|
|
191
|
+
* icon: 'table',
|
|
192
|
+
* // A plugin-name entry (`'table'`) opens that plugin's own UI — for table, the size picker,
|
|
193
|
+
* // which is driven by the pointer. A custom item skips it and inserts straight away, which
|
|
194
|
+
* // keeps the whole gesture on the keyboard: type the trigger, press Enter, done.
|
|
195
|
+
* action: ($) => $.plugins.table.insert(3, 3),
|
|
196
|
+
* },
|
|
167
197
|
* 'bold',
|
|
168
198
|
* 'image',
|
|
169
199
|
* 'blockStyle',
|
|
@@ -191,6 +221,17 @@ declare class SlashCommand extends PluginField {
|
|
|
191
221
|
controller: Controller;
|
|
192
222
|
onInput(params: SunEditor.HookParams.InputWithData): void;
|
|
193
223
|
onKeyDown(params: SunEditor.HookParams.KeyEvent): void | boolean;
|
|
224
|
+
/**
|
|
225
|
+
* @description Open the command menu programmatically, with no trigger character typed and the full tem list shown.
|
|
226
|
+
* - Intended for host UI that wants the same menu without the `/` shortcut — e.g. the
|
|
227
|
+
* - block handle's plus button:
|
|
228
|
+
* ```js
|
|
229
|
+
* blockHandle: { onPlusClick: ($, { block }) => $.plugins.slashCommand.open(block) }
|
|
230
|
+
* ```
|
|
231
|
+
* @param {Node} anchorNode - Node the menu anchors to (typically the line the caret sits on).
|
|
232
|
+
* @returns {boolean} `true` if the menu was opened
|
|
233
|
+
*/
|
|
234
|
+
open(anchorNode: Node): boolean;
|
|
194
235
|
#private;
|
|
195
236
|
}
|
|
196
237
|
import { PluginField } from '../../interfaces';
|