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.
Files changed (217) hide show
  1. package/dist/suneditor-contents.min.css +1 -1
  2. package/dist/suneditor.min.css +28 -1
  3. package/dist/suneditor.min.js +1 -1
  4. package/package.json +2 -1
  5. package/src/assets/design/color.css +12 -0
  6. package/src/assets/design/size.css +9 -2
  7. package/src/assets/icons/defaultIcons.js +96 -47
  8. package/src/assets/suneditor-contents.css +3 -2
  9. package/src/assets/suneditor.css +481 -31
  10. package/src/core/config/contextProvider.js +2 -1
  11. package/src/core/config/eventManager.js +41 -2
  12. package/src/core/config/optionProvider.js +23 -2
  13. package/src/core/editor.js +32 -14
  14. package/src/core/event/actions/index.js +76 -9
  15. package/src/core/event/effects/common.registry.js +2 -1
  16. package/src/core/event/effects/keydown.registry.js +169 -33
  17. package/src/core/event/effects/ruleHelpers.js +20 -6
  18. package/src/core/event/eventOrchestrator.js +162 -30
  19. package/src/core/event/handlers/handler_toolbar.js +4 -2
  20. package/src/core/event/handlers/handler_ww_dragDrop.js +10 -0
  21. package/src/core/event/handlers/handler_ww_input.js +84 -2
  22. package/src/core/event/handlers/handler_ww_key.js +82 -21
  23. package/src/core/event/handlers/handler_ww_mouse.js +45 -8
  24. package/src/core/event/ports.js +27 -13
  25. package/src/core/event/reducers/keydown.reducer.js +33 -5
  26. package/src/core/event/rules/keydown.rule.arrow.js +12 -2
  27. package/src/core/event/rules/keydown.rule.backspace.js +110 -15
  28. package/src/core/event/rules/keydown.rule.delete.js +62 -7
  29. package/src/core/event/rules/keydown.rule.enter.js +62 -31
  30. package/src/core/event/support/defaultLineManager.js +9 -2
  31. package/src/core/event/support/selectionState.js +13 -3
  32. package/src/core/kernel/coreKernel.js +1 -0
  33. package/src/core/logic/dom/char.js +13 -3
  34. package/src/core/logic/dom/format.js +171 -39
  35. package/src/core/logic/dom/html.js +350 -72
  36. package/src/core/logic/dom/inline.js +229 -34
  37. package/src/core/logic/dom/listFormat.js +111 -20
  38. package/src/core/logic/dom/nodeTransform.js +36 -11
  39. package/src/core/logic/dom/offset.js +116 -31
  40. package/src/core/logic/dom/selection.js +147 -29
  41. package/src/core/logic/panel/blockHandle.js +785 -0
  42. package/src/core/logic/panel/blockResolver.js +278 -0
  43. package/src/core/logic/panel/finder.js +16 -6
  44. package/src/core/logic/panel/menu.js +119 -18
  45. package/src/core/logic/panel/toolbar.js +75 -19
  46. package/src/core/logic/panel/viewer.js +76 -20
  47. package/src/core/logic/shell/_commandExecutor.js +44 -9
  48. package/src/core/logic/shell/commandDispatcher.js +46 -4
  49. package/src/core/logic/shell/component.js +102 -25
  50. package/src/core/logic/shell/focusManager.js +13 -3
  51. package/src/core/logic/shell/history.js +21 -6
  52. package/src/core/logic/shell/pluginManager.js +21 -13
  53. package/src/core/logic/shell/shortcuts.js +9 -1
  54. package/src/core/logic/shell/ui.js +139 -37
  55. package/src/core/schema/frameContext.js +34 -3
  56. package/src/core/schema/options.js +46 -4
  57. package/src/core/section/constructor.js +537 -106
  58. package/src/core/section/documentType.js +35 -6
  59. package/src/helper/converter.js +24 -7
  60. package/src/helper/dom/domCheck.js +25 -5
  61. package/src/helper/dom/domQuery.js +2 -1
  62. package/src/helper/dom/domUtils.js +17 -4
  63. package/src/helper/env.js +11 -2
  64. package/src/helper/keyCodeMap.js +6 -2
  65. package/src/helper/markdown.js +24 -5
  66. package/src/helper/msOffice.js +9 -2
  67. package/src/interfaces/plugins.js +1 -1
  68. package/src/langs/ckb.js +0 -1
  69. package/src/langs/cs.js +0 -1
  70. package/src/langs/da.js +0 -1
  71. package/src/langs/de.js +0 -1
  72. package/src/langs/en.js +0 -1
  73. package/src/langs/es.js +0 -1
  74. package/src/langs/fa.js +0 -1
  75. package/src/langs/fr.js +0 -1
  76. package/src/langs/he.js +0 -1
  77. package/src/langs/hu.js +0 -1
  78. package/src/langs/index.js +27 -1
  79. package/src/langs/it.js +0 -1
  80. package/src/langs/ja.js +0 -1
  81. package/src/langs/km.js +0 -1
  82. package/src/langs/ko.js +0 -1
  83. package/src/langs/lv.js +0 -1
  84. package/src/langs/nl.js +0 -1
  85. package/src/langs/pl.js +0 -1
  86. package/src/langs/pt_br.js +0 -1
  87. package/src/langs/ro.js +0 -1
  88. package/src/langs/ru.js +0 -1
  89. package/src/langs/se.js +0 -1
  90. package/src/langs/tr.js +0 -1
  91. package/src/langs/uk.js +0 -1
  92. package/src/langs/ur.js +0 -1
  93. package/src/langs/zh_cn.js +0 -1
  94. package/src/modules/contract/Browser.js +58 -14
  95. package/src/modules/contract/ColorPicker.js +12 -4
  96. package/src/modules/contract/Controller.js +37 -7
  97. package/src/modules/contract/Figure.js +156 -36
  98. package/src/modules/contract/HueSlider.js +27 -4
  99. package/src/modules/contract/Modal.js +50 -10
  100. package/src/modules/manager/FileManager.js +50 -8
  101. package/src/modules/ui/CommandMenu.js +597 -0
  102. package/src/modules/ui/ModalAnchorEditor.js +33 -6
  103. package/src/modules/ui/SelectMenu.js +481 -36
  104. package/src/modules/ui/index.js +1 -0
  105. package/src/plugins/browser/audioGallery.js +2 -1
  106. package/src/plugins/browser/fileBrowser.js +9 -2
  107. package/src/plugins/browser/fileGallery.js +2 -1
  108. package/src/plugins/browser/imageGallery.js +18 -3
  109. package/src/plugins/browser/videoGallery.js +13 -4
  110. package/src/plugins/command/blockquote.js +6 -1
  111. package/src/plugins/command/codeBlock.js +43 -5
  112. package/src/plugins/command/exportPDF.js +20 -4
  113. package/src/plugins/command/fileUpload.js +46 -11
  114. package/src/plugins/command/list_bulleted.js +6 -1
  115. package/src/plugins/command/list_numbered.js +6 -1
  116. package/src/plugins/dropdown/align.js +21 -33
  117. package/src/plugins/dropdown/backgroundColor.js +10 -2
  118. package/src/plugins/dropdown/blockStyle.js +17 -22
  119. package/src/plugins/dropdown/font.js +34 -34
  120. package/src/plugins/dropdown/hr.js +15 -43
  121. package/src/plugins/dropdown/layout.js +10 -27
  122. package/src/plugins/dropdown/lineHeight.js +10 -33
  123. package/src/plugins/dropdown/list.js +19 -25
  124. package/src/plugins/dropdown/paragraphStyle.js +16 -24
  125. package/src/plugins/dropdown/table/index.js +72 -17
  126. package/src/plugins/dropdown/table/render/table.html.js +3 -1
  127. package/src/plugins/dropdown/table/services/table.cell.js +33 -7
  128. package/src/plugins/dropdown/table/services/table.clipboard.js +5 -1
  129. package/src/plugins/dropdown/table/services/table.grid.js +40 -9
  130. package/src/plugins/dropdown/table/services/table.resize.js +55 -11
  131. package/src/plugins/dropdown/table/services/table.selection.js +27 -7
  132. package/src/plugins/dropdown/table/services/table.style.js +120 -20
  133. package/src/plugins/dropdown/template.js +13 -29
  134. package/src/plugins/dropdown/textStyle.js +22 -35
  135. package/src/plugins/field/autocomplete.js +8 -4
  136. package/src/plugins/field/slashCommand.js +297 -0
  137. package/src/plugins/index.js +3 -0
  138. package/src/plugins/input/fontSize.js +37 -8
  139. package/src/plugins/input/pageNavigator.js +7 -1
  140. package/src/plugins/modal/audio.js +71 -17
  141. package/src/plugins/modal/drawing.js +41 -11
  142. package/src/plugins/modal/embed.js +92 -22
  143. package/src/plugins/modal/image/index.js +114 -28
  144. package/src/plugins/modal/image/services/image.size.js +9 -2
  145. package/src/plugins/modal/image/services/image.upload.js +38 -4
  146. package/src/plugins/modal/link.js +9 -2
  147. package/src/plugins/modal/math.js +10 -2
  148. package/src/plugins/modal/video/index.js +112 -26
  149. package/src/plugins/modal/video/render/video.html.js +4 -1
  150. package/src/plugins/modal/video/services/video.size.js +15 -4
  151. package/src/plugins/modal/video/services/video.upload.js +10 -2
  152. package/src/plugins/popup/anchor.js +14 -2
  153. package/src/suneditor.js +8 -2
  154. package/src/themes/cobalt.css +12 -0
  155. package/src/themes/cream.css +12 -0
  156. package/src/themes/dark.css +12 -0
  157. package/src/themes/midnight.css +12 -0
  158. package/src/typedef.js +32 -21
  159. package/types/assets/icons/defaultIcons.d.ts +1 -0
  160. package/types/core/config/contextProvider.d.ts +7 -1
  161. package/types/core/config/eventManager.d.ts +37 -4
  162. package/types/core/config/optionProvider.d.ts +5 -1
  163. package/types/core/event/actions/index.d.ts +44 -6
  164. package/types/core/event/effects/keydown.registry.d.ts +37 -7
  165. package/types/core/event/effects/ruleHelpers.d.ts +6 -1
  166. package/types/core/event/eventOrchestrator.d.ts +13 -3
  167. package/types/core/event/handlers/handler_ww_clipboard.d.ts +15 -3
  168. package/types/core/event/handlers/handler_ww_dragDrop.d.ts +14 -2
  169. package/types/core/event/handlers/handler_ww_input.d.ts +10 -2
  170. package/types/core/event/handlers/handler_ww_key.d.ts +10 -2
  171. package/types/core/event/handlers/handler_ww_mouse.d.ts +25 -5
  172. package/types/core/event/ports.d.ts +11 -4
  173. package/types/core/event/reducers/keydown.reducer.d.ts +12 -3
  174. package/types/core/event/rules/keydown.rule.backspace.d.ts +6 -1
  175. package/types/core/kernel/store.d.ts +4 -1
  176. package/types/core/logic/dom/format.d.ts +32 -14
  177. package/types/core/logic/dom/html.d.ts +11 -3
  178. package/types/core/logic/dom/nodeTransform.d.ts +6 -6
  179. package/types/core/logic/panel/blockHandle.d.ts +64 -0
  180. package/types/core/logic/panel/blockResolver.d.ts +50 -0
  181. package/types/core/logic/panel/menu.d.ts +72 -3
  182. package/types/core/logic/shell/commandDispatcher.d.ts +8 -0
  183. package/types/core/logic/shell/component.d.ts +5 -3
  184. package/types/core/logic/shell/shortcuts.d.ts +10 -1
  185. package/types/core/logic/shell/ui.d.ts +7 -1
  186. package/types/core/schema/context.d.ts +7 -1
  187. package/types/core/schema/frameContext.d.ts +36 -4
  188. package/types/core/schema/options.d.ts +83 -2
  189. package/types/core/section/constructor.d.ts +38 -1
  190. package/types/events.d.ts +208 -32
  191. package/types/helper/converter.d.ts +4 -2
  192. package/types/helper/dom/domCheck.d.ts +12 -2
  193. package/types/helper/dom/domQuery.d.ts +35 -7
  194. package/types/helper/dom/domUtils.d.ts +4 -1
  195. package/types/interfaces/plugins.d.ts +2 -2
  196. package/types/langs/_Lang.d.ts +0 -1
  197. package/types/modules/contract/ColorPicker.d.ts +2 -2
  198. package/types/modules/contract/Controller.d.ts +7 -0
  199. package/types/modules/contract/Figure.d.ts +31 -4
  200. package/types/modules/ui/CommandMenu.d.ts +262 -0
  201. package/types/modules/ui/SelectMenu.d.ts +56 -3
  202. package/types/modules/ui/index.d.ts +1 -0
  203. package/types/plugins/browser/audioGallery.d.ts +1 -1
  204. package/types/plugins/browser/fileBrowser.d.ts +1 -1
  205. package/types/plugins/browser/fileGallery.d.ts +1 -1
  206. package/types/plugins/browser/imageGallery.d.ts +1 -1
  207. package/types/plugins/browser/videoGallery.d.ts +1 -1
  208. package/types/plugins/dropdown/align.d.ts +1 -1
  209. package/types/plugins/dropdown/blockStyle.d.ts +3 -1
  210. package/types/plugins/dropdown/table/index.d.ts +4 -1
  211. package/types/plugins/dropdown/table/services/table.clipboard.d.ts +5 -1
  212. package/types/plugins/dropdown/table/services/table.grid.d.ts +10 -2
  213. package/types/plugins/field/autocomplete.d.ts +0 -1
  214. package/types/plugins/field/slashCommand.d.ts +165 -0
  215. package/types/plugins/index.d.ts +3 -0
  216. package/types/plugins/modal/link.d.ts +4 -1
  217. package/types/typedef.d.ts +48 -23
