[WEB-1610] chore: re-implement reload confirmation hook. (#4880)

* [WEB-1610] chore: re-implement reload confirmation hook.

* chore: attach anchor event listner to window instead of body.
This commit is contained in:
Prateek Shourya 2024-06-20 12:19:29 +05:30 committed by GitHub
parent e04eb1a63d
commit 718453b332
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 41 deletions

View file

@ -2,14 +2,12 @@
// @ts-nocheck
import { NodeViewWrapper } from "@tiptap/react";
import { cn } from "src/lib/utils";
import { useRouter } from "next/navigation";
import { IMentionHighlight } from "src/types/mention-suggestion";
import { useEffect, useState } from "react";
// eslint-disable-next-line import/no-anonymous-default-export
export const MentionNodeView = (props) => {
// TODO: move it to web app
const router = useRouter();
const [highlightsState, setHighlightsState] = useState<IMentionHighlight[]>();
useEffect(() => {
@ -21,25 +19,20 @@ export const MentionNodeView = (props) => {
hightlights();
}, [props.extension.options]);
const handleClick = () => {
if (!props.extension.options.readonly) {
router.push(props.node.attrs.redirect_uri);
}
};
return (
<NodeViewWrapper className="mention-component inline w-fit">
<span
<a
href={props.node.attrs.redirect_uri}
target="_blank"
className={cn("mention rounded bg-custom-primary-100/20 px-1 py-0.5 font-medium text-custom-primary-100", {
"bg-yellow-500/20 text-yellow-500": highlightsState
? highlightsState.includes(props.node.attrs.entity_identifier)
: false,
"cursor-pointer": !props.extension.options.readonly,
})}
onClick={handleClick}
>
@{props.node.attrs.label}
</span>
</a>
</NodeViewWrapper>
);
};