Skip to content
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

[Feature Request] Automatically convert URLs to link #1718

Closed
guanqun-yang opened this issue Jul 9, 2019 · 48 comments
Closed

[Feature Request] Automatically convert URLs to link #1718

guanqun-yang opened this issue Jul 9, 2019 · 48 comments
Labels
desktop All desktop platforms stale An issue that hasn't been active for a while...

Comments

@guanqun-yang
Copy link

Problem

It is sometimes tiresome to manually copy the link insert link using markdown syntax [<description>](<URL>) especially when I need to work with many links in a document. I am wondering if it is possible to directly convert the link with descriptions scraped from the particular website.

Similar features are provided in another note-taking app (BoostNote) as is shown below. Note the description is provided by the app (probably scraped from website).
image

@stale
Copy link

stale bot commented Oct 7, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the stale An issue that hasn't been active for a while... label Oct 7, 2019
@Perkolator
Copy link
Contributor

This would be a big time saver, don't kill this one silly bot.

Quickly copying just the link URL to the note is not that useful because, A) many times it's not that descriptive, B) the rendered view isn't that intelligent to wrap the long URL's (it knows to wrap when it encounters a hyphen (-) but many times the URL's have some other characters that could be used to indicate a "wrap point", but the rendered view doesn't do it).

@stale stale bot removed the stale An issue that hasn't been active for a while... label Oct 11, 2019
@Perkolator
Copy link
Contributor

And perhaps adding an on/off option for this feature would be wise.

@jtagcat
Copy link
Contributor

jtagcat commented Dec 5, 2019

