When I run the code below and click the custom toolbar button I get this error:
Uncaught TypeError: Cannot read properties of undefined (reading 'paste')
I'm not sure why this is happening. Any insight?
JS
tinymce.init({
selector: 'textarea#taskEmail',
height: 550,
menubar: false,
plugins: 'table link',
toolbar:
'tokenButton | tableinsertrowbefore tableinsertrowafter tabledeleterow | styleselect | bold italic | alignleft aligncenter alignright alignjustify | outdent indent | link anchor',
setup: function (editor) {
var taskDetails = function () {
tinymce.activeEditor.dom.setHTML(
tinymce.activeEditor.dom.select('#emailBody'),
'<tr><td style="width:30%">Name</td><td style="width:70%">!EmployeeName!</td></tr>' +
'<tr><td style="width:30%">Task Name</td><td style="width:70%">!TaskName!</td></tr>' +
'<tr><td style="width:30%">Task Description</td><td style="width:70%">!TaskDescription!</td></tr>' +
'<tr><td style="width:30%">Date Assigned</td><td style="width:70%">!DateAssigned!</td></tr>' +
'<tr><td style="width:30%">Due Date</td><td style="width:70%">!DueDate!</td></tr>',
)
}
editor.ui.registry.addMenuButton('tokenButton', {
text: 'Available Tokens',
fetch: function (callback) {
var items = [
{
type: 'menuitem',
text: 'Task Detail Template',
onAction: function (_) {
editor.insertContent(taskDetails())
},
},
]
callback(items)
},
})
},
content_style:
'body { font-family:Helvetica,Arial,sans-serif; font-size:1.25rem }',
})
HTML
<script src="https://cdn.tiny.cloud/1/KEY/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
<textarea id="taskEmail">
<table>
<tbody id="emailBody"></tbody>
</table>
</textarea>