Skip to content

Commit

Permalink
feat: support heading and block for daily notes
Browse files Browse the repository at this point in the history
close #19
  • Loading branch information
Vinzent03 committed Aug 4, 2021
1 parent 8c7c99f commit fe78a27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ The `heading` parameter is for `mode=append` and `mode=prepend` supported too.
| / | parameters | explanation |
| --------- | -------------------------------- | -------------------------------------------------------------------------------------------------------- |
| open | daily=true | Opens the daily note. If the note does not already exists, it will be created |
| write | daily=true, data | Only writes `data` to today's daily note if the note does not already exists |
| write | daily=true, data | Only writes `data` to today's daily note if the note does not already exist |
| overwrite | daily=true, data, mode=overwrite | Writes `data` to today's daily note even if the file already exists |
| append | daily=true, data, mode=append | Only appends `data` to today's daily note. The file will be created, if the file does not already exist |
| prepend | daily=true, data, mode=prepend | Only prepends `data` to today's daily note. The file will be created, if the file does not already exist |

The `heading` parameter is for `mode=append` and `mode=prepend` supported too.
Like with [navigation](https://github.com/Vinzent03/obsidian-advanced-uri#navigation) and [writing](https://github.com/Vinzent03/obsidian-advanced-uri#writing) are `heading` and `block` supported too.

## Execute command

Expand Down
10 changes: 8 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,18 @@ export default class AdvancedURI extends Plugin {
} else if (parameters.data) {
dailyNote = await createDailyNote(moment);
this.writeAndOpenFile(dailyNote.path, parameters.data);

} else {
if (!dailyNote) {
dailyNote = await createDailyNote(moment);
}
await this.app.workspace.openLinkText(dailyNote.path, "", this.settings.openDailyInNewPane);
if (parameters.heading) {
this.app.workspace.openLinkText(dailyNote.path + "#" + parameters.heading, "", this.settings.openDailyInNewPane);

} else if (parameters.block) {
this.app.workspace.openLinkText(dailyNote.path + "#^" + parameters.block, "", this.settings.openDailyInNewPane);
} else {
await this.app.workspace.openLinkText(dailyNote.path, "", this.settings.openDailyInNewPane);
}
if (parameters.mode) {
await this.setCursor(parameters.mode);
}
Expand Down

0 comments on commit fe78a27

Please sign in to comment.