I have added a button to tinyMCE, using the same technique as outlined here:
https://getpublii.com/dev/how-to-add-custom-config-or-js-for-post-editor/
The button works perfectly BUT only displays the first time tinyMCE is displayed (after loading publii). If I browse to a different post, my custom button disappears.
Sharing in case anyone can help! Thanks everyone.
Related info
I am using prodocs theme, and publii 0.42.1
my tinymce.override.json is as follows:
{
"toolbar2": "styleselect formatselect sourcecode customInsertButton"
}
and my tinymce.script.js is:
// get an instance of the editor
var editor = tinymce.editors[0]; //or tinymce.editors[0], or loop, whatever
editor.ui.registry.addButton('customInsertButton', {
text: 'My Button',
onAction: (_) => editor.insertContent(` It's my button! `)
});