diff --git a/packages/amis-theme-editor-helper/src/helper/declares.ts b/packages/amis-theme-editor-helper/src/helper/declares.ts index 39f0079c5c5..8a291de4122 100644 --- a/packages/amis-theme-editor-helper/src/helper/declares.ts +++ b/packages/amis-theme-editor-helper/src/helper/declares.ts @@ -18,6 +18,8 @@ export interface Font { label: string; token: string; value?: string | number; + className: string; + previewUrl?: string; body?: {value: string | number}[]; } @@ -98,7 +100,12 @@ export interface ThemeDefinition { base: { label: string; token: string; - body: {value: string}[]; + body: { + value: string; + label?: string; + className?: string; + previewUrl?: string; + }[]; }; size: { label: string; diff --git a/packages/amis-theme-editor-helper/src/helper/getGlobalData.ts b/packages/amis-theme-editor-helper/src/helper/getGlobalData.ts index f357bfa8a0f..3173c63f62f 100644 --- a/packages/amis-theme-editor-helper/src/helper/getGlobalData.ts +++ b/packages/amis-theme-editor-helper/src/helper/getGlobalData.ts @@ -112,6 +112,7 @@ export function getGlobalData(data: ThemeDefinition | undefined): GlobalData { if (key !== 'base') { fonts[key].body.forEach((font, i: number) => { children.push({ + ...font, label: `${font.label}(${font.value})`, value: `var(${font.token})`, realValue: `${font.value}` @@ -121,7 +122,8 @@ export function getGlobalData(data: ThemeDefinition | undefined): GlobalData { } else { fonts['base'].body.forEach((font, i: number) => { children.push({ - label: font.value, + ...font, + label: font.label || font.value, value: font.value, realValue: font.value }); diff --git a/packages/amis-theme-editor-helper/src/renderers/Font.tsx b/packages/amis-theme-editor-helper/src/renderers/Font.tsx index d59c0d0d692..126cc2e03aa 100644 --- a/packages/amis-theme-editor-helper/src/renderers/Font.tsx +++ b/packages/amis-theme-editor-helper/src/renderers/Font.tsx @@ -1092,6 +1092,26 @@ function FontEditor(props: FontEditorProps) { }} itemName="fontFamily" menuTpl="label" + menuLabelRender={(option: any) => { + return ( +