@open-slide/core 1.12.0 → 1.13.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 (34) hide show
  1. package/README.md +2 -0
  2. package/dist/{build-L2yL1hTo.js → build-OAZ8maw5.js} +1 -1
  3. package/dist/cli/bin.js +3 -3
  4. package/dist/{config-OT4T-im0.js → config-CU_NISD6.js} +49 -4
  5. package/dist/{config-C2C3cut3.d.ts → config-x493taft.d.ts} +1 -1
  6. package/dist/{dev-DJUpPCGT.js → dev-C78J1TLR.js} +1 -1
  7. package/dist/{format-zplQGJPI.js → format-7j0EzhuV.js} +4 -0
  8. package/dist/index.d.ts +31 -9
  9. package/dist/index.js +22 -2
  10. package/dist/locale/index.d.ts +1 -1
  11. package/dist/locale/index.js +1 -1
  12. package/dist/{preview-Bf8up6-P.js → preview-DZLZ3L9v.js} +1 -1
  13. package/dist/{types-uNHQlioH.d.ts → types-CHmFPIG_.d.ts} +1 -0
  14. package/dist/vite/index.d.ts +2 -2
  15. package/dist/vite/index.js +1 -1
  16. package/package.json +5 -5
  17. package/src/app/components/inspector/inspect-overlay.tsx +39 -18
  18. package/src/app/components/inspector/inspector-panel.tsx +5 -1
  19. package/src/app/components/inspector/inspector-provider.tsx +54 -6
  20. package/src/app/components/overview-grid.tsx +200 -69
  21. package/src/app/components/player.tsx +66 -3
  22. package/src/app/components/present/control-bar.tsx +99 -7
  23. package/src/app/components/shared-element.tsx +48 -0
  24. package/src/app/components/slide-canvas.tsx +24 -14
  25. package/src/app/components/slide-transition-layer.tsx +506 -4
  26. package/src/app/lib/export-html.ts +1 -1
  27. package/src/app/lib/transition.ts +7 -0
  28. package/src/app/lib/use-click-page-navigation.ts +10 -2
  29. package/src/app/routes/slide.tsx +175 -143
  30. package/src/locale/en.ts +1 -0
  31. package/src/locale/ja.ts +1 -0
  32. package/src/locale/types.ts +1 -0
  33. package/src/locale/zh-cn.ts +1 -0
  34. package/src/locale/zh-tw.ts +1 -0
@@ -15,6 +15,8 @@ type UseClickPageNavigationOptions<T extends HTMLElement> = {
15
15
  canNext: boolean;
16
16
  onPrev: () => void;
17
17
  onNext: () => void;
18
+ onCenterClick?: () => void;
19
+ onViewportClick?: (point: { x: number; y: number }) => void;
18
20
  };
19
21
 
