@@ -249,6 +258,7 @@ export function renderForm(app: HTMLElement, mode: 'add' | 'edit', existing: Ite
${renderSectionsEditor(sectionsDraft, sectionsExpanded)}
+ ${renderAttachmentsDisclosure({ itemId: existing?.id ?? '', attachments: attachmentsDraft, mode: 'edit' })}
@@ -265,6 +275,27 @@ 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();
+
document.getElementById('gen-btn')?.addEventListener('click', (e) => {
const trigger = e.currentTarget as HTMLElement;
if (isGeneratorPanelOpen()) {
@@ -292,7 +323,7 @@ export function renderForm(app: HTMLElement, mode: 'add' | 'edit', existing: Ite
});
document.getElementById('save-btn')?.addEventListener('click', async () => {
- await saveLogin(mode, existing, sectionsDraft);
+ await saveLogin(mode, existing, sectionsDraft, attachmentsDraft);
});
const escHandler = (e: KeyboardEvent) => {
@@ -320,7 +351,7 @@ function normalizeUrl(raw: string): { ok: true; value: string } | { ok: false; e
}
}
-async function saveLogin(mode: 'add' | 'edit', existing: Item | null, sectionsDraft: Section[]): Promise {
+async function saveLogin(mode: 'add' | 'edit', existing: Item | null, sectionsDraft: Section[], attachmentsDraft: AttachmentRef[]): Promise {
const state = getState();
const title = (document.getElementById('f-title') as HTMLInputElement).value.trim();
const rawUrl = (document.getElementById('f-url') as HTMLInputElement).value;
@@ -371,7 +402,7 @@ async function saveLogin(mode: 'add' | 'edit', existing: Item | null, sectionsDr
trashed_at: undefined,
core,
sections: sectionsDraft,
- attachments: existing?.attachments ?? [],
+ attachments: attachmentsDraft,
field_history: existing?.field_history ?? {},
};
diff --git a/extension/src/popup/components/types/secure-note.ts b/extension/src/popup/components/types/secure-note.ts
index 190e623..94cc663 100644
--- a/extension/src/popup/components/types/secure-note.ts
+++ b/extension/src/popup/components/types/secure-note.ts
@@ -2,17 +2,23 @@
/// detail view; the form is just a big
${renderConcealedRow({ id: 'note-body', label: 'body', value: body, multiline: true })}
${renderSections(item, 'secure-note')}
+ ${renderAttachmentsDisclosure({ itemId: item.id, attachments: item.attachments, mode: 'view' })}