missing path2d support for freedawings, remove node-side rendering, allow async getContent()

* ## Excalidraw and SVG
 * 2022-04-16 - @thfrei
 *
 * Known issues:
 *  - excalidraw-to-svg (node.js) does not render any hand drawn (freedraw) paths. There is an issue with
 *    Path2D object not present in node-canvas library used by jsdom. (See Trilium PR for samples and other issues
 *    in respective library. Link will be added later). Related links:
 *     - https://github.com/Automattic/node-canvas/pull/2013
 *     - https://github.com/google/canvas-5-polyfill
 *     - https://github.com/Automattic/node-canvas/issues/1116
 *     - https://www.npmjs.com/package/path2d-polyfill
 *  - excalidraw-to-svg (node.js) takes quite some time to load an image (1-2s)
 *  - excalidraw-utils (browser) does render freedraw, however NOT freedraw with background
 *
 * Due to this issues, we opt to use **only excalidraw in the frontend**. Upon saving, we will also get the SVG
 * output from the live excalidraw instance. We will save this **SVG side by side the native excalidraw format
 * in the trilium note**.
 *
 * Pro: we will combat bit-rot. Showing the SVG will be very fast, since it is already rendered.
 * Con: The note will get bigger (maybe +30%?), we will generate more bandwith.
 *      (However, using trilium desktop instance, does not care too much about bandwidth. Size increase is probably
 *       acceptable, as a trade off.)
This commit is contained in:
Tom
2022-04-19 00:21:20 +02:00
parent c295fdb142
commit 9771b441ad
10 changed files with 84 additions and 420 deletions

View File

@@ -25,7 +25,6 @@
},
"dependencies": {
"@excalidraw/excalidraw": "0.11.0",
"@excalidraw/utils": "0.1.2",
"archiver": "5.3.1",
"async-mutex": "0.3.2",
"axios": "0.26.1",
@@ -42,7 +41,6 @@
"electron-find": "1.0.7",
"electron-window-state": "5.0.3",
"@electron/remote": "2.0.8",
"excalidraw-to-svg": "3.0.0",
"express": "4.17.2",
"express-partial-content": "1.0.2",
"express-rate-limit": "6.3.0",