diff --git a/package.json b/package.json index 66e35cc..b078b30 100644 --- a/package.json +++ b/package.json @@ -11,12 +11,13 @@ ], "dependencies": { "@ckeditor/ckeditor5-core": "^11.0.1", - "@ckeditor/ckeditor5-engine": "^11.0.0", "@ckeditor/ckeditor5-ui": "^11.1.0", "@ckeditor/ckeditor5-utils": "^11.0.0" }, "devDependencies": { + "@ckeditor/ckeditor5-basic-styles": "^10.0.3", "@ckeditor/ckeditor5-editor-classic": "^11.0.1", + "@ckeditor/ckeditor5-engine": "^11.0.0", "@ckeditor/ckeditor5-enter": "^10.1.2", "@ckeditor/ckeditor5-essentials": "^10.1.2", "@ckeditor/ckeditor5-heading": "^10.1.0", @@ -24,8 +25,6 @@ "@ckeditor/ckeditor5-list": "^11.0.2", "@ckeditor/ckeditor5-paragraph": "^10.0.3", "@ckeditor/ckeditor5-typing": "^11.0.1", - "@ckeditor/ckeditor5-engine": "^10.2.0", - "@ckeditor/ckeditor5-basic-styles": "^10.0.3", "eslint": "^5.5.0", "eslint-config-ckeditor5": "^1.0.7", "husky": "^0.14.3", diff --git a/src/blockquotecommand.js b/src/blockquotecommand.js index 371b590..fff494b 100644 --- a/src/blockquotecommand.js +++ b/src/blockquotecommand.js @@ -9,9 +9,6 @@ import Command from '@ckeditor/ckeditor5-core/src/command'; -import Position from '@ckeditor/ckeditor5-engine/src/model/position'; -import Element from '@ckeditor/ckeditor5-engine/src/model/element'; -import Range from '@ckeditor/ckeditor5-engine/src/model/range'; import first from '@ckeditor/ckeditor5-utils/src/first'; /** @@ -113,7 +110,7 @@ export default class BlockQuoteCommand extends Command { */ _removeQuote( writer, blocks ) { // Unquote all groups of block. Iterate in the reverse order to not break following ranges. - getRangesOfBlockGroups( blocks ).reverse().forEach( groupRange => { + getRangesOfBlockGroups( writer, blocks ).reverse().forEach( groupRange => { if ( groupRange.start.isAtStart && groupRange.end.isAtEnd ) { writer.unwrap( groupRange.start.parent ); @@ -122,7 +119,7 @@ export default class BlockQuoteCommand extends Command { // The group of blocks are at the beginning of an so let's move them left (out of the ). if ( groupRange.start.isAtStart ) { - const positionBefore = Position.createBefore( groupRange.start.parent ); + const positionBefore = writer.createPositionBefore( groupRange.start.parent ); writer.move( groupRange, positionBefore ); @@ -137,7 +134,7 @@ export default class BlockQuoteCommand extends Command { // Now we are sure that groupRange.end.isAtEnd is true, so let's move the blocks right. - const positionAfter = Position.createAfter( groupRange.end.parent ); + const positionAfter = writer.createPositionAfter( groupRange.end.parent ); writer.move( groupRange, positionAfter ); } ); @@ -154,11 +151,11 @@ export default class BlockQuoteCommand extends Command { const quotesToMerge = []; // Quote all groups of block. Iterate in the reverse order to not break following ranges. - getRangesOfBlockGroups( blocks ).reverse().forEach( groupRange => { + getRangesOfBlockGroups( writer, blocks ).reverse().forEach( groupRange => { let quote = findQuote( groupRange.start ); if ( !quote ) { - quote = new Element( 'blockQuote' ); + quote = writer.createElement( 'blockQuote' ); writer.wrap( groupRange, quote ); } @@ -172,7 +169,7 @@ export default class BlockQuoteCommand extends Command { // we want to keep the reference to the first (furthest left) one. quotesToMerge.reverse().reduce( ( currentQuote, nextQuote ) => { if ( currentQuote.nextSibling == nextQuote ) { - writer.merge( Position.createAfter( currentQuote ) ); + writer.merge( writer.createPositionAfter( currentQuote ) ); return currentQuote; } @@ -194,7 +191,7 @@ function findQuote( elementOrPosition ) { // // @param {Array.} blocks // @returns {Array.} -function getRangesOfBlockGroups( blocks ) { +function getRangesOfBlockGroups( writer, blocks ) { let startPosition; let i = 0; const ranges = []; @@ -204,11 +201,11 @@ function getRangesOfBlockGroups( blocks ) { const nextBlock = blocks[ i + 1 ]; if ( !startPosition ) { - startPosition = Position.createBefore( block ); + startPosition = writer.createPositionBefore( block ); } if ( !nextBlock || block.nextSibling != nextBlock ) { - ranges.push( new Range( startPosition, Position.createAfter( block ) ) ); + ranges.push( writer.createRange( startPosition, writer.createPositionAfter( block ) ) ); startPosition = null; } diff --git a/src/blockquoteediting.js b/src/blockquoteediting.js index fdb907d..a6304f2 100644 --- a/src/blockquoteediting.js +++ b/src/blockquoteediting.js @@ -8,8 +8,6 @@ */ import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; -import Range from '@ckeditor/ckeditor5-engine/src/model/range'; -import Position from '@ckeditor/ckeditor5-engine/src/model/position'; import BlockQuoteCommand from './blockquotecommand'; @@ -70,10 +68,10 @@ export default class BlockQuoteEditing extends Plugin { return true; } else if ( element.is( 'element' ) ) { // Just added an element. Check its children to see if there are no nested blockQuotes somewhere inside. - const range = Range.createIn( element ); + const range = writer.createRangeIn( element ); for ( const child of range.getItems() ) { - if ( child.is( 'blockQuote' ) && !schema.checkChild( Position.createBefore( child ), child ) ) { + if ( child.is( 'blockQuote' ) && !schema.checkChild( writer.createPositionBefore( child ), child ) ) { writer.unwrap( child ); return true; diff --git a/tests/blockquoteediting.js b/tests/blockquoteediting.js index 673a00f..ca7c604 100644 --- a/tests/blockquoteediting.js +++ b/tests/blockquoteediting.js @@ -8,8 +8,6 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; import ListEditing from '@ckeditor/ckeditor5-list/src/listediting'; import BoldEditing from '@ckeditor/ckeditor5-basic-styles/src/bold/boldediting'; -import Range from '@ckeditor/ckeditor5-engine/src/model/range'; - import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor'; import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model'; @@ -94,7 +92,7 @@ describe( 'BlockQuoteEditing', () => { const root = model.document.getRoot(); const bq = root.getChild( 0 ); - writer.remove( Range.createIn( bq ) ); + writer.remove( writer.createRangeIn( bq ) ); } ); expect( editor.getData() ).to.equal( '

 

' ); // Autoparagraphed. @@ -122,7 +120,7 @@ describe( 'BlockQuoteEditing', () => { model.change( writer => { const root = model.document.getRoot(); - writer.wrap( Range.createIn( root ), 'blockQuote' ); + writer.wrap( writer.createRangeIn( root ), 'blockQuote' ); } ); expect( editor.getData() ).to.equal( '

Foo

Bar

' ); @@ -136,7 +134,7 @@ describe( 'BlockQuoteEditing', () => { const root = model.document.getRoot(); const p = root.getChild( 0 ).getChild( 0 ); - writer.setAttribute( 'bold', true, Range.createIn( p ) ); + writer.setAttribute( 'bold', true, writer.createRangeIn( p ) ); } ); expect( editor.getData() ).to.equal( '

Foo

' );