mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 09:22:38 +03:00
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
This commit is contained in:
parent
754b2581cd
commit
2560c7b074
@ -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: <TurnIntoIcon />,
|
||||
},
|
||||
{
|
||||
title: 'Add A Below Block',
|
||||
icon: <AddViewIcon />,
|
||||
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: <UngroupIcon />,
|
||||
|
Loading…
Reference in New Issue
Block a user