Skip to content

Commit 2fe4412

Browse files
committed
update text and object children compose style
1 parent 6900349 commit 2fe4412

File tree

6 files changed

+21
-6
lines changed

6 files changed

+21
-6
lines changed

assets/index.less

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
position: relative;
1414
background: @bg-color;
1515
color: @text-color;
16-
16+
font-size: 14px;
1717
height: 100%;
1818

1919
.ant-input {
@@ -91,7 +91,7 @@
9191

9292
&-array,
9393
&-string {
94-
margin: 16px 0;
94+
margin: 8px 0;
9595
}
9696

9797
}
@@ -110,6 +110,12 @@
110110
margin: 8px 0;
111111
color: @text-color2;
112112
}
113+
&-z {
114+
color: @text-color;
115+
border-top: 1px solid @line-color;
116+
padding-top: 8px;
117+
margin-top: 16px;
118+
}
113119
}
114120

115121
&-editor {

examples/simple.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Object(产品优势_0) {
2020
descriptionContent(说明文字): Object{
2121
abc(test): Object{
2222
children(test 文字内容): Image,
23+
a(dsfsd),
2324
},
2425
children(文字内容): Text,
2526
},

src/components/Box.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ export default class Box<props extends IProps, state = any> extends React.Compon
88
return null;
99
}
1010
render() {
11-
const { schema, prefixCls, type, noTitle } = this.props;
11+
const { schema, prefixCls, type, noTitle, noXTitle } = this.props;
1212
const { description } = schema;
1313
const childNames = description.split(remarkStr);
1414
const childrenToRender = this.getChildrenToRender();
1515
const className = classnames(`${prefixCls}-box`, `${prefixCls}-box-${type}`);
16+
console.log(type, noXTitle)
1617
return (
1718
<div className={className}>
18-
{!noTitle && <div className={`${prefixCls}-title-x`}>{childNames[0]}</div>}
19+
{!noTitle && <div className={`${prefixCls}-title-x ${noXTitle ? `${prefixCls}-title-z` : ''}`}>{childNames[0]}</div>}
1920
{childrenToRender}
2021
{childNames[1] && <div>{childNames[1]}</div>}
2122
</div>

src/components/ObjectType.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ export default class ObjectType extends React.Component<IProps> {
3636
if (schema.meta && schema.meta.if && !evaluate(parentData, schema.meta && schema.meta.if)) {
3737
return null;
3838
}
39-
const children = Object.keys(properties).map(key => {
39+
const propertiesType = Object.keys(properties).map(key => properties[key].type);
40+
const children = Object.keys(properties).map((key, i) => {
4041
const item = properties[key];
4142
if (ignore.indexOf(key) >= 0) {
4243
return null;
4344
}
4445
const boxClass = item.type === 'array' && !isOnlyChild || item.type === 'object' && noTop ? `${prefixCls}-box-child` : '';
4546
const $selected = [...selected, key];
47+
console.log(item.type, isOnlyChild, item.type !== 'array' || item.type !== 'object', propertiesType[i - 1], (propertiesType[i - 1] || '').match(/array|object/));
48+
const noXTitle = (item.type !== 'array' || item.type !== 'object') && !!(propertiesType[i - 1] || '').match(/array|object/);
49+
console.log(noXTitle)
4650
return (
4751
<Comp
4852
schema={item}
@@ -58,6 +62,7 @@ export default class ObjectType extends React.Component<IProps> {
5862
selected={$selected}
5963
parentSelected={parentSelected}
6064
noTitle={isOnlyChild && noTop}
65+
noXTitle={noXTitle}
6166
boxClassName={boxClass}
6267
ignore={ignore}
6368
uploadProps={uploadProps}
@@ -69,6 +74,7 @@ export default class ObjectType extends React.Component<IProps> {
6974
if (!children.length) {
7075
return null;
7176
}
77+
console.log(children, noTitle)
7278
return (
7379
<div>
7480
{!noTitle && <div

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class EditorJSON extends React.Component<IProps, IState> {
108108
selected.forEach(key => {
109109
schema = !isNumber(key) ? schema.properties[key] : schema;
110110
data = data[key];
111-
dataBasic = dataBasic[isNumber(key) ? 0 : key];
111+
dataBasic = dataBasic ? dataBasic[isNumber(key) ? 0 : key] : {};
112112
});
113113
return { schema, data, dataBasic };
114114
}

src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface IProps {
1616
boxClassName?: string;
1717
type?: string;
1818
noTitle?: boolean;
19+
noXTitle?: boolean;
1920
uploadProps?: Upload;
2021
uploadImageSize?: number;
2122
uploadVideoSize?: number;

0 commit comments

Comments
 (0)