mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
Merge pull request #7580 from wibetter/master
fix(amis-editor): sparkline走势图 属性配置面板升级
This commit is contained in:
commit
f1985e9513
@ -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<AMisCodeEditorProps>
|
||||
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<AMisCodeEditorProps>
|
||||
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
|
||||
});
|
||||
|
@ -99,7 +99,8 @@ export function autoPreRegisterEditorCustomPlugins() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册Editor插件。
|
||||
* 注册Editor插件
|
||||
* 备注: 支持覆盖原有组件,注册新的组件时需配置 priority。
|
||||
* @param editor
|
||||
*/
|
||||
export function registerEditorPlugin(klass: PluginClass) {
|
||||
|
@ -334,10 +334,7 @@ export class ChartPlugin extends BasePlugin {
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
|
||||
}
|
||||
getSchemaTpl('status')
|
||||
])
|
||||
]
|
||||
},
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user