I am investigating a peculiar problem with my custom Tinymce plugin.
I had the same code working successfully in a single JS file but I encountered this problem when I refactored my code into a proper TinyMce plugin format.
import jsonpath, { parse } from 'jsonpath';
import { parseJSON } from 'jquery';
console.log('* * * * * Responding! * * * * *')
tinymce.PluginManager.add("options", function (editor, url) {
var _dialog = false;
var $options = {}
function _getDialogConfig()
{
return {
title: 'Options',
body: {
type: 'panel',
items: [
{
type: 'input',
name: 'type',
label: 'data',
flex: true,
}
]
},
onSubmit: function (api) {
// insert into wysiwyg
// close the dialog
api.close();
},
buttons: [
{
text: 'Close',
type: 'cancel',
onclick: 'close'
},
{
text: 'Insert',
type: 'submit',
primary: true,
}
]
};
}
function _onAction()
{
$options = {}; // reset the values for new options input
// Open a Dialog, and update the dialog instance var
_dialog = editor.windowManager.open(_getDialogConfig());
// block the Dialog, and commence the data update
// Message is used for accessibility
_dialog.block('Loading...');
// re-build the dialog
_dialog.redial(_getDialogConfig());
// unblock the dialog
_dialog.unblock();
}
editor.on('click', e => {
let text = e.target.innerText
let regex = /\[ID:\d*]/;
let output = regex.test(text)
console.log(output)
console.log('----------------------------')
});
});
My issue is in the editor.on('click', e => { . . . section of the code. Any attempt to test my regular expression, as I'm attempting to do in the code above, or perform anything more than a console.log results in the code not executing. By "not executing" I mean the output I expect to see is not rendered in the console and frustratingly, there are absolutely no error messages to indicate any errors.
The function is an event listener for detecting clicks within the wysiwyg on a particular HTML element.
How can I resolve why my regex or any other logic code does not work nor generate errors?