@arbidocs/blocks 0.5.122 → 0.5.124

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 (124) hide show
  1. package/dist/{ClippingMediaViewer-IEIBT74X.cjs → ClippingMediaViewer-ZFEX5A3U.cjs} +11 -10
  2. package/dist/ClippingMediaViewer-ZFEX5A3U.cjs.map +1 -0
  3. package/dist/{ClippingPdfViewer-OGYLMVCE.cjs → ClippingPdfViewer-3LRTEPHV.cjs} +45 -11
  4. package/dist/ClippingPdfViewer-3LRTEPHV.cjs.map +1 -0
  5. package/dist/{ConnectedPresentation-AU25OW25.cjs → ConnectedPresentation-OV2KBOLK.cjs} +27 -153
  6. package/dist/ConnectedPresentation-OV2KBOLK.cjs.map +1 -0
  7. package/dist/{ConnectedSlidesTab-I75LKKN7.cjs → ConnectedSlidesTab-LUAGZ6FD.cjs} +60 -36
  8. package/dist/ConnectedSlidesTab-LUAGZ6FD.cjs.map +1 -0
  9. package/dist/{FilesViewerDialog-4352KIOG.cjs → FilesViewerDialog-JWKNJLWG.cjs} +10 -7
  10. package/dist/FilesViewerDialog-JWKNJLWG.cjs.map +1 -0
  11. package/dist/SpotlightStrip-ED22UYTM.cjs +398 -0
  12. package/dist/SpotlightStrip-ED22UYTM.cjs.map +1 -0
  13. package/dist/{chunk-LHWOKOMP.cjs → chunk-3IH55CDE.cjs} +4 -4
  14. package/dist/chunk-3IH55CDE.cjs.map +1 -0
  15. package/dist/chunk-3ZZZO4F7.cjs +145 -0
  16. package/dist/chunk-3ZZZO4F7.cjs.map +1 -0
  17. package/dist/{chunk-WFMWKPGY.cjs → chunk-ADPRIBSH.cjs} +9 -33
  18. package/dist/chunk-ADPRIBSH.cjs.map +1 -0
  19. package/dist/{chunk-UTJ223TI.cjs → chunk-BX6G2ZCI.cjs} +138 -146
  20. package/dist/chunk-BX6G2ZCI.cjs.map +1 -0
  21. package/dist/{chunk-WRLGLZIA.cjs → chunk-EMRY62HS.cjs} +2 -2
  22. package/dist/{chunk-WRLGLZIA.cjs.map → chunk-EMRY62HS.cjs.map} +1 -1
  23. package/dist/{chunk-USNTRL22.cjs → chunk-H236SNEV.cjs} +199 -1616
  24. package/dist/chunk-H236SNEV.cjs.map +1 -0
  25. package/dist/chunk-JITYC4OS.cjs +66 -0
  26. package/dist/chunk-JITYC4OS.cjs.map +1 -0
  27. package/dist/chunk-JY7UUZQG.cjs +1513 -0
  28. package/dist/chunk-JY7UUZQG.cjs.map +1 -0
  29. package/dist/chunk-MVXHTAJ4.cjs +111 -0
  30. package/dist/chunk-MVXHTAJ4.cjs.map +1 -0
  31. package/dist/{chunk-4TTX6ZNS.cjs → chunk-ORNLCBNE.cjs} +24 -2
  32. package/dist/chunk-ORNLCBNE.cjs.map +1 -0
  33. package/dist/chunk-WVZLAAIZ.cjs +31 -0
  34. package/dist/chunk-WVZLAAIZ.cjs.map +1 -0
  35. package/dist/chunk-ZZZITHGK.cjs +119 -0
  36. package/dist/chunk-ZZZITHGK.cjs.map +1 -0
  37. package/dist/connect/index.cjs +52 -52
  38. package/dist/connect/viewer.cjs +8 -5
  39. package/dist/connection/presentation/ClippingMediaViewer.js +3 -3
  40. package/dist/connection/presentation/ClippingMediaViewer.js.map +2 -2
  41. package/dist/connection/presentation/ClippingPdfViewer.d.ts +4 -3
  42. package/dist/connection/presentation/ClippingPdfViewer.js +48 -9
  43. package/dist/connection/presentation/ClippingPdfViewer.js.map +2 -2
  44. package/dist/connection/presentation/ConnectedSlidesTab.js +35 -13
  45. package/dist/connection/presentation/ConnectedSlidesTab.js.map +2 -2
  46. package/dist/connection/presentation/SpotlightLayer.d.ts +5 -0
  47. package/dist/connection/presentation/SpotlightLayer.js +19 -0
  48. package/dist/connection/presentation/SpotlightLayer.js.map +7 -0
  49. package/dist/connection/presentation/SpotlightStrip.d.ts +10 -0
  50. package/dist/connection/presentation/SpotlightStrip.js +237 -0
  51. package/dist/connection/presentation/SpotlightStrip.js.map +7 -0
  52. package/dist/connection/presentation/useViewerClipping.d.ts +4 -3
  53. package/dist/connection/presentation/useViewerClipping.js +8 -4
  54. package/dist/connection/presentation/useViewerClipping.js.map +2 -2
  55. package/dist/connection/viewer/ConnectedDocumentViewer.js +52 -61
  56. package/dist/connection/viewer/ConnectedDocumentViewer.js.map +2 -2
  57. package/dist/connection/viewer/ViewerMoreMenu.d.ts +18 -0
  58. package/dist/connection/viewer/ViewerMoreMenu.js +45 -0
  59. package/dist/connection/viewer/ViewerMoreMenu.js.map +7 -0
  60. package/dist/connection/viewer/pdf/PdfPassageHighlights.js +3 -2
  61. package/dist/connection/viewer/pdf/PdfPassageHighlights.js.map +2 -2
  62. package/dist/connection/viewer/pdf/passageHighlights.d.ts +5 -0
  63. package/dist/connection/viewer/pdf/passageHighlights.js +14 -1
  64. package/dist/connection/viewer/pdf/passageHighlights.js.map +2 -2
  65. package/dist/connection/viewer/useCleanView.d.ts +3 -1
  66. package/dist/connection/viewer/useCleanView.js +6 -3
  67. package/dist/connection/viewer/useCleanView.js.map +2 -2
  68. package/dist/document-tools/DocumentToolButtons.js +3 -3
  69. package/dist/document-tools/DocumentToolButtons.js.map +2 -2
  70. package/dist/document-tools/index.cjs +13 -13
  71. package/dist/index.cjs +53 -53
  72. package/dist/presentation/BoxActionBar.d.ts +2 -2
  73. package/dist/presentation/BoxActionBar.js +62 -30
  74. package/dist/presentation/BoxActionBar.js.map +2 -2
  75. package/dist/presentation/ClipActionBar.js +60 -7
  76. package/dist/presentation/ClipActionBar.js.map +2 -2
  77. package/dist/presentation/ClipCaptureOverlay.d.ts +7 -3
  78. package/dist/presentation/ClipCaptureOverlay.js +43 -14
  79. package/dist/presentation/ClipCaptureOverlay.js.map +2 -2
  80. package/dist/presentation/ClipViewControls.d.ts +3 -3
  81. package/dist/presentation/ClipViewControls.js +59 -64
  82. package/dist/presentation/ClipViewControls.js.map +2 -2
  83. package/dist/presentation/PresentControls.d.ts +8 -0
  84. package/dist/presentation/PresentControls.js +1 -0
  85. package/dist/presentation/PresentControls.js.map +2 -2
  86. package/dist/presentation/PresentationStage.d.ts +10 -2
  87. package/dist/presentation/PresentationStage.js +6 -3
  88. package/dist/presentation/PresentationStage.js.map +2 -2
  89. package/dist/presentation/PresenterView.js +1 -22
  90. package/dist/presentation/PresenterView.js.map +2 -2
  91. package/dist/presentation/SlidesEditor.js +56 -42
  92. package/dist/presentation/SlidesEditor.js.map +2 -2
  93. package/dist/presentation/SpotlightView.d.ts +19 -0
  94. package/dist/presentation/SpotlightView.js +180 -0
  95. package/dist/presentation/SpotlightView.js.map +7 -0
  96. package/dist/presentation/StageItem.js +0 -5
  97. package/dist/presentation/StageItem.js.map +2 -2
  98. package/dist/presentation/passage-clip.d.ts +17 -0
  99. package/dist/presentation/passage-clip.js +25 -0
  100. package/dist/presentation/passage-clip.js.map +7 -0
  101. package/dist/presentation/spotlight.d.ts +58 -0
  102. package/dist/presentation/spotlight.js +110 -0
  103. package/dist/presentation/spotlight.js.map +7 -0
  104. package/dist/presentation/store.d.ts +5 -0
  105. package/dist/presentation/store.js +19 -0
  106. package/dist/presentation/store.js.map +2 -2
  107. package/dist/presentation/usePointerActive.d.ts +2 -0
  108. package/dist/presentation/usePointerActive.js +28 -0
  109. package/dist/presentation/usePointerActive.js.map +7 -0
  110. package/dist/styles.css +1 -1
  111. package/node_modules/@arbidocs/coedit/package.json +1 -1
  112. package/package.json +5 -5
  113. package/dist/ClippingMediaViewer-IEIBT74X.cjs.map +0 -1
  114. package/dist/ClippingPdfViewer-OGYLMVCE.cjs.map +0 -1
  115. package/dist/ConnectedPresentation-AU25OW25.cjs.map +0 -1
  116. package/dist/ConnectedSlidesTab-I75LKKN7.cjs.map +0 -1
  117. package/dist/FilesViewerDialog-4352KIOG.cjs.map +0 -1
  118. package/dist/chunk-4TTX6ZNS.cjs.map +0 -1
  119. package/dist/chunk-LHWOKOMP.cjs.map +0 -1
  120. package/dist/chunk-USNTRL22.cjs.map +0 -1
  121. package/dist/chunk-UTJ223TI.cjs.map +0 -1
  122. package/dist/chunk-WFMWKPGY.cjs.map +0 -1
  123. package/dist/chunk-XK4TVJKD.cjs +0 -73
  124. package/dist/chunk-XK4TVJKD.cjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/presentation/SlidesEditor.tsx"],
4
- "sourcesContent": ["/**\n * The presentation editor: its slides one under the other, scrolled like a PDF's pages, each one\n * edited where it is \u2014 clips dragged, resized and reshaped on it, its title and points typed on\n * it. Hovering a slide shows its actions (layout, move up or down, duplicate, delete); between two\n * slides, + inserts one. One small floating bar holds the rest (Design, the host's Save and other\n * actions, Present, \"\u2026\"), so no header takes room from the slides. The clips collected for the\n * presentation wait in the tray along the bottom, to be dragged onto any slide.\n *\n * The same editor shows wherever the host mounts it (the viewer's tab, or its own window).\n */\n\nimport { memo, useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'\nimport {\n ArrowDown,\n ArrowUp,\n Circle,\n Copy,\n Minus,\n MoreHorizontal,\n Play,\n Plus,\n RectangleHorizontal,\n Shapes,\n Square,\n Trash2,\n Type,\n} from 'lucide-react'\nimport {\n Button,\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n cn,\n} from '@arbidocs/react/ui'\nimport { ClipTray } from './ClipTray'\nimport { DesignMenu } from './DesignMenu'\nimport { LayoutMenu } from './LayoutMenu'\nimport { Notice } from './Notice'\nimport { PresentationStage } from './PresentationStage'\nimport type { SlideTextEditing } from './SlideDecor'\nimport { usePresentation } from './store'\nimport { newBox, type BoxShape } from './boxes'\nimport { accentColor, isLightBackground } from './theme'\nimport { usePresenterKeys } from './usePresenterKeys'\n\nexport interface SlidesEditorProps {\n /** Present: the host opens the shareable window. */\n onPresent: () => void\n /** In the floating bar, before Present (e.g. Save, pop out). */\n actions?: ReactNode\n /** At the top of the \"\u2026\" menu (e.g. New from template, Save as, Export). */\n menuItems?: ReactNode\n /** First in the clip tray (e.g. Generate image). */\n trayStart?: ReactNode\n onChooseLogo?: () => void\n onEditImage?: (clipId: string) => void\n onCropImage?: (clipId: string) => void\n}\n\ninterface Selection {\n index: number\n clipId: string\n}\n\n/** A small icon button of a slide's hover bar. */\nfunction SlideAction({\n label,\n onClick,\n disabled,\n children,\n}: {\n label: string\n onClick: () => void\n disabled?: boolean\n children: ReactNode\n}) {\n return (\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"ghost\"\n className=\"size-7 text-muted-foreground hover:text-foreground pointer-coarse:size-10\"\n title={label}\n aria-label={label}\n disabled={disabled}\n onClick={onClick}\n >\n {children}\n </Button>\n )\n}\n\nconst SlideCard = memo(function SlideCard({\n index,\n count,\n current,\n selected,\n onSelect,\n onEditImage,\n onCropImage,\n}: {\n index: number\n count: number\n current: boolean\n selected: string | null\n onSelect: (index: number, clipId: string | null) => void\n onEditImage?: (clipId: string) => void\n onCropImage?: (clipId: string) => void\n}) {\n const empty = usePresentation((s) => {\n const slide = s.slides[index]\n return (\n !!slide &&\n !slide.items.length &&\n !slide.boxes.length &&\n slide.layout !== 'title' &&\n slide.layout !== 'section'\n )\n })\n const notes = usePresentation((s) => s.slides[index]?.notes ?? '')\n const textEditing = useMemo<SlideTextEditing>(\n () => ({\n onTitle: (title) => usePresentation.getState().setSlideCaption(title, index),\n onPoints: (points) => usePresentation.getState().setSlidePoints(points, index),\n }),\n [index]\n )\n const select = useCallback((clipId: string | null) => onSelect(index, clipId), [onSelect, index])\n const actions = usePresentation.getState()\n return (\n <div className=\"group relative flex gap-2\" data-testid={`slide-${index}`}>\n {/* The gutter: the slide's number, and its actions on hover (always on a touch screen's\n current slide), clear of the slide itself. */}\n <div className=\"flex w-9 shrink-0 flex-col items-center gap-0.5\">\n <span\n className={cn(\n 'py-1 text-xs tabular-nums',\n current ? 'font-semibold text-foreground' : 'text-muted-foreground'\n )}\n >\n {index + 1}\n </span>\n <div\n className={cn(\n 'flex flex-col items-center gap-0.5 transition-opacity',\n 'opacity-0 focus-within:opacity-100 group-hover:opacity-100',\n current && 'pointer-coarse:opacity-100'\n )}\n data-testid={`slide-actions-${index}`}\n >\n <LayoutMenu index={index} compact />\n <SlideAction\n label=\"Move up\"\n disabled={index === 0}\n onClick={() => actions.moveSlide(index, index - 1)}\n >\n <ArrowUp className=\"size-3.5\" />\n </SlideAction>\n <SlideAction\n label=\"Move down\"\n disabled={index === count - 1}\n onClick={() => actions.moveSlide(index, index + 1)}\n >\n <ArrowDown className=\"size-3.5\" />\n </SlideAction>\n <SlideAction label=\"Duplicate\" onClick={() => actions.duplicateSlide(index)}>\n <Copy className=\"size-3.5\" />\n </SlideAction>\n <SlideAction label=\"Delete slide\" onClick={() => actions.removeSlide(index)}>\n <Trash2 className=\"size-3.5\" />\n </SlideAction>\n </div>\n </div>\n <div\n className={cn(\n 'relative aspect-video min-w-0 flex-1 rounded-sm',\n current && 'ring-1 ring-primary/40 ring-offset-4 ring-offset-transparent'\n )}\n >\n <PresentationStage\n editable\n slideIndex={index}\n selected={selected}\n onSelect={select}\n onEditImage={onEditImage}\n onCropImage={onCropImage}\n textEditing={textEditing}\n overlay={\n empty && (\n <div className=\"pointer-events-none absolute inset-x-0 bottom-[8%] flex justify-center\">\n <span className=\"rounded-full bg-black/40 px-3 py-1 text-[1.4cqw] text-white/70\">\n Drag a clip here from the tray\n </span>\n </div>\n )\n }\n />\n {(notes || current) && (\n <textarea\n value={notes}\n rows={notes.split('\\n').length}\n placeholder=\"Speaker notes\"\n onChange={(event) =>\n usePresentation.getState().setSlideNotes(event.target.value, index)\n }\n className=\"mt-2 block w-full resize-none rounded-sm border-0 bg-transparent px-1 py-0.5 text-xs text-muted-foreground placeholder:text-muted-foreground/50 focus:bg-background focus:text-foreground focus:outline-none focus:ring-1 focus:ring-ring\"\n aria-label={`Speaker notes for slide ${index + 1}`}\n data-testid={`slide-notes-${index}`}\n />\n )}\n </div>\n </div>\n )\n})\n\nconst INSERTS: { shape: BoxShape; label: string; icon: ReactNode }[] = [\n { shape: 'text', label: 'Text box', icon: <Type className=\"size-4\" /> },\n { shape: 'rect', label: 'Rectangle', icon: <Square className=\"size-4\" /> },\n {\n shape: 'roundRect',\n label: 'Rounded rectangle',\n icon: <RectangleHorizontal className=\"size-4\" />,\n },\n { shape: 'ellipse', label: 'Ellipse', icon: <Circle className=\"size-4\" /> },\n { shape: 'line', label: 'Line', icon: <Minus className=\"size-4\" /> },\n]\n\n/** Insert a text box or a shape on the current slide; it is selected, ready to type in. */\nfunction InsertMenu({ onInserted }: { onInserted: (index: number, boxId: string) => void }) {\n const insert = (shape: BoxShape) => {\n const state = usePresentation.getState()\n const slide = state.slides[state.current]\n const box = newBox(shape, accentColor(state.theme.accent))\n // On a light slide (an imported deck's), text is dark.\n const dark = isLightBackground(slide?.background)\n const { id, ...rest } = dark\n ? {\n ...box,\n paragraphs: box.paragraphs.map((p) => ({\n ...p,\n runs: p.runs.map((r) => ({ color: '#1f2328', ...r })),\n })),\n }\n : box\n void id\n onInserted(state.current, state.addBox(rest))\n }\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"ghost\"\n className=\"size-8 text-muted-foreground hover:text-foreground pointer-coarse:size-11\"\n title=\"Insert a text box or shape\"\n aria-label=\"Insert\"\n data-testid=\"slides-insert\"\n >\n <Shapes className=\"size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {INSERTS.map(({ shape, label, icon }) => (\n <DropdownMenuItem\n key={shape}\n onSelect={() => insert(shape)}\n data-testid={`slides-insert-${shape}`}\n >\n {icon}\n <span className=\"ml-2\">{label}</span>\n </DropdownMenuItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n\n/** Between two slides (and after the last): + inserts a slide there, shown on hover. */\nfunction InsertSlide({ after, always }: { after: number; always?: boolean }) {\n return (\n <div className=\"group/insert relative flex h-8 items-center justify-center pl-11\">\n <button\n type=\"button\"\n onClick={() => usePresentation.getState().addSlide(undefined, after)}\n className={cn(\n 'flex items-center gap-1 rounded-full border border-dashed border-border bg-background px-2.5 py-0.5 text-xs text-muted-foreground transition-opacity hover:border-solid hover:text-foreground focus-visible:opacity-100',\n !always && 'opacity-0 group-hover/insert:opacity-100 pointer-coarse:opacity-100'\n )}\n aria-label={`New slide after slide ${after + 1}`}\n data-testid={`slide-insert-${after}`}\n >\n <Plus className=\"size-3\" />\n Slide\n </button>\n </div>\n )\n}\n\nexport function SlidesEditor({\n onPresent,\n actions,\n menuItems,\n trayStart,\n onChooseLogo,\n onEditImage,\n onCropImage,\n}: SlidesEditorProps) {\n const ids = usePresentation((s) => s.slides.map((slide) => slide.id).join(' '))\n const slideIds = useMemo(() => ids.split(' '), [ids])\n const current = usePresentation((s) => s.current)\n const captions = usePresentation((s) => s.captions)\n // Presenting in the presentation's own window: Present becomes Stop presenting.\n const presenting = usePresentation((s) => s.presenting)\n const [selection, setSelection] = useState<Selection | null>(null)\n const [view, setView] = useState<Window | null>(null)\n const list = useRef<HTMLDivElement>(null)\n const rootRef = useCallback((node: HTMLDivElement | null) => {\n if (node) setView(node.ownerDocument.defaultView)\n }, [])\n\n const onSelect = useCallback((index: number, clipId: string | null) => {\n setSelection(clipId ? { index, clipId } : null)\n }, [])\n const keySelection = useMemo(\n () => ({ clipId: selection?.clipId ?? null, clear: () => setSelection(null) }),\n [selection]\n )\n usePresenterKeys(view, false, keySelection)\n\n // A slide added, duplicated or moved becomes the current one: brought into view.\n useEffect(() => {\n const card = list.current?.querySelector(`[data-testid=\"slide-${current}\"]`)\n card?.scrollIntoView?.({ block: 'nearest', behavior: 'smooth' })\n }, [current, slideIds.length])\n\n return (\n <div\n ref={rootRef}\n className=\"relative flex h-full min-h-0 flex-col bg-muted/30\"\n data-testid=\"slides-editor\"\n >\n <div ref={list} className=\"min-h-0 flex-1 overflow-y-auto\">\n <div className=\"mx-auto flex max-w-[1100px] flex-col pb-6 pl-2 pr-6 pt-14\">\n {slideIds.map((id, index) => (\n <div key={id}>\n <SlideCard\n index={index}\n count={slideIds.length}\n current={index === current}\n selected={selection?.index === index ? selection.clipId : null}\n onSelect={onSelect}\n onEditImage={onEditImage}\n onCropImage={onCropImage}\n />\n <InsertSlide after={index} always={index === slideIds.length - 1} />\n </div>\n ))}\n </div>\n </div>\n\n {/* The rest, in one small floating bar: no header row. */}\n <div\n className=\"absolute right-4 top-2.5 z-40 flex items-center gap-0.5 rounded-full border border-border bg-background p-1 shadow-md\"\n data-testid=\"slides-toolbar\"\n >\n <DesignMenu onChooseLogo={onChooseLogo} />\n <InsertMenu onInserted={(index, boxId) => setSelection({ index, clipId: boxId })} />\n {actions}\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"ghost\"\n className=\"size-8 text-muted-foreground hover:text-foreground pointer-coarse:size-11\"\n title=\"More\"\n aria-label=\"More\"\n >\n <MoreHorizontal className=\"size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {menuItems}\n {menuItems && <DropdownMenuSeparator />}\n <DropdownMenuCheckboxItem\n checked={captions}\n onCheckedChange={(on) => usePresentation.getState().setCaptions(!!on)}\n >\n Show source labels\n </DropdownMenuCheckboxItem>\n </DropdownMenuContent>\n </DropdownMenu>\n {presenting ? (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"destructive\"\n className=\"ml-0.5 h-8 rounded-full\"\n onClick={() => usePresentation.getState().setPresenting(false)}\n title=\"Stop presenting (the presentation window closes)\"\n data-testid=\"presentation-stop-button\"\n >\n <Square className=\"size-3 fill-current\" />\n Stop presenting\n </Button>\n ) : (\n <Button\n type=\"button\"\n size=\"sm\"\n className=\"ml-0.5 h-8 rounded-full\"\n onClick={() => {\n setSelection(null)\n onPresent()\n }}\n title=\"Present: the slides alone, in a window to share or put full screen\"\n data-testid=\"presentation-present-button\"\n >\n <Play className=\"size-3.5\" />\n Present\n </Button>\n )}\n </div>\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AAoB,OAAM,OACxB;AAAA;AAAA,kBACA,aAAa,oBAAC,yBAAsB;AAAA,kBACrC;AAAA,oBAAC;AAAA;AAAA,sBACC,SAAS;AAAA,sBACT,iBAAiB,CAAC,OAAO,gBAAgB,SAAS,EAAE,YAAY,CAAC,CAAC,EAAE;AAAA,sBACrE;AAAA;AAAA,kBAED;AAAA,mBACF;AAAA,iBACF;AAAA,cACC,aACC;AAAA,gBAAC;AAAA;AAAA,kBACC,MAAK;AAAA,kBACL,MAAK;AAAA,kBACL,SAAQ;AAAA,kBACR,WAAU;AAAA,kBACV,SAAS,MAAM,gBAAgB,SAAS,EAAE,cAAc,KAAK;AAAA,kBAC7D,OAAM;AAAA,kBACN,eAAY;AAAA,kBAEZ;AAAA,wCAAC,UAAO,WAAU,uBAAsB;AAAA,oBAAE;AAAA;AAAA;AAAA,cAE5C,IAEA;AAAA,gBAAC;AAAA;AAAA,kBACC,MAAK;AAAA,kBACL,MAAK;AAAA,kBACL,WAAU;AAAA,kBACV,SAAS,MAAM;AACb,iCAAa,IAAI;AACjB,8BAAU;AAAA,kBACZ;AAAA,kBACA,OAAM;AAAA,kBACN,eAAY;AAAA,kBAEZ;AAAA,wCAAC,QAAK,WAAU,YAAW;AAAA,oBAAE;AAAA;AAAA;AAAA,cAE/B;AAAA;AAAA;AAAA,QAEJ;AAAA,QAEA,oBAAC,YAAS,OAAO,WAAW;AAAA,QAC5B,oBAAC,UAAO;AAAA;AAAA;AAAA,EACV;AAEJ;",
4
+ "sourcesContent": ["/**\n * The presentation editor: its slides one under the other, scrolled like a PDF's pages, each one\n * edited where it is \u2014 clips dragged, resized and reshaped on it, its title and points typed on\n * it. Hovering a slide shows its actions (layout, move up or down, duplicate, delete); between two\n * slides, + inserts one. One small floating bar holds the rest (Design, the host's Save and other\n * actions, Present, \"\u2026\"), so no header takes room from the slides. The clips collected for the\n * presentation wait in the tray along the bottom, to be dragged onto any slide.\n *\n * The same editor shows wherever the host mounts it (the viewer's tab, or its own window).\n */\n\nimport { memo, useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'\nimport {\n ArrowDown,\n ArrowUp,\n Circle,\n Copy,\n Minus,\n MoreHorizontal,\n Play,\n Plus,\n RectangleHorizontal,\n Shapes,\n Square,\n Trash2,\n Type,\n} from 'lucide-react'\nimport {\n Button,\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n cn,\n} from '@arbidocs/react/ui'\nimport { ClipTray } from './ClipTray'\nimport { DesignMenu } from './DesignMenu'\nimport { LayoutMenu } from './LayoutMenu'\nimport { Notice } from './Notice'\nimport { PresentationStage } from './PresentationStage'\nimport type { SlideTextEditing } from './SlideDecor'\nimport { usePresentation } from './store'\nimport { newBox, type BoxShape } from './boxes'\nimport { accentColor, isLightBackground } from './theme'\nimport { usePresenterKeys } from './usePresenterKeys'\n\nexport interface SlidesEditorProps {\n /** Present: the host opens the shareable window. */\n onPresent: () => void\n /** In the floating bar, before Present (e.g. Save, pop out). */\n actions?: ReactNode\n /** At the top of the \"\u2026\" menu (e.g. New from template, Save as, Export). */\n menuItems?: ReactNode\n /** First in the clip tray (e.g. Generate image). */\n trayStart?: ReactNode\n onChooseLogo?: () => void\n onEditImage?: (clipId: string) => void\n onCropImage?: (clipId: string) => void\n}\n\ninterface Selection {\n index: number\n clipId: string\n}\n\nconst SlideCard = memo(function SlideCard({\n index,\n count,\n current,\n selected,\n onSelect,\n onEditImage,\n onCropImage,\n}: {\n index: number\n count: number\n current: boolean\n selected: string | null\n onSelect: (index: number, clipId: string | null) => void\n onEditImage?: (clipId: string) => void\n onCropImage?: (clipId: string) => void\n}) {\n const empty = usePresentation((s) => {\n const slide = s.slides[index]\n return (\n !!slide &&\n !slide.items.length &&\n !slide.boxes.length &&\n !slide.points.trim() &&\n slide.layout !== 'title' &&\n slide.layout !== 'section'\n )\n })\n const notes = usePresentation((s) => s.slides[index]?.notes ?? '')\n const textEditing = useMemo<SlideTextEditing>(\n () => ({\n onTitle: (title) => usePresentation.getState().setSlideCaption(title, index),\n onPoints: (points) => usePresentation.getState().setSlidePoints(points, index),\n }),\n [index]\n )\n const select = useCallback((clipId: string | null) => onSelect(index, clipId), [onSelect, index])\n const actions = usePresentation.getState()\n return (\n <div className=\"group relative flex gap-2\" data-testid={`slide-${index}`}>\n {/* The gutter: the slide's number, and its actions on hover (always on a touch screen's\n current slide), clear of the slide itself. */}\n <div className=\"flex w-9 shrink-0 flex-col items-center gap-0.5\">\n <span\n className={cn(\n 'py-1 text-xs tabular-nums',\n current ? 'font-semibold text-foreground' : 'text-muted-foreground'\n )}\n >\n {index + 1}\n </span>\n <div\n className={cn(\n 'flex flex-col items-center gap-0.5 transition-opacity',\n 'opacity-0 focus-within:opacity-100 group-hover:opacity-100',\n current && 'pointer-coarse:opacity-100'\n )}\n data-testid={`slide-actions-${index}`}\n >\n <LayoutMenu index={index} compact />\n {/* The slide's other actions, behind \"\u2026\": moving it, copying it, deleting it. */}\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"ghost\"\n className=\"size-7 text-muted-foreground hover:text-foreground pointer-coarse:size-11\"\n title=\"Slide actions\"\n aria-label={`Slide ${index + 1} actions`}\n data-testid={`slide-menu-${index}`}\n >\n <MoreHorizontal className=\"size-3.5\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"start\">\n <DropdownMenuItem\n disabled={index === 0}\n onSelect={() => actions.moveSlide(index, index - 1)}\n >\n <ArrowUp className=\"size-4\" />\n <span className=\"ml-2\">Move up</span>\n </DropdownMenuItem>\n <DropdownMenuItem\n disabled={index === count - 1}\n onSelect={() => actions.moveSlide(index, index + 1)}\n >\n <ArrowDown className=\"size-4\" />\n <span className=\"ml-2\">Move down</span>\n </DropdownMenuItem>\n <DropdownMenuItem onSelect={() => actions.duplicateSlide(index)}>\n <Copy className=\"size-4\" />\n <span className=\"ml-2\">Duplicate</span>\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem\n className=\"text-destructive\"\n onSelect={() => actions.removeSlide(index)}\n >\n <Trash2 className=\"size-4\" />\n <span className=\"ml-2\">Delete slide</span>\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n </div>\n <div\n className={cn(\n 'relative aspect-video min-w-0 flex-1 rounded-sm',\n current && 'ring-1 ring-primary/40 ring-offset-4 ring-offset-transparent'\n )}\n >\n <PresentationStage\n editable\n slideIndex={index}\n selected={selected}\n onSelect={select}\n onEditImage={onEditImage}\n onCropImage={onCropImage}\n textEditing={textEditing}\n overlay={\n empty && (\n <div className=\"pointer-events-none absolute inset-x-0 bottom-[8%] flex justify-center\">\n <span className=\"rounded-full bg-black/40 px-3 py-1 text-[1.4cqw] text-white/70\">\n Drag a clip here from the tray\n </span>\n </div>\n )\n }\n />\n {(notes || current) && (\n <textarea\n value={notes}\n rows={notes.split('\\n').length}\n placeholder=\"Speaker notes\"\n onChange={(event) =>\n usePresentation.getState().setSlideNotes(event.target.value, index)\n }\n className=\"mt-2 block w-full resize-none rounded-sm border-0 bg-transparent px-1 py-0.5 text-xs text-muted-foreground placeholder:text-muted-foreground/50 focus:bg-background focus:text-foreground focus:outline-none focus:ring-1 focus:ring-ring\"\n aria-label={`Speaker notes for slide ${index + 1}`}\n data-testid={`slide-notes-${index}`}\n />\n )}\n </div>\n </div>\n )\n})\n\nconst INSERTS: { shape: BoxShape; label: string; icon: ReactNode }[] = [\n { shape: 'text', label: 'Text box', icon: <Type className=\"size-4\" /> },\n { shape: 'rect', label: 'Rectangle', icon: <Square className=\"size-4\" /> },\n {\n shape: 'roundRect',\n label: 'Rounded rectangle',\n icon: <RectangleHorizontal className=\"size-4\" />,\n },\n { shape: 'ellipse', label: 'Ellipse', icon: <Circle className=\"size-4\" /> },\n { shape: 'line', label: 'Line', icon: <Minus className=\"size-4\" /> },\n]\n\n/** Insert a text box or a shape on the current slide; it is selected, ready to type in. */\nfunction InsertMenu({ onInserted }: { onInserted: (index: number, boxId: string) => void }) {\n const insert = (shape: BoxShape) => {\n const state = usePresentation.getState()\n const slide = state.slides[state.current]\n const box = newBox(shape, accentColor(state.theme.accent))\n // On a light slide (an imported deck's), text is dark.\n const dark = isLightBackground(slide?.background)\n const { id, ...rest } = dark\n ? {\n ...box,\n paragraphs: box.paragraphs.map((p) => ({\n ...p,\n runs: p.runs.map((r) => ({ color: '#1f2328', ...r })),\n })),\n }\n : box\n void id\n onInserted(state.current, state.addBox(rest))\n }\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"ghost\"\n className=\"size-8 text-muted-foreground hover:text-foreground pointer-coarse:size-11\"\n title=\"Insert a text box or shape\"\n aria-label=\"Insert\"\n data-testid=\"slides-insert\"\n >\n <Shapes className=\"size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {INSERTS.map(({ shape, label, icon }) => (\n <DropdownMenuItem\n key={shape}\n onSelect={() => insert(shape)}\n data-testid={`slides-insert-${shape}`}\n >\n {icon}\n <span className=\"ml-2\">{label}</span>\n </DropdownMenuItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n\n/** Between two slides (and after the last): + inserts a slide there, shown on hover. */\nfunction InsertSlide({ after, always }: { after: number; always?: boolean }) {\n return (\n <div className=\"group/insert relative flex h-8 items-center justify-center pl-11\">\n <button\n type=\"button\"\n onClick={() => usePresentation.getState().addSlide(undefined, after)}\n className={cn(\n 'flex items-center gap-1 rounded-full border border-dashed border-border bg-background px-2.5 py-0.5 text-xs text-muted-foreground transition-opacity hover:border-solid hover:text-foreground focus-visible:opacity-100',\n !always && 'opacity-0 group-hover/insert:opacity-100 pointer-coarse:opacity-100'\n )}\n aria-label={`New slide after slide ${after + 1}`}\n data-testid={`slide-insert-${after}`}\n >\n <Plus className=\"size-3\" />\n Slide\n </button>\n </div>\n )\n}\n\nexport function SlidesEditor({\n onPresent,\n actions,\n menuItems,\n trayStart,\n onChooseLogo,\n onEditImage,\n onCropImage,\n}: SlidesEditorProps) {\n const ids = usePresentation((s) => s.slides.map((slide) => slide.id).join(' '))\n const slideIds = useMemo(() => ids.split(' '), [ids])\n const current = usePresentation((s) => s.current)\n const captions = usePresentation((s) => s.captions)\n // Presenting in the presentation's own window: Present becomes Stop presenting.\n const presenting = usePresentation((s) => s.presenting)\n const [selection, setSelection] = useState<Selection | null>(null)\n const [view, setView] = useState<Window | null>(null)\n const list = useRef<HTMLDivElement>(null)\n const rootRef = useCallback((node: HTMLDivElement | null) => {\n if (node) setView(node.ownerDocument.defaultView)\n }, [])\n\n const onSelect = useCallback((index: number, clipId: string | null) => {\n setSelection(clipId ? { index, clipId } : null)\n }, [])\n const keySelection = useMemo(\n () => ({ clipId: selection?.clipId ?? null, clear: () => setSelection(null) }),\n [selection]\n )\n usePresenterKeys(view, false, keySelection)\n\n // A slide added, duplicated or moved becomes the current one: brought into view.\n useEffect(() => {\n const card = list.current?.querySelector(`[data-testid=\"slide-${current}\"]`)\n card?.scrollIntoView?.({ block: 'nearest', behavior: 'smooth' })\n }, [current, slideIds.length])\n\n return (\n <div\n ref={rootRef}\n className=\"relative flex h-full min-h-0 flex-col bg-muted/30\"\n data-testid=\"slides-editor\"\n >\n <div ref={list} className=\"min-h-0 flex-1 overflow-y-auto\">\n <div className=\"mx-auto flex max-w-[1100px] flex-col pb-6 pl-2 pr-6 pt-14\">\n {slideIds.map((id, index) => (\n <div key={id}>\n <SlideCard\n index={index}\n count={slideIds.length}\n current={index === current}\n selected={selection?.index === index ? selection.clipId : null}\n onSelect={onSelect}\n onEditImage={onEditImage}\n onCropImage={onCropImage}\n />\n <InsertSlide after={index} always={index === slideIds.length - 1} />\n </div>\n ))}\n </div>\n </div>\n\n {/* The rest, in one small floating bar: no header row. */}\n <div\n className=\"absolute right-4 top-2.5 z-40 flex items-center gap-0.5 rounded-full border border-border bg-background p-1 shadow-md\"\n data-testid=\"slides-toolbar\"\n >\n <DesignMenu onChooseLogo={onChooseLogo} />\n <InsertMenu onInserted={(index, boxId) => setSelection({ index, clipId: boxId })} />\n {actions}\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"ghost\"\n className=\"size-8 text-muted-foreground hover:text-foreground pointer-coarse:size-11\"\n title=\"More\"\n aria-label=\"More\"\n >\n <MoreHorizontal className=\"size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {menuItems}\n {menuItems && <DropdownMenuSeparator />}\n <DropdownMenuCheckboxItem\n checked={captions}\n onCheckedChange={(on) => usePresentation.getState().setCaptions(!!on)}\n >\n Show source labels\n </DropdownMenuCheckboxItem>\n </DropdownMenuContent>\n </DropdownMenu>\n {presenting ? (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"destructive\"\n className=\"ml-0.5 h-8 rounded-full\"\n onClick={() => usePresentation.getState().setPresenting(false)}\n title=\"Stop presenting (the presentation window closes)\"\n data-testid=\"presentation-stop-button\"\n >\n <Square className=\"size-3 fill-current\" />\n Stop presenting\n </Button>\n ) : (\n <Button\n type=\"button\"\n size=\"sm\"\n className=\"ml-0.5 h-8 rounded-full\"\n onClick={() => {\n setSelection(null)\n onPresent()\n }}\n title=\"Present: the slides alone, in a window to share or put full screen\"\n data-testid=\"presentation-present-button\"\n >\n <Play className=\"size-3.5\" />\n Present\n </Button>\n )}\n </div>\n\n <ClipTray start={trayStart} />\n <Notice />\n </div>\n )\n}\n"],
5
+ "mappings": ";AA8GQ,cAiCM,YAjCN;AAnGR,SAAS,MAAM,aAAa,WAAW,SAAS,QAAQ,gBAAgC;AACxF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,E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AAW;AAAA,oBAEX,8BAAC,kBAAe,WAAU,UAAS;AAAA;AAAA,gBACrC,GACF;AAAA,gBACA,qBAAC,uBAAoB,OAAM,OACxB;AAAA;AAAA,kBACA,aAAa,oBAAC,yBAAsB;AAAA,kBACrC;AAAA,oBAAC;AAAA;AAAA,sBACC,SAAS;AAAA,sBACT,iBAAiB,CAAC,OAAO,gBAAgB,SAAS,EAAE,YAAY,CAAC,CAAC,EAAE;AAAA,sBACrE;AAAA;AAAA,kBAED;AAAA,mBACF;AAAA,iBACF;AAAA,cACC,aACC;AAAA,gBAAC;AAAA;AAAA,kBACC,MAAK;AAAA,kBACL,MAAK;AAAA,kBACL,SAAQ;AAAA,kBACR,WAAU;AAAA,kBACV,SAAS,MAAM,gBAAgB,SAAS,EAAE,cAAc,KAAK;AAAA,kBAC7D,OAAM;AAAA,kBACN,eAAY;AAAA,kBAEZ;AAAA,wCAAC,UAAO,WAAU,uBAAsB;AAAA,oBAAE;AAAA;AAAA;AAAA,cAE5C,IAEA;AAAA,gBAAC;AAAA;AAAA,kBACC,MAAK;AAAA,kBACL,MAAK;AAAA,kBACL,WAAU;AAAA,kBACV,SAAS,MAAM;AACb,iCAAa,IAAI;AACjB,8BAAU;AAAA,kBACZ;AAAA,kBACA,OAAM;AAAA,kBACN,eAAY;AAAA,kBAEZ;AAAA,wCAAC,QAAK,WAAU,YAAW;AAAA,oBAAE;AAAA;AAAA;AAAA,cAE/B;AAAA;AAAA;AAAA,QAEJ;AAAA,QAEA,oBAAC,YAAS,OAAO,WAAW;AAAA,QAC5B,oBAAC,UAAO;AAAA;AAAA;AAAA,EACV;AAEJ;",
6
6
  "names": ["SlideCard"]
7
7
  }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The spotlight on screen: the document dims and the gathered clips fly from where they are on
3
+ * their pages into a slide over it, in the same window (a call sharing it goes on sharing it). It is
4
+ * the presentation's own stage (`PresentationStage`), so it looks as a slide of the deck would.
5
+ *
6
+ * ← → step through the clips together and each alone, Esc goes back to the document. Each move is
7
+ * a FLIP: a clip is drawn where it ends and animated from where it was (its page, or its place on
8
+ * the previous step) by a transform, about 300 ms; with reduced motion it simply appears.
9
+ */
10
+ import type { Clip } from './model';
11
+ /** How long a clip takes to fly into place. */
12
+ export declare const SPOTLIGHT_MS = 300;
13
+ /** A box on screen, in CSS pixels. */
14
+ export type ScreenRect = Pick<DOMRect, 'left' | 'top' | 'width' | 'height'>;
15
+ export interface SpotlightViewProps {
16
+ /** Where a clip is on screen before the spotlight (its passage on the page), if it shows. */
17
+ fromRect: (clip: Clip) => ScreenRect | null;
18
+ }
19
+ export declare function SpotlightView({ fromRect }: SpotlightViewProps): import("react").JSX.Element;
@@ -0,0 +1,180 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
4
+ import { Check, ChevronLeft, ChevronRight, Presentation, X } from "lucide-react";
5
+ import { cn } from "@arbidocs/react/ui";
6
+ import { Control } from "./PresentControls.js";
7
+ import { PresentationStage } from "./PresentationStage.js";
8
+ import { spotlightSlide, spotlightSteps, useSpotlight } from "./spotlight.js";
9
+ import { usePresentation } from "./store.js";
10
+ import { usePointerActive } from "./usePointerActive.js";
11
+ const SPOTLIGHT_MS = 300;
12
+ const EASING = "cubic-bezier(0.2, 0, 0, 1)";
13
+ const prefersReducedMotion = (view) => !!view?.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
14
+ function SpotlightView({ fromRect }) {
15
+ const clips = useSpotlight((s) => s.clips);
16
+ const note = useSpotlight((s) => s.note);
17
+ const step = useSpotlight((s) => s.step);
18
+ const captions = usePresentation((s) => s.captions);
19
+ const theme = usePresentation((s) => s.theme);
20
+ const steps = useMemo(() => spotlightSteps(clips), [clips]);
21
+ const ids = steps[step] ?? [];
22
+ const stepKey = ids.join();
23
+ const slide = useMemo(
24
+ () => spotlightSlide(clips, ids, note, { captions, theme }),
25
+ // `ids` is new each render; its key says when it changed.
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
27
+ [clips, stepKey, note, captions, theme]
28
+ );
29
+ const show = useMemo(() => ({ slide, clips }), [slide, clips]);
30
+ const [view, setView] = useState(null);
31
+ const root = useRef(null);
32
+ const rootRef = useCallback((node) => {
33
+ root.current = node;
34
+ if (node) setView(node.ownerDocument.defaultView);
35
+ }, []);
36
+ const active = usePointerActive(view);
37
+ const [kept, setKept] = useState(null);
38
+ const last = useRef(/* @__PURE__ */ new Map());
39
+ const fromRectRef = useRef(fromRect);
40
+ fromRectRef.current = fromRect;
41
+ useLayoutEffect(() => {
42
+ const node = root.current;
43
+ if (!node) return;
44
+ const reduce = prefersReducedMotion(node.ownerDocument.defaultView);
45
+ const next = /* @__PURE__ */ new Map();
46
+ for (const id of stepKey.split(",").filter(Boolean)) {
47
+ const element = node.querySelector(`[data-testid="stage-item-${id}"]`);
48
+ const clip = useSpotlight.getState().clips.find((entry) => entry.id === id);
49
+ if (!element || !clip) continue;
50
+ const to = element.getBoundingClientRect();
51
+ next.set(id, to);
52
+ const from = last.current.get(id) ?? fromRectRef.current(clip);
53
+ if (reduce || !from || !to.width || !to.height || typeof element.animate !== "function") {
54
+ continue;
55
+ }
56
+ element.animate(
57
+ [
58
+ {
59
+ transform: `translate(${from.left - to.left}px, ${from.top - to.top}px) scale(${from.width / to.width}, ${from.height / to.height})`
60
+ },
61
+ { transform: "none" }
62
+ ],
63
+ { duration: SPOTLIGHT_MS, easing: EASING }
64
+ );
65
+ }
66
+ last.current = next;
67
+ }, [stepKey]);
68
+ const backdrop = useRef(null);
69
+ useLayoutEffect(() => {
70
+ const element = backdrop.current;
71
+ if (!element || typeof element.animate !== "function") return;
72
+ if (prefersReducedMotion(element.ownerDocument.defaultView)) return;
73
+ element.animate([{ opacity: 0 }, { opacity: 1 }], { duration: SPOTLIGHT_MS, easing: EASING });
74
+ }, []);
75
+ useEffect(() => {
76
+ if (!view) return;
77
+ const onKeyDown = (event) => {
78
+ if (event.metaKey || event.ctrlKey || event.altKey) return;
79
+ const target = event.target;
80
+ if (target?.closest?.('input, textarea, select, [contenteditable="true"]')) return;
81
+ const state = useSpotlight.getState();
82
+ if (event.key === "Escape") state.hide();
83
+ else if (event.key === "ArrowRight" || event.key === "PageDown") state.goTo(state.step + 1);
84
+ else if (event.key === "ArrowLeft" || event.key === "PageUp") state.goTo(state.step - 1);
85
+ else return;
86
+ event.preventDefault();
87
+ event.stopPropagation();
88
+ };
89
+ view.addEventListener("keydown", onKeyDown, true);
90
+ return () => view.removeEventListener("keydown", onKeyDown, true);
91
+ }, [view]);
92
+ const actions = useSpotlight.getState();
93
+ const isKept = kept === `${stepKey}|${note}`;
94
+ return /* @__PURE__ */ jsxs(
95
+ "div",
96
+ {
97
+ ref: rootRef,
98
+ className: "absolute inset-0 z-30 select-none",
99
+ style: { cursor: active ? "default" : "none" },
100
+ role: "dialog",
101
+ "aria-label": "Spotlight",
102
+ "data-testid": "spotlight",
103
+ children: [
104
+ /* @__PURE__ */ jsx("div", { ref: backdrop, className: "absolute inset-0 bg-black/85" }),
105
+ /* @__PURE__ */ jsx("div", { className: "absolute inset-0 p-4 pb-16", children: /* @__PURE__ */ jsx(PresentationStage, { show, className: "bg-transparent" }) }),
106
+ /* @__PURE__ */ jsxs(
107
+ "div",
108
+ {
109
+ className: cn(
110
+ "absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-0.5 rounded-full bg-black/60 p-1 text-white shadow-lg backdrop-blur transition-opacity duration-300",
111
+ active ? "opacity-100" : "pointer-events-none opacity-0"
112
+ ),
113
+ role: "toolbar",
114
+ "aria-label": "Spotlight",
115
+ "data-testid": "spotlight-controls",
116
+ children: [
117
+ /* @__PURE__ */ jsx(
118
+ Control,
119
+ {
120
+ label: "Previous (\u2190)",
121
+ onClick: () => actions.goTo(step - 1),
122
+ disabled: step === 0,
123
+ testId: "spotlight-previous",
124
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "size-4" })
125
+ }
126
+ ),
127
+ /* @__PURE__ */ jsxs(
128
+ "span",
129
+ {
130
+ className: "min-w-12 text-center text-xs tabular-nums text-white/85",
131
+ "data-testid": "spotlight-position",
132
+ children: [
133
+ step + 1,
134
+ " / ",
135
+ steps.length
136
+ ]
137
+ }
138
+ ),
139
+ /* @__PURE__ */ jsx(
140
+ Control,
141
+ {
142
+ label: "Next (\u2192)",
143
+ onClick: () => actions.goTo(step + 1),
144
+ disabled: step >= steps.length - 1,
145
+ testId: "spotlight-next",
146
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "size-4" })
147
+ }
148
+ ),
149
+ /* @__PURE__ */ jsx("div", { className: "mx-1 h-4 w-px bg-white/25" }),
150
+ /* @__PURE__ */ jsxs(
151
+ "button",
152
+ {
153
+ type: "button",
154
+ className: "inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-full px-3 text-xs text-white/85 hover:bg-white/15 hover:text-white disabled:opacity-60 disabled:hover:bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60 pointer-coarse:h-11",
155
+ disabled: isKept,
156
+ onClick: () => {
157
+ actions.keep();
158
+ setKept(`${stepKey}|${note}`);
159
+ },
160
+ title: "Add this as a slide of the open presentation",
161
+ "data-testid": "spotlight-keep",
162
+ children: [
163
+ isKept ? /* @__PURE__ */ jsx(Check, { className: "size-3.5" }) : /* @__PURE__ */ jsx(Presentation, { className: "size-3.5" }),
164
+ isKept ? "Kept as slide" : "Keep as slide"
165
+ ]
166
+ }
167
+ ),
168
+ /* @__PURE__ */ jsx(Control, { label: "Back to the document (Esc)", onClick: actions.hide, testId: "spotlight-close", children: /* @__PURE__ */ jsx(X, { className: "size-4" }) })
169
+ ]
170
+ }
171
+ )
172
+ ]
173
+ }
174
+ );
175
+ }
176
+ export {
177
+ SPOTLIGHT_MS,
178
+ SpotlightView
179
+ };
180
+ //# sourceMappingURL=SpotlightView.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/presentation/SpotlightView.tsx"],
4
+ "sourcesContent": ["/**\n * The spotlight on screen: the document dims and the gathered clips fly from where they are on\n * their pages into a slide over it, in the same window (a call sharing it goes on sharing it). It is\n * the presentation's own stage (`PresentationStage`), so it looks as a slide of the deck would.\n *\n * \u2190 \u2192 step through the clips together and each alone, Esc goes back to the document. Each move is\n * a FLIP: a clip is drawn where it ends and animated from where it was (its page, or its place on\n * the previous step) by a transform, about 300 ms; with reduced motion it simply appears.\n */\n\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'\nimport { Check, ChevronLeft, ChevronRight, Presentation, X } from 'lucide-react'\nimport { cn } from '@arbidocs/react/ui'\nimport type { Clip } from './model'\nimport { Control } from './PresentControls'\nimport { PresentationStage } from './PresentationStage'\nimport { spotlightSlide, spotlightSteps, useSpotlight } from './spotlight'\nimport { usePresentation } from './store'\nimport { usePointerActive } from './usePointerActive'\n\n/** How long a clip takes to fly into place. */\nexport const SPOTLIGHT_MS = 300\nconst EASING = 'cubic-bezier(0.2, 0, 0, 1)'\n\n/** A box on screen, in CSS pixels. */\nexport type ScreenRect = Pick<DOMRect, 'left' | 'top' | 'width' | 'height'>\n\nexport interface SpotlightViewProps {\n /** Where a clip is on screen before the spotlight (its passage on the page), if it shows. */\n fromRect: (clip: Clip) => ScreenRect | null\n}\n\nconst prefersReducedMotion = (view: Window | null) =>\n !!view?.matchMedia?.('(prefers-reduced-motion: reduce)').matches\n\nexport function SpotlightView({ fromRect }: SpotlightViewProps) {\n const clips = useSpotlight((s) => s.clips)\n const note = useSpotlight((s) => s.note)\n const step = useSpotlight((s) => s.step)\n const captions = usePresentation((s) => s.captions)\n const theme = usePresentation((s) => s.theme)\n const steps = useMemo(() => spotlightSteps(clips), [clips])\n const ids = steps[step] ?? []\n const stepKey = ids.join()\n const slide = useMemo(\n () => spotlightSlide(clips, ids, note, { captions, theme }),\n // `ids` is new each render; its key says when it changed.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [clips, stepKey, note, captions, theme]\n )\n const show = useMemo(() => ({ slide, clips }), [slide, clips])\n\n const [view, setView] = useState<Window | null>(null)\n const root = useRef<HTMLDivElement | null>(null)\n const rootRef = useCallback((node: HTMLDivElement | null) => {\n root.current = node\n if (node) setView(node.ownerDocument.defaultView)\n }, [])\n const active = usePointerActive(view)\n const [kept, setKept] = useState<string | null>(null)\n\n // FLIP: each clip from where it was (on its page, or on the step before) to where it is now.\n const last = useRef(new Map<string, ScreenRect>())\n const fromRectRef = useRef(fromRect)\n fromRectRef.current = fromRect\n useLayoutEffect(() => {\n const node = root.current\n if (!node) return\n const reduce = prefersReducedMotion(node.ownerDocument.defaultView)\n const next = new Map<string, ScreenRect>()\n for (const id of stepKey.split(',').filter(Boolean)) {\n const element = node.querySelector<HTMLElement>(`[data-testid=\"stage-item-${id}\"]`)\n const clip = useSpotlight.getState().clips.find((entry) => entry.id === id)\n if (!element || !clip) continue\n const to = element.getBoundingClientRect()\n next.set(id, to)\n const from = last.current.get(id) ?? fromRectRef.current(clip)\n if (reduce || !from || !to.width || !to.height || typeof element.animate !== 'function') {\n continue\n }\n element.animate(\n [\n {\n transform: `translate(${from.left - to.left}px, ${from.top - to.top}px) scale(${\n from.width / to.width\n }, ${from.height / to.height})`,\n },\n { transform: 'none' },\n ],\n { duration: SPOTLIGHT_MS, easing: EASING }\n )\n }\n last.current = next\n }, [stepKey])\n\n // The document dims as the clips arrive.\n const backdrop = useRef<HTMLDivElement>(null)\n useLayoutEffect(() => {\n const element = backdrop.current\n if (!element || typeof element.animate !== 'function') return\n if (prefersReducedMotion(element.ownerDocument.defaultView)) return\n element.animate([{ opacity: 0 }, { opacity: 1 }], { duration: SPOTLIGHT_MS, easing: EASING })\n }, [])\n\n // Esc back to the document, \u2190 \u2192 through the steps; taken before the viewer's own keys.\n useEffect(() => {\n if (!view) return\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.metaKey || event.ctrlKey || event.altKey) return\n const target = event.target as HTMLElement | null\n if (target?.closest?.('input, textarea, select, [contenteditable=\"true\"]')) return\n const state = useSpotlight.getState()\n if (event.key === 'Escape') state.hide()\n else if (event.key === 'ArrowRight' || event.key === 'PageDown') state.goTo(state.step + 1)\n else if (event.key === 'ArrowLeft' || event.key === 'PageUp') state.goTo(state.step - 1)\n else return\n event.preventDefault()\n event.stopPropagation()\n }\n view.addEventListener('keydown', onKeyDown, true)\n return () => view.removeEventListener('keydown', onKeyDown, true)\n }, [view])\n\n const actions = useSpotlight.getState()\n const isKept = kept === `${stepKey}|${note}`\n return (\n <div\n ref={rootRef}\n className=\"absolute inset-0 z-30 select-none\"\n style={{ cursor: active ? 'default' : 'none' }}\n role=\"dialog\"\n aria-label=\"Spotlight\"\n data-testid=\"spotlight\"\n >\n <div ref={backdrop} className=\"absolute inset-0 bg-black/85\" />\n <div className=\"absolute inset-0 p-4 pb-16\">\n <PresentationStage show={show} className=\"bg-transparent\" />\n </div>\n <div\n className={cn(\n 'absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-0.5 rounded-full bg-black/60 p-1 text-white shadow-lg backdrop-blur transition-opacity duration-300',\n active ? 'opacity-100' : 'pointer-events-none opacity-0'\n )}\n role=\"toolbar\"\n aria-label=\"Spotlight\"\n data-testid=\"spotlight-controls\"\n >\n <Control\n label=\"Previous (\u2190)\"\n onClick={() => actions.goTo(step - 1)}\n disabled={step === 0}\n testId=\"spotlight-previous\"\n >\n <ChevronLeft className=\"size-4\" />\n </Control>\n <span\n className=\"min-w-12 text-center text-xs tabular-nums text-white/85\"\n data-testid=\"spotlight-position\"\n >\n {step + 1} / {steps.length}\n </span>\n <Control\n label=\"Next (\u2192)\"\n onClick={() => actions.goTo(step + 1)}\n disabled={step >= steps.length - 1}\n testId=\"spotlight-next\"\n >\n <ChevronRight className=\"size-4\" />\n </Control>\n <div className=\"mx-1 h-4 w-px bg-white/25\" />\n <button\n type=\"button\"\n className=\"inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-full px-3 text-xs text-white/85 hover:bg-white/15 hover:text-white disabled:opacity-60 disabled:hover:bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60 pointer-coarse:h-11\"\n disabled={isKept}\n onClick={() => {\n actions.keep()\n setKept(`${stepKey}|${note}`)\n }}\n title=\"Add this as a slide of the open presentation\"\n data-testid=\"spotlight-keep\"\n >\n {isKept ? <Check className=\"size-3.5\" /> : <Presentation className=\"size-3.5\" />}\n {isKept ? 'Kept as slide' : 'Keep as slide'}\n </button>\n <Control label=\"Back to the document (Esc)\" onClick={actions.hide} testId=\"spotlight-close\">\n <X className=\"size-4\" />\n </Control>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": ";AAsIM,cAqBE,YArBF;AA5HN,SAAS,aAAa,WAAW,iBAAiB,SAAS,QAAQ,gBAAgB;AACnF,SAAS,OAAO,aAAa,cAAc,cAAc,SAAS;AAClE,SAAS,UAAU;AAEnB,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,gBAAgB,gBAAgB,oBAAoB;AAC7D,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AAG1B,MAAM,eAAe;AAC5B,MAAM,SAAS;AAUf,MAAM,uBAAuB,CAAC,SAC5B,CAAC,CAAC,MAAM,aAAa,kCAAkC,EAAE;AAEpD,SAAS,cAAc,EAAE,SAAS,GAAuB;AAC9D,QAAM,QAAQ,aAAa,CAAC,MAAM,EAAE,KAAK;AACzC,QAAM,OAAO,aAAa,CAAC,MAAM,EAAE,IAAI;AACvC,QAAM,OAAO,aAAa,CAAC,MAAM,EAAE,IAAI;AACvC,QAAM,WAAW,gBAAgB,CAAC,MAAM,EAAE,QAAQ;AAClD,QAAM,QAAQ,gBAAgB,CAAC,MAAM,EAAE,KAAK;AAC5C,QAAM,QAAQ,QAAQ,MAAM,eAAe,KAAK,GAAG,CAAC,KAAK,CAAC;AAC1D,QAAM,MAAM,MAAM,IAAI,KAAK,CAAC;AAC5B,QAAM,UAAU,IAAI,KAAK;AACzB,QAAM,QAAQ;AAAA,IAC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AAAA,kBACV,UAAU;AAAA,kBACV,SAAS,MAAM;AACb,4BAAQ,KAAK;AACb,4BAAQ,GAAG,OAAO,IAAI,IAAI,EAAE;AAAA,kBAC9B;AAAA,kBACA,OAAM;AAAA,kBACN,eAAY;AAAA,kBAEX;AAAA,6BAAS,oBAAC,SAAM,WAAU,YAAW,IAAK,oBAAC,gBAAa,WAAU,YAAW;AAAA,oBAC7E,SAAS,kBAAkB;AAAA;AAAA;AAAA,cAC9B;AAAA,cACA,oBAAC,WAAQ,OAAM,8BAA6B,SAAS,QAAQ,MAAM,QAAO,mBACxE,8BAAC,KAAE,WAAU,UAAS,GACxB;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ;",
6
+ "names": []
7
+ }
@@ -3,7 +3,6 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { memo, useRef, useState } from "react";
4
4
  import { cn } from "@arbidocs/react/ui";
