obsidian-stack-overflow icon indicating copy to clipboard operation
obsidian-stack-overflow copied to clipboard

Feature request - Fetch the url from the clipboard.

Open willasm opened this issue 2 years ago • 2 comments

This would be so much easier to use if the plugins command read the copied link from the clipboard rather than having to paste it into the document first.

willasm avatar Dec 18 '22 09:12 willasm

Was able to get this working in main.js by making the following changes in your onload() - this.addCommand...

    navigator.clipboard
        .readText()
        .then((clipText) => (this.convertUrlToTitledLink(editor, clipText)));
//       const selectedText = (EditorExtensions.getSelectedText(editor) || "").trim();
//       this.convertUrlToTitledLink(editor, selectedText);

Now no longer need to paste the url into the document first, just copy the answer url, set your cursor position where you want the answer pasted and run the command. Works great!

willasm avatar Dec 18 '22 10:12 willasm

I'll try and add this to the main release, thanks for the catch!

bramses avatar Dec 20 '22 17:12 bramses