diff --git a/packages/excalidraw/components/App.tsx b/packages/excalidraw/components/App.tsx index 39ce56cafca4..529b2931cb94 100644 --- a/packages/excalidraw/components/App.tsx +++ b/packages/excalidraw/components/App.tsx @@ -436,7 +436,6 @@ import { getExcalidrawContentEl, getMaxZoom, hideFreedrawPenmodeCursor, - initializeObsidianUtils, } from "../obsidianUtils"; import { hitElementBoundText, @@ -680,7 +679,6 @@ class App extends React.Component { objectsSnapModeEnabled = false, theme = defaultAppState.theme, initState, //zsviczian - obsidianHostPlugin, //zsviczian name = `${t("labels.untitled")}-${getDateTime()}`, } = props; this.state = { @@ -699,7 +697,6 @@ class App extends React.Component { }; this.id = nanoid(); - initializeObsidianUtils(obsidianHostPlugin.deref()); //zsviczian this.library = new Library(this); this.actionManager = new ActionManager( this.syncActionResult, diff --git a/packages/excalidraw/index.tsx b/packages/excalidraw/index.tsx index d699a90bac41..77aa6f042fbd 100644 --- a/packages/excalidraw/index.tsx +++ b/packages/excalidraw/index.tsx @@ -61,7 +61,6 @@ const ExcalidrawBase = (props: ExcalidrawProps) => { renderMermaid, //zsviczian onContextMenu, //zsviczian aiEnabled, - obsidianHostPlugin, showDeprecatedFonts, } = props; @@ -161,7 +160,6 @@ const ExcalidrawBase = (props: ExcalidrawProps) => { renderMermaid={renderMermaid} //zsviczian onContextMenu={onContextMenu} //zsviczian aiEnabled={aiEnabled !== false} - obsidianHostPlugin={obsidianHostPlugin} //zsviczian showDeprecatedFonts={showDeprecatedFonts} > {children} @@ -265,6 +263,7 @@ export { getBoundTextMaxWidth, //zsviczian mermaidToExcalidraw, //zsviczian destroyObsidianUtils, //zsviczian + initializeObsidianUtils, //zsviczian registerLocalFont, //zsviczian getFontFamilies, //zsviczian getFontFamilyString, //zsviczian diff --git a/packages/excalidraw/obsidianUtils.ts b/packages/excalidraw/obsidianUtils.ts index eaa3153422a2..8800eb6792ec 100644 --- a/packages/excalidraw/obsidianUtils.ts +++ b/packages/excalidraw/obsidianUtils.ts @@ -133,14 +133,14 @@ export async function getCSSFontDefinition( } export async function loadSceneFonts(elements: NonDeletedExcalidrawElement[]): Promise { - const fontFamilies = Fonts.getElementsFamilies(elements); - await Fonts.loadFontFaces(fontFamilies); + await Fonts.loadElementsFonts(elements); } export async function fetchFontFromVault(url: string | URL): Promise { + url = typeof url === "string" ? url : url.toString(); if(typeof url === "string" && !url.startsWith("data") && url.endsWith(".woff2")) { const filename = decodeURIComponent(url.substring(url.lastIndexOf("/")+1)); - const arrayBuffer = hostPlugin.loadFontFromFile(filename) + const arrayBuffer = await hostPlugin.loadFontFromFile(filename) if(arrayBuffer) { return arrayBuffer; } diff --git a/packages/excalidraw/package.json b/packages/excalidraw/package.json index 58f77eb280a4..95fc99bfd0ef 100644 --- a/packages/excalidraw/package.json +++ b/packages/excalidraw/package.json @@ -1,6 +1,6 @@ { "name": "@zsviczian/excalidraw", - "version": "0.17.6-2", + "version": "0.17.6-3", "main": "main.js", "types": "types/excalidraw/index.d.ts", "files": [ diff --git a/packages/excalidraw/scene/export.ts b/packages/excalidraw/scene/export.ts index 65aefa1003cf..eec9219e0601 100644 --- a/packages/excalidraw/scene/export.ts +++ b/packages/excalidraw/scene/export.ts @@ -548,7 +548,9 @@ function* fontFacesIterator( return; } - const fontFaceOrder = familyIndex + fontFaceIndex; + const fontFaceOrder = Number( + familyIndex.toString() + fontFaceIndex.toString(), + ); const fontFaceTuple = [fontFaceOrder, fontFaceCSS] as const; return fontFaceTuple; diff --git a/packages/excalidraw/types.ts b/packages/excalidraw/types.ts index 51834207019a..6857cc015222 100644 --- a/packages/excalidraw/types.ts +++ b/packages/excalidraw/types.ts @@ -602,7 +602,6 @@ export interface ExcalidrawProps { onClose: (callback?: () => void) => void, ) => JSX.Element | null; aiEnabled?: boolean; - obsidianHostPlugin: WeakRef; //zsviczian showDeprecatedFonts?: boolean; } diff --git a/packages/excalidraw/webpack.dev.config.js b/packages/excalidraw/webpack.dev.config.js index 04c83793c2c9..2c1358c0221a 100644 --- a/packages/excalidraw/webpack.dev.config.js +++ b/packages/excalidraw/webpack.dev.config.js @@ -72,9 +72,12 @@ module.exports = { ], }, { - test: /\.(woff|woff2|eot|ttf|otf)$/, + test: /^(?!.*Xiaolai).*?\.(woff|woff2|eot|ttf|otf)$/, + type: "asset/inline", + }, + { + test: /(Xiaolai.*woff2)$/, type: "asset/resource", - //type: "asset/inline", //zsviczian }, ], }, diff --git a/packages/excalidraw/webpack.prod.config.js b/packages/excalidraw/webpack.prod.config.js index 70cd17b9a564..cbf209e0862d 100644 --- a/packages/excalidraw/webpack.prod.config.js +++ b/packages/excalidraw/webpack.prod.config.js @@ -86,9 +86,12 @@ module.exports = { ], }, { - test: /\.(woff|woff2|eot|ttf|otf)$/, + test: /^(?!.*Xiaolai).*?\.(woff|woff2|eot|ttf|otf)$/, + type: "asset/inline", + }, + { + test: /(Xiaolai.*woff2)$/, type: "asset/resource", - //type: "asset/inline", //zsviczian }, ], }, diff --git a/packages/utils/export.ts b/packages/utils/export.ts index 16bdaf47c420..669773ceef80 100644 --- a/packages/utils/export.ts +++ b/packages/utils/export.ts @@ -220,6 +220,7 @@ export { getBoundTextMaxWidth } from "../excalidraw/element/textElement"; //zsvi export { mermaidToExcalidraw } from "../excalidraw/components/TTDDialog/MermaidToExcalidraw"; //zsviczian export { destroyObsidianUtils, + initializeObsidianUtils, registerLocalFont, getFontFamilies, registerFontsInCSS,