mergecellcommand.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor';
  6. import { getData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  7. import { upcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversion/upcast-converters';
  8. import MergeCellCommand from '../../src/commands/mergecellcommand';
  9. import {
  10. downcastInsertCell,
  11. downcastInsertRow,
  12. downcastInsertTable,
  13. downcastRemoveRow,
  14. downcastTableHeadingColumnsChange,
  15. downcastTableHeadingRowsChange
  16. } from '../../src/converters/downcast';
  17. import upcastTable from '../../src/converters/upcasttable';
  18. import { formatTable, formattedModelTable, modelTable } from '../_utils/utils';
  19. import TableUtils from '../../src/tableutils';
  20. describe( 'MergeCellCommand', () => {
  21. let editor, model, command, root;
  22. beforeEach( () => {
  23. return ModelTestEditor
  24. .create( {
  25. plugins: [ TableUtils ]
  26. } )
  27. .then( newEditor => {
  28. editor = newEditor;
  29. model = editor.model;
  30. root = model.document.getRoot( 'main' );
  31. const conversion = editor.conversion;
  32. const schema = model.schema;
  33. schema.register( 'table', {
  34. allowWhere: '$block',
  35. allowAttributes: [ 'headingRows' ],
  36. isObject: true
  37. } );
  38. schema.register( 'tableRow', { allowIn: 'table' } );
  39. schema.register( 'tableCell', {
  40. allowIn: 'tableRow',
  41. allowContentOf: '$block',
  42. allowAttributes: [ 'colspan', 'rowspan' ],
  43. isLimit: true
  44. } );
  45. schema.extend( '$block', { allowIn: 'tableCell' } );
  46. model.schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  47. // Table conversion.
  48. conversion.for( 'upcast' ).add( upcastTable() );
  49. conversion.for( 'downcast' ).add( downcastInsertTable() );
  50. // Insert row conversion.
  51. conversion.for( 'downcast' ).add( downcastInsertRow() );
  52. // Remove row conversion.
  53. conversion.for( 'downcast' ).add( downcastRemoveRow() );
  54. // Table cell conversion.
  55. conversion.for( 'downcast' ).add( downcastInsertCell() );
  56. conversion.for( 'upcast' ).add( upcastElementToElement( { model: 'tableCell', view: 'td' } ) );
  57. conversion.for( 'upcast' ).add( upcastElementToElement( { model: 'tableCell', view: 'th' } ) );
  58. // Table attributes conversion.
  59. conversion.attributeToAttribute( { model: 'colspan', view: 'colspan' } );
  60. conversion.attributeToAttribute( { model: 'rowspan', view: 'rowspan' } );
  61. conversion.for( 'downcast' ).add( downcastTableHeadingColumnsChange() );
  62. conversion.for( 'downcast' ).add( downcastTableHeadingRowsChange() );
  63. } );
  64. } );
  65. afterEach( () => {
  66. return editor.destroy();
  67. } );
  68. describe( 'direction=right', () => {
  69. beforeEach( () => {
  70. command = new MergeCellCommand( editor, { direction: 'right' } );
  71. } );
  72. describe( 'isEnabled', () => {
  73. it( 'should be true if in cell that has sibling on the right', () => {
  74. setData( model, modelTable( [
  75. [ '00[]', '01' ]
  76. ] ) );
  77. expect( command.isEnabled ).to.be.true;
  78. } );
  79. it( 'should be false if last cell of a row', () => {
  80. setData( model, modelTable( [
  81. [ '00', '01[]' ]
  82. ] ) );
  83. expect( command.isEnabled ).to.be.false;
  84. } );
  85. it( 'should be true if in a cell that has sibling on the right with the same rowspan', () => {
  86. setData( model, modelTable( [
  87. [ { rowspan: 2, contents: '00[]' }, { rowspan: 2, contents: '01' } ]
  88. ] ) );
  89. expect( command.isEnabled ).to.be.true;
  90. } );
  91. it( 'should be false if in a cell that has sibling but with different rowspan', () => {
  92. setData( model, modelTable( [
  93. [ { rowspan: 2, contents: '00[]' }, { rowspan: 3, contents: '01' } ]
  94. ] ) );
  95. expect( command.isEnabled ).to.be.false;
  96. } );
  97. it( 'should be false when next cell is rowspanned', () => {
  98. setData( model, modelTable( [
  99. [ '00', { rowspan: 3, contents: '01' }, '02' ],
  100. [ '10[]', '12' ],
  101. [ '20', '22' ]
  102. ] ) );
  103. expect( command.isEnabled ).to.be.false;
  104. } );
  105. it( 'should be true when current cell is colspanned', () => {
  106. setData( model, modelTable( [
  107. [ { colspan: 2, contents: '00[]' }, '02' ]
  108. ] ) );
  109. expect( command.isEnabled ).to.be.true;
  110. } );
  111. it( 'should be false if not in a cell', () => {
  112. setData( model, '<paragraph>11[]</paragraph>' );
  113. expect( command.isEnabled ).to.be.false;
  114. } );
  115. } );
  116. describe( 'value', () => {
  117. it( 'should be set to mergeable sibling if in cell that has sibling on the right', () => {
  118. setData( model, modelTable( [
  119. [ '00[]', '01' ]
  120. ] ) );
  121. expect( command.value ).to.equal( root.getNodeByPath( [ 0, 0, 1 ] ) );
  122. } );
  123. it( 'should be set to mergeable sibling if in cell that has sibling on the right (selection in block content)', () => {
  124. setData( model, modelTable( [
  125. [ '00', '<paragraph>[]01</paragraph>', '02' ]
  126. ] ) );
  127. expect( command.value ).to.equal( root.getNodeByPath( [ 0, 0, 2 ] ) );
  128. } );
  129. it( 'should be undefined if last cell of a row', () => {
  130. setData( model, modelTable( [
  131. [ '00', '01[]' ]
  132. ] ) );
  133. expect( command.value ).to.be.undefined;
  134. } );
  135. it( 'should be set to mergeable sibling if in a cell that has sibling on the right with the same rowspan', () => {
  136. setData( model, modelTable( [
  137. [ { rowspan: 2, contents: '00[]' }, { rowspan: 2, contents: '01' } ]
  138. ] ) );
  139. expect( command.value ).to.equal( root.getNodeByPath( [ 0, 0, 1 ] ) );
  140. } );
  141. it( 'should be undefined if in a cell that has sibling but with different rowspan', () => {
  142. setData( model, modelTable( [
  143. [ { rowspan: 2, contents: '00[]' }, { rowspan: 3, contents: '01' } ]
  144. ] ) );
  145. expect( command.value ).to.be.undefined;
  146. } );
  147. it( 'should be undefined if not in a cell', () => {
  148. setData( model, '<paragraph>11[]</paragraph>' );
  149. expect( command.value ).to.be.undefined;
  150. } );
  151. } );
  152. describe( 'execute()', () => {
  153. it( 'should merge table cells', () => {
  154. setData( model, modelTable( [
  155. [ '[]00', '01' ]
  156. ] ) );
  157. command.execute();
  158. expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
  159. [ { colspan: 2, contents: '[0001]' } ]
  160. ] ) );
  161. } );
  162. } );
  163. } );
  164. describe( 'direction=left', () => {
  165. beforeEach( () => {
  166. command = new MergeCellCommand( editor, { direction: 'left' } );
  167. } );
  168. describe( 'isEnabled', () => {
  169. it( 'should be true if in cell that has sibling on the left', () => {
  170. setData( model, modelTable( [
  171. [ '00', '01[]' ]
  172. ] ) );
  173. expect( command.isEnabled ).to.be.true;
  174. } );
  175. it( 'should be false if first cell of a row', () => {
  176. setData( model, modelTable( [
  177. [ '00[]', '01' ]
  178. ] ) );
  179. expect( command.isEnabled ).to.be.false;
  180. } );
  181. it( 'should be true if in a cell that has sibling on the left with the same rowspan', () => {
  182. setData( model, modelTable( [
  183. [ { rowspan: 2, contents: '00' }, { rowspan: 2, contents: '01[]' } ]
  184. ] ) );
  185. expect( command.isEnabled ).to.be.true;
  186. } );
  187. it( 'should be false if in a cell that has sibling but with different rowspan', () => {
  188. setData( model, modelTable( [
  189. [ { rowspan: 2, contents: '00' }, { rowspan: 3, contents: '01[]' } ]
  190. ] ) );
  191. expect( command.isEnabled ).to.be.false;
  192. } );
  193. it( 'should be false when next cell is rowspanned', () => {
  194. setData( model, modelTable( [
  195. [ '00', { rowspan: 3, contents: '01' }, '02' ],
  196. [ '10', '12[]' ],
  197. [ '20', '22' ]
  198. ] ) );
  199. expect( command.isEnabled ).to.be.false;
  200. } );
  201. it( 'should be true when mergeable cell is colspanned', () => {
  202. setData( model, modelTable( [
  203. [ { colspan: 2, contents: '00' }, '02[]' ]
  204. ] ) );
  205. expect( command.isEnabled ).to.be.true;
  206. } );
  207. it( 'should be false if not in a cell', () => {
  208. setData( model, '<paragraph>11[]</paragraph>' );
  209. expect( command.isEnabled ).to.be.false;
  210. } );
  211. } );
  212. describe( 'value', () => {
  213. it( 'should be set to mergeable sibling if in cell that has sibling on the left', () => {
  214. setData( model, modelTable( [
  215. [ '00', '01[]' ]
  216. ] ) );
  217. expect( command.value ).to.equal( root.getNodeByPath( [ 0, 0, 0 ] ) );
  218. } );
  219. it( 'should be set to mergeable sibling if in cell that has sibling on the left (selection in block content)', () => {
  220. setData( model, modelTable( [
  221. [ '00', '<paragraph>01[]</paragraph>', '02' ]
  222. ] ) );
  223. expect( command.value ).to.equal( root.getNodeByPath( [ 0, 0, 0 ] ) );
  224. } );
  225. it( 'should be undefined if first cell of a row', () => {
  226. setData( model, modelTable( [
  227. [ '00[]', '01' ]
  228. ] ) );
  229. expect( command.value ).to.be.undefined;
  230. } );
  231. it( 'should be set to mergeable sibling if in a cell that has sibling on the left with the same rowspan', () => {
  232. setData( model, modelTable( [
  233. [ { rowspan: 2, contents: '00' }, { rowspan: 2, contents: '01[]' } ]
  234. ] ) );
  235. expect( command.value ).to.equal( root.getNodeByPath( [ 0, 0, 0 ] ) );
  236. } );
  237. it( 'should be undefined if in a cell that has sibling but with different rowspan', () => {
  238. setData( model, modelTable( [
  239. [ { rowspan: 2, contents: '00' }, { rowspan: 3, contents: '01[]' } ]
  240. ] ) );
  241. expect( command.value ).to.be.undefined;
  242. } );
  243. it( 'should be undefined if not in a cell', () => {
  244. setData( model, '<paragraph>11[]</paragraph>' );
  245. expect( command.value ).to.be.undefined;
  246. } );
  247. } );
  248. describe( 'execute()', () => {
  249. it( 'should merge table cells', () => {
  250. setData( model, modelTable( [
  251. [ '00', '[]01' ]
  252. ] ) );
  253. command.execute();
  254. expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
  255. [ { colspan: 2, contents: '[0001]' } ]
  256. ] ) );
  257. } );
  258. } );
  259. } );
  260. describe( 'direction=down', () => {
  261. beforeEach( () => {
  262. command = new MergeCellCommand( editor, { direction: 'down' } );
  263. } );
  264. describe( 'isEnabled', () => {
  265. it( 'should be true if in cell that has mergeable cell in next row', () => {
  266. setData( model, modelTable( [
  267. [ '00', '01[]' ],
  268. [ '10', '11' ]
  269. ] ) );
  270. expect( command.isEnabled ).to.be.true;
  271. } );
  272. it( 'should be false if in last row', () => {
  273. setData( model, modelTable( [
  274. [ '00', '01' ],
  275. [ '10[]', '11' ]
  276. ] ) );
  277. expect( command.isEnabled ).to.be.false;
  278. } );
  279. it( 'should be true if in a cell that has mergeable cell with the same colspan', () => {
  280. setData( model, modelTable( [
  281. [ { colspan: 2, contents: '00[]' }, '02' ],
  282. [ { colspan: 2, contents: '01' }, '12' ]
  283. ] ) );
  284. expect( command.isEnabled ).to.be.true;
  285. } );
  286. it( 'should be false if in a cell that potential mergeable cell has different colspan', () => {
  287. setData( model, modelTable( [
  288. [ { colspan: 2, contents: '00[]' }, '02' ],
  289. [ { colspan: 3, contents: '01' } ]
  290. ] ) );
  291. expect( command.isEnabled ).to.be.false;
  292. } );
  293. it( 'should be false if not in a cell', () => {
  294. setData( model, '<paragraph>11[]</paragraph>' );
  295. expect( command.isEnabled ).to.be.false;
  296. } );
  297. it( 'should be false if mergeable cell is in other table section then current cell', () => {
  298. setData( model, modelTable( [
  299. [ '00[]', '01' ],
  300. [ '10', '11' ]
  301. ], { headingRows: 1 } ) );
  302. expect( command.isEnabled ).to.be.false;
  303. } );
  304. } );
  305. describe( 'value', () => {
  306. it( 'should be set to mergeable cell', () => {
  307. setData( model, modelTable( [
  308. [ '00', '01[]' ],
  309. [ '10', '11' ]
  310. ] ) );
  311. expect( command.value ).to.equal( root.getNodeByPath( [ 0, 1, 1 ] ) );
  312. } );
  313. it( 'should be set to mergeable cell (selection in block content)', () => {
  314. setData( model, modelTable( [
  315. [ '00' ],
  316. [ '<paragraph>10[]</paragraph>' ],
  317. [ '20' ]
  318. ] ) );
  319. expect( command.value ).to.equal( root.getNodeByPath( [ 0, 2, 0 ] ) );
  320. } );
  321. it( 'should be undefined if in last row', () => {
  322. setData( model, modelTable( [
  323. [ '00', '01' ],
  324. [ '10[]', '11' ]
  325. ] ) );
  326. expect( command.value ).to.be.undefined;
  327. } );
  328. it( 'should be set to mergeable cell with the same rowspan', () => {
  329. setData( model, modelTable( [
  330. [ { colspan: 2, contents: '00[]' }, '02' ],
  331. [ { colspan: 2, contents: '01' }, '12' ]
  332. ] ) );
  333. expect( command.value ).to.equal( root.getNodeByPath( [ 0, 1, 0 ] ) );
  334. } );
  335. it( 'should be undefined if in a cell that potential mergeable cell has different rowspan', () => {
  336. setData( model, modelTable( [
  337. [ { colspan: 2, contents: '00[]' }, '02' ],
  338. [ { colspan: 3, contents: '01' } ]
  339. ] ) );
  340. expect( command.value ).to.be.undefined;
  341. } );
  342. it( 'should be undefined if not in a cell', () => {
  343. setData( model, '<paragraph>11[]</paragraph>' );
  344. expect( command.value ).to.be.undefined;
  345. } );
  346. } );
  347. describe( 'execute()', () => {
  348. it( 'should merge table cells', () => {
  349. setData( model, modelTable( [
  350. [ '00', '01[]' ],
  351. [ '10', '11' ]
  352. ] ) );
  353. command.execute();
  354. expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
  355. [ '00', { rowspan: 2, contents: '[0111]' } ],
  356. [ '10' ]
  357. ] ) );
  358. } );
  359. it( 'should remove empty row if merging table cells ', () => {
  360. setData( model, modelTable( [
  361. [ { rowspan: 2, contents: '00' }, '01[]', { rowspan: 3, contents: '02' } ],
  362. [ '11' ],
  363. [ '20', '21' ]
  364. ] ) );
  365. command.execute();
  366. expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
  367. [ '00', '[0111]', { rowspan: 2, contents: '02' } ],
  368. [ '20', '21' ]
  369. ] ) );
  370. } );
  371. it( 'should not reduce rowspan on cells above removed empty row when merging table cells ', () => {
  372. setData( model, modelTable( [
  373. [ { rowspan: 2, contents: '00' }, '01', '02' ],
  374. [ '11', '12' ],
  375. [ { rowspan: 2, contents: '20' }, '21[]', { rowspan: 3, contents: '22' } ],
  376. [ '31' ],
  377. [ '40', '41' ]
  378. ] ) );
  379. command.execute();
  380. expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
  381. [ { rowspan: 2, contents: '00' }, '01', '02' ],
  382. [ '11', '12' ],
  383. [ '20', '[2131]', { rowspan: 2, contents: '22' } ],
  384. [ '40', '41' ]
  385. ] ) );
  386. } );
  387. } );
  388. } );
  389. describe( 'direction=up', () => {
  390. beforeEach( () => {
  391. command = new MergeCellCommand( editor, { direction: 'up' } );
  392. } );
  393. describe( 'isEnabled', () => {
  394. it( 'should be true if in cell that has mergeable cell in previous row', () => {
  395. setData( model, modelTable( [
  396. [ '00', '01' ],
  397. [ '10', '11[]' ]
  398. ] ) );
  399. expect( command.isEnabled ).to.be.true;
  400. } );
  401. it( 'should be false if in first row', () => {
  402. setData( model, modelTable( [
  403. [ '00[]', '01' ],
  404. [ '10', '11' ]
  405. ] ) );
  406. expect( command.isEnabled ).to.be.false;
  407. } );
  408. it( 'should be true if in a cell that has mergeable cell with the same colspan', () => {
  409. setData( model, modelTable( [
  410. [ { colspan: 2, contents: '00' }, '02' ],
  411. [ { colspan: 2, contents: '01[]' }, '12' ]
  412. ] ) );
  413. expect( command.isEnabled ).to.be.true;
  414. } );
  415. it( 'should be false if in a cell that potential mergeable cell has different colspan', () => {
  416. setData( model, modelTable( [
  417. [ { colspan: 2, contents: '00' }, '02' ],
  418. [ { colspan: 3, contents: '01[]' } ]
  419. ] ) );
  420. expect( command.isEnabled ).to.be.false;
  421. } );
  422. it( 'should be false if not in a cell', () => {
  423. setData( model, '<paragraph>11[]</paragraph>' );
  424. expect( command.isEnabled ).to.be.false;
  425. } );
  426. it( 'should be false if mergeable cell is in other table section then current cell', () => {
  427. setData( model, modelTable( [
  428. [ '00', '01' ],
  429. [ '10[]', '11' ]
  430. ], { headingRows: 1 } ) );
  431. expect( command.isEnabled ).to.be.false;
  432. } );
  433. } );
  434. describe( 'value', () => {
  435. it( 'should be set to mergeable cell', () => {
  436. setData( model, modelTable( [
  437. [ '00', '01' ],
  438. [ '10', '11[]' ]
  439. ] ) );
  440. expect( command.value ).to.equal( root.getNodeByPath( [ 0, 0, 1 ] ) );
  441. } );
  442. it( 'should be set to mergeable cell (selection in block content)', () => {
  443. setData( model, modelTable( [
  444. [ '00' ],
  445. [ '<paragraph>10[]</paragraph>' ],
  446. [ '20' ]
  447. ] ) );
  448. expect( command.value ).to.equal( root.getNodeByPath( [ 0, 0, 0 ] ) );
  449. } );
  450. it( 'should be undefined if in first row', () => {
  451. setData( model, modelTable( [
  452. [ '00[]', '01' ],
  453. [ '10', '11' ]
  454. ] ) );
  455. expect( command.value ).to.be.undefined;
  456. } );
  457. it( 'should be set to mergeable cell with the same rowspan', () => {
  458. setData( model, modelTable( [
  459. [ { colspan: 2, contents: '00' }, '02' ],
  460. [ { colspan: 2, contents: '01[]' }, '12' ]
  461. ] ) );
  462. expect( command.value ).to.equal( root.getNodeByPath( [ 0, 0, 0 ] ) );
  463. } );
  464. it( 'should be set to mergeable cell in rows with spanned cells', () => {
  465. setData( model, modelTable( [
  466. [ { rowspan: 3, contents: '00' }, '11', '12', '13' ],
  467. [ { rowspan: 2, contents: '21' }, '22', '23' ],
  468. [ '32', { rowspan: 2, contents: '33[]' } ],
  469. [ { colspan: 2, contents: '40' }, '42' ]
  470. ] ) );
  471. expect( command.value ).to.equal( root.getNodeByPath( [ 0, 1, 2 ] ) );
  472. } );
  473. it( 'should be undefined if in a cell that potential mergeable cell has different rowspan', () => {
  474. setData( model, modelTable( [
  475. [ { colspan: 2, contents: '00' }, '02' ],
  476. [ { colspan: 3, contents: '01[]' } ]
  477. ] ) );
  478. expect( command.value ).to.be.undefined;
  479. } );
  480. it( 'should be undefined if not in a cell', () => {
  481. setData( model, '<paragraph>11[]</paragraph>' );
  482. expect( command.value ).to.be.undefined;
  483. } );
  484. } );
  485. describe( 'execute()', () => {
  486. it( 'should merge table cells', () => {
  487. setData( model, modelTable( [
  488. [ '00', '01' ],
  489. [ '10', '[]11' ]
  490. ] ) );
  491. command.execute();
  492. expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
  493. [ '00', { rowspan: 2, contents: '[0111]' } ],
  494. [ '10' ]
  495. ] ) );
  496. } );
  497. it( 'should properly merge cells in rows with spaned cells', () => {
  498. setData( model, modelTable( [
  499. [ { rowspan: 3, contents: '00' }, '11', '12', '13' ],
  500. [ { rowspan: 2, contents: '21' }, '22', '23' ],
  501. [ '32', { rowspan: 2, contents: '33[]' } ],
  502. [ { colspan: 2, contents: '40' }, '42' ]
  503. ] ) );
  504. command.execute();
  505. expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
  506. [ { rowspan: 3, contents: '00' }, '11', '12', '13' ],
  507. [ { rowspan: 2, contents: '21' }, '22', { rowspan: 3, contents: '[2333]' } ],
  508. [ '32' ],
  509. [ { colspan: 2, contents: '40' }, '42' ]
  510. ] ) );
  511. } );
  512. it( 'should remove empty row if merging table cells ', () => {
  513. setData( model, modelTable( [
  514. [ { rowspan: 2, contents: '00' }, '01', { rowspan: 3, contents: '02' } ],
  515. [ '11[]' ],
  516. [ '20', '21' ]
  517. ] ) );
  518. command.execute();
  519. expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
  520. [ '00', '[0111]', { rowspan: 2, contents: '02' } ],
  521. [ '20', '21' ]
  522. ] ) );
  523. } );
  524. it( 'should not reduce rowspan on cells above removed empty row when merging table cells ', () => {
  525. setData( model, modelTable( [
  526. [ { rowspan: 2, contents: '00' }, '01', '02' ],
  527. [ '11', '12' ],
  528. [ { rowspan: 2, contents: '20' }, '21', { rowspan: 3, contents: '22' } ],
  529. [ '31[]' ],
  530. [ '40', '41' ]
  531. ] ) );
  532. command.execute();
  533. expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
  534. [ { rowspan: 2, contents: '00' }, '01', '02' ],
  535. [ '11', '12' ],
  536. [ '20', '[2131]', { rowspan: 2, contents: '22' } ],
  537. [ '40', '41' ]
  538. ] ) );
  539. } );
  540. } );
  541. } );
  542. } );