8
0
Просмотр исходного кода

Used new View and Template API across the project.

Aleksander Nowodzinski 9 лет назад
Родитель
Сommit
b66bdbc4c3

+ 3 - 5
packages/ckeditor5-ui/src/editableui/editableuiview.js

@@ -24,8 +24,6 @@ export default class EditableUIView extends View {
 	constructor( model, locale, editableElement ) {
 		super( model, locale );
 
-		const bind = this.attributeBinder;
-
 		if ( editableElement ) {
 			this.element = this.editableElement = editableElement;
 		}
@@ -34,10 +32,10 @@ export default class EditableUIView extends View {
 			tag: 'div',
 			attributes: {
 				class: [
-					bind.to( 'isFocused', value => value ? 'ck-focused' : 'ck-blurred' ),
+					this.bind.to( 'isFocused', value => value ? 'ck-focused' : 'ck-blurred' ),
 					'ck-editor__editable'
 				],
-				contenteditable: bind.to( 'isReadOnly', value => !value ),
+				contenteditable: this.bind.to( 'isReadOnly', value => !value ),
 			}
 		} );
 
@@ -55,7 +53,7 @@ export default class EditableUIView extends View {
 	 */
 	init() {
 		if ( this.editableElement ) {
-			this.applyTemplateToElement( this.editableElement, this.template );
+			this.applyTemplateToElement( this.editableElement, this.template.definition );
 		} else {
 			this.editableElement = this.element;
 		}

+ 8 - 6
packages/ckeditor5-ui/src/editableui/inline/inlineeditableuiview.js

@@ -6,6 +6,7 @@
 'use strict';
 
 import EditableUIView from '../../editableui/editableuiview.js';
+import Template from '/ckeditor5/ui/template.js';
 
 /**
  * The class implementing an inline {@link ui.editableUI.EditableUIView}.
@@ -27,12 +28,13 @@ export default class InlineEditableUIView extends EditableUIView {
 
 		const label = this.t( 'Rich Text Editor, %0', [ this.model.name ] );
 
-		Object.assign( this.template.attributes, {
-			role: 'textbox',
-			'aria-label': label,
-			title: label
+		Template.extend( this.template, {
+			attributes: {
+				role: 'textbox',
+				'aria-label': label,
+				title: label,
+				class: 'ck-editor__editable_inline'
+			}
 		} );
-
-		this.template.attributes.class.push( 'ck-editor__editable_inline' );
 	}
 }

+ 4 - 1
packages/ckeditor5-ui/tests/editableui/editableuiview.js

@@ -15,7 +15,10 @@ describe( 'EditableUIView', () => {
 	let model, view, editableElement, locale;
 
 	beforeEach( () => {
-		model = new Model( { isReadOnly: false, isFocused: false } );
+		model = new Model( {
+			isReadOnly: false,
+			isFocused: false
+		} );
 		locale = new Locale( 'en' );
 		view = new EditableUIView( model, locale );
 		editableElement = document.createElement( 'div' );