diff --git a/packages/extension-table/src/TableView.ts b/packages/extension-table/src/TableView.ts index 4d882bc3b5a..b7775bed74c 100644 --- a/packages/extension-table/src/TableView.ts +++ b/packages/extension-table/src/TableView.ts @@ -30,14 +30,19 @@ export function updateColumns( fixedWidth = false } - if (nextDOM === null) { + if (!nextDOM) { const colElement = document.createElement('col') - colElement.style.setProperty(...getColStyleDeclaration(cellMinWidth, hasWidth)) + const [propertyKey, propertyValue] = getColStyleDeclaration(cellMinWidth, hasWidth) + + colElement.style.setProperty(propertyKey, propertyValue) + colgroup.appendChild(colElement) } else { if ((nextDOM as HTMLTableColElement).style.width !== cssWidth) { - (nextDOM as HTMLTableColElement).style.setProperty(...getColStyleDeclaration(cellMinWidth, hasWidth)) + const [propertyKey, propertyValue] = getColStyleDeclaration(cellMinWidth, hasWidth); + + (nextDOM as HTMLTableColElement).style.setProperty(propertyKey, propertyValue) } nextDOM = nextDOM.nextSibling diff --git a/packages/extension-table/src/utilities/colStyle.ts b/packages/extension-table/src/utilities/colStyle.ts index 4992377430b..0453d94a489 100644 --- a/packages/extension-table/src/utilities/colStyle.ts +++ b/packages/extension-table/src/utilities/colStyle.ts @@ -8,7 +8,3 @@ export function getColStyleDeclaration(minWidth: number, width: number | undefin return ['min-width', `${minWidth}px`] } - -export function getColStyle(minWidth: number, width: number): string { - return getColStyleDeclaration(minWidth, width).join(': ') -} diff --git a/packages/extension-table/src/utilities/createColGroup.ts b/packages/extension-table/src/utilities/createColGroup.ts index a4fa465c3f3..920bc7b18b4 100644 --- a/packages/extension-table/src/utilities/createColGroup.ts +++ b/packages/extension-table/src/utilities/createColGroup.ts @@ -1,6 +1,6 @@ import { DOMOutputSpec, Node as ProseMirrorNode } from '@tiptap/pm/model' -import { getColStyle } from './colStyle.js' +import { getColStyleDeclaration } from './colStyle.js' export type ColGroup = { colgroup: DOMOutputSpec @@ -54,9 +54,11 @@ export function createColGroup( fixedWidth = false } + const [property, value] = getColStyleDeclaration(cellMinWidth, hasWidth) + cols.push([ 'col', - { style: getColStyle(cellMinWidth, hasWidth) }, + { style: { [property]: value } }, ]) } }