suneditor 3.0.0-rc.4 → 3.0.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.
Files changed (171) hide show
  1. package/README.md +4 -3
  2. package/dist/suneditor-contents.min.css +1 -1
  3. package/dist/suneditor.min.css +1 -1
  4. package/dist/suneditor.min.js +1 -1
  5. package/package.json +10 -6
  6. package/src/assets/design/color.css +14 -2
  7. package/src/assets/design/typography.css +5 -0
  8. package/src/assets/icons/defaultIcons.js +22 -4
  9. package/src/assets/suneditor-contents.css +1 -1
  10. package/src/assets/suneditor.css +312 -18
  11. package/src/core/config/eventManager.js +6 -9
  12. package/src/core/editor.js +1 -1
  13. package/src/core/event/actions/index.js +5 -0
  14. package/src/core/event/effects/keydown.registry.js +25 -0
  15. package/src/core/event/eventOrchestrator.js +69 -2
  16. package/src/core/event/handlers/handler_ww_mouse.js +1 -0
  17. package/src/core/event/rules/keydown.rule.backspace.js +9 -1
  18. package/src/core/kernel/coreKernel.js +4 -0
  19. package/src/core/kernel/store.js +2 -0
  20. package/src/core/logic/dom/char.js +11 -0
  21. package/src/core/logic/dom/format.js +22 -0
  22. package/src/core/logic/dom/html.js +126 -11
  23. package/src/core/logic/dom/nodeTransform.js +13 -0
  24. package/src/core/logic/dom/offset.js +100 -37
  25. package/src/core/logic/dom/selection.js +54 -22
  26. package/src/core/logic/panel/finder.js +982 -0
  27. package/src/core/logic/panel/menu.js +8 -6
  28. package/src/core/logic/panel/toolbar.js +112 -19
  29. package/src/core/logic/panel/viewer.js +214 -43
  30. package/src/core/logic/shell/_commandExecutor.js +7 -1
  31. package/src/core/logic/shell/commandDispatcher.js +1 -1
  32. package/src/core/logic/shell/component.js +5 -7
  33. package/src/core/logic/shell/history.js +24 -0
  34. package/src/core/logic/shell/shortcuts.js +3 -3
  35. package/src/core/logic/shell/ui.js +25 -26
  36. package/src/core/schema/frameContext.js +15 -1
  37. package/src/core/schema/options.js +180 -39
  38. package/src/core/section/constructor.js +61 -20
  39. package/src/core/section/documentType.js +2 -2
  40. package/src/events.js +12 -0
  41. package/src/helper/clipboard.js +1 -1
  42. package/src/helper/converter.js +15 -0
  43. package/src/helper/dom/domQuery.js +12 -0
  44. package/src/helper/dom/domUtils.js +26 -14
  45. package/src/helper/index.js +3 -0
  46. package/src/helper/markdown.js +876 -0
  47. package/src/interfaces/plugins.js +7 -5
  48. package/src/langs/ckb.js +9 -0
  49. package/src/langs/cs.js +9 -0
  50. package/src/langs/da.js +9 -0
  51. package/src/langs/de.js +9 -0
  52. package/src/langs/en.js +9 -0
  53. package/src/langs/es.js +9 -0
  54. package/src/langs/fa.js +9 -0
  55. package/src/langs/fr.js +9 -0
  56. package/src/langs/he.js +9 -0
  57. package/src/langs/hu.js +9 -0
  58. package/src/langs/it.js +9 -0
  59. package/src/langs/ja.js +9 -0
  60. package/src/langs/km.js +9 -0
  61. package/src/langs/ko.js +9 -0
  62. package/src/langs/lv.js +9 -0
  63. package/src/langs/nl.js +9 -0
  64. package/src/langs/pl.js +9 -0
  65. package/src/langs/pt_br.js +9 -0
  66. package/src/langs/ro.js +9 -0
  67. package/src/langs/ru.js +9 -0
  68. package/src/langs/se.js +9 -0
  69. package/src/langs/tr.js +9 -0
  70. package/src/langs/uk.js +9 -0
  71. package/src/langs/ur.js +9 -0
  72. package/src/langs/zh_cn.js +9 -0
  73. package/src/modules/contract/Browser.js +31 -1
  74. package/src/modules/contract/ColorPicker.js +6 -0
  75. package/src/modules/contract/Controller.js +77 -39
  76. package/src/modules/contract/Figure.js +57 -0
  77. package/src/modules/contract/Modal.js +6 -0
  78. package/src/modules/manager/ApiManager.js +53 -4
  79. package/src/modules/manager/FileManager.js +18 -1
  80. package/src/modules/ui/ModalAnchorEditor.js +35 -2
  81. package/src/modules/ui/SelectMenu.js +44 -12
  82. package/src/plugins/browser/fileBrowser.js +5 -2
  83. package/src/plugins/command/codeBlock.js +324 -0
  84. package/src/plugins/command/exportPDF.js +15 -3
  85. package/src/plugins/command/fileUpload.js +4 -1
  86. package/src/plugins/dropdown/backgroundColor.js +5 -1
  87. package/src/plugins/dropdown/blockStyle.js +8 -2
  88. package/src/plugins/dropdown/fontColor.js +5 -1
  89. package/src/plugins/dropdown/hr.js +6 -0
  90. package/src/plugins/dropdown/layout.js +4 -1
  91. package/src/plugins/dropdown/lineHeight.js +3 -0
  92. package/src/plugins/dropdown/paragraphStyle.js +5 -5
  93. package/src/plugins/dropdown/table/index.js +4 -1
  94. package/src/plugins/dropdown/table/render/table.html.js +1 -1
  95. package/src/plugins/dropdown/table/services/table.grid.js +16 -8
  96. package/src/plugins/dropdown/table/services/table.style.js +5 -9
  97. package/src/plugins/dropdown/template.js +3 -0
  98. package/src/plugins/dropdown/textStyle.js +5 -1
  99. package/src/plugins/field/mention.js +5 -1
  100. package/src/plugins/index.js +3 -0
  101. package/src/plugins/input/fontSize.js +10 -3
  102. package/src/plugins/modal/audio.js +7 -3
  103. package/src/plugins/modal/embed.js +23 -20
  104. package/src/plugins/modal/image/index.js +5 -1
  105. package/src/plugins/modal/math.js +7 -2
  106. package/src/plugins/modal/video/index.js +21 -4
  107. package/src/themes/cobalt.css +13 -4
  108. package/src/themes/cream.css +11 -2
  109. package/src/themes/dark.css +13 -4
  110. package/src/themes/midnight.css +13 -4
  111. package/src/typedef.js +4 -4
  112. package/types/assets/icons/defaultIcons.d.ts +12 -1
  113. package/types/assets/suneditor.css.d.ts +1 -1
  114. package/types/core/config/eventManager.d.ts +6 -8
  115. package/types/core/event/actions/index.d.ts +1 -0
  116. package/types/core/event/effects/keydown.registry.d.ts +2 -0
  117. package/types/core/event/eventOrchestrator.d.ts +2 -1
  118. package/types/core/kernel/coreKernel.d.ts +5 -0
  119. package/types/core/kernel/store.d.ts +5 -0
  120. package/types/core/logic/dom/char.d.ts +11 -0
  121. package/types/core/logic/dom/format.d.ts +22 -0
  122. package/types/core/logic/dom/html.d.ts +16 -0
  123. package/types/core/logic/dom/nodeTransform.d.ts +13 -0
  124. package/types/core/logic/dom/offset.d.ts +23 -2
  125. package/types/core/logic/dom/selection.d.ts +9 -3
  126. package/types/core/logic/panel/finder.d.ts +83 -0
  127. package/types/core/logic/panel/toolbar.d.ts +14 -1
  128. package/types/core/logic/panel/viewer.d.ts +22 -2
  129. package/types/core/logic/shell/shortcuts.d.ts +1 -1
  130. package/types/core/schema/frameContext.d.ts +22 -0
  131. package/types/core/schema/options.d.ts +362 -79
  132. package/types/events.d.ts +11 -0
  133. package/types/helper/converter.d.ts +15 -0
  134. package/types/helper/dom/domQuery.d.ts +12 -0
  135. package/types/helper/dom/domUtils.d.ts +23 -2
  136. package/types/helper/index.d.ts +5 -0
  137. package/types/helper/markdown.d.ts +27 -0
  138. package/types/interfaces/plugins.d.ts +7 -5
  139. package/types/langs/_Lang.d.ts +9 -0
  140. package/types/modules/contract/Browser.d.ts +36 -2
  141. package/types/modules/contract/ColorPicker.d.ts +6 -0
  142. package/types/modules/contract/Controller.d.ts +35 -1
  143. package/types/modules/contract/Figure.d.ts +57 -0
  144. package/types/modules/contract/Modal.d.ts +6 -0
  145. package/types/modules/manager/ApiManager.d.ts +26 -0
  146. package/types/modules/manager/FileManager.d.ts +17 -0
  147. package/types/modules/ui/ModalAnchorEditor.d.ts +41 -4
  148. package/types/modules/ui/SelectMenu.d.ts +40 -2
  149. package/types/plugins/browser/fileBrowser.d.ts +10 -4
  150. package/types/plugins/command/codeBlock.d.ts +53 -0
  151. package/types/plugins/command/fileUpload.d.ts +8 -2
  152. package/types/plugins/dropdown/backgroundColor.d.ts +10 -2
  153. package/types/plugins/dropdown/blockStyle.d.ts +14 -2
  154. package/types/plugins/dropdown/fontColor.d.ts +10 -2
  155. package/types/plugins/dropdown/hr.d.ts +12 -0
  156. package/types/plugins/dropdown/layout.d.ts +8 -2
  157. package/types/plugins/dropdown/lineHeight.d.ts +6 -0
  158. package/types/plugins/dropdown/paragraphStyle.d.ts +14 -3
  159. package/types/plugins/dropdown/table/index.d.ts +9 -3
  160. package/types/plugins/dropdown/template.d.ts +6 -0
  161. package/types/plugins/dropdown/textStyle.d.ts +10 -2
  162. package/types/plugins/field/mention.d.ts +10 -2
  163. package/types/plugins/index.d.ts +3 -0
  164. package/types/plugins/input/fontSize.d.ts +18 -4
  165. package/types/plugins/modal/audio.d.ts +14 -6
  166. package/types/plugins/modal/embed.d.ts +44 -38
  167. package/types/plugins/modal/image/index.d.ts +9 -1
  168. package/types/plugins/modal/link.d.ts +6 -2
  169. package/types/plugins/modal/math.d.ts +23 -5
  170. package/types/plugins/modal/video/index.d.ts +49 -9
  171. package/types/typedef.d.ts +5 -2
