Closed sattyframework closed 2 weeks ago
It's not elegant, however you need to move those callbacks inline, and just have your configuration as a simple js object.
For example:
{
selector: 'textarea',
plugins: 'tinycomments',
tinycomments_mode: 'callback',
tinycomments_create: (ref, done, fail) => {
const { content, createdAt } = ref;
fetch('https://api.example/conversations/', {
method: 'POST',
body: JSON.stringify({ content: content, createdAt: createdAt }),
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
})
.then((response) => {
if (!response.ok) {
throw new Error('Failed to create comment');
}
return response.json();
})
.then((ref2) => {
let conversationUid = ref2.conversationUid;
done({ conversationUid: conversationUid });
})
.catch((e) => {
fail(e);
});
}
// ...
}
If you were in a Vue app with full access to the tiny Vue component, you could have the scripts in there: but there's no way for us to inject scripts in to the Tiny Cloud component for Statamic.
Bug description
Hello, I am looking at using the comments extension which all works well when using the 'embedded' mode. However I wanted to explore using the callback mode which allows users to save comments to external database.
Have tried to apply the below to the tinymce config in statamic, but given that it needs to be valid json it fails. Is there another way to add callback functions?
Any help is appreciated. Thanks
This is the example given on the tinymce docs: https://www.tiny.cloud/docs/tinymce/latest/comments-callback-mode/#tinycomments_create
Steps to reproduce
Install TinyMCE plugin and add comments extension with mode set to callback
Environment and versions
Additional details
No response