/**
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
import {
downcastInsertCell,
downcastInsertRow,
downcastInsertTable,
downcastRemoveRow,
downcastTableHeadingColumnsChange,
downcastTableHeadingRowsChange
} from '../../src/converters/downcast';
import upcastTable, { upcastTableCell } from '../../src/converters/upcasttable';
import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
const WIDGET_TABLE_CELL_CLASS = 'ck-editor__editable ck-editor__nested-editable';
/**
* Returns a model representation of a table shorthand notation:
*
* modelTable( [
* [ '00' ] // first row
* [ '10' ] // second row
* ] );
*
* will output:
*
* '
0010
'
*
* Each table row passed in `tableData` array is represented as an array of strings or objects. A string defines text contents of a cell.
*
* Passing an object allows to pass additional table cell attributes:
*
* const tableCellData = {
* colspan: 2,
* rowspan: 4,
* contents: 'foo' // text contents of a cell
* };
*
* @param {Array.|Object>} tableData
* @param {Object} [attributes] Optional table attributes: `headingRows` and `headingColumns`.
*
* @returns {String}
*/
export function modelTable( tableData, attributes ) {
const tableRows = makeRows( tableData, {
cellElement: 'tableCell',
rowElement: 'tableRow',
headingElement: 'tableCell',
wrappingElement: 'paragraph',
enforceWrapping: true
} );
return `
${ tableRows }
`;
}
/**
* Returns a view representation of a table shorthand notation:
*
* viewTable( [
* [ '00', '01' ] // first row
* [ '10', '11' ] // second row
* ] );
*
* will output:
*
* '
00
01
10
11
'
*
* Each table row passed in `tableData` array is represented as an array of strings or objects. A string defines text contents of a cell.
*
* Passing an object allows to pass additional table cell attributes:
*
* const tableCellData = {
* colspan: 2,
* rowspan: 4,
* isHeading: true, // will render table cell as `