/**
* @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 Link from '@ckeditor/ckeditor5-link/src/link';
import List from '@ckeditor/ckeditor5-list/src/list';
import PasteFromOffice from '../../../src/pastefromoffice';
import { setData, stringify } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
import { pasteHtml } from '../../_utils/utils';
import simple from '../../_data/list/simple/input.word2016.html';
import styled from '../../_data/list/styled/input.word2016.html';
import multiple from '../../_data/list/multiple/input.word2016.html';
import multipleCombined from '../../_data/list/multiple-combined/input.word2016.html';
import manyOneItem from '../../_data/list/many-one-item/input.word2016.html';
import heading1 from '../../_data/list/heading1/input.word2016.html';
import heading3Styled from '../../_data/list/heading3-styled/input.word2016.html';
import heading7 from '../../_data/list/heading7/input.word2016.html';
describe( 'List – integration', () => {
let element, editor, insertedModel;
before( () => {
element = document.createElement( 'div' );
document.body.appendChild( element );
return ClassicTestEditor
.create( element, { plugins: [ Clipboard, Paragraph, Heading, Bold, Italic, Underline, Link, List, PasteFromOffice ] } )
.then( editorInstance => {
editor = editorInstance;
const model = editor.model;
const insertContent = model.insertContent;
sinon.stub( editor.model, 'insertContent' ).callsFake( ( content, selection ) => {
// Save model string representation now as it may change after `insertContent()` function call
// so accessing it later may not work as it may have empty/changed structure.
insertedModel = stringify( content );
insertContent.call( model, content, selection );
} );
} );
} );
beforeEach( () => {
setData( editor.model, '
1.Item1
//2.>Item 2
// // which should result in the same output as pasting: // //List:
//·Bold
//·Link
//·Multiple
// // which should result in the same output as pasting: // //List:
//1.Item1
//2.Item 2
//Some text
//·Bullet 1
// // which should result in the same output as pasting: // //Some text
//1.Item1
//2.Item 2
//1.Item 1
//2.Item2
// // which should result in the same output as pasting: // //1.A
//1)B
//I.C
//A.D
//a)E
//a.F
//i.G
// //·H
//oI
// //§J
//1.h1
// // which should result in the same output as pasting: // //1.H 7
// // which should result in the same output as pasting: // //`.
it( 'pastes list created from styled headings (h3)', () => {
const expectedModel = '