mirror of
https://github.com/zadam/trilium.git
synced 2025-12-03 22:14:24 +01:00
chore(client): fix missing argument in context menu
This commit is contained in:
parent
28b263a445
commit
1855588270
@ -4,6 +4,7 @@ import appContext, { type CommandNames } from "../components/app_context.js";
|
|||||||
import type { ViewScope } from "../services/link.js";
|
import type { ViewScope } from "../services/link.js";
|
||||||
import utils, { isMobile } from "../services/utils.js";
|
import utils, { isMobile } from "../services/utils.js";
|
||||||
import { getClosestNtxId } from "../widgets/widget_utils.js";
|
import { getClosestNtxId } from "../widgets/widget_utils.js";
|
||||||
|
import type { LeafletMouseEvent } from "leaflet";
|
||||||
|
|
||||||
function openContextMenu(notePath: string, e: ContextMenuEvent, viewScope: ViewScope = {}, hoistedNoteId: string | null = null) {
|
function openContextMenu(notePath: string, e: ContextMenuEvent, viewScope: ViewScope = {}, hoistedNoteId: string | null = null) {
|
||||||
contextMenu.show({
|
contextMenu.show({
|
||||||
@ -14,7 +15,7 @@ function openContextMenu(notePath: string, e: ContextMenuEvent, viewScope: ViewS
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getItems(e: ContextMenuEvent): MenuItem<CommandNames>[] {
|
function getItems(e: ContextMenuEvent | LeafletMouseEvent): MenuItem<CommandNames>[] {
|
||||||
const ntxId = getNtxId(e);
|
const ntxId = getNtxId(e);
|
||||||
const isMobileSplitOpen = isMobile() && appContext.tabManager.getNoteContextById(ntxId).getMainContext().getSubContexts().length > 1;
|
const isMobileSplitOpen = isMobile() && appContext.tabManager.getNoteContextById(ntxId).getMainContext().getSubContexts().length > 1;
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ function getItems(e: ContextMenuEvent): MenuItem<CommandNames>[] {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleLinkContextMenuItem(command: string | undefined, e: ContextMenuEvent, notePath: string, viewScope = {}, hoistedNoteId: string | null = null) {
|
function handleLinkContextMenuItem(command: string | undefined, e: ContextMenuEvent | LeafletMouseEvent, notePath: string, viewScope = {}, hoistedNoteId: string | null = null) {
|
||||||
if (!hoistedNoteId) {
|
if (!hoistedNoteId) {
|
||||||
hoistedNoteId = appContext.tabManager.getActiveContext()?.hoistedNoteId ?? null;
|
hoistedNoteId = appContext.tabManager.getActiveContext()?.hoistedNoteId ?? null;
|
||||||
}
|
}
|
||||||
@ -44,7 +45,7 @@ function handleLinkContextMenuItem(command: string | undefined, e: ContextMenuEv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNtxId(e: ContextMenuEvent) {
|
function getNtxId(e: ContextMenuEvent | LeafletMouseEvent) {
|
||||||
if (utils.isDesktop()) {
|
if (utils.isDesktop()) {
|
||||||
const subContexts = appContext.tabManager.getActiveContext()?.getSubContexts();
|
const subContexts = appContext.tabManager.getActiveContext()?.getSubContexts();
|
||||||
if (!subContexts) return null;
|
if (!subContexts) return null;
|
||||||
|
|||||||
@ -41,7 +41,7 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, note: FNo
|
|||||||
x: event.pageX,
|
x: event.pageX,
|
||||||
y: event.pageY,
|
y: event.pageY,
|
||||||
items: [
|
items: [
|
||||||
...link_context_menu.getItems(),
|
...link_context_menu.getItems(event),
|
||||||
{ kind: "separator" },
|
{ kind: "separator" },
|
||||||
{
|
{
|
||||||
title: t("board_view.insert-above"),
|
title: t("board_view.insert-above"),
|
||||||
@ -81,7 +81,7 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, note: FNo
|
|||||||
componentFn: () => NoteColorPicker({note})
|
componentFn: () => NoteColorPicker({note})
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, note.noteId),
|
selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, event, note.noteId),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export function openCalendarContextMenu(e: ContextMenuEvent, note: FNote, parent
|
|||||||
x: e.pageX,
|
x: e.pageX,
|
||||||
y: e.pageY,
|
y: e.pageY,
|
||||||
items: [
|
items: [
|
||||||
...link_context_menu.getItems(),
|
...link_context_menu.getItems(e),
|
||||||
{ kind: "separator" },
|
{ kind: "separator" },
|
||||||
getArchiveMenuItem(note),
|
getArchiveMenuItem(note),
|
||||||
{
|
{
|
||||||
@ -40,6 +40,6 @@ export function openCalendarContextMenu(e: ContextMenuEvent, note: FNote, parent
|
|||||||
componentFn: () => NoteColorPicker({note: note})
|
componentFn: () => NoteColorPicker({note: note})
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, note.noteId),
|
selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, e, note.noteId),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export default function openContextMenu(noteId: string, e: LeafletMouseEvent, is
|
|||||||
let items: MenuItem<keyof CommandMappings>[] = [
|
let items: MenuItem<keyof CommandMappings>[] = [
|
||||||
...buildGeoLocationItem(e),
|
...buildGeoLocationItem(e),
|
||||||
{ kind: "separator" },
|
{ kind: "separator" },
|
||||||
...linkContextMenu.getItems(),
|
...linkContextMenu.getItems(e),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isEditable) {
|
if (isEditable) {
|
||||||
@ -32,14 +32,14 @@ export default function openContextMenu(noteId: string, e: LeafletMouseEvent, is
|
|||||||
x: e.originalEvent.pageX,
|
x: e.originalEvent.pageX,
|
||||||
y: e.originalEvent.pageY,
|
y: e.originalEvent.pageY,
|
||||||
items,
|
items,
|
||||||
selectMenuItemHandler: ({ command }, e) => {
|
selectMenuItemHandler: ({ command }) => {
|
||||||
if (command === "deleteFromMap") {
|
if (command === "deleteFromMap") {
|
||||||
appContext.triggerCommand(command, { noteId });
|
appContext.triggerCommand(command, { noteId });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass the events to the link context menu
|
// Pass the events to the link context menu
|
||||||
linkContextMenu.handleLinkContextMenuItem(command, noteId);
|
linkContextMenu.handleLinkContextMenuItem(command, e, noteId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -174,7 +174,7 @@ export function showRowContextMenu(parentComponent: Component, e: MouseEvent, ro
|
|||||||
|
|
||||||
contextMenu.show({
|
contextMenu.show({
|
||||||
items: [
|
items: [
|
||||||
...link_context_menu.getItems(),
|
...link_context_menu.getItems(e),
|
||||||
{ kind: "separator" },
|
{ kind: "separator" },
|
||||||
{
|
{
|
||||||
title: t("table_view.row-insert-above"),
|
title: t("table_view.row-insert-above"),
|
||||||
@ -227,7 +227,7 @@ export function showRowContextMenu(parentComponent: Component, e: MouseEvent, ro
|
|||||||
componentFn: () => NoteColorPicker({note: rowData.noteId})
|
componentFn: () => NoteColorPicker({note: rowData.noteId})
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, rowData.noteId),
|
selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, e, rowData.noteId),
|
||||||
x: e.pageX,
|
x: e.pageX,
|
||||||
y: e.pageY
|
y: e.pageY
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user