After successfully implementing the Tinymce comments plugin into our configuration, we have come across a request from our users. They would like the 'showcomments' button to automatically trigger on page load, displaying the sidebar containing the comments.
We have identified that the command 'tc-open-comments' is responsible for this action when the button is clicked, but we are struggling to manually initiate this command ourselves.
Any assistance in resolving this matter would be greatly appreciated.
Configuration Details
tinymce.init({
selector: '.tinymce',
plugins: [
'paste tinycomments'
],
toolbar: 'addcomment showcomments',
tinycomments_mode: 'embedded',
tinycomments_author: 'user1',
tinycomments_author_name: 'username',
content_css: '/css/app.css',
setup: function (editor: any) {
editor.on('ExecCommand', function (e) {
console.log('The ' + e.command + ' command was fired.');
});
editor.on('init', function () {
// These are the two commands executed by clicking the 'showcomments' button
editor.execCommand('tc-open-comment'); // This does not work
editor.execCommand('ToggleSidebar'); // This works
let commentsPresent = false;
let textareaContent = editor.startContent;
if (textareaContent.includes('tox-comment')) {
commentsPresent = true;
console.log(commentsPresent);
} else {
console.log(commentsPresent);
}
});
}
});