mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 01:06:23 +02:00
refactor: remove unused dropdown menu and related components from TableFloatingToolbar for cleaner code
This commit is contained in:
parent
1768887be8
commit
841e764729
2 changed files with 1 additions and 113 deletions
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
import * as React from 'react';
|
||||
|
||||
import type * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
||||
|
||||
import { useDraggable, useDropLine } from '@platejs/dnd';
|
||||
import {
|
||||
BlockSelectionPlugin,
|
||||
|
|
@ -12,7 +10,6 @@ import {
|
|||
import {
|
||||
TablePlugin,
|
||||
TableProvider,
|
||||
useTableBordersDropdownMenuContentState,
|
||||
useTableCellElement,
|
||||
useTableCellElementResizable,
|
||||
useTableElement,
|
||||
|
|
@ -26,7 +23,6 @@ import {
|
|||
ArrowRight,
|
||||
ArrowUp,
|
||||
CombineIcon,
|
||||
Grid2X2Icon,
|
||||
GripVertical,
|
||||
SquareSplitHorizontalIcon,
|
||||
Trash2Icon,
|
||||
|
|
@ -58,27 +54,11 @@ import {
|
|||
import { useElementSelector } from 'platejs/react';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuCheckboxItem,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuPortal,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { Popover, PopoverContent } from '@/components/ui/popover';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import { blockSelectionVariants } from './block-selection';
|
||||
import { ResizeHandle } from './resize-handle';
|
||||
import {
|
||||
BorderAllIcon,
|
||||
BorderBottomIcon,
|
||||
BorderLeftIcon,
|
||||
BorderNoneIcon,
|
||||
BorderRightIcon,
|
||||
BorderTopIcon,
|
||||
} from './table-icons';
|
||||
import {
|
||||
Toolbar,
|
||||
ToolbarButton,
|
||||
|
|
@ -192,18 +172,6 @@ function TableFloatingToolbar({
|
|||
</ToolbarButton>
|
||||
)}
|
||||
|
||||
<DropdownMenu modal={false}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<ToolbarButton tooltip="Cell borders">
|
||||
<Grid2X2Icon />
|
||||
</ToolbarButton>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuPortal>
|
||||
<TableBordersDropdownMenuContent />
|
||||
</DropdownMenuPortal>
|
||||
</DropdownMenu>
|
||||
|
||||
{collapsedInside && (
|
||||
<ToolbarGroup>
|
||||
<ToolbarButton tooltip="Delete table" {...buttonProps}>
|
||||
|
|
@ -282,83 +250,6 @@ function TableFloatingToolbar({
|
|||
);
|
||||
}
|
||||
|
||||
function TableBordersDropdownMenuContent(
|
||||
props: React.ComponentProps<typeof DropdownMenuPrimitive.Content>
|
||||
) {
|
||||
const editor = useEditorRef();
|
||||
const {
|
||||
getOnSelectTableBorder,
|
||||
hasBottomBorder,
|
||||
hasLeftBorder,
|
||||
hasNoBorders,
|
||||
hasOuterBorders,
|
||||
hasRightBorder,
|
||||
hasTopBorder,
|
||||
} = useTableBordersDropdownMenuContentState();
|
||||
|
||||
return (
|
||||
<DropdownMenuContent
|
||||
className="min-w-[220px]"
|
||||
onCloseAutoFocus={(e) => {
|
||||
e.preventDefault();
|
||||
editor.tf.focus();
|
||||
}}
|
||||
align="start"
|
||||
side="right"
|
||||
sideOffset={0}
|
||||
{...props}
|
||||
>
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuCheckboxItem
|
||||
checked={hasTopBorder}
|
||||
onCheckedChange={getOnSelectTableBorder('top')}
|
||||
>
|
||||
<BorderTopIcon />
|
||||
<div>Top Border</div>
|
||||
</DropdownMenuCheckboxItem>
|
||||
<DropdownMenuCheckboxItem
|
||||
checked={hasRightBorder}
|
||||
onCheckedChange={getOnSelectTableBorder('right')}
|
||||
>
|
||||
<BorderRightIcon />
|
||||
<div>Right Border</div>
|
||||
</DropdownMenuCheckboxItem>
|
||||
<DropdownMenuCheckboxItem
|
||||
checked={hasBottomBorder}
|
||||
onCheckedChange={getOnSelectTableBorder('bottom')}
|
||||
>
|
||||
<BorderBottomIcon />
|
||||
<div>Bottom Border</div>
|
||||
</DropdownMenuCheckboxItem>
|
||||
<DropdownMenuCheckboxItem
|
||||
checked={hasLeftBorder}
|
||||
onCheckedChange={getOnSelectTableBorder('left')}
|
||||
>
|
||||
<BorderLeftIcon />
|
||||
<div>Left Border</div>
|
||||
</DropdownMenuCheckboxItem>
|
||||
</DropdownMenuGroup>
|
||||
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuCheckboxItem
|
||||
checked={hasNoBorders}
|
||||
onCheckedChange={getOnSelectTableBorder('none')}
|
||||
>
|
||||
<BorderNoneIcon />
|
||||
<div>No Border</div>
|
||||
</DropdownMenuCheckboxItem>
|
||||
<DropdownMenuCheckboxItem
|
||||
checked={hasOuterBorders}
|
||||
onCheckedChange={getOnSelectTableBorder('outer')}
|
||||
>
|
||||
<BorderAllIcon />
|
||||
<div>Outside Borders</div>
|
||||
</DropdownMenuCheckboxItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
);
|
||||
}
|
||||
|
||||
export function TableRowElement({
|
||||
children,
|
||||
...props
|
||||
|
|
|
|||
|
|
@ -331,7 +331,6 @@ function withTooltip<T extends React.ElementType>(Component: T) {
|
|||
function TooltipContent({
|
||||
children,
|
||||
className,
|
||||
// CHANGE
|
||||
sideOffset = 4,
|
||||
...props
|
||||
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
||||
|
|
@ -339,7 +338,7 @@ function TooltipContent({
|
|||
<TooltipPrimitive.Portal>
|
||||
<TooltipPrimitive.Content
|
||||
className={cn(
|
||||
'z-50 w-fit origin-(--radix-tooltip-content-transform-origin) text-balance rounded-md bg-primary px-3 py-1.5 text-primary-foreground text-xs',
|
||||
'bg-black text-white font-medium shadow-xl px-3 py-1.5 dark:bg-zinc-800 dark:text-zinc-50 border-none animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit rounded-md text-xs text-balance pointer-events-none',
|
||||
className
|
||||
)}
|
||||
data-slot="tooltip-content"
|
||||
|
|
@ -347,8 +346,6 @@ function TooltipContent({
|
|||
{...props}
|
||||
>
|
||||
{children}
|
||||
{/* CHANGE */}
|
||||
{/* <TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-primary fill-primary" /> */}
|
||||
</TooltipPrimitive.Content>
|
||||
</TooltipPrimitive.Portal>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue