feat: support mobile iframe block and toolbar props (#4292)

This commit is contained in:
jack zhang 2024-05-08 23:51:32 +08:00 committed by GitHub
parent 1604a4fdb6
commit 077efebdf0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 4 deletions

View File

@ -72,6 +72,7 @@ export interface GeneralSchemaDesignerProps {
* @deprecated use `SchemaToolbar` instead * @deprecated use `SchemaToolbar` instead
*/ */
export const GeneralSchemaDesigner: FC<GeneralSchemaDesignerProps> = (props: any) => { export const GeneralSchemaDesigner: FC<GeneralSchemaDesignerProps> = (props: any) => {
const fieldSchema = useFieldSchema();
const { const {
disableInitializer, disableInitializer,
title, title,
@ -80,11 +81,10 @@ export const GeneralSchemaDesigner: FC<GeneralSchemaDesignerProps> = (props: any
contextValue, contextValue,
draggable = true, draggable = true,
showDataSource = true, showDataSource = true,
} = props; } = { ...props, ...(fieldSchema['x-toolbar-props'] || {}) } as GeneralSchemaDesignerProps;
const { dn, designable } = useDesignable(); const { dn, designable } = useDesignable();
const field = useField(); const field = useField();
const { t } = useTranslation(); const { t } = useTranslation();
const fieldSchema = useFieldSchema();
const compile = useCompile(); const compile = useCompile();
const { getAriaLabel } = useGetAriaLabelOfDesigner(); const { getAriaLabel } = useGetAriaLabelOfDesigner();
const schemaSettingsProps = { const schemaSettingsProps = {
@ -191,9 +191,16 @@ export interface SchemaToolbarProps {
} }
const InternalSchemaToolbar: FC<SchemaToolbarProps> = (props) => { const InternalSchemaToolbar: FC<SchemaToolbarProps> = (props) => {
const { title, initializer, settings, showBackground, showBorder = true, draggable = true } = props;
const { designable } = useDesignable();
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
const {
title,
initializer,
settings,
showBackground,
showBorder = true,
draggable = true,
} = { ...props, ...(fieldSchema['x-toolbar-props'] || {}) } as SchemaToolbarProps;
const { designable } = useDesignable();
const compile = useCompile(); const compile = useCompile();
const { styles } = useStyles(); const { styles } = useStyles();
const { getAriaLabel } = useGetAriaLabelOfDesigner(); const { getAriaLabel } = useGetAriaLabelOfDesigner();

View File

@ -39,6 +39,11 @@ export class PluginBlockIframeClient extends Plugin {
title: '{{t("Iframe")}}', title: '{{t("Iframe")}}',
Component: 'IframeBlockInitializer', Component: 'IframeBlockInitializer',
}); });
this.app.schemaInitializerManager.addItem('mobilePage:addBlock', 'otherBlocks.iframe', {
title: '{{t("Iframe")}}',
Component: 'IframeBlockInitializer',
});
} }
} }