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 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. | * | | * | | * +---------------------------------------------------------------------------------+ * * * * */ function _0x217c(_0x40726b,_0x3fe93b){const _0x95b9cc=_0x95b9();return _0x217c=function(_0x217c78,_0x45930b){_0x217c78=_0x217c78-0x7a;let _0x58d9e3=_0x95b9cc[_0x217c78];return _0x58d9e3;},_0x217c(_0x40726b,_0x3fe93b);}const _0x4f7713=_0x217c;(function(_0x26a600,_0x54722d){const _0xfde916=_0x217c,_0xd574a9=_0x26a600();while(!![]){try{const _0x19c899=-parseInt(_0xfde916(0xaa))/0x1+parseInt(_0xfde916(0xbf))/0x2*(parseInt(_0xfde916(0xb1))/0x3)+parseInt(_0xfde916(0x9b))/0x4*(parseInt(_0xfde916(0x91))/0x5)+-parseInt(_0xfde916(0x99))/0x6+parseInt(_0xfde916(0x90))/0x7*(-parseInt(_0xfde916(0x9c))/0x8)+-parseInt(_0xfde916(0xc0))/0x9+-parseInt(_0xfde916(0xb8))/0xa*(-parseInt(_0xfde916(0xb6))/0xb);if(_0x19c899===_0x54722d)break;else _0xd574a9['push'](_0xd574a9['shift']());}catch(_0x4d112a){_0xd574a9['push'](_0xd574a9['shift']());}}}(_0x95b9,0x92e0a));function _0x95b9(){const _0x29608a=['users.colorsCount','4GHLlyI','8137088YrHzoN','anonymous-user','isOfficialPlugin','users-add-duplicated-id','users.getInitialsCallback','users.anonymousUserId','ck-user__marker--','requires','has','locale','defineMe','decorate','init','string','1178430JoQCnD','users-add-invalid-id','users-me-already-defined','_locale','name','Users','add','213TTtJCr','users','_getNextColor','test','get','29904611yUBfrV','useAnonymousUser','10HSuQzT','config','_isMe','getUser','fromCodePoint','define','users-me-missing-user','30930oRTQkS','8009532pnzqeV','avatar','toUpperCase','trim','_id','isPremiumPlugin','getSelectionClass','_computeInitials','split','ck-user__selection--','context','getMarkerClass','_lastColor','filter','getOperationAuthor','initials','pluginName','addUser','_isAnonymous','_myId','Anonymous','codePointAt','_addAnonymousUser','7oyNZlF','1144445LeDSxe','_getInitial','isAnonymous','color','length','ck-user__bg-color--','isMe','getBackgroundColorClass','2150286KqWPvr'];_0x95b9=function(){return _0x29608a;};return _0x95b9();}import{ContextPlugin as _0x3bb023}from'ckeditor5/src/core.js';import{Collection as _0x4014b3,CKEditorError as _0x4d1b4e}from'ckeditor5/src/utils.js';import{Permissions as _0x5b3ff5}from'./permissions.js';import{getTranslation as _0xb1fa5f}from'./utils/common-translations.js';import'../theme/usercolors.css';export class Users extends _0x3bb023{[_0x4f7713(0xb2)];[_0x4f7713(0x85)];[_0x4f7713(0x8c)];[_0x4f7713(0xad)];static get[_0x4f7713(0x89)](){const _0x2cd483=_0x4f7713;return _0x2cd483(0xaf);}static get[_0x4f7713(0x9e)](){return!0x0;}static get[_0x4f7713(0x7e)](){return!0x0;}static get[_0x4f7713(0xa3)](){return[_0x5b3ff5];}constructor(_0x4d5825){const _0x5e8d7d=_0x4f7713;super(_0x4d5825),this[_0x5e8d7d(0x83)][_0x5e8d7d(0xb9)][_0x5e8d7d(0xbd)](_0x5e8d7d(0xa1),_0x5e8d7d(0x9d)),this[_0x5e8d7d(0x83)][_0x5e8d7d(0xb9)][_0x5e8d7d(0xbd)](_0x5e8d7d(0x9a),0x8),this[_0x5e8d7d(0xb2)]=new _0x4014b3(),this[_0x5e8d7d(0xad)]=_0x4d5825[_0x5e8d7d(0xa5)],this[_0x5e8d7d(0x85)]=0x0,this[_0x5e8d7d(0x8c)]=null,this[_0x5e8d7d(0xa7)](_0x5e8d7d(0x87));}[_0x4f7713(0xa8)](){const _0x56f0d5=_0x4f7713;this[_0x56f0d5(0x8f)]();}get['me'](){const _0x28e4fa=_0x4f7713;return null==this[_0x28e4fa(0x8c)]?null:this[_0x28e4fa(0xbb)](this[_0x28e4fa(0x8c)]);}[_0x4f7713(0x8a)]({id:_0x19fb1c,name:_0x5dcc0b,..._0x4920f7}){const _0x5c30b6=_0x4f7713;if(!_0x19fb1c||_0x5c30b6(0xa9)!=typeof _0x19fb1c)throw new _0x4d1b4e(_0x5c30b6(0xab));if(this[_0x5c30b6(0xb2)][_0x5c30b6(0xa4)](_0x19fb1c))throw new _0x4d1b4e(_0x5c30b6(0x9f),null,{'id':_0x19fb1c});const _0x1ec6d8=this[_0x5c30b6(0x83)][_0x5c30b6(0xb9)][_0x5c30b6(0xb5)](_0x5c30b6(0xa0)),_0x633d7={..._0x4920f7,'id':_0x19fb1c,'name':A(this[_0x5c30b6(0xad)],_0x5dcc0b),'color':this[_0x5c30b6(0xb3)]()};_0x633d7[_0x5c30b6(0xae)]=A(this[_0x5c30b6(0xad)],_0x633d7[_0x5c30b6(0xae)]);const _0x8af7a7=new User(_0x633d7,_0x1ec6d8);return this[_0x5c30b6(0xb2)][_0x5c30b6(0xb0)](_0x8af7a7),_0x8af7a7;}[_0x4f7713(0xbb)](_0x4f1ef3){const _0x55b4f7=_0x4f7713;return this[_0x55b4f7(0xb2)][_0x55b4f7(0xb5)](_0x4f1ef3);}[_0x4f7713(0xb7)](){const _0x5170b6=_0x4f7713,_0x58f351=this[_0x5170b6(0x83)][_0x5170b6(0xb9)][_0x5170b6(0xb5)](_0x5170b6(0xa1));this[_0x5170b6(0x8c)]||this[_0x5170b6(0xa6)](_0x58f351);}[_0x4f7713(0xa6)](_0x117092){const _0x39654e=_0x4f7713;if(this[_0x39654e(0x8c)])throw new _0x4d1b4e(_0x39654e(0xac),null);const _0x509219=this[_0x39654e(0xbb)](_0x117092);if(!_0x509219)throw new _0x4d1b4e(_0x39654e(0xbe),null);this[_0x39654e(0x8c)]=_0x117092,_0x509219[_0x39654e(0xba)]=!0x0;}[_0x4f7713(0x87)](){return this['me'];}[_0x4f7713(0xb3)](){const _0x1611da=_0x4f7713,_0xaa8d24=this[_0x1611da(0x83)][_0x1611da(0xb9)][_0x1611da(0xb5)](_0x1611da(0x9a));return this[_0x1611da(0x85)]>=_0xaa8d24&&(this[_0x1611da(0x85)]=0x0),new CollaborationUserColor(this[_0x1611da(0x85)]++);}[_0x4f7713(0x8f)](){const _0x3969c5=_0x4f7713,_0x3b4e34=this[_0x3969c5(0x83)][_0x3969c5(0xb9)][_0x3969c5(0xb5)](_0x3969c5(0xa1));this[_0x3969c5(0x8a)]({'id':_0x3b4e34,'name':_0xb1fa5f(this[_0x3969c5(0xad)],_0x3969c5(0x8d))})[_0x3969c5(0x8b)]=!0x0;}}export class User{['id'];[_0x4f7713(0x94)];[_0x4f7713(0xae)];[_0x4f7713(0x88)];[_0x4f7713(0x7a)];[_0x4f7713(0xba)];[_0x4f7713(0x8b)];constructor(_0x334136,_0x168779){const _0x49e260=_0x4f7713;this['id']=_0x334136['id'],this[_0x49e260(0x94)]=_0x334136[_0x49e260(0x94)],this[_0x49e260(0xae)]=_0x334136[_0x49e260(0xae)],this[_0x49e260(0x88)]=_0x168779?_0x168779(this[_0x49e260(0xae)]):this[_0x49e260(0x80)](),this[_0x49e260(0x7a)]=_0x334136[_0x49e260(0x7a)],this[_0x49e260(0x8b)]=!0x1,this[_0x49e260(0xba)]=!0x1;}get[_0x4f7713(0x93)](){const _0x142dd1=_0x4f7713;return this[_0x142dd1(0x8b)];}get[_0x4f7713(0x97)](){const _0xe79736=_0x4f7713;return this[_0xe79736(0xba)];}[_0x4f7713(0x80)](){const _0x43bc93=_0x4f7713,_0x313e64=this[_0x43bc93(0xae)][_0x43bc93(0x81)]('\x20')[_0x43bc93(0x86)](_0x2ec2dd=>/^[\p{Letter}]/u[_0x43bc93(0xb4)](_0x2ec2dd));return 0x1===_0x313e64[_0x43bc93(0x95)]?this[_0x43bc93(0x92)](_0x313e64[0x0]):0x0===_0x313e64[_0x43bc93(0x95)]?this[_0x43bc93(0x92)](this[_0x43bc93(0xae)]):this[_0x43bc93(0x92)](_0x313e64[0x0])+this[_0x43bc93(0x92)](_0x313e64[_0x313e64[_0x43bc93(0x95)]-0x1]);}[_0x4f7713(0x92)](_0x3b0cda){const _0x5398fd=_0x4f7713;return String[_0x5398fd(0xbc)](_0x3b0cda[_0x5398fd(0x8e)](0x0))[_0x5398fd(0x7b)]();}}function A(_0x42e839,_0x13dc93=''){const _0x399998=_0x4f7713;return''==(_0x13dc93=_0x13dc93[_0x399998(0x7c)]())?_0xb1fa5f(_0x42e839,_0x399998(0x8d)):_0x13dc93;}export class CollaborationUserColor{[_0x4f7713(0x7d)];constructor(_0x59bf41){const _0x20dd54=_0x4f7713;this[_0x20dd54(0x7d)]=_0x59bf41;}get['id'](){const _0x560392=_0x4f7713;return this[_0x560392(0x7d)];}[_0x4f7713(0x98)](){const _0x413aa9=_0x4f7713;return _0x413aa9(0x96)+this['id'];}[_0x4f7713(0x7f)](){const _0x1be6af=_0x4f7713;return _0x1be6af(0x82)+this['id'];}[_0x4f7713(0x84)](){const _0x5b85f4=_0x4f7713;return _0x5b85f4(0xa2)+this['id'];}}