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
@@ -21,18 +21,16 @@ declare class EventManager {
21
21
  * @type {(eventName: string, ...args: *) => Promise<*>}
22
22
  */
23
23
  triggerEvent: (eventName: string, ...args: any) => Promise<any>;
24
- /** @type {HTMLInputElement} */
25
- __focusTemp: HTMLInputElement;
26
24
  /**
27
25
  * @description Register for an event.
28
26
  * - Only events registered with this method are unregistered or re-registered when methods such as 'setOptions', 'destroy' are called.
29
27
  * @param {*} target Target element
30
28
  * @param {string} type Event type
31
- * @param {EventListenerOrEventListenerObject} listener Event handler
29
+ * @param {*} listener Event handler
32
30
  * @param {boolean|AddEventListenerOptions} [useCapture] Event useCapture option
33
31
  * @return {?SunEditor.Event.Info} Registered event information
34
32
  */
35
- addEvent(target: any, type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean | AddEventListenerOptions): SunEditor.Event.Info | null;
33
+ addEvent(target: any, type: string, listener: any, useCapture?: boolean | AddEventListenerOptions): SunEditor.Event.Info | null;
36
34
  /**
37
35
  * @description Remove event
38
36
  * @param {SunEditor.Event.Info} params event info = this.addEvent()
@@ -43,20 +41,20 @@ declare class EventManager {
43
41
  * @description Add an event to document.
44
42
  * - When created as an Iframe, the same event is added to the document in the Iframe.
45
43
  * @param {string} type Event type
46
- * @param {(...args: *) => *} listener Event listener
44
+ * @param {*} listener Event listener
47
45
  * @param {boolean|AddEventListenerOptions} [useCapture] Use event capture
48
46
  * @return {SunEditor.Event.GlobalInfo} Registered event information
49
47
  */
50
- addGlobalEvent(type: string, listener: (...args: any) => any, useCapture?: boolean | AddEventListenerOptions): SunEditor.Event.GlobalInfo;
48
+ addGlobalEvent(type: string, listener: any, useCapture?: boolean | AddEventListenerOptions): SunEditor.Event.GlobalInfo;
51
49
  /**
52
50
  * @description Remove events from document.
53
51
  * - When created as an Iframe, the event of the document inside the Iframe is also removed.
54
52
  * @param {string|SunEditor.Event.GlobalInfo} type Event type or (Event info = this.addGlobalEvent())
55
- * @param {(...args: *) => *} [listener] Event listener
53
+ * @param {*} [listener] Event listener
56
54
  * @param {boolean|AddEventListenerOptions} [useCapture] Use event capture
57
55
  * @returns {undefined|null} Success: `null`, Not found: `undefined`
58
56
  */
59
- removeGlobalEvent(type: string | SunEditor.Event.GlobalInfo, listener?: (...args: any) => any, useCapture?: boolean | AddEventListenerOptions): undefined | null;
57
+ removeGlobalEvent(type: string | SunEditor.Event.GlobalInfo, listener?: any, useCapture?: boolean | AddEventListenerOptions): undefined | null;
60
58
  /**
61
59
  * @internal
62
60
  * @description Gives an active effect when the mouse down event is blocked. (Used when "env.isGecko" is `true`)
@@ -15,6 +15,7 @@ export namespace A {
15
15
  function selectComponentFallback(cmponentInfo: SunEditor.ComponentInfo): Action;
16
16
  function delFormatRemoveAndMove(container: Node, formatEl: Element): Action;
17
17
  function backspaceFormatMaintain(formatEl: Element): Action;
18
+ function backspaceBrLineStrip(formatEl: Element): Action;
18
19
  function backspaceComponentSelect(selectionNode: Node, range: Range, fileComponentInfo: SunEditor.ComponentInfo): Action;
19
20
  function backspaceComponentRemove(isList: boolean, sel: Node, formatEl: Element, fileComponentInfo: SunEditor.ComponentInfo): Action;
20
21
  function backspaceListMergePrev(prev: Element, formatEl: Element, rangeEl: Element): Action;
@@ -4,6 +4,8 @@ declare const _default: {
4
4
  /** @action delFormatRemoveAndMove */
5
5
  'del.format.removeAndMove': ({ ports }: EffectContext_keydown, { container, formatEl }: any) => void;
6
6
  /** [backspace] */
7
+ /** @action backspaceBrLineStrip — extract first line from brLine (PRE) */
8
+ 'backspace.brline.strip': ({ ctx, ports }: EffectContext_keydown, { formatEl }: any) => void;
7
9
  /** @action backspaceFormatMaintain */
8
10
  'backspace.format.maintain': ({ ctx }: EffectContext_keydown, { formatEl }: any) => void;
9
11
  /** @action backspaceComponentSelect */
@@ -51,6 +51,8 @@ declare class EventOrchestrator extends KernelInjector {
51
51
  __eventDoc: Document;
52
52
  /** @type {string} */
53
53
  __secopy: string;
54
+ /** @type {HTMLInputElement} */
55
+ __focusTemp: HTMLInputElement;
54
56
  /**
55
57
  * @description Activates the corresponding button with the tags information of the current cursor position,
56
58
  * - such as `bold`, `underline`, etc., and executes the `active` method of the plugins.
@@ -122,7 +124,6 @@ declare class EventOrchestrator extends KernelInjector {
122
124
  * - Disconnects observers and clears stored event references.
123
125
  */
124
126
  _removeAllEvents(): void;
125
- __focusTemp: any;
126
127
  /**
127
128
  * @internal
128
129
  * @description Synchronizes the selection state by resetting it on `mouseup`.
@@ -136,6 +136,10 @@ export type Deps = {
136
136
  * - L3: View mode handler
137
137
  */
138
138
  viewer: import('../logic/panel/viewer').default;
139
+ /**
140
+ * - L3: Finder handler
141
+ */
142
+ finder: import('../logic/panel/finder').default;
139
143
  };
140
144
  /**
141
145
  * @typedef {import('../section/constructor').ConstructorReturnType} ProductType
@@ -180,6 +184,7 @@ export type Deps = {
180
184
  * @property {import('../logic/panel/toolbar').default} subToolbar - L3: Sub-toolbar renderer
181
185
  * @property {import('../logic/panel/menu').default} menu - L3: Menu renderer
182
186
  * @property {import('../logic/panel/viewer').default} viewer - L3: View mode handler
187
+ * @property {import('../logic/panel/finder').default} finder - L3: Finder handler
183
188
  */
184
189
  /**
185
190
  * @description Core dependency container for the editor.
@@ -94,6 +94,10 @@ export type StoreMode = {
94
94
  * - Whether the sub-toolbar is in `balloon-always` mode.
95
95
  */
96
96
  isSubBalloonAlways: boolean;
97
+ /**
98
+ * - Whether the toolbar is placed at the bottom of the editor (`classic:bottom`, `inline:bottom`).
99
+ */
100
+ isBottom: boolean;
97
101
  };
