diff --git a/package.json b/package.json
index 00156f1..1f3b418 100644
--- a/package.json
+++ b/package.json
@@ -24,6 +24,7 @@
"@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.9",
diff --git a/src/blockquotecommand.js b/src/blockquotecommand.js
index fff494b..f1a6c93 100644
--- a/src/blockquotecommand.js
+++ b/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 ) );
diff --git a/tests/integration.js b/tests/integration.js
index a9a78ff..6bb78e4 100644
--- a/tests/integration.js
+++ b/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, '[
]' );
+
+ editor.execute( 'blockQuote' );
+
+ expect( getModelData( model ) ).to.equal(
+ '[]
'
+ );
+ } );
+
+ it( 'unwraps whole table', () => {
+ setModelData(
+ model,
+ '[]
'
+ );
+
+ editor.execute( 'blockQuote' );
+
+ expect( getModelData( model ) ).to.equal(
+ '[]'
+ );
+ } );
+
+ it( 'wraps table cell paragraph', () => {
+ setModelData( model, '' );
+
+ editor.execute( 'blockQuote' );
+
+ expect( getModelData( model ) ).to.equal(
+ ''
+ );
+ } );
+
+ it( 'unwraps table cell paragraph', () => {
+ setModelData(
+ model,
+ ''
+ );
+
+ editor.execute( 'blockQuote' );
+
+ expect( getModelData( model ) ).to.equal(
+ ''
+ );
+ } );
+ } );
} );