diff --git a/client/web/compose/src/components/PageBlocks/FileConfigurator.vue b/client/web/compose/src/components/PageBlocks/FileConfigurator.vue index 05a0978d0..ab2bc4825 100644 --- a/client/web/compose/src/components/PageBlocks/FileConfigurator.vue +++ b/client/web/compose/src/components/PageBlocks/FileConfigurator.vue @@ -21,6 +21,21 @@ > {{ $t('kind.file.view.showName') }} + + + {{ $t('kind.file.view.enablePreview') }} + + + + {{ $t('kind.file.view.enableDownload') }} + +
@@ -205,7 +208,7 @@ export default { computed: { inlineUrl () { - return (a) => (this.ext(a) === 'pdf' ? a.download : a.previewUrl) + return (a) => (this.ext(a) === 'pdf' ? a.download : (this.previewOptions.enablePreview ? a.previewUrl : a.url)) }, previewLabels () { @@ -287,7 +290,10 @@ export default { }, openLightbox (e) { - this.$root.$emit('showAttachmentsModal', e) + if (this.previewOptions.enablePreview) { + const { enableDownload } = this.previewOptions + this.$root.$emit('showAttachmentsModal', { ...e, enableDownload }) + } }, deleteAttachment (index) { @@ -339,6 +345,10 @@ export default { if (this.ext(a) === 'image') { return { + ...((!this.previewOptions.enablePreview || height === '0' || width === '0') && { + height: '100%', + width: '100%', + }), ...(height && { height: `${height}px` }), ...(width && { width: `${width}px` }), ...(maxHeight && { maxHeight: `${maxHeight}px` }), diff --git a/client/web/compose/src/components/Public/Page/Attachment/Modal.vue b/client/web/compose/src/components/Public/Page/Attachment/Modal.vue index 15b9d0571..d0b777f1e 100644 --- a/client/web/compose/src/components/Public/Page/Attachment/Modal.vue +++ b/client/web/compose/src/components/Public/Page/Attachment/Modal.vue @@ -16,7 +16,7 @@

@@ -71,7 +71,7 @@ export default { created () { window.addEventListener('keyup', this.onKeyUp) - this.$root.$on('showAttachmentsModal', ({ url, download, name, document = undefined, meta }) => { + this.$root.$on('showAttachmentsModal', ({ url, download, name, document = undefined, meta, enableDownload }) => { this.attachment = { document, download, @@ -79,6 +79,7 @@ export default { src: url, name: name, caption: name, + enableDownload, } }) }, diff --git a/lib/js/src/compose/types/page-block/file.ts b/lib/js/src/compose/types/page-block/file.ts index 9137608ba..9342b6ef9 100644 --- a/lib/js/src/compose/types/page-block/file.ts +++ b/lib/js/src/compose/types/page-block/file.ts @@ -15,6 +15,8 @@ interface Options { margin?: number; backgroundColor?: string; magnifyOption: string; + enablePreview?: boolean; + enableDownload?: boolean; } const PageBlockFileDefaultMode = 'list' @@ -40,7 +42,9 @@ const defaults: Readonly = Object.freeze({ borderRadius: undefined, margin: undefined, backgroundColor: undefined, - magnifyOption: '' + magnifyOption: '', + enablePreview: true, + enableDownload: true }) export class PageBlockFile extends PageBlock { @@ -60,7 +64,7 @@ export class PageBlockFile extends PageBlock { this.options.attachments = o.attachments } - Apply(this.options, o, Boolean, 'hideFileName') + Apply(this.options, o, Boolean, 'hideFileName', 'enablePreview', 'enableDownload') Apply(this.options, o, String, 'backgroundColor', 'magnifyOption') Apply(this.options, o, Number, 'height', 'width', 'maxHeight', 'maxWidth', 'borderRadius', 'margin') diff --git a/lib/vue/src/components/filePreview/CPreviewInline.vue b/lib/vue/src/components/filePreview/CPreviewInline.vue index a1dcecf02..1726c7a64 100644 --- a/lib/vue/src/components/filePreview/CPreviewInline.vue +++ b/lib/vue/src/components/filePreview/CPreviewInline.vue @@ -1,6 +1,6 @@