mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-31 17:19:56 +08:00
fix command-menu create block after can remove block
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
import { MuiClickAwayListener } from '@toeverything/components/ui';
|
||||||
import { BlockFlavorKeys, Protocol } from '@toeverything/datasource/db-service';
|
import { BlockFlavorKeys, Protocol } from '@toeverything/datasource/db-service';
|
||||||
|
import { HookType, PluginHooks, Virgo } from '@toeverything/framework/virgo';
|
||||||
import React, {
|
import React, {
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
@@ -6,18 +8,15 @@ import React, {
|
|||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
|
import { QueryResult } from '../../search';
|
||||||
import { MuiClickAwayListener } from '@toeverything/components/ui';
|
|
||||||
import { Virgo, HookType, PluginHooks } from '@toeverything/framework/virgo';
|
|
||||||
|
|
||||||
import { CommandMenuContainer } from './Container';
|
|
||||||
import {
|
import {
|
||||||
CommandMenuCategories,
|
CommandMenuCategories,
|
||||||
commandMenuHandlerMap,
|
commandMenuHandlerMap,
|
||||||
commonCommandMenuHandler,
|
commonCommandMenuHandler,
|
||||||
menuItemsMap,
|
menuItemsMap,
|
||||||
} from './config';
|
} from './config';
|
||||||
import { QueryResult } from '../../search';
|
import { CommandMenuContainer } from './Container';
|
||||||
|
|
||||||
export type CommandMenuProps = {
|
export type CommandMenuProps = {
|
||||||
editor: Virgo;
|
editor: Virgo;
|
||||||
hooks: PluginHooks;
|
hooks: PluginHooks;
|
||||||
@@ -225,7 +224,11 @@ export const CommandMenu = ({ editor, hooks, style }: CommandMenuProps) => {
|
|||||||
await commonCommandMenuHandler(blockId, type, editor);
|
await commonCommandMenuHandler(blockId, type, editor);
|
||||||
}
|
}
|
||||||
const block = await editor.getBlockById(blockId);
|
const block = await editor.getBlockById(blockId);
|
||||||
block.remove();
|
let nextBlock = await block.nextSibling();
|
||||||
|
editor.selectionManager.activeNodeByNodeId(nextBlock.id);
|
||||||
|
if (block.blockProvider.isEmpty()) {
|
||||||
|
block.remove();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Protocol.Block.Type[type as BlockFlavorKeys]) {
|
if (Protocol.Block.Type[type as BlockFlavorKeys]) {
|
||||||
const block = await editor.commands.blockCommands.convertBlock(
|
const block = await editor.commands.blockCommands.convertBlock(
|
||||||
|
|||||||
Reference in New Issue
Block a user