Merge pull request #25469 from overleaf/mj-paste-tables-multicol

[web] Improve borders and column definitions of pasted tables with multi-column cells

GitOrigin-RevId: fe9c44bd8ac6a34e8a8057f1a07d97771a116e1a
This commit is contained in:
Kristina
2025-05-13 08:06:10 +00:00
committed by Copybot
parent 70c26b6ed2
commit 67a436b639
2 changed files with 62 additions and 11 deletions
@@ -227,6 +227,40 @@ describe('<CodeMirrorEditor/> paste HTML in Visual mode', function () {
cy.get('.table-generator-cell[colspan="2"]').should('have.length', 2)
})
it('handles a pasted 1-row table with merged columns', function () {
mountEditor()
const data = [
`<table><tbody>`,
`<tr><td>test</td><td colspan="2">test</td></tr>`,
`</tbody></table>`,
].join('')
const clipboardData = new DataTransfer()
clipboardData.setData('text/html', data)
cy.get('@content').trigger('paste', { clipboardData })
cy.get('@content').should('have.text', 'testtest' + menuIconsText)
cy.get('.table-generator-cell').should('have.length', 2)
cy.get('.table-generator-cell[colspan="2"]').should('have.length', 1)
})
it('handles a pasted table with a bordered merged column', function () {
mountEditor()
const data = [
`<table><tbody>`,
`<tr><td style="border-right:1px solid black;border-left:1px solid black;">test</td></tr>`,
`</tbody></table>`,
].join('')
const clipboardData = new DataTransfer()
clipboardData.setData('text/html', data)
cy.get('@content').trigger('paste', { clipboardData })
cy.get('.table-generator-cell-border-right').should('have.length', 1)
cy.get('.table-generator-cell-border-left').should('have.length', 1)
})
it('handles a pasted table with merged rows', function () {
mountEditor()
@@ -312,8 +346,8 @@ describe('<CodeMirrorEditor/> paste HTML in Visual mode', function () {
cy.get('@content').should('have.text', 'foofoobarfoobar' + menuIconsText)
cy.get('.table-generator-cell').should('have.length', 5)
cy.get('.table-generator-cell[colspan="2"]').should('have.length', 1)
cy.get('.table-generator-cell-border-left').should('have.length', 2)
cy.get('.table-generator-cell-border-right').should('have.length', 4)
cy.get('.table-generator-cell-border-left').should('have.length', 3)
cy.get('.table-generator-cell-border-right').should('have.length', 5)
cy.get('.table-generator-row-border-top').should('have.length', 5)
cy.get('.table-generator-row-border-bottom').should('have.length', 2)
})