@ckeditor/ckeditor5-ai 40.0.0 → 40.2.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/LICENSE.md +2 -2
- package/README.md +1 -1
- package/build/ai.js +77 -2
- package/build/translations/af.js +1 -1
- package/build/translations/ar.js +1 -1
- package/build/translations/bg.js +1 -1
- package/build/translations/bn.js +1 -1
- package/build/translations/bs.js +1 -1
- package/build/translations/ca.js +1 -1
- package/build/translations/cs.js +1 -1
- package/build/translations/da.js +1 -1
- package/build/translations/de-ch.js +1 -1
- package/build/translations/de.js +1 -1
- package/build/translations/el.js +1 -1
- package/build/translations/en-au.js +1 -1
- package/build/translations/es-co.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/et.js +1 -1
- package/build/translations/fa.js +1 -1
- package/build/translations/fi.js +1 -1
- package/build/translations/fr.js +1 -1
- package/build/translations/gl.js +1 -1
- package/build/translations/he.js +1 -1
- package/build/translations/hi.js +1 -1
- package/build/translations/hr.js +1 -1
- package/build/translations/hu.js +1 -1
- package/build/translations/id.js +1 -1
- package/build/translations/it.js +1 -1
- package/build/translations/ja.js +1 -1
- package/build/translations/jv.js +1 -1
- package/build/translations/ko.js +1 -1
- package/build/translations/lt.js +1 -1
- package/build/translations/lv.js +1 -1
- package/build/translations/ms.js +1 -1
- package/build/translations/nl.js +1 -1
- package/build/translations/no.js +1 -1
- package/build/translations/pl.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/build/translations/pt.js +1 -1
- package/build/translations/ro.js +1 -1
- package/build/translations/ru.js +1 -1
- package/build/translations/sk.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/build/translations/sv.js +1 -1
- package/build/translations/th.js +1 -1
- package/build/translations/tk.js +1 -1
- package/build/translations/tr.js +1 -1
- package/build/translations/ug.js +1 -1
- package/build/translations/uk.js +1 -1
- package/build/translations/ur.js +1 -1
- package/build/translations/uz.js +1 -0
- package/build/translations/vi.js +1 -1
- package/build/translations/zh-cn.js +1 -1
- package/build/translations/zh.js +1 -1
- package/ckeditor5-metadata.json +1 -1
- package/lang/contexts.json +4 -1
- package/lang/translations/af.po +60 -16
- package/lang/translations/ar.po +60 -16
- package/lang/translations/bg.po +60 -16
- package/lang/translations/bn.po +60 -16
- package/lang/translations/bs.po +60 -16
- package/lang/translations/ca.po +60 -16
- package/lang/translations/cs.po +60 -16
- package/lang/translations/da.po +60 -16
- package/lang/translations/de-ch.po +60 -16
- package/lang/translations/de.po +60 -16
- package/lang/translations/el.po +60 -16
- package/lang/translations/en-au.po +60 -16
- package/lang/translations/en.po +60 -16
- package/lang/translations/es-co.po +60 -16
- package/lang/translations/es.po +60 -16
- package/lang/translations/et.po +60 -16
- package/lang/translations/fa.po +60 -16
- package/lang/translations/fi.po +60 -16
- package/lang/translations/fr.po +60 -16
- package/lang/translations/gl.po +95 -51
- package/lang/translations/he.po +60 -16
- package/lang/translations/hi.po +60 -16
- package/lang/translations/hr.po +93 -49
- package/lang/translations/hu.po +60 -16
- package/lang/translations/id.po +60 -16
- package/lang/translations/it.po +60 -16
- package/lang/translations/ja.po +60 -16
- package/lang/translations/jv.po +60 -16
- package/lang/translations/ko.po +60 -16
- package/lang/translations/lt.po +60 -16
- package/lang/translations/lv.po +60 -16
- package/lang/translations/ms.po +60 -16
- package/lang/translations/nl.po +60 -16
- package/lang/translations/no.po +60 -16
- package/lang/translations/pl.po +60 -16
- package/lang/translations/pt-br.po +60 -16
- package/lang/translations/pt.po +60 -16
- package/lang/translations/ro.po +60 -16
- package/lang/translations/ru.po +60 -16
- package/lang/translations/sk.po +60 -16
- package/lang/translations/sr-latn.po +95 -51
- package/lang/translations/sr.po +60 -16
- package/lang/translations/sv.po +60 -16
- package/lang/translations/th.po +60 -16
- package/lang/translations/tk.po +60 -16
- package/lang/translations/tr.po +60 -16
- package/lang/translations/ug.po +96 -52
- package/lang/translations/uk.po +60 -16
- package/lang/translations/ur.po +60 -16
- package/lang/translations/uz.po +226 -0
- package/lang/translations/vi.po +60 -16
- package/lang/translations/zh-cn.po +60 -16
- package/lang/translations/zh.po +60 -16
- package/package.json +4 -3
- package/src/adapters/aiadapter.d.ts +48 -0
- package/src/adapters/aiadapter.js +23 -0
- package/src/adapters/aitextadapter.d.ts +146 -0
- package/src/adapters/aitextadapter.js +23 -0
- package/src/adapters/awstextadapter.d.ts +178 -0
- package/src/adapters/awstextadapter.js +23 -0
- package/src/adapters/openaitextadapter.d.ts +181 -0
- package/src/adapters/openaitextadapter.js +23 -0
- package/src/aiassistant.d.ts +386 -419
- package/src/aiassistant.js +1 -1
- package/src/aiassistantediting.d.ts +45 -45
- package/src/aiassistantediting.js +1 -1
- package/src/aiassistantui.d.ts +52 -46
- package/src/aiassistantui.js +1 -1
- package/src/aiconfig.d.ts +69 -0
- package/src/aiconfig.js +23 -0
- package/src/augmentation.d.ts +27 -26
- package/src/index.d.ts +13 -9
- package/src/index.js +1 -1
- package/src/ui/aiassistantcontroller.d.ts +109 -59
- package/src/ui/aiassistantcontroller.js +1 -1
- package/src/ui/dropdown/aicommandslistview.d.ts +22 -22
- package/src/ui/dropdown/aicommandslistview.js +1 -1
- package/src/ui/dropdown/buttonlabelwithhighlightview.d.ts +29 -29
- package/src/ui/dropdown/buttonlabelwithhighlightview.js +1 -1
- package/src/ui/dropdown/labelwithhighlightview.d.ts +25 -0
- package/src/ui/dropdown/labelwithhighlightview.js +23 -0
- package/src/ui/form/aiformcontentarea.d.ts +48 -48
- package/src/ui/form/aiformcontentarea.js +1 -1
- package/src/ui/form/aiformerrorview.d.ts +26 -26
- package/src/ui/form/aiformerrorview.js +1 -1
- package/src/ui/form/aiformpromptview.d.ts +46 -46
- package/src/ui/form/aiformpromptview.js +1 -1
- package/src/ui/form/aiformtoolbarview.d.ts +54 -41
- package/src/ui/form/aiformtoolbarview.js +1 -1
- package/src/ui/form/aiformview.d.ts +142 -131
- package/src/ui/form/aiformview.js +1 -1
- package/src/ui/form/aihistorylistitemview.d.ts +18 -18
- package/src/ui/form/aihistorylistitemview.js +1 -1
- package/src/ui/form/aihistorylistview.d.ts +35 -35
- package/src/ui/form/aihistorylistview.js +1 -1
- package/src/ui/form/prompthistory.d.ts +20 -20
- package/src/ui/form/prompthistory.js +1 -1
- package/src/ui/showaiassistantcommand.d.ts +29 -26
- package/src/ui/showaiassistantcommand.js +1 -1
- package/src/utils/common-translations.d.ts +9 -9
- package/src/utils/common-translations.js +1 -1
- package/theme/ai-form.css +58 -11
- package/theme/ai.css +20 -15
- package/src/aiconnector.d.ts +0 -44
- package/src/aiconnector.js +0 -23
package/src/aiassistant.d.ts
CHANGED
|
@@ -1,419 +1,386 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module ai/aiassistant
|
|
7
|
-
* @publicApi
|
|
8
|
-
*/
|
|
9
|
-
import { type Locale } from 'ckeditor5/src/utils';
|
|
10
|
-
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
|
11
|
-
import AIAssistantUI from './aiassistantui';
|
|
12
|
-
import AIAssistantEditing from './aiassistantediting';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
export default class AIAssistant extends Plugin {
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
static get requires(): readonly [typeof AIAssistantUI, typeof AIAssistantEditing
|
|
26
|
-
/**
|
|
27
|
-
* @inheritDoc
|
|
28
|
-
*/
|
|
29
|
-
static get pluginName(): "AIAssistant";
|
|
30
|
-
/**
|
|
31
|
-
* @inheritDoc
|
|
32
|
-
*/
|
|
33
|
-
constructor(editor: Editor);
|
|
34
|
-
/**
|
|
35
|
-
* @inheritDoc
|
|
36
|
-
*/
|
|
37
|
-
init(): void;
|
|
38
|
-
/**
|
|
39
|
-
* @inheritDoc
|
|
40
|
-
*/
|
|
41
|
-
destroy(): void;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* }
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* }
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*/
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
*
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
*
|
|
353
|
-
* }
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
* The
|
|
384
|
-
*/
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
* The array of command definitions that belong to the group.
|
|
388
|
-
*/
|
|
389
|
-
commands: Array<CommandDefinition>;
|
|
390
|
-
};
|
|
391
|
-
export type CommandDefinition = {
|
|
392
|
-
/**
|
|
393
|
-
* The unique identifier of the command. It can be referenced while removing commands. See
|
|
394
|
-
* {@link module:ai/aiassistant~AIAssistantConfig#removeCommands} to learn more.
|
|
395
|
-
*/
|
|
396
|
-
id: string;
|
|
397
|
-
/**
|
|
398
|
-
* The human-readable label of the command.
|
|
399
|
-
*/
|
|
400
|
-
label: string;
|
|
401
|
-
/**
|
|
402
|
-
* The instruction that will be passed to the AI model.
|
|
403
|
-
*
|
|
404
|
-
* It is wrapped in a "full prompt template" for better results.
|
|
405
|
-
*/
|
|
406
|
-
prompt: string;
|
|
407
|
-
};
|
|
408
|
-
/**
|
|
409
|
-
* OpenAI request parameters that will influence how the response is generated.
|
|
410
|
-
*
|
|
411
|
-
* See OpenAI API reference to learn more.
|
|
412
|
-
*/
|
|
413
|
-
export type RequestParameters = {
|
|
414
|
-
model?: string;
|
|
415
|
-
max_tokens?: number;
|
|
416
|
-
temperature?: number;
|
|
417
|
-
top_p?: number;
|
|
418
|
-
user?: string;
|
|
419
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ai/aiassistant
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { type Locale } from 'ckeditor5/src/utils';
|
|
10
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
|
11
|
+
import AIAssistantUI from './aiassistantui';
|
|
12
|
+
import AIAssistantEditing from './aiassistantediting';
|
|
13
|
+
/**
|
|
14
|
+
* AI assistant plugin that allows you to use external AI models to generate content or improve existing content.
|
|
15
|
+
*
|
|
16
|
+
* The feature uses following {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `actionId`} values:
|
|
17
|
+
*
|
|
18
|
+
* * `aiAssistant:command:<commandId>` for the predefined commands, where `<commandId>` is the ID of the predefined command,
|
|
19
|
+
* * `aiAssistant:custom` for custom queries provided by the user.
|
|
20
|
+
*/
|
|
21
|
+
export default class AIAssistant extends Plugin {
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get requires(): readonly [typeof AIAssistantUI, typeof AIAssistantEditing];
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
static get pluginName(): "AIAssistant";
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
constructor(editor: Editor);
|
|
34
|
+
/**
|
|
35
|
+
* @inheritDoc
|
|
36
|
+
*/
|
|
37
|
+
init(): void;
|
|
38
|
+
/**
|
|
39
|
+
* @inheritDoc
|
|
40
|
+
*/
|
|
41
|
+
destroy(): void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A function that returns the list of the default AI commands definitions in the given localization context.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getDefaultCommands(locale: Locale): Array<GroupDefinition>;
|
|
47
|
+
/**
|
|
48
|
+
* The configuration of the AI Assistant feature.
|
|
49
|
+
*
|
|
50
|
+
* The properties defined in this config are set in the `config.ai.aiAssistant` namespace.
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* ClassicEditor
|
|
54
|
+
* .create( editorElement, {
|
|
55
|
+
* ai: {
|
|
56
|
+
* aiAssistant: {
|
|
57
|
+
* // AI Assistant configuration.
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* } )
|
|
61
|
+
* .then( ... )
|
|
62
|
+
* .catch( ... );
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* See {@link module:ai/aiconfig~AIConfig the full AI configuration}.
|
|
66
|
+
*
|
|
67
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
68
|
+
*/
|
|
69
|
+
export interface AIAssistantConfig {
|
|
70
|
+
/**
|
|
71
|
+
* A list of all AI commands groups definitions to be displayed in the `'aiCommands'` UI dropdown.
|
|
72
|
+
*
|
|
73
|
+
* Setting this property will overwrite the default list of predefined commands.
|
|
74
|
+
*
|
|
75
|
+
* The default configuration is as follows. It can be obtained through {@link ~getDefaultCommands}:
|
|
76
|
+
*
|
|
77
|
+
* ```json
|
|
78
|
+
* [ {
|
|
79
|
+
* groupId: 'editOrReview',
|
|
80
|
+
* groupLabel: 'Edit or review',
|
|
81
|
+
* commands: [
|
|
82
|
+
* {
|
|
83
|
+
* id: 'improveWriting',
|
|
84
|
+
* label: 'Improve writing',
|
|
85
|
+
* prompt: 'Fix spelling mistakes, use proper grammar and apply good writing practices. Do not lose the original meaning.'
|
|
86
|
+
* },
|
|
87
|
+
* {
|
|
88
|
+
* id: 'makeShorter',
|
|
89
|
+
* label: 'Make shorter',
|
|
90
|
+
* prompt: 'Remove any repetitive, redundant, or non-essential writing in this content ' +
|
|
91
|
+
* 'without changing the meaning or losing any key information.'
|
|
92
|
+
* },
|
|
93
|
+
* {
|
|
94
|
+
* id: 'makeLonger',
|
|
95
|
+
* label: 'Make longer',
|
|
96
|
+
* prompt: 'Improve this content by using descriptive language and inserting more information and more detailed explanations.'
|
|
97
|
+
* },
|
|
98
|
+
* {
|
|
99
|
+
* id: 'simplifyLanguage',
|
|
100
|
+
* label: 'Simplify language',
|
|
101
|
+
* prompt: 'Simplify the writing style of this content ' +
|
|
102
|
+
* 'and reduce the complexity, so that the content is easy to understand.'
|
|
103
|
+
* }
|
|
104
|
+
* ]
|
|
105
|
+
* },
|
|
106
|
+
* {
|
|
107
|
+
* groupId: 'generate',
|
|
108
|
+
* groupLabel: 'Generate from selection',
|
|
109
|
+
* commands: [
|
|
110
|
+
* {
|
|
111
|
+
* id: 'summarize',
|
|
112
|
+
* label: 'Summarize',
|
|
113
|
+
* prompt: 'Summarize this content into one paragraph of text. Include only the key ideas and conclusions. Keep it short. '
|
|
114
|
+
* },
|
|
115
|
+
* {
|
|
116
|
+
* id: 'continue',
|
|
117
|
+
* label: 'Continue',
|
|
118
|
+
* prompt: 'Start with the provided content and write at the end of it continuing this topic. Keep the added part short.'
|
|
119
|
+
* }
|
|
120
|
+
* ]
|
|
121
|
+
* },
|
|
122
|
+
* {
|
|
123
|
+
* groupId: 'changeTone',
|
|
124
|
+
* groupLabel: 'Change tone',
|
|
125
|
+
* commands: [
|
|
126
|
+
* {
|
|
127
|
+
* id: 'professional',
|
|
128
|
+
* label: 'Professional',
|
|
129
|
+
* prompt: 'Improve using polished, formal, and respectful language ' +
|
|
130
|
+
* 'to convey professional expertise and competence.'
|
|
131
|
+
* },
|
|
132
|
+
* {
|
|
133
|
+
* id: 'casual',
|
|
134
|
+
* label: 'Casual',
|
|
135
|
+
* prompt: 'Improve using casual, informal language to convey a casual conversation with a real person.'
|
|
136
|
+
* },
|
|
137
|
+
* {
|
|
138
|
+
* id: 'direct',
|
|
139
|
+
* label: 'Direct',
|
|
140
|
+
* prompt: 'Improve using direct language using only the essential information.'
|
|
141
|
+
* },
|
|
142
|
+
* {
|
|
143
|
+
* id: 'confident',
|
|
144
|
+
* label: 'Confident',
|
|
145
|
+
* prompt: 'Improve using compelling, optimistic language to convey confidence in the writing.'
|
|
146
|
+
* },
|
|
147
|
+
* {
|
|
148
|
+
* id: 'friendly',
|
|
149
|
+
* label: 'Friendly',
|
|
150
|
+
* prompt: 'Improve using friendly, comforting language, to convey understanding and empathy.'
|
|
151
|
+
* }
|
|
152
|
+
* ]
|
|
153
|
+
* },
|
|
154
|
+
* {
|
|
155
|
+
* groupId: 'changeStyle',
|
|
156
|
+
* groupLabel: 'Change style',
|
|
157
|
+
* commands: [
|
|
158
|
+
* {
|
|
159
|
+
* id: 'business',
|
|
160
|
+
* label: 'Business',
|
|
161
|
+
* prompt: 'Rewrite this content as a business professional with formal language.'
|
|
162
|
+
* },
|
|
163
|
+
* {
|
|
164
|
+
* id: 'legal',
|
|
165
|
+
* label: 'Legal',
|
|
166
|
+
* prompt: 'Rewrite this content as a legal professional using valid legal terminology.'
|
|
167
|
+
* },
|
|
168
|
+
* {
|
|
169
|
+
* id: 'journalism',
|
|
170
|
+
* label: 'Journalism',
|
|
171
|
+
* prompt: 'Rewrite this content as a journalist using engaging language to convey the importance of the information.'
|
|
172
|
+
* },
|
|
173
|
+
* {
|
|
174
|
+
* id: 'poetic',
|
|
175
|
+
* label: 'Poetic',
|
|
176
|
+
* prompt: 'Rewrite this content as a poem using poetic techniques without losing the original meaning.'
|
|
177
|
+
* }
|
|
178
|
+
* ]
|
|
179
|
+
* },
|
|
180
|
+
* {
|
|
181
|
+
* groupId: 'translate',
|
|
182
|
+
* groupLabel: 'Translate',
|
|
183
|
+
* commands: [
|
|
184
|
+
* {
|
|
185
|
+
* id: 'translateEnglish',
|
|
186
|
+
* label: 'Translate to English',
|
|
187
|
+
* prompt: 'Translate the content to English language.'
|
|
188
|
+
* },
|
|
189
|
+
* {
|
|
190
|
+
* id: 'translateSpanish',
|
|
191
|
+
* label: 'Translate to Spanish',
|
|
192
|
+
* prompt: 'Translate the content to Spanish language.'
|
|
193
|
+
* },
|
|
194
|
+
* {
|
|
195
|
+
* id: 'translatePortuguese',
|
|
196
|
+
* label: 'Translate to Portuguese',
|
|
197
|
+
* prompt: 'Translate the content to Portuguese language.'
|
|
198
|
+
* },
|
|
199
|
+
* {
|
|
200
|
+
* id: 'translateGerman',
|
|
201
|
+
* label: 'Translate to German',
|
|
202
|
+
* prompt: 'Translate the content to German language.'
|
|
203
|
+
* },
|
|
204
|
+
* {
|
|
205
|
+
* id: 'translateFrench',
|
|
206
|
+
* label: 'Translate to French',
|
|
207
|
+
* prompt: 'Translate the content to French language.'
|
|
208
|
+
* },
|
|
209
|
+
* {
|
|
210
|
+
* id: 'translateChinese',
|
|
211
|
+
* label: 'Translate to Simplified Chinese',
|
|
212
|
+
* prompt: 'Translate the content to Simplified Chinese language.'
|
|
213
|
+
* },
|
|
214
|
+
* {
|
|
215
|
+
* id: 'translateHindi',
|
|
216
|
+
* label: 'Translate to Hindi',
|
|
217
|
+
* prompt: 'Translate the content to Hindi language.'
|
|
218
|
+
* },
|
|
219
|
+
* {
|
|
220
|
+
* id: 'translateArabic',
|
|
221
|
+
* label: 'Translate to Arabic',
|
|
222
|
+
* prompt: 'Translate the content to Arabic language.'
|
|
223
|
+
* }
|
|
224
|
+
* ]
|
|
225
|
+
* } ]
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
commands?: Array<GroupDefinition>;
|
|
229
|
+
/**
|
|
230
|
+
* A list of additional AI commands groups definitions that will extend
|
|
231
|
+
* {@link module:ai/aiassistant~AIAssistantConfig#commands default commands}.
|
|
232
|
+
*
|
|
233
|
+
* You can define new AI commands groups or add new AI commands to existing groups. If you add AI commands to an existing group,
|
|
234
|
+
* you do not need to specify `groupLabel` property. Use the (optional) `order` property to control the position of new groups
|
|
235
|
+
* and commands.
|
|
236
|
+
*
|
|
237
|
+
* An example configuration:
|
|
238
|
+
*
|
|
239
|
+
* ```json
|
|
240
|
+
* {
|
|
241
|
+
* aiAssistant: {
|
|
242
|
+
* extraCommandGroups: [
|
|
243
|
+
* // Add an AI command to an existing group:
|
|
244
|
+
* {
|
|
245
|
+
* groupId: 'changeTone',
|
|
246
|
+
* commands: [
|
|
247
|
+
* {
|
|
248
|
+
* id: 'sad',
|
|
249
|
+
* label: 'Sad',
|
|
250
|
+
* prompt: 'Rewrite this text to make it sound sad and depressing.',
|
|
251
|
+
* // You can specify the position of this command among existing ones. Commands use zero-based numbering.
|
|
252
|
+
* order: 2
|
|
253
|
+
* }
|
|
254
|
+
* ]
|
|
255
|
+
* },
|
|
256
|
+
* // Create a new AI commands group:
|
|
257
|
+
* {
|
|
258
|
+
* groupId: 'transformations',
|
|
259
|
+
* groupLabel: 'Transformations',
|
|
260
|
+
* // You can specify the position of this group among existing ones. Groups use zero-based numbering.
|
|
261
|
+
* order: 3,
|
|
262
|
+
* commands: [
|
|
263
|
+
* {
|
|
264
|
+
* id: 'addEmojis',
|
|
265
|
+
* label: 'Add emojis',
|
|
266
|
+
* prompt: 'Analyze each sentence of this text. After each sentence add an emoji that summarizes the sentence.'
|
|
267
|
+
* },
|
|
268
|
+
* // ...
|
|
269
|
+
* ]
|
|
270
|
+
* },
|
|
271
|
+
* ],
|
|
272
|
+
* // ...
|
|
273
|
+
* }
|
|
274
|
+
* }
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
extraCommandGroups?: Array<GroupDefinition>;
|
|
278
|
+
/**
|
|
279
|
+
* A list of ids of AI commands to be removed.
|
|
280
|
+
*
|
|
281
|
+
* Learn more about {@link module:ai/aiassistant~CommandDefinition command definition and its id}.
|
|
282
|
+
*
|
|
283
|
+
* An example configuration:
|
|
284
|
+
*
|
|
285
|
+
* ```json
|
|
286
|
+
* {
|
|
287
|
+
* aiAssistant: {
|
|
288
|
+
* removeCommands: [
|
|
289
|
+
* 'improveWriting',
|
|
290
|
+
* // ...
|
|
291
|
+
* ],
|
|
292
|
+
* // ...
|
|
293
|
+
* }
|
|
294
|
+
* }
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
removeCommands?: Array<string>;
|
|
298
|
+
/**
|
|
299
|
+
* An additional CSS class name (or names) added to the AI assistant content area (model response area).
|
|
300
|
+
*
|
|
301
|
+
* Because the content area is usually detached from the flow of the document, this configuration
|
|
302
|
+
* allows for better integration with application's stylesheets and improves the consistency of content
|
|
303
|
+
* styles.
|
|
304
|
+
*/
|
|
305
|
+
contentAreaCssClass?: string;
|
|
306
|
+
/**
|
|
307
|
+
* The AI assistant feature will be disabled if the document selection includes any of these elements.
|
|
308
|
+
*
|
|
309
|
+
* Use this property if AI assistant does not work properly with your custom features.
|
|
310
|
+
*
|
|
311
|
+
* Currently, by default, AI assistant is disabled for following model elements:
|
|
312
|
+
*
|
|
313
|
+
* * Media embed (`'media'`) -- does not display in response area,
|
|
314
|
+
* * HTML embed (`'rawHtml'`) -- sometimes does not display in response area, security uncertainty,
|
|
315
|
+
* * Table of contents (`'tableOfContents'`) -- does not display properly in response area, long processing time.
|
|
316
|
+
*
|
|
317
|
+
* You can set this list to include more model elements or clear it to enable the above features.
|
|
318
|
+
*
|
|
319
|
+
* Note, that all or some of these features may become enabled in the future.
|
|
320
|
+
*
|
|
321
|
+
* @default [ 'media', 'rawHtml', 'tableOfContents' ]
|
|
322
|
+
*/
|
|
323
|
+
disabledElements?: Array<string>;
|
|
324
|
+
}
|
|
325
|
+
export type GroupDefinition = {
|
|
326
|
+
/**
|
|
327
|
+
* The unique identifier of the group. It can be referenced while extending existing groups
|
|
328
|
+
* using {@link module:ai/aiassistant~AIAssistantConfig#extraCommandGroups}.
|
|
329
|
+
*/
|
|
330
|
+
groupId: string;
|
|
331
|
+
/**
|
|
332
|
+
* The human-readable label of the group.
|
|
333
|
+
*/
|
|
334
|
+
groupLabel?: string;
|
|
335
|
+
/**
|
|
336
|
+
* The array of command definitions that belong to the group.
|
|
337
|
+
*/
|
|
338
|
+
commands: Array<CommandDefinition>;
|
|
339
|
+
/**
|
|
340
|
+
* The order of the group on the list. The lower the number, the higher the group is displayed on the list.
|
|
341
|
+
* If not specified, the position of this group will be determined by the order of
|
|
342
|
+
* {@link module:ai/aiassistant~AIAssistantConfig#commands configuration}.
|
|
343
|
+
*
|
|
344
|
+
* If a new group is added without `order` property, it will be added at the end.
|
|
345
|
+
*
|
|
346
|
+
* The order uses zero-based numbering (the first group's order is `0`).
|
|
347
|
+
*/
|
|
348
|
+
order?: number;
|
|
349
|
+
};
|
|
350
|
+
export type CommandDefinition = {
|
|
351
|
+
/**
|
|
352
|
+
* The unique identifier of the command. It can be referenced while removing commands. See
|
|
353
|
+
* {@link module:ai/aiassistant~AIAssistantConfig#removeCommands} to learn more.
|
|
354
|
+
*/
|
|
355
|
+
id: string;
|
|
356
|
+
/**
|
|
357
|
+
* The human-readable label of the command.
|
|
358
|
+
*/
|
|
359
|
+
label: string;
|
|
360
|
+
/**
|
|
361
|
+
* The instruction that will be passed to the AI model.
|
|
362
|
+
*
|
|
363
|
+
* It is wrapped in a "full prompt template" for better results.
|
|
364
|
+
*/
|
|
365
|
+
prompt: string;
|
|
366
|
+
/**
|
|
367
|
+
* By default, all commands require a selection for the assistant to work on. If the selection is collapsed,
|
|
368
|
+
* it automatically expands to the nearest block boundaries to provide the AI context.
|
|
369
|
+
*
|
|
370
|
+
* Setting this to `false` allows the command to work on a collapsed selection and prevent selection expansion.
|
|
371
|
+
* This is helpful, for instance, for commands that generate content from scratch.
|
|
372
|
+
*
|
|
373
|
+
* **Note**: If not specified, the default is `true`.
|
|
374
|
+
*/
|
|
375
|
+
requiresContent?: boolean;
|
|
376
|
+
/**
|
|
377
|
+
* The order of the command on the list. The lower the number, the higher the command is displayed on the list.
|
|
378
|
+
* If not specified, the position of this command will be determined by the order of
|
|
379
|
+
* {@link module:ai/aiassistant~AIAssistantConfig#commands configuration}.
|
|
380
|
+
*
|
|
381
|
+
* If a new command is added without `order` property, it will be added at the end of the group.
|
|
382
|
+
*
|
|
383
|
+
* The order uses zero-based numbering (the first command's order is `0`).
|
|
384
|
+
*/
|
|
385
|
+
order?: number;
|
|
386
|
+
};
|