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

Method addTaskNotesFileMenuActions

src/main.ts:334–377  ·  view source on GitHub ↗
(menu: Menu, file: TAbstractFile, source?: string)

Source from the content-addressed store, hash-verified

332 }
333
334 addTaskNotesFileMenuActions(menu: Menu, file: TAbstractFile, source?: string): void {
335 if (source === "tasknotes-context-menu") {
336 return;
337 }
338
339 if (!(file instanceof TFile)) {
340 return;
341 }
342
343 const metadata = this.app.metadataCache.getFileCache(file);
344 if (!metadata?.frontmatter || !this.cacheManager.isTaskFile(metadata.frontmatter)) {
345 return;
346 }
347
348 menu.addSeparator();
349 menu.addItem((item) => {
350 item.setTitle(this.i18n.translate("modals.taskEdit.title"));
351 item.setIcon("pencil");
352 item.setSection("tasknotes");
353 item.onClick(() => {
354 void this.openTaskEditModalForFile(file);
355 });
356 });
357
358 const task = this.cacheManager.getCachedTaskInfoSync(file.path);
359 if (!task) {
360 return;
361 }
362
363 menu.addItem((item) => {
364 item.setTitle(this.i18n.translate("common.appName"));
365 item.setIcon("list-checks");
366 item.setSection("tasknotes");
367 const submenu = getSubmenu(item);
368 TaskContextMenu.addToMenu(submenu, {
369 task,
370 plugin: this,
371 targetDate: getTodayLocal(),
372 onUpdate: () => {
373 this.app.workspace.trigger("tasknotes:refresh-views");
374 },
375 });
376 });
377 }
378
379 /**
380 * Initialize HTTP API service (desktop only)

Calls 11

getTodayLocalFunction · 0.90
getFileCacheMethod · 0.80
isTaskFileMethod · 0.80
setIconMethod · 0.80
onClickMethod · 0.80
getCachedTaskInfoSyncMethod · 0.80
getSubmenuFunction · 0.70
translateMethod · 0.65
triggerMethod · 0.65
addToMenuMethod · 0.45

Tested by

no test coverage detected