integration.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* global document */
  6. import Heading from '../src/heading.js';
  7. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  8. import Image from '@ckeditor/ckeditor5-image/src/image';
  9. import ImageCaption from '@ckeditor/ckeditor5-image/src/imagecaption';
  10. import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
  11. import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  12. describe( 'Heading integration', () => {
  13. let editor, doc, element;
  14. beforeEach( () => {
  15. element = document.createElement( 'div' );
  16. document.body.appendChild( element );
  17. return ClassicTestEditor.create( element, {
  18. plugins: [ Paragraph, Heading, Image, ImageCaption ]
  19. } )
  20. .then( newEditor => {
  21. editor = newEditor;
  22. doc = editor.document;
  23. } );
  24. } );
  25. afterEach( () => {
  26. element.remove();
  27. return editor.destroy();
  28. } );
  29. describe( 'with the image feature', () => {
  30. // https://github.com/ckeditor/ckeditor5-heading/issues/73
  31. it( 'should not destroy the image when a selection converted to a heading', () => {
  32. setModelData( editor.document,
  33. '<paragraph>fo[o</paragraph>' +
  34. '<image src="foo.png">' +
  35. '<caption>xxx</caption>' +
  36. '</image>' +
  37. '<paragraph>b]ar</paragraph>'
  38. );
  39. editor.execute( 'heading1' );
  40. expect( getModelData( doc ) ).to.equal(
  41. '<heading1>fo[o</heading1>' +
  42. '<image src="foo.png">' +
  43. '<caption>xxx</caption>' +
  44. '</image>' +
  45. '<heading1>b]ar</heading1>'
  46. );
  47. } );
  48. } );
  49. } );