@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.
Files changed (166) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/components/Chat/Chat.css +2 -1
  3. package/dist/components/Chat/Chat.js +17 -17
  4. package/dist/components/Chat/Chat.js.map +1 -1
  5. package/dist/components/ChatBubble/ChatBubble.css +1 -1
  6. package/dist/components/ContentPreviewModal/ContentPreviewModal.css +114 -0
  7. package/dist/components/ContentPreviewModal/ContentPreviewModal.d.ts +14 -0
  8. package/dist/components/ContentPreviewModal/ContentPreviewModal.js +18 -0
  9. package/dist/components/ContentPreviewModal/ContentPreviewModal.js.map +1 -0
  10. package/dist/components/ContentPreviewModal/index.d.ts +2 -0
  11. package/dist/components/ContentPreviewModal/index.js +9 -0
  12. package/dist/components/ContentPreviewModal/index.js.map +1 -0
  13. package/dist/components/FilePreview/FilePreview.css +1 -1
  14. package/dist/components/FilePreview/FilePreview.js +43 -13
  15. package/dist/components/FilePreview/FilePreview.js.map +1 -1
  16. package/dist/components/MediaWidget/DocumentCard.d.ts +3 -0
  17. package/dist/components/MediaWidget/DocumentCard.js +9 -0
  18. package/dist/components/MediaWidget/DocumentCard.js.map +1 -0
  19. package/dist/components/MediaWidget/MediaItemWidget.css +946 -19
  20. package/dist/components/MediaWidget/MediaItemWidget.d.ts +5 -36
  21. package/dist/components/MediaWidget/MediaItemWidget.js +295 -198
  22. package/dist/components/MediaWidget/MediaItemWidget.js.map +1 -1
  23. package/dist/components/MediaWidget/MediaItemWidget.types.d.ts +62 -0
  24. package/dist/components/MediaWidget/MediaItemWidget.types.js +3 -0
  25. package/dist/components/MediaWidget/MediaItemWidget.types.js.map +1 -0
  26. package/dist/components/MediaWidget/MediaItemWidget.utils.d.ts +23 -0
  27. package/dist/components/MediaWidget/MediaItemWidget.utils.js +162 -0
  28. package/dist/components/MediaWidget/MediaItemWidget.utils.js.map +1 -0
  29. package/dist/components/MediaWidget/MediaPreviewModal.d.ts +15 -0
  30. package/dist/components/MediaWidget/MediaPreviewModal.js +162 -0
  31. package/dist/components/MediaWidget/MediaPreviewModal.js.map +1 -0
  32. package/dist/components/MediaWidget/MediaWidget.js +1 -2
  33. package/dist/components/MediaWidget/MediaWidget.js.map +1 -1
  34. package/dist/components/Snippet/Snippet.css +64 -33
  35. package/dist/components/Snippet/Snippet.js +17 -4
  36. package/dist/components/Snippet/Snippet.js.map +1 -1
  37. package/dist/components/StartPanel/StartPanel.js +1 -2
  38. package/dist/components/StartPanel/StartPanel.js.map +1 -1
  39. package/dist/components/UploadButton/UploadButton.css +0 -5
  40. package/dist/components/layouts/WebsiteAssistant.js +8 -8
  41. package/dist/components/layouts/WebsiteAssistant.js.map +1 -1
  42. package/dist/components/layouts/chat.css +1 -1
  43. package/dist/components/layouts/website-assistant.css +405 -197
  44. package/dist/helpers/constants.js +0 -7
  45. package/dist/helpers/constants.js.map +1 -1
  46. package/dist/helpers/utils.d.ts +1 -0
  47. package/dist/helpers/utils.js +3 -1
  48. package/dist/helpers/utils.js.map +1 -1
  49. package/dist/index.js +43 -1
  50. package/dist/index.js.map +1 -1
  51. package/dist/styles.css +0 -2
  52. package/dist/version.d.ts +1 -0
  53. package/dist/version.js +5 -0
  54. package/dist/version.js.map +1 -0
  55. package/esm/components/Chat/Chat.css +2 -1
  56. package/esm/components/Chat/Chat.js +17 -17
  57. package/esm/components/Chat/Chat.js.map +1 -1
  58. package/esm/components/ChatBubble/ChatBubble.css +1 -1
  59. package/esm/components/ContentPreviewModal/ContentPreviewModal.css +114 -0
  60. package/esm/components/ContentPreviewModal/ContentPreviewModal.d.ts +14 -0
  61. package/esm/components/ContentPreviewModal/ContentPreviewModal.js +15 -0
  62. package/esm/components/ContentPreviewModal/ContentPreviewModal.js.map +1 -0
  63. package/esm/components/ContentPreviewModal/index.d.ts +2 -0
  64. package/esm/components/ContentPreviewModal/index.js +2 -0
  65. package/esm/components/ContentPreviewModal/index.js.map +1 -0
  66. package/esm/components/FilePreview/FilePreview.css +1 -1
  67. package/esm/components/FilePreview/FilePreview.js +44 -14
  68. package/esm/components/FilePreview/FilePreview.js.map +1 -1
  69. package/esm/components/MediaWidget/DocumentCard.d.ts +3 -0
  70. package/esm/components/MediaWidget/DocumentCard.js +5 -0
  71. package/esm/components/MediaWidget/DocumentCard.js.map +1 -0
  72. package/esm/components/MediaWidget/MediaItemWidget.css +946 -19
  73. package/esm/components/MediaWidget/MediaItemWidget.d.ts +5 -36
  74. package/esm/components/MediaWidget/MediaItemWidget.js +296 -197
  75. package/esm/components/MediaWidget/MediaItemWidget.js.map +1 -1
  76. package/esm/components/MediaWidget/MediaItemWidget.types.d.ts +62 -0
  77. package/esm/components/MediaWidget/MediaItemWidget.types.js +2 -0
  78. package/esm/components/MediaWidget/MediaItemWidget.types.js.map +1 -0
  79. package/esm/components/MediaWidget/MediaItemWidget.utils.d.ts +23 -0
  80. package/esm/components/MediaWidget/MediaItemWidget.utils.js +149 -0
  81. package/esm/components/MediaWidget/MediaItemWidget.utils.js.map +1 -0
  82. package/esm/components/MediaWidget/MediaPreviewModal.d.ts +15 -0
  83. package/esm/components/MediaWidget/MediaPreviewModal.js +157 -0
  84. package/esm/components/MediaWidget/MediaPreviewModal.js.map +1 -0
  85. package/esm/components/MediaWidget/MediaWidget.js +1 -2
  86. package/esm/components/MediaWidget/MediaWidget.js.map +1 -1
  87. package/esm/components/Snippet/Snippet.css +64 -33
  88. package/esm/components/Snippet/Snippet.js +18 -5
  89. package/esm/components/Snippet/Snippet.js.map +1 -1
  90. package/esm/components/StartPanel/StartPanel.js +1 -2
  91. package/esm/components/StartPanel/StartPanel.js.map +1 -1
  92. package/esm/components/UploadButton/UploadButton.css +0 -5
  93. package/esm/components/layouts/WebsiteAssistant.js +8 -8
  94. package/esm/components/layouts/WebsiteAssistant.js.map +1 -1
  95. package/esm/components/layouts/chat.css +1 -1
  96. package/esm/components/layouts/website-assistant.css +405 -197
  97. package/esm/helpers/constants.js +0 -7
  98. package/esm/helpers/constants.js.map +1 -1
  99. package/esm/helpers/utils.d.ts +1 -0
  100. package/esm/helpers/utils.js +1 -0
  101. package/esm/helpers/utils.js.map +1 -1
  102. package/esm/index.js +43 -1
  103. package/esm/index.js.map +1 -1
  104. package/esm/styles.css +0 -2
  105. package/esm/version.d.ts +1 -0
  106. package/esm/version.js +2 -0
  107. package/esm/version.js.map +1 -0
  108. package/package.json +5 -3
  109. package/src/components/Chat/Chat.css +2 -1
  110. package/src/components/Chat/Chat.stories.tsx +124 -0
  111. package/src/components/Chat/Chat.tsx +72 -71
  112. package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +567 -1034
  113. package/src/components/ChatBubble/ChatBubble.css +1 -1
  114. package/src/components/ContentPreviewModal/ContentPreviewModal.css +114 -0
  115. package/src/components/ContentPreviewModal/ContentPreviewModal.tsx +69 -0
  116. package/src/components/ContentPreviewModal/index.ts +2 -0
  117. package/src/components/FilePreview/FilePreview.css +1 -1
  118. package/src/components/FilePreview/FilePreview.tsx +60 -37
  119. package/src/components/FilePreview/__snapshots__/FilePreview.test.tsx.snap +15 -105
  120. package/src/components/MediaWidget/DocumentCard.test.tsx +45 -0
  121. package/src/components/MediaWidget/DocumentCard.tsx +19 -0
  122. package/src/components/MediaWidget/MediaItemWidget.css +946 -19
  123. package/src/components/MediaWidget/MediaItemWidget.test.tsx +89 -1
  124. package/src/components/MediaWidget/MediaItemWidget.tsx +734 -461
  125. package/src/components/MediaWidget/MediaItemWidget.types.ts +65 -0
  126. package/src/components/MediaWidget/MediaItemWidget.utils.test.ts +324 -0
  127. package/src/components/MediaWidget/MediaItemWidget.utils.ts +194 -0
  128. package/src/components/MediaWidget/MediaPreviewModal.test.tsx +271 -0
  129. package/src/components/MediaWidget/MediaPreviewModal.tsx +423 -0
  130. package/src/components/MediaWidget/MediaWidget.stories.tsx +193 -0
  131. package/src/components/MediaWidget/MediaWidget.tsx +2 -4
  132. package/src/components/MediaWidget/__snapshots__/DocumentCard.test.tsx.snap +24 -0
  133. package/src/components/MediaWidget/__snapshots__/MediaItemWidget.test.tsx.snap +162 -170
  134. package/src/components/MediaWidget/__snapshots__/MediaWidget.test.tsx.snap +21 -63
  135. package/src/components/Snippet/Snippet.css +64 -33
  136. package/src/components/Snippet/Snippet.tsx +30 -21
  137. package/src/components/Snippet/__snapshots__/Snippet.test.tsx.snap +314 -297
  138. package/src/components/StartPanel/StartPanel.tsx +0 -9
  139. package/src/components/StartPanel/__snapshots__/StartPanel.test.tsx.snap +12 -636
  140. package/src/components/UploadButton/UploadButton.css +0 -5
  141. package/src/components/layouts/WebsiteAssistant.tsx +66 -62
  142. package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +1 -53
  143. package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +2 -106
  144. package/src/components/layouts/__snapshots__/HiddenChat.test.tsx.snap +1 -53
  145. package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +1 -53
  146. package/src/components/layouts/__snapshots__/WebsiteAssistant.test.tsx.snap +32 -33
  147. package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +1 -53
  148. package/src/components/layouts/chat.css +1 -1
  149. package/src/components/layouts/layouts.stories.tsx +68 -0
  150. package/src/components/layouts/website-assistant.css +405 -197
  151. package/src/helpers/constants.ts +0 -7
  152. package/src/helpers/utils.ts +4 -0
  153. package/src/index.test.tsx +8 -0
  154. package/src/index.tsx +51 -1
  155. package/src/styles.css +0 -2
  156. package/src/version.ts +2 -0
  157. package/src/components/AttachmentLinkModal/AttachmentLinkModal.css +0 -68
  158. package/src/components/AttachmentLinkModal/AttachmentLinkModal.stories.tsx +0 -32
  159. package/src/components/AttachmentLinkModal/AttachmentLinkModal.test.tsx +0 -10
  160. package/src/components/AttachmentLinkModal/AttachmentLinkModal.tsx +0 -131
  161. package/src/components/AttachmentLinkModal/__snapshots__/AttachmentLinkModal.test.tsx.snap +0 -9
  162. package/src/components/MediaWidget/LinkItemWidget.css +0 -46
  163. package/src/components/MediaWidget/LinkItemWidget.stories.tsx +0 -61
  164. package/src/components/MediaWidget/LinkItemWidget.test.tsx +0 -33
  165. package/src/components/MediaWidget/LinkItemWidget.tsx +0 -204
  166. 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
