From cf21252be402135dd01a45a3b7e3521bb941d722 Mon Sep 17 00:00:00 2001 From: mgmeyers Date: Fri, 21 May 2021 12:19:31 -0700 Subject: [PATCH] Fix #97 --- dist/main.js | 18 ++++++++++++++---- dist/manifest.json | 2 +- manifest.json | 2 +- src/components/Item/Item.tsx | 9 ++++++++- src/components/Item/ItemMenu.ts | 15 ++++++++++++--- 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/dist/main.js b/dist/main.js index 77b9fec5..c6cfe4d9 100644 --- a/dist/main.js +++ b/dist/main.js @@ -19866,7 +19866,7 @@ var jsYaml = { }; const frontMatterKey = "kanban-plugin"; -const frontmatterRegEx = /^---([\w\W]+?)---/; +const frontmatterRegEx = /^---([\w\W]+?)\n---/; const newLineRegex = /[\r\n]+/g; // Begins with one or more # followed by a space const laneRegex = /^#+\s+(.+)$/; @@ -38340,10 +38340,16 @@ function useItemMenu({ setIsEditing, item, laneIndex, itemIndex, boardModifiers, }); } } - return (e) => { + return (e, internalLinkPath) => { coordinates.x = e.clientX; coordinates.y = e.clientY; - menu.showAtPosition(coordinates); + if (internalLinkPath) { + // @ts-ignore + view.app.workspace.onLinkContextMenu(e, obsidian.getLinkpath(internalLinkPath), view.file.path); + } + else { + menu.showAtPosition(coordinates); + } }; }, [view, setIsEditing, boardModifiers, laneIndex, itemIndex, item]); } @@ -38425,7 +38431,11 @@ function draggableItemFactory({ items, laneIndex, }) { return (react.createElement("div", Object.assign({ onContextMenu: (e) => { e.preventDefault(); e.stopPropagation(); - showMenu(e.nativeEvent); + const internalLinkPath = e.target instanceof HTMLAnchorElement && + e.target.hasClass("internal-link") + ? e.target.dataset.href + : undefined; + showMenu(e.nativeEvent, internalLinkPath); }, onDoubleClick: () => { setIsEditing(true); }, className: `${c$2("item")} ${classModifiers.join(" ")}`, ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps), diff --git a/dist/manifest.json b/dist/manifest.json index 9b11a51e..d415bcaf 100644 --- a/dist/manifest.json +++ b/dist/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-kanban", "name": "Kanban", - "version": "0.3.6", + "version": "0.3.7", "minAppVersion": "0.11.13", "description": "Create markdown-backed Kanban boards in Obsidian.", "author": "mgmeyers", diff --git a/manifest.json b/manifest.json index 9b11a51e..d415bcaf 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-kanban", "name": "Kanban", - "version": "0.3.6", + "version": "0.3.7", "minAppVersion": "0.11.13", "description": "Create markdown-backed Kanban boards in Obsidian.", "author": "mgmeyers", diff --git a/src/components/Item/Item.tsx b/src/components/Item/Item.tsx index 06fdaff8..111e6efb 100644 --- a/src/components/Item/Item.tsx +++ b/src/components/Item/Item.tsx @@ -157,7 +157,14 @@ export function draggableItemFactory({ onContextMenu={(e) => { e.preventDefault(); e.stopPropagation(); - showMenu(e.nativeEvent); + + const internalLinkPath = + e.target instanceof HTMLAnchorElement && + e.target.hasClass("internal-link") + ? e.target.dataset.href + : undefined; + + showMenu(e.nativeEvent, internalLinkPath); }} onDoubleClick={() => { setIsEditing(true); diff --git a/src/components/Item/ItemMenu.ts b/src/components/Item/ItemMenu.ts index 7905c771..bf3a7643 100644 --- a/src/components/Item/ItemMenu.ts +++ b/src/components/Item/ItemMenu.ts @@ -1,4 +1,4 @@ -import { Menu, TFolder } from "obsidian"; +import { getLinkpath, Menu, TFolder } from "obsidian"; import update from "immutability-helper"; import React from "react"; @@ -221,11 +221,20 @@ export function useItemMenu({ } } - return (e: MouseEvent) => { + return (e: MouseEvent, internalLinkPath?: string) => { coordinates.x = e.clientX; coordinates.y = e.clientY; - menu.showAtPosition(coordinates); + if (internalLinkPath) { + // @ts-ignore + view.app.workspace.onLinkContextMenu( + e, + getLinkpath(internalLinkPath), + view.file.path + ); + } else { + menu.showAtPosition(coordinates); + } }; }, [view, setIsEditing, boardModifiers, laneIndex, itemIndex, item]); }