Skip to content

Commit

Permalink
feat: support live preview as view mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Jan 4, 2022
1 parent b5f6508 commit 786fcff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ Uses the current daily note. If it doesn't exists already, it will be created. F

## View mode
Every action opening or focusing a pane supports the parameter `viewmode`. Accepted values:
- `source`: Sets the editor to edit/source mode
- `source`: Sets the editor to reading:source mode
- `live`: Sets the editor to reading:live mode
- `preview`: Sets the editor to preview mode

I am not using a boolean value to better support upcoming WYSIWYG mode.

## Actions
`<identification>` needs to be replaced by an option listed [above](https://github.com/Vinzent03/obsidian-advanced-uri#types-of-file-identification).

Expand Down
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface Parameters {
uid?: string;
filename?: string;
exists?: string;
viewmode?: "source" | "preview";
viewmode?: "source" | "preview" | "live";
settingid?: string;
"x-success"?: string;
"x-error"?: string;
Expand Down Expand Up @@ -356,6 +356,8 @@ export default class AdvancedURI extends Plugin {
if (parameters.viewmode != undefined) {
let viewState = leaf.getViewState();
viewState.state.mode = parameters.viewmode;
if (viewState.state.source != undefined)
viewState.state.source = parameters.viewmode == "source";
await leaf.setViewState(viewState);
}
}
Expand Down

0 comments on commit 786fcff

Please sign in to comment.