nl_tokens: 配置和初始化CodeMirror组件 CodeMirror initialization
pl_tokens: function ( ) { var settings = this . settings ; var editor = this . editor ; if ( settings . editorTheme !== "default" ) { editormd . loadCSS ( settings . path + "codemirror/theme/" + settings . editorTheme ) ; } var codeMirrorConfig = { mode : settings . mode , theme : settings . editorTheme , tabSize : settings . tabSize , dragDrop : false , autofocus : settings . autoFocus , autoCloseTags : settings . autoCloseTags , readOnly : ( settings . readOnly ) ? "nocursor" : false , indentUnit : settings . indentUnit , lineNumbers : settings . lineNumbers , lineWrapping : settings . lineWrapping , extraKeys : { "Ctrl-Q" : function ( cm ) { cm . foldCode ( cm . getCursor ( ) ) ; } } , foldGutter : settings . codeFold , gutters : [ "CodeMirror-linenumbers" , "CodeMirror-foldgutter" ] , matchBrackets : settings . matchBrackets , indentWithTabs : settings . indentWithTabs , styleActiveLine : <mask> . styleActiveLine , styleSelectedText : settings . styleSelectedText , autoCloseBrackets : settings . autoCloseBrackets , showTrailingSpace : settings . showTrailingSpace , highlightSelectionMatches : ( ( ! settings . matchWordHighlight ) ? false : { showToken : ( settings . matchWordHighlight === "onselected" ) ? false : / \w / } ) } ; this . codeEditor = this . cm = editormd . $CodeMirror . fromTextArea ( this . markdownTextarea [ 0 ] , codeMirrorConfig ) ; this . codeMirror = this . cmElement = editor . children ( ".CodeMirror" ) ; if ( settings . value !== "" ) { this . cm . setValue ( settings . value ) ; } this . codeMirror . css ( { fontSize : settings . fontSize , width : ( ! settings . watch ) ? "100%" : "50%" } ) ; if ( settings . autoHeight ) { this . codeMirror . css ( "height" , "auto" ) ; this . cm . setOption ( "viewportMargin" , Infinity ) ; } if ( ! settings . lineNumbers ) { this . codeMirror . find ( ".CodeMirror-gutters" ) . css ( "border-right" , "none" ) ; } return this ; }