Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions packages/ckeditor5-engine/src/controller/editingcontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ import {

import { convertSelectionChange } from '../conversion/upcasthelpers.js';

import { tryFixingRange } from '../model/utils/selection-post-fixer.js';

import type { Model, AfterChangesEvent, BeforeChangesEvent } from '../model/model.js';
import { type ModelItem } from '../model/item.js';
import { type ModelText } from '../model/text.js';
import { type ModelTextProxy } from '../model/textproxy.js';
import { type ModelSchema } from '../model/schema.js';
import type { ModelDocumentChangeEvent } from '../model/document.js';
import type { Marker } from '../model/markercollection.js';
import type { StylesProcessor } from '../view/stylesmap.js';
Expand Down Expand Up @@ -123,12 +120,6 @@ export class EditingController extends /* #__PURE__ */ ObservableMixin() {
convertSelectionChange( this.model, this.mapper )
);

// Fix `beforeinput` target ranges so that they map to the valid model ranges.
this.listenTo<ViewDocumentInputEvent>( this.view.document, 'beforeinput',
fixTargetRanges( this.mapper, this.model.schema, this.view ),
{ priority: 'high' }
);

// Attach default model converters.
this.downcastDispatcher.on<DowncastInsertEvent<ModelText | ModelTextProxy>>( 'insert:$text', insertText(), { priority: 'lowest' } );
this.downcastDispatcher.on<DowncastInsertEvent>( 'insert', insertAttributesAndChildren(), { priority: 'lowest' } );
Expand Down Expand Up @@ -246,30 +237,3 @@ export class EditingController extends /* #__PURE__ */ ObservableMixin() {
} );
}
}

/**
* Checks whether the target ranges provided by the `beforeInput` event can be properly mapped to model ranges and fixes them if needed.
*
* This is using the same logic as the selection post-fixer.
*/
function fixTargetRanges( mapper: Mapper, schema: ModelSchema, view: EditingView ): GetCallback<ViewDocumentInputEvent> {
return ( evt, data ) => {
// The Renderer is disabled while composing on non-android browsers, so we can't be sure that target ranges
// could be properly mapped to view and model because the DOM and view tree drifted apart.
if ( view.document.isComposing && !env.isAndroid ) {
return;
}

for ( let i = 0; i < data.targetRanges.length; i++ ) {
const viewRange = data.targetRanges[ i ];
const modelRange = mapper.toModelRange( viewRange );
const correctedRange = tryFixingRange( modelRange, schema );

if ( !correctedRange || correctedRange.isEqual( modelRange ) ) {
continue;
}

data.targetRanges[ i ] = mapper.toViewRange( correctedRange );
}
};
}
4 changes: 0 additions & 4 deletions packages/ckeditor5-engine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,3 @@ export {
} from './view/matcher.js';

export { injectUiElementHandling as _injectViewUIElementHandling } from './view/uielement.js';

export {
tryFixingRange as _tryFixingModelRange
} from './model/utils/selection-post-fixer.js';
Loading