Skip to content

Commit

Permalink
feat: supporting refresh preview after the file content is changed
Browse files Browse the repository at this point in the history
Signed-off-by: edonyzpc <edonyzpc@yahoo.com>
  • Loading branch information
edonyzpc committed Aug 4, 2023
1 parent 77b9d6e commit d71aee1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ export class RecordPreview extends ItemView {
container: this.containerEl,
}
});
this.app.vault.on("modify", (file) => {
this.plugin.log(`update preview record for file[${file.path}] changed`);
if (this.files.slice(0, limits).contains(file.path)) {
// refresh the view after file content changed
this.component.$destroy();
this.component = new RecordList({
target: this.contentEl,
props: {
app: this.app,
plugin: this.plugin,
fileNames: this.files.slice(0, limits),
container: this.containerEl,
}
});
}
});
}

async onClose() {
Expand Down

0 comments on commit d71aee1

Please sign in to comment.