@myoc/excalidraw 0.20.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +253 -0
- package/dist/dev/{chunk-VBVJJWUO.js → chunk-A5GXRKT7.js} +24 -2
- package/dist/dev/chunk-A5GXRKT7.js.map +7 -0
- package/dist/dev/{chunk-6JJSWC4C.js → chunk-ETORD5CS.js} +41 -1
- package/dist/dev/{chunk-6JJSWC4C.js.map → chunk-ETORD5CS.js.map} +3 -3
- package/dist/dev/{chunk-EYSZ36MK.js → chunk-RCINQZKB.js} +2 -2
- package/dist/dev/{chunk-JBD373VY.js → chunk-TYPY4HGC.js} +374 -75
- package/dist/dev/chunk-TYPY4HGC.js.map +7 -0
- package/dist/dev/data/{image-KRZO2CVW.js → image-LHOOLEDU.js} +3 -3
- package/dist/dev/index.css +121 -0
- package/dist/dev/index.css.map +2 -2
- package/dist/dev/index.js +1911 -1513
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-V2WTRX5T.js → en-5NWRTZ4G.js} +4 -2
- package/dist/dev/subset-shared.chunk.js +4 -2
- package/dist/dev/subset-worker.chunk.js +2 -2
- package/dist/prod/{chunk-THEEFQ4B.js → chunk-4M4QNZNP.js} +1 -1
- package/dist/prod/{chunk-MZBVWY5X.js → chunk-FX6OEDRJ.js} +4 -4
- package/dist/prod/chunk-UXMXN2SG.js +4 -0
- package/dist/prod/{chunk-Z5NKEFVG.js → chunk-VDR2JODW.js} +10 -10
- package/dist/prod/data/image-XO3VLL25.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +16 -16
- package/dist/prod/locales/en-3B3DKM74.js +1 -0
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/common/src/constants.d.ts +7 -2
- package/dist/types/common/src/font-metadata.d.ts +4 -2
- package/dist/types/element/src/types.d.ts +2 -2
- package/dist/types/excalidraw/appState.d.ts +1 -1
- package/dist/types/excalidraw/charts/charts.constants.d.ts +1 -1
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +1 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +15 -4
- package/dist/types/excalidraw/components/FontPicker/FontWeightPicker.d.ts +34 -0
- package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +3 -2
- package/dist/types/excalidraw/fonts/ExcalidrawFontFace.d.ts +2 -1
- package/dist/types/excalidraw/fonts/Fonts.d.ts +15 -4
- package/dist/types/excalidraw/fonts/googleFonts.d.ts +40 -0
- package/dist/types/excalidraw/index.d.ts +2 -1
- package/dist/types/excalidraw/subset/subset-main.d.ts +1 -0
- package/dist/types/excalidraw/subset/subset-shared.chunk.d.ts +1 -0
- package/dist/types/excalidraw/subset/woff2/fontMetrics.d.ts +8 -0
- package/dist/types/excalidraw/types.d.ts +42 -0
- package/package.json +4 -4
- package/dist/dev/chunk-JBD373VY.js.map +0 -7
- package/dist/dev/chunk-VBVJJWUO.js.map +0 -7
- package/dist/prod/chunk-CQHKTNJ6.js +0 -4
- package/dist/prod/data/image-3WH4CMOG.js +0 -1
- package/dist/prod/locales/en-ALU5NMSJ.js +0 -1
- /package/dist/dev/{chunk-EYSZ36MK.js.map → chunk-RCINQZKB.js.map} +0 -0
- /package/dist/dev/data/{image-KRZO2CVW.js.map → image-LHOOLEDU.js.map} +0 -0
- /package/dist/dev/locales/{en-V2WTRX5T.js.map → en-5NWRTZ4G.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A,B,C,D,E,F,G,H,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-FX6OEDRJ.js";import"../chunk-SRAX5OIU.js";export{e as alerts,h as bucketfill,d as buttons,l as canvasError,t as clearCanvasDialog,A as colorPicker,y as colors,H as default,i as element,b as elementLink,v as encrypted,p as errorDialog,m as errorSplash,f as errors,r as exportDialog,E as fontList,D as fontWeight,j as headings,s as helpDialog,k as hints,u as imageExportDialog,G as keys,a as labels,B as overwriteConfirm,q as progressDialog,C as quickSearch,o as roomDialog,c as search,n as shareDialog,w as stats,x as toast,g as toolBar,F as userList,z as welcomeScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-VDR2JODW.js";import"./chunk-4M4QNZNP.js";import"./chunk-SRAX5OIU.js";export{a as Commands,d as getWoff2FontMetrics,b as subsetToBase64,c as subsetToBinary,e as toBase64};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r,c as t}from"./chunk-
|
|
1
|
+
import{a as r,c as t}from"./chunk-VDR2JODW.js";import"./chunk-4M4QNZNP.js";import"./chunk-SRAX5OIU.js";var s=import.meta.url?new URL(import.meta.url):void 0;typeof window>"u"&&typeof self<"u"&&(self.onmessage=async e=>{switch(e.data.command){case r.Subset:let a=await t(e.data.arrayBuffer,e.data.codePoints);self.postMessage(a,{transfer:[a]});break}});export{s as WorkerUrl};
|
|
@@ -114,6 +114,11 @@ export declare const FONT_FAMILY: {
|
|
|
114
114
|
"Liberation Sans": number;
|
|
115
115
|
Assistant: number;
|
|
116
116
|
};
|
|
117
|
+
export declare const GOOGLE_FONT_FAMILY_PREFIX = "google:";
|
|
118
|
+
export type GoogleFontFamily = `${typeof GOOGLE_FONT_FAMILY_PREFIX}${string}`;
|
|
119
|
+
export declare const isGoogleFontFamily: (fontFamily: unknown) => fontFamily is GoogleFontFamily;
|
|
120
|
+
export declare const toGoogleFontFamily: (family: string) => GoogleFontFamily;
|
|
121
|
+
export declare const getGoogleFontFamilyName: (fontFamily: GoogleFontFamily) => string;
|
|
117
122
|
export declare const SANS_SERIF_GENERIC_FONT = "sans-serif";
|
|
118
123
|
export declare const MONOSPACE_GENERIC_FONT = "monospace";
|
|
119
124
|
export declare const FONT_FAMILY_GENERIC_FALLBACKS: {
|
|
@@ -126,8 +131,8 @@ export declare const FONT_FAMILY_FALLBACKS: {
|
|
|
126
131
|
monospace: number;
|
|
127
132
|
Xiaolai: number;
|
|
128
133
|
};
|
|
129
|
-
export declare function getGenericFontFamilyFallback(fontFamily: number): keyof typeof FONT_FAMILY_GENERIC_FALLBACKS;
|
|
130
|
-
export declare const getFontFamilyFallbacks: (fontFamily: number) => Array<keyof typeof FONT_FAMILY_FALLBACKS>;
|
|
134
|
+
export declare function getGenericFontFamilyFallback(fontFamily: number | GoogleFontFamily): keyof typeof FONT_FAMILY_GENERIC_FALLBACKS;
|
|
135
|
+
export declare const getFontFamilyFallbacks: (fontFamily: number | GoogleFontFamily) => Array<keyof typeof FONT_FAMILY_FALLBACKS>;
|
|
131
136
|
export declare const THEME: {
|
|
132
137
|
readonly LIGHT: "light";
|
|
133
138
|
readonly DARK: "dark";
|
|
@@ -6,7 +6,7 @@ export interface FontMetadata {
|
|
|
6
6
|
/** for head & hhea metrics read the woff2 with https://fontdrop.info/ */
|
|
7
7
|
metrics: {
|
|
8
8
|
/** head.unitsPerEm metric */
|
|
9
|
-
unitsPerEm:
|
|
9
|
+
unitsPerEm: number;
|
|
10
10
|
/** hhea.ascender metric */
|
|
11
11
|
ascender: number;
|
|
12
12
|
/** hhea.descender metric */
|
|
@@ -25,7 +25,9 @@ export interface FontMetadata {
|
|
|
25
25
|
/** flag to indicate a fallback font */
|
|
26
26
|
fallback?: true;
|
|
27
27
|
}
|
|
28
|
-
export declare const FONT_METADATA: Record<number, FontMetadata>;
|
|
28
|
+
export declare const FONT_METADATA: Record<number | string, FontMetadata>;
|
|
29
|
+
export declare const registerFontMetadata: (fontFamily: FontFamilyValues, metadata: FontMetadata) => void;
|
|
30
|
+
export declare const unregisterFontMetadata: (fontFamily: FontFamilyValues) => void;
|
|
29
31
|
/** Unicode ranges defined by google fonts */
|
|
30
32
|
export declare const GOOGLE_FONTS_RANGES: {
|
|
31
33
|
LATIN: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { LocalPoint, Radians } from "@excalidraw/math";
|
|
2
|
-
import type { FONT_FAMILY, ROUNDNESS, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "@excalidraw/common";
|
|
2
|
+
import type { FONT_FAMILY, GoogleFontFamily, ROUNDNESS, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "@excalidraw/common";
|
|
3
3
|
import type { MakeBrand, MarkNonNullable, Merge, ValueOf } from "@excalidraw/common/utility-types";
|
|
4
4
|
export type ChartType = "bar" | "line" | "radar";
|
|
5
5
|
export type FillStyle = "hachure" | "cross-hatch" | "solid" | "zigzag";
|
|
6
6
|
export type FontFamilyKeys = keyof typeof FONT_FAMILY;
|
|
7
|
-
export type FontFamilyValues =
|
|
7
|
+
export type FontFamilyValues = number | GoogleFontFamily;
|
|
8
8
|
export type Theme = typeof THEME[keyof typeof THEME];
|
|
9
9
|
export type FontString = string & {
|
|
10
10
|
_brand: "fontString";
|
|
@@ -68,7 +68,7 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
|
|
|
68
68
|
currentItemRoughness?: number | undefined;
|
|
69
69
|
currentItemStrokeVariability?: import("@excalidraw/element/types").StrokeVariability | undefined;
|
|
70
70
|
currentItemOpacity?: number | undefined;
|
|
71
|
-
currentItemFontFamily?:
|
|
71
|
+
currentItemFontFamily?: import("@excalidraw/element/types").FontFamilyValues | undefined;
|
|
72
72
|
currentItemFontSize?: number | undefined;
|
|
73
73
|
currentItemTextAlign?: string | undefined;
|
|
74
74
|
currentItemStartArrowhead?: import("@excalidraw/element/types").Arrowhead | null | undefined;
|
|
@@ -28,7 +28,7 @@ export declare const RADAR_LEGEND_ITEM_GAP: number;
|
|
|
28
28
|
export declare const RADAR_LEGEND_TEXT_GAP = 12;
|
|
29
29
|
export declare const commonProps: {
|
|
30
30
|
readonly fillStyle: "hachure";
|
|
31
|
-
readonly fontFamily:
|
|
31
|
+
readonly fontFamily: import("@excalidraw/element/types").FontFamilyValues;
|
|
32
32
|
readonly fontSize: 20;
|
|
33
33
|
readonly opacity: 100;
|
|
34
34
|
readonly roughness: 1;
|
|
@@ -7,7 +7,7 @@ export declare const DEFAULT_FONTS: {
|
|
|
7
7
|
text: string;
|
|
8
8
|
testId: string;
|
|
9
9
|
}[];
|
|
10
|
-
export declare const isDefaultFont: (fontFamily:
|
|
10
|
+
export declare const isDefaultFont: (fontFamily: FontFamilyValues | null) => boolean;
|
|
11
11
|
interface FontPickerProps {
|
|
12
12
|
isOpened: boolean;
|
|
13
13
|
selectedFontFamily: FontFamilyValues | null;
|
|
@@ -2,9 +2,10 @@ import React from "react";
|
|
|
2
2
|
import { type FontFamilyValues } from "@excalidraw/element/types";
|
|
3
3
|
import type { ValueOf } from "@excalidraw/common/utility-types";
|
|
4
4
|
import { DropDownMenuItemBadgeType } from "../dropdownMenu/DropdownMenuItem";
|
|
5
|
+
import type { GoogleFontsConfig } from "../../types";
|
|
5
6
|
import type { JSX } from "react";
|
|
6
7
|
export interface FontDescriptor {
|
|
7
|
-
value:
|
|
8
|
+
value: FontFamilyValues;
|
|
8
9
|
icon: JSX.Element;
|
|
9
10
|
text: string;
|
|
10
11
|
deprecated?: true;
|
|
@@ -12,15 +13,25 @@ export interface FontDescriptor {
|
|
|
12
13
|
type: ValueOf<typeof DropDownMenuItemBadgeType>;
|
|
13
14
|
placeholder: string;
|
|
14
15
|
};
|
|
16
|
+
/** Shown but unselectable and skipped by keyboard navigation */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** Hover text, defaults to the label */
|
|
19
|
+
title?: string;
|
|
20
|
+
/** Google family and state of the row's Add to library button */
|
|
21
|
+
addToLibrary?: {
|
|
22
|
+
family: string;
|
|
23
|
+
state: "available" | "locked";
|
|
24
|
+
};
|
|
15
25
|
}
|
|
16
26
|
interface FontPickerListProps {
|
|
27
|
+
googleFonts?: GoogleFontsConfig;
|
|
17
28
|
selectedFontFamily: FontFamilyValues | null;
|
|
18
29
|
hoveredFontFamily: FontFamilyValues | null;
|
|
19
|
-
onSelect: (value:
|
|
20
|
-
onHover: (value:
|
|
30
|
+
onSelect: (value: FontFamilyValues) => void;
|
|
31
|
+
onHover: (value: FontFamilyValues) => void;
|
|
21
32
|
onLeave: () => void;
|
|
22
33
|
onOpen: () => void;
|
|
23
34
|
onClose: () => void;
|
|
24
35
|
}
|
|
25
|
-
export declare const FontPickerList: React.MemoExoticComponent<({ selectedFontFamily, hoveredFontFamily, onSelect, onHover, onLeave, onOpen, onClose, }: FontPickerListProps) => import("react/jsx-runtime").JSX.Element>;
|
|
36
|
+
export declare const FontPickerList: React.MemoExoticComponent<({ googleFonts, selectedFontFamily, hoveredFontFamily, onSelect, onHover, onLeave, onOpen, onClose, }: FontPickerListProps) => import("react/jsx-runtime").JSX.Element>;
|
|
26
37
|
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FontFamilyValues } from "@excalidraw/element/types";
|
|
2
|
+
import type { GoogleFontsConfig } from "../../types";
|
|
3
|
+
/** 400 if present, else the lowest weight. */
|
|
4
|
+
export declare const pickDefaultWeight: (weights: readonly number[]) => number;
|
|
5
|
+
/**
|
|
6
|
+
* Switching family keeps the current weight if the picked family has it
|
|
7
|
+
* added, otherwise the picked (default) weight stays; scene entries are
|
|
8
|
+
* applied as listed.
|
|
9
|
+
*/
|
|
10
|
+
export declare const mapPickedFontFamily: (picked: FontFamilyValues, current: FontFamilyValues | null, libraryFonts: GoogleFontsConfig["libraryFonts"] | undefined, sceneFamilies: readonly FontFamilyValues[]) => FontFamilyValues;
|
|
11
|
+
/**
|
|
12
|
+
* The weight row of the selected Google family. Plans that can't apply Google
|
|
13
|
+
* fonts (or disabled library entries) get no row (`weights` is `undefined`).
|
|
14
|
+
*/
|
|
15
|
+
export declare const getGoogleFontWeightRow: (selection: {
|
|
16
|
+
fontFamily: FontFamilyValues | null;
|
|
17
|
+
googleFamily: string | null;
|
|
18
|
+
}, googleFonts: GoogleFontsConfig | undefined) => {
|
|
19
|
+
family: string | null;
|
|
20
|
+
weights: readonly number[] | undefined;
|
|
21
|
+
selectedWeight: number | null;
|
|
22
|
+
};
|
|
23
|
+
interface FontWeightPickerProps {
|
|
24
|
+
family: string;
|
|
25
|
+
/** weights added to the library for the family */
|
|
26
|
+
weights: readonly number[];
|
|
27
|
+
/** `null` when the selection has mixed weights */
|
|
28
|
+
selectedWeight: number | null;
|
|
29
|
+
onSelect: (weight: number) => void;
|
|
30
|
+
onEditWeights?: (family: string) => void;
|
|
31
|
+
compactMode?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare const FontWeightPicker: ({ family, weights, selectedWeight, onSelect, onEditWeights, compactMode, }: FontWeightPickerProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
34
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Node } from "@excalidraw/common";
|
|
2
|
+
import type { FontFamilyValues } from "@excalidraw/element/types";
|
|
2
3
|
import { type FontDescriptor } from "./FontPickerList";
|
|
3
4
|
interface FontPickerKeyNavHandlerProps {
|
|
4
5
|
event: React.KeyboardEvent<HTMLDivElement>;
|
|
@@ -6,8 +7,8 @@ interface FontPickerKeyNavHandlerProps {
|
|
|
6
7
|
hoveredFont: Node<FontDescriptor> | undefined;
|
|
7
8
|
filteredFonts: Node<FontDescriptor>[];
|
|
8
9
|
onClose: () => void;
|
|
9
|
-
onSelect: (value:
|
|
10
|
-
onHover: (value:
|
|
10
|
+
onSelect: (value: FontFamilyValues) => void;
|
|
11
|
+
onHover: (value: FontFamilyValues) => void;
|
|
11
12
|
}
|
|
12
13
|
export declare const fontPickerKeyHandler: ({ event, inputRef, hoveredFont, filteredFonts, onClose, onSelect, onHover, }: FontPickerKeyNavHandlerProps) => true | undefined;
|
|
13
14
|
export {};
|
|
@@ -2,8 +2,9 @@ type DataURL = string;
|
|
|
2
2
|
export declare class ExcalidrawFontFace {
|
|
3
3
|
readonly urls: URL[] | DataURL[];
|
|
4
4
|
readonly fontFace: FontFace;
|
|
5
|
+
private readonly mustEmbed;
|
|
5
6
|
private static readonly ASSETS_FALLBACK_URL;
|
|
6
|
-
constructor(family: string, uri: string, descriptors?: FontFaceDescriptors);
|
|
7
|
+
constructor(family: string, uri: string, descriptors?: FontFaceDescriptors, mustEmbed?: boolean);
|
|
7
8
|
/**
|
|
8
9
|
* Generates CSS `@font-face` definition with the (subsetted) font source as a data url for the characters within the unicode range.
|
|
9
10
|
*
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { type FontMetadata } from "@excalidraw/common";
|
|
2
|
-
import type { ExcalidrawElement } from "@excalidraw/element/types";
|
|
2
|
+
import type { ExcalidrawElement, FontFamilyValues } from "@excalidraw/element/types";
|
|
3
3
|
import type { Scene } from "@excalidraw/element";
|
|
4
4
|
import { ExcalidrawFontFace } from "./ExcalidrawFontFace";
|
|
5
5
|
export declare class Fonts {
|
|
6
6
|
static readonly loadedFontsCache: Set<string>;
|
|
7
|
+
private static readonly googleFontPromises;
|
|
8
|
+
private static readonly googleFontMetrics;
|
|
9
|
+
/** CSS source each registered Google font was loaded from. */
|
|
10
|
+
private static readonly googleFontSources;
|
|
7
11
|
private static _registered;
|
|
8
12
|
private static _initialized;
|
|
9
|
-
static get registered(): Map<
|
|
13
|
+
static get registered(): Map<FontFamilyValues, {
|
|
10
14
|
metadata: FontMetadata;
|
|
11
15
|
fontFaces: ExcalidrawFontFace[];
|
|
12
16
|
}>;
|
|
13
|
-
get registered(): Map<
|
|
17
|
+
get registered(): Map<FontFamilyValues, {
|
|
14
18
|
metadata: FontMetadata;
|
|
15
19
|
fontFaces: ExcalidrawFontFace[];
|
|
16
20
|
}>;
|
|
@@ -19,7 +23,7 @@ export declare class Fonts {
|
|
|
19
23
|
/**
|
|
20
24
|
* Get all the font families for the given scene.
|
|
21
25
|
*/
|
|
22
|
-
getSceneFamilies: () =>
|
|
26
|
+
getSceneFamilies: () => FontFamilyValues[];
|
|
23
27
|
/**
|
|
24
28
|
* if we load a (new) font, it's likely that text elements using it have
|
|
25
29
|
* already been rendered using a fallback font. Thus, we want invalidate
|
|
@@ -33,6 +37,8 @@ export declare class Fonts {
|
|
|
33
37
|
* Load font faces for a given scene and trigger scene update.
|
|
34
38
|
*/
|
|
35
39
|
loadSceneFonts: () => Promise<FontFace[]>;
|
|
40
|
+
/** Load a family for picker previews and invalidate text rendered with a fallback. */
|
|
41
|
+
loadFontFamily: (fontFamily: FontFamilyValues, characters: string) => Promise<FontFace[]>;
|
|
36
42
|
/**
|
|
37
43
|
* Load font faces for passed elements - use when the scene is unavailable (i.e. export).
|
|
38
44
|
*/
|
|
@@ -43,6 +49,7 @@ export declare class Fonts {
|
|
|
43
49
|
static generateFontFaceDeclarations(elements: readonly ExcalidrawElement[]): Promise<string[]>;
|
|
44
50
|
private static loadFontFaces;
|
|
45
51
|
private static fontFacesLoader;
|
|
52
|
+
private static loadFontFacesForFamily;
|
|
46
53
|
private static fontFacesStylesGenerator;
|
|
47
54
|
/**
|
|
48
55
|
* Register a new font.
|
|
@@ -68,6 +75,9 @@ export declare class Fonts {
|
|
|
68
75
|
* Get characters for a given family.
|
|
69
76
|
*/
|
|
70
77
|
private static getCharacters;
|
|
78
|
+
private static registerGoogleFont;
|
|
79
|
+
private static resetGoogleFont;
|
|
80
|
+
private static loadGoogleFontMetrics;
|
|
71
81
|
/**
|
|
72
82
|
* Get all registered font families.
|
|
73
83
|
*/
|
|
@@ -76,4 +86,5 @@ export declare class Fonts {
|
|
|
76
86
|
export interface ExcalidrawFontFaceDescriptor {
|
|
77
87
|
uri: string;
|
|
78
88
|
descriptors?: FontFaceDescriptors;
|
|
89
|
+
mustEmbed?: boolean;
|
|
79
90
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { GoogleFontFamily } from "@excalidraw/common";
|
|
2
|
+
import { ExcalidrawFontFace } from "./ExcalidrawFontFace";
|
|
3
|
+
import type { ExcalidrawFontFaceDescriptor } from "./Fonts";
|
|
4
|
+
export declare const DEFAULT_GOOGLE_FONT_WEIGHT = 400;
|
|
5
|
+
/**
|
|
6
|
+
* Font id format: `google:<Family>@<weight>`; no suffix means 400.
|
|
7
|
+
* Returns `null` if the id is not a Google font id.
|
|
8
|
+
*/
|
|
9
|
+
export declare const parseGoogleFontId: (fontId: unknown) => {
|
|
10
|
+
family: string;
|
|
11
|
+
weight: number;
|
|
12
|
+
} | null;
|
|
13
|
+
export declare const formatGoogleFontId: (family: string, weight?: number) => GoogleFontFamily;
|
|
14
|
+
type GoogleFontCssSources = (family: string) => readonly string[];
|
|
15
|
+
/**
|
|
16
|
+
* Host-provided CSS2 base URLs per family, tried in order. The `family` and
|
|
17
|
+
* `display` params are set by the fork. `undefined` restores the default.
|
|
18
|
+
*/
|
|
19
|
+
export declare const setGoogleFontCssSources: (sources: GoogleFontCssSources | undefined) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Marks a source as failed for the session.
|
|
22
|
+
* Returns `true` if the family has another source left to try.
|
|
23
|
+
*/
|
|
24
|
+
export declare const markGoogleFontSourceFailed: (family: string, source: string) => boolean;
|
|
25
|
+
export declare const resetGoogleFontSourceFailures: () => void;
|
|
26
|
+
export declare const getGoogleFontCssUrl: (family: string, weight?: number, source?: string) => URL;
|
|
27
|
+
/**
|
|
28
|
+
* `base` is the CSS URL; relative srcs (e.g. from a relay) resolve against it.
|
|
29
|
+
*/
|
|
30
|
+
export declare const parseGoogleFontFaceCss: (css: string, base?: string | URL) => ExcalidrawFontFaceDescriptor[];
|
|
31
|
+
/**
|
|
32
|
+
* Loads the faces of a Google font id, trying the CSS sources in order.
|
|
33
|
+
* A source that fails with a network error, 5xx or 429 is skipped for the
|
|
34
|
+
* rest of the session; other errors only make this family try the next source.
|
|
35
|
+
*/
|
|
36
|
+
export declare const loadGoogleFontFaces: (fontId: GoogleFontFamily) => Promise<{
|
|
37
|
+
fontFaces: ExcalidrawFontFace[];
|
|
38
|
+
source: string;
|
|
39
|
+
}>;
|
|
40
|
+
export {};
|
|
@@ -54,9 +54,10 @@ export { elementsOverlappingBBox } from "@excalidraw/element";
|
|
|
54
54
|
export { getDataURL } from "./data/blob";
|
|
55
55
|
export { isElementLink } from "@excalidraw/element";
|
|
56
56
|
export { Fonts } from "./fonts/Fonts";
|
|
57
|
+
export { formatGoogleFontId, parseGoogleFontFaceCss, parseGoogleFontId, } from "./fonts/googleFonts";
|
|
57
58
|
export { setCustomTextMetricsProvider } from "@excalidraw/element";
|
|
58
59
|
export type { EditorInterface } from "@excalidraw/common";
|
|
59
|
-
export type { AlignPreferences, ArrangePreferences, CompressImageFile, CompressImageFileOpts, ExcalidrawCommandCatalogEntry, EditorPreferences, ImageContextMenuItem, ImageDownloadErrorStatus, ImageUploadProgressStatus, ImageStatus, ImageStatusStyle, NormalisePreferences, SmartZoomPreferences, ViewpointFlip, ExcalidrawImperativeAPI, UIAppState, ExcalidrawUICustomItem, ExcalidrawUIFormFactorLayout, ExcalidrawUIItem, ExcalidrawUIItemLayout, ExcalidrawUIOrientation, ExcalidrawUIRegion, ExcalidrawUILayout, } from "./types";
|
|
60
|
+
export type { AlignPreferences, ArrangePreferences, CompressImageFile, CompressImageFileOpts, ExcalidrawCommandCatalogEntry, GoogleFontsConfig, EditorPreferences, ImageContextMenuItem, ImageDownloadErrorStatus, ImageUploadProgressStatus, ImageStatus, ImageStatusStyle, NormalisePreferences, SmartZoomPreferences, ViewpointFlip, ExcalidrawImperativeAPI, UIAppState, ExcalidrawUICustomItem, ExcalidrawUIFormFactorLayout, ExcalidrawUIItem, ExcalidrawUIItemLayout, ExcalidrawUIOrientation, ExcalidrawUIRegion, ExcalidrawUILayout, } from "./types";
|
|
60
61
|
export type { DragImageMetadata, ParsedDataTranferList, ParsedDataTransferFile, DragDataSnapshot, RawDragData, } from "./clipboard";
|
|
61
62
|
export { renderSpreadsheet, tryParseSpreadsheet, isSpreadsheetValidForChartType, } from "./charts";
|
|
62
63
|
/**
|
|
@@ -10,3 +10,4 @@
|
|
|
10
10
|
* @returns font with subsetted glyphs (all glyphs in case of errors) converted into a dataurl
|
|
11
11
|
*/
|
|
12
12
|
export declare const subsetWoff2GlyphsByCodepoints: (arrayBuffer: ArrayBuffer, codePoints: Array<number>) => Promise<string>;
|
|
13
|
+
export declare const getWoff2FontMetrics: (arrayBuffer: ArrayBuffer) => Promise<import("./woff2/fontMetrics").Woff2FontMetrics>;
|
|
@@ -24,6 +24,7 @@ export declare const subsetToBase64: (arrayBuffer: ArrayBuffer, codePoints: Arra
|
|
|
24
24
|
* @eturns woff2 font as an ArrayBuffer, to avoid copying large strings between worker threads and the main thread.
|
|
25
25
|
*/
|
|
26
26
|
export declare const subsetToBinary: (arrayBuffer: ArrayBuffer, codePoints: Array<number>) => Promise<ArrayBuffer>;
|
|
27
|
+
export declare const getWoff2FontMetrics: (arrayBuffer: ArrayBuffer) => Promise<import("./woff2/fontMetrics").Woff2FontMetrics>;
|
|
27
28
|
/**
|
|
28
29
|
* Util for isomoprhic browser (main thread), node and jsdom usage.
|
|
29
30
|
*
|
|
@@ -903,6 +903,14 @@ export interface ExcalidrawProps {
|
|
|
903
903
|
children?: React.ReactNode;
|
|
904
904
|
validateEmbeddable?: boolean | string[] | RegExp | RegExp[] | ((link: string) => boolean | undefined);
|
|
905
905
|
renderEmbeddable?: (element: NonDeleted<ExcalidrawEmbeddableElement>, appState: AppState) => JSX.Element | null;
|
|
906
|
+
/**
|
|
907
|
+
* Host-controlled Google Fonts picker access. Scene fonts load independently
|
|
908
|
+
* of this capability so viewers and non-premium editors can render or reuse
|
|
909
|
+
* families already present in the scene. Google Fonts requires
|
|
910
|
+
* `fonts.googleapis.com` in `connect-src` and `fonts.gstatic.com` in
|
|
911
|
+
* `font-src` in the host's Content Security Policy.
|
|
912
|
+
*/
|
|
913
|
+
googleFonts?: GoogleFontsConfig;
|
|
906
914
|
showDeprecatedFonts?: boolean;
|
|
907
915
|
wheelZoomsOnDefault?: boolean;
|
|
908
916
|
strokeColorTopPicks?: ColorTuple;
|
|
@@ -947,6 +955,40 @@ export interface ExcalidrawProps {
|
|
|
947
955
|
signal: AbortSignal;
|
|
948
956
|
}) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
|
|
949
957
|
}
|
|
958
|
+
export interface GoogleFontsConfig {
|
|
959
|
+
/** The user's font library, rendered in host order (never sorted). */
|
|
960
|
+
libraryFonts: readonly {
|
|
961
|
+
family: string;
|
|
962
|
+
weights: readonly number[];
|
|
963
|
+
enabled: boolean;
|
|
964
|
+
}[];
|
|
965
|
+
/**
|
|
966
|
+
* Whether the user's plan can apply Google fonts. When `false`, scene Google
|
|
967
|
+
* fonts are shown but unselectable. A library font's own `enabled` flag only
|
|
968
|
+
* governs its "My fonts" row (the host decides).
|
|
969
|
+
*/
|
|
970
|
+
canApplyGoogleFonts: boolean;
|
|
971
|
+
/** Lets the host edit a family's weights (e.g. a "More weights…" link). */
|
|
972
|
+
onEditWeights?: (family: string) => void;
|
|
973
|
+
/**
|
|
974
|
+
* Whether a scene Google family missing from the library can be added:
|
|
975
|
+
* `locked` shows a lock and still calls `onAddToLibrary` so the host can
|
|
976
|
+
* show its upgrade prompt, `unavailable` hides the button.
|
|
977
|
+
*/
|
|
978
|
+
addToLibrary: "available" | "locked" | "unavailable";
|
|
979
|
+
onAddToLibrary?: (family: string) => void;
|
|
980
|
+
/** Opens the host's font browser. */
|
|
981
|
+
onBrowse?: () => void;
|
|
982
|
+
/** Optional host-rendered action shown below the font list. */
|
|
983
|
+
upgradeAction?: React.ReactNode;
|
|
984
|
+
/**
|
|
985
|
+
* CSS2 base URLs (without query) to load a family's `@font-face` rules from,
|
|
986
|
+
* tried in order; a failing source is skipped for the rest of the session.
|
|
987
|
+
* The fork sets the `family` (`<Family>:wght@<weight>`) and `display`
|
|
988
|
+
* params. Defaults to `https://fonts.googleapis.com/css2`.
|
|
989
|
+
*/
|
|
990
|
+
fontCssUrls?: (family: string) => readonly string[];
|
|
991
|
+
}
|
|
950
992
|
export type SceneData = {
|
|
951
993
|
elements?: ImportedDataState["elements"];
|
|
952
994
|
appState?: ImportedDataState["appState"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myoc/excalidraw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/types/excalidraw/index.d.ts",
|
|
6
6
|
"main": "./dist/prod/index.js",
|
|
@@ -82,10 +82,10 @@
|
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@braintree/sanitize-url": "6.0.2",
|
|
85
|
-
"@excalidraw/common": "npm:@myoc/common@0.
|
|
86
|
-
"@excalidraw/element": "npm:@myoc/element@0.
|
|
85
|
+
"@excalidraw/common": "npm:@myoc/common@0.21.0",
|
|
86
|
+
"@excalidraw/element": "npm:@myoc/element@0.21.0",
|
|
87
87
|
"@excalidraw/laser-pointer": "1.3.1",
|
|
88
|
-
"@excalidraw/math": "npm:@myoc/math@0.
|
|
88
|
+
"@excalidraw/math": "npm:@myoc/math@0.21.0",
|
|
89
89
|
"@excalidraw/random-username": "1.1.0",
|
|
90
90
|
"@lezer/highlight": "^1.0.0",
|
|
91
91
|
"browser-fs-access": "0.38.0",
|