Skip to content

Commit

Permalink
disable active file check
Browse files Browse the repository at this point in the history
  • Loading branch information
Phantom1003 committed May 8, 2023
1 parent 3f5b5d7 commit c8aace9
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions src/pdfblock/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,8 @@ export class PDFBlockRenderer extends MarkdownRenderChild {
try {
const buffer = await this.cache.get(this.params.file);

if (!this.checkActiveFile(this.sourcePath))
return;

const document = await pdfjs.getDocument(buffer).promise;

if (!this.checkActiveFile(this.sourcePath))
return;

if (this.params.page.includes(0)) {
this.params.page = Array.from(
{length: document.numPages},
Expand All @@ -91,8 +85,6 @@ export class PDFBlockRenderer extends MarkdownRenderChild {
}

for (const pageNumber of this.params.page) {
if (!this.checkActiveFile(this.sourcePath))
return;

const page = await document.getPage(pageNumber);
let host = this.el.createEl("div");
Expand All @@ -107,9 +99,6 @@ export class PDFBlockRenderer extends MarkdownRenderChild {
const canvas = host.createEl("canvas");
canvas.style.width = `${Math.floor(this.params.scale * 100)}%`;

if (!this.checkActiveFile(this.sourcePath))
return;

const context = canvas.getContext("2d");
const zoom = this.params.dpi;
const offsetX = this.params.rect[0] == -1 ? 0 : - this.params.rect[0] * page.view[2] * zoom;
Expand All @@ -134,9 +123,6 @@ export class PDFBlockRenderer extends MarkdownRenderChild {
viewport: pageview,
};

if (!this.checkActiveFile(this.sourcePath))
return;

canvas.addEventListener("mouseup", (event)=> {
app.workspace.trigger("slidenote:mouseup", event);
});
Expand Down Expand Up @@ -177,15 +163,4 @@ export class PDFBlockRenderer extends MarkdownRenderChild {
}
}
}

checkActiveFile(ctx_file: string) {
const cur_file = app.workspace.getActiveFile()?.path;
if (cur_file == undefined)
return true;
else if (ctx_file != cur_file)
return false;
else
return true;
}

}

0 comments on commit c8aace9

Please sign in to comment.