Open pcorrick opened 3 years ago
Ok so I got it working but it's a bit of a hack. The editor now uses initObj returned by the data function, which joins the setup function with the options array.
I also had to change onclick to onAction (new in TinyMCE v5).
I'm not sure if there is a way to put the setup function in the options array from my Nova resource.
<template>
<default-field :field="field" :full-width-content="true" :show-help-text="showHelpText">
<template slot="field">
<editor :id="field.id || field.attribute"
v-model="value"
:class="errorClasses"
:placeholder="field.name"
:init="initObj"
></editor>
export default {
data () {
let options = this.field.options
return {
initObj: {
setup: function (editor) {
editor.ui.registry.addButton('mybutton', {
text: "Insert Text",
onAction: function () {
editor.insertContent(' <b>It\'s my button!</b> ');
}
});
},
...options
}
}
},
I'm porting a Laravel app from Voyager (https://github.com/the-control-group/voyager) to Nova. I have a custom javascript function tinymce_setup_callback(editor) in my Voyager app that creates a toolbar button for TinyMCE, but I'm having some trouble replicating it in Nova.
I've tried editing the FormField.vue component to run this.loaded method onInit, but the button doesn't appear. In my options array I have:
I know the loaded method runs because if I use editor.addButton I get an error in the console:
I expect the loaded method is running the tinymce component is initialised so it's too late to add the button but I can't figure out how to get it in there during init/setup.