Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ const InlineFormButton = styled.button`
}
`;

const LinkCoppiedMessage = styled.span`
color: green;
line-height: 25px;
margin-left: 10px;
`;

const popupStyles = {
padding: '0.2em 0.5em 0.2em 0.5em',
zIndex: '9999'
Expand All @@ -115,6 +121,15 @@ const HyperlinkModal = React.forwardRef(({ ...props }, ref) => {
const editor = useEditor();
const [originalSelection, setOriginalSelection] = useState(null);
const [canApply, setApplyStatus] = useState(false);
const [linkCopied, setLinkCopied] = useState(false);

useEffect(() => {
const timer = setTimeout(
() => setLinkCopied(false),
3000
);
return () => clearTimeout(timer);
}, [linkCopied]);

const handleClick = useCallback((e) => {
if (ref.current && !ref.current.contains(e.target)) {
Expand Down Expand Up @@ -197,6 +212,7 @@ const HyperlinkModal = React.forwardRef(({ ...props }, ref) => {
document.addEventListener('copy', listener);
document.execCommand('copy');
document.removeEventListener('copy', listener);
setLinkCopied(true);
};

const openLink = () => {
Expand Down Expand Up @@ -278,6 +294,7 @@ const HyperlinkModal = React.forwardRef(({ ...props }, ref) => {
position='bottom left'
style={popupStyles}
/>
{linkCopied && <LinkCoppiedMessage>Link copied</LinkCoppiedMessage>}
</InlineFormField>
</Form>
</HyperlinkMenu>
Expand Down