Skip to content

Commit b05d7dd

Browse files
committed
DOC-3174: Update interactive demos and examples for embedded mode in tinycomments
1 parent 73b8ad2 commit b05d7dd

File tree

7 files changed

+33
-15
lines changed

7 files changed

+33
-15
lines changed

modules/ROOT/examples/live-demos/comments-embedded/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tinymce.init({
1616
quickbars_image_toolbar: 'alignleft aligncenter alignright | rotateleft rotateright | imageoptions',
1717
tinycomments_mode: 'embedded',
1818
sidebar_show: 'showcomments',
19-
tinycomments_author: currentAuthor,
19+
user_id: currentAuthor,
2020
tinycomments_can_resolve: (req, done, fail) => {
2121
const allowed = req.comments.length > 0 &&
2222
req.comments[0].author === currentAuthor;

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,35 @@ To add the {pluginname} plugin in embedded mode to the {productname}, configure
1111

1212
[source,js]
1313
----
14+
const userDirectory = {
15+
'author': {
16+
id: 'author',
17+
name: 'Name of the commenter',
18+
avatar: 'https://example.com/avatar/john.png'
19+
},
20+
};
21+
1422
tinymce.init({
1523
selector: 'textarea', // change this value according to your html
1624
plugins: 'tinycomments',
1725
toolbar: 'addcomment showcomments',
18-
tinycomments_author: 'author',
19-
tinycomments_author_name: 'Name of the commenter',
26+
user_id: 'author',
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+
},
2038
tinycomments_mode: 'embedded'
2139
});
2240
----
2341

24-
This is the minimum recommended setup for the {pluginname} plugin in embedded mode. If the `+tinycomments_author+` and `+tinycomments_author_name+` options are not configured, all users will be assigned the name "_ANON_".
42+
This is the minimum recommended setup for the {pluginname} plugin in embedded mode. If the `+user_id+` or `+tinycomments_author+` options are not configured, all users will be assigned the name "_ANON_".
2543

2644
[[comments-embedded-live-demo]]
2745
== Interactive example

modules/ROOT/partials/configuration/tinycomments_can_delete.adoc

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

4-
_Optional_: This option sets the author permissions for _deleting comment conversations_. If the `+tinycomments_can_delete+` option is not included, the current author (`+tinycomments_author+`) cannot delete comment conversations created by other authors.
4+
_Optional_: This option sets the author permissions for _deleting comment conversations_. If the `+tinycomments_can_delete+` option is not included, the current author (`+user_id+`) cannot delete comment conversations created by other authors.
55

66
*Type:* `+Function+`
77

88
*Default value:*
99
[source,js]
1010
----
1111
(req, done, fail) => {
12-
const allowed = req.comments.length > 0 && req.comments[0].author === <Current_tinycomments_author>;
12+
const allowed = req.comments.length > 0 && req.comments[0].author === <Current_user_id>;
1313
done({
1414
canDelete: allowed
1515
});
@@ -30,7 +30,7 @@ tinymce.init({
3030
plugins: 'tinycomments',
3131
toolbar: 'addcomment showcomments',
3232
tinycomments_mode: 'embedded',
33-
tinycomments_author: currentAuthor,
33+
user_id: currentAuthor,
3434
tinycomments_can_delete: (req, done, fail) => {
3535
const allowed = req.comments.length > 0 && req.comments[0].author === currentAuthor;
3636
done({

modules/ROOT/partials/configuration/tinycomments_can_delete_comment.adoc

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

4-
_Optional_: This option sets the author permissions for _deleting comments_. If the `+tinycomments_can_delete_comment+` option is not included, the current author (`+tinycomments_author+`) **cannot** delete comments added by other authors.
4+
_Optional_: This option sets the author permissions for _deleting comments_. If the `+tinycomments_can_delete_comment+` option is not included, the current author (`+user_id+`) **cannot** delete comments added by other authors.
55

66
*Type:* `+Function+`
77

88
*Default value:*
99
[source,js]
1010
----
1111
(req, done, fail) => {
12-
const allowed = req.comment.author === <Current_tinycomments_author>;
12+
const allowed = req.comment.author === <Current_user_id>;
1313
done({
1414
canDelete: allowed
1515
});
@@ -30,7 +30,7 @@ tinymce.init({
3030
plugins: 'tinycomments',
3131
toolbar: 'addcomment showcomments',
3232
tinycomments_mode: 'embedded',
33-
tinycomments_author: currentAuthor,
33+
user_id: currentAuthor,
3434
tinycomments_can_delete_comment: (req, done, fail) => {
3535
const allowed = req.comment.author === currentAuthor;
3636
done({

modules/ROOT/partials/configuration/tinycomments_can_edit_comment.adoc

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

4-
_Optional_: This option sets the author permissions for _editing comments_. If the `+tinycomments_can_edit_comment+` option is not included, the current author (`+tinycomments_author+`) cannot edit comments added by other authors.
4+
_Optional_: This option sets the author permissions for _editing comments_. If the `+tinycomments_can_edit_comment+` option is not included, the current author (`+user_id+`) cannot edit comments added by other authors.
55

66
*Type:* `+Function+`
77

88
*Default value:*
99
[source,js]
1010
----
1111
(req, done, fail) => {
12-
const allowed = req.comment.author === <Current_tinycomments_author>;
12+
const allowed = req.comment.author === <Current_user_id>;
1313
done({
1414
canEdit: allowed
1515
});
@@ -29,7 +29,7 @@ tinymce.init({
2929
plugins: 'tinycomments',
3030
toolbar: 'addcomment showcomments',
3131
tinycomments_mode: 'embedded',
32-
tinycomments_author: currentAuthor,
32+
user_id: currentAuthor,
3333
tinycomments_can_edit_comment: (req, done, fail) => {
3434
const allowed = req.comment.author === currentAuthor;
3535
done({

modules/ROOT/partials/configuration/tinycomments_can_resolve.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tinymce.init({
1616
plugins: 'tinycomments',
1717
toolbar: 'addcomment showcomments',
1818
tinycomments_mode: 'embedded',
19-
tinycomments_author: currentAuthor,
19+
user_id: currentAuthor,
2020
tinycomments_can_resolve: (req, done, fail) => {
2121
const allowed = req.comments.length > 0 && req.comments[0].author === currentAuthor;
2222
done({

modules/ROOT/partials/plugins/comments-open-sidebar.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ tinymce.init({
3030
selector: 'textarea', // change this value according to your html
3131
plugins: 'tinycomments',
3232
tinycomments_mode: 'embedded',
33-
tinycomments_author: currentAuthor,
33+
user_id: currentAuthor,
3434
tinycomments_can_resolve: canResolveCommentsCallback,
3535
sidebar_show: 'showcomments'
3636
});

0 commit comments

Comments
 (0)