Răsfoiți Sursa

Merge branch 'master' into ckeditor5/t/1214

Piotrek Koszuliński 7 ani în urmă
părinte
comite
8649cbdaf1

+ 5 - 0
packages/ckeditor5-block-quote/CHANGELOG.md

@@ -1,6 +1,11 @@
 Changelog
 =========
 
+## [10.1.1](https://github.com/ckeditor/ckeditor5-block-quote/compare/v10.1.0...v10.1.1) (2018-12-05)
+
+Internal changes only (updated dependencies, documentation, etc.).
+
+
 ## [10.1.0](https://github.com/ckeditor/ckeditor5-block-quote/compare/v10.0.2...v10.1.0) (2018-10-08)
 
 ### Features

+ 16 - 15
packages/ckeditor5-block-quote/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@ckeditor/ckeditor5-block-quote",
-  "version": "10.1.0",
+  "version": "10.1.1",
   "description": "Block quote feature for CKEditor 5.",
   "keywords": [
     "ckeditor",
@@ -10,23 +10,24 @@
     "ckeditor5-plugin"
   ],
   "dependencies": {
-    "@ckeditor/ckeditor5-core": "^11.0.1",
-    "@ckeditor/ckeditor5-ui": "^11.1.0",
-    "@ckeditor/ckeditor5-utils": "^11.0.0"
+    "@ckeditor/ckeditor5-core": "^11.1.0",
+    "@ckeditor/ckeditor5-ui": "^11.2.0",
+    "@ckeditor/ckeditor5-utils": "^11.1.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",
-    "@ckeditor/ckeditor5-image": "^11.0.0",
-    "@ckeditor/ckeditor5-list": "^11.0.2",
-    "@ckeditor/ckeditor5-paragraph": "^10.0.3",
-    "@ckeditor/ckeditor5-typing": "^11.0.1",
+    "@ckeditor/ckeditor5-basic-styles": "^10.1.0",
+    "@ckeditor/ckeditor5-editor-classic": "^11.0.2",
+    "@ckeditor/ckeditor5-engine": "^12.0.0",
+    "@ckeditor/ckeditor5-enter": "^10.1.3",
+    "@ckeditor/ckeditor5-essentials": "^10.1.3",
+    "@ckeditor/ckeditor5-heading": "^10.1.1",
+    "@ckeditor/ckeditor5-image": "^12.0.0",
+    "@ckeditor/ckeditor5-list": "^11.0.3",
+    "@ckeditor/ckeditor5-paragraph": "^10.0.4",
+    "@ckeditor/ckeditor5-table": "^11.0.0",
+    "@ckeditor/ckeditor5-typing": "^11.0.2",
     "eslint": "^5.5.0",
-    "eslint-config-ckeditor5": "^1.0.7",
+    "eslint-config-ckeditor5": "^1.0.9",
     "husky": "^0.14.3",
     "lint-staged": "^7.0.0"
   },

+ 7 - 4
packages/ckeditor5-block-quote/src/blockquotecommand.js

@@ -34,7 +34,7 @@ export default class BlockQuoteCommand extends Command {
 	}
 
 	/**
-	 * Executes the command. When the command {@link #value is on}, all block quotes within
+	 * Executes the command. When the command {@link #value is on}, all top-most block quotes within
 	 * the selection will be removed. If it is off, all selected blocks will be wrapped with
 	 * a block quote.
 	 *
@@ -42,9 +42,10 @@ export default class BlockQuoteCommand extends Command {
 	 */
 	execute() {
 		const model = this.editor.model;
-		const doc = model.document;
 		const schema = model.schema;
-		const blocks = Array.from( doc.selection.getSelectedBlocks() );
+		const selection = model.document.selection;
+
+		const blocks = Array.from( selection.getTopMostBlocks() );
 
 		model.change( writer => {
 			if ( this.value ) {
@@ -68,7 +69,9 @@ export default class BlockQuoteCommand extends Command {
 	 * @returns {Boolean} The current value.
 	 */
 	_getValue() {
-		const firstBlock = first( this.editor.model.document.selection.getSelectedBlocks() );
+		const selection = this.editor.model.document.selection;
+
+		const firstBlock = first( selection.getTopMostBlocks() );
 
 		// In the current implementation, the block quote must be an immediate parent of a block element.
 		return !!( firstBlock && findQuote( firstBlock ) );

+ 8 - 9
packages/ckeditor5-block-quote/tests/blockquotecommand.js

@@ -6,8 +6,6 @@
 import BlockQuoteEditing from '../src/blockquoteediting';
 import BlockQuoteCommand from '../src/blockquotecommand';
 
-import { downcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversion/downcast-converters';
-
 import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
 import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
@@ -33,13 +31,14 @@ describe( 'BlockQuoteCommand', () => {
 
 				model.schema.extend( 'widget', {
 					allowIn: '$root',
-					isLimit: true
+					isLimit: true,
+					isObject: true
 				} );
 				model.schema.extend( '$text', { allowIn: 'widget' } );
 
-				editor.conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'paragraph', view: 'p' } ) );
-				editor.conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'heading', view: 'h' } ) );
-				editor.conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'widget', view: 'widget' } ) );
+				editor.conversion.for( 'downcast' ).elementToElement( { model: 'paragraph', view: 'p' } );
+				editor.conversion.for( 'downcast' ).elementToElement( { model: 'heading', view: 'h' } );
+				editor.conversion.for( 'downcast' ).elementToElement( { model: 'widget', view: 'widget' } );
 
 				command = editor.commands.get( 'blockQuote' );
 			} );
