diff --git a/src/components/GitDialog.tsx b/src/components/GitDialog.tsx index 8de746bf..0b8346be 100644 --- a/src/components/GitDialog.tsx +++ b/src/components/GitDialog.tsx @@ -46,6 +46,7 @@ import { Settings2, GitPullRequest, ExternalLink, + Copy, } from 'lucide-react'; import { useGitStatus } from '@/hooks/useGitStatus'; import { useGitSettings } from '@/hooks/useGitSettings'; @@ -683,6 +684,60 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog const [isGitManagementOpen, setIsGitManagementOpen] = useState(false); const [gitManagementDefaultTab, setGitManagementDefaultTab] = useState('branches'); + const handleCopyShakespeareURL = async () => { + if (!originUrl.trim()) { + toast({ + title: "No repository URL", + description: "Please enter a Git URL first", + variant: "destructive", + }); + return; + } + + // Create the Shakespeare clone URL by encoding the origin URL + const shakespeareURL = `https://shakespeare.diy/clone?url=${encodeURIComponent(originUrl.trim())}`; + + // Try modern clipboard API first + try { + await navigator.clipboard.writeText(shakespeareURL); + toast({ + title: "Copied to clipboard", + description: "Edit with Shakespeare URL copied", + }); + return; + } catch { + // Fallback to older method + try { + const textArea = document.createElement('textarea'); + textArea.value = shakespeareURL; + textArea.style.position = 'fixed'; + textArea.style.left = '-999999px'; + textArea.style.top = '-999999px'; + document.body.appendChild(textArea); + textArea.focus(); + textArea.select(); + + const successful = document.execCommand('copy'); + document.body.removeChild(textArea); + + if (successful) { + toast({ + title: "Copied to clipboard", + description: "Edit with Shakespeare URL copied", + }); + } else { + throw new Error('execCommand failed'); + } + } catch { + toast({ + title: "Failed to copy", + description: "Could not copy to clipboard. Please copy manually.", + variant: "destructive", + }); + } + } + }; + return ( <> @@ -752,6 +807,45 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog + {/* Edit with Shakespeare URL */} + {originUrl.trim() ? ( +
+ +
+ + +
+
+ ) : ( +
+ +
+
+ + + Push your repository to get a shareable Shakespeare link + +
+
+
+ )} + {/* Credentials Warning */} {gitStatus.remotes.length > 0 && ( (() => {