diff --git a/packages/generator/src/fields/common/propertyConfig/layout.schema.ts b/packages/generator/src/fields/common/propertyConfig/layout.schema.ts index cec56cb3..fe1bf42f 100644 --- a/packages/generator/src/fields/common/propertyConfig/layout.schema.ts +++ b/packages/generator/src/fields/common/propertyConfig/layout.schema.ts @@ -28,6 +28,7 @@ const unitedSchema = { fieldKey: 'margin', type: 'string', title: '组件外边距', + transform: ['trim'], ui: { type: 'text', placeholder: '形如0 30px 20px 0 | 0 30px', @@ -37,6 +38,7 @@ const unitedSchema = { fieldKey: 'padding', type: 'string', title: '组件内边距', + transform: ['trim'], ui: { type: 'text', placeholder: '形如0 10px 0 10px | 0 10px', diff --git a/packages/generator/src/fields/container/root.field.ts b/packages/generator/src/fields/container/root.field.ts index 961b6fb9..c61d7672 100644 --- a/packages/generator/src/fields/container/root.field.ts +++ b/packages/generator/src/fields/container/root.field.ts @@ -229,6 +229,7 @@ const unitedSchema = [ fieldKey: 'margin', type: 'string', title: '标题外边距', + transform: ['trim'], ui: { type: 'text', disabled: false, @@ -290,6 +291,7 @@ const unitedSchema = [ fieldKey: 'margin', type: 'string', title: '组件外边距', + transform: ['trim'], ui: { type: 'text', placeholder: '形如0 30px 20px 0 | 0 30px', @@ -299,6 +301,7 @@ const unitedSchema = [ fieldKey: 'padding', type: 'string', title: '组件内边距', + transform: ['trim'], ui: { type: 'text', placeholder: '形如0 10px 0 10px | 0 10px', diff --git a/packages/utils/src/common/index.ts b/packages/utils/src/common/index.ts index 0279a769..29459713 100644 --- a/packages/utils/src/common/index.ts +++ b/packages/utils/src/common/index.ts @@ -3,7 +3,7 @@ import { CSSProperties } from 'react' * @Author: jiangxiaowei * @Date: 2020-05-30 15:05:13 * @Last Modified by: jiangxiaowei - * @Last Modified time: 2022-06-23 17:53:28 + * @Last Modified time: 2022-07-14 13:25:05 */ import type { TreeItems, TreeItem } from '../tree/types' import type { Map } from './type' @@ -408,7 +408,7 @@ export const handleMargin = (style: CSSProperties): void => { if (width) { if (margin) { if (typeof margin === 'string') { - const marginArr = margin.split(' ') + const marginArr = margin.trim().split(' ') if (marginArr.length === 1) { marginRight = margin marginLeft = margin