|
@@ -40,15 +40,17 @@ export default class BlockQuoteCommand extends Command {
|
|
|
*
|
|
*
|
|
|
* @fires execute
|
|
* @fires execute
|
|
|
*/
|
|
*/
|
|
|
- execute() {
|
|
|
|
|
|
|
+ execute( options = {} ) {
|
|
|
const model = this.editor.model;
|
|
const model = this.editor.model;
|
|
|
const schema = model.schema;
|
|
const schema = model.schema;
|
|
|
const selection = model.document.selection;
|
|
const selection = model.document.selection;
|
|
|
|
|
|
|
|
const blocks = Array.from( selection.getTopMostBlocks() );
|
|
const blocks = Array.from( selection.getTopMostBlocks() );
|
|
|
|
|
|
|
|
|
|
+ const value = ( options.forceValue === undefined ) ? !this.value : options.forceValue;
|
|
|
|
|
+
|
|
|
model.change( writer => {
|
|
model.change( writer => {
|
|
|
- if ( this.value ) {
|
|
|
|
|
|
|
+ if ( !value ) {
|
|
|
this._removeQuote( writer, blocks.filter( findQuote ) );
|
|
this._removeQuote( writer, blocks.filter( findQuote ) );
|
|
|
} else {
|
|
} else {
|
|
|
const blocksToQuote = blocks.filter( block => {
|
|
const blocksToQuote = blocks.filter( block => {
|
|
@@ -189,7 +191,7 @@ function findQuote( elementOrPosition ) {
|
|
|
// Returns a minimal array of ranges containing groups of subsequent blocks.
|
|
// Returns a minimal array of ranges containing groups of subsequent blocks.
|
|
|
//
|
|
//
|
|
|
// content: abcdefgh
|
|
// content: abcdefgh
|
|
|
-// blocks: [ a, b, d , f, g, h ]
|
|
|
|
|
|
|
+// blocks: [ a, b, d, f, g, h ]
|
|
|
// output ranges: [ab]c[d]e[fgh]
|
|
// output ranges: [ab]c[d]e[fgh]
|
|
|
//
|
|
//
|
|
|
// @param {Array.<module:engine/model/element~Element>} blocks
|
|
// @param {Array.<module:engine/model/element~Element>} blocks
|