Skip to content

Commit ba633dc

Browse files
committed
DOC-3174: Add UserLookup partials to revisionhistory and tinycomments pages
1 parent 61d2d7f commit ba633dc

File tree

9 files changed

+38
-6
lines changed

9 files changed

+38
-6
lines changed

modules/ROOT/pages/comments-embedded-mode.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ liveDemo::comments-embedded[]
3030

3131
== Options
3232

33+
include::partial$configuration/user_id.adoc[leveloffset=+1]
34+
35+
include::partial$configuration/fetch_users.adoc[leveloffset=+1]
36+
3337
include::partial$configuration/tinycomments_author.adoc[leveloffset=+1]
3438

3539
include::partial$configuration/tinycomments_author_avatar.adoc[leveloffset=+1]

modules/ROOT/pages/revisionhistory.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ include::partial$configuration/revisionhistory_fetch_revision.adoc[leveloffset=+
109109

110110
include::partial$configuration/revisionhistory_allow_restore.adoc[leveloffset=+1]
111111

112+
include::partial$configuration/user_id.adoc[leveloffset=+1]
113+
114+
include::partial$configuration/fetch_users.adoc[leveloffset=+1]
115+
112116
include::partial$configuration/revisionhistory_author.adoc[leveloffset=+1]
113117

114118
include::partial$configuration/revisionhistory_display_author.adoc[leveloffset=+1]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
IMPORTANT: This option has been deprecated in {productname} 8.0 and may be removed in a future major {productname} release. Use a combination of `user_id` and `fetch_users` instead. | `xref:apis/tinymce.editor.userlookup.adoc[UserLookup]`

modules/ROOT/partials/configuration/fetch_users.adoc

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

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.
4+
A **required callback function** that fetches user data. 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

@@ -15,10 +15,25 @@ A **required callback function** that fetches user data for the Suggested Edits
1515

1616
[source,javascript]
1717
----
18+
const userDirectory = {
19+
'janedoe': { id: 'janedoe', name: 'Jane Doe', avatar: 'https://example.com/avatar/jane.png' },
20+
'johnsmith': { id: 'johnsmith', name: 'John Smith' },
21+
'alextaylor': { id: 'alextaylor', name: 'Alex Taylor', avatar: 'https://example.com/avatar/alex.png' }
22+
};
23+
1824
tinymce.init({
19-
selector: 'textarea', // Change this value according to your HTML
20-
user_id: 'unique-identifier', // Replace this with a unique string to identify the user
21-
fetch_users: (ids) => fetch(`/api/users?ids=${ids.join(',')}`)
22-
.then((r) => r.json())
25+
selector: '#editor',
26+
user_id: 'alextaylor',
27+
fetch_users: (userIds) => {
28+
const results = userIds.map((id) => {
29+
const user = Object.values(userDirectory).find((user) => user.id === id);
30+
if (user) {
31+
return user;
32+
} else {
33+
throw new Error(`User ${id} not found`);
34+
}
35+
});
36+
return Promise.resolve(results);
37+
}
2338
});
2439
----

modules/ROOT/partials/configuration/revisionhistory_author.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[[revisionhistory_author]]
22
== `revisionhistory_author`
33

4+
include::partial$DEPRECATED/generic_8_userlookup.adoc[]
5+
46
This option configures the author for the `initial` and `draft` revisions.
57

68
*Type:* xref:#author[Author] `+Object+`

modules/ROOT/partials/configuration/tinycomments_author.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[[tinycomments_author]]
22
== `+tinycomments_author+`
33

4+
include::partial$DEPRECATED/generic_8_userlookup.adoc[]
5+
46
This option sets the author id to be used when creating or replying to comments.
57

68
*Type:* `+String+`

modules/ROOT/partials/configuration/tinycomments_author_avatar.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[[tinycomments_author_avatar]]
22
== `+tinycomments_author_avatar+`
33

4+
include::partial$DEPRECATED/generic_8_userlookup.adoc[]
5+
46
_Optional_: This option sets the URL for the author's avatar to be used when creating or replying to comments. If this option is omitted, a generated avatar will be used instead. The avatar, if provided:
57

68
* will be scaled to a 36px diameter circle; and

modules/ROOT/partials/configuration/tinycomments_author_name.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[[tinycomments_author_name]]
22
== `+tinycomments_author_name+`
33

4+
include::partial$DEPRECATED/generic_8_userlookup.adoc[]
5+
46
_Optional_: This option sets the author's display name to be used when creating or replying to comments. If this option is omitted, the author `+id+` is used instead.
57

68
*Type:* `+String+`

modules/ROOT/partials/configuration/user_id.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[[user_id]]
2-
== `user_id`
2+
== `+user_id+`
33

44
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

0 commit comments

Comments
 (0)