/** * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md. */ /* globals document */ import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor'; import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard'; import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; import Heading from '@ckeditor/ckeditor5-heading/src/heading'; import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold'; import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic'; import Underline from '@ckeditor/ckeditor5-basic-styles/src/underline'; import Strikethrough from '@ckeditor/ckeditor5-basic-styles/src/strikethrough'; import PasteFromOffice from '../../../src/pastefromoffice'; import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model'; import { getFixtures } from '../../_utils/fixtures'; import { expectModel } from '../../_utils/utils'; describe( 'Basic Styles – integration', () => { let element, editor, input; before( () => { input = getFixtures( 'basic-styles' ).input; element = document.createElement( 'div' ); document.body.appendChild( element ); return ClassicTestEditor .create( element, { plugins: [ Clipboard, Paragraph, Heading, Bold, Italic, Underline, Strikethrough, PasteFromOffice ] } ) .then( editorInstance => { editor = editorInstance; } ); } ); beforeEach( () => { setData( editor.model, '[]' ); } ); after( () => { editor.destroy(); element.remove(); } ); // Pastes: //

Some text with bold.

it( 'pastes bold within text', () => { const expected = 'Some text <$text bold="true">with bold.'; expectModel( editor, input.boldWithinText, expected ); } ); // Pastes: //

Italic text.

it( 'pastes italic starting text', () => { const expected = '<$text italic="true">Italic text.'; expectModel( editor, input.italicStartingText, expected ); } ); // Pastes: //

Whole text underlined

it( 'pastes underlined text', () => { const expected = '<$text underline="true">Whole text underlined'; expectModel( editor, input.underlinedText, expected ); } ); // Pastes: //

Text incorrect

it( 'pastes strikethrough ending text', () => { const expected = 'Text <$text strikethrough="true">incorrect'; expectModel( editor, input.strikethroughEndingText, expected ); } ); // Pastes: //

Text containing multiplestyling.

it( 'pastes mulitple styles single line', () => { const expected = 'Text ' + '<$text bold="true" underline="true">containi' + '<$text bold="true" strikethrough="true" underline="true">ng' + '<$text strikethrough="true" underline="true"> multi' + '<$text strikethrough="true">ple ' + '<$text italic="true">styling.'; expectModel( editor, input.multipleStylesSingleLine, expected ); } ); // Pastes: //

Line bold and italics

//

Line foo bar

//

Third line styling, space on end

it( 'pastes mulitple styles multiline', () => { const expected = 'Line ' + '<$text bold="true">bold and <$text italic="true">italics' + 'Line <$text bold="true" underline="true">foo<$text underline="true"> bar' + '<$text strikethrough="true">Third line <$text bold="true">styling, ' + '<$text bold="true" italic="true">space on e' + '<$text bold="true">nd '; expectModel( editor, input.multipleStylesMultiline, expected ); } ); } );