diff --git a/packages/amis-editor-core/src/component/Panel/AMisCodeEditor.tsx b/packages/amis-editor-core/src/component/Panel/AMisCodeEditor.tsx index c694e0e9b..761edb37c 100644 --- a/packages/amis-editor-core/src/component/Panel/AMisCodeEditor.tsx +++ b/packages/amis-editor-core/src/component/Panel/AMisCodeEditor.tsx @@ -9,6 +9,7 @@ import { import cx from 'classnames'; import {prompt, toast} from 'amis'; import debounce from 'lodash/debounce'; +import isArray from 'lodash/isArray'; import findIndex from 'lodash/findIndex'; import {parse, stringify} from 'json-ast-comments'; import isPlainObject from 'lodash/isPlainObject'; @@ -115,12 +116,17 @@ export default class AMisCodeEditor extends React.Component obj2str(value: any, props: AMisCodeEditorProps) { // 隐藏公共配置 value = filterSchemaForConfig(value); - value = { - type: value?.type, - ...value - }; - if (!value.type && props.$schema?.match(/PageSchema/i)) { + if (!isArray(value)) { + value = { + type: value?.type, + ...value + }; + } + + if (isArray(value)) { + return stringify(value); + } else if (!value.type && props.$schema?.match(/PageSchema/i)) { value.type = 'page'; } else if (!value.type) { delete value.type; @@ -153,7 +159,7 @@ export default class AMisCodeEditor extends React.Component const {onChange, value} = this.props; let ret: any = this.str2obj(this.state.contents); - if (!ret || !isPlainObject(ret)) { + if (!ret || (!isPlainObject(ret) && !isArray(ret))) { this.setState({ wrongSchema: this.state.contents }); diff --git a/packages/amis-editor-core/src/manager.ts b/packages/amis-editor-core/src/manager.ts index 384593653..37340f006 100644 --- a/packages/amis-editor-core/src/manager.ts +++ b/packages/amis-editor-core/src/manager.ts @@ -99,7 +99,8 @@ export function autoPreRegisterEditorCustomPlugins() { } /** - * 注册Editor插件。 + * 注册Editor插件 + * 备注: 支持覆盖原有组件,注册新的组件时需配置 priority。 * @param editor */ export function registerEditorPlugin(klass: PluginClass) { diff --git a/packages/amis-editor/src/plugin/Chart.tsx b/packages/amis-editor/src/plugin/Chart.tsx index bc83443e4..0d1d534f9 100644 --- a/packages/amis-editor/src/plugin/Chart.tsx +++ b/packages/amis-editor/src/plugin/Chart.tsx @@ -334,10 +334,7 @@ export class ChartPlugin extends BasePlugin { } ] }, - { - title: '状态', - body: [getSchemaTpl('ref'), getSchemaTpl('visible')] - } + getSchemaTpl('status') ]) ] }, diff --git a/packages/amis-editor/src/plugin/Sparkline.tsx b/packages/amis-editor/src/plugin/Sparkline.tsx index cd230b77c..94dc02ce1 100644 --- a/packages/amis-editor/src/plugin/Sparkline.tsx +++ b/packages/amis-editor/src/plugin/Sparkline.tsx @@ -3,7 +3,7 @@ */ import {registerEditorPlugin} from 'amis-editor-core'; -import {BasePlugin} from 'amis-editor-core'; +import {BasePlugin, BaseEventContext} from 'amis-editor-core'; import {defaultValue, getSchemaTpl} from 'amis-editor-core'; export class SparklinePlugin extends BasePlugin { @@ -30,14 +30,54 @@ export class SparklinePlugin extends BasePlugin { }; panelTitle = '走势图'; - panelBody = [ - getSchemaTpl('layout:originPosition', {value: 'left-top'}), - { - name: 'height', - type: 'input-number', - label: '高度' - } - ]; + + panelJustify = true; + panelBodyCreator = (context: BaseEventContext) => { + return [ + getSchemaTpl('tabs', [ + { + title: '属性', + body: [ + getSchemaTpl('collapseGroup', [ + { + title: '基本', + body: [ + getSchemaTpl('layout:originPosition', {value: 'left-top'}), + getSchemaTpl('name') + ] + }, + { + title: '宽高设置', + body: [ + { + name: 'width', + type: 'input-number', + label: '宽度' + }, + { + name: 'height', + type: 'input-number', + label: '高度' + } + ] + }, + getSchemaTpl('status') + ]) + ] + }, + { + title: '外观', + body: getSchemaTpl('collapseGroup', [ + ...getSchemaTpl('theme:common', {exclude: ['layout']}), + { + title: '自定义 CSS 类名', + body: [getSchemaTpl('className')] + } + ]) + } + ]) + ]; + }; } registerEditorPlugin(SparklinePlugin);