diff --git a/packages/plugins/@nocobase/plugin-block-workbench/src/client/SchemaSettingsBlockTitleItem.tsx b/packages/plugins/@nocobase/plugin-block-workbench/src/client/SchemaSettingsBlockTitleItem.tsx new file mode 100644 index 0000000000..344c77f250 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-block-workbench/src/client/SchemaSettingsBlockTitleItem.tsx @@ -0,0 +1,56 @@ +/** + * This file is part of the NocoBase (R) project. + * Copyright (c) 2020-2024 NocoBase Co., Ltd. + * Authors: NocoBase Team. + * + * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. + * For more information, please refer to: https://www.nocobase.com/agreement. + */ + +import { ISchema, useField, useFieldSchema } from '@formily/react'; +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import { useDesignable, SchemaSettingsModalItem } from '@nocobase/client'; + +export function CustomSchemaSettingsBlockTitleItem() { + const field = useField(); + const fieldSchema = useFieldSchema(); + const { dn } = useDesignable(); + const { t } = useTranslation(); + + return ( + { + console.log('titleSchemaTest', fieldSchema, field); + + const componentProps = fieldSchema['x-decorator-props'] || {}; + componentProps.title = title; + fieldSchema['x-decorator-props'] = componentProps; + field.decoratorProps.title = title; + dn.emit('patch', { + schema: { + ['x-uid']: fieldSchema['x-uid'], + 'x-decorator-props': fieldSchema['x-decorator-props'], + }, + }); + dn.refresh(); + }} + /> + ); +} diff --git a/packages/plugins/@nocobase/plugin-block-workbench/src/client/blockSchema.ts b/packages/plugins/@nocobase/plugin-block-workbench/src/client/blockSchema.ts index 3dd401ce60..a5eb480dd3 100644 --- a/packages/plugins/@nocobase/plugin-block-workbench/src/client/blockSchema.ts +++ b/packages/plugins/@nocobase/plugin-block-workbench/src/client/blockSchema.ts @@ -12,6 +12,9 @@ import { ISchema } from '@nocobase/client'; export const blockSchema: ISchema = { type: 'void', 'x-decorator': 'CardItem', + 'x-decorator-props': { + title: '', + }, 'x-settings': 'blockSettings:workbench', 'x-schema-toolbar': 'BlockSchemaToolbar', 'x-component': 'WorkbenchBlock', diff --git a/packages/plugins/@nocobase/plugin-block-workbench/src/client/workbenchBlockSettings.tsx b/packages/plugins/@nocobase/plugin-block-workbench/src/client/workbenchBlockSettings.tsx index 0b8ef4851d..8811a1e343 100644 --- a/packages/plugins/@nocobase/plugin-block-workbench/src/client/workbenchBlockSettings.tsx +++ b/packages/plugins/@nocobase/plugin-block-workbench/src/client/workbenchBlockSettings.tsx @@ -8,6 +8,7 @@ */ import { SchemaSettings, SchemaSettingsSelectItem, useDesignable } from '@nocobase/client'; +import { CustomSchemaSettingsBlockTitleItem } from './SchemaSettingsBlockTitleItem'; import React from 'react'; import { useField, useFieldSchema } from '@formily/react'; import { useTranslation } from 'react-i18next'; @@ -50,6 +51,10 @@ const ActionPanelLayout = () => { export const workbenchBlockSettings = new SchemaSettings({ name: 'blockSettings:workbench', items: [ + { + name: 'title', + Component: CustomSchemaSettingsBlockTitleItem, + }, { name: 'layout', Component: ActionPanelLayout,