Reputation: 53
my menu must changes depending on context:
editor.addMenuItem('table_entity', {
context : 'contextmenu',
text : 'Table Entity',
icon : false,
onPostRender: function () {
var menu = this;
editor.on('NodeChange', function (e) {
var table = editor.dom.getParent(e.element, 'table');
if (table === null || table.classList.value.search(/prefix_/) == -1) {
menu.disabled(true);
menu.settings.menu = null;
} else {
var match = table.classList.value.match(/prefix_(.+)\s|$/);
if (match[1] !== undefined) {
menu.settings.menu = firstItem(match[1]).concat(self.getMenu(match[1], self[match[1] + 'Property']));
menu.disabled(false);
}
}
})
}
});
, but its not work. Data in the object changed (menu.settings.menu), and when menu.disabled(true) - all ok, but in other cases I see the menu items that were generated for the first time (i.e. data in object is changing, items in the drop down menu not changing).
Upvotes: 0
Views: 457
Reputation: 13744
TinyMCE does not support dynamically adding items to the menu after the editor is initialized. If you have to do this you could either
remove()
and init()
to reinitialize the editor with different menu optionsUpvotes: 0