@@ -46,7 +46,7 @@ import "codemirror/lib/codemirror.css";
46
46
// 引入主题后还需要在 options 中指定主题才会生效 darcula gruvbox-dark hopscotch monokai
47
47
// import "codemirror/theme/panda-syntax.css";
48
48
49
- import " codemirror/theme/idea .css"
49
+ import " codemirror/theme/monokai .css"
50
50
// 提示css
51
51
import " codemirror/addon/hint/show-hint.css" ;
52
52
@@ -82,6 +82,11 @@ export default {
82
82
type: String ,
83
83
default: " " ,
84
84
},
85
+ // 是否只读,nocursor禁止获取焦点
86
+ readOnly: {
87
+ type: [Boolean , String ],
88
+ default: false
89
+ },
85
90
// 外部传入的语法类型
86
91
language: {
87
92
type: String ,
@@ -139,11 +144,12 @@ export default {
139
144
// 默认配置
140
145
matchBrackets: true ,
141
146
options: {
147
+ readOnly: this .readOnly ,
142
148
// 缩进格式
143
149
tabSize: 2 ,
144
150
// 主题,对应主题库 JS 需要提前引入
145
151
// theme: "panda-syntax",
146
- theme: " idea " ,
152
+ theme: " monokai " ,
147
153
line: true ,
148
154
extraKeys: {' Ctrl' : ' autocomplete' },// 自定义快捷键
149
155
hintOptions: {
@@ -264,23 +270,25 @@ export default {
264
270
// coder 配置
265
271
coderOptions () {
266
272
return {
273
+ readOnly: this .options .readOnly ,
267
274
tabSize: this .options .tabSize ,
268
275
theme: this .options .theme ,
269
276
lineNumbers: this .lineNumbers ,
270
277
line: true ,
278
+ extraKeys: this .options .extraKeys ,
271
279
hintOptions: this .options .hintOptions ,
272
280
};
273
281
},
274
282
isAutoHeight () {
275
283
let { autoHeight } = this ;
276
- if (
277
- typeof autoHeight === " string" &&
278
- autoHeight .toLowerCase ().trim () === " !ie"
279
- ) {
280
- // autoHeight = !(isIE() || isIE11())
281
- } else {
282
- autoHeight = true ;
283
- }
284
+ // if (
285
+ // typeof autoHeight === "string" &&
286
+ // autoHeight.toLowerCase().trim() === "!ie"
287
+ // ) {
288
+ // autoHeight = !(isIE() || isIE11())
289
+ // } else {
290
+ // autoHeight = true;
291
+ // }
284
292
return autoHeight;
285
293
},
286
294
fullScreenParentProps () {
@@ -347,7 +355,8 @@ export default {
347
355
});
348
356
349
357
// 自动提示
350
- this .coder .on (" keypress" , () => {
358
+ this .coder .on (" keyHandled" , (e ) => {
359
+ console .log (e);
351
360
this .coder .showHint ();
352
361
});
353
362
},
@@ -478,8 +487,8 @@ export default {
478
487
position : fixed ;
479
488
top : 10px ;
480
489
left : 10px ;
481
- width : calc (100% - 20 px );
482
- height : calc (100% - 20 px );
490
+ width : calc (100% - 0 px );
491
+ height : calc (100% - 0 px );
483
492
padding : 10px ;
484
493
background-color : #f5f5f5 ;
485
494
@@ -501,8 +510,8 @@ export default {
501
510
502
511
& .auto-height {
503
512
.full-screen-child {
504
- min-height : 120 px ;
505
- max-height : 320 px ;
513
+ min-height : 200 px ;
514
+ max-height : 100 % ;
506
515
height : unset ;
507
516
overflow : hidden ;
508
517
}
0 commit comments