Browse Source

Removed "getLimitElement()" function because it is already available as a method in Schema.

Kamil Piechaczek 8 years ago
parent
commit
e344d167be
1 changed files with 2 additions and 17 deletions
  1. 2 17
      packages/ckeditor5-typing/src/deletecommand.js

+ 2 - 17
packages/ckeditor5-typing/src/deletecommand.js

@@ -131,7 +131,7 @@ export default class DeleteCommand extends Command {
 
 		const document = this.editor.document;
 		const selection = document.selection;
-		const limitElement = getLimitElement( document.schema, selection );
+		const limitElement = document.schema.getLimitElement( selection );
 		const limitStartPosition = Position.createAt( limitElement );
 		const limitEndPosition = Position.createAt( limitElement, 'end' );
 
@@ -162,7 +162,7 @@ export default class DeleteCommand extends Command {
 	_replaceEntireContentWithParagraph() {
 		const document = this.editor.document;
 		const selection = document.selection;
-		const limitElement = getLimitElement( document.schema, selection );
+		const limitElement = document.schema.getLimitElement( selection );
 		const paragraph = new Element( 'paragraph' );
 
 		this._buffer.batch.remove( Range.createIn( limitElement ) );
@@ -171,18 +171,3 @@ export default class DeleteCommand extends Command {
 		selection.collapse( paragraph );
 	}
 }
-
-// Returns the lowest limit element defined in `Schema.limits` for passed selection.
-function getLimitElement( schema, selection ) {
-	let element = selection.getFirstRange().getCommonAncestor();
-
-	while ( !schema.limits.has( element.name ) ) {
-		if ( element.parent ) {
-			element = element.parent;
-		} else {
-			break;
-		}
-	}
-
-	return element;
-}