-
-
Notifications
You must be signed in to change notification settings - Fork 284
feat: Add the ability to launch the task modal to edit an existing line #3528
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
base: main
Are you sure you want to change the base?
Conversation
…ing taskLine to edit
…), also adds exported type for consistent params passing to fix issue I had not passing allTasks from test
… allTasks from plugin
0bd8e12
to
3a16d5f
Compare
Next, I need to smoke test and add smoke tests for the tasks edit api |
Hi @justise, many thanks for doing this. I have a few suggestions for the docs... I'll wait until you make it non-Draft, and then to save your time, I'll make the edits and push them to your branch. |
I've done two smoke tests for it, having built the plugin with the code on this PR. Both worked great!!! 😄 Test 1
const tasksApi = this.app.plugins.plugins['obsidian-tasks-plugin'].apiV1;
let editedTaskLine = await tasksApi.editTaskLineModal('- [ ] #task Do every day 🔼 🔁 every day ➕ 2025-07-06 ⏳ 2025-07-06');
console.log(editedTaskLine);
Result:
Test 2 - changed Tasks settings
const tasksApi = this.app.plugins.plugins['obsidian-tasks-plugin'].apiV1;
let editedTaskLine = await tasksApi.editTaskLineModal('- [ ] #task Do every day 🔼 🔁 every day ➕ 2025-07-06 ⏳ 2025-07-06');
console.log(editedTaskLine);
Result is the same lines returned but correctly in the opposite order:
|
Thanks. Want me to add those to the smoke tests docs? Admittedly I haven't yet smoke tested myself but could mark it ready for review now to unblock till I can do some manual testing. |
Just one of them will be fine. If you could add it to the Demo page I linked in #3509 (comment), that would be ideal - just so we don't forget about how to test it in future... |
Personally, I don't feel a need for any more manual testing. I can't think of anything that could go wrong, based on the smoke testing already done. (The automated tests of the Modal via the API are mostly testing mocks, as far as I can tell, rather than testing actual behaviour - but there is already very thorough other testing of the actual API behaviour - so in the case I'm happy with the smoke testing being sufficient..) |
Pushing some smoke test documentation, hope its decent. :) |
|
Thank you! I will review this as soon as I can. |
## `editTaskLineModal(taskLine: string): Promise<string>;` | ||
|
||
> [!released] | ||
This method was introduced in Tasks X.X.X. |
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.
Version needs updating
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.
Since you asked:
https://publish.obsidian.md/tasks-contributing/Documentation/Version+numbers+in+documentation
It’s on my list to edit that version to X.Y.Z and then the release script will set the version number automatically.
Types of changes
Changes visible to users:
feat
- non-breaking change which adds functionality)docs
- improvements to any documentation content for users)Internal changes:
test
- additions and improvements to unit tests and the smoke tests)Description
Expose an
editTaskLineModal(taskLine: string) : Promise<string>
method in the API.This method takes the content of the task and populates the values into the tasks modal.
The return value is the newly edited tasks markdown, or empty if the modal is canceled.
Motivation and Context
This will support external plugins to interact with tasks by leveraging the Obsidian Tasks API. Without this, plugins cannot enter the tasks edit modal, they'll require users to launch it themselves.
Fixes #1945.
How has this been tested?
[x] Unit tests for the new editTaskLineModal() internal method
[x] Unit tests for the API method to ensure it calls
[ ] Smoke Testing
Screenshots (if appropriate)
API, n/a
Checklist
yarn run lint
.Terms