@open-slide/core 1.19.0 → 2.0.0-beta.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 (100) hide show
  1. package/dist/{build-CaV_vhIw.js → build-CfAxF6Dm.js} +2 -5
  2. package/dist/cli/bin.d.ts +1 -1
  3. package/dist/cli/bin.js +139 -13
  4. package/dist/{config-CDHB8Oow.d.ts → config-AtA2Bqtn.d.ts} +4 -4
  5. package/dist/{config-GA6NMgs_.js → config-C_VI2EpT.js} +545 -776
  6. package/dist/{design-cpzS8aud.js → design-Cpqx7SJs.js} +1 -2
  7. package/dist/{dev-D57ui2yV.js → dev-BChELmc-.js} +4 -7
  8. package/dist/index.d.ts +7 -37
  9. package/dist/index.js +51 -54
  10. package/dist/locale/index.d.ts +2 -8
  11. package/dist/locale/index.js +13 -3
  12. package/dist/{preview-D40Zw_o0.js → preview-CcCQa268.js} +3 -7
  13. package/dist/{types-8HghULIe.d.ts → types-BzPSOxe-.d.ts} +5 -9
  14. package/dist/vite/index.d.ts +1 -4
  15. package/dist/vite/index.js +2 -4
  16. package/dist/{format-74A3B6zu.js → zh-tw-BxZ_pYqe.js} +13 -49
  17. package/package.json +12 -12
  18. package/skills/create-slide/SKILL.md +4 -1
  19. package/skills/slide-authoring/SKILL.md +25 -2
  20. package/src/app/app.tsx +18 -15
  21. package/src/app/assets/open-slide.png +0 -0
  22. package/src/app/components/asset-view.tsx +46 -39
  23. package/src/app/components/command/command-menu.tsx +5 -1
  24. package/src/app/components/command/command.tsx +4 -2
  25. package/src/app/components/command/home-command-menu.tsx +6 -6
  26. package/src/app/components/export-progress-toast.tsx +80 -0
  27. package/src/app/components/history-provider.tsx +1 -5
  28. package/src/app/components/icon-tooltip.tsx +24 -15
  29. package/src/app/components/image-placeholder.tsx +4 -12
  30. package/src/app/components/inspector/asset-picker-dialog.tsx +24 -32
  31. package/src/app/components/inspector/comment-widget.tsx +33 -7
  32. package/src/app/components/inspector/image-crop-dialog.tsx +9 -6
  33. package/src/app/components/inspector/inline-text-editor.tsx +798 -0
  34. package/src/app/components/inspector/inspect-overlay.tsx +35 -76
  35. package/src/app/components/inspector/inspector-panel.tsx +31 -53
  36. package/src/app/components/inspector/inspector-provider.tsx +53 -36
  37. package/src/app/components/language-toggle.tsx +2 -3
  38. package/src/app/components/notes-drawer.tsx +4 -7
  39. package/src/app/components/overview-grid.tsx +15 -8
  40. package/src/app/components/panel/panel-shell.tsx +1 -3
  41. package/src/app/components/panel/save-card.tsx +12 -3
  42. package/src/app/components/player.tsx +5 -6
  43. package/src/app/components/present/blackout-overlay.tsx +16 -3
  44. package/src/app/components/present/control-bar.tsx +21 -13
  45. package/src/app/components/present/jump-input.tsx +27 -5
  46. package/src/app/components/present/laser-pointer.tsx +34 -11
  47. package/src/app/components/present/progress-bar.tsx +1 -1
  48. package/src/app/components/present/use-presenter-channel.ts +0 -1
  49. package/src/app/components/present/use-touch-swipe.ts +9 -2
  50. package/src/app/components/sidebar/folder-item.tsx +48 -21
  51. package/src/app/components/sidebar/icon-picker.tsx +1 -1
  52. package/src/app/components/sidebar/sidebar-footer.tsx +20 -7
  53. package/src/app/components/sidebar/sidebar.tsx +91 -64
  54. package/src/app/components/slide-canvas.tsx +2 -6
  55. package/src/app/components/slide-transition-layer.tsx +48 -76
  56. package/src/app/components/style-panel/design-provider.tsx +1 -14
  57. package/src/app/components/style-panel/style-panel.tsx +16 -12
  58. package/src/app/components/style-panel/use-design.ts +1 -28
  59. package/src/app/components/theme-toggle.tsx +4 -5
  60. package/src/app/components/themes/theme-detail.tsx +11 -8
  61. package/src/app/components/themes/themes-gallery.tsx +13 -8
  62. package/src/app/components/thumbnail-rail.tsx +14 -15
  63. package/src/app/index.html +21 -0
  64. package/src/app/lib/assets.ts +6 -7
  65. package/src/app/lib/dom.ts +42 -0
  66. package/src/app/lib/export-html.ts +10 -25
  67. package/src/app/lib/export-pdf.ts +11 -28
  68. package/src/app/lib/export-pptx.ts +6 -36
  69. package/src/app/lib/folders.ts +51 -46
  70. package/src/app/lib/inspector/inline-text.ts +31 -0
  71. package/src/app/lib/inspector/pick-target.ts +38 -0
  72. package/src/app/lib/inspector/use-comments.ts +1 -1
  73. package/src/app/lib/keys.ts +18 -0
  74. package/src/app/lib/last-home-location.ts +18 -0
  75. package/src/app/lib/print-ready.ts +2 -4
  76. package/src/app/lib/slides.ts +7 -4
  77. package/src/app/lib/text-diff.ts +19 -0
  78. package/src/app/lib/use-click-page-navigation.ts +2 -6
  79. package/src/app/lib/use-is-mobile.ts +2 -14
  80. package/src/app/lib/use-media-query.ts +20 -0
  81. package/src/app/lib/use-prefers-reduced-motion.ts +5 -13
  82. package/src/app/lib/use-slide-module.ts +1 -1
  83. package/src/app/lib/use-wheel-page-navigation.ts +1 -1
  84. package/src/app/lib/utils.test.ts +25 -1
  85. package/src/app/lib/utils.ts +8 -0
  86. package/src/app/routes/home-shell.tsx +71 -64
  87. package/src/app/routes/home.tsx +50 -58
  88. package/src/app/routes/presenter.tsx +14 -23
  89. package/src/app/routes/slide.tsx +90 -77
  90. package/src/app/routes/themes.tsx +7 -8
  91. package/src/app/styles.css +40 -44
  92. package/src/locale/en.ts +2 -7
  93. package/src/locale/ja.ts +2 -7
  94. package/src/locale/types.ts +2 -7
  95. package/src/locale/zh-cn.ts +2 -7
  96. package/src/locale/zh-tw.ts +2 -7
  97. package/dist/sync-BCJDRIqo.js +0 -139
  98. package/dist/sync-j9_QPovT.js +0 -3
  99. package/src/app/components/pdf-progress-toast.tsx +0 -32
  100. package/src/app/components/pptx-progress-toast.tsx +0 -32