20
22
  export function useClickPageNavigation<T extends HTMLElement>({
@@ -25,6 +27,8 @@ export function useClickPageNavigation<T extends HTMLElement>({
25
27
  canNext,
26
28
  onPrev,
27
29
  onNext,
30
+ onCenterClick,
31
+ onViewportClick,
28
32
  }: UseClickPageNavigationOptions<T>) {
29
33
  useEffect(() => {
30
34
  const el = ref.current;
@@ -33,20 +37,24 @@ export function useClickPageNavigation<T extends HTMLElement>({
33
37
  const onClick = (event: MouseEvent) => {
34
38
  if (event.button !== 0 || event.defaultPrevented) return;
35
39
  const target = event.target;
36
- if (target instanceof HTMLElement && target.closest(NAV_PASSTHROUGH)) return;
40
+ if (target instanceof Element && target.closest(NAV_PASSTHROUGH)) return;
37
41
  if (window.getSelection()?.toString()) return;
38
42
 
39
43
  const rect = el.getBoundingClientRect();
40
44
  if (rect.width === 0) return;
41
45
  const x = (event.clientX - rect.left) / rect.width;
46
+ const y = rect.height === 0 ? 0 : (event.clientY - rect.top) / rect.height;
47
+ onViewportClick?.({ x, y });
42
48
  if (x < edgeRatio) {
43
49
  if (canPrev) onPrev();
44
50
  } else if (x > 1 - edgeRatio) {
45
51
  if (canNext) onNext();
52
+ } else {
53
+ onCenterClick?.();
46
54
  }
47
55
  };
48
56
 
49
57
  el.addEventListener('click', onClick);
50
58
  return () => el.removeEventListener('click', onClick);
51
- }, [ref, enabled, edgeRatio, canPrev, canNext, onPrev, onNext]);
59
+ }, [ref, enabled, edgeRatio, canPrev, canNext, onPrev, onNext, onCenterClick, onViewportClick]);
52
60
  }
@@ -11,6 +11,7 @@ import {
11
11
  Loader2,
12
12
  Maximize,
13
13
  MonitorSpeaker,
14
+ MoreHorizontal,
14
15
  Play,
15
16
  Presentation,
16
17
  } from 'lucide-react';
@@ -85,6 +86,7 @@ export function Slide() {
85
86
  const { renameSlide } = useFolders();
86
87
  const slideViewportRef = useRef<HTMLElement>(null);
87
88
  const t = useLocale();
89
+ const isMobile = useIsMobile();
88
90
  const prefersReducedMotion = usePrefersReducedMotion();
89
91
 
90
92
  const modulePages = useMemo(() => slide?.default ?? [], [slide]);
@@ -376,6 +378,127 @@ export function Slide() {
376
378
 
377
379
  const title = slide.meta?.title ?? slideId;
378
380
 
381
+ const copyLink = async () => {
382
+ try {
383
+ await navigator.clipboard.writeText(window.location.href);
384
+ toast.success(t.slide.toastCopyLinkSuccess);
385
+ setLinkCopied(true);
386
+ if (linkCopiedTimerRef.current) clearTimeout(linkCopiedTimerRef.current);
387
+ linkCopiedTimerRef.current = setTimeout(() => setLinkCopied(false), 1200);
388
+ } catch (err) {
389
+ console.error('[open-slide] copy link failed', err);
390
+ toast.error(t.slide.toastCopyLinkFailed);
391
+ }
392
+ };
393
+
394
+ const exportHtml = async () => {
395
+ if (!slide || exporting) return;
396
+ setExporting(true);
397
+ try {
398
+ await exportSlideAsHtml(slide, slideId);
399
+ } catch (err) {
400
+ console.error('[open-slide] export failed', err);
401
+ } finally {
402
+ setExporting(false);
403
+ }
404
+ };
405
+
406
+ const exportPdf = async () => {
407
+ if (!slide || exporting) return;
408
+ if (isSafari()) {
409
+ toast.error(t.slide.pdfExportSafariUnsupported, { duration: 5000 });
410
+ return;
411
+ }
412
+ setExporting(true);
413
+ const toastId = `pdf-export-${slideId}`;
414
+ toast.custom(
415
+ () => (
416
+ <PdfProgressToast
417
+ progress={{ phase: 'processing', current: 0, total: pages.length, percent: 0 }}
418
+ />
419
+ ),
420
+ { id: toastId, duration: Infinity },
421
+ );
422
+ try {
423
+ await exportSlideAsPdf(slide, slideId, (p) => {
424
+ toast.custom(() => <PdfProgressToast progress={p} />, { id: toastId, duration: Infinity });
425
+ });
426
+ } catch (err) {
427
+ console.error('[open-slide] pdf export failed', err);
428
+ toast.error(t.slide.pdfExportFailed, { id: toastId, duration: 4000 });
429
+ } finally {
430
+ setExporting(false);
431
+ toast.dismiss(toastId);
432
+ }
433
+ };
434
+
435
+ const exportImagePptx = async () => {
436
+ if (!slide || exporting) return;
437
+ setExporting(true);
438
+ const toastId = `pptx-export-${slideId}`;
439
+ toast.custom(
440
+ () => (
441
+ <PptxProgressToast
442
+ progress={{ phase: 'processing', current: 0, total: pages.length, percent: 0 }}
443
+ />
444
+ ),
445
+ { id: toastId, duration: Infinity },
446
+ );
447
+ try {
448
+ await exportSlideAsImagePptx(slide, slideId, (p) => {
449
+ toast.custom(() => <PptxProgressToast progress={p} />, { id: toastId, duration: Infinity });
450
+ });
451
+ } catch (err) {
452
+ console.error('[open-slide] image pptx export failed', err);
453
+ toast.error(t.slide.imagePptxExportFailed, { id: toastId, duration: 4000 });
454
+ } finally {
455
+ setExporting(false);
456
+ toast.dismiss(toastId);
457
+ }
458
+ };
459
+
460
+ const exportMenuItems = (
461
+ <>
462
+ <DropdownMenuItem disabled={exporting} onSelect={exportHtml}>
463
+ <FileCode2 />
464
+ {t.slide.exportAsHtml}
465
+ </DropdownMenuItem>
466
+ <DropdownMenuItem disabled={exporting} onSelect={exportPdf}>
467
+ <FileText />
468
+ {t.slide.exportAsPdf}
469
+ </DropdownMenuItem>
470
+ <DropdownMenuSeparator />
471
+ <DropdownMenuItem disabled={exporting} onSelect={exportImagePptx}>
472
+ <FileImage />
473
+ {t.slide.exportAsImagePptx}
474
+ </DropdownMenuItem>
475
+ <TooltipProvider delayDuration={200}>
476
+ <Tooltip>
477
+ <TooltipTrigger asChild>
478
+ <div
479
+ aria-disabled
480
+ className="relative flex cursor-help items-center justify-between gap-2 rounded-[5px] px-2 py-1.5 text-[12.5px] opacity-45 select-none [&_svg]:size-3.5 [&_svg]:shrink-0 [&_svg]:opacity-80"
481
+ >
482
+ <span className="flex items-center gap-2">
483
+ <Presentation />
484
+ {t.slide.exportAsPptx}
485
+ </span>
486
+ <span className="rounded-[3px] bg-muted px-1.5 py-0.5 font-mono text-[9.5px] tracking-[0.04em] text-muted-foreground">
487
+ {t.slide.comingSoon}
488
+ </span>
489
+ </div>
490
+ </TooltipTrigger>
491
+ <TooltipContent
492
+ side="left"
493
+ className="w-max max-w-[min(520px,calc(100vw-2rem))] text-center leading-relaxed"
494
+ >
495
+ {t.slide.pptxComingSoonTooltip}
496
+ </TooltipContent>
497
+ </Tooltip>
498
+ </TooltipProvider>
499
+ </>
500
+ );
501
+
379
502
  return (
380
503
  <HistoryProvider>
381
504
  <InspectorProvider slideId={slideId} pageIndex={index}>
@@ -383,7 +506,7 @@ export function Slide() {
383
506
  <div className="flex h-dvh flex-col overflow-hidden bg-background text-foreground">
384
507
  {/* Editorial toolbar — three zones, hairline separators, mono-folio center */}
385
508
  <header className="relative flex h-12 shrink-0 items-center gap-2 border-b border-hairline bg-sidebar/85 px-2 backdrop-blur-md md:px-3">
386
- <div className="flex shrink-0 items-center gap-1.5 md:gap-2">
509
+ <div className="flex flex-1 items-center gap-1.5 md:flex-none md:gap-2">
387
510
  {showSlideBrowser && (
388
511
  <Button asChild variant="ghost" size="icon-sm" title={t.slide.home}>
389
512
  <Link to="/" aria-label={t.slide.backToHome}>
@@ -416,32 +539,26 @@ export function Slide() {
416
539
  {import.meta.env.DEV && <AgentConnectedBadge />}
417
540
  </div>
418
541
 
419
- {/* Title centered to the viewport, not the leftover space between the side groups. */}
420
- <div className="pointer-events-none absolute inset-x-0 flex justify-center px-2">
542
+ {/* On md+ the title centers to the viewport via absolute positioning. On mobile the
543
+ two side groups each flex-1, so the in-flow title lands at the viewport center too —
544
+ and min-w-0 lets it truncate instead of overlapping the icons on narrow widths. */}
545
+ <div className="pointer-events-none relative flex min-w-0 justify-center px-2 md:absolute md:inset-x-0">
421
546
  <div className="pointer-events-auto min-w-0 max-w-[34rem]">
422
547
  <InlineTitleEditor title={title} onSubmit={(next) => renameSlide(slideId, next)} />
423
548
  </div>
424
549
  </div>
425
550
 
426
- <div className="ml-auto flex shrink-0 items-center gap-1">
551
+ <div className="flex flex-1 items-center justify-end gap-1 md:ml-auto md:flex-none">
427
552
  {view === 'slides' && (
428
553
  <button
429
554
  type="button"
430
555
  aria-label={t.slide.copyLink}
431
556
  title={t.slide.copyLink}
432
- className={cn(buttonVariants({ variant: 'ghost', size: 'icon-sm' }))}
433
- onClick={async () => {
434
- try {
435
- await navigator.clipboard.writeText(window.location.href);
436
- toast.success(t.slide.toastCopyLinkSuccess);
437
- setLinkCopied(true);
438
- if (linkCopiedTimerRef.current) clearTimeout(linkCopiedTimerRef.current);
439
- linkCopiedTimerRef.current = setTimeout(() => setLinkCopied(false), 1200);
440
- } catch (err) {
441
- console.error('[open-slide] copy link failed', err);
442
- toast.error(t.slide.toastCopyLinkFailed);
443
- }
444
- }}
557
+ className={cn(
558
+ buttonVariants({ variant: 'ghost', size: 'icon-sm' }),
559
+ 'hidden md:inline-flex',
560
+ )}
561
+ onClick={copyLink}
445
562
  >
446
563
  <span className="relative grid size-4 place-items-center">
447
564
  <Link2
@@ -466,7 +583,10 @@ export function Slide() {
466
583
  disabled={exporting}
467
584
  aria-label={t.slide.download}
468
585
  title={t.slide.download}
469
- className={cn(buttonVariants({ variant: 'ghost', size: 'icon-sm' }))}
586
+ className={cn(
587
+ buttonVariants({ variant: 'ghost', size: 'icon-sm' }),
588
+ 'hidden md:inline-flex',
589
+ )}
470
590
  >
471
591
  {exporting ? (
472
592
  <Loader2 className="size-4 animate-spin" />
@@ -475,128 +595,35 @@ export function Slide() {
475
595
  )}
476
596
  </DropdownMenuTrigger>
477
597
  <DropdownMenuContent align="end" className="min-w-[200px]">
478
- <DropdownMenuItem
479
- disabled={exporting}
480
- onSelect={async () => {
481
- if (!slide || exporting) return;
482
- setExporting(true);
483
- try {
484
- await exportSlideAsHtml(slide, slideId);
485
- } catch (err) {
486
- console.error('[open-slide] export failed', err);
487
- } finally {
488
- setExporting(false);
489
- }
490
- }}
491
- >
492
- <FileCode2 />
493
- {t.slide.exportAsHtml}
494
- </DropdownMenuItem>
495
- <DropdownMenuItem
496
- disabled={exporting}
497
- onSelect={async () => {
498
- if (!slide || exporting) return;
499
- if (isSafari()) {
500
- toast.error(t.slide.pdfExportSafariUnsupported, { duration: 5000 });
501
- return;
502
- }
503
- setExporting(true);
504
- const toastId = `pdf-export-${slideId}`;
505
- toast.custom(
506
- () => (
507
- <PdfProgressToast
508
- progress={{
509
- phase: 'processing',
510
- current: 0,
511
- total: pages.length,
512
- percent: 0,
513
- }}
514
- />
515
- ),
516
- { id: toastId, duration: Infinity },
517
- );
518
- try {
519
- await exportSlideAsPdf(slide, slideId, (p) => {
520
- toast.custom(() => <PdfProgressToast progress={p} />, {
521
- id: toastId,
522
- duration: Infinity,
523
- });
524
- });
525
- } catch (err) {
526
- console.error('[open-slide] pdf export failed', err);
527
- toast.error(t.slide.pdfExportFailed, { id: toastId, duration: 4000 });
528
- } finally {
529
- setExporting(false);
530
- toast.dismiss(toastId);
531
- }
532
- }}
533
- >
534
- <FileText />
535
- {t.slide.exportAsPdf}
536
- </DropdownMenuItem>
537
- <DropdownMenuSeparator />
538
- <DropdownMenuItem
539
- disabled={exporting}
540
- onSelect={async () => {
541
- if (!slide || exporting) return;
542
- setExporting(true);
543
- const toastId = `pptx-export-${slideId}`;
544
- toast.custom(
545
- () => (
546
- <PptxProgressToast
547
- progress={{
548
- phase: 'processing',
549
- current: 0,
550
- total: pages.length,
551
- percent: 0,
552
- }}
553
- />
554
- ),
555
- { id: toastId, duration: Infinity },
556
- );
557
- try {
558
- await exportSlideAsImagePptx(slide, slideId, (p) => {
559
- toast.custom(() => <PptxProgressToast progress={p} />, {
560
- id: toastId,
561
- duration: Infinity,
562
- });
563
- });
564
- } catch (err) {
565
- console.error('[open-slide] image pptx export failed', err);
566
- toast.error(t.slide.imagePptxExportFailed, {
567
- id: toastId,
568
- duration: 4000,
569
- });
570
- } finally {
571
- setExporting(false);
572
- toast.dismiss(toastId);
573
- }
574
- }}
575
- >
576
- <FileImage />
577
- {t.slide.exportAsImagePptx}
598
+ {exportMenuItems}
599
+ </DropdownMenuContent>
600
+ </DropdownMenu>
601
+ )}
602
+ {view === 'slides' && (
603
+ <DropdownMenu>
604
+ <DropdownMenuTrigger
605
+ type="button"
606
+ disabled={exporting}
607
+ aria-label={t.slide.moreActions}
608
+ title={t.slide.moreActions}
609
+ className={cn(
610
+ buttonVariants({ variant: 'ghost', size: 'icon-sm' }),
611
+ 'inline-flex md:hidden',
612
+ )}
613
+ >
614
+ {exporting ? (
615
+ <Loader2 className="size-4 animate-spin" />
616
+ ) : (
617
+ <MoreHorizontal className="size-4" />
618
+ )}
619
+ </DropdownMenuTrigger>
620
+ <DropdownMenuContent align="end" className="min-w-[200px]">
621
+ <DropdownMenuItem onSelect={copyLink}>
622
+ <Link2 />
623
+ {t.slide.copyLink}
578
624
  </DropdownMenuItem>
579
- <TooltipProvider delayDuration={200}>
580
- <Tooltip>
581
- <TooltipTrigger asChild>
582
- <div
583
- aria-disabled
584
- className="relative flex cursor-help items-center justify-between gap-2 rounded-[5px] px-2 py-1.5 text-[12.5px] opacity-45 select-none [&_svg]:size-3.5 [&_svg]:shrink-0 [&_svg]:opacity-80"
585
- >
586
- <span className="flex items-center gap-2">
587
- <Presentation />
588
- {t.slide.exportAsPptx}
589
- </span>
590
- <span className="rounded-[3px] bg-muted px-1.5 py-0.5 font-mono text-[9.5px] tracking-[0.04em] text-muted-foreground">
591
- {t.slide.comingSoon}
592
- </span>
593
- </div>
594
- </TooltipTrigger>
595
- <TooltipContent side="left" className="max-w-[240px] leading-relaxed">
596
- {t.slide.pptxComingSoonTooltip}
597
- </TooltipContent>
598
- </Tooltip>
599
- </TooltipProvider>
625
+ {allowHtmlDownload && <DropdownMenuSeparator />}
626
+ {allowHtmlDownload && exportMenuItems}
600
627
  </DropdownMenuContent>
601
628
  </DropdownMenu>
602
629
  )}
@@ -610,8 +637,8 @@ export function Slide() {
610
637
  <Button
611
638
  size="sm"
612
639
  variant="brand"
613
- onClick={() => setPlayMode('fullscreen')}
614
- className="rounded-r-none px-2.5 md:px-3"
640
+ onClick={() => setPlayMode(isMobile ? 'window' : 'fullscreen')}
641
+ className="px-2.5 md:rounded-r-none md:px-3"
615
642
  >
616
643
  <Play className="size-3.5 fill-current" />
617
644
  <span className="hidden md:inline">{t.slide.present}</span>
@@ -626,7 +653,7 @@ export function Slide() {
626
653
  title={t.slide.presentMenuAria}
627
654
  className={cn(
628
655
  buttonVariants({ variant: 'brand', size: 'sm' }),
629
- 'rounded-l-none px-1.5 shadow-[inset_1px_0_0_oklch(0_0_0/0.12),inset_0_1px_0_oklch(1_0_0/0.18),0_1px_0_oklch(0_0_0/0.16)]',
656
+ 'hidden rounded-l-none px-1.5 shadow-[inset_1px_0_0_oklch(0_0_0/0.12),inset_0_1px_0_oklch(1_0_0/0.18),0_1px_0_oklch(0_0_0/0.16)] md:inline-flex',
630
657
  )}
631
658
  >
632
659
  <ChevronDown className="size-3.5" />
@@ -737,6 +764,7 @@ export function Slide() {
737
764
  onClose={() => setOverviewOpen(false)}
738
765
  onSelect={goTo}
739
766
  variant="editor"
767
+ moduleTransition={slide.transition}
740
768
  />
741
769
  </div>
742
770
  </DesignProvider>
@@ -896,7 +924,11 @@ function AgentConnectedBadge() {
896
924
  {connected ? t.slide.agentConnected : t.slide.agentDisconnected}
897
925
  </button>
898
926
  </TooltipTrigger>
899
- <TooltipContent side="bottom" align="start" className="max-w-[280px] leading-relaxed">
927
+ <TooltipContent
928
+ side="bottom"
929
+ align="start"
930
+ className="w-max max-w-[min(520px,calc(100vw-2rem))] text-center leading-relaxed"
931
+ >
900
932
  {connected ? t.slide.agentConnectedTooltip : t.slide.agentDisconnectedTooltip}
901
933
  </TooltipContent>
902
934
  </Tooltip>
package/src/locale/en.ts CHANGED
@@ -106,6 +106,7 @@ export const en: Locale = {
106
106
  'Lost connection to the dev server, so your agent can no longer see the current slide or inspector selection. Restart the dev server to restore the connection.',
107
107
  download: 'Download',
108
108
  copyLink: 'Copy link',
109
+ moreActions: 'More actions',
109
110
  toastCopyLinkSuccess: 'Link copied to clipboard',
110
111
  toastCopyLinkFailed: 'Failed to copy link',
111
112
  exportAsHtml: 'Export as HTML',
package/src/locale/ja.ts CHANGED
@@ -107,6 +107,7 @@ export const ja: Locale = {
107
107
  backToHome: 'ホームへ戻る',
108
108
  download: 'ダウンロード',
109
109
  copyLink: 'リンクをコピー',
110
+ moreActions: 'その他の操作',
110
111
  toastCopyLinkSuccess: 'リンクをクリップボードにコピーしました',
111
112
  toastCopyLinkFailed: 'リンクのコピーに失敗しました',
112
113
  exportAsHtml: 'HTML として書き出し',
@@ -108,6 +108,7 @@ export type Locale = {
108
108
  agentDisconnectedTooltip: string;
109
109
  download: string;
110
110
  copyLink: string;
111
+ moreActions: string;
111
112
  toastCopyLinkSuccess: string;
112
113
  toastCopyLinkFailed: string;
113
114
  exportAsHtml: string;
@@ -105,6 +105,7 @@ export const zhCN: Locale = {
105
105
  backToHome: '返回首页',
106
106
  download: '下载',
107
107
  copyLink: '复制链接',
108
+ moreActions: '更多操作',
108
109
  toastCopyLinkSuccess: '已复制链接到剪贴板',
109
110
  toastCopyLinkFailed: '复制链接失败',
110
111
  exportAsHtml: '导出为 HTML',
@@ -105,6 +105,7 @@ export const zhTW: Locale = {
105
105
  backToHome: '返回首頁',
106
106
  download: '下載',
107
107
  copyLink: '複製連結',
108
+ moreActions: '更多動作',
108
109
  toastCopyLinkSuccess: '已複製連結到剪貼簿',
109
110
  toastCopyLinkFailed: '複製連結失敗',
110
111
  exportAsHtml: '匯出為 HTML',