@ckeditor/ckeditor5-ai 0.0.0-nightly-20230927.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 +18 -0
- package/README.md +15 -0
- package/build/ai.js +4 -0
- package/ckeditor5-metadata.json +23 -0
- package/lang/contexts.json +43 -0
- package/package.json +43 -0
- package/src/aiassistant.d.ts +128 -0
- package/src/aiassistant.js +23 -0
- package/src/aiassistantediting.d.ts +44 -0
- package/src/aiassistantediting.js +23 -0
- package/src/aiassistantui.d.ts +41 -0
- package/src/aiassistantui.js +23 -0
- package/src/aiconnector.d.ts +40 -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 +59 -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/form/aiformcontentarea.d.ts +70 -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/aiformtextareaview.d.ts +31 -0
- package/src/ui/form/aiformtextareaview.js +23 -0
- package/src/ui/form/aiformtoolbarview.d.ts +41 -0
- package/src/ui/form/aiformtoolbarview.js +23 -0
- package/src/ui/form/aiformview.d.ts +125 -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/theme/ai-dropdown.css +37 -0
- package/theme/ai-form.css +201 -0
- package/theme/ai.css +96 -0
- package/theme/icons/copy.svg +1 -0
- package/theme/icons/error.svg +3 -0
- package/theme/icons/magic-wand.svg +7 -0
- package/theme/icons/robot-pencil.svg +9 -0
- package/theme/icons/submit.svg +3 -0
|
@@ -0,0 +1,70 @@
|
|
|
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/aiformcontentarea
|
|
7
|
+
*/
|
|
8
|
+
import { type Locale } from 'ckeditor5/src/utils';
|
|
9
|
+
import { View, ButtonView } from 'ckeditor5/src/ui';
|
|
10
|
+
/**
|
|
11
|
+
* A class representing the text area view of the AI assistant.
|
|
12
|
+
*/
|
|
13
|
+
export default class AIFormContentArea extends View {
|
|
14
|
+
/**
|
|
15
|
+
* The value which is displayed in the content field.
|
|
16
|
+
*
|
|
17
|
+
* @observable
|
|
18
|
+
*/
|
|
19
|
+
value: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Controls whether the content area is visible.
|
|
22
|
+
*
|
|
23
|
+
* @observable
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
isVisible: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Indicates if the content area is during processing which can change inner values.
|
|
29
|
+
*/
|
|
30
|
+
isProcessing: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The textarea view.
|
|
33
|
+
*/
|
|
34
|
+
contentFieldView: ContentFieldView;
|
|
35
|
+
/**
|
|
36
|
+
* The copy button displayed in the bottom-right corner of text area.
|
|
37
|
+
*/
|
|
38
|
+
copyButtonView: ButtonView;
|
|
39
|
+
/**
|
|
40
|
+
* @inheritDoc
|
|
41
|
+
*/
|
|
42
|
+
constructor(locale: Locale);
|
|
43
|
+
/**
|
|
44
|
+
* @inheritDoc
|
|
45
|
+
*/
|
|
46
|
+
render(): void;
|
|
47
|
+
focus(): void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A class representing the content field view of the AI assistant.
|
|
51
|
+
*/
|
|
52
|
+
declare class ContentFieldView extends View {
|
|
53
|
+
/**
|
|
54
|
+
* A loader view that get displayed while the response is processing.
|
|
55
|
+
*/
|
|
56
|
+
loaderView: View;
|
|
57
|
+
/**
|
|
58
|
+
* @inheritDoc
|
|
59
|
+
*/
|
|
60
|
+
constructor(locale: Locale);
|
|
61
|
+
/**
|
|
62
|
+
* Sets innerHTML of the content field.
|
|
63
|
+
*/
|
|
64
|
+
setContent(value: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Appends loader to the content field.
|
|
67
|
+
*/
|
|
68
|
+
appendLoader(): void;
|
|
69
|
+
}
|
|
70
|
+
export {};
|
|
@@ -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
|
+
import{global as _0x5bef67}from'ckeditor5/src/utils';import{View as _0x20de52,ButtonView as _0x4462b9,SpinnerView as _0x4860f6}from'ckeditor5/src/ui';import _0x447e26 from'../../../theme/icons/copy.svg';import{icons as _0x55342d}from'ckeditor5/src/core';export default class $ extends _0x20de52{constructor(_0x24e031){super(_0x24e031),this['set']({'value':null,'isVisible':!0x1,'isProcessing':!0x1});const _0x13d171=this['bindTemplate'];this['contentFieldView']=new j(_0x24e031),this['copyButtonView']=this['_createCopyButton'](),this['setTemplate']({'tag':'div','attributes':{'class':['ck','ck-ai-form__content-area-wrapper',_0x13d171['if']('isVisible','ck-hidden',_0x1e43dc=>!_0x1e43dc)],'tabindex':'-1'},'children':[{'tag':'div','attributes':{'class':['ck','ck-ai-form__content-area',_0x13d171['if']('isProcessing','ck-ai-form__content-area--processing')]},'children':[this['contentFieldView'],{'tag':'div','attributes':{'class':['ck','ck-ai-form__copy-button-wrapper']},'children':[this['copyButtonView']]}]}]});}['render'](){super['render'](),this['value']&&this['contentFieldView']['setContent'](this['value']),this['on']('change:value',(_0x264ad9,_0x3bf4ac,_0x54e1c1)=>{this['contentFieldView']['setContent'](_0x54e1c1),this['isProcessing']&&this['value']&&this['element']['scrollTo']({'top':this['element']['scrollHeight'],'behavior':'smooth'});}),this['on']('change:isProcessing',(_0x4b5476,_0x380249,_0x10a1d1)=>{_0x10a1d1?(this['value']=null,this['contentFieldView']['appendLoader']()):this['value']||this['contentFieldView']['setContent']('');});}['focus'](){this['element']['focus']();}['_createCopyButton'](){const t=this['locale']['t'],_0x2a655d=new _0x4462b9(this['locale']),_0x2fb9a1='ck-ai-form__copy-button';return _0x2a655d['set']({'label':t('Copy'),'icon':_0x447e26,'class':_0x2fb9a1,'tooltip':!0x0}),_0x2a655d['bind']('isVisible')['to'](this,'value',_0x405f12=>!!_0x405f12),_0x2a655d['bind']('isEnabled')['to'](this,'isProcessing',_0x402df2=>!_0x402df2),_0x2a655d['on']('execute',()=>{this['_copyHTMLToClipboard'](this['contentFieldView']['element']),_0x2a655d['icon']=_0x55342d['check'],_0x2a655d['class']=_0x2fb9a1+'\x20ck-ai-form__copy-button--copied',this['focus'](),setTimeout(()=>{_0x2a655d['icon']=_0x447e26,_0x2a655d['class']=_0x2fb9a1;},0x3e8);}),_0x2a655d;}['_copyHTMLToClipboard'](_0x325154){const {window:_0x34c5af,document:_0x42a71f}=_0x5bef67;if(_0x34c5af['ClipboardItem']){const {Blob:_0x4605cb,ClipboardItem:_0x213b17}=_0x34c5af,_0x195230=[new _0x213b17({'text/html':new _0x4605cb([_0x325154['innerHTML']],{'type':'text/html'}),'text/plain':new _0x4605cb([_0x325154['textContent']||''],{'type':'text/plain'})})];navigator['clipboard']['write'](_0x195230);}else{const _0x2f7e12=_0x42a71f['createElement']('div');_0x2f7e12['style']['position']='absolute',_0x2f7e12['style']['left']='-9999px',_0x2f7e12['innerHTML']=_0x325154['innerHTML'],_0x42a71f['body']['appendChild'](_0x2f7e12);const _0x1c9084=_0x42a71f['createRange']();_0x1c9084['selectNodeContents'](_0x2f7e12);const _0x4692c6=_0x34c5af['getSelection']();_0x4692c6['removeAllRanges'](),_0x4692c6['addRange'](_0x1c9084),_0x42a71f['execCommand']('copy'),_0x2f7e12['remove']();}}}class j extends _0x20de52{constructor(_0x21455c){super(_0x21455c),this['loaderView']=this['_createLoader'](),this['setTemplate']({'tag':'div','attributes':{'class':['ck','ck-content','ck-reset_all-excluded','ck-ai-form__content-field']}});}['setContent'](_0x5ad20a){this['element']['innerHTML']=_0x5ad20a;}['appendLoader'](){this['element']['appendChild'](this['loaderView']['element']);}['_createLoader'](){const _0x45c26a=new _0x20de52(),t=this['locale']['t'],_0x1a1ceb=new _0x4860f6();return _0x1a1ceb['isVisible']=!0x0,_0x45c26a['setTemplate']({'tag':'div','attributes':{'class':['ck','ck-ai-form__loader']},'children':[_0x1a1ceb,{'text':t('AI\x20is\x20writing...')}]}),_0x45c26a['render'](),_0x45c26a;}}
|
|
@@ -0,0 +1,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/aiformerrorview
|
|
7
|
+
*/
|
|
8
|
+
import type { Locale } from 'ckeditor5/src/utils';
|
|
9
|
+
import { View } from 'ckeditor5/src/ui';
|
|
10
|
+
/**
|
|
11
|
+
* A class representing the error view of the AI assistant.
|
|
12
|
+
*/
|
|
13
|
+
export default class AIFormErrorView extends View {
|
|
14
|
+
/**
|
|
15
|
+
* The text of the error.
|
|
16
|
+
*
|
|
17
|
+
* @observable
|
|
18
|
+
*/
|
|
19
|
+
text: string;
|
|
20
|
+
/**
|
|
21
|
+
* Creates an instance of the {@link module:ai/ui/aiformerrorview~AIFormErrorView} class.
|
|
22
|
+
*
|
|
23
|
+
* @param locale The localization services instance.
|
|
24
|
+
*/
|
|
25
|
+
constructor(locale: Locale, text?: string);
|
|
26
|
+
}
|
|
@@ -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 _0x4b3f=['bindTemplate','ck-ai-form__error','text','set'];(function(_0x5e5a4c,_0x4b3f1a){const _0x533689=function(_0x4da354){while(--_0x4da354){_0x5e5a4c['push'](_0x5e5a4c['shift']());}};_0x533689(++_0x4b3f1a);}(_0x4b3f,0x1f0));const _0x5336=function(_0x5e5a4c,_0x4b3f1a){_0x5e5a4c=_0x5e5a4c-0x0;let _0x533689=_0x4b3f[_0x5e5a4c];return _0x533689;};import{View as _0x3d5c99,IconView as _0xf4e854}from'ckeditor5/src/ui';import _0xaafe0e from'../../../theme/icons/error.svg';export default class D extends _0x3d5c99{constructor(_0x57273b,_0x5eebf4=''){super(_0x57273b);const _0x11c4bf=new _0xf4e854(),_0x5e827c=this[_0x5336('0x0')];this[_0x5336('0x3')]('text',_0x5eebf4),_0x11c4bf['content']=_0xaafe0e,this['setTemplate']({'tag':'div','attributes':{'class':['ck',_0x5336('0x1')]},'children':[_0x11c4bf,{'text':_0x5e827c['to'](_0x5336('0x2'))}]});}}
|
|
@@ -0,0 +1,46 @@
|
|
|
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/aiformpromptview
|
|
7
|
+
*/
|
|
8
|
+
import { type Locale } from 'ckeditor5/src/utils';
|
|
9
|
+
import { AutocompleteView, ButtonView, type TextareaView, type AutocompleteViewConfig } from 'ckeditor5/src/ui';
|
|
10
|
+
/**
|
|
11
|
+
* A textarea field allowing to ask AI.
|
|
12
|
+
*/
|
|
13
|
+
export default class AIFormPromptView extends AutocompleteView<TextareaView> {
|
|
14
|
+
/**
|
|
15
|
+
* The submit button view.
|
|
16
|
+
*/
|
|
17
|
+
submitButtonView: ButtonView;
|
|
18
|
+
/**
|
|
19
|
+
* The button that shows and hides the history autocomplete panel.
|
|
20
|
+
*/
|
|
21
|
+
showHistoryButtonView: ButtonView;
|
|
22
|
+
/**
|
|
23
|
+
* Creates `AIFormPromptView` instance.
|
|
24
|
+
*
|
|
25
|
+
* @param locale The localization services instance.
|
|
26
|
+
* @param value Initial textarea state.
|
|
27
|
+
*/
|
|
28
|
+
constructor(locale: Locale, config: AutocompleteViewConfig<TextareaView>);
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
render(): void;
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
*/
|
|
36
|
+
focus(direction?: 1 | -1): void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Fired when the query is submitted by the user.
|
|
40
|
+
*
|
|
41
|
+
* @eventName ~AIFormPromptView#submit
|
|
42
|
+
*/
|
|
43
|
+
export type AIFormPromptViewSubmitEvent = {
|
|
44
|
+
name: 'submit';
|
|
45
|
+
args: [query: string];
|
|
46
|
+
};
|
|
@@ -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
|
+
import{Rect as _0x39fa79,global as _0xac6598}from'ckeditor5/src/utils';import{AutocompleteView as _0x18aeca,ButtonView as _0x172436}from'ckeditor5/src/ui';import{icons as _0x3e5600}from'ckeditor5/src/core';import{escape as _0x547e65}from'lodash-es';import _0x208fec from'../../../theme/icons/submit.svg';export default class J extends _0x18aeca{constructor(_0x1a6a0f,_0x1fb943){super(_0x1a6a0f,_0x1fb943),this['queryView']['fieldView']['minRows']=0x1,this['queryView']['fieldView']['maxRows']=0x3,this['submitButtonView']=this['_createSubmitButton'](),this['showHistoryButtonView']=this['_createShowHistoryButton'](),this['focusableChildren']['add'](this['showHistoryButtonView'],0x1),this['focusableChildren']['add'](this['submitButtonView']);}['render'](){super['render'](),this['queryView']['fieldWrapperChildren']['add'](this['showHistoryButtonView']),this['children']['add'](this['submitButtonView']),this['keystrokes']['set']('enter',(_0x3a6612,_0x45f38a)=>{_0x3a6612['target']==this['queryView']['fieldView']['element']&&(this['submit'](),_0x45f38a());});}['_createSubmitButton'](){const _0x5aeb23=new _0x172436(this['locale']),t=this['locale']['t'];return _0x5aeb23['set']({'icon':_0x208fec,'label':t('Submit'),'isVisible':!0x0,'tooltip':!0x0,'class':'ck-ai-form__submit'}),_0x5aeb23['on']('execute',()=>{this['submit']();}),_0x5aeb23['bind']('isEnabled')['to'](this['queryView']['fieldView'],'isEmpty',this,'isEnabled',(_0x2be63e,_0x363289)=>!_0x2be63e&&_0x363289),_0x5aeb23;}['_createShowHistoryButton'](){const _0x4edd7c=new _0x172436(this['locale']),_0x552f61=this['resultsView'],t=this['locale']['t'];_0x4edd7c['set']({'label':t('History'),'withText':!0x1,'icon':_0x3e5600['history'],'tooltip':!0x0,'tooltipPosition':'sw','class':'ck-ai-form__toggle-history'}),_0x4edd7c['bind']('isOn')['to'](_0x552f61,'isVisible'),_0x4edd7c['on']('execute',()=>{_0x552f61['isVisible']=!_0x552f61['isVisible'],_0x552f61['isVisible']?this['filteredView']['focus']():this['focus']();});const _0x58d231=()=>{_0xac6598['window']['requestAnimationFrame'](()=>{const _0x47a855=new _0x39fa79(this['queryView']['fieldView']['element']),_0x3fdb40=_0x47a855['width'];_0x47a855['excludeScrollbarsAndBorders'](),_0x4edd7c['element']['style']['right']=_0x3fdb40-_0x47a855['width']+0x1+'px';});};return this['queryView']['fieldView']['on']('update',_0x58d231),this['on']('render',_0x58d231),_0x4edd7c;}['submit'](){const _0x4aba44=this['queryView']['fieldView']['element']['value'];this['fire']('submit',_0x547e65(_0x4aba44));}['focus'](_0x43a2b5){-0x1===_0x43a2b5?this['focusCycler']['focusLast']():this['focusCycler']['focusFirst']();}}
|
|
@@ -0,0 +1,31 @@
|
|
|
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/aiformtextareaview
|
|
7
|
+
*/
|
|
8
|
+
import type { Locale } from 'ckeditor5/src/utils';
|
|
9
|
+
import { LabeledFieldView, ButtonView, type TextareaView } from 'ckeditor5/src/ui';
|
|
10
|
+
/**
|
|
11
|
+
* A textarea field allowing to ask AI.
|
|
12
|
+
*
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
export default class AIFormTextareaView extends LabeledFieldView<TextareaView> {
|
|
16
|
+
/**
|
|
17
|
+
* The submit button view.
|
|
18
|
+
*/
|
|
19
|
+
submitButtonView: ButtonView;
|
|
20
|
+
/**
|
|
21
|
+
* Creates `AIFormTextareaView`.
|
|
22
|
+
*
|
|
23
|
+
* @param locale The localization services instance.
|
|
24
|
+
* @param value Initial textarea state.
|
|
25
|
+
*/
|
|
26
|
+
constructor(locale: Locale, value: string);
|
|
27
|
+
/**
|
|
28
|
+
* Resets the textarea value.
|
|
29
|
+
*/
|
|
30
|
+
reset(): void;
|
|
31
|
+
}
|
|
@@ -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
|
+
import{LabeledFieldView as _0x414d5b,createLabeledTextarea as _0x1fd240,ButtonView as _0x160a89}from'ckeditor5/src/ui';import _0x491501 from'../../../theme/icons/submit.svg';export default class Q extends _0x414d5b{constructor(_0x8cda34,_0x22cddc){super(_0x8cda34,_0x1fd240);const {t:t}=_0x8cda34;this['label']=t('Ask\x20AI'),this['fieldView']['value']=_0x22cddc,this['submitButtonView']=this['_createSubmitButton'](),this['fieldWrapperChildren']['add'](this['submitButtonView']);}['reset'](){this['fieldView']['reset']();}['_createSubmitButton'](){const _0x2e3089=new _0x160a89(this['locale']),t=this['locale']['t'];return _0x2e3089['set']({'icon':_0x491501,'label':t('Submit'),'isVisible':!0x0,'tooltip':!0x0}),_0x2e3089['on']('execute',()=>{this['fire']('submit',this['fieldView']['element']['value']);}),_0x2e3089['bind']('isEnabled')['to'](this['fieldView'],'isEmpty',this,'isEnabled',(_0x44bde6,_0x4e9340)=>!_0x44bde6&&_0x4e9340),_0x2e3089;}}
|
|
@@ -0,0 +1,41 @@
|
|
|
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/aiformtoolbarview
|
|
7
|
+
*/
|
|
8
|
+
import type { Locale } from 'ckeditor5/src/utils';
|
|
9
|
+
import { ToolbarView, ButtonView } from 'ckeditor5/src/ui';
|
|
10
|
+
/**
|
|
11
|
+
* A class representing the text area view of the AI assistant.
|
|
12
|
+
*/
|
|
13
|
+
export default class AIFormToolbarView extends ToolbarView {
|
|
14
|
+
/**
|
|
15
|
+
* Controls whether the toolbar is visible.
|
|
16
|
+
*
|
|
17
|
+
* @observable
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
isVisible: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Button that is used to replace the selected content by the generated one.
|
|
23
|
+
*/
|
|
24
|
+
replaceButton: ButtonView;
|
|
25
|
+
/**
|
|
26
|
+
* Button that is used to insert the generated content below the selection.
|
|
27
|
+
*/
|
|
28
|
+
insertButton: ButtonView;
|
|
29
|
+
/**
|
|
30
|
+
* Button that is used to regenerate the response.
|
|
31
|
+
*/
|
|
32
|
+
tryAgainButton: ButtonView;
|
|
33
|
+
/**
|
|
34
|
+
* Button that is used to stop the processing of the request.
|
|
35
|
+
*/
|
|
36
|
+
stopButton: ButtonView;
|
|
37
|
+
/**
|
|
38
|
+
* @inheritDoc
|
|
39
|
+
*/
|
|
40
|
+
constructor(locale: Locale);
|
|
41
|
+
}
|
|
@@ -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
|
+
import{ToolbarView as _0x1b9a3b,ButtonView as _0x2c71c4}from'ckeditor5/src/ui';export default class W extends _0x1b9a3b{constructor(_0x24e2d6){super(_0x24e2d6);const t=_0x24e2d6['t'];this['set']('isVisible',!0x1),this['replaceButton']=this['_createButton'](t('Replace'),'ck-button-action'),this['insertButton']=this['_createButton'](t('Insert\x20below')),this['tryAgainButton']=this['_createButton'](t('Try\x20again')),this['stopButton']=this['_createButton'](t('Stop'));const _0x1c2950=this['bindTemplate'];this['extendTemplate']({'attributes':{'class':['ck-ai-form__toolbar',_0x1c2950['if']('isVisible','ck-hidden',_0x55536e=>!_0x55536e)]}}),this['items']['addMany']([this['replaceButton'],this['insertButton'],this['tryAgainButton'],this['stopButton']]);}['_createButton'](_0x84df49,_0x2ddbee){const _0x3f2a56=new _0x2c71c4(this['locale']);return _0x3f2a56['set']({'label':_0x84df49,'class':_0x2ddbee||'','isVisible':!0x0,'withText':!0x0}),_0x3f2a56;}}
|
|
@@ -0,0 +1,125 @@
|
|
|
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/aiformview
|
|
7
|
+
*/
|
|
8
|
+
import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils';
|
|
9
|
+
import { View, FormHeaderView } from 'ckeditor5/src/ui';
|
|
10
|
+
import AIFormToolbarView from './aiformtoolbarview';
|
|
11
|
+
import AIFormContentArea from './aiformcontentarea';
|
|
12
|
+
import AIFormErrorView from './aiformerrorview';
|
|
13
|
+
import AIFormPromptView from './aiformpromptview';
|
|
14
|
+
/**
|
|
15
|
+
* A class representing the form view of the AI assistant.
|
|
16
|
+
*/
|
|
17
|
+
export default class AIFormView extends View {
|
|
18
|
+
/**
|
|
19
|
+
* Tracks information about the DOM focus in the form.
|
|
20
|
+
*
|
|
21
|
+
* @readonly
|
|
22
|
+
*/
|
|
23
|
+
focusTracker: FocusTracker;
|
|
24
|
+
/**
|
|
25
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
26
|
+
*
|
|
27
|
+
* @readonly
|
|
28
|
+
*/
|
|
29
|
+
keystrokes: KeystrokeHandler;
|
|
30
|
+
/**
|
|
31
|
+
* The view that represent the header of the form.
|
|
32
|
+
*/
|
|
33
|
+
header: FormHeaderView;
|
|
34
|
+
/**
|
|
35
|
+
* The text area view that is used to display AI response.
|
|
36
|
+
*/
|
|
37
|
+
contentArea: AIFormContentArea;
|
|
38
|
+
/**
|
|
39
|
+
* Toolbar view containing button views that manage the AI response and this form itself.
|
|
40
|
+
*/
|
|
41
|
+
toolbar: AIFormToolbarView;
|
|
42
|
+
/**
|
|
43
|
+
* The component used for handling the user's query, including history and submit buttons.
|
|
44
|
+
*/
|
|
45
|
+
promptView: AIFormPromptView;
|
|
46
|
+
/**
|
|
47
|
+
* View that is used to display the error message.
|
|
48
|
+
*/
|
|
49
|
+
errorView: AIFormErrorView;
|
|
50
|
+
/**
|
|
51
|
+
* The prompt text can be configured either during construction when the AI command has been selected,
|
|
52
|
+
* or later by submitting the {@link #labeledInput}, if it hasn't been previously initialized.
|
|
53
|
+
* After setting this value the AI request is triggered.
|
|
54
|
+
*/
|
|
55
|
+
prompt: string;
|
|
56
|
+
/**
|
|
57
|
+
* The value that is generated after user submitting the user prompt.
|
|
58
|
+
*/
|
|
59
|
+
value: string;
|
|
60
|
+
/**
|
|
61
|
+
* Indicates if the AI request is processing.
|
|
62
|
+
*/
|
|
63
|
+
isProcessing: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Indicates if the AI request failed.
|
|
66
|
+
*/
|
|
67
|
+
isError: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Creates an instance of the {@link module:ai/ui/aiformview~AIFormView} class.
|
|
70
|
+
*
|
|
71
|
+
* @param locale The localization services instance.
|
|
72
|
+
* @param prompt The text label of the prompt with which the form has been initialized.
|
|
73
|
+
*/
|
|
74
|
+
constructor(locale: Locale, prompt: string);
|
|
75
|
+
/**
|
|
76
|
+
* @inheritDoc
|
|
77
|
+
*/
|
|
78
|
+
render(): void;
|
|
79
|
+
focus(): void;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Fired when a user performed an action that should lead to replace the current selection by generated content.
|
|
83
|
+
*
|
|
84
|
+
* @eventName ~AIFormView#replaceContent
|
|
85
|
+
*/
|
|
86
|
+
export type ReplaceContentEvent = {
|
|
87
|
+
name: 'replaceContent';
|
|
88
|
+
args: [value: string];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Fired when a user performed an action that should lead to insert generated content below the current selection.
|
|
92
|
+
*
|
|
93
|
+
* @eventName ~AIFormView#insertContentBelow
|
|
94
|
+
*/
|
|
95
|
+
export type InsertContentBelowEvent = {
|
|
96
|
+
name: 'insertContentBelow';
|
|
97
|
+
args: [value: string];
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Fired when a user performed an action that should lead to retry the previous request to AI.
|
|
101
|
+
*
|
|
102
|
+
* @eventName ~AIFormView#tryAgainEvent
|
|
103
|
+
*/
|
|
104
|
+
export type TryAgainEvent = {
|
|
105
|
+
name: 'tryAgainEvent';
|
|
106
|
+
args: [];
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Fired when a user performed an action that should lead to stop the processing of AI.
|
|
110
|
+
*
|
|
111
|
+
* @eventName ~AIFormView#stopProcessing
|
|
112
|
+
*/
|
|
113
|
+
export type StopProcessingEvent = {
|
|
114
|
+
name: 'stopProcessing';
|
|
115
|
+
args: [];
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Fired when a user performed an action that should lead to ask AI.
|
|
119
|
+
*
|
|
120
|
+
* @eventName ~AIFormView#submitPrompt
|
|
121
|
+
*/
|
|
122
|
+
export type SubmitPromptEvent = {
|
|
123
|
+
name: 'submitPrompt';
|
|
124
|
+
args: [prompt: string];
|
|
125
|
+
};
|
|
@@ -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
|
+
import{FocusTracker as _0x29644f,KeystrokeHandler as _0x5dc465}from'ckeditor5/src/utils';import{View as _0x2ebb39,FocusCycler as _0x820836,createLabeledTextarea as _0x553002,FormHeaderView as tt}from'ckeditor5/src/ui';import _0x1acf25 from'./aiformtoolbarview';import _0x3b19b8 from'./aiformcontentarea';import _0x52288b from'./aiformerrorview';import _0x587150 from'./aiformpromptview';import it from'./aihistorylistview';import st from'./aihistorylistitemview';import et from'./prompthistory';import _0x35023b from'../../../theme/icons/robot-pencil.svg';export default class I extends _0x2ebb39{constructor(_0x4f0c96,_0x250f86){super(_0x4f0c96);const t=this['locale']['t'];this['set']('isProcessing',!0x1),this['set']('prompt',_0x250f86),this['set']('value',''),this['set']('isError',!0x1),this['_promptHistory']=new et(),this['errorView']=new _0x52288b(_0x4f0c96),this['header']=new tt(_0x4f0c96,{'label':t('AI\x20Assistant'),'icon':_0x35023b}),this['contentArea']=new _0x3b19b8(_0x4f0c96),this['contentArea']['bind']('isProcessing')['to'](this),this['contentArea']['bind']('value')['to'](this),this['toolbar']=this['_createToolbar'](),this['promptView']=this['_createPromptView'](),this['focusTracker']=new _0x29644f(),this['keystrokes']=new _0x5dc465(),this['_focusables']=this['createCollection']([this['contentArea'],this['contentArea']['copyButtonView'],this['toolbar'],this['promptView']]),this['_focusCycler']=new _0x820836({'focusables':this['_focusables'],'focusTracker':this['focusTracker'],'keystrokeHandler':this['keystrokes'],'actions':{'focusPrevious':'shift\x20+\x20tab','focusNext':'tab'}}),this['promptView']['focusCycler']['on']('forwardCycle',_0x2dc97b=>{this['_focusCycler']['focusNext'](),_0x2dc97b['stop']();}),this['promptView']['focusCycler']['on']('backwardCycle',_0x12c660=>{this['_focusCycler']['focusPrevious'](),_0x12c660['stop']();});const _0x222cdb=this['bindTemplate'];this['setTemplate']({'tag':'div','attributes':{'class':['ck','ck-ai-form','ck-ai-theme_violet'],'tabindex':'-1'},'children':[this['header'],{'tag':'div','attributes':{'class':['ck','ck-ai-form-content']},'children':[{'tag':'div','attributes':{'class':[_0x222cdb['if']('isError','ck-hidden',_0x2f0d09=>!_0x2f0d09)]},'children':[this['errorView']]},this['contentArea'],this['toolbar'],this['promptView']]}]});}['render'](){super['render'](),this['focusTracker']['add'](this['contentArea']['element']),this['focusTracker']['add'](this['contentArea']['copyButtonView']['element']),this['focusTracker']['add'](this['toolbar']['element']),this['focusTracker']['add'](this['promptView']['element']),this['keystrokes']['listenTo'](this['element']);}['focus'](){this['_focusCycler']['focusFirst']();}['_createPromptView'](){const t=this['locale']['t'],_0x3812f6=new _0x587150(this['locale'],{'queryView':{'label':t('Ask\x20AI\x20to\x20edit\x20or\x20generate'),'creator':_0x553002,'showIcon':!0x1,'showResetButton':!0x1},'infoView':{'text':{'noSearchableItems':{'primary':t('Empty\x20history'),'secondary':t('Ask\x20AI\x20and\x20your\x20prompts\x20will\x20be\x20listed\x20here\x20for\x20you\x20to\x20use\x20later.')}}},'filteredView':this['_createHistoryView'](),'queryMinChars':0x1/0x0,'resetOnBlur':!0x1});return _0x3812f6['bind']('isEnabled')['to'](this,'isProcessing',_0x3273fb=>!_0x3273fb),this['listenTo'](_0x3812f6,'submit',(_0x28cc6c,_0xe5f880)=>{this['prompt']=_0xe5f880,this['fire']('submitPrompt',this['prompt']),_0xe5f880['trim']()&&this['_promptHistory']['add']({'prompt':_0xe5f880['trim']()},0x0);},{'priority':'high'}),_0x3812f6;}['_createHistoryView'](){const _0x386289=new it(this['locale']);return _0x386289['historyGroupView']['items']['bindTo'](this['_promptHistory'])['as'](st),_0x386289['on']('clearHistory',()=>{this['_promptHistory']['clear'](),this['promptView']['search'](''),this['promptView']['focus']();}),_0x386289;}['_createToolbar'](){const _0x1e24f7=new _0x1acf25(this['locale']);return _0x1e24f7['replaceButton']['bind']('isEnabled')['to'](this,'isProcessing',this,'value',(_0x35dab5,_0x1e2a9b)=>!_0x35dab5&&!!_0x1e2a9b),_0x1e24f7['replaceButton']['on']('execute',()=>{this['fire']('replaceContent',this['value']);}),_0x1e24f7['insertButton']['bind']('isEnabled')['to'](this,'isProcessing',this,'value',(_0x5c3f4a,_0x185c82)=>!_0x5c3f4a&&!!_0x185c82),_0x1e24f7['insertButton']['on']('execute',()=>{this['fire']('insertContentBelow',this['value']);}),_0x1e24f7['tryAgainButton']['bind']('isEnabled')['to'](this,'isProcessing',_0x31ad40=>!_0x31ad40),_0x1e24f7['tryAgainButton']['on']('execute',()=>{this['fire']('tryAgainEvent');}),_0x1e24f7['stopButton']['bind']('isEnabled')['to'](this,'isProcessing'),_0x1e24f7['stopButton']['on']('execute',()=>{this['fire']('stopProcessing');}),_0x1e24f7;}['startProcessing'](){this['value']='',this['isError']=!0x1,this['isProcessing']=!0x0,this['contentArea']['isVisible']=!0x0,this['toolbar']['isVisible']=!0x0,this['contentArea']['focus']();}['finishProcessing'](){const t=this['locale']['t'];this['isProcessing']=!0x1,this['prompt']='',this['promptView']['reset'](),this['value']&&(this['promptView']['queryView']['label']=t('Ask\x20AI\x20to\x20improve\x20generated\x20text'));}['handleError'](){const t=this['locale']['t'];this['finishProcessing'](),this['isError']=!0x0,this['errorView']['text']=t('Failed\x20to\x20communicate\x20with\x20the\x20AI\x20service'),this['value']||(this['contentArea']['isVisible']=!0x1);}}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -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 _0x33e2=['locale','children','fire','prompt','execute','add'];(function(_0x48320e,_0x33e226){const _0x57d94c=function(_0x34f2d2){while(--_0x34f2d2){_0x48320e['push'](_0x48320e['shift']());}};_0x57d94c(++_0x33e226);}(_0x33e2,0x193));const _0x57d9=function(_0x48320e,_0x33e226){_0x48320e=_0x48320e-0x0;let _0x57d94c=_0x33e2[_0x48320e];return _0x57d94c;};import{ListItemView as _0x27eff0,ButtonView as _0x5e9dc1}from'ckeditor5/src/ui';import _0x1b0b17 from'../dropdown/buttonlabelwithhighlightview';import{unescape as _0x4dd625}from'lodash-es';export default class st extends _0x27eff0{constructor(_0x560be4){super();const _0x558cd6=new _0x1b0b17(),_0x508e0f=new _0x5e9dc1(this[_0x57d9('0x5')],_0x558cd6);this[_0x57d9('0x0')][_0x57d9('0x4')](_0x508e0f),_0x508e0f['set']({'label':_0x560be4[_0x57d9('0x2')],'withText':!0x0}),_0x508e0f['on'](_0x57d9('0x3'),()=>{this[_0x57d9('0x1')]('execute',{'value':_0x4dd625(_0x560be4[_0x57d9('0x2')])});});}}
|
|
@@ -0,0 +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
|
+
};
|
|
@@ -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
|
+
import{ListView as _0xd9a14d,ListItemGroupView as _0x25c369,ButtonView as _0x1d3ad4}from'ckeditor5/src/ui';export default class it extends _0xd9a14d{constructor(_0x14f536){super(_0x14f536);const t=_0x14f536['t'];this['clearHistoryButton']=this['_createClearHistoryButton'](),this['historyGroupView']=new _0x25c369(),this['historyGroupView']['children']['add'](this['clearHistoryButton'],0x1),this['historyGroupView']['label']=t('Prompt\x20history'),this['historyGroupView']['items']['delegate']('execute')['to'](this),this['items']['add'](this['historyGroupView']);}['filter'](){let _0x333e0f=0x0;for(const _0x215ff6 of this['items'])_0x333e0f+=_0x215ff6['items']['length'];return{'resultsCount':_0x333e0f,'totalItemsCount':_0x333e0f};}['_createClearHistoryButton'](){const t=this['locale']['t'],_0x1bcdbd=new _0x1d3ad4(this['locale']);return _0x1bcdbd['set']({'label':'('+t('Clear')+')','withText':!0x0}),_0x1bcdbd['on']('execute',()=>this['fire']('clearHistory')),_0x1bcdbd;}}
|
|
@@ -0,0 +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
|
+
};
|