UNPKG

@ckeditor/ckeditor5-collaboration-core

Version:

Base utilities used by CKEditor 5 collaboration features to support multiple users working together in a rich text editor.

23 lines 8.08 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 _0x5dbcec=_0x5b15;(function(_0x5722e2,_0x5adcd5){const _0x26adce=_0x5b15,_0x3070c1=_0x5722e2();while(!![]){try{const _0x233e5e=-parseInt(_0x26adce(0x130))/0x1*(parseInt(_0x26adce(0xfc))/0x2)+-parseInt(_0x26adce(0xf8))/0x3+-parseInt(_0x26adce(0xf4))/0x4*(-parseInt(_0x26adce(0x117))/0x5)+-parseInt(_0x26adce(0x10a))/0x6*(parseInt(_0x26adce(0x10b))/0x7)+parseInt(_0x26adce(0x102))/0x8*(parseInt(_0x26adce(0x11e))/0x9)+-parseInt(_0x26adce(0x12d))/0xa+parseInt(_0x26adce(0xf3))/0xb;if(_0x233e5e===_0x5adcd5)break;else _0x3070c1['push'](_0x3070c1['shift']());}catch(_0x25d134){_0x3070c1['push'](_0x3070c1['shift']());}}}(_0x3f02,0x6d5c8));import{ContextPlugin as _0x56abf9}from'ckeditor5/src/core.js';function _0x5b15(_0x4a11c2,_0x3fce48){const _0x3f0265=_0x3f02();return _0x5b15=function(_0x5b15a7,_0x145868){_0x5b15a7=_0x5b15a7-0xec;let _0x32a0b3=_0x3f0265[_0x5b15a7];return _0x32a0b3;},_0x5b15(_0x4a11c2,_0x3fce48);}import{Collection as _0x21c62a,CKEditorError as _0x535773}from'ckeditor5/src/utils.js';import{Permissions as _0xd8bf3d}from'./permissions.js';import{getTranslation as _0x727eee}from'./utils/common-translations.js';import'../theme/usercolors.css';function _0x3f02(){const _0x202039=['Users','_addAnonymousUser','54pJfyNw','347221zFLoKx','split','add','fromCodePoint','get','getOperationAuthor','_myId','ck-user__bg-color--','filter','useAnonymousUser','getMarkerClass','_id','575065hZfCYm','avatar','test','isPremiumPlugin','users','defineMe','users.anonymousUserId','54AHQwQJ','getBackgroundColorClass','decorate','_getNextColor','ck-user__selection--','isAnonymous','name','isOfficialPlugin','users-me-already-defined','context','string','getUser','trim','users-me-missing-user','_lastColor','1248230GubIAw','config','_isMe','983mruNJt','users.colorsCount','_getInitial','_isAnonymous','Anonymous','_computeInitials','define','isMe','ck-user__marker--','users-add-duplicated-id','4979436LQQwHX','20vTgRTS','length','_locale','users.getInitialsCallback','1126212KGDosk','pluginName','locale','requires','862TYFEYn','has','anonymous-user','users-add-invalid-id','initials','getSelectionClass','1054040VVxTLg','codePointAt','toUpperCase','init','addUser','color'];_0x3f02=function(){return _0x202039;};return _0x3f02();}export class Users extends _0x56abf9{[_0x5dbcec(0x11b)];[_0x5dbcec(0x12c)];[_0x5dbcec(0x111)];[_0x5dbcec(0xf6)];static get[_0x5dbcec(0xf9)](){const _0x55a00a=_0x5dbcec;return _0x55a00a(0x108);}static get[_0x5dbcec(0x125)](){return!0x0;}static get[_0x5dbcec(0x11a)](){return!0x0;}static get[_0x5dbcec(0xfb)](){return[_0xd8bf3d];}constructor(_0x1f29f9){const _0x3f9e9b=_0x5dbcec;super(_0x1f29f9),this[_0x3f9e9b(0x127)][_0x3f9e9b(0x12e)][_0x3f9e9b(0xef)](_0x3f9e9b(0x11d),_0x3f9e9b(0xfe)),this[_0x3f9e9b(0x127)][_0x3f9e9b(0x12e)][_0x3f9e9b(0xef)](_0x3f9e9b(0x131),0x8),this[_0x3f9e9b(0x11b)]=new _0x21c62a(),this[_0x3f9e9b(0xf6)]=_0x1f29f9[_0x3f9e9b(0xfa)],this[_0x3f9e9b(0x12c)]=0x0,this[_0x3f9e9b(0x111)]=null,this[_0x3f9e9b(0x120)](_0x3f9e9b(0x110));}[_0x5dbcec(0x105)](){const _0x500d97=_0x5dbcec;this[_0x500d97(0x109)]();}get['me'](){const _0x4808c5=_0x5dbcec;return null==this[_0x4808c5(0x111)]?null:this[_0x4808c5(0x129)](this[_0x4808c5(0x111)]);}[_0x5dbcec(0x106)]({id:_0xeba954,name:_0x2290c9,..._0x2b288b}){const _0x15531a=_0x5dbcec;if(!_0xeba954||_0x15531a(0x128)!=typeof _0xeba954)throw new _0x535773(_0x15531a(0xff));if(this[_0x15531a(0x11b)][_0x15531a(0xfd)](_0xeba954))throw new _0x535773(_0x15531a(0xf2),null,{'id':_0xeba954});const _0x32eabd=this[_0x15531a(0x127)][_0x15531a(0x12e)][_0x15531a(0x10f)](_0x15531a(0xf7)),_0x7e23cf={..._0x2b288b,'id':_0xeba954,'name':u(this[_0x15531a(0xf6)],_0x2290c9),'color':this[_0x15531a(0x121)]()};_0x7e23cf[_0x15531a(0x124)]=u(this[_0x15531a(0xf6)],_0x7e23cf[_0x15531a(0x124)]);const _0x202e34=new User(_0x7e23cf,_0x32eabd);return this[_0x15531a(0x11b)][_0x15531a(0x10d)](_0x202e34),_0x202e34;}[_0x5dbcec(0x129)](_0x1f20a8){const _0x26d21a=_0x5dbcec;return this[_0x26d21a(0x11b)][_0x26d21a(0x10f)](_0x1f20a8);}[_0x5dbcec(0x114)](){const _0xce7a1e=_0x5dbcec,_0x452641=this[_0xce7a1e(0x127)][_0xce7a1e(0x12e)][_0xce7a1e(0x10f)](_0xce7a1e(0x11d));this[_0xce7a1e(0x111)]||this[_0xce7a1e(0x11c)](_0x452641);}[_0x5dbcec(0x11c)](_0x3b4557){const _0x8f5e75=_0x5dbcec;if(this[_0x8f5e75(0x111)])throw new _0x535773(_0x8f5e75(0x126),null);const _0x2fbfb3=this[_0x8f5e75(0x129)](_0x3b4557);if(!_0x2fbfb3)throw new _0x535773(_0x8f5e75(0x12b),null);this[_0x8f5e75(0x111)]=_0x3b4557,_0x2fbfb3[_0x8f5e75(0x12f)]=!0x0;}[_0x5dbcec(0x110)](){return this['me'];}[_0x5dbcec(0x121)](){const _0x577add=_0x5dbcec,_0x4fdae1=this[_0x577add(0x127)][_0x577add(0x12e)][_0x577add(0x10f)](_0x577add(0x131));return this[_0x577add(0x12c)]>=_0x4fdae1&&(this[_0x577add(0x12c)]=0x0),new CollaborationUserColor(this[_0x577add(0x12c)]++);}[_0x5dbcec(0x109)](){const _0x5161fe=_0x5dbcec,_0x59244c=this[_0x5161fe(0x127)][_0x5161fe(0x12e)][_0x5161fe(0x10f)](_0x5161fe(0x11d));this[_0x5161fe(0x106)]({'id':_0x59244c,'name':_0x727eee(this[_0x5161fe(0xf6)],_0x5161fe(0xed))})[_0x5161fe(0xec)]=!0x0;}}export class User{['id'];[_0x5dbcec(0x107)];[_0x5dbcec(0x124)];[_0x5dbcec(0x100)];[_0x5dbcec(0x118)];[_0x5dbcec(0x12f)];[_0x5dbcec(0xec)];constructor(_0x8dded5,_0x1e1514){const _0x1af93f=_0x5dbcec;this['id']=_0x8dded5['id'],this[_0x1af93f(0x107)]=_0x8dded5[_0x1af93f(0x107)],this[_0x1af93f(0x124)]=_0x8dded5[_0x1af93f(0x124)],this[_0x1af93f(0x100)]=_0x1e1514?_0x1e1514(this[_0x1af93f(0x124)]):this[_0x1af93f(0xee)](),this[_0x1af93f(0x118)]=_0x8dded5[_0x1af93f(0x118)],this[_0x1af93f(0xec)]=!0x1,this[_0x1af93f(0x12f)]=!0x1;}get[_0x5dbcec(0x123)](){const _0x51649c=_0x5dbcec;return this[_0x51649c(0xec)];}get[_0x5dbcec(0xf0)](){const _0x133a68=_0x5dbcec;return this[_0x133a68(0x12f)];}[_0x5dbcec(0xee)](){const _0x35920d=_0x5dbcec,_0x4f4184=this[_0x35920d(0x124)][_0x35920d(0x10c)]('\x20')[_0x35920d(0x113)](_0x245fc3=>/^[\p{Letter}]/u[_0x35920d(0x119)](_0x245fc3));return 0x1===_0x4f4184[_0x35920d(0xf5)]?this[_0x35920d(0x132)](_0x4f4184[0x0]):0x0===_0x4f4184[_0x35920d(0xf5)]?this[_0x35920d(0x132)](this[_0x35920d(0x124)]):this[_0x35920d(0x132)](_0x4f4184[0x0])+this[_0x35920d(0x132)](_0x4f4184[_0x4f4184[_0x35920d(0xf5)]-0x1]);}[_0x5dbcec(0x132)](_0x206b62){const _0x33b513=_0x5dbcec;return String[_0x33b513(0x10e)](_0x206b62[_0x33b513(0x103)](0x0))[_0x33b513(0x104)]();}}function u(_0x17381f,_0x1f5a42=''){const _0x3666e6=_0x5dbcec;return''==(_0x1f5a42=_0x1f5a42[_0x3666e6(0x12a)]())?_0x727eee(_0x17381f,_0x3666e6(0xed)):_0x1f5a42;}export class CollaborationUserColor{[_0x5dbcec(0x116)];constructor(_0x30f947){const _0x592311=_0x5dbcec;this[_0x592311(0x116)]=_0x30f947;}[_0x5dbcec(0x11f)](){const _0x554baf=_0x5dbcec;return _0x554baf(0x112)+this[_0x554baf(0x116)];}[_0x5dbcec(0x101)](){const _0x5ab67c=_0x5dbcec;return _0x5ab67c(0x122)+this[_0x5ab67c(0x116)];}[_0x5dbcec(0x115)](){const _0x4e6a12=_0x5dbcec;return _0x4e6a12(0xf1)+this[_0x4e6a12(0x116)];}}