Skip to content

Commit

Permalink
fix: layout of table in read-only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
petyosi committed Jan 14, 2024
1 parent f6aae27 commit 888cd00
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/plugins/table/TableEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,20 @@ export const TableEditor: React.FC<TableEditorProps> = ({ mdastNode, parentEdito
setHighlightedCoordinates([colIndex, rowIndex])
}, [])

// remove tool cols in readOnly mode
return (
<table className={styles.tableEditor} onMouseOver={onTableMouseOver} onMouseLeave={() => setHighlightedCoordinates([-1, -1])}>
<colgroup>
<col />
{readOnly ? null : <col />}

{Array.from({ length: mdastNode.children[0].children.length }, (_, colIndex) => {
const align = mdastNode.align || []
const currentColumnAlign = align[colIndex] || 'left'
const className = AlignToTailwindClassMap[currentColumnAlign]
return <col key={colIndex} className={className} />
})}
<col />

{readOnly ? null : <col />}
</colgroup>

{readOnly || (
Expand Down

0 comments on commit 888cd00

Please sign in to comment.