Skip to content

Commit

Permalink
fix(file-card): fix mid-click and mod-click on file card
Browse files Browse the repository at this point in the history
- fix mid-click and mod-click won't open note in new leaf;
- fix mod-click on title open in
original note

fix #20
  • Loading branch information
aidenlx committed Sep 15, 2021
1 parent 38625dc commit fe89454
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/components/file-card.tsx
Expand Up @@ -9,6 +9,7 @@ import {
App,
FileStats,
moment,
Platform,
SectionCache,
TAbstractFile,
TFile,
Expand Down Expand Up @@ -93,10 +94,19 @@ export const FileCard = ({ plugin, src, cover, linkType }: FileCardProps) => {
}, [file]);

const handleClick = (e: React.MouseEvent) => {
e.stopPropagation();
e.preventDefault();
if (e.target instanceof Element && e.target.matches("a.tag, span.ant-tag"))
return;
else if ([0, 1].includes(e.button))
workspace.openLinkText(file.path, "", false);
else if (e.button === 0) {
workspace.openLinkText(
file.path,
"",
(Platform.isMacOS && e.metaKey) || e.ctrlKey,
);
} else if (e.button === 1) {
workspace.openLinkText(file.path, "", true);
}
};
return (
<Card
Expand Down
1 change: 0 additions & 1 deletion src/components/filter.ts
@@ -1,6 +1,5 @@
// import { Set } from "immutable";
import minimatch from "minimatch";
import RegexParser from "regex-parser";

export type Filter = ((name: string) => boolean) | null;

Expand Down

0 comments on commit fe89454

Please sign in to comment.