@ckeditor/ckeditor5-ai
Version:
AI Assistant feature for CKEditor 5.
24 lines • 10.2 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. |
* | |
* | |
* +---------------------------------------------------------------------------------+
*
*
*
*
*/
const _0x56bb89=_0x9cf7;function _0x9cf7(_0x3b5fe1,_0x5c4913){const _0x52d368=_0x52d3();return _0x9cf7=function(_0x9cf7d9,_0x13e73b){_0x9cf7d9=_0x9cf7d9-0x12c;let _0x15069f=_0x52d368[_0x9cf7d9];return _0x15069f;},_0x9cf7(_0x3b5fe1,_0x5c4913);}(function(_0x5294cd,_0x275376){const _0x33cae8=_0x9cf7,_0xbb14d=_0x5294cd();while(!![]){try{const _0x47312c=parseInt(_0x33cae8(0x17c))/0x1*(parseInt(_0x33cae8(0x183))/0x2)+-parseInt(_0x33cae8(0x141))/0x3*(-parseInt(_0x33cae8(0x131))/0x4)+-parseInt(_0x33cae8(0x163))/0x5*(-parseInt(_0x33cae8(0x13f))/0x6)+-parseInt(_0x33cae8(0x13b))/0x7+parseInt(_0x33cae8(0x138))/0x8*(-parseInt(_0x33cae8(0x160))/0x9)+-parseInt(_0x33cae8(0x13a))/0xa*(parseInt(_0x33cae8(0x171))/0xb)+-parseInt(_0x33cae8(0x185))/0xc*(-parseInt(_0x33cae8(0x187))/0xd);if(_0x47312c===_0x275376)break;else _0xbb14d['push'](_0xbb14d['shift']());}catch(_0x5c32be){_0xbb14d['push'](_0xbb14d['shift']());}}}(_0x52d3,0x96ce8));import{ObservableMixin as _0x1a62b3}from'ckeditor5/src/utils.js';import{AIRequestError as _0x14d9b0}from'../adapters/aiadapter.js';import{Matcher as _0x334eac,UpcastWriter as _0x4a1637}from'ckeditor5/src/engine.js';function _0x52d3(){const _0x29dc17=['1242340JuEyQt','3207862CfOmvZ','_handleQuery','startsWith','custom','3558vzcnFG','then','18GmdBnB','remove','```html','_parseAndNormalizeContent','finally','textAdapter','editor','element','updateView','serializeToString','from','render','get','rename','_stripMarkdownSyntax','setContentOf','isRendered','_xmlSerializer','prompt','exec','stopProcessing','editing','match','endsWith','submitPrompt','_isH1TagSupportEnabled','previousContext','processor','message','currentContext','querySelector','4532454XdoBYJ','previousActionId','set:currentContext','2865YOhovS','trim','abort','length','nodeType','document','ELEMENT_NODE','view','config','reset','value','_domParser','div','once','55mRBlvg','data','toView','```','catch','innerHTML','tryAgainEvent','stringify','body','viewToDom','startProcessing','14537uAXbvq','set','reverse','htmlProcessor','parseFromString','_sanitizationContainer','push','30nZikks','markers','3393864YbqgUl','toModel','39TkKXHN','makeRequest','substring','childNodes','finishProcessing','currentResponse','clear','ai.aiAssistant.preserveComments','isProcessing','_sanitizeHTML','name','_normalizeResponseHeadings','<h1></h1>','createElement','stopListening','previousLabel','initialContext','529624HZatdE','domConverter','destroy','listenTo','text/html','previousQuery','mainAction','8CykRec','handleError'];_0x52d3=function(){return _0x29dc17;};return _0x52d3();}const Z=new RegExp(/^(.*?)<[a-zA-Z][a-zA-Z0-9_\-.]*[ >]/,'is');export default class k extends/* #__PURE__ -- */
_0x1a62b3(){[_0x56bb89(0x147)];[_0x56bb89(0x146)];[_0x56bb89(0x16a)];[_0x56bb89(0x181)];[_0x56bb89(0x16e)];[_0x56bb89(0x152)];constructor(_0x2ae8cd,_0x3a2881,_0xe711ca){const _0x5eea5b=_0x56bb89;super(),this[_0x5eea5b(0x147)]=_0x2ae8cd,this[_0x5eea5b(0x146)]=_0x3a2881,this[_0x5eea5b(0x181)]=document[_0x5eea5b(0x12d)](_0x5eea5b(0x16f)),this[_0x5eea5b(0x16e)]=new DOMParser(),this[_0x5eea5b(0x152)]=new XMLSerializer(),this[_0x5eea5b(0x16a)]=_0xe711ca,this[_0x5eea5b(0x17d)]({'initialContext':'','currentContext':'','currentResponse':'','previousContext':void 0x0,'previousQuery':void 0x0,'previousLabel':void 0x0,'isProcessing':!0x1}),this['on'](_0x5eea5b(0x162),(_0x506b61,_0x5504af,_0x524ca4)=>{const _0x365bac=_0x5eea5b;this[_0x365bac(0x16a)][_0x365bac(0x16d)]=this[_0x365bac(0x190)](_0x524ca4);}),this[_0x5eea5b(0x134)](this[_0x5eea5b(0x16a)],_0x5eea5b(0x159),(_0x19afba,_0x16becd)=>{const _0x1187b4=_0x5eea5b,_0x42de1b=this[_0x1187b4(0x15e)]||this[_0x1187b4(0x130)];this[_0x1187b4(0x13c)](_0x16becd,_0x42de1b,_0x1187b4(0x13e));}),this[_0x5eea5b(0x134)](this[_0x5eea5b(0x16a)],_0x5eea5b(0x177),()=>{const _0x547268=_0x5eea5b;this[_0x547268(0x16a)][_0x547268(0x153)]=this[_0x547268(0x12f)],this[_0x547268(0x13c)](this[_0x547268(0x136)],this[_0x547268(0x15b)],this[_0x547268(0x161)],this[_0x547268(0x12f)]);}),this[_0x5eea5b(0x134)](this[_0x5eea5b(0x16a)],_0x5eea5b(0x155),()=>{const _0x2d3b5c=_0x5eea5b;this[_0x2d3b5c(0x155)]();});}[_0x56bb89(0x133)](){const _0x19ba17=_0x56bb89;this[_0x19ba17(0x12e)]();}async[_0x56bb89(0x149)]({actionId:_0x1d298f,query:_0x5c57ce,htmlContent:_0x4a5e36,label:_0x37acfd,mainActionLabel:_0x39d788}){const _0x4d8fc9=_0x56bb89;this[_0x4d8fc9(0x16a)][_0x4d8fc9(0x153)]=_0x37acfd,this[_0x4d8fc9(0x16a)][_0x4d8fc9(0x137)]=_0x39d788,this[_0x4d8fc9(0x130)]=_0x4a5e36,_0x5c57ce&&(this[_0x4d8fc9(0x16a)][_0x4d8fc9(0x151)]?this[_0x4d8fc9(0x13c)](_0x5c57ce,_0x4a5e36,_0x1d298f,_0x37acfd):this[_0x4d8fc9(0x16a)][_0x4d8fc9(0x170)](_0x4d8fc9(0x14c),()=>{const _0x2a4f0c=_0x4d8fc9;this[_0x2a4f0c(0x13c)](_0x5c57ce,_0x4a5e36,_0x1d298f,_0x37acfd);}));}[_0x56bb89(0x155)](){const _0x1bbcff=_0x56bb89;this[_0x1bbcff(0x18f)]&&(this[_0x1bbcff(0x18f)]=!0x1,this[_0x1bbcff(0x16a)][_0x1bbcff(0x18b)](),this[_0x1bbcff(0x146)][_0x1bbcff(0x165)]());}[_0x56bb89(0x16c)](){const _0x46d326=_0x56bb89;this[_0x46d326(0x130)]='',this[_0x46d326(0x15e)]='',this[_0x46d326(0x18c)]='',this[_0x46d326(0x15b)]='',this[_0x46d326(0x136)]='',this[_0x46d326(0x12f)]='',this[_0x46d326(0x161)]=void 0x0,this[_0x46d326(0x16a)][_0x46d326(0x16c)](),this[_0x46d326(0x155)]();}async[_0x56bb89(0x13c)](_0x51402e,_0x4433d6,_0x1e9cb8,_0x1977d1){const _0x5dce89=_0x56bb89;return this[_0x5dce89(0x18f)]=!0x0,this[_0x5dce89(0x16a)][_0x5dce89(0x17b)](),this[_0x5dce89(0x15b)]=_0x4433d6,this[_0x5dce89(0x136)]=_0x51402e,this[_0x5dce89(0x12f)]=_0x1977d1||_0x51402e,this[_0x5dce89(0x161)]=_0x1e9cb8,new Promise(_0x1d01b9=>{const _0x49dd4b=_0x5dce89;this[_0x49dd4b(0x146)][_0x49dd4b(0x188)]({'query':_0x51402e,'context':_0x4433d6,'onData':_0x34c250=>{const _0x5df174=_0x49dd4b;this[_0x5df174(0x18c)]=_0x34c250,this[_0x5df174(0x15e)]=this[_0x5df174(0x144)](this[_0x5df174(0x18c)]);},'actionId':_0x1e9cb8})[_0x49dd4b(0x140)](()=>{const _0x19f35c=_0x49dd4b;!this[_0x19f35c(0x15e)]&&this[_0x19f35c(0x18c)]&&(this[_0x19f35c(0x15e)]=this[_0x19f35c(0x144)](this[_0x19f35c(0x18c)],!0x0));})[_0x49dd4b(0x175)](_0x5458f3=>{const _0x48fe2c=_0x49dd4b;_0x5458f3 instanceof _0x14d9b0?this[_0x48fe2c(0x16a)][_0x48fe2c(0x139)](_0x5458f3[_0x48fe2c(0x15d)]):this[_0x48fe2c(0x16a)][_0x48fe2c(0x139)](),_0x1d01b9();})[_0x49dd4b(0x145)](()=>{const _0xaa0bcd=_0x49dd4b;this[_0xaa0bcd(0x155)](),_0x1d01b9();});});}[_0x56bb89(0x144)](_0x2bd234,_0x203ee6=!0x1){const _0x358f17=_0x56bb89,_0x14cfc3=Z[_0x358f17(0x154)](_0x2bd234);_0x2bd234=_0x14cfc3?_0x2bd234[_0x358f17(0x189)](_0x14cfc3[0x1][_0x358f17(0x166)]):_0x2bd234[_0x358f17(0x166)]<0x64&&!_0x203ee6?'':this[_0x358f17(0x14f)](_0x2bd234);const _0x21228b=this[_0x358f17(0x16e)][_0x358f17(0x180)](_0x2bd234,_0x358f17(0x135));if(_0x14cfc3){const _0x434051=Array[_0x358f17(0x14b)](_0x21228b[_0x358f17(0x179)][_0x358f17(0x18a)]);_0x434051[_0x358f17(0x17e)]();for(const _0x418451 of _0x434051){if(_0x418451[_0x358f17(0x167)]==Node[_0x358f17(0x169)])break;_0x418451[_0x358f17(0x142)]();}}const _0xdc645f=this[_0x358f17(0x147)][_0x358f17(0x172)][_0x358f17(0x15c)][_0x358f17(0x173)](this[_0x358f17(0x152)][_0x358f17(0x14a)](_0x21228b[_0x358f17(0x179)]));this[_0x358f17(0x15a)]()||this[_0x358f17(0x192)](_0xdc645f);const _0x2f744c=this[_0x358f17(0x147)][_0x358f17(0x16b)][_0x358f17(0x14d)](_0x358f17(0x18e)),_0x23ae70=this[_0x358f17(0x147)][_0x358f17(0x172)][_0x358f17(0x186)](_0xdc645f);return _0x2f744c||_0x23ae70[_0x358f17(0x184)][_0x358f17(0x18d)](),this[_0x358f17(0x147)][_0x358f17(0x172)][_0x358f17(0x178)](_0x23ae70);}[_0x56bb89(0x192)](_0x3e0fcf){const _0x37b011=_0x56bb89,_0x1cd741=new _0x4a1637(this[_0x37b011(0x147)][_0x37b011(0x156)][_0x37b011(0x16a)][_0x37b011(0x168)]),_0x3aa515=new _0x334eac({'name':/^h[1-5]$/}),_0x35ec11=[];let _0x35434f=!0x1;for(const _0x4daf5c of _0x3e0fcf)_0x4daf5c['is'](_0x37b011(0x148))&&_0x3aa515[_0x37b011(0x157)](_0x4daf5c)&&(_0x35ec11[_0x37b011(0x182)](_0x4daf5c),'h1'==_0x4daf5c[_0x37b011(0x191)]&&(_0x35434f=!0x0));if(_0x35434f){for(const _0x412f8b of _0x35ec11)_0x1cd741[_0x37b011(0x14e)]('h'+(parseInt(_0x412f8b[_0x37b011(0x191)][0x1])+0x1),_0x412f8b);}}[_0x56bb89(0x15a)](){const _0x16ac14=_0x56bb89,{data:_0xf3a1e8,editing:_0x1d8d96}=this[_0x16ac14(0x147)],_0x4edd52=_0xf3a1e8[_0x16ac14(0x17f)][_0x16ac14(0x173)](_0x16ac14(0x12c)),_0x407865=_0xf3a1e8[_0x16ac14(0x173)](_0xf3a1e8[_0x16ac14(0x186)](_0x4edd52));return!!_0x1d8d96[_0x16ac14(0x16a)][_0x16ac14(0x132)][_0x16ac14(0x17a)](_0x407865)[_0x16ac14(0x15f)]('h1');}[_0x56bb89(0x190)](_0x5231a4){const _0x1c368c=_0x56bb89;return this[_0x1c368c(0x147)][_0x1c368c(0x156)][_0x1c368c(0x16a)][_0x1c368c(0x132)][_0x1c368c(0x150)](this[_0x1c368c(0x181)],_0x5231a4),this[_0x1c368c(0x181)][_0x1c368c(0x176)];}[_0x56bb89(0x14f)](_0x3dec3a){const _0xcee11a=_0x56bb89,_0x3b8708=_0x3dec3a[_0xcee11a(0x164)]();return _0x3b8708[_0xcee11a(0x13d)](_0xcee11a(0x143))?_0x3b8708[_0xcee11a(0x158)](_0xcee11a(0x174))?_0x3b8708[_0xcee11a(0x189)](0x7,_0x3b8708[_0xcee11a(0x166)]-0x3):_0x3b8708[_0xcee11a(0x189)](0x7):_0x3dec3a;}}