{"version":3,"sources":["webpack:///./node_modules/@ckeditor/ckeditor5-table/src/converters/table-layout-post-fixer.js","webpack:///./node_modules/@ckeditor/ckeditor5-table/src/converters/table-heading-rows-refresh-post-fixer.js","webpack:///./node_modules/@ckeditor/ckeditor5-table/src/converters/upcasttable.js","webpack:///./node_modules/@ckeditor/ckeditor5-table/src/converters/table-cell-refresh-post-fixer.js","webpack:///./node_modules/@ckeditor/ckeditor5-table/src/converters/table-cell-paragraph-post-fixer.js"],"names":["injectTableLayoutPostFixer","model","document","registerPostFixer","writer","tableLayoutPostFixer","_step","changes","differ","getChanges","wasFixed","analyzedTables","Set","_iterator","_createForOfIteratorHelper","s","n","done","entry","value","table","name","type","position","nodeAfter","findAncestor","isTableAttributeEntry","range","start","has","fixTableCellsRowspan","fixTableRowsSizes","add","err","e","f","cellsToTrim","findCellsToTrim","length","_step2","_iterator2","data","updateNumericAttribute","rowspan","cell","_step3","childrenLengths","getChildrenLengths","rowsToRemove","_iterator3","entries","_step3$value","Object","D_Projects_UA_repo_Source_Client_UA_User_Web_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5__","rowIndex","size","getChild","is","push","_step4","_iterator4","reverse","remove","splice","rowsLengths","filter","row","tableSize","isValid","every","_step5","maxColumns","reduce","prev","current","_iterator5","_step5$value","columnsToInsert","i","createEmptyTableCell","createPositionAt","_step6","headingRows","parseInt","getAttribute","maxRows","Array","from","getChildren","count","_iterator6","TableWalker","_step6$value","cellHeight","isInHeader","rowLimit","newRowspan","_step7","lengths","childCount","fill","_iterator7","includeAllSlots","isAttributeType","key","attributeKey","injectTableHeadingRowsRefreshPostFixer","tableHeadingRowsRefreshPostFixer","tablesToRefresh","change","element","values","refreshItem","upcastTableFigure","dispatcher","on","evt","conversionApi","consumable","test","viewItem","classes","viewTable","getViewTableFromFigure","conversionResult","convertItem","modelCursor","modelTable","first","modelRange","getItems","convertChildren","updateConversionResult","upcastTable","_scanTable","scanTable","rows","headingColumns","attributes","createElement","safeInsert","consume","forEach","isEmpty","insert","skipEmptyTableRow","index","stop","priority","ensureParagraphInTableCell","elementName","concat","tableCell","insertElement","figureView","figureChild","firstTheadElement","tableMeta","headRows","bodyRows","_i","_Array$from","tableChild","trs","el","tr","parent","headingCols","scanRowForHeadingColumns","children","child","th","colspan","injectTableCellRefreshPostFixer","mapper","tableCellRefreshPostFixer","cellsToCheck","D_Projects_UA_repo_Source_Client_UA_User_Web_node_modules_babel_runtime_helpers_esm_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_5__","shouldRefresh","paragraph","viewElement","toViewElement","isSingleParagraphWithoutAttributes","injectTableCellParagraphPostFixer","tableCellContentsPostFixer","fixTable","fixTableRow","fixTableCellContent","checkTableCellChange","tableRow","textNodes","wrap","createRangeOn"],"mappings":";;;;GAuNe,SAASA,EAA4BC,GACnDA,EAAMC,SAASC,kBAAmB,SAAAC,GAAM,OAAIC,EAAsBD,EAAQH,KAO3E,SAASI,EAAsBD,EAAQH,GACtC,IAD8CK,EACxCC,EAAUN,EAAMC,SAASM,OAAOC,aAElCC,GAAW,EAGTC,EAAiB,IAAIC,IANmBC,EAAAC,EAQzBP,GARyB,IAQ9C,IAAAM,EAAAE,MAAAT,EAAAO,EAAAG,KAAAC,MAA+B,KAAnBC,EAAmBZ,EAAAa,MAC1BC,OAAK,EAEU,SAAdF,EAAMG,MAAiC,UAAdH,EAAMI,OACnCF,EAAQF,EAAMK,SAASC,WAIL,YAAdN,EAAMG,MAAoC,aAAdH,EAAMG,OACtCD,EAAQF,EAAMK,SAASE,aAAc,UAIjCC,EAAuBR,KAC3BE,EAAQF,EAAMS,MAAMC,MAAMH,aAAc,UAGpCL,IAAUT,EAAekB,IAAKT,KAGlCV,EAAWoB,EAAsBV,EAAOhB,IAAYM,EAEpDA,EAAWqB,EAAmBX,EAAOhB,IAAYM,EAEjDC,EAAeqB,IAAKZ,KAhCwB,MAAAa,GAAApB,EAAAqB,EAAAD,GAAA,QAAApB,EAAAsB,IAoC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EAAqBnC,EAAWpJ,IAAYM,GAJhB,MAAAuB,GAAAgB,EAAAf,EAAAD,GAAA,QAAAgB,EAAAd,IAOxC,OAAOzB,EAUR,SAASiL,EAAqBnC,EAAWpJ,GAExC,GAA6B,GAAxBoJ,EAAUrD,WAKd,OAFA/F,EAAOqJ,cAAe,YAAaD,IAE5B,EAKR,IAZiD7F,EAY3CmI,EAAYxG,MAAMC,KAAMiE,EAAUhE,eAAgBvB,OAAQ,SAAAyG,GAAK,OAAIA,EAAMjH,GAAI,WAZlCG,EAAA9C,EAgB5BgL,GAhB4B,IAgBjD,IAAAlI,EAAA7C,MAAA4C,EAAAC,EAAA5C,KAAAC,MAAiC,KAArByJ,EAAqB/G,EAAAxC,MAChCf,EAAO2L,KAAM3L,EAAO4L,cAAetB,GAAS,cAjBI,MAAAzI,GAAA2B,EAAA1B,EAAAD,GAAA,QAAA2B,EAAAzB,IAqBjD,QAAS2J,EAAUxJ,OASpB,SAASsJ,EAAsB1K,GAC9B,SAAMA,EAAMK,WAAaL,EAAMK,SAAS+I,OAAO7G,GAAI,UAAW,gBAIzC,UAAdvC,EAAMI,MAAkC,SAAdJ,EAAMG,MAAiC,UAAdH,EAAMI","file":"js/chunk-b50e103e.b76d753a.js","sourcesContent":["/**\n * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module table/converters/table-layout-post-fixer\n */\n\nimport TableWalker from './../tablewalker';\nimport { createEmptyTableCell, updateNumericAttribute } from '../utils/common';\n\n/**\n * Injects a table layout post-fixer into the model.\n *\n * The role of the table layout post-fixer is to ensure that the table rows have the correct structure\n * after a {@link module:engine/model/model~Model#change `change()`} block was executed.\n *\n * The correct structure means that:\n *\n * * All table rows have the same size.\n * * None of the table cells extend vertically beyond their section (either header or body).\n * * A table cell has always at least one element as a child.\n *\n * If the table structure is not correct, the post-fixer will automatically correct it in two steps:\n *\n * 1. It will clip table cells that extend beyond their section.\n * 2. It will add empty table cells to the rows that are narrower than the widest table row.\n *\n * ## Clipping overlapping table cells\n *\n * Such situation may occur when pasting a table (or a part of a table) to the editor from external sources.\n *\n * For example, see the following table which has a cell (FOO) with the rowspan attribute (2):\n *\n *\t\t\n *\t\t\t\n *\t\t\t\tFOO\n *\t\t\t\tBAR\n *\t\t\t\n *\t\t\t\n *\t\t\t\tBAZ\n *\t\t\t\tXYZ\n *\t\t\t\n *\t\t
\n *\n * It will be rendered in the view as:\n *\n *\t\t\n *\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\n *\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\n *\t\t
FOOBAR
BAZXYZ
\n *\n * In the above example the table will be rendered as a table with two rows: one in the header and second one in the body.\n * The table cell (FOO) cannot span over multiple rows as it would extend from the header to the body section.\n * The `rowspan` attribute must be changed to (1). The value (1) is the default value of the `rowspan` attribute\n * so the `rowspan` attribute will be removed from the model.\n *\n * The table cell with BAZ in the content will be in the first column of the table.\n *\n * ## Adding missing table cells\n *\n * The table post-fixer will insert empty table cells to equalize table row sizes (the number of columns).\n * The size of a table row is calculated by counting column spans of table cells, both horizontal (from the same row) and\n * vertical (from the rows above).\n *\n * In the above example, the table row in the body section of the table is narrower then the row from the header: it has two cells\n * with the default colspan (1). The header row has one cell with colspan (1) and the second with colspan (2).\n * The table cell (FOO) does not extend beyond the head section (and as such will be fixed in the first step of this post-fixer).\n * The post-fixer will add a missing table cell to the row in the body section of the table.\n *\n * The table from the above example will be fixed and rendered to the view as below:\n *\n *\t\t\n *\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\n *\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\n *\t\t
FOOBAR
BAZXYZ
\n *\n * ## Collaboration and undo - Expectations vs post-fixer results\n *\n * The table post-fixer only ensures proper structure without a deeper analysis of the nature of the change. As such, it might lead\n * to a structure which was not intended by the user. In particular, it will also fix undo steps (in conjunction with collaboration)\n * in which the editor content might not return to the original state.\n *\n * This will usually happen when one or more users change the size of the table.\n *\n * As an example see the table below:\n *\n *\t\t\n *\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\n *\t\t
1112
2122
\n *\n * and the user actions:\n *\n * 1. Both users have a table with two rows and two columns.\n * 2. User A adds a column at the end of the table. This will insert empty table cells to two rows.\n * 3. User B adds a row at the end of the table. This will insert a row with two empty table cells.\n * 4. Both users will have a table as below:\n *\n *\n *\t\t\n *\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\n *\t\t
1112(empty, inserted by A)
2122(empty, inserted by A)
(empty, inserted by B)(empty, inserted by B)
\n *\n * The last row is shorter then others so the table post-fixer will add an empty row to the last row:\n *\n *\t\t\n *\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\n *\t\t
1112(empty, inserted by A)
2122(empty, inserted by A)
(empty, inserted by B)(empty, inserted by B)(empty, inserted by the post-fixer)
\n *\n * Unfortunately undo does not know the nature of the changes and depending on which user applies the post-fixer changes, undoing them\n * might lead to a broken table. If User B undoes inserting the column to the table, the undo engine will undo only the operations of\n * inserting empty cells to rows from the initial table state (row 1 and 2) but the cell in the post-fixed row will remain:\n *\n *\t\t\n *\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\n *\t\t
1112
2122
(empty, inserted by B)(empty, inserted by B)(empty, inserted by a post-fixer)
\n *\n * After undo, the table post-fixer will detect that two rows are shorter than others and will fix the table to:\n *\n *\t\t\n *\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\t\n *\t\t\t\t\n *\t\t\t\n *\t\t
1112(empty, inserted by a post-fixer after undo)
2122(empty, inserted by a post-fixer after undo)
(empty, inserted by B)(empty, inserted by B)(empty, inserted by a post-fixer)
\n * @param {module:engine/model/model~Model} model\n */\nexport default function injectTableLayoutPostFixer( model ) {\n\tmodel.document.registerPostFixer( writer => tableLayoutPostFixer( writer, model ) );\n}\n\n// The table layout post-fixer.\n//\n// @param {module:engine/model/writer~Writer} writer\n// @param {module:engine/model/model~Model} model\nfunction tableLayoutPostFixer( writer, model ) {\n\tconst changes = model.document.differ.getChanges();\n\n\tlet wasFixed = false;\n\n\t// Do not analyze the same table more then once - may happen for multiple changes in the same table.\n\tconst analyzedTables = new Set();\n\n\tfor ( const entry of changes ) {\n\t\tlet table;\n\n\t\tif ( entry.name == 'table' && entry.type == 'insert' ) {\n\t\t\ttable = entry.position.nodeAfter;\n\t\t}\n\n\t\t// Fix table on adding/removing table cells and rows.\n\t\tif ( entry.name == 'tableRow' || entry.name == 'tableCell' ) {\n\t\t\ttable = entry.position.findAncestor( 'table' );\n\t\t}\n\n\t\t// Fix table on any table's attribute change - including attributes of table cells.\n\t\tif ( isTableAttributeEntry( entry ) ) {\n\t\t\ttable = entry.range.start.findAncestor( 'table' );\n\t\t}\n\n\t\tif ( table && !analyzedTables.has( table ) ) {\n\t\t\t// Step 1: correct rowspans of table cells if necessary.\n\t\t\t// The wasFixed flag should be true if any of tables in batch was fixed - might be more then one.\n\t\t\twasFixed = fixTableCellsRowspan( table, writer ) || wasFixed;\n\t\t\t// Step 2: fix table rows sizes.\n\t\t\twasFixed = fixTableRowsSizes( table, writer ) || wasFixed;\n\n\t\t\tanalyzedTables.add( table );\n\t\t}\n\t}\n\n\treturn wasFixed;\n}\n\n// Fixes the invalid value of the `rowspan` attribute because a table cell cannot vertically extend beyond the table section it belongs to.\n//\n// @param {module:engine/model/element~Element} table\n// @param {module:engine/model/writer~Writer} writer\n// @returns {Boolean} Returns `true` if the table was fixed.\nfunction fixTableCellsRowspan( table, writer ) {\n\tlet wasFixed = false;\n\n\tconst cellsToTrim = findCellsToTrim( table );\n\n\tif ( cellsToTrim.length ) {\n\t\t// @if CK_DEBUG_TABLE // console.log( `Post-fixing table: trimming cells row-spans (${ cellsToTrim.length }).` );\n\n\t\twasFixed = true;\n\n\t\tfor ( const data of cellsToTrim ) {\n\t\t\tupdateNumericAttribute( 'rowspan', data.rowspan, data.cell, writer, 1 );\n\t\t}\n\t}\n\n\treturn wasFixed;\n}\n\n// Makes all table rows in a table the same size.\n//\n// @param {module:engine/model/element~Element} table\n// @param {module:engine/model/writer~Writer} writer\n// @returns {Boolean} Returns `true` if the table was fixed.\nfunction fixTableRowsSizes( table, writer ) {\n\tlet wasFixed = false;\n\n\tconst childrenLengths = getChildrenLengths( table );\n\tconst rowsToRemove = [];\n\n\t// Find empty rows.\n\tfor ( const [ rowIndex, size ] of childrenLengths.entries() ) {\n\t\t// Ignore all non-row models.\n\t\tif ( !size && table.getChild( rowIndex ).is( 'element', 'tableRow' ) ) {\n\t\t\trowsToRemove.push( rowIndex );\n\t\t}\n\t}\n\n\t// Remove empty rows.\n\tif ( rowsToRemove.length ) {\n\t\t// @if CK_DEBUG_TABLE // console.log( `Post-fixing table: remove empty rows (${ rowsToRemove.length }).` );\n\n\t\twasFixed = true;\n\n\t\tfor ( const rowIndex of rowsToRemove.reverse() ) {\n\t\t\twriter.remove( table.getChild( rowIndex ) );\n\t\t\tchildrenLengths.splice( rowIndex, 1 );\n\t\t}\n\t}\n\n\t// Filter out everything that's not a table row.\n\tconst rowsLengths = childrenLengths.filter( ( row, rowIndex ) => table.getChild( rowIndex ).is( 'element', 'tableRow' ) );\n\n\t// Verify if all the rows have the same number of columns.\n\tconst tableSize = rowsLengths[ 0 ];\n\tconst isValid = rowsLengths.every( length => length === tableSize );\n\n\tif ( !isValid ) {\n\t\t// @if CK_DEBUG_TABLE // console.log( 'Post-fixing table: adding missing cells.' );\n\n\t\t// Find the maximum number of columns.\n\t\tconst maxColumns = rowsLengths.reduce( ( prev, current ) => current > prev ? current : prev, 0 );\n\n\t\tfor ( const [ rowIndex, size ] of rowsLengths.entries() ) {\n\t\t\tconst columnsToInsert = maxColumns - size;\n\n\t\t\tif ( columnsToInsert ) {\n\t\t\t\tfor ( let i = 0; i < columnsToInsert; i++ ) {\n\t\t\t\t\tcreateEmptyTableCell( writer, writer.createPositionAt( table.getChild( rowIndex ), 'end' ) );\n\t\t\t\t}\n\n\t\t\t\twasFixed = true;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn wasFixed;\n}\n\n// Searches for table cells that extend beyond the table section to which they belong to. It will return an array of objects\n// that stores table cells to be trimmed and the correct value of the `rowspan` attribute to set.\n//\n// @param {module:engine/model/element~Element} table\n// @returns {Array.<{{cell, rowspan}}>}\nfunction findCellsToTrim( table ) {\n\tconst headingRows = parseInt( table.getAttribute( 'headingRows' ) || 0 );\n\tconst maxRows = Array.from( table.getChildren() )\n\t\t.reduce( ( count, row ) => row.is( 'element', 'tableRow' ) ? count + 1 : count, 0 );\n\n\tconst cellsToTrim = [];\n\n\tfor ( const { row, cell, cellHeight } of new TableWalker( table ) ) {\n\t\t// Skip cells that do not expand over its row.\n\t\tif ( cellHeight < 2 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isInHeader = row < headingRows;\n\n\t\t// Row limit is either end of header section or whole table as table body is after the header.\n\t\tconst rowLimit = isInHeader ? headingRows : maxRows;\n\n\t\t// If table cell expands over its limit reduce it height to proper value.\n\t\tif ( row + cellHeight > rowLimit ) {\n\t\t\tconst newRowspan = rowLimit - row;\n\n\t\t\tcellsToTrim.push( { cell, rowspan: newRowspan } );\n\t\t}\n\t}\n\n\treturn cellsToTrim;\n}\n\n// Returns an array with lengths of rows assigned to the corresponding row index.\n//\n// @param {module:engine/model/element~Element} table\n// @returns {Array.}\nfunction getChildrenLengths( table ) {\n\t// TableWalker will not provide items for the empty rows, we need to pre-fill this array.\n\tconst lengths = new Array( table.childCount ).fill( 0 );\n\n\tfor ( const { rowIndex } of new TableWalker( table, { includeAllSlots: true } ) ) {\n\t\tlengths[ rowIndex ]++;\n\t}\n\n\treturn lengths;\n}\n\n// Checks if the differ entry for an attribute change is one of the table's attributes.\n//\n// @param entry\n// @returns {Boolean}\nfunction isTableAttributeEntry( entry ) {\n\tconst isAttributeType = entry.type === 'attribute';\n\tconst key = entry.attributeKey;\n\n\treturn isAttributeType && ( key === 'headingRows' || key === 'colspan' || key === 'rowspan' );\n}\n","/**\n * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module table/converters/table-heading-rows-refresh-post-fixer\n */\n\n/**\n * Injects a table post-fixer into the model which marks the table in the differ to have it re-rendered.\n *\n * Table heading rows are represented in the model by a `headingRows` attribute. However, in the view, it's represented as separate\n * sections of the table (`` or ``) and changing `headingRows` attribute requires moving table rows between two sections.\n * This causes problems with structural changes in a table (like adding and removing rows) thus atomic converters cannot be used.\n *\n * When table `headingRows` attribute changes, the entire table is re-rendered.\n *\n * @param {module:engine/model/model~Model} model\n */\nexport default function injectTableHeadingRowsRefreshPostFixer( model ) {\n\tmodel.document.registerPostFixer( () => tableHeadingRowsRefreshPostFixer( model ) );\n}\n\nfunction tableHeadingRowsRefreshPostFixer( model ) {\n\tconst differ = model.document.differ;\n\n\t// Stores tables to be refreshed so the table will be refreshed once for multiple changes.\n\tconst tablesToRefresh = new Set();\n\n\tfor ( const change of differ.getChanges() ) {\n\t\tif ( change.type != 'attribute' ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst element = change.range.start.nodeAfter;\n\n\t\tif ( element && element.is( 'element', 'table' ) && change.attributeKey == 'headingRows' ) {\n\t\t\ttablesToRefresh.add( element );\n\t\t}\n\t}\n\n\tif ( tablesToRefresh.size ) {\n\t\t// @if CK_DEBUG_TABLE // console.log( `Post-fixing table: refreshing heading rows (${ tablesToRefresh.size }).` );\n\n\t\tfor ( const table of tablesToRefresh.values() ) {\n\t\t\t// Should be handled by a `triggerBy` configuration. See: https://github.com/ckeditor/ckeditor5/issues/8138.\n\t\t\tdiffer.refreshItem( table );\n\t\t}\n\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n","/**\n * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module table/converters/upcasttable\n */\n\nimport { createEmptyTableCell } from '../utils/common';\nimport { first } from 'ckeditor5/src/utils';\n\n/**\n * Returns a function that converts the table view representation:\n *\n *\t\t
...
\n *\n * to the model representation:\n *\n *\t\t
\n *\n * @returns {Function}\n */\nexport function upcastTableFigure() {\n\treturn dispatcher => {\n\t\tdispatcher.on( 'element:figure', ( evt, data, conversionApi ) => {\n\t\t\t// Do not convert if this is not a \"table figure\".\n\t\t\tif ( !conversionApi.consumable.test( data.viewItem, { name: true, classes: 'table' } ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Find an table element inside the figure element.\n\t\t\tconst viewTable = getViewTableFromFigure( data.viewItem );\n\n\t\t\t// Do not convert if table element is absent or was already converted.\n\t\t\tif ( !viewTable || !conversionApi.consumable.test( viewTable, { name: true } ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Convert view table to model table.\n\t\t\tconst conversionResult = conversionApi.convertItem( viewTable, data.modelCursor );\n\n\t\t\t// Get table element from conversion result.\n\t\t\tconst modelTable = first( conversionResult.modelRange.getItems() );\n\n\t\t\t// When table wasn't successfully converted then finish conversion.\n\t\t\tif ( !modelTable ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconversionApi.convertChildren( data.viewItem, conversionApi.writer.createPositionAt( modelTable, 'end' ) );\n\t\t\tconversionApi.updateConversionResult( modelTable, data );\n\t\t} );\n\t};\n}\n\n/**\n * View table element to model table element conversion helper.\n *\n * This conversion helper converts the table element as well as table rows.\n *\n * @returns {Function} Conversion helper.\n */\nexport default function upcastTable() {\n\treturn dispatcher => {\n\t\tdispatcher.on( 'element:table', ( evt, data, conversionApi ) => {\n\t\t\tconst viewTable = data.viewItem;\n\n\t\t\t// When element was already consumed then skip it.\n\t\t\tif ( !conversionApi.consumable.test( viewTable, { name: true } ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { rows, headingRows, headingColumns } = scanTable( viewTable );\n\n\t\t\t// Only set attributes if values is greater then 0.\n\t\t\tconst attributes = {};\n\n\t\t\tif ( headingColumns ) {\n\t\t\t\tattributes.headingColumns = headingColumns;\n\t\t\t}\n\n\t\t\tif ( headingRows ) {\n\t\t\t\tattributes.headingRows = headingRows;\n\t\t\t}\n\n\t\t\tconst table = conversionApi.writer.createElement( 'table', attributes );\n\n\t\t\tif ( !conversionApi.safeInsert( table, data.modelCursor ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconversionApi.consumable.consume( viewTable, { name: true } );\n\n\t\t\t// Upcast table rows in proper order (heading rows first).\n\t\t\trows.forEach( row => conversionApi.convertItem( row, conversionApi.writer.createPositionAt( table, 'end' ) ) );\n\n\t\t\t// Convert everything else.\n\t\t\tconversionApi.convertChildren( viewTable, conversionApi.writer.createPositionAt( table, 'end' ) );\n\n\t\t\t// Create one row and one table cell for empty table.\n\t\t\tif ( table.isEmpty ) {\n\t\t\t\tconst row = conversionApi.writer.createElement( 'tableRow' );\n\t\t\t\tconversionApi.writer.insert( row, conversionApi.writer.createPositionAt( table, 'end' ) );\n\n\t\t\t\tcreateEmptyTableCell( conversionApi.writer, conversionApi.writer.createPositionAt( row, 'end' ) );\n\t\t\t}\n\n\t\t\tconversionApi.updateConversionResult( table, data );\n\t\t} );\n\t};\n}\n\n/**\n * A conversion helper that skips empty elements from upcasting at the beginning of the table.\n *\n * An empty row is considered a table model error but when handling clipboard data there could be rows that contain only row-spanned cells\n * and empty TR-s are used to maintain the table structure (also {@link module:table/tablewalker~TableWalker} assumes that there are only\n * rows that have related `tableRow` elements).\n *\n * *Note:* Only the first empty rows are removed because they have no meaning and it solves the issue\n * of an improper table with all empty rows.\n *\n * @returns {Function} Conversion helper.\n */\nexport function skipEmptyTableRow() {\n\treturn dispatcher => {\n\t\tdispatcher.on( 'element:tr', ( evt, data ) => {\n\t\t\tif ( data.viewItem.isEmpty && data.modelCursor.index == 0 ) {\n\t\t\t\tevt.stop();\n\t\t\t}\n\t\t}, { priority: 'high' } );\n\t};\n}\n\n/**\n * A converter that ensures an empty paragraph is inserted in a table cell if no other content was converted.\n *\n * @returns {Function} Conversion helper.\n */\nexport function ensureParagraphInTableCell( elementName ) {\n\treturn dispatcher => {\n\t\tdispatcher.on( `element:${ elementName }`, ( evt, data, conversionApi ) => {\n\t\t\t// The default converter will create a model range on converted table cell.\n\t\t\tif ( !data.modelRange ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Ensure a paragraph in the model for empty table cells for converted table cells.\n\t\t\tif ( data.viewItem.isEmpty ) {\n\t\t\t\tconst tableCell = data.modelRange.start.nodeAfter;\n\t\t\t\tconst modelCursor = conversionApi.writer.createPositionAt( tableCell, 0 );\n\n\t\t\t\tconversionApi.writer.insertElement( 'paragraph', modelCursor );\n\t\t\t}\n\t\t}, { priority: 'low' } );\n\t};\n}\n\n// Get view `` element from the view widget (`
`).\n//\n// @private\n// @param {module:engine/view/element~Element} figureView\n// @returns {module:engine/view/element~Element}\nfunction getViewTableFromFigure( figureView ) {\n\tfor ( const figureChild of figureView.getChildren() ) {\n\t\tif ( figureChild.is( 'element', 'table' ) ) {\n\t\t\treturn figureChild;\n\t\t}\n\t}\n}\n\n// Scans table rows and extracts required metadata from the table:\n//\n// headingRows - The number of rows that go as table headers.\n// headingColumns - The maximum number of row headings.\n// rows - Sorted `
` elements as they should go into the model - ie. if `` is inserted after `` in the view.\n//\n// @private\n// @param {module:engine/view/element~Element} viewTable\n// @returns {{headingRows, headingColumns, rows}}\nfunction scanTable( viewTable ) {\n\tconst tableMeta = {\n\t\theadingRows: 0,\n\t\theadingColumns: 0\n\t};\n\n\t// The `` and `` sections in the DOM do not have to be in order `` -> `` and there might be more than one\n\t// of them.\n\t// As the model does not have these sections, rows from different sections must be sorted.\n\t// For example, below is a valid HTML table:\n\t//\n\t//\t\t
\n\t//\t\t\t\n\t//\t\t\t\n\t//\t\t\t\n\t//\t\t
2
1
3
\n\t//\n\t// But browsers will render rows in order as: 1 as the heading and 2 and 3 as the body.\n\tconst headRows = [];\n\tconst bodyRows = [];\n\n\t// Currently the editor does not support more then one section.\n\t// Only the first from the view will be used as a heading row and the others will be converted to body rows.\n\tlet firstTheadElement;\n\n\tfor ( const tableChild of Array.from( viewTable.getChildren() ) ) {\n\t\t// Only ``, `` & `` from allowed table children can have ``s.\n\t\t// The else is for future purposes (mainly ``).\n\t\tif ( tableChild.name === 'tbody' || tableChild.name === 'thead' || tableChild.name === 'tfoot' ) {\n\t\t\t// Save the first `` in the table as table header - all other ones will be converted to table body rows.\n\t\t\tif ( tableChild.name === 'thead' && !firstTheadElement ) {\n\t\t\t\tfirstTheadElement = tableChild;\n\t\t\t}\n\n\t\t\t// There might be some extra empty text nodes between the ``s.\n\t\t\t// Make sure further code operates on `tr`s only. (#145)\n\t\t\tconst trs = Array.from( tableChild.getChildren() ).filter( el => el.is( 'element', 'tr' ) );\n\n\t\t\tfor ( const tr of trs ) {\n\t\t\t\t// This is a child of a first element.\n\t\t\t\tif ( tr.parent.name === 'thead' && tr.parent === firstTheadElement ) {\n\t\t\t\t\ttableMeta.headingRows++;\n\t\t\t\t\theadRows.push( tr );\n\t\t\t\t} else {\n\t\t\t\t\tbodyRows.push( tr );\n\t\t\t\t\t// For other rows check how many column headings this row has.\n\n\t\t\t\t\tconst headingCols = scanRowForHeadingColumns( tr, tableMeta, firstTheadElement );\n\n\t\t\t\t\tif ( headingCols > tableMeta.headingColumns ) {\n\t\t\t\t\t\ttableMeta.headingColumns = headingCols;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\ttableMeta.rows = [ ...headRows, ...bodyRows ];\n\n\treturn tableMeta;\n}\n\n// Scans a `` element and its children for metadata:\n// - For heading row:\n// - Adds this row to either the heading or the body rows.\n// - Updates the number of heading rows.\n// - For body rows:\n// - Calculates the number of column headings.\n//\n// @private\n// @param {module:engine/view/element~Element} tr\n// @returns {Number}\nfunction scanRowForHeadingColumns( tr ) {\n\tlet headingColumns = 0;\n\tlet index = 0;\n\n\t// Filter out empty text nodes from tr children.\n\tconst children = Array.from( tr.getChildren() )\n\t\t.filter( child => child.name === 'th' || child.name === 'td' );\n\n\t// Count starting adjacent elements of a .\n\twhile ( index < children.length && children[ index ].name === 'th' ) {\n\t\tconst th = children[ index ];\n\n\t\t// Adjust columns calculation by the number of spanned columns.\n\t\tconst colspan = parseInt( th.getAttribute( 'colspan' ) || 1 );\n\n\t\theadingColumns = headingColumns + colspan;\n\t\tindex++;\n\t}\n\n\treturn headingColumns;\n}\n","/**\n * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module table/converters/table-cell-refresh-post-fixer\n */\n\nimport { isSingleParagraphWithoutAttributes } from './downcast';\n\n/**\n * Injects a table cell post-fixer into the model which marks the table cell in the differ to have it re-rendered.\n *\n * Model `paragraph` inside a table cell can be rendered as `` or `

`. It is rendered as `` if this is the only block\n * element in that table cell and it does not have any attributes. It is rendered as `

` otherwise.\n *\n * When table cell content changes, for example a second `paragraph` element is added, we need to ensure that the first `paragraph` is\n * re-rendered so it changes from `` to `

`. The easiest way to do it is to re-render the entire table cell.\n *\n * @param {module:engine/model/model~Model} model\n * @param {module:engine/conversion/mapper~Mapper} mapper\n */\nexport default function injectTableCellRefreshPostFixer( model, mapper ) {\n\tmodel.document.registerPostFixer( () => tableCellRefreshPostFixer( model.document.differ, mapper ) );\n}\n\nfunction tableCellRefreshPostFixer( differ, mapper ) {\n\t// Stores cells to be refreshed, so the table cell will be refreshed once for multiple changes.\n\n\t// 1. Gather all changes inside table cell.\n\tconst cellsToCheck = new Set();\n\n\tfor ( const change of differ.getChanges() ) {\n\t\tconst parent = change.type == 'attribute' ? change.range.start.parent : change.position.parent;\n\n\t\tif ( parent.is( 'element', 'tableCell' ) ) {\n\t\t\tcellsToCheck.add( parent );\n\t\t}\n\t}\n\n\t// @if CK_DEBUG_TABLE // console.log( `Post-fixing table: Checking table cell to refresh (${ cellsToCheck.size }).` );\n\t// @if CK_DEBUG_TABLE // let paragraphsRefreshed = 0;\n\n\tfor ( const tableCell of cellsToCheck.values() ) {\n\t\tfor ( const paragraph of [ ...tableCell.getChildren() ].filter( child => shouldRefresh( child, mapper ) ) ) {\n\t\t\t// @if CK_DEBUG_TABLE // console.log( `Post-fixing table: refreshing paragraph in table cell (${++paragraphsRefreshed}).` );\n\t\t\tdiffer.refreshItem( paragraph );\n\t\t}\n\t}\n\n\t// Always return false to prevent the refresh post-fixer from re-running on the same set of changes and going into an infinite loop.\n\t// This \"post-fixer\" does not change the model structure so there shouldn't be need to run other post-fixers again.\n\t// See https://github.com/ckeditor/ckeditor5/issues/1936 & https://github.com/ckeditor/ckeditor5/issues/8200.\n\treturn false;\n}\n\n// Check if given model element needs refreshing.\n//\n// @param {module:engine/model/element~Element} modelElement\n// @param {module:engine/conversion/mapper~Mapper} mapper\n// @returns {Boolean}\nfunction shouldRefresh( child, mapper ) {\n\tif ( !child.is( 'element', 'paragraph' ) ) {\n\t\treturn false;\n\t}\n\n\tconst viewElement = mapper.toViewElement( child );\n\n\tif ( !viewElement ) {\n\t\treturn false;\n\t}\n\n\treturn isSingleParagraphWithoutAttributes( child ) !== viewElement.is( 'element', 'span' );\n}\n","/**\n * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module table/converters/table-cell-paragraph-post-fixer\n */\n\n/**\n * Injects a table cell post-fixer into the model which inserts a `paragraph` element into empty table cells.\n *\n * A table cell must contain at least one block element as a child. An empty table cell will have an empty `paragraph` as a child.\n *\n *\t\t\n *\t\t\t\n *\t\t\t\t\n *\t\t\t\n *\t\t
\n *\n * Will be fixed to:\n *\n *\t\t\n *\t\t\t\n *\t\t\t\t\n *\t\t\t\n *\t\t
\n *\n * @param {module:engine/model/model~Model} model\n */\nexport default function injectTableCellParagraphPostFixer( model ) {\n\tmodel.document.registerPostFixer( writer => tableCellContentsPostFixer( writer, model ) );\n}\n\n// The table cell contents post-fixer.\n//\n// @param {module:engine/model/writer~Writer} writer\n// @param {module:engine/model/model~Model} model\nfunction tableCellContentsPostFixer( writer, model ) {\n\tconst changes = model.document.differ.getChanges();\n\n\tlet wasFixed = false;\n\n\tfor ( const entry of changes ) {\n\t\tif ( entry.type == 'insert' && entry.name == 'table' ) {\n\t\t\twasFixed = fixTable( entry.position.nodeAfter, writer ) || wasFixed;\n\t\t}\n\n\t\tif ( entry.type == 'insert' && entry.name == 'tableRow' ) {\n\t\t\twasFixed = fixTableRow( entry.position.nodeAfter, writer ) || wasFixed;\n\t\t}\n\n\t\tif ( entry.type == 'insert' && entry.name == 'tableCell' ) {\n\t\t\twasFixed = fixTableCellContent( entry.position.nodeAfter, writer ) || wasFixed;\n\t\t}\n\n\t\tif ( checkTableCellChange( entry ) ) {\n\t\t\twasFixed = fixTableCellContent( entry.position.parent, writer ) || wasFixed;\n\t\t}\n\t}\n\n\treturn wasFixed;\n}\n\n// Fixes all table cells in a table.\n//\n// @param {module:engine/model/element~Element} table\n// @param {module:engine/model/writer~Writer} writer\nfunction fixTable( table, writer ) {\n\tlet wasFixed = false;\n\n\tfor ( const row of table.getChildren() ) {\n\t\tif ( row.is( 'element', 'tableRow' ) ) {\n\t\t\twasFixed = fixTableRow( row, writer ) || wasFixed;\n\t\t}\n\t}\n\n\treturn wasFixed;\n}\n\n// Fixes all table cells in a table row.\n//\n// @param {module:engine/model/element~Element} tableRow\n// @param {module:engine/model/writer~Writer} writer\nfunction fixTableRow( tableRow, writer ) {\n\tlet wasFixed = false;\n\n\tfor ( const tableCell of tableRow.getChildren() ) {\n\t\twasFixed = fixTableCellContent( tableCell, writer ) || wasFixed;\n\t}\n\n\treturn wasFixed;\n}\n\n// Fixes all table cell content by:\n// - Adding a paragraph to a table cell without any child.\n// - Wrapping direct $text in a ``.\n//\n// @param {module:engine/model/element~Element} table\n// @param {module:engine/model/writer~Writer} writer\n// @returns {Boolean}\nfunction fixTableCellContent( tableCell, writer ) {\n\t// Insert paragraph to an empty table cell.\n\tif ( tableCell.childCount == 0 ) {\n\t\t// @if CK_DEBUG_TABLE // console.log( 'Post-fixing table: insert paragraph in empty cell.' );\n\n\t\twriter.insertElement( 'paragraph', tableCell );\n\n\t\treturn true;\n\t}\n\n\t// Check table cell children for directly placed text nodes.\n\t// Temporary solution. See https://github.com/ckeditor/ckeditor5/issues/1464.\n\tconst textNodes = Array.from( tableCell.getChildren() ).filter( child => child.is( '$text' ) );\n\n\t// @if CK_DEBUG_TABLE // textNodes.length && console.log( 'Post-fixing table: wrap cell content with paragraph.' );\n\n\tfor ( const child of textNodes ) {\n\t\twriter.wrap( writer.createRangeOn( child ), 'paragraph' );\n\t}\n\n\t// Return true when there were text nodes to fix.\n\treturn !!textNodes.length;\n}\n\n// Checks if a differ change should fix the table cell. This happens on:\n// - Removing content from the table cell (i.e. `tableCell` can be left empty).\n// - Adding a text node directly into a table cell.\n//\n// @param {Object} differ change entry\n// @returns {Boolean}\nfunction checkTableCellChange( entry ) {\n\tif ( !entry.position || !entry.position.parent.is( 'element', 'tableCell' ) ) {\n\t\treturn false;\n\t}\n\n\treturn entry.type == 'insert' && entry.name == '$text' || entry.type == 'remove';\n}\n"],"sourceRoot":""}