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" ;
26
16
import {
27
17
EditorState ,
28
18
EditorView ,
29
19
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" ;
33
23
34
24
/**
35
25
* JsonEditor Comp
@@ -47,11 +37,11 @@ const Wrapper = styled.div`
47
37
* Compatible with old data 2022-10-19
48
38
*/
49
39
function fixOldData ( oldData : any ) {
50
- if ( oldData && ! oldData . hasOwnProperty ( ' label' ) ) {
40
+ if ( oldData && ! oldData . hasOwnProperty ( " label" ) ) {
51
41
return {
52
42
...oldData ,
53
43
label : {
54
- text : '' ,
44
+ text : "" ,
55
45
} ,
56
46
} ;
57
47
}
@@ -62,7 +52,7 @@ function fixOldData(oldData: any) {
62
52
* Compatible with old data 2022-11-18
63
53
*/
64
54
function fixOldDataSecond ( oldData : any ) {
65
- if ( oldData && oldData . hasOwnProperty ( ' default' ) ) {
55
+ if ( oldData && oldData . hasOwnProperty ( " default" ) ) {
66
56
return {
67
57
...oldData ,
68
58
value : oldData . default ,
@@ -86,9 +76,9 @@ let JsonEditorTmpComp = (function () {
86
76
const wrapperRef = useRef < HTMLDivElement > ( null ) ;
87
77
const view = useRef < EditorViewType | null > ( null ) ;
88
78
const editContent = useRef < string > ( ) ;
89
- const { extensions} = useExtensions ( {
90
- codeType : ' PureJSON' ,
91
- language : ' json' ,
79
+ const { extensions } = useExtensions ( {
80
+ codeType : " PureJSON" ,
81
+ language : " json" ,
92
82
showLineNum : true ,
93
83
enableClickCompName : false ,
94
84
onFocus : ( focused ) => {
@@ -101,7 +91,7 @@ let JsonEditorTmpComp = (function () {
101
91
try {
102
92
const value = JSON . parse ( state . doc . toString ( ) ) ;
103
93
props . value . onChange ( value ) ;
104
- props . onEvent ( ' change' ) ;
94
+ props . onEvent ( " change" ) ;
105
95
} catch ( error ) { }
106
96
} ,
107
97
} ) ;
@@ -112,7 +102,7 @@ let JsonEditorTmpComp = (function () {
112
102
doc : JSON . stringify ( props . value . value , null , 2 ) ,
113
103
extensions,
114
104
} ) ;
115
- view . current = new EditorView ( { state, parent : wrapperRef . current } ) ;
105
+ view . current = new EditorView ( { state, parent : wrapperRef . current } ) ;
116
106
}
117
107
} , [ wrapperRef . current ] ) ;
118
108
@@ -141,35 +131,26 @@ let JsonEditorTmpComp = (function () {
141
131
return (
142
132
< >
143
133
< Section name = { sectionNames . basic } >
144
- { children . value . propertyView ( {
145
- label : trans ( 'export.jsonEditorDesc' ) ,
146
- } ) }
134
+ { children . value . propertyView ( { label : trans ( "export.jsonEditorDesc" ) } ) }
147
135
</ Section >
148
136
149
137
< FormDataPropertyView { ...children } />
150
138
151
- { ( useContext ( EditorContext ) . editorModeStatus === 'logic' ||
152
- useContext ( EditorContext ) . editorModeStatus === 'both' ) && (
139
+ { ( useContext ( EditorContext ) . editorModeStatus === "logic" || useContext ( EditorContext ) . editorModeStatus === "both" ) && (
153
140
< Section name = { sectionNames . interaction } >
154
141
{ children . onEvent . getPropertyView ( ) }
155
142
{ hiddenPropertyView ( children ) }
156
143
</ Section >
157
144
) }
158
145
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" ) && (
164
148
< >
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
+ </ >
172
152
) }
153
+
173
154
</ >
174
155
) ;
175
156
} )
@@ -187,6 +168,6 @@ JsonEditorTmpComp = class extends JsonEditorTmpComp {
187
168
} ;
188
169
189
170
export const JsonEditorComp = withExposingConfigs ( JsonEditorTmpComp , [
190
- new NameConfig ( ' value' , trans ( ' export.jsonEditorDesc' ) ) ,
171
+ new NameConfig ( " value" , trans ( " export.jsonEditorDesc" ) ) ,
191
172
NameConfigHidden ,
192
173
] ) ;
0 commit comments