diff --git a/.yarn/cache/obsidian-npm-0.14.4-eb5648c626-b0ee32972a.zip b/.yarn/cache/obsidian-npm-0.14.4-eb5648c626-b0ee32972a.zip deleted file mode 100644 index d3ec777..0000000 Binary files a/.yarn/cache/obsidian-npm-0.14.4-eb5648c626-b0ee32972a.zip and /dev/null differ diff --git a/.yarn/cache/obsidian-npm-0.16.3-2085245b2f-48e82e011b.zip b/.yarn/cache/obsidian-npm-0.16.3-2085245b2f-48e82e011b.zip new file mode 100644 index 0000000..4c7acf5 Binary files /dev/null and b/.yarn/cache/obsidian-npm-0.16.3-2085245b2f-48e82e011b.zip differ diff --git a/package.json b/package.json index b12a061..7006130 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "dependencies": { "@popperjs/core": "2.11.5", "lodash": "4.17.21", - "obsidian": "0.14.4", + "obsidian": "0.16.3", "svelte": "3.47.0", "svelte-writable-derived": "^2.1.3", "tslib": "2.3.1" @@ -36,7 +36,7 @@ "esbuild-svelte": "0.7.0", "eslint": "8.13.0", "eslint-plugin-import": "^2.26.0", - "moment": "2.29.2", + "moment": "2.29.4", "sass": "^1.50.0", "standard-version": "^9.3.2", "svelte-check": "2.7.0", diff --git a/src/commands.ts b/src/commands.ts index 60293c4..a8d26a8 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -1,4 +1,4 @@ -import { type Command, App, TFile, Notice } from "obsidian"; +import { type Command, App, TFile, Notice, Keymap } from "obsidian"; import type PeriodicNotesPlugin from "src/main"; import type { Granularity } from "./types"; @@ -56,7 +56,7 @@ async function jumpToAdjacentNote( if (adjacentNoteMeta) { const file = app.vault.getAbstractFileByPath(adjacentNoteMeta.filePath); if (file && file instanceof TFile) { - const leaf = app.workspace.getUnpinnedLeaf(); + const leaf = app.workspace.getLeaf(Keymap.isModEvent(app.lastEvent)); await leaf.openFile(file, { active: true }); } } else { @@ -84,8 +84,10 @@ async function openAdjacentNote( .clone() .add(offset, activeFileMeta.granularity); - plugin.openPeriodicNote(activeFileMeta.granularity, adjacentDate); -} + plugin.openPeriodicNote(activeFileMeta.granularity, adjacentDate, { + leaftype: Keymap.isModEvent(this.app.lastEvent) + }) +}; export function getCommands( app: App, diff --git a/src/main.ts b/src/main.ts index 8ed8ad6..6309cb3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,6 @@ import type { Moment } from "moment"; -import { addIcon, Plugin, TFile } from "obsidian"; +import { addIcon, Plugin, TFile, Keymap } from "obsidian"; +import type { PaneType } from "obsidian"; import { writable, type Writable } from "svelte/store"; import { PeriodicNotesCache, type PeriodicNoteCachedMetadata } from "./cache"; @@ -46,7 +47,7 @@ import { } from "./utils"; interface IOpenOpts { - inNewSplit?: boolean; + leaftype?: boolean | PaneType; calendarSet?: string; } @@ -134,7 +135,7 @@ export default class PeriodicNotesPlugin extends Plugin { (e: MouseEvent) => { if (e.type !== "auxclick") { this.openPeriodicNote(granularity, window.moment(), { - inNewSplit: isMetaPressed(e), + leaftype: Keymap.isModEvent(e), }); } } @@ -271,7 +272,7 @@ export default class PeriodicNotesPlugin extends Plugin { date: Moment, opts?: IOpenOpts ): Promise { - const { inNewSplit = false, calendarSet } = opts ?? {}; + const { leaftype=false, calendarSet } = opts ?? {}; const { workspace } = this.app; let file = this.cache.getPeriodicNote( calendarSet ?? this.calendarSetManager.getActiveId(), @@ -282,7 +283,7 @@ export default class PeriodicNotesPlugin extends Plugin { file = await this.createPeriodicNote(granularity, date); } - const leaf = inNewSplit ? workspace.splitActiveLeaf() : workspace.getUnpinnedLeaf(); + const leaf = workspace.getLeaf(leaftype); await leaf.openFile(file, { active: true }); } } diff --git a/src/switcher/switcher.ts b/src/switcher/switcher.ts index 342113f..95f0059 100644 --- a/src/switcher/switcher.ts +++ b/src/switcher/switcher.ts @@ -1,5 +1,5 @@ import type { Moment } from "moment"; -import { type NLDatesPlugin, setIcon, App, SuggestModal } from "obsidian"; +import { type NLDatesPlugin, setIcon, App, SuggestModal, Keymap } from "obsidian"; import type { MatchType } from "src/cache"; import type PeriodicNotesPlugin from "src/main"; import { @@ -231,7 +231,7 @@ export class NLDNavigator extends SuggestModal { async onChooseSuggestion(item: DateNavigationItem, evt: MouseEvent | KeyboardEvent) { this.plugin.openPeriodicNote(item.granularity, item.date, { - inNewSplit: isMetaPressed(evt), + leaftype: Keymap.isModEvent(evt), }); } } diff --git a/yarn.lock b/yarn.lock index d399281..3a1eb82 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3242,7 +3242,7 @@ __metadata: eslint-plugin-import: ^2.26.0 lodash: 4.17.21 moment: 2.29.2 - obsidian: 0.14.4 + obsidian: 0.16.3 sass: ^1.50.0 standard-version: ^9.3.2 svelte: 3.47.0 @@ -3254,15 +3254,16 @@ __metadata: languageName: unknown linkType: soft -"obsidian@npm:0.14.4": - version: 0.14.4 - resolution: "obsidian@npm:0.14.4" +"obsidian@npm:0.16.3": + version: 0.16.3 + resolution: "obsidian@npm:0.16.3" dependencies: - "@codemirror/state": ^0.19.6 - "@codemirror/view": ^0.19.31 "@types/codemirror": 0.0.108 - moment: 2.29.1 - checksum: b0ee32972aacd2b26a4fd134abc01b437c3d193a3f6c4efeb9a4d262f2230cbf83d9633525d76240017460fba44983156afc8784489a379e3ca7863427a70d3f + moment: 2.29.4 + peerDependencies: + "@codemirror/state": ^6.0.0 + "@codemirror/view": ^6.0.0 + checksum: 48e82e011bc1904587cb681c4a98e27ab130f0d8130888141ebb9394ddf6b943453320be93882f97500061dba7695bf44305e069dee60cdb55bddcaf97dee996 languageName: node linkType: hard