Skip to content

Commit 251e413

Browse files
committed
feat: 变量绑定插件样式优化,并新增文本最大字符限制配置
1 parent 4a82587 commit 251e413

2 files changed

Lines changed: 83 additions & 6 deletions

File tree

src/plugin/plugin-variable-bind-dialog/index.less

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
font-weight: 700;
77
margin-bottom: 8px;
88
color: rgb(0, 0, 0);
9+
display: flex;
10+
justify-content: space-between;
11+
.error-message{
12+
color:rgba(255,97,96);
13+
font-weight: 400;
14+
}
915
}
16+
17+
1018
.dialog-help-tip-input {
1119
height: 180px;
1220
border: 1px solid rgba(31, 56, 88, 0.3);
@@ -29,7 +37,7 @@
2937
.vs-variable-selector-inner {
3038
border: 1px solid rgba(31, 56, 88, 0.3);
3139
display: flex;
32-
height: 382px;
40+
height: 389px;
3341
border-radius: 3px;
3442
ul {
3543
list-style: none;
@@ -141,13 +149,40 @@
141149
width: 420px;
142150
padding-left: 12px;
143151
float: left;
152+
position: relative;
144153

145154
.event-input-container {
146155
margin-bottom: 20px;
147156
}
148157
textarea {
149158
height: 100%;
150159
}
160+
161+
.editor-type-tag {
162+
width: 18px;
163+
height: 18px;
164+
background-color: rgba(17, 105, 247, 0.18);
165+
border-radius: 2px;
166+
display: flex;
167+
justify-content: center;
168+
align-items: center;
169+
position: absolute;
170+
top: 35px;
171+
z-index: 100;
172+
left: 17px;
173+
}
174+
175+
.editor-context{
176+
border: 1px solid rgba(31, 56, 88, 0.3) ;
177+
padding: 5px 5px 0px 15px;
178+
border-top-right-radius: 3px;
179+
border-top-left-radius: 3px;
180+
}
181+
182+
.editor-context-error{
183+
border-color:rgba(255,97,96,0.7);
184+
}
185+
151186
}
152187
}
153188

@@ -191,4 +226,12 @@
191226
.next-tree.next-node-indent .next-tree-node-inner.next-selected .next-tree-node-label {
192227
color: #fff;
193228
background-color: #4576f5;
194-
}
229+
}
230+
231+
.lc-code-control:hover {
232+
border-color: rgba(0, 0, 0, 0);
233+
}
234+
235+
.lc-code-control.ve-focused {
236+
border-color: rgba(0, 0, 0, 0);
237+
}

src/plugin/plugin-variable-bind-dialog/index.tsx

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ const defaultEditorOption = {
4343
scrollbar: {
4444
vertical: 'auto',
4545
horizontal: 'auto',
46+
verticalScrollbarSize:0
4647
},
4748
}
4849
};
4950

5051
export 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
&nbsp;&nbsp;
@@ -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

Comments
 (0)