diff --git a/src/map-renderer.ts b/src/map-renderer.ts index 4fa7ea7..2eeb246 100644 --- a/src/map-renderer.ts +++ b/src/map-renderer.ts @@ -23,7 +23,7 @@ export interface MapPoint { color?: string; size?: number; cover?: string; - file?: TFile | string; + file?: TFile; tags?: string[]; properties?: MapProperty[]; } @@ -153,22 +153,20 @@ function getIconSVG(iconName: string, strokeWidth: number, fill: boolean): strin } function handlePointClick(info: PickingInfo, event: MjolnirEvent, options: MapRendererOptions['options'], app: App) { - if (info.object) { - if (options.onMarkerClick) { - options.onMarkerClick(info.object.point, event); - } else if (info.object.point.file) { - const file = typeof info.object.point.file === 'string' - ? app.vault.getAbstractFileByPath(info.object.point.file) - : info.object.point.file; - if (file instanceof TFile) { - const srcEvent = event?.srcEvent; - const newTab = - (srcEvent && 'button' in srcEvent && srcEvent.button === 1) || - srcEvent?.ctrlKey || - srcEvent?.metaKey; - app.workspace.getLeaf(newTab).openFile(file); - } - } + if (!info.object) return; + + if (options.onMarkerClick) { + options.onMarkerClick(info.object.point, event); + return; + } + + if (info.object.point.file) { + const srcEvent = event?.srcEvent; + const newTab = + (srcEvent && 'button' in srcEvent && srcEvent.button === 1) || + srcEvent?.ctrlKey || + srcEvent?.metaKey; + app.workspace.getLeaf(newTab).openFile(info.object.point.file); } } @@ -339,8 +337,7 @@ export async function createMapRenderer(config: MapRendererOptions): Promise