Skip to content

Commit 2b8e30d

Browse files
committed
feat: Add "Create subtask" option to task card context menu (#192)
Add a new "Create subtask" menu item to the task card context menu that creates a new task with the current task as the project reference. This provides the same functionality as the "New" button in the project subtasks widget but is accessible from any task card.
1 parent be6adb1 commit 2b8e30d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/ui/TaskCard.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,22 @@ export async function showTaskContextMenu(event: MouseEvent, taskPath: string, p
728728

729729
menu.addSeparator();
730730

731+
// Create subtask
732+
menu.addItem((item) => {
733+
item.setTitle('Create subtask');
734+
item.setIcon('plus');
735+
item.onClick(() => {
736+
// Create a subtask with the current task as the project reference
737+
const taskFile = plugin.app.vault.getAbstractFileByPath(task.path);
738+
if (taskFile instanceof TFile) {
739+
const projectReference = `[[${taskFile.basename}]]`;
740+
plugin.openTaskCreationModal({
741+
projects: [projectReference]
742+
});
743+
}
744+
});
745+
});
746+
731747
// Delete Task
732748
menu.addItem((item) => {
733749
item.setTitle('Delete task');

0 commit comments

Comments
 (0)