@@ -385,7 +384,7 @@ describe( 'BlockQuoteCommand', () => {
 					}
 				} );
 
-				editor.conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'fooBlock', view: 'fooblock' } ) );
+				editor.conversion.for( 'downcast' ).elementToElement( { model: 'fooBlock', view: 'fooblock' } );
 
 				setModelData(
 					model,
@@ -416,8 +415,8 @@ describe( 'BlockQuoteCommand', () => {
 				model.schema.extend( 'fooWrapper', { allowIn: '$root' } );
 				model.schema.extend( 'fooBlock', { allowIn: 'fooWrapper' } );
 
-				editor.conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'fooWrapper', view: 'foowrapper' } ) );
-				editor.conversion.for( 'downcast' ).add( downcastElementToElement( { model: 'fooBlock', view: 'fooblock' } ) );
+				editor.conversion.for( 'downcast' ).elementToElement( { model: 'fooWrapper', view: 'foowrapper' } );
+				editor.conversion.for( 'downcast' ).elementToElement( { model: 'fooBlock', view: 'fooblock' } );
 
 				setModelData(
 					model,

+ 50 - 1
packages/ckeditor5-block-quote/tests/integration.js

@@ -13,6 +13,7 @@ import List from '@ckeditor/ckeditor5-list/src/list';
 import Enter from '@ckeditor/ckeditor5-enter/src/enter';
 import Delete from '@ckeditor/ckeditor5-typing/src/delete';
 import Heading from '@ckeditor/ckeditor5-heading/src/heading';
+import Table from '@ckeditor/ckeditor5-table/src/table';
 
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
 import {
@@ -30,7 +31,7 @@ describe( 'BlockQuote integration', () => {
 
 		return ClassicTestEditor
 			.create( element, {
-				plugins: [ BlockQuote, Paragraph, Image, ImageCaption, List, Enter, Delete, Heading ]
+				plugins: [ BlockQuote, Paragraph, Image, ImageCaption, List, Enter, Delete, Heading, Table ]
 			} )
 			.then( newEditor => {
 				editor = newEditor;
@@ -418,4 +419,52 @@ describe( 'BlockQuote integration', () => {
 			);
 		} );
 	} );
+
+	describe( 'compatibility with tables', () => {
+		it( 'wraps whole table', () => {
+			setModelData( model, '[<table><tableRow><tableCell><paragraph>foo</paragraph></tableCell></tableRow></table>]' );
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'<blockQuote>[<table><tableRow><tableCell><paragraph>foo</paragraph></tableCell></tableRow></table>]</blockQuote>'
+			);
+		} );
+
+		it( 'unwraps whole table', () => {
+			setModelData(
+				model,
+				'<blockQuote>[<table><tableRow><tableCell><paragraph>foo</paragraph></tableCell></tableRow></table>]</blockQuote>'
+			);
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'[<table><tableRow><tableCell><paragraph>foo</paragraph></tableCell></tableRow></table>]'
+			);
+		} );
+
+		it( 'wraps table cell paragraph', () => {
+			setModelData( model, '<table><tableRow><tableCell><paragraph>[]foo</paragraph></tableCell></tableRow></table>' );
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'<table><tableRow><tableCell><blockQuote><paragraph>[]foo</paragraph></blockQuote></tableCell></tableRow></table>'
+			);
+		} );
+
+		it( 'unwraps table cell paragraph', () => {
+			setModelData(
+				model,
+				'<table><tableRow><tableCell><blockQuote><paragraph>[]foo</paragraph></blockQuote></tableCell></tableRow></table>'
+			);
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'<table><tableRow><tableCell><paragraph>[]foo</paragraph></tableCell></tableRow></table>'
+			);
+		} );
+	} );
 } );