fix(canvas): proxying of fonts

This commit is contained in:
Elian Doran 2025-05-17 19:52:04 +03:00
parent 626e321f52
commit a4cfef7892
No known key found for this signature in database
6 changed files with 10 additions and 10 deletions

View File

@ -132,7 +132,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
// currently required by excalidraw, in order to allows self-hosting fonts locally.
// this avoids making excalidraw load the fonts from an external CDN.
(window as any).EXCALIDRAW_ASSET_PATH = `${window.location.origin}/${asset_path}/app-dist/excalidraw/`;
(window as any).EXCALIDRAW_ASSET_PATH = `${new URL(import.meta.url).origin}/node_modules/@excalidraw/excalidraw/dist/prod`;
// temporary vars
this.currentNoteId = "";

View File

@ -22,6 +22,15 @@ export default defineConfig(() => ({
src: `src/${asset}/**/*`,
dest: asset
}))
}),
viteStaticCopy({
structured: true,
targets: [
{
src: "node_modules/@excalidraw/excalidraw/dist/prod/fonts/*",
dest: "",
}
]
})
],
// Uncomment this if you are using workers.

View File

@ -10,7 +10,6 @@
},
"devDependencies": {
"@electron/remote": "2.1.2",
"@excalidraw/excalidraw": "0.18.0",
"@types/archiver": "6.0.3",
"@types/better-sqlite3": "7.6.13",
"@types/cls-hooked": "4.3.9",

View File

@ -38,7 +38,6 @@ async function register(app: express.Application) {
app.use(`/${assetPath}/translations/`, persistentCacheStatic(path.join(resourceDir, "public", "translations")));
app.use(`/${assetPath}/images`, persistentCacheStatic(path.join(resourceDir, "assets", "images")));
app.use(`/${assetPath}/app-dist/doc_notes`, persistentCacheStatic(path.join(resourceDir, "assets", "doc_notes")));
app.use(`/${assetPath}/app-dist/excalidraw/fonts`, persistentCacheStatic(path.join(resourceDir, "node_modules/@excalidraw/excalidraw/dist/prod/fonts")));
}
app.use(`/assets/vX/fonts`, express.static(path.join(srcRoot, "public/fonts")));
app.use(`/assets/vX/images`, express.static(path.join(srcRoot, "..", "images")));
@ -48,9 +47,6 @@ async function register(app: express.Application) {
const nodeModulesDir = isDev ? path.join(srcRoot, "..", "node_modules") : path.join(resourceDir, "node_modules");
app.use(`/node_modules/@excalidraw/excalidraw/dist/fonts/`, express.static(path.join(nodeModulesDir, "@excalidraw/excalidraw/dist/prod/fonts/")));
app.use(`/${assetPath}/node_modules/@excalidraw/excalidraw/dist/fonts/`, persistentCacheStatic(path.join(nodeModulesDir, "@excalidraw/excalidraw/dist/prod/fonts/")));
app.use(`/${assetPath}/node_modules/jquery/dist/`, persistentCacheStatic(path.join(nodeModulesDir, "jquery/dist/")));
app.use(`/${assetPath}/node_modules/jquery-hotkeys/`, persistentCacheStatic(path.join(nodeModulesDir, "jquery-hotkeys/")));

View File

@ -13,7 +13,6 @@ function buildFilesToCopy() {
});
const nodePaths = [
"@excalidraw/excalidraw/dist/prod/fonts/",
"jquery/dist",
"jquery-hotkeys",
"jquery.fancytree/dist",

3
pnpm-lock.yaml generated
View File

@ -500,9 +500,6 @@ importers:
'@electron/remote':
specifier: 2.1.2
version: 2.1.2(electron@36.2.1)
'@excalidraw/excalidraw':
specifier: 0.18.0
version: 0.18.0(@types/react-dom@19.1.5(@types/react@19.1.4))(@types/react@19.1.4)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
'@triliumnext/commons':
specifier: workspace:*
version: link:../../packages/commons