({
editor,
element,
attributes,
children,
})
| 13 | } |
| 14 | |
| 15 | const Row: React.FC<TableRowProps & RenderElementProps<TableRow, HTMLTableRowElement>> = ({ |
| 16 | editor, |
| 17 | element, |
| 18 | attributes, |
| 19 | children, |
| 20 | }) => { |
| 21 | const { style, ref, ...rest } = attributes |
| 22 | // 表格宽度变化导致挤压内容需要重新计算高度 |
| 23 | const { width } = useTableSize() |
| 24 | // 单元格内容变动后重新计算行的高度 |
| 25 | useIsomorphicLayoutEffect(() => { |
| 26 | let maxHeight = getOptions(editor).minRowHeight |
| 27 | const rect = ref.current.getBoundingClientRect() |
| 28 | maxHeight = Math.max(maxHeight, rect.height) |
| 29 | if (maxHeight !== RowStore.getContentHeight(element)) { |
| 30 | RowStore.setContentHeight(element, maxHeight) |
| 31 | } |
| 32 | }, [editor, ref, width, element]) |
| 33 | |
| 34 | return ( |
| 35 | <RowStyles ref={ref} style={{ height: element.height, ...style }} {...rest}> |
| 36 | {children} |
| 37 | </RowStyles> |
| 38 | ) |
| 39 | } |
| 40 | |
| 41 | export const withTableRow = <T extends Editable>(editor: T, options: TableRowOptions = {}) => { |
| 42 | const newEditor = editor as T & TableRowEditor |
nothing calls this directly
no test coverage detected