feat: Intra-line double link interaction

This commit is contained in:
xiaodong zuo
2022-08-18 16:22:45 +08:00
parent 879a208034
commit 919e0d08d5
18 changed files with 859 additions and 460 deletions
@@ -0,0 +1,29 @@
import { PagesIcon } from '@toeverything/components/icons';
import React, { useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
export const DoubleLinkComponent = ({ attributes, children, element }: any) => {
const navigate = useNavigate();
const handleClickLinkText = useCallback(
(event: React.MouseEvent<HTMLAnchorElement>) => {
event.preventDefault();
event.stopPropagation();
const { workspaceId, blockId } = element;
navigate(`/${workspaceId}/${blockId}`);
},
[element, navigate]
);
return (
<span>
<PagesIcon style={{ verticalAlign: 'middle', height: '20px' }} />
<a
{...attributes}
href={`/${element.workspaceId}/${element.blockId}`}
>
<span onClick={handleClickLinkText}>{children}</span>
</a>
</span>
);
};