@bendyline/squisq-editor-react 2.1.0 → 2.3.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 (415) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +40 -0
  3. package/dist/chunk-54UGTQBO.js +862 -0
  4. package/dist/chunk-5JMHFAVW.js +2408 -0
  5. package/dist/chunk-5Q4JN4I5.js +132 -0
  6. package/dist/chunk-6VDYKI3L.js +49 -0
  7. package/dist/chunk-GS7QWYFT.js +9 -0
  8. package/dist/chunk-MJJK7YQB.js +949 -0
  9. package/dist/chunk-NITZVAXL.js +986 -0
  10. package/dist/chunk-TRCKHRBS.js +35234 -0
  11. package/dist/chunk-V44VP242.js +3256 -0
  12. package/dist/image-editor/index.d.ts +223 -0
  13. package/dist/image-editor/index.js +15 -0
  14. package/dist/index.d.ts +2060 -4040
  15. package/dist/index.js +496 -40014
  16. package/dist/json-editor/index.d.ts +27 -0
  17. package/dist/json-editor/index.js +7 -0
  18. package/dist/monaco.d.ts +1 -1
  19. package/dist/monaco.js +1 -2
  20. package/dist/recorder/index.d.ts +407 -0
  21. package/dist/recorder/index.js +43 -0
  22. package/dist/shell/index.d.ts +9 -0
  23. package/dist/shell/index.js +22 -0
  24. package/dist/shell-BxSCBm4H.d.ts +1064 -0
  25. package/dist/styles/index.css +598 -161
  26. package/dist/teleprompter/index.d.ts +497 -0
  27. package/dist/teleprompter/index.js +57 -0
  28. package/package.json +34 -8
  29. package/dist/index.js.map +0 -1
  30. package/dist/monaco.js.map +0 -1
  31. package/src/BlockCardView.tsx +0 -121
  32. package/src/BlockPreviewPanel.tsx +0 -69
  33. package/src/BlockPropertiesPopover.tsx +0 -222
  34. package/src/DocumentSettingsDialog.tsx +0 -272
  35. package/src/DropZoneOverlay.tsx +0 -137
  36. package/src/EditorContext.tsx +0 -1274
  37. package/src/EditorShell.tsx +0 -1358
  38. package/src/EmojiPicker.tsx +0 -332
  39. package/src/FolderView.tsx +0 -131
  40. package/src/Icon.tsx +0 -26
  41. package/src/ImageEditor.tsx +0 -395
  42. package/src/ImageNodeView.tsx +0 -284
  43. package/src/ImageViewer.tsx +0 -221
  44. package/src/InlineIcon.ts +0 -84
  45. package/src/InlinePreviewGutter.tsx +0 -590
  46. package/src/LinkDialog.tsx +0 -276
  47. package/src/MediaBin.tsx +0 -500
  48. package/src/MentionExtension.tsx +0 -261
  49. package/src/OutlinePanel.tsx +0 -547
  50. package/src/PlainHtmlPreview.tsx +0 -277
  51. package/src/PreviewControls.tsx +0 -1265
  52. package/src/PreviewPanel.tsx +0 -426
  53. package/src/RawEditor.tsx +0 -743
  54. package/src/RecorderEntry.tsx +0 -162
  55. package/src/StatusBar.tsx +0 -51
  56. package/src/TemplateAnnotation.ts +0 -167
  57. package/src/TemplateContentPreview.tsx +0 -56
  58. package/src/TemplatePicker.tsx +0 -1314
  59. package/src/ThemeCustomizerPanel.tsx +0 -304
  60. package/src/ThemePicker.tsx +0 -433
  61. package/src/TimelineBlockPreview.tsx +0 -37
  62. package/src/TimelineTrack.tsx +0 -671
  63. package/src/Toolbar.tsx +0 -2885
  64. package/src/Tooltip.tsx +0 -142
  65. package/src/TransitionPicker.tsx +0 -390
  66. package/src/VersionHistoryPanel.tsx +0 -359
  67. package/src/ViewMenuPanel.tsx +0 -189
  68. package/src/ViewSwitcher.tsx +0 -56
  69. package/src/WysiwygEditor.tsx +0 -806
  70. package/src/__tests__/blockProperties.test.ts +0 -92
  71. package/src/__tests__/blockPropertiesPopoverTheme.test.tsx +0 -33
  72. package/src/__tests__/blockRange.test.ts +0 -105
  73. package/src/__tests__/blockTagActivity.test.ts +0 -183
  74. package/src/__tests__/buildDocumentPreviewMarkdown.test.ts +0 -75
  75. package/src/__tests__/buildPreviewDocContent.test.ts +0 -65
  76. package/src/__tests__/buildPreviewDocTransition.test.ts +0 -92
  77. package/src/__tests__/canvasSurfaceTextEditing.test.tsx +0 -60
  78. package/src/__tests__/codeContextSectionView.test.tsx +0 -97
  79. package/src/__tests__/codeContextZoneManager.test.ts +0 -127
  80. package/src/__tests__/createShapeLayer.test.ts +0 -46
  81. package/src/__tests__/customLayoutManagerTheme.test.tsx +0 -34
  82. package/src/__tests__/detectMarkdown.test.ts +0 -73
  83. package/src/__tests__/diffContextSections.test.ts +0 -39
  84. package/src/__tests__/documentSettingsDialog.test.tsx +0 -197
  85. package/src/__tests__/drawingShapeRoundTrip.test.ts +0 -49
  86. package/src/__tests__/editorScrollHandoff.test.tsx +0 -102
  87. package/src/__tests__/editorScrollSync.test.ts +0 -65
  88. package/src/__tests__/editorShellCodeContext.test.tsx +0 -86
  89. package/src/__tests__/editorShellProps.test.tsx +0 -550
  90. package/src/__tests__/embeddedMedia.test.ts +0 -48
  91. package/src/__tests__/emojiPicker.test.tsx +0 -93
  92. package/src/__tests__/fileKind.test.ts +0 -112
  93. package/src/__tests__/findMode.test.tsx +0 -104
  94. package/src/__tests__/findModel.test.ts +0 -55
  95. package/src/__tests__/headingTransition.test.ts +0 -176
  96. package/src/__tests__/imageEditAffordance.test.tsx +0 -272
  97. package/src/__tests__/imageEditModalContract.test.tsx +0 -119
  98. package/src/__tests__/imageEditorShell.test.tsx +0 -94
  99. package/src/__tests__/imageEditorState.test.ts +0 -171
  100. package/src/__tests__/inlinePreviewGutter.test.tsx +0 -62
  101. package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +0 -103
  102. package/src/__tests__/jsonEditor.test.tsx +0 -223
  103. package/src/__tests__/layersPanel.test.tsx +0 -167
  104. package/src/__tests__/layoutChildRoundTrip.test.ts +0 -71
  105. package/src/__tests__/linkDialogDocPicker.test.tsx +0 -137
  106. package/src/__tests__/majorApiTypes.test.ts +0 -26
  107. package/src/__tests__/markdownCodeFence.test.ts +0 -45
  108. package/src/__tests__/mediaAttachmentFlow.test.ts +0 -110
  109. package/src/__tests__/mediaBinDrop.test.tsx +0 -90
  110. package/src/__tests__/mediaReferences.test.ts +0 -97
  111. package/src/__tests__/narrationSave.test.ts +0 -148
  112. package/src/__tests__/outlinePanel.test.tsx +0 -169
  113. package/src/__tests__/outlineSource.test.ts +0 -217
  114. package/src/__tests__/plainHtmlPreview.test.tsx +0 -125
  115. package/src/__tests__/presentationMode.test.tsx +0 -290
  116. package/src/__tests__/previewControls.test.tsx +0 -571
  117. package/src/__tests__/previewPanelAudioFailure.test.tsx +0 -46
  118. package/src/__tests__/previewPanelPresentation.test.tsx +0 -126
  119. package/src/__tests__/previewPanelTransforms.test.tsx +0 -117
  120. package/src/__tests__/propertiesPanel.test.tsx +0 -69
  121. package/src/__tests__/rawEditorModelIsolation.test.ts +0 -19
  122. package/src/__tests__/recorderFormats.test.ts +0 -146
  123. package/src/__tests__/recorderMediaInsert.test.ts +0 -86
  124. package/src/__tests__/recorderTheme.test.tsx +0 -42
  125. package/src/__tests__/recorderTimingJson.test.ts +0 -41
  126. package/src/__tests__/resolveBlockVisual.test.ts +0 -43
  127. package/src/__tests__/selectionConversions.test.ts +0 -80
  128. package/src/__tests__/statusBar.test.tsx +0 -27
  129. package/src/__tests__/teleprompter.test.tsx +0 -190
  130. package/src/__tests__/templateAnnotationRoundTrip.test.ts +0 -99
  131. package/src/__tests__/templateContentPreview.test.ts +0 -101
  132. package/src/__tests__/templatePickerMetadata.test.ts +0 -32
  133. package/src/__tests__/templatePickerPortal.test.tsx +0 -62
  134. package/src/__tests__/timelineSource.test.ts +0 -134
  135. package/src/__tests__/tiptapBridge.test.ts +0 -575
  136. package/src/__tests__/tiptapBridgeConformance.test.ts +0 -47
  137. package/src/__tests__/tiptapCodeBlockRoundTrip.test.ts +0 -109
  138. package/src/__tests__/tiptapImageRoundTrip.test.ts +0 -73
  139. package/src/__tests__/toolbarSelectionConversion.test.tsx +0 -190
  140. package/src/__tests__/tooltip.test.tsx +0 -72
  141. package/src/__tests__/transformStyleId.test.ts +0 -13
  142. package/src/__tests__/transitionCatalog.test.ts +0 -64
  143. package/src/__tests__/useBlockNavigator.test.tsx +0 -67
  144. package/src/__tests__/useImageEditor.test.tsx +0 -226
  145. package/src/__tests__/useJsonEditorTokens.test.ts +0 -59
  146. package/src/__tests__/useMediaRecorder.test.ts +0 -302
  147. package/src/__tests__/useTimelineClock.test.ts +0 -21
  148. package/src/__tests__/versionHistory.test.tsx +0 -197
  149. package/src/__tests__/viewMenuPanel.test.tsx +0 -130
  150. package/src/__tests__/writeCanvasSettings.test.ts +0 -15
  151. package/src/__tests__/wysiwygImageUpload.test.ts +0 -69
  152. package/src/__tests__/wysiwygTemplateBadgeFocus.test.tsx +0 -56
  153. package/src/asciiDiagram/AsciiDiagramExtension.ts +0 -343
  154. package/src/asciiDiagram/AsciiDiagramWidget.tsx +0 -254
  155. package/src/asciiDiagram/RepairableDiagramExtension.ts +0 -200
  156. package/src/asciiDiagram/__tests__/AsciiDiagramExtension.test.ts +0 -164
  157. package/src/asciiDiagram/__tests__/RepairableDiagramExtension.test.ts +0 -159
  158. package/src/asciiDiagram/__tests__/asciiDiagramCommands.test.ts +0 -284
  159. package/src/asciiDiagram/__tests__/asciiDiagramOps.test.ts +0 -114
  160. package/src/asciiDiagram/__tests__/asciiPaste.test.ts +0 -43
  161. package/src/asciiDiagram/asciiDiagramCommands.ts +0 -174
  162. package/src/asciiDiagram/asciiDiagramData.ts +0 -149
  163. package/src/asciiDiagram/asciiDiagramOps.ts +0 -238
  164. package/src/asciiDiagram/asciiPaste.ts +0 -19
  165. package/src/blockProperties.ts +0 -88
  166. package/src/blockRange.ts +0 -132
  167. package/src/blockSlice.ts +0 -75
  168. package/src/blockTagActivity.ts +0 -233
  169. package/src/buildDocumentPreviewMarkdown.ts +0 -168
  170. package/src/buildPreviewDoc.ts +0 -407
  171. package/src/codeContext/CodeContextSectionView.tsx +0 -124
  172. package/src/codeContext/CodeContextZoneManager.ts +0 -149
  173. package/src/codeContext/CodeContextZones.tsx +0 -121
  174. package/src/codeContext/diffContextSections.ts +0 -38
  175. package/src/codeContext/types.ts +0 -75
  176. package/src/codeSnippet/CodeSnippetExtension.ts +0 -205
  177. package/src/codeSnippet/CodeSnippetWidget.tsx +0 -109
  178. package/src/codeSnippet/__tests__/CodeSnippetExtension.test.ts +0 -95
  179. package/src/codeSnippet/__tests__/codeSnippetLanguages.test.ts +0 -50
  180. package/src/codeSnippet/codeSnippetCommands.ts +0 -21
  181. package/src/codeSnippet/codeSnippetData.ts +0 -43
  182. package/src/codeSnippet/codeSnippetLanguages.ts +0 -216
  183. package/src/customTemplates/AddBin.tsx +0 -126
  184. package/src/customTemplates/CustomLayoutManager.tsx +0 -234
  185. package/src/customTemplates/CustomTemplateContext.tsx +0 -188
  186. package/src/customTemplates/LayerToolbar.tsx +0 -580
  187. package/src/customTemplates/ShapeGlyph.tsx +0 -47
  188. package/src/customTemplates/TemplateDesigner.tsx +0 -433
  189. package/src/customTemplates/__tests__/library.test.ts +0 -96
  190. package/src/customTemplates/__tests__/normalizePositions.test.ts +0 -109
  191. package/src/customTemplates/__tests__/shapeDefs.test.ts +0 -49
  192. package/src/customTemplates/__tests__/useMemoryLayerAdapter.test.ts +0 -108
  193. package/src/customTemplates/designer.css +0 -732
  194. package/src/customTemplates/index.ts +0 -31
  195. package/src/customTemplates/library.ts +0 -110
  196. package/src/customTemplates/normalizePositions.ts +0 -75
  197. package/src/customTemplates/shapeDefs.ts +0 -131
  198. package/src/customTemplates/thumbnail.tsx +0 -63
  199. package/src/customTemplates/tokenDefs.ts +0 -60
  200. package/src/customTemplates/useDocCustomTemplates.ts +0 -52
  201. package/src/customTemplates/useMemoryLayerAdapter.ts +0 -129
  202. package/src/customThemes/CustomThemeContext.tsx +0 -185
  203. package/src/customThemes/CustomThemeDialog.tsx +0 -316
  204. package/src/customThemes/ImportThemeSection.tsx +0 -178
  205. package/src/customThemes/__tests__/CustomThemeContext.test.tsx +0 -64
  206. package/src/customThemes/__tests__/CustomThemeDialog.test.tsx +0 -47
  207. package/src/customThemes/__tests__/customThemeLibrary.test.ts +0 -60
  208. package/src/customThemes/__tests__/importThemeSection.test.tsx +0 -192
  209. package/src/customThemes/customThemeLibrary.ts +0 -100
  210. package/src/customThemes/index.ts +0 -37
  211. package/src/customThemes/themeControls.tsx +0 -229
  212. package/src/customThemes/themeDraft.ts +0 -288
  213. package/src/customThemes/useDocCustomThemes.ts +0 -49
  214. package/src/detectMarkdown.ts +0 -62
  215. package/src/diagram/DiagramCanvas.tsx +0 -260
  216. package/src/diagram/DiagramMaximizedOverlay.tsx +0 -46
  217. package/src/diagram/diagramCommands.ts +0 -604
  218. package/src/diagram/diagramConstants.ts +0 -17
  219. package/src/diagram/types.ts +0 -35
  220. package/src/editorScrollSync.ts +0 -73
  221. package/src/embeddedMedia.ts +0 -78
  222. package/src/emojiData.ts +0 -1317
  223. package/src/fileKind.ts +0 -158
  224. package/src/find/FindHighlightExtension.ts +0 -81
  225. package/src/find/FindToolbar.tsx +0 -314
  226. package/src/find/findModel.ts +0 -77
  227. package/src/frontmatter.ts +0 -29
  228. package/src/frontmatterSettings.ts +0 -23
  229. package/src/headingTransition.ts +0 -291
  230. package/src/hooks/useFileDrop.ts +0 -266
  231. package/src/imageEditor/CanvasSurface.tsx +0 -703
  232. package/src/imageEditor/ImageVersionHistoryDropdown.tsx +0 -396
  233. package/src/imageEditor/LayersPanel.tsx +0 -218
  234. package/src/imageEditor/PropertiesPanel.tsx +0 -474
  235. package/src/imageEditor/Toolbar.tsx +0 -459
  236. package/src/imageEditor/createShapeLayer.ts +0 -280
  237. package/src/imageEditor/icons.tsx +0 -68
  238. package/src/imageEditor/image-editor.css +0 -574
  239. package/src/imageEditor/layers/EditorImageLayer.tsx +0 -45
  240. package/src/imageEditor/layers/EditorShapeLayer.tsx +0 -62
  241. package/src/imageEditor/layers/EditorTextLayer.tsx +0 -45
  242. package/src/imageEditor/layers/SelectionHandles.tsx +0 -86
  243. package/src/imageEditor/state.ts +0 -173
  244. package/src/imageEditor/useImageEditor.ts +0 -385
  245. package/src/imageEditor/useImageEditorTokens.ts +0 -70
  246. package/src/index.ts +0 -559
  247. package/src/jsonEditor/EmbeddedRichTextField.tsx +0 -81
  248. package/src/jsonEditor/JsonEditor.tsx +0 -81
  249. package/src/jsonEditor/JsonEditorContext.tsx +0 -81
  250. package/src/jsonEditor/RenderNode.tsx +0 -87
  251. package/src/jsonEditor/editors.tsx +0 -745
  252. package/src/jsonEditor/index.ts +0 -2
  253. package/src/jsonEditor/json-editor.css +0 -463
  254. package/src/jsonEditor/useJsonEditorTokens.ts +0 -33
  255. package/src/markdownCodeFence.ts +0 -72
  256. package/src/mediaDragMime.ts +0 -32
  257. package/src/mediaEntries.ts +0 -12
  258. package/src/mediaReferences.ts +0 -301
  259. package/src/mermaid/MermaidDiagramCanvas.tsx +0 -693
  260. package/src/mermaid/MermaidDiagramExtension.ts +0 -243
  261. package/src/mermaid/MermaidDiagramTypeThumbnail.tsx +0 -184
  262. package/src/mermaid/MermaidDiagramWidget.tsx +0 -653
  263. package/src/mermaid/MermaidShapePalette.tsx +0 -245
  264. package/src/mermaid/__tests__/MermaidDiagramExtension.test.ts +0 -361
  265. package/src/mermaid/__tests__/mermaidDiagramTypes.test.ts +0 -35
  266. package/src/mermaid/__tests__/mermaidRenderer.test.ts +0 -49
  267. package/src/mermaid/__tests__/mermaidSourceOps.test.ts +0 -213
  268. package/src/mermaid/__tests__/mermaidSyntax.test.ts +0 -71
  269. package/src/mermaid/mermaidCommands.ts +0 -34
  270. package/src/mermaid/mermaidData.ts +0 -31
  271. package/src/mermaid/mermaidDiagramTypes.ts +0 -325
  272. package/src/mermaid/mermaidModel.ts +0 -31
  273. package/src/mermaid/mermaidRenderer.ts +0 -181
  274. package/src/mermaid/mermaidShapes.ts +0 -113
  275. package/src/mermaid/mermaidSourceOps.ts +0 -454
  276. package/src/monaco.ts +0 -35
  277. package/src/monacoWorkers.ts +0 -89
  278. package/src/outlineSource.ts +0 -171
  279. package/src/presentation/PresentationMode.tsx +0 -596
  280. package/src/rawEditorIsolation.ts +0 -18
  281. package/src/recorder/RecorderButton.tsx +0 -80
  282. package/src/recorder/RecorderModal.tsx +0 -706
  283. package/src/recorder/RecorderPanel.tsx +0 -77
  284. package/src/recorder/formats.ts +0 -159
  285. package/src/recorder/hooks/useMediaRecorder.ts +0 -436
  286. package/src/recorder/hooks/useStreamPreview.ts +0 -47
  287. package/src/recorder/insertMediaBlock.ts +0 -30
  288. package/src/recorder/sources/cameraStream.ts +0 -32
  289. package/src/recorder/sources/micStream.ts +0 -25
  290. package/src/recorder/sources/screenStream.ts +0 -162
  291. package/src/recorder/timingJson.ts +0 -66
  292. package/src/resolveBlockVisual.ts +0 -39
  293. package/src/scene/Scene.tsx +0 -647
  294. package/src/scene/SceneBlockExtension.ts +0 -205
  295. package/src/scene/SceneBlockToolbar.tsx +0 -216
  296. package/src/scene/SceneBlockWidget.tsx +0 -441
  297. package/src/scene/ScenePropsBar.tsx +0 -85
  298. package/src/scene/SceneSelection.tsx +0 -111
  299. package/src/scene/SceneSideToolbar.tsx +0 -89
  300. package/src/scene/SceneViewControls.tsx +0 -43
  301. package/src/scene/SceneViewport.tsx +0 -106
  302. package/src/scene/ShapePalette.tsx +0 -196
  303. package/src/scene/__tests__/DiagramAdapter.test.ts +0 -142
  304. package/src/scene/__tests__/SceneBlockExtension.test.ts +0 -33
  305. package/src/scene/__tests__/bezierEdit.test.ts +0 -85
  306. package/src/scene/__tests__/blockLayers.test.ts +0 -57
  307. package/src/scene/__tests__/fitScale.test.ts +0 -19
  308. package/src/scene/__tests__/sceneIsolation.test.tsx +0 -119
  309. package/src/scene/__tests__/shapeLayers.test.ts +0 -106
  310. package/src/scene/__tests__/useSceneHitTest.test.ts +0 -90
  311. package/src/scene/__tests__/useScenePanZoom.test.ts +0 -130
  312. package/src/scene/adapters/DiagramAdapter.ts +0 -79
  313. package/src/scene/adapters/DrawingAdapter.ts +0 -420
  314. package/src/scene/adapters/LayoutAdapter.ts +0 -313
  315. package/src/scene/adapters/blockLayers.ts +0 -159
  316. package/src/scene/commands/SceneCommand.ts +0 -84
  317. package/src/scene/commands/drawingCommands.ts +0 -318
  318. package/src/scene/commands/layoutCommands.ts +0 -301
  319. package/src/scene/fitScale.ts +0 -17
  320. package/src/scene/hooks/useSceneHitTest.ts +0 -105
  321. package/src/scene/hooks/useScenePanZoom.ts +0 -154
  322. package/src/scene/hooks/useSceneSelection.ts +0 -62
  323. package/src/scene/index.ts +0 -90
  324. package/src/scene/layers/DiagramEdges.tsx +0 -142
  325. package/src/scene/layers/edgeGeometry.ts +0 -104
  326. package/src/scene/layers/nodeCard.tsx +0 -164
  327. package/src/scene/layers/renderLayer.tsx +0 -70
  328. package/src/scene/layers/shapeLayers.ts +0 -201
  329. package/src/scene/paths/bezierEdit.ts +0 -208
  330. package/src/scene/scene.css +0 -874
  331. package/src/scene/text/SceneTextOverlay.tsx +0 -161
  332. package/src/scene/text/sceneTextChannel.ts +0 -46
  333. package/src/scene/text/sceneTextConfig.ts +0 -31
  334. package/src/scene/text/sceneTiptap.ts +0 -36
  335. package/src/scene/text/useSceneTextEditing.ts +0 -39
  336. package/src/scene/tools/ConnectTool.ts +0 -209
  337. package/src/scene/tools/DrawingConnectTool.ts +0 -231
  338. package/src/scene/tools/PathTool.ts +0 -158
  339. package/src/scene/tools/PlaceTool.ts +0 -47
  340. package/src/scene/tools/SceneTool.ts +0 -85
  341. package/src/scene/tools/SelectTool.ts +0 -300
  342. package/src/scene/tools/ShapeTool.ts +0 -143
  343. package/src/scene/tools/TextTool.ts +0 -72
  344. package/src/scene/tools/TokenTool.ts +0 -95
  345. package/src/scene/tools/createDrawShapeTool.ts +0 -82
  346. package/src/selectionConversions.ts +0 -155
  347. package/src/styles/ascii-diagram.css +0 -79
  348. package/src/styles/ascii-timeline.css +0 -596
  349. package/src/styles/code-context.css +0 -155
  350. package/src/styles/code-snippet.css +0 -76
  351. package/src/styles/diagram.css +0 -183
  352. package/src/styles/editor.css +0 -7131
  353. package/src/styles/folder-view.css +0 -210
  354. package/src/styles/image-edit-affordance.css +0 -201
  355. package/src/styles/index.css +0 -20
  356. package/src/styles/mermaid-diagram.css +0 -487
  357. package/src/styles/tree-view.css +0 -189
  358. package/src/teleprompter/TeleprompterControls.tsx +0 -218
  359. package/src/teleprompter/TeleprompterSelfView.tsx +0 -22
  360. package/src/teleprompter/TeleprompterSurface.tsx +0 -267
  361. package/src/teleprompter/TeleprompterView.tsx +0 -338
  362. package/src/teleprompter/canvasRenderer.ts +0 -161
  363. package/src/teleprompter/floatingWindow.ts +0 -352
  364. package/src/teleprompter/index.ts +0 -61
  365. package/src/teleprompter/pcmWorklet.ts +0 -62
  366. package/src/teleprompter/recording/insertPreamble.ts +0 -80
  367. package/src/teleprompter/recording/narrationSave.ts +0 -134
  368. package/src/teleprompter/recording/useNarrationRecorder.ts +0 -367
  369. package/src/teleprompter/scrollModel.ts +0 -85
  370. package/src/teleprompter/teleprompterTheme.ts +0 -303
  371. package/src/teleprompter/types.ts +0 -38
  372. package/src/teleprompter/useFloatingWindow.ts +0 -74
  373. package/src/teleprompter/useMicAnalysis.ts +0 -211
  374. package/src/teleprompter/useTeleprompter.ts +0 -421
  375. package/src/templateContentPreviewResolver.ts +0 -360
  376. package/src/timeline/TimelineEditorWidget.tsx +0 -861
  377. package/src/timeline/TimelineViewExtension.ts +0 -252
  378. package/src/timeline/__tests__/TimelineEditorWidget.test.tsx +0 -414
  379. package/src/timeline/__tests__/TimelineViewExtension.test.ts +0 -163
  380. package/src/timeline/__tests__/timelineCommands.test.ts +0 -359
  381. package/src/timeline/__tests__/timelineOps.test.ts +0 -277
  382. package/src/timeline/__tests__/timelinePaste.test.ts +0 -34
  383. package/src/timeline/timelineCommands.ts +0 -421
  384. package/src/timeline/timelineData.ts +0 -54
  385. package/src/timeline/timelineOps.ts +0 -381
  386. package/src/timeline/timelinePaste.ts +0 -8
  387. package/src/timelineSource.ts +0 -244
  388. package/src/tiptap/TiptapAudio.tsx +0 -86
  389. package/src/tiptap/TiptapVideo.tsx +0 -119
  390. package/src/tiptap/useResolvedMediaSrc.ts +0 -47
  391. package/src/tiptapBridge.ts +0 -986
  392. package/src/tooltipPlacement.ts +0 -13
  393. package/src/transformStyleId.ts +0 -17
  394. package/src/transitionCatalog.ts +0 -159
  395. package/src/treeview/TreeOutlineWidget.tsx +0 -390
  396. package/src/treeview/TreeViewExtension.ts +0 -250
  397. package/src/treeview/__tests__/TreeOutlineWidget.test.tsx +0 -156
  398. package/src/treeview/__tests__/TreeViewExtension.test.ts +0 -122
  399. package/src/treeview/__tests__/treeOps.test.ts +0 -177
  400. package/src/treeview/__tests__/treePaste.test.ts +0 -40
  401. package/src/treeview/__tests__/treeViewCommands.test.ts +0 -179
  402. package/src/treeview/treeOps.ts +0 -231
  403. package/src/treeview/treePaste.ts +0 -13
  404. package/src/treeview/treeViewCommands.ts +0 -99
  405. package/src/treeview/treeViewData.ts +0 -41
  406. package/src/types/monaco-shims.d.ts +0 -10
  407. package/src/useBlockNavigator.ts +0 -153
  408. package/src/useHeadingLayout.ts +0 -294
  409. package/src/useMonacoLoader.ts +0 -82
  410. package/src/useTimelineClock.ts +0 -76
  411. package/src/utils/collectInlineFontAwesomeCss.ts +0 -69
  412. package/src/utils/dropUtils.ts +0 -136
  413. package/src/utils/normalizeMalformedAssetUrl.ts +0 -22
  414. package/src/writeCanvasSettings.ts +0 -30
  415. package/src/wysiwygImageUpload.ts +0 -113
