Skip to content

Commit

Permalink
Merge pull request #2541 from udecode/react-tweets
Browse files Browse the repository at this point in the history
Resizable headless
  • Loading branch information
zbeyens committed Jul 27, 2023
1 parent c0eb53b commit 4d1e706
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/plate-ui/table-element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React, { forwardRef } from 'react';
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
import { PopoverAnchor, PopoverContentProps } from '@radix-ui/react-popover';
import {
isCollapsed,
findNodePath,
getBlockAbove,
PlateElement,
PlateElementProps,
someNode,
useElement,
usePlateEditorState,
useRemoveNodeButton,
Expand All @@ -16,6 +16,7 @@ import {
useTableElement,
useTableElementState,
} from '@udecode/plate-table';
import { Path } from 'slate';
import { useReadOnly } from 'slate-react';

import { cn } from '@/lib/utils';
Expand Down Expand Up @@ -114,12 +115,13 @@ const TableFloatingToolbar = React.forwardRef<

const readOnly = useReadOnly();
const editor = usePlateEditorState();
const path = findNodePath(editor, element);
const open =
path &&
!readOnly &&
someNode(editor, {
match: (n) => n === element,
}) &&
isCollapsed(editor.selection);
!!getBlockAbove(editor, {
match: (_n, p) => Path.equals(path, p),
});

return (
<Popover open={open}>
Expand Down

0 comments on commit 4d1e706

Please sign in to comment.