Skip to content

Commit 940c2fd

Browse files
loivseniOvergaard
authored andcommitted
extension example
1 parent cdcfde0 commit 940c2fd

File tree

4 files changed

+123
-2
lines changed

4 files changed

+123
-2
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { ManifestFileUploadPreview } from '@umbraco-cms/backoffice/extension-registry';
2+
const previews: Array<ManifestFileUploadPreview> = [
3+
{
4+
type: 'fileUploadPreview',
5+
alias: 'My PDF Showcase',
6+
name: 'PDF Showcase',
7+
forMimeTypes: ['application/pdf'],
8+
},
9+
];
10+
console.log('export..');
11+
12+
export const manifests = [...previews];
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { html, customElement, property, css } from '@umbraco-cms/backoffice/external/lit';
2+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
3+
4+
@customElement('umb-pdf-preview')
5+
export class UmbPDFPreviewElement extends UmbLitElement {
6+
@property({ attribute: false })
7+
file?: File;
8+
9+
@property({ type: String })
10+
path?: string;
11+
12+
override render() {
13+
if (!this.path) return html`<uui-loader></uui-loader>`;
14+
15+
return html`This is the path: ${this.path} & the file is named ${this.file?.name}`;
16+
}
17+
18+
static override styles = [
19+
css`
20+
:host {
21+
display: flex;
22+
background-color: #fff;
23+
background-image: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" fill-opacity=".1"><path d="M50 0h50v50H50zM0 50h50v50H0z"/></svg>');
24+
background-repeat: repeat;
25+
background-size: 10px 10px;
26+
height: 100%;
27+
min-height: 240px;
28+
position: relative;
29+
width: fit-content;
30+
max-height: 240px;
31+
}
32+
33+
img {
34+
max-width: 100%;
35+
max-height: 100%;
36+
object-fit: contain;
37+
width: auto;
38+
height: auto;
39+
}
40+
`,
41+
];
42+
}
43+
44+
declare global {
45+
interface HTMLElementTagNameMap {
46+
'umb-pdf-preview': UmbPDFPreviewElement;
47+
}
48+
}

src/packages/media/media/property-editors/upload-field/manifests.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { manifest as schemaManifest } from './Umbraco.UploadField.js';
2-
import type { ManifestPropertyEditorUi, ManifestTypes } from '@umbraco-cms/backoffice/extension-registry';
2+
import type {
3+
ManifestFileUploadPreview,
4+
ManifestPropertyEditorUi,
5+
ManifestTypes,
6+
} from '@umbraco-cms/backoffice/extension-registry';
37

48
const manifest: ManifestPropertyEditorUi = {
59
type: 'propertyEditorUi',
@@ -14,4 +18,13 @@ const manifest: ManifestPropertyEditorUi = {
1418
},
1519
};
1620

17-
export const manifests: Array<ManifestTypes> = [manifest, schemaManifest];
21+
/** Testing */
22+
const previews: ManifestFileUploadPreview = {
23+
type: 'fileUploadPreview',
24+
alias: 'My PDF Showcase',
25+
name: 'PDF Showcase',
26+
element: () => import('./test.element.js'),
27+
forMimeTypes: ['application/pdf'],
28+
};
29+
30+
export const manifests: Array<ManifestTypes> = [manifest, schemaManifest, previews];
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { html, customElement, property, css } from '@umbraco-cms/backoffice/external/lit';
2+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
3+
4+
@customElement('umb-pdf-preview')
5+
export default class UmbPDFPreviewElement extends UmbLitElement {
6+
@property({ attribute: false })
7+
file?: File;
8+
9+
@property({ type: String })
10+
path?: string;
11+
12+
override render() {
13+
if (!this.path) return html`<uui-loader></uui-loader>`;
14+
15+
return html`This is the path: ${this.path} & the file is named ${this.file?.name}`;
16+
}
17+
18+
static override styles = [
19+
css`
20+
:host {
21+
display: flex;
22+
background-color: #fff;
23+
background-image: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" fill-opacity=".1"><path d="M50 0h50v50H50zM0 50h50v50H0z"/></svg>');
24+
background-repeat: repeat;
25+
background-size: 10px 10px;
26+
height: 100%;
27+
min-height: 240px;
28+
position: relative;
29+
width: fit-content;
30+
max-height: 240px;
31+
}
32+
33+
img {
34+
max-width: 100%;
35+
max-height: 100%;
36+
object-fit: contain;
37+
width: auto;
38+
height: auto;
39+
}
40+
`,
41+
];
42+
}
43+
44+
declare global {
45+
interface HTMLElementTagNameMap {
46+
'umb-pdf-preview': UmbPDFPreviewElement;
47+
}
48+
}

0 commit comments

Comments
 (0)