Skip to content

Commit

Permalink
Fix #97
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed May 21, 2021
1 parent aa235cd commit cf21252
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
18 changes: 14 additions & 4 deletions dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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+(.+)$/;
Expand Down Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion dist/manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 8 additions & 1 deletion src/components/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 12 additions & 3 deletions src/components/Item/ItemMenu.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Menu, TFolder } from "obsidian";
import { getLinkpath, Menu, TFolder } from "obsidian";
import update from "immutability-helper";
import React from "react";

Expand Down Expand Up @@ -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]);
}

0 comments on commit cf21252

Please sign in to comment.