Skip to content

Commit b99dd19

Browse files
authored
Merge pull request #3351 from obsidian-tasks-group/docs-quickadd-and-api
docs: Improve the API and QuickAdd pages
2 parents cf8cd96 + fd8fc06 commit b99dd19

File tree

2 files changed

+65
-44
lines changed

2 files changed

+65
-44
lines changed

docs/Advanced/Tasks Api.md

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -67,54 +67,20 @@ console.log(taskLine);
6767
```
6868

6969
> [!warning]
70-
> This function is returns a `Promise` - always `await` the result!
70+
> This function returns a `Promise` - always `await` the result!
71+
72+
> [!Tip]- Find plugins that use the Tasks API to create tasks
73+
> [Search GitHub for plugins which may use this function](https://github.com/search?q=createTaskLineModal+NOT+is%3Afork+NOT+repo%3Aobsidian-tasks-group%2Fobsidian-tasks+NOT+path%3A*.md&type=code), and by using `createTaskLineModal()`, will fully respect your Tasks settings.
74+
> > [!warning]
75+
> >
76+
> > - You will need to be logged in to GitHub for this search to work.
77+
> > - Not all of these plugins have been reviewed by the Obsidian team: you should search for them in `Settings` > `Community plugins` - or review in [Plugins - Obsidian](https://obsidian.md/plugins) - for safety.
7178
7279
### Usage with QuickAdd
7380
One of the most common usage scenarios is probably in combination with the [QuickAdd](https://github.com/chhoumann/quickadd) plugin
7481
to automatically add tasks to a specific file.
7582

76-
For this you need to enter the following code as the Capture format:
77-
78-
<!-- markdownlint-disable code-fence-style -->
79-
~~~markdown
80-
```js quickadd
81-
return await this.app.plugins.plugins['obsidian-tasks-plugin'].apiV1.createTaskLineModal();
82-
```
83-
~~~
84-
<!-- markdownlint-enable code-fence-style -->
85-
86-
Or if you would like a newline character to be added after your new task line, use this as the Capture format instead:
87-
88-
<!-- markdownlint-disable code-fence-style -->
89-
~~~markdown
90-
```js quickadd
91-
return await this.app.plugins.plugins['obsidian-tasks-plugin'].apiV1.createTaskLineModal() + '\n';
92-
```
93-
~~~
94-
<!-- markdownlint-enable code-fence-style -->
95-
96-
For details refer to [QuickAdd - Inline scripts](https://quickadd.obsidian.guide/docs/InlineScripts).
97-
98-
#### Create the QuickAdd Capture
99-
100-
Use these steps to make the following options appear (tested in QuickAdd 0.12.0):
101-
102-
![Screenshot - Create the QuickAdd Capture](../../images/quickadd-settings-create-capture.png)
103-
104-
1. Open the QuickAdd options.
105-
2. Type the name `Add task` in the `Name` box.
106-
3. Click on the `Template` button and select `Capture`.
107-
4. Click `Add Choice`.
108-
109-
#### Configure the QuickAdd Capture
110-
111-
![Screenshot - Open the QuickAdd Capture Configuration](../../images/quickadd-settings-configure-capture.png)
112-
113-
1. In the new row that was added, click on the cog (⚙) icon.
114-
2. Now fill in the values below. (See above for the code to enter in to the `Capture format` box.)
115-
116-
Screenshot of QuickAdd capture settings (example)
117-
![Screenshot - Edit the QuickAdd Capture Configuration](../../images/api-create-taskline-modal-quickadd-capture-example.png)
83+
See [[QuickAdd#Launching the Edit task modal via QuickAdd|Launching the Edit task modal via QuickAdd]] for full details of how to do this.
11884

11985
## `executeToggleTaskDoneCommand: (line: string, path: string) => string;`
12086

@@ -130,9 +96,18 @@ const taskLine = '- [ ] This is a task 📅 2024-04-24';
13096

13197
const result = tasksApi.executeToggleTaskDoneCommand(taskLine, sourceFile.path);
13298

99+
// Do whatever you want with the returned value.
100+
// It's just a string containing the Markdown for the toggled task.
133101
console.log(result); // "- [x] This is a task 📅 2024-04-24 ✅ 2024-04-23"
134102
```
135103

