Skip to content

Commit

Permalink
Now markdown vies can dynamically adjust to preamble changes
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio committed Nov 25, 2023
1 parent c0534d5 commit 2018311
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export default class MathJaxPreamblePlugin extends Plugin {
const view = leaf.view as MarkdownView;
const state = view.getEphemeralState();
view.previewMode.rerender(true);
const editor = view.editor;
editor.setValue(editor.getValue());
view.setEphemeralState(state);
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export class PreambleManager extends Component {
}

onload() {
this.app.workspace.onLayoutReady(async () => this.deserialize(this.serialized));
this.app.workspace.onLayoutReady(async () => {
await this.deserialize(this.serialized);
this.plugin.rerender();
});
this.registerEvent(this.app.vault.on('modify', (file) => this.onModify(file)));
this.registerEvent(this.app.vault.on('rename', (file, oldPath) => this.onRename(file, oldPath)));
this.registerEvent(this.app.vault.on('delete', (file) => this.onDelete(file)));
Expand Down Expand Up @@ -83,6 +86,7 @@ export class PreambleManager extends Component {
if (path === file.path) {
const content = await this.app.vault.read(file);
this.preambles.set(id, { id, path, content: this.preprocess(content) });
this.plugin.rerender();
}
}
}
Expand Down

0 comments on commit 2018311

Please sign in to comment.