Przeglądaj źródła

Moved "removeDomSelction" do the separate method.

Piotr Jasiun 9 lat temu
rodzic
commit
f4859015cb
1 zmienionych plików z 16 dodań i 12 usunięć
  1. 16 12
      packages/ckeditor5-engine/src/view/renderer.js

+ 16 - 12
packages/ckeditor5-engine/src/view/renderer.js

@@ -425,18 +425,7 @@ export default class Renderer {
 
 		// If there is no selection - remove it from DOM elements that belongs to the editor.
 		if ( this.selection.rangeCount === 0 ) {
-			for ( let doc of this.domDocuments ) {
-				const domSelection = doc.getSelection();
-
-				if ( domSelection.rangeCount ) {
-					const activeDomElement = doc.activeElement;
-					const viewElement = this.domConverter.getCorrespondingViewElement( activeDomElement );
-
-					if ( activeDomElement && viewElement ) {
-						doc.getSelection().removeAllRanges();
-					}
-				}
-			}
+			this._removeDomSelction();
 
 			return;
 		}
@@ -470,6 +459,21 @@ export default class Renderer {
 		}
 	}
 
+	_removeDomSelction() {
+		for ( let doc of this.domDocuments ) {
+			const domSelection = doc.getSelection();
+
+			if ( domSelection.rangeCount ) {
+				const activeDomElement = doc.activeElement;
+				const viewElement = this.domConverter.getCorrespondingViewElement( activeDomElement );
+
+				if ( activeDomElement && viewElement ) {
+					doc.getSelection().removeAllRanges();
+				}
+			}
+		}
+	}
+
 	/**
 	 * Checks if focus needs to be updated and possibly updates it.
 	 *