commit a6ab904cd0d2fa06c408450f541618a3c953d8f2
parent 2f9c7fd8393088735b91d060f6082f44b271ab06
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 4 Feb 2014 20:55:12 -0500
Note link tweaks
- Send modifier keys through to loadURI() when clicking Open Link in notes
- Open link in parent window from external note window
- Don't show both menus on right-click
Follow-up from #450
Diffstat:
3 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/chrome/content/zotero/bindings/styled-textbox.xml b/chrome/content/zotero/bindings/styled-textbox.xml
@@ -140,7 +140,10 @@
break;
case 'openlink':
- ZoteroPane.loadURI(event.target.href);
+ var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+ .getService(Components.interfaces.nsIWindowMediator);
+ win = wm.getMostRecentWindow('navigator:browser');
+ win.ZoteroPane.loadURI(event.target.href, event.modifierKeys);
break;
default:
diff --git a/resource/tinymce/plugins/linksmenu/editor_plugin.js b/resource/tinymce/plugins/linksmenu/editor_plugin.js
@@ -26,9 +26,18 @@
// add editor command to open links through zoteroHandleEvent
ed.addCommand('openlink', function(command) {
- var node = tinyMCE.activeEditor.selection.getNode();
+ var ed = tinyMCE.activeEditor;
+ var node = ed.selection.getNode();
if (node.nodeName == 'A') {
- zoteroHandleEvent({ type: 'openlink', target: node });
+ zoteroHandleEvent({
+ type: 'openlink',
+ target: node,
+ // We don't seem to be able to access the click event that triggered this
+ // command in order to check the modifier keys used, so instead we save
+ // the keys on every menu click in tiny_mce.js and pass them on here
+ // for use by loadURI().
+ modifierKeys: ed.lastClickModifierKeys
+ });
}
});
@@ -46,9 +55,20 @@
};
showMenu = ed.onClick.add(function(ed, e) {
- // only show when <a> node + Block TinyMCE menu on ctrlKey and work around Safari issue
- if (e.target.nodeName != 'A' || ((realCtrlKey !== 0 ? realCtrlKey : e.ctrlKey) && !contextmenuNeverUseNative))
+ // Only show on left-click
+ if (e.button != 0) {
return;
+ }
+
+ // Only show when <a> node
+ if (e.target.nodeName != 'A') {
+ return;
+ }
+
+ // Block TinyMCE menu on ctrlKey and work around Safari issue
+ if ((realCtrlKey !== 0 ? realCtrlKey : e.ctrlKey) && !contextmenuNeverUseNative) {
+ return;
+ }
Event.cancel(e);
diff --git a/resource/tinymce/tiny_mce.js b/resource/tinymce/tiny_mce.js
@@ -11646,6 +11646,16 @@ tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', {
t.mouseClickFunc = Event.add(co, 'click', function(e) {
var m;
+ // Added by Zotero
+ //
+ // Record the modifier keys used with the last menu click -- used by linksmenu plugin
+ tinymce.activeEditor.lastClickModifierKeys = {
+ altKey: e.altKey,
+ ctrlKey: e.ctrlKey,
+ metaKey: e.metaKey,
+ shiftKey: e.shiftKey
+ };
+
e = e.target;
if (e && (e = DOM.getParent(e, 'tr')) && !DOM.hasClass(e, cp + 'ItemSub')) {