99
1010import {
1111 CKEditorError ,
12- ObservableMixin ,
13- env ,
14- type GetCallback
12+ ObservableMixin
1513} from '@ckeditor/ckeditor5-utils' ;
1614
1715import RootEditableElement from '../view/rooteditableelement.js' ;
@@ -34,18 +32,14 @@ import {
3432
3533import { convertSelectionChange } from '../conversion/upcasthelpers.js' ;
3634
37- import { tryFixingRange } from '../model/utils/selection-post-fixer.js' ;
38-
3935import type { default as Model , AfterChangesEvent , BeforeChangesEvent } from '../model/model.js' ;
4036import type ModelItem from '../model/item.js' ;
4137import type ModelText from '../model/text.js' ;
4238import type ModelTextProxy from '../model/textproxy.js' ;
43- import type Schema from '../model/schema.js' ;
4439import type { DocumentChangeEvent } from '../model/document.js' ;
4540import type { Marker } from '../model/markercollection.js' ;
4641import type { StylesProcessor } from '../view/stylesmap.js' ;
4742import type { ViewDocumentSelectionChangeEvent } from '../view/observer/selectionobserver.js' ;
48- import type { ViewDocumentInputEvent } from '../view/observer/inputobserver.js' ;
4943
5044// @if CK_DEBUG_ENGINE // const { dumpTrees, initDocumentDumping } = require( '../dev-utils/utils' );
5145
@@ -125,12 +119,6 @@ export default class EditingController extends /* #__PURE__ */ ObservableMixin()
125119 convertSelectionChange ( this . model , this . mapper )
126120 ) ;
127121
128- // Fix `beforeinput` target ranges so that they map to the valid model ranges.
129- this . listenTo < ViewDocumentInputEvent > ( this . view . document , 'beforeinput' ,
130- fixTargetRanges ( this . mapper , this . model . schema , this . view ) ,
131- { priority : 'high' }
132- ) ;
133-
134122 // Attach default model converters.
135123 this . downcastDispatcher . on < DowncastInsertEvent < ModelText | ModelTextProxy > > ( 'insert:$text' , insertText ( ) , { priority : 'lowest' } ) ;
136124 this . downcastDispatcher . on < DowncastInsertEvent > ( 'insert' , insertAttributesAndChildren ( ) , { priority : 'lowest' } ) ;
@@ -248,30 +236,3 @@ export default class EditingController extends /* #__PURE__ */ ObservableMixin()
248236 } ) ;
249237 }
250238}
251-
252- /**
253- * Checks whether the target ranges provided by the `beforeInput` event can be properly mapped to model ranges and fixes them if needed.
254- *
255- * This is using the same logic as the selection post-fixer.
256- */
257- function fixTargetRanges ( mapper : Mapper , schema : Schema , view : View ) : GetCallback < ViewDocumentInputEvent > {
258- return ( evt , data ) => {
259- // The Renderer is disabled while composing on non-android browsers, so we can't be sure that target ranges
260- // could be properly mapped to view and model because the DOM and view tree drifted apart.
261- if ( view . document . isComposing && ! env . isAndroid ) {
262- return ;
263- }
264-
265- for ( let i = 0 ; i < data . targetRanges . length ; i ++ ) {
266- const viewRange = data . targetRanges [ i ] ;
267- const modelRange = mapper . toModelRange ( viewRange ) ;
268- const correctedRange = tryFixingRange ( modelRange , schema ) ;
269-
270- if ( ! correctedRange || correctedRange . isEqual ( modelRange ) ) {
271- continue ;
272- }
273-
274- data . targetRanges [ i ] = mapper . toViewRange ( correctedRange ) ;
275- }
276- } ;
277- }
0 commit comments