From 573105cbab1d48df6a80cf8f8e3deab38b948171 Mon Sep 17 00:00:00 2001 From: Alex Reznik Date: Mon, 3 Jun 2024 21:50:43 +0100 Subject: [PATCH] [lexical-table] Bug Fix: Change exported table column width (#6243) Co-authored-by: areznik10 --- packages/lexical-table/src/LexicalTableCellNode.ts | 8 ++------ packages/lexical-table/src/constants.ts | 4 ++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/lexical-table/src/LexicalTableCellNode.ts b/packages/lexical-table/src/LexicalTableCellNode.ts index a6246b699fe..455d39bf6c9 100644 --- a/packages/lexical-table/src/LexicalTableCellNode.ts +++ b/packages/lexical-table/src/LexicalTableCellNode.ts @@ -28,7 +28,7 @@ import { ElementNode, } from 'lexical'; -import {PIXEL_VALUE_REG_EXP} from './constants'; +import {COLUMN_WIDTH, PIXEL_VALUE_REG_EXP} from './constants'; export const TableCellHeaderStates = { BOTH: 3, @@ -152,8 +152,6 @@ export class TableCellNode extends ElementNode { if (element) { const element_ = element as HTMLTableCellElement; - const maxWidth = 700; - const colCount = this.getParentOrThrow().getChildrenSize(); element_.style.border = '1px solid black'; if (this.__colSpan > 1) { element_.colSpan = this.__colSpan; @@ -161,9 +159,7 @@ export class TableCellNode extends ElementNode { if (this.__rowSpan > 1) { element_.rowSpan = this.__rowSpan; } - element_.style.width = `${ - this.getWidth() || Math.max(90, maxWidth / colCount) - }px`; + element_.style.width = `${this.getWidth() || COLUMN_WIDTH}px`; element_.style.verticalAlign = 'top'; element_.style.textAlign = 'start'; diff --git a/packages/lexical-table/src/constants.ts b/packages/lexical-table/src/constants.ts index 2a23fe63d35..ffa6ba1c35b 100644 --- a/packages/lexical-table/src/constants.ts +++ b/packages/lexical-table/src/constants.ts @@ -7,3 +7,7 @@ */ export const PIXEL_VALUE_REG_EXP = /^(\d+(?:\.\d+)?)px$/; + +// .PlaygroundEditorTheme__tableCell width value from +// packages/lexical-playground/src/themes/PlaygroundEditorTheme.css +export const COLUMN_WIDTH = 75;