@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.
Files changed (162) hide show
  1. package/LICENSE.md +2 -2
  2. package/README.md +1 -1
  3. package/build/ai.js +77 -2
  4. package/build/translations/af.js +1 -1
  5. package/build/translations/ar.js +1 -1
  6. package/build/translations/bg.js +1 -1
  7. package/build/translations/bn.js +1 -1
  8. package/build/translations/bs.js +1 -1
  9. package/build/translations/ca.js +1 -1
  10. package/build/translations/cs.js +1 -1
  11. package/build/translations/da.js +1 -1
  12. package/build/translations/de-ch.js +1 -1
  13. package/build/translations/de.js +1 -1
  14. package/build/translations/el.js +1 -1
  15. package/build/translations/en-au.js +1 -1
  16. package/build/translations/es-co.js +1 -1
  17. package/build/translations/es.js +1 -1
  18. package/build/translations/et.js +1 -1
  19. package/build/translations/fa.js +1 -1
  20. package/build/translations/fi.js +1 -1
  21. package/build/translations/fr.js +1 -1
  22. package/build/translations/gl.js +1 -1
  23. package/build/translations/he.js +1 -1
  24. package/build/translations/hi.js +1 -1
  25. package/build/translations/hr.js +1 -1
  26. package/build/translations/hu.js +1 -1
  27. package/build/translations/id.js +1 -1
  28. package/build/translations/it.js +1 -1
  29. package/build/translations/ja.js +1 -1
  30. package/build/translations/jv.js +1 -1
  31. package/build/translations/ko.js +1 -1
  32. package/build/translations/lt.js +1 -1
  33. package/build/translations/lv.js +1 -1
  34. package/build/translations/ms.js +1 -1
  35. package/build/translations/nl.js +1 -1
  36. package/build/translations/no.js +1 -1
  37. package/build/translations/pl.js +1 -1
  38. package/build/translations/pt-br.js +1 -1
  39. package/build/translations/pt.js +1 -1
  40. package/build/translations/ro.js +1 -1
  41. package/build/translations/ru.js +1 -1
  42. package/build/translations/sk.js +1 -1
  43. package/build/translations/sr-latn.js +1 -1
  44. package/build/translations/sr.js +1 -1
  45. package/build/translations/sv.js +1 -1
  46. package/build/translations/th.js +1 -1
  47. package/build/translations/tk.js +1 -1
  48. package/build/translations/tr.js +1 -1
  49. package/build/translations/ug.js +1 -1
  50. package/build/translations/uk.js +1 -1
  51. package/build/translations/ur.js +1 -1
  52. package/build/translations/uz.js +1 -0
  53. package/build/translations/vi.js +1 -1
  54. package/build/translations/zh-cn.js +1 -1
  55. package/build/translations/zh.js +1 -1
  56. package/ckeditor5-metadata.json +1 -1
  57. package/lang/contexts.json +4 -1
  58. package/lang/translations/af.po +60 -16
  59. package/lang/translations/ar.po +60 -16
  60. package/lang/translations/bg.po +60 -16
  61. package/lang/translations/bn.po +60 -16
  62. package/lang/translations/bs.po +60 -16
  63. package/lang/translations/ca.po +60 -16
  64. package/lang/translations/cs.po +60 -16
  65. package/lang/translations/da.po +60 -16
  66. package/lang/translations/de-ch.po +60 -16
  67. package/lang/translations/de.po +60 -16
  68. package/lang/translations/el.po +60 -16
  69. package/lang/translations/en-au.po +60 -16
  70. package/lang/translations/en.po +60 -16
  71. package/lang/translations/es-co.po +60 -16
  72. package/lang/translations/es.po +60 -16
  73. package/lang/translations/et.po +60 -16
  74. package/lang/translations/fa.po +60 -16
  75. package/lang/translations/fi.po +60 -16
  76. package/lang/translations/fr.po +60 -16
  77. package/lang/translations/gl.po +95 -51
  78. package/lang/translations/he.po +60 -16
  79. package/lang/translations/hi.po +60 -16
  80. package/lang/translations/hr.po +93 -49
  81. package/lang/translations/hu.po +60 -16
  82. package/lang/translations/id.po +60 -16
  83. package/lang/translations/it.po +60 -16
  84. package/lang/translations/ja.po +60 -16
  85. package/lang/translations/jv.po +60 -16
  86. package/lang/translations/ko.po +60 -16
  87. package/lang/translations/lt.po +60 -16
  88. package/lang/translations/lv.po +60 -16
  89. package/lang/translations/ms.po +60 -16
  90. package/lang/translations/nl.po +60 -16
  91. package/lang/translations/no.po +60 -16
  92. package/lang/translations/pl.po +60 -16
  93. package/lang/translations/pt-br.po +60 -16
  94. package/lang/translations/pt.po +60 -16
  95. package/lang/translations/ro.po +60 -16
  96. package/lang/translations/ru.po +60 -16
  97. package/lang/translations/sk.po +60 -16
  98. package/lang/translations/sr-latn.po +95 -51
  99. package/lang/translations/sr.po +60 -16
  100. package/lang/translations/sv.po +60 -16
  101. package/lang/translations/th.po +60 -16
  102. package/lang/translations/tk.po +60 -16
  103. package/lang/translations/tr.po +60 -16
  104. package/lang/translations/ug.po +96 -52
  105. package/lang/translations/uk.po +60 -16
  106. package/lang/translations/ur.po +60 -16
  107. package/lang/translations/uz.po +226 -0
  108. package/lang/translations/vi.po +60 -16
  109. package/lang/translations/zh-cn.po +60 -16
  110. package/lang/translations/zh.po +60 -16
  111. package/package.json +4 -3
  112. package/src/adapters/aiadapter.d.ts +48 -0
  113. package/src/adapters/aiadapter.js +23 -0
  114. package/src/adapters/aitextadapter.d.ts +146 -0
  115. package/src/adapters/aitextadapter.js +23 -0
  116. package/src/adapters/awstextadapter.d.ts +178 -0
  117. package/src/adapters/awstextadapter.js +23 -0
  118. package/src/adapters/openaitextadapter.d.ts +181 -0
  119. package/src/adapters/openaitextadapter.js +23 -0
  120. package/src/aiassistant.d.ts +386 -419
  121. package/src/aiassistant.js +1 -1
  122. package/src/aiassistantediting.d.ts +45 -45
  123. package/src/aiassistantediting.js +1 -1
  124. package/src/aiassistantui.d.ts +52 -46
  125. package/src/aiassistantui.js +1 -1
  126. package/src/aiconfig.d.ts +69 -0
  127. package/src/aiconfig.js +23 -0
  128. package/src/augmentation.d.ts +27 -26
  129. package/src/index.d.ts +13 -9
  130. package/src/index.js +1 -1
  131. package/src/ui/aiassistantcontroller.d.ts +109 -59
  132. package/src/ui/aiassistantcontroller.js +1 -1
  133. package/src/ui/dropdown/aicommandslistview.d.ts +22 -22
  134. package/src/ui/dropdown/aicommandslistview.js +1 -1
  135. package/src/ui/dropdown/buttonlabelwithhighlightview.d.ts +29 -29
  136. package/src/ui/dropdown/buttonlabelwithhighlightview.js +1 -1
  137. package/src/ui/dropdown/labelwithhighlightview.d.ts +25 -0
  138. package/src/ui/dropdown/labelwithhighlightview.js +23 -0
  139. package/src/ui/form/aiformcontentarea.d.ts +48 -48
  140. package/src/ui/form/aiformcontentarea.js +1 -1
  141. package/src/ui/form/aiformerrorview.d.ts +26 -26
  142. package/src/ui/form/aiformerrorview.js +1 -1
  143. package/src/ui/form/aiformpromptview.d.ts +46 -46
  144. package/src/ui/form/aiformpromptview.js +1 -1
  145. package/src/ui/form/aiformtoolbarview.d.ts +54 -41
  146. package/src/ui/form/aiformtoolbarview.js +1 -1
  147. package/src/ui/form/aiformview.d.ts +142 -131
  148. package/src/ui/form/aiformview.js +1 -1
  149. package/src/ui/form/aihistorylistitemview.d.ts +18 -18
  150. package/src/ui/form/aihistorylistitemview.js +1 -1
  151. package/src/ui/form/aihistorylistview.d.ts +35 -35
  152. package/src/ui/form/aihistorylistview.js +1 -1
  153. package/src/ui/form/prompthistory.d.ts +20 -20
  154. package/src/ui/form/prompthistory.js +1 -1
  155. package/src/ui/showaiassistantcommand.d.ts +29 -26
  156. package/src/ui/showaiassistantcommand.js +1 -1
  157. package/src/utils/common-translations.d.ts +9 -9
  158. package/src/utils/common-translations.js +1 -1
  159. package/theme/ai-form.css +58 -11
  160. package/theme/ai.css +20 -15
  161. package/src/aiconnector.d.ts +0 -44
  162. package/src/aiconnector.js +0 -23
