@@ -114,13 +114,14 @@ var nameKey; //added by chromoxdor
114
114
} while ( child = child . parentNode )
115
115
}
116
116
117
- function activeElt ( doc ) {
117
+ function activeElt ( rootNode ) {
118
118
// IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
119
119
// IE < 10 will throw when accessed while the page is loading or in an iframe.
120
120
// IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
121
+ var doc = rootNode . ownerDocument || rootNode ;
121
122
var activeElement ;
122
123
try {
123
- activeElement = doc . activeElement ;
124
+ activeElement = rootNode . activeElement ;
124
125
} catch ( e ) {
125
126
activeElement = doc . body || null ;
126
127
}
@@ -148,6 +149,15 @@ var nameKey; //added by chromoxdor
148
149
149
150
function doc ( cm ) { return cm . display . wrapper . ownerDocument }
150
151
152
+ function root ( cm ) {
153
+ return rootNode ( cm . display . wrapper )
154
+ }
155
+
156
+ function rootNode ( element ) {
157
+ // Detect modern browsers (2017+).
158
+ return element . getRootNode ? element . getRootNode ( ) : element . ownerDocument
159
+ }
160
+
151
161
function win ( cm ) { return doc ( cm ) . defaultView }
152
162
153
163
function bind ( f ) {
@@ -540,7 +550,7 @@ var nameKey; //added by chromoxdor
540
550
541
551
var on = function ( emitter , type , f ) {
542
552
if ( emitter . addEventListener ) {
543
- emitter . addEventListener ( type , f , { passive : false } ) ;
553
+ emitter . addEventListener ( type , f , false ) ;
544
554
} else if ( emitter . attachEvent ) {
545
555
emitter . attachEvent ( "on" + type , f ) ;
546
556
} else {
@@ -3902,7 +3912,7 @@ var nameKey; //added by chromoxdor
3902
3912
cm . display . maxLineChanged = false ;
3903
3913
}
3904
3914
3905
- var takeFocus = op . focus && op . focus == activeElt ( doc ( cm ) ) ;
3915
+ var takeFocus = op . focus && op . focus == activeElt ( root ( cm ) ) ;
3906
3916
if ( op . preparedSelection )
3907
3917
{ cm . display . input . showSelection ( op . preparedSelection , takeFocus ) ; }
3908
3918
if ( op . updatedDisplay || op . startHeight != cm . doc . height )
@@ -4079,7 +4089,7 @@ var nameKey; //added by chromoxdor
4079
4089
4080
4090
function selectionSnapshot ( cm ) {
4081
4091
if ( cm . hasFocus ( ) ) { return null }
4082
- var active = activeElt ( doc ( cm ) ) ;
4092
+ var active = activeElt ( root ( cm ) ) ;
4083
4093
if ( ! active || ! contains ( cm . display . lineDiv , active ) ) { return null }
4084
4094
var result = { activeElt : active } ;
4085
4095
if ( window . getSelection ) {
@@ -4095,7 +4105,7 @@ var nameKey; //added by chromoxdor
4095
4105
}
4096
4106
4097
4107
function restoreSelection ( snapshot ) {
4098
- if ( ! snapshot || ! snapshot . activeElt || snapshot . activeElt == activeElt ( snapshot . activeElt . ownerDocument ) ) { return }
4108
+ if ( ! snapshot || ! snapshot . activeElt || snapshot . activeElt == activeElt ( rootNode ( snapshot . activeElt ) ) ) { return }
4099
4109
snapshot . activeElt . focus ( ) ;
4100
4110
if ( ! / ^ ( I N P U T | T E X T A R E A ) $ / . test ( snapshot . activeElt . nodeName ) &&
4101
4111
snapshot . anchorNode && contains ( document . body , snapshot . anchorNode ) && contains ( document . body , snapshot . focusNode ) ) {
@@ -4417,6 +4427,8 @@ var nameKey; //added by chromoxdor
4417
4427
d . scroller . setAttribute ( "tabIndex" , "-1" ) ;
4418
4428
// The element in which the editor lives.
4419
4429
d . wrapper = elt ( "div" , [ d . scrollbarFiller , d . gutterFiller , d . scroller ] , "CodeMirror" ) ;
4430
+ // See #6982. FIXME remove when this has been fixed for a while in Chrome
4431
+ if ( chrome && chrome_version >= 105 ) { d . wrapper . style . clipPath = "inset(0px)" ; }
4420
4432
4421
4433
// This attribute is respected by automatic translation systems such as Google Translate,
4422
4434
// and may also be respected by tools used by human translators.
@@ -7265,7 +7277,7 @@ var nameKey; //added by chromoxdor
7265
7277
function onKeyDown ( e ) {
7266
7278
var cm = this ;
7267
7279
if ( e . target && e . target != cm . display . input . getField ( ) ) { return }
7268
- cm . curOp . focus = activeElt ( doc ( cm ) ) ;
7280
+ cm . curOp . focus = activeElt ( root ( cm ) ) ;
7269
7281
if ( signalDOMEvent ( cm , e ) ) { return }
7270
7282
// IE does strange things with escape.
7271
7283
if ( ie && ie_version < 11 && e . keyCode == 27 ) { e . returnValue = false ; }
@@ -7427,7 +7439,7 @@ var nameKey; //added by chromoxdor
7427
7439
7428
7440
function leftButtonDown ( cm , pos , repeat , event ) {
7429
7441
if ( ie ) { setTimeout ( bind ( ensureFocus , cm ) , 0 ) ; }
7430
- else { cm . curOp . focus = activeElt ( doc ( cm ) ) ; }
7442
+ else { cm . curOp . focus = activeElt ( root ( cm ) ) ; }
7431
7443
7432
7444
var behavior = configureMouse ( cm , repeat , event ) ;
7433
7445
@@ -7497,19 +7509,19 @@ var nameKey; //added by chromoxdor
7497
7509
// Normal selection, as opposed to text dragging.
7498
7510
function leftButtonSelect ( cm , event , start , behavior ) {
7499
7511
if ( ie ) { delayBlurEvent ( cm ) ; }
7500
- var display = cm . display , doc$1 = cm . doc ;
7512
+ var display = cm . display , doc = cm . doc ;
7501
7513
e_preventDefault ( event ) ;
7502
7514
7503
- var ourRange , ourIndex , startSel = doc$1 . sel , ranges = startSel . ranges ;
7515
+ var ourRange , ourIndex , startSel = doc . sel , ranges = startSel . ranges ;
7504
7516
if ( behavior . addNew && ! behavior . extend ) {
7505
- ourIndex = doc$1 . sel . contains ( start ) ;
7517
+ ourIndex = doc . sel . contains ( start ) ;
7506
7518
if ( ourIndex > - 1 )
7507
7519
{ ourRange = ranges [ ourIndex ] ; }
7508
7520
else
7509
7521
{ ourRange = new Range ( start , start ) ; }
7510
7522
} else {
7511
- ourRange = doc$1 . sel . primary ( ) ;
7512
- ourIndex = doc$1 . sel . primIndex ;
7523
+ ourRange = doc . sel . primary ( ) ;
7524
+ ourIndex = doc . sel . primIndex ;
7513
7525
}
7514
7526
7515
7527
if ( behavior . unit == "rectangle" ) {
@@ -7526,18 +7538,18 @@ var nameKey; //added by chromoxdor
7526
7538
7527
7539
if ( ! behavior . addNew ) {
7528
7540
ourIndex = 0 ;
7529
- setSelection ( doc$1 , new Selection ( [ ourRange ] , 0 ) , sel_mouse ) ;
7530
- startSel = doc$1 . sel ;
7541
+ setSelection ( doc , new Selection ( [ ourRange ] , 0 ) , sel_mouse ) ;
7542
+ startSel = doc . sel ;
7531
7543
} else if ( ourIndex == - 1 ) {
7532
7544
ourIndex = ranges . length ;
7533
- setSelection ( doc$1 , normalizeSelection ( cm , ranges . concat ( [ ourRange ] ) , ourIndex ) ,
7545
+ setSelection ( doc , normalizeSelection ( cm , ranges . concat ( [ ourRange ] ) , ourIndex ) ,
7534
7546
{ scroll : false , origin : "*mouse" } ) ;
7535
7547
} else if ( ranges . length > 1 && ranges [ ourIndex ] . empty ( ) && behavior . unit == "char" && ! behavior . extend ) {
7536
- setSelection ( doc$1 , normalizeSelection ( cm , ranges . slice ( 0 , ourIndex ) . concat ( ranges . slice ( ourIndex + 1 ) ) , 0 ) ,
7548
+ setSelection ( doc , normalizeSelection ( cm , ranges . slice ( 0 , ourIndex ) . concat ( ranges . slice ( ourIndex + 1 ) ) , 0 ) ,
7537
7549
{ scroll : false , origin : "*mouse" } ) ;
7538
- startSel = doc$1 . sel ;
7550
+ startSel = doc . sel ;
7539
7551
} else {
7540
- replaceOneSelection ( doc$1 , ourIndex , ourRange , sel_mouse ) ;
7552
+ replaceOneSelection ( doc , ourIndex , ourRange , sel_mouse ) ;
7541
7553
}
7542
7554
7543
7555
var lastPos = start ;
@@ -7547,19 +7559,19 @@ var nameKey; //added by chromoxdor
7547
7559
7548
7560
if ( behavior . unit == "rectangle" ) {
7549
7561
var ranges = [ ] , tabSize = cm . options . tabSize ;
7550
- var startCol = countColumn ( getLine ( doc$1 , start . line ) . text , start . ch , tabSize ) ;
7551
- var posCol = countColumn ( getLine ( doc$1 , pos . line ) . text , pos . ch , tabSize ) ;
7562
+ var startCol = countColumn ( getLine ( doc , start . line ) . text , start . ch , tabSize ) ;
7563
+ var posCol = countColumn ( getLine ( doc , pos . line ) . text , pos . ch , tabSize ) ;
7552
7564
var left = Math . min ( startCol , posCol ) , right = Math . max ( startCol , posCol ) ;
7553
7565
for ( var line = Math . min ( start . line , pos . line ) , end = Math . min ( cm . lastLine ( ) , Math . max ( start . line , pos . line ) ) ;
7554
7566
line <= end ; line ++ ) {
7555
- var text = getLine ( doc$1 , line ) . text , leftPos = findColumn ( text , left , tabSize ) ;
7567
+ var text = getLine ( doc , line ) . text , leftPos = findColumn ( text , left , tabSize ) ;
7556
7568
if ( left == right )
7557
7569
{ ranges . push ( new Range ( Pos ( line , leftPos ) , Pos ( line , leftPos ) ) ) ; }
7558
7570
else if ( text . length > leftPos )
7559
7571
{ ranges . push ( new Range ( Pos ( line , leftPos ) , Pos ( line , findColumn ( text , right , tabSize ) ) ) ) ; }
7560
7572
}
7561
7573
if ( ! ranges . length ) { ranges . push ( new Range ( start , start ) ) ; }
7562
- setSelection ( doc$1 , normalizeSelection ( cm , startSel . ranges . slice ( 0 , ourIndex ) . concat ( ranges ) , ourIndex ) ,
7574
+ setSelection ( doc , normalizeSelection ( cm , startSel . ranges . slice ( 0 , ourIndex ) . concat ( ranges ) , ourIndex ) ,
7563
7575
{ origin : "*mouse" , scroll : false } ) ;
7564
7576
cm . scrollIntoView ( pos ) ;
7565
7577
} else {
@@ -7574,8 +7586,8 @@ var nameKey; //added by chromoxdor
7574
7586
anchor = maxPos ( oldRange . to ( ) , range . head ) ;
7575
7587
}
7576
7588
var ranges$1 = startSel . ranges . slice ( 0 ) ;
7577
- ranges$1 [ ourIndex ] = bidiSimplify ( cm , new Range ( clipPos ( doc$1 , anchor ) , head ) ) ;
7578
- setSelection ( doc$1 , normalizeSelection ( cm , ranges$1 , ourIndex ) , sel_mouse ) ;
7589
+ ranges$1 [ ourIndex ] = bidiSimplify ( cm , new Range ( clipPos ( doc , anchor ) , head ) ) ;
7590
+ setSelection ( doc , normalizeSelection ( cm , ranges$1 , ourIndex ) , sel_mouse ) ;
7579
7591
}
7580
7592
}
7581
7593
@@ -7591,9 +7603,9 @@ var nameKey; //added by chromoxdor
7591
7603
var cur = posFromMouse ( cm , e , true , behavior . unit == "rectangle" ) ;
7592
7604
if ( ! cur ) { return }
7593
7605
if ( cmp ( cur , lastPos ) != 0 ) {
7594
- cm . curOp . focus = activeElt ( doc ( cm ) ) ;
7606
+ cm . curOp . focus = activeElt ( root ( cm ) ) ;
7595
7607
extendTo ( cur ) ;
7596
- var visible = visibleLines ( display , doc$1 ) ;
7608
+ var visible = visibleLines ( display , doc ) ;
7597
7609
if ( cur . line >= visible . to || cur . line < visible . from )
7598
7610
{ setTimeout ( operation ( cm , function ( ) { if ( counter == curCount ) { extend ( e ) ; } } ) , 150 ) ; }
7599
7611
} else {
@@ -7618,7 +7630,7 @@ var nameKey; //added by chromoxdor
7618
7630
}
7619
7631
off ( display . wrapper . ownerDocument , "mousemove" , move ) ;
7620
7632
off ( display . wrapper . ownerDocument , "mouseup" , up ) ;
7621
- doc$1 . history . lastSelOrigin = null ;
7633
+ doc . history . lastSelOrigin = null ;
7622
7634
}
7623
7635
7624
7636
var move = operation ( cm , function ( e ) {
@@ -7775,7 +7787,7 @@ var nameKey; //added by chromoxdor
7775
7787
for ( var i = newBreaks . length - 1 ; i >= 0 ; i -- )
7776
7788
{ replaceRange ( cm . doc , val , newBreaks [ i ] , Pos ( newBreaks [ i ] . line , newBreaks [ i ] . ch + val . length ) ) ; }
7777
7789
} ) ;
7778
- option ( "specialChars" , / [ \u0000 - \u001f \u007f - \u009f \u00ad \u061c \u200b \u200e \u200f \u2028 \u2029 \ufeff \ufff9 - \ufffc ] / g, function ( cm , val , old ) {
7790
+ option ( "specialChars" , / [ \u0000 - \u001f \u007f - \u009f \u00ad \u061c \u200b \u200e \u200f \u2028 \u2029 \u202d \u202e \u2066 \u2067 \u2069 \ ufeff\ufff9 - \ufffc ] / g, function ( cm , val , old ) {
7779
7791
cm . state . specialChars = new RegExp ( val . source + ( val . test ( "\t" ) ? "" : "|\t" ) , "g" ) ;
7780
7792
if ( old != Init ) { cm . refresh ( ) ; }
7781
7793
} ) ;
@@ -8260,8 +8272,8 @@ var nameKey; //added by chromoxdor
8260
8272
}
8261
8273
8262
8274
function disableBrowserMagic ( field , spellcheck , autocorrect , autocapitalize ) {
8263
- field . setAttribute ( "autocorrect" , autocorrect ? "" : "off" ) ;
8264
- field . setAttribute ( "autocapitalize" , autocapitalize ? "" : "off" ) ;
8275
+ field . setAttribute ( "autocorrect" , autocorrect ? "on " : "off" ) ;
8276
+ field . setAttribute ( "autocapitalize" , autocapitalize ? "on " : "off" ) ;
8265
8277
field . setAttribute ( "spellcheck" , ! ! spellcheck ) ;
8266
8278
}
8267
8279
@@ -8276,7 +8288,6 @@ var nameKey; //added by chromoxdor
8276
8288
else { te . setAttribute ( "wrap" , "off" ) ; }
8277
8289
// If border: 0; -- iOS fails to open keyboard (issue #1287)
8278
8290
if ( ios ) { te . style . border = "1px solid black" ; }
8279
- disableBrowserMagic ( te ) ;
8280
8291
return div
8281
8292
}
8282
8293
@@ -8619,7 +8630,7 @@ var nameKey; //added by chromoxdor
8619
8630
8620
8631
signal ( this , "overwriteToggle" , this , this . state . overwrite ) ;
8621
8632
} ,
8622
- hasFocus : function ( ) { return this . display . input . getField ( ) == activeElt ( doc ( this ) ) } ,
8633
+ hasFocus : function ( ) { return this . display . input . getField ( ) == activeElt ( root ( this ) ) } ,
8623
8634
isReadOnly : function ( ) { return ! ! ( this . options . readOnly || this . doc . cantEdit ) } ,
8624
8635
8625
8636
scrollTo : methodOp ( function ( x , y ) { scrollToCoords ( this , x , y ) ; } ) ,
@@ -8898,9 +8909,10 @@ var nameKey; //added by chromoxdor
8898
8909
}
8899
8910
// Old-fashioned briefly-focus-a-textarea hack
8900
8911
var kludge = hiddenTextarea ( ) , te = kludge . firstChild ;
8912
+ disableBrowserMagic ( te ) ;
8901
8913
cm . display . lineSpace . insertBefore ( kludge , cm . display . lineSpace . firstChild ) ;
8902
8914
te . value = lastCopied . text . join ( "\n" ) ;
8903
- var hadFocus = activeElt ( div . ownerDocument ) ;
8915
+ var hadFocus = activeElt ( rootNode ( div ) ) ;
8904
8916
selectInput ( te ) ;
8905
8917
setTimeout ( function ( ) {
8906
8918
cm . display . lineSpace . removeChild ( kludge ) ;
@@ -8923,7 +8935,7 @@ var nameKey; //added by chromoxdor
8923
8935
8924
8936
ContentEditableInput . prototype . prepareSelection = function ( ) {
8925
8937
var result = prepareSelection ( this . cm , false ) ;
8926
- result . focus = activeElt ( this . div . ownerDocument ) == this . div ;
8938
+ result . focus = activeElt ( rootNode ( this . div ) ) == this . div ;
8927
8939
return result
8928
8940
} ;
8929
8941
@@ -9019,7 +9031,7 @@ var nameKey; //added by chromoxdor
9019
9031
9020
9032
ContentEditableInput . prototype . focus = function ( ) {
9021
9033
if ( this . cm . options . readOnly != "nocursor" ) {
9022
- if ( ! this . selectionInEditor ( ) || activeElt ( this . div . ownerDocument ) != this . div )
9034
+ if ( ! this . selectionInEditor ( ) || activeElt ( rootNode ( this . div ) ) != this . div )
9023
9035
{ this . showSelection ( this . prepareSelection ( ) , true ) ; }
9024
9036
this . div . focus ( ) ;
9025
9037
}
@@ -9371,6 +9383,7 @@ var nameKey; //added by chromoxdor
9371
9383
// Used to work around IE issue with selection being forgotten when focus moves away from textarea
9372
9384
this . hasSelection = false ;
9373
9385
this . composing = null ;
9386
+ this . resetting = false ;
9374
9387
} ;
9375
9388
9376
9389
TextareaInput . prototype . init = function ( display ) {
@@ -9461,6 +9474,8 @@ var nameKey; //added by chromoxdor
9461
9474
// The semihidden textarea that is focused when the editor is
9462
9475
// focused, and receives input.
9463
9476
this . textarea = this . wrapper . firstChild ;
9477
+ var opts = this . cm . options ;
9478
+ disableBrowserMagic ( this . textarea , opts . spellcheck , opts . autocorrect , opts . autocapitalize ) ;
9464
9479
} ;
9465
9480
9466
9481
TextareaInput . prototype . screenReaderLabelChanged = function ( label ) {
@@ -9503,8 +9518,9 @@ var nameKey; //added by chromoxdor
9503
9518
// Reset the input to correspond to the selection (or to be empty,
9504
9519
// when not typing and nothing is selected)
9505
9520
TextareaInput . prototype . reset = function ( typing ) {
9506
- if ( this . contextMenuPending || this . composing ) { return }
9521
+ if ( this . contextMenuPending || this . composing && typing ) { return }
9507
9522
var cm = this . cm ;
9523
+ this . resetting = true ;
9508
9524
if ( cm . somethingSelected ( ) ) {
9509
9525
this . prevInput = "" ;
9510
9526
var content = cm . getSelection ( ) ;
@@ -9515,14 +9531,15 @@ var nameKey; //added by chromoxdor
9515
9531
this . prevInput = this . textarea . value = "" ;
9516
9532
if ( ie && ie_version >= 9 ) { this . hasSelection = null ; }
9517
9533
}
9534
+ this . resetting = false ;
9518
9535
} ;
9519
9536
9520
9537
TextareaInput . prototype . getField = function ( ) { return this . textarea } ;
9521
9538
9522
9539
TextareaInput . prototype . supportsTouch = function ( ) { return false } ;
9523
9540
9524
9541
TextareaInput . prototype . focus = function ( ) {
9525
- if ( this . cm . options . readOnly != "nocursor" && ( ! mobile || activeElt ( this . textarea . ownerDocument ) != this . textarea ) ) {
9542
+ if ( this . cm . options . readOnly != "nocursor" && ( ! mobile || activeElt ( rootNode ( this . textarea ) ) != this . textarea ) ) {
9526
9543
try { this . textarea . focus ( ) ; }
9527
9544
catch ( e ) { } // IE8 will throw if the textarea is display: none or not in DOM
9528
9545
}
@@ -9576,7 +9593,7 @@ var nameKey; //added by chromoxdor
9576
9593
// possible when it is clear that nothing happened. hasSelection
9577
9594
// will be the case when there is a lot of text in the textarea,
9578
9595
// in which case reading its value would be expensive.
9579
- if ( this . contextMenuPending || ! cm . state . focused ||
9596
+ if ( this . contextMenuPending || this . resetting || ! cm . state . focused ||
9580
9597
( hasSelection ( input ) && ! prevInput && ! this . composing ) ||
9581
9598
cm . isReadOnly ( ) || cm . options . disableInput || cm . state . keySeq )
9582
9599
{ return false }
@@ -9729,7 +9746,7 @@ var nameKey; //added by chromoxdor
9729
9746
// Set autofocus to true if this textarea is focused, or if it has
9730
9747
// autofocus and no other element is focused.
9731
9748
if ( options . autofocus == null ) {
9732
- var hasFocus = activeElt ( textarea . ownerDocument ) ;
9749
+ var hasFocus = activeElt ( rootNode ( textarea ) ) ;
9733
9750
options . autofocus = hasFocus == textarea ||
9734
9751
textarea . getAttribute ( "autofocus" ) != null && hasFocus == document . body ;
9735
9752
}
@@ -9863,7 +9880,7 @@ var nameKey; //added by chromoxdor
9863
9880
9864
9881
addLegacyProps ( CodeMirror ) ;
9865
9882
9866
- CodeMirror . version = "5.65.7 " ;
9883
+ CodeMirror . version = "5.65.16 " ;
9867
9884
9868
9885
return CodeMirror ;
9869
9886
0 commit comments