Open JalpeshVadgama opened 4 years ago
Hi, I had the same problem, we want to update the dropdown on the run time based on some conditions. The is the solution I found:
FroalaEditor.RegisterCommand('dropdown', {
title: 'Dropdown',
type: 'dropdown',
focus: false,
undo: false,
refreshAfterCallback: true,
options: () => this.toolbarDropdownItems,
refreshOnShow: ($btn: any, $dropdown: any) => {
const list = $dropdown.find('ul.fr-dropdown-list');
const containerElement = document.createElement('div');
containerElement.innerHTML = this.editor.button.buildList([dropdown]);
list.replaceWith(containerElement.querySelector('ul.fr-dropdown-list'));
},
callback(cmd: any, val: any) {
this.html.insert(val);
},
refresh(btn) {
// The current context is the editor instance.
},
});
Hello Team,
First of all, You are doing great work for Forola editor.
In our application. We want to dynamically update the newly created dropdown. I have created a dropdown for variables in the editor as per the forola editor document like below.
https://froala.com/wysiwyg-editor/examples/custom-dropdown/
For that, I have used the following code and its works fine as intended.
` FroalaEditor.DefineIcon('dropdown', { NAME: 'plus', SVG_KEY: 'add' });
But now I need to change the optionsDynamic based on some condition. Right now it changes the dynamicOption variable but does not affect anything. I have also done clone via JSON.parse but no effect on it.