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');