Skip to content

Commit

Permalink
Add a comment and move the global definition before loading excalidra…
Browse files Browse the repository at this point in the history
…w.production.min.js
  • Loading branch information
ggrossetie committed Oct 12, 2023
1 parent 5fe69e1 commit ec65329
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions excalidraw/src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ export default class Worker {
try {
await page.setViewport({ height: 800, width: 600 })
await page.goto(this.pageUrl)
await page.addScriptTag({
path: `${path.join(__dirname, '..', 'assets', 'excalidraw', 'excalidraw.production.min.js')}`
});
await page.addScriptTag({
content: `window.EXCALIDRAW_ASSET_PATH="${this.assetPath}"`
});
})
// excalidraw.production.min.js is using the EXCALIDRAW_ASSET_PATH variable.
await page.addScriptTag({
path: `${path.join(__dirname, '..', 'assets', 'excalidraw', 'excalidraw.production.min.js')}`
})
// QUESTION: should we reuse the page for performance reason ?
return await page.evaluate(async (definition) => {
const svgElement = await window.ExcalidrawLib.exportToSvg(JSON.parse(definition))
Expand Down

0 comments on commit ec65329

Please sign in to comment.