Currently links get highlighted and are clickable.
As for description scraping, it seems like a very low priority for development.
Though if you want to implement this, make the link text a certain character (for example if you insert a hyphen [-](https://joplinapp.org)), then Joplin knows to scrape the content and replace the hyphen with the description.

@laurent22 laurent22 added desktop All desktop platforms good first issue labels Dec 15, 2019
@adrijshikhar
Copy link

i would like to work on this issue. is it still available?

@jtagcat
Copy link
Contributor

jtagcat commented Feb 23, 2020

i would like to work on this issue. is it still available?

Yes, go for it.

@alishamohanty
Copy link

@adrijshikhar Are you still working in the issue? If not I would like to take on the task.

@adrijshikhar
Copy link

Go ahead

@Perkolator
Copy link
Contributor

Though if you want to implement this, make the link text a certain character (for example if you insert a hyphen [-](https://joplinapp.org)), then Joplin knows to scrape the content and replace the hyphen with the description.

I don't think that this would be that useful. Best implementation would be that when no text is selected and user just pastes URL, Joplin would automatically create the markdown syntax [<description>](<URL>) and fetch the title of the URL, just like I think the issue opener meant.

When text is selected and something (URL or no URL) is pasted, Joplin would just do normal paste.

This feature would need a settings option to turn this behavior on/off (which would be the default?). Some users might not like this feature.

@Rishabh-malhotraa
Copy link
Contributor

Though if you want to implement this, make the link text a certain character (for example if you insert a hyphen [-](https://joplinapp.org)), then Joplin knows to scrape the content and replace the hyphen with the description.

I don't think that this would be that useful. Best implementation would be that when no text is selected and user just pastes URL, Joplin would automatically create the markdown syntax [<description>](<URL>) and fetch the title of the URL, just like I think the issue opener meant.

When text is selected and something (URL or no URL) is pasted, Joplin would just do normal paste.

This feature would need a settings option to turn this behavior on/off (which would be the default?). Some users might not like this feature.

this is definitely helpful @Perkolator I'll look into it and see what I can do

@tessus
Copy link
Collaborator

tessus commented Feb 27, 2020

I certainly don't want this behavior. At least not by default. If it's guarded by a setting, I don't care.

But Joplin connecting to the Internet, every time I paste a link, would be a showstopper for me. This is unacceptable.

@Rishabh-malhotraa
Copy link
Contributor

I certainly don't want this behavior. At least not by default. If it's guarded by a setting, I don't care.

But Joplin connecting to the Internet, every time I paste a link, would be a showstopper for me. This is unacceptable.

Ok, @tessus, this is to the best of my understanding, CORRECT ME IF I'm WRONG, if I was working on the PR I would go about like this,

(AS mentioned by @Perkolator )

67167601-93b7e780-f3a4-11e9-99ee-76a9c5c54a3c

  • First when you need input Hyperlink in the dialogue box

  • We would have a feature for feature automatically, if this is unchecked there would be no behaviour change, this will behave the same as it behaves now

  • If the check-box is checked we can extract the title of the URL either from Regexp of using URL-Polyfill

  • If you Enter the tittle it would override the automatic extraction of Tittle

BottleNecks

  • We need to use a different dependency than small talk, as it only has one dialogue for entry, which seems like a major change, because you have to install a different dependency, and that dependency might not be consistent with the UI look of the app, but I'm confident we can find one

Any thoughts @Perkolator @PackElend

@tessus
Copy link
Collaborator

tessus commented Feb 27, 2020

Thanks for the detailed explanation.

Ok, this makes sense and is acceptable. However, I had the impression that this PR was about pasting a link into the editor with Cmd+V. But if it's the same as #1731, let's close this one, since we don't need 2 issues for the same thing.

@Perkolator
Copy link
Contributor

No no, this is NOT the same as the other one, I don't know what @Rishgod is messing about. This issue is about pasting URL and creating markdown syntax and description automatically. Here's my previous message again:

Best implementation would be that when no text is selected and user just pastes URL, Joplin would automatically create the markdown syntax [<description>](<URL>) and fetch the title of the URL, just like I think the issue opener meant.

When text is selected and something (URL or no URL) is pasted, Joplin would just do normal paste.

This feature would need a settings option to turn this behavior on/off (which would be the default?). Some users might not like this feature.

@Rishabh-malhotraa
Copy link
Contributor

No no, this is NOT the same as the other one, I don't know what @Rishgod is messing about. This issue is about pasting URL and creating markdown syntax and description automatically. Here's my previous message again:

Best implementation would be that when no text is selected and user just pastes URL, Joplin would automatically create the markdown syntax [<description>](<URL>) and fetch the title of the URL, just like I think the issue opener meant.
When text is selected and something (URL or no URL) is pasted, Joplin would just do normal paste.
This feature would need a settings option to turn this behavior on/off (which would be the default?). Some users might not like this feature.

Okay can you, please clarify this, so that I understand you correctly

you mean to say if we post the link in the editor it automatically gets converted into markdown URL with a title

Like as soon as I paste the link it should look like what the latter looks in the gif
ISSUE-TITLE

@Perkolator
Copy link
Contributor

Yes, that's correct. But only when no text is selected in the editor prior paste. If some text is selected, then Joplin would do normal paste.

@miciasto
Copy link
Contributor

miciasto commented Mar 2, 2020

@Perkolator what are you basing these requirements on?

@Perkolator
Copy link
Contributor

What specifically? You can write a differentiating opinion how this could/should be implemented.

@miciasto
Copy link
Contributor

miciasto commented Mar 2, 2020

Yes, I was going to ;) But I was wondering if your suggestions were based on an another editor? I just wanted to understand the context.

My concern was overriding the standard paste function.

I was thinking perhaps use Ctrl-K like here on GitHub but a bit more helpful. I was going to suggest Ctrl-K behaviours, depending on whether text is selected and whether there is a URL in the clipboard. Something like:

Text is selected and a URL is in the clipboard:
(selected text)[url from clipboard]

No text is selected and a URL is in the clipboard
(cursor is here )[url from the clipboard]

Text is selected and no URL is in the clipboard
(selected text)[cursor is here]

No text is selected and no URL is in the clipboard
(cursor is here)[ ]

@Perkolator
Copy link
Contributor

I'm not a fan of that Ctrl-K idea. Harder to use button combination. And your suggestion doesn't automatically fetch the title/description of the URL like the issue opener wished. Also the Ctrl-K shortcut is already tied to the "insert hyperlink" popup window.

But your post makes me slightly revise my suggestion:

With normal Ctrl-V / paste operation:

No text is selected and a URL is in the clipboard:
(title from the url)[URL from clipboard]

Text is selected and a URL is in the clipboard:
(selected text)[URL from clipboard] (better implementation than my previous idea)

Otherwise, when there's no URL in the clipboard, Joplin would do normal paste operation.

This feature would need a settings option to turn this behavior on/off.

@tessus
Copy link
Collaborator

tessus commented Mar 2, 2020

At one point we discussed a Paste special idea. e.g. for tables and/or csv. This could also be used for links. We haven't implemented this yet, but it could be useful.

e.g. Cmd+Shift+V or something would invoke the special paste. If the clipboard contains only a link, do the whatever-you-want-with-URLs-and-title-or-whatnot.

@miciasto
Copy link
Contributor

miciasto commented Mar 2, 2020

And your suggestion doesn't automatically fetch the title/description of the URL like the issue opener wished

I thought that was a separate issue #1731

Also the Ctrl-K shortcut is already tied to the "insert hyperlink" popup window

Oh I didn't realise that.

But your post makes me slightly revise my suggestion

Sounds good on first read. For the first scenario, I would like it as you say, but with the title from the url text left selected at the end of the operation.

@miciasto
Copy link
Contributor

miciasto commented Mar 2, 2020

e.g. Cmd+Shift+V or something would invoke the special paste

That could work too.

@Perkolator
Copy link
Contributor

And your suggestion doesn't automatically fetch the title/description of the URL like the issue opener wished

I thought that was a separate issue #1731

That is primarily about the "insert hyperlink" popup window, it had an additional bonus, "enhanced" suggestion like what this issue primarily is about.

Here's a quote from the first post of this issue:

I am wondering if it is possible to directly convert the link with descriptions scraped from the particular website.


e.g. Cmd+Shift+V or something would invoke the special paste

That could work too.

That is a good idea. Ctrl+Shift+V is a rather easy key combination and normal paste would be left intact, which means IMO that Joplin wouldn't need a new settings option at all.

@miciasto
Copy link
Contributor

miciasto commented Mar 2, 2020

That is primarily about the "insert hyperlink" popup window

OK so this one is about key command, and the other is about the popup window. I think I get it now!

IMO automatically formatting links when pasting into a note with a dedicated key combination is great. Retrieving info from the URL site should be optional (setting) defaulting to off.

@Perkolator
Copy link
Contributor

Retrieving info from the URL site should be optional (setting) defaulting to off.

That's fine with me. :)

@aaronxn
Copy link
Contributor

aaronxn commented Mar 7, 2020

Text is selected and a URL is in the clipboard:
(selected text)[url from clipboard]

No text is selected and a URL is in the clipboard
(cursor is here )[url from the clipboard]

Text is selected and no URL is in the clipboard
(selected text)[cursor is here]

No text is selected and no URL is in the clipboard
(cursor is here)[ ]

I personally love the logic mentioned above, and the SHIFT+CTRL+V idea. If this feature workes really well and users love it, it can always be incorporated into a 'smart paste' hybrid as default CTRL+V behavior (with a settings toggle) later on.

@ankitpal1029
Copy link

ankitpal1029 commented Feb 8, 2021

i would love to implement the CTRL+SHIFT+V idea to paste links that autofill the heading of a given site, @tessus can you please tell me where in the codebase should i look as i am new to this project

@ankitpal1029
Copy link

I was wondering if we could make the special paste (ctrl+shift+v) for the links to auto input onto the editor in the form - where the focus will be on the hyphen right after the pasting action so that the user could modify the naming of the link as soon as he pastes. maybe later on we could implement a scraping function on this special paste?

@ArenaGrenade
Copy link

Is this feature implemented yet? If not can I pick it up and figure something?

@ArenaGrenade
Copy link

@tessus can I pick this issue up?

@roman-r-m
Copy link
Collaborator

Go ahead, it seems no one is working on it.

@ArenaGrenade
Copy link

Alright! I was able to add the feature into a context menu - #4676. I even setup stuff for getting the shortcuts going, but I am not sure how to bridge the keystrokes and commands :(

@ArenaGrenade
Copy link

Specifications:

  • Cmd+Shift+V / context menu item triggers a special paste function
  • The special paste function, then checks whether the content in the clipboard is an URL.
  • If it turns out to be an URL, then we check if there is a part of the text selected in the editor.
  • If some text is selected, then we replace that text with a link with the alt text to be of the selected text. So, essentially if "hello" is selected text and we are trying to special paste the link "https://www.google.com", then we will have it replaced to "hello"
  • If no text is selected, then we go ahead with either replacing with "https://www.google.com" or just paste it as such - as markdown render automatically converts links to click-eable ones.

@ArenaGrenade
Copy link

@laurent22 would the above specs be good enough for discussion?

@tessus
Copy link
Collaborator

tessus commented Mar 15, 2021

@ArenaGrenade the whole point for paste special was that the title of the URL is retrieved and then used in the markdown code.

e.g.: let's say https://joplinapp.org/ is in the clipboard. You Paste -> Special or Cmd+Shift+V and the following is inserted at the current cursor position:

[Joplin - an open source note taking and to-do application with synchronisation capabilities](https://joplinapp.org/)

@tessus
Copy link
Collaborator

tessus commented Mar 15, 2021

I'll be back in a few hours. I have to get some sleep....

@ArenaGrenade
Copy link

I certainly don't want this behavior. At least not by default. If it's guarded by a setting, I don't care.

But Joplin connecting to the Internet, every time I paste a link, would be a showstopper for me. This is unacceptable.

Refering to your point and hence the discussion watered down the feature to what I motioned above.

@ArenaGrenade
Copy link

I'll be back in a few hours. I have to get some sleep....

Sorry take your time :)

@ArenaGrenade
Copy link

Text is selected and a URL is in the clipboard:
(selected text)[url from clipboard]
No text is selected and a URL is in the clipboard
(cursor is here )[url from the clipboard]
Text is selected and no URL is in the clipboard
(selected text)[cursor is here]
No text is selected and no URL is in the clipboard
(cursor is here)[ ]

I personally love the logic mentioned above, and the SHIFT+CTRL+V idea. If this feature workes really well and users love it, it can always be incorporated into a 'smart paste' hybrid as default CTRL+V behavior (with a settings toggle) later on.

As mentioned here, I completely agree with them and I feel it would only help how useful this feature might even be before taking the effort towards a scraper - thought a scraper is not very hard to implement tbf (baby steps than a giant leap :))

@Perkolator
Copy link
Contributor

Perkolator commented Mar 15, 2021

Here's what I suggested earlier:

No text is selected and a URL is in the clipboard:
(title from the url)[URL from clipboard]

Text is selected and a URL is in the clipboard:
(selected text)[URL from clipboard]

I personally don't like the "cursor is here" suggestions, especially (EDIT: or rather only for because I don't see myself using the other cases where "cursor is here" was suggested) for the "No text is selected and a URL is in the clipboard".

@ArenaGrenade
Copy link

Aight so I will reiterate the points and paste them here for the cases:

  1. URL is in clipboard, text is selected

[selected text](url in clipboard)

  1. URL is in clipboard, no text is selected

[scraped text from website](url in clipboard)

  1. Two more cases but we just ignore as there will be no URL in clipboard.

@tessus
Copy link
Collaborator

tessus commented Mar 15, 2021

The other 2 cases are already handled by Cmd+K (Insert Hyperlink).

However, theoretically item 1 could also be handled by Cmd+K. It checks if a link is in the clipboard and if so, skip the dialog.

But these are decisions Laurent will have to make.

@ArenaGrenade
Copy link

True but, isn't a dialog would just be a un-necessary step as is, because we are replacing the text with the corresponding markdown URL format - people can just choose to edit it if they want.

Just as a suggestion - it takes a shorter time to just press a combination of keys or press a button to see changes rather than see a dialog and make do with that to get the link working.

As to the scraper - it is perfectly feasible with a bunch of regex and ClientRequest from electron.js and possibly do some fallback in case of no internet connection detection.

So, the suggestion of this as a shortcut along with context menu actions is not only feasible but could prove as a better and faster alternative to the insert hyperlink. Another way we can go about this is to keep the insert hyperlink as is and add this as an additional way to do the same thing.

@stale
Copy link

stale bot commented Apr 18, 2021

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.

@stale stale bot added the stale An issue that hasn't been active for a while... label Apr 18, 2021
@jtagcat
Copy link
Contributor

jtagcat commented Apr 18, 2021

notfixed

@stale
Copy link

stale bot commented Jun 3, 2021

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Jun 3, 2021
@jtagcat
Copy link
Contributor

jtagcat commented Jun 4, 2021

cc @guanqun-yang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop All desktop platforms stale An issue that hasn't been active for a while...
Projects
None yet
Development

No branches or pull requests