From edfc23661bcf9c860f6bcd15999131e032c55074 Mon Sep 17 00:00:00 2001 From: Petyo Ivanov Date: Mon, 11 Dec 2023 18:48:17 +0200 Subject: [PATCH] fix: consistent table click handlers Fixes #230 --- src/plugins/table/TableEditor.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/plugins/table/TableEditor.tsx b/src/plugins/table/TableEditor.tsx index 94cf6be9..4b8a57b8 100644 --- a/src/plugins/table/TableEditor.tsx +++ b/src/plugins/table/TableEditor.tsx @@ -47,12 +47,11 @@ export const TableEditor: React.FC = ({ mdastNode, parentEdito const [activeCell, setActiveCell] = React.useState<[number, number] | null>(null) const [iconComponentFor, readOnly] = corePluginHooks.useEmitterValues('iconComponentFor', 'readOnly') const getCellKey = React.useMemo(() => { - const cellKeyMap = new WeakMap() - return (cell: Mdast.TableCell) => { - if (!cellKeyMap.has(cell)) { - cellKeyMap.set(cell, uuidv4()) + return (cell: Mdast.TableCell & { __cacheKey?: string }) => { + if (!cell.__cacheKey) { + cell.__cacheKey = uuidv4() } - return cellKeyMap.get(cell)! + return cell.__cacheKey } }, [])