QuickAdd Plugin

Hey! Could you show me the macro in question? I put

Diet: {{VALUE:DIET}}
Supplement: {{VALUE:SUPP}}
Daily Log: {{VALUE:LOG}}

in a template and it worked fine. I also put it in a capture, and it worked fine. :slight_smile:

Do you have anything in the frontmatter or filename that indicates that a given file denotes a project? If so, I think it would be very possible with a script - and it would always be updated to include all projects, including new ones. :slight_smile:

Hey @Christian ,

Thanks for your reply. My script knowledge is limited but I’m keen to make it happen.

Coming back to your question, yes, all files have a frontmatter property called “Type” where I can identify them as Project, Notes, Archive, etc.

i was looking at metaedit api to use it in quickadd:

update(propertyName: string, propertyValue: string, file: TFile | string)
Updates a property with the given name to the given value in the given file.

If the file is a string, it should be the file path. Otherwise, a TFile is fine.

This is an asynchronous function, so you should await it.

it say the update function value type is string, i have a counter in yaml that i want to go up by one number in the current active file. what should i do?

That makes it a bit easier. You’d be able to fetch all files where the type is project.
Something like this (probably not a very efficient way to do it):

app.metadataCache.getCachedFiles()
    .map(file => app.metadataCache.getFileCache(app.vault.getAbstractFileByPath(file)))
.filter(meta => meta?.frontmatter?.type === "Project")

Something like this :slight_smile:

const currentFile = app.workspace.getActiveFile();
if (!currentFile) return;

const cfMeta = app.metadataCache.getFileCache(currentFile);
const counter = parseInt(cfMeta.frontmatter.count);

app.plugins.plugins["metaedit"].api.update("count", counter + 1, currentFile);
2 Likes

thank you so much, i got he desired results for the counter, but couldn’t pass it to update the matadata because i couldn’t figure out that yaml key needs to be in “”. it is a bit confusing in the documentaion.

1 Like

Can you use the suggester, but be able to choose more than one option? How would I do that? I tried using this, {{VALUE: but could not seem to make it work. I want to be able to have options for how I slept like was up late, and fell asleep quickly or had a hard time sleeping.

Something like {{VALUE:Up late,Fast asleep,Poor sleep}}?

I don’t think I explained what I am tying to do clearly. So, today I want to be able to say that I was Up late and Fell asleep quickly, so I want to use two of the suggested responses. Is that possible?

Hello! I admit I am new to Obsidian and not much into coding, but I really like how Obsidian is fitting into my time management and Quickadd is becoming a staple part of it.

I was wondering though, for Capture, can you please keep the “Insert After” option if “Current File” option is turned on, or at least have a {{CURRENTFILEPATH}} syntax? It would be a great option if I want to quickly add items to a heading block in a file that is currently open, or even move whole sections to a particular heading, without having multiple commands/macros for each file if said files have similar structures like, let’s say, multiple projects.

Or if you have an alternative way of doing what I described I would love to hear it!

3 Likes

+1 for this, i felt the exact same issue with these two situations

1 Like

Hello! I just discovered quickadd js yesterday and was hoping to achieve this with it:

  1. automatically obtain weather info from “wttr.in/?format=3” on mobile.

Could anyone tell me what I should write in the quickadd js codeblock? I’m a newbie at coding and could not possibly figure out a way myself atm. I use tp.user function curl "wttr.in/?format=3" on PC, but neither can tp.user nor curl work on mobile.

Many thanks.

Has someone understood the purpose of :

executeChoice(choiceName: string, variables?: {[key: string]: any})

In the QuickAdd API ?

Bug description :

Empty variables ("") declared in QuickAdd.variables will trigger an input prompt.

Desired outcome :

We should be able to choose if we want an input prompt for empty variables or not.

Any way to change this behavior ?

Usecase :

In a .js script made to import movies, I define the variable myRating in QuickAdd.variables. If the movie has been seen, this variable is worth the rating (e.g. : "8/10"). Else, this variable is empty ("").

If I decided that the variable myRating is empty, I don’t want a prompt to specify its value, which is the case currently.

Workaround :

If an empty variable is desired, define it as " " and not as "".

2 Likes

Hey guys!
I have a {{VDATE: date, DD-MM-yyyy}} on a template which is used in a macro and works fine.
I’d like to automatically increase that date, like what’s done with {{DATE+7}}, is it possible?

Thanks

The plugin’s format syntax documentation is at

https://github.com/chhoumann/quickadd/blob/master/docs/FormatSyntax.md

There it says

{{VDATE:<variable name>, <date format>}} You’ll get prompted to enter a date and it’ll be parsed to the given date format. You could write ‘today’ or ‘in two weeks’ and it’ll give you the date for that. Works like variables, so you can use the date in multiple places. REQUIRES THE NATURAL LANGUAGE DATES PLUGIN!

Thaks for helping

I’m able to use these formats, what I wanted to know is if I can increase the VDATE without having to input it again.

Like this

Aah, so some kind of multi-select? It’s not possible by default. I added it to my backlog.

Here’s a simple script to do it. You can change the options as you want, but do keep Done the same.

```js quickadd
const suggester = this.quickAddApi.suggester;
let toSuggest = ["Up late", "Fast asleep", "Poor sleep", "Done"];
const responses = [];
let response;

while (response !== "Done") {
    response = await suggester(toSuggest, toSuggest);
    if (response !== "Done") {
        responses.push(response);
        toSuggest = toSuggest.map(s => s === response ? `✅ ${s}` : s);
    }
}

return responses.join(", ");
```

You can put that in your capture, for example.

4 Likes

This is definitely something I want to do. It’s a weird constraint in the first place, lol. I have it on my to-dos!

1 Like