summaryrefslogtreecommitdiff
path: root/program/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-06-24 13:22:08 +0000
committeralecpl <alec@alec.pl>2010-06-24 13:22:08 +0000
commit2011bef155aacdfa8461a4d5c2cd3988d946d135 (patch)
tree15eb4903597ded4ea1d6cbe3c9e18d6d31f13f0a /program/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js
parentf821fecac880c8e4b3ca33897b6a32c140348c65 (diff)
- TinyMCE 3.3.7
Diffstat (limited to 'program/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js')
-rw-r--r--program/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js26
1 files changed, 23 insertions, 3 deletions
diff --git a/program/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js b/program/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js
index 26e9ce2f8..13813a64e 100644
--- a/program/js/tiny_mce/plugins/contextmenu/editor_plugin_src.js
+++ b/program/js/tiny_mce/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();