8
0
Prechádzať zdrojové kódy

Extracted the getPlaceholderElement helper from the editors.

Aleksander Nowodzinski 7 rokov pred
rodič
commit
84eb391464

+ 14 - 0
packages/ckeditor5-engine/src/view/placeholder.js

@@ -157,3 +157,17 @@ function updateSinglePlaceholder( writer, element, info ) {
 
 	return changed;
 }
+
+export function getPlaceholderElement( viewRoot ) {
+	return () => {
+		if ( viewRoot.childCount === 1 ) {
+			const firstRootChild = viewRoot.getChild( 0 );
+
+			if ( firstRootChild.is( 'element' ) ) {
+				return firstRootChild;
+			}
+		}
+
+		return null;
+	};
+}