up-doc-pdf-picker.element.ts
PDF media picker with thumbnail preview. Replaces umb-input-media for PDF selection in the Create Workflow sidebar.
What it does
Section titled “What it does”Provides a complete pick-preview-remove flow for selecting a PDF from Umbraco’s media library:
- Empty state —
<uui-button look="placeholder">matching Umbraco’s standard media picker “Choose” button - After selection —
<uui-card-media>with a real PDF page 1 thumbnail (rendered byup-doc-pdf-thumbnail) and the media item’s file name - Actions — Remove (trash icon) and Change (edit icon) in a
<uui-action-bar>on the card
Why not use umb-input-media?
Section titled “Why not use umb-input-media?”umb-input-media uses umb-imaging-thumbnail which falls back to a generic icon for PDFs — there’s no visual preview. By building our own picker, we can inject a real PDF page render via up-doc-pdf-thumbnail while keeping all other behaviour (media picker modal, card layout, action buttons) consistent with Umbraco’s patterns.
How it works
Section titled “How it works”- Choose button — opens
UMB_MEDIA_PICKER_MODALviaUMB_MODAL_MANAGER_CONTEXT(standard Umbraco media picker) - On selection — stores the media key, fetches the media item name via
GET /umbraco/management/api/v1/media/item?id={guid} - Thumbnail render — passes the media key and auth token to
<up-doc-pdf-thumbnail>which handles PDF.js rendering - Events — dispatches
CustomEvent('change', { detail: { mediaKey } })on selection or removal
UUI patterns used
Section titled “UUI patterns used”| Component | Usage |
|---|---|
uui-button look="placeholder" | Empty state “Choose” button — matches umb-input-media’s add button |
uui-card-media | Card wrapper with name label — matches media library cards |
uui-action-bar slot="actions" | Hover action buttons on the card |
uui-icon | Icons for add, trash, edit actions |
Registered in
Section titled “Registered in”- Not registered in
manifest.ts— imported directly bycreate-workflow-sidebar.element.ts
Used by
Section titled “Used by”create-workflow-sidebar.element.ts— PDF source type section