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

Fixed FocusObserver's manual test.

Szymon Kupś 9 лет назад
Родитель
Сommit
630d2986e7

+ 5 - 4
packages/ckeditor5-engine/tests/view/manual/focusobserver.js

@@ -10,8 +10,8 @@ import { setData } from '../../../src/dev-utils/view';
 
 const viewDocument = new Document();
 
-viewDocument.on( 'focus', ( evt, data ) => console.log( 'event:focus', data.domTarget ) );
-viewDocument.on( 'blur', ( evt, data ) => console.log( 'event:blur', data.domTarget ) );
+viewDocument.on( 'focus', ( evt, data ) => console.log( `Focus in ${ data.domTarget.id }.` ) );
+viewDocument.on( 'blur', ( evt, data ) => console.log( `Blur in ${ data.domTarget.id }.` ) );
 
 const domEditable1 = document.getElementById( 'editable1' );
 const domEditable2 = document.getElementById( 'editable2' );
@@ -21,12 +21,13 @@ const editable2 = viewDocument.createRoot( domEditable2, 'editable2' );
 
 viewDocument.on( 'selectionChange', ( evt, data ) => {
 	viewDocument.selection.setTo( data.newSelection );
+	viewDocument.render();
 } );
 
-setData( viewDocument, '<p>First editable.</p>', { rootName: 'editable1' } );
+setData( viewDocument, '<p>{}First editable.</p>', { rootName: 'editable1' } );
 setData( viewDocument, '<p>Second editable.</p>', { rootName: 'editable2' } );
 
 editable1.on( 'change:isFocused', () => domEditable1.style.backgroundColor = editable1.isFocused ? 'green' : 'red' );
 editable2.on( 'change:isFocused', () => domEditable2.style.backgroundColor = editable2.isFocused ? 'green' : 'red' );
 
-viewDocument.render();
+viewDocument.focus();

+ 7 - 2
packages/ckeditor5-engine/tests/view/manual/focusobserver.md

@@ -1,9 +1,14 @@
 Focused editable should be green.
 Blurred editable should be red.
 
+* Selection should be placed in 1st editable
 * Open console.
-* Focus the first editable.
-  * Focus in the 1st editable should be logged.
+* Focus in the 1st editable should be logged.
 * Focus the second editable.
   * Blur in the 1st editable should be logged.
   * Focus in the 2nd editable should be logged.
+* Focus the first editable.
+  * Blur in the 2nd editable should be logged.
+  * Focus in the 1st editable should be logged.
+* Click outside editables.
+  * Blur in the 1st editable should be logged.