From 077efebdf01e259fc1a0451aa39b2bf2d35ca954 Mon Sep 17 00:00:00 2001 From: jack zhang <1098626505@qq.com> Date: Wed, 8 May 2024 23:51:32 +0800 Subject: [PATCH] feat: support mobile iframe block and toolbar props (#4292) --- .../src/schema-settings/GeneralSchemaDesigner.tsx | 15 +++++++++++---- .../plugin-block-iframe/src/client/index.ts | 5 +++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/core/client/src/schema-settings/GeneralSchemaDesigner.tsx b/packages/core/client/src/schema-settings/GeneralSchemaDesigner.tsx index 4ad2cda48b..6e39251c4c 100644 --- a/packages/core/client/src/schema-settings/GeneralSchemaDesigner.tsx +++ b/packages/core/client/src/schema-settings/GeneralSchemaDesigner.tsx @@ -72,6 +72,7 @@ export interface GeneralSchemaDesignerProps { * @deprecated use `SchemaToolbar` instead */ export const GeneralSchemaDesigner: FC = (props: any) => { + const fieldSchema = useFieldSchema(); const { disableInitializer, title, @@ -80,11 +81,10 @@ export const GeneralSchemaDesigner: FC = (props: any contextValue, draggable = true, showDataSource = true, - } = props; + } = { ...props, ...(fieldSchema['x-toolbar-props'] || {}) } as GeneralSchemaDesignerProps; const { dn, designable } = useDesignable(); const field = useField(); const { t } = useTranslation(); - const fieldSchema = useFieldSchema(); const compile = useCompile(); const { getAriaLabel } = useGetAriaLabelOfDesigner(); const schemaSettingsProps = { @@ -191,9 +191,16 @@ export interface SchemaToolbarProps { } const InternalSchemaToolbar: FC = (props) => { - const { title, initializer, settings, showBackground, showBorder = true, draggable = true } = props; - const { designable } = useDesignable(); 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 { styles } = useStyles(); const { getAriaLabel } = useGetAriaLabelOfDesigner(); diff --git a/packages/plugins/@nocobase/plugin-block-iframe/src/client/index.ts b/packages/plugins/@nocobase/plugin-block-iframe/src/client/index.ts index d8063da592..547ff1079c 100644 --- a/packages/plugins/@nocobase/plugin-block-iframe/src/client/index.ts +++ b/packages/plugins/@nocobase/plugin-block-iframe/src/client/index.ts @@ -39,6 +39,11 @@ export class PluginBlockIframeClient extends Plugin { title: '{{t("Iframe")}}', Component: 'IframeBlockInitializer', }); + + this.app.schemaInitializerManager.addItem('mobilePage:addBlock', 'otherBlocks.iframe', { + title: '{{t("Iframe")}}', + Component: 'IframeBlockInitializer', + }); } }