fix(editor): ensure font picker font names are not quoted (#11036)
This commit is contained in:
@@ -46,6 +46,7 @@ import {
|
|||||||
import { fontPickerKeyHandler } from "./keyboardNavHandlers";
|
import { fontPickerKeyHandler } from "./keyboardNavHandlers";
|
||||||
|
|
||||||
import type { JSX } from "react";
|
import type { JSX } from "react";
|
||||||
|
import type { ExcalidrawFontFace } from "../../fonts/ExcalidrawFontFace";
|
||||||
|
|
||||||
export interface FontDescriptor {
|
export interface FontDescriptor {
|
||||||
value: number;
|
value: number;
|
||||||
@@ -86,6 +87,15 @@ const getFontFamilyIcon = (fontFamily: FontFamilyValues): JSX.Element => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getFontFamilyLabel = (
|
||||||
|
fontFamily: FontFamilyValues,
|
||||||
|
fontFaces: ExcalidrawFontFace[],
|
||||||
|
) =>
|
||||||
|
// prefer our config as the browser resolved names may be wrapped in quotes and such
|
||||||
|
Object.entries(FONT_FAMILY).find(([, id]) => id === fontFamily)?.[0] ??
|
||||||
|
fontFaces[0]?.fontFace?.family ??
|
||||||
|
"Unknown";
|
||||||
|
|
||||||
export const FontPickerList = React.memo(
|
export const FontPickerList = React.memo(
|
||||||
({
|
({
|
||||||
selectedFontFamily,
|
selectedFontFamily,
|
||||||
@@ -114,7 +124,7 @@ export const FontPickerList = React.memo(
|
|||||||
const fontDescriptor = {
|
const fontDescriptor = {
|
||||||
value: familyId,
|
value: familyId,
|
||||||
icon: getFontFamilyIcon(familyId),
|
icon: getFontFamilyIcon(familyId),
|
||||||
text: fontFaces[0]?.fontFace?.family ?? "Unknown",
|
text: getFontFamilyLabel(familyId, fontFaces),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (metadata.deprecated) {
|
if (metadata.deprecated) {
|
||||||
|
|||||||
Reference in New Issue
Block a user