diff --git a/src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/manifests.ts new file mode 100644 index 0000000000..12e70fe184 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/manifests.ts @@ -0,0 +1,12 @@ +import type { ManifestFileUploadPreview } from '@umbraco-cms/backoffice/extension-registry'; +const previews: Array = [ + { + type: 'fileUploadPreview', + alias: 'My PDF Showcase', + name: 'PDF Showcase', + forMimeTypes: ['application/pdf'], + }, +]; +console.log('export..'); + +export const manifests = [...previews]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/test.element.ts b/src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/test.element.ts new file mode 100644 index 0000000000..09adc8addc --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-upload-field/test.element.ts @@ -0,0 +1,48 @@ +import { html, customElement, property, css } from '@umbraco-cms/backoffice/external/lit'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; + +@customElement('umb-pdf-preview') +export class UmbPDFPreviewElement extends UmbLitElement { + @property({ attribute: false }) + file?: File; + + @property({ type: String }) + path?: string; + + override render() { + if (!this.path) return html``; + + return html`This is the path: ${this.path} & the file is named ${this.file?.name}`; + } + + static override styles = [ + css` + :host { + display: flex; + background-color: #fff; + background-image: url('data:image/svg+xml;charset=utf-8,'); + background-repeat: repeat; + background-size: 10px 10px; + height: 100%; + min-height: 240px; + position: relative; + width: fit-content; + max-height: 240px; + } + + img { + max-width: 100%; + max-height: 100%; + object-fit: contain; + width: auto; + height: auto; + } + `, + ]; +} + +declare global { + interface HTMLElementTagNameMap { + 'umb-pdf-preview': UmbPDFPreviewElement; + } +} diff --git a/src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/upload-field/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/upload-field/manifests.ts index 311f8d61b9..a5aca4d748 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/upload-field/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/upload-field/manifests.ts @@ -1,5 +1,9 @@ import { manifest as schemaManifest } from './Umbraco.UploadField.js'; -import type { ManifestPropertyEditorUi, ManifestTypes } from '@umbraco-cms/backoffice/extension-registry'; +import type { + ManifestFileUploadPreview, + ManifestPropertyEditorUi, + ManifestTypes, +} from '@umbraco-cms/backoffice/extension-registry'; const manifest: ManifestPropertyEditorUi = { type: 'propertyEditorUi', @@ -14,4 +18,13 @@ const manifest: ManifestPropertyEditorUi = { }, }; -export const manifests: Array = [manifest, schemaManifest]; +/** Testing */ +const previews: ManifestFileUploadPreview = { + type: 'fileUploadPreview', + alias: 'My PDF Showcase', + name: 'PDF Showcase', + element: () => import('./test.element.js'), + forMimeTypes: ['application/pdf'], +}; + +export const manifests: Array = [manifest, schemaManifest, previews]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/upload-field/test.element.ts b/src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/upload-field/test.element.ts new file mode 100644 index 0000000000..65072a1316 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/media/media/property-editors/upload-field/test.element.ts @@ -0,0 +1,48 @@ +import { html, customElement, property, css } from '@umbraco-cms/backoffice/external/lit'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; + +@customElement('umb-pdf-preview') +export default class UmbPDFPreviewElement extends UmbLitElement { + @property({ attribute: false }) + file?: File; + + @property({ type: String }) + path?: string; + + override render() { + if (!this.path) return html``; + + return html`This is the path: ${this.path} & the file is named ${this.file?.name}`; + } + + static override styles = [ + css` + :host { + display: flex; + background-color: #fff; + background-image: url('data:image/svg+xml;charset=utf-8,'); + background-repeat: repeat; + background-size: 10px 10px; + height: 100%; + min-height: 240px; + position: relative; + width: fit-content; + max-height: 240px; + } + + img { + max-width: 100%; + max-height: 100%; + object-fit: contain; + width: auto; + height: auto; + } + `, + ]; +} + +declare global { + interface HTMLElementTagNameMap { + 'umb-pdf-preview': UmbPDFPreviewElement; + } +}