@@ -4796,7 +4796,7 @@ function addChangeToHistory(doc, change, selAfter, opId) {
47964796
47974797 if ( ( hist . lastOp == opId ||
47984798 hist . lastOrigin == change . origin && change . origin &&
4799- ( ( change . origin . charAt ( 0 ) == "+" && doc . cm && hist . lastModTime > time - doc . cm . options . historyEventDelay ) ||
4799+ ( ( change . origin . charAt ( 0 ) == "+" && hist . lastModTime > time - ( doc . cm ? doc . cm . options . historyEventDelay : 500 ) ) ||
48004800 change . origin . charAt ( 0 ) == "*" ) ) &&
48014801 ( cur = lastChangeEvent ( hist , hist . lastOp == opId ) ) ) {
48024802 // Merge this change into the last event
@@ -5410,7 +5410,7 @@ function makeChangeSingleDocInEditor(cm, change, spans) {
54105410function replaceRange ( doc , code , from , to , origin ) {
54115411 if ( ! to ) { to = from ; }
54125412 if ( cmp ( to , from ) < 0 ) { var assign ;
5413- ( assign = [ to , from ] , from = assign [ 0 ] , to = assign [ 1 ] , assign ) ; }
5413+ ( assign = [ to , from ] , from = assign [ 0 ] , to = assign [ 1 ] ) ; }
54145414 if ( typeof code == "string" ) { code = doc . splitLines ( code ) ; }
54155415 makeChange ( doc , { from : from , to : to , text : code , origin : origin } ) ;
54165416}
@@ -5506,10 +5506,10 @@ function LeafChunk(lines) {
55065506}
55075507
55085508LeafChunk . prototype = {
5509- chunkSize : function chunkSize ( ) { return this . lines . length } ,
5509+ chunkSize : function ( ) { return this . lines . length } ,
55105510
55115511 // Remove the n lines at offset 'at'.
5512- removeInner : function removeInner ( at , n ) {
5512+ removeInner : function ( at , n ) {
55135513 var this$1 = this ;
55145514
55155515 for ( var i = at , e = at + n ; i < e ; ++ i ) {
@@ -5522,13 +5522,13 @@ LeafChunk.prototype = {
55225522 } ,
55235523
55245524 // Helper used to collapse a small branch into a single leaf.
5525- collapse : function collapse ( lines ) {
5525+ collapse : function ( lines ) {
55265526 lines . push . apply ( lines , this . lines ) ;
55275527 } ,
55285528
55295529 // Insert the given array of lines at offset 'at', count them as
55305530 // having the given height.
5531- insertInner : function insertInner ( at , lines , height ) {
5531+ insertInner : function ( at , lines , height ) {
55325532 var this$1 = this ;
55335533
55345534 this . height += height ;
@@ -5537,7 +5537,7 @@ LeafChunk.prototype = {
55375537 } ,
55385538
55395539 // Used to iterate over a part of the tree.
5540- iterN : function iterN ( at , n , op ) {
5540+ iterN : function ( at , n , op ) {
55415541 var this$1 = this ;
55425542
55435543 for ( var e = at + n ; at < e ; ++ at )
@@ -5561,9 +5561,9 @@ function BranchChunk(children) {
55615561}
55625562
55635563BranchChunk . prototype = {
5564- chunkSize : function chunkSize ( ) { return this . size } ,
5564+ chunkSize : function ( ) { return this . size } ,
55655565
5566- removeInner : function removeInner ( at , n ) {
5566+ removeInner : function ( at , n ) {
55675567 var this$1 = this ;
55685568
55695569 this . size -= n ;
@@ -5589,13 +5589,13 @@ BranchChunk.prototype = {
55895589 }
55905590 } ,
55915591
5592- collapse : function collapse ( lines ) {
5592+ collapse : function ( lines ) {
55935593 var this$1 = this ;
55945594
55955595 for ( var i = 0 ; i < this . children . length ; ++ i ) { this$1 . children [ i ] . collapse ( lines ) ; }
55965596 } ,
55975597
5598- insertInner : function insertInner ( at , lines , height ) {
5598+ insertInner : function ( at , lines , height ) {
55995599 var this$1 = this ;
56005600
56015601 this . size += lines . length ;
@@ -5624,7 +5624,7 @@ BranchChunk.prototype = {
56245624 } ,
56255625
56265626 // When a node has grown, check whether it should be split.
5627- maybeSpill : function maybeSpill ( ) {
5627+ maybeSpill : function ( ) {
56285628 if ( this . children . length <= 10 ) { return }
56295629 var me = this ;
56305630 do {
@@ -5646,7 +5646,7 @@ BranchChunk.prototype = {
56465646 me . parent . maybeSpill ( ) ;
56475647 } ,
56485648
5649- iterN : function iterN ( at , n , op ) {
5649+ iterN : function ( at , n , op ) {
56505650 var this$1 = this ;
56515651
56525652 for ( var i = 0 ; i < this . children . length ; ++ i ) {
@@ -7324,8 +7324,8 @@ function leftButtonStartDrag(cm, event, pos, behavior) {
73247324 var dragEnd = operation ( cm , function ( e ) {
73257325 if ( webkit ) { display . scroller . draggable = false ; }
73267326 cm . state . draggingText = false ;
7327- off ( document , "mouseup" , dragEnd ) ;
7328- off ( document , "mousemove" , mouseMove ) ;
7327+ off ( display . wrapper . ownerDocument , "mouseup" , dragEnd ) ;
7328+ off ( display . wrapper . ownerDocument , "mousemove" , mouseMove ) ;
73297329 off ( display . scroller , "dragstart" , dragStart ) ;
73307330 off ( display . scroller , "drop" , dragEnd ) ;
73317331 if ( ! moved ) {
@@ -7334,7 +7334,7 @@ function leftButtonStartDrag(cm, event, pos, behavior) {
73347334 { extendSelection ( cm . doc , pos , null , null , behavior . extend ) ; }
73357335 // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
73367336 if ( webkit || ie && ie_version == 9 )
7337- { setTimeout ( function ( ) { document . body . focus ( ) ; display . input . focus ( ) ; } , 20 ) ; }
7337+ { setTimeout ( function ( ) { display . wrapper . ownerDocument . body . focus ( ) ; display . input . focus ( ) ; } , 20 ) ; }
73387338 else
73397339 { display . input . focus ( ) ; }
73407340 }
@@ -7349,8 +7349,8 @@ function leftButtonStartDrag(cm, event, pos, behavior) {
73497349 dragEnd . copy = ! behavior . moveOnDrag ;
73507350 // IE's approach to draggable
73517351 if ( display . scroller . dragDrop ) { display . scroller . dragDrop ( ) ; }
7352- on ( document , "mouseup" , dragEnd ) ;
7353- on ( document , "mousemove" , mouseMove ) ;
7352+ on ( display . wrapper . ownerDocument , "mouseup" , dragEnd ) ;
7353+ on ( display . wrapper . ownerDocument , "mousemove" , mouseMove ) ;
73547354 on ( display . scroller , "dragstart" , dragStart ) ;
73557355 on ( display . scroller , "drop" , dragEnd ) ;
73567356
@@ -7482,8 +7482,8 @@ function leftButtonSelect(cm, event, start, behavior) {
74827482 counter = Infinity ;
74837483 e_preventDefault ( e ) ;
74847484 display . input . focus ( ) ;
7485- off ( document , "mousemove" , move ) ;
7486- off ( document , "mouseup" , up ) ;
7485+ off ( display . wrapper . ownerDocument , "mousemove" , move ) ;
7486+ off ( display . wrapper . ownerDocument , "mouseup" , up ) ;
74877487 doc . history . lastSelOrigin = null ;
74887488 }
74897489
@@ -7493,8 +7493,8 @@ function leftButtonSelect(cm, event, start, behavior) {
74937493 } ) ;
74947494 var up = operation ( cm , done ) ;
74957495 cm . state . selectingText = up ;
7496- on ( document , "mousemove" , move ) ;
7497- on ( document , "mouseup" , up ) ;
7496+ on ( display . wrapper . ownerDocument , "mousemove" , move ) ;
7497+ on ( display . wrapper . ownerDocument , "mouseup" , up ) ;
74987498}
74997499
75007500// Used when mouse-selecting to adjust the anchor to the proper side
@@ -9199,13 +9199,10 @@ TextareaInput.prototype.init = function (display) {
91999199 var this$1 = this ;
92009200
92019201 var input = this , cm = this . cm ;
9202+ this . createField ( display ) ;
9203+ var te = this . textarea ;
92029204
9203- // Wraps and hides input textarea
9204- var div = this . wrapper = hiddenTextarea ( ) ;
9205- // The semihidden textarea that is focused when the editor is
9206- // focused, and receives input.
9207- var te = this . textarea = div . firstChild ;
9208- display . wrapper . insertBefore ( div , display . wrapper . firstChild ) ;
9205+ display . wrapper . insertBefore ( this . wrapper , display . wrapper . firstChild ) ;
92099206
92109207 // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
92119208 if ( ios ) { te . style . width = "0px" ; }
@@ -9272,6 +9269,14 @@ TextareaInput.prototype.init = function (display) {
92729269 } ) ;
92739270} ;
92749271
9272+ TextareaInput . prototype . createField = function ( _display ) {
9273+ // Wraps and hides input textarea
9274+ this . wrapper = hiddenTextarea ( ) ;
9275+ // The semihidden textarea that is focused when the editor is
9276+ // focused, and receives input.
9277+ this . textarea = this . wrapper . firstChild ;
9278+ } ;
9279+
92759280TextareaInput . prototype . prepareSelection = function ( ) {
92769281 // Redraw the selection and/or cursor
92779282 var cm = this . cm , display = cm . display , doc = cm . doc ;
@@ -9665,7 +9670,7 @@ CodeMirror$1.fromTextArea = fromTextArea;
96659670
96669671addLegacyProps ( CodeMirror$1 ) ;
96679672
9668- CodeMirror$1 . version = "5.35 .0" ;
9673+ CodeMirror$1 . version = "5.36 .0" ;
96699674
96709675return CodeMirror$1 ;
96719676
0 commit comments