Skip to content

Commit

Permalink
move indices update to useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaanj committed Nov 20, 2023
1 parent 7dd65bd commit 2b9861f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 63 deletions.
12 changes: 6 additions & 6 deletions packages/table/src/components/TableElement/useTableElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ export const useTableElementState = ({
} = {}): TableElementState => {
const editor = useEditorRef();

const { minColumnWidth, disableMarginLeft } = getPluginOptions<TablePlugin>(
editor,
ELEMENT_TABLE
);
const { minColumnWidth, disableMarginLeft, disableCellsMerging } =
getPluginOptions<TablePlugin>(editor, ELEMENT_TABLE);

const element = useElement<TTableElement>();
const selectedCells = useTableStore().get.selectedCells();
Expand All @@ -46,8 +44,10 @@ export const useTableElementState = ({
let colSizes = useTableColSizes(element);

useEffect(() => {
computeAllCellIndices(editor, element);
}, [editor, element]);
if (!disableCellsMerging) {
computeAllCellIndices(editor, element);
}
}, [editor, element, disableCellsMerging]);

if (transformColSizes) {
colSizes = transformColSizes(colSizes);
Expand Down
54 changes: 0 additions & 54 deletions packages/table/src/withMergedCells.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/table/src/withTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ export const withTable = <
editor: E,
plugin: WithPlatePlugin<TablePlugin<V>, V, E>
) => {
editor = plugin.options.disableCellsMerging
? editor
: withMergedCells<V, E>(editor);
editor = withNormalizeTable<V, E>(editor);
editor = withDeleteTable<V, E>(editor);
editor = withGetFragmentTable<V, E>(editor);
Expand Down

0 comments on commit 2b9861f

Please sign in to comment.