@memori.ai/memori-react 8.4.1 → 8.5.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 +21 -0
- package/dist/components/LoginDrawer/LoginDrawer.d.ts +1 -2
- package/dist/components/LoginDrawer/LoginDrawer.js +2 -105
- package/dist/components/LoginDrawer/LoginDrawer.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.css +0 -4
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.d.ts +1 -0
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.js +3 -3
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyButtonWithDropdown.js +110 -8
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyButtonWithDropdown.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyMenuItem.js +3 -0
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyMenuItem.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/hooks/useCopyArtifact.js +42 -38
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/hooks/useCopyArtifact.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/styles.css +1 -2
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/types.d.ts +2 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +428 -15
- package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.d.ts +1 -0
- package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js +47 -8
- package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.css +150 -0
- package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.d.ts +9 -0
- package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.js +35 -0
- package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.js.map +1 -0
- package/dist/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.css +2 -0
- package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.css +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.d.ts +2 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js +15 -26
- package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/context/ArtifactContext.js +1 -5
- package/dist/components/MemoriArtifactSystem/context/ArtifactContext.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/icons/Close.d.ts +2 -1
- package/dist/components/icons/Close.js +1 -1
- package/dist/components/icons/Close.js.map +1 -1
- package/dist/components/icons/MenuVertical.d.ts +7 -0
- package/dist/components/icons/MenuVertical.js +6 -0
- package/dist/components/icons/MenuVertical.js.map +1 -0
- package/dist/components/layouts/Chat.js +1 -1
- package/dist/components/layouts/Chat.js.map +1 -1
- package/dist/components/layouts/FullPage.js +1 -1
- package/dist/components/layouts/FullPage.js.map +1 -1
- package/dist/components/layouts/ZoomedFullBody.js +1 -1
- package/dist/components/layouts/ZoomedFullBody.js.map +1 -1
- package/dist/components/layouts/chat.css +73 -85
- package/dist/components/ui/Drawer.d.ts +1 -0
- package/dist/components/ui/Drawer.js +2 -2
- package/dist/components/ui/Drawer.js.map +1 -1
- package/dist/locales/de.json +37 -1
- package/dist/locales/en.json +37 -1
- package/dist/locales/es.json +37 -1
- package/dist/locales/fr.json +37 -1
- package/dist/locales/it.json +37 -1
- package/esm/components/LoginDrawer/LoginDrawer.d.ts +1 -2
- package/esm/components/LoginDrawer/LoginDrawer.js +3 -106
- package/esm/components/LoginDrawer/LoginDrawer.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.css +0 -4
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.d.ts +1 -0
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.js +3 -3
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyButtonWithDropdown.js +110 -8
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyButtonWithDropdown.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyMenuItem.js +3 -0
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyMenuItem.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/hooks/useCopyArtifact.js +42 -38
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/hooks/useCopyArtifact.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/styles.css +1 -2
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/types.d.ts +2 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +428 -15
- package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.d.ts +1 -0
- package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js +48 -9
- package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.css +150 -0
- package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.d.ts +9 -0
- package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.js +32 -0
- package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.js.map +1 -0
- package/esm/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.css +2 -0
- package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.css +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.d.ts +2 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js +16 -27
- package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/context/ArtifactContext.js +1 -5
- package/esm/components/MemoriArtifactSystem/context/ArtifactContext.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/icons/Close.d.ts +2 -1
- package/esm/components/icons/Close.js +1 -1
- package/esm/components/icons/Close.js.map +1 -1
- package/esm/components/icons/MenuVertical.d.ts +7 -0
- package/esm/components/icons/MenuVertical.js +4 -0
- package/esm/components/icons/MenuVertical.js.map +1 -0
- package/esm/components/layouts/Chat.js +1 -1
- package/esm/components/layouts/Chat.js.map +1 -1
- package/esm/components/layouts/FullPage.js +1 -1
- package/esm/components/layouts/FullPage.js.map +1 -1
- package/esm/components/layouts/ZoomedFullBody.js +1 -1
- package/esm/components/layouts/ZoomedFullBody.js.map +1 -1
- package/esm/components/layouts/chat.css +73 -85
- package/esm/components/ui/Drawer.d.ts +1 -0
- package/esm/components/ui/Drawer.js +2 -2
- package/esm/components/ui/Drawer.js.map +1 -1
- package/esm/locales/de.json +37 -1
- package/esm/locales/en.json +37 -1
- package/esm/locales/es.json +37 -1
- package/esm/locales/fr.json +37 -1
- package/esm/locales/it.json +37 -1
- package/package.json +1 -1
- package/src/components/FilePreview/__snapshots__/FilePreview.test.tsx.snap +9 -0
- package/src/components/LoginDrawer/LoginDrawer.tsx +46 -221
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.css +0 -4
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.tsx +7 -5
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyButtonWithDropdown.tsx +148 -12
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyMenuItem.tsx +3 -0
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/hooks/useCopyArtifact.ts +54 -47
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/styles.css +1 -2
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/types.ts +2 -1
- package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +428 -15
- package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.tsx +240 -42
- package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.css +150 -0
- package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/components/TabSwitch.tsx +79 -0
- package/src/components/MemoriArtifactSystem/components/ArtifactHandler/ArtifactHandler.css +2 -0
- package/src/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.css +1 -1
- package/src/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.tsx +2 -41
- package/src/components/MemoriArtifactSystem/context/ArtifactContext.tsx +1 -5
- package/src/components/MemoriWidget/MemoriWidget.tsx +0 -1
- package/src/components/icons/Close.tsx +8 -1
- package/src/components/icons/MenuVertical.tsx +29 -0
- package/src/components/layouts/Chat.tsx +3 -1
- package/src/components/layouts/FullPage.tsx +7 -2
- package/src/components/layouts/ZoomedFullBody.tsx +8 -3
- package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +1 -1
- package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +112 -104
- package/src/components/layouts/__snapshots__/HiddenChat.test.tsx.snap +3 -0
- package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +56 -52
- package/src/components/layouts/chat.css +73 -85
- package/src/components/ui/Drawer.tsx +3 -1
- package/src/components/ui/__snapshots__/Alert.test.tsx.snap +3 -0
- package/src/locales/de.json +37 -1
- package/src/locales/en.json +37 -1
- package/src/locales/es.json +37 -1
- package/src/locales/fr.json +37 -1
- package/src/locales/it.json +38 -1
package/src/components/MemoriArtifactSystem/components/ArtifactActions/hooks/useCopyArtifact.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useState, useCallback, useMemo } from 'react';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
7
8
|
import {
|
|
8
9
|
CopyFormat,
|
|
9
10
|
UseCopyArtifactReturn,
|
|
@@ -18,6 +19,7 @@ export const useCopyArtifact = (
|
|
|
18
19
|
onDownload?: () => void,
|
|
19
20
|
onPrint?: () => void
|
|
20
21
|
): UseCopyArtifactReturn => {
|
|
22
|
+
const { t } = useTranslation();
|
|
21
23
|
const [copyState, setCopyState] = useState<CopyState>({
|
|
22
24
|
isOpen: false,
|
|
23
25
|
loading: false,
|
|
@@ -37,15 +39,15 @@ export const useCopyArtifact = (
|
|
|
37
39
|
baseFormats.push(
|
|
38
40
|
{
|
|
39
41
|
id: 'markdown',
|
|
40
|
-
label: 'Download as Markdown',
|
|
41
|
-
description: 'Download raw markdown text',
|
|
42
|
+
label: t('artifact.downloadAsMarkdown') || 'Download as Markdown',
|
|
43
|
+
description: t('artifact.downloadRawMarkdownText') || 'Download raw markdown text',
|
|
42
44
|
mimeType: 'text/markdown',
|
|
43
45
|
action: 'download',
|
|
44
46
|
},
|
|
45
47
|
{
|
|
46
48
|
id: 'pdf',
|
|
47
|
-
label: 'Download as PDF',
|
|
48
|
-
description: 'Export as PDF document',
|
|
49
|
+
label: t('artifact.downloadAsPdf') || 'Download as PDF',
|
|
50
|
+
description: t('artifact.exportAsPdfDocument') || 'Export as PDF document',
|
|
49
51
|
mimeType: 'application/pdf',
|
|
50
52
|
action: 'pdf',
|
|
51
53
|
isAsync: true,
|
|
@@ -56,8 +58,8 @@ export const useCopyArtifact = (
|
|
|
56
58
|
case 'html':
|
|
57
59
|
baseFormats.push({
|
|
58
60
|
id: 'html',
|
|
59
|
-
label: 'Download as HTML',
|
|
60
|
-
description: 'Download formatted HTML',
|
|
61
|
+
label: t('artifact.downloadAsHtml') || 'Download as HTML',
|
|
62
|
+
description: t('artifact.downloadFormattedHtml') || 'Download formatted HTML',
|
|
61
63
|
mimeType: 'text/html',
|
|
62
64
|
action: 'download',
|
|
63
65
|
});
|
|
@@ -66,8 +68,8 @@ export const useCopyArtifact = (
|
|
|
66
68
|
case 'json':
|
|
67
69
|
baseFormats.push({
|
|
68
70
|
id: 'json',
|
|
69
|
-
label: 'Download as JSON',
|
|
70
|
-
description: 'Download JSON data',
|
|
71
|
+
label: t('artifact.downloadAsJson') || 'Download as JSON',
|
|
72
|
+
description: t('artifact.downloadJsonData') || 'Download JSON data',
|
|
71
73
|
mimeType: 'application/json',
|
|
72
74
|
action: 'download',
|
|
73
75
|
});
|
|
@@ -76,8 +78,8 @@ export const useCopyArtifact = (
|
|
|
76
78
|
case 'image/png':
|
|
77
79
|
baseFormats.push({
|
|
78
80
|
id: 'png',
|
|
79
|
-
label: 'Download as PNG',
|
|
80
|
-
description: 'Download PNG image',
|
|
81
|
+
label: t('artifact.downloadAsPng') || 'Download as PNG',
|
|
82
|
+
description: t('artifact.downloadPngImage') || 'Download PNG image',
|
|
81
83
|
mimeType: 'image/png',
|
|
82
84
|
action: 'download',
|
|
83
85
|
});
|
|
@@ -86,8 +88,8 @@ export const useCopyArtifact = (
|
|
|
86
88
|
case 'image/jpeg':
|
|
87
89
|
baseFormats.push({
|
|
88
90
|
id: 'jpeg',
|
|
89
|
-
label: 'Download as JPEG',
|
|
90
|
-
description: 'Download JPEG image',
|
|
91
|
+
label: t('artifact.downloadAsJpeg') || 'Download as JPEG',
|
|
92
|
+
description: t('artifact.downloadJpegImage') || 'Download JPEG image',
|
|
91
93
|
mimeType: 'image/jpeg',
|
|
92
94
|
action: 'download',
|
|
93
95
|
});
|
|
@@ -96,8 +98,8 @@ export const useCopyArtifact = (
|
|
|
96
98
|
case 'image/gif':
|
|
97
99
|
baseFormats.push({
|
|
98
100
|
id: 'gif',
|
|
99
|
-
label: 'Download as GIF',
|
|
100
|
-
description: 'Download GIF image',
|
|
101
|
+
label: t('artifact.downloadAsGif') || 'Download as GIF',
|
|
102
|
+
description: t('artifact.downloadGifImage') || 'Download GIF image',
|
|
101
103
|
mimeType: 'image/gif',
|
|
102
104
|
action: 'download',
|
|
103
105
|
});
|
|
@@ -106,8 +108,8 @@ export const useCopyArtifact = (
|
|
|
106
108
|
case 'image/webp':
|
|
107
109
|
baseFormats.push({
|
|
108
110
|
id: 'webp',
|
|
109
|
-
label: 'Download as WebP',
|
|
110
|
-
description: 'Download WebP image',
|
|
111
|
+
label: t('artifact.downloadAsWebp') || 'Download as WebP',
|
|
112
|
+
description: t('artifact.downloadWebpImage') || 'Download WebP image',
|
|
111
113
|
mimeType: 'image/webp',
|
|
112
114
|
action: 'download',
|
|
113
115
|
});
|
|
@@ -117,15 +119,15 @@ export const useCopyArtifact = (
|
|
|
117
119
|
baseFormats.push(
|
|
118
120
|
{
|
|
119
121
|
id: 'svg',
|
|
120
|
-
label: 'Copy as SVG',
|
|
121
|
-
description: 'Copy SVG source code',
|
|
122
|
+
label: t('artifact.copyAsSvg') || 'Copy as SVG',
|
|
123
|
+
description: t('artifact.copySvgSourceCode') || 'Copy SVG source code',
|
|
122
124
|
mimeType: 'image/svg+xml',
|
|
123
125
|
action: 'copy',
|
|
124
126
|
},
|
|
125
127
|
{
|
|
126
128
|
id: 'plain',
|
|
127
|
-
label: 'Copy as Plain Text',
|
|
128
|
-
description: 'Copy as text',
|
|
129
|
+
label: t('artifact.copyAsPlainText') || 'Copy as Plain Text',
|
|
130
|
+
description: t('artifact.copyAsText') || 'Copy as text',
|
|
129
131
|
mimeType: 'text/plain',
|
|
130
132
|
action: 'copy',
|
|
131
133
|
}
|
|
@@ -139,17 +141,15 @@ export const useCopyArtifact = (
|
|
|
139
141
|
baseFormats.push(
|
|
140
142
|
{
|
|
141
143
|
id: 'code',
|
|
142
|
-
label: `Copy as ${
|
|
143
|
-
|
|
144
|
-
}`,
|
|
145
|
-
description: `Copy ${language} code`,
|
|
144
|
+
label: t('artifact.copyAsLanguage', { language: language.charAt(0).toUpperCase() + language.slice(1) }) || `Copy as ${language.charAt(0).toUpperCase() + language.slice(1)}`,
|
|
145
|
+
description: t('artifact.copyLanguageCode', { language }) || `Copy ${language} code`,
|
|
146
146
|
mimeType: artifact.mimeType,
|
|
147
147
|
action: 'copy',
|
|
148
148
|
},
|
|
149
149
|
{
|
|
150
150
|
id: 'plain',
|
|
151
|
-
label: 'Copy as Plain Text',
|
|
152
|
-
description: 'Copy without syntax highlighting',
|
|
151
|
+
label: t('artifact.copyAsPlainText') || 'Copy as Plain Text',
|
|
152
|
+
description: t('artifact.copyWithoutSyntaxHighlighting') || 'Copy without syntax highlighting',
|
|
153
153
|
mimeType: 'text/plain',
|
|
154
154
|
action: 'copy',
|
|
155
155
|
}
|
|
@@ -158,8 +158,8 @@ export const useCopyArtifact = (
|
|
|
158
158
|
// Generic text content
|
|
159
159
|
baseFormats.push({
|
|
160
160
|
id: 'text',
|
|
161
|
-
label: 'Copy as Text',
|
|
162
|
-
description: 'Copy text content',
|
|
161
|
+
label: t('artifact.copyAsText') || 'Copy as Text',
|
|
162
|
+
description: t('artifact.copyTextContent') || 'Copy text content',
|
|
163
163
|
mimeType: 'text/plain',
|
|
164
164
|
action: 'copy',
|
|
165
165
|
});
|
|
@@ -168,7 +168,7 @@ export const useCopyArtifact = (
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
return baseFormats;
|
|
171
|
-
}, [artifact.mimeType]);
|
|
171
|
+
}, [artifact.mimeType, t]);
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
174
|
* Convert content based on format
|
|
@@ -253,25 +253,30 @@ export const useCopyArtifact = (
|
|
|
253
253
|
try {
|
|
254
254
|
if (format.action === 'pdf') {
|
|
255
255
|
// Handle PDF generation
|
|
256
|
+
// First check if PDF export is supported in this browser
|
|
257
|
+
// If not, throw a translated error message
|
|
256
258
|
if (!pdfExporter.isSupported()) {
|
|
257
|
-
throw new Error('PDF export is not supported in this browser');
|
|
259
|
+
throw new Error(t('artifact.pdfExportNotSupported') || 'PDF export is not supported in this browser');
|
|
258
260
|
}
|
|
259
261
|
|
|
262
|
+
// Configure PDF export options with sensible defaults
|
|
260
263
|
const pdfOptions: PDFExportOptions = {
|
|
261
|
-
title: artifact.title || 'Artifact',
|
|
262
|
-
fontSize: '12pt',
|
|
263
|
-
fontFamily: 'system-ui, -apple-system, sans-serif',
|
|
264
|
-
lineHeight: '1.6',
|
|
265
|
-
color: '#333',
|
|
266
|
-
backgroundColor: '#fff',
|
|
264
|
+
title: artifact.title || 'Artifact', // Use artifact title or fallback
|
|
265
|
+
fontSize: '12pt', // Standard readable font size
|
|
266
|
+
fontFamily: 'system-ui, -apple-system, sans-serif', // System fonts
|
|
267
|
+
lineHeight: '1.6', // Comfortable line height for reading
|
|
268
|
+
color: '#333', // Dark gray text for good contrast
|
|
269
|
+
backgroundColor: '#fff', // White background
|
|
267
270
|
};
|
|
268
271
|
|
|
272
|
+
// Export the artifact content to PDF using the configured options
|
|
269
273
|
await pdfExporter.exportAsPDF(
|
|
270
274
|
artifact.content,
|
|
271
275
|
artifact.title || 'Artifact',
|
|
272
276
|
pdfOptions
|
|
273
277
|
);
|
|
274
278
|
|
|
279
|
+
// Call the optional onPrint callback if provided
|
|
275
280
|
onPrint?.();
|
|
276
281
|
} else if (format.action === 'print') {
|
|
277
282
|
// Handle print operation
|
|
@@ -279,7 +284,7 @@ export const useCopyArtifact = (
|
|
|
279
284
|
const printWindow = window.open('', '_blank');
|
|
280
285
|
|
|
281
286
|
if (!printWindow) {
|
|
282
|
-
throw new Error('Popup blocked! Please enable popups to print.');
|
|
287
|
+
throw new Error(t('artifact.popupBlocked') || 'Popup blocked! Please enable popups to print.');
|
|
283
288
|
}
|
|
284
289
|
|
|
285
290
|
const htmlContent = `
|
|
@@ -327,7 +332,7 @@ export const useCopyArtifact = (
|
|
|
327
332
|
a.click();
|
|
328
333
|
URL.revokeObjectURL(url);
|
|
329
334
|
onDownload?.();
|
|
330
|
-
} else {
|
|
335
|
+
} else if (format.action === 'copy') {
|
|
331
336
|
// Handle regular copy operation
|
|
332
337
|
const contentToCopy = convertContent(format);
|
|
333
338
|
await copyToClipboard(contentToCopy);
|
|
@@ -337,17 +342,19 @@ export const useCopyArtifact = (
|
|
|
337
342
|
setCopyState(prev => ({
|
|
338
343
|
...prev,
|
|
339
344
|
loading: false,
|
|
340
|
-
success:
|
|
345
|
+
success: format.action === 'copy',
|
|
341
346
|
error: null,
|
|
342
347
|
}));
|
|
343
348
|
|
|
344
|
-
// Reset success state after delay
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
349
|
+
// Reset success state after delay (only for copy actions)
|
|
350
|
+
if (format.action === 'copy') {
|
|
351
|
+
setTimeout(() => {
|
|
352
|
+
setCopyState(prev => ({
|
|
353
|
+
...prev,
|
|
354
|
+
success: false,
|
|
355
|
+
}));
|
|
356
|
+
}, 2000);
|
|
357
|
+
}
|
|
351
358
|
} catch (error) {
|
|
352
359
|
console.error('Copy operation failed:', error);
|
|
353
360
|
setCopyState(prev => ({
|
|
@@ -367,7 +374,7 @@ export const useCopyArtifact = (
|
|
|
367
374
|
}, 3000);
|
|
368
375
|
}
|
|
369
376
|
},
|
|
370
|
-
[artifact, convertContent, copyToClipboard, onCopy, onPrint]
|
|
377
|
+
[artifact, convertContent, copyToClipboard, onCopy, onPrint, t]
|
|
371
378
|
);
|
|
372
379
|
|
|
373
380
|
/**
|
|
@@ -140,7 +140,6 @@
|
|
|
140
140
|
height: 12px;
|
|
141
141
|
border: 2px solid #e5e7eb;
|
|
142
142
|
border-radius: 50%;
|
|
143
|
-
border-top: 2px solid #3b82f6;
|
|
144
143
|
animation: memori-copy-spin 1s linear infinite;
|
|
145
144
|
}
|
|
146
145
|
|
|
@@ -161,7 +160,7 @@
|
|
|
161
160
|
z-index: 10001;
|
|
162
161
|
top: 100%;
|
|
163
162
|
right: 0;
|
|
164
|
-
left: 0;
|
|
163
|
+
/* left: 0; */
|
|
165
164
|
overflow: hidden;
|
|
166
165
|
min-width: 280px;
|
|
167
166
|
max-width: 320px;
|
|
@@ -10,7 +10,7 @@ export interface CopyFormat {
|
|
|
10
10
|
description?: string;
|
|
11
11
|
icon?: React.ReactNode | undefined;
|
|
12
12
|
mimeType: string;
|
|
13
|
-
action: 'copy' | 'pdf' | 'print' | 'download';
|
|
13
|
+
action: 'copy' | 'pdf' | 'print' | 'download' | 'link';
|
|
14
14
|
isAsync?: boolean;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -32,6 +32,7 @@ export interface CopyButtonWithDropdownProps {
|
|
|
32
32
|
onCopy?: () => void;
|
|
33
33
|
onDownload?: () => void;
|
|
34
34
|
onPrint?: () => void;
|
|
35
|
+
onOpenExternal?: () => void;
|
|
35
36
|
loading?: boolean;
|
|
36
37
|
className?: string;
|
|
37
38
|
disabled?: boolean;
|