diff --git a/extension/src/components/popup/App.tsx b/extension/src/components/popup/App.tsx index 78c79ef..e6e6d94 100644 --- a/extension/src/components/popup/App.tsx +++ b/extension/src/components/popup/App.tsx @@ -707,6 +707,7 @@ export function App() { openCollectionModal(item.uri || item.id || '')} onConverted={loadAnnotations} @@ -717,6 +718,7 @@ export function App() { openCollectionModal(item.uri || item.id || '')} onConverted={loadAnnotations} @@ -968,11 +970,13 @@ export function App() { function AnnotationCard({ item, + sessionDid, formatDate, onAddToCollection, onConverted, }: { item: Annotation; + sessionDid?: string; formatDate: (d?: string) => string; onAddToCollection?: () => void; onConverted?: () => void; @@ -987,6 +991,7 @@ function AnnotationCard({ const selector = item.target?.selector; const quote = selector?.exact || ''; const isHighlight = (item as any).type === 'Highlight'; + const isOwned = sessionDid && author.did === sessionDid; const highlightColor = item.color || (isHighlight ? '#fbbf24' : 'var(--accent)'); async function handleConvert() { @@ -1043,7 +1048,7 @@ function AnnotationCard({ )}
- {isHighlight && !showNoteInput && ( + {isHighlight && isOwned && !showNoteInput && ( -
-
-
"${escapeHtml(truncatedQuote)}"
- -
- - `; + const header = document.createElement('div'); + header.className = 'compose-header'; + + const titleSpan = document.createElement('span'); + titleSpan.className = 'compose-title'; + titleSpan.textContent = 'New Annotation'; + header.appendChild(titleSpan); + + const closeBtn = document.createElement('button'); + closeBtn.className = 'compose-close'; + closeBtn.innerHTML = Icons.close; + header.appendChild(closeBtn); + + composeModal.appendChild(header); + + const body = document.createElement('div'); + body.className = 'compose-body'; + + const quoteDiv = document.createElement('div'); + quoteDiv.className = 'inline-compose-quote'; + quoteDiv.textContent = `"${truncatedQuote}"`; + body.appendChild(quoteDiv); + + const textarea = document.createElement('textarea'); + textarea.className = 'inline-compose-textarea'; + textarea.placeholder = 'Write your annotation...'; + body.appendChild(textarea); + + composeModal.appendChild(body); + + const footer = document.createElement('div'); + footer.className = 'compose-footer'; + + const cancelBtn = document.createElement('button'); + cancelBtn.className = 'btn-cancel'; + cancelBtn.textContent = 'Cancel'; + footer.appendChild(cancelBtn); + + const submitBtn = document.createElement('button'); + submitBtn.className = 'btn-submit'; + submitBtn.textContent = 'Post'; + footer.appendChild(submitBtn); + + composeModal.appendChild(footer); composeModal.querySelector('.compose-close')?.addEventListener('click', () => { composeModal?.remove(); composeModal = null; }); - composeModal.querySelector('.btn-cancel')?.addEventListener('click', () => { + cancelBtn.addEventListener('click', () => { composeModal?.remove(); composeModal = null; }); - const textarea = composeModal.querySelector('.inline-compose-textarea') as HTMLTextAreaElement; - const submitBtn = composeModal.querySelector('.btn-submit') as HTMLButtonElement; - submitBtn.addEventListener('click', async () => { const text = textarea?.value.trim(); if (!text) return; @@ -362,10 +389,14 @@ export async function initContentScript(ctx: { onInvalidated: (cb: () => void) = const toast = document.createElement('div'); toast.className = `margin-toast ${type === 'success' ? 'toast-success' : ''}`; - toast.innerHTML = ` - ${type === 'success' ? Icons.check : Icons.close} - ${message} - `; + const iconSpan = document.createElement('span'); + iconSpan.className = 'toast-icon'; + iconSpan.innerHTML = type === 'success' ? Icons.check : Icons.close; + toast.appendChild(iconSpan); + + const msgSpan = document.createElement('span'); + msgSpan.textContent = message; + toast.appendChild(msgSpan); container.appendChild(toast); @@ -844,7 +875,7 @@ export async function initContentScript(ctx: { onInvalidated: (cb: () => void) = }); popoverEl.querySelectorAll('.btn-share').forEach((btn) => { - btn.addEventListener('click', async (e) => { + btn.addEventListener('click', async (_e) => { const text = (btn as HTMLElement).getAttribute('data-text') || ''; try { await navigator.clipboard.writeText(text);