diff --git a/docs/docs/api/configOptions.md b/docs/docs/api/configOptions.md index 67d2fae2c..88a25573c 100644 --- a/docs/docs/api/configOptions.md +++ b/docs/docs/api/configOptions.md @@ -115,7 +115,9 @@ config.set('enableCondition', false) ```typescript focusNodeSelector?: (rootNode: IPublicModelNode) => Node; ``` - +#### supportResetGlobally - 设置所有属性支持重置 +`@type {boolean}` `@default {false}` +设置所有属性支持重置, 开启后会给组件属性增加一个resetSetter,点击后会将组件的该属性重置为默认状态(defaultValue/initialValue)。如果没有设置默认值则回到该项属性不存在于props中的状态。不能重置成snippets中定义的低代码组件属性的值 #### supportVariableGlobally - 全局变量配置 `@type {boolean}` `@default {false}` diff --git a/docs/docs/demoUsage/panels/datasource.md b/docs/docs/demoUsage/panels/datasource.md index 7e9028e5e..9a73e1e2c 100644 --- a/docs/docs/demoUsage/panels/datasource.md +++ b/docs/docs/demoUsage/panels/datasource.md @@ -122,6 +122,7 @@ const preference = new Map(); enableCanvasLock: true, // 默认绑定变量 supportVariableGlobally: true, + supportResetGlobally: true, // simulatorUrl 在当 engine-core.js 同一个父路径下时是不需要配置的!!! // 这里因为用的是 alifd cdn,在不同 npm 包,engine-core.js 和 react-simulator-renderer.js 是不同路径 simulatorUrl: [ diff --git a/docs/docs/specs/material-spec.md b/docs/docs/specs/material-spec.md index c766c6834..7d4aeeecb 100644 --- a/docs/docs/specs/material-spec.md +++ b/docs/docs/specs/material-spec.md @@ -833,6 +833,7 @@ props 数组下对象字段描述: | name | 属性名 | String | type = 'field' 生效 | | defaultValue | 默认值 | Any(视字段类型而定) | type = 'field' 生效 | | supportVariable | 是否支持配置变量 | Boolean | type = 'field' 生效 | +| supportReset | 是否支持配置重置属性 | Boolean | type = 'field' 生效 | | condition | 配置当前 prop 是否展示 | (target: IPublicModelSettingField) => boolean; | - | | ignoreDefaultValue | 配置当前 prop 是否忽略默认值处理逻辑,如果返回值是 true 引擎不会处理默认值 | (target: IPublicModelSettingField) => boolean; | - | | setter | 单个控件 (setter) 描述,搭建基础协议组件的描述对象,支持 JSExpression / JSFunction / JSSlot | `String\|Object\|Function` | type = 'field' 生效 | diff --git a/packages/editor-core/src/config.ts b/packages/editor-core/src/config.ts index c4ff407b9..bf5871588 100644 --- a/packages/editor-core/src/config.ts +++ b/packages/editor-core/src/config.ts @@ -116,6 +116,11 @@ const VALID_ENGINE_OPTIONS = { default: false, description: '设置所有属性支持变量配置', }, + supportResetGlobally: { + type: 'boolean', + default: false, + description: '设置所有属性支持重置', + }, visionSettings: { type: 'object', description: 'Vision-polyfill settings', diff --git a/packages/editor-skeleton/src/components/field/fields.tsx b/packages/editor-skeleton/src/components/field/fields.tsx index 21ae93eb2..8be65da10 100644 --- a/packages/editor-skeleton/src/components/field/fields.tsx +++ b/packages/editor-skeleton/src/components/field/fields.tsx @@ -1,5 +1,5 @@ /* eslint-disable react/no-unused-prop-types */ -import { Component, ErrorInfo, MouseEvent } from 'react'; +import { Component, ErrorInfo, MouseEvent, ReactNode } from 'react'; import { isObject } from 'lodash'; import classNames from 'classnames'; import { Icon } from '@alifd/next'; @@ -25,6 +25,7 @@ export interface FieldProps { tip?: any; onExpandChange?: (expandState: boolean) => void; onClear?: () => void; + children: ReactNode; } export class Field extends Component { @@ -149,7 +150,8 @@ export class Field extends Component { return null; } - const { className, children, meta, title, valueState, name: propName, tip } = this.props; + const { className, children, meta, title, valueState, + name: propName, tip } = this.props; const { display, collapsed } = this.state; const isAccordion = display === 'accordion'; let hostName = ''; diff --git a/packages/editor-skeleton/src/components/settings/settings-pane.tsx b/packages/editor-skeleton/src/components/settings/settings-pane.tsx index 1d651bb5a..e823fb3ee 100644 --- a/packages/editor-skeleton/src/components/settings/settings-pane.tsx +++ b/packages/editor-skeleton/src/components/settings/settings-pane.tsx @@ -151,32 +151,46 @@ class SettingFieldView extends Component