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

Commit

Permalink
Improved the docs and adjusted to changes in engine (Selection API).
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Piechaczek committed Aug 18, 2017
1 parent 45e9beb commit e801e3c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/deletecommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export default class DeleteCommand extends Command {
* we want to replace the entire content with a paragraph if:
*
* * the current limit element is empty,
* * the paragraph is allowed in the common ancestor,
* * other paragraph does not occur in the editor.
* * the paragraph is allowed in the limit element,
* * other empty paragraph does not occur in the limit element.
*
* See https://github.com/ckeditor/ckeditor5-typing/issues/61.
*
Expand All @@ -138,9 +138,10 @@ export default class DeleteCommand extends Command {
const document = this.editor.document;
const selection = document.selection;
const limitElement = document.schema.getLimitElement( selection );

// If a collapsed selection contains the whole content it means that the content is empty
// (from the user perspective).
const limitElementIsEmpty = selection.isCollapsed && selection.isEntireContentSelected( limitElement );
const limitElementIsEmpty = selection.isCollapsed && selection.entireContentSelected( limitElement );

if ( !limitElementIsEmpty ) {
return false;
Expand All @@ -150,7 +151,7 @@ export default class DeleteCommand extends Command {
return false;
}

// Does nothing if editor already contains an empty paragraph.
// Does nothing if limit element already contains an empty paragraph.
if ( selection.getFirstRange().getCommonAncestor().name === 'paragraph' ) {
return false;
}
Expand Down

0 comments on commit e801e3c

Please sign in to comment.