@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
24 lines • 10.1 kB
JavaScript
/*
* 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. |
* | |
* | |
* +---------------------------------------------------------------------------------+
*
*
*
*
*/
function _0x3b2d(){const _0x476fa8=['18154Kstsvd','6784000NTNDNw','querySelector','5772208yhUdLr','div','endsWith','body','ai.assistant.preserveComments','editor','message','tryAgainEvent','_domParser','remove','text/html','_normalizeResponseHeadings','37oSuhHs','_parseAndNormalizeContent','catch','```','previousContext','makeRequest','5413940uYIYBc','reverse','stopListening','push','finally','custom','36bIfbLa','reset','htmlProcessor','markers','destroy','stopProcessing','get','data','clear','exec','_sanitizationContainer','once','abort','view','11671512ccPALB','ELEMENT_NODE','currentResponse','1556765aoWEWx','_isH1TagSupportEnabled','<h1></h1>','value','name','from','serializeToString','trim','_sanitizeHTML','innerHTML','processor','submitPrompt','prompt','element','length','_xmlSerializer','rename','11YswRns','handleError','render','substring','updateView','domConverter','match','startProcessing','finishProcessing','previousLabel','```html','nodeType','mainAction','document','set','childNodes','set:currentContext','toView','isRendered','setContentOf','config','_stripMarkdownSyntax','viewToDom','9ilmLYp','toModel','textAdapter','listenTo','6bZKETW','then','_handleQuery','startsWith','previousActionId','previousQuery','stringify','currentContext','editing','createElement','isProcessing','parseFromString','300708xfjaGD','initialContext'];_0x3b2d=function(){return _0x476fa8;};return _0x3b2d();}const _0x3b823e=_0x5456;function _0x5456(_0x55df1a,_0xee0c4b){const _0x3b2dc2=_0x3b2d();return _0x5456=function(_0x545625,_0x3b1141){_0x545625=_0x545625-0x183;let _0x4a57e5=_0x3b2dc2[_0x545625];return _0x4a57e5;},_0x5456(_0x55df1a,_0xee0c4b);}(function(_0x5b8a8a,_0x575c9a){const _0x5cc520=_0x5456,_0x41b8e3=_0x5b8a8a();while(!![]){try{const _0x413d4d=parseInt(_0x5cc520(0x1af))/0x1*(-parseInt(_0x5cc520(0x1a0))/0x2)+parseInt(_0x5cc520(0x19e))/0x3*(parseInt(_0x5cc520(0x1bb))/0x4)+-parseInt(_0x5cc520(0x1cc))/0x5*(-parseInt(_0x5cc520(0x192))/0x6)+-parseInt(_0x5cc520(0x1b5))/0x7+-parseInt(_0x5cc520(0x1a3))/0x8*(-parseInt(_0x5cc520(0x18e))/0x9)+parseInt(_0x5cc520(0x1a1))/0xa+parseInt(_0x5cc520(0x1dd))/0xb*(-parseInt(_0x5cc520(0x1c9))/0xc);if(_0x413d4d===_0x575c9a)break;else _0x41b8e3['push'](_0x41b8e3['shift']());}catch(_0x7c3bdb){_0x41b8e3['push'](_0x41b8e3['shift']());}}}(_0x3b2d,0x81c34));import{ObservableMixin as _0x91e3a6}from'ckeditor5/src/utils.js';import{AIRequestError as _0x371545}from'../adapters/aiadapter.js';import{Matcher as _0x23cca9,ViewUpcastWriter as _0x3d6c07}from'ckeditor5/src/engine.js';const ds=new RegExp(/^(.*?)<[a-zA-Z][a-zA-Z0-9_\-.]*[ >]/,'is');export class AIAssistantController extends/* #__PURE__ -- */
_0x91e3a6(){[_0x3b823e(0x1a8)];[_0x3b823e(0x190)];[_0x3b823e(0x1c8)];[_0x3b823e(0x1c5)];[_0x3b823e(0x1ab)];[_0x3b823e(0x1db)];constructor(_0x86f727,_0x3091aa,_0x2e8418){const _0x46d847=_0x3b823e;super(),this[_0x46d847(0x1a8)]=_0x86f727,this[_0x46d847(0x190)]=_0x3091aa,this[_0x46d847(0x1c5)]=document[_0x46d847(0x19b)](_0x46d847(0x1a4)),this[_0x46d847(0x1ab)]=new DOMParser(),this[_0x46d847(0x1db)]=new XMLSerializer(),this[_0x46d847(0x1c8)]=_0x2e8418,this[_0x46d847(0x185)]({'initialContext':'','currentContext':'','currentResponse':'','previousContext':void 0x0,'previousQuery':void 0x0,'previousLabel':void 0x0,'isProcessing':!0x1}),this['on'](_0x46d847(0x187),(_0x53fc96,_0x9cfabe,_0x14a570)=>{const _0x22e41c=_0x46d847;this[_0x22e41c(0x1c8)][_0x22e41c(0x1cf)]=this[_0x22e41c(0x1d4)](_0x14a570);}),this[_0x46d847(0x191)](this[_0x46d847(0x1c8)],_0x46d847(0x1d7),(_0x24ac52,_0x179104)=>{const _0x394f39=_0x46d847,_0x51d69a=this[_0x394f39(0x199)]||this[_0x394f39(0x19f)];this[_0x394f39(0x194)](_0x179104,_0x51d69a,_0x394f39(0x1ba));}),this[_0x46d847(0x191)](this[_0x46d847(0x1c8)],_0x46d847(0x1aa),()=>{const _0x47688d=_0x46d847;this[_0x47688d(0x1c8)][_0x47688d(0x1d8)]=this[_0x47688d(0x1e6)],this[_0x47688d(0x194)](this[_0x47688d(0x197)],this[_0x47688d(0x1b3)],this[_0x47688d(0x196)],this[_0x47688d(0x1e6)]);}),this[_0x46d847(0x191)](this[_0x46d847(0x1c8)],_0x46d847(0x1c0),()=>{const _0x157e79=_0x46d847;this[_0x157e79(0x1c0)]();});}[_0x3b823e(0x1bf)](){const _0x52ee9b=_0x3b823e;this[_0x52ee9b(0x1b7)]();}async[_0x3b823e(0x1e1)]({actionId:_0x38d98c,query:_0x5135d6,htmlContent:_0x1f550f,label:_0x40dcd4,mainActionLabel:_0x3c7d6b}){const _0x33571a=_0x3b823e;this[_0x33571a(0x1c8)][_0x33571a(0x1d8)]=_0x40dcd4,this[_0x33571a(0x1c8)][_0x33571a(0x183)]=_0x3c7d6b,this[_0x33571a(0x19f)]=_0x1f550f,_0x5135d6&&(this[_0x33571a(0x1c8)][_0x33571a(0x189)]?this[_0x33571a(0x194)](_0x5135d6,_0x1f550f,_0x38d98c,_0x40dcd4):this[_0x33571a(0x1c8)][_0x33571a(0x1c6)](_0x33571a(0x1df),()=>{const _0x1ff6bd=_0x33571a;this[_0x1ff6bd(0x194)](_0x5135d6,_0x1f550f,_0x38d98c,_0x40dcd4);}));}[_0x3b823e(0x1c0)](){const _0x10c41b=_0x3b823e;this[_0x10c41b(0x19c)]&&(this[_0x10c41b(0x19c)]=!0x1,this[_0x10c41b(0x1c8)][_0x10c41b(0x1e5)](),this[_0x10c41b(0x190)][_0x10c41b(0x1c7)]());}[_0x3b823e(0x1bc)](){const _0x9887=_0x3b823e;this[_0x9887(0x19f)]='',this[_0x9887(0x199)]='',this[_0x9887(0x1cb)]='',this[_0x9887(0x1b3)]='',this[_0x9887(0x197)]='',this[_0x9887(0x1e6)]='',this[_0x9887(0x196)]=void 0x0,this[_0x9887(0x1c8)][_0x9887(0x1bc)](),this[_0x9887(0x1c0)]();}async[_0x3b823e(0x194)](_0xca9aac,_0x4d7f9c,_0xb25b78,_0x4dc79a){const _0x1208bb=_0x3b823e;return this[_0x1208bb(0x19c)]=!0x0,this[_0x1208bb(0x1c8)][_0x1208bb(0x1e4)](),this[_0x1208bb(0x1b3)]=_0x4d7f9c,this[_0x1208bb(0x197)]=_0xca9aac,this[_0x1208bb(0x1e6)]=_0x4dc79a||_0xca9aac,this[_0x1208bb(0x196)]=_0xb25b78,new Promise(_0x57e4d6=>{const _0x3a6a00=_0x1208bb;this[_0x3a6a00(0x190)][_0x3a6a00(0x1b4)]({'query':_0xca9aac,'context':_0x4d7f9c,'onData':_0x53690e=>{const _0xc8e8a=_0x3a6a00;this[_0xc8e8a(0x1cb)]=_0x53690e,this[_0xc8e8a(0x199)]=this[_0xc8e8a(0x1b0)](this[_0xc8e8a(0x1cb)]);},'actionId':_0xb25b78})[_0x3a6a00(0x193)](()=>{const _0x59ea43=_0x3a6a00;!this[_0x59ea43(0x199)]&&this[_0x59ea43(0x1cb)]&&(this[_0x59ea43(0x199)]=this[_0x59ea43(0x1b0)](this[_0x59ea43(0x1cb)],!0x0));})[_0x3a6a00(0x1b1)](_0x3d5b34=>{const _0x4c68b2=_0x3a6a00;_0x3d5b34 instanceof _0x371545?this[_0x4c68b2(0x1c8)][_0x4c68b2(0x1de)](_0x3d5b34[_0x4c68b2(0x1a9)]):this[_0x4c68b2(0x1c8)][_0x4c68b2(0x1de)](),_0x57e4d6();})[_0x3a6a00(0x1b9)](()=>{const _0x48e934=_0x3a6a00;this[_0x48e934(0x1c0)](),_0x57e4d6();});});}[_0x3b823e(0x1b0)](_0x2d2a32,_0x3f1195=!0x1){const _0x357286=_0x3b823e,_0x535c62=ds[_0x357286(0x1c4)](_0x2d2a32);_0x2d2a32=_0x535c62?_0x2d2a32[_0x357286(0x1e0)](_0x535c62[0x1][_0x357286(0x1da)]):_0x2d2a32[_0x357286(0x1da)]<0x64&&!_0x3f1195?'':this[_0x357286(0x18c)](_0x2d2a32);const _0x5d405c=this[_0x357286(0x1ab)][_0x357286(0x19d)](_0x2d2a32,_0x357286(0x1ad));if(_0x535c62){const _0x5711b9=Array[_0x357286(0x1d1)](_0x5d405c[_0x357286(0x1a6)][_0x357286(0x186)]);_0x5711b9[_0x357286(0x1b6)]();for(const _0x3b79c8 of _0x5711b9){if(_0x3b79c8[_0x357286(0x1e8)]==Node[_0x357286(0x1ca)])break;_0x3b79c8[_0x357286(0x1ac)]();}}const _0x258a7d=this[_0x357286(0x1a8)][_0x357286(0x1c2)][_0x357286(0x1d6)][_0x357286(0x188)](this[_0x357286(0x1db)][_0x357286(0x1d2)](_0x5d405c[_0x357286(0x1a6)]));this[_0x357286(0x1cd)]()||this[_0x357286(0x1ae)](_0x258a7d);const _0x4064c3=this[_0x357286(0x1a8)][_0x357286(0x18b)][_0x357286(0x1c1)](_0x357286(0x1a7)),_0x2f8a52=this[_0x357286(0x1a8)][_0x357286(0x1c2)][_0x357286(0x18f)](_0x258a7d);return _0x4064c3||_0x2f8a52[_0x357286(0x1be)][_0x357286(0x1c3)](),this[_0x357286(0x1a8)][_0x357286(0x1c2)][_0x357286(0x198)](_0x2f8a52);}[_0x3b823e(0x1ae)](_0x4c3420){const _0x487cee=_0x3b823e,_0x40fcd5=new _0x3d6c07(this[_0x487cee(0x1a8)][_0x487cee(0x19a)][_0x487cee(0x1c8)][_0x487cee(0x184)]),_0x5c54e8=new _0x23cca9({'name':/^h[1-5]$/}),_0x40fe7c=[];let _0x3bb90c=!0x1;for(const _0x16d56a of _0x4c3420)_0x16d56a['is'](_0x487cee(0x1d9))&&_0x5c54e8[_0x487cee(0x1e3)](_0x16d56a)&&(_0x40fe7c[_0x487cee(0x1b8)](_0x16d56a),'h1'==_0x16d56a[_0x487cee(0x1d0)]&&(_0x3bb90c=!0x0));if(_0x3bb90c){for(const _0x318203 of _0x40fe7c)_0x40fcd5[_0x487cee(0x1dc)]('h'+(parseInt(_0x318203[_0x487cee(0x1d0)][0x1])+0x1),_0x318203);}}[_0x3b823e(0x1cd)](){const _0xff1efb=_0x3b823e,{data:_0x12d990,editing:_0x326dea}=this[_0xff1efb(0x1a8)],_0x2d51d1=_0x12d990[_0xff1efb(0x1bd)][_0xff1efb(0x188)](_0xff1efb(0x1ce)),_0xa59368=_0x12d990[_0xff1efb(0x188)](_0x12d990[_0xff1efb(0x18f)](_0x2d51d1));return!!_0x326dea[_0xff1efb(0x1c8)][_0xff1efb(0x1e2)][_0xff1efb(0x18d)](_0xa59368)[_0xff1efb(0x1a2)]('h1');}[_0x3b823e(0x1d4)](_0x445f1f){const _0x232f56=_0x3b823e;return this[_0x232f56(0x1a8)][_0x232f56(0x19a)][_0x232f56(0x1c8)][_0x232f56(0x1e2)][_0x232f56(0x18a)](this[_0x232f56(0x1c5)],_0x445f1f),this[_0x232f56(0x1c5)][_0x232f56(0x1d5)];}[_0x3b823e(0x18c)](_0xdaf0f5){const _0x2e4d4c=_0x3b823e,_0xb95fa6=_0xdaf0f5[_0x2e4d4c(0x1d3)]();return _0xb95fa6[_0x2e4d4c(0x195)](_0x2e4d4c(0x1e7))?_0xb95fa6[_0x2e4d4c(0x1a5)](_0x2e4d4c(0x1b2))?_0xb95fa6[_0x2e4d4c(0x1e0)](0x7,_0xb95fa6[_0x2e4d4c(0x1da)]-0x3):_0xb95fa6[_0x2e4d4c(0x1e0)](0x7):_0xdaf0f5;}}