@@ -49,6 +49,15 @@ declare class FileManager {
49
49
  * @param {FileList|File[]|{formData: FormData, size: number}} data FormData in body or Files array
50
50
  * @param {?(xmlHttp: XMLHttpRequest) => boolean} [callBack] Success call back function
51
51
  * @param {?(res: *, xmlHttp: XMLHttpRequest) => string} [errorCallBack] Error call back function
52
+ * @example
53
+ * // Upload with a File array
54
+ * const files = [new File(['content'], 'photo.jpg', { type: 'image/jpeg' })];
55
+ * fileManager.upload('/api/upload', { Authorization: 'Bearer token' }, files, onSuccess, onError);
56
+ *
57
+ * // Upload with a pre-built FormData
58
+ * const formData = new FormData();
59
+ * formData.append('file-0', myFile);
60
+ * fileManager.upload('/api/upload', null, { formData, size: 1 }, onSuccess, onError);
52
61
  */
53
62
  upload(
54
63
  uploadUrl: string,
@@ -71,6 +80,10 @@ declare class FileManager {
71
80
  * @param {?Object<string, string>} uploadHeader Request header
72
81
  * @param {FileList|File[]|{formData: FormData, size: number}} data FormData in body or Files array
73
82
  * @returns {Promise<XMLHttpRequest>}
83
+ * @example
84
+ * const files = [new File(['content'], 'photo.jpg')];
85
+ * const xmlHttp = await fileManager.asyncUpload('/api/upload', { Authorization: 'Bearer token' }, files);
86
+ * const response = JSON.parse(xmlHttp.responseText);
74
87
  */
75
88
  asyncUpload(
76
89
  uploadUrl: string,
@@ -92,6 +105,10 @@ declare class FileManager {
92
105
  * @param {string} params.name File name
93
106
  * @param {number} params.size File size
94
107
  * @returns
108
+ * @example
109
+ * const imgElement = document.createElement('img');
110
+ * imgElement.src = 'https://example.com/photo.jpg';
111
+ * fileManager.setFileData(imgElement, { name: 'photo.jpg', size: 2048 });
95
112
  */
96
113
  setFileData(
97
114
  element: Node,
@@ -18,11 +18,15 @@ export type ModalAnchorEditorParams = {
18
18
  */
19
19
  noAutoPrefix?: boolean;
20
20
  /**
21
- * - The `rel` attribute list of anchor tag.
21
+ * - Available `rel` attribute values shown as checkboxes in the link modal.
22
22
  */
23
23
  relList?: Array<string>;
24
24
  /**
25
- * - Default `rel` attributes of anchor tag.
25
+ * - Default `rel` values auto-applied by condition.
26
+ * `default` is always applied, `check_new_window` when "Open in new window" is checked, `check_bookmark` for bookmark links.
27
+ * ```js
28
+ * { relList: ['nofollow', 'noreferrer', 'noopener'], defaultRel: { default: 'noopener', check_new_window: 'noreferrer' } }
29
+ * ```
26
30
  */
27
31
  defaultRel?: {
28
32
  default?: string;
@@ -62,8 +66,12 @@ export type ModalAnchorEditorParams = {
62
66
  * @property {boolean} [textToDisplay=''] - Create Text to display input.
63
67
  * @property {boolean} [openNewWindow=false] - Default checked value of the "Open in new window" checkbox.
64
68
  * @property {boolean} [noAutoPrefix=false] - If `true`, disables the automatic prefixing of the host URL to the value of the link.
65
- * @property {Array<string>} [relList=[]] - The `rel` attribute list of anchor tag.
66
- * @property {{default?: string, check_new_window?: string, check_bookmark?: string}} [defaultRel={}] - Default `rel` attributes of anchor tag.
69
+ * @property {Array<string>} [relList=[]] - Available `rel` attribute values shown as checkboxes in the link modal.
70
+ * @property {{default?: string, check_new_window?: string, check_bookmark?: string}} [defaultRel={}] - Default `rel` values auto-applied by condition.
71
+ * `default` is always applied, `check_new_window` when "Open in new window" is checked, `check_bookmark` for bookmark links.
72
+ * ```js
73
+ * { relList: ['nofollow', 'noreferrer', 'noopener'], defaultRel: { default: 'noopener', check_new_window: 'noreferrer' } }
74
+ * ```
67
75
  * @property {string} [uploadUrl] - File upload URL.
68
76
  * @property {Object<string, string>} [uploadHeaders] - File upload headers.
69
77
  * @property {number} [uploadSizeLimit] - File upload size limit.
@@ -82,6 +90,17 @@ declare class ModalAnchorEditor {
82
90
  * @param {SunEditor.Deps} $ Kernel dependencies
83
91
  * @param {HTMLElement} modalForm Modal <form>
84
92
  * @param {ModalAnchorEditorParams} params ModalAnchorEditor options
93
+ * @example
94
+ * // In a link plugin (text anchor):
95
+ * this.anchor = new ModalAnchorEditor(this.$, modalEl, this.pluginOptions);
96
+ *
97
+ * // In an image plugin (non-text anchor with custom options):
98
+ * const linkOptions = this.$.plugins.link ? this.$.plugins.link.pluginOptions : {};
99
+ * this.anchor = new ModalAnchorEditor(this.$, modalEl.html, {
100
+ * ...linkOptions,
101
+ * textToDisplay: false,
102
+ * title: true,
103
+ * });
85
104
  */
86
105
  constructor($: SunEditor.Deps, modalForm: HTMLElement, params: ModalAnchorEditorParams);
87
106
  openNewWindow: boolean;
@@ -135,12 +154,30 @@ declare class ModalAnchorEditor {
135
154
  /**
136
155
  * @description Opens the anchor editor modal and populates it with data.
137
156
  * @param {boolean} isUpdate - Indicates whether an existing anchor is being updated (`true`) or a new one is being created (`false`).
157
+ * @example
158
+ * // Called from modalOn() — populate form for a new link:
159
+ * this.anchor.on(false);
160
+ *
161
+ * // Populate form to edit an existing link (call set() first):
162
+ * this.anchor.set(existingAnchorElement);
163
+ * this.anchor.on(true);
138
164
  */
139
165
  on(isUpdate: boolean): void;
140
166
  /**
141
167
  * @description Creates an anchor (`<a>`) element with the specified attributes.
142
168
  * @param {boolean} notText - If `true`, the anchor will not contain text content.
143
169
  * @returns {HTMLElement|null} - The newly created anchor element, or `null` if the URL is empty.
170
+ * @example
171
+ * // In a link plugin — create anchor with text content:
172
+ * const oA = this.anchor.create(false);
173
+ * if (oA === null) return false;
174
+ * this.$.html.insertNode(oA);
175
+ *
176
+ * // In an image plugin — create anchor without text (wraps an image):
177
+ * const anchor = this.anchor.create(true);
178
+ * if (anchor) {
179
+ * anchor.appendChild(imgElement);
180
+ * }
144
181
  */
145
182
  create(notText: boolean): HTMLElement | null;
146
183
  /**
@@ -2,7 +2,12 @@ import type {} from '../../typedef';
2
2
  export default SelectMenu;
3
3
  export type SelectMenuParams = {
4
4
  /**
5
- * Position of the select menu, specified as `"[left|right]-[middle|top|bottom]"` or `"[top|bottom]-[center|left|right]"`
5
+ * Position of the select menu, specified as `"[left|right]-[middle|top|bottom]"` or `"[top|bottom]-[center|left|right]"`.
6
+ * ```js
7
+ * // position
8
+ * 'left-bottom' // menu appears below, aligned to the left
9
+ * 'top-center' // menu appears above, centered
10
+ * ```
6
11
  */
7
12
  position: string;
8
13
  /**
@@ -25,15 +30,30 @@ export type SelectMenuParams = {
25
30
  * Optional method to call when the menu is closed
26
31
  */
27
32
  closeMethod?: () => void;
33
+ /**
34
+ * Optional max-height CSS value (e.g. `"200px"`). Enables scrolling when items exceed this height.
35
+ */
36
+ maxHeight?: string;
37
+ /**
38
+ * Optional min-width CSS value (e.g. `"130px"`).
39
+ */
40
+ minWidth?: string;
28
41
  };
29
42
  /**
30
43
  * @typedef {Object} SelectMenuParams
31
- * @property {string} position Position of the select menu, specified as `"[left|right]-[middle|top|bottom]"` or `"[top|bottom]-[center|left|right]"`
44
+ * @property {string} position Position of the select menu, specified as `"[left|right]-[middle|top|bottom]"` or `"[top|bottom]-[center|left|right]"`.
45
+ * ```js
46
+ * // position
47
+ * 'left-bottom' // menu appears below, aligned to the left
48
+ * 'top-center' // menu appears above, centered
49
+ * ```
32
50
  * @property {boolean} [checkList=false] Flag to determine if the checklist is enabled (`true` or `false`)
33
51
  * @property {"rtl" | "ltr"} [dir="ltr"] Optional text direction: `"rtl"` for right-to-left, `"ltr"` for left-to-right
34
52
  * @property {number} [splitNum=0] Optional split number for horizontal positioning; defines how many items per row
35
53
  * @property {() => void} [openMethod] Optional method to call when the menu is opened
36
54
  * @property {() => void} [closeMethod] Optional method to call when the menu is closed
55
+ * @property {string} [maxHeight] Optional max-height CSS value (e.g. `"200px"`). Enables scrolling when items exceed this height.
56
+ * @property {string} [minWidth] Optional min-width CSS value (e.g. `"130px"`).
37
57
  */
38
58
  /**
39
59
  * @class
@@ -61,6 +81,8 @@ declare class SelectMenu {
61
81
  horizontal: boolean;
62
82
  openMethod: () => void;
63
83
  closeMethod: () => void;
84
+ maxHeight: string;
85
+ minWidth: string;
64
86
  /**
65
87
  * @description Creates the select menu items.
66
88
  * @param {Array<string>|SunEditor.NodeCollection} items - Command list of selectable items.
@@ -72,6 +94,12 @@ declare class SelectMenu {
72
94
  * @param {Node} referElement - The element that triggers the select menu.
73
95
  * @param {(command: string) => void} selectMethod - The function to execute when an item is selected.
74
96
  * @param {{class?: string, style?: string}} [attr={}] - Additional attributes for the select menu container.
97
+ * @example
98
+ * // Basic: attach menu to a button with a selection callback
99
+ * selectMenu.on(this.alignButton, this.onAlignSelect.bind(this));
100
+ *
101
+ * // With custom attributes for styling
102
+ * selectMenu.on(this.alignButton, this.onAlignSelect.bind(this), { class: 'se-figure-select-list' });
75
103
  */
76
104
  on(
77
105
  referElement: Node,
@@ -84,7 +112,17 @@ declare class SelectMenu {
84
112
  /**
85
113
  * @description Select menu open
86
114
  * @param {?string} [position] `"[left|right]-[middle|top|bottom] | [top|bottom]-[center|left|right]"`
115
+ * Always specify in LTR orientation. In RTL environments, left/right are automatically swapped.
87
116
  * @param {?string} [onItemQuerySelector] The querySelector string of the menu to be activated
117
+ * @example
118
+ * // Open with default position (uses constructor's position param)
119
+ * selectMenu.open();
120
+ *
121
+ * // Open at a specific position (always use LTR basis; RTL is auto-mirrored)
122
+ * selectMenu.open('bottom-left');
123
+ *
124
+ * // Open with an active item highlighted via querySelector
125
+ * selectMenu.open('', '[data-command="' + this.align + '"]');
88
126
  */
89
127
  open(position?: string | null, onItemQuerySelector?: string | null): void;
90
128
  /**
@@ -2,7 +2,7 @@ import type {} from '../../typedef';
2
2
  export default FileBrowser;
3
3
  export type FileBrowserPluginOptions = {
4
4
  /**
5
- * - Direct data without server calls
5
+ * - Direct data without server calls (bypasses URL fetch).
6
6
  */
7
7
  data?:
8
8
  | {
@@ -20,21 +20,27 @@ export type FileBrowserPluginOptions = {
20
20
  [x: string]: string;
21
21
  };
22
22
  /**
23
- * - Default thumbnail
23
+ * - Default thumbnail URL or a function that returns a thumbnail URL per item.
24
24
  */
25
25
  thumbnail?: string | ((item: SunEditor.Module.Browser.File) => string);
26
26
  /**
27
27
  * - Additional tag names
28
+ * ```js
29
+ * { url: '/api/files', headers: { Authorization: 'Bearer token' }, thumbnail: (item) => item.thumbUrl }
30
+ * ```
28
31
  */
29
32
  props?: Array<string>;
30
33
  };
31
34
  /**
32
35
  * @typedef {Object} FileBrowserPluginOptions
33
- * @property {Object<string, *>|Array<*>} [data] - Direct data without server calls
36
+ * @property {Object<string, *>|Array<*>} [data] - Direct data without server calls (bypasses URL fetch).
34
37
  * @property {string} [url] - Server request URL
35
38
  * @property {Object<string, string>} [headers] - Server request headers
36
- * @property {string|((item: SunEditor.Module.Browser.File) => string)} [thumbnail] - Default thumbnail
39
+ * @property {string|((item: SunEditor.Module.Browser.File) => string)} [thumbnail] - Default thumbnail URL or a function that returns a thumbnail URL per item.
37
40
  * @property {Array<string>} [props] - Additional tag names
41
+ * ```js
42
+ * { url: '/api/files', headers: { Authorization: 'Bearer token' }, thumbnail: (item) => item.thumbUrl }
43
+ * ```
38
44
  */
39
45
  /**
40
46
  * @class
@@ -0,0 +1,53 @@
1
+ import type {} from '../../typedef';
2
+ export default CodeBlock;
3
+ export type CodeBlockPluginOptions = {
4
+ /**
5
+ * - List of selectable programming languages for code blocks.
6
+ * - Defaults to 21 common languages
7
+ * - [javascript, typescript, html, css, json, python, java, c, cpp, csharp, go, rust, ruby, php, swift, kotlin, sql, bash, markdown, xml, yaml].
8
+ * - Set to empty array `[]` to disable language selection UI entirely.
9
+ * ```js
10
+ * { codeBlock: { langs: ['javascript', 'python', 'html', 'css'] } }
11
+ * ```
12
+ */
13
+ langs?: Array<string>;
14
+ };
15
+ /**
16
+ * @typedef {Object} CodeBlockPluginOptions
17
+ * @property {Array<string>} [langs] - List of selectable programming languages for code blocks.
18
+ * - Defaults to 21 common languages
19
+ * - [javascript, typescript, html, css, json, python, java, c, cpp, csharp, go, rust, ruby, php, swift, kotlin, sql, bash, markdown, xml, yaml].
20
+ * - Set to empty array `[]` to disable language selection UI entirely.
21
+ * ```js
22
+ * { codeBlock: { langs: ['javascript', 'python', 'html', 'css'] } }
23
+ * ```
24
+ */
25
+ /**
26
+ * @class
27
+ * @implements {PluginDropdown}
28
+ * @description Code block plugin — toggles `<pre>` formatting with language selection.
29
+ * - Toolbar: command button (toggle `<pre>`) + optional dropdown (language list)
30
+ * - Hover UI: shows language selector on `<pre>` hover (Controller + SelectMenu)
31
+ * - I/O conversion: `<pre class="language-xxx">` ↔ `<pre><code class="language-xxx">`
32
+ */
33
+ declare class CodeBlock extends PluginCommand implements PluginDropdown {
34
+ /**
35
+ * @constructor
36
+ * @param {SunEditor.Kernel} kernel - The Kernel instance
37
+ * @param {CodeBlockPluginOptions} pluginOptions - Configuration options for the CodeBlock plugin.
38
+ */
39
+ constructor(kernel: SunEditor.Kernel, pluginOptions: CodeBlockPluginOptions);
40
+ title: any;
41
+ onMouseMove(params: SunEditor.HookParams.MouseEvent): void;
42
+ active(element: HTMLElement | null, target: HTMLElement | null): boolean | void;
43
+ on(target?: HTMLElement): void;
44
+ /** @hook Module.Controller */
45
+ controllerClose(): void;
46
+ /**
47
+ * @description Cleans up resources.
48
+ */
49
+ destroy(): void;
50
+ #private;
51
+ }
52
+ import { PluginDropdown } from '../../interfaces';
53
+ import { PluginCommand } from '../../interfaces';
@@ -24,7 +24,10 @@ export type FileUploadPluginOptions = {
24
24
  */
25
25
  allowMultiple?: boolean;
26
26
  /**
27
- * - Accepted file formats (e.g., 'image/*, .pdf')
27
+ * - Accepted file formats.
28
+ * ```js
29
+ * { acceptedFormats: 'image/*, .pdf, .docx' }
30
+ * ```
28
31
  */
29
32
  acceptedFormats?: string;
30
33
  /**
@@ -52,7 +55,10 @@ export type FileUploadPluginOptions = {
52
55
  * @property {number} [uploadSizeLimit] - Total upload size limit in bytes
53
56
  * @property {number} [uploadSingleSizeLimit] - Single file size limit in bytes
54
57
  * @property {boolean} [allowMultiple=false] - Allow multiple file uploads
55
- * @property {string} [acceptedFormats="*"] - Accepted file formats (e.g., 'image/*, .pdf')
58
+ * @property {string} [acceptedFormats="*"] - Accepted file formats.
59
+ * ```js
60
+ * { acceptedFormats: 'image/*, .pdf, .docx' }
61
+ * ```
56
62
  * @property {string} [as="box"] - Specify the default form of the file component as `box` or `link`
57
63
  * @property {Array<string>} [controls] - Additional controls to be added to the figure
58
64
  * @property {SunEditor.ComponentInsertType} [insertBehavior] - Component insertion behavior for selection and cursor placement.
@@ -2,7 +2,8 @@ import type {} from '../../typedef';
2
2
  export default BackgroundColor;
3
3
  export type BackgroundColorPluginOptions = {
4
4
  /**
5
- * - Color list
5
+ * - Color list.
6
+ * Use HEX strings or objects with `value`/`name` for labeled colors.
6
7
  */
7
8
  items?: Array<
8
9
  | string
@@ -17,14 +18,21 @@ export type BackgroundColorPluginOptions = {
17
18
  splitNum?: number;
18
19
  /**
19
20
  * - Disable HEX input
21
+ * ```js
22
+ * { items: ['#ff0000', '#00ff00', { value: '#0000ff', name: 'Blue' }], splitNum: 6 }
23
+ * ```
20
24
  */
21
25
  disableHEXInput?: boolean;
22
26
  };
23
27
  /**
24
28
  * @typedef {Object} BackgroundColorPluginOptions
25
- * @property {Array<string|{value: string, name: string}>} [items] - Color list
29
+ * @property {Array<string|{value: string, name: string}>} [items] - Color list.
30
+ * Use HEX strings or objects with `value`/`name` for labeled colors.
26
31
  * @property {number} [splitNum] - Number of colors per line
27
32
  * @property {boolean} [disableHEXInput] - Disable HEX input
33
+ * ```js
34
+ * { items: ['#ff0000', '#00ff00', { value: '#0000ff', name: 'Blue' }], splitNum: 6 }
35
+ * ```
28
36
  */
29
37
  /**
30
38
  * @class
@@ -8,7 +8,13 @@ export type BlockStyleItem = {
8
8
  };
9
9
  export type BlockStylePluginOptions = {
10
10
  /**
11
- * - Format list
11
+ * - Format list.
12
+ * Use string shortcuts for built-in tags, or `BlockStyleItem` objects for custom block styles.
13
+ * - `command` — `"line"`: single line block, `"br-line"`: br-separated block, `"block"`: container block.
14
+ * ```js
15
+ * // string shortcuts + custom item
16
+ * ['p', 'h1', 'h2', 'blockquote', { tag: 'div', command: 'block', name: 'Custom Block', class: 'my-block' }]
17
+ * ```
12
18
  */
13
19
  items?: Array<'p' | 'div' | 'blockquote' | 'pre' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | string | BlockStyleItem>;
14
20
  };
@@ -17,7 +23,13 @@ export type BlockStylePluginOptions = {
17
23
  */
18
24
  /**
19
25
  * @typedef {Object} BlockStylePluginOptions
20
- * @property {Array<"p"|"div"|"blockquote"|"pre"|"h1"|"h2"|"h3"|"h4"|"h5"|"h6"|string|BlockStyleItem>} [items] - Format list
26
+ * @property {Array<"p"|"div"|"blockquote"|"pre"|"h1"|"h2"|"h3"|"h4"|"h5"|"h6"|string|BlockStyleItem>} [items] - Format list.
27
+ * Use string shortcuts for built-in tags, or `BlockStyleItem` objects for custom block styles.
28
+ * - `command` — `"line"`: single line block, `"br-line"`: br-separated block, `"block"`: container block.
29
+ * ```js
30
+ * // string shortcuts + custom item
31
+ * ['p', 'h1', 'h2', 'blockquote', { tag: 'div', command: 'block', name: 'Custom Block', class: 'my-block' }]
32
+ * ```
21
33
  */
22
34
  /**
23
35
  * @class
@@ -2,7 +2,8 @@ import type {} from '../../typedef';
2
2
  export default FontColor;
3
3
  export type FontColorPluginOptions = {
4
4
  /**
5
- * - Color list
5
+ * - Color list.
6
+ * Use HEX strings or objects with `value`/`name` for labeled colors.
6
7
  */
7
8
  items?: Array<
8
9
  | string
@@ -17,14 +18,21 @@ export type FontColorPluginOptions = {
17
18
  splitNum?: number;
18
19
  /**
19
20
  * - Disable HEX input
21
+ * ```js
22
+ * { items: ['#ff0000', '#00ff00', { value: '#0000ff', name: 'Blue' }], splitNum: 6 }
23
+ * ```
20
24
  */
21
25
  disableHEXInput?: boolean;
22
26
  };
23
27
  /**
24
28
  * @typedef {Object} FontColorPluginOptions
25
- * @property {Array<string|{value: string, name: string}>} [items] - Color list
29
+ * @property {Array<string|{value: string, name: string}>} [items] - Color list.
30
+ * Use HEX strings or objects with `value`/`name` for labeled colors.
26
31
  * @property {number} [splitNum] - Number of colors per line
27
32
  * @property {boolean} [disableHEXInput] - Disable HEX input
33
+ * ```js
34
+ * { items: ['#ff0000', '#00ff00', { value: '#0000ff', name: 'Blue' }], splitNum: 6 }
35
+ * ```
28
36
  */
29
37
  /**
30
38
  * @class
@@ -3,6 +3,12 @@ export default HR;
3
3
  export type HRPluginOptions = {
4
4
  /**
5
5
  * - HR list
6
+ * ```js
7
+ * [
8
+ * { name: 'Solid', class: '__se__solid', style: 'border-top: 1px solid #000;' },
9
+ * { name: 'Dashed', class: '__se__dashed' }
10
+ * ]
11
+ * ```
6
12
  */
7
13
  items?: Array<{
8
14
  name: string;
@@ -13,6 +19,12 @@ export type HRPluginOptions = {
13
19
  /**
14
20
  * @typedef {Object} HRPluginOptions
15
21
  * @property {Array<{name: string, class: string, style?: string}>} [items] - HR list
22
+ * ```js
23
+ * [
24
+ * { name: 'Solid', class: '__se__solid', style: 'border-top: 1px solid #000;' },
25
+ * { name: 'Dashed', class: '__se__dashed' }
26
+ * ]
27
+ * ```
16
28
  */
17
29
  /**
18
30
  * @class
@@ -2,7 +2,10 @@ import type {} from '../../typedef';
2
2
  export default Layout;
3
3
  export type LayoutPluginOptions = {
4
4
  /**
5
- * - Layout list
5
+ * - Layout list. Each item defines a named layout template with raw HTML.
6
+ * ```js
7
+ * [{ name: 'Two Columns', html: '<div style="display:flex"><div style="flex:1">Left</div><div style="flex:1">Right</div></div>' }]
8
+ * ```
6
9
  */
7
10
  items?: Array<{
8
11
  name: string;
@@ -11,7 +14,10 @@ export type LayoutPluginOptions = {
11
14
  };
12
15
  /**
13
16
  * @typedef {Object} LayoutPluginOptions
14
- * @property {Array<{name: string, html: string}>} [items] - Layout list
17
+ * @property {Array<{name: string, html: string}>} [items] - Layout list. Each item defines a named layout template with raw HTML.
18
+ * ```js
19
+ * [{ name: 'Two Columns', html: '<div style="display:flex"><div style="flex:1">Left</div><div style="flex:1">Right</div></div>' }]
20
+ * ```
15
21
  */
16
22
  /**
17
23
  * @class
@@ -3,6 +3,9 @@ export default LineHeight;
3
3
  export type LineHeightPluginOptions = {
4
4
  /**
5
5
  * - Line height list
6
+ * ```js
7
+ * [{ text: 'Single', value: '1' }, { text: '1.5', value: '1.5' }, { text: 'Double', value: '2' }]
8
+ * ```
6
9
  */
7
10
  items?: Array<{
8
11
  text: string;
@@ -12,6 +15,9 @@ export type LineHeightPluginOptions = {
12
15
  /**
13
16
  * @typedef {Object} LineHeightPluginOptions
14
17
  * @property {Array<{text: string, value: string}>} [items] - Line height list
18
+ * ```js
19
+ * [{ text: 'Single', value: '1' }, { text: '1.5', value: '1.5' }, { text: 'Double', value: '2' }]
20
+ * ```
15
21
  */
16
22
  /**
17
23
  * @class
@@ -3,6 +3,16 @@ export default ParagraphStyle;
3
3
  export type ParagraphStylePluginOptions = {
4
4
  /**
5
5
  * - Paragraph item list
6
+ * ```js
7
+ * // use default paragraph styles
8
+ * ['spaced', 'bordered', 'neon']
9
+ * // custom paragraph styles
10
+ * [
11
+ * { name: 'spaced', class: '__se__p-spaced', _class: '' },
12
+ * { name: 'bordered', class: '__se__p-bordered', _class: '' },
13
+ * { name: 'neon', class: '__se__p-neon', _class: '' }
14
+ * ]
15
+ * ```
6
16
  */
7
17
  items?: Array<
8
18
  | string
@@ -16,15 +26,16 @@ export type ParagraphStylePluginOptions = {
16
26
  /**
17
27
  * @typedef {Object} ParagraphStylePluginOptions
18
28
  * @property {Array<string|{name: string, class: string, _class: string}>} [items] - Paragraph item list
19
- * @example
20
- * use default paragraph styles
29
+ * ```js
30
+ * // use default paragraph styles
21
31
  * ['spaced', 'bordered', 'neon']
22
- * custom paragraph styles
32
+ * // custom paragraph styles
23
33
  * [
24
34
  * { name: 'spaced', class: '__se__p-spaced', _class: '' },
25
35
  * { name: 'bordered', class: '__se__p-bordered', _class: '' },
26
36
  * { name: 'neon', class: '__se__p-neon', _class: '' }
27
37
  * ]
38
+ * ```
28
39
  */
29
40
  /**
30
41
  * @class
@@ -14,9 +14,12 @@ export type TablePluginOptions = {
14
14
  */
15
15
  cellControllerPosition?: 'cell' | 'table';
16
16
  /**
17
- * - Color list, used in cell color picker
17
+ * - HEX color list for the cell background color picker.
18
+ * ```js
19
+ * { colorList: ['#bbf7d0', '#fde68a', '#fecaca', '#e9d5ff'] }
20
+ * ```
18
21
  */
19
- colorList?: any[];
22
+ colorList?: Array<string>;
20
23
  };
21
24
  export type TableState = import('./shared/table.constants').TableState;
22
25
  /**
@@ -24,7 +27,10 @@ export type TableState = import('./shared/table.constants').TableState;
24
27
  * @property {"x"|"y"|"xy"} [scrollType='x'] - Scroll type (`x`, `y`, `xy`)
25
28
  * @property {"top"|"bottom"} [captionPosition='bottom'] - Caption position (`top`, `bottom`)
26
29
  * @property {"cell"|"table"} [cellControllerPosition='cell'] - Cell controller position (`cell`, `table`)
27
- * @property {Array} [colorList] - Color list, used in cell color picker
30
+ * @property {Array<string>} [colorList] - HEX color list for the cell background color picker.
31
+ * ```js
32
+ * { colorList: ['#bbf7d0', '#fde68a', '#fecaca', '#e9d5ff'] }
33
+ * ```
28
34
  */
29
35
  /**
30
36
  * @typedef {import('./shared/table.constants').TableState} TableState
@@ -3,6 +3,9 @@ export default Template;
3
3
  export type TemplatePluginOptions = {
4
4
  /**
5
5
  * - Template list
6
+ * ```js
7
+ * [{ name: 'Greeting', html: '<p>Hello! Thank you for contacting us.</p>' }]
8
+ * ```
6
9
  */
7
10
  items?: Array<{
8
11
  name: string;
@@ -12,6 +15,9 @@ export type TemplatePluginOptions = {
12
15
  /**
13
16
  * @typedef {Object} TemplatePluginOptions
14
17
  * @property {Array<{name: string, html: string}>} [items] - Template list
18
+ * ```js
19
+ * [{ name: 'Greeting', html: '<p>Hello! Thank you for contacting us.</p>' }]
20
+ * ```
15
21
  */
16
22
  /**
17
23
  * @class
@@ -2,7 +2,11 @@ import type {} from '../../typedef';
2
2
  export default TextStyle;
3
3
  export type TextStylePluginOptions = {
4
4
  /**
5
- * - Text style item list
5
+ * - Text style item list.
6
+ * Use string shortcuts for built-in styles (e.g., `'shadow'`), or objects for custom styles.
7
+ * ```js
8
+ * ['shadow', { name: 'Highlight', class: 'my-highlight', tag: 'mark' }]
9
+ * ```
6
10
  */
7
11
  items?: Array<
8
12
  | string
@@ -15,7 +19,11 @@ export type TextStylePluginOptions = {
15
19
  };
16
20
  /**
17
21
  * @typedef {Object} TextStylePluginOptions
18
- * @property {Array<string|{name: string, class: string, tag?: string}>} [items] - Text style item list
22
+ * @property {Array<string|{name: string, class: string, tag?: string}>} [items] - Text style item list.
23
+ * Use string shortcuts for built-in styles (e.g., `'shadow'`), or objects for custom styles.
24
+ * ```js
25
+ * ['shadow', { name: 'Highlight', class: 'my-highlight', tag: 'mark' }]
26
+ * ```
19
27
  */
20
28
  /**
21
29
  * @class
@@ -18,7 +18,11 @@ export type MentionPluginOptions = {
18
18
  */
19
19
  delayTime?: number;
20
20
  /**
21
- * - Use data without using API
21
+ * - Static mention data (used instead of API).
22
+ * ```js
23
+ * // data
24
+ * [{ key: 'john', name: 'John Doe', url: '/users/john' }]
25
+ * ```
22
26
  */
23
27
  data?: Array<{
24
28
  key: string;
@@ -50,7 +54,11 @@ export type MentionPluginOptions = {
50
54
  * @property {number} [limitSize=5] - The number of items to display in the mention list
51
55
  * @property {number} [searchStartLength=0] - The number of characters to start searching for the mention list
52
56
  * @property {number} [delayTime=200] - The time to wait before displaying the mention list
53
- * @property {Array<{key: string, name: string, url: string}>} [data] - Use data without using API
57
+ * @property {Array<{key: string, name: string, url: string}>} [data] - Static mention data (used instead of API).
58
+ * ```js
59
+ * // data
60
+ * [{ key: 'john', name: 'John Doe', url: '/users/john' }]
61
+ * ```
54
62
  * @property {string} [apiUrl] - The URL to call the mention list
55
63
  * @property {Object<string, string>} [apiHeaders] - The headers to send with the API call
56
64
  * @property {boolean} [useCachingData=true] - Whether to cache the mention list data
@@ -1,6 +1,7 @@
1
1
  import type {} from '../typedef';
2
2
  declare namespace _default {
3
3
  export { blockquote };
4
+ export { codeBlock };
4
5
  export { exportPDF };
5
6
  export { fileUpload };
6
7
  export { list_bulleted };
@@ -42,6 +43,7 @@ import fileGallery from './browser/fileGallery';
42
43
  import imageGallery from './browser/imageGallery';
43
44
  import videoGallery from './browser/videoGallery';
44
45
  import blockquote from './command/blockquote';
46
+ import codeBlock from './command/codeBlock';
45
47
  import exportPDF from './command/exportPDF';
46
48
  import fileUpload from './command/fileUpload';
47
49
  import list_bulleted from './command/list_bulleted';
@@ -78,6 +80,7 @@ export {
78
80
  backgroundColor,
79
81
  blockquote,
80
82
  blockStyle,
83
+ codeBlock,
81
84
  drawing,
82
85
  embed,
83
86
  exportPDF,