xournalpp icon indicating copy to clipboard operation
xournalpp copied to clipboard

Issue #4732 url link tool

Open CruzeBlade opened this issue 2 years ago • 12 comments

Hi, I added a new tool to embed links into the document as requested in issue #4732. This is just an early draft of that feature with basic functionality.

I'm sharing the current status to get feedback and see if there is a chance to merge this in the future, as this will cause compatibility issues with older versions of Xournal++.

Here is a short demo: ezgif com-video-to-gif

What still needs to be done:

  • [x] Integrate with PDF export
  • [x] Open URL by clicking in Browser

CruzeBlade avatar Mar 29 '23 12:03 CruzeBlade

After having work on this feature for the last couple of weeks, here is a small status update on what has changed since.

  • Open the embedded link (normal click opens the editor dialog, and a ctrl + click will open the link in the default program)
  • Improved the link dialog editor
    • Automatically resizes the text field until a certain height
    • Changed text font and alignment options
    • link prefix combo box
  • "Hover" effect for the link element

Here are some images showing the current status:

Improved dialog Hover effects
demo_improved_link_dialog demo_link_hover_effect

Any feedback is greatly appreciated 😎!

CruzeBlade avatar May 25 '23 18:05 CruzeBlade

  • Open the embedded link (normal click opens the editor dialog, and a ctrl + click will open the link in the default program)
    • Improved the link dialog editor

Hello! Thanks for all the effort! This looks amazing hope it can get merged. It would be a valueable contribution to the project! I am no maintainer so I have no say in it. In the past it has been noted in the forums though, that people with "touch devices only" need to be included as well (convertibles), so the programm gets more barrier free. They won't have a Ctrl-Key available when they transform their decive into a touch only one. Hence they won't be able to click the link, only edit the link. There have been similiar discussions on the implementation of the PDF Tools.
#4673 back then "alt" was used, and later neglected. Regards N. Edit: the topic also arose here #4010. "Copy paste selection anchors".

netlimpopo avatar May 31 '23 04:05 netlimpopo

Hi, thank you for the feedback. That is a very good point I haven't thought about. I will have to find a solution for that.

CruzeBlade avatar May 31 '23 06:05 CruzeBlade

Regarding how to open a link:

I'm personally not in favor of opening a link by simply clicking on it. Especially on touch devices, it is quite common to accidentally click somewhere (e.g. while scrolling). This would not only be annoying, but could potentially also be a security issue when somebody has embedded a malicious link. Therefore, I think it is very important that the user can see the full URL before opening it (hence the popover in the current version) and that there needs to be a mechanism to verify the user intentionally wants to open the link (hence the CTRL+click). But that's just my personal opinion on that topic.

My initial thought on how to improve the controls was:

  • Double click for editing & creating -> In the link dialog, I would add a button to open the link
  • Single click will highlight the link (see hover effects) -> I would restyle the URL label as a link -> Clicking on the URL in the popover will open the link (as with pdf links)
  • Single click + CTRL opens the link (as is)

That was just some first idea, and I'm open for discussion and other suggestions.

Regarding internal linking:

I would prefer to do this in a second PR, just to not further inflate the complexity of this PR.

Regarding backwards compatibility:

Does Xournal++ have a warning if users open a newer file with an older xournal++ version? If not something like this might be useful. (But out of scope for this PR)

CruzeBlade avatar Jun 01 '23 18:06 CruzeBlade

Regarding how to open a link:

I'm personally not in favor of opening a link by simply clicking on it. Especially on touch devices, it is quite common to accidentally click somewhere (e.g. while scrolling). This would not only be annoying, but could potentially also be a security issue when somebody has embedded a malicious link. Therefore, I think it is very important that the user can see the full URL before opening it (hence the popover in the current version) and that there needs to be a mechanism to verify the user intentionally wants to open the link (hence the CTRL+click). But that's just my personal opinion on that topic.

Maybe doing it the same way like for PDF links (clicking on the PDF link opens the popover displaying the URL, then clicking on the URL opens the link) would be the way to go then.

Does Xournal++ have a warning if users open a newer file with an older xournal++ version? If not something like this might be useful. (But out of scope for this PR)

Yes, it does:

https://github.com/xournalpp/xournalpp/blob/7d3c6ec13a4174cc24fae3e7832c695d7398e27f/src/core/control/Control.cpp#L2372-L2384

rolandlo avatar Jun 01 '23 21:06 rolandlo

I have now implemented the new controls as mentioned in the previous post.

Here a small demo showing the enhanced popover (I added some control hints for the user): Demo_new_controls

I currently don't own any touch device on which I can run Xournal++. Therefore, it would be great if somebody else could help me out and test if everything works as intended with touch devices.

CruzeBlade avatar Jun 04 '23 15:06 CruzeBlade

I have now finalized the implementation, and therefore I will make this a pull request.

CruzeBlade avatar Jun 10 '23 14:06 CruzeBlade

I have tried out the PR once more and I really like how you solved the way of choosing between editing and following the link. Could you please rebase on master? I want to look at the code in detail. Also please take into account #4763 for making dialogs GTK4 compatible.

One minor thing I found that could possibly be improved: The default value for the text field for the URL is the same regardless of the URI scheme. It doesn't make sense though to write an email to xournalpp.github.io for example. So maybe a different default could be used for different schemes.

rolandlo avatar Aug 16 '23 03:08 rolandlo

Is there any news here yet? I find this almost indispensable for teaching purposes.

Mr-DblH avatar Jul 29 '24 10:07 Mr-DblH

Any news regarding this? It will be very useful. Thanks a lot

Exlonk avatar Aug 08 '25 13:08 Exlonk

Hi guys,

are there any updates on this PR? Thanks!

Photon89 avatar Sep 25 '25 11:09 Photon89