5
5
  import { ClipImage } from "./ClipImage.js";
6
- import { ClipViewControls } from "./ClipViewControls.js";
7
6
  import {
8
7
  frameHeight,
9
8
  moveFrame,
@@ -36,7 +35,6 @@ const StageItem = memo(function StageItem2({
36
35
  }) {
37
36
  const element = useRef(null);
38
37
  const gesture = useRef(null);
39
- const [dragging, setDragging] = useState(false);
40
38
  const [reshape, setReshape] = useState(null);
41
39
  const shown = reshape ? { ...clip, ...reshape.shape } : clip;
42
40
  const box = reshape?.frame ?? frame;
@@ -86,7 +84,6 @@ const StageItem = memo(function StageItem2({
86
84
  const g = gesture.current;
87
85
  if (!g) return;
88
86
  if (!g.next) {
89
- setDragging(true);
90
87
  host.dragging(true);
91
88
  if (element.current) element.current.style.willChange = "transform";
92
89
  }
@@ -117,7 +114,6 @@ const StageItem = memo(function StageItem2({
117
114
  }
118
115
  if (!g.next) return;
119
116
  setReshape(null);
120
- setDragging(false);
121
117
  host.dragging(false);
122
118
  host.guides([]);
123
119
  host.commit(clip.id, g.next.frame, g.next.shape);
@@ -167,7 +163,6 @@ const StageItem = memo(function StageItem2({
167
163
  children: label
168
164
  }
169
165
  ),
170
- selected && !dragging && /* @__PURE__ */ jsx(ClipViewControls, { clip }),
171
166
  selected && CORNERS.map(({ corner, left, top, cursor }) => /* @__PURE__ */ jsx(
172
167
  "div",
173
168
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/presentation/StageItem.tsx"],
4
- "sourcesContent": ["/**\n * One clip on the stage, and its own gestures: moved by dragging it, resized from a corner (its\n * shape kept), reshaped from a side's middle (more or less of the page that way), snapping to the\n * stage and to the other clips.\n *\n * Built for smooth dragging: while a clip is moved or resized nothing re-renders and nothing is\n * laid out again. Its element is moved by a GPU transform (translate, scale) once per animation\n * frame, and the new frame reaches the presentation once, when the drag ends. Only reshaping, which\n * changes what the clip shows, re-renders the clip itself (and nothing else). The component is\n * memoised: other clips, the slide's text and the other slides are untouched by its drags.\n */\n\nimport { memo, useRef, useState, type PointerEvent as ReactPointerEvent } from 'react'\nimport { cn } from '@arbidocs/react/ui'\nimport { ClipImage } from './ClipImage'\nimport { ClipViewControls } from './ClipViewControls'\nimport {\n frameHeight,\n moveFrame,\n reshapeFrame,\n resizeFrame,\n type Clip,\n type Corner,\n type Edge,\n type Frame,\n type Guide,\n type Placed,\n} from './model'\nimport { TEXT_COLORS, clipEdgeCss } from './theme'\n\ntype Kind = 'move' | Corner | Edge\n\nconst isEdge = (kind: Kind): kind is Edge =>\n kind === 'n' || kind === 'e' || kind === 's' || kind === 'w'\n\n/** The handle on each side's middle: drag it to show more (or less) of the page that way. */\nconst EDGES: { edge: Edge; left: string; top: string; cursor: string; label: string }[] = [\n { edge: 'n', left: '50%', top: '0%', cursor: 'ns-resize', label: 'top' },\n { edge: 'e', left: '100%', top: '50%', cursor: 'ew-resize', label: 'right' },\n { edge: 's', left: '50%', top: '100%', cursor: 'ns-resize', label: 'bottom' },\n { edge: 'w', left: '0%', top: '50%', cursor: 'ew-resize', label: 'left' },\n]\n\nconst CORNERS: { corner: Corner; left: string; top: string; cursor: string }[] = [\n { corner: 'nw', left: '0%', top: '0%', cursor: 'nwse-resize' },\n { corner: 'ne', left: '100%', top: '0%', cursor: 'nesw-resize' },\n { corner: 'sw', left: '0%', top: '100%', cursor: 'nesw-resize' },\n { corner: 'se', left: '100%', top: '100%', cursor: 'nwse-resize' },\n]\n\nconst EDGE_CSS = clipEdgeCss()\n\n/** What a stage gives its clips (stable across renders: the clips are memoised). */\nexport interface StageItemHost {\n /** The stage's box on screen, as a gesture begins. */\n stageBox(): DOMRect | null\n /** The other clips of the slide, as a gesture begins: what this one snaps to. */\n others(clipId: string): Placed[]\n select(clipId: string): void\n /** The snap lines to draw while a clip is dragged (empty: none). */\n guides(guides: Guide[]): void\n /** A drag is on (the stage hides the selected clip's floating actions meanwhile). */\n dragging(on: boolean): void\n /** The drag's result, once it ends. */\n commit(clipId: string, frame: Frame, shape?: Pick<Clip, 'rect' | 'aspect'>): void\n}\n\nexport interface StageItemProps {\n clip: Clip\n frame: Frame\n editable: boolean\n selected: boolean\n dim: boolean\n /** Its source label, under it (empty: none). */\n label: string\n host: StageItemHost\n}\n\ninterface Gesture {\n kind: Kind\n pointer: { x: number; y: number }\n frame: Frame\n shape: Pick<Clip, 'rect' | 'aspect'>\n stage: DOMRect\n others: Placed[]\n /** The latest result, applied at the next animation frame and committed at the end. */\n next: { frame: Frame; shape?: Pick<Clip, 'rect' | 'aspect'>; guides: Guide[] } | null\n request: number | null\n guidesKey: string\n}\n\nexport const StageItem = memo(function StageItem({\n clip,\n frame,\n editable,\n selected,\n dim,\n label,\n host,\n}: StageItemProps) {\n const element = useRef<HTMLDivElement>(null)\n const gesture = useRef<Gesture | null>(null)\n const [dragging, setDragging] = useState(false)\n // Being reshaped: drawn as it will be (the one case that re-renders while dragging).\n const [reshape, setReshape] = useState<{\n frame: Frame\n shape: Pick<Clip, 'rect' | 'aspect'>\n } | null>(null)\n\n const shown = reshape ? { ...clip, ...reshape.shape } : clip\n const box = reshape?.frame ?? frame\n\n const view = () => element.current?.ownerDocument.defaultView ?? window\n\n const apply = () => {\n const g = gesture.current\n const el = element.current\n if (!g) return\n g.request = null\n const next = g.next\n if (!next || !el) return\n if (next.shape) {\n setReshape({ frame: next.frame, shape: next.shape })\n } else {\n // Moved or resized: a transform from where the drag began (top left fixed as the origin).\n const dx = (next.frame.x - g.frame.x) * g.stage.width\n const dy = (next.frame.y - g.frame.y) * g.stage.height\n const scale = next.frame.w / g.frame.w\n el.style.transform = `translate3d(${dx}px, ${dy}px, 0) scale(${scale})`\n }\n const key = next.guides.map((guide) => `${guide.axis}${guide.at}`).join()\n if (key !== g.guidesKey) {\n g.guidesKey = key\n host.guides(next.guides)\n }\n }\n\n const start = (event: ReactPointerEvent, kind: Kind) => {\n if (!editable || event.button !== 0) return\n const stage = host.stageBox()\n if (!stage) return\n event.preventDefault()\n event.stopPropagation()\n host.select(clip.id)\n event.currentTarget.setPointerCapture(event.pointerId)\n gesture.current = {\n kind,\n pointer: { x: event.clientX, y: event.clientY },\n frame,\n shape: { rect: clip.rect, aspect: clip.aspect },\n stage,\n others: host.others(clip.id),\n next: null,\n request: null,\n guidesKey: '',\n }\n }\n\n const move = (event: ReactPointerEvent) => {\n const g = gesture.current\n if (!g) return\n if (!g.next) {\n // The first move: the drag is on (handles and actions hide; the layer is promoted).\n setDragging(true)\n host.dragging(true)\n if (element.current) element.current.style.willChange = 'transform'\n }\n const dx = (event.clientX - g.pointer.x) / g.stage.width\n const dy = (event.clientY - g.pointer.y) / g.stage.height\n // Alt (Option) places freely, without snapping.\n const free = event.altKey\n if (isEdge(g.kind)) {\n const result = reshapeFrame(g.frame, g.shape, g.kind, dx, dy, g.others, free)\n g.next = {\n frame: result.frame,\n shape: { rect: result.rect, aspect: result.aspect },\n guides: result.guides,\n }\n } else {\n g.next =\n g.kind === 'move'\n ? moveFrame(g.frame, g.shape.aspect, dx, dy, g.others, free)\n : resizeFrame(g.frame, g.shape.aspect, g.kind, dx, dy, g.others, free)\n }\n g.request ??= view().requestAnimationFrame(apply)\n }\n\n const end = () => {\n const g = gesture.current\n gesture.current = null\n if (!g) return\n if (g.request !== null) view().cancelAnimationFrame(g.request)\n const el = element.current\n if (el) {\n el.style.transform = ''\n el.style.willChange = ''\n }\n if (!g.next) return // a click: the clip is selected, nothing moved\n setReshape(null)\n setDragging(false)\n host.dragging(false)\n host.guides([])\n host.commit(clip.id, g.next.frame, g.next.shape)\n }\n\n return (\n <div\n ref={element}\n className={cn(\n 'absolute origin-top-left',\n // Lifted off the background (a picture that is part of the slide's design is not).\n !clip.plain && 'rounded-[0.6cqw] shadow-[0_0.5cqw_1.6cqw_rgba(0,0,0,0.5)]',\n editable && 'cursor-move touch-none',\n selected && 'outline outline-2 outline-offset-2 outline-primary',\n dim && 'opacity-30'\n )}\n style={{\n left: `${box.x * 100}%`,\n top: `${box.y * 100}%`,\n width: `${box.w * 100}%`,\n height: `${frameHeight(box, shown.aspect) * 100}%`,\n }}\n onPointerDown={(event) => start(event, 'move')}\n onPointerMove={move}\n onPointerUp={end}\n onPointerCancel={end}\n data-testid={`stage-item-${clip.id}`}\n >\n {/* Softly rounded, with a faint light edge: crisp on any background. */}\n <div className={cn('absolute inset-0 overflow-hidden', !clip.plain && 'rounded-[0.6cqw]')}>\n <ClipImage clip={shown} live={!editable} />\n {/* A page's text fades out at the clip's edge rather than being sliced. */}\n {clip.kind === 'pdf' && !clip.plain && (\n <div\n className=\"pointer-events-none absolute inset-0\"\n style={{ background: EDGE_CSS }}\n data-testid=\"stage-clip-edge\"\n />\n )}\n {!clip.plain && (\n <div className=\"pointer-events-none absolute inset-0 rounded-[0.6cqw] ring-1 ring-inset ring-white/15\" />\n )}\n </div>\n {label && !clip.plain && (\n // Under the clip, in the room the layout keeps (CAPTION_SPACE): never over it.\n <div\n className=\"pointer-events-none absolute left-0 top-full mt-[0.5cqw] max-w-full truncate text-[1.7cqw] leading-tight\"\n style={{ color: TEXT_COLORS.muted }}\n >\n {label}\n </div>\n )}\n {/* Scroll and zoom what it shows, on a layer over it (not while it is dragged). */}\n {selected && !dragging && <ClipViewControls clip={clip} />}\n {/* A handle on each corner (a small dot in a finger-sized target), and a bar on each side's\n middle; their moves bubble to the clip's handlers while the gesture lasts. */}\n {selected &&\n CORNERS.map(({ corner, left, top, cursor }) => (\n <div\n key={corner}\n className=\"absolute flex size-6 -translate-x-1/2 -translate-y-1/2 items-center justify-center pointer-coarse:size-11\"\n style={{ left, top, cursor, touchAction: 'none' }}\n onPointerDown={(event) => start(event, corner)}\n aria-label={`Resize from the ${corner} corner`}\n data-testid={`stage-item-resize-${corner}`}\n >\n <span className=\"pointer-events-none size-3 rounded-full border-2 border-primary bg-background\" />\n </div>\n ))}\n {selected &&\n EDGES.map(({ edge, left, top, cursor, label: side }) => (\n <div\n key={edge}\n className=\"absolute flex size-6 -translate-x-1/2 -translate-y-1/2 items-center justify-center pointer-coarse:size-11\"\n style={{ left, top, cursor, touchAction: 'none' }}\n onPointerDown={(event) => start(event, edge)}\n aria-label={`Show more or less at the ${side}`}\n title=\"Drag to show more or less of the page\"\n data-testid={`stage-item-reshape-${edge}`}\n >\n <span\n className={cn(\n 'pointer-events-none rounded-full border-2 border-primary bg-background',\n edge === 'n' || edge === 's' ? 'h-2 w-4' : 'h-4 w-2'\n )}\n />\n </div>\n ))}\n </div>\n )\n})\n"],
5
- "mappings": ";AAqOM,SACE,KADF;AAzNN,SAAS,MAAM,QAAQ,gBAAwD;AAC/E,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AACP,SAAS,aAAa,mBAAmB;AAIzC,MAAM,SAAS,CAAC,SACd,SAAS,OAAO,SAAS,OAAO,SAAS,OAAO,SAAS;AAG3D,MAAM,QAAoF;AAAA,EACxF,EAAE,MAAM,KAAK,MAAM,OAAO,KAAK,MAAM,QAAQ,aAAa,OAAO,MAAM;AAAA,EACvE,EAAE,MAAM,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MAAM;AAAA,YAC7C,cAAY,mBAAmB,MAAM;AAAA,YACrC,eAAa,qBAAqB,MAAM;AAAA,YAExC,8BAAC,UAAK,WAAU,iFAAgF;AAAA;AAAA,UAP3F;AAAA,QAQP,CACD;AAAA,QACF,YACC,MAAM,IAAI,CAAC,EAAE,MAAM,MAAM,KAAK,QAAQ,OAAO,KAAK,MAChD;AAAA,UAAC;AAAA;AAAA,YAEC,WAAU;AAAA,YACV,OAAO,EAAE,MAAM,KAAK,QAAQ,aAAa,OAAO;AAAA,YAChD,eAAe,CAAC,UAAU,MAAM,OAAO,IAAI;AAAA,YAC3C,cAAY,4BAA4B,IAAI;AAAA,YAC5C,OAAM;AAAA,YACN,eAAa,sBAAsB,IAAI;AAAA,YAEvC;AAAA,cAAC;AAAA;AAAA,gBACC,WAAW;AAAA,kBACT;AAAA,kBACA,SAAS,OAAO,SAAS,MAAM,YAAY;AAAA,gBAC7C;AAAA;AAAA,YACF;AAAA;AAAA,UAbK;AAAA,QAcP,CACD;AAAA;AAAA;AAAA,EACL;AAEJ,CAAC;",
4
+ "sourcesContent": ["/**\n * One clip on the stage, and its own gestures: moved by dragging it, resized from a corner (its\n * shape kept), reshaped from a side's middle (more or less of the page that way), snapping to the\n * stage and to the other clips.\n *\n * Built for smooth dragging: while a clip is moved or resized nothing re-renders and nothing is\n * laid out again. Its element is moved by a GPU transform (translate, scale) once per animation\n * frame, and the new frame reaches the presentation once, when the drag ends. Only reshaping, which\n * changes what the clip shows, re-renders the clip itself (and nothing else). The component is\n * memoised: other clips, the slide's text and the other slides are untouched by its drags.\n */\n\nimport { memo, useRef, useState, type PointerEvent as ReactPointerEvent } from 'react'\nimport { cn } from '@arbidocs/react/ui'\nimport { ClipImage } from './ClipImage'\nimport {\n frameHeight,\n moveFrame,\n reshapeFrame,\n resizeFrame,\n type Clip,\n type Corner,\n type Edge,\n type Frame,\n type Guide,\n type Placed,\n} from './model'\nimport { TEXT_COLORS, clipEdgeCss } from './theme'\n\ntype Kind = 'move' | Corner | Edge\n\nconst isEdge = (kind: Kind): kind is Edge =>\n kind === 'n' || kind === 'e' || kind === 's' || kind === 'w'\n\n/** The handle on each side's middle: drag it to show more (or less) of the page that way. */\nconst EDGES: { edge: Edge; left: string; top: string; cursor: string; label: string }[] = [\n { edge: 'n', left: '50%', top: '0%', cursor: 'ns-resize', label: 'top' },\n { edge: 'e', left: '100%', top: '50%', cursor: 'ew-resize', label: 'right' },\n { edge: 's', left: '50%', top: '100%', cursor: 'ns-resize', label: 'bottom' },\n { edge: 'w', left: '0%', top: '50%', cursor: 'ew-resize', label: 'left' },\n]\n\nconst CORNERS: { corner: Corner; left: string; top: string; cursor: string }[] = [\n { corner: 'nw', left: '0%', top: '0%', cursor: 'nwse-resize' },\n { corner: 'ne', left: '100%', top: '0%', cursor: 'nesw-resize' },\n { corner: 'sw', left: '0%', top: '100%', cursor: 'nesw-resize' },\n { corner: 'se', left: '100%', top: '100%', cursor: 'nwse-resize' },\n]\n\nconst EDGE_CSS = clipEdgeCss()\n\n/** What a stage gives its clips (stable across renders: the clips are memoised). */\nexport interface StageItemHost {\n /** The stage's box on screen, as a gesture begins. */\n stageBox(): DOMRect | null\n /** The other clips of the slide, as a gesture begins: what this one snaps to. */\n others(clipId: string): Placed[]\n select(clipId: string): void\n /** The snap lines to draw while a clip is dragged (empty: none). */\n guides(guides: Guide[]): void\n /** A drag is on (the stage hides the selected clip's floating actions meanwhile). */\n dragging(on: boolean): void\n /** The drag's result, once it ends. */\n commit(clipId: string, frame: Frame, shape?: Pick<Clip, 'rect' | 'aspect'>): void\n}\n\nexport interface StageItemProps {\n clip: Clip\n frame: Frame\n editable: boolean\n selected: boolean\n dim: boolean\n /** Its source label, under it (empty: none). */\n label: string\n host: StageItemHost\n}\n\ninterface Gesture {\n kind: Kind\n pointer: { x: number; y: number }\n frame: Frame\n shape: Pick<Clip, 'rect' | 'aspect'>\n stage: DOMRect\n others: Placed[]\n /** The latest result, applied at the next animation frame and committed at the end. */\n next: { frame: Frame; shape?: Pick<Clip, 'rect' | 'aspect'>; guides: Guide[] } | null\n request: number | null\n guidesKey: string\n}\n\nexport const StageItem = memo(function StageItem({\n clip,\n frame,\n editable,\n selected,\n dim,\n label,\n host,\n}: StageItemProps) {\n const element = useRef<HTMLDivElement>(null)\n const gesture = useRef<Gesture | null>(null)\n // Being reshaped: drawn as it will be (the one case that re-renders while dragging).\n const [reshape, setReshape] = useState<{\n frame: Frame\n shape: Pick<Clip, 'rect' | 'aspect'>\n } | null>(null)\n\n const shown = reshape ? { ...clip, ...reshape.shape } : clip\n const box = reshape?.frame ?? frame\n\n const view = () => element.current?.ownerDocument.defaultView ?? window\n\n const apply = () => {\n const g = gesture.current\n const el = element.current\n if (!g) return\n g.request = null\n const next = g.next\n if (!next || !el) return\n if (next.shape) {\n setReshape({ frame: next.frame, shape: next.shape })\n } else {\n // Moved or resized: a transform from where the drag began (top left fixed as the origin).\n const dx = (next.frame.x - g.frame.x) * g.stage.width\n const dy = (next.frame.y - g.frame.y) * g.stage.height\n const scale = next.frame.w / g.frame.w\n el.style.transform = `translate3d(${dx}px, ${dy}px, 0) scale(${scale})`\n }\n const key = next.guides.map((guide) => `${guide.axis}${guide.at}`).join()\n if (key !== g.guidesKey) {\n g.guidesKey = key\n host.guides(next.guides)\n }\n }\n\n const start = (event: ReactPointerEvent, kind: Kind) => {\n if (!editable || event.button !== 0) return\n const stage = host.stageBox()\n if (!stage) return\n event.preventDefault()\n event.stopPropagation()\n host.select(clip.id)\n event.currentTarget.setPointerCapture(event.pointerId)\n gesture.current = {\n kind,\n pointer: { x: event.clientX, y: event.clientY },\n frame,\n shape: { rect: clip.rect, aspect: clip.aspect },\n stage,\n others: host.others(clip.id),\n next: null,\n request: null,\n guidesKey: '',\n }\n }\n\n const move = (event: ReactPointerEvent) => {\n const g = gesture.current\n if (!g) return\n if (!g.next) {\n // The first move: the drag is on (handles and actions hide; the layer is promoted).\n host.dragging(true)\n if (element.current) element.current.style.willChange = 'transform'\n }\n const dx = (event.clientX - g.pointer.x) / g.stage.width\n const dy = (event.clientY - g.pointer.y) / g.stage.height\n // Alt (Option) places freely, without snapping.\n const free = event.altKey\n if (isEdge(g.kind)) {\n const result = reshapeFrame(g.frame, g.shape, g.kind, dx, dy, g.others, free)\n g.next = {\n frame: result.frame,\n shape: { rect: result.rect, aspect: result.aspect },\n guides: result.guides,\n }\n } else {\n g.next =\n g.kind === 'move'\n ? moveFrame(g.frame, g.shape.aspect, dx, dy, g.others, free)\n : resizeFrame(g.frame, g.shape.aspect, g.kind, dx, dy, g.others, free)\n }\n g.request ??= view().requestAnimationFrame(apply)\n }\n\n const end = () => {\n const g = gesture.current\n gesture.current = null\n if (!g) return\n if (g.request !== null) view().cancelAnimationFrame(g.request)\n const el = element.current\n if (el) {\n el.style.transform = ''\n el.style.willChange = ''\n }\n if (!g.next) return // a click: the clip is selected, nothing moved\n setReshape(null)\n host.dragging(false)\n host.guides([])\n host.commit(clip.id, g.next.frame, g.next.shape)\n }\n\n return (\n <div\n ref={element}\n className={cn(\n 'absolute origin-top-left',\n // Lifted off the background (a picture that is part of the slide's design is not).\n !clip.plain && 'rounded-[0.6cqw] shadow-[0_0.5cqw_1.6cqw_rgba(0,0,0,0.5)]',\n editable && 'cursor-move touch-none',\n selected && 'outline outline-2 outline-offset-2 outline-primary',\n dim && 'opacity-30'\n )}\n style={{\n left: `${box.x * 100}%`,\n top: `${box.y * 100}%`,\n width: `${box.w * 100}%`,\n height: `${frameHeight(box, shown.aspect) * 100}%`,\n }}\n onPointerDown={(event) => start(event, 'move')}\n onPointerMove={move}\n onPointerUp={end}\n onPointerCancel={end}\n data-testid={`stage-item-${clip.id}`}\n >\n {/* Softly rounded, with a faint light edge: crisp on any background. */}\n <div className={cn('absolute inset-0 overflow-hidden', !clip.plain && 'rounded-[0.6cqw]')}>\n <ClipImage clip={shown} live={!editable} />\n {/* A page's text fades out at the clip's edge rather than being sliced. */}\n {clip.kind === 'pdf' && !clip.plain && (\n <div\n className=\"pointer-events-none absolute inset-0\"\n style={{ background: EDGE_CSS }}\n data-testid=\"stage-clip-edge\"\n />\n )}\n {!clip.plain && (\n <div className=\"pointer-events-none absolute inset-0 rounded-[0.6cqw] ring-1 ring-inset ring-white/15\" />\n )}\n </div>\n {label && !clip.plain && (\n // Under the clip, in the room the layout keeps (CAPTION_SPACE): never over it.\n <div\n className=\"pointer-events-none absolute left-0 top-full mt-[0.5cqw] max-w-full truncate text-[1.7cqw] leading-tight\"\n style={{ color: TEXT_COLORS.muted }}\n >\n {label}\n </div>\n )}\n {/* A handle on each corner (a small dot in a finger-sized target), and a bar on each side's\n middle; their moves bubble to the clip's handlers while the gesture lasts. */}\n {selected &&\n CORNERS.map(({ corner, left, top, cursor }) => (\n <div\n key={corner}\n className=\"absolute flex size-6 -translate-x-1/2 -translate-y-1/2 items-center justify-center pointer-coarse:size-11\"\n style={{ left, top, cursor, touchAction: 'none' }}\n onPointerDown={(event) => start(event, corner)}\n aria-label={`Resize from the ${corner} corner`}\n data-testid={`stage-item-resize-${corner}`}\n >\n <span className=\"pointer-events-none size-3 rounded-full border-2 border-primary bg-background\" />\n </div>\n ))}\n {selected &&\n EDGES.map(({ edge, left, top, cursor, label: side }) => (\n <div\n key={edge}\n className=\"absolute flex size-6 -translate-x-1/2 -translate-y-1/2 items-center justify-center pointer-coarse:size-11\"\n style={{ left, top, cursor, touchAction: 'none' }}\n onPointerDown={(event) => start(event, edge)}\n aria-label={`Show more or less at the ${side}`}\n title=\"Drag to show more or less of the page\"\n data-testid={`stage-item-reshape-${edge}`}\n >\n <span\n className={cn(\n 'pointer-events-none rounded-full border-2 border-primary bg-background',\n edge === 'n' || edge === 's' ? 'h-2 w-4' : 'h-4 w-2'\n )}\n />\n </div>\n ))}\n </div>\n )\n})\n"],
5
+ "mappings": ";AAiOM,SACE,KADF;AArNN,SAAS,MAAM,QAAQ,gBAAwD;AAC/E,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,E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EC,WAAU;AAAA,YACV,OAAO,EAAE,MAAM,KAAK,QAAQ,aAAa,OAAO;AAAA,YAChD,eAAe,CAAC,UAAU,MAAM,OAAO,MAAM;AAAA,YAC7C,cAAY,mBAAmB,MAAM;AAAA,YACrC,eAAa,qBAAqB,MAAM;AAAA,YAExC,8BAAC,UAAK,WAAU,iFAAgF;AAAA;AAAA,UAP3F;AAAA,QAQP,CACD;AAAA,QACF,YACC,MAAM,IAAI,CAAC,EAAE,MAAM,MAAM,KAAK,QAAQ,OAAO,KAAK,MAChD;AAAA,UAAC;AAAA;AAAA,YAEC,WAAU;AAAA,YACV,OAAO,EAAE,MAAM,KAAK,QAAQ,aAAa,OAAO;AAAA,YAChD,eAAe,CAAC,UAAU,MAAM,OAAO,IAAI;AAAA,YAC3C,cAAY,4BAA4B,IAAI;AAAA,YAC5C,OAAM;AAAA,YACN,eAAa,sBAAsB,IAAI;AAAA,YAEvC;AAAA,cAAC;AAAA;AAAA,gBACC,WAAW;AAAA,kBACT;AAAA,kBACA,SAAS,OAAO,SAAS,MAAM,YAAY;AAAA,gBAC7C;AAAA;AAAA,YACF;AAAA;AAAA,UAbK;AAAA,QAcP,CACD;AAAA;AAAA;AAAA,EACL;AAEJ,CAAC;",
6
6
  "names": ["StageItem"]
7
7
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Clipping a passage with one click: the parser places each passage on its page (`page_bbox`,
3
+ * fractions of the page), so in clip mode the passage under the pointer is outlined and a click
4
+ * clips exactly its box, with a little room around it — the same room the server leaves when it
5
+ * clips a passage for a slide (`PASSAGE_MARGIN_X` / `_Y` in its presentation tool).
6
+ */
7
+ import type { Rect } from './model';
8
+ /** Room kept around a clipped passage, as fractions of the page's width and height. */
9
+ export declare const PASSAGE_MARGIN_X = 0.015;
10
+ export declare const PASSAGE_MARGIN_Y = 0.008;
11
+ /** A passage's box `[x0, y0, x1, y1]` as the area to clip: with its margin, kept on the page. */
12
+ export declare function passageClipRect([x0, y0, x1, y1]: readonly [number, number, number, number]): Rect;
13
+ /**
14
+ * The passage at a point of the page (fractions), if any: the smallest one holding it, so a
15
+ * caption inside a figure's box wins over the figure.
16
+ */
17
+ export declare function passageAt(passages: readonly Rect[], x: number, y: number): Rect | null;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ const PASSAGE_MARGIN_X = 0.015;
3
+ const PASSAGE_MARGIN_Y = 8e-3;
4
+ function passageClipRect([x0, y0, x1, y1]) {
5
+ const left = Math.max(0, x0 - PASSAGE_MARGIN_X);
6
+ const top = Math.max(0, y0 - PASSAGE_MARGIN_Y);
7
+ const right = Math.min(1, x1 + PASSAGE_MARGIN_X);
8
+ const bottom = Math.min(1, y1 + PASSAGE_MARGIN_Y);
9
+ return { x: left, y: top, w: right - left, h: bottom - top };
10
+ }
11
+ function passageAt(passages, x, y) {
12
+ let best = null;
13
+ for (const passage of passages) {
14
+ const inside = x >= passage.x && x <= passage.x + passage.w && y >= passage.y && y <= passage.y + passage.h;
15
+ if (inside && (!best || passage.w * passage.h < best.w * best.h)) best = passage;
16
+ }
17
+ return best;
18
+ }
19
+ export {
20
+ PASSAGE_MARGIN_X,
21
+ PASSAGE_MARGIN_Y,
22
+ passageAt,
23
+ passageClipRect
24
+ };
25
+ //# sourceMappingURL=passage-clip.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/presentation/passage-clip.ts"],
4
+ "sourcesContent": ["/**\n * Clipping a passage with one click: the parser places each passage on its page (`page_bbox`,\n * fractions of the page), so in clip mode the passage under the pointer is outlined and a click\n * clips exactly its box, with a little room around it \u2014 the same room the server leaves when it\n * clips a passage for a slide (`PASSAGE_MARGIN_X` / `_Y` in its presentation tool).\n */\n\nimport type { Rect } from './model'\n\n/** Room kept around a clipped passage, as fractions of the page's width and height. */\nexport const PASSAGE_MARGIN_X = 0.015\nexport const PASSAGE_MARGIN_Y = 0.008\n\n/** A passage's box `[x0, y0, x1, y1]` as the area to clip: with its margin, kept on the page. */\nexport function passageClipRect([x0, y0, x1, y1]: readonly [number, number, number, number]): Rect {\n const left = Math.max(0, x0 - PASSAGE_MARGIN_X)\n const top = Math.max(0, y0 - PASSAGE_MARGIN_Y)\n const right = Math.min(1, x1 + PASSAGE_MARGIN_X)\n const bottom = Math.min(1, y1 + PASSAGE_MARGIN_Y)\n return { x: left, y: top, w: right - left, h: bottom - top }\n}\n\n/**\n * The passage at a point of the page (fractions), if any: the smallest one holding it, so a\n * caption inside a figure's box wins over the figure.\n */\nexport function passageAt(passages: readonly Rect[], x: number, y: number): Rect | null {\n let best: Rect | null = null\n for (const passage of passages) {\n const inside =\n x >= passage.x && x <= passage.x + passage.w && y >= passage.y && y <= passage.y + passage.h\n if (inside && (!best || passage.w * passage.h < best.w * best.h)) best = passage\n }\n return best\n}\n"],
5
+ "mappings": ";AAUO,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AAGzB,SAAS,gBAAgB,CAAC,IAAI,IAAI,IAAI,EAAE,GAAoD;AACjG,QAAM,OAAO,KAAK,IAAI,GAAG,KAAK,gBAAgB;AAC9C,QAAM,MAAM,KAAK,IAAI,GAAG,KAAK,gBAAgB;AAC7C,QAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,gBAAgB;AAC/C,QAAM,SAAS,KAAK,IAAI,GAAG,KAAK,gBAAgB;AAChD,SAAO,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,MAAM,GAAG,SAAS,IAAI;AAC7D;AAMO,SAAS,UAAU,UAA2B,GAAW,GAAwB;AACtF,MAAI,OAAoB;AACxB,aAAW,WAAW,UAAU;AAC9B,UAAM,SACJ,KAAK,QAAQ,KAAK,KAAK,QAAQ,IAAI,QAAQ,KAAK,KAAK,QAAQ,KAAK,KAAK,QAAQ,IAAI,QAAQ;AAC7F,QAAI,WAAW,CAAC,QAAQ,QAAQ,IAAI,QAAQ,IAAI,KAAK,IAAI,KAAK,GAAI,QAAO;AAAA,EAC3E;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The spotlight: clips gathered in the document viewer (from one document or several) and shown,
3
+ * on request, as a slide over the viewer itself — the same window, so a call sharing it keeps
4
+ * sharing it. It is transient: nothing reaches the presentation unless "Keep as slide" (or "Add to
5
+ * the presentation") puts it there.
6
+ *
7
+ * Kept in memory only, like the presentation (a clip holds its decrypted file), and cleared when
8
+ * another user signs in (`owner`).
9
+ */
10
+ import { type Clip, type Slide } from './model';
11
+ import { reserveOf, type NewClip } from './store';
12
+ /** A spotlight slide holds this many clips at most; more are shown on further slides. */
13
+ export declare const SPOTLIGHT_PER_SLIDE = 4;
14
+ interface SpotlightState {
15
+ clips: Clip[];
16
+ /** A line of text shown as the spotlight's title (empty: none). */
17
+ note: string;
18
+ /** The spotlight is on screen. */
19
+ showing: boolean;
20
+ /** Which of its steps (`spotlightSteps`) is shown. */
21
+ step: number;
22
+ /** The user the clips were gathered by. */
23
+ owner: string | null;
24
+ /**
25
+ * The viewer's Clip mode is on: kept here, not in the viewer, so it stays on as the viewer opens
26
+ * one document after another.
27
+ */
28
+ clipping: boolean;
29
+ }
30
+ interface SpotlightActions {
31
+ gather(clip: NewClip): string;
32
+ remove(clipId: string): void;
33
+ setNote(note: string): void;
34
+ show(): void;
35
+ hide(): void;
36
+ goTo(step: number): void;
37
+ /** The step on screen, as a slide of the open presentation (after its current slide). */
38
+ keep(): void;
39
+ /** The gathered clips, into the presentation's tray (not placed); the spotlight is emptied. */
40
+ addToTray(): void;
41
+ clear(): void;
42
+ /** Gathering for this user: another's clips are dropped. */
43
+ own(userId: string | null): void;
44
+ setClipping(on: boolean): void;
45
+ }
46
+ export type SpotlightStore = SpotlightState & SpotlightActions;
47
+ /**
48
+ * What ← → step through: the clips together (up to four a slide), and, where a slide shows more
49
+ * than one, each of them alone after it. Each step lists clip ids.
50
+ */
51
+ export declare function spotlightSteps(clips: readonly Pick<Clip, 'id'>[]): string[][];
52
+ /**
53
+ * A step as a slide, arranged as the presentation arranges one (`autoLayout`: two tall clips go
54
+ * side by side, two wide ones stack), with the note as its title and the presentation's look.
55
+ */
56
+ export declare function spotlightSlide(clips: readonly Clip[], ids: readonly string[], note: string, look: Parameters<typeof reserveOf>[1]): Slide;
57
+ export declare const useSpotlight: import("zustand").UseBoundStore<import("zustand").StoreApi<SpotlightStore>>;
58
+ export {};