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

Don't override standard ctrl+v functionality #22

Open
Mpic opened this issue May 14, 2021 · 18 comments
Open

Don't override standard ctrl+v functionality #22

Mpic opened this issue May 14, 2021 · 18 comments

Comments

@Mpic
Copy link

Mpic commented May 14, 2021

This plugin is awesome as it implements one of my preferred Typora's functionalities : automatic handling of URL pasting.
I love being able to copy a URL, select some text (or not if I just want one word) then ctrl+K to automagically make a perfect Markdown link.

However, I really don't want to use ctrl+v for that, and this plugin even though I set a hotkey to ctrl+k continues to override ctrl+v and it shows each time I paste something that is detected wrongfully or not as an URL : as an example, pasting <% tp.file.cursor() %> anywhere gives [](<%3C% tp.file.cursor() %%3E>) and using shift+ctrl+v doesn't bypass this, so I have to either manually delete all the junk added by the plugin or stop using the plugin :'(

Please, just use the hotkey setting to activate the plugin !

@denolehov
Copy link
Owner

denolehov commented May 15, 2021

Hey @Mpic, I am unable to reproduce the issue with <%3C% tp.file.cursor() %%3E> string :(

Could you please make sure that you have the following regex specified in settings?

^[a-z0-9-]+:(\/){2,3}[a-zA-Z0-9-]+

If it's the only issue you're experiencing with the ctrl+v shortcut, I don't see a reason to kill it from plugin.

But I agree, ideally, the plugin should disable the ctrl+v shortcut if a custom one was specified in settings because the former one becomes redundant.

@Mpic Mpic changed the title Don't override standard ctlr+v functionality Don't override standard ctrl+v functionality May 16, 2021
@Mpic
Copy link
Author

Mpic commented May 16, 2021

Thanks !
It's not the only issue, that was just the latest example of a pasted text being misinterpreted by the plugin =/
It happens a lot with long texts copied from the web.
I can however confirm that the regex was not what you pasted, it was this instead (I think it was the default ?) :

[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)

The one you gave works better.

Still, it really would be nice to leave ctrl+v alone especially if another hotkey was specified.

@NeighNeighNeigh
Copy link

Yeah I would also like to prevent the plugin from hijacking ctrl+v. Sometimes I want to paste a link without using the plugin (ie. I just want a raw url). I am also accustomed to being able to make a text selection and to then paste over it with ctrl+v. Here's the problem: Sometimes I want to paste a raw url over a selection and can't do so because of this issue. This has happened often enough that I came here to open an issue, only to discover someone else had me beat.

@Mpic
Copy link
Author

Mpic commented May 17, 2021

I would also argue that a better default hotkey would be ctrl+k, as it is quite a standard one for inserting an URL in a selected text (here on GitHub, in your mail client, in Microsoft Word, in Typora, most smart text editors).

@NeighNeighNeigh
Copy link

I have mine set to ctrl+shift+K leaving ctrl+k for Obsidian's default add markdown link behaviour.

@Mpic
Copy link
Author

Mpic commented May 20, 2021

I have mine set to ctrl+shift+K leaving ctrl+k for Obsidian's default add markdown link behaviour.

I have found that I don’t need the default add markdown link as this plugin implements its functionality.

@HaujetZhao
Copy link

Yes, even if I choose 3.14, paste 2, it will become [2](3.14), so it's really annoying me.

I think it's necessary to judge whether the chosen or copied content is a URL before changing the pasting action.

@Cito
Copy link
Contributor

Cito commented Jun 18, 2021

Right. Either we use a dedicated hotkey for pasting URLs or we use the same hotkey ctrl-v, but then it should be checked whether it's really a URL. Also, if you are already inside a link construct, i.e. [...](...), then pasting should not create another, nested link construct, but change the URL in the already existing link.

@NeighNeighNeigh
Copy link

Thought maybe a video demonstrating the issue might be helpful?

Screen.Recording.2021-07-03.at.10.08.33.am.mp4

@mementori
Copy link

This plugin is awesome as it implements one of my preferred Typora's functionalities : automatic handling of URL pasting.
I love being able to copy a URL, select some text (or not if I just want one word) then ctrl+K to automagically make a perfect Markdown link.

However, I really don't want to use ctrl+v for that, and this plugin even though I set a hotkey to ctrl+k continues to override ctrl+v and it shows each time I paste something that is detected wrongfully or not as an URL : as an example, pasting <% tp.file.cursor() %> anywhere gives [](<%3C% tp.file.cursor() %%3E>) and using shift+ctrl+v doesn't bypass this, so I have to either manually delete all the junk added by the plugin or stop using the plugin :'(

Please, just use the hotkey setting to activate the plugin !

Hi, i just created a GitHub account, just to tell you that your plugin is great.
However, I ran exactly in the same issues described earlier. Here is my paste result.

<<title: %3C%+ tp.file.title %%3E>>

I tried to change the hotkey, i tried to change almost every possible setting.
Copy/Paste would only work, if i turn your plugin off. Which I need to do for now.
I really hope you can solve this mystery, because, as mentioned, it was really useful for me.

Thank for your work on that.
Sincerely, N

@firinael
Copy link

firinael commented Sep 9, 2021

This is happening for me even when I'm not using Templater.

I'm using Ctrl+K as my "paste into link" hotkey, and Ctrl+V'ing into a selection still pastes the link "inside" it.

@denolehov
Copy link
Owner

I will see what I can do about this, most likely over the weekend.

@mitchallain
Copy link

mitchallain commented Nov 21, 2021

I too am wishing this plug-in would fallback to standard paste behavior in more scenarios. Regarding @NeighNeighNeigh's example, perhaps just testing the selected text for isUrl would solve the use case of replacing an existing link?

Allowing the option of an alternate link pasting hotkey would be nice, though.

Also thanks for this work!

@ghost
Copy link

ghost commented Feb 3, 2022

Yes, I ran into the same situation a few times while going through old notes and editing them.
Trying to paste a word over an URL instead leads to the word becoming hyperlinked with said URL. It would be better if it was just replaced with ctrl + k so there isn't an overlap with functions of traditional copy-and-pasting.

@vii33
Copy link

vii33 commented Mar 6, 2022

Same issue here. I love the plugin but it is quite error prone when copying text around.
As an idea perhaps you could just add a keyboard shortcut (which could by default be CTRL+V), so people can change it to their likings? Then everybody woulde be happy, I guess.

@NomarCub
Copy link

NomarCub commented Sep 8, 2022

Is this plugin maintained at all @denolehov? Could the people with the pull requests take over or just also maintain?

@BumbrT
Copy link

BumbrT commented Oct 23, 2023

Looks like, I created duplicate issue here #53.
You can use my fork https://github.com/BumbrT/obsidian-url-into-selection through BRAT plugin. Only one line difference with this repo: disabled editor paste handling.

@jose-elias-alvarez
Copy link

If anyone's curious, I also made my own version of this plugin that implements this as an option (and also allows bypassing the plugin by holding Shift otherwise): https://github.com/jose-elias-alvarez/obsidian-paste-link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests