Skip to content

Commit bc89577

Browse files
committed
formating removed-41
1 parent 260cd88 commit bc89577

File tree

1 file changed

+35
-54
lines changed

1 file changed

+35
-54
lines changed

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

Lines changed: 35 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,25 @@
1-
import {Section, sectionNames} from 'lowcoder-design';
2-
import {UICompBuilder} from '../../generators';
3-
import {
4-
NameConfigHidden,
5-
NameConfig,
6-
withExposingConfigs,
7-
} from '../../generators/withExposing';
8-
import {defaultData} from './jsonConstants';
9-
import styled from 'styled-components';
10-
import {jsonValueExposingStateControl} from 'comps/controls/codeStateControl';
11-
import {ChangeEventHandlerControl} from 'comps/controls/eventHandlerControl';
12-
import {hiddenPropertyView} from 'comps/utils/propertyUtils';
13-
import {trans} from 'i18n';
14-
import {LabelControl} from 'comps/controls/labelControl';
15-
import {
16-
formDataChildren,
17-
FormDataPropertyView,
18-
} from '../formComp/formDataConstants';
19-
import {
20-
AnimationStyle,
21-
JsonEditorStyle,
22-
} from 'comps/controls/styleControlConstants';
23-
import {styleControl} from 'comps/controls/styleControl';
24-
import {migrateOldData, withDefault} from 'comps/generators/simpleGenerators';
25-
import {useRef, useEffect, useContext} from 'react';
1+
import { Section, sectionNames } from "lowcoder-design";
2+
import { UICompBuilder } from "../../generators";
3+
import { NameConfigHidden, NameConfig, withExposingConfigs } from "../../generators/withExposing";
4+
import { defaultData } from "./jsonConstants";
5+
import styled from "styled-components";
6+
import { jsonValueExposingStateControl } from "comps/controls/codeStateControl";
7+
import { ChangeEventHandlerControl } from "comps/controls/eventHandlerControl";
8+
import { hiddenPropertyView } from "comps/utils/propertyUtils";
9+
import { trans } from "i18n";
10+
import { LabelControl } from "comps/controls/labelControl";
11+
import { formDataChildren, FormDataPropertyView } from "../formComp/formDataConstants";
12+
import { AnimationStyle, JsonEditorStyle } from "comps/controls/styleControlConstants";
13+
import { styleControl } from "comps/controls/styleControl";
14+
import { migrateOldData, withDefault } from "comps/generators/simpleGenerators";
15+
import { useRef, useEffect, useContext } from "react";
2616
import {
2717
EditorState,
2818
EditorView,
2919
type EditorView as EditorViewType,
30-
} from 'base/codeEditor/codeMirror';
31-
import {useExtensions} from 'base/codeEditor/extensions';
32-
import {EditorContext} from 'comps/editorState';
20+
} from "base/codeEditor/codeMirror";
21+
import { useExtensions } from "base/codeEditor/extensions";
22+
import { EditorContext } from "comps/editorState";
3323

3424
/**
3525
* JsonEditor Comp
@@ -47,11 +37,11 @@ const Wrapper = styled.div`
4737
* Compatible with old data 2022-10-19
4838
*/
4939
function fixOldData(oldData: any) {
50-
if (oldData && !oldData.hasOwnProperty('label')) {
40+
if (oldData && !oldData.hasOwnProperty("label")) {
5141
return {
5242
...oldData,
5343
label: {
54-
text: '',
44+
text: "",
5545
},
5646
};
5747
}
@@ -62,7 +52,7 @@ function fixOldData(oldData: any) {
6252
* Compatible with old data 2022-11-18
6353
*/
6454
function fixOldDataSecond(oldData: any) {
65-
if (oldData && oldData.hasOwnProperty('default')) {
55+
if (oldData && oldData.hasOwnProperty("default")) {
6656
return {
6757
...oldData,
6858
value: oldData.default,
@@ -86,9 +76,9 @@ let JsonEditorTmpComp = (function () {
8676
const wrapperRef = useRef<HTMLDivElement>(null);
8777
const view = useRef<EditorViewType | null>(null);
8878
const editContent = useRef<string>();
89-
const {extensions} = useExtensions({
90-
codeType: 'PureJSON',
91-
language: 'json',
79+
const { extensions } = useExtensions({
80+
codeType: "PureJSON",
81+
language: "json",
9282
showLineNum: true,
9383
enableClickCompName: false,
9484
onFocus: (focused) => {
@@ -101,7 +91,7 @@ let JsonEditorTmpComp = (function () {
10191
try {
10292
const value = JSON.parse(state.doc.toString());
10393
props.value.onChange(value);
104-
props.onEvent('change');
94+
props.onEvent("change");
10595
} catch (error) {}
10696
},
10797
});
@@ -112,7 +102,7 @@ let JsonEditorTmpComp = (function () {
112102
doc: JSON.stringify(props.value.value, null, 2),
113103
extensions,
114104
});
115-
view.current = new EditorView({state, parent: wrapperRef.current});
105+
view.current = new EditorView({ state, parent: wrapperRef.current });
116106
}
117107
}, [wrapperRef.current]);
118108

@@ -141,35 +131,26 @@ let JsonEditorTmpComp = (function () {
141131
return (
142132
<>
143133
<Section name={sectionNames.basic}>
144-
{children.value.propertyView({
145-
label: trans('export.jsonEditorDesc'),
146-
})}
134+
{children.value.propertyView({ label: trans("export.jsonEditorDesc") })}
147135
</Section>
148136

149137
<FormDataPropertyView {...children} />
150138

151-
{(useContext(EditorContext).editorModeStatus === 'logic' ||
152-
useContext(EditorContext).editorModeStatus === 'both') && (
139+
{(useContext(EditorContext).editorModeStatus === "logic" || useContext(EditorContext).editorModeStatus === "both") && (
153140
<Section name={sectionNames.interaction}>
154141
{children.onEvent.getPropertyView()}
155142
{hiddenPropertyView(children)}
156143
</Section>
157144
)}
158145

159-
{(useContext(EditorContext).editorModeStatus === 'layout' ||
160-
useContext(EditorContext).editorModeStatus === 'both') &&
161-
children.label.getPropertyView()}
162-
{(useContext(EditorContext).editorModeStatus === 'layout' ||
163-
useContext(EditorContext).editorModeStatus === 'both') && (
146+
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && ( children.label.getPropertyView() )}
147+
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && (
164148
<>
165-
<Section name={sectionNames.style}>
166-
{children.style.getPropertyView()}
167-
</Section>
168-
<Section name={sectionNames.animationStyle}>
169-
{children.animationStyle.getPropertyView()}
170-
</Section>
171-
</>
149+
<Section name={sectionNames.style}>{children.style.getPropertyView()}</Section>
150+
<Section name={sectionNames.animationStyle}>{children.animationStyle.getPropertyView()}</Section>
151+
</>
172152
)}
153+
173154
</>
174155
);
175156
})
@@ -187,6 +168,6 @@ JsonEditorTmpComp = class extends JsonEditorTmpComp {
187168
};
188169

189170
export const JsonEditorComp = withExposingConfigs(JsonEditorTmpComp, [
190-
new NameConfig('value', trans('export.jsonEditorDesc')),
171+
new NameConfig("value", trans("export.jsonEditorDesc")),
191172
NameConfigHidden,
192173
]);

0 commit comments

Comments
 (0)