mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 15:16:28 +08:00
fix: delete block leftMenu not delete (#472)
This commit is contained in:
@@ -18,17 +18,21 @@ interface LeftMenuProps {
|
||||
editor?: Virgo;
|
||||
hooks: PluginHooks;
|
||||
blockId: string;
|
||||
onDelete: () => void;
|
||||
}
|
||||
|
||||
export function LeftMenu(props: LeftMenuProps) {
|
||||
const { editor, anchorEl, hooks, blockId, onClose } = props;
|
||||
const { editor, anchorEl, hooks, blockId, onClose, onDelete } = props;
|
||||
const { t } = useTranslation();
|
||||
const menu: CascaderItemProps[] = useMemo(
|
||||
() => [
|
||||
{
|
||||
title: t('Delete'),
|
||||
callback: () => {
|
||||
editor.commands.blockCommands.removeBlock(blockId);
|
||||
callback: async () => {
|
||||
await editor.commands.blockCommands.removeBlock(
|
||||
blockId,
|
||||
onDelete
|
||||
);
|
||||
},
|
||||
shortcut: 'Del',
|
||||
icon: <DeleteCashBinIcon />,
|
||||
|
||||
@@ -165,6 +165,10 @@ export const LeftMenuDraggable = (props: LeftMenuProps) => {
|
||||
setAnchorEl(currentTarget);
|
||||
};
|
||||
|
||||
const onDelete = useCallback(() => {
|
||||
setBlock(undefined);
|
||||
}, []);
|
||||
|
||||
const onClose = useCallback(() => setAnchorEl(undefined), [setAnchorEl]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -241,6 +245,7 @@ export const LeftMenuDraggable = (props: LeftMenuProps) => {
|
||||
editor={props.editor}
|
||||
hooks={props.hooks}
|
||||
onClose={onClose}
|
||||
onDelete={onDelete}
|
||||
blockId={block.block.id}
|
||||
>
|
||||
<Draggable onClick={onClick}>
|
||||
|
||||
Reference in New Issue
Block a user