X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FTinyMCE%2Fjs%2Fplugins%2Fcontextmenu%2Feditor_plugin_src.js;fp=plugins%2FTinyMCE%2Fjs%2Fplugins%2Fcontextmenu%2Feditor_plugin_src.js;h=13813a64e4630df01ed620a1d04554c00c4ad939;hb=bb711cb98d2c63e98b7cb9addf6a0979addaaf3b;hp=26e9ce2f8b4ceef71f0a9f0857dbd5977acf5379;hpb=819d33210d298de74b64dc7ead79e9d9b223b12e;p=quix0rs-gnu-social.git diff --git a/plugins/TinyMCE/js/plugins/contextmenu/editor_plugin_src.js b/plugins/TinyMCE/js/plugins/contextmenu/editor_plugin_src.js index 26e9ce2f8b..13813a64e4 100644 --- a/plugins/TinyMCE/js/plugins/contextmenu/editor_plugin_src.js +++ b/plugins/TinyMCE/js/plugins/contextmenu/editor_plugin_src.js @@ -27,7 +27,7 @@ * @param {string} url Absolute URL to where the plugin is located. */ init : function(ed) { - var t = this; + var t = this, lastRng; t.editor = ed; @@ -42,13 +42,33 @@ ed.onContextMenu.add(function(ed, e) { if (!e.ctrlKey) { + // Restore the last selection since it was removed + if (lastRng) + ed.selection.setRng(lastRng); + t._getMenu(ed).showMenu(e.clientX, e.clientY); - Event.add(ed.getDoc(), 'click', hide); + Event.add(ed.getDoc(), 'click', function(e) { + hide(ed, e); + }); Event.cancel(e); } }); - function hide() { + ed.onRemove.add(function() { + if (t._menu) + t._menu.removeAll(); + }); + + function hide(ed, e) { + lastRng = null; + + // Since the contextmenu event moves + // the selection we need to store it away + if (e && e.button == 2) { + lastRng = ed.selection.getRng(); + return; + } + if (t._menu) { t._menu.removeAll(); t._menu.destroy();