-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desktop: Handle URL links #5302
Conversation
So far I've only tested in on Linux. I can also test on Windows but I have no way to test Mac OS so looking for volunteers. Annoyingly on Linux I have to build the AppImage to get it to work but I think on Win & Mac OS it should work with dev builds too. |
Thanks for implementing this. Would you mind running I could test the macOS version. |
I had to commit with
That'd be great. There are 2 scenarios:
There are still a few more things to add here but none of them are OS-specific. |
It might print many warnings for class member accessibility but you can ignore these (hopefully they'll be fixed over time but there are too many in the old codebase to turn this into an error). Other than that the whole codebase should pass the linter without any error. If you're having one unrelated to your code, please post it here. |
… functions to a separate file
Linter errors should be fixed now. |
What happens, if you use the id from a tag or a notebook? Arent't the specs a bit different to your implementation or is this just the first attempt? |
if (noteIds.length == 1) { | ||
menu.append( | ||
new MenuItem({ | ||
label: _('Copy note URL'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit confusing because we already have "Copy markdown link". I think we need to discuss all this in the spec and perhaps also see how it's done in other applications?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Markdown link is a different format though.
I'm not sure how people would use this function but it seems logical to allow for easy creation of links to items that can be linked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about calling this "Copy external link"? (and then same for tags and folders)
packages/lib/ProtocolUtils.ts
Outdated
|
||
export function parseUrl(s: string): UlrInfo { | ||
if (!s.startsWith('joplin://')) return null; | ||
const url = new URL(s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if "URL" is defined in React Native. Perhaps you could use the "url-parse" which is already part of the lib package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to implement the same functionality for mobile next. Until then I don't think anyone is going to call this code on mobile so while it's not safe it shouldn't be an issue either.
packages/lib/ProtocolUtils.ts
Outdated
} | ||
|
||
export function parseUrl(s: string): UlrInfo { | ||
if (!s.startsWith('joplin://')) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should throw an error if the url is invalid. Also shouldn't it start with joplin://x-callback-url/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I don't think throwing error here is a good idea because the error will not be visible in dev tools
Currently nothing happens except for a message in the log. Is there a way to show a notification to the user? The spec has
and
I have both of these plus a similar thing for tags: |
This is strange. When I run linter locally there are no errors. I tried |
And also, I think previously whenever I added a new |
Ok that should be fixed now. It was incorrectly scanning directories that were ignored due to slightly wrong glob pattern. |
Perhaps I'm doing something wrong? I'm testing this feature and when using a callback URL Joplin gains focus, but the note isn't selected. The same note stays on the display. Could something be incorrectly registered in the protocol handler? I've tested by opening the links from Firefox, and also with xdg-open on the command line. Edited to add: forgot to mention that xdg-open gives an "xdg-settings: invalid application name" error. |
What's your OS? Since you mention |
Yes, Ubuntu 20.04 LTE. Joplin installed via the script on the main Github page, so I have the AppImage. |
I tried it out on Linux Mint 20.04 with 2.5.12 (script appimage) and saw the same issue.
Makes no difference if Joplin was already running or was closed. Trying the link again doesn't go to the correct note. |
Could you also check if the same happens with links to folders or tags? |
Same behavior with notebooks (I think that's what you meant) and tags. |
Same behaviour here, selecting tags or notebooks just goes to the same page you already had open (even from closed). |
Just tested it on macOS and it works. Well, we always had the issue on macOS that Joplin had to run, because for some reason the info was not passed as an argument. So, if Joplin runs, all is good on macOS. This seems to be an issue with Linux then. However, I am sure that Roman tested this on Linux when he wrote this PR and afaik it was working back then. |
Btw, this is the wrong PR. It was merged by accident and then reverted. The correct PR is #5416 |
As the (correct) PR is already merged should this just be opened as an issue instead? |
Yes, an issue might be better to track this. |
FWIW it's working for me on Linux. But I did not install it the recommended way, instead I built an AppImage via |
Here's what I did.
Now, I'm not too familiar with different flavours of Linux but I suspect it's the "integrate the app image part" that may be different. |
Out of interest what are you using? As Linux Mint is just a flavour of Ubuntu we don't have the greatest variation from the existing reports. I have to admit I don't ever recall being asked to integrate the app image, it has always just kind of worked without me messing around with it and I don't recall using any other installations (for example the software centre contains the flatpak version). |
I never got a prompt. That said, I first tried it under Firefox, not in a terminal. Perhaps that's necessary? |
I'm on Manjaro. |
I managed to reproduce it on Ubuntu though I still don't understand where the issue is. Since Joplin receives focus the url-scheme-handler must be working. My only idea is that the OS does something to the url that makes it invalid. |
Perhaps you can simply view the URL received from within Joplin to debug. I think your suspicion is correct. Do you also get "xdg-settings: invalid application name" error when running xdg-open on a Joplin link? That could also be a hint as to what the problem is. |
Could there be something different in the implementation of the AppImage on Ubuntu, or perhaps something common to all AppImages, that interferes with the URL being passed? |
On my main Manjaro system - no, it opens Joplin and switches to the note.
Possibly, but I am not an expert on Linux. |
I figured out a solution. Go to ~/.local/share/applications and edit appimagekit-joplin.desktop Change this line: To: I don't know why it works in some distros though. Also, I figure there should be a way to automate this without requiring a user manually edit the .desktop file. |
Ha! Was just about to post exactly that. Including the part where I have no idea why it's working for me. |
That I can take care of. |
Just to close this off - I think I now know why it was working for me. There are 2 |
To resolve going forward, are you going to fix the script? When installing (or at least updating) via script, there's no prompt to integrate the AppImage, and apparently that isn't done automatically. |
The PR above has the |
Partially resolves #5168