mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #14811 from overleaf/mj-table-cell-overflow-selection-border
[visual] Fix cell overflow and cell selection outline GitOrigin-RevId: 91cea09956d27162283c12e842f0b5e1680ed582
This commit is contained in:
parent
e7519be904
commit
a4de4dbd3e
3 changed files with 16 additions and 18 deletions
|
@ -180,7 +180,7 @@ export const Cell: FC<{
|
|||
[update, filterInput]
|
||||
)
|
||||
|
||||
let body = <div ref={renderDiv} />
|
||||
let body = <div ref={renderDiv} className="table-generator-cell-render" />
|
||||
if (editing) {
|
||||
body = (
|
||||
<CellInput
|
||||
|
|
|
@ -53,7 +53,7 @@ export const Table: FC = () => {
|
|||
const { table: tableData } = useTableContext()
|
||||
const tableRef = useRef<HTMLTableElement>(null)
|
||||
const view = useCodeMirrorViewContext()
|
||||
const cellWidths: number[] = useMemo(() => {
|
||||
const { columns: cellWidths, tableWidth } = useMemo(() => {
|
||||
const columns = Array.from(
|
||||
{ length: tableData.columns.length },
|
||||
() => MINIMUM_CELL_WIDTH_CHARACTERS
|
||||
|
@ -95,9 +95,9 @@ export const Table: FC = () => {
|
|||
// Third pass, normalize the columns to the total width of the table
|
||||
const totalLog = columns.reduce((a, b) => a + b, 0)
|
||||
for (let i = 0; i < columns.length; ++i) {
|
||||
columns[i] = Math.round((columns[i] / totalLog) * total)
|
||||
columns[i] = Math.round((columns[i] / totalLog) * 100)
|
||||
}
|
||||
return columns
|
||||
return { columns, tableWidth: total }
|
||||
}, [
|
||||
tableData,
|
||||
cellData?.cellIndex,
|
||||
|
@ -333,20 +333,15 @@ export const Table: FC = () => {
|
|||
onKeyDown={onKeyDown}
|
||||
tabIndex={-1}
|
||||
ref={tableRef}
|
||||
style={{ width: `${tableWidth}ch` }}
|
||||
>
|
||||
<colgroup>
|
||||
<col width="20" />
|
||||
{tableData.columns.map((_, index) => (
|
||||
<col key={index} width={`${cellWidths[index]}%`} />
|
||||
))}
|
||||
</colgroup>
|
||||
<thead>
|
||||
{/* A workaround for a chrome bug where it will not respect colspan
|
||||
unless there is a row filled with cells without colspan */}
|
||||
<tr className="table-generator-filler-row">
|
||||
{/* A td for the row selector */}
|
||||
<td />
|
||||
{tableData.columns.map((_, columnIndex) => (
|
||||
<td
|
||||
key={columnIndex}
|
||||
style={{ width: `${cellWidths[columnIndex]}ch` }}
|
||||
/>
|
||||
))}
|
||||
</tr>
|
||||
<tr>
|
||||
<td />
|
||||
{tableData.columns.map((_, columnIndex) => (
|
||||
|
|
|
@ -117,8 +117,11 @@ export const tableGeneratorTheme = EditorView.baseTheme({
|
|||
'border-bottom-color': 'var(--table-generator-active-border-color)',
|
||||
'border-bottom-width': 'var(--table-generator-active-border-width)',
|
||||
},
|
||||
'overflow-x': 'auto',
|
||||
'overflow-y': 'hidden',
|
||||
'& .table-generator-cell-render': {
|
||||
'overflow-x': 'auto',
|
||||
'overflow-y': 'hidden',
|
||||
width: '100%',
|
||||
},
|
||||
},
|
||||
|
||||
'.table-generator-table': {
|
||||
|
|
Loading…
Reference in a new issue