From e56de460c9a21252dac524704c9b9a195463322a Mon Sep 17 00:00:00 2001 From: Abhay V Ashokan Date: Fri, 22 Mar 2024 19:00:03 +0530 Subject: [PATCH] Added a minimum width to the table columns --- .../Editor/CustomExtensions/Table/ExtensionConfig.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Editor/CustomExtensions/Table/ExtensionConfig.js b/src/components/Editor/CustomExtensions/Table/ExtensionConfig.js index db9175cb..06070032 100644 --- a/src/components/Editor/CustomExtensions/Table/ExtensionConfig.js +++ b/src/components/Editor/CustomExtensions/Table/ExtensionConfig.js @@ -16,7 +16,12 @@ const Table = TiptapTable.extend({ }, renderHTML({ node }) { const colgroups = node?.content?.content?.[0]?.content?.content?.map( - col => ["col", { style: `width: ${col.attrs?.colwidth || 100}px;` }] + col => { + let style = "min-width: 100px;"; + if (col.attrs?.colwidth) style += `width: ${col.attrs.colwidth}px;`; + + return ["col", { style }]; + } ); return ["table", {}, ["colgroup", ...colgroups], ["tbody", 0]];