Skip to content

Commit 8685fb8

Browse files
r-farkhutdinovRuslan Farkhutdinovmpreyskurantov
authored
HtmlEditor: Add AI toolbar option types (DevExpress#29415)
Co-authored-by: Ruslan Farkhutdinov <[email protected]> Co-authored-by: Mikhail Preyskurantov <[email protected]>
1 parent cfbeb9e commit 8685fb8

File tree

3 files changed

+289
-4
lines changed

3 files changed

+289
-4
lines changed

packages/devextreme/js/ui/html_editor.d.ts

Lines changed: 145 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,150 @@ export type HtmlEditorImageUploadTab = 'url' | 'file';
4646
/** @public */
4747
export type HtmlEditorPredefinedContextMenuItem = 'background' | 'bold' | 'color' | 'font' | 'italic' | 'link' | 'image' | 'strike' | 'subscript' | 'superscript' | 'underline' | 'blockquote' | 'increaseIndent' | 'decreaseIndent' | 'orderedList' | 'bulletList' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify' | 'codeBlock' | 'variable' | 'undo' | 'redo' | 'clear' | 'insertTable' | 'insertHeaderRow' | 'insertRowAbove' | 'insertRowBelow' | 'insertColumnLeft' | 'insertColumnRight' | 'deleteColumn' | 'deleteRow' | 'deleteTable' | 'cellProperties' | 'tableProperties';
4848
/** @public */
49-
export type HtmlEditorPredefinedToolbarItem = 'background' | 'bold' | 'color' | 'font' | 'italic' | 'link' | 'image' | 'size' | 'strike' | 'subscript' | 'superscript' | 'underline' | 'blockquote' | 'header' | 'increaseIndent' | 'decreaseIndent' | 'orderedList' | 'bulletList' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify' | 'codeBlock' | 'variable' | 'separator' | 'undo' | 'redo' | 'clear' | 'cellProperties' | 'tableProperties' | 'insertTable' | 'insertHeaderRow' | 'insertRowAbove' | 'insertRowBelow' | 'insertColumnLeft' | 'insertColumnRight' | 'deleteColumn' | 'deleteRow' | 'deleteTable';
49+
export type HtmlEditorPredefinedToolbarItem = 'background' | 'bold' | 'color' | 'font' | 'italic' | 'link' | 'image' | 'size' | 'strike' | 'subscript' | 'superscript' | 'underline' | 'blockquote' | 'header' | 'increaseIndent' | 'decreaseIndent' | 'orderedList' | 'bulletList' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify' | 'codeBlock' | 'variable' | 'separator' | 'undo' | 'redo' | 'clear' | 'cellProperties' | 'tableProperties' | 'insertTable' | 'insertHeaderRow' | 'insertRowAbove' | 'insertRowBelow' | 'insertColumnLeft' | 'insertColumnRight' | 'deleteColumn' | 'deleteRow' | 'deleteTable' | 'ai';
50+
51+
/** @public */
52+
export type AICommandName = 'summarize' | 'proofread' | 'expand' | 'shorten' | 'changeStyle' | 'changeTone' | 'translate' | 'askAI';
53+
54+
/** @public */
55+
export type AIChangeStyleOption =
56+
| 'formal'
57+
| 'informal'
58+
| 'technical'
59+
| 'business'
60+
| 'creative'
61+
| 'journalistic'
62+
| 'academic'
63+
| 'persuasive'
64+
| 'narrative'
65+
| 'expository'
66+
| 'descriptive'
67+
| 'conversational';
68+
69+
/** @public */
70+
export type AIChangeToneOption =
71+
| 'professional'
72+
| 'casual'
73+
| 'straightforward'
74+
| 'confident'
75+
| 'friendly';
76+
77+
/** @public */
78+
export type AITranslateOption =
79+
| 'arabic'
80+
| 'chinese'
81+
| 'english'
82+
| 'french'
83+
| 'german'
84+
| 'japanese'
85+
| 'spanish';
86+
87+
/**
88+
* @docid
89+
* @public
90+
*/
91+
export type AICommandNameExtended = AICommandName | 'custom';
92+
93+
/**
94+
* @docid
95+
* @namespace DevExpress.ui.dxHtmlEditor
96+
*/
97+
export interface AICommandBase<
98+
CommandName extends AICommandNameExtended, // eslint-disable-line @typescript-eslint/no-unused-vars
99+
CommandOptions = undefined> {
100+
/**
101+
* @docid
102+
* @public
103+
*/
104+
name: AICommandNameExtended;
105+
/**
106+
* @docid
107+
* @public
108+
*/
109+
text?: string;
110+
/**
111+
* @docid
112+
* @public
113+
*/
114+
options?: CommandOptions;
115+
}
116+
117+
/**
118+
* @docid
119+
* @public
120+
* @inherits AICommandBase
121+
* @namespace DevExpress.ui.dxHtmlEditor
122+
*/
123+
export type AIChangeStyleCommand = AICommandBase<'changeStyle', (AIChangeStyleOption | string)[]>;
124+
125+
/**
126+
* @docid
127+
* @public
128+
* @inherits AICommandBase
129+
* @namespace DevExpress.ui.dxHtmlEditor
130+
*/
131+
export type AIChangeToneCommand = AICommandBase<'changeTone', (AIChangeToneOption | string)[]>;
132+
133+
/**
134+
* @docid
135+
* @public
136+
* @inherits AICommandBase
137+
* @namespace DevExpress.ui.dxHtmlEditor
138+
*/
139+
export type AITranslateCommand = AICommandBase<'translate', (AITranslateOption | string)[]>;
140+
141+
/**
142+
* @docid
143+
* @public
144+
* @inherits AICommandBase
145+
* @namespace DevExpress.ui.dxHtmlEditor
146+
*/
147+
export interface AICustomCommand extends AICommandBase<'custom', string[]> {
148+
/**
149+
* @docid
150+
* @public
151+
*/
152+
prompt: (param?: string) => string;
153+
/**
154+
* @docid
155+
* @public
156+
*/
157+
text: string;
158+
}
159+
160+
/**
161+
* @docid
162+
* @public
163+
* @namespace DevExpress.ui.dxHtmlEditor
164+
*/
165+
export type AICommand =
166+
| AICommandBase<'summarize', any>
167+
| AICommandBase<'proofread', any>
168+
| AICommandBase<'expand', any>
169+
| AICommandBase<'shorten', any>
170+
| AICommandBase<'askAI', any>
171+
| AIChangeStyleCommand
172+
| AIChangeToneCommand
173+
| AITranslateCommand
174+
| AICustomCommand;
175+
176+
/**
177+
* @docid
178+
* @public
179+
* @namespace DevExpress.ui.dxHtmlEditor
180+
*/
181+
export interface AIToolbarItem extends Omit<dxToolbarItem, 'menuItemTemplate' | 'showText' | 'widget' | 'options' | 'template' | 'html'> {
182+
/**
183+
* @docid
184+
* @public
185+
*/
186+
name: 'ai';
187+
/**
188+
* @docid
189+
* @public
190+
*/
191+
commands?: Array<AICommandName | AICommand>;
192+
}
50193

51194
/**
52195
* @docid _ui_html_editor_ContentReadyEvent
@@ -660,7 +803,7 @@ export interface dxHtmlEditorToolbar {
660803
* @public
661804
* @namespace DevExpress.ui.dxHtmlEditor
662805
*/
663-
export type ToolbarItem = dxHtmlEditorToolbarItem;
806+
export type ToolbarItem = dxHtmlEditorToolbarItem | AIToolbarItem;
664807

665808
/**
666809
* @deprecated Use ToolbarItem instead

packages/devextreme/js/ui/html_editor_types.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ export {
66
HtmlEditorImageUploadTab,
77
HtmlEditorPredefinedContextMenuItem,
88
HtmlEditorPredefinedToolbarItem,
9+
AICommandName,
10+
AIChangeStyleOption,
11+
AIChangeToneOption,
12+
AITranslateOption,
13+
AICommandNameExtended,
14+
AIChangeStyleCommand,
15+
AIChangeToneCommand,
16+
AITranslateCommand,
17+
AICustomCommand,
18+
AICommand,
19+
AIToolbarItem,
920
ContentReadyEvent,
1021
DisposingEvent,
1122
FocusInEvent,

packages/devextreme/ts/dx.all.d.ts

Lines changed: 133 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19584,6 +19584,46 @@ declare module DevExpress.ui {
1958419584
undo(): void;
1958519585
}
1958619586
module dxHtmlEditor {
19587+
export type AIChangeStyleOption =
19588+
| 'formal'
19589+
| 'informal'
19590+
| 'technical'
19591+
| 'business'
19592+
| 'creative'
19593+
| 'journalistic'
19594+
| 'academic'
19595+
| 'persuasive'
19596+
| 'narrative'
19597+
| 'expository'
19598+
| 'descriptive'
19599+
| 'conversational';
19600+
export type AIChangeToneOption =
19601+
| 'professional'
19602+
| 'casual'
19603+
| 'straightforward'
19604+
| 'confident'
19605+
| 'friendly';
19606+
export type AICommandName =
19607+
| 'summarize'
19608+
| 'proofread'
19609+
| 'expand'
19610+
| 'shorten'
19611+
| 'changeStyle'
19612+
| 'changeTone'
19613+
| 'translate'
19614+
| 'askAI';
19615+
/**
19616+
* [descr:AICommandNameExtended]
19617+
*/
19618+
export type AICommandNameExtended = AICommandName | 'custom';
19619+
export type AITranslateOption =
19620+
| 'arabic'
19621+
| 'chinese'
19622+
| 'english'
19623+
| 'french'
19624+
| 'german'
19625+
| 'japanese'
19626+
| 'spanish';
1958719627
/**
1958819628
* [descr:_ui_html_editor_ContentReadyEvent]
1958919629
*/
@@ -19703,7 +19743,8 @@ declare module DevExpress.ui {
1970319743
| 'insertColumnRight'
1970419744
| 'deleteColumn'
1970519745
| 'deleteRow'
19706-
| 'deleteTable';
19746+
| 'deleteTable'
19747+
| 'ai';
1970719748
/**
1970819749
* [descr:_ui_html_editor_InitializedEvent]
1970919750
*/
@@ -31784,6 +31825,96 @@ declare module DevExpress.ui.dxGantt {
3178431825
export type ToolbarItem = dxGanttToolbarItem;
3178531826
}
3178631827
declare module DevExpress.ui.dxHtmlEditor {
31828+
/**
31829+
* [descr:AIChangeStyleCommand]
31830+
*/
31831+
export type AIChangeStyleCommand = AICommandBase<
31832+
'changeStyle',
31833+
(AIChangeStyleOption | string)[]
31834+
>;
31835+
/**
31836+
* [descr:AIChangeToneCommand]
31837+
*/
31838+
export type AIChangeToneCommand = AICommandBase<
31839+
'changeTone',
31840+
(AIChangeToneOption | string)[]
31841+
>;
31842+
/**
31843+
* [descr:AICommand]
31844+
*/
31845+
export type AICommand =
31846+
| AICommandBase<'summarize', any>
31847+
| AICommandBase<'proofread', any>
31848+
| AICommandBase<'expand', any>
31849+
| AICommandBase<'shorten', any>
31850+
| AICommandBase<'askAI', any>
31851+
| AIChangeStyleCommand
31852+
| AIChangeToneCommand
31853+
| AITranslateCommand
31854+
| AICustomCommand;
31855+
/**
31856+
* [descr:AICommandBase]
31857+
* @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
31858+
*/
31859+
export interface AICommandBase<
31860+
CommandName extends AICommandNameExtended,
31861+
CommandOptions = undefined
31862+
> {
31863+
/**
31864+
* [descr:AICommandBase.name]
31865+
*/
31866+
name: AICommandNameExtended;
31867+
/**
31868+
* [descr:AICommandBase.text]
31869+
*/
31870+
text?: string;
31871+
/**
31872+
* [descr:AICommandBase.options]
31873+
*/
31874+
options?: CommandOptions;
31875+
}
31876+
/**
31877+
* [descr:AICustomCommand]
31878+
*/
31879+
export interface AICustomCommand extends AICommandBase<'custom', string[]> {
31880+
/**
31881+
* [descr:AICustomCommand.prompt]
31882+
*/
31883+
prompt: (param?: string) => string;
31884+
/**
31885+
* [descr:AICustomCommand.text]
31886+
*/
31887+
text: string;
31888+
}
31889+
/**
31890+
* [descr:AIToolbarItem]
31891+
*/
31892+
export interface AIToolbarItem
31893+
extends Omit<
31894+
DevExpress.ui.dxToolbar.Item,
31895+
| 'menuItemTemplate'
31896+
| 'showText'
31897+
| 'widget'
31898+
| 'options'
31899+
| 'template'
31900+
| 'html'
31901+
> {
31902+
/**
31903+
* [descr:AIToolbarItem.name]
31904+
*/
31905+
name: 'ai';
31906+
/**
31907+
* [descr:AIToolbarItem.commands]
31908+
*/
31909+
commands?: Array<AICommandName | AICommand>;
31910+
}
31911+
/**
31912+
* [descr:AITranslateCommand]
31913+
*/
31914+
export type AITranslateCommand = AICommandBase<
31915+
'translate',
31916+
(AITranslateOption | string)[]
31917+
>;
3178731918
export type ContextMenuItem = dxHtmlEditorTableContextMenuItem;
3178831919
/**
3178931920
* [descr:Converter]
@@ -31799,7 +31930,7 @@ declare module DevExpress.ui.dxHtmlEditor {
3179931930
fromHtml?: (value: string) => string;
3180031931
};
3180131932
export type ImageUploadTab = dxHtmlEditorImageUploadTabItem;
31802-
export type ToolbarItem = dxHtmlEditorToolbarItem;
31933+
export type ToolbarItem = dxHtmlEditorToolbarItem | AIToolbarItem;
3180331934
}
3180431935
declare module DevExpress.ui.dxList {
3180531936
export type Item = dxListItem;

0 commit comments

Comments
 (0)