UNPKG

@ckeditor/ckeditor5-ai

Version:

AI features for CKEditor 5.

23 lines • 12.4 kB
/* * Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved. * * * * * +---------------------------------------------------------------------------------+ * | | * | Hello stranger! | * | | * | | * | What you're currently looking at is the source code of a legally protected, | * | proprietary software. Any attempts to deobfuscate / disassemble this code | * | are forbidden and will result in legal consequences. | * | | * | | * +---------------------------------------------------------------------------------+ * * * * */ const _0x2efec0=_0x2e67;(function(_0xb4ccda,_0x121fe0){const _0x4769ca=_0x2e67,_0x33259a=_0xb4ccda();while(!![]){try{const _0x34bb76=-parseInt(_0x4769ca(0x96))/0x1+parseInt(_0x4769ca(0x9a))/0x2*(parseInt(_0x4769ca(0xa9))/0x3)+parseInt(_0x4769ca(0xab))/0x4+-parseInt(_0x4769ca(0xa6))/0x5+parseInt(_0x4769ca(0xce))/0x6+-parseInt(_0x4769ca(0xc5))/0x7+parseInt(_0x4769ca(0x9f))/0x8;if(_0x34bb76===_0x121fe0)break;else _0x33259a['push'](_0x33259a['shift']());}catch(_0x23af93){_0x33259a['push'](_0x33259a['shift']());}}}(_0x50e5,0x32345));import{CKEditorError as _0x514c9a,ObservableMixin as _0x5173d0,uid as _0x306a81}from'ckeditor5/src/utils.js';import{Element as _0x249503,findAll as _0x24fd16,getAttribute as _0x1fd1a5,getParents as _0x2f565b,Document as _0x657692,parse as _0x469195,Text as _0x111dc6}from'../utils/htmlparser.js';import{AIResponseParser as _0x4344c8}from'../pipeline/airesponseparser.js';function _0x50e5(){const _0x4d719a=['conversation-title','reasoning','unshift','splice','354640ZGfXrQ','parsedMergedContent','change:content','17211ctjbsC','removedNodeIds','569284odeFks','state','forEach','data-unstable','ai-get-editor-from-context-no-editor','stopListening','onContentChange','parseAndNormalizeHTML','_getCachedContentParts','_setCachedContentParts','filter','node','setChangeGroupState','new','length','updateChangeGroups','fire','appendContent','documentContextContent','content','values','destroy','isDone','merge','changes','replyContentUpdated','1105566FZcKYi','context','text-delta','newNodeIds','withoutDiff','index','find','removed','modification-delta','889422AaBsYh','locale','AI_SUGGESTION_CONTENT_PART_REMOVED','set','map','span','type','done','every','convertMarkdownToHTML','getContentParts','changeGroups','cloneNode','interactionId','aiResponseParser','modifiedNodeIds','source','previousSibling','push','color:\x20#808080;\x20font-style:\x20italic','aiResponseApplier','replyChangeGroupStateUpdated','cachedSuggestionContentParts','sources','includes','indexOf','data-id','ai-reply-get-content-parts-group-not-found','205251ThXRKS','_getDifferentChangeGroups','withDiff','areActionsDisabled','28jAUhFf','modified','web-search','editor','nextSibling','2151024OmdxbV','pending','parsedContent'];_0x50e5=function(){return _0x4d719a;};return _0x50e5();}import{AIResponseApplier as _0x610486}from'../pipeline/airesponseapplier.js';import{getSuggestionPartsFromReply as _0x137bf9}from'../utils/getsuggestionpartsfromreply.js';function _0x2e67(_0x476f92,_0x5579eb){const _0x50e5b8=_0x50e5();return _0x2e67=function(_0x2e6722,_0x53b786){_0x2e6722=_0x2e6722-0x7c;let _0x1c6a44=_0x50e5b8[_0x2e6722];return _0x1c6a44;},_0x2e67(_0x476f92,_0x5579eb);}import{getTranslation as _0x17af8e}from'../utils/common-translations.js';import{cloneDeep as _0x5cc09b}from'es-toolkit';export const AI_REPLY_TYPES=[_0x2efec0(0xcd),_0x2efec0(0xc7),_0x2efec0(0x9c),_0x2efec0(0xa3)];export const AI_REPLY_TYPES_IGNORED=[_0x2efec0(0xa2)];export const AI_REPLY_TITLE_TYPE=_0x2efec0(0xa2);export class AIReply extends _0x5173d0(){['id'];[_0x2efec0(0x87)];[_0x2efec0(0x80)];[_0x2efec0(0x91)]=[];[_0x2efec0(0xa1)]=new _0x657692([]);[_0x2efec0(0xa7)]=new _0x657692([]);[_0x2efec0(0x85)]=[];[_0x2efec0(0x99)]=!0x1;[_0x2efec0(0xbd)];[_0x2efec0(0x88)];[_0x2efec0(0x8e)];[_0x2efec0(0x9d)];[_0x2efec0(0x90)]={'withDiff':[],'withoutDiff':[]};constructor({type:_0x13a89c,content:_0x1e9c24='',isDone:_0x599102=!0x1,interactionId:_0x318e35,areActionsDisabled:_0x5ac397,documentContextContent:_0x29b5b5,editor:_0x17c513,id:_0xcc92b0}){const _0x173a10=_0x2efec0;super(),this['id']=_0xcc92b0||_0x306a81(),this[_0x173a10(0x87)]=_0x318e35,this[_0x173a10(0x80)]=_0x13a89c,this[_0x173a10(0x99)]=!!_0x5ac397,this[_0x173a10(0x9d)]=_0x17c513,this[_0x173a10(0x88)]=new _0x4344c8(),this[_0x173a10(0x8e)]=new _0x610486(),this[_0x173a10(0xbd)]=_0x469195(_0x29b5b5||''),this[_0x173a10(0x7d)](_0x173a10(0xc1),_0x599102),this['on'](_0x173a10(0xa8),()=>{const _0x46f2bf=_0x173a10;this[_0x46f2bf(0xb1)]();}),this[_0x173a10(0x7d)](_0x173a10(0xbe),_0x1e9c24);}[_0x2efec0(0xbc)](_0x1d0898){const _0x87a0b1=_0x2efec0;this[_0x87a0b1(0x7d)](_0x87a0b1(0xbe),this[_0x87a0b1(0xbe)]+_0x1d0898);}[_0x2efec0(0x81)](){const _0x3e36e5=_0x2efec0;this[_0x3e36e5(0xc1)]||(this[_0x3e36e5(0x7d)](_0x3e36e5(0xc1),!0x0),this[_0x3e36e5(0xb1)]());}[_0x2efec0(0xc0)](){const _0x56da92=_0x2efec0;this[_0x56da92(0xb0)]();}[_0x2efec0(0xb7)](_0x1a4770,_0x160a74){const _0x227334=_0x2efec0;this[_0x227334(0x85)][_0x1a4770][_0x227334(0xac)]=_0x160a74,this[_0x227334(0xbb)](_0x227334(0x8f),{'reply':this,'index':_0x1a4770,'state':_0x160a74});}[_0x2efec0(0x84)]({showDiff:_0xf02aa7,groupIndex:_0x117048}){const _0xead260=_0x2efec0;if(!this[_0xead260(0x9d)])throw new _0x514c9a(_0xead260(0xaf),null,{'aiReply':this});const _0xba6813=this[_0xead260(0xb3)](_0xf02aa7,_0x117048);if(_0xba6813)return _0xba6813;let _0x19baad=[];if(void 0x0===_0x117048)_0x19baad=this[_0xead260(0x85)];else{const _0x1414d9=this[_0xead260(0x85)][_0xead260(0xcb)](({index:_0x81f1d})=>_0x81f1d===_0x117048);if(!_0x1414d9)throw new _0x514c9a(_0xead260(0x95),null,{'aiReply':this,'groupIndex':_0x117048});_0x19baad=[_0x1414d9];}const _0x829740=_0x137bf9({'editor':this[_0xead260(0x9d)],'showDiff':_0xf02aa7,'changeGroups':_0x19baad,'documentContextContent':this[_0xead260(0xbd)]});return this[_0xead260(0xb4)](_0xf02aa7,_0x829740),_0x829740;}[_0x2efec0(0xb3)](_0x458db4,_0x2af408){const _0x355f3c=_0x2efec0,_0x6ff931=_0x458db4?_0x355f3c(0x98):_0x355f3c(0xc9);if(!this[_0x355f3c(0x90)][_0x6ff931][_0x355f3c(0xb9)])return null;const _0x1d0106=this[_0x355f3c(0x90)][_0x6ff931];if(void 0x0===_0x2af408)return _0x5cc09b(_0x1d0106);{const _0x30ae4d=_0x1d0106[_0x355f3c(0xcb)](({index:_0x507d73})=>_0x507d73===_0x2af408);if(_0x30ae4d)return[_0x5cc09b(_0x30ae4d)];}return null;}[_0x2efec0(0xb4)](_0xeaacbf,_0x476672){const _0x5b60d1=_0x2efec0,_0x544f95=_0xeaacbf?_0x5b60d1(0x98):_0x5b60d1(0xc9);_0x476672[_0x5b60d1(0xad)](_0x1622ee=>{const _0x523918=_0x5b60d1,_0x1c1684=this[_0x523918(0x90)][_0x544f95],_0x4ad9e3=_0x1c1684[_0x523918(0xcb)](({index:_0x37a661})=>_0x37a661===_0x1622ee[_0x523918(0xca)]);if(_0x4ad9e3){const _0x3b2f2f=_0x1c1684[_0x523918(0x93)](_0x4ad9e3);_0x1c1684[_0x523918(0xa5)](_0x3b2f2f,0x1,_0x1622ee);}else _0x1c1684[_0x523918(0x8c)](_0x1622ee);});}[_0x2efec0(0xb1)](){const _0x2325e8=_0x2efec0;if(_0x2325e8(0xcd)===this[_0x2325e8(0x80)]){this[_0x2325e8(0xa1)]=this[_0x2325e8(0x88)][_0x2325e8(0xb2)](this[_0x2325e8(0xbe)]);const _0x1d6889=this[_0x2325e8(0x85)];this[_0x2325e8(0xba)]();const _0x131b84=this[_0x2325e8(0x97)](_0x1d6889,this[_0x2325e8(0x85)]);(_0x131b84[_0x2325e8(0xb9)]||this[_0x2325e8(0xc1)])&&(this[_0x2325e8(0xbb)](_0x2325e8(0xc4),this,_0x131b84),this[_0x2325e8(0x90)][_0x2325e8(0x98)][_0x2325e8(0xb9)]=this[_0x2325e8(0x90)][_0x2325e8(0xc9)][_0x2325e8(0xb9)]=0x0);}else this[_0x2325e8(0xa1)]=this[_0x2325e8(0x88)][_0x2325e8(0x83)](this[_0x2325e8(0xbe)]),this[_0x2325e8(0xbb)](_0x2325e8(0xc4),this);}[_0x2efec0(0x97)](_0x2d0637,_0x536c69){const _0x80d97=_0x2efec0,_0x2856fe=[];for(const _0xc0fc50 of _0x536c69){const _0x48c6b8=_0x2d0637[_0xc0fc50[_0x80d97(0xca)]];_0x48c6b8?_0x48c6b8[_0x80d97(0xc3)][_0x80d97(0xb9)]!==_0xc0fc50[_0x80d97(0xc3)][_0x80d97(0xb9)]?_0x2856fe[_0x80d97(0x8c)](_0xc0fc50):_0x48c6b8[_0x80d97(0xc3)][_0x80d97(0xad)]((_0x31a620,_0x488418)=>{const _0x42aa57=_0x80d97,_0x1ba14a=_0xc0fc50[_0x42aa57(0xc3)][_0x488418];_0x31a620['id']!==_0x1ba14a['id']&&_0x2856fe[_0x42aa57(0x8c)](_0xc0fc50);}):_0x2856fe[_0x80d97(0x8c)](_0xc0fc50);}return _0x2856fe;}[_0x2efec0(0xba)](){const _0x3dc3f3=_0x2efec0,_0x3535e9=new _0x249503('p',{},[new _0x249503(_0x3dc3f3(0x7f),{'style':_0x3dc3f3(0x8d)},[new _0x111dc6(_0x17af8e(this[_0x3dc3f3(0x9d)][_0x3dc3f3(0xcf)],_0x3dc3f3(0x7c)))])]),_0xd3e4b1=this[_0x3dc3f3(0x8e)][_0x3dc3f3(0xc2)](this[_0x3dc3f3(0xa1)],this[_0x3dc3f3(0xbd)][_0x3dc3f3(0x86)](!0x0),{'markUnstableElements':!this[_0x3dc3f3(0xc1)],'replaceRemovedWith':_0x3535e9,'cutAfterLastChange':!this[_0x3dc3f3(0xc1)]});if(!_0xd3e4b1[_0x3dc3f3(0x89)][_0x3dc3f3(0xb9)]&&!this[_0x3dc3f3(0xc1)])return;this[_0x3dc3f3(0xa7)]=_0xd3e4b1[_0x3dc3f3(0xa1)];let _0x58e0f0=[];if(_0x24fd16(_0x43378b=>{const _0x2e6d0c=_0x3dc3f3,_0x4f15a9=_0x1fd1a5(_0x43378b,_0x2e6d0c(0x94));if(!_0x4f15a9||!_0x2cee9b(_0x4f15a9))return!0x1;const _0x6637b4=[_0x43378b,..._0x2f565b(_0x43378b)]['at'](-0x2);if(_0x43378b!=_0x6637b4){const _0x22d6c2=_0x1fd1a5(_0x6637b4,_0x2e6d0c(0x94));_0x2cee9b(_0x22d6c2)||(_0x58e0f0[_0x2e6d0c(0x8c)]({'node':_0x6637b4,'id':_0x22d6c2,'type':_0x2e6d0c(0x9b)}),_0xd3e4b1[_0x2e6d0c(0x89)][_0x2e6d0c(0x8c)](_0x22d6c2));}else _0xd3e4b1[_0x2e6d0c(0x89)][_0x2e6d0c(0x92)](_0x4f15a9)?_0x58e0f0[_0x2e6d0c(0x8c)]({'node':_0x43378b,'type':_0x2e6d0c(0x9b),'id':_0x4f15a9}):_0xd3e4b1[_0x2e6d0c(0xc8)][_0x2e6d0c(0x92)](_0x4f15a9)?_0x58e0f0[_0x2e6d0c(0x8c)]({'node':_0x43378b,'type':_0x2e6d0c(0xb8),'id':_0x4f15a9,'anchorId':_0x1fd1a5(_0x43378b[_0x2e6d0c(0x8b)],_0x2e6d0c(0x94))}):_0x58e0f0[_0x2e6d0c(0x8c)]({'node':_0x43378b,'type':_0x2e6d0c(0xcc),'id':_0x4f15a9});return!0x0;},this[_0x3dc3f3(0xa7)]),_0x58e0f0=_0x58e0f0[_0x3dc3f3(0xb5)](({node:_0x5ef3f3})=>[..._0x2f565b(_0x5ef3f3),_0x5ef3f3][_0x3dc3f3(0x82)](_0x16efd7=>!_0x1fd1a5(_0x16efd7,_0x3dc3f3(0xae)))),0x0==_0x58e0f0[_0x3dc3f3(0xb9)])return;const _0x1169e3=[[_0x58e0f0[0x0]]];for(let _0xba2edf=0x1;_0xba2edf<_0x58e0f0[_0x3dc3f3(0xb9)];_0xba2edf++){const _0x3dca48=_0x1169e3[_0x1169e3[_0x3dc3f3(0xb9)]-0x1],_0x537a2c=_0x3dca48[_0x3dca48[_0x3dc3f3(0xb9)]-0x1];_0x58e0f0[_0xba2edf][_0x3dc3f3(0xb6)][_0x3dc3f3(0x8b)]==_0x537a2c[_0x3dc3f3(0xb6)]&&_0x3dc3f3(0x9b)!=_0x58e0f0[_0xba2edf][_0x3dc3f3(0x80)]&&_0x3dc3f3(0x9b)!=_0x537a2c[_0x3dc3f3(0x80)]?_0x3dca48[_0x3dc3f3(0x8c)](_0x58e0f0[_0xba2edf]):_0x1169e3[_0x3dc3f3(0x8c)]([_0x58e0f0[_0xba2edf]]);}for(const _0x16638a of _0x1169e3){const _0x23b3a6=_0x16638a[0x0],_0xf0a44a=_0x16638a[_0x16638a[_0x3dc3f3(0xb9)]-0x1],_0x1a5e3b=_0x3e05c2(_0x23b3a6[_0x3dc3f3(0xb6)][_0x3dc3f3(0x8b)]);_0x1a5e3b&&_0x16638a[_0x3dc3f3(0xa4)](_0x1a5e3b);const _0x4eb843=_0x3e05c2(_0xf0a44a[_0x3dc3f3(0xb6)][_0x3dc3f3(0x9e)]);_0x4eb843&&_0x16638a[_0x3dc3f3(0x8c)](_0x4eb843);}function _0x2cee9b(_0x31166f){const _0x283801=_0x3dc3f3;return _0xd3e4b1[_0x283801(0x89)][_0x283801(0x92)](_0x31166f)||_0xd3e4b1[_0x283801(0xc8)][_0x283801(0x92)](_0x31166f)||_0xd3e4b1[_0x283801(0xaa)][_0x283801(0x92)](_0x31166f);}function _0x3e05c2(_0x172ca6){const _0x4c3f31=_0x3dc3f3;if(_0x172ca6&&_0x1fd1a5(_0x172ca6,_0x4c3f31(0x94))&&!_0x1fd1a5(_0x172ca6,_0x4c3f31(0xae))){const _0x1e402a=_0x1fd1a5(_0x172ca6,_0x4c3f31(0x94));if(!_0x2cee9b(_0x1e402a))return{'node':_0x172ca6,'type':_0x4c3f31(0xc6),'id':_0x1e402a};}return null;}this[_0x3dc3f3(0x85)]=_0x1169e3[_0x3dc3f3(0x7e)]((_0x51ac5f,_0x1b80cb)=>({'changes':_0x51ac5f,'state':_0x3dc3f3(0xa0),'index':_0x1b80cb}));}}export function isValidReplyType(_0x1b2b68){const _0x16b911=_0x2efec0;return Object[_0x16b911(0xbf)](AI_REPLY_TYPES)[_0x16b911(0x92)](_0x1b2b68);}export function isIgnoredReplyType(_0x521bc2){const _0x293c5e=_0x2efec0;return AI_REPLY_TYPES_IGNORED[_0x293c5e(0x92)](_0x521bc2);}export function isReplyTitleType(_0x15932e){return _0x15932e===AI_REPLY_TITLE_TYPE;}export function isSourceType(_0x2a88a0){const _0x1dc28f=_0x2efec0;return _0x1dc28f(0x8a)===_0x2a88a0;}