You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ROOT/pages/userlookup.adoc
+71-88Lines changed: 71 additions & 88 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,48 +2,37 @@
2
2
:navtitle: User Lookup
3
3
:description: TinyMCE User Lookup provides an API to identify the current user and retrieve user details via integration-defined methods.
4
4
:keywords: userLookup, fetchUsers, user_id, user management, collaborative editing
5
+
:apiname: User Lookup
5
6
6
-
The {productname}User Lookup API enables integrations to retrieve and cache user details (such as names and avatars) and identify the current user within the editor.
7
+
The {productname}{apiname}API allows you to retrieve and cache user details, such as names and avatars, and identify the current user within the editor.
7
8
8
-
This is useful when building features that rely on user context, such as commenting, collaborative editing, or displaying user-specific information. The API provides built-in caching for efficient user data management.
9
+
This is useful when building features that rely on user context, such as commenting, collaborative editing, or displaying user-specific information. The API provides built-in caching for efficient user data management, as well as fallback user data when none is provided.
9
10
10
-
== How it works
11
+
== Properties and Methods
11
12
12
-
The User Lookup API provides two main functions:
13
+
The {apiname} API serves two purposes, to identify the current user and to fetch user details for other users. These can be configured to suit your application through the xref:#user_id[`user_id`] and xref:#fetch_users[`fetch_users`] options respectively.
13
14
14
-
[cols="2,4",options="header"]
15
-
|===
16
-
|Method|Description
15
+
The {apiname} API provides properties and methods through the `editor.userLookup` object, which is available after the editor is initialized.
17
16
18
-
|`editor.userLookup.userId`|Returns the current user's ID, set via the `user_id` configuration option.
19
-
|`editor.userLookup.fetchUsers(userIds)`|Fetches and caches user information. Returns a Promise-based lookup object.
17
+
[cols="2,1,2",options="header"]
20
18
|===
19
+
|API|Type|Return Type
21
20
22
-
== Basic setup
23
-
24
-
For a basic setup, you only need to configure the `user_id` option:
25
-
26
-
[source,js]
27
-
----
28
-
tinymce.init({
29
-
selector: '#editor',
30
-
user_id: 'current-user-id'
31
-
});
32
-
----
33
-
34
-
For more advanced user data fetching, see the <<options,Options>> section below.
Returns the current user's ID, set via the `user_id` configuration option. This is a string that uniquely identifies the user in the context of the editor, such as a username or an email address. If the `user_id` option is not set, it defaults to `'Anonymous'`.
39
29
40
-
1. **Basic identification**: Setting a current user ID for editor context
41
-
2. **Dynamic fetching**: Retrieving user details from backend systems
42
-
3. **Fallback behavior**: Auto-generating user data when no fetch function is provided
30
+
[[userlookup-fetchusers]]
31
+
=== `editor.userLookup.fetchUsers`
43
32
44
-
== Data structure
33
+
Fetches and caches user information for the specified user IDs. This method accepts an array of user IDs and returns an object where each key is a user ID and each value is a Promise that resolves to the user object. If a user ID is not found, the Promise will reject with an error message.
45
34
46
-
=== User
35
+
=== The `user` object
47
36
48
37
The user is an `Object` that contains the following fields:
49
38
@@ -53,7 +42,7 @@ The user is an `Object` that contains the following fields:
53
42
| `id` | `string` | required | The unique string ID of the user.
54
43
| `name` | `string` | optional | The display name of the user. If not provided, defaults to the `id`.
55
44
| `avatar` | `string` | optional | The URL of the user's avatar image or data URI. If not provided, an auto-generated SVG using the user's initials will be used.
56
-
| `custom` | `Object` | optional | Additional metadata for the user.
45
+
| `custom` | `Object` | optional | Additional metadata for the user. This can include any custom fields relevant to your application, such as roles or permissions.
57
46
|===
58
47
59
48
.Example user object:
@@ -72,46 +61,29 @@ The user is an `Object` that contains the following fields:
72
61
73
62
== Options
74
63
75
-
The following configuration options affect the behavior of the User Lookup API.
64
+
The following configuration options affect the behavior of the {apiname} API.
Once the editor is initialized, you can access the current user ID and fetch user information:
74
+
For a basic setup, configuring the `user_id` option allows you to identify the current user. The `fetch_users` option can be omitted, and {productname} will provide fallback user data.
NOTE: All lookups are cached. If a user has already been fetched, the same promise will be returned without calling `fetch_users` again.
84
+
=== Complete setup with `fetch_users`
110
85
111
-
[[complete-example]]
112
-
=== Complete Example with User Database
113
-
114
-
This example shows how to set up a complete user lookup system with a simulated backend:
86
+
This example demonstrates how to simulate user lookup in-browser. In a production environment, the `fetch_users` function would typically make network requests to your backend API.
(resolve) => resolve(userDb[userId] || { id: userId }) // Return user data or a fallback object if not found
144
116
)
145
117
)
146
118
)
147
119
},
148
120
});
149
121
----
150
122
151
-
This example demonstrates how to simulate user lookup in-browser. In a production environment, the `fetch_users` function would typically make network requests to your backend API.
123
+
NOTE: It is recommended to handle (or catch) promise rejections in the `fetch_users` function by providing fallback data. This will ensure that your application can gracefully handle cases where user data is not found or the network request fails.
152
124
153
-
[[fallback-behavior]]
154
-
=== Fallback Behavior
125
+
=== Basic usage
155
126
156
-
If no `fetch_users` function is configured, {productname} will return fallback users with auto-generated data:
157
-
158
-
* `name` defaults to the user ID
159
-
* `avatar` is an auto-generated SVG using the first letter of the name
160
-
161
-
This is useful for simpler setups or prototyping:
127
+
Once the editor is initialized, you can access the current user ID and fetch user information:
The User Lookup API provides the following methods:
183
+
If no `fetch_users` function is configured, {productname} will return fallback users with auto-generated data:
213
184
214
-
[cols="3,4,2",options="header"]
215
-
|===
216
-
|Method|Description|Return Type
185
+
* `name` defaults to the user ID
186
+
* `avatar` is an auto-generated SVG using the first letter of the name
217
187
218
-
|`editor.userLookup.userId`|Gets the current user's ID, set via the `user_id` configuration option.|`string`
219
-
|`editor.userLookup.fetchUsers(userIds)`|Fetches and caches user information for the specified user IDs. Returns an object where each key is a user ID and each value is a Promise that resolves to the user object.|`Object<string, Promise<UserObject>>`
Copy file name to clipboardExpand all lines: modules/ROOT/partials/configuration/suggestededits_access.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
[[suggestededits_access]]
2
2
== `suggestededits_access`
3
3
4
-
The `suggestededits_access` option determines the level of access a user has to the {pluginname} view. This setting is crucial for controlling who can accept or reject suggestions, add feedback, or view the document in read-only mode. When used in conjunction with the `readonly` option, it allows for fine-grained control over user permissions.
4
+
The `suggestededits_access` option determines the level of access a user has to the {pluginname} view. This setting is crucial for controlling who can accept or reject suggestions, add feedback, or view suggestions in read-only mode. The `suggestededits_access` option does not control access to the editor content, however when used in conjunction with the xref:editor-important-options#readonly[`readonly`] option it allows for fine-grained control over user permissions.
Copy file name to clipboardExpand all lines: modules/ROOT/partials/configuration/suggestededits_content.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ When set to:
8
8
* `'html'`: the editor loads content normally, and the plugin synchronises the model with the content. This simplifies the configuration of {pluginname} in an existing integration, by attaching the {pluginname} model as an additional field alongside the editor content.
9
9
* `'model'`: the editor uses the `suggestededits_model` option to generate the initial content, ignoring any pre-existing content in the editor. With this configuration, you only need to store and provide the model, simplifying the integration of the {pluginname} plugin.
10
10
11
-
NOTE: The integrator is responsible for saving the model and providing it on the next load using the `suggestededits_model` option.
11
+
NOTE: You are responsible for saving the model and providing it on the next load using the `suggestededits_model` option.
0 commit comments