如何从右键单击菜单中删除指定的选项
How to remove the specified option from right click meun in tinymce?
我想从tinymce的右键菜单中删除图像属性选项。我用的是timymce 3。X版请帮帮我
你可以这样做:
tinyMCE.init({
setup: function (ed) {
ed.onInit.add(editor_oninit);
}
...
});
function editor_oninit(ed) {
// Add hook for onContextMenu so that Insert Image can be removed
ed.plugins.contextmenu.onContextMenu.add(editor_remove_image);
}
和函数
function editor_remove_image(sender, menu) {
// create a new object
var otherItems = {};
for (var itemName in menu.items) {
var item = menu.items[itemName];
if (/^mce_/.test(itemName)) {
if (item.settings) {
if (item.settings.cmd == "mceImage" || item.settings.cmd == "mceAdvImage") {
// skip these items
continue;
}
}
}
// add all other items to this new object, so it is effectively a clone
// of menu.items but without the offending entries
otherItems[itemName] = item;
}
// replace menu.items with our new object
menu.items = otherItems;
}
我第一次使用这个TinyMCE,实际上是在寻找解决这里问的相同问题的方法。
下面是我的TinyMCE脚本:tinymce.init({
selector: "textarea#elm1",
images_upload_credentials: false,
theme: "modern",
branding: false,
<!-- elementpath: false, -->
menubar:false,
<!-- preview_styles: false, -->
height:300,
automatic_uploads: false,
plugins: [
"advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"save table contextmenu directionality emoticons template paste textcolor"
]
});
现在,如何删除右键单击图像Url选项?
直接从插件中删除图像
plugins: [
"advlist autolink link lists charmap print preview hr anchor pagebreak spellchecker",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"save table contextmenu directionality emoticons template paste textcolor"
]
对于使用TinyMCE 5的用户,一个解决方案可能是显式指定上下文菜单中允许的项:
tinymce.init({
...
contextmenu: 'link table' /*just do not mention the 'image'*/
...
});
相关文章:
- 带有预览和删除选项的图像上传-Javascript/Jquery
- 从dojo comboBox中删除选项
- 在 IE 中从 DOM 中删除选项时,滚动选择元素会跳到顶部
- 如何从选择 jsp 上的映射中删除选项
- 如何使用fine Uploader通过删除选项将上传的文件名传递到服务器端
- 如果选择框已在其他框中选中,则从该框中删除选项
- 使用jQuery的预览和删除选项上传多个图像
- 从选项卡面板中删除选项卡
- 从“按值选择”中删除选项
- jquery检查字符串是否已从文本区域删除,并从select中删除选项
- 修改googlechrome扩展以删除选项卡
- Jquery,从下拉列表中删除选项不起作用
- HTML选择框,通过javascript删除选项'无'选项出现
- 要添加的搜索功能&从select下拉列表中删除选项
- Javascript-动态网格花式删除选项
- 基于下拉选择从从属下拉列表中删除选项
- 上传文件与大小和删除选项在Javascript
- 两个选择-删除选项的一个基于另一个
- 通过焦点切换在TabPanel中添加和删除选项卡
- 删除选项绑定:如果选项被选中,如何从弹出框中动态删除选项