@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
23 lines • 12.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 _0x2c3ce1=_0x2c6c;(function(_0x1acdf8,_0x1a5965){const _0x37d953=_0x2c6c,_0x446c2f=_0x1acdf8();while(!![]){try{const _0x795926=parseInt(_0x37d953(0x14a))/0x1+-parseInt(_0x37d953(0x139))/0x2*(-parseInt(_0x37d953(0x11b))/0x3)+parseInt(_0x37d953(0xfa))/0x4*(-parseInt(_0x37d953(0x100))/0x5)+parseInt(_0x37d953(0x14b))/0x6*(-parseInt(_0x37d953(0x112))/0x7)+parseInt(_0x37d953(0x11d))/0x8*(-parseInt(_0x37d953(0x120))/0x9)+-parseInt(_0x37d953(0x157))/0xa*(-parseInt(_0x37d953(0x108))/0xb)+parseInt(_0x37d953(0x109))/0xc;if(_0x795926===_0x1a5965)break;else _0x446c2f['push'](_0x446c2f['shift']());}catch(_0x171e9b){_0x446c2f['push'](_0x446c2f['shift']());}}}(_0xdafe,0x6917d));import{ContextPlugin as _0x5d7822}from'ckeditor5/src/core.js';import{AIConnector as _0x19d7eb}from'../aicore/aiconnector.js';import{AIEditing as _0x6b735e}from'../aicore/aiediting.js';function _0xdafe(){const _0x5b66d0=['stopAutoScroll','context','open','fire','off','563510xOrNNQ','ai-selection','commands','max','startsWith','render','\x20ai-balloon-rotator','isTrackChangesOn','editing','root','_isUpdatingMarkers','markers','_pendingRenderCallback','delegate','updateContent','close','aiBalloon','showBlockingError','108CfYHka','view','width','ranges','showFakeVisualSelection','plugins','76035gwxlhA','round','end','title','_cleanupMarkerRemovalListener','trackChanges','content','dialogClosed','44GTPqjr','7425144vKcwgP','balloonView','isOfficialPlugin','label','hideFakeVisualSelection','get','getMarkersGroup','left','length','7ZYuRUC','isEqual','updatePosition','isOpen','_updateBalloon','index','isPremiumPlugin','_getSelectionElements','window','30396ZwmnJq','AI_ACTIONS_SELECTION_REMOVED_ERROR','33744qolMyn','requires','listenTo','27NQxIzp','height','_setupMarkerRemovalListener','show','model','_setupVisualSelection','locale','once','AIEditing','value','bottom','config','startAutoScroll','selectionRemoved','setupRotator','Dialog','change','bind','iconView','icon','pluginName','ai-balloon-selection','ai.availableReplyActions','rootName','mainView','56oPMHAl','_config','$graveyard','ai-selection:','stopListening','start','_showDialog','ai-balloon','getVisible','ai-balloon-','AIBalloon','top','filter','_calculateOptimalTopPosition','getIntersection','getChangedMarkers','headerView','245397yJBncH','3117330vYsGHP','_calculateDialogPosition','showRotator','hide','document','getBoundingRect','differ'];_0xdafe=function(){return _0x5b66d0;};return _0xdafe();}import{AI_BALLOON_VIEW_EVENT_NAMES as _0x887d9b,AIBalloonView as _0x51807e}from'./ui/aiballoonview.js';import'../../theme/aiballoon/aiballoon.css';import{getAllMarkersDomElementsSorted as _0x5b74de}from'ckeditor5-collaboration/src/collaboration-core.js';import{global as _0x1d0d58,Rect as _0x151388,scrollViewportToShowTarget as _0x29b416}from'ckeditor5/src/utils.js';import{getEditorFromContext as _0x498fab}from'../aicore/utils/geteditorfromcontext.js';import{AI_REPLY_ACTIONS as _0x42c921}from'../aichat/ui/feed/aichatfeedsuggestionitemactionsview.js';import{getTranslation as _0x24bc97}from'../aicore/utils/common-translations.js';export const AI_BALLOON_EVENT_NAMES=[..._0x887d9b,_0x2c3ce1(0x107),_0x2c3ce1(0x12d)];const g=0xa;function _0x2c6c(_0x195ecf,_0x482068){const _0xdafe90=_0xdafe();return _0x2c6c=function(_0x2c6c28,_0x30e1ef){_0x2c6c28=_0x2c6c28-0xf4;let _0x5b580e=_0xdafe90[_0x2c6c28];return _0x5b580e;},_0x2c6c(_0x195ecf,_0x482068);}export class AIBalloon extends _0x5d7822{static get[_0x2c3ce1(0x11e)](){return[_0x19d7eb,_0x6b735e];}static get[_0x2c3ce1(0x134)](){const _0x3e7010=_0x2c3ce1;return _0x3e7010(0x143);}static get[_0x2c3ce1(0x10b)](){return!0x0;}static get[_0x2c3ce1(0x118)](){return!0x0;}[_0x2c3ce1(0x115)]=!0x1;[_0x2c3ce1(0x13a)];[_0x2c3ce1(0x161)]=!0x1;[_0x2c3ce1(0xf4)]=null;[_0x2c3ce1(0x154)](_0x1219e1){const _0x483b5e=_0x2c3ce1,_0xbdeee3=_0x498fab(this[_0x483b5e(0x153)]);if(this[_0x483b5e(0x13a)]=_0x1219e1,this[_0x483b5e(0x115)])return void this[_0x483b5e(0x116)](_0x1219e1);const _0x4a4dac=this[_0x483b5e(0x153)][_0x483b5e(0x12b)][_0x483b5e(0x10e)](_0x483b5e(0x136))||[..._0x42c921],_0x5bf0af=_0xbdeee3?.[_0x483b5e(0x159)][_0x483b5e(0x10e)](_0x483b5e(0x105)),_0x3adacc=_0x5bf0af?.[_0x483b5e(0x129)];this[_0x483b5e(0x10a)]=new _0x51807e(_0xbdeee3[_0x483b5e(0x126)],_0x1219e1,_0x4a4dac,!!_0x3adacc),this[_0x483b5e(0x10a)][_0x483b5e(0xf5)](..._0x887d9b)['to'](this),_0x5bf0af&&this[_0x483b5e(0x10a)][_0x483b5e(0x131)](_0x483b5e(0x15e))['to'](_0x5bf0af,_0x483b5e(0x129)),this[_0x483b5e(0x13f)](_0x1219e1);}[_0x2c3ce1(0xf7)](){const _0x5c2a6c=_0x2c3ce1;_0x498fab(this[_0x5c2a6c(0x153)])[_0x5c2a6c(0xff)][_0x5c2a6c(0x10e)](_0x5c2a6c(0x12f))[_0x5c2a6c(0x14e)]();}[_0x2c3ce1(0x12c)](){const _0x2d2922=_0x2c3ce1;this[_0x2d2922(0x10a)]&&this[_0x2d2922(0x10a)][_0x2d2922(0x12c)]();}[_0x2c3ce1(0x152)](){const _0x216997=_0x2c3ce1;this[_0x216997(0x10a)]&&this[_0x216997(0x10a)][_0x216997(0x152)]();}[_0x2c3ce1(0x116)](_0x9a17af){const _0x258015=_0x2c3ce1,_0x277e1a=_0x498fab(this[_0x258015(0x153)]),_0x53a10b=_0x277e1a[_0x258015(0xff)][_0x258015(0x10e)](_0x258015(0x12f));this[_0x258015(0xf4)]&&(_0x277e1a[_0x258015(0x15f)][_0x258015(0xfb)][_0x258015(0x156)](_0x258015(0x15c),this[_0x258015(0xf4)]),this[_0x258015(0xf4)]=null),this[_0x258015(0x161)]=!0x0,_0x53a10b[_0x258015(0xfb)]?.[_0x258015(0x149)]&&(_0x53a10b[_0x258015(0xfb)][_0x258015(0x149)][_0x258015(0x10c)]=_0x9a17af[_0x258015(0x103)],_0x53a10b[_0x258015(0xfb)][_0x258015(0x149)][_0x258015(0x132)]&&_0x9a17af[_0x258015(0x133)]&&(_0x53a10b[_0x258015(0xfb)][_0x258015(0x149)][_0x258015(0x132)][_0x258015(0x106)]=_0x9a17af[_0x258015(0x133)])),this[_0x258015(0x10a)][_0x258015(0xf6)](_0x9a17af[_0x258015(0x138)]),this[_0x258015(0x125)](_0x9a17af[_0x258015(0xfd)],_0x9a17af[_0x258015(0x117)]),this[_0x258015(0xf4)]=()=>{const _0x94b04b=_0x258015;this[_0x94b04b(0x161)]=!0x1,this[_0x94b04b(0xf4)]=null,_0x53a10b[_0x94b04b(0xfb)]&&_0x53a10b[_0x94b04b(0xfb)][_0x94b04b(0x114)]();},_0x277e1a[_0x258015(0x15f)][_0x258015(0xfb)][_0x258015(0x127)](_0x258015(0x15c),this[_0x258015(0xf4)]);}[_0x2c3ce1(0x125)](_0x583aa9,_0x1bcfd2){const _0x3edd76=_0x2c3ce1;this[_0x3edd76(0x153)][_0x3edd76(0xff)][_0x3edd76(0x10e)](_0x6b735e)[_0x3edd76(0xfe)](_0x583aa9,_0x3edd76(0x142)+_0x1bcfd2,!0x0,!0x0);}[_0x2c3ce1(0x13f)](_0x3562c7){const _0xbe44c8=_0x2c3ce1,_0x2d8e2a=_0x498fab(this[_0xbe44c8(0x153)]);this[_0xbe44c8(0x125)](_0x3562c7[_0xbe44c8(0xfd)],_0x3562c7[_0xbe44c8(0x117)]);const _0x35d770=this[_0xbe44c8(0x119)]();_0x35d770&&_0x35d770[0x0]&&_0x29b416({'target':_0x35d770[0x0],'ancestorOffset':0x14,'alignToTop':!0x0,'viewportOffset':{'top':0x14,'bottom':0x14,'left':0x0,'right':0x0}}),_0x2d8e2a[_0xbe44c8(0xff)][_0xbe44c8(0x10e)](_0xbe44c8(0x12f))[_0xbe44c8(0x123)]({'title':_0x3562c7[_0xbe44c8(0x103)],'icon':_0x3562c7[_0xbe44c8(0x133)],'hasCloseButton':!0x0,'id':_0xbe44c8(0xf8),'position':this[_0xbe44c8(0x14c)][_0xbe44c8(0x131)](this),'className':_0xbe44c8(0x140)+(_0x3562c7[_0xbe44c8(0x14d)]?_0xbe44c8(0x15d):''),'content':this[_0xbe44c8(0x10a)],'onShow':_0x80448=>{const _0x48630a=_0xbe44c8;_0x3562c7[_0x48630a(0x14d)]&&this[_0x48630a(0x10a)][_0x48630a(0x12e)](_0x80448),this[_0x48630a(0x122)](),this[_0x48630a(0x115)]=!0x0;},'onHide':()=>{const _0x4866ed=_0xbe44c8;this[_0x4866ed(0x153)][_0x4866ed(0xff)][_0x4866ed(0x10e)](_0x4866ed(0x128))[_0x4866ed(0x10d)](_0x4866ed(0x142)+this[_0x4866ed(0x13a)][_0x4866ed(0x117)]),this[_0x4866ed(0x104)](),this[_0x4866ed(0x155)](_0x4866ed(0x107)),this[_0x4866ed(0x115)]=!0x1;}});}[_0x2c3ce1(0x14c)](_0x327177,_0x2c8fc0){const _0x14db39=_0x2c3ce1;if(!_0x2c8fc0)return null;const _0x3233c7=this[_0x14db39(0x119)]();if(!_0x3233c7||0x0===_0x3233c7[_0x14db39(0x111)])return{'left':Math[_0x14db39(0x101)](_0x2c8fc0[_0x14db39(0x110)]+_0x2c8fc0[_0x14db39(0xfc)]/0x2-_0x327177[_0x14db39(0xfc)]/0x2),'top':Math[_0x14db39(0x101)](_0x2c8fc0[_0x14db39(0x144)]+_0x2c8fc0[_0x14db39(0x121)]/0x2-_0x327177[_0x14db39(0x121)]/0x2)};const _0x597181=Math[_0x14db39(0x101)](_0x2c8fc0[_0x14db39(0x110)]+_0x2c8fc0[_0x14db39(0xfc)]/0x2-_0x327177[_0x14db39(0xfc)]/0x2),_0x3af71e=new _0x151388(_0x3233c7[0x0]),_0x5b9c3b=new _0x151388(_0x3233c7[_0x3233c7[_0x14db39(0x111)]-0x1]),_0x1ae1ff=_0x327177[_0x14db39(0x121)],_0x16a033=this[_0x14db39(0x13a)][_0x14db39(0x14d)]?0x8:0x0;return{'left':_0x597181,'top':this[_0x14db39(0x146)](_0x3af71e,_0x5b9c3b,_0x1ae1ff,_0x16a033,_0x2c8fc0)};}[_0x2c3ce1(0x146)](_0x1b0247,_0x493157,_0x467a2b,_0x58747d=0x0,_0x3ee8d1){const _0x196d36=_0x2c3ce1,_0xe016b4=_0x467a2b+_0x58747d,_0x291005=new _0x151388(_0x1d0d58[_0x196d36(0x11a)]),_0x157242=[_0x1b0247[_0x196d36(0x141)](),_0x493157[_0x196d36(0x141)]()][_0x196d36(0x145)](_0x4ca895=>_0x4ca895),_0x434b58=_0x151388[_0x196d36(0x150)](_0x157242);if(!_0x434b58)return Math[_0x196d36(0x101)](_0x3ee8d1[_0x196d36(0x144)]+_0x3ee8d1[_0x196d36(0x121)]/0x2);const _0x4fff18=_0x291005[_0x196d36(0x147)](_0x434b58);if(!_0x4fff18)return Math[_0x196d36(0x101)](_0x3ee8d1[_0x196d36(0x144)]+_0x3ee8d1[_0x196d36(0x121)]/0x2);const _0x1d5cd9=_0x3ee8d1[_0x196d36(0x141)](),_0x32b5e3=_0x1d5cd9&&_0x434b58[_0x196d36(0x121)]>_0x1d5cd9[_0x196d36(0x121)],_0x18f3ed=_0x4fff18[_0x196d36(0x144)],_0x19ea13=_0x4fff18[_0x196d36(0x12a)];if(_0x32b5e3){const _0x347328=(_0x1d5cd9||_0x291005)[_0x196d36(0x121)]/0x2-_0xe016b4/0x2,_0x79d6=_0x18f3ed-g-_0x3ee8d1[_0x196d36(0x144)],_0x1c9f1d=_0x3ee8d1[_0x196d36(0x12a)]-_0x19ea13-g;return _0x79d6>=_0xe016b4?Math[_0x196d36(0x15a)](g,_0x18f3ed-_0xe016b4-g):_0x1c9f1d>=_0xe016b4?_0x19ea13+g:Math[_0x196d36(0x15a)](g,_0x347328);}const _0x299811=_0x18f3ed-_0xe016b4,_0x118185=_0x3ee8d1[_0x196d36(0x12a)]-_0x19ea13-g,_0x451b9f=_0x18f3ed-g-_0x3ee8d1[_0x196d36(0x144)];let _0x2de88f;if(_0x118185>=_0xe016b4)_0x2de88f=_0x19ea13+g;else{if(_0x451b9f>=_0xe016b4)_0x2de88f=_0x299811-g;else _0x2de88f=_0x18f3ed+_0x434b58[_0x196d36(0x121)]/0x2-_0xe016b4/0x2;}return _0x2de88f;}[_0x2c3ce1(0x122)](){const _0x115d42=_0x2c3ce1,_0x256fdb=_0x498fab(this[_0x115d42(0x153)]);this[_0x115d42(0x11f)](_0x256fdb[_0x115d42(0x124)][_0x115d42(0x14f)],_0x115d42(0x130),()=>{const _0x4970e8=_0x115d42;if(this[_0x4970e8(0x161)])return;for(const {name:_0x481aeb,data:{newRange:_0x4c825a}}of _0x256fdb[_0x4970e8(0x124)][_0x4970e8(0x14f)][_0x4970e8(0x151)][_0x4970e8(0x148)]())if(_0x481aeb[_0x4970e8(0x15b)](_0x4970e8(0x13c))&&(_0x4c825a&&(_0x4c825a[_0x4970e8(0x13e)][_0x4970e8(0x113)](_0x4c825a[_0x4970e8(0x102)])||_0x4970e8(0x13b)==_0x4c825a[_0x4970e8(0x160)][_0x4970e8(0x137)])||null==_0x4c825a)){const _0x4924e7=_0x24bc97(this[_0x4970e8(0x153)][_0x4970e8(0x126)],_0x4970e8(0x11c));this[_0x4970e8(0x10a)][_0x4970e8(0xf9)](_0x4924e7),this[_0x4970e8(0x155)](_0x4970e8(0x12d));}});}[_0x2c3ce1(0x104)](){const _0x553a2f=_0x2c3ce1,_0x32bce2=_0x498fab(this[_0x553a2f(0x153)]);this[_0x553a2f(0x13d)](_0x32bce2[_0x553a2f(0x124)][_0x553a2f(0x14f)]);}[_0x2c3ce1(0x119)](){const _0x31838c=_0x2c3ce1,_0x3ce29e=_0x498fab(this[_0x31838c(0x153)]);return _0x5b74de(_0x3ce29e[_0x31838c(0x15f)],[..._0x3ce29e[_0x31838c(0x124)][_0x31838c(0x162)][_0x31838c(0x10f)](_0x31838c(0x158)),..._0x3ce29e[_0x31838c(0x124)][_0x31838c(0x162)][_0x31838c(0x10f)](_0x31838c(0x135))]);}}