bramses / obsidian-stack-overflow

Fetch Stack Oveflow answers and copy paste them directly into Obsidian
MIT License
33 stars 0 forks source link

Feature request - Fetch the url from the clipboard. #10

Open willasm opened 1 year ago

willasm commented 1 year ago

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 commented 1 year ago

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!

bramses commented 1 year ago

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