Skip to content

Commit 61d2d7f

Browse files
committed
DOC-3174: Some edits
1 parent 4a826c5 commit 61d2d7f

5 files changed

Lines changed: 20 additions & 164 deletions

File tree

modules/ROOT/pages/apis/tinymce.userlookup.adoc

Lines changed: 0 additions & 142 deletions
This file was deleted.

modules/ROOT/pages/userlookup.adoc

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,7 @@ Follow the steps below to configure and use the `userLookup` API within your int
1515

1616
The first step is to tell the editor which user is currently active. This is done using the `+user_id+` initialization option.
1717

18-
[source,js]
19-
----
20-
tinymce.init({
21-
selector: '#editor',
22-
user_id: 'user-42', // <1>
23-
// ...
24-
});
25-
----
26-
**This ID will be used as the value of `+editor.userLookup.userId+`.**
18+
include::partial$configuration/user_id.adoc[leveloffset=+2]
2719

2820
To access it:
2921

@@ -37,19 +29,21 @@ editor.on('init', () => {
3729
[[step-2-provide-a-user-fetcher]]
3830
=== 2. Provide a function to fetch user details
3931

40-
To simulate a backend lookup, define a local object that maps user IDs to their corresponding data.
32+
To simulate a backend lookup, define a local object that maps user IDs to their corresponding data.
33+
34+
include::partial$configuration/fetch_users.adoc[]
4135

4236
[source,js]
4337
----
4438
const userDirectory = {
45-
'user-1': { id: 'user-1', name: 'Jane Doe', avatar: 'https://example.com/avatar/jane.png' },
46-
'user-2': { id: 'user-2', name: 'John Smith' },
47-
'user-42': { id: 'user-42', name: 'Alex Taylor', avatar: 'https://example.com/avatar/alex.png' }
39+
'janedoe': { id: 'janedoe', name: 'Jane Doe', avatar: 'https://example.com/avatar/jane.png' },
40+
'johnsmith': { id: 'johnsmith', name: 'John Smith' },
41+
'alextaylor': { id: 'alextaylor', name: 'Alex Taylor', avatar: 'https://example.com/avatar/alex.png' }
4842
};
4943
5044
tinymce.init({
5145
selector: '#editor',
52-
user_id: 'user-42',
46+
user_id: 'alextaylor',
5347
fetch_users: (userIds) => {
5448
const results = userIds.map((id) => {
5549
const user = Object.values(userDirectory).find((user) => user.id === id);

modules/ROOT/partials/configuration/fetch_users.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[[fetch_users]]
22
== `fetch_users`
33

4-
A callback function that retrieves user data for the plugin. It receives an array of user IDs and returns a `Promise` resolving to an array of user objects. The callback uses the xref:#userlookupapi[`UserLookup API`].
4+
A **required callback function** that fetches user data for the Suggested Edits view. This function is called with an array of user IDs and should return a `Promise` that resolves to an array of user objects. The callback is used by the xref:userlookup.adoc[`UserLookup`] API.
55

66
*Type:* `Function`
77

@@ -11,7 +11,8 @@ A callback function that retrieves user data for the plugin. It receives an arra
1111
*Returns:*
1212
- `Promise<Array<Object>>`: A promise that resolves to an array of user objects.
1313

14-
.Example
14+
=== Example: using `fetch_users` option
15+
1516
[source,javascript]
1617
----
1718
tinymce.init({

modules/ROOT/partials/configuration/suggestededits_content.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[[suggestededits_content]]
22
== `suggestededits_content`
3-
The `{plugincode}_content` option determines where the initial content of the document is loaded from. With this option, you can set the content to be loaded from either the editor or the model, allowing you to control the source of truth for the document.
3+
The `suggestededits_content` option determines where the initial content of the document is loaded from. With this option, you can set the content to be loaded from either the editor or the model, allowing you to control the source of truth for the document.
44

55
When set to `'html'`, the editor loads the initial content from the HTML in the textarea or the `content` property. In this case, if a model is provided, it will need to match the content in the editor for the plugin to work correctly
66

7-
When set to `'model'`, the editor loads the initial content from the `{plugincode}_model` option. In this case, the content in the editor will be overwritten with the content from the model. This would allow you to only require the model for document tracking, though it is still recommended to save the content in the editor externally.
7+
When set to `'model'`, the editor loads the initial content from the `suggestededits_model` option. In this case, the content in the editor will be overwritten with the content from the model. This would allow you to only require the model for document tracking, though it is still recommended to save the content in the editor externally.
88

99
In either case, if a model is not provided, the plugin will generate a new model from the current content of the editor, whether it is empty or not.
1010

@@ -14,7 +14,7 @@ In either case, if a model is not provided, the plugin will generate a new model
1414

1515
*Default value:* `'html'`
1616

17-
=== Example: using `{plugincode}_content`
17+
=== Example: using `suggestededits_content`
1818

1919
[source,js]
2020
----
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
[[user_id]]
22
== `user_id`
33

4-
This option specifies a unique identifier for the current user, enabling the plugin to distinguish between different users in the editor. The option uses the xref:#userlookupapi[`UserLookup API`].
4+
This option sets the unique identifier for the current user in the editor. It is used in the the xref:userlookup.adoc[`UserLookup`] API.
55

66
*Type:* `+String+`
77

8-
.Example
8+
*Default value:* `'Anonymous'`
9+
10+
=== Example: using `user_id` option
11+
912
[source,javascript]
1013
----
1114
tinymce.init({
1215
selector: 'textarea', // Change this value according to your HTML
13-
user_id: 'unique-identifier' // replace this with a unique string to identify the user
16+
user_id: 'alextaylor' // replace this with a unique string to identify the user
1417
});
1518
----

0 commit comments

Comments
 (0)