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.
- package/README.md +4 -3
- package/dist/suneditor-contents.min.css +1 -1
- package/dist/suneditor.min.css +1 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +10 -6
- package/src/assets/design/color.css +14 -2
- package/src/assets/design/typography.css +5 -0
- package/src/assets/icons/defaultIcons.js +22 -4
- package/src/assets/suneditor-contents.css +1 -1
- package/src/assets/suneditor.css +312 -18
- package/src/core/config/eventManager.js +6 -9
- package/src/core/editor.js +1 -1
- package/src/core/event/actions/index.js +5 -0
- package/src/core/event/effects/keydown.registry.js +25 -0
- package/src/core/event/eventOrchestrator.js +69 -2
- package/src/core/event/handlers/handler_ww_mouse.js +1 -0
- package/src/core/event/rules/keydown.rule.backspace.js +9 -1
- package/src/core/kernel/coreKernel.js +4 -0
- package/src/core/kernel/store.js +2 -0
- package/src/core/logic/dom/char.js +11 -0
- package/src/core/logic/dom/format.js +22 -0
- package/src/core/logic/dom/html.js +126 -11
- package/src/core/logic/dom/nodeTransform.js +13 -0
- package/src/core/logic/dom/offset.js +100 -37
- package/src/core/logic/dom/selection.js +54 -22
- package/src/core/logic/panel/finder.js +982 -0
- package/src/core/logic/panel/menu.js +8 -6
- package/src/core/logic/panel/toolbar.js +112 -19
- package/src/core/logic/panel/viewer.js +214 -43
- package/src/core/logic/shell/_commandExecutor.js +7 -1
- package/src/core/logic/shell/commandDispatcher.js +1 -1
- package/src/core/logic/shell/component.js +5 -7
- package/src/core/logic/shell/history.js +24 -0
- package/src/core/logic/shell/shortcuts.js +3 -3
- package/src/core/logic/shell/ui.js +25 -26
- package/src/core/schema/frameContext.js +15 -1
- package/src/core/schema/options.js +180 -39
- package/src/core/section/constructor.js +61 -20
- package/src/core/section/documentType.js +2 -2
- package/src/events.js +12 -0
- package/src/helper/clipboard.js +1 -1
- package/src/helper/converter.js +15 -0
- package/src/helper/dom/domQuery.js +12 -0
- package/src/helper/dom/domUtils.js +26 -14
- package/src/helper/index.js +3 -0
- package/src/helper/markdown.js +876 -0
- package/src/interfaces/plugins.js +7 -5
- package/src/langs/ckb.js +9 -0
- package/src/langs/cs.js +9 -0
- package/src/langs/da.js +9 -0
- package/src/langs/de.js +9 -0
- package/src/langs/en.js +9 -0
- package/src/langs/es.js +9 -0
- package/src/langs/fa.js +9 -0
- package/src/langs/fr.js +9 -0
- package/src/langs/he.js +9 -0
- package/src/langs/hu.js +9 -0
- package/src/langs/it.js +9 -0
- package/src/langs/ja.js +9 -0
- package/src/langs/km.js +9 -0
- package/src/langs/ko.js +9 -0
- package/src/langs/lv.js +9 -0
- package/src/langs/nl.js +9 -0
- package/src/langs/pl.js +9 -0
- package/src/langs/pt_br.js +9 -0
- package/src/langs/ro.js +9 -0
- package/src/langs/ru.js +9 -0
- package/src/langs/se.js +9 -0
- package/src/langs/tr.js +9 -0
- package/src/langs/uk.js +9 -0
- package/src/langs/ur.js +9 -0
- package/src/langs/zh_cn.js +9 -0
- package/src/modules/contract/Browser.js +31 -1
- package/src/modules/contract/ColorPicker.js +6 -0
- package/src/modules/contract/Controller.js +77 -39
- package/src/modules/contract/Figure.js +57 -0
- package/src/modules/contract/Modal.js +6 -0
- package/src/modules/manager/ApiManager.js +53 -4
- package/src/modules/manager/FileManager.js +18 -1
- package/src/modules/ui/ModalAnchorEditor.js +35 -2
- package/src/modules/ui/SelectMenu.js +44 -12
- package/src/plugins/browser/fileBrowser.js +5 -2
- package/src/plugins/command/codeBlock.js +324 -0
- package/src/plugins/command/exportPDF.js +15 -3
- package/src/plugins/command/fileUpload.js +4 -1
- package/src/plugins/dropdown/backgroundColor.js +5 -1
- package/src/plugins/dropdown/blockStyle.js +8 -2
- package/src/plugins/dropdown/fontColor.js +5 -1
- package/src/plugins/dropdown/hr.js +6 -0
- package/src/plugins/dropdown/layout.js +4 -1
- package/src/plugins/dropdown/lineHeight.js +3 -0
- package/src/plugins/dropdown/paragraphStyle.js +5 -5
- package/src/plugins/dropdown/table/index.js +4 -1
- package/src/plugins/dropdown/table/render/table.html.js +1 -1
- package/src/plugins/dropdown/table/services/table.grid.js +16 -8
- package/src/plugins/dropdown/table/services/table.style.js +5 -9
- package/src/plugins/dropdown/template.js +3 -0
- package/src/plugins/dropdown/textStyle.js +5 -1
- package/src/plugins/field/mention.js +5 -1
- package/src/plugins/index.js +3 -0
- package/src/plugins/input/fontSize.js +10 -3
- package/src/plugins/modal/audio.js +7 -3
- package/src/plugins/modal/embed.js +23 -20
- package/src/plugins/modal/image/index.js +5 -1
- package/src/plugins/modal/math.js +7 -2
- package/src/plugins/modal/video/index.js +21 -4
- package/src/themes/cobalt.css +13 -4
- package/src/themes/cream.css +11 -2
- package/src/themes/dark.css +13 -4
- package/src/themes/midnight.css +13 -4
- package/src/typedef.js +4 -4
- package/types/assets/icons/defaultIcons.d.ts +12 -1
- package/types/assets/suneditor.css.d.ts +1 -1
- package/types/core/config/eventManager.d.ts +6 -8
- package/types/core/event/actions/index.d.ts +1 -0
- package/types/core/event/effects/keydown.registry.d.ts +2 -0
- package/types/core/event/eventOrchestrator.d.ts +2 -1
- package/types/core/kernel/coreKernel.d.ts +5 -0
- package/types/core/kernel/store.d.ts +5 -0
- package/types/core/logic/dom/char.d.ts +11 -0
- package/types/core/logic/dom/format.d.ts +22 -0
- package/types/core/logic/dom/html.d.ts +16 -0
- package/types/core/logic/dom/nodeTransform.d.ts +13 -0
- package/types/core/logic/dom/offset.d.ts +23 -2
- package/types/core/logic/dom/selection.d.ts +9 -3
- package/types/core/logic/panel/finder.d.ts +83 -0
- package/types/core/logic/panel/toolbar.d.ts +14 -1
- package/types/core/logic/panel/viewer.d.ts +22 -2
- package/types/core/logic/shell/shortcuts.d.ts +1 -1
- package/types/core/schema/frameContext.d.ts +22 -0
- package/types/core/schema/options.d.ts +362 -79
- package/types/events.d.ts +11 -0
- package/types/helper/converter.d.ts +15 -0
- package/types/helper/dom/domQuery.d.ts +12 -0
- package/types/helper/dom/domUtils.d.ts +23 -2
- package/types/helper/index.d.ts +5 -0
- package/types/helper/markdown.d.ts +27 -0
- package/types/interfaces/plugins.d.ts +7 -5
- package/types/langs/_Lang.d.ts +9 -0
- package/types/modules/contract/Browser.d.ts +36 -2
- package/types/modules/contract/ColorPicker.d.ts +6 -0
- package/types/modules/contract/Controller.d.ts +35 -1
- package/types/modules/contract/Figure.d.ts +57 -0
- package/types/modules/contract/Modal.d.ts +6 -0
- package/types/modules/manager/ApiManager.d.ts +26 -0
- package/types/modules/manager/FileManager.d.ts +17 -0
- package/types/modules/ui/ModalAnchorEditor.d.ts +41 -4
- package/types/modules/ui/SelectMenu.d.ts +40 -2
- package/types/plugins/browser/fileBrowser.d.ts +10 -4
- package/types/plugins/command/codeBlock.d.ts +53 -0
- package/types/plugins/command/fileUpload.d.ts +8 -2
- package/types/plugins/dropdown/backgroundColor.d.ts +10 -2
- package/types/plugins/dropdown/blockStyle.d.ts +14 -2
- package/types/plugins/dropdown/fontColor.d.ts +10 -2
- package/types/plugins/dropdown/hr.d.ts +12 -0
- package/types/plugins/dropdown/layout.d.ts +8 -2
- package/types/plugins/dropdown/lineHeight.d.ts +6 -0
- package/types/plugins/dropdown/paragraphStyle.d.ts +14 -3
- package/types/plugins/dropdown/table/index.d.ts +9 -3
- package/types/plugins/dropdown/template.d.ts +6 -0
- package/types/plugins/dropdown/textStyle.d.ts +10 -2
- package/types/plugins/field/mention.d.ts +10 -2
- package/types/plugins/index.d.ts +3 -0
- package/types/plugins/input/fontSize.d.ts +18 -4
- package/types/plugins/modal/audio.d.ts +14 -6
- package/types/plugins/modal/embed.d.ts +44 -38
- package/types/plugins/modal/image/index.d.ts +9 -1
- package/types/plugins/modal/link.d.ts +6 -2
- package/types/plugins/modal/math.d.ts +23 -5
- package/types/plugins/modal/video/index.d.ts +49 -9
- package/types/typedef.d.ts +5 -2
package/types/events.d.ts
CHANGED
|
@@ -239,6 +239,7 @@ export type EventHandlers = {
|
|
|
239
239
|
onShowController?: typeof onShowController | null;
|
|
240
240
|
onBeforeShowController?: typeof onBeforeShowController | null;
|
|
241
241
|
onToggleCodeView?: typeof onToggleCodeView | null;
|
|
242
|
+
onToggleMarkdownView?: typeof onToggleMarkdownView | null;
|
|
242
243
|
onToggleFullScreen?: typeof onToggleFullScreen | null;
|
|
243
244
|
onResizeEditor?: typeof onResizeEditor | null;
|
|
244
245
|
onSetToolbarButtons?: typeof onSetToolbarButtons | null;
|
|
@@ -554,6 +555,16 @@ declare function onBeforeShowController(params: { $: SunEditor.Deps; frameContex
|
|
|
554
555
|
* @param {boolean} params.is - code view status
|
|
555
556
|
*/
|
|
556
557
|
declare function onToggleCodeView(params: { $: SunEditor.Deps; frameContext: SunEditor.FrameContext; is: boolean }): void;
|
|
558
|
+
/**
|
|
559
|
+
* @callback
|
|
560
|
+
* @description Fired when the editor switches between WYSIWYG view and markdown view.
|
|
561
|
+
* The `is` parameter indicates whether markdown view is now active (`true`) or WYSIWYG view is active (`false`).
|
|
562
|
+
* @param {Object} params
|
|
563
|
+
* @param {SunEditor.Deps} params.$ - Kernel dependencies
|
|
564
|
+
* @param {SunEditor.FrameContext} params.frameContext - frame context
|
|
565
|
+
* @param {boolean} params.is - markdown view status
|
|
566
|
+
*/
|
|
567
|
+
declare function onToggleMarkdownView(params: { $: SunEditor.Deps; frameContext: SunEditor.FrameContext; is: boolean }): void;
|
|
557
568
|
/**
|
|
558
569
|
* @callback
|
|
559
570
|
* @description Fired when the editor enters or exits fullscreen mode.
|
|
@@ -33,12 +33,16 @@ export function jsonToHtml(jsonData: { [x: string]: any }): string;
|
|
|
33
33
|
* @description Convert HTML string to HTML Entity
|
|
34
34
|
* @param {string} content
|
|
35
35
|
* @returns {string} Content string
|
|
36
|
+
* @example
|
|
37
|
+
* converter.htmlToEntity('<div>'); // '<div>'
|
|
36
38
|
*/
|
|
37
39
|
export function htmlToEntity(content: string): string;
|
|
38
40
|
/**
|
|
39
41
|
* @description Convert HTML Entity to HTML string
|
|
40
42
|
* @param {string} content Content string
|
|
41
43
|
* @returns {string}
|
|
44
|
+
* @example
|
|
45
|
+
* converter.entityToHTML('<div>'); // '<div>'
|
|
42
46
|
*/
|
|
43
47
|
export function entityToHTML(content: string): string;
|
|
44
48
|
/**
|
|
@@ -46,6 +50,9 @@ export function entityToHTML(content: string): string;
|
|
|
46
50
|
* @param {(...args: *) => void} func function
|
|
47
51
|
* @param {number} wait delay ms
|
|
48
52
|
* @returns {*} executedFunction
|
|
53
|
+
* @example
|
|
54
|
+
* const debouncedSave = converter.debounce(() => save(), 300);
|
|
55
|
+
* input.addEventListener('input', debouncedSave);
|
|
49
56
|
*/
|
|
50
57
|
export function debounce(func: (...args: any) => void, wait: number): any;
|
|
51
58
|
/**
|
|
@@ -72,6 +79,9 @@ export function getValues(obj: any): Array<any>;
|
|
|
72
79
|
/**
|
|
73
80
|
* @description Convert the `CamelCase` To the `KebabCase`.
|
|
74
81
|
* @param {string|Array<string>} param [Camel string]
|
|
82
|
+
* @example
|
|
83
|
+
* converter.camelToKebabCase('fontSize'); // 'font-size'
|
|
84
|
+
* converter.camelToKebabCase(['fontSize', 'fontFamily']); // ['font-size', 'font-family']
|
|
75
85
|
*/
|
|
76
86
|
export function camelToKebabCase(param: string | Array<string>): any;
|
|
77
87
|
/**
|
|
@@ -84,6 +94,8 @@ export function kebabToCamelCase(param: string): string;
|
|
|
84
94
|
* @overload
|
|
85
95
|
* @param {Array<string>} param - Array of `Kebab-case` strings.
|
|
86
96
|
* @returns {Array<string>} Array of `CamelCase` strings.
|
|
97
|
+
* @example
|
|
98
|
+
* converter.kebabToCamelCase('font-size'); // 'fontSize'
|
|
87
99
|
*/
|
|
88
100
|
export function kebabToCamelCase(param: Array<string>): Array<string>;
|
|
89
101
|
/**
|
|
@@ -131,6 +143,9 @@ export function isHexColor(str: string): boolean;
|
|
|
131
143
|
* @description Function to convert hex format to a `rgb` color
|
|
132
144
|
* @param {string} rgba RGBA color format
|
|
133
145
|
* @returns {string}
|
|
146
|
+
* @example
|
|
147
|
+
* converter.rgb2hex('rgb(255, 0, 0)'); // '#ff0000'
|
|
148
|
+
* converter.rgb2hex('rgba(255, 0, 0, 0.5)'); // '#ff000080'
|
|
134
149
|
*/
|
|
135
150
|
export function rgb2hex(rgba: string): string;
|
|
136
151
|
/**
|
|
@@ -29,6 +29,8 @@ export function getNodePath(
|
|
|
29
29
|
* @param {Array<number>} offsets Position array, array obtained from `helper.dom.getNodePath`
|
|
30
30
|
* @param {Node} parentNode Base parent element
|
|
31
31
|
* @returns {T}
|
|
32
|
+
* @example
|
|
33
|
+
* const node = dom.query.getNodeFromPath([0, 1, 0], wysiwygElement);
|
|
32
34
|
*/
|
|
33
35
|
export function getNodeFromPath<T extends Node>(offsets: Array<number>, parentNode: Node): T;
|
|
34
36
|
/**
|
|
@@ -55,6 +57,8 @@ export function getListChildren<T extends HTMLElement>(element: Node, validation
|
|
|
55
57
|
* @param {?(current: *) => boolean} validation Conditional function
|
|
56
58
|
* @param {?number} depth Number of child levels to depth.
|
|
57
59
|
* @returns {Array<T>}
|
|
60
|
+
* @example
|
|
61
|
+
* const allNodes = dom.query.getListChildNodes(container, (node) => node.nodeType === 3);
|
|
58
62
|
*/
|
|
59
63
|
export function getListChildNodes<T extends Node>(element: Node, validation: ((current: any) => boolean) | null, depth: number | null): Array<T>;
|
|
60
64
|
/**
|
|
@@ -69,6 +73,8 @@ export function getNodeDepth(node: Node): number;
|
|
|
69
73
|
* @description Sort a node array by depth of element.
|
|
70
74
|
* @param {Array<Node>} array Node array
|
|
71
75
|
* @param {boolean} des `true`: descending order / `false`: ascending order
|
|
76
|
+
* @example
|
|
77
|
+
* const sorted = dom.query.sortNodeByDepth([nodeA, nodeB], true);
|
|
72
78
|
*/
|
|
73
79
|
export function sortNodeByDepth(array: Array<Node>, des: boolean): void;
|
|
74
80
|
/**
|
|
@@ -76,6 +82,9 @@ export function sortNodeByDepth(array: Array<Node>, des: boolean): void;
|
|
|
76
82
|
* @param {Node} a Node to compare.
|
|
77
83
|
* @param {Node} b Node to compare.
|
|
78
84
|
* @returns {{ancestor: ?HTMLElement, a: Node, b: Node, result: number}} { ancesstor, a, b, result: (a > b ? 1 : a < b ? -1 : 0) };
|
|
85
|
+
* @example
|
|
86
|
+
* const result = dom.query.compareElements(nodeA, nodeB);
|
|
87
|
+
* // result: { ancestor: true, result: 0 } (same node), { ancestor: true, result: 1 } (a before b)
|
|
79
88
|
*/
|
|
80
89
|
export function compareElements(
|
|
81
90
|
a: Node,
|
|
@@ -143,6 +152,9 @@ export function getEventTarget<T extends HTMLElement>(event: Event): T | null;
|
|
|
143
152
|
* Not use it like jquery.
|
|
144
153
|
* Only one condition can be entered at a time.
|
|
145
154
|
* @returns {T|null} Not found: `null`
|
|
155
|
+
* @example
|
|
156
|
+
* const firstLeaf = dom.query.getEdgeChild(container, (n) => n.nodeType === 3, false);
|
|
157
|
+
* const lastLeaf = dom.query.getEdgeChild(container, (n) => n.nodeType === 3, true);
|
|
146
158
|
*/
|
|
147
159
|
export function getEdgeChild<T extends Node>(node: Node, query: string | ((current: any) => boolean) | Node, last: boolean): T | null;
|
|
148
160
|
/**
|
|
@@ -43,6 +43,8 @@ export function createTextNode(text: string): Text;
|
|
|
43
43
|
* @param {Node} element Element object
|
|
44
44
|
* @param {?Array<string>} exceptAttrs Array of attribute names to exclude from the result
|
|
45
45
|
* @returns {string}
|
|
46
|
+
* @example
|
|
47
|
+
* const attrs = dom.utils.getAttributesToString(element, ['id', 'class']);
|
|
46
48
|
*/
|
|
47
49
|
export function getAttributesToString(element: Node, exceptAttrs: Array<string> | null): string;
|
|
48
50
|
/**
|
|
@@ -92,6 +94,8 @@ export function prevIndex(array: SunEditor.NodeCollection, item: Node): number;
|
|
|
92
94
|
* @param {Node} originEl Origin element
|
|
93
95
|
* @param {Node} copyEl Element to copy
|
|
94
96
|
* @param {?Array<string>} [blacklist] Blacklist array(LowerCase)
|
|
97
|
+
* @example
|
|
98
|
+
* dom.utils.copyTagAttributes(newElement, originalElement, ['contenteditable']);
|
|
95
99
|
*/
|
|
96
100
|
export function copyTagAttributes(originEl: Node, copyEl: Node, blacklist?: Array<string> | null): void;
|
|
97
101
|
/**
|
|
@@ -109,6 +113,9 @@ export function removeItem(item: Node): void;
|
|
|
109
113
|
* @description Replace element
|
|
110
114
|
* @param {Node} element Target element
|
|
111
115
|
* @param {string|Node} newElement String or element of the new element to apply
|
|
116
|
+
* @example
|
|
117
|
+
* dom.utils.changeElement(oldSpan, 'STRONG');
|
|
118
|
+
* dom.utils.changeElement(oldElement, newElement);
|
|
112
119
|
*/
|
|
113
120
|
export function changeElement(element: Node, newElement: string | Node): void;
|
|
114
121
|
/**
|
|
@@ -122,6 +129,9 @@ export function changeTxt(node: Node, txt: string): void;
|
|
|
122
129
|
* @param {Node|Node[]} elements Element to set style
|
|
123
130
|
* @param {string} styleName Style attribute name (`marginLeft`, `textAlign`...)
|
|
124
131
|
* @param {string|number} value Style value
|
|
132
|
+
* @example
|
|
133
|
+
* dom.utils.setStyle(element, 'color', 'red');
|
|
134
|
+
* dom.utils.setStyle([el1, el2], 'display', 'none');
|
|
125
135
|
*/
|
|
126
136
|
export function setStyle(elements: Node | Node[], styleName: string, value: string | number): void;
|
|
127
137
|
/**
|
|
@@ -149,26 +159,33 @@ export function hasClass(element: Node | null, className: string): boolean;
|
|
|
149
159
|
* @description Append the className value of the argument value element
|
|
150
160
|
* @param {Node|SunEditor.NodeCollection} element Elements to add class name
|
|
151
161
|
* @param {string} className Class name to be add
|
|
162
|
+
* @example
|
|
163
|
+
* dom.utils.addClass(element, 'active');
|
|
164
|
+
* dom.utils.addClass(element.children, 'highlight');
|
|
152
165
|
*/
|
|
153
166
|
export function addClass(element: Node | SunEditor.NodeCollection, className: string): void;
|
|
154
167
|
/**
|
|
155
168
|
* @description Delete the className value of the argument value element
|
|
156
169
|
* @param {Node|SunEditor.NodeCollection} element Elements to remove class name
|
|
157
170
|
* @param {string} className Class name to be remove
|
|
171
|
+
* @example
|
|
172
|
+
* dom.utils.removeClass(element, 'active');
|
|
158
173
|
*/
|
|
159
174
|
export function removeClass(element: Node | SunEditor.NodeCollection, className: string): void;
|
|
160
175
|
/**
|
|
161
176
|
* @description Argument value If there is no class name, insert it and delete the class name if it exists
|
|
162
177
|
* @param {Node} element Element to replace class name
|
|
163
178
|
* @param {string} className Class name to be change
|
|
164
|
-
* @
|
|
179
|
+
* @param {boolean} [force] If true, adds the class; if false, removes it.
|
|
165
180
|
*/
|
|
166
|
-
export function toggleClass(element: Node, className: string):
|
|
181
|
+
export function toggleClass(element: Node, className: string, force?: boolean): void;
|
|
167
182
|
/**
|
|
168
183
|
* @description Flash the class name of the argument value element for a certain time
|
|
169
184
|
* @param {Node} element Element to flash class name
|
|
170
185
|
* @param {string} className class name
|
|
171
186
|
* @param {number} [duration=120] duration milliseconds
|
|
187
|
+
* @example
|
|
188
|
+
* dom.utils.flashClass(element, 'blink', 500);
|
|
172
189
|
*/
|
|
173
190
|
export function flashClass(element: Node, className: string, duration?: number): void;
|
|
174
191
|
/**
|
|
@@ -195,6 +212,8 @@ export function getViewportSize(): {
|
|
|
195
212
|
* @param {boolean} includeWW Include the `wwTarget` element in the copy
|
|
196
213
|
* @param {Iterable<string>} styles Style list - kamel case
|
|
197
214
|
* @returns
|
|
215
|
+
* @example
|
|
216
|
+
* dom.utils.applyInlineStylesAll(wysiwygElement, true, ['font-family', 'font-size']);
|
|
198
217
|
*/
|
|
199
218
|
export function applyInlineStylesAll(wwTarget: Node, includeWW: boolean, styles: Iterable<string>): HTMLElement;
|
|
200
219
|
/**
|
|
@@ -202,6 +221,8 @@ export function applyInlineStylesAll(wwTarget: Node, includeWW: boolean, styles:
|
|
|
202
221
|
* @param {Node} target Target element
|
|
203
222
|
* @param {number} timeout Timeout milliseconds
|
|
204
223
|
* @returns {Promise<void>}
|
|
224
|
+
* @example
|
|
225
|
+
* await dom.utils.waitForMediaLoad(imgElement, 5000);
|
|
205
226
|
*/
|
|
206
227
|
export function waitForMediaLoad(target: Node, timeout?: number): Promise<void>;
|
|
207
228
|
/**
|
package/types/helper/index.d.ts
CHANGED
|
@@ -170,6 +170,10 @@ export const keyCodeMap: {
|
|
|
170
170
|
export const clipboard: {
|
|
171
171
|
write: typeof import('./clipboard').write;
|
|
172
172
|
};
|
|
173
|
+
export const markdown: {
|
|
174
|
+
jsonToMarkdown: typeof import('./markdown').jsonToMarkdown;
|
|
175
|
+
markdownToHtml: typeof import('./markdown').markdownToHtml;
|
|
176
|
+
};
|
|
173
177
|
declare namespace _default {
|
|
174
178
|
export { env };
|
|
175
179
|
export { unicode };
|
|
@@ -178,5 +182,6 @@ declare namespace _default {
|
|
|
178
182
|
export { numbers };
|
|
179
183
|
export { keyCodeMap };
|
|
180
184
|
export { clipboard };
|
|
185
|
+
export { markdown };
|
|
181
186
|
}
|
|
182
187
|
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {} from '../typedef';
|
|
2
|
+
/**
|
|
3
|
+
* @description Converts a JSON tree (from htmlToJson) to a Markdown string.
|
|
4
|
+
* @param {Object} jsonNode JSON node from htmlToJson
|
|
5
|
+
* @returns {string} Markdown string
|
|
6
|
+
* @example
|
|
7
|
+
* const json = htmlToJson('<p><strong>Hello</strong> World</p>');
|
|
8
|
+
* const md = jsonToMarkdown(json);
|
|
9
|
+
* // '**Hello** World\n\n'
|
|
10
|
+
*/
|
|
11
|
+
export function jsonToMarkdown(jsonNode: any): string;
|
|
12
|
+
/**
|
|
13
|
+
* @description Parses a Markdown string into an HTML string.
|
|
14
|
+
* - HTML tags in the markdown are passed through as-is (for fallback elements).
|
|
15
|
+
* @param {string} md Markdown string
|
|
16
|
+
* @param {string} [defaultLine='p'] Default block element tag
|
|
17
|
+
* @returns {string} HTML string
|
|
18
|
+
* @example
|
|
19
|
+
* markdownToHtml('# Hello\n\n**bold** text');
|
|
20
|
+
* // '<h1>Hello</h1><p><strong>bold</strong> text</p>'
|
|
21
|
+
*/
|
|
22
|
+
export function markdownToHtml(md: string, defaultLine?: string): string;
|
|
23
|
+
export default markdown;
|
|
24
|
+
declare namespace markdown {
|
|
25
|
+
export { jsonToMarkdown };
|
|
26
|
+
export { markdownToHtml };
|
|
27
|
+
}
|
|
@@ -154,15 +154,17 @@ declare class Base extends KernelInjector {
|
|
|
154
154
|
eventIndex?: number;
|
|
155
155
|
isInputComponent?: boolean;
|
|
156
156
|
};
|
|
157
|
-
/** @type {string} */
|
|
157
|
+
/** @type {string}Toolbar button tooltip text (e.g., `this.$.lang.font`) */
|
|
158
158
|
title: string;
|
|
159
|
-
/** @type {string} */
|
|
159
|
+
/** @type {string} - Toolbar button icon HTML string (e.g., `this.$.icons.bold`) */
|
|
160
160
|
icon: string;
|
|
161
|
-
/** @type {HTMLElement} */
|
|
161
|
+
/** @type {string|HTMLElement|boolean|null} - Inner content of the toolbar button. HTML string for dropdown text labels, HTMLElement for input fields, or `false` to hide. */
|
|
162
|
+
inner: string | HTMLElement | boolean | null;
|
|
163
|
+
/** @type {HTMLElement} - Element inserted before the main toolbar button (e.g., decrease button in fontSize) */
|
|
162
164
|
beforeItem: HTMLElement;
|
|
163
|
-
/** @type {HTMLElement} */
|
|
165
|
+
/** @type {HTMLElement} - Element inserted after the main toolbar button (e.g., dropdown arrow, increase button) */
|
|
164
166
|
afterItem: HTMLElement;
|
|
165
|
-
/** @type {HTMLElement} */
|
|
167
|
+
/** @type {HTMLElement} - Replaces the entire default toolbar button with a custom element */
|
|
166
168
|
replaceButton: HTMLElement;
|
|
167
169
|
}
|
|
168
170
|
import KernelInjector from '../core/kernel/kernelInjector';
|
package/types/langs/_Lang.d.ts
CHANGED
|
@@ -110,6 +110,7 @@ export type _Lang = {
|
|
|
110
110
|
link_modal_url: string;
|
|
111
111
|
link_modal_relAttribute: string;
|
|
112
112
|
list: string;
|
|
113
|
+
markdownView: string;
|
|
113
114
|
math: string;
|
|
114
115
|
math_modal_fontSizeLabel: string;
|
|
115
116
|
math_modal_inputLabel: string;
|
|
@@ -171,6 +172,7 @@ export type _Lang = {
|
|
|
171
172
|
tableProperties: string;
|
|
172
173
|
tags: string;
|
|
173
174
|
tag_blockquote: string;
|
|
175
|
+
codeBlock: string;
|
|
174
176
|
tag_div: string;
|
|
175
177
|
tag_h: string;
|
|
176
178
|
tag_p: string;
|
|
@@ -189,6 +191,13 @@ export type _Lang = {
|
|
|
189
191
|
video_modal_title: string;
|
|
190
192
|
video_modal_url: string;
|
|
191
193
|
width: string;
|
|
194
|
+
codeLanguage: string;
|
|
195
|
+
codeLanguage_none: string;
|
|
196
|
+
finder_matchCase: string;
|
|
197
|
+
finder_wholeWord: string;
|
|
198
|
+
finder_regex: string;
|
|
199
|
+
finder_prev: string;
|
|
200
|
+
finder_next: string;
|
|
192
201
|
message_copy_success: string;
|
|
193
202
|
message_copy_fail: string;
|
|
194
203
|
};
|
|
@@ -97,7 +97,11 @@ export type BrowserParams = {
|
|
|
97
97
|
*/
|
|
98
98
|
listClass?: string;
|
|
99
99
|
/**
|
|
100
|
-
* - Function that
|
|
100
|
+
* - Function that returns HTML string for rendering each file item. Required. Can be overridden in browser.
|
|
101
|
+
* ```js
|
|
102
|
+
* // drawItemHandler
|
|
103
|
+
* (item) => `<div><img src="${item.thumbnail}"><span>${item.name}</span></div>`
|
|
104
|
+
* ```
|
|
101
105
|
*/
|
|
102
106
|
drawItemHandler?: (item: BrowserFile) => string;
|
|
103
107
|
/**
|
|
@@ -140,7 +144,11 @@ export type BrowserParams = {
|
|
|
140
144
|
* @property {string} [searchUrl] - File server search url. Optional. Can be overridden in browser.
|
|
141
145
|
* @property {Object<string, string>} [searchUrlHeader] - File server search http header. Optional. Can be overridden in browser.
|
|
142
146
|
* @property {string} [listClass] - Class name of list div. Required. Can be overridden in browser.
|
|
143
|
-
* @property {(item: BrowserFile) => string} [drawItemHandler] - Function that
|
|
147
|
+
* @property {(item: BrowserFile) => string} [drawItemHandler] - Function that returns HTML string for rendering each file item. Required. Can be overridden in browser.
|
|
148
|
+
* ```js
|
|
149
|
+
* // drawItemHandler
|
|
150
|
+
* (item) => `<div><img src="${item.thumbnail}"><span>${item.name}</span></div>`
|
|
151
|
+
* ```
|
|
144
152
|
* @property {Array<*>} [props] - `props` argument to `drawItemHandler` function. Optional. Can be overridden in browser.
|
|
145
153
|
* @property {number} [columnSize] - Number of `div.se-file-item-column` to be created.
|
|
146
154
|
* - Optional. Can be overridden in browser. Default: 4.
|
|
@@ -156,6 +164,17 @@ declare class Browser {
|
|
|
156
164
|
* @param {*} host The instance object that called the constructor.
|
|
157
165
|
* @param {SunEditor.Deps} $ Kernel dependencies
|
|
158
166
|
* @param {BrowserParams} params Browser options
|
|
167
|
+
* @example
|
|
168
|
+
* // Inside a PluginBrowser constructor:
|
|
169
|
+
* this.browser = new Browser(this, this.$, {
|
|
170
|
+
* title: this.$.lang.imageGallery,
|
|
171
|
+
* data: pluginOptions.data,
|
|
172
|
+
* url: pluginOptions.url,
|
|
173
|
+
* headers: pluginOptions.headers,
|
|
174
|
+
* selectorHandler: this.#OnSelect.bind(this),
|
|
175
|
+
* columnSize: 4,
|
|
176
|
+
* className: 'se-image-gallery',
|
|
177
|
+
* });
|
|
159
178
|
*/
|
|
160
179
|
constructor(host: any, $: SunEditor.Deps, params: BrowserParams);
|
|
161
180
|
useSearch: boolean;
|
|
@@ -226,6 +245,16 @@ declare class Browser {
|
|
|
226
245
|
* @param {string} [params.title] - File browser window title. If not, use `this.title`.
|
|
227
246
|
* @param {string} [params.url] - File server url. If not, use `this.url`.
|
|
228
247
|
* @param {Object<string, string>} [params.urlHeader] - File server http header. If not, use `this.urlHeader`.
|
|
248
|
+
* @example
|
|
249
|
+
* // Open with default settings (configured at construction):
|
|
250
|
+
* this.browser.open();
|
|
251
|
+
*
|
|
252
|
+
* // Open with runtime overrides:
|
|
253
|
+
* this.browser.open({
|
|
254
|
+
* title: 'Select a video',
|
|
255
|
+
* url: '/api/videos',
|
|
256
|
+
* urlHeader: { Authorization: 'Bearer token' },
|
|
257
|
+
* });
|
|
229
258
|
*/
|
|
230
259
|
open(params?: {
|
|
231
260
|
listClass?: string;
|
|
@@ -249,6 +278,11 @@ declare class Browser {
|
|
|
249
278
|
* @description Filter items by tag
|
|
250
279
|
* @param {Array<BrowserFile>} items - Items to filter
|
|
251
280
|
* @returns {Array<BrowserFile>}
|
|
281
|
+
* @example
|
|
282
|
+
* // Filter items by currently selected tags:
|
|
283
|
+
* browser.selectedTags = ['photo', 'landscape'];
|
|
284
|
+
* const filtered = browser.tagfilter(items);
|
|
285
|
+
* // Returns only items whose `tag` array includes 'photo' or 'landscape'
|
|
252
286
|
*/
|
|
253
287
|
tagfilter(items: Array<BrowserFile>): Array<BrowserFile>;
|
|
254
288
|
/**
|
|
@@ -81,6 +81,12 @@ declare class ColorPicker {
|
|
|
81
81
|
* @param {?(current: Node) => boolean} [stopCondition] - A function used to stop traversing parent nodes while finding the color.
|
|
82
82
|
* - When this function returns `true`, the traversal ends at that node.
|
|
83
83
|
* - e.g., `(node) => this.format.isLine(node)` stops at line-level elements like <p>, <div>.
|
|
84
|
+
* @example
|
|
85
|
+
* // Initialize with a selected node and stop traversal at line-level elements
|
|
86
|
+
* this.colorPicker.init(this.$.selection.getNode(), target, (current) => this.$.format.isLine(current));
|
|
87
|
+
*
|
|
88
|
+
* // Initialize with a color string directly (e.g., from a table cell style)
|
|
89
|
+
* this.colorPicker.init(color?.value || '', button);
|
|
84
90
|
*/
|
|
85
91
|
init(nodeOrColor: Node | string, target: Node, stopCondition?: ((current: Node) => boolean) | null): void;
|
|
86
92
|
/**
|
|
@@ -150,24 +150,40 @@ declare class Controller {
|
|
|
150
150
|
* @param {Node} [positionTarget] Position target element
|
|
151
151
|
* @param {Object} [params={}] params
|
|
152
152
|
* @param {boolean} [params.isWWTarget] If the controller is in the WYSIWYG area, set it to `true`.
|
|
153
|
+
* @param {boolean} [params.passive] If `true`, opens the controller visually without affecting editor state
|
|
154
|
+
* - (`_preventBlur`, `controlActive`, `onControllerContext`, `opendControllers`).
|
|
155
|
+
* - Used for lightweight, non-intrusive display such as hover-triggered UI (e.g., codeLang selector on `<pre>` hover).
|
|
156
|
+
* - Automatically set to `true` when opened during component hover selection (`ON_OVER_COMPONENT`).
|
|
153
157
|
* @param {() => void} [params.initMethod] Method to be called when the controller is closed.
|
|
154
158
|
* @param {boolean} [params.disabled] If `true`, When the `controller` is opened, buttons without the `se-component-enabled` class are disabled. (default: `this.disabled`)
|
|
155
|
-
* @param {{left?: number, top?: number}} [params.addOffset] Additional offset values
|
|
159
|
+
* @param {{left?: number, right?:number, top?: number}} [params.addOffset] Additional offset values
|
|
160
|
+
* @example
|
|
161
|
+
* // Open controller on a target element with default options
|
|
162
|
+
* this.controller.open(target);
|
|
163
|
+
*
|
|
164
|
+
* // Open with explicit options and additional offset
|
|
165
|
+
* this.controller.open(target, null, { isWWTarget: false, initMethod: null, addOffset: null });
|
|
166
|
+
*
|
|
167
|
+
* // Open on a Range target (e.g., text selection)
|
|
168
|
+
* this.controller.open(this.$.selection.getRange());
|
|
156
169
|
*/
|
|
157
170
|
open(
|
|
158
171
|
target: Node | Range,
|
|
159
172
|
positionTarget?: Node,
|
|
160
173
|
{
|
|
161
174
|
isWWTarget,
|
|
175
|
+
passive,
|
|
162
176
|
initMethod,
|
|
163
177
|
disabled,
|
|
164
178
|
addOffset,
|
|
165
179
|
}?: {
|
|
166
180
|
isWWTarget?: boolean;
|
|
181
|
+
passive?: boolean;
|
|
167
182
|
initMethod?: () => void;
|
|
168
183
|
disabled?: boolean;
|
|
169
184
|
addOffset?: {
|
|
170
185
|
left?: number;
|
|
186
|
+
right?: number;
|
|
171
187
|
top?: number;
|
|
172
188
|
};
|
|
173
189
|
},
|
|
@@ -176,6 +192,12 @@ declare class Controller {
|
|
|
176
192
|
* @description Close a modal plugin
|
|
177
193
|
* - The plugin's `init` method is called.
|
|
178
194
|
* @param {boolean} [force] If `true`, parent controllers are forcibly closed.
|
|
195
|
+
* @example
|
|
196
|
+
* // Close the controller (skips if not open or preventClose is set)
|
|
197
|
+
* this.controller.close();
|
|
198
|
+
*
|
|
199
|
+
* // Force close, also closing parent controllers in the hierarchy
|
|
200
|
+
* this.controller.close(true);
|
|
179
201
|
*/
|
|
180
202
|
close(force?: boolean): void;
|
|
181
203
|
/**
|
|
@@ -189,11 +211,23 @@ declare class Controller {
|
|
|
189
211
|
/**
|
|
190
212
|
* @description Sets whether the element (form) should be brought to the top based on `z-index`.
|
|
191
213
|
* @param {boolean} value - `true`: `'2147483646'`, `false`: `'2147483645'`.
|
|
214
|
+
* @example
|
|
215
|
+
* // Bring controller to the highest z-index layer (2147483646)
|
|
216
|
+
* this.controller_cell.bringToTop(true);
|
|
217
|
+
*
|
|
218
|
+
* // Restore to the default top z-index (2147483645)
|
|
219
|
+
* this.controller_cell.bringToTop(false);
|
|
192
220
|
*/
|
|
193
221
|
bringToTop(value: boolean): void;
|
|
194
222
|
/**
|
|
195
223
|
* @description Reset controller position
|
|
196
224
|
* @param {Node} [target]
|
|
225
|
+
* @example
|
|
226
|
+
* // Reposition using a new target element
|
|
227
|
+
* this.controller_cell.resetPosition(tdElement);
|
|
228
|
+
*
|
|
229
|
+
* // Reposition using the previously set target
|
|
230
|
+
* this.controller.resetPosition();
|
|
197
231
|
*/
|
|
198
232
|
resetPosition(target?: Node): void;
|
|
199
233
|
/**
|
|
@@ -242,6 +242,12 @@ declare class Figure {
|
|
|
242
242
|
* @param {Node} element Target element
|
|
243
243
|
* @param {string} [className] Class name of container (fixed: `se-component`)
|
|
244
244
|
* @returns {FigureInfo} {target, container, cover, inlineCover, caption}
|
|
245
|
+
* @example
|
|
246
|
+
* const imgEl = document.createElement('IMG');
|
|
247
|
+
* imgEl.src = imageUrl;
|
|
248
|
+
* const figureInfo = Figure.CreateContainer(imgEl, 'se-image-container');
|
|
249
|
+
* // figureInfo.container → <div class="se-component se-image-container">
|
|
250
|
+
* // figureInfo.cover → <figure> wrapping the imgEl
|
|
245
251
|
*/
|
|
246
252
|
static CreateContainer(element: Node, className?: string): FigureInfo;
|
|
247
253
|
/**
|
|
@@ -249,6 +255,12 @@ declare class Figure {
|
|
|
249
255
|
* @param {Node} element Target element
|
|
250
256
|
* @param {string} [className] Class name of container (fixed: `se-component` `se-inline-component`)
|
|
251
257
|
* @returns {FigureInfo} {target, container, cover, inlineCover, caption}
|
|
258
|
+
* @example
|
|
259
|
+
* const imgEl = document.createElement('IMG');
|
|
260
|
+
* imgEl.src = imageUrl;
|
|
261
|
+
* const figureInfo = Figure.CreateInlineContainer(imgEl, 'se-image-container');
|
|
262
|
+
* // figureInfo.container → <span class="se-component se-inline-component se-image-container">
|
|
263
|
+
* // figureInfo.inlineCover → same as container (inline mode)
|
|
252
264
|
*/
|
|
253
265
|
static CreateInlineContainer(element: Node, className?: string): FigureInfo;
|
|
254
266
|
/**
|
|
@@ -269,6 +281,13 @@ declare class Figure {
|
|
|
269
281
|
* @param {string|number} h Height size
|
|
270
282
|
* @param {?string} [defaultSizeUnit="px"] Default size unit (default: `"px"`)
|
|
271
283
|
* @return {{w: number, h: number}}
|
|
284
|
+
* @example
|
|
285
|
+
* const ratio = Figure.GetRatio(200, 100, 'px');
|
|
286
|
+
* // ratio → { w: 2, h: 0.5 }
|
|
287
|
+
*
|
|
288
|
+
* // Used with proportion-locked resizing
|
|
289
|
+
* const ratio = Figure.GetRatio(inputX.value, inputY.value, sizeUnit);
|
|
290
|
+
* const adjusted = Figure.CalcRatio(newWidth, newHeight, sizeUnit, ratio);
|
|
272
291
|
*/
|
|
273
292
|
static GetRatio(
|
|
274
293
|
w: string | number,
|
|
@@ -285,6 +304,11 @@ declare class Figure {
|
|
|
285
304
|
* @param {string} defaultSizeUnit Default size unit (default: `"px"`)
|
|
286
305
|
* @param {?{w: number, h: number}} [ratio] Ratio size (Figure.GetRatio)
|
|
287
306
|
* @return {{w: string|number, h: string|number}}
|
|
307
|
+
* @example
|
|
308
|
+
* const ratio = Figure.GetRatio(200, 100, 'px');
|
|
309
|
+
* // When width changes, recalculate height to maintain aspect ratio
|
|
310
|
+
* const result = Figure.CalcRatio(inputX.value, inputY.value, 'px', ratio);
|
|
311
|
+
* inputY.value = result.h; // adjusted height preserving ratio
|
|
288
312
|
*/
|
|
289
313
|
static CalcRatio(
|
|
290
314
|
w: string | number,
|
|
@@ -372,6 +396,19 @@ declare class Figure {
|
|
|
372
396
|
* @param {boolean} [params.figureTarget=false] If `true`, the target is a figure element
|
|
373
397
|
* @param {boolean} [params.infoOnly=false] If `true`, returns only the figure target info without opening the controller
|
|
374
398
|
* @returns {FigureTargetInfo|undefined} figure target info
|
|
399
|
+
* @example
|
|
400
|
+
* // Open controller with full UI (resize handles, size info, border)
|
|
401
|
+
* const info = this.figure.open(imgElement, {
|
|
402
|
+
* nonResizing: false, nonSizeInfo: false, nonBorder: false,
|
|
403
|
+
* figureTarget: false, infoOnly: false
|
|
404
|
+
* });
|
|
405
|
+
*
|
|
406
|
+
* // Get figure info without opening the controller UI
|
|
407
|
+
* const info = this.figure.open(oFrame, {
|
|
408
|
+
* nonResizing: false, nonSizeInfo: false, nonBorder: false,
|
|
409
|
+
* figureTarget: false, infoOnly: true
|
|
410
|
+
* });
|
|
411
|
+
* // info.width, info.height, info.ratio are available
|
|
375
412
|
*/
|
|
376
413
|
open(
|
|
377
414
|
targetNode: Node,
|
|
@@ -452,6 +489,13 @@ declare class Figure {
|
|
|
452
489
|
* @param {?Node} targetNode Target element
|
|
453
490
|
* @param {"block"|"inline"} formatStyle Format style
|
|
454
491
|
* @returns {HTMLElement} New target element after conversion
|
|
492
|
+
* @example
|
|
493
|
+
* // Convert a block image to inline format
|
|
494
|
+
* const newImgEl = this.figure.convertAsFormat(imgElement, 'inline');
|
|
495
|
+
* // newImgEl is a cloned element inside a new inline container
|
|
496
|
+
*
|
|
497
|
+
* // Convert an inline image back to block format
|
|
498
|
+
* const newImgEl = this.figure.convertAsFormat(imgElement, 'block');
|
|
455
499
|
*/
|
|
456
500
|
convertAsFormat(targetNode: Node | null, formatStyle: 'block' | 'inline'): HTMLElement;
|
|
457
501
|
controllerAction(target: HTMLButtonElement): void;
|
|
@@ -461,6 +505,13 @@ declare class Figure {
|
|
|
461
505
|
* @param {Node} originEl - The original element of the figure component.
|
|
462
506
|
* @param {Node} anchorCover - The anchor cover element of the figure component.
|
|
463
507
|
* @param {import('../manager/FileManager').default} [fileManagerInst=null] - FileManager module instance, if used.
|
|
508
|
+
* @example
|
|
509
|
+
* // Insert a new image figure, replacing the original element in the DOM
|
|
510
|
+
* const figureInfo = Figure.CreateContainer(imgElement, 'se-image-container');
|
|
511
|
+
* this.figure.retainFigureFormat(figureInfo.container, this.#element, null, this.fileManager);
|
|
512
|
+
*
|
|
513
|
+
* // Replace with anchor cover (e.g., image wrapped in a link)
|
|
514
|
+
* this.figure.retainFigureFormat(container, this.#element, anchorEl, this.fileManager);
|
|
464
515
|
*/
|
|
465
516
|
retainFigureFormat(container: Node, originEl: Node, anchorCover: Node, fileManagerInst?: import('../manager/FileManager').default): void;
|
|
466
517
|
/**
|
|
@@ -474,6 +525,12 @@ declare class Figure {
|
|
|
474
525
|
* @param {?string|number} width Element's width size
|
|
475
526
|
* @param {?string|number} height Element's height size
|
|
476
527
|
* @param {?number} deg rotate value
|
|
528
|
+
* @example
|
|
529
|
+
* // Rotate element 90 degrees clockwise
|
|
530
|
+
* this.figure.setTransform(imgElement, 100, 50, 90);
|
|
531
|
+
*
|
|
532
|
+
* // Apply size without additional rotation (deg=0 preserves current rotation)
|
|
533
|
+
* this.figure.setTransform(oFrame, width, height, 0);
|
|
477
534
|
*/
|
|
478
535
|
setTransform(node: Node, width: (string | number) | null, height: (string | number) | null, deg: number | null): void;
|
|
479
536
|
/**
|
|
@@ -12,6 +12,12 @@ declare class Modal {
|
|
|
12
12
|
* - acceptedFormats: `"image/*, video/*, audio/*"`, etc.
|
|
13
13
|
* - allowMultiple: `true` or `false`
|
|
14
14
|
* @returns {string} HTML string
|
|
15
|
+
* @example
|
|
16
|
+
* // Inside a plugin's modal HTML template:
|
|
17
|
+
* const html = Modal.CreateFileInput(
|
|
18
|
+
* { icons, lang },
|
|
19
|
+
* { acceptedFormats: 'image/*', allowMultiple: true }
|
|
20
|
+
* );
|
|
15
21
|
*/
|
|
16
22
|
static CreateFileInput(
|
|
17
23
|
{
|
|
@@ -71,6 +71,20 @@ declare class ApiManager {
|
|
|
71
71
|
/**
|
|
72
72
|
* @description Call API
|
|
73
73
|
* @param {ApiManagerParams} params
|
|
74
|
+
* @example
|
|
75
|
+
* // POST with FormData and callbacks
|
|
76
|
+
* apiManager.call({
|
|
77
|
+
* method: 'POST', url: '/upload', headers: { 'x-custom': 'value' },
|
|
78
|
+
* data: formData,
|
|
79
|
+
* callBack: (xhr) => console.log(xhr.responseText),
|
|
80
|
+
* errorCallBack: (res, xhr) => res.errorMessage || 'Upload failed'
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* // GET request with minimal params (uses constructor defaults for omitted options)
|
|
84
|
+
* apiManager.call({
|
|
85
|
+
* method: 'GET', url: '/api/files',
|
|
86
|
+
* callBack: (xhr) => JSON.parse(xhr.responseText)
|
|
87
|
+
* });
|
|
74
88
|
*/
|
|
75
89
|
call({ method, url, headers, data, callBack, errorCallBack, responseType }: ApiManagerParams): void;
|
|
76
90
|
/**
|
|
@@ -82,6 +96,18 @@ declare class ApiManager {
|
|
|
82
96
|
* @param {*} [params.data] - API data
|
|
83
97
|
* @param {XMLHttpRequestResponseType} [params.responseType] - XMLHttpRequest.responseType
|
|
84
98
|
* @returns {Promise<XMLHttpRequest>}
|
|
99
|
+
* @example
|
|
100
|
+
* // POST FormData and await the response
|
|
101
|
+
* const xhr = await apiManager.asyncCall({
|
|
102
|
+
* method: 'POST', url: '/upload',
|
|
103
|
+
* headers: { 'x-api-key': 'key' }, data: formData
|
|
104
|
+
* });
|
|
105
|
+
* const result = JSON.parse(xhr.responseText);
|
|
106
|
+
*
|
|
107
|
+
* // Send JSON data (uses constructor defaults for method/url)
|
|
108
|
+
* const xhr = await apiManager.asyncCall({
|
|
109
|
+
* data: JSON.stringify({ fileName: 'doc.pdf', htmlContent })
|
|
110
|
+
* });
|
|
85
111
|
*/
|
|
86
112
|
asyncCall({
|
|
87
113
|
method,
|