@sedoo/unidoo 0.1.68 → 0.1.70

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sedoo/unidoo",
3
- "version": "0.1.68",
3
+ "version": "0.1.70",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "build": "npm run build:unidoo && npm run build:auth",
@@ -22,7 +22,9 @@
22
22
  "dependencies": {
23
23
  "date-fns": "^2.30.0",
24
24
  "date-fns-tz": "^1.3.8",
25
+ "dompurify": "^3.2.4",
25
26
  "keycloak-js": "^8.0.2",
27
+ "marked": "^0.8.2",
26
28
  "moment": "^2.30.1",
27
29
  "ol": "^6.15.1",
28
30
  "ol-ext": "^4.0.23",
@@ -0,0 +1,49 @@
1
+ <template>
2
+ <v-app>
3
+ <v-container>
4
+ <v-row>
5
+ <v-col>
6
+ <v-card v-if="markdown" flat>
7
+ <v-card-text v-html="markdown"></v-card-text>
8
+ </v-card>
9
+ </v-col>
10
+ </v-row>
11
+ </v-container>
12
+ </v-app>
13
+ </template>
14
+
15
+ <script>
16
+ import marked from "marked";
17
+ import DOMPurify from "dompurify/dist/purify.min.js";
18
+
19
+ export default {
20
+ name: "unidoo-markdown",
21
+ props: {
22
+ service: {
23
+ type: String,
24
+ default: null
25
+ }
26
+ },
27
+ data() {
28
+ return {
29
+ markdown: null
30
+ };
31
+ },
32
+ mounted() {
33
+ this.fetchMarkdown();
34
+ },
35
+ methods: {
36
+ async fetchMarkdown() {
37
+ if (!this.service) return;
38
+
39
+ try {
40
+ const response = await this.axios.get(this.service);
41
+ this.markdown = DOMPurify.sanitize(marked(response.data), null);
42
+ } catch (error) {
43
+ this.markdown = null;
44
+ console.error("An error occurred while fetching markdown", error);
45
+ }
46
+ }
47
+ }
48
+ };
49
+ </script>
@@ -16,6 +16,7 @@
16
16
  :label="label"
17
17
  :entries="entries"
18
18
  :displayThumbnails="displayThumbnails"
19
+ :thumbnailRatio="thumbnailRatio"
19
20
  >
20
21
 
21
22
  <template v-slot:customField>
@@ -75,11 +76,16 @@ export default {
75
76
  displayThumbnails: {
76
77
  type: Boolean,
77
78
  default: false
79
+ },
80
+
81
+ thumbnailRatio: {
82
+ type: String,
83
+ default: "null"
78
84
  }
79
85
  },
80
86
 
81
87
  data: () => ({
82
- entries: null
88
+ entries: []
83
89
  }),
84
90
 
85
91
  computed: {
@@ -1,30 +1,32 @@
1
1
  <template>
2
2
  <v-container class="d-flex justify-start flex-wrap">
3
- <v-img
4
- class="thumbnail ma-1"
5
- :style="selected === index ? activeStyle : ''"
3
+ <thumbnail-entry
6
4
  v-for="(link, index) in links"
7
- :lazy-src="link"
8
- :src="link"
9
- :key="link"
10
- :max-width="100"
11
- contain
12
- @click="select(index)"
13
- ></v-img>
5
+ :selected="isActive(index)"
6
+ :link="link"
7
+ :thumbnailRatio="thumbnailRatio"
8
+ :key="index"
9
+ @select="select(index)"
10
+ ></thumbnail-entry>
14
11
  </v-container>
15
12
  </template>
16
13
 
17
14
  <script>
15
+ import ThumbnailEntry from "./ThumbnailEntry.vue";
16
+
18
17
  export default {
19
18
  name: "thumbnail-entries",
19
+ components: {
20
+ ThumbnailEntry
21
+ },
20
22
  props: {
21
- entries: { type: Array, required: true },
22
- value: { type: Number, default: 0 }
23
+ entries: { type: Array, default: () => [], required: true },
24
+ value: { type: Number, default: 0 },
25
+ thumbnailRatio: { type: String, default: null }
23
26
  },
24
27
  data() {
25
28
  return {
26
- selected: null,
27
- activeStyle: "border: 3px solid black; border-radius: 3px;"
29
+ selected: null
28
30
  };
29
31
  },
30
32
  created() {
@@ -44,9 +46,9 @@ export default {
44
46
  }
45
47
  },
46
48
  methods: {
47
- select(link) {
48
- this.selected = link;
49
- this.$emit("select", link);
49
+ select(index) {
50
+ this.selected = index;
51
+ this.$emit("select", index);
50
52
  },
51
53
  isActive(index) {
52
54
  return this.selected === index;
@@ -54,9 +56,3 @@ export default {
54
56
  }
55
57
  };
56
58
  </script>
57
-
58
- <style scoped>
59
- .thumbnail {
60
- cursor: pointer;
61
- }
62
- </style>
@@ -0,0 +1,60 @@
1
+ <template>
2
+ <v-img
3
+ ref="thumbnail"
4
+ class="thumbnail ma-1"
5
+ :style="selected ? activeStyle : ''"
6
+ :src="link"
7
+ :aspect-ratio="computedRatio"
8
+ :width="width"
9
+ :max-width="width"
10
+ contain
11
+ @click="select"
12
+ @load="handleLoadImage"
13
+ ></v-img>
14
+ </template>
15
+
16
+ <script>
17
+ export default {
18
+ name: "thumbnail-entry",
19
+ props: {
20
+ selected: { type: Boolean, default: false },
21
+ link: { type: String, default: null },
22
+ thumbnailRatio: { type: String, default: null }
23
+ },
24
+ data() {
25
+ return {
26
+ activeStyle: "border: 3px solid black; border-radius: 3px;",
27
+ ratio: null,
28
+ width: "calc(100%/3 - 16px)"
29
+ };
30
+ },
31
+ computed: {
32
+ computedRatio() {
33
+ if (this.thumbnailRatio) {
34
+ const [a, b] = this.thumbnailRatio.split("/");
35
+ if (b) {
36
+ return Number(a) / Number(b);
37
+ }
38
+ return Number(a);
39
+ }
40
+ return this.ratio;
41
+ }
42
+ },
43
+ methods: {
44
+ select() {
45
+ this.$emit("select");
46
+ },
47
+ handleLoadImage() {
48
+ const { height, width } =
49
+ this.$refs.thumbnail.$el.getBoundingClientRect();
50
+ this.ratio = width / height;
51
+ }
52
+ }
53
+ };
54
+ </script>
55
+
56
+ <style scoped>
57
+ .thumbnail {
58
+ cursor: pointer;
59
+ }
60
+ </style>
@@ -115,6 +115,7 @@
115
115
  v-if="displayThumbnails"
116
116
  :value.sync="value"
117
117
  :entries="entries"
118
+ :thumbnailRatio="thumbnailRatio"
118
119
  @select="updateFromThumbnail"
119
120
  ></thumbnail-entries>
120
121
  </div>
@@ -145,7 +146,8 @@ export default {
145
146
  clickableFrame: { type: Boolean, default: true },
146
147
  playerBarTop: { type: Boolean, default: true },
147
148
  entries: { type: Array, default: () => [] },
148
- displayThumbnails: { type: Boolean, default: false }
149
+ displayThumbnails: { type: Boolean, default: false },
150
+ thumbnailRatio: { type: String, default: null }
149
151
  },
150
152
 
151
153
  data: () => ({
@@ -12,6 +12,7 @@
12
12
  :loadedFrames="loadedFrames"
13
13
  :entries="entries"
14
14
  :displayThumbnails="displayThumbnails"
15
+ :thumbnailRatio="thumbnailRatio"
15
16
  @reload-frames="refreshPreload(loadIndex)"
16
17
  progressBarTitle="Loading image"
17
18
  >
@@ -63,12 +64,17 @@ export default {
63
64
 
64
65
  entries: {
65
66
  type: Array,
66
- default: () => null
67
+ default: () => []
67
68
  },
68
69
 
69
70
  displayThumbnails: {
70
71
  type: Boolean,
71
72
  default: false
73
+ },
74
+
75
+ thumbnailRatio: {
76
+ type: String,
77
+ default: null
72
78
  }
73
79
  },
74
80