PluginProbe
Gutenberg / 12.5.4
Gutenberg v12.5.4
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / build / block-library / blocks / file / view.js

view.js in Gutenberg 12.5.4, at build/block-library/blocks/file/view.js

77 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function() { // webpackBootstrap
2 /******/ "use strict";
3 var __webpack_exports__ = {};
4
5 ;// CONCATENATED MODULE: ./packages/block-library/build-module/file/utils.js
6 /**
7 * Uses a combination of user agent matching and feature detection to determine whether
8 * the current browser supports rendering PDFs inline.
9 *
10 * @return {boolean} Whether or not the browser supports inline PDFs.
11 */
12 const browserSupportsPdfs = () => {
13 // Most mobile devices include "Mobi" in their UA.
14 if (window.navigator.userAgent.indexOf('Mobi') > -1) {
15 return false;
16 } // Android tablets are the noteable exception.
17
18
19 if (window.navigator.userAgent.indexOf('Android') > -1) {
20 return false;
21 } // iPad pretends to be a Mac.
22
23
24 if (window.navigator.userAgent.indexOf('Macintosh') > -1 && window.navigator.maxTouchPoints && window.navigator.maxTouchPoints > 2) {
25 return false;
26 } // IE only supports PDFs when there's an ActiveX object available for it.
27
28
29 if (!!(window.ActiveXObject || 'ActiveXObject' in window) && !(createActiveXObject('AcroPDF.PDF') || createActiveXObject('PDF.PdfCtrl'))) {
30 return false;
31 }
32
33 return true;
34 };
35 /**
36 * Helper function for creating ActiveX objects, catching any errors that are thrown
37 * when it's generated.
38 *
39 * @param {string} type The name of the ActiveX object to create.
40 * @return {window.ActiveXObject|undefined} The generated ActiveXObject, or null if it failed.
41 */
42
43 const createActiveXObject = type => {
44 let ax;
45
46 try {
47 ax = new window.ActiveXObject(type);
48 } catch (e) {
49 ax = undefined;
50 }
51
52 return ax;
53 };
54 /**
55 * Hides all .wp-block-file__embed elements on the document. This function is only intended
56 * to be run on the front-end, it may have weird side effects running in the block editor.
57 */
58
59
60 const hidePdfEmbedsOnUnsupportedBrowsers = () => {
61 if (!browserSupportsPdfs()) {
62 const embeds = document.getElementsByClassName('wp-block-file__embed');
63 Array.from(embeds).forEach(embed => {
64 embed.style.display = 'none';
65 });
66 }
67 };
68 //# sourceMappingURL=utils.js.map
69 ;// CONCATENATED MODULE: ./packages/block-library/build-module/file/view.js
70 /**
71 * Internal dependencies
72 */
73
74 hidePdfEmbedsOnUnsupportedBrowsers();
75 //# sourceMappingURL=view.js.map
76 /******/ })()
77 ;