@@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { Box, Button, Grid, Typography } from '@mui/joy';
|
import { Box, Button, Grid, styled, Typography } from '@mui/joy';
|
||||||
|
|
||||||
import GitHubIcon from '@mui/icons-material/GitHub';
|
import GitHubIcon from '@mui/icons-material/GitHub';
|
||||||
import RedditIcon from '@mui/icons-material/Reddit';
|
import RedditIcon from '@mui/icons-material/Reddit';
|
||||||
@@ -361,7 +361,14 @@ export const AFFiNEFooter = ({
|
|||||||
>
|
>
|
||||||
#OpenSource
|
#OpenSource
|
||||||
</span>
|
</span>
|
||||||
company
|
<span>software, built with </span>
|
||||||
|
<StyledLink
|
||||||
|
href="https://block-suite.com"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
BlockSuite
|
||||||
|
</StyledLink>
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Grid>
|
</Grid>
|
||||||
@@ -383,3 +390,13 @@ export const AFFiNEFooter = ({
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const StyledLink = styled('a')({
|
||||||
|
fontWeight: '900',
|
||||||
|
color: '#000',
|
||||||
|
textDecoration: 'none',
|
||||||
|
|
||||||
|
'&:hover': {
|
||||||
|
textDecoration: 'underline',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|||||||
@@ -551,9 +551,9 @@ export const Text = forwardRef<ExtendedTextUtils, TextProps>((props, ref) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// markdown interception
|
// markdown interception
|
||||||
if (supportMarkdown && !!handleMarkdown(e)) {
|
if (supportMarkdown && handleMarkdown(e)) {
|
||||||
const start_selection = utils.current.getStartSelection();
|
const endOfMarkdown = utils.current.getEndSelection();
|
||||||
utils.current.setSelection(start_selection);
|
utils.current.setSelection(endOfMarkdown);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,12 +46,14 @@ export class BlockCommands {
|
|||||||
*
|
*
|
||||||
* remove block by block id
|
* remove block by block id
|
||||||
* @param {string} blockId
|
* @param {string} blockId
|
||||||
|
* @param onDelete Delete Block's LeftMenuDraggable
|
||||||
* @memberof BlockCommands
|
* @memberof BlockCommands
|
||||||
*/
|
*/
|
||||||
public async removeBlock(blockId: string) {
|
public async removeBlock(blockId: string, onDelete?: () => void) {
|
||||||
const block = await this._editor.getBlockById(blockId);
|
const block = await this._editor.getBlockById(blockId);
|
||||||
if (block) {
|
if (block) {
|
||||||
block.remove();
|
onDelete();
|
||||||
|
await block.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,17 +18,21 @@ interface LeftMenuProps {
|
|||||||
editor?: Virgo;
|
editor?: Virgo;
|
||||||
hooks: PluginHooks;
|
hooks: PluginHooks;
|
||||||
blockId: string;
|
blockId: string;
|
||||||
|
onDelete: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LeftMenu(props: LeftMenuProps) {
|
export function LeftMenu(props: LeftMenuProps) {
|
||||||
const { editor, anchorEl, hooks, blockId, onClose } = props;
|
const { editor, anchorEl, hooks, blockId, onClose, onDelete } = props;
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const menu: CascaderItemProps[] = useMemo(
|
const menu: CascaderItemProps[] = useMemo(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
title: t('Delete'),
|
title: t('Delete'),
|
||||||
callback: () => {
|
callback: async () => {
|
||||||
editor.commands.blockCommands.removeBlock(blockId);
|
await editor.commands.blockCommands.removeBlock(
|
||||||
|
blockId,
|
||||||
|
onDelete
|
||||||
|
);
|
||||||
},
|
},
|
||||||
shortcut: 'Del',
|
shortcut: 'Del',
|
||||||
icon: <DeleteCashBinIcon />,
|
icon: <DeleteCashBinIcon />,
|
||||||
|
|||||||
@@ -165,6 +165,10 @@ export const LeftMenuDraggable = (props: LeftMenuProps) => {
|
|||||||
setAnchorEl(currentTarget);
|
setAnchorEl(currentTarget);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onDelete = useCallback(() => {
|
||||||
|
setBlock(undefined);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const onClose = useCallback(() => setAnchorEl(undefined), [setAnchorEl]);
|
const onClose = useCallback(() => setAnchorEl(undefined), [setAnchorEl]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -241,6 +245,7 @@ export const LeftMenuDraggable = (props: LeftMenuProps) => {
|
|||||||
editor={props.editor}
|
editor={props.editor}
|
||||||
hooks={props.hooks}
|
hooks={props.hooks}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
|
onDelete={onDelete}
|
||||||
blockId={block.block.id}
|
blockId={block.block.id}
|
||||||
>
|
>
|
||||||
<Draggable onClick={onClick}>
|
<Draggable onClick={onClick}>
|
||||||
|
|||||||
Reference in New Issue
Block a user