- <button
25
- class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
26
- title="copy"
24
+ <div
25
+ class="memori-snippet--copy-wrapper"
27
26
  >
28
- <span
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
- <svg
32
- aria-hidden="true"
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
- <rect
44
- height="14"
45
- rx="2"
46
- ry="2"
47
- width="14"
48
- x="8"
49
- y="8"
50
- />
51
- <path
52
- d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
53
- />
54
- </svg>
55
- </span>
56
- </button>
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
  &lt;p&gt;ciao&lt;/p&gt;
85
83
  </code>
86
84
  </pre>
87
- <button
88
- class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
89
- title="copy"
85
+ <div
86
+ class="memori-snippet--copy-wrapper"
90
87
  >
91
- <span
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
- <svg
95
- aria-hidden="true"
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
- <rect
107
- height="14"
108
- rx="2"
109
- ry="2"
110
- width="14"
111
- x="8"
112
- y="8"
113
- />
114
- <path
115
- d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
116
- />
117
- </svg>
118
- </span>
119
- </button>
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
- <button
151
- class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
152
- title="copy"
146
+ <div
147
+ class="memori-snippet--copy-wrapper"
153
148
  >
154
- <span
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
- <svg
158
- aria-hidden="true"
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
- <rect
170
- height="14"
171
- rx="2"
172
- ry="2"
173
- width="14"
174
- x="8"
175
- y="8"
176
- />
177
- <path
178
- d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
179
- />
180
- </svg>
181
- </span>
182
- </button>
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
- <button
244
- class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
245
- title="copy"
231
+ <div
232
+ class="memori-snippet--copy-wrapper"
246
233
  >
