@ckeditor/ckeditor5-ai 0.0.1 → 40.1.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/CHANGELOG.md +4 -0
- package/LICENSE.md +7 -7
- package/README.md +32 -3
- package/build/ai.js +5 -0
- package/build/translations/af.js +1 -0
- package/build/translations/ar.js +1 -0
- package/build/translations/bg.js +1 -0
- package/build/translations/bn.js +1 -0
- package/build/translations/bs.js +1 -0
- package/build/translations/ca.js +1 -0
- package/build/translations/cs.js +1 -0
- package/build/translations/da.js +1 -0
- package/build/translations/de-ch.js +1 -0
- package/build/translations/de.js +1 -0
- package/build/translations/el.js +1 -0
- package/build/translations/en-au.js +1 -0
- package/build/translations/es-co.js +1 -0
- package/build/translations/es.js +1 -0
- package/build/translations/et.js +1 -0
- package/build/translations/fa.js +1 -0
- package/build/translations/fi.js +1 -0
- package/build/translations/fr.js +1 -0
- package/build/translations/gl.js +1 -0
- package/build/translations/he.js +1 -0
- package/build/translations/hi.js +1 -0
- package/build/translations/hr.js +1 -0
- package/build/translations/hu.js +1 -0
- package/build/translations/id.js +1 -0
- package/build/translations/it.js +1 -0
- package/build/translations/ja.js +1 -0
- package/build/translations/jv.js +1 -0
- package/build/translations/ko.js +1 -0
- package/build/translations/lt.js +1 -0
- package/build/translations/lv.js +1 -0
- package/build/translations/ms.js +1 -0
- package/build/translations/nl.js +1 -0
- package/build/translations/no.js +1 -0
- package/build/translations/pl.js +1 -0
- package/build/translations/pt-br.js +1 -0
- package/build/translations/pt.js +1 -0
- package/build/translations/ro.js +1 -0
- package/build/translations/ru.js +1 -0
- package/build/translations/sk.js +1 -0
- package/build/translations/sr-latn.js +1 -0
- package/build/translations/sr.js +1 -0
- package/build/translations/sv.js +1 -0
- package/build/translations/th.js +1 -0
- package/build/translations/tk.js +1 -0
- package/build/translations/tr.js +1 -0
- package/build/translations/ug.js +1 -0
- package/build/translations/uk.js +1 -0
- package/build/translations/ur.js +1 -0
- package/build/translations/uz.js +1 -0
- package/build/translations/vi.js +1 -0
- package/build/translations/zh-cn.js +1 -0
- package/build/translations/zh.js +1 -0
- package/ckeditor5-metadata.json +23 -0
- package/lang/contexts.json +54 -0
- package/lang/translations/af.po +226 -0
- package/lang/translations/ar.po +226 -0
- package/lang/translations/bg.po +226 -0
- package/lang/translations/bn.po +226 -0
- package/lang/translations/bs.po +226 -0
- package/lang/translations/ca.po +226 -0
- package/lang/translations/cs.po +226 -0
- package/lang/translations/da.po +226 -0
- package/lang/translations/de-ch.po +226 -0
- package/lang/translations/de.po +226 -0
- package/lang/translations/el.po +226 -0
- package/lang/translations/en-au.po +226 -0
- package/lang/translations/en.po +226 -0
- package/lang/translations/es-co.po +226 -0
- package/lang/translations/es.po +226 -0
- package/lang/translations/et.po +226 -0
- package/lang/translations/fa.po +226 -0
- package/lang/translations/fi.po +226 -0
- package/lang/translations/fr.po +226 -0
- package/lang/translations/gl.po +226 -0
- package/lang/translations/he.po +226 -0
- package/lang/translations/hi.po +226 -0
- package/lang/translations/hr.po +226 -0
- package/lang/translations/hu.po +226 -0
- package/lang/translations/id.po +226 -0
- package/lang/translations/it.po +226 -0
- package/lang/translations/ja.po +226 -0
- package/lang/translations/jv.po +226 -0
- package/lang/translations/ko.po +226 -0
- package/lang/translations/lt.po +226 -0
- package/lang/translations/lv.po +226 -0
- package/lang/translations/ms.po +226 -0
- package/lang/translations/nl.po +226 -0
- package/lang/translations/no.po +226 -0
- package/lang/translations/pl.po +226 -0
- package/lang/translations/pt-br.po +226 -0
- package/lang/translations/pt.po +226 -0
- package/lang/translations/ro.po +226 -0
- package/lang/translations/ru.po +226 -0
- package/lang/translations/sk.po +226 -0
- package/lang/translations/sr-latn.po +226 -0
- package/lang/translations/sr.po +226 -0
- package/lang/translations/sv.po +226 -0
- package/lang/translations/th.po +226 -0
- package/lang/translations/tk.po +226 -0
- package/lang/translations/tr.po +226 -0
- package/lang/translations/ug.po +226 -0
- package/lang/translations/uk.po +226 -0
- package/lang/translations/ur.po +226 -0
- package/lang/translations/uz.po +226 -0
- package/lang/translations/vi.po +226 -0
- package/lang/translations/zh-cn.po +226 -0
- package/lang/translations/zh.po +226 -0
- package/package.json +38 -7
- package/src/aiassistant.d.ts +458 -0
- package/src/aiassistant.js +23 -0
- package/src/aiassistantediting.d.ts +45 -0
- package/src/aiassistantediting.js +23 -0
- package/src/aiassistantui.d.ts +44 -0
- package/src/aiassistantui.js +23 -0
- package/src/aiconnector.d.ts +45 -0
- package/src/aiconnector.js +23 -0
- package/src/augmentation.d.ts +26 -0
- package/src/augmentation.js +23 -0
- package/src/index.d.ts +9 -0
- package/src/index.js +23 -0
- package/src/ui/aiassistantcontroller.d.ts +96 -0
- package/src/ui/aiassistantcontroller.js +23 -0
- package/src/ui/dropdown/aicommandslistview.d.ts +22 -0
- package/src/ui/dropdown/aicommandslistview.js +23 -0
- package/src/ui/dropdown/buttonlabelwithhighlightview.d.ts +29 -0
- package/src/ui/dropdown/buttonlabelwithhighlightview.js +23 -0
- 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 -0
- package/src/ui/form/aiformcontentarea.js +23 -0
- package/src/ui/form/aiformerrorview.d.ts +26 -0
- package/src/ui/form/aiformerrorview.js +23 -0
- package/src/ui/form/aiformpromptview.d.ts +46 -0
- package/src/ui/form/aiformpromptview.js +23 -0
- package/src/ui/form/aiformtoolbarview.d.ts +54 -0
- package/src/ui/form/aiformtoolbarview.js +23 -0
- package/src/ui/form/aiformview.d.ts +142 -0
- package/src/ui/form/aiformview.js +23 -0
- package/src/ui/form/aihistorylistitemview.d.ts +18 -0
- package/src/ui/form/aihistorylistitemview.js +23 -0
- package/src/ui/form/aihistorylistview.d.ts +35 -0
- package/src/ui/form/aihistorylistview.js +23 -0
- package/src/ui/form/prompthistory.d.ts +20 -0
- package/src/ui/form/prompthistory.js +23 -0
- package/src/ui/showaiassistantcommand.d.ts +26 -0
- package/src/ui/showaiassistantcommand.js +23 -0
- package/src/utils/common-translations.d.ts +9 -0
- package/src/utils/common-translations.js +23 -0
- package/theme/ai-dropdown.css +37 -0
- package/theme/ai-form.css +250 -0
- package/theme/ai.css +103 -0
- package/theme/icons/copy.svg +1 -0
- package/theme/icons/error.svg +1 -0
- package/theme/icons/magic-wand.svg +1 -0
- package/theme/icons/robot-pencil.svg +1 -0
- package/theme/icons/submit.svg +1 -0
|
@@ -0,0 +1,458 @@
|
|
|
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
|
+
import AIConnector from './aiconnector';
|
|
14
|
+
/**
|
|
15
|
+
* A function that returns the list of default AI commands definitions in the given localization context.
|
|
16
|
+
*/
|
|
17
|
+
export declare const getDefaultCommands: (locale: Locale) => Array<GroupDefinition>;
|
|
18
|
+
/**
|
|
19
|
+
* AI assistant plugin that allows you to use external AI models to generate content or improve existing content.
|
|
20
|
+
*/
|
|
21
|
+
export default class AIAssistant extends Plugin {
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get requires(): readonly [typeof AIAssistantUI, typeof AIAssistantEditing, typeof AIConnector];
|
|
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
|
+
* The configuration of the AI assistant feature.
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* ClassicEditor
|
|
48
|
+
* .create( editorElement, {
|
|
49
|
+
* aiAssistant: ... // AI assistant options.
|
|
50
|
+
* } )
|
|
51
|
+
* .then( ... )
|
|
52
|
+
* .catch( ... );
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
56
|
+
*/
|
|
57
|
+
export interface AIAssistantConfig {
|
|
58
|
+
/**
|
|
59
|
+
* The URL to which the API request will be sent.
|
|
60
|
+
*
|
|
61
|
+
* Defaults to `'https://api.openai.com/v1/chat/completions'`.
|
|
62
|
+
*/
|
|
63
|
+
apiUrl?: string;
|
|
64
|
+
/**
|
|
65
|
+
* A key used to authorize the request to the AI service.
|
|
66
|
+
*
|
|
67
|
+
* If you are connecting directly to the OpenAI API, use your OpenAI API key as `authKey`.
|
|
68
|
+
*
|
|
69
|
+
* **Important: use your API key ONLY in a development environment or for testing purposes!**
|
|
70
|
+
* In the production environment, {@glink features/ai-assistant#using-proxy-endpoint pass your request through a proxy}.
|
|
71
|
+
*
|
|
72
|
+
* If you are using a proxy service to send requests to the AI service, `authKey` can be used to implement authorization for your
|
|
73
|
+
* requests.
|
|
74
|
+
*
|
|
75
|
+
* If the key is provided, it is added to the `Authorization` header of the request call, using the bearer scheme:
|
|
76
|
+
*
|
|
77
|
+
* ```
|
|
78
|
+
* Authorization: Bearer <authKey>
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* If the provided value is a `string`, it is simply used as provided.
|
|
82
|
+
*
|
|
83
|
+
* If the provided value is a function, it should be a function that returns a `Promise` which resolves with the authorization token.
|
|
84
|
+
* This way, you can perform an authorization request to your application and receive the authorization token (and also implement
|
|
85
|
+
* any custom logic that you need). The authorization token is then used to make the actual call to the AI service.
|
|
86
|
+
*
|
|
87
|
+
* ```js
|
|
88
|
+
* {
|
|
89
|
+
* aiAssistant: {
|
|
90
|
+
* authKey: async () => {
|
|
91
|
+
* return await fetch( 'https://example.com/jwt-endpoint' );
|
|
92
|
+
* }
|
|
93
|
+
* // ...
|
|
94
|
+
* }
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* If the authorization request fails, the promise should be rejected. In this case, the feature will display an error notification.
|
|
99
|
+
*/
|
|
100
|
+
authKey?: string | (() => Promise<string>);
|
|
101
|
+
/**
|
|
102
|
+
* A list of all AI commands groups definitions to be displayed in the `'aiCommands'` UI dropdown.
|
|
103
|
+
*
|
|
104
|
+
* Setting this property will overwrite the default list of predefined commands.
|
|
105
|
+
*
|
|
106
|
+
* The default configuration is as follows:
|
|
107
|
+
*
|
|
108
|
+
* ```json
|
|
109
|
+
* {
|
|
110
|
+
* groupId: 'editOrReview',
|
|
111
|
+
* groupLabel: 'Edit or review',
|
|
112
|
+
* commands: [
|
|
113
|
+
* {
|
|
114
|
+
* id: 'improveWriting',
|
|
115
|
+
* label: 'Improve writing',
|
|
116
|
+
* prompt: 'Rewrite this content with no spelling mistakes, proper grammar, ' +
|
|
117
|
+
* 'and with more descriptive language, using best writing practices without losing the original meaning.'
|
|
118
|
+
* },
|
|
119
|
+
* {
|
|
120
|
+
* id: 'makeShorter',
|
|
121
|
+
* label: 'Make shorter',
|
|
122
|
+
* prompt: 'Remove any repetitive, redundant, or non-essential writing in this content ' +
|
|
123
|
+
* 'without changing the meaning or losing any key information.'
|
|
124
|
+
* },
|
|
125
|
+
* {
|
|
126
|
+
* id: 'makeLonger',
|
|
127
|
+
* label: 'Make longer',
|
|
128
|
+
* prompt: 'Expand upon this content with descriptive language and more detailed explanations, ' +
|
|
129
|
+
* 'to make the writing easier to understand and increase the length of the content.'
|
|
130
|
+
* },
|
|
131
|
+
* {
|
|
132
|
+
* id: 'simplifyLanguage',
|
|
133
|
+
* label: 'Simplify language',
|
|
134
|
+
* prompt: 'Rewrite this content with simplified language ' +
|
|
135
|
+
* 'and reduce the complexity of the writing, so that the content is easier to understand.'
|
|
136
|
+
* }
|
|
137
|
+
* ]
|
|
138
|
+
* },
|
|
139
|
+
* {
|
|
140
|
+
* groupId: 'generate',
|
|
141
|
+
* groupLabel: 'Generate from selection',
|
|
142
|
+
* commands: [
|
|
143
|
+
* {
|
|
144
|
+
* id: 'summarize',
|
|
145
|
+
* label: 'Summarize',
|
|
146
|
+
* prompt: 'Provide the key points and concepts in this content in a succinct summary.'
|
|
147
|
+
* },
|
|
148
|
+
* {
|
|
149
|
+
* id: 'continue',
|
|
150
|
+
* label: 'Continue',
|
|
151
|
+
* prompt: 'Continue this text.'
|
|
152
|
+
* }
|
|
153
|
+
* ]
|
|
154
|
+
* },
|
|
155
|
+
* {
|
|
156
|
+
* groupId: 'changeTone',
|
|
157
|
+
* groupLabel: 'Change tone',
|
|
158
|
+
* commands: [
|
|
159
|
+
* {
|
|
160
|
+
* id: 'professional',
|
|
161
|
+
* label: 'Professional',
|
|
162
|
+
* prompt: 'Rewrite this content using polished, formal, and respectful language ' +
|
|
163
|
+
* 'to convey professional expertise and competence.'
|
|
164
|
+
* },
|
|
165
|
+
* {
|
|
166
|
+
* id: 'casual',
|
|
167
|
+
* label: 'Casual',
|
|
168
|
+
* prompt: 'Rewrite this content with casual, informal language to convey a casual conversation with a real person.'
|
|
169
|
+
* },
|
|
170
|
+
* {
|
|
171
|
+
* id: 'direct',
|
|
172
|
+
* label: 'Direct',
|
|
173
|
+
* prompt: 'Rewrite this content with direct language using only the essential information.'
|
|
174
|
+
* },
|
|
175
|
+
* {
|
|
176
|
+
* id: 'confident',
|
|
177
|
+
* label: 'Confident',
|
|
178
|
+
* prompt: 'Rewrite this content using compelling, optimistic language to convey confidence in the writing.'
|
|
179
|
+
* },
|
|
180
|
+
* {
|
|
181
|
+
* id: 'friendly',
|
|
182
|
+
* label: 'Friendly',
|
|
183
|
+
* prompt: 'Rewrite this content using friendly, comforting language, to convey understanding and empathy.'
|
|
184
|
+
* }
|
|
185
|
+
* ]
|
|
186
|
+
* },
|
|
187
|
+
* {
|
|
188
|
+
* groupId: 'changeStyle',
|
|
189
|
+
* groupLabel: 'Change style',
|
|
190
|
+
* commands: [
|
|
191
|
+
* {
|
|
192
|
+
* id: 'business',
|
|
193
|
+
* label: 'Business',
|
|
194
|
+
* prompt: 'Rewrite this content as a business professional with formal language.'
|
|
195
|
+
* },
|
|
196
|
+
* {
|
|
197
|
+
* id: 'legal',
|
|
198
|
+
* label: 'Legal',
|
|
199
|
+
* prompt: 'Rewrite this content as a legal professional using valid legal terminology.'
|
|
200
|
+
* },
|
|
201
|
+
* {
|
|
202
|
+
* id: 'journalism',
|
|
203
|
+
* label: 'Journalism',
|
|
204
|
+
* prompt: 'Rewrite this content as a journalist using engaging language to convey the importance of the information.'
|
|
205
|
+
* },
|
|
206
|
+
* {
|
|
207
|
+
* id: 'poetic',
|
|
208
|
+
* label: 'Poetic',
|
|
209
|
+
* prompt: 'Rewrite this content as a poem using poetic techniques without losing the original meaning.'
|
|
210
|
+
* }
|
|
211
|
+
* ]
|
|
212
|
+
* },
|
|
213
|
+
* {
|
|
214
|
+
* groupId: 'translate',
|
|
215
|
+
* groupLabel: 'Translate',
|
|
216
|
+
* commands: [
|
|
217
|
+
* {
|
|
218
|
+
* id: 'translateEnglish',
|
|
219
|
+
* label: 'Translate to English',
|
|
220
|
+
* prompt: 'Translate to English language.'
|
|
221
|
+
* },
|
|
222
|
+
* {
|
|
223
|
+
* id: 'translateSpanish',
|
|
224
|
+
* label: 'Translate to Spanish',
|
|
225
|
+
* prompt: 'Translate to Spanish language.'
|
|
226
|
+
* },
|
|
227
|
+
* {
|
|
228
|
+
* id: 'translatePortuguese',
|
|
229
|
+
* label: 'Translate to Portuguese',
|
|
230
|
+
* prompt: 'Translate to Portuguese language.'
|
|
231
|
+
* },
|
|
232
|
+
* {
|
|
233
|
+
* id: 'translateGerman',
|
|
234
|
+
* label: 'Translate to German',
|
|
235
|
+
* prompt: 'Translate to German language.'
|
|
236
|
+
* },
|
|
237
|
+
* {
|
|
238
|
+
* id: 'translateFrench',
|
|
239
|
+
* label: 'Translate to French',
|
|
240
|
+
* prompt: 'Translate to French language.'
|
|
241
|
+
* },
|
|
242
|
+
* {
|
|
243
|
+
* id: 'translateChinese',
|
|
244
|
+
* label: 'Translate to Simplified Chinese',
|
|
245
|
+
* prompt: 'Translate to Simplified Chinese language.'
|
|
246
|
+
* },
|
|
247
|
+
* {
|
|
248
|
+
* id: 'translateHindi',
|
|
249
|
+
* label: 'Translate to Hindi',
|
|
250
|
+
* prompt: 'Translate to Hindi language.'
|
|
251
|
+
* },
|
|
252
|
+
* {
|
|
253
|
+
* id: 'translateArabic',
|
|
254
|
+
* label: 'Translate to Arabic',
|
|
255
|
+
* prompt: 'Translate to Arabic language.'
|
|
256
|
+
* }
|
|
257
|
+
* ]
|
|
258
|
+
* }
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
commands?: Array<GroupDefinition>;
|
|
262
|
+
/**
|
|
263
|
+
* A list of additional AI commands groups definitions that will extend
|
|
264
|
+
* {@link module:ai/aiassistant~AIAssistantConfig#commands default commands}.
|
|
265
|
+
*
|
|
266
|
+
* You can define new AI commands groups or add new AI commands to existing groups. If you add AI commands to an existing group,
|
|
267
|
+
* you do not need to specify `groupLabel` property. Use the (optional) `order` property to control the position of new groups
|
|
268
|
+
* and commands.
|
|
269
|
+
*
|
|
270
|
+
* An example configuration:
|
|
271
|
+
*
|
|
272
|
+
* ```json
|
|
273
|
+
* {
|
|
274
|
+
* aiAssistant: {
|
|
275
|
+
* extraCommandGroups: [
|
|
276
|
+
* // Add an AI command to an existing group:
|
|
277
|
+
* {
|
|
278
|
+
* groupId: 'changeTone',
|
|
279
|
+
* commands: [
|
|
280
|
+
* {
|
|
281
|
+
* id: 'sad',
|
|
282
|
+
* label: 'Sad',
|
|
283
|
+
* prompt: 'Rewrite this text to make it sound sad and depressing.',
|
|
284
|
+
* // You can specify the position of this command among existing ones. Commands use zero-based numbering.
|
|
285
|
+
* order: 2
|
|
286
|
+
* }
|
|
287
|
+
* ]
|
|
288
|
+
* },
|
|
289
|
+
* // Create a new AI commands group:
|
|
290
|
+
* {
|
|
291
|
+
* groupId: 'transformations',
|
|
292
|
+
* groupLabel: 'Transformations',
|
|
293
|
+
* // You can specify the position of this group among existing ones. Groups use zero-based numbering.
|
|
294
|
+
* order: 3,
|
|
295
|
+
* commands: [
|
|
296
|
+
* {
|
|
297
|
+
* id: 'addEmojis',
|
|
298
|
+
* label: 'Add emojis',
|
|
299
|
+
* prompt: 'Analyze each sentence of this text. After each sentence add an emoji that summarizes the sentence.'
|
|
300
|
+
* },
|
|
301
|
+
* // ...
|
|
302
|
+
* ]
|
|
303
|
+
* },
|
|
304
|
+
* ],
|
|
305
|
+
* // ...
|
|
306
|
+
* }
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
extraCommandGroups?: Array<GroupDefinition>;
|
|
310
|
+
/**
|
|
311
|
+
* A list of ids of AI commands to be removed.
|
|
312
|
+
*
|
|
313
|
+
* Learn more about {@link module:ai/aiassistant~CommandDefinition command definition and its id}.
|
|
314
|
+
*
|
|
315
|
+
* An example configuration:
|
|
316
|
+
*
|
|
317
|
+
* ```json
|
|
318
|
+
* {
|
|
319
|
+
* aiAssistant: {
|
|
320
|
+
* removeCommands: [
|
|
321
|
+
* 'improveWriting',
|
|
322
|
+
* // ...
|
|
323
|
+
* ],
|
|
324
|
+
* // ...
|
|
325
|
+
* }
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
removeCommands?: Array<string>;
|
|
329
|
+
/**
|
|
330
|
+
* Enables or disables the AI assistant UI theme.
|
|
331
|
+
*
|
|
332
|
+
* * Leaving this property unset will preserve the default theme on AI Assistant UI elements.
|
|
333
|
+
* * Setting this property to **`false`** will remove the default theme from AI assistant UI elements.
|
|
334
|
+
*
|
|
335
|
+
* {@glink features/ai-assistant#ui-customization Learn more about AI assistant UI customization.}
|
|
336
|
+
*
|
|
337
|
+
* @default true
|
|
338
|
+
*/
|
|
339
|
+
useTheme?: boolean;
|
|
340
|
+
/**
|
|
341
|
+
* An additional CSS class name (or names) added to the AI assistant content area (model response area).
|
|
342
|
+
*
|
|
343
|
+
* Because the content area is usually detached from the flow of the document, this configuration
|
|
344
|
+
* allows for better integration with application's stylesheets and improves the consistency of content
|
|
345
|
+
* styles.
|
|
346
|
+
*/
|
|
347
|
+
contentAreaCssClass?: string;
|
|
348
|
+
/**
|
|
349
|
+
* Additional configuration parameters for the AI request. Use it to customize how the AI service generates responses.
|
|
350
|
+
*
|
|
351
|
+
* See [OpenAI API reference](https://platform.openai.com/docs/api-reference/chat/create) to learn more.
|
|
352
|
+
*
|
|
353
|
+
* Defaults to:
|
|
354
|
+
*
|
|
355
|
+
* ```json
|
|
356
|
+
* {
|
|
357
|
+
* model: 'gpt-3.5-turbo',
|
|
358
|
+
* max_tokens: 2000,
|
|
359
|
+
* temperature: 1,
|
|
360
|
+
* top_p: 1
|
|
361
|
+
* }
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
requestParameters?: RequestParameters;
|
|
365
|
+
/**
|
|
366
|
+
* The AI assistant feature will be disabled if the document selection includes any of these elements.
|
|
367
|
+
*
|
|
368
|
+
* Use this property if AI assistant does not work properly with your custom features.
|
|
369
|
+
*
|
|
370
|
+
* Currently, by default, AI assistant is disabled for following model elements:
|
|
371
|
+
*
|
|
372
|
+
* * Media embed (`'media'`) -- does not display in response area,
|
|
373
|
+
* * HTML embed (`'rawHtml'`) -- sometimes does not display in response area, security uncertainty,
|
|
374
|
+
* * Table of contents (`'tableOfContents'`) -- does not display properly in response area, long processing time.
|
|
375
|
+
*
|
|
376
|
+
* You can set this list to include more model elements or clear it to enable the above features.
|
|
377
|
+
*
|
|
378
|
+
* Note, that all or some of these features may become enabled in the future.
|
|
379
|
+
*
|
|
380
|
+
* @default [ 'media', 'rawHtml', 'tableOfContents' ]
|
|
381
|
+
*/
|
|
382
|
+
disabledElements?: Array<string>;
|
|
383
|
+
}
|
|
384
|
+
export type GroupDefinition = {
|
|
385
|
+
/**
|
|
386
|
+
* The unique identifier of the group. It can be referenced while extending existing groups
|
|
387
|
+
* using {@link module:ai/aiassistant~AIAssistantConfig#extraCommandGroups}.
|
|
388
|
+
*/
|
|
389
|
+
groupId: string;
|
|
390
|
+
/**
|
|
391
|
+
* The human-readable label of the group.
|
|
392
|
+
*/
|
|
393
|
+
groupLabel?: string;
|
|
394
|
+
/**
|
|
395
|
+
* The array of command definitions that belong to the group.
|
|
396
|
+
*/
|
|
397
|
+
commands: Array<CommandDefinition>;
|
|
398
|
+
/**
|
|
399
|
+
* The order of the group on the list. The lower the number, the higher the group is displayed on the list.
|
|
400
|
+
* If not specified, the position of this group will be determined by the order of
|
|
401
|
+
* {@link module:ai/aiassistant~AIAssistantConfig#commands configuration}.
|
|
402
|
+
*
|
|
403
|
+
* If a new group is added without `order` property, it will be added at the end.
|
|
404
|
+
*
|
|
405
|
+
* The order uses zero-based numbering (the first group's order is `0`).
|
|
406
|
+
*/
|
|
407
|
+
order?: number;
|
|
408
|
+
};
|
|
409
|
+
export type CommandDefinition = {
|
|
410
|
+
/**
|
|
411
|
+
* The unique identifier of the command. It can be referenced while removing commands. See
|
|
412
|
+
* {@link module:ai/aiassistant~AIAssistantConfig#removeCommands} to learn more.
|
|
413
|
+
*/
|
|
414
|
+
id: string;
|
|
415
|
+
/**
|
|
416
|
+
* The human-readable label of the command.
|
|
417
|
+
*/
|
|
418
|
+
label: string;
|
|
419
|
+
/**
|
|
420
|
+
* The instruction that will be passed to the AI model.
|
|
421
|
+
*
|
|
422
|
+
* It is wrapped in a "full prompt template" for better results.
|
|
423
|
+
*/
|
|
424
|
+
prompt: string;
|
|
425
|
+
/**
|
|
426
|
+
* By default, all commands require a selection for the assistant to work on. If the selection is collapsed,
|
|
427
|
+
* it automatically expands to the nearest block boundaries to provide the AI context.
|
|
428
|
+
*
|
|
429
|
+
* Setting this to `false` allows the command to work on a collapsed selection and prevent selection expansion.
|
|
430
|
+
* This is helpful, for instance, for commands that generate content from scratch.
|
|
431
|
+
*
|
|
432
|
+
* **Note**: If not specified, the default is `true`.
|
|
433
|
+
*/
|
|
434
|
+
requiresContent?: boolean;
|
|
435
|
+
/**
|
|
436
|
+
* The order of the command on the list. The lower the number, the higher the command is displayed on the list.
|
|
437
|
+
* If not specified, the position of this command will be determined by the order of
|
|
438
|
+
* {@link module:ai/aiassistant~AIAssistantConfig#commands configuration}.
|
|
439
|
+
*
|
|
440
|
+
* If a new command is added without `order` property, it will be added at the end of the group.
|
|
441
|
+
*
|
|
442
|
+
* The order uses zero-based numbering (the first command's order is `0`).
|
|
443
|
+
*/
|
|
444
|
+
order?: number;
|
|
445
|
+
};
|
|
446
|
+
/**
|
|
447
|
+
* OpenAI request parameters that will influence how the response is generated.
|
|
448
|
+
*
|
|
449
|
+
* See OpenAI API reference to learn more.
|
|
450
|
+
*/
|
|
451
|
+
export type RequestParameters = {
|
|
452
|
+
model?: string;
|
|
453
|
+
max_tokens?: number;
|
|
454
|
+
temperature?: number;
|
|
455
|
+
top_p?: number;
|
|
456
|
+
user?: string;
|
|
457
|
+
stream?: boolean;
|
|
458
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* +---------------------------------------------------------------------------------+
|
|
8
|
+
* | |
|
|
9
|
+
* | Hello stranger! |
|
|
10
|
+
* | |
|
|
11
|
+
* | |
|
|
12
|
+
* | What you're currently looking at is the source code of a legally protected, |
|
|
13
|
+
* | proprietary software. Any attempts to deobfuscate / disassemble this code |
|
|
14
|
+
* | are forbidden and will result in legal consequences. |
|
|
15
|
+
* | |
|
|
16
|
+
* | |
|
|
17
|
+
* +---------------------------------------------------------------------------------+
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
const _0x2076=['Improve\x20using\x20casual,\x20informal\x20language\x20to\x20convey\x20a\x20casual\x20conversation\x20with\x20a\x20real\x20person.','Change\x20tone','Translate\x20the\x20content\x20to\x20Spanish\x20language.','confident','Improve\x20this\x20content\x20by\x20using\x20descriptive\x20language\x20and\x20inserting\x20more\x20information\x20and\x20more\x20detailed\x20explanations.','translatePortuguese','Journalism','Legal','aiLicenseKeyValid','Simplify\x20language','Start\x20with\x20the\x20provided\x20content\x20and\x20write\x20at\x20the\x20end\x20of\x20it\x20continuing\x20this\x20topic.\x20Keep\x20the\x20added\x20part\x20short.','Fix\x20spelling\x20mistakes,\x20use\x20proper\x20grammar\x20and\x20apply\x20good\x20writing\x20practices.\x20Do\x20not\x20lose\x20the\x20original\x20meaning.','changeTone','poetic','push','aiAssistant.commands','Professional','translateGerman','Generate\x20from\x20selection','improveWriting','translateFrench','_licenseKeyCheckInterval','Summarize\x20this\x20content\x20into\x20one\x20paragraph\x20of\x20text.\x20Include\x20only\x20the\x20key\x20ideas\x20and\x20conclusions.\x20Keep\x20it\x20short.\x20Do\x20not\x20keep\x20original\x20text\x20formatting.','translateChinese','Poetic','German','French','config','Casual','filter','continue','ai-invalid-license-key','Translate\x20the\x20content\x20to\x20German\x20language.','editOrReview','define','Direct','makeShorter','Arabic','aiAssistant.extraCommandGroups','Translate\x20the\x20content\x20to\x20English\x20language.','Rewrite\x20this\x20content\x20as\x20a\x20poem\x20using\x20poetic\x20techniques\x20without\x20losing\x20the\x20original\x20meaning.','Translate\x20the\x20content\x20to\x20French\x20language.','translateSpanish','Spanish','init','Change\x20style','casual','info','Edit\x20or\x20review','makeLonger','Hindi','aiLicenseKeyInvalid','professional','Improve\x20using\x20direct\x20language,\x20using\x20only\x20the\x20essential\x20information.','ai-trial-license-key-reached-limit-changes','aiAssistant.removeCommands','translateEnglish','Translate\x20the\x20content\x20to\x20Portuguese\x20language.','Simplified\x20Chinese','journalism','Rewrite\x20this\x20content\x20as\x20a\x20business\x20professional\x20with\x20formal\x20language.','translateHindi','Improve\x20using\x20friendly,\x20comforting\x20language,\x20to\x20convey\x20understanding\x20and\x20empathy.','translate','locale','destroy','legal','generate','licenseKey','requires','Portuguese','Translate\x20to\x20%0','Improve\x20writing','friendly','simplifyLanguage','Improve\x20using\x20compelling,\x20optimistic\x20language\x20to\x20convey\x20confidence\x20in\x20the\x20writing.','aiLicenseKeyTrial','Summarize','Friendly','get','English','Continue','Rewrite\x20this\x20content\x20as\x20a\x20legal\x20professional\x20using\x20valid\x20legal\x20terminology.','Make\x20longer','commands','includes','Translate','business','summarize','aiLicenseKeyTrialLimit:operations','Simplify\x20the\x20writing\x20style\x20of\x20this\x20content\x20and\x20reduce\x20the\x20complexity,\x20so\x20that\x20the\x20content\x20is\x20easy\x20to\x20understand.','groupId','Translate\x20the\x20content\x20to\x20Arabic\x20language.','translateArabic','Confident','Translate\x20the\x20content\x20to\x20Hindi\x20language.','Business'];(function(_0x282cf1,_0x20760a){const _0x376ca6=function(_0x436f8e){while(--_0x436f8e){_0x282cf1['push'](_0x282cf1['shift']());}};_0x376ca6(++_0x20760a);}(_0x2076,0x10c));const _0x376c=function(_0x282cf1,_0x20760a){_0x282cf1=_0x282cf1-0x0;let _0x376ca6=_0x2076[_0x282cf1];return _0x376ca6;};import{CKEditorError as _0x2a14ef}from'ckeditor5/src/utils';import{Plugin as _0x425378}from'ckeditor5/src/core';import _0x893417 from'./aiassistantui';import _0x2657d7 from'./aiassistantediting';import _0x14f7e0 from'./aiconnector';import{getTranslation as _0x45c5cd}from'./utils/common-translations';export const getDefaultCommands=_0x14bf34=>[{'groupId':_0x376c('0x38'),'groupLabel':_0x45c5cd(_0x14bf34,_0x376c('0x47')),'commands':[{'id':_0x376c('0x2a'),'label':_0x45c5cd(_0x14bf34,_0x376c('0x5f')),'prompt':'Fix\x20spelling\x20mistakes,\x20use\x20proper\x20grammar\x20and\x20apply\x20good\x20writing\x20practices.\x20Do\x20not\x20lose\x20the\x20original\x20meaning.'},{'id':_0x376c('0x3b'),'label':_0x45c5cd(_0x14bf34,'Make\x20shorter'),'prompt':'Remove\x20any\x20repetitive,\x20redundant,\x20or\x20non-essential\x20writing\x20in\x20this\x20content\x20without\x20changing\x20the\x20meaning\x20or\x20losing\x20any\x20key\x20information.'},{'id':'makeLonger','label':_0x45c5cd(_0x14bf34,_0x376c('0x9')),'prompt':_0x376c('0x1b')},{'id':'simplifyLanguage','label':_0x45c5cd(_0x14bf34,_0x376c('0x20')),'prompt':_0x376c('0x10')}]},{'groupId':'generate','groupLabel':_0x45c5cd(_0x14bf34,_0x376c('0x29')),'commands':[{'id':_0x376c('0xe'),'label':_0x45c5cd(_0x14bf34,_0x376c('0x3')),'prompt':_0x376c('0x2d')},{'id':_0x376c('0x35'),'label':_0x45c5cd(_0x14bf34,_0x376c('0x7')),'prompt':_0x376c('0x21')}]},{'groupId':_0x376c('0x23'),'groupLabel':_0x45c5cd(_0x14bf34,_0x376c('0x18')),'commands':[{'id':'professional','label':_0x45c5cd(_0x14bf34,'Professional'),'prompt':'Improve\x20using\x20polished,\x20formal,\x20and\x20respectful\x20language\x20to\x20convey\x20professional\x20expertise\x20and\x20competence.'},{'id':_0x376c('0x45'),'label':_0x45c5cd(_0x14bf34,_0x376c('0x33')),'prompt':_0x376c('0x17')},{'id':'direct','label':_0x45c5cd(_0x14bf34,_0x376c('0x3a')),'prompt':_0x376c('0x4c')},{'id':_0x376c('0x1a'),'label':_0x45c5cd(_0x14bf34,_0x376c('0x14')),'prompt':'Improve\x20using\x20compelling,\x20optimistic\x20language\x20to\x20convey\x20confidence\x20in\x20the\x20writing.'},{'id':_0x376c('0x60'),'label':_0x45c5cd(_0x14bf34,_0x376c('0x4')),'prompt':_0x376c('0x55')}]},{'groupId':'changeStyle','groupLabel':_0x45c5cd(_0x14bf34,_0x376c('0x44')),'commands':[{'id':_0x376c('0xd'),'label':_0x45c5cd(_0x14bf34,_0x376c('0x16')),'prompt':_0x376c('0x53')},{'id':'legal','label':_0x45c5cd(_0x14bf34,_0x376c('0x1e')),'prompt':_0x376c('0x8')},{'id':_0x376c('0x52'),'label':_0x45c5cd(_0x14bf34,'Journalism'),'prompt':'Rewrite\x20this\x20content\x20as\x20a\x20journalist\x20using\x20engaging\x20language\x20to\x20convey\x20the\x20importance\x20of\x20the\x20information.'},{'id':_0x376c('0x24'),'label':_0x45c5cd(_0x14bf34,_0x376c('0x2f')),'prompt':_0x376c('0x3f')}]},{'groupId':'translate','groupLabel':_0x45c5cd(_0x14bf34,_0x376c('0xc')),'commands':[{'id':_0x376c('0x4f'),'label':_0x45c5cd(_0x14bf34,'Translate\x20to\x20%0',[_0x45c5cd(_0x14bf34,_0x376c('0x6'))]),'prompt':_0x376c('0x3e')},{'id':_0x376c('0x41'),'label':_0x45c5cd(_0x14bf34,_0x376c('0x5e'),[_0x45c5cd(_0x14bf34,_0x376c('0x42'))]),'prompt':_0x376c('0x19')},{'id':'translatePortuguese','label':_0x45c5cd(_0x14bf34,'Translate\x20to\x20%0',[_0x45c5cd(_0x14bf34,_0x376c('0x5d'))]),'prompt':_0x376c('0x50')},{'id':_0x376c('0x28'),'label':_0x45c5cd(_0x14bf34,_0x376c('0x5e'),[_0x45c5cd(_0x14bf34,_0x376c('0x30'))]),'prompt':_0x376c('0x37')},{'id':_0x376c('0x2b'),'label':_0x45c5cd(_0x14bf34,_0x376c('0x5e'),[_0x45c5cd(_0x14bf34,'French')]),'prompt':_0x376c('0x40')},{'id':_0x376c('0x2e'),'label':_0x45c5cd(_0x14bf34,'Translate\x20to\x20%0',[_0x45c5cd(_0x14bf34,'Simplified\x20Chinese')]),'prompt':'Translate\x20the\x20content\x20to\x20Simplified\x20Chinese\x20language.'},{'id':_0x376c('0x54'),'label':_0x45c5cd(_0x14bf34,_0x376c('0x5e'),[_0x45c5cd(_0x14bf34,_0x376c('0x49'))]),'prompt':_0x376c('0x15')},{'id':'translateArabic','label':_0x45c5cd(_0x14bf34,_0x376c('0x5e'),[_0x45c5cd(_0x14bf34,_0x376c('0x3c'))]),'prompt':_0x376c('0x12')}]}];export default class l extends _0x425378{static get[_0x376c('0x5c')](){return[_0x893417,_0x2657d7,_0x14f7e0];}static get['pluginName'](){return'AIAssistant';}constructor(_0x3c38d6){super(_0x3c38d6);const _0x12ede1=_0x3c38d6[_0x376c('0x32')];var _0x45a972;_0x12ede1[_0x376c('0x39')](_0x376c('0x26'),(_0x45a972=_0x3c38d6[_0x376c('0x57')],[{'groupId':'editOrReview','groupLabel':_0x45c5cd(_0x45a972,_0x376c('0x47')),'commands':[{'id':'improveWriting','label':_0x45c5cd(_0x45a972,_0x376c('0x5f')),'prompt':_0x376c('0x22')},{'id':_0x376c('0x3b'),'label':_0x45c5cd(_0x45a972,'Make\x20shorter'),'prompt':'Remove\x20any\x20repetitive,\x20redundant,\x20or\x20non-essential\x20writing\x20in\x20this\x20content\x20without\x20changing\x20the\x20meaning\x20or\x20losing\x20any\x20key\x20information.'},{'id':_0x376c('0x48'),'label':_0x45c5cd(_0x45a972,'Make\x20longer'),'prompt':_0x376c('0x1b')},{'id':_0x376c('0x0'),'label':_0x45c5cd(_0x45a972,_0x376c('0x20')),'prompt':'Simplify\x20the\x20writing\x20style\x20of\x20this\x20content\x20and\x20reduce\x20the\x20complexity,\x20so\x20that\x20the\x20content\x20is\x20easy\x20to\x20understand.'}]},{'groupId':_0x376c('0x5a'),'groupLabel':_0x45c5cd(_0x45a972,_0x376c('0x29')),'commands':[{'id':'summarize','label':_0x45c5cd(_0x45a972,_0x376c('0x3')),'prompt':_0x376c('0x2d')},{'id':_0x376c('0x35'),'label':_0x45c5cd(_0x45a972,'Continue'),'prompt':'Start\x20with\x20the\x20provided\x20content\x20and\x20write\x20at\x20the\x20end\x20of\x20it\x20continuing\x20this\x20topic.\x20Keep\x20the\x20added\x20part\x20short.'}]},{'groupId':_0x376c('0x23'),'groupLabel':_0x45c5cd(_0x45a972,_0x376c('0x18')),'commands':[{'id':_0x376c('0x4b'),'label':_0x45c5cd(_0x45a972,_0x376c('0x27')),'prompt':'Improve\x20using\x20polished,\x20formal,\x20and\x20respectful\x20language\x20to\x20convey\x20professional\x20expertise\x20and\x20competence.'},{'id':_0x376c('0x45'),'label':_0x45c5cd(_0x45a972,'Casual'),'prompt':_0x376c('0x17')},{'id':'direct','label':_0x45c5cd(_0x45a972,_0x376c('0x3a')),'prompt':_0x376c('0x4c')},{'id':_0x376c('0x1a'),'label':_0x45c5cd(_0x45a972,_0x376c('0x14')),'prompt':_0x376c('0x1')},{'id':_0x376c('0x60'),'label':_0x45c5cd(_0x45a972,_0x376c('0x4')),'prompt':'Improve\x20using\x20friendly,\x20comforting\x20language,\x20to\x20convey\x20understanding\x20and\x20empathy.'}]},{'groupId':'changeStyle','groupLabel':_0x45c5cd(_0x45a972,'Change\x20style'),'commands':[{'id':_0x376c('0xd'),'label':_0x45c5cd(_0x45a972,_0x376c('0x16')),'prompt':_0x376c('0x53')},{'id':_0x376c('0x59'),'label':_0x45c5cd(_0x45a972,'Legal'),'prompt':_0x376c('0x8')},{'id':_0x376c('0x52'),'label':_0x45c5cd(_0x45a972,_0x376c('0x1d')),'prompt':'Rewrite\x20this\x20content\x20as\x20a\x20journalist\x20using\x20engaging\x20language\x20to\x20convey\x20the\x20importance\x20of\x20the\x20information.'},{'id':_0x376c('0x24'),'label':_0x45c5cd(_0x45a972,_0x376c('0x2f')),'prompt':_0x376c('0x3f')}]},{'groupId':_0x376c('0x56'),'groupLabel':_0x45c5cd(_0x45a972,_0x376c('0xc')),'commands':[{'id':'translateEnglish','label':_0x45c5cd(_0x45a972,'Translate\x20to\x20%0',[_0x45c5cd(_0x45a972,_0x376c('0x6'))]),'prompt':_0x376c('0x3e')},{'id':_0x376c('0x41'),'label':_0x45c5cd(_0x45a972,_0x376c('0x5e'),[_0x45c5cd(_0x45a972,'Spanish')]),'prompt':'Translate\x20the\x20content\x20to\x20Spanish\x20language.'},{'id':_0x376c('0x1c'),'label':_0x45c5cd(_0x45a972,_0x376c('0x5e'),[_0x45c5cd(_0x45a972,_0x376c('0x5d'))]),'prompt':'Translate\x20the\x20content\x20to\x20Portuguese\x20language.'},{'id':_0x376c('0x28'),'label':_0x45c5cd(_0x45a972,_0x376c('0x5e'),[_0x45c5cd(_0x45a972,_0x376c('0x30'))]),'prompt':_0x376c('0x37')},{'id':_0x376c('0x2b'),'label':_0x45c5cd(_0x45a972,_0x376c('0x5e'),[_0x45c5cd(_0x45a972,_0x376c('0x31'))]),'prompt':_0x376c('0x40')},{'id':_0x376c('0x2e'),'label':_0x45c5cd(_0x45a972,_0x376c('0x5e'),[_0x45c5cd(_0x45a972,_0x376c('0x51'))]),'prompt':'Translate\x20the\x20content\x20to\x20Simplified\x20Chinese\x20language.'},{'id':_0x376c('0x54'),'label':_0x45c5cd(_0x45a972,_0x376c('0x5e'),[_0x45c5cd(_0x45a972,_0x376c('0x49'))]),'prompt':_0x376c('0x15')},{'id':_0x376c('0x13'),'label':_0x45c5cd(_0x45a972,'Translate\x20to\x20%0',[_0x45c5cd(_0x45a972,_0x376c('0x3c'))]),'prompt':_0x376c('0x12')}]}])),_0x12ede1[_0x376c('0x39')](_0x376c('0x3d'),[]),_0x12ede1[_0x376c('0x39')](_0x376c('0x4e'),[]);const _0x5c03e0=_0x12ede1[_0x376c('0x5')]('aiAssistant.commands'),_0x312fda=_0x12ede1[_0x376c('0x5')](_0x376c('0x3d')),_0x5e00ad=_0x12ede1['get'](_0x376c('0x4e'));_0x312fda['forEach'](_0x2b1614=>{const _0x59d016=_0x5c03e0['find'](_0x458b38=>_0x458b38[_0x376c('0x11')]===_0x2b1614['groupId']);_0x59d016?_0x59d016[_0x376c('0xa')]=_0x59d016[_0x376c('0xa')]['concat'](_0x2b1614[_0x376c('0xa')]):_0x5c03e0[_0x376c('0x25')](_0x2b1614);}),_0x5c03e0['forEach'](_0x3baee2=>{_0x3baee2[_0x376c('0xa')]=_0x3baee2[_0x376c('0xa')][_0x376c('0x34')](_0xe838c5=>!_0x5e00ad[_0x376c('0xb')](_0xe838c5['id']));}),_0x12ede1['set'](_0x376c('0x26'),_0x5c03e0);}[_0x376c('0x43')](){const _0x3f4551=this['editor'];this[_0x376c('0x5b')]=_0x3f4551[_0x376c('0x32')][_0x376c('0x5')](_0x376c('0x5b')),this[_0x376c('0x2c')]=setInterval(()=>{let _0x3caed6;for(const _0x34d57f in _0x3f4551){const _0xa43076=_0x34d57f,_0x157299=_0x3f4551[_0xa43076];if('aiLicenseKeyTrial'===_0x157299||'aiLicenseKeyInvalid'===_0x157299||_0x376c('0x1f')===_0x157299||'aiLicenseKeyTrialLimit:operations'===_0x157299){delete _0x3f4551[_0xa43076],_0x3caed6=_0x157299;break;}}if(_0x376c('0x4a')===_0x3caed6)throw clearInterval(this[_0x376c('0x2c')]),new _0x2a14ef(_0x376c('0x36'),null);if(_0x376c('0x2')===_0x3caed6&&console[_0x376c('0x46')]('You\x20are\x20using\x20the\x20trial\x20version\x20of\x20CKEditor\x205\x20ai\x20plugin\x20with\x20limited\x20usage.\x20Make\x20sure\x20you\x20will\x20not\x20use\x20it\x20in\x20the\x20production\x20environment.'),_0x376c('0xf')===_0x3caed6)throw clearInterval(this[_0x376c('0x2c')]),new _0x2a14ef(_0x376c('0x4d'),null);_0x376c('0x1f')===_0x3caed6&&clearInterval(this[_0x376c('0x2c')]);},0x3e8);}[_0x376c('0x58')](){this['_licenseKeyCheckInterval']&&clearInterval(this[_0x376c('0x2c')]);}}
|
|
@@ -0,0 +1,45 @@
|
|
|
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/aiassistantediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import type { Position } from 'ckeditor5/src/engine';
|
|
10
|
+
/**
|
|
11
|
+
* The AI assistant editing plugin.
|
|
12
|
+
*/
|
|
13
|
+
export default class AIAssistantEditing extends Plugin {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get pluginName(): "AIAssistantEditing";
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
init(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Displays a fake visual selection when the contextual balloon is displayed.
|
|
24
|
+
*
|
|
25
|
+
* This adds a 'ai-ui' marker into the document that is rendered as a highlight on selected text fragment.
|
|
26
|
+
*/
|
|
27
|
+
showFakeVisualSelection(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Removes a fake visual selection when the contextual balloon is hidden.
|
|
30
|
+
*
|
|
31
|
+
* This removes all 'ai-ui' markers from the document.
|
|
32
|
+
*/
|
|
33
|
+
hideFakeVisualSelection(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Converts the HTML string into the model fragment and inserts it at the specified position.
|
|
36
|
+
*
|
|
37
|
+
* If a position is not provided, the insertion will be performed at the current selection.
|
|
38
|
+
*/
|
|
39
|
+
insertContent(content: string, position?: Position): void;
|
|
40
|
+
/**
|
|
41
|
+
* Converts the HTML string into the model fragment and inserts it at the specified position.
|
|
42
|
+
* If a position is not provided, the insertion will be performed at the current selection.
|
|
43
|
+
*/
|
|
44
|
+
insertContentBelow(content: string): void;
|
|
45
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* +---------------------------------------------------------------------------------+
|
|
8
|
+
* | |
|
|
9
|
+
* | Hello stranger! |
|
|
10
|
+
* | |
|
|
11
|
+
* | |
|
|
12
|
+
* | What you're currently looking at is the source code of a legally protected, |
|
|
13
|
+
* | proprietary software. Any attempts to deobfuscate / disassemble this code |
|
|
14
|
+
* | are forbidden and will result in legal consequences. |
|
|
15
|
+
* | |
|
|
16
|
+
* | |
|
|
17
|
+
* +---------------------------------------------------------------------------------+
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
const _0x9e50=['toView','canEditAt','insertContentBelow','data','hideFakeVisualSelection','ck-fake-ai-selection_collapsed','model','markerToElement','pluginName','conversion','document','toModel','editor','getLastMatchingPosition','getLastPosition','span','editingDowncast','processor','has','markers','getSelectedBlocks','selection','isAtEnd','createRange','addMarker','from','isContent','for','insertContent','init','pop','updateMarker','change','start','length'];(function(_0x370254,_0x9e50b8){const _0xe622b4=function(_0xb54faa){while(--_0xb54faa){_0x370254['push'](_0x370254['shift']());}};_0xe622b4(++_0x9e50b8);}(_0x9e50,0x14b));const _0xe622=function(_0x370254,_0x9e50b8){_0x370254=_0x370254-0x0;let _0xe622b4=_0x9e50[_0x370254];return _0xe622b4;};import{Plugin as _0x3a15c2}from'ckeditor5/src/core';const s='ai-ui';export default class i extends _0x3a15c2{static get[_0xe622('0x1b')](){return'AIAssistantEditing';}[_0xe622('0xd')](){const {editor:_0x33c007}=this;_0x33c007[_0xe622('0x1c')][_0xe622('0xb')](_0xe622('0x0'))['markerToHighlight']({'model':s,'view':{'classes':['ck-fake-ai-selection']}}),_0x33c007[_0xe622('0x1c')][_0xe622('0xb')](_0xe622('0x0'))[_0xe622('0x1a')]({'model':s,'view':{'name':_0xe622('0x22'),'classes':['ck-fake-ai-selection',_0xe622('0x18')]}});}['showFakeVisualSelection'](){const _0x15aeaf=this['editor'][_0xe622('0x19')];_0x15aeaf[_0xe622('0x10')](_0x471e83=>{const _0x3fe952=_0x15aeaf['document'][_0xe622('0x5')]['getFirstRange']();if(_0x15aeaf[_0xe622('0x3')][_0xe622('0x2')](s))_0x471e83[_0xe622('0xf')](s,{'range':_0x3fe952});else{if(_0x3fe952[_0xe622('0x11')][_0xe622('0x6')]){const _0x5c68c5=_0x3fe952[_0xe622('0x11')][_0xe622('0x20')](({item:_0x45e63f})=>!_0x15aeaf['schema'][_0xe622('0xa')](_0x45e63f),{'boundaries':_0x3fe952});_0x471e83['addMarker'](s,{'usingOperation':!0x1,'affectsData':!0x1,'range':_0x471e83[_0xe622('0x7')](_0x5c68c5,_0x3fe952['end'])});}else _0x471e83[_0xe622('0x8')](s,{'usingOperation':!0x1,'affectsData':!0x1,'range':_0x3fe952});}});}[_0xe622('0x17')](){this['editor']['model'][_0xe622('0x10')](_0x8ff20d=>{_0x8ff20d['removeMarker'](s);});}[_0xe622('0xc')](_0x3523e0,_0x3761ab){const _0x499918=_0x3761ab||this[_0xe622('0x1f')]['model'][_0xe622('0x1d')][_0xe622('0x5')];if(!this[_0xe622('0x1f')]['model'][_0xe622('0x14')](_0x499918))return;const _0x42375b=this['editor']['data'][_0xe622('0x1')][_0xe622('0x13')](_0x3523e0),_0x19d9f2=this[_0xe622('0x1f')][_0xe622('0x16')][_0xe622('0x1e')](_0x42375b);this[_0xe622('0x1f')][_0xe622('0x19')][_0xe622('0x10')](_0x404ca2=>{const _0x38e8fd=this[_0xe622('0x1f')]['model'][_0xe622('0xc')](_0x19d9f2,_0x499918);_0x38e8fd&&_0x404ca2['setSelection'](_0x38e8fd);});}[_0xe622('0x15')](_0x2255d7){const {model:_0x2fe986}=this[_0xe622('0x1f')],_0x3df4d9=Array[_0xe622('0x9')](_0x2fe986['document']['selection'][_0xe622('0x4')]()),_0x1d9bea=_0x3df4d9[_0xe622('0x12')]?_0x2fe986['createPositionAfter'](_0x3df4d9[_0xe622('0xe')]()):_0x2fe986[_0xe622('0x1d')][_0xe622('0x5')][_0xe622('0x21')]();this['insertContent'](_0x2255d7,_0x1d9bea);}}
|
|
@@ -0,0 +1,44 @@
|
|
|
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/aiassistantui
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
|
10
|
+
import { ContextualBalloon } from 'ckeditor5/src/ui';
|
|
11
|
+
import AIAssistantEditing from './aiassistantediting';
|
|
12
|
+
import '../theme/ai.css';
|
|
13
|
+
import '../theme/ai-dropdown.css';
|
|
14
|
+
import '../theme/ai-form.css';
|
|
15
|
+
/**
|
|
16
|
+
* The UI plugin of the AI assistant.
|
|
17
|
+
*/
|
|
18
|
+
export default class AIAssistantUI extends Plugin {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get pluginName(): "AIAssistantUI";
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get requires(): readonly [typeof AIAssistantEditing, "AIConnector", typeof ContextualBalloon];
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
constructor(editor: Editor);
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
init(): void;
|
|
35
|
+
afterInit(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Initializes the balloon content and displays it based on the selection.
|
|
38
|
+
*/
|
|
39
|
+
showUI(prompt?: string, label?: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Removes fake markers and clears the balloon content causing it hidden.
|
|
42
|
+
*/
|
|
43
|
+
hideUI(): void;
|
|
44
|
+
}
|