Skip to content

Commit 7cc493c

Browse files
authored
DOC-3269: Fix missing tinycomments_fetch_author_info callback causing ANON avatar display in new comments before callback is returned. (#3839)
1 parent e8c6822 commit 7cc493c

File tree

3 files changed

+44
-17
lines changed

3 files changed

+44
-17
lines changed

modules/ROOT/examples/live-demos/comments-callback-with-mentions/index.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,18 @@ const tinycomments_fetch = (conversationUids, done) => {
235235
setTimeout(() => done({ conversations: fetchedConversations }), fakeDelay);
236236
};
237237

238+
const tinycomments_fetch_author_info = (done) => {
239+
fetch(`${API_URL}/${user_id}`)
240+
.then(res => res.json())
241+
.then(currentUser => {
242+
done({
243+
author: currentUser.id,
244+
authorName: currentUser.name,
245+
authorAvatar: currentUser.avatar
246+
});
247+
});
248+
};
249+
238250
tinymce.init({
239251
selector: 'textarea#comments-callback-with-mentions',
240252
license_key: 'gpl',
@@ -262,15 +274,12 @@ tinymce.init({
262274
tinycomments_delete_comment,
263275
tinycomments_edit_comment,
264276
tinycomments_fetch,
265-
277+
tinycomments_fetch_author_info,
266278
mentions_item_type: 'profile',
267279
mentions_min_chars: 0,
268280
mentions_selector: '.mymention',
269281
mentions_fetch,
270282
mentions_menu_hover,
271283
mentions_menu_complete,
272-
mentions_select,
273-
tinycomments_author: user_id,
274-
tinycomments_author_name: 'James Wilson',
275-
tinycomments_author_avatar: 'https://sneak-preview.tiny.cloud/demouserdirectory/images/employee_james-wilson_128_52f19412.jpg'
284+
mentions_select
276285
});

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,18 @@ const tinycomments_fetch = (conversationUids, done) => {
181181
setTimeout(() => done({ conversations: fetchedConversations }), fakeDelay);
182182
};
183183

184+
const tinycomments_fetch_author_info = (done) => {
185+
fetch(`${API_URL}/${user_id}`)
186+
.then(res => res.json())
187+
.then(currentUser => {
188+
done({
189+
author: currentUser.id,
190+
authorName: currentUser.name,
191+
authorAvatar: currentUser.avatar
192+
});
193+
});
194+
};
195+
184196
tinymce.init({
185197
selector: 'textarea#comments-callback',
186198
license_key: 'gpl',
@@ -208,7 +220,5 @@ tinymce.init({
208220
tinycomments_delete_comment,
209221
tinycomments_edit_comment,
210222
tinycomments_fetch,
211-
tinycomments_author: user_id,
212-
tinycomments_author_name: 'James Wilson',
213-
tinycomments_author_avatar: 'https://sneak-preview.tiny.cloud/demouserdirectory/images/employee_james-wilson_128_52f19412.jpg'
223+
tinycomments_fetch_author_info
214224
});

modules/ROOT/examples/live-demos/full-featured/index.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,18 @@ const tinycomments_fetch = (conversationUids, done) => {
238238
setTimeout(() => done({ conversations: fetchedConversations }), fakeDelay);
239239
};
240240

241+
const tinycomments_fetch_author_info = (done) => {
242+
fetch(`${API_URL}/${user_id}`)
243+
.then(res => res.json())
244+
.then(currentUser => {
245+
done({
246+
author: currentUser.id,
247+
authorName: currentUser.name,
248+
authorAvatar: currentUser.avatar
249+
});
250+
});
251+
};
252+
241253
const ai_request = (request, respondWith) => {
242254
respondWith.stream((signal, streamMessage) => {
243255
// Adds each previous query and response as individual messages
@@ -525,7 +537,7 @@ const revisionhistory_fetch_revision = (_editor, revision) => new Promise((resol
525537
tinymce.init({
526538
selector: 'textarea#full-featured',
527539
plugins: [
528-
'ai', 'suggestededits', 'preview', 'powerpaste', 'casechange', 'importcss', 'tinydrive', 'searchreplace',
540+
'ai', 'preview', 'powerpaste', 'casechange', 'importcss', 'tinydrive', 'searchreplace',
529541
'autolink', 'autosave', 'save', 'directionality', 'advcode', 'visualblocks', 'visualchars', 'fullscreen',
530542
'image', 'link', 'math', 'media', 'mediaembed', 'codesample', 'table', 'charmap', 'pagebreak', 'nonbreaking',
531543
'anchor', 'tableofcontents', 'insertdatetime', 'advlist', 'lists', 'checklist', 'wordcount', 'tinymcespellchecker',
@@ -541,9 +553,9 @@ tinymce.init({
541553
},
542554
menubar: 'file edit view insert format tools table tc help',
543555
// Note: if a toolbar item requires a plugin, the item will not present in the toolbar if the plugin is not also loaded.
544-
toolbar: "undo redo | importword exportword exportpdf | suggestededits | revisionhistory | aidialog aishortcuts | blocks fontsizeinput | bold italic | align numlist bullist | link image | table math media pageembed | lineheight outdent indent | strikethrough forecolor backcolor formatpainter removeformat | charmap emoticons checklist | code fullscreen preview | save print | pagebreak anchor codesample footnotes mergetags | addtemplate inserttemplate | addcomment showcomments | ltr rtl casechange | spellcheckdialog a11ycheck",
556+
toolbar: "undo redo | importword exportword exportpdf | revisionhistory | aidialog aishortcuts | blocks fontsizeinput | bold italic | align numlist bullist | link image | table math media pageembed | lineheight outdent indent | strikethrough forecolor backcolor formatpainter removeformat | charmap emoticons checklist | code fullscreen preview | save print | pagebreak anchor codesample footnotes mergetags | addtemplate inserttemplate | addcomment showcomments | ltr rtl casechange | spellcheckdialog a11ycheck",
545557
mobile: {
546-
plugins: 'ai suggestededits preview powerpaste casechange importcss tinydrive searchreplace autolink autosave save directionality advcode visualblocks visualchars fullscreen image link math media mediaembed codesample table charmap pagebreak nonbreaking anchor tableofcontents insertdatetime advlist lists checklist wordcount tinymcespellchecker a11ychecker help formatpainter pageembed charmap mentions quickbars emoticons advtable footnotes mergetags autocorrect typography advtemplate',
558+
plugins: 'ai preview powerpaste casechange importcss tinydrive searchreplace autolink autosave save directionality advcode visualblocks visualchars fullscreen image link math media mediaembed codesample table charmap pagebreak nonbreaking anchor tableofcontents insertdatetime advlist lists checklist wordcount tinymcespellchecker a11ychecker help formatpainter pageembed charmap mentions quickbars emoticons advtable footnotes mergetags autocorrect typography advtemplate',
547559
},
548560

549561
editimage_cors_hosts: ['picsum.photos'],
@@ -658,6 +670,7 @@ tinymce.init({
658670
tinycomments_delete_comment,
659671
tinycomments_edit_comment,
660672
tinycomments_fetch,
673+
tinycomments_fetch_author_info,
661674

662675
mentions_item_type: 'profile',
663676
mentions_min_chars: 0,
@@ -721,10 +734,5 @@ tinymce.init({
721734
},
722735
revisionhistory_fetch,
723736
revisionhistory_fetch_revision,
724-
revisionhistory_display_author: true,
725-
suggestededits_content: 'html',
726-
suggestededits_access: 'full',
727-
tinycomments_author: user_id,
728-
tinycomments_author_name: 'James Wilson',
729-
tinycomments_author_avatar: 'https://sneak-preview.tiny.cloud/demouserdirectory/images/employee_james-wilson_128_52f19412.jpg'
737+
revisionhistory_display_author: true
730738
});

0 commit comments

Comments
 (0)