问题
Here is a piece of code from TinyMCE Link plugin:
editor.addMenuItem('link', {
icon: 'link',
text: 'Insert/edit link',
shortcut: 'Meta+K',
onclick: createLinkList(showDialog),
stateSelector: 'a[href]',
context: 'insert',
prependToContext: true
});
What does prependToContext: true
mean? I can't find it in the documentation.
回答1:
Taken from the tinymce core (theme.js
):
// Added though context
if (!isUserDefined) {
each(editor.menuItems, function(menuItem) {
if (menuItem.context == context) {
...
if (menuItem.prependToContext) {
menuItems.unshift(menuItem);
} else {
menuItems.push(menuItem);
}
...
}
});
}
So, your MenuItem gets reinserted at the beginning of the internal MenuItems array.
来源:https://stackoverflow.com/questions/34628791/prependtocontext-in-tinymce