blockquotecommand.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import BlockQuoteEditing from '../src/blockquoteediting';
  6. import BlockQuoteCommand from '../src/blockquotecommand';
  7. import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
  8. import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  9. import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
  10. import Command from '@ckeditor/ckeditor5-core/src/command';
  11. describe( 'BlockQuoteCommand', () => {
  12. let editor, model, command;
  13. beforeEach( () => {
  14. return VirtualTestEditor
  15. .create( {
  16. plugins: [ BlockQuoteEditing ]
  17. } )
  18. .then( newEditor => {
  19. editor = newEditor;
  20. model = editor.model;
  21. model.schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  22. model.schema.register( 'heading', { inheritAllFrom: '$block' } );
  23. model.schema.register( 'widget' );
  24. model.schema.extend( 'widget', {
  25. allowIn: '$root',
  26. isLimit: true,
  27. isObject: true
  28. } );
  29. model.schema.extend( '$text', { allowIn: 'widget' } );
  30. editor.conversion.for( 'downcast' ).elementToElement( { model: 'paragraph', view: 'p' } );
  31. editor.conversion.for( 'downcast' ).elementToElement( { model: 'heading', view: 'h' } );
  32. editor.conversion.for( 'downcast' ).elementToElement( { model: 'widget', view: 'widget' } );
  33. command = editor.commands.get( 'blockQuote' );
  34. } );
  35. } );
  36. afterEach( () => {
  37. editor.destroy();
  38. } );
  39. it( 'is a command', () => {
  40. expect( BlockQuoteCommand.prototype ).to.be.instanceOf( Command );
  41. expect( command ).to.be.instanceOf( Command );
  42. } );
  43. describe( 'value', () => {
  44. it( 'is false when selection is not in a block quote', () => {
  45. setModelData( model, '<paragraph>x[]x</paragraph>' );
  46. expect( command ).to.have.property( 'value', false );
  47. } );
  48. it( 'is false when start of the selection is not in a block quote', () => {
  49. setModelData( model, '<paragraph>x[x</paragraph><blockQuote><paragraph>y]y</paragraph></blockQuote>' );
  50. expect( command ).to.have.property( 'value', false );
  51. } );
  52. it( 'is false when selection starts in a blockless space', () => {
  53. model.schema.extend( '$text', { allowIn: '$root' } );
  54. setModelData( model, 'x[]x' );
  55. expect( command ).to.have.property( 'value', false );
  56. } );
  57. it( 'is true when selection is in a block quote', () => {
  58. setModelData( model, '<blockQuote><paragraph>x[]x</paragraph></blockQuote>' );
  59. expect( command ).to.have.property( 'value', true );
  60. } );
  61. it( 'is true when selection starts in a block quote', () => {
  62. setModelData( model, '<blockQuote><paragraph>x[x</paragraph></blockQuote><paragraph>y]y</paragraph>' );
  63. expect( command ).to.have.property( 'value', true );
  64. } );
  65. } );
  66. describe( 'isEnabled', () => {
  67. it( 'is true when selection is in a block which can be wrapped with blockQuote', () => {
  68. setModelData( model, '<paragraph>x[]x</paragraph>' );
  69. expect( command ).to.have.property( 'isEnabled', true );
  70. } );
  71. it( 'is true when selection is in a block which is already in blockQuote', () => {
  72. setModelData( model, '<blockQuote><paragraph>x[]x</paragraph></blockQuote>' );
  73. expect( command ).to.have.property( 'isEnabled', true );
  74. } );
  75. it( 'is true when selection starts in a block which can be wrapped with blockQuote', () => {
  76. setModelData( model, '<paragraph>x[x</paragraph><widget>y]y</widget>' );
  77. expect( command ).to.have.property( 'isEnabled', true );
  78. } );
  79. it( 'is false when selection is in an element which cannot be wrapped with blockQuote (because it cannot be its child)', () => {
  80. setModelData( model, '<widget>x[]x</widget>' );
  81. expect( command ).to.have.property( 'isEnabled', false );
  82. } );
  83. it(
  84. 'is false when selection is in an element which cannot be wrapped with blockQuote' +
  85. '(because mQ is not allowed in its parent)',
  86. () => {
  87. model.schema.addChildCheck( ( ctx, childDef ) => {
  88. if ( childDef.name == 'blockQuote' ) {
  89. return false;
  90. }
  91. } );
  92. setModelData( model, '<paragraph>x[]x</paragraph>' );
  93. expect( command ).to.have.property( 'isEnabled', false );
  94. }
  95. );
  96. // https://github.com/ckeditor/ckeditor5-engine/issues/826
  97. // it( 'is false when selection starts in an element which cannot be wrapped with blockQuote', () => {
  98. // setModelData( model, '<widget>x[x</widget><paragraph>y]y</paragraph>' );
  99. // expect( command ).to.have.property( 'isEnabled', false );
  100. // } );
  101. } );
  102. describe( 'execute()', () => {
  103. describe( 'applying quote', () => {
  104. it( 'should wrap a single block', () => {
  105. setModelData(
  106. model,
  107. '<paragraph>abc</paragraph>' +
  108. '<paragraph>x[]x</paragraph>' +
  109. '<paragraph>def</paragraph>'
  110. );
  111. editor.execute( 'blockQuote' );
  112. expect( getModelData( model ) ).to.equal(
  113. '<paragraph>abc</paragraph>' +
  114. '<blockQuote><paragraph>x[]x</paragraph></blockQuote>' +
  115. '<paragraph>def</paragraph>'
  116. );
  117. expect( getViewData( editor.editing.view ) ).to.equal(
  118. '<p>abc</p><blockquote><p>x{}x</p></blockquote><p>def</p>'
  119. );
  120. } );
  121. it( 'should wrap multiple blocks', () => {
  122. setModelData(
  123. model,
  124. '<heading>a[bc</heading>' +
  125. '<paragraph>xx</paragraph>' +
  126. '<paragraph>de]f</paragraph>'
  127. );
  128. editor.execute( 'blockQuote' );
  129. expect( getModelData( model ) ).to.equal(
  130. '<blockQuote>' +
  131. '<heading>a[bc</heading>' +
  132. '<paragraph>xx</paragraph>' +
  133. '<paragraph>de]f</paragraph>' +
  134. '</blockQuote>'
  135. );
  136. expect( getViewData( editor.editing.view ) ).to.equal(
  137. '<blockquote><h>a{bc</h><p>xx</p><p>de}f</p></blockquote>'
  138. );
  139. } );
  140. it( 'should merge with an existing quote', () => {
  141. setModelData(
  142. model,
  143. '<heading>a[bc</heading>' +
  144. '<blockQuote><paragraph>x]x</paragraph><paragraph>yy</paragraph></blockQuote>' +
  145. '<paragraph>def</paragraph>'
  146. );
  147. editor.execute( 'blockQuote' );
  148. // Selection incorrectly trimmed.
  149. expect( getModelData( model ) ).to.equal(
  150. '<blockQuote>' +
  151. '<heading>abc</heading>' +
  152. '<paragraph>[x]x</paragraph>' +
  153. '<paragraph>yy</paragraph>' +
  154. '</blockQuote>' +
  155. '<paragraph>def</paragraph>'
  156. );
  157. // Selection incorrectly trimmed.
  158. expect( getViewData( editor.editing.view ) ).to.equal(
  159. '<blockquote><h>abc</h><p>{x}x</p><p>yy</p></blockquote><p>def</p>'
  160. );
  161. } );
  162. it( 'should not merge with a quote preceding the current block', () => {
  163. setModelData(
  164. model,
  165. '<blockQuote><paragraph>abc</paragraph></blockQuote>' +
  166. '<paragraph>x[]x</paragraph>'
  167. );
  168. editor.execute( 'blockQuote' );
  169. expect( getModelData( model ) ).to.equal(
  170. '<blockQuote><paragraph>abc</paragraph></blockQuote>' +
  171. '<blockQuote><paragraph>x[]x</paragraph></blockQuote>'
  172. );
  173. expect( getViewData( editor.editing.view ) ).to.equal(
  174. '<blockquote><p>abc</p></blockquote>' +
  175. '<blockquote><p>x{}x</p></blockquote>'
  176. );
  177. } );
  178. it( 'should not merge with a quote following the current block', () => {
  179. setModelData(
  180. model,
  181. '<paragraph>x[]x</paragraph>' +
  182. '<blockQuote><paragraph>abc</paragraph></blockQuote>'
  183. );
  184. editor.execute( 'blockQuote' );
  185. expect( getModelData( model ) ).to.equal(
  186. '<blockQuote><paragraph>x[]x</paragraph></blockQuote>' +
  187. '<blockQuote><paragraph>abc</paragraph></blockQuote>'
  188. );
  189. expect( getViewData( editor.editing.view ) ).to.equal(
  190. '<blockquote><p>x{}x</p></blockquote>' +
  191. '<blockquote><p>abc</p></blockquote>'
  192. );
  193. } );
  194. it( 'should merge with an existing quote (more blocks)', () => {
  195. setModelData(
  196. model,
  197. '<heading>a[bc</heading>' +
  198. '<paragraph>def</paragraph>' +
  199. '<blockQuote><paragraph>x]x</paragraph></blockQuote>' +
  200. '<paragraph>ghi</paragraph>'
  201. );
  202. editor.execute( 'blockQuote' );
  203. // Selection incorrectly trimmed.
  204. expect( getModelData( model ) ).to.equal(
  205. '<blockQuote>' +
  206. '<heading>abc</heading>' +
  207. '<paragraph>def</paragraph>' +
  208. '<paragraph>[x]x</paragraph>' +
  209. '</blockQuote>' +
  210. '<paragraph>ghi</paragraph>'
  211. );
  212. // Selection incorrectly trimmed.
  213. expect( getViewData( editor.editing.view ) ).to.equal(
  214. '<blockquote><h>abc</h><p>def</p><p>{x}x</p></blockquote><p>ghi</p>'
  215. );
  216. } );
  217. it( 'should not wrap non-block content', () => {
  218. setModelData(
  219. model,
  220. '<paragraph>a[bc</paragraph>' +
  221. '<widget>xx</widget>' +
  222. '<paragraph>de]f</paragraph>'
  223. );
  224. editor.execute( 'blockQuote' );
  225. // Selection incorrectly trimmed.
  226. expect( getModelData( model ) ).to.equal(
  227. '<blockQuote>' +
  228. '<paragraph>abc</paragraph>' +
  229. '</blockQuote>' +
  230. '[<widget>xx</widget>' +
  231. '<blockQuote>' +
  232. '<paragraph>de]f</paragraph>' +
  233. '</blockQuote>'
  234. );
  235. // Selection incorrectly trimmed.
  236. expect( getViewData( editor.editing.view ) ).to.equal(
  237. '<blockquote><p>abc</p></blockquote>[<widget>xx</widget><blockquote><p>de}f</p></blockquote>'
  238. );
  239. } );
  240. it( 'should correctly wrap and merge groups of blocks', () => {
  241. setModelData(
  242. model,
  243. '<paragraph>a[bc</paragraph>' +
  244. '<widget>xx</widget>' +
  245. '<paragraph>def</paragraph>' +
  246. '<blockQuote><paragraph>ghi</paragraph></blockQuote>' +
  247. '<widget>yy</widget>' +
  248. '<paragraph>jk]l</paragraph>'
  249. );
  250. editor.execute( 'blockQuote' );
  251. // Selection incorrectly trimmed.
  252. expect( getModelData( model ) ).to.equal(
  253. '<blockQuote><paragraph>abc</paragraph></blockQuote>' +
  254. '[<widget>xx</widget>' +
  255. '<blockQuote><paragraph>def</paragraph><paragraph>ghi</paragraph></blockQuote>' +
  256. '<widget>yy</widget>' +
  257. '<blockQuote><paragraph>jk]l</paragraph></blockQuote>'
  258. );
  259. // Selection incorrectly trimmed.
  260. expect( getViewData( editor.editing.view ) ).to.equal(
  261. '<blockquote><p>abc</p></blockquote>' +
  262. '[<widget>xx</widget>' +
  263. '<blockquote><p>def</p><p>ghi</p></blockquote>' +
  264. '<widget>yy</widget>' +
  265. '<blockquote><p>jk}l</p></blockquote>'
  266. );
  267. } );
  268. it( 'should correctly merge a couple of subsequent quotes', () => {
  269. setModelData(
  270. model,
  271. '<paragraph>x</paragraph>' +
  272. '<paragraph>a[bc</paragraph>' +
  273. '<blockQuote><paragraph>def</paragraph></blockQuote>' +
  274. '<paragraph>ghi</paragraph>' +
  275. '<blockQuote><paragraph>jkl</paragraph></blockQuote>' +
  276. '<paragraph>mn]o</paragraph>' +
  277. '<paragraph>y</paragraph>'
  278. );
  279. editor.execute( 'blockQuote' );
  280. // Selection incorrectly trimmed.
  281. expect( getModelData( model ) ).to.equal(
  282. '<paragraph>x</paragraph>' +
  283. '<blockQuote>' +
  284. '<paragraph>abc</paragraph>' +
  285. '<paragraph>def</paragraph>' +
  286. '<paragraph>ghi</paragraph>' +
  287. '<paragraph>jkl</paragraph>' +
  288. '<paragraph>[mn]o</paragraph>' +
  289. '</blockQuote>' +
  290. '<paragraph>y</paragraph>'
  291. );
  292. // Selection incorrectly trimmed.
  293. expect( getViewData( editor.editing.view ) ).to.equal(
  294. '<p>x</p>' +
  295. '<blockquote>' +
  296. '<p>abc</p>' +
  297. '<p>def</p>' +
  298. '<p>ghi</p>' +
  299. '<p>jkl</p>' +
  300. '<p>{mn}o</p>' +
  301. '</blockquote>' +
  302. '<p>y</p>'
  303. );
  304. } );
  305. it( 'should not wrap a block which can not be in a quote', () => {
  306. // blockQuote is allowed in root, but fooBlock can not be inside blockQuote.
  307. model.schema.register( 'fooBlock', { inheritAllFrom: '$block' } );
  308. model.schema.addChildCheck( ( ctx, childDef ) => {
  309. if ( ctx.endsWith( 'blockQuote' ) && childDef.name == 'fooBlock' ) {
  310. return false;
  311. }
  312. } );
  313. editor.conversion.for( 'downcast' ).elementToElement( { model: 'fooBlock', view: 'fooblock' } );
  314. setModelData(
  315. model,
  316. '<paragraph>a[bc</paragraph>' +
  317. '<fooBlock>xx</fooBlock>' +
  318. '<paragraph>de]f</paragraph>'
  319. );
  320. editor.execute( 'blockQuote' );
  321. // Selection incorrectly trimmed.
  322. expect( getModelData( model ) ).to.equal(
  323. '<blockQuote>' +
  324. '<paragraph>abc</paragraph>' +
  325. '</blockQuote>' +
  326. '<fooBlock>[xx</fooBlock>' +
  327. '<blockQuote>' +
  328. '<paragraph>de]f</paragraph>' +
  329. '</blockQuote>'
  330. );
  331. } );
  332. it( 'should not wrap a block which parent does not allow quote inside itself', () => {
  333. // blockQuote is not be allowed in fooWrapper, but fooBlock can be inside blockQuote.
  334. model.schema.register( 'fooWrapper' );
  335. model.schema.register( 'fooBlock', { inheritAllFrom: '$block' } );
  336. model.schema.extend( 'fooWrapper', { allowIn: '$root' } );
  337. model.schema.extend( 'fooBlock', { allowIn: 'fooWrapper' } );
  338. editor.conversion.for( 'downcast' ).elementToElement( { model: 'fooWrapper', view: 'foowrapper' } );
  339. editor.conversion.for( 'downcast' ).elementToElement( { model: 'fooBlock', view: 'fooblock' } );
  340. setModelData(
  341. model,
  342. '<paragraph>a[bc</paragraph>' +
  343. '<fooWrapper><fooBlock>xx</fooBlock></fooWrapper>' +
  344. '<paragraph>de]f</paragraph>'
  345. );
  346. editor.execute( 'blockQuote' );
  347. // Selection incorrectly trimmed.
  348. expect( getModelData( model ) ).to.equal(
  349. '<blockQuote>' +
  350. '<paragraph>abc</paragraph>' +
  351. '</blockQuote>' +
  352. '<fooWrapper><fooBlock>[xx</fooBlock></fooWrapper>' +
  353. '<blockQuote>' +
  354. '<paragraph>de]f</paragraph>' +
  355. '</blockQuote>'
  356. );
  357. } );
  358. it( 'should handle forceValue = true param', () => {
  359. setModelData(
  360. model,
  361. '<blockQuote>' +
  362. '<paragraph>x[x</paragraph>' +
  363. '</blockQuote>' +
  364. '<paragraph>d]ef</paragraph>'
  365. );
  366. editor.execute( 'blockQuote', { forceValue: true } );
  367. expect( getModelData( model ) ).to.equal(
  368. '<blockQuote>' +
  369. '<paragraph>x[x</paragraph>' +
  370. '<paragraph>d]ef</paragraph>' +
  371. '</blockQuote>'
  372. );
  373. expect( getViewData( editor.editing.view ) ).to.equal(
  374. '<blockquote><p>x{x</p><p>d}ef</p></blockquote>'
  375. );
  376. } );
  377. } );
  378. describe( 'removing quote', () => {
  379. it( 'should unwrap a single block', () => {
  380. setModelData(
  381. model,
  382. '<paragraph>abc</paragraph>' +
  383. '<blockQuote><paragraph>x[]x</paragraph></blockQuote>' +
  384. '<paragraph>def</paragraph>'
  385. );
  386. editor.execute( 'blockQuote' );
  387. expect( getModelData( model ) ).to.equal(
  388. '<paragraph>abc</paragraph>' +
  389. '<paragraph>x[]x</paragraph>' +
  390. '<paragraph>def</paragraph>'
  391. );
  392. expect( getViewData( editor.editing.view ) ).to.equal(
  393. '<p>abc</p><p>x{}x</p><p>def</p>'
  394. );
  395. } );
  396. it( 'should unwrap multiple blocks', () => {
  397. setModelData(
  398. model,
  399. '<blockQuote>' +
  400. '<paragraph>a[bc</paragraph>' +
  401. '<paragraph>xx</paragraph>' +
  402. '<paragraph>de]f</paragraph>' +
  403. '</blockQuote>'
  404. );
  405. editor.execute( 'blockQuote' );
  406. expect( getModelData( model ) ).to.equal(
  407. '<paragraph>a[bc</paragraph>' +
  408. '<paragraph>xx</paragraph>' +
  409. '<paragraph>de]f</paragraph>'
  410. );
  411. expect( getViewData( editor.editing.view ) ).to.equal(
  412. '<p>a{bc</p><p>xx</p><p>de}f</p>'
  413. );
  414. } );
  415. it( 'should unwrap only the selected blocks - at the beginning', () => {
  416. setModelData(
  417. model,
  418. '<paragraph>xx</paragraph>' +
  419. '<blockQuote>' +
  420. '<paragraph>a[b]c</paragraph>' +
  421. '<paragraph>xx</paragraph>' +
  422. '</blockQuote>' +
  423. '<paragraph>yy</paragraph>'
  424. );
  425. editor.execute( 'blockQuote' );
  426. expect( getModelData( model ) ).to.equal(
  427. '<paragraph>xx</paragraph>' +
  428. '<paragraph>a[b]c</paragraph>' +
  429. '<blockQuote>' +
  430. '<paragraph>xx</paragraph>' +
  431. '</blockQuote>' +
  432. '<paragraph>yy</paragraph>'
  433. );
  434. expect( getViewData( editor.editing.view ) ).to.equal(
  435. '<p>xx</p><p>a{b}c</p><blockquote><p>xx</p></blockquote><p>yy</p>'
  436. );
  437. } );
  438. it( 'should unwrap only the selected blocks - at the end', () => {
  439. setModelData(
  440. model,
  441. '<blockQuote>' +
  442. '<paragraph>abc</paragraph>' +
  443. '<paragraph>x[x</paragraph>' +
  444. '</blockQuote>' +
  445. '<paragraph>de]f</paragraph>'
  446. );
  447. editor.execute( 'blockQuote' );
  448. expect( getModelData( model ) ).to.equal(
  449. '<blockQuote>' +
  450. '<paragraph>abc</paragraph>' +
  451. '</blockQuote>' +
  452. '<paragraph>x[x</paragraph>' +
  453. '<paragraph>de]f</paragraph>'
  454. );
  455. expect( getViewData( editor.editing.view ) ).to.equal(
  456. '<blockquote><p>abc</p></blockquote><p>x{x</p><p>de}f</p>'
  457. );
  458. } );
  459. it( 'should unwrap only the selected blocks - in the middle', () => {
  460. setModelData(
  461. model,
  462. '<paragraph>xx</paragraph>' +
  463. '<blockQuote>' +
  464. '<paragraph>abc</paragraph>' +
  465. '<paragraph>c[]de</paragraph>' +
  466. '<paragraph>fgh</paragraph>' +
  467. '</blockQuote>' +
  468. '<paragraph>xx</paragraph>'
  469. );
  470. editor.execute( 'blockQuote' );
  471. expect( getModelData( model ) ).to.equal(
  472. '<paragraph>xx</paragraph>' +
  473. '<blockQuote><paragraph>abc</paragraph></blockQuote>' +
  474. '<paragraph>c[]de</paragraph>' +
  475. '<blockQuote><paragraph>fgh</paragraph></blockQuote>' +
  476. '<paragraph>xx</paragraph>'
  477. );
  478. expect( getViewData( editor.editing.view ) ).to.equal(
  479. '<p>xx</p>' +
  480. '<blockquote><p>abc</p></blockquote>' +
  481. '<p>c{}de</p>' +
  482. '<blockquote><p>fgh</p></blockquote>' +
  483. '<p>xx</p>'
  484. );
  485. } );
  486. it( 'should remove multiple quotes', () => {
  487. setModelData(
  488. model,
  489. '<blockQuote><paragraph>a[bc</paragraph></blockQuote>' +
  490. '<paragraph>xx</paragraph>' +
  491. '<blockQuote><paragraph>def</paragraph><paragraph>ghi</paragraph></blockQuote>' +
  492. '<paragraph>yy</paragraph>' +
  493. '<blockQuote><paragraph>de]f</paragraph><paragraph>ghi</paragraph></blockQuote>'
  494. );
  495. editor.execute( 'blockQuote' );
  496. expect( getModelData( model ) ).to.equal(
  497. '<paragraph>a[bc</paragraph>' +
  498. '<paragraph>xx</paragraph>' +
  499. '<paragraph>def</paragraph><paragraph>ghi</paragraph>' +
  500. '<paragraph>yy</paragraph>' +
  501. '<paragraph>de]f</paragraph>' +
  502. '<blockQuote><paragraph>ghi</paragraph></blockQuote>'
  503. );
  504. expect( getViewData( editor.editing.view ) ).to.equal(
  505. '<p>a{bc</p>' +
  506. '<p>xx</p>' +
  507. '<p>def</p><p>ghi</p>' +
  508. '<p>yy</p>' +
  509. '<p>de}f</p>' +
  510. '<blockquote><p>ghi</p></blockquote>'
  511. );
  512. } );
  513. it( 'should handle forceValue = false param', () => {
  514. setModelData(
  515. model,
  516. '<paragraph>a[bc</paragraph>' +
  517. '<blockQuote>' +
  518. '<paragraph>x]x</paragraph>' +
  519. '</blockQuote>'
  520. );
  521. editor.execute( 'blockQuote', { forceValue: false } );
  522. // Incorrect selection.
  523. expect( getModelData( model ) ).to.equal(
  524. '<paragraph>a[bc]</paragraph>' +
  525. '<paragraph>xx</paragraph>'
  526. );
  527. expect( getViewData( editor.editing.view ) ).to.equal(
  528. '<p>a{bc}</p><p>xx</p>'
  529. );
  530. } );
  531. } );
  532. } );
  533. } );