@@ -79,6 +79,7 @@ var renderer = require('./render')
7979var preventXSS = renderer . preventXSS
8080
8181import Editor from './lib/editor'
82+ import EditorConfig from './lib/editor/config'
8283
8384import getUIElements from './lib/editor/ui-elements'
8485
@@ -320,27 +321,6 @@ window.editor = editor
320321var inlineAttach = inlineAttachment . editors . codemirror4 . attach ( editor )
321322defaultTextHeight = parseInt ( $ ( '.CodeMirror' ) . css ( 'line-height' ) )
322323
323- function updateStatusBar ( ) {
324- if ( ! editorInstance . statusBar ) return
325- var cursor = editor . getCursor ( )
326- var cursorText = 'Line ' + ( cursor . line + 1 ) + ', Columns ' + ( cursor . ch + 1 )
327- editorInstance . statusCursor . text ( cursorText )
328- var fileText = ' — ' + editor . lineCount ( ) + ' Lines'
329- editorInstance . statusFile . text ( fileText )
330- var docLength = editor . getValue ( ) . length
331- editorInstance . statusLength . text ( 'Length ' + docLength )
332- if ( docLength > ( docmaxlength * 0.95 ) ) {
333- editorInstance . statusLength . css ( 'color' , 'red' )
334- editorInstance . statusLength . attr ( 'title' , 'Your almost reach note max length limit.' )
335- } else if ( docLength > ( docmaxlength * 0.8 ) ) {
336- editorInstance . statusLength . css ( 'color' , 'orange' )
337- editorInstance . statusLength . attr ( 'title' , 'You nearly fill the note, consider to make more pieces.' )
338- } else {
339- editorInstance . statusLength . css ( 'color' , 'white' )
340- editorInstance . statusLength . attr ( 'title' , 'You could write up to ' + docmaxlength + ' characters in this note.' )
341- }
342- }
343-
344324// initalize ui reference
345325const ui = getUIElements ( )
346326// FIXME: fix global ui element expose
@@ -830,7 +810,7 @@ function changeMode (type) {
830810 // add and update status bar
831811 if ( ! editorInstance . statusBar ) {
832812 editorInstance . addStatusBar ( )
833- updateStatusBar ( )
813+ editorInstance . updateStatusBar ( )
834814 }
835815 // work around foldGutter might not init properly
836816 editor . setOption ( 'foldGutter' , false )
@@ -2105,12 +2085,12 @@ socket.on('check', function (data) {
21052085socket . on ( 'permission' , function ( data ) {
21062086 updatePermission ( data . permission )
21072087} )
2108- var docmaxlength = null
2088+
21092089var permission = null
21102090socket . on ( 'refresh' , function ( data ) {
21112091 // console.log(data);
2112- docmaxlength = data . docmaxlength
2113- editor . setOption ( 'maxLength' , docmaxlength )
2092+ EditorConfig . docmaxlength = data . docmaxlength
2093+ editor . setOption ( 'maxLength' , EditorConfig . docmaxlength )
21142094 updateInfo ( data )
21152095 updatePermission ( data . permission )
21162096 if ( ! window . loaded ) {
@@ -2714,10 +2694,10 @@ function cursorActivityInner (editor) {
27142694 }
27152695}
27162696
2717- editorInstance . on ( 'cursorActivity' , updateStatusBar )
2697+ editorInstance . on ( 'cursorActivity' , editorInstance . updateStatusBar )
27182698editorInstance . on ( 'cursorActivity' , cursorActivity )
27192699
2720- editorInstance . on ( 'beforeSelectionChange' , updateStatusBar )
2700+ editorInstance . on ( 'beforeSelectionChange' , editorInstance . updateStatusBar )
27212701editorInstance . on ( 'beforeSelectionChange' , function ( doc , selections ) {
27222702 // check selection and whether the statusbar has added
27232703 if ( selections && editorInstance . statusSelection ) {
0 commit comments