Skip to content

Commit

Permalink
0.17.6-3 2.3.5-beta-2, removed hostplugin prop, moved old fonts inlin…
Browse files Browse the repository at this point in the history
…e, CJK from web
  • Loading branch information
zsviczian committed Oct 20, 2024
1 parent c065d09 commit 584652e
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 15 deletions.
3 changes: 0 additions & 3 deletions packages/excalidraw/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ import {
getExcalidrawContentEl,
getMaxZoom,
hideFreedrawPenmodeCursor,
initializeObsidianUtils,
} from "../obsidianUtils";
import {
hitElementBoundText,
Expand Down Expand Up @@ -680,7 +679,6 @@ class App extends React.Component<AppProps, AppState> {
objectsSnapModeEnabled = false,
theme = defaultAppState.theme,
initState, //zsviczian
obsidianHostPlugin, //zsviczian
name = `${t("labels.untitled")}-${getDateTime()}`,
} = props;
this.state = {
Expand All @@ -699,7 +697,6 @@ class App extends React.Component<AppProps, AppState> {
};

this.id = nanoid();
initializeObsidianUtils(obsidianHostPlugin.deref()); //zsviczian
this.library = new Library(this);
this.actionManager = new ActionManager(
this.syncActionResult,
Expand Down
3 changes: 1 addition & 2 deletions packages/excalidraw/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
renderMermaid, //zsviczian
onContextMenu, //zsviczian
aiEnabled,
obsidianHostPlugin,
showDeprecatedFonts,
} = props;

Expand Down Expand Up @@ -161,7 +160,6 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
renderMermaid={renderMermaid} //zsviczian
onContextMenu={onContextMenu} //zsviczian
aiEnabled={aiEnabled !== false}
obsidianHostPlugin={obsidianHostPlugin} //zsviczian
showDeprecatedFonts={showDeprecatedFonts}
>
{children}
Expand Down Expand Up @@ -265,6 +263,7 @@ export {
getBoundTextMaxWidth, //zsviczian
mermaidToExcalidraw, //zsviczian
destroyObsidianUtils, //zsviczian
initializeObsidianUtils, //zsviczian
registerLocalFont, //zsviczian
getFontFamilies, //zsviczian
getFontFamilyString, //zsviczian
Expand Down
6 changes: 3 additions & 3 deletions packages/excalidraw/obsidianUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ export async function getCSSFontDefinition(
}

export async function loadSceneFonts(elements: NonDeletedExcalidrawElement[]): Promise<void> {
const fontFamilies = Fonts.getElementsFamilies(elements);
await Fonts.loadFontFaces(fontFamilies);
await Fonts.loadElementsFonts(elements);
}

export async function fetchFontFromVault(url: string | URL): Promise<ArrayBuffer|undefined> {
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;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/excalidraw/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
4 changes: 3 additions & 1 deletion packages/excalidraw/scene/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion packages/excalidraw/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,6 @@ export interface ExcalidrawProps {
onClose: (callback?: () => void) => void,
) => JSX.Element | null;
aiEnabled?: boolean;
obsidianHostPlugin: WeakRef<any>; //zsviczian
showDeprecatedFonts?: boolean;
}

Expand Down
7 changes: 5 additions & 2 deletions packages/excalidraw/webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
],
},
Expand Down
7 changes: 5 additions & 2 deletions packages/excalidraw/webpack.prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
],
},
Expand Down
1 change: 1 addition & 0 deletions packages/utils/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 584652e

Please sign in to comment.