@@ -1,18 +1,18 @@
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/ui/aihistorylistitemview
7
- */
8
- import { ListItemView } from 'ckeditor5/src/ui';
9
- import type { PromptHistoryEntry } from './prompthistory';
10
- /**
11
- * A list item view that displays a historical prompt
12
- */
13
- export default class AIHistoryListItemView extends ListItemView {
14
- /**
15
- * @inheritDoc
16
- */
17
- constructor(promptHistoryEntry: PromptHistoryEntry);
18
- }
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/ui/aihistorylistitemview
7
+ */
8
+ import { ListItemView } from 'ckeditor5/src/ui';
9
+ import type { PromptHistoryEntry } from './prompthistory';
10
+ /**
11
+ * A list item view that displays a historical prompt
12
+ */
13
+ export default class AIHistoryListItemView extends ListItemView {
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ constructor(promptHistoryEntry: PromptHistoryEntry);
18
+ }
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- const _0x2709=['add','execute','prompt','locale','set','children'];(function(_0x50495a,_0x270962){const _0x1982eb=function(_0x17f496){while(--_0x17f496){_0x50495a['push'](_0x50495a['shift']());}};_0x1982eb(++_0x270962);}(_0x2709,0x1b5));const _0x1982=function(_0x50495a,_0x270962){_0x50495a=_0x50495a-0x0;let _0x1982eb=_0x2709[_0x50495a];return _0x1982eb;};import{ListItemView as _0x35e25a,ButtonView as _0x8bc712}from'ckeditor5/src/ui';import _0x567cdb from'../dropdown/buttonlabelwithhighlightview';import{unescape as _0x502257}from'lodash-es';export default class et extends _0x35e25a{constructor(_0x21d01f){super();const _0x344282=new _0x567cdb(),_0x40844b=new _0x8bc712(this[_0x1982('0x4')],_0x344282);this[_0x1982('0x0')][_0x1982('0x1')](_0x40844b),_0x40844b[_0x1982('0x5')]({'label':_0x21d01f[_0x1982('0x3')],'withText':!0x0}),_0x40844b['on'](_0x1982('0x2'),()=>{this['fire'](_0x1982('0x2'),{'value':_0x502257(_0x21d01f['prompt'])});});}}
23
+ const _0x35dc=['fire','locale','execute','children','prompt','add','set'];(function(_0x546f54,_0x35dc86){const _0x2f68e5=function(_0x13289d){while(--_0x13289d){_0x546f54['push'](_0x546f54['shift']());}};_0x2f68e5(++_0x35dc86);}(_0x35dc,0x7a));const _0x2f68=function(_0x546f54,_0x35dc86){_0x546f54=_0x546f54-0x0;let _0x2f68e5=_0x35dc[_0x546f54];return _0x2f68e5;};import{ListItemView as _0x56287e,ButtonView as _0x4fe861}from'ckeditor5/src/ui';import _0x5e63be from'../dropdown/buttonlabelwithhighlightview';import{unescape as _0x572a25}from'lodash-es';export default class pt extends _0x56287e{constructor(_0x429b4c){super();const _0x54e236=new _0x5e63be(),_0x524a0f=new _0x4fe861(this[_0x2f68('0x5')],_0x54e236);this[_0x2f68('0x0')][_0x2f68('0x2')](_0x524a0f),_0x524a0f[_0x2f68('0x3')]({'label':_0x429b4c[_0x2f68('0x1')],'withText':!0x0}),_0x524a0f['on'](_0x2f68('0x6'),()=>{this[_0x2f68('0x4')](_0x2f68('0x6'),{'value':_0x572a25(_0x429b4c[_0x2f68('0x1')])});});}}
@@ -1,35 +1,35 @@
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/ui/aihistorylistview
7
- */
8
- import { ListView, ListItemGroupView, ButtonView, type FilteredView } from 'ckeditor5/src/ui';
9
- import type { Locale } from 'ckeditor5/src/utils';
10
- /**
11
- * A list view that displays a list of AI prompts with filter pass-through.
12
- *
13
- * @private
14
- */
15
- export default class AIHistoryListView extends ListView implements FilteredView {
16
- historyGroupView: ListItemGroupView;
17
- clearHistoryButton: ButtonView;
18
- constructor(locale: Locale);
19
- /**
20
- * @inheritDoc
21
- */
22
- filter(): {
23
- resultsCount: number;
24
- totalItemsCount: number;
25
- };
26
- }
27
- /**
28
- * Fired when the clear history button was executed by the user.
29
- *
30
- * @eventName ~AIHistoryListView#clearHistory
31
- */
32
- export type AIHistoryListViewClearHistoryEvent = {
33
- name: 'clearHistory';
34
- args: [];
35
- };
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/ui/aihistorylistview
7
+ */
8
+ import { ListView, ListItemGroupView, ButtonView, type FilteredView } from 'ckeditor5/src/ui';
9
+ import type { Locale } from 'ckeditor5/src/utils';
10
+ /**
11
+ * A list view that displays a list of AI prompts with filter pass-through.
12
+ *
13
+ * @private
14
+ */
15
+ export default class AIHistoryListView extends ListView implements FilteredView {
16
+ historyGroupView: ListItemGroupView;
17
+ clearHistoryButton: ButtonView;
18
+ constructor(locale: Locale);
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ filter(): {
23
+ resultsCount: number;
24
+ totalItemsCount: number;
25
+ };
26
+ }
27
+ /**
28
+ * Fired when the clear history button was executed by the user.
29
+ *
30
+ * @eventName ~AIHistoryListView#clearHistory
31
+ */
32
+ export type AIHistoryListViewClearHistoryEvent = {
33
+ name: 'clearHistory';
34
+ args: [];
35
+ };
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- const _0x1f85=['filter','locale','label','items','delegate','children','execute','fire','Clear','set','_createClearHistoryButton','historyGroupView','clearHistoryButton','Prompt\x20history','add','length','clearHistory'];(function(_0x15144d,_0x1f8511){const _0x4dcf81=function(_0x1effcf){while(--_0x1effcf){_0x15144d['push'](_0x15144d['shift']());}};_0x4dcf81(++_0x1f8511);}(_0x1f85,0xbc));const _0x4dcf=function(_0x15144d,_0x1f8511){_0x15144d=_0x15144d-0x0;let _0x4dcf81=_0x1f85[_0x15144d];return _0x4dcf81;};import{ListView as _0x3279da,ListItemGroupView as _0x6dc875,ButtonView as _0x58d7b3}from'ckeditor5/src/ui';import{getTranslation as _0x57f81d}from'../../utils/common-translations';export default class st extends _0x3279da{constructor(_0x4a65e3){super(_0x4a65e3),this[_0x4dcf('0xb')]=this[_0x4dcf('0x9')](),this[_0x4dcf('0xa')]=new _0x6dc875(),this[_0x4dcf('0xa')][_0x4dcf('0x4')][_0x4dcf('0xd')](this[_0x4dcf('0xb')],0x1),this[_0x4dcf('0xa')][_0x4dcf('0x1')]=_0x57f81d(_0x4a65e3,_0x4dcf('0xc')),this[_0x4dcf('0xa')]['items'][_0x4dcf('0x3')](_0x4dcf('0x5'))['to'](this),this[_0x4dcf('0x2')]['add'](this[_0x4dcf('0xa')]);}[_0x4dcf('0x10')](){let _0x305117=0x0;for(const _0x24cd1e of this[_0x4dcf('0x2')])_0x305117+=_0x24cd1e[_0x4dcf('0x2')][_0x4dcf('0xe')];return{'resultsCount':_0x305117,'totalItemsCount':_0x305117};}['_createClearHistoryButton'](){const _0x1aaf52=this[_0x4dcf('0x0')],_0x379f8c=new _0x58d7b3(this[_0x4dcf('0x0')]);return _0x379f8c[_0x4dcf('0x8')]({'label':'('+_0x57f81d(_0x1aaf52,_0x4dcf('0x7'))+')','withText':!0x0}),_0x379f8c['on'](_0x4dcf('0x5'),()=>this[_0x4dcf('0x6')](_0x4dcf('0xf'))),_0x379f8c;}}
23
+ const _0x4f95=['locale','add','children','historyGroupView','execute','clearHistory','fire','items','_createClearHistoryButton','delegate','clearHistoryButton','Prompt\x20history','Clear'];(function(_0x23faf1,_0x4f952f){const _0x3ce790=function(_0x465884){while(--_0x465884){_0x23faf1['push'](_0x23faf1['shift']());}};_0x3ce790(++_0x4f952f);}(_0x4f95,0xfb));const _0x3ce7=function(_0x23faf1,_0x4f952f){_0x23faf1=_0x23faf1-0x0;let _0x3ce790=_0x4f95[_0x23faf1];return _0x3ce790;};import{ListView as _0x3276da,ListItemGroupView as _0x303995,ButtonView as _0x3e2e1d}from'ckeditor5/src/ui';import{getTranslation as _0x2aaab3}from'../../utils/common-translations';export default class ut extends _0x3276da{constructor(_0x548d1d){super(_0x548d1d),this[_0x3ce7('0x6')]=this[_0x3ce7('0x4')](),this['historyGroupView']=new _0x303995(),this[_0x3ce7('0xc')][_0x3ce7('0xb')][_0x3ce7('0xa')](this[_0x3ce7('0x6')],0x1),this[_0x3ce7('0xc')]['label']=_0x2aaab3(_0x548d1d,_0x3ce7('0x7')),this[_0x3ce7('0xc')][_0x3ce7('0x3')][_0x3ce7('0x5')](_0x3ce7('0x0'))['to'](this),this['items']['add'](this[_0x3ce7('0xc')]);}['filter'](){let _0x4a59f1=0x0;for(const _0x85ff85 of this[_0x3ce7('0x3')])_0x4a59f1+=_0x85ff85[_0x3ce7('0x3')]['length'];return{'resultsCount':_0x4a59f1,'totalItemsCount':_0x4a59f1};}[_0x3ce7('0x4')](){const _0xa17eaf=this['locale'],_0x1204b5=new _0x3e2e1d(this[_0x3ce7('0x9')]);return _0x1204b5['set']({'label':'('+_0x2aaab3(_0xa17eaf,_0x3ce7('0x8'))+')','withText':!0x0}),_0x1204b5['on']('execute',()=>this[_0x3ce7('0x2')](_0x3ce7('0x1'))),_0x1204b5;}}
@@ -1,20 +1,20 @@
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
- import { Collection } from 'ckeditor5/src/utils';
6
- /**
7
- * A collection that stores the prompt history in the session storage as a side effect.
8
- */
9
- export default class PromptHistory extends Collection<PromptHistoryEntry> {
10
- /**
11
- * @inheritDoc
12
- */
13
- constructor();
14
- }
15
- /**
16
- * An object that represents a historical prompt.
17
- */
18
- export type PromptHistoryEntry = {
19
- prompt: string;
20
- };
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
+ import { Collection } from 'ckeditor5/src/utils';
6
+ /**
7
+ * A collection that stores the prompt history in the session storage as a side effect.
8
+ */
9
+ export default class PromptHistory extends Collection<PromptHistoryEntry> {
10
+ /**
11
+ * @inheritDoc
12
+ */
13
+ constructor();
14
+ }
15
+ /**
16
+ * An object that represents a historical prompt.
17
+ */
18
+ export type PromptHistoryEntry = {
19
+ prompt: string;
20
+ };
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- const _0x20eb=['CKEditor/AIFormView/PromptHistory','trim','prompt','getItem','setItem','parse','remove','last','addMany','_saveToSessionStorage','map','add','_loadFromSessionStorage'];(function(_0x515ea8,_0x20eb5c){const _0x575c3d=function(_0x324e74){while(--_0x324e74){_0x515ea8['push'](_0x515ea8['shift']());}};_0x575c3d(++_0x20eb5c);}(_0x20eb,0x1ba));const _0x575c=function(_0x515ea8,_0x20eb5c){_0x515ea8=_0x515ea8-0x0;let _0x575c3d=_0x20eb[_0x515ea8];return _0x575c3d;};import{Collection as _0x4e31d3}from'ckeditor5/src/utils';const ts=_0x575c('0x0');export default class rt extends _0x4e31d3{constructor(){super(),this[_0x575c('0xc')](),this['on'](_0x575c('0xb'),(_0x35ac10,_0x44a3ff)=>{const _0x839757=os(_0x44a3ff[_0x575c('0x2')]);for(const _0x216331 of this)if(_0x216331!=_0x44a3ff&&os(_0x216331[_0x575c('0x2')])===_0x839757){this['remove'](_0x216331);break;}this['length']>0x14&&this[_0x575c('0x6')](this[_0x575c('0x7')]),this[_0x575c('0x9')]();}),this['on']('remove',()=>{this[_0x575c('0x9')]();});}[_0x575c('0xc')](){const _0x4d4bcf=sessionStorage[_0x575c('0x3')](ts)||'[]';this[_0x575c('0x8')](JSON[_0x575c('0x5')](_0x4d4bcf));}['_saveToSessionStorage'](){sessionStorage[_0x575c('0x4')](ts,JSON['stringify'](this[_0x575c('0xa')](_0x5eb5c9=>_0x5eb5c9)));}}function os(_0x322da0){return _0x322da0['toLowerCase']()[_0x575c('0x1')]();}
23
+ const _0x249f=['_loadFromSessionStorage','add','map','last','remove','_saveToSessionStorage','toLowerCase','stringify','CKEditor/AIFormView/PromptHistory','length','addMany','trim','setItem','getItem','prompt'];(function(_0x25c4c3,_0x249fb7){const _0x516582=function(_0x9431f3){while(--_0x9431f3){_0x25c4c3['push'](_0x25c4c3['shift']());}};_0x516582(++_0x249fb7);}(_0x249f,0x102));const _0x5165=function(_0x25c4c3,_0x249fb7){_0x25c4c3=_0x25c4c3-0x0;let _0x516582=_0x249f[_0x25c4c3];return _0x516582;};import{Collection as _0x396808}from'ckeditor5/src/utils';const ts=_0x5165('0x5');export default class dt extends _0x396808{constructor(){super(),this[_0x5165('0xc')](),this['on'](_0x5165('0xd'),(_0x809c23,_0x2ab92e)=>{const _0x467a55=os(_0x2ab92e[_0x5165('0xb')]);for(const _0x26f08a of this)if(_0x26f08a!=_0x2ab92e&&os(_0x26f08a[_0x5165('0xb')])===_0x467a55){this['remove'](_0x26f08a);break;}this[_0x5165('0x6')]>0x14&&this['remove'](this[_0x5165('0x0')]),this[_0x5165('0x2')]();}),this['on'](_0x5165('0x1'),()=>{this[_0x5165('0x2')]();});}['_loadFromSessionStorage'](){const _0x3bbdee=sessionStorage[_0x5165('0xa')](ts)||'[]';this[_0x5165('0x7')](JSON['parse'](_0x3bbdee));}[_0x5165('0x2')](){sessionStorage[_0x5165('0x9')](ts,JSON[_0x5165('0x4')](this[_0x5165('0xe')](_0x530358=>_0x530358)));}}function os(_0xb5b7b2){return _0xb5b7b2[_0x5165('0x3')]()[_0x5165('0x8')]();}
@@ -1,26 +1,29 @@
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/ui/showaiassistantcommand
7
- * @publicApi
8
- */
9
- import { Command } from 'ckeditor5/src/core';
10
- /**
11
- * Command that shows the AI Assistant user interface.
12
- */
13
- export default class ShowAIAssistantCommand extends Command {
14
- /**
15
- * @inheritDoc
16
- */
17
- refresh(): void;
18
- /**
19
- * Opens AI Assistant user interface for the current document selection.
20
- *
21
- * @param prompt The initial prompt. If set, the AI assistant will automatically submit given prompt to the AI service.
22
- * @param label Label to be displayed in the AI assistant query input field while the AI assistant processes the initial prompt.
23
- * @fires execute
24
- */
25
- execute(prompt?: string, label?: string): void;
26
- }
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/ui/showaiassistantcommand
7
+ * @publicApi
8
+ */
9
+ import { Command } from 'ckeditor5/src/core';
10
+ /**
11
+ * Command that shows the AI Assistant user interface.
12
+ */
13
+ export default class ShowAIAssistantCommand extends Command {
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ refresh(): void;
18
+ /**
19
+ * Opens AI Assistant user interface for the current document selection.
20
+ *
21
+ * @param query The initial query. If set, the AI assistant will automatically submit given query to the AI service.
22
+ * @param label Label to be displayed in the AI assistant query input field while the AI assistant processes the initial query.
23
+ * @param actionId The id of the executed action. It can be used in extended and custom adapters to customize the request. It
24
+ * will be prefixed with `aiAssistant:`. See also
25
+ * {@link module:ai/adapters/aitextadapter~AITextAdapterRequestData#actionId `AITextAdapterRequestData#actionId`}.
26
+ * @fires execute
27
+ */
28
+ execute(query?: string, label?: string, actionId?: string): void;
29
+ }
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- const _0x5be9=['selection','execute','isEnabled','getRanges','plugins','editor','get','getItems','name','model','includes','showUI','element','refresh'];(function(_0x3b8c6f,_0x5be972){const _0x4ae474=function(_0x1c8ab8){while(--_0x1c8ab8){_0x3b8c6f['push'](_0x3b8c6f['shift']());}};_0x4ae474(++_0x5be972);}(_0x5be9,0x15e));const _0x4ae4=function(_0x3b8c6f,_0x5be972){_0x3b8c6f=_0x3b8c6f-0x0;let _0x4ae474=_0x5be9[_0x3b8c6f];return _0x4ae474;};import{Command as _0x5696cd}from'ckeditor5/src/core';import _0x4baeb8 from'../aiassistantui';export default class A extends _0x5696cd{[_0x4ae4('0xd')](){const _0x3f2962=this['editor'][_0x4ae4('0x9')]['document'][_0x4ae4('0x0')],_0x19b897=this['editor']['config'][_0x4ae4('0x6')]('aiAssistant.disabledElements');for(const _0x1a2185 of _0x3f2962[_0x4ae4('0x3')]())for(const _0x409131 of _0x1a2185[_0x4ae4('0x7')]())if(_0x409131['is'](_0x4ae4('0xc'))&&_0x19b897[_0x4ae4('0xa')](_0x409131[_0x4ae4('0x8')]))return void(this[_0x4ae4('0x2')]=!0x1);this[_0x4ae4('0x2')]=!0x0;}[_0x4ae4('0x1')](_0x219880='',_0x2e174e=''){this[_0x4ae4('0x5')][_0x4ae4('0x4')][_0x4ae4('0x6')](_0x4baeb8)[_0x4ae4('0xb')](_0x219880,_0x2e174e,this['editor'][_0x4ae4('0x9')]['document']['selection']);}}
23
+ const _0x218c=['model','showUI','getRanges','get','selection','editor','element','ai.aiAssistant.disabledElements','getItems','custom','plugins','isEnabled','includes','document'];(function(_0x4b9bee,_0x218c26){const _0x34e3a9=function(_0x52c64e){while(--_0x52c64e){_0x4b9bee['push'](_0x4b9bee['shift']());}};_0x34e3a9(++_0x218c26);}(_0x218c,0x1a1));const _0x34e3=function(_0x4b9bee,_0x218c26){_0x4b9bee=_0x4b9bee-0x0;let _0x34e3a9=_0x218c[_0x4b9bee];return _0x34e3a9;};import{Command as _0x4a67c9}from'ckeditor5/src/core';import _0x23b8a8 from'../aiassistantui';export default class I extends _0x4a67c9{['refresh'](){const _0x467a38=this['editor'][_0x34e3('0x3')][_0x34e3('0x2')][_0x34e3('0x7')],_0x56b682=this[_0x34e3('0x8')]['config'][_0x34e3('0x6')](_0x34e3('0xa'));for(const _0x2562e3 of _0x467a38[_0x34e3('0x5')]())for(const _0x4bb82d of _0x2562e3[_0x34e3('0xb')]())if(_0x4bb82d['is'](_0x34e3('0x9'))&&_0x56b682[_0x34e3('0x1')](_0x4bb82d['name']))return void(this[_0x34e3('0x0')]=!0x1);this[_0x34e3('0x0')]=!0x0;}['execute'](_0x49c74f='',_0x41faf0='',_0x1c3269=_0x34e3('0xc')){this[_0x34e3('0x8')][_0x34e3('0xd')]['get'](_0x23b8a8)[_0x34e3('0x4')](_0x49c74f,_0x41faf0,_0x1c3269);}}
@@ -1,9 +1,9 @@
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/utils/common-translations
7
- */
8
- import type { Locale } from 'ckeditor5/src/utils';
9
- export declare function getTranslation(locale: Locale, id: string, values?: string | Array<string> | number): string;
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/utils/common-translations
7
+ */
8
+ import type { Locale } from 'ckeditor5/src/utils';
9
+ export declare function getTranslation(locale: Locale, id: string, values?: string | Array<string> | number): string;
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- export function getTranslation(_0x3d8e36,_0x3cb3a2,_0x5fe0cd){const t=_0x3d8e36['t'];switch(_0x3cb3a2){case'Edit\x20or\x20review':return t('Edit\x20or\x20review');case'Improve\x20writing':return t('Improve\x20writing');case'Make\x20shorter':return t('Make\x20shorter');case'Make\x20longer':return t('Make\x20longer');case'Simplify\x20language':return t('Simplify\x20language');case'Generate\x20from\x20selection':return t('Generate\x20from\x20selection');case'Summarize':return t('Summarize');case'Continue':return t('Continue');case'Change\x20tone':return t('Change\x20tone');case'Professional':return t('Professional');case'Casual':return t('Casual');case'Direct':return t('Direct');case'Confident':return t('Confident');case'Friendly':return t('Friendly');case'Change\x20style':return t('Change\x20style');case'Business':return t('Business');case'Legal':return t('Legal');case'Journalism':return t('Journalism');case'Poetic':return t('Poetic');case'Translate':return t('Translate');case'Translate\x20to\x20%0':return t('Translate\x20to\x20%0',_0x5fe0cd);case'English':return t('English');case'Spanish':return t('Spanish');case'German':return t('German');case'Portuguese':return t('Portuguese');case'French':return t('French');case'Simplified\x20Chinese':return t('Simplified\x20Chinese');case'Hindi':return t('Hindi');case'Arabic':return t('Arabic');case'AI\x20Assistant':return t('AI\x20Assistant');case'AI\x20Commands':return t('AI\x20Commands');case'Ask\x20AI\x20to\x20edit\x20or\x20generate':return t('Ask\x20AI\x20to\x20edit\x20or\x20generate');case'Ask\x20AI\x20to\x20improve\x20generated\x20text':return t('Ask\x20AI\x20to\x20improve\x20generated\x20text');case'Copy':return t('Copy');case'Submit':return t('Submit');case'Insert\x20below':return t('Insert\x20below');case'Try\x20again':return t('Try\x20again');case'Stop':return t('Stop');case'AI\x20is\x20writing...':return t('AI\x20is\x20writing...');case'History':return t('History');case'Empty\x20history':return t('Empty\x20history');case'Ask\x20AI\x20and\x20your\x20prompts\x20will\x20be\x20listed\x20here\x20for\x20you\x20to\x20use\x20later.':return t('Ask\x20AI\x20and\x20your\x20prompts\x20will\x20be\x20listed\x20here\x20for\x20you\x20to\x20use\x20later.');case'Prompt\x20history':return t('Prompt\x20history');case'Search\x20AI\x20command':return t('Search\x20AI\x20command');case'No\x20commands\x20found':return t('No\x20commands\x20found');case'No\x20commands\x20available':return t('No\x20commands\x20available');case'Clear':return t('Clear');case'AI_REPLACE_CONTENT':return t({'id':'AI_REPLACE_CONTENT','string':'Replace'});case'AI_ERROR_AUTH_REQUEST':return t({'id':'AI_ERROR_AUTH_REQUEST','string':'Authorization\x20request\x20failed'});case'AI_ERROR_CONTEXT_LENGTH':return t({'id':'AI_ERROR_CONTEXT_LENGTH','string':'Selected\x20content\x20is\x20too\x20long'});case'AI_ERROR_MODERATION':return t({'id':'AI_ERROR_MODERATION','string':'Requested\x20query\x20does\x20not\x20pass\x20moderation\x20rules'});case'AI_ERROR_FAILED':return t({'id':'AI_ERROR_FAILED','string':'Failed\x20to\x20communicate\x20with\x20the\x20AI\x20service'});default:return'';}}
23
+ export function getTranslation(_0x28a569,_0x40dec0,_0x17b838){const t=_0x28a569['t'];switch(_0x40dec0){case'Edit\x20or\x20review':return t('Edit\x20or\x20review');case'Improve\x20writing':return t('Improve\x20writing');case'Make\x20shorter':return t('Make\x20shorter');case'Make\x20longer':return t('Make\x20longer');case'Simplify\x20language':return t('Simplify\x20language');case'Generate\x20from\x20selection':return t('Generate\x20from\x20selection');case'Summarize':return t('Summarize');case'Continue':return t('Continue');case'Change\x20tone':return t('Change\x20tone');case'Professional':return t('Professional');case'Casual':return t('Casual');case'Direct':return t('Direct');case'Confident':return t('Confident');case'Friendly':return t('Friendly');case'Change\x20style':return t('Change\x20style');case'Business':return t('Business');case'Legal':return t('Legal');case'Journalism':return t('Journalism');case'Poetic':return t('Poetic');case'Translate':return t('Translate');case'Translate\x20to\x20%0':return t('Translate\x20to\x20%0',_0x17b838);case'English':return t('English');case'Spanish':return t('Spanish');case'German':return t('German');case'Portuguese':return t('Portuguese');case'French':return t('French');case'Simplified\x20Chinese':return t('Simplified\x20Chinese');case'Hindi':return t('Hindi');case'Arabic':return t('Arabic');case'AI\x20Assistant':return t('AI\x20Assistant');case'AI\x20Commands':return t('AI\x20Commands');case'Ask\x20AI\x20to\x20edit\x20or\x20generate':return t('Ask\x20AI\x20to\x20edit\x20or\x20generate');case'Ask\x20AI\x20to\x20improve\x20generated\x20text':return t('Ask\x20AI\x20to\x20improve\x20generated\x20text');case'Copy':return t('Copy');case'Submit':return t('Submit');case'Insert\x20below':return t('Insert\x20below');case'Try\x20again':return t('Try\x20again');case'Stop':return t('Stop');case'AI\x20is\x20writing...':return t('AI\x20is\x20writing...');case'History':return t('History');case'Empty\x20history':return t('Empty\x20history');case'Ask\x20AI\x20and\x20your\x20prompts\x20will\x20be\x20listed\x20here\x20for\x20you\x20to\x20use\x20later.':return t('Ask\x20AI\x20and\x20your\x20prompts\x20will\x20be\x20listed\x20here\x20for\x20you\x20to\x20use\x20later.');case'Prompt\x20history':return t('Prompt\x20history');case'Search\x20AI\x20command':return t('Search\x20AI\x20command');case'No\x20commands\x20found':return t('No\x20commands\x20found');case'No\x20commands\x20available':return t('No\x20commands\x20available');case'Clear':return t('Clear');case'AI_REPLACE_CONTENT':return t({'id':'AI_REPLACE_CONTENT','string':'Replace'});case'AI_INSERT_CONTENT':return t({'id':'AI_INSERT_CONTENT','string':'Insert'});case'AI_ERROR_GET_HEADERS':return t({'id':'AI_ERROR_GET_HEADERS','string':'Preparing\x20request\x20headers\x20failed'});case'AI_ERROR_GET_PARAMETERS':return t({'id':'AI_ERROR_GET_PARAMETERS','string':'Preparing\x20request\x20parameters\x20failed'});case'AI_ERROR_UNSUPPORTED_MODEL':return t({'id':'AI_ERROR_UNSUPPORTED_MODEL','string':'The\x20requested\x20AI\x20model\x20(\x22%0\x22)\x20is\x20not\x20supported'},_0x17b838);case'AI_ERROR_CONTEXT_LENGTH':return t({'id':'AI_ERROR_CONTEXT_LENGTH','string':'Selected\x20content\x20is\x20too\x20long'});case'AI_ERROR_MODERATION':return t({'id':'AI_ERROR_MODERATION','string':'Requested\x20query\x20does\x20not\x20pass\x20moderation\x20rules'});case'AI_ERROR_FAILED':return t({'id':'AI_ERROR_FAILED','string':'Failed\x20to\x20communicate\x20with\x20the\x20AI\x20service'});default:return _0x40dec0;}}
package/theme/ai-form.css CHANGED
@@ -16,8 +16,7 @@
16
16
  --ck-ai-form-content-background: hsl(0, 0%, 98%);
