`prependToContext` in TinyMCE

十年热恋 提交于 2020-01-15 04:45:50

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!