From 4d2b27107a6e8d575b2d2b16a5d3b71c3d234557 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Thu, 23 Jul 2026 20:35:59 +0700 Subject: [PATCH] =?UTF-8?q?newsletter:=20fix=20Edit=20first=20button=20?= =?UTF-8?q?=E2=80=94=20opens=20inline=20textarea,=20Preview=20toggle,=20pu?= =?UTF-8?q?blish=20with=20edited=20text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: shakespeare.diy --- src/pages/NewsletterPage.tsx | 147 +++++++++++++++++++++-------------- 1 file changed, 88 insertions(+), 59 deletions(-) diff --git a/src/pages/NewsletterPage.tsx b/src/pages/NewsletterPage.tsx index 205cf3d..3987341 100644 --- a/src/pages/NewsletterPage.tsx +++ b/src/pages/NewsletterPage.tsx @@ -3,6 +3,7 @@ import { useSeoMeta } from '@unhead/react'; import { Layout } from '@/components/Layout'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; +import { Textarea } from '@/components/ui/textarea'; import { Link } from 'react-router-dom'; import { Skeleton } from '@/components/ui/skeleton'; import { @@ -249,7 +250,7 @@ function NostrPreviewModal({ issue: NewsletterIssue; open: boolean; onClose: () => void; - onConfirm: () => void; + onConfirm: (text: string) => void; isPending: boolean; }) { const { user } = useCurrentUser(); @@ -260,16 +261,16 @@ function NostrPreviewModal({ const now = new Date(); const timeStr = now.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' }); - // Render the nostrText with hashtags highlighted and URL as a link-style span + const [editing, setEditing] = useState(false); + const [editedText, setEditedText] = useState(issue.nostrText); + + const currentText = editing ? editedText : issue.nostrText; + const renderPreviewText = (text: string) => { return text.split('\n').map((line, i) => { const parts = line.split(/(\s+)/).map((word, j) => { - if (word.startsWith('#')) { - return {word}; - } - if (word.startsWith('https://')) { - return {word}; - } + if (word.startsWith('#')) return {word}; + if (word.startsWith('https://')) return {word}; return {word}; }); return

{parts}

; @@ -282,64 +283,92 @@ function NostrPreviewModal({ - Preview — Drop #{String(issue.number).padStart(3, '0')} + {editing ? 'Edit' : 'Preview'} — Drop #{String(issue.number).padStart(3, '0')} - This is how the note will appear on most Nostr clients. Formatting varies by client. + {editing + ? 'Edit the note text below. Changes only affect this publish — the source file stays unchanged.' + : 'This is how the note will appear on most Nostr clients. Formatting varies by client.'} - {/* Mock Nostr post card */} -
- {/* Post header */} -
- - - - {displayName.slice(0, 2).toUpperCase()} - - -
-

{displayName}

-

{timeStr} · via skate-spots.org

+ {editing ? ( + /* ── Edit mode ── */ +
+