247
- <span
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
- <svg
251
- aria-hidden="true"
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
- <rect
263
- height="14"
264
- rx="2"
265
- ry="2"
266
- width="14"
267
- x="8"
268
- y="8"
269
- />
270
- <path
271
- d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
272
- />
273
- </svg>
274
- </span>
275
- </button>
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 'r
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) =&gt; {
313
+ return (
314
+ &lt;SyntaxHighlighter
315
+ style={atomDark}
316
+ showLineNumbers
317
+ language={
318
+ prismSyntaxLangs.find(
319
+ (l) =&gt;
320
+ medium.mimeType === l.mimeType,
321
+ )?.lang ?? 'text'
322
+ }
323
+ &gt;
324
+ {medium.content?.length && medium.content.length &gt; 200 && preview
325
+ ? \`\${medium.content.slice(0, 200)}
326
+ ...\`
327
+ : \`\${medium.content}\`}
328
+ &lt;/SyntaxHighlighter&gt;
329
+ );
330
+ };
331
+
332
+ export default Snippet;
333
+
309
334
  </code>
310
335
  </pre>
311
- <button
312
- class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
313
- title="copy"
336
+ <div
337
+ class="memori-snippet--copy-wrapper"
314
338
  >
315
- <span
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
- <svg
319
- aria-hidden="true"
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
- <rect
331
- height="14"
332
- rx="2"
333
- ry="2"
334
- width="14"
335
- x="8"
336
- y="8"
337
- />
338
- <path
339
- d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
340
- />
341
- </svg>
342
- </span>
343
- </button>
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
- <button
419
- class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
420
- title="copy"
441
+ <div
442
+ class="memori-snippet--copy-wrapper"
421
443
  >
422
- <span
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
- <svg
426
- aria-hidden="true"
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
- <rect
438
- height="14"
439
- rx="2"
440
- ry="2"
441
- width="14"
442
- x="8"
443
- y="8"
444
- />
445
- <path
446
- d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
447
- />
448
- </svg>
449
- </span>
450
- </button>
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
  &lt;p&gt;ciao&lt;/p&gt;
479
500
  </code>
480
501
  </pre>
481
- <button
482
- class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
483
- title="copy"
502
+ <div
503
+ class="memori-snippet--copy-wrapper"
484
504
  >
485
- <span
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
- <svg
489
- aria-hidden="true"
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
- <rect
501
- height="14"
502
- rx="2"
503
- ry="2"
504
- width="14"
505
- x="8"
506
- y="8"
507
- />
508
- <path
509
- d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
510
- />
511
- </svg>
512
- </span>
513
- </button>
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
  &lt;p&gt;ciao&lt;/p&gt;
542
561
  </code>
543
562
  </pre>
544
- <button
545
- class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
546
- title="copy"
563
+ <div
564
+ class="memori-snippet--copy-wrapper"
547
565
  >
548
- <span
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
- <svg
552
- aria-hidden="true"
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
- <rect
564
- height="14"
565
- rx="2"
566
- ry="2"
567
- width="14"
568
- x="8"
569
- y="8"
570
- />
571
- <path
572
- d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
573
- />
574
- </svg>
575
- </span>
576
- </button>
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
  `;