init
This commit is contained in:
77
public/tinymce/plugins/contextmenu/plugin.js
Normal file
77
public/tinymce/plugins/contextmenu/plugin.js
Normal file
@ -0,0 +1,77 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
|
||||
tinymce.PluginManager.add('contextmenu', function(editor) {
|
||||
var menu;
|
||||
|
||||
editor.on('contextmenu', function(e) {
|
||||
var contextmenu;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
contextmenu = editor.settings.contextmenu || 'link image inserttable | cell row column deletetable';
|
||||
|
||||
// Render menu
|
||||
if (!menu) {
|
||||
var items = [];
|
||||
|
||||
tinymce.each(contextmenu.split(/[ ,]/), function(name) {
|
||||
var item = editor.menuItems[name];
|
||||
|
||||
if (name == '|') {
|
||||
item = {text: name};
|
||||
}
|
||||
|
||||
if (item) {
|
||||
item.shortcut = ''; // Hide shortcuts
|
||||
items.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].text == '|') {
|
||||
if (i === 0 || i == items.length - 1) {
|
||||
items.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu = new tinymce.ui.Menu({
|
||||
items: items,
|
||||
context: 'contextmenu'
|
||||
});
|
||||
|
||||
// allow css to target this special menu
|
||||
menu.addClass('contextmenu');
|
||||
|
||||
menu.renderTo(document.body);
|
||||
|
||||
editor.on('remove', function() {
|
||||
menu.remove();
|
||||
menu = null;
|
||||
});
|
||||
} else {
|
||||
menu.show();
|
||||
}
|
||||
|
||||
// Position menu
|
||||
var pos = {x: e.pageX, y: e.pageY};
|
||||
|
||||
if (!editor.inline) {
|
||||
pos = tinymce.DOM.getPos(editor.getContentAreaContainer());
|
||||
pos.x += e.clientX;
|
||||
pos.y += e.clientY;
|
||||
}
|
||||
|
||||
menu.moveTo(pos.x, pos.y);
|
||||
});
|
||||
});
|
1
public/tinymce/plugins/contextmenu/plugin.min.js
vendored
Normal file
1
public/tinymce/plugins/contextmenu/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("contextmenu",function(e){var n;e.on("contextmenu",function(t){var o;if(t.preventDefault(),o=e.settings.contextmenu||"link image inserttable | cell row column deletetable",n)n.show();else{var i=[];tinymce.each(o.split(/[ ,]/),function(n){var t=e.menuItems[n];"|"==n&&(t={text:n}),t&&(t.shortcut="",i.push(t))});for(var c=0;c<i.length;c++)"|"==i[c].text&&(0===c||c==i.length-1)&&i.splice(c,1);n=new tinymce.ui.Menu({items:i,context:"contextmenu"}),n.addClass("contextmenu"),n.renderTo(document.body),e.on("remove",function(){n.remove(),n=null})}var a={x:t.pageX,y:t.pageY};e.inline||(a=tinymce.DOM.getPos(e.getContentAreaContainer()),a.x+=t.clientX,a.y+=t.clientY),n.moveTo(a.x,a.y)})});
|
Reference in New Issue
Block a user