-
-
Notifications
You must be signed in to change notification settings - Fork 56
add command for copy markdowned link #156
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting idea. What's your use case for this feature? I've left some comments.
// const copyFunc = asMarkdown ? | ||
// (parameters)=>this.tools.copyMarkdownLink(parameters) : (parameters) =>this.tools.copyURI(parameters); | ||
|
||
let copyFunc = (parameters: Parameters) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be const
const view = app.workspace.getActiveViewOfType(FileView); | ||
if (!view && !file) return; | ||
|
||
// const copyFunc = asMarkdown ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment should be removed.
@@ -116,6 +117,16 @@ export default class Tools { | |||
new Notice("Advanced URI copied to your clipboard"); | |||
} | |||
|
|||
async copyMarkdownLink(parameters: Parameters) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the markdownTitle
should not be added to Parameters
,because Parameters
should only be used for uri input or output. Add it as another argument.
const uri = await this.generateURI(parameters, true); | ||
const markdownLink = "[" + markdownTitle + "](" + uri + ")"; | ||
|
||
new Notice("Advanced URI copied to your clipboard (Markdown)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case the copying fails, the notice should be placed after the actual copy function call.
); | ||
}); | ||
menu.addItem((item)=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like the file menu is already pretty full. I would rather keep it concise and therefore not add this item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think need both version, because remove old behaviour will break current scenarios.
And it is may be not comfort as option in settings, because somebody can need both types of link and he will deside about link type at copy moment. It depends from target link (as simple link or paste to another markdown file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I can't follow your comment. Just keep the old menu item with the old function to just copy the uri. The added commands should be used as a way to copy the whole markdown link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I add an option to the settings for show/hide markdown item (hidden by default)?
@@ -63,6 +63,12 @@ export default class AdvancedURI extends Plugin { | |||
callback: () => this.handlers.handleCopyFileURI(true), | |||
}); | |||
|
|||
this.addCommand({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would either add the markdown version for the command with options as well, or just the one with options.
I need work with two vaults: work and personal. Sometimes I need link from each to other. Thanks for review, I will fix style soon |
Thanks for your pr, but I've solved it now differently myself. |
Let's add copy link to a note as markdown, with filename as title.