@@ -89,29 +89,31 @@ export default class Renderer {
89
89
*/
90
90
this . selection = selection ;
91
91
92
- /**
93
- * The text node in which the inline filler was rendered.
94
- *
95
- * @private
96
- * @member {Text}
97
- */
98
- this . _inlineFiller = null ;
99
-
100
92
/**
101
93
* Indicates whether the view document is focused and selection can be rendered. Selection will not be rendered if
102
94
* this is set to `false`.
103
95
*
96
+ * @readonly
104
97
* @member {Boolean}
105
98
*/
106
99
this . isFocused = false ;
107
100
108
101
/**
109
102
* Indicates whether text composition takes place in the document.
110
103
*
104
+ * @readonly
111
105
* @member {Boolean}
112
106
*/
113
107
this . isComposing = false ;
114
108
109
+ /**
110
+ * The text node in which the inline filler was rendered.
111
+ *
112
+ * @private
113
+ * @member {Text}
114
+ */
115
+ this . _inlineFiller = null ;
116
+
115
117
/**
116
118
* DOM element containing fake selection.
117
119
*
@@ -188,25 +190,28 @@ export default class Renderer {
188
190
let inlineFillerPosition ;
189
191
190
192
if ( this . _inlineFiller ) {
193
+ // There was inline filler rendered in the DOM but it's not at the selection position any more, so we can remove
194
+ // it if not during composition (cause even if it's needed, it must be placed in another location).
191
195
if ( ! this . isComposing && ! this . _isSelectionInInlineFiller ( false ) ) {
192
- // There was inline filler rendered in the DOM but it's not at the selection position any more, so we can remove
193
- // it if not during composition (cause even if it's needed, it must be placed in another location).
194
196
this . _removeInlineFiller ( ) ;
195
197
} else if ( this . isComposing ) {
196
198
// When selection has 0 ranges, `isCollapsed` returns false, but here
197
199
// we are only interested in non-collapsed selection (so with at least 1 range).
198
- if ( ! this . selection . isCollapsed && this . selection . rangeCount > 0 ) {
199
- // During composition selection may be extended and its start/end moved to a different text
200
- // node (using 'shift + up' in Chrome on Windows during composition). In such situations
201
- // filler should not be moved or deleted (because it is possible to continue composing).
200
+ const isSelectionNotCollapsed = ! this . selection . isCollapsed && this . selection . rangeCount > 0 ;
201
+
202
+ // During composition selection may be extended and its start/end moved to a different text
203
+ // node (using 'shift + up' in Chrome on Windows during composition). In such situations
204
+ // filler should not be moved or deleted (because it is possible to continue composing).
205
+ if ( isSelectionNotCollapsed ) {
202
206
inlineFillerPosition = this . _getExistingInlineFillerPosition ( ) ;
203
- } else if ( ! this . _isValidCompositionSelection ( ) ) {
204
- // Check for situations like:
205
- //
206
- // <p>text{}</p><p>FILLERtext</p> or <p>{}</p><p>FILLERtext</p>
207
- //
208
- // when collapsed selection was moved to a different node (without inline filler) during composition.
209
- // It means `compositionend` event was not fired properly and inline filler should be removed.
207
+ }
208
+ // Check for situations like:
209
+ //
210
+ // <p>text{}</p><p>FILLERtext</p> or <p>{}</p><p>FILLERtext</p>
211
+ //
212
+ // when collapsed selection was moved to a different node (without inline filler) during composition.
213
+ // It means `compositionend` event was not fired properly and inline filler should be removed.
214
+ else if ( ! this . _isValidCompositionSelection ( ) ) {
210
215
this . _removeInlineFiller ( ) ;
211
216
}
212
217
}
@@ -239,13 +244,15 @@ export default class Renderer {
239
244
this . _updateText ( node , { inlineFillerPosition } ) ;
240
245
}
241
246
}
247
+
242
248
// Check whether the inline filler is required and where it really is in the DOM.
243
249
// At this point in most cases it will be in the DOM, but there are exceptions.
244
250
// For example, if the inline filler was deep in the created DOM structure, it will not be created.
245
251
// Similarly, if it was removed at the beginning of this function and then neither text nor children were updated,
246
252
// it will not be present.
247
253
// Fix those and similar scenarios.
248
254
this . _inlineFiller = null ; // Reset filler first.
255
+
249
256
if ( inlineFillerPosition ) {
250
257
const fillerDomPosition = this . domConverter . viewPositionToDom ( inlineFillerPosition ) ;
251
258
0 commit comments