From 8b607328036c922d3c1e32104aea497cba056219 Mon Sep 17 00:00:00 2001 From: Oli Jones <78092825+duckRabbitPy@users.noreply.github.com> Date: Fri, 3 Nov 2023 16:39:16 +0000 Subject: [PATCH 1/2] handle new row header property --- .../table/src/transforms/insertTableRow.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/table/src/transforms/insertTableRow.ts b/packages/table/src/transforms/insertTableRow.ts index 5204bd182b..cd5a1a3a2a 100644 --- a/packages/table/src/transforms/insertTableRow.ts +++ b/packages/table/src/transforms/insertTableRow.ts @@ -59,16 +59,18 @@ export const insertTableRow = ( 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, () => { From dd6a2a5b5b9a3aa1c6a3ca90fde9ef0cb70915c0 Mon Sep 17 00:00:00 2001 From: Ziad Beyens Date: Tue, 28 Nov 2023 11:37:50 +0100 Subject: [PATCH 2/2] Create six-bears-destroy.md --- .changeset/six-bears-destroy.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changeset/six-bears-destroy.md diff --git a/.changeset/six-bears-destroy.md b/.changeset/six-bears-destroy.md new file mode 100644 index 0000000000..d3bbd187a2 --- /dev/null +++ b/.changeset/six-bears-destroy.md @@ -0,0 +1,8 @@ +--- +"@udecode/plate-table": patch +--- + +Table row insertion: cells in a newly added row will now receive header styling only if they satisfy specific criteria: +- Every cell in the column is a header cell, +- The table contains more than one row, or +- The column possesses a predefined header property.