98
102
  /**
99
103
  * @typedef {Object} StoreState
@@ -122,6 +126,7 @@ export type StoreMode = {
122
126
  * @property {boolean} isBalloonAlways - Whether the toolbar is in `balloon-always` mode (always visible as floating).
123
127
  * @property {boolean} isSubBalloon - Whether the sub-toolbar is in `balloon` mode.
124
128
  * @property {boolean} isSubBalloonAlways - Whether the sub-toolbar is in `balloon-always` mode.
129
+ * @property {boolean} isBottom - Whether the toolbar is placed at the bottom of the editor (`classic:bottom`, `inline:bottom`).
125
130
  */
126
131
  /**
127
132
  * @description Central runtime state management for the editor.
@@ -13,6 +13,8 @@ declare class Char {
13
13
  * @description Returns `false` if char count is greater than "frameOptions.get('charCounter_max')" when "html" is added to the current editor.
14
14
  * @param {Node|string} html Element node or String.
15
15
  * @returns {boolean}
16
+ * @example
17
+ * const canInsert = editor.$.char.check('<strong>new text</strong>');
16
18
  */
17
19
  check(html: Node | string): boolean;
18
20
  /**
@@ -20,12 +22,17 @@ declare class Char {
20
22
  * - If [content] is `undefined`, get the current editor's number of characters or binary data size.
21
23
  * @param {string} [content] Content to count. (defalut: this.#frameContext.get('wysiwyg'))
22
24
  * @returns {number}
25
+ * @example
26
+ * const currentLength = editor.$.char.getLength();
27
+ * const textLength = editor.$.char.getLength('Hello World');
23
28
  */
