File tree 3 files changed +11
-10
lines changed
client/packages/lowcoder/src
3 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { CodeEditorPanel } from "../../pages/editor/codeEditorPanel";
14
14
import type { CodeEditorProps , StyleName } from "./codeEditorTypes" ;
15
15
import { useClickCompNameEffect } from "./clickCompName" ;
16
16
import { Layers } from "../../constants/Layers" ;
17
+ import { debounce } from "lodash" ;
17
18
18
19
type StyleConfig = {
19
20
minHeight : string ;
@@ -219,12 +220,12 @@ function useCodeMirror(
219
220
const showLineNum = props . showLineNum ?? getStyle ( props . styleName ) . showLineNum ;
220
221
221
222
const handleChange = useCallback (
222
- ( state : EditorState ) => {
223
+ debounce ( ( state : EditorState ) => {
223
224
window . clearTimeout ( isTypingRef . current ) ;
224
225
isTypingRef . current = window . setTimeout ( ( ) => ( isTypingRef . current = 0 ) , 100 ) ;
225
226
onChange ?.( state ) ;
226
- } ,
227
- [ onChange ]
227
+ } , 100 )
228
+ , [ onChange ]
228
229
) ;
229
230
230
231
const { extensions, reconfigure, isFocus } = useExtensions ( {
Original file line number Diff line number Diff line change @@ -100,18 +100,18 @@ export function codeControl<
100
100
this . _exposingNode = withFunction ( this . _node , ( x ) => x . value ) ;
101
101
102
102
// make sure handleChange's reference only changes when the instance changes, avoid CodeEditor frequent reconfigure
103
- this . handleChange = debounce ( ( state : EditorState ) => {
103
+ this . handleChange = ( state : EditorState ) => {
104
104
this . dispatchChangeValueAction ( state . doc . toString ( ) ) ;
105
- } , 50 ) ;
105
+ } ;
106
106
}
107
107
108
108
override changeDispatch ( dispatch : DispatchType ) {
109
109
// need to re-bind handleChange when dispatch changes, otherwise old instance's dispatch is still in use
110
110
const comp = setFieldsNoTypeCheck ( this , {
111
111
dispatch,
112
- handleChange : debounce ( ( state : EditorState ) => {
112
+ handleChange : ( state : EditorState ) => {
113
113
comp . dispatchChangeValueAction ( state . doc . toString ( ) ) ;
114
- } , 50 ) ,
114
+ } ,
115
115
} ) ;
116
116
return comp ;
117
117
}
Original file line number Diff line number Diff line change @@ -75,11 +75,11 @@ export function ExtendedPropertyView<
75
75
const [ compVersions , setCompVersions ] = useState ( [ 'latest' ] ) ;
76
76
const [ compName , setCompName ] = useState ( '' ) ;
77
77
const editorState = useContext ( EditorContext ) ;
78
- const selectedComp = values ( editorState . selectedComps ( ) ) [ 0 ] ;
79
- const compType = selectedComp . children . compType . getView ( ) as UICompType ;
78
+ const selectedComp = values ( editorState ? .selectedComps ( ) ) [ 0 ] ;
79
+ const compType = selectedComp ? .children ? .compType ? .getView ( ) as UICompType ;
80
80
81
81
useEffect ( ( ) => {
82
- setCompName ( uiCompRegistry [ compType ] . compName || '' ) ;
82
+ setCompName ( uiCompRegistry [ compType ] ? .compName || '' ) ;
83
83
} , [ compType ] ) ;
84
84
85
85
useEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments