-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Link attatchment * Fix lint * fix * Update ContextMenu.tsx * Update ContextMenu.tsx
- Loading branch information
Showing
6 changed files
with
185 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import { useCanvasElementStore } from '@/stores/CanvasElementsStore'; | ||
import { useToast } from '@/components/ui/use-toast'; | ||
/** | ||
* Component that allows users to attach a link to a canvas element. | ||
* Modified to prompt for link input on button click. | ||
* @author Dana El Sherif | ||
*/ | ||
const LinkAttach = () => { | ||
const { selectedElementIds, updateAttachedUrl } = useCanvasElementStore([ | ||
'selectedElementIds', | ||
'updateAttachedUrl', | ||
]); | ||
const { toast } = useToast(); | ||
|
||
const attachLink = () => { | ||
if (selectedElementIds.length > 0) { | ||
const link = window.prompt('Enter link:'); | ||
if (link !== null && link !== '') { | ||
updateAttachedUrl(selectedElementIds[0], link); | ||
toast({ | ||
title: 'Link Attached', | ||
description: 'Link has been successfully attached.', | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="ml-auto pl-6 group-data-[highlighted]:text-white group-data-[disabled]:text-mauve8"> | ||
<button | ||
onClick={attachLink} | ||
className="cursor-pointer text-[13px] leading-none text-violet-500" | ||
> | ||
Attach Link | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LinkAttach; |
Oops, something went wrong.