From e801e3c372489cd846d2e6fe4ee9fce007b20982 Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Thu, 17 Aug 2017 11:56:22 +0200 Subject: [PATCH] Improved the docs and adjusted to changes in engine (Selection API). --- src/deletecommand.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/deletecommand.js b/src/deletecommand.js index 7865dd4..2523bcb 100644 --- a/src/deletecommand.js +++ b/src/deletecommand.js @@ -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. * @@ -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; @@ -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; }