Skip to content

Commit e8008cc

Browse files
committed
autoheight in json comps
1 parent 6e98446 commit e8008cc

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

client/packages/lowcoder/src/comps/comps/jsonComp/jsonEditorComp.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@ import {
2121
import { useExtensions } from "base/codeEditor/extensions";
2222
import { EditorContext } from "comps/editorState";
2323
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
24+
import { AutoHeightControl } from "@lowcoder-ee/index.sdk";
2425

2526
/**
2627
* JsonEditor Comp
2728
*/
2829

29-
const Wrapper = styled.div`
30+
const Wrapper = styled.div<{$height:boolean}>`
3031
background-color: #fff;
3132
border: 1px solid #d7d9e0;
3233
border-radius: 4px;
3334
overflow: auto;
34-
height: 100%;
35+
height: ${props=>props.$height?'100%':'300px'};
3536
`;
3637

3738
/**
@@ -63,11 +64,12 @@ function fixOldDataSecond(oldData: any) {
6364
}
6465

6566
const childrenMap = {
66-
value: jsonValueExposingStateControl("value", defaultData),
67+
value: jsonValueExposingStateControl('value', defaultData),
6768
onEvent: ChangeEventHandlerControl,
68-
label: withDefault(LabelControl, { position: "column" }),
69+
autoHeight: AutoHeightControl,
70+
label: withDefault(LabelControl, {position: 'column'}),
6971
style: styleControl(JsonEditorStyle, 'style'),
70-
animationStyle: styleControl(AnimationStyle , 'animationStyle'),
72+
animationStyle: styleControl(AnimationStyle, 'animationStyle'),
7173
...formDataChildren,
7274
};
7375

@@ -121,7 +123,7 @@ let JsonEditorTmpComp = (function () {
121123
return props.label({
122124
style: props.style,
123125
animationStyle: props.animationStyle,
124-
children: <Wrapper ref={wrapperRef} onFocus={() => (editContent.current = "focus")} />,
126+
children: <Wrapper ref={wrapperRef} onFocus={() => (editContent.current = "focus")} $height={props.autoHeight}/>,
125127
});
126128
})
127129
.setPropertyViewFn((children) => {
@@ -139,7 +141,9 @@ let JsonEditorTmpComp = (function () {
139141
{hiddenPropertyView(children)}
140142
</Section>
141143
)}
142-
144+
<Section name={trans('prop.height')}>
145+
{children.autoHeight.propertyView({ label: trans('prop.height') })}
146+
</Section>
143147
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && ( children.label.getPropertyView() )}
144148
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && (
145149
<>

client/packages/lowcoder/src/comps/comps/jsonComp/jsonExplorerComp.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { useContext, useEffect } from "react";
1414
import { AnimationStyle, AnimationStyleType } from "@lowcoder-ee/comps/controls/styleControlConstants";
1515
import { styleControl } from "@lowcoder-ee/comps/controls/styleControl";
1616
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
17+
import { AutoHeightControl } from "@lowcoder-ee/index.sdk";
1718

1819
/**
1920
* JsonExplorer Comp
@@ -40,9 +41,10 @@ const bgColorMap = {
4041
const JsonExplorerContainer = styled.div<{
4142
$theme: keyof typeof bgColorMap;
4243
$animationStyle: AnimationStyleType;
44+
$height: boolean
4345
}>`
4446
${(props) => props.$animationStyle}
45-
height: 100%;
47+
height: ${props => props.$height ?'100%':'300px'};
4648
overflow-y: scroll;
4749
background-color: ${(props) => bgColorMap[props.$theme] || "#ffffff"};
4850
border: 1px solid #d7d9e0;
@@ -53,6 +55,7 @@ const JsonExplorerContainer = styled.div<{
5355
let JsonExplorerTmpComp = (function () {
5456
const childrenMap = {
5557
value: withDefault(ArrayOrJSONObjectControl, JSON.stringify(defaultData, null, 2)),
58+
autoHeight: AutoHeightControl,
5659
indent: withDefault(NumberControl, 4),
5760
expandToggle: BoolControl.DEFAULT_TRUE,
5861
theme: dropdownControl(themeOptions, 'shapeshifter:inverted'),
@@ -63,6 +66,7 @@ let JsonExplorerTmpComp = (function () {
6366

6467
return (
6568
<JsonExplorerContainer
69+
$height={props.autoHeight}
6670
$theme={props.theme as keyof typeof bgColorMap}
6771
$animationStyle={props.animationStyle}
6872
>
@@ -81,7 +85,7 @@ let JsonExplorerTmpComp = (function () {
8185
return (
8286
<>
8387
<Section name={sectionNames.basic}>
84-
{children.value.propertyView({ label: trans("export.jsonEditorDesc") })}
88+
{children.value.propertyView({ label: trans("export.jsonEditorDesc") })}
8589
</Section>
8690

8791
{(useContext(EditorContext).editorModeStatus === "logic" || useContext(EditorContext).editorModeStatus === "both") && (
@@ -96,7 +100,9 @@ let JsonExplorerTmpComp = (function () {
96100
{children.indent.propertyView({ label: trans("jsonExplorer.indent") })}
97101
</Section>
98102
)}
99-
103+
<Section name={trans('prop.height')}>
104+
{children.autoHeight.propertyView({label: trans('prop.height')})}
105+
</Section>
100106
{(useContext(EditorContext).editorModeStatus === 'layout' ||
101107
useContext(EditorContext).editorModeStatus === 'both') && (
102108
<>

0 commit comments

Comments
 (0)