/** * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor'; import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; import ShiftEnter from '@ckeditor/ckeditor5-enter/src/shiftenter'; import { getData } from '../../../src/dev-utils/model'; // NOTE: // dev utils' setData() loses white spaces so don't use it for tests here!!! // https://github.com/ckeditor/ckeditor5-engine/issues/1428 describe( 'DomConverter – whitespace handling – integration', () => { let editor; // See https://github.com/ckeditor/ckeditor5-engine/issues/822. describe( 'normalizing whitespaces around block boundaries (#822)', () => { beforeEach( () => { return VirtualTestEditor .create( { plugins: [ Paragraph ] } ) .then( newEditor => { editor = newEditor; } ); } ); afterEach( () => { return editor.destroy(); } ); it( 'new line at the end of the content is ignored', () => { editor.setData( '
foo
\n' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'whitespaces at the end of the content are ignored', () => { editor.setData( 'foo
\n\r\n \t' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); // Controversial result. See https://github.com/ckeditor/ckeditor5-engine/issues/987. it( 'nbsp at the end of the content is not ignored', () => { editor.setData( 'foo
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'new line at the beginning of the content is ignored', () => { editor.setData( '\nfoo
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'whitespaces at the beginning of the content are ignored', () => { editor.setData( '\n\n \tfoo
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); // Controversial result. See https://github.com/ckeditor/ckeditor5-engine/issues/987. it( 'nbsp at the beginning of the content is not ignored', () => { editor.setData( 'foo
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'new line between blocks is ignored', () => { editor.setData( 'foo
\nbar
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
bar
' ); } ); it( 'whitespaces between blocks are ignored', () => { editor.setData( 'foo
\n\n \tbar
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
bar
' ); } ); // Controversial result. See https://github.com/ckeditor/ckeditor5-engine/issues/987. it( 'nbsp between blocks is not ignored', () => { editor.setData( 'foo
bar
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
bar
' ); } ); it( 'new lines inside blocks are ignored', () => { editor.setData( '\nfoo\n
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'whitespaces inside blocks are ignored', () => { editor.setData( '\n\n \tfoo\n\n \t
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'nbsp inside blocks are not ignored', () => { editor.setData( 'foo
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'all whitespaces together are ignored', () => { editor.setData( '\nfoo\n\r\n \t
\nbar
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
bar
' ); } ); } ); // https://github.com/ckeditor/ckeditor5/issues/1024 describe( 'whitespaces aroundfoo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar
foo
bar