UNPKG

@ckeditor/ckeditor5-ai

Version:

AI Assistant feature for CKEditor 5.

24 lines • 9.92 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 _0x2b5fd5=_0x39ab;(function(_0x2a04f8,_0x48c048){const _0x41c6fd=_0x39ab,_0x5a5757=_0x2a04f8();while(!![]){try{const _0x43e673=parseInt(_0x41c6fd(0x1df))/0x1*(-parseInt(_0x41c6fd(0x1c6))/0x2)+-parseInt(_0x41c6fd(0x1c4))/0x3+-parseInt(_0x41c6fd(0x1b7))/0x4*(-parseInt(_0x41c6fd(0x1f4))/0x5)+-parseInt(_0x41c6fd(0x20e))/0x6*(-parseInt(_0x41c6fd(0x1e7))/0x7)+parseInt(_0x41c6fd(0x1e2))/0x8+-parseInt(_0x41c6fd(0x1d3))/0x9+parseInt(_0x41c6fd(0x1f1))/0xa;if(_0x43e673===_0x48c048)break;else _0x5a5757['push'](_0x5a5757['shift']());}catch(_0x1d3729){_0x5a5757['push'](_0x5a5757['shift']());}}}(_0x1b4f,0xe9946));import{ObservableMixin as _0x424de5}from'ckeditor5/src/utils.js';import{AIRequestError as _0x39abdc}from'../adapters/aiadapter.js';import{Matcher as _0x51eebe,UpcastWriter as _0x98e2ce}from'ckeditor5/src/engine.js';const Z=new RegExp(/^(.*?)<[a-zA-Z][a-zA-Z0-9_\-.]*[ >]/,'is');export default class j extends/* #__PURE__ -- @preserve */ _0x424de5(){constructor(_0x18394a,_0x5cd2a3,_0x42f684){const _0x42fa8a=_0x39ab;super(),this[_0x42fa8a(0x1c8)]=_0x18394a,this[_0x42fa8a(0x1c2)]=_0x5cd2a3,this[_0x42fa8a(0x210)]=document[_0x42fa8a(0x203)](_0x42fa8a(0x1d9)),this[_0x42fa8a(0x1ed)]=new DOMParser(),this[_0x42fa8a(0x1b1)]=new XMLSerializer(),this[_0x42fa8a(0x1b6)]=_0x42f684,this[_0x42fa8a(0x1f8)]({'initialContext':'','currentContext':'','currentResponse':'','previousContext':void 0x0,'previousQuery':void 0x0,'previousLabel':void 0x0,'isProcessing':!0x1}),this['on'](_0x42fa8a(0x1c9),(_0x1c4a5f,_0x40e5ba,_0x2bd3ee)=>{const _0x4a9f73=_0x42fa8a;this[_0x4a9f73(0x1b6)][_0x4a9f73(0x201)]=this[_0x4a9f73(0x1cb)](_0x2bd3ee);}),this[_0x42fa8a(0x1d8)](this[_0x42fa8a(0x1b6)],_0x42fa8a(0x1c7),(_0x12bed0,_0x4dc7de)=>{const _0x37125b=_0x42fa8a,_0x4069d6=this[_0x37125b(0x206)]||this[_0x37125b(0x1b5)];this[_0x37125b(0x1ea)](_0x4dc7de,_0x4069d6,_0x37125b(0x1e3));}),this[_0x42fa8a(0x1d8)](this[_0x42fa8a(0x1b6)],_0x42fa8a(0x1f0),()=>{const _0x60b406=_0x42fa8a;this[_0x60b406(0x1b6)][_0x60b406(0x1fc)]=this[_0x60b406(0x1f7)],this[_0x60b406(0x1ea)](this[_0x60b406(0x1ff)],this[_0x60b406(0x1de)],this[_0x60b406(0x1bf)],this[_0x60b406(0x1f7)]);}),this[_0x42fa8a(0x1d8)](this[_0x42fa8a(0x1b6)],_0x42fa8a(0x1f5),()=>{const _0x3ed4b5=_0x42fa8a;this[_0x3ed4b5(0x1f5)]();});}[_0x2b5fd5(0x1cd)](){const _0x43c5ed=_0x2b5fd5;this[_0x43c5ed(0x1f3)]();}async[_0x2b5fd5(0x1ec)]({actionId:_0x548563,query:_0x3b83e7,htmlContent:_0x13b996,label:_0x11399c,mainActionLabel:_0x500e30}){const _0x39f67a=_0x2b5fd5;this[_0x39f67a(0x1b6)][_0x39f67a(0x1fc)]=_0x11399c,this[_0x39f67a(0x1b6)][_0x39f67a(0x1d5)]=_0x500e30,this[_0x39f67a(0x1b5)]=_0x13b996,_0x3b83e7&&(this[_0x39f67a(0x1b6)][_0x39f67a(0x1b2)]?this[_0x39f67a(0x1ea)](_0x3b83e7,_0x13b996,_0x548563,_0x11399c):this[_0x39f67a(0x1b6)][_0x39f67a(0x1fa)](_0x39f67a(0x1c0),()=>{const _0x2af337=_0x39f67a;this[_0x2af337(0x1ea)](_0x3b83e7,_0x13b996,_0x548563,_0x11399c);}));}[_0x2b5fd5(0x1f5)](){const _0x21015f=_0x2b5fd5;this[_0x21015f(0x209)]&&(this[_0x21015f(0x209)]=!0x1,this[_0x21015f(0x1b6)][_0x21015f(0x1c1)](),this[_0x21015f(0x1c2)][_0x21015f(0x20f)]());}[_0x2b5fd5(0x207)](){const _0x5878ce=_0x2b5fd5;this[_0x5878ce(0x1b5)]='',this[_0x5878ce(0x206)]='',this[_0x5878ce(0x1b9)]='',this[_0x5878ce(0x1de)]='',this[_0x5878ce(0x1ff)]='',this[_0x5878ce(0x1f7)]='',this[_0x5878ce(0x1bf)]=void 0x0,this[_0x5878ce(0x1b6)][_0x5878ce(0x207)](),this[_0x5878ce(0x1f5)]();}async[_0x2b5fd5(0x1ea)](_0x5bb517,_0x5e2cc3,_0x4d2889,_0x25fe66){const _0x3a28b7=_0x2b5fd5;return this[_0x3a28b7(0x209)]=!0x0,this[_0x3a28b7(0x1b6)][_0x3a28b7(0x1e5)](),this[_0x3a28b7(0x1de)]=_0x5e2cc3,this[_0x3a28b7(0x1ff)]=_0x5bb517,this[_0x3a28b7(0x1f7)]=_0x25fe66||_0x5bb517,this[_0x3a28b7(0x1bf)]=_0x4d2889,new Promise(_0x4aa50d=>{const _0x202345=_0x3a28b7;this[_0x202345(0x1c2)][_0x202345(0x1dd)]({'query':_0x5bb517,'context':_0x5e2cc3,'onData':_0x3edf2f=>{const _0x700433=_0x202345;this[_0x700433(0x1b9)]=_0x3edf2f,this[_0x700433(0x206)]=this[_0x700433(0x202)](this[_0x700433(0x1b9)]);},'actionId':_0x4d2889})[_0x202345(0x1ce)](()=>{const _0x2e3153=_0x202345;!this[_0x2e3153(0x206)]&&this[_0x2e3153(0x1b9)]&&(this[_0x2e3153(0x206)]=this[_0x2e3153(0x202)](this[_0x2e3153(0x1b9)],!0x0));})[_0x202345(0x20b)](_0x2df4e9=>{const _0x184803=_0x202345;_0x2df4e9 instanceof _0x39abdc?this[_0x184803(0x1b6)][_0x184803(0x1bd)](_0x2df4e9[_0x184803(0x20d)]):this[_0x184803(0x1b6)][_0x184803(0x1bd)](),_0x4aa50d();})[_0x202345(0x1be)](()=>{const _0xf85c3b=_0x202345;this[_0xf85c3b(0x1f5)](),_0x4aa50d();});});}[_0x2b5fd5(0x202)](_0x532ce8,_0x3fd621=!0x1){const _0x4c3ba9=_0x2b5fd5,_0x1b50c3=Z[_0x4c3ba9(0x1ad)](_0x532ce8);_0x532ce8=_0x1b50c3?_0x532ce8[_0x4c3ba9(0x1d4)](_0x1b50c3[0x1][_0x4c3ba9(0x1d1)]):_0x532ce8[_0x4c3ba9(0x1d1)]<0x64&&!_0x3fd621?'':this[_0x4c3ba9(0x1b8)](_0x532ce8);const _0x4a96c7=this[_0x4c3ba9(0x1ed)][_0x4c3ba9(0x1e9)](_0x532ce8,_0x4c3ba9(0x1fb));if(_0x1b50c3){const _0x3c8ddb=Array[_0x4c3ba9(0x1af)](_0x4a96c7[_0x4c3ba9(0x1d2)][_0x4c3ba9(0x1bc)]);_0x3c8ddb[_0x4c3ba9(0x200)]();for(const _0x58747b of _0x3c8ddb){if(_0x58747b[_0x4c3ba9(0x1ee)]==Node[_0x4c3ba9(0x1c5)])break;_0x58747b[_0x4c3ba9(0x205)]();}}const _0x596fcc=this[_0x4c3ba9(0x1c8)][_0x4c3ba9(0x1e4)][_0x4c3ba9(0x1e1)][_0x4c3ba9(0x1ef)](this[_0x4c3ba9(0x1b1)][_0x4c3ba9(0x1f6)](_0x4a96c7[_0x4c3ba9(0x1d2)]));this[_0x4c3ba9(0x1d6)]()||this[_0x4c3ba9(0x1b3)](_0x596fcc);const _0x4d31fb=this[_0x4c3ba9(0x1c8)][_0x4c3ba9(0x1db)][_0x4c3ba9(0x1ba)](_0x4c3ba9(0x1cf)),_0x1fac9f=this[_0x4c3ba9(0x1c8)][_0x4c3ba9(0x1e4)][_0x4c3ba9(0x1e6)](_0x596fcc);return _0x4d31fb||_0x1fac9f[_0x4c3ba9(0x1b4)][_0x4c3ba9(0x1f2)](),this[_0x4c3ba9(0x1c8)][_0x4c3ba9(0x1e4)][_0x4c3ba9(0x1da)](_0x1fac9f);}[_0x2b5fd5(0x1b3)](_0x36c6ab){const _0x1f2ab7=_0x2b5fd5,_0x4e6996=new _0x98e2ce(this[_0x1f2ab7(0x1c8)][_0x1f2ab7(0x204)][_0x1f2ab7(0x1b6)][_0x1f2ab7(0x1e8)]),_0x488bc5=new _0x51eebe({'name':/^h[1-5]$/}),_0x1f8712=[];let _0x19da34=!0x1;for(const _0x487f4a of _0x36c6ab)_0x487f4a['is'](_0x1f2ab7(0x1d0))&&_0x488bc5[_0x1f2ab7(0x1e0)](_0x487f4a)&&(_0x1f8712[_0x1f2ab7(0x1bb)](_0x487f4a),'h1'==_0x487f4a[_0x1f2ab7(0x1c3)]&&(_0x19da34=!0x0));if(_0x19da34){for(const _0x5e47fa of _0x1f8712)_0x4e6996[_0x1f2ab7(0x1f9)]('h'+(parseInt(_0x5e47fa[_0x1f2ab7(0x1c3)][0x1])+0x1),_0x5e47fa);}}[_0x2b5fd5(0x1d6)](){const _0x1cec1c=_0x2b5fd5,{data:_0xf9190e,editing:_0x351741}=this[_0x1cec1c(0x1c8)],_0x20b5c5=_0xf9190e[_0x1cec1c(0x208)][_0x1cec1c(0x1ef)](_0x1cec1c(0x1dc)),_0x68438c=_0xf9190e[_0x1cec1c(0x1ef)](_0xf9190e[_0x1cec1c(0x1e6)](_0x20b5c5));return!!_0x351741[_0x1cec1c(0x1b6)][_0x1cec1c(0x20a)][_0x1cec1c(0x1ca)](_0x68438c)[_0x1cec1c(0x20c)]('h1');}[_0x2b5fd5(0x1cb)](_0x16ef32){const _0x518001=_0x2b5fd5;return this[_0x518001(0x1c8)][_0x518001(0x204)][_0x518001(0x1b6)][_0x518001(0x20a)][_0x518001(0x1d7)](this[_0x518001(0x210)],_0x16ef32),this[_0x518001(0x210)][_0x518001(0x1eb)];}[_0x2b5fd5(0x1b8)](_0x2cc04c){const _0x464a81=_0x2b5fd5,_0x41a0dc=_0x2cc04c[_0x464a81(0x1fd)]();return _0x41a0dc[_0x464a81(0x1cc)](_0x464a81(0x1fe))?_0x41a0dc[_0x464a81(0x1ae)](_0x464a81(0x1b0))?_0x41a0dc[_0x464a81(0x1d4)](0x7,_0x41a0dc[_0x464a81(0x1d1)]-0x3):_0x41a0dc[_0x464a81(0x1d4)](0x7):_0x2cc04c;}}function _0x39ab(_0x1e3f10,_0x1d82cd){const _0x1b4f1=_0x1b4f();return _0x39ab=function(_0x39ab38,_0x4a5aec){_0x39ab38=_0x39ab38-0x1ad;let _0x4b494e=_0x1b4f1[_0x39ab38];return _0x4b494e;},_0x39ab(_0x1e3f10,_0x1d82cd);}function _0x1b4f(){const _0x34c956=['ai.aiAssistant.preserveComments','element','length','body','10498554pgBtoD','substring','mainAction','_isH1TagSupportEnabled','setContentOf','listenTo','div','stringify','config','<h1></h1>','makeRequest','previousContext','32QgURss','match','processor','7074440qGZaRH','custom','data','startProcessing','toModel','574FFJnqB','document','parseFromString','_handleQuery','innerHTML','updateView','_domParser','nodeType','toView','tryAgainEvent','20319950OJOWUL','clear','stopListening','3805vAYlEF','stopProcessing','serializeToString','previousLabel','set','rename','once','text/html','prompt','trim','```html','previousQuery','reverse','value','_parseAndNormalizeContent','createElement','editing','remove','currentContext','reset','htmlProcessor','isProcessing','domConverter','catch','querySelector','message','24834KgvZJM','abort','_sanitizationContainer','exec','endsWith','from','```','_xmlSerializer','isRendered','_normalizeResponseHeadings','markers','initialContext','view','188dWcWZa','_stripMarkdownSyntax','currentResponse','get','push','childNodes','handleError','finally','previousActionId','render','finishProcessing','textAdapter','name','223851OpTkCZ','ELEMENT_NODE','68350EBeEsz','submitPrompt','editor','set:currentContext','viewToDom','_sanitizeHTML','startsWith','destroy','then'];_0x1b4f=function(){return _0x34c956;};return _0x1b4f();}