8
0

selectionobserver.js 879 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals console, document */
  6. import Document from '../../../src/view/document';
  7. import { setData } from '../../../src/dev-utils/view';
  8. const viewDocument = new Document();
  9. viewDocument.createRoot( document.getElementById( 'editor' ) );
  10. setData( viewDocument,
  11. '<container:p><attribute:b>foo</attribute:b>bar</container:p>' +
  12. '<container:p>bom</container:p>' );
  13. viewDocument.on( 'selectionChange', ( evt, data ) => {
  14. console.log( 'selectionChange', data );
  15. viewDocument.selection.setTo( data.newSelection );
  16. } );
  17. viewDocument.on( 'selectionChangeDone', ( evt, data ) => {
  18. console.log( '%c selectionChangeDone ', 'background: #222; color: #bada55', data );
  19. viewDocument.selection.setTo( data.newSelection );
  20. } );
  21. viewDocument.render();