I'm developping a plugin for TinyMCE and I want to have a listbox on which the user can select an option to insert in the editor.
This option list is not always the same, it depends on actions made on the website. The values are stored in an array that I successfully pass to the plugin.
I process the array to format it as an options list:
Object.keys(variablesArray).forEach(function (key) {
parametersText = parametersText + "{text: '" + variablesArray[key] + "', value: '{{" + key + "}}'},";
});
The result is good. Then I want to declare it in my listbox:
editor.windowManager.open({
title: 'Insérer variable',
body: [
{
type: 'listbox',
name: 'list_variables',
label: 'Sélectionnez une variable',
'values': [
{text: 'Numéro de dossier', value: '{{id}}'},
{text: 'Date de l\'accident', value: '{{date_case}}'},
{text: 'Heure de l\'accident', value: '{{time_case}}'},
{text: 'Lieu de l\'accident', value: '{{case_address_1}}, {{case_address_2}}, {{case_postcode}}, {{case_city}}, {{case_country}}'},
{text: 'Description de l\'accident', value: '{{case_description}}'},
{text: 'Date de l\'accident', value: '{{date_case}}'},
parametersText,
{text: '', value: '{{}}'}
]}
],
But I get the following error: Uncaught Error: Could not find control by type: {text: '1', value: '{{id}}'},{text: 'mon test', value: '{{test}}'},
That shows me that it expects a proper option and not a var. Any idea how to fix that ?
Thanks in advance for your time.