zotero/zotero — pull request #450 by jlegewie (2014-02-03 13:37:25+00:00)
Title: TinyMCE Improvements: Open links from note window with popup and auto-create links (for 4.0 branch)

Okay, here is an updated version for the 4.0 branch.

> 1) I'll accept this on the 4.0 branch for 4.0.18...

I have Moved the pull-request.

> 2) We should pass through the modifier keys to loadURI so that people can open in a new tab/window, etc. You can see the properties checked by loadURI() (.shiftKey, etc.) and just pass a fake event object with those copied from the original event.

I tried but have problems doing this because I am unable to get the original event. Maybe you have an idea what's going on. Currently, the linksmenu plugin adds a command using `ed.addCommand('openlink'`, which calls `zoteroHandleEvent` with a fake event (but without .shiftKey, etc.). This 'openlink' command is called when the user clicks the button based on this line `cmd : 'openlink'` in the definition of the `Open Link` button. The command is not an event though so that I don't know how to get the data. An alternative would be to replace `cmd : 'openlink'` with `onclick: function() {... call to zoteroHandleEvent...` but that function only gets the node as an argument not the event.

> 3) Rather than modifying tiny_mce.js (which we generally want to avoid, since it makes upgrades more annoying), can't you just add the 'openlink' command in the setup function in note.html?

3) Done. The command is now defined in the plugin so that the `linksmenu` plugin contains all the relevant code. There is, however, a second place were I used to modify tinymce code. I changed the `contextmenu` plugin to add the open button to the right click menu as well. It's a little annoying because the contextmenu plugin is minified so that my small change replaces the entire plugin. I don't think there is a workaround for that. This pull request *does not include this commit* for now. I can add the commit, I could create a new plugin `contextmenu2` with the modification, or the `open link` button does not appear in the right-click menu but I think it's nice. What is your preference?

> 4) I'm seeing a little glitchiness...

For me, two finger click on touchpad is right click (OSX/Firefox) and I can't reproduce the problem. So it would be great if you can take a look.

> 5) I'd say that, with the single-click menu, we should get rid of the Unlink button in the toolbar and just leave the one link button.

I remove the Unlink button from the toolbar.

6) There is another limitation. The current implementation does not work for separate note windows. It's probably easy to fix but I wasn't sure how. The popup appear but clicking on "open link" doesn't do anything. I think the problem is in `loadURI`, which might try to open the link in the separate note window.