104+
> [!Tip]- Find plugins that use the Tasks API to toggle tasks
105+
> [Search GitHub for plugins which may use this function](https://github.com/search?q=executeToggleTaskDoneCommand+NOT+is%3Afork+NOT+repo%3Aobsidian-tasks-group%2Fobsidian-tasks+NOT+path%3A*.md&type=code), and by using `executeToggleTaskDoneCommand()`, will fully respect your Tasks settings.
106+
> > [!warning]
107+
> >
108+
> > - You will need to be logged in to GitHub for this search to work.
109+
> > - Not all of these plugins have been reviewed by the Obsidian team: you should search for them in `Settings` > `Community plugins` - or review in [Plugins - Obsidian](https://obsidian.md/plugins) - for safety.
110+
136111
## Auto-Suggest Integration
137112

138113
> [!released]
@@ -165,6 +140,13 @@ This can be used, for example, to display the Auto-Suggest on non-task lines. [S
165140
> If the `Editor` is not a `MarkdownView`, the functionality is slightly limited.
166141
> It won't be possible to create [[Task Dependencies]] fields `id` and `dependsOn`.
167142
143+
> [!Tip]- Find plugins that use the Tasks API to suggest task properties
144+
> [Search GitHub for plugins which may use this function](https://github.com/search?q=showTasksPluginAutoSuggest+NOT+is%3Afork+NOT+repo%3Aobsidian-tasks-group%2Fobsidian-tasks+NOT+path%3A*.md&type=code), and by using `showTasksPluginAutoSuggest()`, will fully respect your Tasks settings.
145+
> > [!warning]
146+
> >
147+
> > - You will need to be logged in to GitHub for this search to work.
148+
> > - Not all of these plugins have been reviewed by the Obsidian team: you should search for them in `Settings` > `Community plugins` - or review in [Plugins - Obsidian](https://obsidian.md/plugins) - for safety.
149+
168150
## Limitations of the Tasks API
169151

170152
- Editing tasks:

docs/Other Plugins/QuickAdd.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,46 @@ aliases:
1010

1111
## Launching the Edit task modal via QuickAdd
1212

13-
See [[Tasks Api#Usage with QuickAdd]] for how to use the [[Create or edit Task]] modal to add a task.
13+
This section shows how to use QuickAdd with the [[Create or edit Task]] modal to automatically add tasks to a specific file.
14+
15+
For this you need to enter the following code as the Capture format:
16+
17+
````markdown
18+
```js quickadd
19+
return await this.app.plugins.plugins['obsidian-tasks-plugin'].apiV1.createTaskLineModal();
20+
```
21+
````
22+
23+
Or if you would like a newline character to be added after your new task line, use this as the Capture format instead:
24+
25+
````markdown
26+
```js quickadd
27+
return await this.app.plugins.plugins['obsidian-tasks-plugin'].apiV1.createTaskLineModal() + '\n';
28+
```
29+
````
30+
31+
For details refer to [QuickAdd - Inline scripts](https://quickadd.obsidian.guide/docs/InlineScripts).
32+
33+
### Create the QuickAdd Capture
34+
35+
Use these steps to make the following options appear (tested in QuickAdd 0.12.0):
36+
37+
![Screenshot - Create the QuickAdd Capture](../../images/quickadd-settings-create-capture.png)
38+
39+
1. Open the QuickAdd options.
40+
2. Type the name `Add task` in the `Name` box.
41+
3. Click on the `Template` button and select `Capture`.
42+
4. Click `Add Choice`.
43+
44+
### Configure the QuickAdd Capture
45+
46+
![Screenshot - Open the QuickAdd Capture Configuration](../../images/quickadd-settings-configure-capture.png)
47+
48+
1. In the new row that was added, click on the cog (⚙) icon.
49+
2. Now fill in the values below. (See above for the code to enter in to the `Capture format` box.)
50+
51+
Screenshot of QuickAdd capture settings (example)
52+
![Screenshot - Edit the QuickAdd Capture Configuration](../../images/api-create-taskline-modal-quickadd-capture-example.png)
1453

1554
## Creating your own shortcut to build a task
1655

0 commit comments

Comments
 (0)