Skip to content

Commit

Permalink
Open in new split from ribbon icon (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcain authored May 23, 2021
1 parent 545cf35 commit 807bf29
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "periodic-notes",
"name": "Periodic Notes",
"description": "Create/manage your daily, weekly, and monthly notes",
"version": "0.0.15",
"version": "0.0.16",
"author": "Liam Cain",
"authorUrl": "https://github.com/liamcain/",
"isDesktopOnly": false,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-periodic-notes",
"version": "0.0.15",
"version": "0.0.16",
"description": "Create/manage daily, weekly, and monthly notes",
"author": "liamcain",
"main": "main.js",
Expand Down
2 changes: 1 addition & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async function openFile(file: TFile, inNewSplit: boolean): Promise<void> {
? workspace.splitActiveLeaf()
: workspace.getUnpinnedLeaf();

await leaf.openFile(file, { active : true });
await leaf.openFile(file, { active: true });
}

async function openNextNote(periodicity: IPeriodicity): Promise<void> {
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import {
getLegacyWeeklyNoteSettings,
hasLegacyWeeklyNoteSettings,
isMetaPressed,
} from "./utils";

declare global {
Expand Down Expand Up @@ -81,7 +82,8 @@ export default class PeriodicNotesPlugin extends Plugin {
this.ribbonEl = this.addRibbonIcon(
`calendar-${config.unitOfTime}`,
`Open ${config.relativeUnit}`,
() => openPeriodicNote(periodicity, window.moment(), false)
(event: MouseEvent) =>
openPeriodicNote(periodicity, window.moment(), isMetaPressed(event))
);
this.ribbonEl.addEventListener("contextmenu", (ev: MouseEvent) => {
showFileMenu(this.app, this.settings, {
Expand Down
8 changes: 8 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,11 @@ export function getLegacyWeeklyNoteSettings(): IPeriodicNoteSettings {
template: options.weeklyNoteTemplate?.trim() || "",
};
}

function isMacOS() {
return navigator.appVersion.indexOf("Mac") !== -1;
}

export function isMetaPressed(e: MouseEvent): boolean {
return isMacOS() ? e.metaKey : e.ctrlKey;
}

0 comments on commit 807bf29

Please sign in to comment.