diff --git a/services/web/frontend/js/features/source-editor/components/table-generator/toolbar/commands.ts b/services/web/frontend/js/features/source-editor/components/table-generator/toolbar/commands.ts index bdcaefbb0d..52c608fe17 100644 --- a/services/web/frontend/js/features/source-editor/components/table-generator/toolbar/commands.ts +++ b/services/web/frontend/js/features/source-editor/components/table-generator/toolbar/commands.ts @@ -236,6 +236,7 @@ export const removeRowOrColumns = ( minY: startRow, maxY: endRow, } = selection.normalized() + const borderTheme = table.getBorderTheme() const changes: { from: number; to: number; insert: string }[] = [] const specification = view.state.sliceDoc( positions.columnDeclarations.from, @@ -259,10 +260,17 @@ export const removeRowOrColumns = ( for (let row = startRow; row <= endRow; row++) { if (selection.isRowSelected(row, table)) { const rowPosition = positions.rowPositions[row] + let insert = '' + if ( + row === numberOfRows - 1 && + borderTheme === BorderTheme.FULLY_BORDERED + ) { + insert = '\\hline' + } changes.push({ from: rowPosition.from, to: rowPosition.to, - insert: '', + insert, }) } else { for (let cell = startCell; cell <= endCell; ) { diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-table-generator.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-table-generator.spec.tsx index 31a20651e7..361a08d0e7 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-table-generator.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-table-generator.spec.tsx @@ -265,10 +265,11 @@ cell 3 & cell 4 \\\\ it('Removes rows and columns', function () { mountEditor(` -\\begin{tabular}{ccc} - cell 1 & cell 2 & cell 3 \\\\ - cell 4 & cell 5 & cell 6 \\\\ - cell 7 & cell 8 & cell 9 \\\\ +\\begin{tabular}{|c|c|c|} + \\hline + cell 1 & cell 2 & cell 3 \\\\ \\hline + cell 4 & cell 5 & cell 6 \\\\ \\hline + cell 7 & cell 8 & cell 9 \\\\ \\hline \\end{tabular} `) checkTable([ @@ -288,12 +289,13 @@ cell 3 & cell 4 \\\\ ['cell 4', 'cell 6'], ['cell 7', 'cell 9'], ]) - cy.get('.row-selector').eq(1).click() + cy.get('.row-selector').eq(2).click() cy.get('@toolbar').findByLabelText('Delete row or column').click() checkTable([ ['cell 1', 'cell 3'], - ['cell 7', 'cell 9'], + ['cell 4', 'cell 6'], ]) + checkBordersWithNoMultiColumn([true, true, true], [true, true, true]) }) it('Removes rows correctly when removing from the left', function () {