@@ -1,11 +1,11 @@
1
- import { Image as ImageIcon, Palette, Presentation } from 'lucide-react';
1
+ import { Presentation } from 'lucide-react';
2
2
  import { useMemo } from 'react';
3
3
  import { useNavigate } from 'react-router-dom';
4
4
  import { useLocale } from '@/lib/use-locale';
5
5
  import { useSlideTitles } from '@/lib/use-slide-titles';
6
6
  import type { Folder } from '../../lib/sdk';
7
7
  import { slideIds } from '../../lib/slides';
8
- import { FolderIconChip } from '../sidebar/folder-item';
8
+ import { FolderIconChip, SystemViewIcon } from '../sidebar/folder-item';
9
9
  import { ALL_SLIDES_ID, ASSETS_ID, DRAFT_ID, THEMES_ID } from '../sidebar/sidebar';
10
10
  import { type CommandGroupSpec, CommandMenu, type CommandSpec } from './command-menu';
11
11
 
@@ -39,14 +39,14 @@ export function HomeCommandMenu({
39
39
  {
40
40
  id: `view-${ALL_SLIDES_ID}`,
41
41
  label: t.home.slides,
42
- icon: <FolderIconChip icon={{ type: 'emoji', value: '🎞️' }} />,
42
+ icon: <SystemViewIcon kind="all" />,
43
43
  keywords: ['all', 'slides'],
44
44
  run: () => onSelectView(ALL_SLIDES_ID),
45
45
  },
46
46
  {
47
47
  id: `view-${DRAFT_ID}`,
48
48
  label: t.home.draft,
49
- icon: <FolderIconChip icon={{ type: 'emoji', value: '📝' }} />,
49
+ icon: <SystemViewIcon kind="draft" />,
50
50
  keywords: ['draft', 'unsorted'],
51
51
  run: () => onSelectView(DRAFT_ID),
52
52
  },
@@ -63,7 +63,7 @@ export function HomeCommandMenu({
63
63
  {
64
64
  id: `view-${THEMES_ID}`,
65
65
  label: t.home.themes,
66
- icon: <Palette />,
66
+ icon: <SystemViewIcon kind="themes" />,
67
67
  keywords: ['themes', 'design'],
68
68
  run: () => onSelectView(THEMES_ID),
69
69
  },
@@ -72,7 +72,7 @@ export function HomeCommandMenu({
72
72
  navigation.push({
73
73
  id: `view-${ASSETS_ID}`,
74
74
  label: t.home.assets,
75
- icon: <ImageIcon />,
75
+ icon: <SystemViewIcon kind="assets" />,
76
76
  keywords: ['assets', 'images', 'files'],
77
77
  run: () => onSelectView(ASSETS_ID),
78
78
  });
@@ -0,0 +1,80 @@
1
+ import { Check, Loader2 } from 'lucide-react';
2
+ import { format, useLocale } from '@/lib/use-locale';
3
+ import { pad2 } from '@/lib/utils';
4
+ import type { PdfExportProgress } from '../lib/export-pdf';
5
+ import type { PptxExportProgress } from '../lib/export-pptx';
6
+ import { Progress } from './ui/progress';
7
+
8
+ function ExportProgressToast({
9
+ title,
10
+ text,
11
+ done,
12
+ percent,
13
+ }: {
14
+ title: string;
15
+ text: string;
16
+ done: boolean;
17
+ percent: number;
18
+ }) {
19
+ return (
20
+ <div className="flex w-80 items-start gap-3 rounded-[8px] border border-border bg-popover px-3.5 py-3 text-popover-foreground shadow-floating">
21
+ {done ? (
22
+ <Check className="mt-0.5 size-3.5 shrink-0 text-[oklch(0.55_0.13_165)]" strokeWidth={2.5} />
23
+ ) : (
24
+ <Loader2 className="mt-0.5 size-3.5 shrink-0 animate-spin text-brand motion-reduce:animate-none" />
25
+ )}
26
+ <div className="min-w-0 flex-1">
27
+ <p className="font-heading text-[12.5px] font-semibold tracking-tight">{title}</p>
28
+ <p className="nums truncate font-mono text-[10.5px] tracking-[0.04em] text-muted-foreground">
29
+ {text}
30
+ </p>
31
+ <Progress value={Math.round(percent)} className="mt-2 h-[3px]" />
32
+ </div>
33
+ </div>
34
+ );
35
+ }
36
+
37
+ function pageCounts(progress: { current: number; total: number }) {
38
+ return {
39
+ current: pad2(progress.current),
40
+ total: pad2(progress.total),
41
+ };
42
+ }
43
+
44
+ export function PdfProgressToast({ progress }: { progress: PdfExportProgress }) {
45
+ const t = useLocale();
46
+ const text =
47
+ progress.phase === 'processing'
48
+ ? format(t.pdfToast.processing, pageCounts(progress))
49
+ : progress.phase === 'printing'
50
+ ? t.pdfToast.printing
51
+ : t.pdfToast.done;
52
+
53
+ return (
54
+ <ExportProgressToast
55
+ title={t.pdfToast.title}
56
+ text={text}
57
+ done={progress.phase === 'done'}
58
+ percent={progress.percent}
59
+ />
60
+ );
61
+ }
62
+
63
+ export function PptxProgressToast({ progress }: { progress: PptxExportProgress }) {
64
+ const t = useLocale();
65
+ const text =
66
+ progress.phase === 'processing'
67
+ ? format(t.pptxToast.processing, pageCounts(progress))
68
+ : progress.phase === 'generating'
69
+ ? t.pptxToast.generating
70
+ : t.pptxToast.done;
71
+
72
+ return (
73
+ <ExportProgressToast
74
+ title={t.pptxToast.title}
75
+ text={text}
76
+ done={progress.phase === 'done'}
77
+ percent={progress.percent}
78
+ />
79
+ );
80
+ }
@@ -22,7 +22,6 @@ type HistoryCtx = {
22
22
  undo: () => void;
23
23
  redo: () => void;
24
24
  clear: () => void;
25
- isSuppressed: () => boolean;
26
25
  };
27
26
 
28
27
  const COALESCE_WINDOW_MS = 500;
@@ -101,8 +100,6 @@ export function HistoryProvider({ children }: { children: ReactNode }) {
101
100
  setFuture([]);
102
101
  }, []);
103
102
 
104
- const isSuppressed = useCallback(() => suppressedRef.current, []);
105
-
106
103
  const value = useMemo<HistoryCtx>(
107
104
  () => ({
108
105
  canUndo: past.length > 0,
@@ -111,9 +108,8 @@ export function HistoryProvider({ children }: { children: ReactNode }) {
111
108
  undo,
112
109
  redo,
113
110
  clear,
114
- isSuppressed,
115
111
  }),
116
- [past.length, future.length, record, undo, redo, clear, isSuppressed],
112
+ [past.length, future.length, record, undo, redo, clear],
117
113
  );
118
114
 
119
115
  return <Ctx.Provider value={value}>{children}</Ctx.Provider>;
@@ -1,10 +1,19 @@
1
+ import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
1
2
  import type { ReactNode } from 'react';
2
- import { Tooltip, TooltipContent, TooltipProvider } from '@/components/ui/tooltip';
3
+ import { Tooltip, TooltipContent } from '@/components/ui/tooltip';
4
+
5
+ /**
6
+ * Tooltip trigger for a button that also opens a menu. The `ui/tooltip` wrapper
7
+ * is a plain function component, so on React 18 it swallows the ref that
8
+ * `DropdownMenuTrigger` hands to its `render` element and the menu never opens —
9
+ * the primitive forwards it.
10
+ */
11
+ export const MenuTooltipTrigger = TooltipPrimitive.Trigger;
3
12
 
4
13
  /**
5
14
  * Shared hover label for the toolbar icon buttons. `children` supplies the
6
15
  * `TooltipTrigger`; a button that also opens a menu has to compose it inward
7
- * (`<DropdownMenuTrigger render={<TooltipTrigger />}>`) — the other nesting
16
+ * (`<DropdownMenuTrigger render={<MenuTooltipTrigger />}>`) — the other nesting
8
17
  * order swallows the trigger ref and the tooltip never opens.
9
18
  */
10
19
  export function IconTooltip({
@@ -16,19 +25,19 @@ export function IconTooltip({
16
25
  shortcut?: string;
17
26
  children: ReactNode;
18
27
  }) {
28
+ // No local provider — tooltips join the app-level group so adjacent
29
+ // toolbar buttons open instantly once one tooltip is showing.
19
30
  return (
20
- <TooltipProvider delay={200}>
21
- <Tooltip>
22
- {children}
23
- <TooltipContent side="bottom" sideOffset={6} className="flex items-center gap-1.5">
24
- {label}
25
- {shortcut && (
26
- <kbd className="rounded-[3px] bg-background/18 px-1 py-0.5 font-mono text-[9.5px] tracking-[0.04em] text-background/85">
27
- {shortcut}
28
- </kbd>
29
- )}
30
- </TooltipContent>
31
- </Tooltip>
32
- </TooltipProvider>
31
+ <Tooltip>
32
+ {children}
33
+ <TooltipContent side="bottom" sideOffset={6} className="flex items-center gap-1.5">
34
+ {label}
35
+ {shortcut && (
36
+ <kbd className="rounded-[3px] bg-background/18 px-1 py-0.5 font-mono text-[9.5px] tracking-[0.04em] text-background/85">
37
+ {shortcut}
38
+ </kbd>
39
+ )}
40
+ </TooltipContent>
41
+ </Tooltip>
33
42
  );
34
43
  }
@@ -2,6 +2,7 @@ import { type CSSProperties, type HTMLAttributes, useRef, useState } from 'react
2
2
  import { toast } from 'sonner';
3
3
  import { uploadWithAutoRename } from '@/lib/assets';
4
4
  import { useLocale } from '@/lib/use-locale';
5
+ import { dragHasFiles } from '../lib/dom';
5
6
 
6
7
  export type ImagePlaceholderProps = {
7
8
  hint: string;
@@ -28,13 +29,13 @@ export function ImagePlaceholder({
28
29
  const dndProps = import.meta.env.DEV
29
30
  ? {
30
31
  onDragEnter: (e: React.DragEvent<HTMLDivElement>) => {
31
- if (uploading || !hasImageFile(e)) return;
32
+ if (uploading || !dragHasFiles(e)) return;
32
33
  e.preventDefault();
33
34
  dragDepth.current += 1;
34
35
  setDragActive(true);
35
36
  },
36
37
  onDragOver: (e: React.DragEvent<HTMLDivElement>) => {
37
- if (uploading || !hasImageFile(e)) return;
38
+ if (uploading || !dragHasFiles(e)) return;
38
39
  e.preventDefault();
39
40
  e.dataTransfer.dropEffect = 'copy';
40
41
  },
@@ -43,7 +44,7 @@ export function ImagePlaceholder({
43
44
  if (dragDepth.current === 0) setDragActive(false);
44
45
  },
45
46
  onDrop: (e: React.DragEvent<HTMLDivElement>) => {
46
- if (uploading || !hasImageFile(e)) return;
47
+ if (uploading || !dragHasFiles(e)) return;
47
48
  e.preventDefault();
48
49
  dragDepth.current = 0;
49
50
  setDragActive(false);
@@ -186,15 +187,6 @@ function DropOverlay({ label }: { label: string }) {
186
187
  );
187
188
  }
188
189
 
189
- function hasImageFile(e: React.DragEvent): boolean {
190
- const types = e.dataTransfer?.types;
191
- if (!types) return false;
192
- for (let i = 0; i < types.length; i++) {
193
- if (types[i] === 'Files') return true;
194
- }
195
- return false;
196
- }
197
-
198
190
  function pickImageFile(files: FileList): File | null {
199
191
  for (let i = 0; i < files.length; i++) {
200
192
  const f = files[i];
@@ -1,5 +1,4 @@
1
1
  import { ArrowDownToLine, Loader2, Upload } from 'lucide-react';
2
- import type React from 'react';
3
2
  import { useCallback, useId, useRef, useState } from 'react';
4
3
  import { toast } from 'sonner';
5
4
  import {
@@ -10,12 +9,12 @@ import {
10
9
  DialogTitle,
11
10
  } from '@/components/ui/dialog';
12
11
  import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
13
- import { type AssetEntry, uploadWithAutoRename, useAssets } from '@/lib/assets';
12
+ import { type AssetEntry, GLOBAL_ASSET_SCOPE, uploadWithAutoRename, useAssets } from '@/lib/assets';
13
+ import { dragHasFiles } from '@/lib/dom';
14
14
  import { format, useLocale } from '@/lib/use-locale';
15
15
  import { cn } from '@/lib/utils';
16
16
 
17
17
  export type PickerScope = 'slide' | 'global';
18
- const GLOBAL_PICKER_SLIDE_ID = '@global';
19
18
 
20
19
  export function AssetPickerDialog({
21
20
  slideId,
@@ -27,7 +26,7 @@ export function AssetPickerDialog({
27
26
  onPick: (asset: AssetEntry, scope: PickerScope) => void;
28
27
  }) {
29
28
  const [scope, setScope] = useState<PickerScope>('slide');
30
- const effectiveSlideId = scope === 'global' ? GLOBAL_PICKER_SLIDE_ID : slideId;
29
+ const effectiveSlideId = scope === 'global' ? GLOBAL_ASSET_SCOPE : slideId;
31
30
  const { assets, loading, refresh } = useAssets(effectiveSlideId);
32
31
  const images = assets.filter((a) => a.mime.startsWith('image/'));
33
32
  const t = useLocale();
@@ -83,7 +82,7 @@ export function AssetPickerDialog({
83
82
  )}
84
83
  >
85
84
  {uploading ? (
86
- <Loader2 className="size-3.5 animate-spin" />
85
+ <Loader2 className="size-3.5 animate-spin motion-reduce:animate-none" />
87
86
  ) : (
88
87
  <Upload className="size-3.5" />
89
88
  )}
@@ -105,13 +104,13 @@ export function AssetPickerDialog({
105
104
  aria-label={t.inspector.replaceImageDialogTitle}
106
105
  className="relative max-h-[60vh] overflow-y-auto"
107
106
  onDragEnter={(e) => {
108
- if (uploading || !hasFiles(e)) return;
107
+ if (uploading || !dragHasFiles(e)) return;
109
108
  e.preventDefault();
110
109
  dragDepth.current += 1;
111
110
  setDragActive(true);
112
111
  }}
113
112
  onDragOver={(e) => {
114
- if (uploading || !hasFiles(e)) return;
113
+ if (uploading || !dragHasFiles(e)) return;
115
114
  e.preventDefault();
116
115
  e.dataTransfer.dropEffect = 'copy';
117
116
  }}
@@ -120,7 +119,7 @@ export function AssetPickerDialog({
120
119
  if (dragDepth.current === 0) setDragActive(false);
121
120
  }}
122
121
  onDrop={(e) => {
123
- if (uploading || !hasFiles(e)) return;
122
+ if (uploading || !dragHasFiles(e)) return;
124
123
  e.preventDefault();
125
124
  dragDepth.current = 0;
126
125
  setDragActive(false);
@@ -144,8 +143,9 @@ export function AssetPickerDialog({
144
143
  type="button"
145
144
  onClick={() => onPick(asset, scope)}
146
145
  className={cn(
147
- 'group flex flex-col overflow-hidden rounded-lg border bg-card text-left shadow-sm transition-all',
148
- 'hover:-translate-y-0.5 hover:shadow-md focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none',
146
+ 'group flex flex-col overflow-hidden rounded-[8px] border bg-card text-left shadow-edge transition-[translate,scale,box-shadow,border-color] duration-150 ease-swift',
147
+ 'motion-safe:hover:-translate-y-0.5 hover:shadow-floating focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none',
148
+ 'motion-safe:active:translate-y-0 motion-safe:active:scale-[0.98]',
149
149
  )}
150
150
  >
151
151
  <div className="flex aspect-square w-full items-center justify-center overflow-hidden bg-[repeating-conic-gradient(theme(colors.muted)_0_25%,transparent_0_50%)] bg-[length:12px_12px]">
@@ -165,32 +165,24 @@ export function AssetPickerDialog({
165
165
  ))}
166
166
  </div>
167
167
  )}
168
- {dragActive && (
169
- <div
170
- className="pointer-events-none absolute inset-0 z-10 animate-in fade-in-0 duration-200"
171
- aria-hidden
172
- >
173
- <div className="absolute inset-0 bg-brand/5" />
174
- <div className="absolute inset-1 rounded-[8px] border border-dashed border-brand/40" />
175
- <div className="absolute inset-x-0 bottom-4 flex justify-center">
176
- <div className="flex items-center gap-2 rounded-[6px] border border-border bg-card px-3 py-1.5 text-[12px] font-medium shadow-floating">
177
- <ArrowDownToLine className="size-3.5 text-brand" />
178
- <span>{t.asset.dropToUpload}</span>
179
- </div>
168
+ <div
169
+ className={cn(
170
+ 'pointer-events-none absolute inset-0 z-10 motion-safe:transition-opacity motion-safe:duration-150',
171
+ dragActive ? 'opacity-100' : 'opacity-0',
172
+ )}
173
+ aria-hidden
174
+ >
175
+ <div className="absolute inset-0 bg-brand/5" />
176
+ <div className="absolute inset-1 rounded-[8px] border border-dashed border-brand/40" />
177
+ <div className="absolute inset-x-0 bottom-4 flex justify-center">
178
+ <div className="flex items-center gap-2 rounded-[6px] border border-border bg-card px-3 py-1.5 text-[12px] font-medium shadow-floating">
179
+ <ArrowDownToLine className="size-3.5 text-brand" />
180
+ <span>{t.asset.dropToUpload}</span>
180
181
  </div>
181
182
  </div>
182
- )}
183
+ </div>
183
184
  </section>
184
185
  </DialogContent>
185
186
  </Dialog>
186
187
  );
187
188
  }
188
-
189
- function hasFiles(e: React.DragEvent): boolean {
190
- const types = e.dataTransfer?.types;
191
- if (!types) return false;
192
- for (let i = 0; i < types.length; i++) {
193
- if (types[i] === 'Files') return true;
194
- }
195
- return false;
196
- }
@@ -1,6 +1,8 @@
1
1
  import { MessageSquare, Trash2, X } from 'lucide-react';
2
2
  import { useEffect, useRef, useState } from 'react';
3
+ import { usePanelMount } from '@/components/panel/panel-shell';
3
4
  import { format, plural, useLocale } from '@/lib/use-locale';
5
+ import { cn } from '@/lib/utils';
4
6
  import { useInspector } from './inspector-provider';
5
7
 
6
8
  export function CommentWidget() {
@@ -9,6 +11,9 @@ export function CommentWidget() {
9
11
  const [open, setOpen] = useState(false);
10
12
  const count = comments.length;
11
13
  const ref = useRef<HTMLDivElement>(null);
14
+ const panelRef = useRef<HTMLDivElement>(null);
15
+ const fabRef = useRef<HTMLButtonElement>(null);
16
+ const { mounted, animVisible } = usePanelMount(open);
12
17
 
13
18
  useEffect(() => {
14
19
  if (!open) return;
@@ -19,27 +24,45 @@ export function CommentWidget() {
19
24
  return () => document.removeEventListener('pointerdown', onPointerDown);
20
25
  }, [open]);
21
26
 
27
+ // The panel stays mounted through its close fade; hand focus back to the
28
+ // toggle so it doesn't sit on a control that's about to unmount.
29
+ useEffect(() => {
30
+ if (open) return;
31
+ if (panelRef.current?.contains(document.activeElement)) fabRef.current?.focus();
32
+ }, [open]);
33
+
22
34
  return (
23
35
  <div
24
36
  ref={ref}
25
37
  data-inspector-ui
26
38
  className="absolute right-4 bottom-4 z-20 flex flex-col items-end gap-2"
27
39
  >
28
- {open && (
29
- <div className="w-80 rounded-md border bg-card shadow-xl animate-in fade-in-0 slide-in-from-bottom-2 duration-200">
40
+ {mounted && (
41
+ <div
42
+ ref={panelRef}
43
+ aria-hidden={!animVisible}
44
+ className={cn(
45
+ 'w-80 origin-bottom-right rounded-[8px] border bg-card shadow-overlay',
46
+ 'motion-safe:transition-[opacity,translate,scale] motion-safe:duration-200 motion-safe:ease-swift',
47
+ animVisible
48
+ ? 'translate-y-0 scale-100 opacity-100'
49
+ : 'pointer-events-none translate-y-1.5 scale-95 opacity-0',
50
+ )}
51
+ >
30
52
  <div className="flex items-center justify-between border-b px-3 py-2">
31
53
  <span className="text-xs font-semibold">
32
54
  {format(plural(count, t.inspector.commentsCount), { count })}
33
55
  </span>
34
56
  <button
35
57
  type="button"
36
- className="text-muted-foreground hover:text-foreground"
58
+ aria-label={t.common.close}
59
+ className="-m-1 rounded-[5px] p-1 text-muted-foreground transition-[color,scale] duration-150 hover:text-foreground active:scale-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
37
60
  onClick={() => setOpen(false)}
38
61
  >
39
62
  <X className="size-3.5" />
40
63
  </button>
41
64
  </div>
42
- {error && <p className="px-3 py-2 text-xs text-red-600">{error}</p>}
65
+ {error && <p className="px-3 py-2 text-xs text-destructive">{error}</p>}
43
66
  {count === 0 ? (
44
67
  <p className="px-3 py-6 text-center text-xs text-muted-foreground">
45
68
  {t.inspector.commentsEmpty}
@@ -61,7 +84,8 @@ export function CommentWidget() {
61
84
  <button
62
85
  type="button"
63
86
  onClick={() => remove(c.id)}
64
- className="shrink-0 rounded p-1 text-muted-foreground hover:bg-muted hover:text-red-600"
87
+ className="shrink-0 rounded-[5px] p-1 text-muted-foreground transition-[color,background-color,scale] duration-150 hover:bg-muted hover:text-destructive active:scale-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
88
+ aria-label={t.inspector.commentDeleteAria}
65
89
  title={t.inspector.commentDeleteAria}
66
90
  >
67
91
  <Trash2 className="size-3.5" />
@@ -81,12 +105,14 @@ export function CommentWidget() {
81
105
  </div>
82
106
  )}
83
107
  <button
108
+ ref={fabRef}
84
109
  type="button"
85
110
  onClick={() => setOpen((o) => !o)}
86
- className="flex items-center gap-2 rounded-full border bg-card px-3 py-2 text-xs font-medium shadow-lg hover:bg-muted"
111
+ className="flex items-center gap-2 rounded-full border bg-card px-3 py-2 text-xs font-medium shadow-floating transition-[background-color,scale] duration-150 hover:bg-muted active:scale-[0.96] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
112
+ aria-expanded={open}
87
113
  >
88
114
  <MessageSquare className="size-4" />
89
- {count}
115
+ <span className="nums">{count}</span>
90
116
  </button>
91
117
  </div>
92
118
  );
@@ -1,5 +1,6 @@
1
1
  import { type SyntheticEvent, useEffect, useRef, useState } from 'react';
2
2
  import ReactCrop, { type Crop, type PercentCrop } from 'react-image-crop';
3
+ import { round2 } from '@/lib/utils';
3
4
  import 'react-image-crop/dist/ReactCrop.css';
4
5
  import { Button } from '@/components/ui/button';
5
6
  import {
@@ -95,7 +96,7 @@ export function ImageCropDialog({
95
96
  </ToggleGroupItem>
96
97
  </ToggleGroup>
97
98
  </div>
98
- <div className="flex h-[420px] w-full items-center justify-center overflow-hidden rounded-md border bg-[repeating-conic-gradient(theme(colors.muted)_0_25%,transparent_0_50%)] bg-[length:12px_12px]">
99
+ <div className="flex h-[420px] w-full touch-none select-none items-center justify-center overflow-hidden rounded-md border bg-[repeating-conic-gradient(theme(colors.muted)_0_25%,transparent_0_50%)] bg-[length:12px_12px]">
99
100
  {fit === 'cover' ? (
100
101
  <ReactCrop
101
102
  crop={crop}
@@ -108,12 +109,18 @@ export function ImageCropDialog({
108
109
  ref={imgRef}
109
110
  src={src}
110
111
  alt=""
112
+ draggable={false}
111
113
  style={{ maxHeight: 420, maxWidth: '100%' }}
112
114
  onLoad={onImageLoad}
113
115
  />
114
116
  </ReactCrop>
115
117
  ) : (
116
- <img src={src} alt="" className="max-h-full max-w-full object-contain" />
118
+ <img
119
+ src={src}
120
+ alt=""
121
+ draggable={false}
122
+ className="max-h-full max-w-full object-contain"
123
+ />
117
124
  )}
118
125
  </div>
119
126
  <DialogFooter>
@@ -206,7 +213,3 @@ function roundRect(crop: PercentCrop): ImageCropRect {
206
213
  function clamp(v: number, lo: number, hi: number) {
207
214
  return v < lo ? lo : v > hi ? hi : v;
208
215
  }
209
-
210
- function round2(n: number): number {
211
- return Math.round(n * 100) / 100;
212
- }