From 2560c7b07404b224fc6e1afba821eb736833ae2f Mon Sep 17 00:00:00 2001 From: Simon Li <36295999+chenmoonmo@users.noreply.github.com> Date: Sat, 13 Aug 2022 03:18:26 +0800 Subject: [PATCH] feature: add a left menu option to add a below block (#232) * feature: add a left menu to add a below block * fix: 1.remove extra spaces 2.update hard code to predefined types --- .../src/menu/left-menu/LeftMenu.tsx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libs/components/editor-plugins/src/menu/left-menu/LeftMenu.tsx b/libs/components/editor-plugins/src/menu/left-menu/LeftMenu.tsx index 38db125aca..043b9a77c6 100644 --- a/libs/components/editor-plugins/src/menu/left-menu/LeftMenu.tsx +++ b/libs/components/editor-plugins/src/menu/left-menu/LeftMenu.tsx @@ -1,8 +1,10 @@ import { useMemo } from 'react'; import { Virgo, PluginHooks } from '@toeverything/framework/virgo'; import { Cascader, CascaderItemProps } from '@toeverything/components/ui'; +import { Protocol } from '@toeverything/datasource/db-service'; import { TurnIntoMenu } from './TurnIntoMenu'; import { + AddViewIcon, DeleteCashBinIcon, TurnIntoIcon, UngroupIcon, @@ -45,6 +47,24 @@ export function LeftMenu(props: LeftMenuProps) { ), icon: , }, + { + title: 'Add A Below Block', + icon: , + callback: async () => { + const block = await editor.getBlockById(blockId); + const belowType = [ + Protocol.Block.Type.numbered, + Protocol.Block.Type.bullet, + Protocol.Block.Type.todo, + ].some(type => type === block.type) + ? block.type + : Protocol.Block.Type.text; + editor.commands.blockCommands.createNextBlock( + blockId, + belowType + ); + }, + }, { title: 'Divide Here As A New Group', icon: ,