8
0

5564.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
  6. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  7. import ShiftEnter from '@ckeditor/ckeditor5-enter/src/shiftenter';
  8. import { getData as getModelData, setData as setModelData } from '../../src/dev-utils/model';
  9. describe( 'Bug ckeditor5#5564', () => {
  10. let editor;
  11. beforeEach( () => {
  12. return VirtualTestEditor
  13. .create( { plugins: [ Paragraph, ShiftEnter ] } )
  14. .then( newEditor => {
  15. editor = newEditor;
  16. } );
  17. } );
  18. afterEach( () => {
  19. return editor.destroy();
  20. } );
  21. it( 'does not create an excessive new line when loading <p>x</p><p><br></p><p>x</p>', () => {
  22. editor.setData( '<p>x</p><p><br></p><p>x</p>' );
  23. expect( getModelData( editor.model ) ).to.equal(
  24. '<paragraph>[]x</paragraph><paragraph></paragraph><paragraph>x</paragraph>'
  25. );
  26. } );
  27. it( 'preserves a soft break in an empty paragraph', () => {
  28. setModelData( editor.model, '<paragraph>x</paragraph><paragraph><softBreak /></paragraph><paragraph>x</paragraph>' );
  29. const expectedData = '<p>x</p><p><br>&nbsp;</p><p>x</p>';
  30. const actualData = editor.getData();
  31. expect( actualData ).to.equal( expectedData );
  32. // Loading this data into the editor will actually create an excessive space as &nbsp; here isn't recognized as a filler.
  33. // It's a known issue.
  34. editor.setData( actualData );
  35. expect( editor.getData() ).to.equal( expectedData );
  36. } );
  37. } );