@webitel/ui-chats 26.12.3 → 26.12.5
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 +1 -1
- package/src/adapters/chat-web-sdk/__tests__/toChatMessage.spec.ts +58 -0
- package/src/adapters/chat-web-sdk/toChatMessage.ts +3 -2
- package/src/shared/scripts/__tests__/isSafeAttachmentUrl.spec.ts +13 -0
- package/src/shared/scripts/isSafeAttachmentUrl.ts +18 -0
- package/src/ui/image-viewer/__tests__/image-viewer.spec.ts +28 -0
- package/src/ui/image-viewer/image-viewer.vue +7 -2
- package/src/ui/messaging/modules/message/components/chat-message.vue +2 -2
- package/src/ui/messaging/modules/message/components/details/__tests__/details.spec.ts +130 -0
- package/src/ui/messaging/modules/message/components/details/chat-message-document.vue +7 -2
- package/src/ui/messaging/modules/message/components/details/chat-message-image.vue +5 -1
- package/src/ui/messaging/modules/message/components/details/chat-message-player.vue +3 -1
- package/src/v2/scripts/__tests__/attachments.spec.ts +71 -0
- package/src/v2/scripts/attachments.ts +13 -4
- package/src/v2/ui/chat-history/__tests__/chat-history.spec.ts +31 -0
- package/src/v2/ui/chat-history/chat-history.vue +5 -1
- package/src/v2/ui/chat-history/components/__tests__/message-attachments.spec.ts +73 -0
- package/src/v2/ui/chat-history/components/message-attachments.vue +22 -7
- package/types/.tsbuildinfo +1 -1
- package/types/shared/scripts/isSafeAttachmentUrl.d.ts +4 -0
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
@click="gallery?.open(key)"
|
|
15
15
|
>
|
|
16
16
|
<img
|
|
17
|
-
:src="image.url"
|
|
17
|
+
:src="toSafeAttachmentUrl(image.url)"
|
|
18
18
|
alt=""
|
|
19
19
|
loading="lazy"
|
|
20
20
|
>
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
</div>
|
|
23
23
|
|
|
24
24
|
<template
|
|
25
|
-
v-for="{ key, document, kind } of
|
|
25
|
+
v-for="{ key, document, kind, playerSrc } of media"
|
|
26
26
|
:key="key"
|
|
27
27
|
>
|
|
28
28
|
<wt-vidstack-player
|
|
29
29
|
v-if="kind === 'video'"
|
|
30
30
|
class="message-attachments__media"
|
|
31
|
-
:src="document.url"
|
|
31
|
+
:src="toPlayableAttachmentUrl(document.url)"
|
|
32
32
|
:mime="document.mime"
|
|
33
33
|
:title="document.name"
|
|
34
34
|
:size="ComponentSize.SM"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
<wt-player
|
|
41
41
|
v-else
|
|
42
42
|
class="message-attachments__media"
|
|
43
|
-
:src="
|
|
43
|
+
:src="playerSrc"
|
|
44
44
|
:autoplay="false"
|
|
45
45
|
:closable="false"
|
|
46
46
|
countdown-time-mode
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
v-for="file of attachments.files"
|
|
54
54
|
:key="file.key"
|
|
55
55
|
class="message-attachments__file"
|
|
56
|
-
:href="file.url"
|
|
56
|
+
:href="toSafeAttachmentUrl(file.url)"
|
|
57
57
|
target="_blank"
|
|
58
|
-
rel="noopener"
|
|
58
|
+
rel="noopener noreferrer"
|
|
59
59
|
download
|
|
60
60
|
:title="t('history.download')"
|
|
61
61
|
>
|
|
@@ -75,7 +75,10 @@ import { WtIcon, WtPlayer, WtVidstackPlayer } from '@webitel/ui-sdk/components';
|
|
|
75
75
|
import { ComponentSize } from '@webitel/ui-sdk/enums';
|
|
76
76
|
import { prettifyFileSize } from '@webitel/ui-sdk/scripts';
|
|
77
77
|
import { computed, inject } from 'vue';
|
|
78
|
-
|
|
78
|
+
import {
|
|
79
|
+
toPlayableAttachmentUrl,
|
|
80
|
+
toSafeAttachmentUrl,
|
|
81
|
+
} from '../../../../shared/scripts/isSafeAttachmentUrl';
|
|
79
82
|
import { useChatsV2I18n } from '../../../locale/useChatsV2I18n';
|
|
80
83
|
import { classifyAttachments } from '../../../scripts/attachments';
|
|
81
84
|
import type { ChatImage, MessageModel } from '../../../types';
|
|
@@ -88,8 +91,20 @@ const props = defineProps<{
|
|
|
88
91
|
const { t } = useChatsV2I18n();
|
|
89
92
|
const gallery = inject(ChatGalleryKey, null);
|
|
90
93
|
|
|
94
|
+
// classifyAttachments already filters; the template re-checks on purpose
|
|
91
95
|
const attachments = computed(() => classifyAttachments(props.message));
|
|
92
96
|
|
|
97
|
+
// typed source: with no MIME Vidstack would turn a youtube url into an embed
|
|
98
|
+
const media = computed(() =>
|
|
99
|
+
attachments.value.media.map((item) => ({
|
|
100
|
+
...item,
|
|
101
|
+
playerSrc: {
|
|
102
|
+
src: toPlayableAttachmentUrl(item.document.url),
|
|
103
|
+
type: item.document.mime ?? '',
|
|
104
|
+
},
|
|
105
|
+
})),
|
|
106
|
+
);
|
|
107
|
+
|
|
93
108
|
// Reserve the box before the image loads, so a late load cannot shift the
|
|
94
109
|
// scroll position.
|
|
95
110
|
const aspectRatio = (image: ChatImage) => ({
|