suneditor 3.1.4 → 3.2.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/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 +481 -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 +162 -30
- 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 +84 -2
- package/src/core/event/handlers/handler_ww_key.js +82 -21
- package/src/core/event/handlers/handler_ww_mouse.js +45 -8
- package/src/core/event/ports.js +27 -13
- package/src/core/event/reducers/keydown.reducer.js +33 -5
- 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 -106
- 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 +13 -3
- 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 +11 -4
- package/types/core/event/reducers/keydown.reducer.d.ts +12 -3
- 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
|
@@ -25,13 +25,13 @@ declare class Format {
|
|
|
25
25
|
/**
|
|
26
26
|
* @description If a parent node that contains an argument node finds a format node (`format.isLine`), it returns that node.
|
|
27
27
|
* @param {Node} node Reference node.
|
|
28
|
-
* @param {?(current:
|
|
28
|
+
* @param {?(current: *) => boolean} [validation] Additional validation function.
|
|
29
29
|
* @returns {HTMLElement|null}
|
|
30
30
|
* @example
|
|
31
31
|
* const line = editor.$.format.getLine(editor.$.selection.getNode());
|
|
32
32
|
* const lineWithFilter = editor.$.format.getLine(node, (el) => el.nodeName !== 'LI');
|
|
33
33
|
*/
|
|
34
|
-
getLine(node: Node, validation?: ((current:
|
|
34
|
+
getLine(node: Node, validation?: ((current: any) => boolean) | null): HTMLElement | null;
|
|
35
35
|
/**
|
|
36
36
|
* @description Replace the br-line tag of the current selection.
|
|
37
37
|
* @param {Node} element BR-Line element (PRE..)
|
|
@@ -42,30 +42,48 @@ declare class Format {
|
|
|
42
42
|
/**
|
|
43
43
|
* @description If a parent node that contains an argument node finds a `brLine` (`format.isBrLine`), it returns that node.
|
|
44
44
|
* @param {Node} element Reference node.
|
|
45
|
-
* @param {?(current:
|
|
45
|
+
* @param {?(current: *) => boolean} [validation] Additional validation function.
|
|
46
46
|
* @returns {HTMLBRElement|null}
|
|
47
47
|
* @example
|
|
48
48
|
* const brLine = editor.$.format.getBrLine(editor.$.selection.getNode());
|
|
49
49
|
*/
|
|
50
|
-
getBrLine(element: Node, validation?: ((current:
|
|
50
|
+
getBrLine(element: Node, validation?: ((current: any) => boolean) | null): HTMLBRElement | null;
|
|
51
51
|
/**
|
|
52
|
-
* @description
|
|
53
|
-
* -
|
|
54
|
-
* -
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
52
|
+
* @description Insert a new line as the next sibling of `element`.
|
|
53
|
+
* - Selection-aware — tag/attributes default to the **currently selected line**, not
|
|
54
|
+
* - `element`'s tag. Use {@link addLineAfter} when the decision must depend only on
|
|
55
|
+
* - `element` (e.g., Enter exiting a heading).
|
|
56
|
+
*
|
|
57
|
+
* - Tag resolution: brLine context → bare `<br>`; else `lineNode` override → current
|
|
58
|
+
* - line clone → `defaultLine`. Attribute copy excludes only `id` (vs `addLineAfter`
|
|
59
|
+
* - which respects `lineAttrReset`). Inside a table cell, inserts within the cell.
|
|
60
|
+
*
|
|
61
|
+
* @param {Node} element Reference element — new line is inserted right after it
|
|
62
|
+
* @param {?(string|Node)} [lineNode] Override: string tag name, or Node whose tag
|
|
63
|
+
* and attributes (except `id`) are copied
|
|
64
|
+
* @returns {HTMLElement} The new line, or a `<br>` in brLine context
|
|
58
65
|
*/
|
|
59
66
|
addLine(element: Node, lineNode?: (string | Node) | null): HTMLElement;
|
|
67
|
+
/**
|
|
68
|
+
* @description Insert a new line after the given block element.
|
|
69
|
+
* Selection-independent — determines tag/attributes from the element itself.
|
|
70
|
+
* - Heading (H1-H6), HR → new default line
|
|
71
|
+
* - LI → new LI with copied attributes
|
|
72
|
+
* - PRE / brLine → new default line (exit brLine)
|
|
73
|
+
* - Normal line → same tag with copied attributes
|
|
74
|
+
* @param {HTMLElement} element The block element to insert after
|
|
75
|
+
* @returns {HTMLElement|null} The newly created element
|
|
76
|
+
*/
|
|
77
|
+
addLineAfter(element: HTMLElement): HTMLElement | null;
|
|
60
78
|
/**
|
|
61
79
|
* @description If a parent node that contains an argument node finds a format node (`format.isBlock`), it returns that node.
|
|
62
80
|
* @param {Node} element Reference node.
|
|
63
|
-
* @param {?(current:
|
|
81
|
+
* @param {?(current: *) => boolean} [validation] Additional validation function.
|
|
64
82
|
* @returns {HTMLElement|null}
|
|
65
83
|
* @example
|
|
66
84
|
* const block = editor.$.format.getBlock(editor.$.selection.getNode());
|
|
67
85
|
*/
|
|
68
|
-
getBlock(element: Node, validation?: ((current:
|
|
86
|
+
getBlock(element: Node, validation?: ((current: any) => boolean) | null): HTMLElement | null;
|
|
69
87
|
/**
|
|
70
88
|
* @description Appended all selected `line` element to the argument element(`block`) and insert
|
|
71
89
|
* @param {Node} blockElement Element of wrap the arguments (BLOCKQUOTE...)
|
|
@@ -218,12 +236,12 @@ declare class Format {
|
|
|
218
236
|
isClosureBrLine(element: Node | string): element is HTMLElement;
|
|
219
237
|
/**
|
|
220
238
|
* @description Returns a `line` array from selected range.
|
|
221
|
-
* @param {?(current:
|
|
239
|
+
* @param {?(current: *) => boolean} [validation] The validation function. (Replaces the default validation `format.isLine(current)`)
|
|
222
240
|
* @returns {Array<HTMLElement>}
|
|
223
241
|
* @example
|
|
224
242
|
* const selectedLines = editor.$.format.getLines();
|
|
225
243
|
*/
|
|
226
|
-
getLines(validation?: ((current:
|
|
244
|
+
getLines(validation?: ((current: any) => boolean) | null): Array<HTMLElement>;
|
|
227
245
|
/**
|
|
228
246
|
* @description Get lines and components from the selected range. (P, DIV, H[1-6], OL, UL, TABLE..)
|
|
229
247
|
* - If some of the component are included in the selection, get the entire that component.
|
|
@@ -17,7 +17,7 @@ declare class HTML {
|
|
|
17
17
|
* @param {Object} params - Filtering parameters.
|
|
18
18
|
* @param {string} [params.tagWhitelist] - Allowed tags, specified as a string with tags separated by `'|'`. (e.g. `"div|p|span"`).
|
|
19
19
|
* @param {string} [params.tagBlacklist] - Disallowed tags, specified as a string with tags separated by `'|'`. (e.g. `"script|iframe"`).
|
|
20
|
-
* @param {(node:
|
|
20
|
+
* @param {(node: *) => Node | string | null} [params.validate] - Function to validate and modify individual nodes.
|
|
21
21
|
* - Return `null` to remove the node.
|
|
22
22
|
* - Return a `Node` to replace the current node.
|
|
23
23
|
* - Return a `string` to replace the node's `outerHTML`.
|
|
@@ -54,7 +54,7 @@ declare class HTML {
|
|
|
54
54
|
}: {
|
|
55
55
|
tagWhitelist?: string;
|
|
56
56
|
tagBlacklist?: string;
|
|
57
|
-
validate?: (node:
|
|
57
|
+
validate?: (node: any) => Node | string | null;
|
|
58
58
|
validateAll?: boolean;
|
|
59
59
|
},
|
|
60
60
|
): string;
|
|
@@ -185,7 +185,15 @@ declare class HTML {
|
|
|
185
185
|
* const html = editor.$.html.get();
|
|
186
186
|
* const htmlWithFrame = editor.$.html.get({ withFrame: true });
|
|
187
187
|
*/
|
|
188
|
-
get({
|
|
188
|
+
get({
|
|
189
|
+
withFrame,
|
|
190
|
+
includeFullPage,
|
|
191
|
+
rootKey,
|
|
192
|
+
}?: {
|
|
193
|
+
withFrame?: boolean;
|
|
194
|
+
includeFullPage?: boolean;
|
|
195
|
+
rootKey?: number | Array<number>;
|
|
196
|
+
}): string | any;
|
|
189
197
|
/**
|
|
190
198
|
* @description Sets the HTML string to the editor content
|
|
191
199
|
* @param {string} html HTML string
|
|
@@ -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
|
*/
|