fix: commend-menu create block can leave menu name
This commit is contained in:
@@ -211,6 +211,8 @@ export const CommandMenu = ({ editor, hooks, style }: CommandMenuProps) => {
|
|||||||
|
|
||||||
const handleSelected = async (type: BlockFlavorKeys | string) => {
|
const handleSelected = async (type: BlockFlavorKeys | string) => {
|
||||||
const text = await editor.commands.textCommands.getBlockText(blockId);
|
const text = await editor.commands.textCommands.getBlockText(blockId);
|
||||||
|
const block = await editor.getBlockById(blockId);
|
||||||
|
let textValue = block.getProperty('text').value;
|
||||||
editor.blockHelper.removeSearchSlash(blockId, true);
|
editor.blockHelper.removeSearchSlash(blockId, true);
|
||||||
if (type.startsWith('Virgo')) {
|
if (type.startsWith('Virgo')) {
|
||||||
const handler =
|
const handler =
|
||||||
@@ -223,14 +225,18 @@ export const CommandMenu = ({ editor, hooks, style }: CommandMenuProps) => {
|
|||||||
} else {
|
} else {
|
||||||
await commonCommandMenuHandler(blockId, type, editor);
|
await commonCommandMenuHandler(blockId, type, editor);
|
||||||
}
|
}
|
||||||
const block = await editor.getBlockById(blockId);
|
|
||||||
const nextBlock = await block.nextSibling();
|
const nextBlock = await block.nextSibling();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
editor.selectionManager.activeNodeByNodeId(nextBlock.id);
|
editor.selectionManager.activeNodeByNodeId(nextBlock.id);
|
||||||
|
if (textValue.length === 1) {
|
||||||
|
block.remove();
|
||||||
|
} else {
|
||||||
|
block.setProperty('text', {
|
||||||
|
//@ts-ignore
|
||||||
|
value: textValue.filter(text => !text.search),
|
||||||
|
});
|
||||||
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
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