suneditor 3.2.6 → 3.3.1
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-contents.min.css +1 -1
- package/dist/suneditor.min.css +3 -3
- package/dist/suneditor.min.js +1 -1
- package/package.json +4 -4
- package/src/assets/design/color.css +5 -2
- package/src/assets/design/size.css +6 -2
- package/src/assets/icons/defaultIcons.js +195 -162
- package/src/assets/suneditor.css +5101 -5105
- package/src/core/config/eventManager.js +24 -1
- package/src/core/config/optionProvider.js +5 -4
- package/src/core/event/actions/index.js +8 -4
- package/src/core/event/effects/keydown.registry.js +59 -10
- package/src/core/event/ports.js +2 -0
- package/src/core/event/rules/keydown.rule.backspace.js +52 -1
- package/src/core/event/rules/keydown.rule.delete.js +51 -0
- package/src/core/logic/dom/format.js +1 -1
- package/src/core/logic/dom/html.js +31 -0
- package/src/core/logic/panel/blockHandle.js +61 -24
- package/src/core/logic/panel/blockResolver.js +41 -4
- package/src/core/logic/panel/finder.js +3 -0
- package/src/core/logic/panel/menu.js +38 -1
- package/src/core/logic/panel/toolbar.js +1 -0
- package/src/core/logic/shell/_commandExecutor.js +2 -1
- package/src/core/logic/shell/pluginManager.js +15 -2
- package/src/core/logic/shell/ui.js +73 -32
- package/src/core/schema/frameContext.js +1 -1
- package/src/core/schema/options.js +49 -3
- package/src/core/section/constructor.js +17 -9
- package/src/modules/contract/Controller.js +14 -0
- package/src/modules/contract/Figure.js +5 -2
- package/src/modules/ui/CommandMenu.js +53 -14
- package/src/modules/ui/SelectMenu.js +103 -36
- package/src/plugins/dropdown/table/index.js +25 -8
- package/src/plugins/dropdown/table/services/table.cell.js +4 -7
- package/src/plugins/dropdown/table/shared/table.constants.js +2 -0
- package/src/plugins/field/slashCommand.js +59 -12
- package/types/assets/icons/defaultIcons.d.ts +1 -0
- package/types/core/event/actions/index.d.ts +1 -0
- package/types/core/event/effects/keydown.registry.d.ts +4 -0
- package/types/core/event/ports.d.ts +3 -0
- package/types/core/logic/panel/blockHandle.d.ts +3 -16
- package/types/core/logic/panel/menu.d.ts +8 -0
- package/types/core/logic/shell/ui.d.ts +31 -5
- package/types/core/schema/frameContext.d.ts +6 -2
- package/types/core/schema/options.d.ts +95 -4
- 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
|
@@ -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.
|
|
@@ -118,6 +118,14 @@ declare class Menu {
|
|
|
118
118
|
* @description Closes the currently open dropdown menu.
|
|
119
119
|
*/
|
|
120
120
|
dropdownOff(): void;
|
|
121
|
+
/**
|
|
122
|
+
* @description Subscribe to be notified after a dropdown is turned off — i.e. a dropdown-free
|
|
123
|
+
* plugin committed and closed itself via {@link dropdownOff}. Mirrors {@link Store#subscribe}:
|
|
124
|
+
* returns an unsubscribe function.
|
|
125
|
+
* @param {() => void} callback
|
|
126
|
+
* @returns {() => void} Unsubscribe function
|
|
127
|
+
*/
|
|
128
|
+
subscribeDropdownOff(callback: () => void): () => void;
|
|
121
129
|
/**
|
|
122
130
|
* @description Shows a previously hidden dropdown menu that is still in `on` state.
|
|
123
131
|
* - Only works when a dropdown is active (`currentButton` exists)
|
|
@@ -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
|
|
@@ -231,6 +240,23 @@ declare class UIManager {
|
|
|
231
240
|
* @param {SunEditor.FrameContext} [fc] - Frame context (defaults to current frameContext)
|
|
232
241
|
*/
|
|
233
242
|
_updatePlaceholder(fc?: SunEditor.FrameContext): void;
|
|
243
|
+
/**
|
|
244
|
+
* @description Resolves the per-line placeholder text for an empty line from the `placeholder_line` option.
|
|
245
|
+
* - String option: one hint for every empty line — except list cells and table cells (backward compatible).
|
|
246
|
+
* - Object option: keyed by tag name or a category sentinel matching the editor's format classification
|
|
247
|
+
* ({@link Format#isNormalLine}, `isBrLine`, `isClosureBrLine`, `isBlock`, `isClosureBlock`, list cells).
|
|
248
|
+
* @param {?Node} line - The (empty) line element.
|
|
249
|
+
* @param {string|Object<string, string>} opt - The `placeholder_line` option value.
|
|
250
|
+
* @returns {string} The resolved placeholder text (`''` = none).
|
|
251
|
+
*/
|
|
252
|
+
resolveLinePlaceholder(
|
|
253
|
+
line: Node | null,
|
|
254
|
+
opt:
|
|
255
|
+
| string
|
|
256
|
+
| {
|
|
257
|
+
[x: string]: string;
|
|
258
|
+
},
|
|
259
|
+
): string;
|
|
234
260
|
/**
|
|
235
261
|
* @internal
|
|
236
262
|
* @description Synchronizes frame UI state after content changes.
|
|
@@ -33,7 +33,7 @@ import type {} from '../../typedef';
|
|
|
33
33
|
* @property {HTMLTextAreaElement} markdown - Markdown view editing element (a <textarea>).
|
|
34
34
|
* @property {HTMLTextAreaElement} markdownNumbers - Element displaying line numbers in markdown view mode.
|
|
35
35
|
* @property {HTMLElement} placeholder - Placeholder element shown when the editor is empty.
|
|
36
|
-
* @property {string} placeholder_line - Per-line placeholder text, rendered via a `::before` on the focused empty line.
|
|
36
|
+
* @property {string|Object<string, string>} placeholder_line - Per-line placeholder text, rendered via a `::before` on the focused empty line.
|
|
37
37
|
* @property {HTMLElement} statusbar - Editor status bar element (for resizing, info, etc.).
|
|
38
38
|
* @property {HTMLElement} navigation - Navigation element (e.g., for outline or bookmarks).
|
|
39
39
|
* @property {HTMLElement} charWrapper - Wrapper for the character counter element.
|
|
@@ -216,7 +216,11 @@ export type FrameContextStore = {
|
|
|
216
216
|
/**
|
|
217
217
|
* - Per-line placeholder text, rendered via a `::before` on the focused empty line.
|
|
218
218
|
*/
|
|
219
|
-
placeholder_line:
|
|
219
|
+
placeholder_line:
|
|
220
|
+
| string
|
|
221
|
+
| {
|
|
222
|
+
[x: string]: string;
|
|
223
|
+
};
|
|
220
224
|
/**
|
|
221
225
|
* - Editor status bar element (for resizing, info, etc.).
|
|
222
226
|
*/
|
|
@@ -56,8 +56,22 @@ export namespace DEFAULTS {
|
|
|
56
56
|
* === Content & Editing ===
|
|
57
57
|
* @property {string} [value=""] - Initial value for the editor.
|
|
58
58
|
* @property {string} [placeholder=""] - Placeholder text shown when the whole editor is empty.
|
|
59
|
-
* @property {string} [placeholder_line=""] - per-line placeholder shown on the focused
|
|
59
|
+
* @property {string|Object<string, string>} [placeholder_line=""] - per-line placeholder shown on the focused
|
|
60
60
|
* line when that line is empty. Takes priority over `placeholder` while a line is focused.
|
|
61
|
+
* - **string**: one hint for every empty line (list cells and table cells excluded).
|
|
62
|
+
* - **object**: per-type hints keyed by tag name (`p`, `pre`, `blockquote`, ...) or a category sentinel
|
|
63
|
+
* matching the editor's format classification: `@line`, `@normalLine`, `@list`, `@brLine`, `@closureBrLine`,
|
|
64
|
+
* `@block`, `@closureBlock`. Resolved most-specific → least, like `tagStyles`:
|
|
65
|
+
* `<tag>` → `@list` → `@closureBrLine` → `@brLine` → block container (`<blockTag>` → `@closureBlock` → `@block`)
|
|
66
|
+
* → `@normalLine` → `@line`. A missing key = no placeholder for that type; an explicit `''` suppresses it.
|
|
67
|
+
* ```js
|
|
68
|
+
* // one hint everywhere
|
|
69
|
+
* placeholder_line: 'Type something…'
|
|
70
|
+
* // per-type
|
|
71
|
+
* placeholder_line: {
|
|
72
|
+
* '@normalLine': 'Type…', '@list': 'List item', '@block': 'Quote…', '@closureBlock': 'Cell', pre: '// code'
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
61
75
|
* @property {Object<string, string>} [editableFrameAttributes={spellcheck: "false"}] - Attributes for the editable frame[.sun-editor-editable].
|
|
62
76
|
* ```js
|
|
63
77
|
* { editableFrameAttributes: { spellcheck: 'true', autocomplete: 'on' } }
|
|
@@ -256,9 +270,25 @@ export namespace DEFAULTS {
|
|
|
256
270
|
* menu: [
|
|
257
271
|
* 'p', 'heading', 'blockStyle',
|
|
258
272
|
* { title: 'Duplicate', icon: 'copy', action: ($, { block }) => block.after(block.cloneNode(true)) },
|
|
273
|
+
* // `'table'` as a string opens the size picker; a custom item inserts a default table directly
|
|
274
|
+
* { title: 'Table', icon: 'table', action: ($) => $.plugins.table.insert(3, 3) },
|
|
259
275
|
* ],
|
|
260
276
|
* }
|
|
261
277
|
* ```
|
|
278
|
+
* @property {string} [blockHandle.maxHeight=""] - Max height of the menu list. Any CSS length; the list scrolls past it.
|
|
279
|
+
* - Unset by default: the menu grows with its items and is only clamped when it would overflow the viewport.
|
|
280
|
+
* @property {string} [blockHandle.minWidth="200px"] - Min width of the menu.
|
|
281
|
+
* @property {function(SunEditor.Deps, { block: HTMLElement, openMenu: function(): void }): void} [blockHandle.onPlusClick] - Runs after the plus button inserted a new line.
|
|
282
|
+
* - Adding the line is fixed behavior; this hook decides what happens next. Nothing does by default.
|
|
283
|
+
* - `block` is the new line, already focused. `openMenu()` opens the block handle's own `menu`.
|
|
284
|
+
* ```js
|
|
285
|
+
* blockHandle: {
|
|
286
|
+
* // open the block handle menu
|
|
287
|
+
* onPlusClick: ($, { openMenu }) => openMenu(),
|
|
288
|
+
* // ...or the slash command menu
|
|
289
|
+
* onPlusClick: ($, { block }) => $.plugins.slashCommand.open(block),
|
|
290
|
+
* }
|
|
291
|
+
* ```
|
|
262
292
|
* @property {string} [type=""] - Editor type. Use `"document"` for a document-style layout, with optional sub-types after `:`.
|
|
263
293
|
* ```js
|
|
264
294
|
* // type
|
|
@@ -403,6 +433,13 @@ export namespace DEFAULTS {
|
|
|
403
433
|
* - Formats that include `line`, such as "Quote", still operate on a `line` basis.
|
|
404
434
|
* - suneditor processes work in `line` units.
|
|
405
435
|
* - When set to `br`, performance may decrease when editing a lot of data.
|
|
436
|
+
* @property {boolean} [lineBreakClearStyle=false] - When `true`, pressing Enter at the **end** of a line
|
|
437
|
+
* starts a fresh line that does not carry the caret's inline style nodes (e.g. bold/italic/color spans, links);
|
|
438
|
+
* the line-level element and its attributes are preserved.
|
|
439
|
+
* Only affects the end-of-line case — mid-line splits, start-of-line breaks, and Shift+Enter are unchanged.
|
|
440
|
+
* ```js
|
|
441
|
+
* { lineBreakClearStyle: true }
|
|
442
|
+
* ```
|
|
406
443
|
* @property {string} [lineAttrReset=""] - Line properties that should be reset when changing lines. Delimiter: `"|"`.
|
|
407
444
|
* ```js
|
|
408
445
|
* { lineAttrReset: 'id|name' }
|
|
@@ -453,12 +490,16 @@ export namespace DEFAULTS {
|
|
|
453
490
|
* { toolbar_innerWidth: 'auto' }
|
|
454
491
|
* ```
|
|
455
492
|
* @property {?HTMLElement} [toolbar_container] - Container element for the toolbar.
|
|
456
|
-
* @property {number|{top: number, offset
|
|
493
|
+
* @property {number|{top: number, offset?: number, position?: "sticky"|"fixed"}} [toolbar_sticky=0] - Enables sticky toolbar.
|
|
457
494
|
* - `number`: Sets the sticky top position (px). Use `-1` to disable sticky.
|
|
458
495
|
* - `{top, offset}`: `top` is the sticky position when the page header is visible.
|
|
459
496
|
* - `offset` is the sticky position when a virtual keyboard shifts the viewport (e.g., on tablets, touch devices).
|
|
460
497
|
* - When the virtual keyboard is active, `offset` replaces `top` so the toolbar doesn't leave a gap
|
|
461
498
|
* - for a page header that has scrolled out of view. Default `offset` is `0`.
|
|
499
|
+
* - `position` (default `"sticky"`): the positioning engine.
|
|
500
|
+
* - `"sticky"` uses native CSS `position: sticky` (with a JS `position: fixed` fallback where unsupported).
|
|
501
|
+
* `"fixed"` forces the JS `position: fixed` engine
|
|
502
|
+
* - even when CSS sticky is supported — for environments where CSS sticky silently misbehaves and can't be
|
|
462
503
|
* ```js
|
|
463
504
|
* // Basic usage — sticky at top with 0px offset
|
|
464
505
|
* toolbar_sticky: 0
|
|
@@ -468,6 +509,9 @@ export namespace DEFAULTS {
|
|
|
468
509
|
*
|
|
469
510
|
* // 92px header on desktop, but 0px when virtual keyboard pushes the viewport
|
|
470
511
|
* toolbar_sticky: { top: 92, offset: 0 }
|
|
512
|
+
*
|
|
513
|
+
* // Force the JS position:fixed engine (CSS sticky unreliable in this environment)
|
|
514
|
+
* toolbar_sticky: { top: 0, position: 'fixed' }
|
|
471
515
|
* ```
|
|
472
516
|
* @property {boolean} [toolbar_hide=false] - Hides toolbar initially.
|
|
473
517
|
* @property {Object} [subToolbar={}] - Sub-toolbar configuration. A secondary toolbar that appears on text selection.
|
|
@@ -669,8 +713,26 @@ export type EditorFrameOptions = {
|
|
|
669
713
|
/**
|
|
670
714
|
* - per-line placeholder shown on the focused
|
|
671
715
|
* line when that line is empty. Takes priority over `placeholder` while a line is focused.
|
|
716
|
+
* - **string**: one hint for every empty line (list cells and table cells excluded).
|
|
717
|
+
* - **object**: per-type hints keyed by tag name (`p`, `pre`, `blockquote`, ...) or a category sentinel
|
|
718
|
+
* matching the editor's format classification: `@line`, `@normalLine`, `@list`, `@brLine`, `@closureBrLine`,
|
|
719
|
+
* `@block`, `@closureBlock`. Resolved most-specific → least, like `tagStyles`:
|
|
720
|
+
* `<tag>` → `@list` → `@closureBrLine` → `@brLine` → block container (`<blockTag>` → `@closureBlock` → `@block`)
|
|
721
|
+
* → `@normalLine` → `@line`. A missing key = no placeholder for that type; an explicit `''` suppresses it.
|
|
722
|
+
* ```js
|
|
723
|
+
* // one hint everywhere
|
|
724
|
+
* placeholder_line: 'Type something…'
|
|
725
|
+
* // per-type
|
|
726
|
+
* placeholder_line: {
|
|
727
|
+
* '@normalLine': 'Type…', '@list': 'List item', '@block': 'Quote…', '@closureBlock': 'Cell', pre: '// code'
|
|
728
|
+
* }
|
|
729
|
+
* ```
|
|
672
730
|
*/
|
|
673
|
-
placeholder_line?:
|
|
731
|
+
placeholder_line?:
|
|
732
|
+
| string
|
|
733
|
+
| {
|
|
734
|
+
[x: string]: string;
|
|
735
|
+
};
|
|
674
736
|
/**
|
|
675
737
|
* - Attributes for the editable frame[.sun-editor-editable].
|
|
676
738
|
* ```js
|
|
@@ -1010,6 +1072,15 @@ export type EditorBaseOptions = {
|
|
|
1010
1072
|
) => void;
|
|
1011
1073
|
}
|
|
1012
1074
|
>;
|
|
1075
|
+
maxHeight?: string;
|
|
1076
|
+
minWidth?: string;
|
|
1077
|
+
onPlusClick?: (
|
|
1078
|
+
arg0: SunEditor.Deps,
|
|
1079
|
+
arg1: {
|
|
1080
|
+
block: HTMLElement;
|
|
1081
|
+
openMenu: () => void;
|
|
1082
|
+
},
|
|
1083
|
+
) => void;
|
|
1013
1084
|
};
|
|
1014
1085
|
/**
|
|
1015
1086
|
* - Editor type. Use `"document"` for a document-style layout, with optional sub-types after `:`.
|
|
@@ -1232,6 +1303,16 @@ export type EditorBaseOptions = {
|
|
|
1232
1303
|
* - When set to `br`, performance may decrease when editing a lot of data.
|
|
1233
1304
|
*/
|
|
1234
1305
|
defaultLineBreakFormat?: 'line' | 'br';
|
|
1306
|
+
/**
|
|
1307
|
+
* - When `true`, pressing Enter at the **end** of a line
|
|
1308
|
+
* starts a fresh line that does not carry the caret's inline style nodes (e.g. bold/italic/color spans, links);
|
|
1309
|
+
* the line-level element and its attributes are preserved.
|
|
1310
|
+
* Only affects the end-of-line case — mid-line splits, start-of-line breaks, and Shift+Enter are unchanged.
|
|
1311
|
+
* ```js
|
|
1312
|
+
* { lineBreakClearStyle: true }
|
|
1313
|
+
* ```
|
|
1314
|
+
*/
|
|
1315
|
+
lineBreakClearStyle?: boolean;
|
|
1235
1316
|
/**
|
|
1236
1317
|
* - Line properties that should be reset when changing lines. Delimiter: `"|"`.
|
|
1237
1318
|
* ```js
|
|
@@ -1325,6 +1406,10 @@ export type EditorBaseOptions = {
|
|
|
1325
1406
|
* - `offset` is the sticky position when a virtual keyboard shifts the viewport (e.g., on tablets, touch devices).
|
|
1326
1407
|
* - When the virtual keyboard is active, `offset` replaces `top` so the toolbar doesn't leave a gap
|
|
1327
1408
|
* - for a page header that has scrolled out of view. Default `offset` is `0`.
|
|
1409
|
+
* - `position` (default `"sticky"`): the positioning engine.
|
|
1410
|
+
* - `"sticky"` uses native CSS `position: sticky` (with a JS `position: fixed` fallback where unsupported).
|
|
1411
|
+
* `"fixed"` forces the JS `position: fixed` engine
|
|
1412
|
+
* - even when CSS sticky is supported — for environments where CSS sticky silently misbehaves and can't be
|
|
1328
1413
|
* ```js
|
|
1329
1414
|
* // Basic usage — sticky at top with 0px offset
|
|
1330
1415
|
* toolbar_sticky: 0
|
|
@@ -1334,13 +1419,17 @@ export type EditorBaseOptions = {
|
|
|
1334
1419
|
*
|
|
1335
1420
|
* // 92px header on desktop, but 0px when virtual keyboard pushes the viewport
|
|
1336
1421
|
* toolbar_sticky: { top: 92, offset: 0 }
|
|
1422
|
+
*
|
|
1423
|
+
* // Force the JS position:fixed engine (CSS sticky unreliable in this environment)
|
|
1424
|
+
* toolbar_sticky: { top: 0, position: 'fixed' }
|
|
1337
1425
|
* ```
|
|
1338
1426
|
*/
|
|
1339
1427
|
toolbar_sticky?:
|
|
1340
1428
|
| number
|
|
1341
1429
|
| {
|
|
1342
1430
|
top: number;
|
|
1343
|
-
offset
|
|
1431
|
+
offset?: number;
|
|
1432
|
+
position?: 'sticky' | 'fixed';
|
|
1344
1433
|
};
|
|
1345
1434
|
/**
|
|
1346
1435
|
* - Hides toolbar initially.
|
|
@@ -1654,6 +1743,7 @@ export type TransformedOptionKeys =
|
|
|
1654
1743
|
| 'toolbar_container'
|
|
1655
1744
|
| '_toolbar_sticky'
|
|
1656
1745
|
| '_toolbar_sticky_offset'
|
|
1746
|
+
| '_toolbar_sticky_fixed'
|
|
1657
1747
|
| 'strictMode'
|
|
1658
1748
|
| 'lineAttrReset';
|
|
1659
1749
|
export type StrictModeOptions = {
|
|
@@ -1707,6 +1797,7 @@ export type TransformedOptions = {
|
|
|
1707
1797
|
toolbar_container: HTMLElement | null;
|
|
1708
1798
|
_toolbar_sticky: number;
|
|
1709
1799
|
_toolbar_sticky_offset: number;
|
|
1800
|
+
_toolbar_sticky_fixed: boolean;
|
|
1710
1801
|
strictMode: StrictModeOptions;
|
|
1711
1802
|
lineAttrReset: string[];
|
|
1712
1803
|
};
|
|
@@ -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';
|