MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / showFileContextMenu

Function showFileContextMenu

src/ui/taskCardContextMenu.ts:111–140  ·  view source on GitHub ↗
(event: MouseEvent, file: TFile, plugin: TaskNotesPlugin)

Source from the content-addressed store, hash-verified

109}
110
111function showFileContextMenu(event: MouseEvent, file: TFile, plugin: TaskNotesPlugin): void {
112 const menu = new Menu();
113
114 let populated = false;
115 try {
116 plugin.app.workspace.trigger("file-menu", menu, file, "tasknotes-bases-view");
117 populated = ((menu as MenuWithItems).items?.length ?? 0) > 0;
118 } catch {
119 populated = false;
120 }
121
122 if (!populated) {
123 menu.addItem((item) => {
124 item.setTitle("Open");
125 item.setIcon("file-text");
126 item.onClick(() => {
127 void plugin.app.workspace.getLeaf(false).openFile(file);
128 });
129 });
130 menu.addItem((item) => {
131 item.setTitle("Open in new tab");
132 item.setIcon("external-link");
133 item.onClick(() => {
134 void plugin.app.workspace.openLinkText(file.path, "", true);
135 });
136 });
137 }
138
139 menu.showAtMouseEvent(event);
140}

Callers 1

showFileMenuFallbackFunction · 0.85

Calls 4

setIconMethod · 0.80
onClickMethod · 0.80
getLeafMethod · 0.80
triggerMethod · 0.65

Tested by

no test coverage detected