24
29
  getLength(content?: string): number;
25
30
  /**
26
31
  * @descriptionGets Get the length in bytes of a string.
27
32
  * @param {string} text String text
28
33
  * @returns {number}
34
+ * @example
35
+ * const bytes = editor.$.char.getByteLength('Hello 世界'); // 12
29
36
  */
30
37
  getByteLength(text: string): number;
31
38
  /**
@@ -40,6 +47,10 @@ declare class Char {
40
47
  * @param {string} inputText Text added.
41
48
  * @param {boolean} _fromInputEvent Whether the test is triggered from an input event.
42
49
  * @returns {boolean}
50
+ * @example
51
+ * if (!editor.$.char.test(inputData, true)) {
52
+ * e.preventDefault();
53
+ * }
43
54
  */
44
55
  test(inputText: string, _fromInputEvent: boolean): boolean;
45
56
  #private;
@@ -27,11 +27,16 @@ declare class Format {
27
27
  * @param {Node} node Reference node.
28
28
  * @param {?(current: Node) => boolean} [validation] Additional validation function.
29
29
  * @returns {HTMLElement|null}
30
+ * @example
31
+ * const line = editor.$.format.getLine(editor.$.selection.getNode());
32
+ * const lineWithFilter = editor.$.format.getLine(node, (el) => el.nodeName !== 'LI');
30
33
  */
31
34
  getLine(node: Node, validation?: ((current: Node) => boolean) | null): HTMLElement | null;
32
35
  /**
33
36
  * @description Replace the br-line tag of the current selection.
34
37
  * @param {Node} element BR-Line element (PRE..)
38
+ * @example
39
+ * editor.$.format.setBrLine(document.createElement('pre'));
35
40
  */
36
41
  setBrLine(element: Node): void;
37
42
  /**
@@ -39,6 +44,8 @@ declare class Format {
39
44
  * @param {Node} element Reference node.
40
45
  * @param {?(current: Node) => boolean} [validation] Additional validation function.
41
46
  * @returns {HTMLBRElement|null}
47
+ * @example
48
+ * const brLine = editor.$.format.getBrLine(editor.$.selection.getNode());
42
49
  */
43
50
  getBrLine(element: Node, validation?: ((current: Node) => boolean) | null): HTMLBRElement | null;
44
51
  /**
@@ -55,6 +62,8 @@ declare class Format {
55
62
  * @param {Node} element Reference node.
56
63
  * @param {?(current: Node) => boolean} [validation] Additional validation function.
57
64
  * @returns {HTMLElement|null}
65
+ * @example
66
+ * const block = editor.$.format.getBlock(editor.$.selection.getNode());
58
67
  */
59
68
  getBlock(element: Node, validation?: ((current: Node) => boolean) | null): HTMLElement | null;
60
69
  /**
@@ -140,6 +149,9 @@ declare class Format {
140
149
  * @description It is judged whether it is a node related to the text style.
141
150
  * @param {Node|string} element The node to check
142
151
  * @returns {element is HTMLElement}
152
+ * @example
153
+ * editor.$.format.isTextStyleNode('STRONG'); // true
154
+ * editor.$.format.isTextStyleNode('P'); // false
143
155
  */
144
156
  isTextStyleNode(element: Node | string): element is HTMLElement;
145
157
  /**
@@ -148,6 +160,9 @@ declare class Format {
148
160
  * - `line` element also contain `brLine` element
149
161
  * @param {Node|string} element The node to check
150
162
  * @returns {element is HTMLElement}
163
+ * @example
164
+ * editor.$.format.isLine(document.createElement('p')); // true
165
+ * editor.$.format.isLine('SPAN'); // false
151
166
  */
152
167
  isLine(element: Node | string): element is HTMLElement;
153
168
  /**
@@ -164,6 +179,8 @@ declare class Format {
164
179
  * ※ Entering the Enter key in the space on the last line ends `brLine` and appends `line`.
165
180
  * @param {Node|string} element The node to check
166
181
  * @returns {element is HTMLElement}
182
+ * @example
183
+ * editor.$.format.isBrLine(document.createElement('pre')); // true
167
184
  */
168
185
  isBrLine(element: Node | string): element is HTMLElement;
169
186
  /**
@@ -172,6 +189,9 @@ declare class Format {
172
189
  * - `block` is wrap the `line` and `component`
173
190
  * @param {Node|string} element The node to check
174
191
  * @returns {element is HTMLElement}
192
+ * @example
193
+ * editor.$.format.isBlock(document.createElement('blockquote')); // true
194
+ * editor.$.format.isBlock(document.createElement('ul')); // true
175
195
  */
176
196
  isBlock(element: Node | string): element is HTMLElement;
177
197
  /**
@@ -200,6 +220,8 @@ declare class Format {
200
220
  * @description Returns a `line` array from selected range.
201
221
  * @param {?(current: Node) => boolean} [validation] The validation function. (Replaces the default validation `format.isLine(current)`)
202
222
  * @returns {Array<HTMLElement>}
223
+ * @example
224
+ * const selectedLines = editor.$.format.getLines();
203
225
  */
204
226
  getLines(validation?: ((current: Node) => boolean) | null): Array<HTMLElement>;
205
227
  /**
@@ -181,6 +181,9 @@ declare class HTML {
181
181
  * @param {boolean} [options.includeFullPage=false] Return only the content of the body without headers when the `iframe_fullPage` option is `true`
182
182
  * @param {number|Array<number>} [options.rootKey=null] Root index
183
183
  * @returns {string|Object<*, string>}
184
+ * @example
185
+ * const html = editor.$.html.get();
186
+ * const htmlWithFrame = editor.$.html.get({ withFrame: true });
184
187
  */
185
188
  get({ withFrame, includeFullPage, rootKey }?: { withFrame?: boolean; includeFullPage?: boolean; rootKey?: number | Array<number> }): string | any;
186
189
  /**
@@ -188,6 +191,9 @@ declare class HTML {
188
191
  * @param {string} html HTML string
189
192
  * @param {Object} [options] Options
190
193
  * @param {number|Array<number>} [options.rootKey=null] Root index
194
+ * @example
195
+ * editor.$.html.set('<p>New content</p>');
196
+ * editor.$.html.set(html, { rootKey: 'header' });
191
197
  */
192
198
  set(
193
199
  html: string,
@@ -217,15 +223,25 @@ declare class HTML {
217
223
  * @param {boolean} [options.withFrame=false] Gets the current content with containing parent `div.sun-editor-editable` (`<div class="sun-editor-editable">{content}</div>`).
218
224
  * @param {number|Array<number>} [options.rootKey=null] Root index
219
225
  * @returns {Object<string, *>} JSON data
226
+ * @example
227
+ * const json = editor.$.html.getJson();
228
+ * const jsonWithFrame = editor.$.html.getJson({ withFrame: true });
220
229
  */
221
230
  getJson({ withFrame, rootKey }?: { withFrame?: boolean; rootKey?: number | Array<number> }): {
222
231
  [x: string]: any;
223
232
  };
224
233
  /**
225
234
  * @description Sets the JSON data to the editor content
235
+ * (see @link converter.jsonToHtml)
226
236
  * @param {Object<string, *>} jsdonData HTML string
227
237
  * @param {Object} [options] Options
228
238
  * @param {number|Array<number>} [options.rootKey=null] Root index
239
+ * @example
240
+ * const html = editor.$.html.setJson({
241
+ * type: 'element', tag: 'p', attributes: { class: 'txt' },
242
+ * children: [{ type: 'text', content: 'Hello' }],
243
+ * });
244
+ * // '<p class="txt">Hello</p>'
229
245
  */
230
246
  setJson(
231
247
  jsdonData: {
@@ -55,6 +55,8 @@ declare class NodeTransform {
55
55
  * @description Remove nested tags without other child nodes.
56
56
  * @param {Node} element Element object
57
57
  * @param {?(((current: Node) => boolean)|string)} [validation] Validation function / String(`tag1|tag2..`) / If `null`, all tags are applicable.
58
+ * @example
59
+ * editor.$.nodeTransform.mergeNestedTags(parentElement, (current) => current.nodeName === 'SPAN');
58
60
  */
59
61
  mergeNestedTags(element: Node, validation?: (((current: Node) => boolean) | string) | null): void;
60
62
  /**
@@ -98,6 +100,17 @@ declare class NodeTransform {
98
100
  * @param {SunEditor.NodeCollection} nodeArray An array of nodes to clone. The first node in the array will be the top-level parent.
99
101
  * @param {?(current: Node) => boolean} [validate] A validate function.
100
102
  * @returns {{ parent: Node, inner: Node }} An object containing the top-level parent node and the innermost child node.
103
+ * @example
104
+ * // [div, span, em] → <div><span><em></em></span></div> (cloned)
105
+ * const { parent, inner } = editor.$.nodeTransform.createNestedNode([div, span, em]);
106
+ * // parent = div (top), inner = em (innermost)
107
+ *
108
+ * // validate: skip nodes that fail the condition
109
+ * const { parent, inner } = editor.$.nodeTransform.createNestedNode(
110
+ * [div, span, em],
111
+ * (node) => node.nodeName !== 'SPAN'
112
+ * );
113
+ * // Result: <div><em></em></div> (SPAN excluded)
101
114
  */
102
115
  createNestedNode(
103
116
  nodeArray: SunEditor.NodeCollection,
@@ -262,6 +262,7 @@ declare class Offset {
262
262
  */
263
263
  getGlobal(node?: Node | null): OffsetGlobalInfo;
264
264
  /**
265
+ * @deprecated
265
266
  * @description Gets the current editor-relative scroll offset.
266
267
  * @param {?Node} [node] Target element.
267
268
  * @returns {OffsetGlobalScrollInfo} Global scroll information.
@@ -278,19 +279,35 @@ declare class Offset {
278
279
  * @param {HTMLElement} e_container Element's root container
279
280
  * @param {HTMLElement} target Target element to position against
280
281
  * @param {HTMLElement} t_container Target's root container
282
+ * @param {Object} [opts] Options
283
+ * @param {boolean} [opts.preferUp=false] Open upward by default (for bottom toolbar)
281
284
  */
282
- setRelPosition(element: HTMLElement, e_container: HTMLElement, target: HTMLElement, t_container: HTMLElement): void;
285
+ setRelPosition(
286
+ element: HTMLElement,
287
+ e_container: HTMLElement,
288
+ target: HTMLElement,
289
+ t_container: HTMLElement,
290
+ {
291
+ preferUp,
292
+ }?: {
293
+ preferUp?: boolean;
294
+ },
295
+ ): void;
283
296
  /**
284
297
  * @description Sets the absolute position of an element
285
298
  * @param {HTMLElement} element Element to position
286
299
  * @param {HTMLElement} target Target element
287
300
  * @param {Object} params Position parameters
288
301
  * @param {boolean} [params.isWWTarget=false] Whether the target is within the editor's WYSIWYG area
289
- * @param {{left:number, top:number}} [params.addOffset={left:0, top:0}] Additional offset
302
+ * @param {{left:number, right:number, top:number}} [params.addOffset={left:0, right:0, top:0}] Additional offset
290
303
  * @param {"bottom"|"top"} [params.position="bottom"] Position ('bottom'|'top')
291
304
  * @param {*} params.inst Instance object of caller
292
305
  * @param {HTMLElement} [params.sibling=null] The sibling controller element
293
306
  * @returns {{position: "top" | "bottom"} | undefined} Success -> {position: current position}
307
+ * @example
308
+ * const result = editor.$.offset.setAbsPosition(controller, targetElement, {
309
+ * position: 'bottom', inst: this, addOffset: { left: 0, right: 0, top: 0 }
310
+ * });
294
311
  */
295
312
  setAbsPosition(
296
313
  element: HTMLElement,
@@ -299,6 +316,7 @@ declare class Offset {
299
316
  isWWTarget?: boolean;
300
317
  addOffset?: {
301
318
  left: number;
319
+ right: number;
302
320
  top: number;
303
321
  };
304
322
  position?: 'bottom' | 'top';
@@ -319,6 +337,9 @@ declare class Offset {
319
337
  * @param {"bottom"|"top"} [options.position="bottom"] Position ('bottom'|'top')
320
338
  * @param {number} [options.addTop=0] Additional top offset
321
339
  * @returns {boolean} Success / Failure
340
+ * @example
341
+ * const success = editor.$.offset.setRangePosition(toolbar, null, { position: 'bottom', addTop: 0 });
342
+ * if (!success) toolbar.style.display = 'none';
322
343
  */
323
344
  setRangePosition(
324
345
  element: HTMLElement,
@@ -62,6 +62,9 @@ declare class Selection_ {
62
62
  * - If there is no next sibling but a previous sibling exists, it returns the previous sibling with an offset of 1.
63
63
  * @param {Node} target Target node whose neighboring range is to be determined.
64
64
  * @returns {{container: Node, offset: number}|null} An object containing the nearest container node and its offset.
65
+ * @example
66
+ * const nearRange = editor.$.selection.getNearRange(targetNode);
67
+ * if (nearRange) editor.$.selection.setRange(nearRange.container, nearRange.offset, nearRange.container, nearRange.offset);
65
68
  */
66
69
  getNearRange(target: Node): {
67
70
  container: Node;
@@ -77,6 +80,9 @@ declare class Selection_ {
77
80
  /**
78
81
  * @description Get current select node
79
82
  * @returns {HTMLElement|Text}
83
+ * @example
84
+ * const node = editor.$.selection.getNode();
85
+ * const line = editor.$.format.getLine(node);
80
86
  */
81
87
  getNode(): HTMLElement | Text;
82
88
  /**
@@ -121,7 +127,7 @@ declare class Selection_ {
121
127
  /**
122
128
  * @description Scroll to the corresponding selection or range position.
123
129
  * @param {Selection|Range|Node} ref selection or range object
124
- * @param {Object<string, *>} [scrollOption] option of scrollTo
130
+ * @param {ScrollIntoViewOptions & {noFocus?: boolean}} [scrollOption] Scroll options. Extends `ScrollIntoViewOptions` (`behavior`, `block`, `inline`) with `noFocus` to prevent focus change.
125
131
  * @example
126
132
  * // Scroll to current selection smoothly
127
133
  * editor.selection.scrollTo(editor.selection.get());
@@ -138,8 +144,8 @@ declare class Selection_ {
138
144
  */
139
145
  scrollTo(
140
146
  ref: Selection | Range | Node,
141
- scrollOption?: {
142
- [x: string]: any;
147
+ scrollOption?: ScrollIntoViewOptions & {
148
+ noFocus?: boolean;
143
149
  },
144
150
  ): void;
145
151
  /**
@@ -0,0 +1,83 @@
1
+ import type {} from '../../../typedef';
2
+ export default Finder;
3
+ /**
4
+ * @description Find/Replace feature
5
+ */
6
+ declare class Finder {
7
+ /** @description Inject ::highlight() styles at runtime (avoids PostCSS parse errors). */
8
+ static #highlightStyleInjected: boolean;
9
+ static #injectHighlightStyles(): void;
10
+ /**
11
+ * @constructor
12
+ * @param {SunEditor.Kernel} kernel
13
+ */
14
+ constructor(kernel: SunEditor.Kernel);
15
+ /**
16
+ * @description Whether the panel is open.
17
+ * @returns {boolean}
18
+ */
19
+ get isOpen(): boolean;
20
+ /**
21
+ * @description Opens the finder. With panel: shows UI. Without panel: activates search state only.
22
+ * @param {boolean} [replaceMode=true] Whether to show replace row
23
+ */
24
+ open(replaceMode?: boolean): void;
25
+ /**
26
+ * @description Closes the finder and clears highlights.
27
+ */
28
+ close(): void;
29
+ /**
30
+ * @description Navigate to next match (public for shortcut binding).
31
+ */
32
+ findNext(): void;
33
+ /**
34
+ * @description Navigate to previous match (public for shortcut binding).
35
+ */
36
+ findPrev(): void;
37
+ /**
38
+ * @description Search for a term in the editor content (headless API).
39
+ * @param {string} term Search term
40
+ * @param {Object} [options] Search options
41
+ * @param {boolean} [options.matchCase=false] Case-sensitive search
42
+ * @param {boolean} [options.wholeWord=false] Whole word search
43
+ * @param {boolean} [options.regex=false] Regex search
44
+ * @returns {number} Number of matches found
45
+ */
46
+ search(
47
+ term: string,
48
+ {
49
+ matchCase,
50
+ wholeWord,
51
+ regex,
52
+ }?: {
53
+ matchCase?: boolean;
54
+ wholeWord?: boolean;
55
+ regex?: boolean;
56
+ },
57
+ ): number;
58
+ /**
59
+ * @description Replace the current match (headless API).
60
+ * @param {string} replaceText Replacement text
61
+ */
62
+ replace(replaceText: string): void;
63
+ /**
64
+ * @description Replace all matches (headless API).
65
+ * @param {string} replaceText Replacement text
66
+ */
67
+ replaceAll(replaceText: string): void;
68
+ /**
69
+ * @description Current match count and index.
70
+ * @returns {{ current: number, total: number }}
71
+ */
72
+ get matchInfo(): {
73
+ current: number;
74
+ total: number;
75
+ };
76
+ /**
77
+ * @description Re-run search with current term (debounced 300ms). Called on wysiwyg content change.
78
+ */
79
+ refresh(): void;
80
+ /** @internal */
81
+ _destroy(): void;
82
+ #private;
83
+ }
@@ -40,7 +40,6 @@ declare class Toolbar {
40
40
  */
41
41
  keyName: any;
42
42
  currentMoreLayerActiveButton: HTMLButtonElement;
43
- isSticky: boolean;
44
43
  isBalloonMode: boolean;
45
44
  isInlineMode: boolean;
46
45
  isBalloonAlwaysMode: boolean;
@@ -53,6 +52,20 @@ declare class Toolbar {
53
52
  top: number;
54
53
  left: number;
55
54
  };
55
+ isBottomMode: boolean;
56
+ /**
57
+ * @description Whether the toolbar is currently in a sticky (fixed) state.
58
+ * For CSS sticky mode, computed from the element's viewport position.
59
+ * For JS sticky mode (toolbar_container), uses a manual flag.
60
+ * @type {boolean}
61
+ */
62
+ get isSticky(): boolean;
63
+ /**
64
+ * @description Whether the toolbar uses native CSS `position: sticky`.
65
+ * - When `false`, the JS-based sticky fallback (`position: fixed`) is active.
66
+ * @type {boolean}
67
+ */
68
+ get isCSSSticky(): boolean;
56
69
  /**
57
70
  * @description Disables all toolbar buttons.
58
71
  */
@@ -14,6 +14,11 @@ declare class Viewer {
14
14
  * @param {boolean} [value] `true`/`false`, If `undefined` toggle the `codeView` mode.
15
15
  */
16
16
  codeView(value?: boolean): void;
17
+ /**
18
+ * @description Changes to markdown view or wysiwyg view
19
+ * @param {boolean} [value] `true`/`false`, If `undefined` toggle the `markdownView` mode.
20
+ */
21
+ markdownView(value?: boolean): void;
17
22
  /**
18
23
  * @description Changes to full screen or default screen
19
24
  * @param {boolean} [value] `true`/`false`, If `undefined` toggle the `fullScreen` mode.
@@ -67,11 +72,11 @@ declare class Viewer {
67
72
  * @internal
68
73
  * @description Adjusts the height of the code view area.
69
74
  * - Ensures the code block `auto`-resizes based on its content.
70
- * @param {HTMLElement} code - Code area
75
+ * @param {HTMLTextAreaElement} code - Code area
71
76
  * @param {HTMLTextAreaElement} codeNumbers - Code numbers area
72
77
  * @param {boolean} isAuto - `auto` height option
73
78
  */
74
- _codeViewAutoHeight(code: HTMLElement, codeNumbers: HTMLTextAreaElement, isAuto: boolean): void;
79
+ _codeViewAutoHeight(code: HTMLTextAreaElement, codeNumbers: HTMLTextAreaElement, isAuto: boolean): void;
75
80
  /**
76
81
  * @internal
77
82
  * @this {HTMLElement} Code numbers area
@@ -80,6 +85,21 @@ declare class Viewer {
80
85
  * @param {HTMLTextAreaElement} codeNumbers - Code numbers textarea
81
86
  */
82
87
  _scrollLineNumbers(this: HTMLElement, codeNumbers: HTMLTextAreaElement): void;
88
+ /**
89
+ * @internal
90
+ * @description Adjusts the height of the markdown view area.
91
+ * @param {HTMLTextAreaElement} md - Markdown area
92
+ * @param {HTMLTextAreaElement} mdNumbers - Markdown numbers area
93
+ * @param {boolean} isAuto - `auto` height option
94
+ */
95
+ _markdownViewAutoHeight(md: HTMLTextAreaElement, mdNumbers: HTMLTextAreaElement, isAuto: boolean): void;
96
+ /**
97
+ * @internal
98
+ * @this {HTMLElement} Markdown numbers area
99
+ * @description Synchronizes scrolling of line numbers with the markdown editor.
100
+ * @param {HTMLTextAreaElement} mdNumbers - Markdown numbers textarea
101
+ */
102
+ _scrollMarkdownLineNumbers(this: HTMLElement, mdNumbers: HTMLTextAreaElement): void;
83
103
  /**
84
104
  * @internal
85
105
  * @description Destroy the Viewer instance and release memory
@@ -121,7 +121,7 @@ declare class Shortcuts {
121
121
  * @description Registers custom shortcut keys (keys starting with `_`) into the shortcut map.
122
122
  * Called during initialization and when toolbar is reset.
123
123
  */
124
- _registerCustomShortcuts(): void;
124
+ _registerShortcuts(): void;
125
125
  /**
126
126
  * @internal
127
127
  * @description Destroy the Shortcuts instance and release memory
@@ -29,6 +29,9 @@ import type {} from '../../typedef';
29
29
  * @property {HTMLElement} codeWrapper - Wrapper element for the code-view mode.
30
30
  * @property {HTMLElement & HTMLTextAreaElement} code - Code view editing element (a <textarea> or <pre>).
31
31
  * @property {HTMLTextAreaElement} codeNumbers - Element displaying line numbers in code view mode.
32
+ * @property {HTMLElement} markdownWrapper - Wrapper element for the markdown-view mode.
33
+ * @property {HTMLTextAreaElement} markdown - Markdown view editing element (a <textarea>).
34
+ * @property {HTMLTextAreaElement} markdownNumbers - Element displaying line numbers in markdown view mode.
32
35
  * @property {HTMLElement} placeholder - Placeholder element shown when the editor is empty.
33
36
  * @property {HTMLElement} statusbar - Editor status bar element (for resizing, info, etc.).
34
37
  * @property {HTMLElement} navigation - Navigation element (e.g., for outline or bookmarks).
@@ -46,6 +49,7 @@ import type {} from '../../typedef';
46
49
  *
47
50
  * === State Flags ===
48
51
  * @property {boolean} isCodeView - Whether the editor is currently in code view mode.
52
+ * @property {boolean} isMarkdownView - Whether the editor is currently in markdown view mode.
49
53
  * @property {boolean} isFullScreen - Whether the editor is currently in fullscreen mode.
50
54
  * @property {boolean} isReadOnly - Whether the editor is set to readonly mode.
51
55
  * @property {boolean} isDisabled - Whether the editor is currently disabled.
@@ -97,6 +101,8 @@ export function CreateFrameContext(
97
101
  wwFrame: HTMLElement,
98
102
  codeWrapper: HTMLElement,
99
103
  codeFrame: HTMLElement,
104
+ markdownWrapper: any,
105
+ markdownFrame: any,
100
106
  statusbar: HTMLElement | null,
101
107
  documentTypeInner: {
102
108
  inner: HTMLElement;
@@ -177,6 +183,18 @@ export type FrameContextStore = {
177
183
  * - Element displaying line numbers in code view mode.
178
184
  */
179
185
  codeNumbers: HTMLTextAreaElement;
186
+ /**
187
+ * - Wrapper element for the markdown-view mode.
188
+ */
189
+ markdownWrapper: HTMLElement;
190
+ /**
191
+ * - Markdown view editing element (a <textarea>).
192
+ */
193
+ markdown: HTMLTextAreaElement;
194
+ /**
195
+ * - Element displaying line numbers in markdown view mode.
196
+ */
197
+ markdownNumbers: HTMLTextAreaElement;
180
198
  /**
181
199
  * - Placeholder element shown when the editor is empty.
182
200
  */
@@ -238,6 +256,10 @@ export type FrameContextStore = {
238
256
  * - Whether the editor is currently in code view mode.
239
257
  */
240
258
  isCodeView: boolean;
259
+ /**
260
+ * - Whether the editor is currently in markdown view mode.
261
+ */
262
+ isMarkdownView: boolean;
241
263
  /**
242
264
  * - Whether the editor is currently in fullscreen mode.
243
265
  */