MCPcopy Create free account
hub / github.com/editablejs/editable / Row

Function Row

packages/plugins/table/src/row/plugin/with-table-row.tsx:15–39  ·  view source on GitHub ↗
({
  editor,
  element,
  attributes,
  children,
})

Source from the content-addressed store, hash-verified

13}
14
15const 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
41export const withTableRow = <T extends Editable>(editor: T, options: TableRowOptions = {}) => {
42 const newEditor = editor as T & TableRowEditor

Callers

nothing calls this directly

Calls 2

useTableSizeFunction · 0.90
getOptionsFunction · 0.90

Tested by

no test coverage detected