@ckeditor/ckeditor5-collaboration-core 40.0.0 → 40.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -17
- package/LICENSE.md +5 -5
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/augmentation.d.ts +38 -38
- package/src/collaborationhistory.d.ts +21 -21
- package/src/collaborationoperation.d.ts +28 -28
- package/src/config.d.ts +102 -102
- package/src/index.d.ts +19 -18
- package/src/index.js +1 -1
- package/src/permissions.d.ts +46 -45
- package/src/permissions.js +1 -1
- package/src/suggestionstyles.d.ts +12 -12
- package/src/users/view/userview.d.ts +16 -16
- package/src/users/view/userview.js +1 -1
- package/src/users.d.ts +161 -161
- package/src/users.js +1 -1
- package/src/utils/common-translations.d.ts +9 -9
- package/src/utils/common-translations.js +1 -1
- package/src/utils/confirmmixin.d.ts +20 -20
- package/src/utils/confirmmixin.js +1 -1
- package/src/utils/confirmview.d.ts +13 -13
- package/src/utils/confirmview.js +1 -1
- package/src/utils/getdatetimeformatter.d.ts +29 -29
- package/src/utils/getdatetimeformatter.js +1 -1
- package/src/utils/getmarkerdomelement.d.ts +22 -22
- package/src/utils/getmarkerdomelement.js +1 -1
- package/src/utils/hashobject.d.ts +8 -8
- package/src/utils/hashobject.js +1 -1
- package/src/utils/sanitizeEditorConfig.d.ts +15 -15
- package/src/utils/sanitizeEditorConfig.js +1 -1
- package/src/utils/surroundingmarkersdetector.d.ts +16 -0
- package/src/utils/surroundingmarkersdetector.js +23 -0
- package/src/utils/trim-html.d.ts +16 -16
- package/src/utils/trim-html.js +1 -1
- package/theme/suggestionmarker.css +2 -2
package/src/permissions.d.ts
CHANGED
@@ -1,45 +1,46 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
/**
|
6
|
-
* @module collaboration-core/permissions
|
7
|
-
* @publicApi
|
8
|
-
*/
|
9
|
-
import { ContextPlugin } from 'ckeditor5/src/core';
|
10
|
-
/**
|
11
|
-
* The `Permissions` plugin manages permissions set for the local user.
|
12
|
-
*
|
13
|
-
* Following is the list of all defined permissions:
|
14
|
-
*
|
15
|
-
* * `document:write` - modify the content of the document,
|
16
|
-
* * `comment:write` - create, edit and remove own comments and create,
|
17
|
-
*
|
18
|
-
* * `comment:
|
19
|
-
*
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
23
|
-
*
|
24
|
-
*
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
*
|
37
|
-
*
|
38
|
-
*
|
39
|
-
* is not
|
40
|
-
*
|
41
|
-
*
|
42
|
-
* @param
|
43
|
-
|
44
|
-
|
45
|
-
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module collaboration-core/permissions
|
7
|
+
* @publicApi
|
8
|
+
*/
|
9
|
+
import { ContextPlugin } from 'ckeditor5/src/core';
|
10
|
+
/**
|
11
|
+
* The `Permissions` plugin manages permissions set for the local user.
|
12
|
+
*
|
13
|
+
* Following is the list of all defined permissions:
|
14
|
+
*
|
15
|
+
* * `document:write` - modify the content of the document, and resolve comment threads created by any user,
|
16
|
+
* * `comment:write` - create, edit and remove own comments and create, remove own comment threads,
|
17
|
+
* and resolve comment threads created by any user,
|
18
|
+
* * `comment:admin` - resolve and remove comment threads created by other users (enables `comment:write`).
|
19
|
+
* * `comment:modify_all` - edit and remove any comments created by other users.
|
20
|
+
*
|
21
|
+
* For example, a user with `comment:write` permission but with no `document:write` permission will be able to add
|
22
|
+
* comments but will not be able to change the document data (comments-only mode).
|
23
|
+
*
|
24
|
+
* By default, the following permissions are set: `document:write`, `comment:write`, `comment:admin`.
|
25
|
+
*
|
26
|
+
* Permissions are handled separately for each channel id (for each editor instance and context instance).
|
27
|
+
*
|
28
|
+
* See also the {@glink features/collaboration/users#user-permissions User permissions} guide to learn how to use this plugin.
|
29
|
+
*/
|
30
|
+
export default class Permissions extends ContextPlugin {
|
31
|
+
/**
|
32
|
+
* @inheritDoc
|
33
|
+
*/
|
34
|
+
static get pluginName(): "Permissions";
|
35
|
+
/**
|
36
|
+
* Sets permissions for editor/context instance with given `channelId`.
|
37
|
+
*
|
38
|
+
* If `channelId` is not set, the channel id of the editor/context to which the plugin was added will be used.
|
39
|
+
* This means that it is not required if the plugin is added to the editor configuration and {@link module:core/context~Context}
|
40
|
+
* is not used.
|
41
|
+
*
|
42
|
+
* @param permissions Permissions to set.
|
43
|
+
* @param channelId The channel ID.
|
44
|
+
*/
|
45
|
+
setPermissions(permissions: Array<string>, channelId?: string): void;
|
46
|
+
}
|
package/src/permissions.js
CHANGED
@@ -20,4 +20,4 @@
|
|
20
20
|
*
|
21
21
|
*
|
22
22
|
*/
|
23
|
-
const
|
23
|
+
const _0x1c8f=['commands','CommentsOnly','setPermissions','get','no-permissions','isEnabled','noPermissions','permissions-set-permissions-invalid-channel-id','enableReadOnlyMode','document:write','CommentsRepository','editors','includes','comment:write','context','collaboration.channelId','pluginName','comment:modify_all','addCommentThread','plugins','Permissions','has','comment:admin','config','clearForceDisabled'];(function(_0x3f6bb3,_0x1c8fbf){const _0x3671bb=function(_0x7a50a9){while(--_0x7a50a9){_0x3f6bb3['push'](_0x3f6bb3['shift']());}};_0x3671bb(++_0x1c8fbf);}(_0x1c8f,0x16e));const _0x3671=function(_0x3f6bb3,_0x1c8fbf){_0x3f6bb3=_0x3f6bb3-0x0;let _0x3671bb=_0x1c8f[_0x3f6bb3];return _0x3671bb;};import{ContextPlugin as _0x35894c,Editor as _0x40bf17}from'ckeditor5/src/core';import{CKEditorError as _0xc209e2}from'ckeditor5/src/utils';export default class n extends _0x35894c{static get[_0x3671('0x0')](){return _0x3671('0x4');}[_0x3671('0xb')](_0x5444ca,_0x2dfb4b){let _0x57c5d0;if(_0x2dfb4b||(_0x2dfb4b=this[_0x3671('0x17')]['config'][_0x3671('0xc')](_0x3671('0x18'))),this['context']['config']['get']('collaboration.channelId')==_0x2dfb4b?_0x57c5d0=this[_0x3671('0x17')]:_0x3671('0x14')in this['context']&&this[_0x3671('0x17')][_0x3671('0x14')]&&(_0x57c5d0=this['context'][_0x3671('0x14')]['find'](_0x4162a2=>_0x4162a2[_0x3671('0x7')]['get']('collaboration.channelId')==_0x2dfb4b)),!_0x57c5d0)throw new _0xc209e2(_0x3671('0x10'),null);const _0x2fabd8=_0x57c5d0[_0x3671('0x3')],_0x5cc24f=_0x2fabd8[_0x3671('0x5')]('CommentsRepository')?_0x2fabd8['get'](_0x3671('0x13')):void 0x0,_0x14ad9f=_0x2fabd8[_0x3671('0x5')]('CommentsOnly')&&_0x2fabd8[_0x3671('0xc')](_0x3671('0xa')),_0x38f347=_0x5444ca[_0x3671('0x15')](_0x3671('0x12')),_0xd85eb1=_0x5444ca[_0x3671('0x15')](_0x3671('0x1')),_0xf8c5a0=_0x5444ca[_0x3671('0x15')](_0x3671('0x6')),_0x3a0e84=_0x5444ca[_0x3671('0x15')](_0x3671('0x16')),_0x243a6b=_0x3a0e84||_0xf8c5a0,_0x566783=_0x243a6b||_0xd85eb1,_0x5b1e4d=_0x38f347||_0x243a6b;(_0x14ad9f&&(_0x14ad9f[_0x3671('0xe')]=!_0x38f347&&_0x566783),_0x57c5d0 instanceof _0x40bf17)&&(!(_0x38f347||_0x566783&&_0x5cc24f)?_0x57c5d0[_0x3671('0x11')]('no-permissions'):_0x57c5d0['disableReadOnlyMode'](_0x3671('0xd')));if(_0x5cc24f){_0x5cc24f['setPermissions']({'admin':_0xf8c5a0,'modifyAll':_0xd85eb1,'write':_0x3a0e84,'resolve':_0x5b1e4d},_0x2dfb4b);const _0x496807=_0x57c5d0 instanceof _0x40bf17&&_0x57c5d0[_0x3671('0x9')][_0x3671('0xc')](_0x3671('0x2'));_0x496807&&(_0x243a6b?_0x496807[_0x3671('0x8')](_0x3671('0xf')):_0x496807['forceDisabled']('noPermissions'));}}}
|
@@ -1,12 +1,12 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
import '../theme/suggestion.css';
|
6
|
-
import '../theme/suggestionmarker.css';
|
7
|
-
import '../theme/integrations/image.css';
|
8
|
-
import '../theme/integrations/horizontalline.css';
|
9
|
-
import '../theme/integrations/mediaembed.css';
|
10
|
-
import '../theme/integrations/pagebreak.css';
|
11
|
-
import '../theme/integrations/table.css';
|
12
|
-
import '../theme/integrations/codeblock.css';
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
import '../theme/suggestion.css';
|
6
|
+
import '../theme/suggestionmarker.css';
|
7
|
+
import '../theme/integrations/image.css';
|
8
|
+
import '../theme/integrations/horizontalline.css';
|
9
|
+
import '../theme/integrations/mediaembed.css';
|
10
|
+
import '../theme/integrations/pagebreak.css';
|
11
|
+
import '../theme/integrations/table.css';
|
12
|
+
import '../theme/integrations/codeblock.css';
|
@@ -1,16 +1,16 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
/**
|
6
|
-
* @module collaboration-core/users/view/userview
|
7
|
-
*/
|
8
|
-
import { View, type TemplateDefinition } from 'ckeditor5/src/ui';
|
9
|
-
import type { Locale } from 'ckeditor5/src/utils';
|
10
|
-
import type { User } from '../../users';
|
11
|
-
import '../../../theme/users.css';
|
12
|
-
export default class UserView extends View {
|
13
|
-
name: string;
|
14
|
-
notificationView: TemplateDefinition | null;
|
15
|
-
constructor(locale: Locale, user: User, notificationText?: null | string);
|
16
|
-
}
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module collaboration-core/users/view/userview
|
7
|
+
*/
|
8
|
+
import { View, type TemplateDefinition } from 'ckeditor5/src/ui';
|
9
|
+
import type { Locale } from 'ckeditor5/src/utils';
|
10
|
+
import type { User } from '../../users';
|
11
|
+
import '../../../theme/users.css';
|
12
|
+
export default class UserView extends View {
|
13
|
+
name: string;
|
14
|
+
notificationView: TemplateDefinition | null;
|
15
|
+
constructor(locale: Locale, user: User, notificationText?: null | string);
|
16
|
+
}
|
@@ -20,4 +20,4 @@
|
|
20
20
|
*
|
21
21
|
*
|
22
22
|
*/
|
23
|
-
const
|
23
|
+
const _0x1df4=['url(\x27','ck-user__notification','ck-user__avatar','avatar','div','content','ck\x20ck-user__name\x20ck-user__name--hidden','name','extendTemplate','initials','setTemplate','push','ck-user','ck\x20ck-user__name','ck-user__img','isAnonymous','notificationView','ck-user__icon'];(function(_0xc72dfb,_0x1df4bc){const _0x2eccc3=function(_0x91a364){while(--_0x91a364){_0xc72dfb['push'](_0xc72dfb['shift']());}};_0x2eccc3(++_0x1df4bc);}(_0x1df4,0x98));const _0x2ecc=function(_0xc72dfb,_0x1df4bc){_0xc72dfb=_0xc72dfb-0x0;let _0x2eccc3=_0x1df4[_0xc72dfb];return _0x2eccc3;};import{View as _0x24c3c8,IconView as _0x2cbf3f}from'ckeditor5/src/ui';import _0x172991 from'../../../theme/icons/notification.svg';import'../../../theme/users.css';export default class C extends _0x24c3c8{constructor(_0xe341e3,_0x39ff41,_0x100ea0){super(_0xe341e3),this[_0x2ecc('0x11')]=_0x39ff41[_0x2ecc('0x11')],this['notificationView']=null;const _0x671f48=['ck',_0x2ecc('0x6')];if(_0x39ff41[_0x2ecc('0x7')]&&_0x671f48[_0x2ecc('0x3')]('ck-user__anonymous'),_0x39ff41['avatar']&&_0x671f48[_0x2ecc('0x3')](_0x2ecc('0xc')),_0x100ea0){const _0x127798=new _0x2cbf3f();_0x127798[_0x2ecc('0x0')]({'attributes':{'class':[_0x2ecc('0x9')]}}),_0x127798[_0x2ecc('0xf')]=_0x172991,this[_0x2ecc('0x8')]={'tag':'div','attributes':{'class':['ck',_0x2ecc('0xb')],'data-cke-tooltip-position':'n','data-cke-tooltip-text':_0x100ea0},'children':[_0x127798]};}const _0x5ed59c=[{'tag':_0x2ecc('0xe'),'attributes':{'class':_0x671f48,'style':{'background-image':_0x39ff41[_0x2ecc('0xd')]?_0x2ecc('0xa')+_0x39ff41[_0x2ecc('0xd')]+'\x27)':''}}},{'tag':_0x2ecc('0xe'),'attributes':{'class':_0x39ff41[_0x2ecc('0xd')]?_0x2ecc('0x10'):_0x2ecc('0x5')},'children':[{'text':_0x39ff41[_0x2ecc('0x1')]}]}];this['notificationView']&&_0x5ed59c[_0x2ecc('0x3')](this[_0x2ecc('0x8')]),this[_0x2ecc('0x2')]({'tag':_0x2ecc('0xe'),'attributes':{'class':['ck',_0x2ecc('0x4')],'data-user-id':_0x39ff41['id']},'children':_0x5ed59c});}}
|
package/src/users.d.ts
CHANGED
@@ -1,161 +1,161 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
/**
|
6
|
-
* @module collaboration-core/users
|
7
|
-
* @publicApi
|
8
|
-
*/
|
9
|
-
import { ContextPlugin, type Context, type Editor } from 'ckeditor5/src/core';
|
10
|
-
import { Collection } from 'ckeditor5/src/utils';
|
11
|
-
import Permissions from './permissions';
|
12
|
-
import '../theme/usercolors.css';
|
13
|
-
/**
|
14
|
-
* The `Users` plugin provides the basic interface for setting and getting users involved in the document editing process.
|
15
|
-
*/
|
16
|
-
export default class Users extends ContextPlugin {
|
17
|
-
licenseKey: string;
|
18
|
-
/**
|
19
|
-
* Holds all {@link module:collaboration-core/users~User users} added to the editor.
|
20
|
-
*
|
21
|
-
* Note, that the {@link module:collaboration-core/users~User#isAnonymous anonymous user} is always present in the editor.
|
22
|
-
* You may want to filter it out when processing the users lists.
|
23
|
-
*
|
24
|
-
* ```ts
|
25
|
-
* for ( const user of editor.plugins.get( 'Users' ).users ) {
|
26
|
-
* if ( !user.isAnonymous ) {
|
27
|
-
* console.log( user.name );
|
28
|
-
* }
|
29
|
-
* }
|
30
|
-
* ```
|
31
|
-
*
|
32
|
-
* Use {@link #addUser} to add a new user.
|
33
|
-
*/
|
34
|
-
readonly users: Collection<User>;
|
35
|
-
/**
|
36
|
-
* @inheritDoc
|
37
|
-
*/
|
38
|
-
static get pluginName(): "Users";
|
39
|
-
/**
|
40
|
-
* @inheritDoc
|
41
|
-
*/
|
42
|
-
static get requires(): readonly [typeof Permissions];
|
43
|
-
/**
|
44
|
-
* @inheritDoc
|
45
|
-
*/
|
46
|
-
constructor(context: Context | Editor);
|
47
|
-
/**
|
48
|
-
* @inheritDoc
|
49
|
-
*/
|
50
|
-
init(): void;
|
51
|
-
/**
|
52
|
-
* A reference to the local user or `null` if it has not been set.
|
53
|
-
*/
|
54
|
-
get me(): User | null;
|
55
|
-
/**
|
56
|
-
* Adds a new user to the list of users.
|
57
|
-
*/
|
58
|
-
addUser({ id, name, ...additionalData }: Partial<UserData>): User;
|
59
|
-
/**
|
60
|
-
* Returns the user with a given ID.
|
61
|
-
*/
|
62
|
-
getUser(id: string): User | null;
|
63
|
-
/**
|
64
|
-
* Sets an {@link module:collaboration-core/users~User#isAnonymous anonymous user} as {@link #me the local user}.
|
65
|
-
*
|
66
|
-
* The local user ID will be set to the value of `config.users.anonymousUserId` property. All actions performed by the local user
|
67
|
-
* will be contributed to the anonymous user.
|
68
|
-
*/
|
69
|
-
useAnonymousUser(): void;
|
70
|
-
/**
|
71
|
-
* Sets the user with the given ID as the local user ({@link #me}).
|
72
|
-
*
|
73
|
-
* The local user can be only set once (this includes setting anonymous as the local user).
|
74
|
-
*/
|
75
|
-
defineMe(userId: string): void;
|
76
|
-
/**
|
77
|
-
* Returns the author of the operation. It returns {@link #me} by default if it is not overwritten.
|
78
|
-
*/
|
79
|
-
getOperationAuthor(): User | null;
|
80
|
-
/**
|
81
|
-
* @inheritDoc
|
82
|
-
*/
|
83
|
-
destroy(): void;
|
84
|
-
}
|
85
|
-
/**
|
86
|
-
* The representation of a single user that is involved in document editing.
|
87
|
-
*/
|
88
|
-
export declare class User {
|
89
|
-
/**
|
90
|
-
* The ID of the user.
|
91
|
-
*/
|
92
|
-
id: string;
|
93
|
-
/**
|
94
|
-
* CSS colors classes object for the user.
|
95
|
-
*/
|
96
|
-
color: Color;
|
97
|
-
/**
|
98
|
-
* The name of the user.
|
99
|
-
*/
|
100
|
-
name: string;
|
101
|
-
/**
|
102
|
-
* The URL pointing to the image with the avatar of the user.
|
103
|
-
*
|
104
|
-
* If avatar is not set, default avatar is used.
|
105
|
-
*/
|
106
|
-
avatar: string | undefined;
|
107
|
-
/**
|
108
|
-
* @param data User data.
|
109
|
-
* @param data.id The ID of the user.
|
110
|
-
* @param data.color A helper object to generate CSS classes with the user color in the UI.
|
111
|
-
* @param data.name The name of the user.
|
112
|
-
* @param data.avatar The URL to the user avatar.
|
113
|
-
*/
|
114
|
-
constructor(data: UserData);
|
115
|
-
/**
|
116
|
-
* Is `true` for the anonymous user, `false` otherwise.
|
117
|
-
*
|
118
|
-
* The anonymous user is used when there is no defined user for given resource.
|
119
|
-
*
|
120
|
-
* The situations when the anonymous user is used will depend on your application. For example, it can be used when the editor can be
|
121
|
-
* used by "guest" users of your application, or when the original user's account was removed.
|
122
|
-
*/
|
123
|
-
get isAnonymous(): boolean;
|
124
|
-
/**
|
125
|
-
* The initials of the user.
|
126
|
-
*
|
127
|
-
* The initials are composed from the user name's first and last words:
|
128
|
-
*
|
129
|
-
* * for `Joe Doe`, the initials are `JD`,
|
130
|
-
* * for `Anonymous` the initials are `A`,
|
131
|
-
* * for `Katie John-Newman` the initials are `KJ`,
|
132
|
-
* * for `Adam Daniel Smith` the initials are `AS`.
|
133
|
-
*/
|
134
|
-
get initials(): string;
|
135
|
-
}
|
136
|
-
/**
|
137
|
-
* The color object used to generate specified CSS classes with an individual color number assigned to the user.
|
138
|
-
*/
|
139
|
-
declare class Color {
|
140
|
-
constructor(colorId: number);
|
141
|
-
/**
|
142
|
-
* Returns CSS class for user avatar background color.
|
143
|
-
*/
|
144
|
-
getBackgroundColorClass(): string;
|
145
|
-
/**
|
146
|
-
* Returns CSS class for user selection highlight (the selected range).
|
147
|
-
*/
|
148
|
-
getSelectionClass(): string;
|
149
|
-
/**
|
150
|
-
* Returns CSS class for user caret position element (the pipe).
|
151
|
-
*/
|
152
|
-
getMarkerClass(): string;
|
153
|
-
}
|
154
|
-
type UserData = {
|
155
|
-
id: string;
|
156
|
-
color: Color;
|
157
|
-
name: string;
|
158
|
-
avatar?: string;
|
159
|
-
_isAnonymous?: boolean;
|
160
|
-
};
|
161
|
-
export {};
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module collaboration-core/users
|
7
|
+
* @publicApi
|
8
|
+
*/
|
9
|
+
import { ContextPlugin, type Context, type Editor } from 'ckeditor5/src/core';
|
10
|
+
import { Collection } from 'ckeditor5/src/utils';
|
11
|
+
import Permissions from './permissions';
|
12
|
+
import '../theme/usercolors.css';
|
13
|
+
/**
|
14
|
+
* The `Users` plugin provides the basic interface for setting and getting users involved in the document editing process.
|
15
|
+
*/
|
16
|
+
export default class Users extends ContextPlugin {
|
17
|
+
licenseKey: string;
|
18
|
+
/**
|
19
|
+
* Holds all {@link module:collaboration-core/users~User users} added to the editor.
|
20
|
+
*
|
21
|
+
* Note, that the {@link module:collaboration-core/users~User#isAnonymous anonymous user} is always present in the editor.
|
22
|
+
* You may want to filter it out when processing the users lists.
|
23
|
+
*
|
24
|
+
* ```ts
|
25
|
+
* for ( const user of editor.plugins.get( 'Users' ).users ) {
|
26
|
+
* if ( !user.isAnonymous ) {
|
27
|
+
* console.log( user.name );
|
28
|
+
* }
|
29
|
+
* }
|
30
|
+
* ```
|
31
|
+
*
|
32
|
+
* Use {@link #addUser} to add a new user.
|
33
|
+
*/
|
34
|
+
readonly users: Collection<User>;
|
35
|
+
/**
|
36
|
+
* @inheritDoc
|
37
|
+
*/
|
38
|
+
static get pluginName(): "Users";
|
39
|
+
/**
|
40
|
+
* @inheritDoc
|
41
|
+
*/
|
42
|
+
static get requires(): readonly [typeof Permissions];
|
43
|
+
/**
|
44
|
+
* @inheritDoc
|
45
|
+
*/
|
46
|
+
constructor(context: Context | Editor);
|
47
|
+
/**
|
48
|
+
* @inheritDoc
|
49
|
+
*/
|
50
|
+
init(): void;
|
51
|
+
/**
|
52
|
+
* A reference to the local user or `null` if it has not been set.
|
53
|
+
*/
|
54
|
+
get me(): User | null;
|
55
|
+
/**
|
56
|
+
* Adds a new user to the list of users.
|
57
|
+
*/
|
58
|
+
addUser({ id, name, ...additionalData }: Partial<UserData>): User;
|
59
|
+
/**
|
60
|
+
* Returns the user with a given ID.
|
61
|
+
*/
|
62
|
+
getUser(id: string): User | null;
|
63
|
+
/**
|
64
|
+
* Sets an {@link module:collaboration-core/users~User#isAnonymous anonymous user} as {@link #me the local user}.
|
65
|
+
*
|
66
|
+
* The local user ID will be set to the value of `config.users.anonymousUserId` property. All actions performed by the local user
|
67
|
+
* will be contributed to the anonymous user.
|
68
|
+
*/
|
69
|
+
useAnonymousUser(): void;
|
70
|
+
/**
|
71
|
+
* Sets the user with the given ID as the local user ({@link #me}).
|
72
|
+
*
|
73
|
+
* The local user can be only set once (this includes setting anonymous as the local user).
|
74
|
+
*/
|
75
|
+
defineMe(userId: string): void;
|
76
|
+
/**
|
77
|
+
* Returns the author of the operation. It returns {@link #me} by default if it is not overwritten.
|
78
|
+
*/
|
79
|
+
getOperationAuthor(): User | null;
|
80
|
+
/**
|
81
|
+
* @inheritDoc
|
82
|
+
*/
|
83
|
+
destroy(): void;
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* The representation of a single user that is involved in document editing.
|
87
|
+
*/
|
88
|
+
export declare class User {
|
89
|
+
/**
|
90
|
+
* The ID of the user.
|
91
|
+
*/
|
92
|
+
id: string;
|
93
|
+
/**
|
94
|
+
* CSS colors classes object for the user.
|
95
|
+
*/
|
96
|
+
color: Color;
|
97
|
+
/**
|
98
|
+
* The name of the user.
|
99
|
+
*/
|
100
|
+
name: string;
|
101
|
+
/**
|
102
|
+
* The URL pointing to the image with the avatar of the user.
|
103
|
+
*
|
104
|
+
* If avatar is not set, default avatar is used.
|
105
|
+
*/
|
106
|
+
avatar: string | undefined;
|
107
|
+
/**
|
108
|
+
* @param data User data.
|
109
|
+
* @param data.id The ID of the user.
|
110
|
+
* @param data.color A helper object to generate CSS classes with the user color in the UI.
|
111
|
+
* @param data.name The name of the user.
|
112
|
+
* @param data.avatar The URL to the user avatar.
|
113
|
+
*/
|
114
|
+
constructor(data: UserData);
|
115
|
+
/**
|
116
|
+
* Is `true` for the anonymous user, `false` otherwise.
|
117
|
+
*
|
118
|
+
* The anonymous user is used when there is no defined user for given resource.
|
119
|
+
*
|
120
|
+
* The situations when the anonymous user is used will depend on your application. For example, it can be used when the editor can be
|
121
|
+
* used by "guest" users of your application, or when the original user's account was removed.
|
122
|
+
*/
|
123
|
+
get isAnonymous(): boolean;
|
124
|
+
/**
|
125
|
+
* The initials of the user.
|
126
|
+
*
|
127
|
+
* The initials are composed from the user name's first and last words:
|
128
|
+
*
|
129
|
+
* * for `Joe Doe`, the initials are `JD`,
|
130
|
+
* * for `Anonymous` the initials are `A`,
|
131
|
+
* * for `Katie John-Newman` the initials are `KJ`,
|
132
|
+
* * for `Adam Daniel Smith` the initials are `AS`.
|
133
|
+
*/
|
134
|
+
get initials(): string;
|
135
|
+
}
|
136
|
+
/**
|
137
|
+
* The color object used to generate specified CSS classes with an individual color number assigned to the user.
|
138
|
+
*/
|
139
|
+
declare class Color {
|
140
|
+
constructor(colorId: number);
|
141
|
+
/**
|
142
|
+
* Returns CSS class for user avatar background color.
|
143
|
+
*/
|
144
|
+
getBackgroundColorClass(): string;
|
145
|
+
/**
|
146
|
+
* Returns CSS class for user selection highlight (the selected range).
|
147
|
+
*/
|
148
|
+
getSelectionClass(): string;
|
149
|
+
/**
|
150
|
+
* Returns CSS class for user caret position element (the pipe).
|
151
|
+
*/
|
152
|
+
getMarkerClass(): string;
|
153
|
+
}
|
154
|
+
type UserData = {
|
155
|
+
id: string;
|
156
|
+
color: Color;
|
157
|
+
name: string;
|
158
|
+
avatar?: string;
|
159
|
+
_isAnonymous?: boolean;
|
160
|
+
};
|
161
|
+
export {};
|
package/src/users.js
CHANGED
@@ -20,4 +20,4 @@
|
|
20
20
|
*
|
21
21
|
*
|
22
22
|
*/
|
23
|
-
const
|
23
|
+
const _0x128a=['split','licenseKeyTrialLimit:operations','pluginName','users.anonymousUserId','licenseKey','licenseKeyTrialLimit:revisions','You\x20are\x20using\x20the\x20trial\x20version\x20of\x20CKEditor\x205\x20collaboration\x20plugin\x20with\x20limited\x20usage.\x20Make\x20sure\x20you\x20will\x20not\x20use\x20it\x20in\x20the\x20production\x20environment.','toUpperCase','locale','trim','_id','init','destroy','users','licenseKeyValid','string','requires','initials','_licenseKeyCheckInterval','_getInitial','includes','ck-user__marker--','add','useAnonymousUser','Anonymous','_locale','context','_getNextColor','anonymous-user','invalid-license-key','config','licenseKeyTrialLimit:time','trial-license-key-reached-limit-time','users-add-duplicated-id','define','name','decorate','getSelectionClass','getUser','avatar','users-me-already-defined','ck-user__selection--','defineMe','users-me-missing-user','trial-license-key-reached-limit-revisions','users.colorsCount','length','info','addUser','isAnonymous','trial-license-key-reached-limit-changes','has','_myId','licenseKeyTrial','_isAnonymous','_lastColor','charAt','get','licenseKeyInvalid','getMarkerClass','getOperationAuthor'];(function(_0x4ea929,_0x128a80){const _0x3bb480=function(_0x279ff5){while(--_0x279ff5){_0x4ea929['push'](_0x4ea929['shift']());}};_0x3bb480(++_0x128a80);}(_0x128a,0x1ae));const _0x3bb4=function(_0x4ea929,_0x128a80){_0x4ea929=_0x4ea929-0x0;let _0x3bb480=_0x128a[_0x4ea929];return _0x3bb480;};import{ContextPlugin as _0x44f272}from'ckeditor5/src/core';import{Collection as _0x5492b1,CKEditorError as _0x309315}from'ckeditor5/src/utils';import _0xd42d29 from'./permissions';import{getTranslation as _0x4351b5}from'./utils/common-translations';import'../theme/usercolors.css';export default class l extends _0x44f272{static get[_0x3bb4('0x3c')](){return'Users';}static get[_0x3bb4('0xd')](){return[_0xd42d29];}constructor(_0x441eea){super(_0x441eea),this['context'][_0x3bb4('0x1b')][_0x3bb4('0x1f')](_0x3bb4('0x0'),_0x3bb4('0x19')),this[_0x3bb4('0x17')][_0x3bb4('0x1b')][_0x3bb4('0x1f')](_0x3bb4('0x2a'),0x8),this[_0x3bb4('0xa')]=new _0x5492b1(),this[_0x3bb4('0x16')]=_0x441eea[_0x3bb4('0x5')],this[_0x3bb4('0xf')]=null,this[_0x3bb4('0x34')]=0x0,this[_0x3bb4('0x31')]=null,this[_0x3bb4('0x21')](_0x3bb4('0x39'));}[_0x3bb4('0x8')](){const _0x3e7cda=this[_0x3bb4('0x17')];this['licenseKey']=_0x3e7cda[_0x3bb4('0x1b')]['get'](_0x3bb4('0x1'));const _0x537009=[_0x3bb4('0x32'),_0x3bb4('0x37'),_0x3bb4('0xb'),'licenseKeyTrialLimit:operations',_0x3bb4('0x1c'),_0x3bb4('0x2')];this['_licenseKeyCheckInterval']=setInterval(()=>{let _0x22a97d;for(const _0x479048 in _0x3e7cda){const _0x35276c=_0x3e7cda[_0x479048];if(_0x537009[_0x3bb4('0x11')](_0x35276c)){delete _0x3e7cda[_0x479048],_0x22a97d=_0x35276c;break;}}if(_0x3bb4('0x37')===_0x22a97d)throw clearInterval(this[_0x3bb4('0xf')]),new _0x309315(_0x3bb4('0x1a'),null);if(_0x3bb4('0x32')===_0x22a97d&&console[_0x3bb4('0x2c')](_0x3bb4('0x3')),_0x3bb4('0x3b')===_0x22a97d)throw clearInterval(this['_licenseKeyCheckInterval']),new _0x309315(_0x3bb4('0x2f'),null);if('licenseKeyTrialLimit:time'===_0x22a97d)throw clearInterval(this[_0x3bb4('0xf')]),new _0x309315(_0x3bb4('0x1d'),null);if(_0x3bb4('0x2')===_0x22a97d)throw clearInterval(this['_licenseKeyCheckInterval']),new _0x309315(_0x3bb4('0x29'),null);_0x3bb4('0xb')===_0x22a97d&&clearInterval(this[_0x3bb4('0xf')]);},0x3e8),this['_addAnonymousUser']();}get['me'](){return null==this[_0x3bb4('0x31')]?null:this[_0x3bb4('0x23')](this[_0x3bb4('0x31')]);}[_0x3bb4('0x2d')]({id:_0x5cc999,name:_0x3676a0,..._0x51b47c}){if(!_0x5cc999||_0x3bb4('0xc')!=typeof _0x5cc999)throw new _0x309315('users-add-invalid-id');if(this[_0x3bb4('0xa')][_0x3bb4('0x30')](_0x5cc999))throw new _0x309315(_0x3bb4('0x1e'),null,{'id':_0x5cc999});const _0xe66c35={..._0x51b47c,'id':_0x5cc999,'name':a(this[_0x3bb4('0x16')],_0x3676a0),'color':this[_0x3bb4('0x18')]()};_0xe66c35[_0x3bb4('0x20')]=a(this[_0x3bb4('0x16')],_0xe66c35[_0x3bb4('0x20')]);const _0x31919d=new User(_0xe66c35);return this[_0x3bb4('0xa')][_0x3bb4('0x13')](_0x31919d),_0x31919d;}[_0x3bb4('0x23')](_0x10403a){return this[_0x3bb4('0xa')][_0x3bb4('0x36')](_0x10403a);}[_0x3bb4('0x14')](){const _0x4d9cb5=this['context'][_0x3bb4('0x1b')]['get'](_0x3bb4('0x0'));this['_myId']||this[_0x3bb4('0x27')](_0x4d9cb5);}[_0x3bb4('0x27')](_0x5aad9e){if(this['_myId'])throw new _0x309315(_0x3bb4('0x25'),null);if(!this['getUser'](_0x5aad9e))throw new _0x309315(_0x3bb4('0x28'),null);this[_0x3bb4('0x31')]=_0x5aad9e;}[_0x3bb4('0x39')](){return this['me'];}[_0x3bb4('0x9')](){super['destroy'](),clearInterval(this[_0x3bb4('0xf')]);}[_0x3bb4('0x18')](){const _0x439ae6=this[_0x3bb4('0x17')][_0x3bb4('0x1b')][_0x3bb4('0x36')](_0x3bb4('0x2a'));return this['_lastColor']>=_0x439ae6&&(this[_0x3bb4('0x34')]=0x0),new u(this[_0x3bb4('0x34')]++);}['_addAnonymousUser'](){const _0x472873=this[_0x3bb4('0x17')][_0x3bb4('0x1b')][_0x3bb4('0x36')](_0x3bb4('0x0'));this[_0x3bb4('0x2d')]({'id':_0x472873,'name':_0x4351b5(this[_0x3bb4('0x16')],'Anonymous')})[_0x3bb4('0x33')]=!0x0;}}export class User{constructor(_0x248428){this['id']=_0x248428['id'],this['color']=_0x248428['color'],this[_0x3bb4('0x20')]=_0x248428[_0x3bb4('0x20')],this[_0x3bb4('0x24')]=_0x248428['avatar'],this[_0x3bb4('0x33')]=!0x1;}get[_0x3bb4('0x2e')](){return this[_0x3bb4('0x33')];}get[_0x3bb4('0xe')](){const _0x54b72b=this[_0x3bb4('0x20')][_0x3bb4('0x3a')]('\x20');return 0x1===_0x54b72b['length']?this['_getInitial'](_0x54b72b[0x0]):this['_getInitial'](_0x54b72b[0x0])+this[_0x3bb4('0x10')](_0x54b72b[_0x54b72b[_0x3bb4('0x2b')]-0x1]);}[_0x3bb4('0x10')](_0x5612bf){return _0x5612bf[_0x3bb4('0x35')](0x0)[_0x3bb4('0x4')]();}}function a(_0x1dd28,_0x5a50df=''){return''==(_0x5a50df=_0x5a50df[_0x3bb4('0x6')]())?_0x4351b5(_0x1dd28,_0x3bb4('0x15')):_0x5a50df;}class u{constructor(_0xb96d1c){this[_0x3bb4('0x7')]=_0xb96d1c;}['getBackgroundColorClass'](){return'ck-user__bg-color--'+this[_0x3bb4('0x7')];}[_0x3bb4('0x22')](){return _0x3bb4('0x26')+this[_0x3bb4('0x7')];}[_0x3bb4('0x38')](){return _0x3bb4('0x12')+this[_0x3bb4('0x7')];}}
|
@@ -1,9 +1,9 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
/**
|
6
|
-
* @module collaboration-core/utils/common-translations
|
7
|
-
*/
|
8
|
-
import type { Locale } from 'ckeditor5/src/utils';
|
9
|
-
export declare function getTranslation(locale: Locale, id: string): string;
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module collaboration-core/utils/common-translations
|
7
|
+
*/
|
8
|
+
import type { Locale } from 'ckeditor5/src/utils';
|
9
|
+
export declare function getTranslation(locale: Locale, id: string): string;
|
@@ -20,4 +20,4 @@
|
|
20
20
|
*
|
21
21
|
*
|
22
22
|
*/
|
23
|
-
export function getTranslation(
|
23
|
+
export function getTranslation(_0x4ffdac,_0x21b646){const t=_0x4ffdac['t'];switch(_0x21b646){case'Anonymous':return t('Anonymous');case'Yes':return t('Yes');case'No':return t('No');case'Are\x20you\x20sure?':return t('Are\x20you\x20sure?');default:return'';}}
|