tg-blog 1.3.2 → 1.3.3

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,7 +1,7 @@
1
1
  {
2
2
  "name": "tg-blog",
3
3
  "type": "module",
4
- "version": "1.3.2",
4
+ "version": "1.3.3",
5
5
  "packageManager": "bun@1.3.13",
6
6
  "repository": {
7
7
  "type": "git",
@@ -52,7 +52,7 @@ function pause() {
52
52
 
53
53
  function play() {
54
54
  if (!playing.value) return
55
- void playing.value.play()
55
+ playing.value.play().catch(() => {})
56
56
  playbackTick.value++
57
57
  emit("play")
58
58
  }
@@ -99,7 +99,7 @@ function init() {
99
99
  next()
100
100
  }
101
101
 
102
- void player.play()
102
+ player.play().catch(() => {})
103
103
  }
104
104
 
105
105
  watch(() => props.audio, init, {immediate: true})
@@ -1,26 +1,27 @@
1
1
  <template>
2
- <div class="post-media-content" :class="{bleed, compact}">
3
- <div class="images" v-if="images.length"
4
- :class="{'has-head': hasHead}"
5
- :style="containerStyle">
6
- <div class="image_container" v-for="(img, i) in images" :key="`${img.url}-${i}`" :style="getImageStyle(i)">
7
- <img :src="img.thumb || img.url" alt="image"
8
- class="clickable"
9
- :class="{media_spoiler: isSpoilerActive(img, i)}"
10
- @click.stop="clickImg(img, i)"
11
- style="inset: 0">
12
- </div>
13
- </div>
14
- <div class="files" v-if="files.length" :class="{'has-images': images.length > 0}">
15
- <FileView v-for="(f, i) in files" :key="`${f.url}-${i}`" :f="f"
16
- :has-head="i > 0 || hasHead || images.length > 0"
17
- :interactive="interactive"
18
- :poll-state="f.media_type === 'poll' ? pollState : null"
19
- :poll-voting="pollVoting"
20
- @play-file="file => emit('play-file', file)"
21
- @vote-poll="(pollId, indices) => emit('vote-poll', pollId, indices)" />
2
+ <div v-if="images.length"
3
+ class="images"
4
+ :class="{'has-head': hasHead, bleed, compact}"
5
+ :style="containerStyle">
6
+ <div class="image_container" v-for="(img, i) in images" :key="`${img.url}-${i}`" :style="getImageStyle(i)">
7
+ <img :src="img.thumb || img.url" alt="image"
8
+ class="clickable"
9
+ :class="{media_spoiler: isSpoilerActive(img, i)}"
10
+ @click.stop="clickImg(img, i)"
11
+ style="inset: 0">
22
12
  </div>
23
13
  </div>
14
+ <div v-if="files.length"
15
+ class="files"
16
+ :class="{'has-images': images.length > 0, bleed, compact}">
17
+ <FileView v-for="(f, i) in files" :key="`${f.url}-${i}`" :f="f"
18
+ :has-head="i > 0 || hasHead || images.length > 0"
19
+ :interactive="interactive"
20
+ :poll-state="f.media_type === 'poll' ? pollState : null"
21
+ :poll-voting="pollVoting"
22
+ @play-file="file => emit('play-file', file)"
23
+ @vote-poll="(pollId, indices) => emit('vote-poll', pollId, indices)" />
24
+ </div>
24
25
  </template>
25
26
 
26
27
  <script lang="ts" setup>
@@ -74,7 +75,9 @@ const containerStyle = computed(() => {
74
75
  if (!dims.value) return {}
75
76
  const ss = props.scale
76
77
  const dm = dims.value.containerStyle
77
- return {width: dm.width * ss + 'px', height: dm.height * ss + 'px'}
78
+ const width = dm.width || Math.max(0, ...dims.value.layout.map(l => l.dimensions.x + l.dimensions.width))
79
+ const height = dm.height || Math.max(0, ...dims.value.layout.map(l => l.dimensions.y + l.dimensions.height))
80
+ return {width: width * ss + 'px', height: height * ss + 'px'}
78
81
  })
79
82
 
80
83
  function getImageStyle(i: number): StyleValue {
@@ -106,53 +109,49 @@ function clickImg(img: Image, i: number) {
106
109
  </script>
107
110
 
108
111
  <style lang="sass" scoped>
109
- .post-media-content
110
- .images
111
- display: flex
112
- position: relative
113
- max-width: 100%
114
-
115
- .image_container
116
- overflow: hidden
117
- position: absolute
118
- // Gray bg is needed to fix the white infix vignette effect from the spoiler blur
119
- background: gray
120
-
121
- img
122
- width: 100%
123
- height: 100%
124
- object-fit: cover
125
- transition: filter 1s ease
112
+ .images
113
+ display: flex
114
+ position: relative
115
+
116
+ .image_container
117
+ overflow: hidden
118
+ position: absolute
119
+ // Gray bg is needed to fix the white infix vignette effect from the spoiler blur
120
+ background: gray
121
+
122
+ img
123
+ width: 100%
124
+ height: 100%
125
+ object-fit: cover
126
+ transition: filter 1s ease
126
127
 
127
128
  &.bleed
128
- .images
129
- margin: -12px -20px 10px
129
+ margin: -12px -20px 10px
130
+
131
+ &.has-head
132
+ margin: 0 -20px 10px
130
133
 
131
- &.has-head
132
- margin: 0 -20px 10px
134
+ &:not(.bleed)
135
+ margin: 0
136
+ max-width: 100%
137
+ border-radius: 10px
138
+ overflow: hidden
133
139
 
134
- .files
135
- margin-left: -20px
136
- margin-right: -20px
140
+ .files
141
+ &.bleed
142
+ margin-left: -20px
143
+ margin-right: -20px
137
144
 
138
- > * + *
139
- margin-top: 10px
145
+ > * + *
146
+ margin-top: 10px
140
147
 
141
148
  &:not(.bleed)
142
149
  display: flex
143
150
  flex-direction: column
144
151
  gap: 6px
145
- max-width: 100%
146
-
147
- .images
148
- margin: 0
149
- border-radius: 10px
150
- overflow: hidden
151
152
 
152
- .files
153
- display: flex
154
- flex-direction: column
155
- gap: 6px
153
+ &.has-images:not(.bleed)
154
+ margin-top: 6px
156
155
 
157
156
  &.compact
158
157
  :deep(.file), :deep(.sticker)