@@ -111,8 +111,12 @@ export default class ContentEditableInput {
111111 this . showMultipleSelections ( info )
112112 }
113113
114+ getSelection ( ) {
115+ return this . cm . display . wrapper . ownerDocument . getSelection ( )
116+ }
117+
114118 showPrimarySelection ( ) {
115- let sel = window . getSelection ( ) , cm = this . cm , prim = cm . doc . sel . primary ( )
119+ let sel = this . getSelection ( ) , cm = this . cm , prim = cm . doc . sel . primary ( )
116120 let from = prim . from ( ) , to = prim . to ( )
117121
118122 if ( cm . display . viewTo == cm . display . viewFrom || from . line >= cm . display . viewTo || to . line < cm . display . viewFrom ) {
@@ -177,13 +181,13 @@ export default class ContentEditableInput {
177181 }
178182
179183 rememberSelection ( ) {
180- let sel = window . getSelection ( )
184+ let sel = this . getSelection ( )
181185 this . lastAnchorNode = sel . anchorNode ; this . lastAnchorOffset = sel . anchorOffset
182186 this . lastFocusNode = sel . focusNode ; this . lastFocusOffset = sel . focusOffset
183187 }
184188
185189 selectionInEditor ( ) {
186- let sel = window . getSelection ( )
190+ let sel = this . getSelection ( )
187191 if ( ! sel . rangeCount ) return false
188192 let node = sel . getRangeAt ( 0 ) . commonAncestorContainer
189193 return contains ( this . div , node )
@@ -218,14 +222,14 @@ export default class ContentEditableInput {
218222 }
219223
220224 selectionChanged ( ) {
221- let sel = window . getSelection ( )
225+ let sel = this . getSelection ( )
222226 return sel . anchorNode != this . lastAnchorNode || sel . anchorOffset != this . lastAnchorOffset ||
223227 sel . focusNode != this . lastFocusNode || sel . focusOffset != this . lastFocusOffset
224228 }
225229
226230 pollSelection ( ) {
227231 if ( this . readDOMTimeout != null || this . gracePeriod || ! this . selectionChanged ( ) ) return
228- let sel = window . getSelection ( ) , cm = this . cm
232+ let sel = this . getSelection ( ) , cm = this . cm
229233 // On Android Chrome (version 56, at least), backspacing into an
230234 // uneditable block element will put the cursor in that element,
231235 // and then, because it's not editable, hide the virtual keyboard.
0 commit comments