denolehov / obsidian-url-into-selection

Paste URLs into selected text "notion style"
345 stars 28 forks source link

Plugin activates on Ctrl + V even after the hotkey is changed to something else #25

Open welpdx opened 3 years ago

welpdx commented 3 years ago

Issue / Actual Behavior

I changed the hotkey from Ctrl + V to Ctrl + Shift + V. While Ctrl + Shift + V now activates the plugin, Ctrl + V also activates the plugin.

Expected Behaviour

After changing the hotkey from Ctrl + V to Ctrl + Shift + V, Ctrl + V should paste as normal and not activate the plugin.

Steps to Reproduce the problem

  1. Activate plugin
  2. Go to Settings -> Hotkeys -> Paste URL into selection: -> Customize this command -> Ctrl + Shift + V
  3. Pasting url (using Ctrl + V) when selecting "word" results in [word](url) instead of just url.

Specifications

Plugin Version: 1.6.0 Obsidian Version: 0.12.5

Note

It looks like this issue was noted here... But the issue still persists
gif

firinael commented 3 years ago

Pretty sure the project has been abandoned. I'm gonna ask someone on the Discord's #plugin-dev channel to see if they can take over. Shouldn't be too much to take care of.

Also, that gif of yours was super pretty, what did you use for it?

welpdx commented 3 years ago

Pretty sure the project has been abandoned. I'm gonna ask someone on the Discord's #plugin-dev channel to see if they can take over. Shouldn't be too much to take care of.

That'll be cool! And if they ask for someone to take over, maybe we can!

Also, that gif of yours was super pretty, what did you use for it?

Aw thanks! I use ShareX to take the gif and upload it to imgur; and I use Crealesson to show keyboard and mouse activities on screen.

pjeby commented 3 years ago

May I suggest using Mod-K Mod-V instead of this plugin? I'm not sure if Mod-K is Obsidian's default binding for "Insert Markdown link", it might just be what I've personally set it to, but if you use that command (i.e. Insert Markdown link) followed by pasting, then the selected text will become a link and the cursor will be positioned just right to paste in the URL.

welpdx commented 3 years ago

Hi @pjeby, thanks for the suggestion. Is Mod a mac shortcut?

Anyways, I currently use this script below and I use the Hotkeys for templates plugin to trigger this Templater script with Ctrl + Shift + B.

<%*
var clip = await tp.system.clipboard();

if (tp.file.selection() !== "" ) { 
// If there is text selected
    %>[<%  tp.file.selection() %>](<% clip %>)<%*
} else  if (clip.charAt(0) !== '"'){  
// If no text selection and clipboard not empty, just paste it in set format, add text later
    %>[](<% clip %>)<%*
} else { 
// toast error message
    new Notice('Somefing Wong!',3000);
}
%>

Above script is barebones because I can't figure out how to process C:/foo/bar and zotero://foo/bar links together with html links yet. This plugin has a isUrl() function which uses regex to test if clipboard contains an url. So I guess I am stuck figuring out a regex line that accepts the typical windows file path, zotero links, and html. Yea, that is waaay down at the bottom of my to do list rn. Either that or I use some switch statements...

~welp

pjeby commented 3 years ago

Mod is Obsidian's official way of describing "Control on PC / Cmd on Mac".

So, Ctrl-K, Ctrl-V does the equivalent of this plugin (on PC), or Cmd-K, Cmd-V on Mac.

welpdx commented 3 years ago

Oh I see, I didn't know that! Yea Ctrl + K works great, but I still prefer this plugin or the script I posted though, cause it skips a few clickity clicks

welp