17
17
  --ck-ai-form-history-font-size: .9em;
18
18
 
19
- /* TODO: Move this color to CKE5 */
20
- --ck-ai-form-error-background: hsl(0, 100%, 90%);
19
+ --ck-ai-form-error-background: var(--ck-color-light-red);
21
20
  }
22
21
 
23
22
  /* Note: This class name is mentioned in the guide and acts like a public API. */
@@ -64,10 +63,17 @@
64
63
  width: 100%;
65
64
  white-space: normal;
66
65
  padding: var(--ck-spacing-tiny) var(--ck-spacing-medium);
67
- padding-right: 0;
68
66
  min-height: calc( var(--ck-line-height-base) * var(--ck-font-size-base) );
69
67
  box-sizing: content-box;
70
68
 
69
+ @mixin ck-dir ltr {
70
+ padding-right: 0;
71
+ }
72
+
73
+ @mixin ck-dir rtl {
74
+ padding-left: 0;
75
+ }
76
+
71
77
  & > * {
72
78
  white-space: normal;
73
79
  color: inherit;
@@ -75,7 +81,14 @@
75
81
  }
76
82
 
77
83
  & .ck-spinner-container {
78
- margin-right: var(--ck-spacing-medium);
84
+ @mixin ck-dir ltr {
85
+ margin-right: var(--ck-spacing-medium);
86
+ }
87
+
88
+ @mixin ck-dir rtl {
89
+ margin-left: var(--ck-spacing-medium);
90
+ }
91
+
79
92
  }
