@@ -24,7 +24,16 @@ export class Textarea extends InputItem {
2424 'styleActiveLine' : true , // 当前行背景高亮
2525 'matchBrackets' : true , //括号匹配
2626 'lineWrapping' : true , //自动换行
27- 'autoRefresh' : true // https://codemirror.net/doc/manual.html#addon_autorefresh
27+ 'autoRefresh' : true , // https://codemirror.net/doc/manual.html#addon_autorefresh
28+ 'extraKeys' : {
29+ // Full Screen Editing, https://codemirror.net/demo/fullscreen.html
30+ "F11" : function ( cm : any ) {
31+ cm . setOption ( "fullScreen" , ! cm . getOption ( "fullScreen" ) ) ;
32+ } ,
33+ "Esc" : function ( cm : any ) {
34+ if ( cm . getOption ( "fullScreen" ) ) cm . setOption ( "fullScreen" , false ) ;
35+ }
36+ }
2837 } ;
2938
3039 constructor ( spec : any , task_id : string , on_input_event : ( event_name : string , input_item : InputItem ) => void ) {
@@ -62,7 +71,8 @@ export class Textarea extends InputItem {
6271 this . code_mirror_config [ k ] = that . spec . code [ k ] ;
6372
6473 // Get mode name by extension or MIME
65- let mode_info = CodeMirror . findModeByExtension ( spec . code . mode ) || CodeMirror . findModeByMIME ( spec . code . mode ) ;
74+ let origin_mode = spec . code . mode || 'text/plain' ;
75+ let mode_info = CodeMirror . findModeByExtension ( origin_mode ) || CodeMirror . findModeByMIME ( origin_mode ) ;
6676 if ( mode_info )
6777 this . code_mirror_config . mode = mode_info . mode ;
6878
0 commit comments