@veritree/ui 0.16.3 → 0.16.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<component
|
|
3
3
|
:is="tag"
|
|
4
4
|
:to="to"
|
|
5
|
+
:href="href"
|
|
5
6
|
:type="type"
|
|
6
7
|
:disabled="isDisabled"
|
|
7
8
|
:class="[
|
|
@@ -71,6 +72,10 @@ export default {
|
|
|
71
72
|
type: [String, Object],
|
|
72
73
|
default: null,
|
|
73
74
|
},
|
|
75
|
+
href: {
|
|
76
|
+
type: [String],
|
|
77
|
+
default: null,
|
|
78
|
+
},
|
|
74
79
|
headless: {
|
|
75
80
|
type: Boolean,
|
|
76
81
|
default: false,
|
|
@@ -115,7 +120,7 @@ export default {
|
|
|
115
120
|
},
|
|
116
121
|
|
|
117
122
|
tag() {
|
|
118
|
-
return this.to ? 'NuxtLink' : 'button';
|
|
123
|
+
return this.to ? 'NuxtLink' : this.href ? 'a' : 'button';
|
|
119
124
|
},
|
|
120
125
|
|
|
121
126
|
type() {
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
11
|
<script>
|
|
12
|
-
import { handleImageResizing } from
|
|
12
|
+
import { handleImageResizing } from '../../utils/images';
|
|
13
13
|
|
|
14
14
|
export default {
|
|
15
|
-
name:
|
|
15
|
+
name: 'VTImage',
|
|
16
16
|
|
|
17
17
|
props: {
|
|
18
18
|
src: {
|
|
19
19
|
type: String,
|
|
20
|
-
default:
|
|
20
|
+
default: '',
|
|
21
21
|
},
|
|
22
22
|
cdnSrc: {
|
|
23
23
|
type: [String, Object],
|
|
@@ -67,7 +67,7 @@ export default {
|
|
|
67
67
|
|
|
68
68
|
onError() {
|
|
69
69
|
this.canLoad = false;
|
|
70
|
-
this.$emit(
|
|
70
|
+
this.$emit('error');
|
|
71
71
|
},
|
|
72
72
|
},
|
|
73
73
|
};
|
package/src/utils/images.js
CHANGED
|
@@ -3,36 +3,42 @@ export const handleImageResizing = (url, width) => {
|
|
|
3
3
|
if (!url) {
|
|
4
4
|
return '';
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
let cdn;
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
if (typeof url === 'object') {
|
|
11
|
+
cdn = url.cdn_url;
|
|
12
|
+
}
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
cdn = JSON.parse(url).cdn_url;
|
|
13
|
-
}
|
|
14
|
+
if (typeof url === 'string') {
|
|
15
|
+
cdn = JSON.parse(url).cdn_url;
|
|
16
|
+
}
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
const base64String = cdn.split('net/');
|
|
19
|
+
const firstPart = base64String[0];
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
// if atob is crossed and your editor says is not supported,
|
|
22
|
+
// don't worry, it seems to be about NodeJS and not about
|
|
23
|
+
// browsers.
|
|
24
|
+
//
|
|
25
|
+
// Details: https://developer.mozilla.org/en-US/docs/Web/API/atob
|
|
26
|
+
const decodedString = JSON.parse(atob(base64String[1]));
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
width
|
|
29
|
+
? (decodedString.edits.resize.width = width)
|
|
30
|
+
: (decodedString.edits.resize.width = 450);
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
// if btoa is crossed and your editor says is not supported,
|
|
33
|
+
// don't worry, it seems to be about NodeJS and not about
|
|
34
|
+
// browsers.
|
|
35
|
+
//
|
|
36
|
+
// Details: https://developer.mozilla.org/en-US/docs/Web/API/atob
|
|
37
|
+
const encodedString = btoa(JSON.stringify(decodedString));
|
|
38
|
+
const encodedUrl = `${firstPart}net/${encodedString}`;
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
return encodedUrl
|
|
41
|
+
} catch(error) {
|
|
42
|
+
console.error(`${error} in ${cdn}`);
|
|
43
|
+
}
|
|
38
44
|
};
|