8
0

downcast.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
  6. import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
  7. import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  8. import { defaultConversion, defaultSchema, formatTable, formattedViewTable, modelTable } from '../_utils/utils';
  9. import env from '@ckeditor/ckeditor5-utils/src/env';
  10. import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
  11. function paragraphInTableCell() {
  12. return dispatcher => dispatcher.on( 'insert:paragraph', ( evt, data, conversionApi ) => {
  13. const tableCell = data.item.parent;
  14. if ( tableCell.is( 'tableCell' ) && tableCell.childCount > 1 ) {
  15. for ( const child of tableCell.getChildren() ) {
  16. if ( child.name != 'paragraph' ) {
  17. continue;
  18. }
  19. const viewElement = conversionApi.mapper.toViewElement( child );
  20. if ( viewElement && viewElement.name === 'span' ) {
  21. conversionApi.mapper.unbindModelElement( tableCell );
  22. conversionApi.writer.rename( 'p', viewElement );
  23. conversionApi.mapper.bindElements( child, viewElement );
  24. }
  25. }
  26. }
  27. }, { converterPriority: 'highest' } );
  28. }
  29. describe( 'downcast converters', () => {
  30. let editor, model, doc, root, viewDocument;
  31. testUtils.createSinonSandbox();
  32. beforeEach( () => {
  33. // Most tests assume non-edge environment but we do not set `contenteditable=false` on Edge so stub `env.isEdge`.
  34. testUtils.sinon.stub( env, 'isEdge' ).get( () => false );
  35. return VirtualTestEditor.create()
  36. .then( newEditor => {
  37. editor = newEditor;
  38. model = editor.model;
  39. doc = model.document;
  40. root = doc.getRoot( 'main' );
  41. viewDocument = editor.editing.view;
  42. defaultSchema( model.schema );
  43. defaultConversion( editor.conversion );
  44. } );
  45. } );
  46. describe( 'downcastInsertTable()', () => {
  47. it( 'should create table with tbody', () => {
  48. setModelData( model, modelTable( [ [ '' ] ] ) );
  49. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  50. '<figure class="table">' +
  51. '<table>' +
  52. '<tbody>' +
  53. '<tr><td></td></tr>' +
  54. '</tbody>' +
  55. '</table>' +
  56. '</figure>'
  57. ) );
  58. } );
  59. it( 'should create table with tbody and thead', () => {
  60. setModelData( model, modelTable( [
  61. [ '00' ],
  62. [ '10' ]
  63. ], { headingRows: 1 } ) );
  64. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  65. '<figure class="table">' +
  66. '<table>' +
  67. '<thead>' +
  68. '<tr><th>00</th></tr>' +
  69. '</thead>' +
  70. '<tbody>' +
  71. '<tr><td>10</td></tr>' +
  72. '</tbody>' +
  73. '</table>' +
  74. '</figure>'
  75. ) );
  76. } );
  77. it( 'should create table with thead', () => {
  78. setModelData( model, modelTable( [
  79. [ '00' ],
  80. [ '10' ]
  81. ], { headingRows: 2 } ) );
  82. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  83. '<figure class="table">' +
  84. '<table>' +
  85. '<thead>' +
  86. '<tr><th>00</th></tr>' +
  87. '<tr><th>10</th></tr>' +
  88. '</thead>' +
  89. '</table>' +
  90. '</figure>'
  91. ) );
  92. } );
  93. it( 'should create table with heading columns and rows', () => {
  94. setModelData( model, modelTable( [
  95. [ '00', '01', '02', '03' ],
  96. [ '10', '11', '12', '13' ]
  97. ], { headingColumns: 3, headingRows: 1 } ) );
  98. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  99. '<figure class="table">' +
  100. '<table>' +
  101. '<thead>' +
  102. '<tr><th>00</th><th>01</th><th>02</th><th>03</th></tr>' +
  103. '</thead>' +
  104. '<tbody>' +
  105. '<tr><th>10</th><th>11</th><th>12</th><td>13</td></tr>' +
  106. '</tbody>' +
  107. '</table>' +
  108. '</figure>'
  109. ) );
  110. } );
  111. it( 'should create table with block content', () => {
  112. setModelData( model, modelTable( [
  113. [ '<paragraph>00</paragraph><paragraph>foo</paragraph>', '01' ]
  114. ] ) );
  115. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  116. '<figure class="table">' +
  117. '<table>' +
  118. '<tbody>' +
  119. '<tr>' +
  120. '<td><p>00</p><p>foo</p></td>' +
  121. '<td>01</td>' +
  122. '</tr>' +
  123. '</tbody>' +
  124. '</table>' +
  125. '</figure>'
  126. ) );
  127. } );
  128. it( 'should create table with block content (attribute on paragraph)', () => {
  129. editor.conversion.attributeToAttribute(
  130. {
  131. model: { key: 'alignment', values: [ 'right', 'center', 'justify' ] },
  132. view: {
  133. right: { key: 'style', value: { 'text-align': 'right' } },
  134. center: { key: 'style', value: { 'text-align': 'center' } },
  135. justify: { key: 'style', value: { 'text-align': 'justify' } }
  136. }
  137. }
  138. );
  139. setModelData( model, modelTable( [
  140. [ '<paragraph alignment="right">00</paragraph>' ]
  141. ] ) );
  142. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  143. '<figure class="table">' +
  144. '<table>' +
  145. '<tbody>' +
  146. '<tr>' +
  147. '<td><p style="text-align:right">00</p></td>' +
  148. '</tr>' +
  149. '</tbody>' +
  150. '</table>' +
  151. '</figure>'
  152. ) );
  153. } );
  154. it( 'should be possible to overwrite', () => {
  155. editor.conversion.elementToElement( { model: 'tableRow', view: 'tr', converterPriority: 'high' } );
  156. editor.conversion.elementToElement( { model: 'tableCell', view: 'td', converterPriority: 'high' } );
  157. editor.conversion.for( 'downcast' ).add( dispatcher => {
  158. dispatcher.on( 'insert:table', ( evt, data, conversionApi ) => {
  159. conversionApi.consumable.consume( data.item, 'insert' );
  160. const tableElement = conversionApi.writer.createContainerElement( 'table', { foo: 'bar' } );
  161. const viewPosition = conversionApi.mapper.toViewPosition( data.range.start );
  162. conversionApi.mapper.bindElements( data.item, tableElement );
  163. conversionApi.writer.insert( viewPosition, tableElement );
  164. }, { priority: 'high' } );
  165. } );
  166. setModelData( model, modelTable( [ [ '' ] ] ) );
  167. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  168. '<table foo="bar">' +
  169. '<tr><td><p></p></td></tr>' +
  170. '</table>'
  171. ) );
  172. } );
  173. it( 'should re-create table on reinsert', () => {
  174. model.schema.register( 'wrapper', {
  175. allowWhere: '$block',
  176. allowContentOf: '$root'
  177. } );
  178. editor.conversion.elementToElement( { model: 'wrapper', view: 'div' } );
  179. setModelData( model, modelTable( [ [ '[]' ] ] ) );
  180. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  181. '<figure class="table">' +
  182. '<table>' +
  183. '<tbody>' +
  184. '<tr><td></td></tr>' +
  185. '</tbody>' +
  186. '</table>' +
  187. '</figure>'
  188. ) );
  189. model.change( writer => {
  190. const table = model.document.getRoot().getChild( 0 );
  191. const range = writer.createRange( writer.createPositionBefore( table ), writer.createPositionAfter( table ) );
  192. const wrapper = writer.createElement( 'wrapper' );
  193. writer.wrap( range, wrapper );
  194. } );
  195. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  196. '<div>' +
  197. '<figure class="table">' +
  198. '<table>' +
  199. '<tbody>' +
  200. '<tr><td></td></tr>' +
  201. '</tbody>' +
  202. '</table>' +
  203. '</figure>' +
  204. '</div>'
  205. ) );
  206. } );
  207. describe( 'headingColumns attribute', () => {
  208. it( 'should mark heading columns table cells', () => {
  209. setModelData( model, modelTable( [
  210. [ '00', '01', '02' ],
  211. [ '10', '11', '12' ]
  212. ], { headingColumns: 2 } ) );
  213. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  214. '<figure class="table">' +
  215. '<table>' +
  216. '<tbody>' +
  217. '<tr><th>00</th><th>01</th><td>02</td></tr>' +
  218. '<tr><th>10</th><th>11</th><td>12</td></tr>' +
  219. '</tbody>' +
  220. '</table>' +
  221. '</figure>'
  222. ) );
  223. } );
  224. it( 'should mark heading columns table cells when one has colspan attribute', () => {
  225. setModelData( model, modelTable( [
  226. [ '00', '01', '02', '03' ],
  227. [ { colspan: 2, contents: '10' }, '12', '13' ]
  228. ], { headingColumns: 3 } ) );
  229. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  230. '<figure class="table">' +
  231. '<table>' +
  232. '<tbody>' +
  233. '<tr><th>00</th><th>01</th><th>02</th><td>03</td></tr>' +
  234. '<tr><th colspan="2">10</th><th>12</th><td>13</td></tr>' +
  235. '</tbody>' +
  236. '</table>' +
  237. '</figure>'
  238. ) );
  239. } );
  240. it( 'should work with colspan and rowspan attributes on table cells', () => {
  241. // The table in this test looks like a table below:
  242. //
  243. // Row headings | Normal cells
  244. // |
  245. // +----+----+----+----+
  246. // | 00 | 01 | 02 | 03 |
  247. // | +----+ +----+
  248. // | | 11 | | 13 |
  249. // |----+----+ +----+
  250. // | 20 | | 23 |
  251. // | +----+----+
  252. // | | 32 | 33 |
  253. // +----+----+----+----+
  254. setModelData( model, modelTable( [
  255. [ { rowspan: 2, contents: '00' }, '01', { rowspan: 3, contents: '02' }, '03' ],
  256. [ '11', '13' ],
  257. [ { colspan: 2, rowspan: 2, contents: '20' }, '23' ],
  258. [ '32', '33' ]
  259. ], { headingColumns: 3 } ) );
  260. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  261. '<figure class="table">' +
  262. '<table>' +
  263. '<tbody>' +
  264. '<tr><th rowspan="2">00</th><th>01</th><th rowspan="3">02</th><td>03</td></tr>' +
  265. '<tr><th>11</th><td>13</td></tr>' +
  266. '<tr><th colspan="2" rowspan="2">20</th><td>23</td></tr>' +
  267. '<tr><th>32</th><td>33</td></tr>' +
  268. '</tbody>' +
  269. '</table>' +
  270. '</figure>'
  271. ) );
  272. } );
  273. } );
  274. describe( 'options.asWidget=true', () => {
  275. beforeEach( () => {
  276. return VirtualTestEditor.create()
  277. .then( newEditor => {
  278. editor = newEditor;
  279. model = editor.model;
  280. doc = model.document;
  281. root = doc.getRoot( 'main' );
  282. viewDocument = editor.editing.view;
  283. defaultSchema( model.schema );
  284. defaultConversion( editor.conversion, true );
  285. } );
  286. } );
  287. it( 'should create table as a widget', () => {
  288. setModelData( model, modelTable( [ [ '' ] ] ) );
  289. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  290. '<figure class="ck-widget ck-widget_with-selection-handler table" contenteditable="false">' +
  291. '<div class="ck ck-widget__selection-handler"></div>' +
  292. '<table>' +
  293. '<tbody>' +
  294. '<tr>' +
  295. '<td class="ck-editor__editable ck-editor__nested-editable" contenteditable="true"><span></span></td>' +
  296. '</tr>' +
  297. '</tbody>' +
  298. '</table>' +
  299. '</figure>'
  300. ) );
  301. } );
  302. } );
  303. } );
  304. describe( 'downcastInsertRow()', () => {
  305. it( 'should react to changed rows', () => {
  306. setModelData( model, modelTable( [
  307. [ '00', '01' ]
  308. ] ) );
  309. const table = root.getChild( 0 );
  310. model.change( writer => {
  311. const row = writer.createElement( 'tableRow' );
  312. writer.insert( row, table, 1 );
  313. writer.insertElement( 'tableCell', row, 'end' );
  314. writer.insertElement( 'tableCell', row, 'end' );
  315. } );
  316. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  317. [ '00', '01' ],
  318. [ '', '' ]
  319. ] ) );
  320. } );
  321. it( 'should properly consume already added rows', () => {
  322. setModelData( model, modelTable( [
  323. [ '00', '01' ]
  324. ] ) );
  325. const table = root.getChild( 0 );
  326. model.change( writer => {
  327. const row = writer.createElement( 'tableRow' );
  328. writer.insert( row, table, 1 );
  329. writer.insertElement( 'tableCell', row, 'end' );
  330. writer.insertElement( 'tableCell', row, 'end' );
  331. } );
  332. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  333. [ '00', '01' ],
  334. [ '', '' ]
  335. ] ) );
  336. model.change( writer => {
  337. const row = writer.createElement( 'tableRow' );
  338. writer.insert( row, table, 2 );
  339. writer.insertElement( 'tableCell', row, 'end' );
  340. writer.insertElement( 'tableCell', row, 'end' );
  341. } );
  342. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  343. [ '00', '01' ],
  344. [ '', '' ],
  345. [ '', '' ]
  346. ] ) );
  347. } );
  348. it( 'should insert row on proper index', () => {
  349. setModelData( model, modelTable( [
  350. [ '00', '01' ],
  351. [ '21', '22' ],
  352. [ '31', '32' ]
  353. ] ) );
  354. const table = root.getChild( 0 );
  355. model.change( writer => {
  356. const row = writer.createElement( 'tableRow' );
  357. writer.insert( row, table, 1 );
  358. writer.insertElement( 'tableCell', row, 'end' );
  359. writer.insertElement( 'tableCell', row, 'end' );
  360. } );
  361. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  362. [ '00', '01' ],
  363. [ '', '' ],
  364. [ '21', '22' ],
  365. [ '31', '32' ]
  366. ] ) );
  367. } );
  368. it( 'should insert row on proper index when table has heading rows defined - insert in body', () => {
  369. setModelData( model, modelTable( [
  370. [ '00', '01' ],
  371. [ '21', '22' ],
  372. [ '31', '32' ]
  373. ], { headingRows: 1 } ) );
  374. const table = root.getChild( 0 );
  375. model.change( writer => {
  376. const row = writer.createElement( 'tableRow' );
  377. writer.insert( row, table, 1 );
  378. writer.insertElement( 'tableCell', row, 'end' );
  379. writer.insertElement( 'tableCell', row, 'end' );
  380. } );
  381. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  382. [ '00', '01' ],
  383. [ '', '' ],
  384. [ '21', '22' ],
  385. [ '31', '32' ]
  386. ], { headingRows: 1 } ) );
  387. } );
  388. it( 'should insert row on proper index when table has heading rows defined - insert in heading', () => {
  389. setModelData( model, modelTable( [
  390. [ '00', '01' ],
  391. [ '21', '22' ],
  392. [ '31', '32' ]
  393. ], { headingRows: 2 } ) );
  394. const table = root.getChild( 0 );
  395. model.change( writer => {
  396. const row = writer.createElement( 'tableRow' );
  397. writer.insert( row, table, 1 );
  398. writer.insertElement( 'tableCell', row, 'end' );
  399. writer.insertElement( 'tableCell', row, 'end' );
  400. } );
  401. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  402. [ '00', '01' ],
  403. [ '', '' ],
  404. [ '21', '22' ],
  405. [ '31', '32' ]
  406. ], { headingRows: 3 } ) );
  407. } );
  408. it( 'should react to changed rows when previous rows\' cells has rowspans', () => {
  409. setModelData( model, modelTable( [
  410. [ { rowspan: 3, contents: '00' }, '01' ],
  411. [ '22' ]
  412. ] ) );
  413. const table = root.getChild( 0 );
  414. model.change( writer => {
  415. const row = writer.createElement( 'tableRow' );
  416. writer.insert( row, table, 2 );
  417. writer.insertElement( 'tableCell', row, 'end' );
  418. } );
  419. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  420. [ { rowspan: 3, contents: '00' }, '01' ],
  421. [ '22' ],
  422. [ '' ]
  423. ] ) );
  424. } );
  425. it( 'should properly create row headings', () => {
  426. setModelData( model, modelTable( [
  427. [ { rowspan: 3, contents: '00' }, '01' ],
  428. [ '22' ]
  429. ], { headingColumns: 1 } ) );
  430. const table = root.getChild( 0 );
  431. model.change( writer => {
  432. const firstRow = writer.createElement( 'tableRow' );
  433. writer.insert( firstRow, table, 2 );
  434. writer.insert( writer.createElement( 'tableCell' ), firstRow, 'end' );
  435. const secondRow = writer.createElement( 'tableRow' );
  436. writer.insert( secondRow, table, 3 );
  437. writer.insert( writer.createElement( 'tableCell' ), secondRow, 'end' );
  438. writer.insert( writer.createElement( 'tableCell' ), secondRow, 'end' );
  439. } );
  440. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  441. [ { rowspan: 3, contents: '00', isHeading: true }, '01' ],
  442. [ '22' ],
  443. [ '' ],
  444. [ { contents: '', isHeading: true }, '' ]
  445. ] ) );
  446. } );
  447. describe( 'options.asWidget=true', () => {
  448. beforeEach( () => {
  449. return VirtualTestEditor.create()
  450. .then( newEditor => {
  451. editor = newEditor;
  452. model = editor.model;
  453. doc = model.document;
  454. root = doc.getRoot( 'main' );
  455. viewDocument = editor.editing.view;
  456. defaultSchema( model.schema );
  457. defaultConversion( editor.conversion, true );
  458. } );
  459. } );
  460. it( 'should create table cell inside inserted row as a widget', () => {
  461. setModelData( model, modelTable( [ [ '00' ] ] ) );
  462. const table = root.getChild( 0 );
  463. model.change( writer => {
  464. const firstRow = writer.createElement( 'tableRow' );
  465. writer.insert( firstRow, table, 1 );
  466. writer.insert( writer.createElement( 'tableCell' ), firstRow, 'end' );
  467. } );
  468. expect( formatTable(
  469. getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  470. '<figure class="ck-widget ck-widget_with-selection-handler table" contenteditable="false">' +
  471. '<div class="ck ck-widget__selection-handler"></div>' +
  472. '<table>' +
  473. '<tbody>' +
  474. '<tr>' +
  475. '<td class="ck-editor__editable ck-editor__nested-editable" contenteditable="true">' +
  476. '<span>00</span>' +
  477. '</td>' +
  478. '</tr>' +
  479. '<tr>' +
  480. '<td class="ck-editor__editable ck-editor__nested-editable" contenteditable="true"></td>' +
  481. '</tr>' +
  482. '</tbody>' +
  483. '</table>' +
  484. '</figure>'
  485. ) );
  486. } );
  487. } );
  488. } );
  489. describe( 'downcastInsertCell()', () => {
  490. it( 'should add tableCell on proper index in tr', () => {
  491. setModelData( model, modelTable( [
  492. [ '00', '01' ]
  493. ] ) );
  494. const table = root.getChild( 0 );
  495. model.change( writer => {
  496. const row = table.getChild( 0 );
  497. writer.insertElement( 'tableCell', row, 1 );
  498. } );
  499. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  500. [ '00', '', '01' ]
  501. ] ) );
  502. } );
  503. it( 'should add tableCell on proper index in tr when previous have colspans', () => {
  504. setModelData( model, modelTable( [
  505. [ { colspan: 2, contents: '00' }, '13' ]
  506. ] ) );
  507. const table = root.getChild( 0 );
  508. model.change( writer => {
  509. const row = table.getChild( 0 );
  510. writer.insertElement( 'tableCell', row, 1 );
  511. } );
  512. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  513. [ { colspan: 2, contents: '00' }, '', '13' ]
  514. ] ) );
  515. } );
  516. it( 'should add tableCell on proper index in tr when previous row have rowspans', () => {
  517. setModelData( model, modelTable( [
  518. [ { rowspan: 2, contents: '00' }, '13' ],
  519. [ '11', '12' ]
  520. ] ) );
  521. const table = root.getChild( 0 );
  522. model.change( writer => {
  523. writer.insertElement( 'tableCell', table.getChild( 0 ), 1 );
  524. writer.insertElement( 'tableCell', table.getChild( 1 ), 0 );
  525. } );
  526. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  527. [ { rowspan: 2, contents: '00' }, '', '13' ],
  528. [ '', '11', '12' ]
  529. ] ) );
  530. } );
  531. it( 'split cell simulation - simple', () => {
  532. setModelData( model, modelTable( [
  533. [ '00', '01' ],
  534. [ '10', '11' ]
  535. ] ) );
  536. const table = root.getChild( 0 );
  537. model.change( writer => {
  538. const firstRow = table.getChild( 0 );
  539. const secondRow = table.getChild( 1 );
  540. writer.insertElement( 'tableCell', firstRow, 1 );
  541. writer.setAttribute( 'colspan', 2, secondRow.getChild( 0 ) );
  542. } );
  543. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  544. [ '00', '', '01' ],
  545. [ { colspan: 2, contents: '10' }, '11' ]
  546. ] ) );
  547. } );
  548. it( 'merge simulation - simple', () => {
  549. setModelData( model, modelTable( [
  550. [ '00', '01' ],
  551. [ '10', '11' ]
  552. ] ) );
  553. const table = root.getChild( 0 );
  554. model.change( writer => {
  555. const firstRow = table.getChild( 0 );
  556. writer.setAttribute( 'colspan', 2, firstRow.getChild( 0 ) );
  557. writer.remove( firstRow.getChild( 1 ) );
  558. } );
  559. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  560. [ { colspan: 2, contents: '00' } ],
  561. [ '10', '11' ]
  562. ] ) );
  563. } );
  564. describe( 'options.asWidget=true', () => {
  565. beforeEach( () => {
  566. return VirtualTestEditor.create()
  567. .then( newEditor => {
  568. editor = newEditor;
  569. model = editor.model;
  570. doc = model.document;
  571. root = doc.getRoot( 'main' );
  572. viewDocument = editor.editing.view;
  573. defaultSchema( model.schema );
  574. defaultConversion( editor.conversion, true );
  575. } );
  576. } );
  577. it( 'should create inserted table cell as a widget', () => {
  578. setModelData( model, modelTable( [ [ '00' ] ] ) );
  579. const table = root.getChild( 0 );
  580. model.change( writer => {
  581. const row = table.getChild( 0 );
  582. writer.insert( writer.createElement( 'tableCell' ), row, 'end' );
  583. } );
  584. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  585. '<figure class="ck-widget ck-widget_with-selection-handler table" contenteditable="false">' +
  586. '<div class="ck ck-widget__selection-handler"></div>' +
  587. '<table>' +
  588. '<tbody>' +
  589. '<tr>' +
  590. '<td class="ck-editor__editable ck-editor__nested-editable" contenteditable="true">' +
  591. '<span>00</span>' +
  592. '</td>' +
  593. '<td class="ck-editor__editable ck-editor__nested-editable" contenteditable="true"></td>' +
  594. '</tr>' +
  595. '</tbody>' +
  596. '</table>' +
  597. '</figure>'
  598. ) );
  599. } );
  600. } );
  601. } );
  602. describe( 'downcastTableHeadingColumnsChange()', () => {
  603. it( 'should work for adding heading columns', () => {
  604. setModelData( model, modelTable( [
  605. [ '00', '01' ],
  606. [ '10', '11' ]
  607. ] ) );
  608. const table = root.getChild( 0 );
  609. model.change( writer => {
  610. writer.setAttribute( 'headingColumns', 1, table );
  611. } );
  612. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  613. [ { isHeading: true, contents: '00' }, '01' ],
  614. [ { isHeading: true, contents: '10' }, '11' ]
  615. ], { headingColumns: 1 } ) );
  616. } );
  617. it( 'should work for changing heading columns to a bigger number', () => {
  618. setModelData( model, modelTable( [
  619. [ '00', '01', '02', '03' ],
  620. [ '10', '11', '12', '13' ]
  621. ], { headingColumns: 1 } ) );
  622. const table = root.getChild( 0 );
  623. model.change( writer => {
  624. writer.setAttribute( 'headingColumns', 3, table );
  625. } );
  626. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  627. [ { isHeading: true, contents: '00' }, { isHeading: true, contents: '01' }, { isHeading: true, contents: '02' }, '03' ],
  628. [ { isHeading: true, contents: '10' }, { isHeading: true, contents: '11' }, { isHeading: true, contents: '12' }, '13' ]
  629. ] ) );
  630. } );
  631. it( 'should work for changing heading columns to a smaller number', () => {
  632. setModelData( model, modelTable( [
  633. [ { isHeading: true, contents: '00' }, { isHeading: true, contents: '01' }, { isHeading: true, contents: '02' }, '03' ],
  634. [ { isHeading: true, contents: '10' }, { isHeading: true, contents: '11' }, { isHeading: true, contents: '12' }, '13' ]
  635. ], { headingColumns: 3 } ) );
  636. const table = root.getChild( 0 );
  637. model.change( writer => {
  638. writer.setAttribute( 'headingColumns', 1, table );
  639. } );
  640. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  641. [ { isHeading: true, contents: '00' }, '01', '02', '03' ],
  642. [ { isHeading: true, contents: '10' }, '11', '12', '13' ]
  643. ], { headingColumns: 3 } ) );
  644. } );
  645. it( 'should work for removing heading columns', () => {
  646. setModelData( model, modelTable( [
  647. [ '00', '01' ],
  648. [ '10', '11' ]
  649. ], { headingColumns: 1 } ) );
  650. const table = root.getChild( 0 );
  651. model.change( writer => {
  652. writer.removeAttribute( 'headingColumns', table );
  653. } );
  654. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  655. [ '00', '01' ],
  656. [ '10', '11' ]
  657. ] ) );
  658. } );
  659. it( 'should be possible to overwrite', () => {
  660. editor.conversion.attributeToAttribute( { model: 'headingColumns', view: 'headingColumns', converterPriority: 'high' } );
  661. setModelData( model, modelTable( [ [ '00' ] ] ) );
  662. const table = root.getChild( 0 );
  663. model.change( writer => {
  664. writer.setAttribute( 'headingColumns', 1, table );
  665. } );
  666. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  667. '<figure class="table" headingColumns="1">' +
  668. '<table>' +
  669. '<tbody>' +
  670. '<tr><td>00</td></tr>' +
  671. '</tbody>' +
  672. '</table>' +
  673. '</figure>'
  674. ) );
  675. } );
  676. it( 'should work with adding table cells', () => {
  677. setModelData( model, modelTable( [
  678. [ { rowspan: 2, contents: '00' }, '01', '13', '14' ],
  679. [ '11', '12', '13' ],
  680. [ { colspan: 2, contents: '20' }, '22', '23' ]
  681. ], { headingColumns: 2 } ) );
  682. const table = root.getChild( 0 );
  683. model.change( writer => {
  684. // Inserting column in heading columns so update table's attribute also
  685. writer.setAttribute( 'headingColumns', 3, table );
  686. writer.insertElement( 'tableCell', table.getChild( 0 ), 2 );
  687. writer.insertElement( 'tableCell', table.getChild( 1 ), 1 );
  688. writer.insertElement( 'tableCell', table.getChild( 2 ), 1 );
  689. } );
  690. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  691. [
  692. { isHeading: true, rowspan: 2, contents: '00' },
  693. { isHeading: true, contents: '01' },
  694. { isHeading: true, contents: '' },
  695. '13',
  696. '14'
  697. ],
  698. [
  699. { isHeading: true, contents: '11' },
  700. { isHeading: true, contents: '' },
  701. '12',
  702. '13'
  703. ],
  704. [
  705. { isHeading: true, colspan: 2, contents: '20' },
  706. { isHeading: true, contents: '' },
  707. '22',
  708. '23'
  709. ]
  710. ] ) );
  711. } );
  712. describe( 'options.asWidget=true', () => {
  713. beforeEach( () => {
  714. return VirtualTestEditor.create()
  715. .then( newEditor => {
  716. editor = newEditor;
  717. model = editor.model;
  718. doc = model.document;
  719. root = doc.getRoot( 'main' );
  720. viewDocument = editor.editing.view;
  721. defaultSchema( model.schema );
  722. defaultConversion( editor.conversion, true );
  723. } );
  724. } );
  725. it( 'should create renamed cell as a widget', () => {
  726. setModelData( model, modelTable( [ [ '00' ] ] ) );
  727. const table = root.getChild( 0 );
  728. model.change( writer => {
  729. writer.setAttribute( 'headingRows', 1, table );
  730. } );
  731. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  732. '<figure class="ck-widget ck-widget_with-selection-handler table" contenteditable="false">' +
  733. '<div class="ck ck-widget__selection-handler"></div>' +
  734. '<table>' +
  735. '<thead>' +
  736. '<tr>' +
  737. '<th class="ck-editor__editable ck-editor__nested-editable" contenteditable="true">' +
  738. '<span>00</span>' +
  739. '</th>' +
  740. '</tr>' +
  741. '</thead>' +
  742. '</table>' +
  743. '</figure>'
  744. ) );
  745. } );
  746. } );
  747. } );
  748. describe( 'downcastTableHeadingRowsChange()', () => {
  749. it( 'should work for adding heading rows', () => {
  750. setModelData( model, modelTable( [
  751. [ '00', '01' ],
  752. [ '10', '11' ],
  753. [ '20', '21' ]
  754. ] ) );
  755. const table = root.getChild( 0 );
  756. model.change( writer => {
  757. writer.setAttribute( 'headingRows', 2, table );
  758. } );
  759. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  760. [ '00', '01' ],
  761. [ '10', '11' ],
  762. [ '20', '21' ]
  763. ], { headingRows: 2 } ) );
  764. } );
  765. it( 'should work for changing number of heading rows to a bigger number', () => {
  766. setModelData( model, modelTable( [
  767. [ '00', '01' ],
  768. [ '10', '11' ],
  769. [ '20', '21' ]
  770. ], { headingRows: 1 } ) );
  771. const table = root.getChild( 0 );
  772. model.change( writer => {
  773. writer.setAttribute( 'headingRows', 2, table );
  774. } );
  775. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  776. [ '00', '01' ],
  777. [ '10', '11' ],
  778. [ '20', '21' ]
  779. ], { headingRows: 2 } ) );
  780. } );
  781. it( 'should work for changing number of heading rows to a smaller number', () => {
  782. setModelData( model, modelTable( [
  783. [ '00', '01' ],
  784. [ '10', '11' ],
  785. [ '20', '21' ],
  786. [ '30', '31' ]
  787. ], { headingRows: 3 } ) );
  788. const table = root.getChild( 0 );
  789. model.change( writer => {
  790. writer.setAttribute( 'headingRows', 2, table );
  791. } );
  792. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  793. [ '00', '01' ],
  794. [ '10', '11' ],
  795. [ '20', '21' ],
  796. [ '30', '31' ]
  797. ], { headingRows: 2 } ) );
  798. } );
  799. it( 'should work for removing heading rows', () => {
  800. setModelData( model, modelTable( [
  801. [ '00', '01' ],
  802. [ '10', '11' ]
  803. ], { headingRows: 2 } ) );
  804. const table = root.getChild( 0 );
  805. model.change( writer => {
  806. writer.removeAttribute( 'headingRows', table );
  807. } );
  808. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  809. [ '00', '01' ],
  810. [ '10', '11' ]
  811. ] ) );
  812. } );
  813. it( 'should work for making heading rows without tbody', () => {
  814. setModelData( model, modelTable( [
  815. [ '00', '01' ],
  816. [ '10', '11' ]
  817. ] ) );
  818. const table = root.getChild( 0 );
  819. model.change( writer => {
  820. writer.setAttribute( 'headingRows', 2, table );
  821. } );
  822. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  823. [ '00', '01' ],
  824. [ '10', '11' ]
  825. ], { headingRows: 2 } ) );
  826. } );
  827. it( 'should be possible to overwrite', () => {
  828. editor.conversion.attributeToAttribute( { model: 'headingRows', view: 'headingRows', converterPriority: 'high' } );
  829. setModelData( model, modelTable( [ [ '00' ] ] ) );
  830. const table = root.getChild( 0 );
  831. model.change( writer => {
  832. writer.setAttribute( 'headingRows', 1, table );
  833. } );
  834. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  835. '<figure class="table" headingRows="1">' +
  836. '<table>' +
  837. '<tbody>' +
  838. '<tr><td>00</td></tr>' +
  839. '</tbody>' +
  840. '</table>' +
  841. '</figure>'
  842. ) );
  843. } );
  844. it( 'should work with adding table rows at the beginning of a table', () => {
  845. setModelData( model, modelTable( [
  846. [ '00', '01' ],
  847. [ '10', '11' ]
  848. ], { headingRows: 1 } ) );
  849. const table = root.getChild( 0 );
  850. model.change( writer => {
  851. writer.setAttribute( 'headingRows', 2, table );
  852. const tableRow = writer.createElement( 'tableRow' );
  853. writer.insert( tableRow, table, 0 );
  854. writer.insertElement( 'tableCell', tableRow, 'end' );
  855. writer.insertElement( 'tableCell', tableRow, 'end' );
  856. } );
  857. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  858. [ '', '' ],
  859. [ '00', '01' ],
  860. [ '10', '11' ]
  861. ], { headingRows: 2 } ) );
  862. } );
  863. it( 'should work with adding a table row and expanding heading', () => {
  864. setModelData( model, modelTable( [
  865. [ '00', '01' ],
  866. [ '10', '11' ],
  867. [ '20', '21' ]
  868. ], { headingRows: 1 } ) );
  869. const table = root.getChild( 0 );
  870. model.change( writer => {
  871. writer.setAttribute( 'headingRows', 2, table );
  872. const tableRow = writer.createElement( 'tableRow' );
  873. writer.insert( tableRow, table, 1 );
  874. writer.insertElement( 'tableCell', tableRow, 'end' );
  875. writer.insertElement( 'tableCell', tableRow, 'end' );
  876. } );
  877. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  878. [ '00', '01' ],
  879. [ '', '' ],
  880. [ '10', '11' ],
  881. [ '20', '21' ]
  882. ], { headingRows: 2 } ) );
  883. } );
  884. describe( 'options.asWidget=true', () => {
  885. beforeEach( () => {
  886. return VirtualTestEditor.create()
  887. .then( newEditor => {
  888. editor = newEditor;
  889. model = editor.model;
  890. doc = model.document;
  891. root = doc.getRoot( 'main' );
  892. viewDocument = editor.editing.view;
  893. defaultSchema( model.schema );
  894. defaultConversion( editor.conversion, true );
  895. } );
  896. } );
  897. it( 'should create renamed cell as a widget', () => {
  898. setModelData( model, modelTable( [ [ '00' ] ] ) );
  899. const table = root.getChild( 0 );
  900. model.change( writer => {
  901. writer.setAttribute( 'headingColumns', 1, table );
  902. } );
  903. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
  904. '<figure class="ck-widget ck-widget_with-selection-handler table" contenteditable="false">' +
  905. '<div class="ck ck-widget__selection-handler"></div>' +
  906. '<table>' +
  907. '<tbody>' +
  908. '<tr>' +
  909. '<th class="ck-editor__editable ck-editor__nested-editable" contenteditable="true">' +
  910. '<span>00</span>' +
  911. '</th>' +
  912. '</tr>' +
  913. '</tbody>' +
  914. '</table>' +
  915. '</figure>'
  916. ) );
  917. } );
  918. } );
  919. } );
  920. describe( 'downcastRemoveRow()', () => {
  921. it( 'should react to removed row from the beginning of a tbody', () => {
  922. setModelData( model, modelTable( [
  923. [ '00[]', '01' ],
  924. [ '10', '11' ]
  925. ] ) );
  926. const table = root.getChild( 0 );
  927. model.change( writer => {
  928. writer.remove( table.getChild( 1 ) );
  929. } );
  930. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  931. [ '00', '01' ]
  932. ] ) );
  933. } );
  934. it( 'should react to removed row form the end of a tbody', () => {
  935. setModelData( model, modelTable( [
  936. [ '00[]', '01' ],
  937. [ '10', '11' ]
  938. ] ) );
  939. const table = root.getChild( 0 );
  940. model.change( writer => {
  941. writer.remove( table.getChild( 0 ) );
  942. } );
  943. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  944. [ '10', '11' ]
  945. ] ) );
  946. } );
  947. it( 'should react to removed row from the beginning of a thead', () => {
  948. setModelData( model, modelTable( [
  949. [ '00[]', '01' ],
  950. [ '10', '11' ]
  951. ], { headingRows: 2 } ) );
  952. const table = root.getChild( 0 );
  953. model.change( writer => {
  954. writer.remove( table.getChild( 1 ) );
  955. } );
  956. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  957. [ '00', '01' ]
  958. ], { headingRows: 2 } ) );
  959. } );
  960. it( 'should react to removed row form the end of a thead', () => {
  961. setModelData( model, modelTable( [
  962. [ '00[]', '01' ],
  963. [ '10', '11' ]
  964. ], { headingRows: 2 } ) );
  965. const table = root.getChild( 0 );
  966. model.change( writer => {
  967. writer.remove( table.getChild( 0 ) );
  968. } );
  969. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  970. [ '10', '11' ]
  971. ], { headingRows: 2 } ) );
  972. } );
  973. it( 'should remove empty thead section if a last row was removed from thead', () => {
  974. setModelData( model, modelTable( [
  975. [ '00[]', '01' ],
  976. [ '10', '11' ]
  977. ], { headingRows: 1 } ) );
  978. const table = root.getChild( 0 );
  979. model.change( writer => {
  980. writer.setAttribute( 'headingRows', 0, table );
  981. writer.remove( table.getChild( 0 ) );
  982. } );
  983. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  984. [ '10', '11' ]
  985. ] ) );
  986. } );
  987. it( 'should remove empty tbody section if a last row was removed from tbody', () => {
  988. setModelData( model, modelTable( [
  989. [ '00[]', '01' ],
  990. [ '10', '11' ]
  991. ], { headingRows: 1 } ) );
  992. const table = root.getChild( 0 );
  993. model.change( writer => {
  994. writer.remove( table.getChild( 1 ) );
  995. } );
  996. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  997. [ '00', '01' ]
  998. ], { headingRows: 1 } ) );
  999. } );
  1000. } );
  1001. describe( 'options.asWidget=true', () => {
  1002. beforeEach( () => {
  1003. return VirtualTestEditor.create()
  1004. .then( newEditor => {
  1005. editor = newEditor;
  1006. model = editor.model;
  1007. doc = model.document;
  1008. root = doc.getRoot( 'main' );
  1009. viewDocument = editor.editing.view;
  1010. defaultSchema( model.schema );
  1011. defaultConversion( editor.conversion, true );
  1012. editor.conversion.for( 'downcast' ).add( paragraphInTableCell() );
  1013. } );
  1014. } );
  1015. it( 'should rename <span> to <p> when more then one block content inside table cell', () => {
  1016. setModelData( model, modelTable( [
  1017. [ '00[]' ]
  1018. ] ) );
  1019. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  1020. [ '00' ]
  1021. ], { asWidget: true } ) );
  1022. const table = root.getChild( 0 );
  1023. model.change( writer => {
  1024. const nodeByPath = table.getNodeByPath( [ 0, 0, 0 ] );
  1025. const paragraph = writer.createElement( 'paragraph' );
  1026. writer.insert( paragraph, nodeByPath, 'after' );
  1027. writer.setSelection( nodeByPath.nextSibling, 0 );
  1028. } );
  1029. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  1030. [ '<p>00</p><p></p>' ]
  1031. ], { asWidget: true } ) );
  1032. } );
  1033. it( 'should rename <span> to <p> for single paragraph with attribute', () => {
  1034. model.schema.extend( '$block', { allowAttributes: 'foo' } );
  1035. editor.conversion.attributeToAttribute( { model: 'foo', view: 'foo' } );
  1036. setModelData( model, modelTable( [
  1037. [ '<paragraph foo="bar">00[]</paragraph>' ]
  1038. ] ) );
  1039. expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formattedViewTable( [
  1040. [ '<p foo="bar">00</p>' ]
  1041. ], { asWidget: true } ) );
  1042. } );
  1043. } );
  1044. } );