quickadd icon indicating copy to clipboard operation
quickadd copied to clipboard

[FEATURE REQUEST] Capture to any file by select filename in input textbox instead of setting

Open Jackiexiao opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe. I want to capture idea/thought to different markdown pages, but currently I can only set one page for one command ( except the daily note which we could use a template like daily/{{DATE:gggg-MM-DD - ddd MMM D}}.md )

Describe the solution you'd like A clear and concise description of what you want to happen.

image

in this example, we could add any content to any file under file's title #todo, after insert, we could get result in filename.md

...
# todo  
some_context #this line is add by quick-add
....

It would be much more convenient then select only one filename in Capture setting

Jackiexiao avatar Aug 17 '22 05:08 Jackiexiao

@chhoumann is there a workaround to this? Maybe by combining macro somehow?

datavistics avatar Aug 20 '22 18:08 datavistics

Sure, @datavistics!

You could create a macro with this script:

module.exports = async (params) => {
    const allMdFiles = params.app.vault.getMarkdownFiles();
    const selectedFilePath = await params.quickAddApi.suggester(
        allMdFiles.map(f => f.basename),
        allMdFiles.map(f => f.path)
    );

    params.variables.path = selectedFilePath;
}

Call the script first, and then capture to the {{VALUE:path}} variable. image

So the macro looks like this: image

I called the script ask_for_file.js.

chhoumann avatar Aug 20 '22 18:08 chhoumann

wow! thx for your reply! @datavistics @chhoumann its really helpful!

I take some time to understand how quick add's micro work and it works perfect!

I have a few question

  • I wonder how to suggest files alias too not just file's base name?
  • can we add a feature to support dynamic insert after params as well? so basically we can use this script to add any content to any file under any line
  • ps: I have to change Capture format to {{VALUE}} \n in other to add a newline to avoid just add content to already exist line's ending. Is this a deliberate design?

Jackiexiao avatar Aug 21 '22 10:08 Jackiexiao

@chhoumann seriously THANKS so much. Thats amazing. If I ever meet you Ill give you a big hug.

datavistics avatar Aug 22 '22 04:08 datavistics

image

If we can use macro directly in capture filename, it could be much convenient .

ChitaGideon avatar Nov 20 '22 13:11 ChitaGideon