Skip to content

Commit

Permalink
[lexical-table] Bug Fix: Change exported table column width (#6243)
Browse files Browse the repository at this point in the history
Co-authored-by: areznik10 <[email protected]>
  • Loading branch information
AlexanderReznik and areznik10 authored Jun 3, 2024
1 parent b77c39a commit 573105c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/lexical-table/src/LexicalTableCellNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -152,18 +152,14 @@ 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;
}
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';
Expand Down
4 changes: 4 additions & 0 deletions packages/lexical-table/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 573105c

Please sign in to comment.