Skip to content

Commit

Permalink
fix: reduce dom for images
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Aug 13, 2023
1 parent 7c4e37d commit f0d6c36
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ class NamedWindow {
}
}

private getNoteElement() {
openFile: string;
async loadNote(file: TFile) {
this.openFile = file.path;
const content = await this.parent.app.vault.cachedRead(file);

const doc = createEl("html");
doc.append(this.head);

Expand All @@ -215,14 +219,6 @@ class NamedWindow {
.createDiv("markdown-reading-view")
.createDiv("markdown-preview-view")
.createDiv("markdown-preview-sizer markdown preview-section");
return { doc, note };
}

openFile: string;
async loadNote(file: TFile) {
this.openFile = file.path;
const content = await this.parent.app.vault.cachedRead(file);
const { doc, note } = this.getNoteElement();
await MarkdownRenderer.renderMarkdown(
content,
note,
Expand All @@ -247,8 +243,14 @@ class NamedWindow {
)}" style="height: 100%; width: 100%; object-fit: contain;"></div>`
);

const { doc, note } = this.getNoteElement();
note.appendChild(fragment);
const doc = createEl("html");
doc.append(this.head);

doc.createEl("body", { cls: this.mode })
.createDiv("app-container")
.createDiv("horizontal-main-container")
.createDiv("workspace")
.appendChild(fragment);

await this.parent.app.vault.adapter.write(
`${this.parent.app.plugins.getPluginFolder()}/image-window/file.html`,
Expand Down

0 comments on commit f0d6c36

Please sign in to comment.