8
0

x-index.js 916 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals console, document */
  6. import View from '../../../src/view/view';
  7. import { setData } from '../../../src/dev-utils/view';
  8. import createViewRoot from '../_utils/createroot';
  9. const view = new View();
  10. const viewDocument = view.document;
  11. createViewRoot( viewDocument );
  12. view.attachDomRoot( document.getElementById( 'editor' ) );
  13. setData( view,
  14. '<container:p>fo{}o</container:p>' +
  15. '<container:p></container:p>' +
  16. '<container:p><attribute:strong></attribute:strong></container:p>' +
  17. '<container:p>bar</container:p>' );
  18. view.focus();
  19. viewDocument.on( 'selectionChange', ( evt, data ) => {
  20. const node = data.newSelection.getFirstPosition().parent;
  21. console.log( node.name ? node.name : node._data );
  22. view.change( writer => writer.setSelection( data.newSelection ) );
  23. } );