vue-pdfjs-demo
Advanced tools
Comparing version 1.0.39 to 1.0.40
{ | ||
"_id": "vue-pdfjs-demo@1.0.39", | ||
"_id": "vue-pdfjs-demo@1.0.40", | ||
"_inBundle": false, | ||
@@ -62,4 +62,4 @@ "_integrity": "", | ||
"author": "Jerome CHENEAUX", | ||
"version": "1.0.39", | ||
"version": "1.0.40", | ||
"license": "MIT" | ||
} |
104
README.md
@@ -38,109 +38,17 @@ # vue-pdfjs-demo | ||
<template> | ||
<div id="appt"> | ||
<PDFViewer | ||
class="grey" | ||
v-bind="{url}" | ||
@document-errored="onDocumentErrored" | ||
> | ||
<PDFUploader | ||
v-if="enableUploader" | ||
slot="header" | ||
:document-error="documentError" | ||
class="header-item" | ||
@updated="urlUpdated" | ||
/> | ||
</PDFViewer> | ||
</div> | ||
<VuePdfJs class="grey" /> | ||
</template> | ||
<script> | ||
import PDFUploader from 'vue-pdfjs-demo/src/components/PDFUploader.vue' | ||
import PDFViewer from 'vue-pdfjs-demo/src/components/PDFViewer.vue' | ||
import VuePdfJs from "vue-pdfjs-demo/src/App.vue"; | ||
export default { | ||
components: { | ||
PDFUploader, | ||
PDFViewer, | ||
}, | ||
data() { | ||
return { | ||
url: process.env.VUE_APP_PDF_URL, | ||
documentError: undefined, | ||
enableUploader: process.env.VUE_APP_UPLOAD_ENABLED === 'true', | ||
}; | ||
}, | ||
methods: { | ||
urlUpdated(url) { | ||
this.documentError = undefined; | ||
this.url = url; | ||
}, | ||
onDocumentErrored(e) { | ||
this.documentError = e.text; | ||
}, | ||
}, | ||
VuePdfJs | ||
} | ||
} | ||
</script> | ||
<style scoped> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
background-color: #606f7b; | ||
} | ||
#appt { | ||
font-family: 'Avenir', Helvetica, Arial, sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
text-align: center; | ||
color: #62637a; | ||
} | ||
label.form { | ||
color: white; | ||
font-family: Monaco, 'Courier New', Courier, monospace; | ||
font-weight: bold; | ||
margin-bottom: 2em; | ||
display: block; | ||
} | ||
input { | ||
padding: 0.45em; | ||
font-size: 1em; | ||
} | ||
.error { | ||
border: 1px solid red; | ||
background: pink; | ||
color: red; | ||
padding: 0.5em 3em; | ||
display: inline; | ||
} | ||
a.icon { | ||
cursor: pointer; | ||
display: block; | ||
border: 1px #333 solid; | ||
background: white; | ||
color: #333; | ||
font-weight: bold; | ||
padding: 0.25em; | ||
width: 1em; | ||
height: 1em; | ||
font-size: 1.5em; | ||
} | ||
.box-shadow { | ||
box-shadow: 0 15px 30px 0 rgba(0, 0, 0, 0.11), 0 5px 15px 0 rgba(0, 0, 0, 0.08); | ||
} | ||
.overflow-hidden { | ||
overflow: hidden; | ||
} | ||
@media print { | ||
body { | ||
background-color: transparent; | ||
} | ||
#appt { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
} | ||
</style> | ||
``` | ||
@@ -147,0 +55,0 @@ |
@@ -1,7 +0,7 @@ | ||
import App from './App.vue'; | ||
import App from './App.vue' | ||
const defaultComponentName = 'vuePdfJs' | ||
export default { | ||
install(Vue, options) { | ||
const Plugin = { | ||
install(Vue, options = {}) { | ||
/** | ||
@@ -21,3 +21,3 @@ * Makes sure that plugin can be installed only once | ||
*/ | ||
Vue.prototype.$vuePDFjs = { | ||
Vue.prototype.$apiVuepdfjs = { | ||
_setDynamicContainer (dynamicContainer) { | ||
@@ -31,3 +31,18 @@ Plugin.dynamicContainer = dynamicContainer | ||
Vue.component(this.componentName, App) | ||
} | ||
} | ||
} | ||
// Auto-install when vue is found (eg. in browser via <script> tag) | ||
let GlobalVue = null; | ||
if (typeof window !== 'undefined') { | ||
GlobalVue = window.Vue; | ||
} else if (typeof global !== 'undefined') { | ||
GlobalVue = global.Vue; | ||
} | ||
if (GlobalVue) { | ||
GlobalVue.use(Plugin); | ||
} | ||
export default Plugin |
174
52101
60