From 29b86361b7b6ebef1d7233885d1fe88ab86139e8 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Tue, 24 Nov 2020 18:34:15 +0800 Subject: [PATCH] Use PDFObject --- _config.yml | 3 +++ _vendors.yml | 4 ++++ layout/_third-party/tags/pdf.njk | 36 ++++++++++++++++---------------- scripts/tags/pdf.js | 2 +- source/js/utils.js | 7 ------- test/tags/pdf.js | 4 ++-- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/_config.yml b/_config.yml index 2056e22..111e4f7 100644 --- a/_config.yml +++ b/_config.yml @@ -923,6 +923,9 @@ vendors: algolia_search: instant_search: + # PDF + pdfobject: + # Mermaid mermaid: diff --git a/_vendors.yml b/_vendors.yml index 63b89a8..65d9536 100644 --- a/_vendors.yml +++ b/_vendors.yml @@ -118,6 +118,10 @@ instant_search: name: instantsearch.js version: 4.8.4 file: dist/instantsearch.production.min.js +pdfobject: + name: pdfobject + version: 2.2.4 + file: pdfobject.min.js mermaid: name: mermaid version: 8.8.2 diff --git a/layout/_third-party/tags/pdf.njk b/layout/_third-party/tags/pdf.njk index 30cafcd..7290396 100644 --- a/layout/_third-party/tags/pdf.njk +++ b/layout/_third-party/tags/pdf.njk @@ -1,23 +1,23 @@ {%- if theme.pdf.enable %} +{%- set pdfobject_uri = theme.vendors.pdfobject %} {%- set pdf_uri = url_for('lib/pdf/web/viewer.html') %} {%- endif %} diff --git a/scripts/tags/pdf.js b/scripts/tags/pdf.js index 8145365..6c29f6c 100644 --- a/scripts/tags/pdf.js +++ b/scripts/tags/pdf.js @@ -6,5 +6,5 @@ module.exports = ctx => function(args) { const theme = ctx.theme.config; - return `
`; + return ``; }; diff --git a/source/js/utils.js b/source/js/utils.js index 6451ca9..1fea7e2 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -281,13 +281,6 @@ NexT.utils = { }); }, - supportsPDFs: function() { - const ua = navigator.userAgent; - const supportsPdfMimeType = typeof navigator.mimeTypes['application/pdf'] !== 'undefined'; - const isIOS = /iphone|ipad|ipod/i.test(ua.toLowerCase()); - return ua.includes('irefox') || (supportsPdfMimeType && !isIOS); - }, - getComputedStyle: function(element) { const clone = element.cloneNode(true); clone.style.position = 'absolute'; diff --git a/test/tags/pdf.js b/test/tags/pdf.js index 6186677..d360000 100644 --- a/test/tags/pdf.js +++ b/test/tags/pdf.js @@ -14,10 +14,10 @@ describe('pdf', () => { }); it('default', () => { - pdf(['https://example.com/sample.pdf']).should.eql(''); + pdf(['https://example.com/sample.pdf']).should.eql(''); }); it('custom height', () => { - pdf(['https://example.com/sample.pdf', '1000px']).should.eql(''); + pdf(['https://example.com/sample.pdf', '1000px']).should.eql(''); }); });