@memori.ai/memori-react 8.15.1 → 8.16.0
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/CHANGELOG.md +26 -0
- package/dist/components/Chat/Chat.css +2 -1
- package/dist/components/Chat/Chat.js +17 -17
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.css +1 -1
- package/dist/components/ContentPreviewModal/ContentPreviewModal.css +114 -0
- package/dist/components/ContentPreviewModal/ContentPreviewModal.d.ts +14 -0
- package/dist/components/ContentPreviewModal/ContentPreviewModal.js +18 -0
- package/dist/components/ContentPreviewModal/ContentPreviewModal.js.map +1 -0
- package/dist/components/ContentPreviewModal/index.d.ts +2 -0
- package/dist/components/ContentPreviewModal/index.js +9 -0
- package/dist/components/ContentPreviewModal/index.js.map +1 -0
- package/dist/components/FilePreview/FilePreview.css +1 -1
- package/dist/components/FilePreview/FilePreview.js +43 -13
- package/dist/components/FilePreview/FilePreview.js.map +1 -1
- package/dist/components/MediaWidget/DocumentCard.d.ts +3 -0
- package/dist/components/MediaWidget/DocumentCard.js +9 -0
- package/dist/components/MediaWidget/DocumentCard.js.map +1 -0
- package/dist/components/MediaWidget/MediaItemWidget.css +946 -19
- package/dist/components/MediaWidget/MediaItemWidget.d.ts +5 -36
- package/dist/components/MediaWidget/MediaItemWidget.js +295 -198
- package/dist/components/MediaWidget/MediaItemWidget.js.map +1 -1
- package/dist/components/MediaWidget/MediaItemWidget.types.d.ts +62 -0
- package/dist/components/MediaWidget/MediaItemWidget.types.js +3 -0
- package/dist/components/MediaWidget/MediaItemWidget.types.js.map +1 -0
- package/dist/components/MediaWidget/MediaItemWidget.utils.d.ts +23 -0
- package/dist/components/MediaWidget/MediaItemWidget.utils.js +162 -0
- package/dist/components/MediaWidget/MediaItemWidget.utils.js.map +1 -0
- package/dist/components/MediaWidget/MediaPreviewModal.d.ts +15 -0
- package/dist/components/MediaWidget/MediaPreviewModal.js +162 -0
- package/dist/components/MediaWidget/MediaPreviewModal.js.map +1 -0
- package/dist/components/MediaWidget/MediaWidget.js +1 -2
- package/dist/components/MediaWidget/MediaWidget.js.map +1 -1
- package/dist/components/Snippet/Snippet.css +64 -33
- package/dist/components/Snippet/Snippet.js +17 -4
- package/dist/components/Snippet/Snippet.js.map +1 -1
- package/dist/components/StartPanel/StartPanel.js +1 -2
- package/dist/components/StartPanel/StartPanel.js.map +1 -1
- package/dist/components/UploadButton/UploadButton.css +0 -5
- package/dist/components/layouts/WebsiteAssistant.js +8 -8
- package/dist/components/layouts/WebsiteAssistant.js.map +1 -1
- package/dist/components/layouts/chat.css +1 -1
- package/dist/components/layouts/website-assistant.css +405 -197
- package/dist/helpers/constants.js +0 -7
- package/dist/helpers/constants.js.map +1 -1
- package/dist/helpers/utils.d.ts +1 -0
- package/dist/helpers/utils.js +3 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/index.js +43 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +0 -2
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/esm/components/Chat/Chat.css +2 -1
- package/esm/components/Chat/Chat.js +17 -17
- package/esm/components/Chat/Chat.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.css +1 -1
- package/esm/components/ContentPreviewModal/ContentPreviewModal.css +114 -0
- package/esm/components/ContentPreviewModal/ContentPreviewModal.d.ts +14 -0
- package/esm/components/ContentPreviewModal/ContentPreviewModal.js +15 -0
- package/esm/components/ContentPreviewModal/ContentPreviewModal.js.map +1 -0
- package/esm/components/ContentPreviewModal/index.d.ts +2 -0
- package/esm/components/ContentPreviewModal/index.js +2 -0
- package/esm/components/ContentPreviewModal/index.js.map +1 -0
- package/esm/components/FilePreview/FilePreview.css +1 -1
- package/esm/components/FilePreview/FilePreview.js +44 -14
- package/esm/components/FilePreview/FilePreview.js.map +1 -1
- package/esm/components/MediaWidget/DocumentCard.d.ts +3 -0
- package/esm/components/MediaWidget/DocumentCard.js +5 -0
- package/esm/components/MediaWidget/DocumentCard.js.map +1 -0
- package/esm/components/MediaWidget/MediaItemWidget.css +946 -19
- package/esm/components/MediaWidget/MediaItemWidget.d.ts +5 -36
- package/esm/components/MediaWidget/MediaItemWidget.js +296 -197
- package/esm/components/MediaWidget/MediaItemWidget.js.map +1 -1
- package/esm/components/MediaWidget/MediaItemWidget.types.d.ts +62 -0
- package/esm/components/MediaWidget/MediaItemWidget.types.js +2 -0
- package/esm/components/MediaWidget/MediaItemWidget.types.js.map +1 -0
- package/esm/components/MediaWidget/MediaItemWidget.utils.d.ts +23 -0
- package/esm/components/MediaWidget/MediaItemWidget.utils.js +149 -0
- package/esm/components/MediaWidget/MediaItemWidget.utils.js.map +1 -0
- package/esm/components/MediaWidget/MediaPreviewModal.d.ts +15 -0
- package/esm/components/MediaWidget/MediaPreviewModal.js +157 -0
- package/esm/components/MediaWidget/MediaPreviewModal.js.map +1 -0
- package/esm/components/MediaWidget/MediaWidget.js +1 -2
- package/esm/components/MediaWidget/MediaWidget.js.map +1 -1
- package/esm/components/Snippet/Snippet.css +64 -33
- package/esm/components/Snippet/Snippet.js +18 -5
- package/esm/components/Snippet/Snippet.js.map +1 -1
- package/esm/components/StartPanel/StartPanel.js +1 -2
- package/esm/components/StartPanel/StartPanel.js.map +1 -1
- package/esm/components/UploadButton/UploadButton.css +0 -5
- package/esm/components/layouts/WebsiteAssistant.js +8 -8
- package/esm/components/layouts/WebsiteAssistant.js.map +1 -1
- package/esm/components/layouts/chat.css +1 -1
- package/esm/components/layouts/website-assistant.css +405 -197
- package/esm/helpers/constants.js +0 -7
- package/esm/helpers/constants.js.map +1 -1
- package/esm/helpers/utils.d.ts +1 -0
- package/esm/helpers/utils.js +1 -0
- package/esm/helpers/utils.js.map +1 -1
- package/esm/index.js +43 -1
- package/esm/index.js.map +1 -1
- package/esm/styles.css +0 -2
- package/esm/version.d.ts +1 -0
- package/esm/version.js +2 -0
- package/esm/version.js.map +1 -0
- package/package.json +5 -3
- package/src/components/Chat/Chat.css +2 -1
- package/src/components/Chat/Chat.stories.tsx +124 -0
- package/src/components/Chat/Chat.tsx +72 -71
- package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +567 -1034
- package/src/components/ChatBubble/ChatBubble.css +1 -1
- package/src/components/ContentPreviewModal/ContentPreviewModal.css +114 -0
- package/src/components/ContentPreviewModal/ContentPreviewModal.tsx +69 -0
- package/src/components/ContentPreviewModal/index.ts +2 -0
- package/src/components/FilePreview/FilePreview.css +1 -1
- package/src/components/FilePreview/FilePreview.tsx +60 -37
- package/src/components/FilePreview/__snapshots__/FilePreview.test.tsx.snap +15 -105
- package/src/components/MediaWidget/DocumentCard.test.tsx +45 -0
- package/src/components/MediaWidget/DocumentCard.tsx +19 -0
- package/src/components/MediaWidget/MediaItemWidget.css +946 -19
- package/src/components/MediaWidget/MediaItemWidget.test.tsx +89 -1
- package/src/components/MediaWidget/MediaItemWidget.tsx +734 -461
- package/src/components/MediaWidget/MediaItemWidget.types.ts +65 -0
- package/src/components/MediaWidget/MediaItemWidget.utils.test.ts +324 -0
- package/src/components/MediaWidget/MediaItemWidget.utils.ts +194 -0
- package/src/components/MediaWidget/MediaPreviewModal.test.tsx +271 -0
- package/src/components/MediaWidget/MediaPreviewModal.tsx +423 -0
- package/src/components/MediaWidget/MediaWidget.stories.tsx +193 -0
- package/src/components/MediaWidget/MediaWidget.tsx +2 -4
- package/src/components/MediaWidget/__snapshots__/DocumentCard.test.tsx.snap +24 -0
- package/src/components/MediaWidget/__snapshots__/MediaItemWidget.test.tsx.snap +162 -170
- package/src/components/MediaWidget/__snapshots__/MediaWidget.test.tsx.snap +21 -63
- package/src/components/Snippet/Snippet.css +64 -33
- package/src/components/Snippet/Snippet.tsx +30 -21
- package/src/components/Snippet/__snapshots__/Snippet.test.tsx.snap +314 -297
- package/src/components/StartPanel/StartPanel.tsx +0 -9
- package/src/components/StartPanel/__snapshots__/StartPanel.test.tsx.snap +12 -636
- package/src/components/UploadButton/UploadButton.css +0 -5
- package/src/components/layouts/WebsiteAssistant.tsx +66 -62
- package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +1 -53
- package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +2 -106
- package/src/components/layouts/__snapshots__/HiddenChat.test.tsx.snap +1 -53
- package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +1 -53
- package/src/components/layouts/__snapshots__/WebsiteAssistant.test.tsx.snap +32 -33
- package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +1 -53
- package/src/components/layouts/chat.css +1 -1
- package/src/components/layouts/layouts.stories.tsx +68 -0
- package/src/components/layouts/website-assistant.css +405 -197
- package/src/helpers/constants.ts +0 -7
- package/src/helpers/utils.ts +4 -0
- package/src/index.test.tsx +8 -0
- package/src/index.tsx +51 -1
- package/src/styles.css +0 -2
- package/src/version.ts +2 -0
- package/src/components/AttachmentLinkModal/AttachmentLinkModal.css +0 -68
- package/src/components/AttachmentLinkModal/AttachmentLinkModal.stories.tsx +0 -32
- package/src/components/AttachmentLinkModal/AttachmentLinkModal.test.tsx +0 -10
- package/src/components/AttachmentLinkModal/AttachmentLinkModal.tsx +0 -131
- package/src/components/AttachmentLinkModal/__snapshots__/AttachmentLinkModal.test.tsx.snap +0 -9
- package/src/components/MediaWidget/LinkItemWidget.css +0 -46
- package/src/components/MediaWidget/LinkItemWidget.stories.tsx +0 -61
- package/src/components/MediaWidget/LinkItemWidget.test.tsx +0 -33
- package/src/components/MediaWidget/LinkItemWidget.tsx +0 -204
- package/src/components/MediaWidget/__snapshots__/LinkItemWidget.test.tsx.snap +0 -253
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { MediaPreviewModal } from './MediaPreviewModal';
|
|
5
|
+
import type { Medium } from '@memori.ai/memori-api-client/dist/types';
|
|
6
|
+
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
if (typeof window !== 'undefined' && !window.IntersectionObserver) {
|
|
9
|
+
(window as unknown as { IntersectionObserver: unknown }).IntersectionObserver = jest.fn().mockImplementation(() => ({
|
|
10
|
+
observe: jest.fn(),
|
|
11
|
+
unobserve: jest.fn(),
|
|
12
|
+
disconnect: jest.fn(),
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
if (typeof global !== 'undefined' && !globalThis.IntersectionObserver) {
|
|
16
|
+
(globalThis as unknown as { IntersectionObserver: unknown }).IntersectionObserver = jest.fn().mockImplementation(() => ({
|
|
17
|
+
observe: jest.fn(),
|
|
18
|
+
unobserve: jest.fn(),
|
|
19
|
+
disconnect: jest.fn(),
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
jest.mock('../../helpers/media', () => ({
|
|
25
|
+
getResourceUrl: jest.fn(({ resourceURI }: { resourceURI?: string }) =>
|
|
26
|
+
resourceURI ? `https://resolved.example.com/${resourceURI}` : ''
|
|
27
|
+
),
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
describe('MediaPreviewModal', () => {
|
|
31
|
+
const onClose = jest.fn();
|
|
32
|
+
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
jest.clearAllMocks();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('images', () => {
|
|
38
|
+
it('renders image in ContentPreviewModal with title and src', () => {
|
|
39
|
+
const medium: Medium = {
|
|
40
|
+
mediumID: 'img-1',
|
|
41
|
+
mimeType: 'image/jpeg',
|
|
42
|
+
title: 'Photo',
|
|
43
|
+
url: 'https://example.com/photo.jpg',
|
|
44
|
+
};
|
|
45
|
+
render(
|
|
46
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
47
|
+
);
|
|
48
|
+
expect(screen.getByAltText('Photo')).toBeInTheDocument();
|
|
49
|
+
expect(screen.getByAltText('Photo')).toHaveAttribute('src', expect.stringContaining('photo.jpg'));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('uses base64 data URL when image has content', () => {
|
|
53
|
+
const medium: Medium = {
|
|
54
|
+
mediumID: 'img-2',
|
|
55
|
+
mimeType: 'image/png',
|
|
56
|
+
title: 'Inline',
|
|
57
|
+
content: 'base64content',
|
|
58
|
+
};
|
|
59
|
+
render(
|
|
60
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
61
|
+
);
|
|
62
|
+
const img = screen.getByAltText('Inline');
|
|
63
|
+
expect(img).toHaveAttribute('src', expect.stringMatching(/^data:image\/png;base64,/));
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('code', () => {
|
|
68
|
+
it('renders code snippet with Snippet component', () => {
|
|
69
|
+
const medium: Medium = {
|
|
70
|
+
mediumID: 'code-1',
|
|
71
|
+
mimeType: 'text/javascript',
|
|
72
|
+
title: 'Script',
|
|
73
|
+
content: 'console.log("hello");',
|
|
74
|
+
};
|
|
75
|
+
render(
|
|
76
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
77
|
+
);
|
|
78
|
+
expect(screen.getByText(/console\.log/)).toBeInTheDocument();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('PDF', () => {
|
|
83
|
+
it('renders PDF in iframe when url or content present', () => {
|
|
84
|
+
const medium: Medium = {
|
|
85
|
+
mediumID: 'pdf-1',
|
|
86
|
+
mimeType: 'application/pdf',
|
|
87
|
+
title: 'Document',
|
|
88
|
+
url: 'https://example.com/doc.pdf',
|
|
89
|
+
};
|
|
90
|
+
render(
|
|
91
|
+
<MediaPreviewModal medium={medium} onClose={onClose} sessionID="s1" baseURL="https://api.example.com" />
|
|
92
|
+
);
|
|
93
|
+
const iframe = screen.getByTitle('Document');
|
|
94
|
+
expect(iframe).toBeInTheDocument();
|
|
95
|
+
expect(iframe.tagName).toBe('IFRAME');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe('Excel', () => {
|
|
100
|
+
it('renders Excel in iframe when url or content present', () => {
|
|
101
|
+
const medium: Medium = {
|
|
102
|
+
mediumID: 'xls-1',
|
|
103
|
+
mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
104
|
+
title: 'Sheet',
|
|
105
|
+
url: 'https://example.com/sheet.xlsx',
|
|
106
|
+
};
|
|
107
|
+
render(
|
|
108
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
109
|
+
);
|
|
110
|
+
const iframe = screen.getByTitle('Sheet');
|
|
111
|
+
expect(iframe).toBeInTheDocument();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe('HTML', () => {
|
|
116
|
+
it('renders HTML link in iframe when only url', () => {
|
|
117
|
+
const medium: Medium = {
|
|
118
|
+
mediumID: 'html-1',
|
|
119
|
+
mimeType: 'text/html',
|
|
120
|
+
title: 'Page',
|
|
121
|
+
url: 'example.com/page',
|
|
122
|
+
};
|
|
123
|
+
render(
|
|
124
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
125
|
+
);
|
|
126
|
+
const iframe = screen.getByTitle('Page');
|
|
127
|
+
expect(iframe).toBeInTheDocument();
|
|
128
|
+
expect(iframe).toHaveAttribute('src', 'https://example.com/page');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('renders HTML with content as stripped text in Snippet', () => {
|
|
132
|
+
const medium: Medium = {
|
|
133
|
+
mediumID: 'html-2',
|
|
134
|
+
mimeType: 'text/html',
|
|
135
|
+
title: 'Inline HTML',
|
|
136
|
+
content: '<p>Hello world</p>',
|
|
137
|
+
};
|
|
138
|
+
render(
|
|
139
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
140
|
+
);
|
|
141
|
+
expect(screen.getByText(/Hello world/)).toBeInTheDocument();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
describe('video and audio', () => {
|
|
146
|
+
it('renders video with native controls', () => {
|
|
147
|
+
const medium: Medium = {
|
|
148
|
+
mediumID: 'vid-1',
|
|
149
|
+
mimeType: 'video/mp4',
|
|
150
|
+
title: 'Clip',
|
|
151
|
+
url: 'https://example.com/video.mp4',
|
|
152
|
+
};
|
|
153
|
+
render(
|
|
154
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
155
|
+
);
|
|
156
|
+
const video = document.querySelector('video');
|
|
157
|
+
expect(video).toBeInTheDocument();
|
|
158
|
+
expect(video).toHaveAttribute('src', expect.stringContaining('video.mp4'));
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('renders audio with title and controls', () => {
|
|
162
|
+
const medium: Medium = {
|
|
163
|
+
mediumID: 'aud-1',
|
|
164
|
+
mimeType: 'audio/mpeg',
|
|
165
|
+
title: 'Track',
|
|
166
|
+
url: 'https://example.com/audio.mp3',
|
|
167
|
+
};
|
|
168
|
+
render(
|
|
169
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
170
|
+
);
|
|
171
|
+
expect(screen.getAllByText('Track').length).toBeGreaterThan(0);
|
|
172
|
+
const audio = document.querySelector('audio');
|
|
173
|
+
expect(audio).toBeInTheDocument();
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
describe('plain text and markdown', () => {
|
|
178
|
+
it('renders plain text in Snippet', () => {
|
|
179
|
+
const medium: Medium = {
|
|
180
|
+
mediumID: 'txt-1',
|
|
181
|
+
mimeType: 'text/plain',
|
|
182
|
+
title: 'Notes',
|
|
183
|
+
content: 'Some plain text.',
|
|
184
|
+
};
|
|
185
|
+
render(
|
|
186
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
187
|
+
);
|
|
188
|
+
expect(screen.getByText(/Some plain text/)).toBeInTheDocument();
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('renders markdown in Snippet', () => {
|
|
192
|
+
const medium: Medium = {
|
|
193
|
+
mediumID: 'md-1',
|
|
194
|
+
mimeType: 'text/markdown',
|
|
195
|
+
title: 'Readme',
|
|
196
|
+
content: '# Title\n\nParagraph.',
|
|
197
|
+
};
|
|
198
|
+
render(
|
|
199
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
200
|
+
);
|
|
201
|
+
expect(screen.getByText(/# Title/)).toBeInTheDocument();
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
describe('Word / fallback', () => {
|
|
206
|
+
it('shows "Preview not available" for Word docs with Open and Download', () => {
|
|
207
|
+
const medium: Medium = {
|
|
208
|
+
mediumID: 'doc-1',
|
|
209
|
+
mimeType: 'application/msword',
|
|
210
|
+
title: 'Report.doc',
|
|
211
|
+
url: 'https://example.com/report.doc',
|
|
212
|
+
};
|
|
213
|
+
render(
|
|
214
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
215
|
+
);
|
|
216
|
+
expect(screen.getByText(/Preview not available for this document/)).toBeInTheDocument();
|
|
217
|
+
expect(screen.getByText(/Open in new tab/)).toBeInTheDocument();
|
|
218
|
+
expect(screen.getByText(/Download/)).toBeInTheDocument();
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('shows generic fallback for unknown file type', () => {
|
|
222
|
+
const medium: Medium = {
|
|
223
|
+
mediumID: 'unk-1',
|
|
224
|
+
mimeType: 'application/octet-stream',
|
|
225
|
+
title: 'file.bin',
|
|
226
|
+
url: 'https://example.com/file.bin',
|
|
227
|
+
};
|
|
228
|
+
render(
|
|
229
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
230
|
+
);
|
|
231
|
+
expect(screen.getByText(/Preview not available for this file type/)).toBeInTheDocument();
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
describe('document attachment content', () => {
|
|
236
|
+
it('renders document attachment text in Snippet', () => {
|
|
237
|
+
const medium: Medium = {
|
|
238
|
+
mediumID: 'att-1',
|
|
239
|
+
mimeType: 'text/plain',
|
|
240
|
+
title: 'Extracted',
|
|
241
|
+
content: 'Extracted text from PDF',
|
|
242
|
+
properties: { isDocumentAttachment: true },
|
|
243
|
+
};
|
|
244
|
+
render(
|
|
245
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
246
|
+
);
|
|
247
|
+
expect(screen.getByText(/Extracted text from PDF/)).toBeInTheDocument();
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
describe('onClose', () => {
|
|
252
|
+
it('modal can be closed via ContentPreviewModal', () => {
|
|
253
|
+
const medium: Medium = {
|
|
254
|
+
mediumID: 'img-1',
|
|
255
|
+
mimeType: 'image/jpeg',
|
|
256
|
+
title: 'Photo',
|
|
257
|
+
url: 'https://example.com/photo.jpg',
|
|
258
|
+
};
|
|
259
|
+
render(
|
|
260
|
+
<MediaPreviewModal medium={medium} onClose={onClose} />
|
|
261
|
+
);
|
|
262
|
+
const closeWrapper = document.querySelector('.memori-modal--close');
|
|
263
|
+
expect(closeWrapper).toBeInTheDocument();
|
|
264
|
+
const closeButton = closeWrapper?.querySelector('button');
|
|
265
|
+
if (closeButton) {
|
|
266
|
+
fireEvent.click(closeButton);
|
|
267
|
+
expect(onClose).toHaveBeenCalled();
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
});
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import type { Medium } from '@memori.ai/memori-api-client/dist/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { getResourceUrl } from '../../helpers/media';
|
|
4
|
+
import { prismSyntaxLangs } from '../../helpers/constants';
|
|
5
|
+
import { stripHTML, stripDocumentAttachmentTags } from '../../helpers/utils';
|
|
6
|
+
import Snippet from '../Snippet/Snippet';
|
|
7
|
+
import ContentPreviewModal from '../ContentPreviewModal';
|
|
8
|
+
import ModelViewer from '../CustomGLBModelViewer/ModelViewer';
|
|
9
|
+
import {
|
|
10
|
+
IMAGE_MIME_TYPES,
|
|
11
|
+
getImageDisplaySource,
|
|
12
|
+
} from './MediaItemWidget.utils';
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* Media types handled in MediaPreviewModal and recommended UX:
|
|
16
|
+
*
|
|
17
|
+
* 1. IMAGES (image/jpeg, image/png, image/jpg, image/gif)
|
|
18
|
+
* → Full-size in modal with title. Object-fit contain, optional alt.
|
|
19
|
+
*
|
|
20
|
+
* 2. CODE (text/javascript, text/ecmascript, application/json, text/css, application/xml,
|
|
21
|
+
* application/x-sh, text/x-python, text/x-c++src, application/x-php, text/x-ruby, text/x-sql)
|
|
22
|
+
* → Snippet with syntax highlighting and copy button.
|
|
23
|
+
*
|
|
24
|
+
* 3. PDF (application/pdf)
|
|
25
|
+
* → Inline iframe preview; base64 or resource URL.
|
|
26
|
+
*
|
|
27
|
+
* 4. EXCEL (application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
|
|
28
|
+
* → Inline iframe preview; base64 or resource URL.
|
|
29
|
+
*
|
|
30
|
+
* 5. HTML WITH CONTENT (text/html + content)
|
|
31
|
+
* → Snippet showing stripped HTML as plain text.
|
|
32
|
+
*
|
|
33
|
+
* 6. HTML LINK (text/html + url only)
|
|
34
|
+
* → Iframe loading the URL (https normalized).
|
|
35
|
+
*
|
|
36
|
+
* 7. VIDEO (video/mp4, video/quicktime, video/avi, video/mpeg)
|
|
37
|
+
* → Native <video> with controls; base64 or resource URL.
|
|
38
|
+
*
|
|
39
|
+
* 8. AUDIO (audio/mpeg3, audio/wav, audio/mpeg)
|
|
40
|
+
* → Native <audio> with controls; clear label and optional poster.
|
|
41
|
+
*
|
|
42
|
+
* 9. 3D MODEL (model/gltf-binary)
|
|
43
|
+
* → ModelViewer in modal with fixed height and camera controls.
|
|
44
|
+
*
|
|
45
|
+
* 10. PLAIN TEXT (text/plain)
|
|
46
|
+
* → Snippet (language-text) for readable, copyable content.
|
|
47
|
+
*
|
|
48
|
+
* 11. MARKDOWN (text/markdown)
|
|
49
|
+
* → Snippet for now (readable as text); can be upgraded to rendered markdown later.
|
|
50
|
+
*
|
|
51
|
+
* 12. WORD / OTHER DOCS (application/msword, application/vnd...wordprocessingml.document, etc.)
|
|
52
|
+
* → No reliable in-browser preview; show “Preview not available” + Open in new tab + Download.
|
|
53
|
+
*
|
|
54
|
+
* 13. UNKNOWN / FALLBACK
|
|
55
|
+
* → Never empty: show title, type, and Open in new tab / Download.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
// Collect supported code mime types for quick lookup
|
|
59
|
+
const CODE_MIME_TYPES = prismSyntaxLangs.map((l) => l.mimeType);
|
|
60
|
+
|
|
61
|
+
// Constants for file type mime types
|
|
62
|
+
const MIME_PDF = 'application/pdf';
|
|
63
|
+
const MIME_EXCEL_XLS = 'application/vnd.ms-excel';
|
|
64
|
+
const MIME_EXCEL_XLSX =
|
|
65
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
66
|
+
const MIME_HTML = 'text/html';
|
|
67
|
+
const MIME_PLAIN = 'text/plain';
|
|
68
|
+
const MIME_CSV = 'text/csv';
|
|
69
|
+
const MIME_MARKDOWN = 'text/markdown';
|
|
70
|
+
const MIME_WORD_DOC = 'application/msword';
|
|
71
|
+
const MIME_WORD_DOCX =
|
|
72
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
|
73
|
+
|
|
74
|
+
const VIDEO_MIME_TYPES = [
|
|
75
|
+
'video/mp4',
|
|
76
|
+
'video/quicktime',
|
|
77
|
+
'video/avi',
|
|
78
|
+
'video/mpeg',
|
|
79
|
+
] as const;
|
|
80
|
+
|
|
81
|
+
const AUDIO_MIME_TYPES = [
|
|
82
|
+
'audio/mpeg3',
|
|
83
|
+
'audio/wav',
|
|
84
|
+
'audio/mpeg',
|
|
85
|
+
] as const;
|
|
86
|
+
|
|
87
|
+
const MIME_3D_GLB = 'model/gltf-binary';
|
|
88
|
+
|
|
89
|
+
// Placeholder for 3D model loading (gray 200x200 SVG)
|
|
90
|
+
const DEFAULT_GLB_POSTER =
|
|
91
|
+
'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgZmlsbD0iI2U1ZTdlYiIvPjwvc3ZnPg==';
|
|
92
|
+
|
|
93
|
+
function isVideo(mimeType: string): boolean {
|
|
94
|
+
return (VIDEO_MIME_TYPES as readonly string[]).includes(mimeType);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function isAudio(mimeType: string): boolean {
|
|
98
|
+
return (AUDIO_MIME_TYPES as readonly string[]).includes(mimeType);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function isWordDoc(mimeType: string): boolean {
|
|
102
|
+
return mimeType === MIME_WORD_DOC || mimeType === MIME_WORD_DOCX;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Document attachments (PDF, XLSX, TXT, CSV, etc.) are extracted as text, not binary.
|
|
106
|
+
// Detect when content is actually plain text / XML from document_attachment so we render it as text.
|
|
107
|
+
function isDocumentAttachmentContent(content: string | null | undefined): boolean {
|
|
108
|
+
if (!content || typeof content !== 'string') return false;
|
|
109
|
+
const trimmed = content.trim();
|
|
110
|
+
return (
|
|
111
|
+
trimmed.includes('document_attachment') ||
|
|
112
|
+
trimmed.includes('<document_attachment') ||
|
|
113
|
+
trimmed.includes('</document_attachment>') ||
|
|
114
|
+
trimmed.includes('<document_attachment') ||
|
|
115
|
+
trimmed.includes('</document_attachment>') ||
|
|
116
|
+
(trimmed.startsWith('<') && trimmed.includes('>') && trimmed.length < 10000) // Likely XML/text, not binary
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Props for the MediaPreviewModal component
|
|
121
|
+
export interface MediaPreviewModalProps {
|
|
122
|
+
medium: Medium;
|
|
123
|
+
onClose: () => void;
|
|
124
|
+
sessionID?: string;
|
|
125
|
+
tenantID?: string;
|
|
126
|
+
baseURL?: string;
|
|
127
|
+
apiURL?: string;
|
|
128
|
+
customMediaRenderer?: (mimeType: string) => JSX.Element | null;
|
|
129
|
+
descriptionOneLine?: boolean;
|
|
130
|
+
onLinkPreviewInfo?: (info: import('./MediaItemWidget.types').LinkPreviewInfo) => void;
|
|
131
|
+
onMediumClick?: (mediumID: string) => void;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// MediaPreviewModal displays a modal preview of a media file, including special handling for code, PDF, HTML, etc.
|
|
135
|
+
export function MediaPreviewModal({
|
|
136
|
+
medium,
|
|
137
|
+
onClose,
|
|
138
|
+
sessionID,
|
|
139
|
+
tenantID,
|
|
140
|
+
baseURL,
|
|
141
|
+
apiURL,
|
|
142
|
+
customMediaRenderer: _customMediaRenderer,
|
|
143
|
+
descriptionOneLine: _descriptionOneLine,
|
|
144
|
+
onLinkPreviewInfo: _onLinkPreviewInfo,
|
|
145
|
+
onMediumClick: _onMediumClick,
|
|
146
|
+
}: MediaPreviewModalProps): React.ReactElement {
|
|
147
|
+
// Determine the preview url for the medium based on its properties and the current session
|
|
148
|
+
const previewUrl = getResourceUrl({
|
|
149
|
+
resourceURI: medium.url,
|
|
150
|
+
sessionID,
|
|
151
|
+
tenantID,
|
|
152
|
+
baseURL,
|
|
153
|
+
apiURL,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Check if this is a document attachment (extracted text, not binary file)
|
|
157
|
+
// Document attachments can be PDF, XLSX, TXT, CSV, HTML, JSON, MD - all converted to text
|
|
158
|
+
// Also check for attached files uploaded by the user
|
|
159
|
+
const isDocumentAttachment =
|
|
160
|
+
medium.properties?.isDocumentAttachment === true ||
|
|
161
|
+
medium.properties?.isAttachedFile === true ||
|
|
162
|
+
isDocumentAttachmentContent(medium.content);
|
|
163
|
+
|
|
164
|
+
// Detect the type of the medium for custom rendering logic
|
|
165
|
+
const isImage = IMAGE_MIME_TYPES.includes(medium.mimeType as (typeof IMAGE_MIME_TYPES)[number]);
|
|
166
|
+
const isCode = CODE_MIME_TYPES.includes(medium.mimeType);
|
|
167
|
+
const isPdf = medium.mimeType === MIME_PDF && !isDocumentAttachment;
|
|
168
|
+
const isExcel =
|
|
169
|
+
(medium.mimeType === MIME_EXCEL_XLS || medium.mimeType === MIME_EXCEL_XLSX) &&
|
|
170
|
+
!isDocumentAttachment;
|
|
171
|
+
const isHtmlWithContent = medium.mimeType === MIME_HTML && !!medium.content;
|
|
172
|
+
const isHtmlLink =
|
|
173
|
+
medium.mimeType === MIME_HTML && !!medium.url;
|
|
174
|
+
const isVideoType = isVideo(medium.mimeType);
|
|
175
|
+
const isAudioType = isAudio(medium.mimeType);
|
|
176
|
+
const is3D = medium.mimeType === MIME_3D_GLB;
|
|
177
|
+
// CSV files are converted to text and should be rendered as plain text
|
|
178
|
+
const isCsv = medium.mimeType === MIME_CSV;
|
|
179
|
+
const isPlainText = medium.mimeType === MIME_PLAIN || isDocumentAttachment || isCsv;
|
|
180
|
+
const isMarkdown = medium.mimeType === MIME_MARKDOWN;
|
|
181
|
+
const isWordType = isWordDoc(medium.mimeType);
|
|
182
|
+
|
|
183
|
+
// Video/audio src: data URL from content or resource URL
|
|
184
|
+
const mediaSrc =
|
|
185
|
+
medium.content != null
|
|
186
|
+
? `data:${medium.mimeType};base64,${medium.content}`
|
|
187
|
+
: previewUrl;
|
|
188
|
+
const hasMediaSrc = !!mediaSrc;
|
|
189
|
+
const glbSrc =
|
|
190
|
+
medium.content != null
|
|
191
|
+
? `data:model/gltf-binary;base64,${medium.content}`
|
|
192
|
+
: previewUrl;
|
|
193
|
+
|
|
194
|
+
// Image: use shared resolution (resource URL, base64, or rgb) so modal matches grid
|
|
195
|
+
const imageDisplay = isImage
|
|
196
|
+
? getImageDisplaySource(medium, previewUrl)
|
|
197
|
+
: { src: undefined as string | undefined, isRgb: false };
|
|
198
|
+
const { src: imageSrc, isRgb: isImageRgb } = imageDisplay;
|
|
199
|
+
|
|
200
|
+
// For Excel and similar types, prepare an iframe src using either content (data URL) or preview url
|
|
201
|
+
const iframeSrcFromContent = medium.content
|
|
202
|
+
? `data:${medium.mimeType};base64,${medium.content}`
|
|
203
|
+
: previewUrl;
|
|
204
|
+
|
|
205
|
+
// For HTML links, ensure the link src starts with "http" or prepend "https://"
|
|
206
|
+
const htmlLinkSrc =
|
|
207
|
+
!medium.url || medium.url.startsWith('http')
|
|
208
|
+
? medium.url
|
|
209
|
+
: `https://${medium.url}`;
|
|
210
|
+
|
|
211
|
+
// HTML/content as text: render inside Snippet (converted to text)
|
|
212
|
+
const htmlAsTextMedium: Medium = {
|
|
213
|
+
...medium,
|
|
214
|
+
mimeType: 'text/plain',
|
|
215
|
+
content: stripHTML(medium.content || ''),
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// Image preview: same source as grid (URL, base64, or rgb swatch)
|
|
219
|
+
if (isImage) {
|
|
220
|
+
if (isImageRgb && medium.url) {
|
|
221
|
+
return (
|
|
222
|
+
<ContentPreviewModal
|
|
223
|
+
open
|
|
224
|
+
onClose={onClose}
|
|
225
|
+
title={medium.title ?? undefined}
|
|
226
|
+
>
|
|
227
|
+
<div
|
|
228
|
+
className="memori-media-item-preview--content memori-media-item--modal-rgb"
|
|
229
|
+
style={{
|
|
230
|
+
width: '100%',
|
|
231
|
+
minHeight: 200,
|
|
232
|
+
backgroundColor: medium.url,
|
|
233
|
+
}}
|
|
234
|
+
/>
|
|
235
|
+
</ContentPreviewModal>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
if (imageSrc) {
|
|
239
|
+
return (
|
|
240
|
+
<ContentPreviewModal
|
|
241
|
+
open
|
|
242
|
+
onClose={onClose}
|
|
243
|
+
title={medium.title ?? undefined}
|
|
244
|
+
isImage
|
|
245
|
+
imageSrc={imageSrc}
|
|
246
|
+
imageAlt={medium.title ?? ''}
|
|
247
|
+
/>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return (
|
|
253
|
+
<ContentPreviewModal
|
|
254
|
+
open
|
|
255
|
+
onClose={onClose}
|
|
256
|
+
title={medium.title ?? undefined}
|
|
257
|
+
>
|
|
258
|
+
{isCode ? (
|
|
259
|
+
<Snippet preview={false} medium={medium} />
|
|
260
|
+
) : isDocumentAttachment && medium.content ? (
|
|
261
|
+
// Document attachments contain extracted text, not binary data
|
|
262
|
+
// For HTML document attachments, open in new tab; for others, render as plain text
|
|
263
|
+
(() => {
|
|
264
|
+
const isHtmlDocumentAttachment =
|
|
265
|
+
medium.mimeType === MIME_HTML && isDocumentAttachment;
|
|
266
|
+
|
|
267
|
+
if (isHtmlDocumentAttachment) {
|
|
268
|
+
// HTML document attachment: display HTML content in a code-like format
|
|
269
|
+
let htmlContent = medium.content || '';
|
|
270
|
+
if (htmlContent.includes('<') || htmlContent.includes('"')) {
|
|
271
|
+
const div = document.createElement('div');
|
|
272
|
+
div.innerHTML = htmlContent;
|
|
273
|
+
htmlContent = div.textContent || div.innerText || htmlContent;
|
|
274
|
+
} else {
|
|
275
|
+
htmlContent = stripDocumentAttachmentTags(htmlContent);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Create a medium object for HTML content to display in Snippet
|
|
279
|
+
// Use 'application/xml' mimeType so Prism highlights it (maps to tsx/HTML highlighting)
|
|
280
|
+
const htmlMedium: Medium = {
|
|
281
|
+
...medium,
|
|
282
|
+
mimeType: 'application/xml', // Maps to HTML/XML highlighting in Prism
|
|
283
|
+
content: htmlContent,
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
return (
|
|
287
|
+
<Snippet preview={false} medium={htmlMedium} />
|
|
288
|
+
);
|
|
289
|
+
} else {
|
|
290
|
+
// Other document attachments: render as plain text
|
|
291
|
+
let displayContent = medium.content;
|
|
292
|
+
if (displayContent.includes('<') || displayContent.includes('"')) {
|
|
293
|
+
const div = document.createElement('div');
|
|
294
|
+
div.innerHTML = displayContent;
|
|
295
|
+
displayContent = div.textContent || div.innerText || displayContent;
|
|
296
|
+
} else {
|
|
297
|
+
displayContent = stripDocumentAttachmentTags(displayContent);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Improve formatting for PDF text: normalize whitespace and ensure proper line breaks
|
|
301
|
+
// Replace multiple spaces with single space, but preserve line breaks
|
|
302
|
+
displayContent = displayContent
|
|
303
|
+
.replace(/[ \t]+/g, ' ') // Replace multiple spaces/tabs with single space
|
|
304
|
+
.replace(/\n{3,}/g, '\n\n') // Replace 3+ newlines with double newline
|
|
305
|
+
.trim();
|
|
306
|
+
|
|
307
|
+
return (
|
|
308
|
+
<Snippet
|
|
309
|
+
preview={false}
|
|
310
|
+
medium={{
|
|
311
|
+
...medium,
|
|
312
|
+
mimeType: 'text/plain',
|
|
313
|
+
content: displayContent,
|
|
314
|
+
}}
|
|
315
|
+
/>
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
})()
|
|
319
|
+
) : isPdf && (previewUrl || medium.content) ? (
|
|
320
|
+
<div className="memori-media-item-preview--content memori-media-item--modal-iframe-wrap">
|
|
321
|
+
<iframe
|
|
322
|
+
title={medium.title || 'PDF preview'}
|
|
323
|
+
src={
|
|
324
|
+
medium.content
|
|
325
|
+
? `data:application/pdf;base64,${medium.content}`
|
|
326
|
+
: previewUrl
|
|
327
|
+
}
|
|
328
|
+
className="memori-media-item--modal-iframe"
|
|
329
|
+
/>
|
|
330
|
+
</div>
|
|
331
|
+
) : isExcel && (previewUrl || medium.content) ? (
|
|
332
|
+
<div className="memori-media-item-preview--content memori-media-item--modal-iframe-wrap">
|
|
333
|
+
<iframe
|
|
334
|
+
title={medium.title || 'Spreadsheet preview'}
|
|
335
|
+
src={iframeSrcFromContent}
|
|
336
|
+
className="memori-media-item--modal-iframe"
|
|
337
|
+
/>
|
|
338
|
+
</div>
|
|
339
|
+
) : isHtmlWithContent && !isDocumentAttachment ? (
|
|
340
|
+
// HTML with content (not a document attachment) - show as text
|
|
341
|
+
<Snippet preview={false} medium={htmlAsTextMedium} />
|
|
342
|
+
) : isHtmlLink ? (
|
|
343
|
+
<div className="memori-media-item-preview--content memori-media-item--modal-iframe-wrap">
|
|
344
|
+
<iframe
|
|
345
|
+
title={medium.title || 'Link preview'}
|
|
346
|
+
src={htmlLinkSrc}
|
|
347
|
+
className="memori-media-item--modal-iframe"
|
|
348
|
+
/>
|
|
349
|
+
</div>
|
|
350
|
+
) : isVideoType && hasMediaSrc ? (
|
|
351
|
+
<div className="memori-media-item-preview--content memori-media-item--modal-video-wrap">
|
|
352
|
+
<video
|
|
353
|
+
className="memori-media-item--modal-video"
|
|
354
|
+
controls
|
|
355
|
+
src={mediaSrc}
|
|
356
|
+
title={medium.title || 'Video preview'}
|
|
357
|
+
>
|
|
358
|
+
{medium.mimeType === 'video/quicktime' && (
|
|
359
|
+
<source src={mediaSrc} type="video/mp4" />
|
|
360
|
+
)}
|
|
361
|
+
Your browser does not support this video format.
|
|
362
|
+
</video>
|
|
363
|
+
</div>
|
|
364
|
+
) : isAudioType && hasMediaSrc ? (
|
|
365
|
+
<div className="memori-media-item-preview--content memori-media-item--modal-audio-wrap">
|
|
366
|
+
<p className="memori-media-item--modal-audio-title">
|
|
367
|
+
{medium.title || 'Audio'}
|
|
368
|
+
</p>
|
|
369
|
+
<audio
|
|
370
|
+
className="memori-media-item--modal-audio"
|
|
371
|
+
controls
|
|
372
|
+
src={mediaSrc}
|
|
373
|
+
title={medium.title || 'Audio preview'}
|
|
374
|
+
>
|
|
375
|
+
Your browser does not support this audio format.
|
|
376
|
+
</audio>
|
|
377
|
+
</div>
|
|
378
|
+
) : is3D && glbSrc ? (
|
|
379
|
+
<div className="memori-media-item-preview--content memori-media-item--modal-3d-wrap">
|
|
380
|
+
<ModelViewer
|
|
381
|
+
src={glbSrc}
|
|
382
|
+
poster={DEFAULT_GLB_POSTER}
|
|
383
|
+
alt={medium.title || '3D model'}
|
|
384
|
+
/>
|
|
385
|
+
</div>
|
|
386
|
+
) : isPlainText && medium.content ? (
|
|
387
|
+
<Snippet preview={false} medium={medium} />
|
|
388
|
+
) : isMarkdown && medium.content ? (
|
|
389
|
+
<Snippet preview={false} medium={medium} />
|
|
390
|
+
) : (
|
|
391
|
+
<div className="memori-media-item-preview--content memori-media-item--modal-fallback">
|
|
392
|
+
<p className="memori-media-item--modal-fallback-message">
|
|
393
|
+
{isWordType
|
|
394
|
+
? 'Preview not available for this document.'
|
|
395
|
+
: 'Preview not available for this file type.'}
|
|
396
|
+
</p>
|
|
397
|
+
<p className="memori-media-item--modal-fallback-hint">
|
|
398
|
+
You can open it in a new tab or download it.
|
|
399
|
+
</p>
|
|
400
|
+
{previewUrl && (
|
|
401
|
+
<div className="memori-media-item--modal-fallback-actions">
|
|
402
|
+
<a
|
|
403
|
+
href={previewUrl}
|
|
404
|
+
target="_blank"
|
|
405
|
+
rel="noopener noreferrer"
|
|
406
|
+
className="memori-media-item--modal-fallback-link"
|
|
407
|
+
>
|
|
408
|
+
Open in new tab
|
|
409
|
+
</a>
|
|
410
|
+
<a
|
|
411
|
+
href={previewUrl}
|
|
412
|
+
download={medium.title || undefined}
|
|
413
|
+
className="memori-media-item--modal-fallback-link"
|
|
414
|
+
>
|
|
415
|
+
Download
|
|
416
|
+
</a>
|
|
417
|
+
</div>
|
|
418
|
+
)}
|
|
419
|
+
</div>
|
|
420
|
+
)}
|
|
421
|
+
</ContentPreviewModal>
|
|
422
|
+
);
|
|
423
|
+
}
|