Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge t/ckeditor5-engine/1208
Browse files Browse the repository at this point in the history
Other: Aligned code to the changes in the engine.
  • Loading branch information
Reinmar committed Dec 26, 2017
2 parents 9bab999 + 9eb9f7e commit 39e4b4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/entercommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ export default class EnterCommand extends Command {
const doc = model.document;

model.change( writer => {
enterBlock( this.editor.data, writer, doc.selection, model.schema );
enterBlock( this.editor.model, writer, doc.selection, model.schema );
this.fire( 'afterExecute', { writer } );
} );
}
}

// Creates a new block in the way that the <kbd>Enter</kbd> key is expected to work.
//
// @param {engine.controller.DataController} dataController
// @param {module:engine.model/writer~Writer} writer
// @param {module:engine/model~Model} model
// @param {module:engine/model/writer~Writer} writer
// @param {module:engine/model/selection~Selection} selection Selection on which the action should be performed.
// @param {module:engine/model/schema~Schema} schema
function enterBlock( dataController, writer, selection, schema ) {
function enterBlock( model, writer, selection, schema ) {
const isSelectionEmpty = selection.isCollapsed;
const range = selection.getFirstRange();
const startElement = range.start.parent;
Expand All @@ -48,7 +48,7 @@ function enterBlock( dataController, writer, selection, schema ) {
// This is an edge case and it's hard to tell what should actually happen because such a selection
// is not entirely valid.
if ( !isSelectionEmpty && startElement == endElement ) {
dataController.deleteContent( selection );
model.deleteContent( selection );
}

return;
Expand All @@ -60,7 +60,7 @@ function enterBlock( dataController, writer, selection, schema ) {
const leaveUnmerged = !( range.start.isAtStart && range.end.isAtEnd );
const isContainedWithinOneElement = ( startElement == endElement );

dataController.deleteContent( selection, { leaveUnmerged } );
model.deleteContent( selection, { leaveUnmerged } );

if ( leaveUnmerged ) {
// Partially selected elements.
Expand Down
2 changes: 1 addition & 1 deletion tests/entercommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe( 'EnterCommand', () => {
it( 'uses DataController.deleteContent', () => {
const spy = sinon.spy();

editor.data.on( 'deleteContent', spy );
editor.model.on( 'deleteContent', spy );

setData( model, '<p>[x]</p>' );

Expand Down

0 comments on commit 39e4b4c

Please sign in to comment.