Преглед изворни кода

Draft of the view root destriction.

Aleksander Nowodzinski пре 7 година
родитељ
комит
f3eada7c78
1 измењених фајлова са 12 додато и 2 уклоњено
  1. 12 2
      packages/ckeditor5-engine/src/view/view.js

+ 12 - 2
packages/ckeditor5-engine/src/view/view.js

@@ -187,8 +187,6 @@ export default class View {
 		// Copy the attributes, to remember the state of the attributes as the element
 		// was before attaching. Apply the attributes using the engine, so they all
 		// remain under the control of the engine.
-		// TODO detachDomRoot back to viewRoot._domAttributes.
-		// TODO get rid of .change(), this._writer
 		for ( const { name, value } of domRoot.attributes ) {
 			this._writer.setAttribute( name, viewRoot._domAttributes[ name ] = value, viewRoot );
 		}
@@ -216,6 +214,18 @@ export default class View {
 		}
 	}
 
+	detachDomRoots() {
+		this.change( writer => {
+			for ( const viewRoot of this.document.roots ) {
+				writer.removeAttribute( 'contenteditable', viewRoot );
+
+				for ( const attribute in viewRoot._domAttributes ) {
+					writer.setAttribute( attribute, viewRoot._domAttributes[ attribute ], viewRoot );
+				}
+			}
+		} );
+	}
+
 	/**
 	 * Gets DOM root element.
 	 *