@@ -1,671 +0,0 @@
1
- /**
2
- * TimelineTrack
3
- *
4
- * Horizontal timeline strip for the Timeline view. Shows every block as a bar
5
- * (width ∝ duration, x ∝ startTime) with its media clips as sub-bars below.
6
- * Clicking a block selects it (the editor above follows). Dragging a block's
7
- * right edge changes its duration; dragging its left edge changes the previous
8
- * block's duration (the boundary, since startTime is derived). Dragging a media
9
- * clip moves its `startAt`; dragging the clip's right edge changes its length;
10
- * double-clicking a clip toggles `spillover`. All edits are written back to the
11
- * markdown source via {@link timelineSource}.
12
- */
13
-
14
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
15
- import type { Block, MediaClip } from '@bendyline/squisq/schemas';
16
- import {
17
- resolveMediaSchedule,
18
- getDocPlaybackDuration,
19
- VIEWPORT_PRESETS,
20
- type ScheduledClip,
21
- } from '@bendyline/squisq/schemas';
22
- import { flattenBlocks, DEFAULT_THEME } from '@bendyline/squisq/doc';
23
- import { MediaClipLayer, MediaContext } from '@bendyline/squisq-react';
24
- import { useEditorContext } from './EditorContext';
25
- import { usePreviewSettingsOptional } from './PreviewControls';
26
- import {
27
- setBlockDurationInSource,
28
- setMediaClipInSource,
29
- placeClipInBlock,
30
- type ClipSpec,
31
- } from './timelineSource';
32
- import { collectEmbeddedMedia } from './embeddedMedia';
33
- import { BlockThumbnail } from './TimelineBlockPreview';
34
- import { resolveBlockVisual } from './resolveBlockVisual';
35
- import { useTimelineClock } from './useTimelineClock';
36
-
37
- /** Viewport the per-bar thumbnails render at. */
38
- const PREVIEW_VIEWPORT = VIEWPORT_PRESETS.landscape;
39
-
40
- const DEFAULT_PX_PER_SECOND = 18;
41
- const ZOOM_MIN = 4;
42
- const ZOOM_MAX = 160;
43
- const ZOOM_FACTOR = 1.4;
44
- const MIN_DURATION = 0.5; // seconds — floor when dragging a block edge
45
- /** Candidate ruler-tick intervals (seconds); the first wide enough is used. */
46
- const TICK_STEPS = [1, 2, 5, 10, 15, 30, 60, 120, 300, 600];
47
- /** Minimum pixels between ruler ticks. */
48
- const TICK_MIN_PX = 64;
49
-
50
- type DragKind =
51
- | 'block-right'
52
- | 'block-left'
53
- | 'clip-move'
54
- | 'clip-right'
55
- | 'embed-move'
56
- | 'embed-right';
57
-
58
- interface DragState {
59
- kind: DragKind;
60
- startX: number;
61
- /** Lower bound (seconds) for the dragged value (0 for position drags). */
62
- floor: number;
63
- /** Value (seconds) at drag start, added to the pointer delta. */
64
- previewBase: number;
65
- /** Live preview value (seconds) shown while dragging. */
66
- preview: number;
67
- commit: (seconds: number) => void;
68
- /** Id of the bar/clip being dragged (for live preview geometry). */
69
- targetId: string;
70
- /**
71
- * For block-edge drags: index of the block whose duration changes. Its bar
72
- * previews at `preview` and every block after it shifts by the delta so the
73
- * whole track follows the mouse live.
74
- */
75
- pivotIndex?: number;
76
- /**
77
- * True after pointer-up: the edit is committed but kept applied so the bar
78
- * holds its new position while the markdown re-parses (debounced). Cleared
79
- * once the regenerated `doc` reflects the edit — avoids a snap-back flash.
80
- */
81
- committed?: boolean;
82
- }
83
-
84
- function headingLine(block: Block): number | undefined {
85
- return block.sourceHeading?.position?.start.line;
86
- }
87
-
88
- export interface TimelineTrackProps {
89
- height?: number;
90
- }
91
-
92
- export function TimelineTrack({ height = 160 }: TimelineTrackProps) {
93
- const {
94
- doc,
95
- markdownSource,
96
- setMarkdownSource,
97
- goToBlockByLine,
98
- activeBlockStartLine,
99
- mediaProvider,
100
- } = useEditorContext();
101
- const [drag, setDrag] = useState<DragState | null>(null);
102
- const [pxPerSecond, setPxPerSecond] = useState(DEFAULT_PX_PER_SECOND);
103
- const scrollRef = useRef<HTMLDivElement>(null);
104
-
105
- const blocks = useMemo(() => (doc ? flattenBlocks(doc.blocks) : []), [doc]);
106
-
107
- // Tiny slideshow thumbnail for every block, filling its bar. Resolved once
108
- // per doc/theme so dragging (which re-renders bar geometry each frame)
109
- // doesn't re-render the SVGs.
110
- const previewSettings = usePreviewSettingsOptional();
111
- const previewTheme = previewSettings?.activeTheme ?? DEFAULT_THEME;
112
- const visualByBlock = useMemo(() => {
113
- const map = new Map<string, Block>();
114
- if (doc) {
115
- for (const b of blocks) {
116
- const visual = resolveBlockVisual(doc, b, previewTheme, PREVIEW_VIEWPORT);
117
- if (visual) map.set(b.id, visual);
118
- }
119
- }
120
- return map;
121
- }, [doc, blocks, previewTheme]);
122
- const clips = useMemo<ScheduledClip[]>(() => (doc ? resolveMediaSchedule(doc) : []), [doc]);
123
- const total = useMemo(() => (doc ? getDocPlaybackDuration(doc) : 0), [doc]);
124
- const width = Math.max(total * pxPerSecond, 200);
125
-
126
- // Real-time playback clock for the playhead + media. Starting playback also
127
- // drops any in-progress edit so the playhead drives.
128
- const { currentTime, isPlaying, play, pause, seek } = useTimelineClock(total);
129
- const startPlay = useCallback(() => {
130
- setDrag(null);
131
- play();
132
- }, [play]);
133
-
134
- // Scrubbing the playhead: drag the red bar to seek. Pauses playback while
135
- // dragging; seeks continuously from the pointer position.
136
- const [scrubbing, setScrubbing] = useState(false);
137
- useEffect(() => {
138
- if (!scrubbing) return;
139
- const onMove = (e: PointerEvent) => {
140
- const scroll = scrollRef.current;
141
- if (!scroll) return;
142
- const rect = scroll.getBoundingClientRect();
143
- const x = e.clientX - rect.left + scroll.scrollLeft;
144
- seek(x / pxPerSecond);
145
- };
146
- const onUp = () => setScrubbing(false);
147
- window.addEventListener('pointermove', onMove);
148
- window.addEventListener('pointerup', onUp);
149
- return () => {
150
- window.removeEventListener('pointermove', onMove);
151
- window.removeEventListener('pointerup', onUp);
152
- };
153
- }, [scrubbing, pxPerSecond, seek]);
154
-
155
- // Raw clip lookup (keeps clipStart/clipEnd/spillover that the schedule drops)
156
- // so a clip can be rebuilt verbatim when relocated to another block.
157
- const rawClipById = useMemo(() => {
158
- const map = new Map<string, MediaClip>();
159
- if (doc) {
160
- for (const b of flattenBlocks(doc.blocks)) for (const m of b.media ?? []) map.set(m.id, m);
161
- for (const m of doc.documentMedia ?? []) map.set(m.id, m);
162
- }
163
- return map;
164
- }, [doc]);
165
-
166
- // The heading-bearing block whose [startTime, startTime+duration) contains
167
- // `time`, clamped to the first/last such block. Used to retarget a dragged
168
- // clip to whichever block it lands in.
169
- const blockAtTime = useCallback(
170
- (time: number): Block | null => {
171
- const withHeadings = blocks.filter((b) => headingLine(b) != null);
172
- if (withHeadings.length === 0) return null;
173
- let found = withHeadings[0];
174
- for (const b of withHeadings) {
175
- if (time >= b.startTime) found = b;
176
- }
177
- return found;
178
- },
179
- [blocks],
180
- );
181
-
182
- // While playing, follow the playhead: when it crosses into a new block,
183
- // select that block so the card editor + bar highlight track playback. Guarded
184
- // by a ref so we only fire on block boundaries, not every animation frame.
185
- const followedBlockRef = useRef<string | null>(null);
186
- useEffect(() => {
187
- if (!isPlaying) {
188
- followedBlockRef.current = null;
189
- return;
190
- }
191
- const block = blockAtTime(currentTime);
192
- if (!block || block.id === followedBlockRef.current) return;
193
- followedBlockRef.current = block.id;
194
- const line = headingLine(block);
195
- if (line != null) goToBlockByLine(line);
196
- }, [isPlaying, currentTime, blockAtTime, goToBlockByLine]);
197
-
198
- // Auto-scroll so the playhead stays visible while playing.
199
- useEffect(() => {
200
- if (!isPlaying) return;
201
- const scroll = scrollRef.current;
202
- if (!scroll) return;
203
- const x = currentTime * pxPerSecond;
204
- const left = scroll.scrollLeft;
205
- const right = left + scroll.clientWidth;
206
- if (x < left || x > right - 80) {
207
- scroll.scrollLeft = Math.max(0, x - scroll.clientWidth / 2);
208
- }
209
- }, [isPlaying, currentTime, pxPerSecond]);
210
-
211
- // Move a clip's start to an absolute timeline position. If the new start
212
- // lands in a different block, the clip's annotation relocates to that block
213
- // (rebuilt from `spec`); within the same block it's a minimal `startAt` edit.
214
- // `extraPatch` carries non-position edits (e.g. clipEnd) for the same-block case.
215
- const moveClipToTime = useCallback(
216
- (
217
- sourceLine: number | undefined,
218
- currentBlockId: string | undefined,
219
- spec: ClipSpec,
220
- newAbsStart: number,
221
- extraPatch?: { clipEnd?: number },
222
- ) => {
223
- if (sourceLine == null) return;
224
- const target = blockAtTime(newAbsStart);
225
- const targetLine = target ? headingLine(target) : undefined;
226
- if (target == null || targetLine == null) return;
227
- const startAt = Math.max(0, newAbsStart - target.startTime);
228
- if (currentBlockId === target.id) {
229
- // Same block → in-place edit, preserving any extra params on the line.
230
- const next = setMediaClipInSource(markdownSource, sourceLine, { startAt, ...extraPatch });
231
- if (next) setMarkdownSource(next);
232
- return;
233
- }
234
- const next = placeClipInBlock(
235
- markdownSource,
236
- sourceLine,
237
- targetLine,
238
- extraPatch?.clipEnd != null ? { ...spec, clipEnd: extraPatch.clipEnd } : spec,
239
- startAt,
240
- );
241
- if (next) setMarkdownSource(next);
242
- },
243
- [blockAtTime, markdownSource, setMarkdownSource],
244
- );
245
-
246
- // Convert a body-embedded media tag into a timed clip annotation at
247
- // `newAbsStart` (relocating to the landing block). Always writes an
248
- // annotation, since the embed isn't one yet.
249
- const placeEmbeddedClip = useCallback(
250
- (sourceLine: number | undefined, spec: ClipSpec, newAbsStart: number) => {
251
- if (sourceLine == null) return;
252
- const target = blockAtTime(newAbsStart);
253
- const targetLine = target ? headingLine(target) : undefined;
254
- if (target == null || targetLine == null) return;
255
- const startAt = Math.max(0, newAbsStart - target.startTime);
256
- const next = placeClipInBlock(markdownSource, sourceLine, targetLine, spec, startAt);
257
- if (next) setMarkdownSource(next);
258
- },
259
- [blockAtTime, markdownSource, setMarkdownSource],
260
- );
261
-
262
- const zoomIn = useCallback(() => setPxPerSecond((s) => Math.min(ZOOM_MAX, s * ZOOM_FACTOR)), []);
263
- const zoomOut = useCallback(() => setPxPerSecond((s) => Math.max(ZOOM_MIN, s / ZOOM_FACTOR)), []);
264
-
265
- // Track the visible width so the ruler can draw ticks across the whole
266
- // viewport, not just up to where the content ends.
267
- const [viewportWidth, setViewportWidth] = useState(0);
268
- useEffect(() => {
269
- const el = scrollRef.current;
270
- if (!el || typeof ResizeObserver === 'undefined') return;
271
- const update = () => setViewportWidth(el.clientWidth);
272
- update();
273
- const ro = new ResizeObserver(update);
274
- ro.observe(el);
275
- return () => ro.disconnect();
276
- }, []);
277
-
278
- // Live drag handling on the window so the pointer can leave the bar. The
279
- // current scale is read from a ref so the handler doesn't re-bind on zoom.
280
- const scaleRef = useRef(pxPerSecond);
281
- scaleRef.current = pxPerSecond;
282
- const dragRef = useRef<DragState | null>(null);
283
- dragRef.current = drag;
284
- const isDragging = drag != null && !drag.committed;
285
- useEffect(() => {
286
- if (!isDragging) return;
287
- const onMove = (e: PointerEvent) => {
288
- const d = dragRef.current;
289
- if (!d) return;
290
- const deltaSec = (e.clientX - d.startX) / scaleRef.current;
291
- setDrag({ ...d, preview: Math.max(d.floor, d.previewBase + deltaSec) });
292
- };
293
- const onUp = () => {
294
- const d = dragRef.current;
295
- if (!d) return;
296
- d.commit(d.preview);
297
- // Keep the preview applied (committed) until the regenerated doc reflects
298
- // the edit, so the bar doesn't snap back to the old layout for a frame.
299
- setDrag({ ...d, committed: true });
300
- // Fallback: if the edit produced identical markdown (no re-parse), drop
301
- // the committed preview anyway so it can't get stuck.
302
- window.setTimeout(() => {
303
- if (dragRef.current?.committed) setDrag(null);
304
- }, 500);
305
- };
306
- window.addEventListener('pointermove', onMove);
307
- window.addEventListener('pointerup', onUp);
308
- return () => {
309
- window.removeEventListener('pointermove', onMove);
310
- window.removeEventListener('pointerup', onUp);
311
- };
312
- }, [isDragging]);
313
-
314
- // Drop the committed preview once the doc re-parses with the new value.
315
- useEffect(() => {
316
- if (dragRef.current?.committed) setDrag(null);
317
- }, [doc]);
318
-
319
- const beginDrag = useCallback(
320
- (
321
- e: React.PointerEvent,
322
- kind: DragKind,
323
- targetId: string,
324
- base: number,
325
- commit: (seconds: number) => void,
326
- opts?: { pivotIndex?: number; floor?: number },
327
- ) => {
328
- e.preventDefault();
329
- e.stopPropagation();
330
- // Position drags (moving a clip) floor at 0; length drags floor at MIN_DURATION.
331
- const floor =
332
- opts?.floor ?? (kind === 'clip-move' || kind === 'embed-move' ? 0 : MIN_DURATION);
333
- setDrag({
334
- kind,
335
- startX: e.clientX,
336
- floor,
337
- preview: base,
338
- previewBase: base,
339
- commit,
340
- targetId,
341
- pivotIndex: opts?.pivotIndex,
342
- });
343
- },
344
- [],
345
- );
346
-
347
- if (!doc) return null;
348
-
349
- // Live layout while a block edge is dragged: the pivot block previews at the
350
- // new duration and every block after it shifts by the delta, so the track
351
- // re-lays-out under the mouse instead of snapping on release.
352
- const blockDrag =
353
- drag && (drag.kind === 'block-right' || drag.kind === 'block-left') ? drag : null;
354
- const pivot = blockDrag?.pivotIndex ?? -1;
355
- const blockDelta = blockDrag ? blockDrag.preview - blockDrag.previewBase : 0;
356
- const previewLeft = (index: number) =>
357
- (blocks[index].startTime + (index > pivot ? blockDelta : 0)) * pxPerSecond;
358
- const previewWidth = (index: number) =>
359
- Math.max((index === pivot ? blockDrag!.preview : blocks[index].duration) * pxPerSecond, 2);
360
- const clipShift = (clip: ScheduledClip) => {
361
- if (!blockDrag || clip.anchor === 'document' || !clip.blockId) return 0;
362
- const owning = blocks.findIndex((b) => b.id === clip.blockId);
363
- return owning > pivot ? blockDelta : 0;
364
- };
365
-
366
- // Ruler ticks: the smallest interval that keeps labels at least TICK_MIN_PX
367
- // apart at the current zoom.
368
- const tickSeconds =
369
- TICK_STEPS.find((s) => s * pxPerSecond >= TICK_MIN_PX) ?? TICK_STEPS[TICK_STEPS.length - 1];
370
- // Fill ticks across the whole visible track, continuing past the content end.
371
- const rulerEnd = Math.max(total, viewportWidth / pxPerSecond);
372
- const ticks: number[] = [];
373
- for (let t = 0; t <= rulerEnd + 0.001 && ticks.length < 1000; t += tickSeconds) ticks.push(t);
374
-
375
- return (
376
- <div className="squisq-timeline" style={{ height }} data-testid="timeline-track">
377
- <div className="squisq-timeline-controls">
378
- <button
379
- type="button"
380
- className="squisq-timeline-zoom-button squisq-timeline-play-button"
381
- onClick={isPlaying ? pause : startPlay}
382
- aria-label={isPlaying ? 'Pause' : 'Play'}
383
- data-tooltip={isPlaying ? 'Pause' : 'Play'}
384
- data-testid="timeline-play"
385
- >
386
- {isPlaying ? '❚❚' : '▶'}
387
- </button>
388
- <span className="squisq-timeline-time" data-testid="timeline-time">
389
- {formatClock(currentTime)} / {formatClock(total)}
390
- </span>
391
- <button
392
- type="button"
393
- className="squisq-timeline-zoom-button"
394
- onClick={zoomOut}
395
- disabled={pxPerSecond <= ZOOM_MIN}
396
- aria-label="Zoom out"
397
- data-tooltip="Zoom out"
398
- >
399
-
400
- </button>
401
- <button
402
- type="button"
403
- className="squisq-timeline-zoom-button"
404
- onClick={zoomIn}
405
- disabled={pxPerSecond >= ZOOM_MAX}
406
- aria-label="Zoom in"
407
- data-tooltip="Zoom in"
408
- >
409
- +
410
- </button>
411
- </div>
412
- <div className="squisq-timeline-scroll" ref={scrollRef}>
413
- <div className="squisq-timeline-inner" style={{ width }}>
414
- <div className="squisq-timeline-row squisq-timeline-row--blocks">
415
- {blocks.map((b, i) => {
416
- const line = headingLine(b);
417
- const isActive = line != null && line === activeBlockStartLine;
418
- const left = previewLeft(i);
419
- const barWidth = previewWidth(i);
420
- const prev = i > 0 ? blocks[i - 1] : null;
421
- return (
422
- <div
423
- key={b.id}
424
- className={`squisq-timeline-block${isActive ? ' squisq-timeline-block--active' : ''}`}
425
- style={{ left, width: barWidth }}
426
- title={`${b.title ?? b.id} — ${formatDur(b.duration)}`}
427
- onClick={() => {
428
- seek(b.startTime);
429
- if (line != null) goToBlockByLine(line);
430
- }}
431
- >
432
- {visualByBlock.has(b.id) && (
433
- <div className="squisq-timeline-block-thumb" aria-hidden>
434
- <BlockThumbnail
435
- visual={visualByBlock.get(b.id)!}
436
- viewport={PREVIEW_VIEWPORT}
437
- mediaProvider={mediaProvider}
438
- />
439
- </div>
440
- )}
441
- {prev && headingLine(prev) != null && (
442
- <span
443
- className="squisq-timeline-edge squisq-timeline-edge--left"
444
- onPointerDown={(e) =>
445
- beginDrag(
446
- e,
447
- 'block-left',
448
- b.id,
449
- prev.duration,
450
- (sec) => {
451
- // Moving the boundary changes the previous block's duration.
452
- const next = setBlockDurationInSource(
453
- markdownSource,
454
- headingLine(prev)!,
455
- sec,
456
- );
457
- if (next) setMarkdownSource(next);
458
- },
459
- { pivotIndex: i - 1 },
460
- )
461
- }
462
- />
463
- )}
464
- <span className="squisq-timeline-block-label">{b.title ?? b.id}</span>
465
- {line != null && (
466
- <span
467
- className="squisq-timeline-edge squisq-timeline-edge--right"
468
- onPointerDown={(e) =>
469
- beginDrag(
470
- e,
471
- 'block-right',
472
- b.id,
473
- b.duration,
474
- (sec) => {
475
- const next = setBlockDurationInSource(markdownSource, line, sec);
476
- if (next) setMarkdownSource(next);
477
- },
478
- { pivotIndex: i },
479
- )
480
- }
481
- />
482
- )}
483
- </div>
484
- );
485
- })}
486
- </div>
487
-
488
- <div className="squisq-timeline-row squisq-timeline-row--media">
489
- {clips.map((c) => {
490
- const length = c.absoluteEnd - c.absoluteStart;
491
- // Live geometry while dragging: follow a block-edge drag's shift,
492
- // or the clip's own move/resize (drag.preview is an absolute time).
493
- let left = (c.absoluteStart + clipShift(c)) * pxPerSecond;
494
- let clipWidth = Math.max(length * pxPerSecond, 4);
495
- if (drag?.targetId === c.id && drag.kind === 'clip-move') {
496
- left = drag.preview * pxPerSecond;
497
- } else if (drag?.targetId === c.id && drag.kind === 'clip-right') {
498
- clipWidth = Math.max(drag.preview * pxPerSecond, 4);
499
- }
500
- const editable = c.sourceLine != null;
501
- const specOf = (): ClipSpec => {
502
- const raw = rawClipById.get(c.id);
503
- return raw
504
- ? {
505
- kind: raw.kind,
506
- src: raw.src,
507
- clipStart: raw.clipStart,
508
- clipEnd: raw.clipEnd,
509
- spillover: raw.spillover,
510
- }
511
- : { kind: c.kind, src: c.src, clipStart: c.sourceIn };
512
- };
513
- return (
514
- <div
515
- key={c.id}
516
- className={`squisq-timeline-clip squisq-timeline-clip--${c.kind}${
517
- c.anchor === 'document' ? ' squisq-timeline-clip--document' : ''
518
- }`}
519
- style={{ left, width: clipWidth }}
520
- title={`${c.src} — ${formatDur(length)}${c.anchor === 'document' ? ' (document)' : ''}`}
521
- onPointerDown={(e) =>
522
- editable &&
523
- beginDrag(e, 'clip-move', c.id, c.absoluteStart, (absStart) => {
524
- if (c.anchor === 'document') {
525
- const next = setMediaClipInSource(markdownSource, c.sourceLine!, {
526
- startAt: absStart,
527
- });
528
- if (next) setMarkdownSource(next);
529
- } else {
530
- moveClipToTime(c.sourceLine, c.blockId, specOf(), absStart);
531
- }
532
- })
533
- }
534
- onDoubleClick={() => {
535
- if (c.sourceLine == null) return;
536
- // Toggle spillover (block clips only).
537
- const next = setMediaClipInSource(markdownSource, c.sourceLine, {
538
- spillover: c.anchor === 'block' ? true : null,
539
- });
540
- if (next) setMarkdownSource(next);
541
- }}
542
- >
543
- <span className="squisq-timeline-clip-label">{clipName(c.src)}</span>
544
- {editable && (
545
- <span
546
- className="squisq-timeline-edge squisq-timeline-edge--right"
547
- onPointerDown={(e) =>
548
- beginDrag(e, 'clip-right', c.id, length, (len) => {
549
- const next = setMediaClipInSource(markdownSource, c.sourceLine!, {
550
- clipEnd: (c.sourceIn ?? 0) + len,
551
- });
552
- if (next) setMarkdownSource(next);
553
- })
554
- }
555
- />
556
- )}
557
- </div>
558
- );
559
- })}
560
-
561
- {/* Media embedded in a block's body (recordings, dropped files):
562
- snapped to the parent block. Editing one converts it to a timed
563
- clip annotation and relocates it to wherever it's dragged. */}
564
- {blocks.flatMap((b, i) =>
565
- collectEmbeddedMedia(b).map((m, j) => {
566
- const id = `embed:${b.id}:${j}`;
567
- const absStart = b.startTime;
568
- const length = b.duration;
569
- let left = previewLeft(i);
570
- let clipWidth = previewWidth(i);
571
- if (drag?.targetId === id && drag.kind === 'embed-move') {
572
- left = drag.preview * pxPerSecond;
573
- } else if (drag?.targetId === id && drag.kind === 'embed-right') {
574
- clipWidth = Math.max(drag.preview * pxPerSecond, 4);
575
- }
576
- const spec: ClipSpec = { kind: m.kind, src: m.src };
577
- return (
578
- <div
579
- key={id}
580
- className={`squisq-timeline-clip squisq-timeline-clip--${m.kind} squisq-timeline-clip--embedded`}
581
- style={{ left, width: clipWidth }}
582
- title={`${m.src} — drag to time / move between blocks`}
583
- onPointerDown={(e) =>
584
- m.sourceLine != null &&
585
- beginDrag(e, 'embed-move', id, absStart, (newAbsStart) => {
586
- placeEmbeddedClip(m.sourceLine, { ...spec, clipEnd: length }, newAbsStart);
587
- })
588
- }
589
- >
590
- <span className="squisq-timeline-clip-label">{clipName(m.src)}</span>
591
- {m.sourceLine != null && (
592
- <span
593
- className="squisq-timeline-edge squisq-timeline-edge--right"
594
- onPointerDown={(e) =>
595
- beginDrag(e, 'embed-right', id, length, (len) => {
596
- placeEmbeddedClip(m.sourceLine, { ...spec, clipEnd: len }, absStart);
597
- })
598
- }
599
- />
600
- )}
601
- </div>
602
- );
603
- }),
604
- )}
605
- </div>
606
-
607
- <div
608
- className="squisq-timeline-row squisq-timeline-row--ruler"
609
- onClick={(e) => {
610
- const rect = e.currentTarget.getBoundingClientRect();
611
- seek((e.clientX - rect.left) / pxPerSecond);
612
- }}
613
- >
614
- {ticks.map((t) => (
615
- <div key={t} className="squisq-timeline-tick" style={{ left: t * pxPerSecond }}>
616
- <span className="squisq-timeline-tick-label">{formatDur(t)}</span>
617
- </div>
618
- ))}
619
- </div>
620
-
621
- {/* Playhead — vertical line at the current time, over all rows.
622
- Drag the bar (or its knob) to scrub. */}
623
- <div
624
- className="squisq-timeline-playhead"
625
- style={{ left: currentTime * pxPerSecond }}
626
- data-testid="timeline-playhead"
627
- onPointerDown={(e) => {
628
- e.preventDefault();
629
- e.stopPropagation();
630
- pause();
631
- setScrubbing(true);
632
- }}
633
- >
634
- <div className="squisq-timeline-playhead-knob" />
635
- </div>
636
- </div>
637
- </div>
638
-
639
- {/* Off-screen host: plays the timed audio clips in sync with the clock. */}
640
- <div className="squisq-timeline-media-host" aria-hidden>
641
- <MediaContext.Provider value={mediaProvider ?? null}>
642
- <MediaClipLayer
643
- schedule={clips}
644
- currentTime={currentTime}
645
- isPlaying={isPlaying}
646
- basePath="/"
647
- />
648
- </MediaContext.Provider>
649
- </div>
650
- </div>
651
- );
652
- }
653
-
654
- function formatClock(seconds: number): string {
655
- const s = Math.max(0, Math.floor(seconds));
656
- const m = Math.floor(s / 60);
657
- return `${m}:${String(s % 60).padStart(2, '0')}`;
658
- }
659
-
660
- function formatDur(seconds: number): string {
661
- const s = Math.round(seconds * 10) / 10;
662
- if (s < 60) return `${s}s`;
663
- const m = Math.floor(s / 60);
664
- const rem = Math.round(s - m * 60);
665
- return `${m}:${String(rem).padStart(2, '0')}`;
666
- }
667
-
668
- function clipName(src: string): string {
669
- const base = src.split('/').pop() ?? src;
670
- return base;
671
- }