diff --git a/example/app.js b/example/app.js
index 6f76a98..06a95d4 100644
--- a/example/app.js
+++ b/example/app.js
@@ -1,5 +1,5 @@
import Vue from 'vue'
-import JsonViewer from '../vue-json-viewer'
+import JsonViewer from '../lib'
Vue.use(JsonViewer)
@@ -34,6 +34,7 @@ new Vue({
{
id: '5968fcad629fa84ab65a5247',
firstname: 'Ada',
+ link: 'http://google.com',
lastname: 'Lovelace',
awards: null,
known: [
diff --git a/lib/json-viewer.vue b/lib/json-viewer.vue
index e937eef..6226a9c 100644
--- a/lib/json-viewer.vue
+++ b/lib/json-viewer.vue
@@ -8,7 +8,6 @@
ref="clip"
class="jv-button"
:class="{copied}"
- @click="clip"
>{{ copied ? 'copied!' : 'copy' }}
{
+ return JSON.stringify(this.value, null, 2)
+ }
+ });
+ clipBoard.on('success', () => {
+ this.onCopied()
+ })
+ }
},
methods: {
onResized () {
@@ -108,25 +117,15 @@ export default {
}
})
},
- clip () {
+ onCopied() {
if (this.copied) {
- return
+ return;
}
-
- const clipBoard = new Clipboard(this.$refs.clip, {
- text: () => {
- return JSON.stringify(this.value, null, 2)
- }
- })
-
- clipBoard.on('success', () => {
- this.copied = true
- setTimeout(() => {
- this.copied = false
- }, 2000)
- this.$emit('copied')
- clipBoard.destroy()
- })
+ this.copied = true
+ setTimeout(() => {
+ this.copied = false
+ }, 2000)
+ this.$emit('copied')
},
toggleExpandCode () {
this.expandCode = !this.expandCode
diff --git a/lib/types/json-object.vue b/lib/types/json-object.vue
index 62bbddd..729bd9e 100644
--- a/lib/types/json-object.vue
+++ b/lib/types/json-object.vue
@@ -26,7 +26,7 @@ export default {
}
const ordered = {}
- Object.keys(this.jsonValue).sort().forEach(key => {
+ Object.keys(this.jsonValue).forEach(key => {
ordered[key] = this.jsonValue[key]
})
return ordered
diff --git a/lib/types/json-string.vue b/lib/types/json-string.vue
index be39379..8faf941 100644
--- a/lib/types/json-string.vue
+++ b/lib/types/json-string.vue
@@ -1,4 +1,6 @@