Skip to content

Commit

Permalink
fix: support mode=new on
Browse files Browse the repository at this point in the history
close #71
  • Loading branch information
Vinzent03 committed Sep 26, 2022
1 parent e6b798d commit 14736c1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default class AdvancedURI extends Plugin {
new Notice("Daily notes plugin is not loaded");
return;
}
const moment = (window as any).moment(Date.now());
const moment = window.moment(Date.now());
const allDailyNotes = getAllDailyNotes();
let dailyNote = getDailyNote(moment, allDailyNotes);
if (!dailyNote) {
Expand Down Expand Up @@ -323,6 +323,12 @@ export default class AdvancedURI extends Plugin {
async handleCommand(parameters: Parameters) {
if (parameters.filepath) {
if (parameters.mode) {
if (parameters.mode == "new") {
const file = this.app.metadataCache.getFirstLinkpathDest(parameters.filepath, "/");
if (file instanceof TFile) {
parameters.filepath = this.getAlternativeFilePath(file);
}
}
await this.app.workspace.openLinkText(parameters.filepath, "/", undefined, {
state: { mode: "source" }
});
Expand Down

0 comments on commit 14736c1

Please sign in to comment.