]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/TinyMCE/js/plugins/contextmenu/editor_plugin_src.js
Update TinyMCE to release 3.3.8, jQuery version
[quix0rs-gnu-social.git] / plugins / TinyMCE / js / plugins / contextmenu / editor_plugin_src.js
index 26e9ce2f8b4ceef71f0a9f0857dbd5977acf5379..13813a64e4630df01ed620a1d04554c00c4ad939 100644 (file)
@@ -27,7 +27,7 @@
                 * @param {string} url Absolute URL to where the plugin is located.\r
                 */\r
                init : function(ed) {\r
-                       var t = this;\r
+                       var t = this, lastRng;\r
 \r
                        t.editor = ed;\r
 \r
 \r
                        ed.onContextMenu.add(function(ed, e) {\r
                                if (!e.ctrlKey) {\r
+                                       // Restore the last selection since it was removed\r
+                                       if (lastRng)\r
+                                               ed.selection.setRng(lastRng);\r
+\r
                                        t._getMenu(ed).showMenu(e.clientX, e.clientY);\r
-                                       Event.add(ed.getDoc(), 'click', hide);\r
+                                       Event.add(ed.getDoc(), 'click', function(e) {\r
+                                               hide(ed, e);\r
+                                       });\r
                                        Event.cancel(e);\r
                                }\r
                        });\r
 \r
-                       function hide() {\r
+                       ed.onRemove.add(function() {\r
+                               if (t._menu)\r
+                                       t._menu.removeAll();\r
+                       });\r
+\r
+                       function hide(ed, e) {\r
+                               lastRng = null;\r
+\r
+                               // Since the contextmenu event moves\r
+                               // the selection we need to store it away\r
+                               if (e && e.button == 2) {\r
+                                       lastRng = ed.selection.getRng();\r
+                                       return;\r
+                               }\r
+\r
                                if (t._menu) {\r
                                        t._menu.removeAll();\r
                                        t._menu.destroy();\r