Skip to content

Commit

Permalink
moved Drop handlers to DropManager, added await to page.getViewport a…
Browse files Browse the repository at this point in the history
…s there seems to be a race condition impacting page.render()
  • Loading branch information
zsviczian committed Dec 20, 2024
1 parent 682307b commit be383f2
Show file tree
Hide file tree
Showing 5 changed files with 649 additions and 577 deletions.
5 changes: 4 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { terser } from "rollup-plugin-terser";
import copy from "rollup-plugin-copy";
import typescript2 from "rollup-plugin-typescript2";
import fs from 'fs';
import path from 'path';
import LZString from 'lz-string';
import postprocess from '@zsviczian/rollup-plugin-postprocess';
import cssnano from 'cssnano';
Expand All @@ -16,6 +17,8 @@ import dotenv from 'dotenv';
dotenv.config();

const DIST_FOLDER = 'dist';
const absolutePath = path.resolve(DIST_FOLDER);
fs.mkdirSync(absolutePath, { recursive: true });
const isProd = (process.env.NODE_ENV === "production");
const isLib = (process.env.NODE_ENV === "lib");
console.log(`Running: ${process.env.NODE_ENV}; isProd: ${isProd}; isLib: ${isLib}`);
Expand Down Expand Up @@ -145,7 +148,7 @@ const BUILD_CONFIG = {
tsconfig: isProd ? "tsconfig.json" : "tsconfig.dev.json",
sourcemap: !isProd,
clean: true,
verbosity: isProd ? 1 : 2,
//verbosity: isProd ? 1 : 2,
},
...(isProd ? [
terser({
Expand Down
2 changes: 1 addition & 1 deletion src/shared/EmbeddedFileLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ export class EmbeddedFilesLoader {
// Get page
const page = await pdfDoc.getPage(num);
// Set scale
const viewport = page.getViewport({ scale });
const viewport = await page.getViewport({ scale });
height = canvas.height = viewport.height;
width = canvas.width = viewport.width;

Expand Down
13 changes: 1 addition & 12 deletions src/types/excalidrawViewTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,7 @@ import { WorkspaceLeaf } from "obsidian";
import { FileId } from "@zsviczian/excalidraw/types/excalidraw/element/types";
import { ObsidianCanvasNode } from "../view/managers/CanvasNodeFactory";

export interface DropData {
files?: File[];
text?: string;
html?: string;
uri?: string;
}

export interface DropContext {
event: DragEvent;
position: {x: number; y: number};
modifierAction: string;
}
export type Position = { x: number; y: number };

export interface SelectedElementWithLink {
id: string | null;
Expand Down
Loading

0 comments on commit be383f2

Please sign in to comment.