@@ -83,7 +83,7 @@ declare class VideoGallery extends PluginBrowser {
83
83
  */
84
84
  constructor(kernel: SunEditor.Kernel, pluginOptions: VideoGalleryPluginOptions);
85
85
  title: any;
86
- onSelectfunction: (target: Node) => any;
86
+ onSelectfunction: (target: any) => any;
87
87
  browser: Browser;
88
88
  width: any;
89
89
  height: any;
@@ -21,7 +21,6 @@ declare class Align extends PluginDropdown {
21
21
  */
22
22
  constructor(kernel: SunEditor.Kernel, pluginOptions: AlignPluginOptions);
23
23
  title: any;
24
- _itemMenu: HTMLUListElement;
25
24
  defaultDir: string;
26
25
  alignIcons: {
27
26
  justify: any;
@@ -29,6 +28,7 @@ declare class Align extends PluginDropdown {
29
28
  right: any;
30
29
  center: any;
31
30
  };
31
+ _itemMenu: HTMLUListElement;
32
32
  alignList: NodeListOf<Element>;
33
33
  active(element: HTMLElement | null, target: HTMLElement | null): boolean | void;
34
34
  setDir(dir: string): void;
@@ -16,7 +16,9 @@ export type BlockStylePluginOptions = {
16
16
  * ['p', 'h1', 'h2', 'blockquote', { tag: 'div', command: 'block', name: 'Custom Block', class: 'my-block' }]
17
17
  * ```
18
18
  */
19
- items?: Array<'p' | 'div' | 'blockquote' | 'pre' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | string | BlockStyleItem>;
19
+ items?: Array<
20
+ 'p' | 'div' | 'blockquote' | 'pre' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | string | BlockStyleItem
21
+ >;
20
22
  };
21
23
  /**
22
24
  * @typedef {{tag: string, command: "line"|"br-line"|"block", name?: string, class?: string}} BlockStyleItem
@@ -79,7 +79,10 @@ declare class Table extends PluginDropdownFree {
79
79
  * @param {K} key
80
80
  * @param {import('./shared/table.constants').TableState[K]} value
81
81
  */
82
- setState<K extends keyof import('./shared/table.constants').TableState>(key: K, value: import('./shared/table.constants').TableState[K]): void;
82
+ setState<K extends keyof import('./shared/table.constants').TableState>(
83
+ key: K,
84
+ value: import('./shared/table.constants').TableState[K],
85
+ ): void;
83
86
  componentSelect(target: HTMLElement): void | boolean;
84
87
  componentDeselect(target: HTMLElement): void;
85
88
  componentDestroy(target: HTMLElement): Promise<void>;
@@ -13,7 +13,11 @@ export class TableClipboardService {
13
13
  * @param {HTMLElement} container - The container element
14
14
  * @param {NodeListOf<HTMLTableCellElement>} selectedCells - The selected table cells
15
15
  */
16
- copySelectedTableCells(e: ClipboardEvent, container: HTMLElement, selectedCells: NodeListOf<HTMLTableCellElement>): void;
16
+ copySelectedTableCells(
17
+ e: ClipboardEvent,
18
+ container: HTMLElement,
19
+ selectedCells: NodeListOf<HTMLTableCellElement>,
20
+ ): void;
17
21
  /**
18
22
  * @description Updates the target table's cells with the data from the copied table.
19
23
  * @param {HTMLTableElement} copyTable The table containing the copied data.
@@ -52,7 +52,11 @@ export class TableGridService {
52
52
  * @param {?HTMLTableCellElement} [positionResetElement] The element to reset the position of (optional). This can be the cell that triggered the column edit.
53
53
  * @returns {HTMLTableCellElement} Target table cell
54
54
  */
55
- editColumn(option: string | null, targetCell?: HTMLTableCellElement | null, positionResetElement?: HTMLTableCellElement | null): HTMLTableCellElement;
55
+ editColumn(
56
+ option: string | null,
57
+ targetCell?: HTMLTableCellElement | null,
58
+ positionResetElement?: HTMLTableCellElement | null,
59
+ ): HTMLTableCellElement;
56
60
  /**
57
61
  * @description Edits a table row, either adding, removing, the row
58
62
  * @param {?string} option The action to perform on the row (`up`|`down`|`null`)
@@ -62,7 +66,11 @@ export class TableGridService {
62
66
  * @param {?HTMLTableCellElement} [targetCell] Target cell, (default: current selected cell)
63
67
  * @param {?HTMLTableCellElement} [positionResetElement] The element to reset the position of (optional). This can be the cell that triggered the row edit.
64
68
  */
65
- editRow(option: string | null, targetCell?: HTMLTableCellElement | null, positionResetElement?: HTMLTableCellElement | null): void;
69
+ editRow(
70
+ option: string | null,
71
+ targetCell?: HTMLTableCellElement | null,
72
+ positionResetElement?: HTMLTableCellElement | null,
73
+ ): void;
66
74
  /**
67
75
  * @description Inserts a new row into the table at the specified index to it.
68
76
  * @param {HTMLTableElement} table The table element to insert the row into.
@@ -238,7 +238,6 @@ declare class Autocomplete extends PluginField {
238
238
  * @param {AutocompletePluginOptions} pluginOptions
239
239
  */
240
240
  constructor(kernel: SunEditor.Kernel, pluginOptions: AutocompletePluginOptions);
241
- title: any;
242
241
  triggerContexts: Map<any, any>;
243
242
  sortedTriggers: any[];
244
243
  selectMenu: SelectMenu;
@@ -0,0 +1,165 @@
1
+ import type {} from '../../typedef';
2
+ export default SlashCommand;
3
+ export type SlashCommandItem = {
4
+ /**
5
+ * - Unique identifier for the item.
6
+ */
7
+ key: string;
8
+ /**
9
+ * - Display label.
10
+ */
11
+ title: string;
12
+ /**
13
+ * - Icon key from `$.icons` (e.g. `'h1'`) or a raw HTML string (e.g. `'<svg>...</svg>'`).
14
+ */
15
+ icon?: string;
16
+ /**
17
+ * - Extra search terms used in addition to the title.
18
+ */
19
+ keywords?: string[];
20
+ /**
21
+ * - Invoked when the item is selected.
22
+ * The trigger string (e.g. `/hea`) is already removed from the editor and the caret restored to that position before `action` runs.
23
+ * The action owns its history entry — calling an L3 wrapper (`$.html.*`, `$.format.*`, `$.inline.apply`) auto-pushes; otherwise call `$.history.push(false)` manually.
24
+ */
25
+ action: (arg0: SunEditor.Deps, arg1: SlashCommandActionContext) => void | Promise<void>;
26
+ };
27
+ export type SlashCommandActionContext = {
28
+ /**
29
+ * - The configured trigger character (e.g. `'/'`).
30
+ */
31
+ triggerChar: string;
32
+ /**
33
+ * - The text the user typed after the trigger (e.g. `'hea'`).
34
+ */
35
+ query: string;
36
+ /**
37
+ * - The selected item.
38
+ */
39
+ item: SlashCommandItem;
40
+ };
41
+ export type SlashCommandPluginOptions = {
42
+ /**
43
+ * - Character that opens the command menu. Single character recommended.
44
+ */
45
+ triggerChar?: string;
46
+ /**
47
+ * - Menu entries. Strings resolve via `ResolveButton`
48
+ * (plugin names, built-in commands like `'bold'`); objects are custom items with their own `action`.
49
+ * Required.
50
+ */
51
+ items: Array<SlashCommandItem | string>;
52
+ /**
53
+ * - Debounce delay (ms) before the input is inspected for the trigger.
54
+ */
55
+ delayTime?: number;
56
+ /**
57
+ * - Maximum number of items shown in the dropdown.
58
+ */
59
+ limitSize?: number;
60
+ /**
61
+ * - Message shown when no items match the query. If unset, the menu closes on no match.
62
+ */
63
+ emptyMessage?: string;
64
+ /**
65
+ * - Custom item HTML renderer.
66
+ * Applied only to custom item objects; plugin-name entries always render with the canonical BlockHandle row.
67
+ * ```js
68
+ * SUNEDITOR.create('#editor', {
69
+ * plugins: [slashCommand],
70
+ * slashCommand: {
71
+ * triggerChar: '/',
72
+ * items: [
73
+ * {
74
+ * key: 'h1',
75
+ * title: 'Heading 1',
76
+ * icon: 'h1',
77
+ * keywords: ['header', 'title'],
78
+ * action: ($) => $.format.applyBlock(document.createElement('H1')),
79
+ * },
80
+ * 'bold',
81
+ * 'image',
82
+ * 'blockStyle',
83
+ * ],
84
+ * },
85
+ * });
86
+ * ```
87
+ */
88
+ renderItem?: (
89
+ arg0: SlashCommandItem,
90
+ arg1: {
91
+ icons: any;
92
+ },
93
+ ) => string;
94
+ };
95
+ /**
96
+ * @typedef {Object} SlashCommandItem
97
+ * @property {string} key - Unique identifier for the item.
98
+ * @property {string} title - Display label.
99
+ * @property {string} [icon] - Icon key from `$.icons` (e.g. `'h1'`) or a raw HTML string (e.g. `'<svg>...</svg>'`).
100
+ * @property {string[]} [keywords] - Extra search terms used in addition to the title.
101
+ * @property {function(SunEditor.Deps, SlashCommandActionContext): void | Promise<void>} action - Invoked when the item is selected.
102
+ * The trigger string (e.g. `/hea`) is already removed from the editor and the caret restored to that position before `action` runs.
103
+ * The action owns its history entry — calling an L3 wrapper (`$.html.*`, `$.format.*`, `$.inline.apply`) auto-pushes; otherwise call `$.history.push(false)` manually.
104
+ */
105
+ /**
106
+ * @typedef {Object} SlashCommandActionContext
107
+ * @property {string} triggerChar - The configured trigger character (e.g. `'/'`).
108
+ * @property {string} query - The text the user typed after the trigger (e.g. `'hea'`).
109
+ * @property {SlashCommandItem} item - The selected item.
110
+ */
111
+ /**
112
+ * @typedef {Object} SlashCommandPluginOptions
113
+ * @property {string} [triggerChar='/'] - Character that opens the command menu. Single character recommended.
114
+ * @property {Array<SlashCommandItem | string>} items - Menu entries. Strings resolve via `ResolveButton`
115
+ * (plugin names, built-in commands like `'bold'`); objects are custom items with their own `action`.
116
+ * Required.
117
+ * @property {number} [delayTime=120] - Debounce delay (ms) before the input is inspected for the trigger.
118
+ * @property {number} [limitSize=10] - Maximum number of items shown in the dropdown.
119
+ * @property {string} [emptyMessage] - Message shown when no items match the query. If unset, the menu closes on no match.
120
+ * @property {function(SlashCommandItem, { icons: Object }): string} [renderItem] - Custom item HTML renderer.
121
+ * Applied only to custom item objects; plugin-name entries always render with the canonical BlockHandle row.
122
+ * ```js
123
+ * SUNEDITOR.create('#editor', {
124
+ * plugins: [slashCommand],
125
+ * slashCommand: {
126
+ * triggerChar: '/',
127
+ * items: [
128
+ * {
129
+ * key: 'h1',
130
+ * title: 'Heading 1',
131
+ * icon: 'h1',
132
+ * keywords: ['header', 'title'],
133
+ * action: ($) => $.format.applyBlock(document.createElement('H1')),
134
+ * },
135
+ * 'bold',
136
+ * 'image',
137
+ * 'blockStyle',
138
+ * ],
139
+ * },
140
+ * });
141
+ * ```
142
+ */
143
+ /**
144
+ * @class
145
+ * @description Slash Command plugin
146
+ * - Notion / Tiptap style "/" command menu. Triggered by the configured character (default `'/'`).
147
+ * - Menu rendering + dispatch is delegated to {@link CommandMenu}, which is also used by BlockHandle's
148
+ * action menu — both menus share the exact same row HTML and dispatch behavior.
149
+ * - SlashCommand-specific concerns kept here: input watching, debounce, trigger detection,
150
+ * trigger text deletion before dispatch, empty-state row.
151
+ */
152
+ declare class SlashCommand extends PluginField {
153
+ /**
154
+ * @constructor
155
+ * @param {SunEditor.Kernel} kernel
156
+ * @param {SlashCommandPluginOptions} pluginOptions
157
+ */
158
+ constructor(kernel: SunEditor.Kernel, pluginOptions: SlashCommandPluginOptions);
159
+ controller: Controller;
160
+ onInput(params: SunEditor.HookParams.InputWithData): void;
161
+ onKeyDown(params: SunEditor.HookParams.KeyEvent): void | boolean;
162
+ #private;
163
+ }
164
+ import { PluginField } from '../../interfaces';
165
+ import { Controller } from '../../modules/contract';
@@ -7,6 +7,7 @@ declare namespace _default {
7
7
  export { list_bulleted };
8
8
  export { list_numbered };
9
9
  export { autocomplete };
10
+ export { slashCommand };
10
11
  export { align };
11
12
  export { font };
12
13
  export { fontColor };
@@ -62,6 +63,7 @@ import table from './dropdown/table';
62
63
  import template from './dropdown/template';
63
64
  import textStyle from './dropdown/textStyle';
64
65
  import autocomplete from './field/autocomplete';
66
+ import slashCommand from './field/slashCommand';
65
67
  import fontSize from './input/fontSize';
66
68
  import pageNavigator from './input/pageNavigator';
67
69
  import audio from './modal/audio';
@@ -103,6 +105,7 @@ export {
103
105
  math,
104
106
  pageNavigator,
105
107
  paragraphStyle,
108
+ slashCommand,
106
109
  table,
107
110
  template,
108
111
  textStyle,
@@ -36,7 +36,10 @@ export type LinkOptions = {
36
36
  */
37
37
  acceptedFormats?: string;
38
38
  };
39
- export type LinkPluginOptions = Omit<LinkOptions & import('../../modules/ui/ModalAnchorEditor').ModalAnchorEditorParams, ''>;
39
+ export type LinkPluginOptions = Omit<
40
+ LinkOptions & import('../../modules/ui/ModalAnchorEditor').ModalAnchorEditorParams,
41
+ ''
42
+ >;
40
43
  /**
41
44
  * @typedef {Object} LinkOptions
42
45
  * @property {string} [uploadUrl] - The URL endpoint for file uploads.
@@ -17,6 +17,20 @@ declare global {
17
17
  type EventWysiwyg = HTMLElement & Window;
18
18
  type WysiwygFrame = HTMLElement & HTMLIFrameElement;
19
19
  type GlobalWindow = Window & typeof globalThis;
20
+ type ComponentLauncher = {
21
+ /**
22
+ * - Delete hook (invoked by the selected-component keydown handler).
23
+ */
24
+ componentDestroy?: (target: any) => void | Promise<void>;
25
+ /**
26
+ * - Optional select hook.
27
+ */
28
+ componentSelect?: (target: any) => boolean | void;
29
+ /**
30
+ * - Optional deselect hook.
31
+ */
32
+ componentDeselect?: (target: any) => void;
33
+ };
20
34
  type ComponentInfo = {
21
35
  /**
22
36
  * - The target element associated with the component.
@@ -53,9 +67,9 @@ declare global {
53
67
  */
54
68
  isFile: boolean;
55
69
  /**
56
- * - The element that triggered the component, if applicable.
70
+ * - Hook object for non-plugin components (e.g. `pageBreak`), if applicable.
57
71
  */
58
- launcher: HTMLElement | null;
72
+ launcher: SunEditor.ComponentLauncher | null;
59
73
  /**
60
74
  * - Whether the component is an input component (e.g., table).
61
75
  */
@@ -117,35 +131,35 @@ declare global {
117
131
  type Init = typeof import('./hooks/base').Core.Init;
118
132
  }
119
133
  namespace Component {
120
- type Select = typeof import('./interfaces/contracts').EditorComponent.prototype.componentSelect;
121
- type Deselect = typeof import('./interfaces/contracts').EditorComponent.prototype.componentDeselect;
122
- type Edit = typeof import('./interfaces/contracts').EditorComponent.prototype.componentEdit;
123
- type Destroy = typeof import('./interfaces/contracts').EditorComponent.prototype.componentDestroy;
124
- type Copy = typeof import('./interfaces/contracts').EditorComponent.prototype.componentCopy;
134
+ type Select = import('./interfaces/contracts').EditorComponent['componentSelect'];
135
+ type Deselect = import('./interfaces/contracts').EditorComponent['componentDeselect'];
136
+ type Edit = import('./interfaces/contracts').EditorComponent['componentEdit'];
137
+ type Destroy = import('./interfaces/contracts').EditorComponent['componentDestroy'];
138
+ type Copy = import('./interfaces/contracts').EditorComponent['componentCopy'];
125
139
  }
126
140
  namespace Modal {
127
- type Action = typeof import('./interfaces/contracts').ModuleModal.prototype.modalAction;
128
- type On = typeof import('./interfaces/contracts').ModuleModal.prototype.modalOn;
129
- type Init = typeof import('./interfaces/contracts').ModuleModal.prototype.modalInit;
130
- type Off = typeof import('./interfaces/contracts').ModuleModal.prototype.modalOff;
131
- type Resize = typeof import('./interfaces/contracts').ModuleModal.prototype.modalResize;
141
+ type Action = import('./interfaces/contracts').ModuleModal['modalAction'];
142
+ type On = import('./interfaces/contracts').ModuleModal['modalOn'];
143
+ type Init = import('./interfaces/contracts').ModuleModal['modalInit'];
144
+ type Off = import('./interfaces/contracts').ModuleModal['modalOff'];
145
+ type Resize = import('./interfaces/contracts').ModuleModal['modalResize'];
132
146
  }
133
147
  namespace Controller {
134
- type Action = typeof import('./interfaces/contracts').ModuleController.prototype.controllerAction;
135
- type On = typeof import('./interfaces/contracts').ModuleController.prototype.controllerOn;
136
- type Close = typeof import('./interfaces/contracts').ModuleController.prototype.controllerClose;
148
+ type Action = import('./interfaces/contracts').ModuleController['controllerAction'];
149
+ type On = import('./interfaces/contracts').ModuleController['controllerOn'];
150
+ type Close = import('./interfaces/contracts').ModuleController['controllerClose'];
137
151
  }
138
152
  namespace Browser {
139
- type Init = typeof import('./interfaces/contracts').ModuleBrowser.prototype.browserInit;
153
+ type Init = import('./interfaces/contracts').ModuleBrowser['browserInit'];
140
154
  }
141
155
  namespace ColorPicker {
142
- type Action = typeof import('./interfaces/contracts').ModuleColorPicker.prototype.colorPickerAction;
143
- type HueSliderOpen = typeof import('./interfaces/contracts').ModuleColorPicker.prototype.colorPickerHueSliderOpen;
144
- type HueSliderClose = typeof import('./interfaces/contracts').ModuleColorPicker.prototype.colorPickerHueSliderClose;
156
+ type Action = import('./interfaces/contracts').ModuleColorPicker['colorPickerAction'];
157
+ type HueSliderOpen = import('./interfaces/contracts').ModuleColorPicker['colorPickerHueSliderOpen'];
158
+ type HueSliderClose = import('./interfaces/contracts').ModuleColorPicker['colorPickerHueSliderClose'];
145
159
  }
146
160
  namespace HueSlider {
147
- type Action = typeof import('./interfaces/contracts').ModuleHueSlider.prototype.hueSliderAction;
148
- type CancelAction = typeof import('./interfaces/contracts').ModuleHueSlider.prototype.hueSliderCancelAction;
161
+ type Action = import('./interfaces/contracts').ModuleHueSlider['hueSliderAction'];
162
+ type CancelAction = import('./interfaces/contracts').ModuleHueSlider['hueSliderCancelAction'];
149
163
  }
150
164
  }
151
165
  export namespace HookParams {
@@ -261,7 +275,13 @@ declare global {
261
275
  * - `"#fix"`: RTL direction fix
262
276
  * - `"%100"|"%50"`: Responsive breakpoint (percentage)
263
277
  */
264
- type ButtonSpecial = '|' | '/' | `-${'left' | 'right' | 'center'}` | '#fix' | `:${string}-${string}` | `%${number}`;
278
+ type ButtonSpecial =
279
+ | '|'
280
+ | '/'
281
+ | `-${'left' | 'right' | 'center'}`
282
+ | '#fix'
283
+ | `:${string}-${string}`
284
+ | `%${number}`;
265
285
  /**
266
286
  * Plugin buttons available in the toolbar
267
287
  */
@@ -307,6 +327,7 @@ declare global {
307
327
  | 'list_bulleted'
308
328
  | 'list_numbered'
309
329
  | 'autocomplete'
330
+ | 'slashCommand'
310
331
  | 'align'
311
332
  | 'font'
312
333
  | 'fontColor'
@@ -339,7 +360,11 @@ declare global {
339
360
  * Button list configuration for the toolbar
340
361
  * Supports nested arrays, special controls, and responsive breakpoint configurations
341
362
  */
342
- type ButtonItem = SunEditor.UI.ButtonCommand | SunEditor.UI.ButtonPlugin | SunEditor.UI.ButtonSpecial | string;
363
+ type ButtonItem =
364
+ | SunEditor.UI.ButtonCommand
365
+ | SunEditor.UI.ButtonPlugin
366
+ | SunEditor.UI.ButtonSpecial
367
+ | string;
343
368
  /**
344
369
  * ///
345
370
  * ---[ End of auto-generated button types ]---