Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Requested changes during the review.
Browse files Browse the repository at this point in the history
  • Loading branch information
pomek committed Feb 24, 2020
1 parent 0498e42 commit c6a7495
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/filters/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ export function parseHtml( htmlString ) {
// @param {Document} htmlDocument Native `Document` object to be transformed.
// @returns {module:engine/view/documentfragment~DocumentFragment}
function documentToView( htmlDocument ) {
const domConverter = new DomConverter( { blockFillerMode: 'nbsp' } );
const viewDocument = new ViewDocument( new StylesProcessor() );
const domConverter = new DomConverter( viewDocument, { blockFillerMode: 'nbsp' } );
const fragment = htmlDocument.createDocumentFragment();
const nodes = htmlDocument.body.childNodes;

while ( nodes.length > 0 ) {
fragment.appendChild( nodes[ 0 ] );
}

return domConverter.domToView( new ViewDocument( new StylesProcessor() ), fragment );
return domConverter.domToView( fragment );
}

// Extracts both `CSSStyleSheet` and string representation from all `style` elements available in a provided `htmlDocument`.
Expand Down
3 changes: 2 additions & 1 deletion tests/_utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
import ViewDocument from '@ckeditor/ckeditor5-engine/src/view/document';

import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
import normalizeClipboardData from '@ckeditor/ckeditor5-clipboard/src/utils/normalizeclipboarddata';
Expand All @@ -18,7 +19,7 @@ import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils'
import { fixtures, browserFixtures } from './fixtures';
import { StylesProcessor } from '@ckeditor/ckeditor5-engine/src/view/stylesmap';

const htmlDataProcessor = new HtmlDataProcessor( new StylesProcessor() );
const htmlDataProcessor = new HtmlDataProcessor( new ViewDocument( new StylesProcessor() ) );

/**
* Mocks dataTransfer object which can be used for simulating paste.
Expand Down
10 changes: 5 additions & 5 deletions tests/filters/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { StylesProcessor } from '@ckeditor/ckeditor5-engine/src/view/stylesmap';

describe( 'PasteFromOffice - filters', () => {
describe( 'list - paste from MS Word', () => {
const htmlDataProcessor = new HtmlDataProcessor( new StylesProcessor() );
const htmlDataProcessor = new HtmlDataProcessor( new Document( new StylesProcessor() ) );

describe( 'transformListItemLikeElementsIntoLists()', () => {
it( 'replaces list-like elements with semantic lists', () => {
Expand Down Expand Up @@ -85,12 +85,12 @@ describe( 'PasteFromOffice - filters', () => {
} );

describe( 'list - paste from google docs', () => {
const htmlDataProcessor = new HtmlDataProcessor( new StylesProcessor() );
let writer, viewDocument;
let writer, viewDocument, htmlDataProcessor;

before( () => {
viewDocument = new Document();
beforeEach( () => {
viewDocument = new Document( new StylesProcessor() );
writer = new UpcastWriter( viewDocument );
htmlDataProcessor = new HtmlDataProcessor( viewDocument );
} );

describe( 'unwrapParagraphInListItem', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/filters/reomoveboldwrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Document from '@ckeditor/ckeditor5-engine/src/view/document';
import { StylesProcessor } from '@ckeditor/ckeditor5-engine/src/view/stylesmap';

describe( 'PasteFromOffice - filters', () => {
const htmlDataProcessor = new HtmlDataProcessor( new StylesProcessor() );
const htmlDataProcessor = new HtmlDataProcessor( new Document( new StylesProcessor() ) );
describe( 'removeBoldWrapper', () => {
let writer, viewDocument;

Expand Down
3 changes: 2 additions & 1 deletion tests/pastefromoffice.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import { createDataTransfer } from './_utils/utils';
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import { StylesProcessor } from '@ckeditor/ckeditor5-engine/src/view/stylesmap';
import ViewDocument from '@ckeditor/ckeditor5-engine/src/view/document';

describe( 'PasteFromOffice', () => {
const htmlDataProcessor = new HtmlDataProcessor( new StylesProcessor() );
const htmlDataProcessor = new HtmlDataProcessor( new ViewDocument( new StylesProcessor() ) );
let editor, pasteFromOffice, clipboard;

testUtils.createSinonSandbox();
Expand Down

0 comments on commit c6a7495

Please sign in to comment.