suneditor 3.1.4 → 3.2.0
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/dist/suneditor-contents.min.css +1 -1
- package/dist/suneditor.min.css +28 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +2 -1
- package/src/assets/design/color.css +12 -0
- package/src/assets/design/size.css +9 -2
- package/src/assets/icons/defaultIcons.js +96 -47
- package/src/assets/suneditor-contents.css +3 -2
- package/src/assets/suneditor.css +480 -31
- package/src/core/config/contextProvider.js +2 -1
- package/src/core/config/eventManager.js +41 -2
- package/src/core/config/optionProvider.js +23 -2
- package/src/core/editor.js +32 -14
- package/src/core/event/actions/index.js +76 -9
- package/src/core/event/effects/common.registry.js +2 -1
- package/src/core/event/effects/keydown.registry.js +169 -33
- package/src/core/event/effects/ruleHelpers.js +20 -6
- package/src/core/event/eventOrchestrator.js +136 -23
- package/src/core/event/handlers/handler_toolbar.js +4 -2
- package/src/core/event/handlers/handler_ww_dragDrop.js +10 -0
- package/src/core/event/handlers/handler_ww_input.js +9 -2
- package/src/core/event/handlers/handler_ww_key.js +86 -17
- package/src/core/event/handlers/handler_ww_mouse.js +45 -8
- package/src/core/event/ports.js +23 -5
- package/src/core/event/reducers/keydown.reducer.js +15 -2
- package/src/core/event/rules/keydown.rule.arrow.js +12 -2
- package/src/core/event/rules/keydown.rule.backspace.js +110 -15
- package/src/core/event/rules/keydown.rule.delete.js +62 -7
- package/src/core/event/rules/keydown.rule.enter.js +62 -31
- package/src/core/event/support/defaultLineManager.js +9 -2
- package/src/core/event/support/selectionState.js +13 -3
- package/src/core/kernel/coreKernel.js +1 -0
- package/src/core/logic/dom/char.js +13 -3
- package/src/core/logic/dom/format.js +171 -39
- package/src/core/logic/dom/html.js +350 -72
- package/src/core/logic/dom/inline.js +229 -34
- package/src/core/logic/dom/listFormat.js +111 -20
- package/src/core/logic/dom/nodeTransform.js +36 -11
- package/src/core/logic/dom/offset.js +116 -31
- package/src/core/logic/dom/selection.js +147 -29
- package/src/core/logic/panel/blockHandle.js +785 -0
- package/src/core/logic/panel/blockResolver.js +278 -0
- package/src/core/logic/panel/finder.js +16 -6
- package/src/core/logic/panel/menu.js +119 -18
- package/src/core/logic/panel/toolbar.js +75 -19
- package/src/core/logic/panel/viewer.js +76 -20
- package/src/core/logic/shell/_commandExecutor.js +44 -9
- package/src/core/logic/shell/commandDispatcher.js +46 -4
- package/src/core/logic/shell/component.js +102 -25
- package/src/core/logic/shell/focusManager.js +13 -3
- package/src/core/logic/shell/history.js +21 -6
- package/src/core/logic/shell/pluginManager.js +21 -13
- package/src/core/logic/shell/shortcuts.js +9 -1
- package/src/core/logic/shell/ui.js +139 -37
- package/src/core/schema/frameContext.js +34 -3
- package/src/core/schema/options.js +46 -4
- package/src/core/section/constructor.js +537 -93
- package/src/core/section/documentType.js +35 -6
- package/src/helper/converter.js +24 -7
- package/src/helper/dom/domCheck.js +25 -5
- package/src/helper/dom/domQuery.js +2 -1
- package/src/helper/dom/domUtils.js +17 -4
- package/src/helper/env.js +11 -2
- package/src/helper/keyCodeMap.js +6 -2
- package/src/helper/markdown.js +24 -5
- package/src/helper/msOffice.js +9 -2
- package/src/interfaces/plugins.js +1 -1
- package/src/langs/ckb.js +0 -1
- package/src/langs/cs.js +0 -1
- package/src/langs/da.js +0 -1
- package/src/langs/de.js +0 -1
- package/src/langs/en.js +0 -1
- package/src/langs/es.js +0 -1
- package/src/langs/fa.js +0 -1
- package/src/langs/fr.js +0 -1
- package/src/langs/he.js +0 -1
- package/src/langs/hu.js +0 -1
- package/src/langs/index.js +27 -1
- package/src/langs/it.js +0 -1
- package/src/langs/ja.js +0 -1
- package/src/langs/km.js +0 -1
- package/src/langs/ko.js +0 -1
- package/src/langs/lv.js +0 -1
- package/src/langs/nl.js +0 -1
- package/src/langs/pl.js +0 -1
- package/src/langs/pt_br.js +0 -1
- package/src/langs/ro.js +0 -1
- package/src/langs/ru.js +0 -1
- package/src/langs/se.js +0 -1
- package/src/langs/tr.js +0 -1
- package/src/langs/uk.js +0 -1
- package/src/langs/ur.js +0 -1
- package/src/langs/zh_cn.js +0 -1
- package/src/modules/contract/Browser.js +58 -14
- package/src/modules/contract/ColorPicker.js +12 -4
- package/src/modules/contract/Controller.js +37 -7
- package/src/modules/contract/Figure.js +156 -36
- package/src/modules/contract/HueSlider.js +27 -4
- package/src/modules/contract/Modal.js +50 -10
- package/src/modules/manager/FileManager.js +50 -8
- package/src/modules/ui/CommandMenu.js +597 -0
- package/src/modules/ui/ModalAnchorEditor.js +33 -6
- package/src/modules/ui/SelectMenu.js +481 -36
- package/src/modules/ui/index.js +1 -0
- package/src/plugins/browser/audioGallery.js +2 -1
- package/src/plugins/browser/fileBrowser.js +9 -2
- package/src/plugins/browser/fileGallery.js +2 -1
- package/src/plugins/browser/imageGallery.js +18 -3
- package/src/plugins/browser/videoGallery.js +13 -4
- package/src/plugins/command/blockquote.js +6 -1
- package/src/plugins/command/codeBlock.js +43 -5
- package/src/plugins/command/exportPDF.js +20 -4
- package/src/plugins/command/fileUpload.js +46 -11
- package/src/plugins/command/list_bulleted.js +6 -1
- package/src/plugins/command/list_numbered.js +6 -1
- package/src/plugins/dropdown/align.js +21 -33
- package/src/plugins/dropdown/backgroundColor.js +10 -2
- package/src/plugins/dropdown/blockStyle.js +17 -22
- package/src/plugins/dropdown/font.js +34 -34
- package/src/plugins/dropdown/hr.js +15 -43
- package/src/plugins/dropdown/layout.js +10 -27
- package/src/plugins/dropdown/lineHeight.js +10 -33
- package/src/plugins/dropdown/list.js +19 -25
- package/src/plugins/dropdown/paragraphStyle.js +16 -24
- package/src/plugins/dropdown/table/index.js +72 -17
- package/src/plugins/dropdown/table/render/table.html.js +3 -1
- package/src/plugins/dropdown/table/services/table.cell.js +33 -7
- package/src/plugins/dropdown/table/services/table.clipboard.js +5 -1
- package/src/plugins/dropdown/table/services/table.grid.js +40 -9
- package/src/plugins/dropdown/table/services/table.resize.js +55 -11
- package/src/plugins/dropdown/table/services/table.selection.js +27 -7
- package/src/plugins/dropdown/table/services/table.style.js +120 -20
- package/src/plugins/dropdown/template.js +13 -29
- package/src/plugins/dropdown/textStyle.js +22 -35
- package/src/plugins/field/autocomplete.js +8 -4
- package/src/plugins/field/slashCommand.js +297 -0
- package/src/plugins/index.js +3 -0
- package/src/plugins/input/fontSize.js +37 -8
- package/src/plugins/input/pageNavigator.js +7 -1
- package/src/plugins/modal/audio.js +71 -17
- package/src/plugins/modal/drawing.js +41 -11
- package/src/plugins/modal/embed.js +92 -22
- package/src/plugins/modal/image/index.js +114 -28
- package/src/plugins/modal/image/services/image.size.js +9 -2
- package/src/plugins/modal/image/services/image.upload.js +38 -4
- package/src/plugins/modal/link.js +9 -2
- package/src/plugins/modal/math.js +10 -2
- package/src/plugins/modal/video/index.js +112 -26
- package/src/plugins/modal/video/render/video.html.js +4 -1
- package/src/plugins/modal/video/services/video.size.js +15 -4
- package/src/plugins/modal/video/services/video.upload.js +10 -2
- package/src/plugins/popup/anchor.js +14 -2
- package/src/suneditor.js +8 -2
- package/src/themes/cobalt.css +12 -0
- package/src/themes/cream.css +12 -0
- package/src/themes/dark.css +12 -0
- package/src/themes/midnight.css +12 -0
- package/src/typedef.js +32 -21
- package/types/assets/icons/defaultIcons.d.ts +1 -0
- package/types/core/config/contextProvider.d.ts +7 -1
- package/types/core/config/eventManager.d.ts +37 -4
- package/types/core/config/optionProvider.d.ts +5 -1
- package/types/core/event/actions/index.d.ts +44 -6
- package/types/core/event/effects/keydown.registry.d.ts +37 -7
- package/types/core/event/effects/ruleHelpers.d.ts +6 -1
- package/types/core/event/eventOrchestrator.d.ts +6 -1
- package/types/core/event/handlers/handler_ww_clipboard.d.ts +15 -3
- package/types/core/event/handlers/handler_ww_dragDrop.d.ts +14 -2
- package/types/core/event/handlers/handler_ww_input.d.ts +10 -2
- package/types/core/event/handlers/handler_ww_key.d.ts +10 -2
- package/types/core/event/handlers/handler_ww_mouse.d.ts +25 -5
- package/types/core/event/ports.d.ts +7 -2
- package/types/core/event/rules/keydown.rule.backspace.d.ts +6 -1
- package/types/core/kernel/store.d.ts +4 -1
- package/types/core/logic/dom/format.d.ts +32 -14
- package/types/core/logic/dom/html.d.ts +11 -3
- package/types/core/logic/dom/nodeTransform.d.ts +6 -6
- package/types/core/logic/panel/blockHandle.d.ts +64 -0
- package/types/core/logic/panel/blockResolver.d.ts +50 -0
- package/types/core/logic/panel/menu.d.ts +72 -3
- package/types/core/logic/shell/commandDispatcher.d.ts +8 -0
- package/types/core/logic/shell/component.d.ts +5 -3
- package/types/core/logic/shell/shortcuts.d.ts +10 -1
- package/types/core/logic/shell/ui.d.ts +7 -1
- package/types/core/schema/context.d.ts +7 -1
- package/types/core/schema/frameContext.d.ts +36 -4
- package/types/core/schema/options.d.ts +83 -2
- package/types/core/section/constructor.d.ts +38 -1
- package/types/events.d.ts +208 -32
- package/types/helper/converter.d.ts +4 -2
- package/types/helper/dom/domCheck.d.ts +12 -2
- package/types/helper/dom/domQuery.d.ts +35 -7
- package/types/helper/dom/domUtils.d.ts +4 -1
- package/types/interfaces/plugins.d.ts +2 -2
- package/types/langs/_Lang.d.ts +0 -1
- package/types/modules/contract/ColorPicker.d.ts +2 -2
- package/types/modules/contract/Controller.d.ts +7 -0
- package/types/modules/contract/Figure.d.ts +31 -4
- package/types/modules/ui/CommandMenu.d.ts +262 -0
- package/types/modules/ui/SelectMenu.d.ts +56 -3
- package/types/modules/ui/index.d.ts +1 -0
- package/types/plugins/browser/audioGallery.d.ts +1 -1
- package/types/plugins/browser/fileBrowser.d.ts +1 -1
- package/types/plugins/browser/fileGallery.d.ts +1 -1
- package/types/plugins/browser/imageGallery.d.ts +1 -1
- package/types/plugins/browser/videoGallery.d.ts +1 -1
- package/types/plugins/dropdown/align.d.ts +1 -1
- package/types/plugins/dropdown/blockStyle.d.ts +3 -1
- package/types/plugins/dropdown/table/index.d.ts +4 -1
- package/types/plugins/dropdown/table/services/table.clipboard.d.ts +5 -1
- package/types/plugins/dropdown/table/services/table.grid.d.ts +10 -2
- package/types/plugins/field/autocomplete.d.ts +0 -1
- package/types/plugins/field/slashCommand.d.ts +165 -0
- package/types/plugins/index.d.ts +3 -0
- package/types/plugins/modal/link.d.ts +4 -1
- package/types/typedef.d.ts +48 -23
|
@@ -54,16 +54,16 @@ declare class NodeTransform {
|
|
|
54
54
|
/**
|
|
55
55
|
* @description Remove nested tags without other child nodes.
|
|
56
56
|
* @param {Node} element Element object
|
|
57
|
-
* @param {?(((current:
|
|
57
|
+
* @param {?(((current: *) => boolean)|string)} [validation] Validation function / String(`tag1|tag2..`) / If `null`, all tags are applicable.
|
|
58
58
|
* @example
|
|
59
59
|
* editor.$.nodeTransform.mergeNestedTags(parentElement, (current) => current.nodeName === 'SPAN');
|
|
60
60
|
*/
|
|
61
|
-
mergeNestedTags(element: Node, validation?: (((current:
|
|
61
|
+
mergeNestedTags(element: Node, validation?: (((current: any) => boolean) | string) | null): void;
|
|
62
62
|
/**
|
|
63
63
|
* @description Delete itself and all parent nodes that match the condition.
|
|
64
64
|
* - Returns an {sc: previousSibling, ec: nextSibling}(the deleted node reference) or `null`.
|
|
65
65
|
* @param {Node} item Node to be remove
|
|
66
|
-
* @param {?(current:
|
|
66
|
+
* @param {?(current: *) => boolean} [validation] Validation function. default(Deleted if it only have `breakLine` and blanks)
|
|
67
67
|
* @param {?Node} [stopParent] Stop when the parent node reaches `stopParent`
|
|
68
68
|
* @returns {{sc: Node|null, ec: Node|null}|null} {sc: previousSibling, ec: nextSibling} (the deleted node reference) or `null`.
|
|
69
69
|
* @example
|
|
@@ -82,7 +82,7 @@ declare class NodeTransform {
|
|
|
82
82
|
*/
|
|
83
83
|
removeAllParents(
|
|
84
84
|
item: Node,
|
|
85
|
-
validation?: ((current:
|
|
85
|
+
validation?: ((current: any) => boolean) | null,
|
|
86
86
|
stopParent?: Node | null,
|
|
87
87
|
): {
|
|
88
88
|
sc: Node | null;
|
|
@@ -98,7 +98,7 @@ declare class NodeTransform {
|
|
|
98
98
|
/**
|
|
99
99
|
* @description Creates a nested node structure from the given array of nodes.
|
|
100
100
|
* @param {SunEditor.NodeCollection} nodeArray An array of nodes to clone. The first node in the array will be the top-level parent.
|
|
101
|
-
* @param {?(current:
|
|
101
|
+
* @param {?(current: *) => boolean} [validate] A validate function.
|
|
102
102
|
* @returns {{ parent: Node, inner: Node }} An object containing the top-level parent node and the innermost child node.
|
|
103
103
|
* @example
|
|
104
104
|
* // [div, span, em] → <div><span><em></em></span></div> (cloned)
|
|
@@ -114,7 +114,7 @@ declare class NodeTransform {
|
|
|
114
114
|
*/
|
|
115
115
|
createNestedNode(
|
|
116
116
|
nodeArray: SunEditor.NodeCollection,
|
|
117
|
-
validate?: ((current:
|
|
117
|
+
validate?: ((current: any) => boolean) | null,
|
|
118
118
|
): {
|
|
119
119
|
parent: Node;
|
|
120
120
|
inner: Node;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type {} from '../../../typedef';
|
|
2
|
+
export default BlockHandle;
|
|
3
|
+
/**
|
|
4
|
+
* @class
|
|
5
|
+
* @description Block handle UI — appears in the left gutter on block hover.
|
|
6
|
+
*/
|
|
7
|
+
declare class BlockHandle {
|
|
8
|
+
/**
|
|
9
|
+
* @constructor
|
|
10
|
+
* @param {SunEditor.Deps} $ - Kernel dependencies
|
|
11
|
+
* @param {HTMLElement} blockHandleArea - Container (.se-block-handle-area)
|
|
12
|
+
* @param {HTMLElement} blockHandle - Handle group (.se-block-handle)
|
|
13
|
+
* @param {HTMLElement} blockHandlePlus - Plus button
|
|
14
|
+
* @param {HTMLElement} blockHandleDrag - Drag button
|
|
15
|
+
* @param {Array<string | { title: string, icon?: string, action: function(SunEditor.Deps, { block: HTMLElement }): void }>|null} menuConfig
|
|
16
|
+
* Menu entries. Strings resolve via `ResolveButton` (plugin names, built-in commands). Objects
|
|
17
|
+
* define a custom row whose `action` is invoked with the Deps bag and the current block element.
|
|
18
|
+
*/
|
|
19
|
+
constructor(
|
|
20
|
+
$: SunEditor.Deps,
|
|
21
|
+
blockHandleArea: HTMLElement,
|
|
22
|
+
blockHandle: HTMLElement,
|
|
23
|
+
blockHandlePlus: HTMLElement,
|
|
24
|
+
blockHandleDrag: HTMLElement,
|
|
25
|
+
menuConfig: Array<
|
|
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,
|
|
38
|
+
);
|
|
39
|
+
/**
|
|
40
|
+
* @description Position the block handle for the given mouse target. Uses rAF throttle.
|
|
41
|
+
* Called from wysiwyg mousemove.
|
|
42
|
+
* @param {Node} eventTarget - The element under the mouse cursor
|
|
43
|
+
* @param {number} [mouseY] - Mouse clientY for nested list resolution
|
|
44
|
+
*/
|
|
45
|
+
positionForTarget(eventTarget: Node, mouseY?: number): void;
|
|
46
|
+
/**
|
|
47
|
+
* @description Schedule hiding the block handle with a short delay.
|
|
48
|
+
* @param {MouseEvent} e - Mouse event
|
|
49
|
+
*/
|
|
50
|
+
hide(e: MouseEvent): void;
|
|
51
|
+
/**
|
|
52
|
+
* @description Immediately hide the block handle (no delay).
|
|
53
|
+
*/
|
|
54
|
+
hideNow(): void;
|
|
55
|
+
/**
|
|
56
|
+
* @description Sync handle position on editor scroll. Closes menu if open.
|
|
57
|
+
*/
|
|
58
|
+
syncScroll(): void;
|
|
59
|
+
/**
|
|
60
|
+
* @description Cleanup — remove listeners, destroy menus, null references.
|
|
61
|
+
*/
|
|
62
|
+
destroy(): void;
|
|
63
|
+
#private;
|
|
64
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type {} from '../../../typedef';
|
|
2
|
+
/**
|
|
3
|
+
* @description Resolve any DOM node inside the editor to its owning block-level element.
|
|
4
|
+
* @param {Node|null} node - Any DOM node inside the editor
|
|
5
|
+
* @param {FormatAPI} format - Injected format methods (getLine, getBlock, isLine, isBlock)
|
|
6
|
+
* @param {HTMLElement} wysiwygFrame - The wysiwyg root element
|
|
7
|
+
* @param {number} [mouseY] - Mouse clientY for nested list resolution
|
|
8
|
+
* @returns {BlockInfo|null} Block information, or null if node is outside editable area
|
|
9
|
+
*/
|
|
10
|
+
export function resolveBlock(
|
|
11
|
+
node: Node | null,
|
|
12
|
+
format: FormatAPI,
|
|
13
|
+
wysiwygFrame: HTMLElement,
|
|
14
|
+
mouseY?: number,
|
|
15
|
+
): BlockInfo | null;
|
|
16
|
+
export type BlockInfo = {
|
|
17
|
+
/**
|
|
18
|
+
* - The resolved block-level DOM element
|
|
19
|
+
*/
|
|
20
|
+
element: HTMLElement;
|
|
21
|
+
/**
|
|
22
|
+
* - Block type: 'p', 'heading', 'list', 'blockquote', 'pre', 'figure', 'table', 'div'
|
|
23
|
+
*/
|
|
24
|
+
type: string;
|
|
25
|
+
/**
|
|
26
|
+
* - Nesting level from wysiwyg root (0 = top-level)
|
|
27
|
+
*/
|
|
28
|
+
depth: number;
|
|
29
|
+
/**
|
|
30
|
+
* - Parent block element, or null if top-level
|
|
31
|
+
*/
|
|
32
|
+
parent: HTMLElement | null;
|
|
33
|
+
/**
|
|
34
|
+
* - Adjacent blocks at same depth
|
|
35
|
+
*/
|
|
36
|
+
siblings: {
|
|
37
|
+
prev: HTMLElement | null;
|
|
38
|
+
next: HTMLElement | null;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* - getBoundingClientRect() of the element (caller handles scroll/iframe offset)
|
|
42
|
+
*/
|
|
43
|
+
rect: DOMRect;
|
|
44
|
+
};
|
|
45
|
+
export type FormatAPI = {
|
|
46
|
+
getLine: (node: Node, validation?: (current: any) => boolean) => HTMLElement | null;
|
|
47
|
+
getBlock: (element: Node, validation?: (current: any) => boolean) => HTMLElement | null;
|
|
48
|
+
isLine: (element: Node) => boolean;
|
|
49
|
+
isBlock: (element: Node) => boolean;
|
|
50
|
+
};
|
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
import type {} from '../../../typedef';
|
|
2
2
|
export default Menu;
|
|
3
|
+
export type DropdownItem = {
|
|
4
|
+
/**
|
|
5
|
+
* - `data-command` attribute value
|
|
6
|
+
*/
|
|
7
|
+
command: string;
|
|
8
|
+
/**
|
|
9
|
+
* - `data-value` attribute value
|
|
10
|
+
*/
|
|
11
|
+
value?: string;
|
|
12
|
+
/**
|
|
13
|
+
* - Title text (used for `title` and `aria-label`)
|
|
14
|
+
*/
|
|
15
|
+
title: string;
|
|
16
|
+
/**
|
|
17
|
+
* - Button inner HTML content
|
|
18
|
+
*/
|
|
19
|
+
innerHTML: string;
|
|
20
|
+
/**
|
|
21
|
+
* - Additional CSS class for the `<button>`
|
|
22
|
+
*/
|
|
23
|
+
className?: string;
|
|
24
|
+
/**
|
|
25
|
+
* - Extra data attributes (e.g. `{ 'data-class': 'xxx' }`)
|
|
26
|
+
*/
|
|
27
|
+
attrs?: {
|
|
28
|
+
[x: string]: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* - Rendered button element (set by `initDropdownTarget`)
|
|
32
|
+
*/
|
|
33
|
+
_element?: HTMLElement;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {Object} DropdownItem
|
|
37
|
+
* @property {string} command - `data-command` attribute value
|
|
38
|
+
* @property {string} [value] - `data-value` attribute value
|
|
39
|
+
* @property {string} title - Title text (used for `title` and `aria-label`)
|
|
40
|
+
* @property {string} innerHTML - Button inner HTML content
|
|
41
|
+
* @property {string} [className] - Additional CSS class for the `<button>`
|
|
42
|
+
* @property {Object<string, string>} [attrs] - Extra data attributes (e.g. `{ 'data-class': 'xxx' }`)
|
|
43
|
+
* @property {HTMLElement} [_element] - Rendered button element (set by `initDropdownTarget`)
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* @description Creates a dropdown menu element from standardized item objects.
|
|
47
|
+
* @param {Array<DropdownItem>} items - Menu items
|
|
48
|
+
* @param {Object} [options]
|
|
49
|
+
* @param {string} [options.className] - Additional class for the wrapper `<div>`
|
|
50
|
+
* @param {string} [options.prependHTML] - HTML to prepend inside the `<ul>` (e.g. default value items)
|
|
51
|
+
* @returns {HTMLElement}
|
|
52
|
+
*/
|
|
53
|
+
export function CreateDropdownMenu(
|
|
54
|
+
items: Array<DropdownItem>,
|
|
55
|
+
options?: {
|
|
56
|
+
className?: string;
|
|
57
|
+
prependHTML?: string;
|
|
58
|
+
},
|
|
59
|
+
): HTMLElement;
|
|
3
60
|
/**
|
|
4
61
|
* @description Dropdown and container menu management class
|
|
5
62
|
*/
|
|
@@ -13,6 +70,10 @@ declare class Menu {
|
|
|
13
70
|
targetMap: {
|
|
14
71
|
[x: string]: HTMLElement;
|
|
15
72
|
};
|
|
73
|
+
/** @type {Object<string, Array<DropdownItem>>} Structured items keyed by plugin name */
|
|
74
|
+
itemsMap: {
|
|
75
|
+
[x: string]: DropdownItem[];
|
|
76
|
+
};
|
|
16
77
|
index: number;
|
|
17
78
|
menus: any[];
|
|
18
79
|
currentButton: HTMLButtonElement;
|
|
@@ -28,7 +89,11 @@ declare class Menu {
|
|
|
28
89
|
* @description Method for managing dropdown element.
|
|
29
90
|
* - You must add the `dropdown` element using this method at custom plugin.
|
|
30
91
|
* @param {{key: string, type: string}} classObj Class object
|
|
31
|
-
* @param {Node}
|
|
92
|
+
* @param {Node|Array<DropdownItem>} menuOrItems Dropdown element or array of standardized items
|
|
93
|
+
* @param {Object} [options] Options when passing items array
|
|
94
|
+
* @param {string} [options.className] Additional CSS class for the wrapper element
|
|
95
|
+
* @param {string} [options.prependHTML] HTML to prepend inside the `<ul>` (e.g. default/sub-list items)
|
|
96
|
+
* @returns {HTMLElement} The registered menu element
|
|
32
97
|
*/
|
|
33
98
|
initDropdownTarget(
|
|
34
99
|
{
|
|
@@ -38,8 +103,12 @@ declare class Menu {
|
|
|
38
103
|
key: string;
|
|
39
104
|
type: string;
|
|
40
105
|
},
|
|
41
|
-
|
|
42
|
-
|
|
106
|
+
menuOrItems: Node | Array<DropdownItem>,
|
|
107
|
+
options?: {
|
|
108
|
+
className?: string;
|
|
109
|
+
prependHTML?: string;
|
|
110
|
+
},
|
|
111
|
+
): HTMLElement;
|
|
43
112
|
/**
|
|
44
113
|
* @description Opens the dropdown menu for the specified button.
|
|
45
114
|
* @param {Node} button Dropdown's button element to call
|
|
@@ -50,6 +50,14 @@ export default class CommandDispatcher {
|
|
|
50
50
|
* @param {HTMLButtonElement} target - The associated command button.
|
|
51
51
|
*/
|
|
52
52
|
registerTargets(cmd: string, target: HTMLButtonElement): void;
|
|
53
|
+
/**
|
|
54
|
+
* @description Inverse of {@link registerTargets}. Removes a previously registered target so
|
|
55
|
+
* ephemeral participants (e.g. CommandMenu rows) can opt out of the active-state pass on close.
|
|
56
|
+
* Drops the command entry when its target array empties.
|
|
57
|
+
* @param {string} cmd - The command identifier.
|
|
58
|
+
* @param {HTMLElement} target - The target previously registered.
|
|
59
|
+
*/
|
|
60
|
+
unregisterTargets(cmd: string, target: HTMLElement): void;
|
|
53
61
|
resetTargets(): void;
|
|
54
62
|
/**
|
|
55
63
|
* @internal
|
|
@@ -25,10 +25,12 @@ declare class Component {
|
|
|
25
25
|
*/
|
|
26
26
|
currentTarget: Node | null;
|
|
27
27
|
/**
|
|
28
|
-
* @description Currently selected component plugin instance
|
|
29
|
-
*
|
|
28
|
+
* @description Currently selected component plugin instance (a full plugin) or a
|
|
29
|
+
* launcher stand-in for non-plugin components (e.g. `pageBreak`). Consumers call the
|
|
30
|
+
* shared component hooks (`componentDestroy`/`componentSelect`/`componentDeselect`) on it.
|
|
31
|
+
* @type {?SunEditor.ComponentLauncher}
|
|
30
32
|
*/
|
|
31
|
-
currentPlugin:
|
|
33
|
+
currentPlugin: SunEditor.ComponentLauncher | null;
|
|
32
34
|
/**
|
|
33
35
|
* @description Currently selected component plugin name
|
|
34
36
|
* @type {*}
|
|
@@ -107,7 +107,16 @@ declare class Shortcuts {
|
|
|
107
107
|
* @param {Range} range The current range object
|
|
108
108
|
* @returns {boolean} Whether to execute shortcuts
|
|
109
109
|
*/
|
|
110
|
-
command(
|
|
110
|
+
command(
|
|
111
|
+
event: KeyboardEvent,
|
|
112
|
+
ctrl: boolean,
|
|
113
|
+
shift: boolean,
|
|
114
|
+
keyCode: string,
|
|
115
|
+
text: string,
|
|
116
|
+
edge: boolean,
|
|
117
|
+
line: HTMLElement,
|
|
118
|
+
range: Range,
|
|
119
|
+
): boolean;
|
|
111
120
|
/**
|
|
112
121
|
* @description Disable the shortcut activation.
|
|
113
122
|
*/
|
|
@@ -160,7 +160,12 @@ declare class UIManager {
|
|
|
160
160
|
/**
|
|
161
161
|
* @param {SunEditor.FrameContext} rt Root target[key] FrameContext
|
|
162
162
|
*/
|
|
163
|
-
|
|
163
|
+
/**
|
|
164
|
+
* @description Block handle instance for external access.
|
|
165
|
+
* @type {BlockHandle}
|
|
166
|
+
*/
|
|
167
|
+
get blockHandle(): BlockHandle;
|
|
168
|
+
reset(rt: any): void;
|
|
164
169
|
/**
|
|
165
170
|
* @internal
|
|
166
171
|
* @description Closes all open controllers except those marked as `fixed`.
|
|
@@ -259,3 +264,4 @@ declare class UIManager {
|
|
|
259
264
|
opendBrowser: any;
|
|
260
265
|
#private;
|
|
261
266
|
}
|
|
267
|
+
import BlockHandle from '../panel/blockHandle.js';
|
|
@@ -38,7 +38,13 @@ import type {} from '../../typedef';
|
|
|
38
38
|
* @param {?Element} statusbarContainer - Status bar container element.
|
|
39
39
|
* @returns {SunEditor.Context} - A map of key DOM nodes used throughout the editor.
|
|
40
40
|
*/
|
|
41
|
-
export function CreateContext(
|
|
41
|
+
export function CreateContext(
|
|
42
|
+
toolbar: Element,
|
|
43
|
+
toolbarContainer: Element | null,
|
|
44
|
+
menuTray: Element,
|
|
45
|
+
subbar: Element | null,
|
|
46
|
+
statusbarContainer: Element | null,
|
|
47
|
+
): SunEditor.Context;
|
|
42
48
|
/**
|
|
43
49
|
* This object stores **global editor-level UI references** for a SunEditor instance.
|
|
44
50
|
*
|
|
@@ -33,6 +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
37
|
* @property {HTMLElement} statusbar - Editor status bar element (for resizing, info, etc.).
|
|
37
38
|
* @property {HTMLElement} navigation - Navigation element (e.g., for outline or bookmarks).
|
|
38
39
|
* @property {HTMLElement} charWrapper - Wrapper for the character counter element.
|
|
@@ -45,6 +46,10 @@ import type {} from '../../typedef';
|
|
|
45
46
|
* === UI Utilities & Visual Components ===
|
|
46
47
|
* @property {HTMLElement} lineBreaker_t - Top floating line-breaker UI element (for line insertion).
|
|
47
48
|
* @property {HTMLElement} lineBreaker_b - Bottom floating line-breaker UI element (for line insertion).
|
|
49
|
+
* @property {?HTMLElement} blockHandleArea - Gutter container (`.se-block-handle-area`) holding the per-line block handle. `null` when the `blockHandle` option is disabled.
|
|
50
|
+
* @property {?HTMLElement} blockHandle - Block handle group (`.se-block-handle`) containing the plus and drag buttons. `null` when disabled.
|
|
51
|
+
* @property {?HTMLElement} blockHandlePlus - Plus button (`.se-block-handle-plus`) — inserts a new line after the current block. `null` when disabled.
|
|
52
|
+
* @property {?HTMLElement} blockHandleDrag - Drag button (`.se-block-handle-drag`) — opens the action menu / starts drag-to-reorder. `null` when disabled.
|
|
48
53
|
* @property {HTMLElement} [_stickyDummy] - Placeholder element used for sticky toolbar behavior.
|
|
49
54
|
* @property {HTMLElement} [_toolbarShadow] - Shadow element below the toolbar for visual effects.
|
|
50
55
|
* @property {{main: HTMLElement, border: HTMLElement, display: HTMLElement, handles: HTMLElement[]}} [_figure] - Current active figure component (image, table, etc.).
|
|
@@ -88,8 +93,11 @@ import type {} from '../../typedef';
|
|
|
88
93
|
* @param {HTMLElement} wwFrame Editor wysiwyg frame
|
|
89
94
|
* @param {HTMLElement} codeWrapper Editor code view wrapper
|
|
90
95
|
* @param {HTMLElement} codeFrame Editor code view frame
|
|
91
|
-
* @param {
|
|
96
|
+
* @param {?HTMLElement} markdownWrapper Editor markdown view wrapper (only present when the markdown view button is enabled)
|
|
97
|
+
* @param {?HTMLElement} markdownFrame Editor markdown view frame (only present when the markdown view button is enabled)
|
|
92
98
|
* @param {?HTMLElement} statusbar Editor statusbar
|
|
99
|
+
* @param {{inner: HTMLElement, page: HTMLElement, pageMirror: HTMLElement}} documentTypeInner Document type elements
|
|
100
|
+
* @param {?HTMLElement} blockHandleArea Block handle gutter (`.se-block-handle-area`). `null` when the `blockHandle` option is disabled.
|
|
93
101
|
* @param {*} key root key
|
|
94
102
|
* @returns {FrameContexType}
|
|
95
103
|
*/
|
|
@@ -103,14 +111,15 @@ export function CreateFrameContext(
|
|
|
103
111
|
wwFrame: HTMLElement,
|
|
104
112
|
codeWrapper: HTMLElement,
|
|
105
113
|
codeFrame: HTMLElement,
|
|
106
|
-
markdownWrapper:
|
|
107
|
-
markdownFrame:
|
|
114
|
+
markdownWrapper: HTMLElement | null,
|
|
115
|
+
markdownFrame: HTMLElement | null,
|
|
108
116
|
statusbar: HTMLElement | null,
|
|
109
117
|
documentTypeInner: {
|
|
110
118
|
inner: HTMLElement;
|
|
111
119
|
page: HTMLElement;
|
|
112
120
|
pageMirror: HTMLElement;
|
|
113
121
|
},
|
|
122
|
+
blockHandleArea: HTMLElement | null,
|
|
114
123
|
key: any,
|
|
115
124
|
): FrameContexType;
|
|
116
125
|
/**
|
|
@@ -118,7 +127,10 @@ export function CreateFrameContext(
|
|
|
118
127
|
* @param {HTMLElement} statusbar Statusbar element
|
|
119
128
|
* @param {FrameContexType|import('../config/contextProvider').FrameContextMap} mapper FrameContext map
|
|
120
129
|
*/
|
|
121
|
-
export function UpdateStatusbarContext(
|
|
130
|
+
export function UpdateStatusbarContext(
|
|
131
|
+
statusbar: HTMLElement,
|
|
132
|
+
mapper: FrameContexType | import('../config/contextProvider').FrameContextMap,
|
|
133
|
+
): void;
|
|
122
134
|
/**
|
|
123
135
|
* This object stores **all frame-specific states and DOM references** for a SunEditor instance.
|
|
124
136
|
*
|
|
@@ -201,6 +213,10 @@ export type FrameContextStore = {
|
|
|
201
213
|
* - Placeholder element shown when the editor is empty.
|
|
202
214
|
*/
|
|
203
215
|
placeholder: HTMLElement;
|
|
216
|
+
/**
|
|
217
|
+
* - Per-line placeholder text, rendered via a `::before` on the focused empty line.
|
|
218
|
+
*/
|
|
219
|
+
placeholder_line: string;
|
|
204
220
|
/**
|
|
205
221
|
* - Editor status bar element (for resizing, info, etc.).
|
|
206
222
|
*/
|
|
@@ -243,6 +259,22 @@ export type FrameContextStore = {
|
|
|
243
259
|
* - Bottom floating line-breaker UI element (for line insertion).
|
|
244
260
|
*/
|
|
245
261
|
lineBreaker_b: HTMLElement;
|
|
262
|
+
/**
|
|
263
|
+
* - Gutter container (`.se-block-handle-area`) holding the per-line block handle. `null` when the `blockHandle` option is disabled.
|
|
264
|
+
*/
|
|
265
|
+
blockHandleArea: HTMLElement | null;
|
|
266
|
+
/**
|
|
267
|
+
* - Block handle group (`.se-block-handle`) containing the plus and drag buttons. `null` when disabled.
|
|
268
|
+
*/
|
|
269
|
+
blockHandle: HTMLElement | null;
|
|
270
|
+
/**
|
|
271
|
+
* - Plus button (`.se-block-handle-plus`) — inserts a new line after the current block. `null` when disabled.
|
|
272
|
+
*/
|
|
273
|
+
blockHandlePlus: HTMLElement | null;
|
|
274
|
+
/**
|
|
275
|
+
* - Drag button (`.se-block-handle-drag`) — opens the action menu / starts drag-to-reorder. `null` when disabled.
|
|
276
|
+
*/
|
|
277
|
+
blockHandleDrag: HTMLElement | null;
|
|
246
278
|
/**
|
|
247
279
|
* - Placeholder element used for sticky toolbar behavior.
|
|
248
280
|
*/
|
|
@@ -54,7 +54,9 @@ export namespace DEFAULTS {
|
|
|
54
54
|
*
|
|
55
55
|
* === Content & Editing ===
|
|
56
56
|
* @property {string} [value=""] - Initial value for the editor.
|
|
57
|
-
* @property {string} [placeholder=""] - Placeholder text.
|
|
57
|
+
* @property {string} [placeholder=""] - Placeholder text shown when the whole editor is empty.
|
|
58
|
+
* @property {string} [placeholder_line=""] - per-line placeholder shown on the focused
|
|
59
|
+
* line when that line is empty. Takes priority over `placeholder` while a line is focused.
|
|
58
60
|
* @property {Object<string, string>} [editableFrameAttributes={spellcheck: "false"}] - Attributes for the editable frame[.sun-editor-editable].
|
|
59
61
|
* ```js
|
|
60
62
|
* { editableFrameAttributes: { spellcheck: 'true', autocomplete: 'on' } }
|
|
@@ -65,6 +67,13 @@ export namespace DEFAULTS {
|
|
|
65
67
|
* @property {string|number} [width="100%"] - Width for the editor.
|
|
66
68
|
* @property {string|number} [minWidth=""] - Min width for the editor.
|
|
67
69
|
* @property {string|number} [maxWidth=""] - Max width for the editor.
|
|
70
|
+
* @property {string} [innerWidth=""] - Optional max-width for the editor body (`.se-wrapper`).
|
|
71
|
+
* - **CSS length** (`"740px"`, `"60ch"`): editor body's content is clamped to this width and centered horizontally; scroll container stays full width (scrollbar at the outer edge, wheel/touch active over the whole area).
|
|
72
|
+
* - **`"auto"`** or **empty string** (default): no constraint — natural full-width layout with default content padding.
|
|
73
|
+
* - In `blockHandle` mode, the gutter handle tracks the centered text band.
|
|
74
|
+
* ```js
|
|
75
|
+
* { innerWidth: '740px' }
|
|
76
|
+
* ```
|
|
68
77
|
* @property {string|number} [height="auto"] - Height for the editor.
|
|
69
78
|
* @property {string|number} [minHeight=""] - Min height for the editor.
|
|
70
79
|
* @property {string|number} [maxHeight=""] - Max height for the editor.
|
|
@@ -233,6 +242,22 @@ export namespace DEFAULTS {
|
|
|
233
242
|
* === Modes & Themes ===
|
|
234
243
|
* @property {boolean} [v2Migration=false] - Enables migration mode for SunEditor v2.
|
|
235
244
|
* @property {"classic"|"inline"|"balloon"|"balloon-always"|"classic:bottom"|"inline:bottom"} [mode="classic"] - Toolbar mode: `classic`, `inline`, `balloon`, `balloon-always`. Append `:bottom` to place toolbar at the bottom (e.g. `classic:bottom`, `inline:bottom`).
|
|
245
|
+
* @property {Object} [blockHandle] - Block handle configuration. When provided, a per-line block handle UI is shown. Works independently of `mode`.
|
|
246
|
+
* @property {Array<string | { title: string, icon?: string, action: (deps: SunEditor.Deps, ctx: { block: HTMLElement }) => void }>} [blockHandle.menu] - Menu entries.
|
|
247
|
+
* - **String entries** — resolved via `ResolveButton`. Accepts the same values as toolbar `buttonList`:
|
|
248
|
+
* - **Block format keys**: `p`, `h1`-`h6`, `heading` (H1-H6 submenu), `ul`, `ol`, `list` (UL/OL submenu), `blockquote`, `pre`.
|
|
249
|
+
* - **Plugin names**: Any registered plugin name (e.g. `blockStyle`, `align`, `image`, `link`). Dropdown plugins display their items as a submenu. Modal plugins open the modal on click.
|
|
250
|
+
* - **Built-in commands**: `bold`, `italic`, `underline`, `strike`, `undo`, `redo`, etc.
|
|
251
|
+
* - **Custom item objects** — `{ title, icon?, action }`. `icon` is an icon key from `$.icons` or a raw `<svg>` HTML string; `action` is invoked with `($, { block })`.
|
|
252
|
+
* - Defaults to `['p', 'heading', 'list', 'blockquote', 'pre']`.
|
|
253
|
+
* ```js
|
|
254
|
+
* blockHandle: {
|
|
255
|
+
* menu: [
|
|
256
|
+
* 'p', 'heading', 'blockStyle',
|
|
257
|
+
* { title: 'Duplicate', icon: 'copy', action: ($, { block }) => block.after(block.cloneNode(true)) },
|
|
258
|
+
* ],
|
|
259
|
+
* }
|
|
260
|
+
* ```
|
|
236
261
|
* @property {string} [type=""] - Editor type. Use `"document"` for a document-style layout, with optional sub-types after `:`.
|
|
237
262
|
* ```js
|
|
238
263
|
* // type
|
|
@@ -416,6 +441,15 @@ export namespace DEFAULTS {
|
|
|
416
441
|
* @property {boolean} [syncTabIndent=true] - Synchronizes tab indent with spaces.
|
|
417
442
|
* @property {boolean} [tabDisable=false] - Disables tab key input.
|
|
418
443
|
* @property {string} [toolbar_width="auto"] - Toolbar width.
|
|
444
|
+
* @property {string} [toolbar_innerWidth=""] - Center the toolbar's button row (`.se-btn-tray`) horizontally.
|
|
445
|
+
* - **CSS length** (e.g. `"500px"`, `"740px"`, `"60ch"`): toolbar background spans full width while the button row is capped at that width and centered. If buttons fit, the row stays on a single line; if they exceed the cap, they wrap inside it.
|
|
446
|
+
* - **`"auto"`**: no cap — the row is sized to its content and simply centered.
|
|
447
|
+
* - **Empty string** (default): no constraint.
|
|
448
|
+
* - **Note on `responsiveButtonList`**: thresholds compare against the toolbar's full width, not the band. When this option is set, calibrate `responsiveButtonList` keys around the toolbar size you actually want each button set to kick in at.
|
|
449
|
+
* ```js
|
|
450
|
+
* { toolbar_innerWidth: '740px' }
|
|
451
|
+
* { toolbar_innerWidth: 'auto' }
|
|
452
|
+
* ```
|
|
419
453
|
* @property {?HTMLElement} [toolbar_container] - Container element for the toolbar.
|
|
420
454
|
* @property {number|{top: number, offset: number}} [toolbar_sticky=0] - Enables sticky toolbar.
|
|
421
455
|
* - `number`: Sets the sticky top position (px). Use `-1` to disable sticky.
|
|
@@ -550,6 +584,7 @@ export namespace DEFAULTS {
|
|
|
550
584
|
* @property {import('../../plugins/modal/link.js').LinkPluginOptions} [link]
|
|
551
585
|
* @property {import('../../plugins/modal/math.js').MathPluginOptions} [math]
|
|
552
586
|
* @property {import('../../plugins/dropdown/paragraphStyle.js').ParagraphStylePluginOptions} [paragraphStyle]
|
|
587
|
+
* @property {import('../../plugins/field/slashCommand.js').SlashCommandPluginOptions} [slashCommand]
|
|
553
588
|
* @property {import('../../plugins/dropdown/table/index.js').TablePluginOptions} [table]
|
|
554
589
|
* @property {import('../../plugins/dropdown/template.js').TemplatePluginOptions} [template]
|
|
555
590
|
* @property {import('../../plugins/dropdown/textStyle.js').TextStylePluginOptions} [textStyle]
|
|
@@ -626,9 +661,14 @@ export type EditorFrameOptions = {
|
|
|
626
661
|
*/
|
|
627
662
|
value?: string;
|
|
628
663
|
/**
|
|
629
|
-
* - Placeholder text.
|
|
664
|
+
* - Placeholder text shown when the whole editor is empty.
|
|
630
665
|
*/
|
|
631
666
|
placeholder?: string;
|
|
667
|
+
/**
|
|
668
|
+
* - per-line placeholder shown on the focused
|
|
669
|
+
* line when that line is empty. Takes priority over `placeholder` while a line is focused.
|
|
670
|
+
*/
|
|
671
|
+
placeholder_line?: string;
|
|
632
672
|
/**
|
|
633
673
|
* - Attributes for the editable frame[.sun-editor-editable].
|
|
634
674
|
* ```js
|
|
@@ -653,6 +693,16 @@ export type EditorFrameOptions = {
|
|
|
653
693
|
* - Max width for the editor.
|
|
654
694
|
*/
|
|
655
695
|
maxWidth?: string | number;
|
|
696
|
+
/**
|
|
697
|
+
* - Optional max-width for the editor body (`.se-wrapper`).
|
|
698
|
+
* - **CSS length** (`"740px"`, `"60ch"`): editor body's content is clamped to this width and centered horizontally; scroll container stays full width (scrollbar at the outer edge, wheel/touch active over the whole area).
|
|
699
|
+
* - **`"auto"`** or **empty string** (default): no constraint — natural full-width layout with default content padding.
|
|
700
|
+
* - In `blockHandle` mode, the gutter handle tracks the centered text band.
|
|
701
|
+
* ```js
|
|
702
|
+
* { innerWidth: '740px' }
|
|
703
|
+
* ```
|
|
704
|
+
*/
|
|
705
|
+
innerWidth?: string;
|
|
656
706
|
/**
|
|
657
707
|
* - Height for the editor.
|
|
658
708
|
*/
|
|
@@ -941,6 +991,24 @@ export type EditorBaseOptions = {
|
|
|
941
991
|
* - Toolbar mode: `classic`, `inline`, `balloon`, `balloon-always`. Append `:bottom` to place toolbar at the bottom (e.g. `classic:bottom`, `inline:bottom`).
|
|
942
992
|
*/
|
|
943
993
|
mode?: 'classic' | 'inline' | 'balloon' | 'balloon-always' | 'classic:bottom' | 'inline:bottom';
|
|
994
|
+
/**
|
|
995
|
+
* - Block handle configuration. When provided, a per-line block handle UI is shown. Works independently of `mode`.
|
|
996
|
+
*/
|
|
997
|
+
blockHandle?: {
|
|
998
|
+
menu?: Array<
|
|
999
|
+
| string
|
|
1000
|
+
| {
|
|
1001
|
+
title: string;
|
|
1002
|
+
icon?: string;
|
|
1003
|
+
action: (
|
|
1004
|
+
deps: SunEditor.Deps,
|
|
1005
|
+
ctx: {
|
|
1006
|
+
block: HTMLElement;
|
|
1007
|
+
},
|
|
1008
|
+
) => void;
|
|
1009
|
+
}
|
|
1010
|
+
>;
|
|
1011
|
+
};
|
|
944
1012
|
/**
|
|
945
1013
|
* - Editor type. Use `"document"` for a document-style layout, with optional sub-types after `:`.
|
|
946
1014
|
* ```js
|
|
@@ -1231,6 +1299,18 @@ export type EditorBaseOptions = {
|
|
|
1231
1299
|
* - Toolbar width.
|
|
1232
1300
|
*/
|
|
1233
1301
|
toolbar_width?: string;
|
|
1302
|
+
/**
|
|
1303
|
+
* - Center the toolbar's button row (`.se-btn-tray`) horizontally.
|
|
1304
|
+
* - **CSS length** (e.g. `"500px"`, `"740px"`, `"60ch"`): toolbar background spans full width while the button row is capped at that width and centered. If buttons fit, the row stays on a single line; if they exceed the cap, they wrap inside it.
|
|
1305
|
+
* - **`"auto"`**: no cap — the row is sized to its content and simply centered.
|
|
1306
|
+
* - **Empty string** (default): no constraint.
|
|
1307
|
+
* - **Note on `responsiveButtonList`**: thresholds compare against the toolbar's full width, not the band. When this option is set, calibrate `responsiveButtonList` keys around the toolbar size you actually want each button set to kick in at.
|
|
1308
|
+
* ```js
|
|
1309
|
+
* { toolbar_innerWidth: '740px' }
|
|
1310
|
+
* { toolbar_innerWidth: 'auto' }
|
|
1311
|
+
* ```
|
|
1312
|
+
*/
|
|
1313
|
+
toolbar_innerWidth?: string;
|
|
1234
1314
|
/**
|
|
1235
1315
|
* - Container element for the toolbar.
|
|
1236
1316
|
*/
|
|
@@ -1450,6 +1530,7 @@ export type EditorBaseOptions = {
|
|
|
1450
1530
|
link?: import('../../plugins/modal/link.js').LinkPluginOptions;
|
|
1451
1531
|
math?: import('../../plugins/modal/math.js').MathPluginOptions;
|
|
1452
1532
|
paragraphStyle?: import('../../plugins/dropdown/paragraphStyle.js').ParagraphStylePluginOptions;
|
|
1533
|
+
slashCommand?: import('../../plugins/field/slashCommand.js').SlashCommandPluginOptions;
|
|
1453
1534
|
table?: import('../../plugins/dropdown/table/index.js').TablePluginOptions;
|
|
1454
1535
|
template?: import('../../plugins/dropdown/template.js').TemplatePluginOptions;
|
|
1455
1536
|
textStyle?: import('../../plugins/dropdown/textStyle.js').TextStylePluginOptions;
|
|
@@ -8,7 +8,14 @@ import type {} from '../../typedef';
|
|
|
8
8
|
* @param {Array} rc `_reverseCommandArray` option
|
|
9
9
|
* @param {Set} reverseKeys Reverse key array
|
|
10
10
|
*/
|
|
11
|
-
export function CreateShortcuts(
|
|
11
|
+
export function CreateShortcuts(
|
|
12
|
+
command: string,
|
|
13
|
+
button: Element | null,
|
|
14
|
+
values: Array<string>,
|
|
15
|
+
keyMap: Map<string, any>,
|
|
16
|
+
rc: any[],
|
|
17
|
+
reverseKeys: Set<any>,
|
|
18
|
+
): void;
|
|
12
19
|
/**
|
|
13
20
|
* @typedef {Object} InitOptionsReturnType
|
|
14
21
|
* @property {Map<string, *>} o - Processed base options (`Map` containing {@link AllBaseOptions_constructor} keys)
|
|
@@ -55,6 +62,36 @@ export function CreateStatusbar(
|
|
|
55
62
|
wordWrapper: HTMLElement;
|
|
56
63
|
wordCounter: HTMLElement;
|
|
57
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* @description Resolves a button key to its toolbar metadata.
|
|
67
|
+
* Checks plugins first, then falls back to the default button list.
|
|
68
|
+
* Same resolution logic as `CreateToolBar`.
|
|
69
|
+
* @param {string} key Button name
|
|
70
|
+
* @param {?Object<string, *>} plugins Plugin instances
|
|
71
|
+
* @param {SunEditor.Options} options Options map
|
|
72
|
+
* @param {Object<string, string>} icons Icons
|
|
73
|
+
* @param {Object<string, string>} lang Language object
|
|
74
|
+
* @returns {{className: string, title: string, command: string, type: string, icon: string}|null}
|
|
75
|
+
*/
|
|
76
|
+
export function ResolveButton(
|
|
77
|
+
key: string,
|
|
78
|
+
plugins: {
|
|
79
|
+
[x: string]: any;
|
|
80
|
+
} | null,
|
|
81
|
+
options: SunEditor.Options,
|
|
82
|
+
icons: {
|
|
83
|
+
[x: string]: string;
|
|
84
|
+
},
|
|
85
|
+
lang: {
|
|
86
|
+
[x: string]: string;
|
|
87
|
+
},
|
|
88
|
+
): {
|
|
89
|
+
className: string;
|
|
90
|
+
title: string;
|
|
91
|
+
command: string;
|
|
92
|
+
type: string;
|
|
93
|
+
icon: string;
|
|
94
|
+
} | null;
|
|
58
95
|
/**
|
|
59
96
|
* @description Update a button state, attributes, and icons
|
|
60
97
|
* @param {?HTMLElement} element Button element
|