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
This commit is contained in:
Dan Stillman 2014-02-04 20:55:12 -05:00
parent 2f9c7fd839
commit a6ab904cd0
3 changed files with 38 additions and 5 deletions

View file

@ -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:

View file

@ -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);

View file

@ -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')) {