MCPcopy
hub / github.com/callumalpass/tasknotes / showTaskContextMenu

Function showTaskContextMenu

src/ui/taskCardContextMenu.ts:66–109  ·  view source on GitHub ↗
(
	event: MouseEvent,
	taskPath: string,
	plugin: TaskNotesPlugin,
	targetDate: Date,
	options: { promoteOccurrenceControls?: boolean } = {}
)

Source from the content-addressed store, hash-verified

64 * Show context menu for task card.
65 */
66export async function showTaskContextMenu(
67 event: MouseEvent,
68 taskPath: string,
69 plugin: TaskNotesPlugin,
70 targetDate: Date,
71 options: { promoteOccurrenceControls?: boolean } = {}
72): Promise<void> {
73 const file = plugin.app.vault.getAbstractFileByPath(taskPath);
74 const showFileMenuFallback = () => {
75 if (file instanceof TFile) {
76 showFileContextMenu(event, file, plugin);
77 }
78 };
79
80 try {
81 const task = await plugin.cacheManager.getTaskInfo(taskPath);
82 if (!task) {
83 showFileMenuFallback();
84 return;
85 }
86
87 const contextMenu = new TaskContextMenu({
88 task,
89 plugin,
90 targetDate,
91 promoteOccurrenceControls: options.promoteOccurrenceControls,
92 onUpdate: () => {
93 plugin.app.workspace.trigger("tasknotes:refresh-views");
94 },
95 });
96
97 contextMenu.show(event);
98 } catch (error) {
99 const errorMessage = error instanceof Error ? error.message : String(error);
100 getTaskCardContextMenuLogger(plugin).error("Error creating context menu", {
101 category: "internal",
102 operation: "create-context-menu",
103 details: { taskPath, errorMessage },
104 error,
105 });
106 new Notice(`Failed to create context menu: ${errorMessage}`);
107 showFileMenuFallback();
108 }
109}
110
111function showFileContextMenu(event: MouseEvent, file: TFile, plugin: TaskNotesPlugin): void {
112 const menu = new Menu();

Callers 9

createTaskCardFunction · 0.90
setupCardDragHandlersMethod · 0.85
KanbanViewClass · 0.85
handleKanbanCardActionFunction · 0.85
TaskListViewClass · 0.85
handleActionClickMethod · 0.85
TaskCard.test.tsFile · 0.85

Calls 7

showMethod · 0.95
showFileMenuFallbackFunction · 0.85
getAbstractFileByPathMethod · 0.80
errorMethod · 0.80
getTaskInfoMethod · 0.65
triggerMethod · 0.65

Tested by

no test coverage detected