mirror of
https://github.com/dream-num/univer.git
synced 2026-09-24 15:32:18 +08:00
fix: fix font selector view value (#6453)
This commit is contained in:
@@ -45,15 +45,19 @@ export const FontFamily = ({ id, value, disabled$ }: IFontFamilyProps) => {
|
||||
|
||||
const viewValue = useMemo(() => {
|
||||
if (value == null) return '';
|
||||
let fontFamily = localeService.t(`fontFamily.${(`${value ?? ''}`).replace(/\s/g, '')}`);
|
||||
|
||||
// Handle font family from copy paste.
|
||||
if (fontFamily.startsWith('fontFamily.') && typeof value === 'string') {
|
||||
fontFamily = value.split(',')[0];
|
||||
const fixedValue = (`${value ?? ''}`).replace(/\s/g, '');
|
||||
|
||||
const font = fonts.find((font) => {
|
||||
return font.value === fixedValue;
|
||||
});
|
||||
|
||||
if (!font) {
|
||||
return fixedValue;
|
||||
}
|
||||
|
||||
return fontFamily;
|
||||
}, [value]);
|
||||
return localeService.t(font.label);
|
||||
}, [value, fonts]);
|
||||
|
||||
useMemo(() => {
|
||||
setInputValue(viewValue);
|
||||
|
||||
Reference in New Issue
Block a user