@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 _0x1d7f7c=_0x9306;(function(_0x3d57b7,_0x85a289){const _0x4333ba=_0x9306,_0x38f5b2=_0x3d57b7();while(!![]){try{const _0x1a5e25=-parseInt(_0x4333ba(0x1b2))/0x1*(-parseInt(_0x4333ba(0x181))/0x2)+parseInt(_0x4333ba(0x17d))/0x3*(parseInt(_0x4333ba(0x16c))/0x4)+-parseInt(_0x4333ba(0x1c1))/0x5*(parseInt(_0x4333ba(0x187))/0x6)+parseInt(_0x4333ba(0x170))/0x7*(parseInt(_0x4333ba(0x1ae))/0x8)+-parseInt(_0x4333ba(0x1b4))/0x9*(parseInt(_0x4333ba(0x161))/0xa)+parseInt(_0x4333ba(0x188))/0xb*(parseInt(_0x4333ba(0x164))/0xc)+-parseInt(_0x4333ba(0x1b5))/0xd*(parseInt(_0x4333ba(0x1be))/0xe);if(_0x1a5e25===_0x85a289)break;else _0x38f5b2['push'](_0x38f5b2['shift']());}catch(_0x46e680){_0x38f5b2['push'](_0x38f5b2['shift']());}}}(_0x3440,0x7305f));import{ObservableMixin as _0x2deb92}from'ckeditor5/src/utils.js';function _0x3440(){const _0x5654e2=['textAdapter','```','3057016iToGKH','div','_sanitizationContainer','abort','13597ssusEJ','toView','239004UGzhqv','39wKLvPY','render','set','ELEMENT_NODE','setContentOf','rename','config','startsWith','markers','2561986HPXVNZ','value','length','43090XveoXD','stopListening','destroy','get','querySelector','finally','stringify','_stripMarkdownSyntax','320XIYRKG','listenTo','currentResponse','12NPHSaY','reset','_handleQuery','<h1></h1>','editing','tryAgainEvent','ai.aiAssistant.preserveComments','toModel','4ewiCNq','catch','previousContext','body','7eNmMqj','prompt','htmlProcessor','name','previousQuery','makeRequest','message','trim','previousActionId','element','_parseAndNormalizeContent','custom','text/html','2631171tCPXOT','remove','push','nodeType','106BPTAnw','_isH1TagSupportEnabled','reverse','childNodes','editor','previousLabel','402rnbNil','5142555hVPJNh','view','updateView','finishProcessing','innerHTML','isProcessing','currentContext','handleError','submitPrompt','once','processor','parseFromString','from','_xmlSerializer','domConverter','_sanitizeHTML','createElement','startProcessing','_domParser','viewToDom','then','```html','mainAction','endsWith','set:currentContext','substring','isRendered','_normalizeResponseHeadings','exec','serializeToString','initialContext','document','clear','stopProcessing','match','data'];_0x3440=function(){return _0x5654e2;};return _0x3440();}function _0x9306(_0x223e5f,_0x22017d){const _0x344053=_0x3440();return _0x9306=function(_0x930607,_0x29c156){_0x930607=_0x930607-0x15f;let _0xb72235=_0x344053[_0x930607];return _0xb72235;},_0x9306(_0x223e5f,_0x22017d);}import{AIRequestError as _0x15f098}from'../adapters/aiadapter.js';import{Matcher as _0xbefcee,ViewUpcastWriter as _0x54208f}from'ckeditor5/src/engine.js';const Q=new RegExp(/^(.*?)<[a-zA-Z][a-zA-Z0-9_\-.]*[ >]/,'is');export class AIAssistantController extends/* #__PURE__ -- */
_0x2deb92(){[_0x1d7f7c(0x185)];[_0x1d7f7c(0x1ac)];[_0x1d7f7c(0x189)];[_0x1d7f7c(0x1b0)];[_0x1d7f7c(0x19a)];[_0x1d7f7c(0x195)];constructor(_0x5aa126,_0x32ab14,_0x330dda){const _0x4689f6=_0x1d7f7c;super(),this[_0x4689f6(0x185)]=_0x5aa126,this[_0x4689f6(0x1ac)]=_0x32ab14,this[_0x4689f6(0x1b0)]=document[_0x4689f6(0x198)](_0x4689f6(0x1af)),this[_0x4689f6(0x19a)]=new DOMParser(),this[_0x4689f6(0x195)]=new XMLSerializer(),this[_0x4689f6(0x189)]=_0x330dda,this[_0x4689f6(0x1b7)]({'initialContext':'','currentContext':'','currentResponse':'','previousContext':void 0x0,'previousQuery':void 0x0,'previousLabel':void 0x0,'isProcessing':!0x1}),this['on'](_0x4689f6(0x1a0),(_0x5eb6b4,_0x15dd3d,_0x3e357b)=>{const _0x4332c3=_0x4689f6;this[_0x4332c3(0x189)][_0x4332c3(0x1bf)]=this[_0x4332c3(0x197)](_0x3e357b);}),this[_0x4689f6(0x162)](this[_0x4689f6(0x189)],_0x4689f6(0x190),(_0x59b55b,_0xd95b75)=>{const _0x467a54=_0x4689f6,_0x407eb4=this[_0x467a54(0x18e)]||this[_0x467a54(0x1a6)];this[_0x467a54(0x166)](_0xd95b75,_0x407eb4,_0x467a54(0x17b));}),this[_0x4689f6(0x162)](this[_0x4689f6(0x189)],_0x4689f6(0x169),()=>{const _0x4b63fe=_0x4689f6;this[_0x4b63fe(0x189)][_0x4b63fe(0x171)]=this[_0x4b63fe(0x186)],this[_0x4b63fe(0x166)](this[_0x4b63fe(0x174)],this[_0x4b63fe(0x16e)],this[_0x4b63fe(0x178)],this[_0x4b63fe(0x186)]);}),this[_0x4689f6(0x162)](this[_0x4689f6(0x189)],_0x4689f6(0x1a9),()=>{const _0x21352b=_0x4689f6;this[_0x21352b(0x1a9)]();});}[_0x1d7f7c(0x1c3)](){const _0x46a6b8=_0x1d7f7c;this[_0x46a6b8(0x1c2)]();}async[_0x1d7f7c(0x18a)]({actionId:_0x335dc3,query:_0x33a442,htmlContent:_0x3f130e,label:_0x30a520,mainActionLabel:_0x26af74}){const _0xe1bcd5=_0x1d7f7c;this[_0xe1bcd5(0x189)][_0xe1bcd5(0x171)]=_0x30a520,this[_0xe1bcd5(0x189)][_0xe1bcd5(0x19e)]=_0x26af74,this[_0xe1bcd5(0x1a6)]=_0x3f130e,_0x33a442&&(this[_0xe1bcd5(0x189)][_0xe1bcd5(0x1a2)]?this[_0xe1bcd5(0x166)](_0x33a442,_0x3f130e,_0x335dc3,_0x30a520):this[_0xe1bcd5(0x189)][_0xe1bcd5(0x191)](_0xe1bcd5(0x1b6),()=>{const _0x2495be=_0xe1bcd5;this[_0x2495be(0x166)](_0x33a442,_0x3f130e,_0x335dc3,_0x30a520);}));}[_0x1d7f7c(0x1a9)](){const _0x3cdb1f=_0x1d7f7c;this[_0x3cdb1f(0x18d)]&&(this[_0x3cdb1f(0x18d)]=!0x1,this[_0x3cdb1f(0x189)][_0x3cdb1f(0x18b)](),this[_0x3cdb1f(0x1ac)][_0x3cdb1f(0x1b1)]());}[_0x1d7f7c(0x165)](){const _0x40a69b=_0x1d7f7c;this[_0x40a69b(0x1a6)]='',this[_0x40a69b(0x18e)]='',this[_0x40a69b(0x163)]='',this[_0x40a69b(0x16e)]='',this[_0x40a69b(0x174)]='',this[_0x40a69b(0x186)]='',this[_0x40a69b(0x178)]=void 0x0,this[_0x40a69b(0x189)][_0x40a69b(0x165)](),this[_0x40a69b(0x1a9)]();}async[_0x1d7f7c(0x166)](_0x1b0b0b,_0x56e304,_0x52f2c5,_0x2d9634){const _0x22a25c=_0x1d7f7c;return this[_0x22a25c(0x18d)]=!0x0,this[_0x22a25c(0x189)][_0x22a25c(0x199)](),this[_0x22a25c(0x16e)]=_0x56e304,this[_0x22a25c(0x174)]=_0x1b0b0b,this[_0x22a25c(0x186)]=_0x2d9634||_0x1b0b0b,this[_0x22a25c(0x178)]=_0x52f2c5,new Promise(_0x3177c4=>{const _0x71f124=_0x22a25c;this[_0x71f124(0x1ac)][_0x71f124(0x175)]({'query':_0x1b0b0b,'context':_0x56e304,'onData':_0x2983f2=>{const _0x35bb26=_0x71f124;this[_0x35bb26(0x163)]=_0x2983f2,this[_0x35bb26(0x18e)]=this[_0x35bb26(0x17a)](this[_0x35bb26(0x163)]);},'actionId':_0x52f2c5})[_0x71f124(0x19c)](()=>{const _0x327d1b=_0x71f124;!this[_0x327d1b(0x18e)]&&this[_0x327d1b(0x163)]&&(this[_0x327d1b(0x18e)]=this[_0x327d1b(0x17a)](this[_0x327d1b(0x163)],!0x0));})[_0x71f124(0x16d)](_0x460b0c=>{const _0x3774ce=_0x71f124;_0x460b0c instanceof _0x15f098?this[_0x3774ce(0x189)][_0x3774ce(0x18f)](_0x460b0c[_0x3774ce(0x176)]):this[_0x3774ce(0x189)][_0x3774ce(0x18f)](),_0x3177c4();})[_0x71f124(0x1c6)](()=>{const _0x1f934a=_0x71f124;this[_0x1f934a(0x1a9)](),_0x3177c4();});});}[_0x1d7f7c(0x17a)](_0x3abe9a,_0x12c1fc=!0x1){const _0x470948=_0x1d7f7c,_0x51c166=Q[_0x470948(0x1a4)](_0x3abe9a);_0x3abe9a=_0x51c166?_0x3abe9a[_0x470948(0x1a1)](_0x51c166[0x1][_0x470948(0x1c0)]):_0x3abe9a[_0x470948(0x1c0)]<0x64&&!_0x12c1fc?'':this[_0x470948(0x160)](_0x3abe9a);const _0x5e06b1=this[_0x470948(0x19a)][_0x470948(0x193)](_0x3abe9a,_0x470948(0x17c));if(_0x51c166){const _0x680600=Array[_0x470948(0x194)](_0x5e06b1[_0x470948(0x16f)][_0x470948(0x184)]);_0x680600[_0x470948(0x183)]();for(const _0x55f64c of _0x680600){if(_0x55f64c[_0x470948(0x180)]==Node[_0x470948(0x1b8)])break;_0x55f64c[_0x470948(0x17e)]();}}const _0x283878=this[_0x470948(0x185)][_0x470948(0x1ab)][_0x470948(0x192)][_0x470948(0x1b3)](this[_0x470948(0x195)][_0x470948(0x1a5)](_0x5e06b1[_0x470948(0x16f)]));this[_0x470948(0x182)]()||this[_0x470948(0x1a3)](_0x283878);const _0xcea67=this[_0x470948(0x185)][_0x470948(0x1bb)][_0x470948(0x1c4)](_0x470948(0x16a)),_0x2ca30c=this[_0x470948(0x185)][_0x470948(0x1ab)][_0x470948(0x16b)](_0x283878);return _0xcea67||_0x2ca30c[_0x470948(0x1bd)][_0x470948(0x1a8)](),this[_0x470948(0x185)][_0x470948(0x1ab)][_0x470948(0x15f)](_0x2ca30c);}[_0x1d7f7c(0x1a3)](_0x35a7cf){const _0x3f3323=_0x1d7f7c,_0x4dc0f3=new _0x54208f(this[_0x3f3323(0x185)][_0x3f3323(0x168)][_0x3f3323(0x189)][_0x3f3323(0x1a7)]),_0x3cc062=new _0xbefcee({'name':/^h[1-5]$/}),_0x445e6e=[];let _0x5452df=!0x1;for(const _0x717c4b of _0x35a7cf)_0x717c4b['is'](_0x3f3323(0x179))&&_0x3cc062[_0x3f3323(0x1aa)](_0x717c4b)&&(_0x445e6e[_0x3f3323(0x17f)](_0x717c4b),'h1'==_0x717c4b[_0x3f3323(0x173)]&&(_0x5452df=!0x0));if(_0x5452df){for(const _0x47e460 of _0x445e6e)_0x4dc0f3[_0x3f3323(0x1ba)]('h'+(parseInt(_0x47e460[_0x3f3323(0x173)][0x1])+0x1),_0x47e460);}}[_0x1d7f7c(0x182)](){const _0x2a33eb=_0x1d7f7c,{data:_0x452c37,editing:_0x45fb7a}=this[_0x2a33eb(0x185)],_0x42aa3d=_0x452c37[_0x2a33eb(0x172)][_0x2a33eb(0x1b3)](_0x2a33eb(0x167)),_0x4b1d8d=_0x452c37[_0x2a33eb(0x1b3)](_0x452c37[_0x2a33eb(0x16b)](_0x42aa3d));return!!_0x45fb7a[_0x2a33eb(0x189)][_0x2a33eb(0x196)][_0x2a33eb(0x19b)](_0x4b1d8d)[_0x2a33eb(0x1c5)]('h1');}[_0x1d7f7c(0x197)](_0x29fe09){const _0x3e7413=_0x1d7f7c;return this[_0x3e7413(0x185)][_0x3e7413(0x168)][_0x3e7413(0x189)][_0x3e7413(0x196)][_0x3e7413(0x1b9)](this[_0x3e7413(0x1b0)],_0x29fe09),this[_0x3e7413(0x1b0)][_0x3e7413(0x18c)];}[_0x1d7f7c(0x160)](_0x3aa1b6){const _0x1361f5=_0x1d7f7c,_0x4186a5=_0x3aa1b6[_0x1361f5(0x177)]();return _0x4186a5[_0x1361f5(0x1bc)](_0x1361f5(0x19d))?_0x4186a5[_0x1361f5(0x19f)](_0x1361f5(0x1ad))?_0x4186a5[_0x1361f5(0x1a1)](0x7,_0x4186a5[_0x1361f5(0x1c0)]-0x3):_0x4186a5[_0x1361f5(0x1a1)](0x7):_0x3aa1b6;}}