I want to insert content like <span class="some-class">text</span>
inside tinymce editor using a button in vue js template. How could I accomplish that using the tinymce-vue wrapper?
Here's the code:
<template>
<tinymce-editor
api-key="my-api-key-here"
/>
<button @click="addContent">button</button>
</template>
import Editor from '@tinymce/tinymce-vue'
export default {
components: {
tinymceEditor: Editor
},
methods: {
addContent () {
tinymce.activeEditor.setContent('<span class="some-class">text</span>');
}
}
}
Edit:
I also installed tinymce
using npm i tinymce --save
and added the import import tinymce from 'tinymce/tinymce
to the code above. Now I don't get the error 'tinymce' is not defined
anymore, but the editor doesn't appear either.