Added some extra popover dropdwon

This commit is contained in:
Nate Kelley 2025-09-09 17:37:51 -06:00
parent 985548a8ca
commit 8c7fd381a2
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
5 changed files with 19 additions and 16 deletions

View File

@ -1,5 +1,5 @@
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
import * as React from 'react';
import type * as React from 'react';
import { cn } from '@/lib/utils';
import { Check3 as Check, ChevronRight } from '../icons/NucleoIconOutlined';
import RadioUnchecked from '../icons/NucleoIconOutlined/radio-unchecked';

View File

@ -364,7 +364,6 @@ const DropdownItem = <
showIndex: boolean;
}) => {
const onClickItem = useMemoizedFn((e: React.MouseEvent<HTMLDivElement> | KeyboardEvent) => {
console.log('onClickItem', e, disabled, onClick, onSelect, value);
if (disabled) return;
if (onClick) onClick(e);
if (onSelect) onSelect(value as T);

View File

@ -100,7 +100,7 @@ const DropdownMenuItem = React.forwardRef<
'group',
className
)}
onClick={(e) => {
onMouseDown={(e) => {
if (!closeOnSelect) {
e.stopPropagation();
e.preventDefault();

View File

@ -11,9 +11,7 @@ export function createDropdownItem<
TRouter extends RegisteredRouter,
TOptions,
TFrom extends string = string,
>(
item: IDropdownItem<T, TRouter, TOptions, TFrom> | DropdownDivider
): IDropdownItem<T, TRouter, TOptions, TFrom> | DropdownDivider {
>(item: IDropdownItem<T, TRouter, TOptions, TFrom>): IDropdownItem<T, TRouter, TOptions, TFrom> {
return item;
}

View File

@ -1,6 +1,6 @@
import { BlockSelectionPlugin } from '@platejs/selection/react';
import type { DropdownMenuProps } from '@radix-ui/react-dropdown-menu';
import { KEYS } from 'platejs';
import { KEYS, PathApi } from 'platejs';
import { useEditorRef, useElement } from 'platejs/react';
import * as React from 'react';
import { Button } from '../../buttons';
@ -18,13 +18,16 @@ export function MoreToolbarButton() {
label: NodeTypeLabels.duplicate.label,
icon: <NodeTypeIcons.duplicate />,
onClick: () => {
console.log(
'duplicate',
editor.selection,
editor.api.block(),
editor.api.blocks({ mode: 'lowest' })
);
editor.tf.duplicateNodes({ block: true, select: true });
const block = editor.api.block();
if (!block) return;
editor.tf.duplicateNodes({
nodes: [block],
});
const path = PathApi.next(block[1]);
setTimeout(() => {
editor.tf.select(path);
editor.tf.focus();
}, 0);
},
},
{
@ -32,8 +35,11 @@ export function MoreToolbarButton() {
label: NodeTypeLabels.delete.label,
icon: <NodeTypeIcons.trash />,
onClick: () => {
console.log('delete');
editor.tf.removeNodes({ block: true });
const block = editor.api.block();
if (!block) return;
editor.tf.removeNodes({
at: block[1],
});
},
},
{ type: 'divider' as const } satisfies DropdownDivider,