@@ -43,13 +43,15 @@ const defaultEditorOption = {
4343 scrollbar : {
4444 vertical : 'auto' ,
4545 horizontal : 'auto' ,
46+ verticalScrollbarSize :0
4647 } ,
4748 }
4849} ;
4950
5051export default class VariableBindDialog extends Component < PluginProps > {
5152 state = {
5253 visiable : false ,
54+ isOverFlowMaxSize :false ,
5355 // stateVaroableList: [],
5456 helpText : HelpText ,
5557 // contextKeys: [],
@@ -63,6 +65,7 @@ export default class VariableBindDialog extends Component<PluginProps> {
6365 minimize : false , // 是否最小化
6466 autoExpandParent : true ,
6567 expandedKeys : [ ] ,
68+ maxTextSize :0 , // 绑定变量最大字符数
6669 } ;
6770
6871 private editorJsRef = React . createRef ( ) ;
@@ -82,6 +85,9 @@ export default class VariableBindDialog extends Component<PluginProps> {
8285 this . openDialog ( ) ;
8386 } ) ;
8487 } ) ;
88+
89+
90+
8591 }
8692
8793 exportSchema = ( ) => {
@@ -94,6 +100,8 @@ export default class VariableBindDialog extends Component<PluginProps> {
94100 const fieldValue = field . getValue ( ) ;
95101 const jsCode = fieldValue ?. value ;
96102
103+ const { maxTextSize} = this . props . config ?. props || { }
104+
97105 this . setState ( {
98106 jsCode,
99107 // fullScreenStatus: false,
@@ -103,6 +111,9 @@ export default class VariableBindDialog extends Component<PluginProps> {
103111 selParentVariable : null , // 选中的父级变量
104112 childrenVariableList : [ ] , // 子级变量列表
105113 minimize : false , // 是否最小化
114+ isOverFlowMaxSize :false ,
115+ // 配置的最大文本长度,默认为0,不控制
116+ maxTextSize :maxTextSize ?maxTextSize :0
106117 } ) ;
107118 } ;
108119
@@ -311,12 +322,24 @@ export default class VariableBindDialog extends Component<PluginProps> {
311322 } ;
312323
313324 updateCode = ( newCode ) => {
325+
326+ let isOverFlowMaxSize = false ;
327+ if ( this . state . maxTextSize ) {
328+ isOverFlowMaxSize = newCode ?. length > this . state . maxTextSize
329+ }
330+
331+
314332 this . setState (
315333 {
316334 jsCode : newCode ,
335+ isOverFlowMaxSize
317336 } ,
318337 this . autoSave ,
319338 ) ;
339+
340+
341+
342+ console . log ( 'size====' , newCode ?. length ) ;
320343 } ;
321344
322345 autoSave = ( ) => {
@@ -362,7 +385,7 @@ export default class VariableBindDialog extends Component<PluginProps> {
362385 } ;
363386
364387 renderBottom = ( ) => {
365- const { jsCode } = this . state ;
388+ const { jsCode, isOverFlowMaxSize } = this . state ;
366389 return (
367390 < div className = "variable-bind-dialog-bottom" >
368391 < div className = "bottom-left-container" >
@@ -374,7 +397,7 @@ export default class VariableBindDialog extends Component<PluginProps> {
374397 </ div >
375398
376399 < div className = "bottom-right-container" >
377- < Button type = "primary" onClick = { this . onOk } >
400+ < Button type = "primary" onClick = { this . onOk } disabled = { isOverFlowMaxSize } >
378401 确定
379402 </ Button >
380403
@@ -504,6 +527,15 @@ export default class VariableBindDialog extends Component<PluginProps> {
504527 ) ;
505528 } ;
506529
530+ renderErrorMessage = ( ) => {
531+ const { isOverFlowMaxSize, maxTextSize} = this . state ;
532+ return (
533+ isOverFlowMaxSize ? < span className = 'error-message' > 表达式文本不能超过{ maxTextSize } 个字符,请换成函数调用</ span > :null
534+
535+ )
536+ }
537+
538+
507539 render ( ) {
508540 const {
509541 visiable,
@@ -516,6 +548,7 @@ export default class VariableBindDialog extends Component<PluginProps> {
516548 minimize,
517549 expandedKeys,
518550 autoExpandParent,
551+ isOverFlowMaxSize
519552 } = this . state ;
520553
521554 const filterTreeNode = ( node ) => {
@@ -604,8 +637,9 @@ export default class VariableBindDialog extends Component<PluginProps> {
604637 </ div >
605638
606639 < div className = "dialog-right-container" >
607- < div className = "dialog-small-title" > 绑定</ div >
608- < div id = "jsEditorDom" className = "editor-context" ref = { this . editorJsRef } >
640+ < div className = "dialog-small-title" > 绑定 { this . renderErrorMessage ( ) } </ div >
641+ < div id = "jsEditorDom" className = { isOverFlowMaxSize ?"editor-context editor-context-error" :"editor-context" } ref = { this . editorJsRef } >
642+ < div className = "editor-type-tag" > =</ div >
609643 < MonacoEditor
610644 value = { jsCode }
611645 { ...defaultEditorProps }
0 commit comments