From 685b85bd48ab33af65a8ad63905b5f13426624f4 Mon Sep 17 00:00:00 2001 From: adueck Date: Tue, 8 Nov 2022 14:56:43 +0500 Subject: [PATCH] expose word id copy tag for all --- website/src/screens/IsolatedEntry.tsx | 34 +++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/website/src/screens/IsolatedEntry.tsx b/website/src/screens/IsolatedEntry.tsx index cc2d47d..bce2813 100644 --- a/website/src/screens/IsolatedEntry.tsx +++ b/website/src/screens/IsolatedEntry.tsx @@ -53,11 +53,18 @@ function IsolatedEntry({ state, dictionary, isolateEntry }: { const [comment, setComment] = useState(""); const [editSubmitted, setEditSubmitted] = useState(false); const [showingDeleteWarning, setShowingDeleteWarning] = useState(false); + const [showClipped, setShowClipped] = useState(""); useEffect(() => { setEditing(false); setComment(""); setEditSubmitted(false); }, [state]); + function flashClippedMessage(m: string) { + setShowClipped(m); + setTimeout(() => { + setShowClipped(""); + }, 1250); + } const wordlistWord = state.wordlist.find((w) => w.entry.ts === state.isolatedEntry?.ts); const textOptions = getTextOptions(state); function submitEdit() { @@ -128,6 +135,16 @@ function IsolatedEntry({ state, dictionary, isolateEntry }: { return null; } } + function handleClipId() { + if (!entry) return + navigator.clipboard.writeText(entry.ts.toString()); + flashClippedMessage("word id copied to clipboard"); + } + function handleClipEntry() { + if (!entry) return + navigator.clipboard.writeText(JSON.stringify(entry)); + flashClippedMessage("entry data copied to clipboard"); + } return
{entry.p} - LingDocs Pashto Dictionary @@ -149,11 +166,11 @@ function IsolatedEntry({ state, dictionary, isolateEntry }: { >
+
+ +
{state.user && state.user.level === "editor" && <> -
navigator.clipboard.writeText(entry.ts.toString())}> - -
-
navigator.clipboard.writeText(JSON.stringify(entry))}> +
@@ -251,6 +268,15 @@ function IsolatedEntry({ state, dictionary, isolateEntry }: { {isVerbEntry &&
} + {showClipped &&
+ {showClipped} +
} {!!(relatedEntries && relatedEntries.length) ? <>

Related Words