mirror of https://github.com/buster-so/buster.git
Added some extra popover dropdwon
This commit is contained in:
parent
985548a8ca
commit
8c7fd381a2
|
@ -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';
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -100,7 +100,7 @@ const DropdownMenuItem = React.forwardRef<
|
|||
'group',
|
||||
className
|
||||
)}
|
||||
onClick={(e) => {
|
||||
onMouseDown={(e) => {
|
||||
if (!closeOnSelect) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue