From 7ff10af066c33679e2be08c07188dfeb0616fb7f Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 7 Jun 2026 13:37:21 -0400 Subject: [PATCH] Share button via the Web Share API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apple offers no content-accepting Notes URL scheme; the native share sheet is the real path — Notes, Messages, Mail, one tap. Button only appears where navigator.share exists (Safari, iOS, Android). Co-Authored-By: Claude Opus 4.8 (1M context) --- static/index.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/static/index.html b/static/index.html index b07a5b5..4f1cc56 100644 --- a/static/index.html +++ b/static/index.html @@ -291,6 +291,7 @@ Double-click any word to look it up on the right."> + @@ -1134,6 +1135,20 @@ function draftFilename(){ return (((doc && doc.title && doc.title !== 'Untitled') ? doc.title : 'rhymepad') .replace(/[^\w\- ]+/g, '').trim() || 'rhymepad') + '.txt'; } +const shareBtn = document.getElementById('shareBtn'); +if(navigator.share){ + shareBtn.hidden = false; + shareBtn.addEventListener('click', async ()=>{ + if(!editor.value.trim()) return; + const doc = docsState.docs.find(d=>d.id===docsState.current); + try{ + await navigator.share({ + title: (doc && doc.title !== 'Untitled') ? doc.title : 'RhymePad draft', + text: editor.value, + }); + }catch(e){ /* user closed the sheet */ } + }); +} document.getElementById('downloadBtn').addEventListener('click', ()=>{ if(!editor.value.trim()) return; const a = document.createElement('a');