80
93
 
81
94
  & .ck-ai-form__copy-button-wrapper {
@@ -126,14 +139,36 @@
126
139
  flex-grow: 1;
127
140
  }
128
141
 
129
- & > .ck.ck-button {
130
- margin-left: var(--ck-spacing-medium);
142
+ & > .ck.ck-ai-form__submit {
143
+ @mixin ck-dir ltr {
144
+ margin-left: var(--ck-spacing-medium);
145
+ }
146
+
147
+ @mixin ck-dir rtl {
148
+ margin-right: var(--ck-spacing-medium);
149
+ }
150
+
151
+ border-color: var(--ck-ai-form-submit-button-border-color);
152
+ color: var(--ck-ai-form-submit-button-text-color);
153
+
154
+ &.ck-disabled {
155
+ border-color: var(--ck-ai-form-submit-button-disabled-border-color);
156
+ }
131
157
  }
132
158
 
133
- & > .ck-labeled-field-view .ck-button {
159
+ /* Toggle history button */
160
+ & > .ck-labeled-field-view .ck-ai-form__toggle-history {
134
161
  position: absolute;
135
162
  font-size: var(--ck-font-size-tiny);
136
- right: var(--ck-spacing-medium);
163
+
164
+ @mixin ck-dir ltr {
165
+ right: var(--ck-spacing-medium);
166
+ }
167
+
168
+ @mixin ck-dir rtl {
169
+ left: var(--ck-spacing-medium);
170
+ }
171
+
137
172
  bottom: var(--ck-spacing-small);
138
173
  top: var(--ck-spacing-small);
139
174
  padding: 4px;
@@ -142,7 +177,14 @@
142
177
  }
143
178
 
144
179
  & .ck-textarea {
145
- padding-right: 30px;
180
+ /* Give the toggle history button some space */
181
+ @mixin ck-dir ltr {
182
+ padding-right: 30px;
183
+ }
184
+
185
+ @mixin ck-dir rtl {
186
+ padding-left: 30px;
187
+ }
146
188
  }
147
189
 
148
190
  /* Prompt history group */
@@ -166,9 +208,14 @@
166
208
  font-size: var(--ck-ai-form-history-font-size);
167
209
  justify-self: start;
168
210
  background: none;
211
+ margin: var(--ck-spacing-medium) 0 0;
212
+
213
+ & .ck-button__label {
214
+ line-height: inherit;
169
215
 
170
- &:hover .ck-button__label {
171
- text-decoration: underline;
216
+ &:hover {
217
+ text-decoration: underline;
218
+ }
172
219
  }
173
220
  }
174
221
 
package/theme/ai.css CHANGED
@@ -10,7 +10,15 @@
10
10
  /*
11
11
  * These definitions bring violet accents (tint) across the AI UI.
12
12
  */
13
- .ck-ai-assistant-ui {
13
+ :root {
14
+ --ck-ai-form-submit-button-text-color: var(--ck-color-text);
15
+ --ck-ai-form-submit-button-border-color: transparent;
16
+ --ck-ai-form-submit-button-disabled-border-color: transparent;
17
+ --ck-ai-toolbar-button-hover-color: var(--ck-color-text);
18
+ }
19
+
20
+ /* Note: This class name is mentioned in the guide and acts like a public API. */
21
+ .ck-ai-assistant-ui_theme {
14
22
  --ck-color-button-default-hover-background: hsl(262.1,100%,96.3%);
15
23
  --ck-color-button-default-active-background: hsl(262.1,100%,96.3%);
16
24
 
@@ -28,22 +36,19 @@
28
36
  --ck-color-list-button-hover-background: hsl(262.1,100%,96.3%);
29
37
 
30
38
  --ck-ai-form-content-background: hsl(0,0%,97.6%);
31
-
32
- & .ck-ai-form__submit {
33
- border-color: var(--ck-color-button-action-background);
34
- color: var(--ck-color-button-action-background);
35
-
36
- &.ck-disabled {
37
- border-color: var(--ck-color-button-action-disabled-background);
38
- }
39
- }
40
-
41
- &.ck-ai-commands-dropdown > .ck-button:hover,
42
- &.ck-ai-assistant-button:hover {
43
- color: var(--ck-color-button-on-color);
44
- }
39
+ --ck-ai-form-submit-button-text-color: var(--ck-color-button-on-color);
40
+ --ck-ai-form-submit-button-border-color: var(--ck-color-button-action-background);
41
+ --ck-ai-form-submit-button-disabled-border-color: var(--ck-color-button-action-disabled-background);
42
+ --ck-ai-toolbar-button-hover-color: var(--ck-color-button-on-color);
45
43
  }
46
44
 
45
+ /*
46
+ * Apply the theme colors for specific elements.
47
+ */
48
+ .ck-ai-commands-dropdown > .ck-button:hover,
49
+ .ck-ai-assistant-button:hover {
50
+ color: var(--ck-ai-toolbar-button-hover-color);
51
+ }
47
52
 
48
53
  /*
49
54
  * Classes used by the "fake visual selection" displayed in the content when an input
@@ -1,44 +0,0 @@
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
- import { Plugin, type Editor } from 'ckeditor5/src/core';
6
- /**
7
- * The AI handler plugin that is responsible for the whole communication with AI.
8
- * It uses the Adapter for OpenAI by default.
9
- */
10
- export default class AIConnector extends Plugin {
11
- /**
12
- * The adapter instance which is used to handle the communication with AI API.
13
- */
14
- adapter: Adapter;
15
- /**
16
- * @inheritDoc
17
- */
18
- static get pluginName(): "AIConnector";
19
- /**
20
- * @inheritDoc
21
- */
22
- constructor(editor: Editor);
23
- /**
24
- * Processes a user prompt and sends it to the AI API.
25
- *
26
- * @param prompt The user's prompt to be processed.
27
- * @param context The context on which the prompt is used.
28
- * @param onDataCallback The callback that is called after receiving content from AI API.
29
- * @returns A Promise that resolves with the AI-generated response.
30
- * @throws If sending the prompt to the AI API fails.
31
- */
32
- processPrompt(prompt: string, context: string, onDataCallback: (content: string) => any): Promise<void>;
33
- /**
34
- * The method that stops the current request and then recreates the abort controller instance.
35
- */
36
- abort(): void;
37
- }
38
- interface Adapter {
39
- sendPrompt(systemMessage: string, userMessage: string, abortSignal: AbortSignal, onDataCallback: (content: string) => any): Promise<void>;
40
- }
41
- export declare class AIRequestError extends Error {
42
- constructor(message: string);
43
- }
44
- export {};
@@ -1,23 +0,0 @@
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 _0x103a=['_cleanUpData','data:\x20','Instruction:\x0a','data','aiAssistant.requestParameters.model','Authorization','choices','user','match','aiconnector-send-prompt-failed','processor','aiAssistant.requestParameters.top_p','string','get','error','aiAssistant.requestParameters.max_tokens','authKey','_processStream','_domParser','content','body','reject','Bearer\x20','aiAssistant.requestParameters.temperature','aiAssistant.apiUrl','document','define','abort','adapter','toModel','startsWith','AI_ERROR_CONTEXT_LENGTH','text/html','filter','stringify','editing','top_p','join','processPrompt','_parseAndNormalizeContent','push','aborted','model','\x0aYou\x20must\x20keep\x20the\x20text\x20formatting.\x0a\x0aContent:\x0a','AIRequestError','https://api.openai.com/v1/chat/completions','Your\x20task\x20is\x20to\x20execute\x20the\x20instruction\x20using\x20the\x20provided\x20HTML\x20content.\x20Follow\x20the\x20instruction\x20closely.\x20Your\x20answer\x20must\x20be\x20a\x20properly\x20formatted\x20HTML\x20code.\x20Do\x20not\x20add\x20any\x20additional\x20remarks\x20or\x20notes.\x20Do\x20not\x20act\x20like\x20a\x20chatbot\x20or\x20a\x20real\x20person.','resolve','_authKey','serializeToString','_isBufferIncomplete','gpt-3.5-turbo','catch','<span>','AI_ERROR_MODERATION','toView','_apiUrl','length','includes','name','config','replace','_abortController','_requestParameters','parseFromString','_prepareMessages','[DONE]','_xmlSerializer','_normalizeResponseHeadings','signal','editor','aiAssistant.requestParameters','max_tokens','context_length_exceeded','split','getReader','AbortError','view','temperature','sendPrompt'];(function(_0x1ef6f4,_0x103aeb){const _0x214239=function(_0x50986a){while(--_0x50986a){_0x1ef6f4['push'](_0x1ef6f4['shift']());}};_0x214239(++_0x103aeb);}(_0x103a,0xe6));const _0x2142=function(_0x1ef6f4,_0x103aeb){_0x1ef6f4=_0x1ef6f4-0x0;let _0x214239=_0x103a[_0x1ef6f4];return _0x214239;};import{Matcher as _0x19670b,UpcastWriter as _0x5ea036}from'ckeditor5/src/engine';import{Plugin as _0x5dd575}from'ckeditor5/src/core';import{CKEditorError as _0x300097}from'ckeditor5/src/utils';import{getTranslation as _0x1e8118}from'./utils/common-translations';export default class o extends _0x5dd575{static get['pluginName'](){return'AIConnector';}constructor(_0x225eff){super(_0x225eff),_0x225eff[_0x2142('0x46')][_0x2142('0x24')](_0x2142('0x22'),_0x2142('0x37')),_0x225eff[_0x2142('0x46')][_0x2142('0x24')](_0x2142('0xe'),_0x2142('0x3d')),_0x225eff['config'][_0x2142('0x24')](_0x2142('0x19'),0x7d0),_0x225eff[_0x2142('0x46')][_0x2142('0x24')](_0x2142('0x21'),0x1),_0x225eff[_0x2142('0x46')]['define'](_0x2142('0x15'),0x1);const _0x46d1e2=_0x225eff[_0x2142('0x46')][_0x2142('0x17')](_0x2142('0x22')),_0x3b0781=_0x225eff['config'][_0x2142('0x17')]('aiAssistant')[_0x2142('0x1a')],_0x34da0=_0x225eff[_0x2142('0x46')][_0x2142('0x17')](_0x2142('0x1'));this[_0x2142('0x48')]=new AbortController(),this[_0x2142('0x26')]=new OpenAIAdapter(_0x225eff,_0x46d1e2,_0x34da0,_0x3b0781);}async[_0x2142('0x30')](_0x1388d7,_0x2deebb,_0x277f0f){const {systemMessage:_0xe954e4,userMessage:_0x197ede}=this[_0x2142('0x4b')](_0x1388d7,_0x2deebb);return this['adapter'][_0x2142('0x9')](_0xe954e4,_0x197ede,this[_0x2142('0x48')][_0x2142('0x4f')],_0x277f0f)[_0x2142('0x3e')](_0x4c14b1=>{if(_0x4c14b1 instanceof AIRequestError)return Promise[_0x2142('0x1f')](_0x4c14b1);if(_0x2142('0x6')==_0x4c14b1['name'])return Promise[_0x2142('0x39')]();throw console[_0x2142('0x18')](_0x4c14b1),new _0x300097(_0x2142('0x13'),null);});}[_0x2142('0x25')](){this[_0x2142('0x48')][_0x2142('0x4f')][_0x2142('0x33')]||(this[_0x2142('0x48')]['abort'](),this[_0x2142('0x48')]=new AbortController());}[_0x2142('0x4b')](_0x3d9883,_0x2c445c){let _0x23ceb6,_0x49f0ae;return _0x2c445c?(_0x23ceb6=_0x2142('0x38'),_0x49f0ae=_0x2142('0xc')+_0x3d9883+_0x2142('0x35')+(_0x2c445c[_0x2142('0x28')]('<')?_0x2c445c:_0x2142('0x3f')+_0x2c445c+'</span>')):(_0x23ceb6='Your\x20task\x20is\x20to\x20generate\x20HTML\x20content\x20accordingly\x20to\x20the\x20given\x20instruction.\x20Never\x20include\x20<img>\x20tag\x20in\x20your\x20response\x20even\x20if\x20asked\x20for.\x20Your\x20answer\x20must\x20be\x20a\x20well-structured\x20and\x20properly\x20formatted\x20HTML\x20code.\x20Answer\x20only\x20with\x20the\x20generated\x20HTML\x20content.\x20Do\x20not\x20add\x20any\x20additional\x20remarks\x20or\x20notes.\x20Do\x20not\x20act\x20like\x20a\x20chatbot\x20or\x20a\x20real\x20person.',_0x49f0ae=_0x3d9883),{'systemMessage':_0x23ceb6,'userMessage':_0x49f0ae};}}export class OpenAIAdapter{constructor(_0x50e370,_0x518e06,_0x1ac30d,_0x4da0ab){this[_0x2142('0x0')]=_0x50e370,this['_apiUrl']=_0x518e06,this[_0x2142('0x3a')]=_0x4da0ab,this[_0x2142('0x49')]=_0x1ac30d,this[_0x2142('0x1c')]=new DOMParser(),this[_0x2142('0x4d')]=new XMLSerializer();}async[_0x2142('0x9')](_0x52614e,_0x352a8a,_0x10a71e,_0x5c2f2f){const _0x2b2d8a=this[_0x2142('0x0')]['locale'],_0x1ea3dd={'Content-Type':'application/json'};if(_0x2142('0x16')==typeof this[_0x2142('0x3a')])_0x1ea3dd[_0x2142('0xf')]='Bearer\x20'+this[_0x2142('0x3a')];else{if(this[_0x2142('0x3a')])try{const _0x4d127f=await this['_authKey']();_0x1ea3dd['Authorization']=_0x2142('0x20')+_0x4d127f;}catch(_0x29cf4f){return Promise['reject'](new AIRequestError(_0x1e8118(_0x2b2d8a,'AI_ERROR_AUTH_REQUEST')));}}const _0x20a17e={'model':this[_0x2142('0x49')][_0x2142('0x34')],'messages':[{'role':'system','content':_0x52614e},{'role':_0x2142('0x11'),'content':_0x352a8a}],'stream':!0x0,'max_tokens':this[_0x2142('0x49')][_0x2142('0x2')],'temperature':this[_0x2142('0x49')][_0x2142('0x8')],'top_p':this['_requestParameters'][_0x2142('0x2e')]};this[_0x2142('0x49')][_0x2142('0x11')]&&(_0x20a17e['user']=this['_requestParameters'][_0x2142('0x11')]);const _0x5d3232={'method':'POST','headers':_0x1ea3dd,'body':JSON[_0x2142('0x2c')](_0x20a17e),'signal':_0x10a71e},_0x425b87=await fetch(this[_0x2142('0x42')],_0x5d3232);if(_0x425b87['ok']){const _0x4dd59a=_0x425b87[_0x2142('0x1e')];return await this[_0x2142('0x1b')](_0x4dd59a,_0x5c2f2f),Promise[_0x2142('0x39')]();}{const _0x3912e6=await _0x425b87['text']();return _0x3912e6['includes'](_0x2142('0x3'))?Promise[_0x2142('0x1f')](new AIRequestError(_0x1e8118(_0x2b2d8a,_0x2142('0x29')))):_0x3912e6[_0x2142('0x44')]('Moderation')?Promise[_0x2142('0x1f')](new AIRequestError(_0x1e8118(_0x2b2d8a,_0x2142('0x40')))):Promise[_0x2142('0x1f')](new Error(_0x3912e6));}}async[_0x2142('0x1b')](_0x2a9f17,_0x5a7ba4){const _0x73ddc4=_0x2a9f17[_0x2142('0x5')](),_0x1d695b=new TextDecoder();let _0x54fa8f='',_0x167187='',_0x3569ba='',_0x239610=!0x1;for(;!_0x239610;){const {done:_0x1f3520,value:_0xbd38c7}=await _0x73ddc4['read'](),_0xdb8720=_0x54fa8f+_0x1d695b['decode'](_0xbd38c7);let _0x21d4f2='';_0x239610=_0x1f3520;try{_0x21d4f2=this[_0x2142('0xa')](_0xdb8720),_0x54fa8f='';}catch(_0x433d4f){_0x54fa8f+=_0xdb8720;continue;}_0x167187+=_0x21d4f2,!_0x1f3520&&this[_0x2142('0x3c')](_0x167187)||_0x167187&&(_0x3569ba+=_0x167187,_0x5a7ba4(this[_0x2142('0x31')](_0x3569ba)),_0x167187='');}return Promise[_0x2142('0x39')]();}[_0x2142('0x3c')](_0xa0d9e8){const _0x5131c1=_0xa0d9e8[_0x2142('0x4')]('<')[_0x2142('0x43')]!==_0xa0d9e8[_0x2142('0x4')]('>')['length'],_0x43a494=_0xa0d9e8[_0x2142('0x43')]<0x1e;return _0x5131c1&&_0x43a494;}['_parseAndNormalizeContent'](_0x1f6bea){const _0x1abe00=this[_0x2142('0x1c')][_0x2142('0x4a')](_0x1f6bea,_0x2142('0x2a')),_0x5332ad=this[_0x2142('0x0')][_0x2142('0xd')][_0x2142('0x14')][_0x2142('0x41')](this[_0x2142('0x4d')][_0x2142('0x3b')](_0x1abe00['body']));return this[_0x2142('0x4e')](_0x5332ad),this['editor']['data'][_0x2142('0x2c')](this[_0x2142('0x0')][_0x2142('0xd')][_0x2142('0x27')](_0x5332ad));}[_0x2142('0x4e')](_0x271f94){const _0x37bdb3=new _0x5ea036(this[_0x2142('0x0')][_0x2142('0x2d')][_0x2142('0x7')][_0x2142('0x23')]),_0x440035=new _0x19670b({'name':/^h[1-5]$/}),_0x1f1228=[];let _0x349e7f=!0x1;for(const _0x104f4f of _0x271f94)_0x104f4f['is']('element')&&_0x440035[_0x2142('0x12')](_0x104f4f)&&(_0x1f1228[_0x2142('0x32')](_0x104f4f),'h1'==_0x104f4f[_0x2142('0x45')]&&(_0x349e7f=!0x0));if(_0x349e7f)for(const _0x203ad3 of _0x1f1228)_0x37bdb3['rename']('h'+(parseInt(_0x203ad3[_0x2142('0x45')][0x1])+0x1),_0x203ad3);}[_0x2142('0xa')](_0x1ac8d3){return _0x1ac8d3['split']('\x0a')['map'](_0x17ec5b=>_0x17ec5b[_0x2142('0x47')](_0x2142('0xb'),''))['filter'](_0x122c73=>_0x122c73&&_0x122c73[_0x2142('0x43')]>0x0&&_0x2142('0x4c')!==_0x122c73)['map'](_0x389cb3=>JSON['parse'](_0x389cb3)[_0x2142('0x10')][0x0]['delta'][_0x2142('0x1d')])[_0x2142('0x2b')](_0x114a60=>_0x114a60)[_0x2142('0x2f')]('');}}export class AIRequestError extends Error{constructor(_0x1d0aff){super(_0x1d0aff),this[_0x2142('0x45')]=_0x2142('0x36');}}