add note wrapper

This commit is contained in:
Ren Amamiya
2023-05-07 09:12:32 +07:00
parent 390137f5b0
commit f46f4530a6
10 changed files with 58 additions and 67 deletions

View File

@@ -0,0 +1,26 @@
import { navigate } from 'vite-plugin-ssr/client/router';
export const NoteWrapper = ({
children,
href,
className,
}: {
children: React.ReactNode;
href: string;
className: string;
}) => {
const openThread = (event: any, href: string) => {
const selection = window.getSelection();
if (selection.toString().length === 0) {
navigate(href, { keepScrollPosition: true });
} else {
event.stopPropagation();
}
};
return (
<div onClick={(event) => openThread(event, href)} className={className}>
{children}
</div>
);
};