fix(extension-table): correctly set min-width for table (#4684)

This commit is contained in:
Moch. Irfan Rafif 2024-07-24 19:16:48 +07:00 committed by GitHub
parent 5283a51931
commit c7f55500ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
"@tiptap/extension-table": patch
---
Set correct `min-width` for a table fixes #5217

View File

@ -63,7 +63,7 @@ context('/src/Nodes/Table/React/', () => {
const html = editor.getHTML()
expect(html).to.equal(
'<table style="minWidth: 25px"><colgroup><col></colgroup><tbody><tr><td colspan="1" rowspan="1"><p></p></td></tr></tbody></table>',
'<table style="min-width: 25px"><colgroup><col></colgroup><tbody><tr><td colspan="1" rowspan="1"><p></p></td></tr></tbody></table>',
)
})
})
@ -75,7 +75,7 @@ context('/src/Nodes/Table/React/', () => {
const html = editor.getHTML()
expect(html).to.equal(
'<table style="minWidth: 25px"><colgroup><col></colgroup><tbody><tr><th colspan="1" rowspan="1"><p></p></th></tr></tbody></table>',
'<table style="min-width: 25px"><colgroup><col></colgroup><tbody><tr><th colspan="1" rowspan="1"><p></p></th></tr></tbody></table>',
)
})
})

View File

@ -62,7 +62,7 @@ context('/src/Nodes/Table/Vue/', () => {
const html = editor.getHTML()
expect(html).to.equal('<table style="minWidth: 25px"><colgroup><col></colgroup><tbody><tr><td colspan="1" rowspan="1"><p></p></td></tr></tbody></table>')
expect(html).to.equal('<table style="min-width: 25px"><colgroup><col></colgroup><tbody><tr><td colspan="1" rowspan="1"><p></p></td></tr></tbody></table>')
})
})
@ -72,7 +72,7 @@ context('/src/Nodes/Table/Vue/', () => {
const html = editor.getHTML()
expect(html).to.equal('<table style="minWidth: 25px"><colgroup><col></colgroup><tbody><tr><th colspan="1" rowspan="1"><p></p></th></tr></tbody></table>')
expect(html).to.equal('<table style="min-width: 25px"><colgroup><col></colgroup><tbody><tr><th colspan="1" rowspan="1"><p></p></th></tr></tbody></table>')
})
})

View File

@ -286,7 +286,7 @@ export const Table = Node.create<TableOptions>({
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
style: tableWidth
? `width: ${tableWidth}`
: `minWidth: ${tableMinWidth}`,
: `min-width: ${tableMinWidth}`,
}),
colgroup,
['tbody', 0],