@kortix/ui 0.15.8 → 0.15.9
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/dist/_vendor/kortix-shared.js +4 -1
- package/dist/access/access/access-dialog-share.js +12 -6
- package/dist/access/access/share-selection.d.ts +9 -0
- package/dist/access/access/share-selection.js +64 -0
- package/dist/customize/connectors/connector-identity.js +3 -3
- package/dist/customize/connectors/detail/app-page.js +2 -2
- package/dist/customize/connectors/detail/connector-accounts.d.ts +3 -1
- package/dist/customize/connectors/detail/connector-accounts.js +2 -2
- package/dist/customize/connectors/detail/connector-notice-view.d.ts +4 -0
- package/dist/customize/connectors/detail/connector-notice-view.js +4 -0
- package/dist/customize/connectors/detail/connector-notice.d.ts +31 -4
- package/dist/customize/connectors/detail/connector-notice.js +23 -4
- package/dist/customize/connectors/detail/connector-page.js +27 -7
- package/dist/customize/connectors/detail/connector-status.d.ts +12 -1
- package/dist/customize/connectors/detail/connector-status.js +11 -0
- package/dist/customize/connectors/detail/status-badge.d.ts +3 -3
- package/dist/customize/connectors/detail/status-badge.js +2 -1
- package/dist/customize/connectors/detail/use-connector-detail.js +10 -2
- package/dist/customize/connectors/detail/use-mcp-oauth-sign-in.d.ts +13 -0
- package/dist/customize/connectors/detail/use-mcp-oauth-sign-in.js +29 -0
- package/dist/customize/providers/provider-accordion.js +5 -4
- package/dist/customize/providers/provider-connect.js +3 -1
- package/dist/customize/providers/provider-sheet.js +9 -4
- package/dist/customize/sections/component/email-connect-form.js +4 -2
- package/dist/customize/sections/connectors-view.d.ts +4 -1
- package/dist/customize/sections/connectors-view.js +42 -7
- package/dist/customize/sections/view/account-secret-resources-panel.d.ts +15 -0
- package/dist/customize/sections/view/account-secret-resources-panel.js +44 -5
- package/dist/customize/sections/view/secret-delivery.d.ts +9 -2
- package/dist/customize/sections/view/secret-delivery.js +14 -4
- package/dist/customize/sections/view/secrets-view.js +21 -5
- package/dist/customize/triggers/schedule/schedule-builder.js +1 -1
- package/dist/customize/triggers/schedule/schedule-copy.js +4 -0
- package/dist/customize/triggers/schedule/schedule-detail-sheet.js +14 -3
- package/dist/customize/triggers/schedule/then-fields.d.ts +3 -1
- package/dist/customize/triggers/schedule/then-fields.js +8 -4
- package/dist/customize/triggers/schedule/trigger-composer.js +1 -1
- package/dist/customize/triggers/schedule/trigger-list.d.ts +3 -1
- package/dist/customize/triggers/schedule/trigger-list.js +18 -2
- package/dist/customize/triggers/schedule/trigger-runs-logic.js +4 -2
- package/dist/customize/triggers/schedule/trigger-runs-panel.js +4 -1
- package/dist/files/renderers/pptx-renderer.js +5 -20
- package/dist/files/renderers/presentation/FullScreenPresentationViewer.d.ts +3 -2
- package/dist/files/renderers/presentation/FullScreenPresentationViewer.js +23 -304
- package/dist/files/renderers/presentation/presentation-export-menu.d.ts +14 -0
- package/dist/files/renderers/presentation/presentation-export-menu.js +44 -0
- package/dist/files/renderers/presentation/presentation-utils.d.ts +1 -0
- package/dist/files/renderers/presentation/presentation-utils.js +4 -0
- package/dist/files/renderers/presentation/slide-iframe.d.ts +23 -0
- package/dist/files/renderers/presentation/slide-iframe.js +61 -0
- package/dist/files/renderers/presentation/use-presentation-metadata.d.ts +39 -0
- package/dist/files/renderers/presentation/use-presentation-metadata.js +137 -0
- package/dist/files/renderers/presentation/use-slide-navigation.d.ts +17 -0
- package/dist/files/renderers/presentation/use-slide-navigation.js +82 -0
- package/dist/files/renderers/shared/use-stage-fit-scale.d.ts +19 -0
- package/dist/files/renderers/shared/use-stage-fit-scale.js +41 -0
- package/dist/files/renderers/show-content-renderer.js +16 -11
- package/dist/files/renderers/xlsx/xlsx-renderer.d.ts +4 -13
- package/dist/files/renderers/xlsx/xlsx-renderer.js +6 -63
- package/dist/files/renderers/xlsx/xlsx-viewer.d.ts +4 -2
- package/dist/files/renderers/xlsx/xlsx-viewer.js +28 -34
- package/dist/files/viewer/file-content-renderer.js +1 -4
- package/dist/files/viewer/use-file-content-state.js +10 -9
- package/dist/i18n/en.d.ts +48 -0
- package/dist/i18n/en.js +51 -3
- package/dist/internal/chrome/use-chrome-offered.d.ts +2 -1
- package/dist/internal/chrome/use-chrome-offered.js +4 -2
- package/dist/internal/hooks/connectors/use-finish-sign-in.d.ts +13 -0
- package/dist/internal/hooks/connectors/use-finish-sign-in.js +33 -0
- package/dist/internal/hooks/connectors/use-pipedream-connect-member.js +6 -1
- package/dist/internal/hooks/connectors/use-pipedream-connect-project.js +6 -1
- package/dist/internal/lib/error-handler.js +33 -0
- package/dist/internal/lib/trigger-clock.d.ts +7 -2
- package/dist/internal/lib/trigger-clock.js +17 -3
- package/dist/lib/z-stack.d.ts +5 -1
- package/dist/lib/z-stack.js +12 -2
- package/dist/session/models/model-connection-gate.js +16 -3
- package/dist/session/models/model-picker-panel.js +6 -2
- package/dist/session/models/provider-key-action.d.ts +10 -0
- package/dist/session/models/provider-key-action.js +35 -0
- package/dist/session/models/provider-key-slot.d.ts +9 -0
- package/dist/session/models/provider-key-slot.js +19 -0
- package/dist/session/prompts/session-connect-prompt.d.ts +40 -0
- package/dist/session/prompts/session-connect-prompt.js +126 -0
- package/dist/session/status/session-error-banner.d.ts +1 -1
- package/dist/session/status/session-error-banner.js +12 -4
- package/dist/session/thread/session-chat.js +7 -2
- package/dist/session/thread/transcript.js +31 -7
- package/dist/test-utils/intl.d.ts +48 -0
- package/package.json +3 -3
|
@@ -1,326 +1,45 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button } from '../../../primitives/button.js';
|
|
3
|
-
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '../../../primitives/dropdown-menu.js';
|
|
4
3
|
import { KortixLoader } from '../../../primitives/kortix-loader.js';
|
|
5
|
-
import { framePolicy } from '../../viewer/preview-policy.js';
|
|
6
|
-
import { useDownloadRestriction } from '../../../internal/billing/use-download-restriction.js';
|
|
7
|
-
import { useSandboxProxy } from '../../../internal/hooks/use-sandbox-proxy.js';
|
|
8
4
|
import { useTranslations } from '../../../i18n/index.js';
|
|
9
5
|
import { cn } from '../../../lib/utils.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
6
|
+
import { CaretLeftIcon as ChevronLeft, CaretRightIcon as ChevronRight, PencilSimpleIcon as Edit, PresentationIcon as Presentation, SkipBackIcon as SkipBack, SkipForwardIcon as SkipForward, XIcon as X, } from '@phosphor-icons/react';
|
|
7
|
+
import { useMemo, useState } from 'react';
|
|
8
|
+
import { PresentationExportMenu } from './presentation-export-menu.js';
|
|
9
|
+
import { SlideIframe } from './slide-iframe.js';
|
|
10
|
+
import { usePresentationMetadata } from './use-presentation-metadata.js';
|
|
11
|
+
import { useSlideNavigation } from './use-slide-navigation.js';
|
|
12
|
+
/** The fullscreen presentation modal. The metadata lifecycle, the slide
|
|
13
|
+
* stage, the keyboard map and the export menu live in their own modules. */
|
|
15
14
|
export function FullScreenPresentationViewer({ isOpen, onClose, presentationName, sandboxUrl, initialSlide = 1, }) {
|
|
16
15
|
const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
|
|
17
16
|
const tHardcodedUi = useTranslations('hardcodedUi');
|
|
18
|
-
const { subdomainOpts } = useSandboxProxy();
|
|
19
|
-
const [metadata, setMetadata] = useState(null);
|
|
20
|
-
const [currentSlide, setCurrentSlide] = useState(initialSlide);
|
|
21
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
22
|
-
const [retryAttempt, setRetryAttempt] = useState(0);
|
|
23
|
-
const retryTimeoutRef = useRef(null);
|
|
24
|
-
const hasLoadedRef = useRef(false);
|
|
25
17
|
const [showEditor, setShowEditor] = useState(false);
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const { isRestricted: isDownloadRestricted, openUpgradeModal } = useDownloadRestriction({
|
|
32
|
-
featureName: 'presentations',
|
|
18
|
+
const { metadata, slides, isLoading, retryAttempt, subdomainOpts } = usePresentationMetadata({
|
|
19
|
+
isOpen,
|
|
20
|
+
presentationName,
|
|
21
|
+
sandboxUrl,
|
|
22
|
+
showEditor,
|
|
33
23
|
});
|
|
34
24
|
// Create a stable refresh timestamp when metadata changes (like PresentationViewer)
|
|
35
25
|
const refreshTimestamp = useMemo(() => metadata?.updated_at || Date.now(), [metadata?.updated_at]);
|
|
36
|
-
const slides = metadata
|
|
37
|
-
? Object.entries(metadata.slides)
|
|
38
|
-
.map(([num, slide]) => ({ number: parseInt(num), ...slide }))
|
|
39
|
-
.sort((a, b) => a.number - b.number)
|
|
40
|
-
: [];
|
|
41
26
|
const totalSlides = slides.length;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
// If sandbox URL isn't available yet, wait and don't set loading state
|
|
53
|
-
if (!presentationName || !sandboxUrl) {
|
|
54
|
-
setIsLoading(false);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
setIsLoading(true);
|
|
58
|
-
setRetryAttempt(retryCount);
|
|
59
|
-
try {
|
|
60
|
-
// Sanitize the presentation name to match backend directory creation
|
|
61
|
-
const sanitizedPresentationName = sanitizeFilename(presentationName);
|
|
62
|
-
const metadataUrl = constructHtmlPreviewUrl(`presentations/${sanitizedPresentationName}/metadata.json`, subdomainOpts);
|
|
63
|
-
const urlWithCacheBust = `${metadataUrl}?t=${Date.now()}`;
|
|
64
|
-
console.log(`Loading presentation metadata (attempt ${retryCount + 1}):`, urlWithCacheBust);
|
|
65
|
-
const response = await fetch(urlWithCacheBust, {
|
|
66
|
-
cache: 'no-cache',
|
|
67
|
-
headers: { 'Cache-Control': 'no-cache' },
|
|
68
|
-
});
|
|
69
|
-
if (response.ok) {
|
|
70
|
-
const data = await response.json();
|
|
71
|
-
setMetadata(data);
|
|
72
|
-
hasLoadedRef.current = true; // Mark as successfully loaded
|
|
73
|
-
console.log('Successfully loaded presentation metadata:', data);
|
|
74
|
-
setIsLoading(false);
|
|
75
|
-
// Clear any pending retry timeout on success
|
|
76
|
-
if (retryTimeoutRef.current) {
|
|
77
|
-
clearTimeout(retryTimeoutRef.current);
|
|
78
|
-
retryTimeoutRef.current = null;
|
|
79
|
-
}
|
|
80
|
-
return; // Success, exit early
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
catch (err) {
|
|
87
|
-
console.error(`Error loading metadata (attempt ${retryCount + 1}):`, err);
|
|
88
|
-
// Calculate delay with exponential backoff, capped at 10 seconds
|
|
89
|
-
// For early attempts, use shorter delays. After 5 attempts, use consistent 5 second intervals
|
|
90
|
-
const delay = retryCount < 5
|
|
91
|
-
? Math.min(1000 * Math.pow(2, retryCount), 10000) // Exponential backoff for first 5 attempts
|
|
92
|
-
: 5000; // Consistent 5 second intervals after that
|
|
93
|
-
console.log(`Retrying in ${delay}ms... (attempt ${retryCount + 1})`);
|
|
94
|
-
// Keep retrying indefinitely - don't set error state
|
|
95
|
-
retryTimeoutRef.current = setTimeout(() => {
|
|
96
|
-
loadMetadata(retryCount + 1, maxRetries);
|
|
97
|
-
}, delay);
|
|
98
|
-
return; // Keep loading state, don't set error
|
|
99
|
-
}
|
|
100
|
-
}, [presentationName, sandboxUrl, subdomainOpts]);
|
|
101
|
-
// Sync currentSlide with initialSlide when modal opens (not on every initialSlide change)
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
const justOpened = isOpen && !wasOpenRef.current;
|
|
104
|
-
wasOpenRef.current = isOpen;
|
|
105
|
-
if (justOpened) {
|
|
106
|
-
// Modal just opened - set the slide to the requested initial slide
|
|
107
|
-
setCurrentSlide(initialSlide);
|
|
108
|
-
// Reset loaded flag when opening (so we can reload if needed)
|
|
109
|
-
hasLoadedRef.current = false;
|
|
110
|
-
// Clear any existing retry timeout when opening
|
|
111
|
-
if (retryTimeoutRef.current) {
|
|
112
|
-
clearTimeout(retryTimeoutRef.current);
|
|
113
|
-
retryTimeoutRef.current = null;
|
|
114
|
-
}
|
|
115
|
-
// Only start loading if we have the required data
|
|
116
|
-
if (presentationName && sandboxUrl) {
|
|
117
|
-
loadMetadata();
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
setIsLoading(false);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
else if (!isOpen) {
|
|
124
|
-
// Clear retry timeout when closing
|
|
125
|
-
if (retryTimeoutRef.current) {
|
|
126
|
-
clearTimeout(retryTimeoutRef.current);
|
|
127
|
-
retryTimeoutRef.current = null;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}, [isOpen, presentationName, sandboxUrl, initialSlide, loadMetadata]);
|
|
131
|
-
// Cleanup retry timeout on unmount
|
|
132
|
-
useEffect(() => {
|
|
133
|
-
return () => {
|
|
134
|
-
if (retryTimeoutRef.current) {
|
|
135
|
-
clearTimeout(retryTimeoutRef.current);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}, []);
|
|
139
|
-
// Reload metadata when exiting editor mode to refresh with latest changes
|
|
140
|
-
useEffect(() => {
|
|
141
|
-
let timeoutId;
|
|
142
|
-
if (!showEditor && isOpen) {
|
|
143
|
-
// Reset loaded flag so we can reload after editor changes
|
|
144
|
-
hasLoadedRef.current = false;
|
|
145
|
-
// Add a small delay to allow the editor to save changes
|
|
146
|
-
timeoutId = setTimeout(() => {
|
|
147
|
-
loadMetadata();
|
|
148
|
-
}, 300);
|
|
149
|
-
}
|
|
150
|
-
return () => {
|
|
151
|
-
if (timeoutId) {
|
|
152
|
-
clearTimeout(timeoutId);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
156
|
-
}, [showEditor, isOpen]);
|
|
157
|
-
// Navigation functions
|
|
158
|
-
const goToNextSlide = useCallback(() => {
|
|
159
|
-
if (currentSlide < totalSlides) {
|
|
160
|
-
setCurrentSlide((prev) => prev + 1);
|
|
161
|
-
}
|
|
162
|
-
}, [currentSlide, totalSlides]);
|
|
163
|
-
const goToPreviousSlide = useCallback(() => {
|
|
164
|
-
if (currentSlide > 1) {
|
|
165
|
-
setCurrentSlide((prev) => prev - 1);
|
|
166
|
-
}
|
|
167
|
-
}, [currentSlide]);
|
|
168
|
-
// Keyboard navigation
|
|
169
|
-
useEffect(() => {
|
|
170
|
-
if (!isOpen)
|
|
171
|
-
return;
|
|
172
|
-
const handleKeyDown = (e) => {
|
|
173
|
-
// Prevent default for all our handled keys
|
|
174
|
-
const handledKeys = [
|
|
175
|
-
'ArrowLeft',
|
|
176
|
-
'ArrowRight',
|
|
177
|
-
'ArrowUp',
|
|
178
|
-
'ArrowDown',
|
|
179
|
-
' ',
|
|
180
|
-
'Home',
|
|
181
|
-
'End',
|
|
182
|
-
'Escape',
|
|
183
|
-
];
|
|
184
|
-
if (handledKeys.includes(e.key)) {
|
|
185
|
-
e.preventDefault();
|
|
186
|
-
e.stopPropagation();
|
|
187
|
-
}
|
|
188
|
-
switch (e.key) {
|
|
189
|
-
case 'ArrowLeft':
|
|
190
|
-
case 'ArrowUp':
|
|
191
|
-
goToPreviousSlide();
|
|
192
|
-
break;
|
|
193
|
-
case 'ArrowRight':
|
|
194
|
-
case 'ArrowDown':
|
|
195
|
-
case ' ':
|
|
196
|
-
goToNextSlide();
|
|
197
|
-
break;
|
|
198
|
-
case 'Home':
|
|
199
|
-
setCurrentSlide(1);
|
|
200
|
-
break;
|
|
201
|
-
case 'End':
|
|
202
|
-
setCurrentSlide(totalSlides);
|
|
203
|
-
break;
|
|
204
|
-
case 'Escape':
|
|
205
|
-
if (showEditor) {
|
|
206
|
-
setShowEditor(false);
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
onClose();
|
|
210
|
-
}
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
// Add event listener to document with capture to ensure we get the events first
|
|
215
|
-
document.addEventListener('keydown', handleKeyDown, true);
|
|
216
|
-
return () => document.removeEventListener('keydown', handleKeyDown, true);
|
|
217
|
-
}, [isOpen, goToNextSlide, goToPreviousSlide, totalSlides, onClose, showEditor]);
|
|
218
|
-
// Download handlers
|
|
219
|
-
const handleDownload = async (format) => {
|
|
220
|
-
if (isDownloadRestricted) {
|
|
221
|
-
openUpgradeModal();
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
if (!sandboxUrl || !presentationName)
|
|
225
|
-
return;
|
|
226
|
-
// Use sanitized name for the path (matching backend directory structure)
|
|
227
|
-
const sanitizedName = sanitizeFilename(presentationName);
|
|
228
|
-
const setDownloadState = format === DownloadFormat.PDF ? setIsDownloadingPDF : setIsDownloadingPPTX;
|
|
229
|
-
setDownloadState(true);
|
|
230
|
-
try {
|
|
231
|
-
await downloadPresentation(format, sandboxUrl, `/workspace/presentations/${sanitizedName}`, presentationName, tI18nComplete);
|
|
232
|
-
}
|
|
233
|
-
catch (error) {
|
|
234
|
-
console.error(`Error downloading ${format}:`, error);
|
|
235
|
-
}
|
|
236
|
-
finally {
|
|
237
|
-
setDownloadState(false);
|
|
238
|
-
}
|
|
239
|
-
};
|
|
27
|
+
const { currentSlide, setCurrentSlide, goToNextSlide, goToPreviousSlide } = useSlideNavigation({
|
|
28
|
+
isOpen,
|
|
29
|
+
initialSlide,
|
|
30
|
+
totalSlides,
|
|
31
|
+
showEditor,
|
|
32
|
+
onExitEditor: () => setShowEditor(false),
|
|
33
|
+
onClose,
|
|
34
|
+
});
|
|
240
35
|
const currentSlideData = slides.find((slide) => slide.number === currentSlide);
|
|
241
|
-
// Memoized slide iframe component with proper scaling (matching PresentationViewer)
|
|
242
|
-
const SlideIframe = useMemo(() => {
|
|
243
|
-
const SlideIframeComponent = React.memo(({ slide }) => {
|
|
244
|
-
const [containerRef, setContainerRef] = useState(null);
|
|
245
|
-
const [scale, setScale] = useState(1);
|
|
246
|
-
useEffect(() => {
|
|
247
|
-
if (containerRef) {
|
|
248
|
-
const updateScale = () => {
|
|
249
|
-
const containerWidth = containerRef.offsetWidth;
|
|
250
|
-
const containerHeight = containerRef.offsetHeight;
|
|
251
|
-
// Calculate scale to fit 1920x1080 into container while maintaining aspect ratio
|
|
252
|
-
const scaleX = containerWidth / 1920;
|
|
253
|
-
const scaleY = containerHeight / 1080;
|
|
254
|
-
const newScale = Math.min(scaleX, scaleY);
|
|
255
|
-
// Only update if scale actually changed to prevent unnecessary re-renders
|
|
256
|
-
if (Math.abs(newScale - scale) > 0.001) {
|
|
257
|
-
setScale(newScale);
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
// Use a debounced version for resize events to prevent excessive updates
|
|
261
|
-
let resizeTimeout;
|
|
262
|
-
const debouncedUpdateScale = () => {
|
|
263
|
-
clearTimeout(resizeTimeout);
|
|
264
|
-
resizeTimeout = setTimeout(updateScale, 100);
|
|
265
|
-
};
|
|
266
|
-
updateScale();
|
|
267
|
-
window.addEventListener('resize', debouncedUpdateScale);
|
|
268
|
-
return () => {
|
|
269
|
-
window.removeEventListener('resize', debouncedUpdateScale);
|
|
270
|
-
clearTimeout(resizeTimeout);
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
}, [containerRef, scale]);
|
|
274
|
-
if (!sandboxUrl) {
|
|
275
|
-
return (_jsx("div", { className: "flex h-full items-center justify-center", children: _jsxs("div", { className: "text-center", children: [_jsx(Presentation, { className: "mx-auto mb-4 h-12 w-12 text-zinc-400" }), _jsx("p", { className: "text-sm text-zinc-500 dark:text-zinc-400", children: tHardcodedUi.raw('componentsThreadToolViewsPresentationToolsFullscreenpresentationviewer.line377JsxTextNoSlideContentToPreview') })] }) }));
|
|
276
|
-
}
|
|
277
|
-
const slideUrl = constructHtmlPreviewUrl(slide.file_path, subdomainOpts);
|
|
278
|
-
// Add cache-busting to iframe src to ensure fresh content
|
|
279
|
-
const slideUrlWithCacheBust = `${slideUrl}?t=${refreshTimestamp}`;
|
|
280
|
-
const frameSrc = showEditor
|
|
281
|
-
? `${sandboxUrl}/api/html/${slide.file_path}/editor`
|
|
282
|
-
: slideUrlWithCacheBust;
|
|
283
|
-
return (_jsx("div", { className: "flex h-full w-full items-center justify-center bg-transparent", children: _jsx("div", { ref: setContainerRef, className: "relative overflow-hidden rounded-lg bg-transparent", style: {
|
|
284
|
-
width: '100%',
|
|
285
|
-
maxWidth: '100%',
|
|
286
|
-
aspectRatio: '16 / 9',
|
|
287
|
-
maxHeight: '100%',
|
|
288
|
-
containIntrinsicSize: '1920px 1080px',
|
|
289
|
-
contain: 'layout style',
|
|
290
|
-
}, children: _jsx("iframe", { src: frameSrc, title: tI18nComplete('text871475cb411c', {
|
|
291
|
-
value0: slide.number,
|
|
292
|
-
value1: slide.title,
|
|
293
|
-
}), className: "rounded-xl border-0",
|
|
294
|
-
// Agent-written slides keep same-origin only on a preview origin
|
|
295
|
-
// of their own, never on this app's or the API's origin.
|
|
296
|
-
sandbox: framePolicy('slide', frameSrc).sandbox, style: {
|
|
297
|
-
width: '1920px',
|
|
298
|
-
height: '1080px',
|
|
299
|
-
border: 'none',
|
|
300
|
-
display: 'block',
|
|
301
|
-
transform: `scale(${scale})`,
|
|
302
|
-
transformOrigin: '0 0',
|
|
303
|
-
position: 'absolute',
|
|
304
|
-
top: 0,
|
|
305
|
-
left: `calc((100% - ${1920 * scale}px) / 2)`,
|
|
306
|
-
backfaceVisibility: 'hidden',
|
|
307
|
-
WebkitBackfaceVisibility: 'hidden',
|
|
308
|
-
} }, `slide-${slide.number}-${refreshTimestamp}-${showEditor}`) }) }));
|
|
309
|
-
}, (prevProps, nextProps) => {
|
|
310
|
-
// Custom comparison function - only re-render if slide number or file_path changes
|
|
311
|
-
return (prevProps.slide.number === nextProps.slide.number &&
|
|
312
|
-
prevProps.slide.file_path === nextProps.slide.file_path);
|
|
313
|
-
});
|
|
314
|
-
SlideIframeComponent.displayName = 'SlideIframeComponent';
|
|
315
|
-
return SlideIframeComponent;
|
|
316
|
-
}, [sandboxUrl, refreshTimestamp, showEditor, subdomainOpts, tHardcodedUi, tI18nComplete]);
|
|
317
36
|
if (!isOpen)
|
|
318
37
|
return null;
|
|
319
38
|
// Render slide iframe with proper scaling
|
|
320
|
-
const renderSlide = !currentSlideData || !sandboxUrl ? null : _jsx(SlideIframe, { slide: currentSlideData });
|
|
39
|
+
const renderSlide = !currentSlideData || !sandboxUrl ? null : (_jsx(SlideIframe, { slide: currentSlideData, sandboxUrl: sandboxUrl, subdomainOpts: subdomainOpts, refreshTimestamp: refreshTimestamp, showEditor: showEditor, tI18nComplete: tI18nComplete, tHardcodedUi: tHardcodedUi }));
|
|
321
40
|
return (_jsxs("div", { className: "fixed inset-0 z-50 flex flex-col bg-black/90 backdrop-blur-sm", children: [_jsx("div", { className: "shrink-0 border-b border-zinc-200 bg-white dark:border-zinc-800 dark:bg-zinc-950", children: _jsxs("div", { className: "kx-titlebar-row flex items-center justify-between p-4", "data-sidebar-collapsed": "", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "relative shrink-0 rounded-2xl border border-zinc-300 bg-zinc-200/60 p-2 dark:border-zinc-700 dark:bg-zinc-900", children: _jsx(Presentation, { className: "h-5 w-5 text-zinc-500 dark:text-zinc-400" }) }), metadata && (_jsxs("div", { children: [_jsx("h1", { className: "text-base font-medium text-zinc-900 dark:text-zinc-100", children: metadata.title || metadata.presentation_name }), _jsxs("p", { className: "text-sm text-zinc-500 dark:text-zinc-400", children: [tHardcodedUi.raw('i18nComplete.text6bb4c1177681'), " ", currentSlide, ' ', tHardcodedUi.raw('i18nComplete.text28391d3bc64e'), " ", totalSlides] })] }))] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { variant: "ghost", size: "sm", className: "w-8 p-0", title: showEditor
|
|
322
41
|
? tHardcodedUi.raw('i18nComplete.textbd0b7be215ce')
|
|
323
|
-
: tHardcodedUi.raw('i18nComplete.text8268dd9ea939'), onClick: () => setShowEditor(!showEditor), children: showEditor ? (_jsx(Presentation, { className: "h-3.5 w-3.5" })) : (_jsx(Edit, { className: "h-3.5 w-3.5" })) }),
|
|
42
|
+
: tHardcodedUi.raw('i18nComplete.text8268dd9ea939'), onClick: () => setShowEditor(!showEditor), children: showEditor ? (_jsx(Presentation, { className: "h-3.5 w-3.5" })) : (_jsx(Edit, { className: "h-3.5 w-3.5" })) }), _jsx(PresentationExportMenu, { sandboxUrl: sandboxUrl, presentationName: presentationName, tI18nComplete: tI18nComplete, tHardcodedUi: tHardcodedUi }), _jsx(Button, { variant: "ghost", size: "sm", onClick: onClose, className: "h-8 w-8 p-0", title: tHardcodedUi.raw('componentsThreadToolViewsPresentationToolsFullscreenpresentationviewer.line529JsxAttrTitleCloseFullScreen'), children: _jsx(X, { className: "h-3.5 w-3.5" }) })] })] }) }), _jsx("div", { className: "flex min-h-0 flex-1 items-center justify-center bg-zinc-100 p-2 dark:bg-zinc-900", children: isLoading || !currentSlideData ? (_jsxs("div", { className: "text-center", children: [_jsx(KortixLoader, { size: "large", className: "mx-auto mb-4" }), _jsx("p", { className: "text-zinc-700 dark:text-zinc-300", children: retryAttempt > 0
|
|
324
43
|
? tI18nComplete('text3df439a7a73b', { value0: retryAttempt + 1 })
|
|
325
44
|
: tHardcodedUi.raw('i18nComplete.text1ac9fe8126fa') })] })) : currentSlideData ? (_jsxs("div", { className: "flex h-full w-full flex-col", children: [_jsx("div", { className: "flex-1 overflow-hidden rounded-xl bg-transparent", style: { aspectRatio: '16 / 9' }, children: renderSlide }), _jsxs("div", { className: "mt-3 flex items-center justify-between px-4", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { variant: "ghost", size: "sm", onClick: () => setCurrentSlide(1), disabled: currentSlide <= 1, className: "h-8 w-8 p-0 disabled:opacity-50", children: _jsx(SkipBack, { className: "h-3.5 w-3.5" }) }), _jsx(Button, { variant: "ghost", size: "sm", onClick: goToPreviousSlide, disabled: currentSlide <= 1, className: "h-8 w-8 p-0 disabled:opacity-50", children: _jsx(ChevronLeft, { className: "h-4 w-4" }) })] }), _jsx("div", { className: "flex items-center", children: _jsx("div", { className: "flex gap-2", children: slides.map((slide) => (_jsx("button", { "aria-label": `${tHardcodedUi.raw('i18nComplete.text6bb4c1177681')} ${slide.number}`, onClick: () => setCurrentSlide(slide.number), className: cn('h-2.5 w-2.5 rounded-full transition-colors duration-200', slide.number === currentSlide
|
|
326
45
|
? 'bg-black dark:bg-white'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { useTranslations } from '../../../i18n/index.js';
|
|
2
|
+
/** The `useTranslations` return for a namespace, as the viewer calls it. */
|
|
3
|
+
type Translator<NS extends string> = ReturnType<typeof useTranslations<NS>>;
|
|
4
|
+
/**
|
|
5
|
+
* The export dropdown of the fullscreen viewer: the download restriction
|
|
6
|
+
* check and the two download formats (PDF, PPTX).
|
|
7
|
+
*/
|
|
8
|
+
export declare function PresentationExportMenu({ sandboxUrl, presentationName, tI18nComplete, tHardcodedUi, }: {
|
|
9
|
+
sandboxUrl?: string;
|
|
10
|
+
presentationName?: string;
|
|
11
|
+
tI18nComplete: Translator<'hardcodedUi.i18nComplete'>;
|
|
12
|
+
tHardcodedUi: Translator<'hardcodedUi'>;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { FileTextIcon as FileText, PresentationIcon as Presentation, } from '@phosphor-icons/react';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { Download } from '../../../internal/icons/download.js';
|
|
6
|
+
import { useDownloadRestriction } from '../../../internal/billing/use-download-restriction.js';
|
|
7
|
+
import { Button } from '../../../primitives/button.js';
|
|
8
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '../../../primitives/dropdown-menu.js';
|
|
9
|
+
import { KortixLoader } from '../../../primitives/kortix-loader.js';
|
|
10
|
+
import { DownloadFormat, downloadPresentation, sanitizeFilename, } from './presentation-utils.js';
|
|
11
|
+
/**
|
|
12
|
+
* The export dropdown of the fullscreen viewer: the download restriction
|
|
13
|
+
* check and the two download formats (PDF, PPTX).
|
|
14
|
+
*/
|
|
15
|
+
export function PresentationExportMenu({ sandboxUrl, presentationName, tI18nComplete, tHardcodedUi, }) {
|
|
16
|
+
// Download restriction for free tier users
|
|
17
|
+
const { isRestricted: isDownloadRestricted, openUpgradeModal } = useDownloadRestriction({
|
|
18
|
+
featureName: 'presentations',
|
|
19
|
+
});
|
|
20
|
+
const [isDownloadingPDF, setIsDownloadingPDF] = useState(false);
|
|
21
|
+
const [isDownloadingPPTX, setIsDownloadingPPTX] = useState(false);
|
|
22
|
+
const handleDownload = async (format) => {
|
|
23
|
+
if (isDownloadRestricted) {
|
|
24
|
+
openUpgradeModal();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!sandboxUrl || !presentationName)
|
|
28
|
+
return;
|
|
29
|
+
// Use sanitized name for the path (matching backend directory structure)
|
|
30
|
+
const sanitizedName = sanitizeFilename(presentationName);
|
|
31
|
+
const setDownloadState = format === DownloadFormat.PDF ? setIsDownloadingPDF : setIsDownloadingPPTX;
|
|
32
|
+
setDownloadState(true);
|
|
33
|
+
try {
|
|
34
|
+
await downloadPresentation(format, sandboxUrl, `/workspace/presentations/${sanitizedName}`, presentationName, tI18nComplete);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error(`Error downloading ${format}:`, error);
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
setDownloadState(false);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "sm", className: "w-8 p-0", title: tHardcodedUi.raw('componentsThreadToolViewsPresentationToolsFullscreenpresentationviewer.line485JsxAttrTitleExportPresentation'), disabled: isDownloadingPDF || isDownloadingPPTX, children: isDownloadingPDF || isDownloadingPPTX ? (_jsx(KortixLoader, { customSize: 14 })) : (_jsx(Download, { className: "h-3.5 w-3.5" })) }) }), _jsxs(DropdownMenuContent, { align: "end", className: "w-32", children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => handleDownload(DownloadFormat.PDF), disabled: isDownloadingPDF, children: [_jsx(FileText, { className: "mr-2 h-4 w-4" }), "PDF"] }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => handleDownload(DownloadFormat.PPTX), disabled: isDownloadingPPTX, children: [_jsx(Presentation, { className: "mr-2 h-4 w-4" }), "PPTX"] })] })] }));
|
|
44
|
+
}
|
|
@@ -5,6 +5,10 @@ export var DownloadFormat;
|
|
|
5
5
|
DownloadFormat["PDF"] = "pdf";
|
|
6
6
|
DownloadFormat["PPTX"] = "pptx";
|
|
7
7
|
})(DownloadFormat || (DownloadFormat = {}));
|
|
8
|
+
// Helper function to sanitize filename (matching backend logic)
|
|
9
|
+
export function sanitizeFilename(name) {
|
|
10
|
+
return name.replace(/[^a-zA-Z0-9\-_]/g, '').toLowerCase();
|
|
11
|
+
}
|
|
8
12
|
/** Trigger a browser "save as" for a generated blob. */
|
|
9
13
|
function saveBlob(blob, filename) {
|
|
10
14
|
const url = window.URL.createObjectURL(blob);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { buildStaticFilePreviewUrl as constructHtmlPreviewUrl } from '@kortix/sdk';
|
|
2
|
+
import type { useTranslations } from '../../../i18n/index.js';
|
|
3
|
+
import type { SlideMetadata } from './use-presentation-metadata.js';
|
|
4
|
+
/** The `useTranslations` return for a namespace, as the viewer calls it. */
|
|
5
|
+
type Translator<NS extends string> = ReturnType<typeof useTranslations<NS>>;
|
|
6
|
+
interface SlideIframeProps {
|
|
7
|
+
slide: SlideMetadata & {
|
|
8
|
+
number: number;
|
|
9
|
+
};
|
|
10
|
+
sandboxUrl?: string;
|
|
11
|
+
subdomainOpts: Parameters<typeof constructHtmlPreviewUrl>[1];
|
|
12
|
+
refreshTimestamp: string | number;
|
|
13
|
+
showEditor: boolean;
|
|
14
|
+
tI18nComplete: Translator<'hardcodedUi.i18nComplete'>;
|
|
15
|
+
tHardcodedUi: Translator<'hardcodedUi'>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The slide stage: the sandbox iframe with its sandbox policy, and the
|
|
19
|
+
* fit-scale of the 1920x1080 stage inside its 16:9 container (upscale
|
|
20
|
+
* allowed — the stage follows the container in both directions).
|
|
21
|
+
*/
|
|
22
|
+
export declare const SlideIframe: import("react").MemoExoticComponent<({ slide, sandboxUrl, subdomainOpts, refreshTimestamp, showEditor, tI18nComplete, tHardcodedUi, }: SlideIframeProps) => import("react").JSX.Element>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { buildStaticFilePreviewUrl as constructHtmlPreviewUrl } from '@kortix/sdk';
|
|
4
|
+
import { PresentationIcon as Presentation } from '@phosphor-icons/react';
|
|
5
|
+
import { memo } from 'react';
|
|
6
|
+
import { framePolicy } from '../../viewer/preview-policy.js';
|
|
7
|
+
import { useStageFitScale } from '../shared/use-stage-fit-scale.js';
|
|
8
|
+
/**
|
|
9
|
+
* The slide stage: the sandbox iframe with its sandbox policy, and the
|
|
10
|
+
* fit-scale of the 1920x1080 stage inside its 16:9 container (upscale
|
|
11
|
+
* allowed — the stage follows the container in both directions).
|
|
12
|
+
*/
|
|
13
|
+
export const SlideIframe = memo(({ slide, sandboxUrl, subdomainOpts, refreshTimestamp, showEditor, tI18nComplete, tHardcodedUi, }) => {
|
|
14
|
+
const [containerRef, scale] = useStageFitScale(1920, 1080, { allowUpscale: true });
|
|
15
|
+
if (!sandboxUrl) {
|
|
16
|
+
return (_jsx("div", { className: "flex h-full items-center justify-center", children: _jsxs("div", { className: "text-center", children: [_jsx(Presentation, { className: "mx-auto mb-4 h-12 w-12 text-zinc-400" }), _jsx("p", { className: "text-sm text-zinc-500 dark:text-zinc-400", children: tHardcodedUi.raw('componentsThreadToolViewsPresentationToolsFullscreenpresentationviewer.line377JsxTextNoSlideContentToPreview') })] }) }));
|
|
17
|
+
}
|
|
18
|
+
const slideUrl = constructHtmlPreviewUrl(slide.file_path, subdomainOpts);
|
|
19
|
+
// Add cache-busting to iframe src to ensure fresh content
|
|
20
|
+
const slideUrlWithCacheBust = `${slideUrl}?t=${refreshTimestamp}`;
|
|
21
|
+
const frameSrc = showEditor
|
|
22
|
+
? `${sandboxUrl}/api/html/${slide.file_path}/editor`
|
|
23
|
+
: slideUrlWithCacheBust;
|
|
24
|
+
return (_jsx("div", { className: "flex h-full w-full items-center justify-center bg-transparent", children: _jsx("div", { ref: containerRef, className: "relative overflow-hidden rounded-lg bg-transparent", style: {
|
|
25
|
+
width: '100%',
|
|
26
|
+
maxWidth: '100%',
|
|
27
|
+
aspectRatio: '16 / 9',
|
|
28
|
+
maxHeight: '100%',
|
|
29
|
+
containIntrinsicSize: '1920px 1080px',
|
|
30
|
+
contain: 'layout style',
|
|
31
|
+
}, children: _jsx("iframe", { src: frameSrc, title: tI18nComplete('text871475cb411c', {
|
|
32
|
+
value0: slide.number,
|
|
33
|
+
value1: slide.title,
|
|
34
|
+
}), className: "rounded-xl border-0",
|
|
35
|
+
// Agent-written slides keep same-origin only on a preview origin
|
|
36
|
+
// of their own, never on this app's or the API's origin.
|
|
37
|
+
sandbox: framePolicy('slide', frameSrc).sandbox, style: {
|
|
38
|
+
width: '1920px',
|
|
39
|
+
height: '1080px',
|
|
40
|
+
border: 'none',
|
|
41
|
+
display: 'block',
|
|
42
|
+
transform: `scale(${scale})`,
|
|
43
|
+
transformOrigin: '0 0',
|
|
44
|
+
position: 'absolute',
|
|
45
|
+
top: 0,
|
|
46
|
+
left: `calc((100% - ${1920 * scale}px) / 2)`,
|
|
47
|
+
backfaceVisibility: 'hidden',
|
|
48
|
+
WebkitBackfaceVisibility: 'hidden',
|
|
49
|
+
} }, `slide-${slide.number}-${refreshTimestamp}-${showEditor}`) }) }));
|
|
50
|
+
}, (prevProps, nextProps) => {
|
|
51
|
+
// Custom comparison function - only re-render if slide number or file_path changes
|
|
52
|
+
// (extended with the now-explicit stage props; the iframe element itself
|
|
53
|
+
// remounts only through its key).
|
|
54
|
+
return (prevProps.slide.number === nextProps.slide.number &&
|
|
55
|
+
prevProps.slide.file_path === nextProps.slide.file_path &&
|
|
56
|
+
prevProps.sandboxUrl === nextProps.sandboxUrl &&
|
|
57
|
+
prevProps.subdomainOpts === nextProps.subdomainOpts &&
|
|
58
|
+
prevProps.refreshTimestamp === nextProps.refreshTimestamp &&
|
|
59
|
+
prevProps.showEditor === nextProps.showEditor);
|
|
60
|
+
});
|
|
61
|
+
SlideIframe.displayName = 'SlideIframe';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface SlideMetadata {
|
|
2
|
+
title: string;
|
|
3
|
+
filename: string;
|
|
4
|
+
file_path: string;
|
|
5
|
+
preview_url: string;
|
|
6
|
+
created_at: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PresentationMetadata {
|
|
9
|
+
presentation_name: string;
|
|
10
|
+
title: string;
|
|
11
|
+
description: string;
|
|
12
|
+
slides: Record<string, SlideMetadata>;
|
|
13
|
+
created_at: string;
|
|
14
|
+
updated_at: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The fullscreen viewer's metadata lifecycle: the fetch (with cache busting),
|
|
18
|
+
* its unbounded retry with exponential backoff, the reload when the modal
|
|
19
|
+
* opens and when the editor closes, and the cleanup of a pending retry.
|
|
20
|
+
*/
|
|
21
|
+
export declare function usePresentationMetadata({ isOpen, presentationName, sandboxUrl, showEditor, }: {
|
|
22
|
+
isOpen: boolean;
|
|
23
|
+
presentationName?: string;
|
|
24
|
+
sandboxUrl?: string;
|
|
25
|
+
showEditor: boolean;
|
|
26
|
+
}): {
|
|
27
|
+
metadata: PresentationMetadata | null;
|
|
28
|
+
slides: {
|
|
29
|
+
title: string;
|
|
30
|
+
filename: string;
|
|
31
|
+
file_path: string;
|
|
32
|
+
preview_url: string;
|
|
33
|
+
created_at: string;
|
|
34
|
+
number: number;
|
|
35
|
+
}[];
|
|
36
|
+
isLoading: boolean;
|
|
37
|
+
retryAttempt: number;
|
|
38
|
+
subdomainOpts: import("@kortix/sdk").SubdomainUrlOptions;
|
|
39
|
+
};
|