@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
|
@@ -21,46 +21,44 @@ exports[`renders SnippetUpload with css code 1`] = `
|
|
|
21
21
|
}
|
|
22
22
|
</code>
|
|
23
23
|
</pre>
|
|
24
|
-
<
|
|
25
|
-
class="memori-
|
|
26
|
-
title="copy"
|
|
24
|
+
<div
|
|
25
|
+
class="memori-snippet--copy-wrapper"
|
|
27
26
|
>
|
|
28
|
-
<
|
|
29
|
-
class="memori-button--icon"
|
|
27
|
+
<button
|
|
28
|
+
class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
|
|
29
|
+
title="copy"
|
|
30
30
|
>
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
fill="none"
|
|
34
|
-
focusable="false"
|
|
35
|
-
role="img"
|
|
36
|
-
stroke="currentColor"
|
|
37
|
-
stroke-linecap="round"
|
|
38
|
-
stroke-linejoin="round"
|
|
39
|
-
stroke-width="1.5"
|
|
40
|
-
viewBox="0 0 24 24"
|
|
41
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
31
|
+
<span
|
|
32
|
+
class="memori-button--icon"
|
|
42
33
|
>
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
34
|
+
<svg
|
|
35
|
+
aria-hidden="true"
|
|
36
|
+
fill="none"
|
|
37
|
+
focusable="false"
|
|
38
|
+
role="img"
|
|
39
|
+
stroke="currentColor"
|
|
40
|
+
stroke-linecap="round"
|
|
41
|
+
stroke-linejoin="round"
|
|
42
|
+
stroke-width="1.5"
|
|
43
|
+
viewBox="0 0 24 24"
|
|
44
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
45
|
+
>
|
|
46
|
+
<rect
|
|
47
|
+
height="14"
|
|
48
|
+
rx="2"
|
|
49
|
+
ry="2"
|
|
50
|
+
width="14"
|
|
51
|
+
x="8"
|
|
52
|
+
y="8"
|
|
53
|
+
/>
|
|
54
|
+
<path
|
|
55
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
56
|
+
/>
|
|
57
|
+
</svg>
|
|
58
|
+
</span>
|
|
59
|
+
</button>
|
|
60
|
+
</div>
|
|
57
61
|
</div>
|
|
58
|
-
<p
|
|
59
|
-
class="memori-snippet--caption"
|
|
60
|
-
id="snippet-a669fadb-12c0-469b-9b6c-34db22d371ca"
|
|
61
|
-
>
|
|
62
|
-
Snippet
|
|
63
|
-
</p>
|
|
64
62
|
</div>
|
|
65
63
|
</div>
|
|
66
64
|
`;
|
|
@@ -84,46 +82,44 @@ exports[`renders SnippetUpload with html code 1`] = `
|
|
|
84
82
|
<p>ciao</p>
|
|
85
83
|
</code>
|
|
86
84
|
</pre>
|
|
87
|
-
<
|
|
88
|
-
class="memori-
|
|
89
|
-
title="copy"
|
|
85
|
+
<div
|
|
86
|
+
class="memori-snippet--copy-wrapper"
|
|
90
87
|
>
|
|
91
|
-
<
|
|
92
|
-
class="memori-button--icon"
|
|
88
|
+
<button
|
|
89
|
+
class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
|
|
90
|
+
title="copy"
|
|
93
91
|
>
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
fill="none"
|
|
97
|
-
focusable="false"
|
|
98
|
-
role="img"
|
|
99
|
-
stroke="currentColor"
|
|
100
|
-
stroke-linecap="round"
|
|
101
|
-
stroke-linejoin="round"
|
|
102
|
-
stroke-width="1.5"
|
|
103
|
-
viewBox="0 0 24 24"
|
|
104
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
92
|
+
<span
|
|
93
|
+
class="memori-button--icon"
|
|
105
94
|
>
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
95
|
+
<svg
|
|
96
|
+
aria-hidden="true"
|
|
97
|
+
fill="none"
|
|
98
|
+
focusable="false"
|
|
99
|
+
role="img"
|
|
100
|
+
stroke="currentColor"
|
|
101
|
+
stroke-linecap="round"
|
|
102
|
+
stroke-linejoin="round"
|
|
103
|
+
stroke-width="1.5"
|
|
104
|
+
viewBox="0 0 24 24"
|
|
105
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
106
|
+
>
|
|
107
|
+
<rect
|
|
108
|
+
height="14"
|
|
109
|
+
rx="2"
|
|
110
|
+
ry="2"
|
|
111
|
+
width="14"
|
|
112
|
+
x="8"
|
|
113
|
+
y="8"
|
|
114
|
+
/>
|
|
115
|
+
<path
|
|
116
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
117
|
+
/>
|
|
118
|
+
</svg>
|
|
119
|
+
</span>
|
|
120
|
+
</button>
|
|
121
|
+
</div>
|
|
120
122
|
</div>
|
|
121
|
-
<p
|
|
122
|
-
class="memori-snippet--caption"
|
|
123
|
-
id="snippet-65ca4a6d-f20b-402e-9d79-5e470f247927"
|
|
124
|
-
>
|
|
125
|
-
Snippet
|
|
126
|
-
</p>
|
|
127
123
|
</div>
|
|
128
124
|
</div>
|
|
129
125
|
`;
|
|
@@ -147,46 +143,44 @@ exports[`renders SnippetUpload with js code 1`] = `
|
|
|
147
143
|
console.log("Hello World!");
|
|
148
144
|
</code>
|
|
149
145
|
</pre>
|
|
150
|
-
<
|
|
151
|
-
class="memori-
|
|
152
|
-
title="copy"
|
|
146
|
+
<div
|
|
147
|
+
class="memori-snippet--copy-wrapper"
|
|
153
148
|
>
|
|
154
|
-
<
|
|
155
|
-
class="memori-button--icon"
|
|
149
|
+
<button
|
|
150
|
+
class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
|
|
151
|
+
title="copy"
|
|
156
152
|
>
|
|
157
|
-
<
|
|
158
|
-
|
|
159
|
-
fill="none"
|
|
160
|
-
focusable="false"
|
|
161
|
-
role="img"
|
|
162
|
-
stroke="currentColor"
|
|
163
|
-
stroke-linecap="round"
|
|
164
|
-
stroke-linejoin="round"
|
|
165
|
-
stroke-width="1.5"
|
|
166
|
-
viewBox="0 0 24 24"
|
|
167
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
153
|
+
<span
|
|
154
|
+
class="memori-button--icon"
|
|
168
155
|
>
|
|
169
|
-
<
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
156
|
+
<svg
|
|
157
|
+
aria-hidden="true"
|
|
158
|
+
fill="none"
|
|
159
|
+
focusable="false"
|
|
160
|
+
role="img"
|
|
161
|
+
stroke="currentColor"
|
|
162
|
+
stroke-linecap="round"
|
|
163
|
+
stroke-linejoin="round"
|
|
164
|
+
stroke-width="1.5"
|
|
165
|
+
viewBox="0 0 24 24"
|
|
166
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
167
|
+
>
|
|
168
|
+
<rect
|
|
169
|
+
height="14"
|
|
170
|
+
rx="2"
|
|
171
|
+
ry="2"
|
|
172
|
+
width="14"
|
|
173
|
+
x="8"
|
|
174
|
+
y="8"
|
|
175
|
+
/>
|
|
176
|
+
<path
|
|
177
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
178
|
+
/>
|
|
179
|
+
</svg>
|
|
180
|
+
</span>
|
|
181
|
+
</button>
|
|
182
|
+
</div>
|
|
183
183
|
</div>
|
|
184
|
-
<p
|
|
185
|
-
class="memori-snippet--caption"
|
|
186
|
-
id="snippet-95226d7e-7bae-465e-8b80-995587bb5971"
|
|
187
|
-
>
|
|
188
|
-
Snippet
|
|
189
|
-
</p>
|
|
190
184
|
</div>
|
|
191
185
|
</div>
|
|
192
186
|
`;
|
|
@@ -211,12 +205,6 @@ exports[`renders SnippetUpload with js code without copy button 1`] = `
|
|
|
211
205
|
</code>
|
|
212
206
|
</pre>
|
|
213
207
|
</div>
|
|
214
|
-
<p
|
|
215
|
-
class="memori-snippet--caption"
|
|
216
|
-
id="snippet-95226d7e-7bae-465e-8b80-995587bb5971"
|
|
217
|
-
>
|
|
218
|
-
Snippet
|
|
219
|
-
</p>
|
|
220
208
|
</div>
|
|
221
209
|
</div>
|
|
222
210
|
`;
|
|
@@ -240,46 +228,44 @@ exports[`renders SnippetUpload with js code without line numbers 1`] = `
|
|
|
240
228
|
console.log("Hello World!");
|
|
241
229
|
</code>
|
|
242
230
|
</pre>
|
|
243
|
-
<
|
|
244
|
-
class="memori-
|
|
245
|
-
title="copy"
|
|
231
|
+
<div
|
|
232
|
+
class="memori-snippet--copy-wrapper"
|
|
246
233
|
>
|
|
247
|
-
<
|
|
248
|
-
class="memori-button--icon"
|
|
234
|
+
<button
|
|
235
|
+
class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
|
|
236
|
+
title="copy"
|
|
249
237
|
>
|
|
250
|
-
<
|
|
251
|
-
|
|
252
|
-
fill="none"
|
|
253
|
-
focusable="false"
|
|
254
|
-
role="img"
|
|
255
|
-
stroke="currentColor"
|
|
256
|
-
stroke-linecap="round"
|
|
257
|
-
stroke-linejoin="round"
|
|
258
|
-
stroke-width="1.5"
|
|
259
|
-
viewBox="0 0 24 24"
|
|
260
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
238
|
+
<span
|
|
239
|
+
class="memori-button--icon"
|
|
261
240
|
>
|
|
262
|
-
<
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
241
|
+
<svg
|
|
242
|
+
aria-hidden="true"
|
|
243
|
+
fill="none"
|
|
244
|
+
focusable="false"
|
|
245
|
+
role="img"
|
|
246
|
+
stroke="currentColor"
|
|
247
|
+
stroke-linecap="round"
|
|
248
|
+
stroke-linejoin="round"
|
|
249
|
+
stroke-width="1.5"
|
|
250
|
+
viewBox="0 0 24 24"
|
|
251
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
252
|
+
>
|
|
253
|
+
<rect
|
|
254
|
+
height="14"
|
|
255
|
+
rx="2"
|
|
256
|
+
ry="2"
|
|
257
|
+
width="14"
|
|
258
|
+
x="8"
|
|
259
|
+
y="8"
|
|
260
|
+
/>
|
|
261
|
+
<path
|
|
262
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
263
|
+
/>
|
|
264
|
+
</svg>
|
|
265
|
+
</span>
|
|
266
|
+
</button>
|
|
267
|
+
</div>
|
|
276
268
|
</div>
|
|
277
|
-
<p
|
|
278
|
-
class="memori-snippet--caption"
|
|
279
|
-
id="snippet-95226d7e-7bae-465e-8b80-995587bb5971"
|
|
280
|
-
>
|
|
281
|
-
Snippet
|
|
282
|
-
</p>
|
|
283
269
|
</div>
|
|
284
270
|
</div>
|
|
285
271
|
`;
|
|
@@ -287,7 +273,7 @@ exports[`renders SnippetUpload with js code without line numbers 1`] = `
|
|
|
287
273
|
exports[`renders SnippetUpload with preview mode (clamping) 1`] = `
|
|
288
274
|
<div>
|
|
289
275
|
<div
|
|
290
|
-
class="memori-snippet"
|
|
276
|
+
class="memori-snippet memori-snippet--preview"
|
|
291
277
|
>
|
|
292
278
|
<div
|
|
293
279
|
class="memori-snippet--content"
|
|
@@ -304,50 +290,87 @@ exports[`renders SnippetUpload with preview mode (clamping) 1`] = `
|
|
|
304
290
|
import type { Medium } from 'types';
|
|
305
291
|
import { prismSyntaxLangs } from 'helpers/constants';
|
|
306
292
|
import { PrismAsyncLight as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
307
|
-
import { atomDark } from '
|
|
308
|
-
|
|
293
|
+
import { atomDark } from 'react-syntax-highlighter/dist/cjs/styles/prism';
|
|
294
|
+
import tsx from 'react-syntax-highlighter/dist/cjs/languages/prism/tsx';
|
|
295
|
+
import scss from 'react-syntax-highlighter/dist/cjs/languages/prism/scss';
|
|
296
|
+
import bash from 'react-syntax-highlighter/dist/cjs/languages/prism/bash';
|
|
297
|
+
import python from 'react-syntax-highlighter/dist/cjs/languages/prism/python';
|
|
298
|
+
import cpp from 'react-syntax-highlighter/dist/cjs/languages/prism/cpp';
|
|
299
|
+
|
|
300
|
+
interface Props {
|
|
301
|
+
medium: Medium;
|
|
302
|
+
preview?: boolean;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// These have to match prismSyntaxLangs
|
|
306
|
+
SyntaxHighlighter.registerLanguage('tsx', tsx);
|
|
307
|
+
SyntaxHighlighter.registerLanguage('scss', scss);
|
|
308
|
+
SyntaxHighlighter.registerLanguage('bash', bash);
|
|
309
|
+
SyntaxHighlighter.registerLanguage('python', python);
|
|
310
|
+
SyntaxHighlighter.registerLanguage('cpp', cpp);
|
|
311
|
+
|
|
312
|
+
const Snippet = ({ medium, preview = false }: Props) => {
|
|
313
|
+
return (
|
|
314
|
+
<SyntaxHighlighter
|
|
315
|
+
style={atomDark}
|
|
316
|
+
showLineNumbers
|
|
317
|
+
language={
|
|
318
|
+
prismSyntaxLangs.find(
|
|
319
|
+
(l) =>
|
|
320
|
+
medium.mimeType === l.mimeType,
|
|
321
|
+
)?.lang ?? 'text'
|
|
322
|
+
}
|
|
323
|
+
>
|
|
324
|
+
{medium.content?.length && medium.content.length > 200 && preview
|
|
325
|
+
? \`\${medium.content.slice(0, 200)}
|
|
326
|
+
...\`
|
|
327
|
+
: \`\${medium.content}\`}
|
|
328
|
+
</SyntaxHighlighter>
|
|
329
|
+
);
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
export default Snippet;
|
|
333
|
+
|
|
309
334
|
</code>
|
|
310
335
|
</pre>
|
|
311
|
-
<
|
|
312
|
-
class="memori-
|
|
313
|
-
title="copy"
|
|
336
|
+
<div
|
|
337
|
+
class="memori-snippet--copy-wrapper"
|
|
314
338
|
>
|
|
315
|
-
<
|
|
316
|
-
class="memori-button--icon"
|
|
339
|
+
<button
|
|
340
|
+
class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
|
|
341
|
+
title="copy"
|
|
317
342
|
>
|
|
318
|
-
<
|
|
319
|
-
|
|
320
|
-
fill="none"
|
|
321
|
-
focusable="false"
|
|
322
|
-
role="img"
|
|
323
|
-
stroke="currentColor"
|
|
324
|
-
stroke-linecap="round"
|
|
325
|
-
stroke-linejoin="round"
|
|
326
|
-
stroke-width="1.5"
|
|
327
|
-
viewBox="0 0 24 24"
|
|
328
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
343
|
+
<span
|
|
344
|
+
class="memori-button--icon"
|
|
329
345
|
>
|
|
330
|
-
<
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
346
|
+
<svg
|
|
347
|
+
aria-hidden="true"
|
|
348
|
+
fill="none"
|
|
349
|
+
focusable="false"
|
|
350
|
+
role="img"
|
|
351
|
+
stroke="currentColor"
|
|
352
|
+
stroke-linecap="round"
|
|
353
|
+
stroke-linejoin="round"
|
|
354
|
+
stroke-width="1.5"
|
|
355
|
+
viewBox="0 0 24 24"
|
|
356
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
357
|
+
>
|
|
358
|
+
<rect
|
|
359
|
+
height="14"
|
|
360
|
+
rx="2"
|
|
361
|
+
ry="2"
|
|
362
|
+
width="14"
|
|
363
|
+
x="8"
|
|
364
|
+
y="8"
|
|
365
|
+
/>
|
|
366
|
+
<path
|
|
367
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
368
|
+
/>
|
|
369
|
+
</svg>
|
|
370
|
+
</span>
|
|
371
|
+
</button>
|
|
372
|
+
</div>
|
|
344
373
|
</div>
|
|
345
|
-
<p
|
|
346
|
-
class="memori-snippet--caption"
|
|
347
|
-
id="snippet-38dd29a5-cdf6-40f6-963a-8e42a7caaac1"
|
|
348
|
-
>
|
|
349
|
-
Snippet
|
|
350
|
-
</p>
|
|
351
374
|
</div>
|
|
352
375
|
</div>
|
|
353
376
|
`;
|
|
@@ -415,46 +438,44 @@ export default Snippet;
|
|
|
415
438
|
|
|
416
439
|
</code>
|
|
417
440
|
</pre>
|
|
418
|
-
<
|
|
419
|
-
class="memori-
|
|
420
|
-
title="copy"
|
|
441
|
+
<div
|
|
442
|
+
class="memori-snippet--copy-wrapper"
|
|
421
443
|
>
|
|
422
|
-
<
|
|
423
|
-
class="memori-button--icon"
|
|
444
|
+
<button
|
|
445
|
+
class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
|
|
446
|
+
title="copy"
|
|
424
447
|
>
|
|
425
|
-
<
|
|
426
|
-
|
|
427
|
-
fill="none"
|
|
428
|
-
focusable="false"
|
|
429
|
-
role="img"
|
|
430
|
-
stroke="currentColor"
|
|
431
|
-
stroke-linecap="round"
|
|
432
|
-
stroke-linejoin="round"
|
|
433
|
-
stroke-width="1.5"
|
|
434
|
-
viewBox="0 0 24 24"
|
|
435
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
448
|
+
<span
|
|
449
|
+
class="memori-button--icon"
|
|
436
450
|
>
|
|
437
|
-
<
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
+
<svg
|
|
452
|
+
aria-hidden="true"
|
|
453
|
+
fill="none"
|
|
454
|
+
focusable="false"
|
|
455
|
+
role="img"
|
|
456
|
+
stroke="currentColor"
|
|
457
|
+
stroke-linecap="round"
|
|
458
|
+
stroke-linejoin="round"
|
|
459
|
+
stroke-width="1.5"
|
|
460
|
+
viewBox="0 0 24 24"
|
|
461
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
462
|
+
>
|
|
463
|
+
<rect
|
|
464
|
+
height="14"
|
|
465
|
+
rx="2"
|
|
466
|
+
ry="2"
|
|
467
|
+
width="14"
|
|
468
|
+
x="8"
|
|
469
|
+
y="8"
|
|
470
|
+
/>
|
|
471
|
+
<path
|
|
472
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
473
|
+
/>
|
|
474
|
+
</svg>
|
|
475
|
+
</span>
|
|
476
|
+
</button>
|
|
477
|
+
</div>
|
|
451
478
|
</div>
|
|
452
|
-
<p
|
|
453
|
-
class="memori-snippet--caption"
|
|
454
|
-
id="snippet-4946dca4-7103-4400-b80d-94b77f9a4f0a"
|
|
455
|
-
>
|
|
456
|
-
Snippet
|
|
457
|
-
</p>
|
|
458
479
|
</div>
|
|
459
480
|
</div>
|
|
460
481
|
`;
|
|
@@ -478,46 +499,44 @@ exports[`renders SnippetUpload with text 1`] = `
|
|
|
478
499
|
<p>ciao</p>
|
|
479
500
|
</code>
|
|
480
501
|
</pre>
|
|
481
|
-
<
|
|
482
|
-
class="memori-
|
|
483
|
-
title="copy"
|
|
502
|
+
<div
|
|
503
|
+
class="memori-snippet--copy-wrapper"
|
|
484
504
|
>
|
|
485
|
-
<
|
|
486
|
-
class="memori-button--icon"
|
|
505
|
+
<button
|
|
506
|
+
class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
|
|
507
|
+
title="copy"
|
|
487
508
|
>
|
|
488
|
-
<
|
|
489
|
-
|
|
490
|
-
fill="none"
|
|
491
|
-
focusable="false"
|
|
492
|
-
role="img"
|
|
493
|
-
stroke="currentColor"
|
|
494
|
-
stroke-linecap="round"
|
|
495
|
-
stroke-linejoin="round"
|
|
496
|
-
stroke-width="1.5"
|
|
497
|
-
viewBox="0 0 24 24"
|
|
498
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
509
|
+
<span
|
|
510
|
+
class="memori-button--icon"
|
|
499
511
|
>
|
|
500
|
-
<
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
512
|
+
<svg
|
|
513
|
+
aria-hidden="true"
|
|
514
|
+
fill="none"
|
|
515
|
+
focusable="false"
|
|
516
|
+
role="img"
|
|
517
|
+
stroke="currentColor"
|
|
518
|
+
stroke-linecap="round"
|
|
519
|
+
stroke-linejoin="round"
|
|
520
|
+
stroke-width="1.5"
|
|
521
|
+
viewBox="0 0 24 24"
|
|
522
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
523
|
+
>
|
|
524
|
+
<rect
|
|
525
|
+
height="14"
|
|
526
|
+
rx="2"
|
|
527
|
+
ry="2"
|
|
528
|
+
width="14"
|
|
529
|
+
x="8"
|
|
530
|
+
y="8"
|
|
531
|
+
/>
|
|
532
|
+
<path
|
|
533
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
534
|
+
/>
|
|
535
|
+
</svg>
|
|
536
|
+
</span>
|
|
537
|
+
</button>
|
|
538
|
+
</div>
|
|
514
539
|
</div>
|
|
515
|
-
<p
|
|
516
|
-
class="memori-snippet--caption"
|
|
517
|
-
id="snippet-43ac43b8-e220-4111-b89d-c5bfe8b031e2"
|
|
518
|
-
>
|
|
519
|
-
Snippet
|
|
520
|
-
</p>
|
|
521
540
|
</div>
|
|
522
541
|
</div>
|
|
523
542
|
`;
|
|
@@ -541,46 +560,44 @@ exports[`renders SnippetUpload with text as fallback 1`] = `
|
|
|
541
560
|
<p>ciao</p>
|
|
542
561
|
</code>
|
|
543
562
|
</pre>
|
|
544
|
-
<
|
|
545
|
-
class="memori-
|
|
546
|
-
title="copy"
|
|
563
|
+
<div
|
|
564
|
+
class="memori-snippet--copy-wrapper"
|
|
547
565
|
>
|
|
548
|
-
<
|
|
549
|
-
class="memori-button--icon"
|
|
566
|
+
<button
|
|
567
|
+
class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
|
|
568
|
+
title="copy"
|
|
550
569
|
>
|
|
551
|
-
<
|
|
552
|
-
|
|
553
|
-
fill="none"
|
|
554
|
-
focusable="false"
|
|
555
|
-
role="img"
|
|
556
|
-
stroke="currentColor"
|
|
557
|
-
stroke-linecap="round"
|
|
558
|
-
stroke-linejoin="round"
|
|
559
|
-
stroke-width="1.5"
|
|
560
|
-
viewBox="0 0 24 24"
|
|
561
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
570
|
+
<span
|
|
571
|
+
class="memori-button--icon"
|
|
562
572
|
>
|
|
563
|
-
<
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
573
|
+
<svg
|
|
574
|
+
aria-hidden="true"
|
|
575
|
+
fill="none"
|
|
576
|
+
focusable="false"
|
|
577
|
+
role="img"
|
|
578
|
+
stroke="currentColor"
|
|
579
|
+
stroke-linecap="round"
|
|
580
|
+
stroke-linejoin="round"
|
|
581
|
+
stroke-width="1.5"
|
|
582
|
+
viewBox="0 0 24 24"
|
|
583
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
584
|
+
>
|
|
585
|
+
<rect
|
|
586
|
+
height="14"
|
|
587
|
+
rx="2"
|
|
588
|
+
ry="2"
|
|
589
|
+
width="14"
|
|
590
|
+
x="8"
|
|
591
|
+
y="8"
|
|
592
|
+
/>
|
|
593
|
+
<path
|
|
594
|
+
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
|
595
|
+
/>
|
|
596
|
+
</svg>
|
|
597
|
+
</span>
|
|
598
|
+
</button>
|
|
599
|
+
</div>
|
|
577
600
|
</div>
|
|
578
|
-
<p
|
|
579
|
-
class="memori-snippet--caption"
|
|
580
|
-
id="snippet-cc8882fa-d7d5-435a-90a1-5c9f2a1bc918"
|
|
581
|
-
>
|
|
582
|
-
Snippet
|
|
583
|
-
</p>
|
|
584
601
|
</div>
|
|
585
602
|
</div>
|
|
586
603
|
`;
|