diff --git a/addons/im_livechat/static/src/legacy/public_livechat.js b/addons/im_livechat/static/src/legacy/public_livechat.js index 46db2d8cd81..8a714e99cd2 100644 --- a/addons/im_livechat/static/src/legacy/public_livechat.js +++ b/addons/im_livechat/static/src/legacy/public_livechat.js @@ -3530,6 +3530,7 @@ odoo.define('im_livechat.legacy.mail.DocumentViewer', function (require) { var core = require('web.core'); var Widget = require('web.Widget'); +var { hidePDFJSButtons } = require('@web/js/libs/pdfjs'); var QWeb = core.qweb; @@ -3658,6 +3659,9 @@ var DocumentViewer = Widget.extend({ this.$('.o_viewer_content').html(QWeb.render('im_livechat.legacy.mail.DocumentViewer.Content', { widget: this })); + if (this.activeAttachment.fileType === 'application/pdf') { + hidePDFJSButtons(this.$('.o_viewer_content')[0]); + } this.$('.o_viewer_img').on("load", _.bind(this._onImageLoaded, this)); this.$('[data-toggle="tooltip"]').tooltip({ delay: 0 }); this._reset(); diff --git a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js index bd2f3896c73..108006b14d3 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js @@ -5,6 +5,8 @@ import useShouldUpdateBasedOnProps from '@mail/component_hooks/use_should_update import useStore from '@mail/component_hooks/use_store/use_store'; import { link } from '@mail/model/model_field_command'; +import { hidePDFJSButtons } from '@web/js/libs/pdfjs'; + const { Component, QWeb } = owl; const { useRef } = owl.hooks; @@ -53,6 +55,10 @@ class AttachmentViewer extends Component { * transformation on image visualisation. */ this._zoomerRef = useRef('zoomer'); + /** + * Reference of the IFRAME node when the attachment is a PDF. + */ + this._iframeViewerPdfRef = useRef('iframeViewerPdf'); /** * Tracked translate transformations on image visualisation. This is * not observed with `useStore` because they are used to compute zoomer @@ -67,6 +73,7 @@ class AttachmentViewer extends Component { mounted() { this.el.focus(); this._handleImageLoad(); + this._hideUnwantedPdfJsButtons(); document.addEventListener('click', this._onClickGlobal); } @@ -75,6 +82,7 @@ class AttachmentViewer extends Component { */ patched() { this._handleImageLoad(); + this._hideUnwantedPdfJsButtons(); } willUnmount() { @@ -169,6 +177,17 @@ class AttachmentViewer extends Component { } } + /** + * @see 'hidePDFJSButtons' + * + * @private + */ + _hideUnwantedPdfJsButtons() { + if (this._iframeViewerPdfRef.el) { + hidePDFJSButtons(this._iframeViewerPdfRef.el); + } + } + /** * Display the previous attachment in the list of attachments. * diff --git a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.xml b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.xml index af0651291d9..e3c5ef1f312 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.xml +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.xml @@ -46,7 +46,7 @@ -