This commit is contained in:
Fatih Kadir Akın 2025-06-17 00:26:39 +03:00
parent a8a69caf76
commit eee62fe478
6 changed files with 86 additions and 6 deletions

View File

@ -30,8 +30,19 @@
<body class="bg-dynamic-background text-dynamic-foreground overflow-hidden"> <body class="bg-dynamic-background text-dynamic-foreground overflow-hidden">
<!-- Viewer Mode --> <!-- Viewer Mode -->
<div id="viewer-mode" class="viewer-mode h-screen flex flex-col p-2 sm:p-4"> <div id="viewer-mode" class="viewer-mode h-screen flex flex-col p-2 sm:p-4">
<!-- Top Bar with Context Pills and Edit Button -->
<div class="flex justify-between items-start gap-2 mb-0 sm:mb-2">
<!-- Context Pills --> <!-- Context Pills -->
<div id="context-pills" class="flex overflow-x-auto gap-2 empty:hidden mb-0 sm:mb-2 pb-1 scrollbar-hide"></div> <div id="context-pills" class="flex overflow-x-auto gap-2 empty:hidden pb-1 scrollbar-hide flex-1"></div>
<!-- Edit Button -->
<button id="edit-button" class="p-1 text-dynamic-muted-foreground hover:text-dynamic-foreground transition-colors" title="Edit in designer">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
</svg>
</button>
</div>
<!-- Main Prompt Interface - Full Height --> <!-- Main Prompt Interface - Full Height -->
<div class="flex-1 flex flex-col"> <div class="flex-1 flex flex-col">

View File

@ -177,6 +177,11 @@ class EmbedPreview {
if (copyButton) { if (copyButton) {
copyButton.addEventListener('click', () => this.handleCopy()); copyButton.addEventListener('click', () => this.handleCopy());
} }
const editButton = document.getElementById('edit-button');
if (editButton) {
editButton.addEventListener('click', () => this.handleEdit());
}
} }
render() { render() {
@ -353,6 +358,30 @@ class EmbedPreview {
this.showNotification('Prompt copied to clipboard!'); this.showNotification('Prompt copied to clipboard!');
} }
handleEdit() {
// Get current query string
const queryString = window.location.search;
// Get current URL path parts
const pathParts = window.location.pathname.split('/');
// Find index of 'embed-preview' and replace with 'embed'
const embedPreviewIndex = pathParts.findIndex(part => part === 'embed-preview');
if (embedPreviewIndex !== -1) {
pathParts[embedPreviewIndex] = 'embed';
} else {
// Fallback: just append /embed/ if embed-preview not found
pathParts.push('embed');
}
// Construct new URL
const newPath = pathParts.join('/');
const newUrl = window.location.origin + newPath + queryString;
// Open in new tab
window.open(newUrl, '_blank');
}
async copyToClipboard(text) { async copyToClipboard(text) {
if (navigator.clipboard && window.isSecureContext) { if (navigator.clipboard && window.isSecureContext) {
await navigator.clipboard.writeText(text); await navigator.clipboard.writeText(text);

View File

@ -30,8 +30,19 @@
<body class="bg-dynamic-background text-dynamic-foreground overflow-hidden"> <body class="bg-dynamic-background text-dynamic-foreground overflow-hidden">
<!-- Viewer Mode --> <!-- Viewer Mode -->
<div id="viewer-mode" class="viewer-mode h-screen flex flex-col p-2 sm:p-4"> <div id="viewer-mode" class="viewer-mode h-screen flex flex-col p-2 sm:p-4">
<!-- Top Bar with Context Pills and Edit Button -->
<div class="flex justify-between items-start gap-2 mb-0 sm:mb-2">
<!-- Context Pills --> <!-- Context Pills -->
<div id="context-pills" class="flex overflow-x-auto gap-2 empty:hidden mb-0 sm:mb-2 pb-1 scrollbar-hide"></div> <div id="context-pills" class="flex overflow-x-auto gap-2 empty:hidden pb-1 scrollbar-hide flex-1"></div>
<!-- Edit Button -->
<button id="edit-button" class="p-1 text-dynamic-muted-foreground hover:text-dynamic-foreground transition-colors" title="Edit in designer">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
</svg>
</button>
</div>
<!-- Main Prompt Interface - Full Height --> <!-- Main Prompt Interface - Full Height -->
<div class="flex-1 flex flex-col"> <div class="flex-1 flex flex-col">

View File

@ -25,7 +25,7 @@
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="/style.css?v=6eaf839c38bd08d088d00ca61df334cd3fba3890"> <link rel="stylesheet" href="/style.css?v=a8a69caf7649bb8f02c225029af543967973a65f">
</head> </head>
<body class=""> <body class="">
<div class="layout-wrapper"> <div class="layout-wrapper">

View File

@ -25,7 +25,7 @@
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="/style.css?v=6eaf839c38bd08d088d00ca61df334cd3fba3890"> <link rel="stylesheet" href="/style.css?v=a8a69caf7649bb8f02c225029af543967973a65f">
</head> </head>
<body class="vibe"> <body class="vibe">
<div class="layout-wrapper"> <div class="layout-wrapper">

View File

@ -177,6 +177,11 @@ class EmbedPreview {
if (copyButton) { if (copyButton) {
copyButton.addEventListener('click', () => this.handleCopy()); copyButton.addEventListener('click', () => this.handleCopy());
} }
const editButton = document.getElementById('edit-button');
if (editButton) {
editButton.addEventListener('click', () => this.handleEdit());
}
} }
render() { render() {
@ -353,6 +358,30 @@ class EmbedPreview {
this.showNotification('Prompt copied to clipboard!'); this.showNotification('Prompt copied to clipboard!');
} }
handleEdit() {
// Get current query string
const queryString = window.location.search;
// Get current URL path parts
const pathParts = window.location.pathname.split('/');
// Find index of 'embed-preview' and replace with 'embed'
const embedPreviewIndex = pathParts.findIndex(part => part === 'embed-preview');
if (embedPreviewIndex !== -1) {
pathParts[embedPreviewIndex] = 'embed';
} else {
// Fallback: just append /embed/ if embed-preview not found
pathParts.push('embed');
}
// Construct new URL
const newPath = pathParts.join('/');
const newUrl = window.location.origin + newPath + queryString;
// Open in new tab
window.open(newUrl, '_blank');
}
async copyToClipboard(text) { async copyToClipboard(text) {
if (navigator.clipboard && window.isSecureContext) { if (navigator.clipboard && window.isSecureContext) {
await navigator.clipboard.writeText(text); await navigator.clipboard.writeText(text);