diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..0f243d7 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,5 @@ +{ + "enabledPlugins": { + "superpowers@claude-plugins-official": true + } +} diff --git a/extension/src/popup/components/item-form.ts b/extension/src/popup/components/item-form.ts index e0370a9..36809cc 100644 --- a/extension/src/popup/components/item-form.ts +++ b/extension/src/popup/components/item-form.ts @@ -78,7 +78,11 @@ function renderTypeSelection(app: HTMLElement): void { btn.addEventListener('click', () => { const type = btn.dataset.type as ItemType; setState({ newType: type }); - renderItemForm(app, 'add'); + if (type === 'login' || type === 'secure_note') { + renderItemForm(app, 'add'); + } else { + popOutToTab(); + } }); }); } diff --git a/extension/src/popup/components/types/login.ts b/extension/src/popup/components/types/login.ts index d69560a..a34c7f4 100644 --- a/extension/src/popup/components/types/login.ts +++ b/extension/src/popup/components/types/login.ts @@ -1,7 +1,7 @@ /// Login type detail + form. Reference implementation for the shared /// field helpers introduced in Slice 2. -import { getState, setState, sendMessage, navigate, escapeHtml, popOutToTab } from '../../popup'; +import { getState, setState, sendMessage, navigate, escapeHtml, popOutToTab, isInTab } from '../../popup'; import type { Item, ItemId, LoginCore, ManifestEntry, Section, TotpConfig, AttachmentRef } from '../../../shared/types'; import { DEFAULT_PASSWORD_REQUEST } from '../../../shared/types'; import { base32Decode, base32Encode } from '../../../shared/base32'; @@ -267,7 +267,7 @@ export function renderForm(app: HTMLElement, mode: 'add' | 'edit', existing: Ite
${renderSectionsEditor(sectionsDraft, sectionsExpanded)} - ${renderAttachmentsDisclosure({ itemId: existing?.id ?? '', attachments: attachmentsDraft, mode: 'edit' })} + ${isInTab() ? renderAttachmentsDisclosure({ itemId: existing?.id ?? '', attachments: attachmentsDraft, mode: 'edit' }) : ''}
@@ -284,26 +284,28 @@ export function renderForm(app: HTMLElement, mode: 'add' | 'edit', existing: Ite }; wireSectionsEditor(app, sectionsDraft, rerender); - const wireDisclosure = (): void => { - wireAttachmentsDisclosure(app, { - itemId: existing?.id ?? '', - attachments: attachmentsDraft, - mode: 'edit', - onChange: (next) => { - attachmentsDraft = next; - const disc = app.querySelector('.attachments-disclosure'); - if (disc) { - disc.outerHTML = renderAttachmentsDisclosure({ - itemId: existing?.id ?? '', - attachments: attachmentsDraft, - mode: 'edit', - }); - wireDisclosure(); - } - }, - }); - }; - wireDisclosure(); + if (isInTab()) { + const wireDisclosure = (): void => { + wireAttachmentsDisclosure(app, { + itemId: existing?.id ?? '', + attachments: attachmentsDraft, + mode: 'edit', + onChange: (next) => { + attachmentsDraft = next; + const disc = app.querySelector('.attachments-disclosure'); + if (disc) { + disc.outerHTML = renderAttachmentsDisclosure({ + itemId: existing?.id ?? '', + attachments: attachmentsDraft, + mode: 'edit', + }); + wireDisclosure(); + } + }, + }); + }; + wireDisclosure(); + } document.getElementById('gen-btn')?.addEventListener('click', (e) => { const trigger = e.currentTarget as HTMLElement; diff --git a/extension/src/popup/components/types/secure-note.ts b/extension/src/popup/components/types/secure-note.ts index 6e0a7b8..a341b34 100644 --- a/extension/src/popup/components/types/secure-note.ts +++ b/extension/src/popup/components/types/secure-note.ts @@ -1,7 +1,7 @@ /// SecureNote: a single multiline body field. Concealed by default in the /// detail view; the form is just a big
${renderSectionsEditor(sectionsDraft, sectionsExpanded)} - ${renderAttachmentsDisclosure({ itemId: existing?.id ?? '', attachments: attachmentsDraft, mode: 'edit' })} + ${isInTab() ? renderAttachmentsDisclosure({ itemId: existing?.id ?? '', attachments: attachmentsDraft, mode: 'edit' }) : ''}
@@ -139,26 +139,28 @@ export function renderForm(app: HTMLElement, mode: 'add' | 'edit', existing: Ite }; wireSectionsEditor(app, sectionsDraft, rerender); - const wireDisclosure = (): void => { - wireAttachmentsDisclosure(app, { - itemId: existing?.id ?? '', - attachments: attachmentsDraft, - mode: 'edit', - onChange: (next) => { - attachmentsDraft = next; - const disc = app.querySelector('.attachments-disclosure'); - if (disc) { - disc.outerHTML = renderAttachmentsDisclosure({ - itemId: existing?.id ?? '', - attachments: attachmentsDraft, - mode: 'edit', - }); - wireDisclosure(); - } - }, - }); - }; - wireDisclosure(); + if (isInTab()) { + const wireDisclosure = (): void => { + wireAttachmentsDisclosure(app, { + itemId: existing?.id ?? '', + attachments: attachmentsDraft, + mode: 'edit', + onChange: (next) => { + attachmentsDraft = next; + const disc = app.querySelector('.attachments-disclosure'); + if (disc) { + disc.outerHTML = renderAttachmentsDisclosure({ + itemId: existing?.id ?? '', + attachments: attachmentsDraft, + mode: 'edit', + }); + wireDisclosure(); + } + }, + }); + }; + wireDisclosure(); + } document.getElementById('cancel-btn')?.addEventListener('click', () => { setState({ error: null }); diff --git a/extension/src/popup/popup.ts b/extension/src/popup/popup.ts index 99428eb..16be54f 100644 --- a/extension/src/popup/popup.ts +++ b/extension/src/popup/popup.ts @@ -30,6 +30,10 @@ export function escapeHtml(str: string): string { // --- Pop out to tab --- +export function isInTab(): boolean { + return window.location.search.length > 0; +} + export function popOutToTab(): void { const state = getState(); const params = new URLSearchParams();