Skip to content

Commit

Permalink
handle new row header property
Browse files Browse the repository at this point in the history
  • Loading branch information
duckRabbitPy committed Nov 3, 2023
1 parent 9d2931b commit 8b60732
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/table/src/transforms/insertTableRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,18 @@ export const insertTableRow = <V extends Value>(

const getEmptyRowNode = () => ({
type: getPluginType(editor, ELEMENT_TR),
children: (trNode.children as TElement[]).map((_, i) =>
getEmptyCellNode(editor, {
header:
header ??
(tableEntry[0].children as TElement[]).every(
(n) => n.children[i].type === ELEMENT_TH
),
children: (trNode.children as TElement[]).map((_, i) => {
const hasSingleRow = tableEntry[0].children.length === 1;
const isHeaderColumn =
!hasSingleRow &&
(tableEntry[0].children as TElement[]).every(
(n) => n.children[i].type === ELEMENT_TH
);
return getEmptyCellNode(editor, {
header: header ?? isHeaderColumn,
...newCellChildren,
})
),
});
}),
});

withoutNormalizing(editor, () => {
Expand Down

0 comments on commit 8b60732

Please sign in to comment.