@bendyline/squisq-editor-react 2.1.0 → 2.2.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 (394) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +40 -0
  3. package/dist/index.d.ts +188 -55
  4. package/dist/index.js +5094 -2948
  5. package/dist/monaco.js +0 -1
  6. package/dist/styles/index.css +234 -145
  7. package/package.json +9 -6
  8. package/dist/index.js.map +0 -1
  9. package/dist/monaco.js.map +0 -1
  10. package/src/BlockCardView.tsx +0 -121
  11. package/src/BlockPreviewPanel.tsx +0 -69
  12. package/src/BlockPropertiesPopover.tsx +0 -222
  13. package/src/DocumentSettingsDialog.tsx +0 -272
  14. package/src/DropZoneOverlay.tsx +0 -137
  15. package/src/EditorContext.tsx +0 -1274
  16. package/src/EditorShell.tsx +0 -1358
  17. package/src/EmojiPicker.tsx +0 -332
  18. package/src/FolderView.tsx +0 -131
  19. package/src/Icon.tsx +0 -26
  20. package/src/ImageEditor.tsx +0 -395
  21. package/src/ImageNodeView.tsx +0 -284
  22. package/src/ImageViewer.tsx +0 -221
  23. package/src/InlineIcon.ts +0 -84
  24. package/src/InlinePreviewGutter.tsx +0 -590
  25. package/src/LinkDialog.tsx +0 -276
  26. package/src/MediaBin.tsx +0 -500
  27. package/src/MentionExtension.tsx +0 -261
  28. package/src/OutlinePanel.tsx +0 -547
  29. package/src/PlainHtmlPreview.tsx +0 -277
  30. package/src/PreviewControls.tsx +0 -1265
  31. package/src/PreviewPanel.tsx +0 -426
  32. package/src/RawEditor.tsx +0 -743
  33. package/src/RecorderEntry.tsx +0 -162
  34. package/src/StatusBar.tsx +0 -51
  35. package/src/TemplateAnnotation.ts +0 -167
  36. package/src/TemplateContentPreview.tsx +0 -56
  37. package/src/TemplatePicker.tsx +0 -1314
  38. package/src/ThemeCustomizerPanel.tsx +0 -304
  39. package/src/ThemePicker.tsx +0 -433
  40. package/src/TimelineBlockPreview.tsx +0 -37
  41. package/src/TimelineTrack.tsx +0 -671
  42. package/src/Toolbar.tsx +0 -2885
  43. package/src/Tooltip.tsx +0 -142
  44. package/src/TransitionPicker.tsx +0 -390
  45. package/src/VersionHistoryPanel.tsx +0 -359
  46. package/src/ViewMenuPanel.tsx +0 -189
  47. package/src/ViewSwitcher.tsx +0 -56
  48. package/src/WysiwygEditor.tsx +0 -806
  49. package/src/__tests__/blockProperties.test.ts +0 -92
  50. package/src/__tests__/blockPropertiesPopoverTheme.test.tsx +0 -33
  51. package/src/__tests__/blockRange.test.ts +0 -105
  52. package/src/__tests__/blockTagActivity.test.ts +0 -183
  53. package/src/__tests__/buildDocumentPreviewMarkdown.test.ts +0 -75
  54. package/src/__tests__/buildPreviewDocContent.test.ts +0 -65
  55. package/src/__tests__/buildPreviewDocTransition.test.ts +0 -92
  56. package/src/__tests__/canvasSurfaceTextEditing.test.tsx +0 -60
  57. package/src/__tests__/codeContextSectionView.test.tsx +0 -97
  58. package/src/__tests__/codeContextZoneManager.test.ts +0 -127
  59. package/src/__tests__/createShapeLayer.test.ts +0 -46
  60. package/src/__tests__/customLayoutManagerTheme.test.tsx +0 -34
  61. package/src/__tests__/detectMarkdown.test.ts +0 -73
  62. package/src/__tests__/diffContextSections.test.ts +0 -39
  63. package/src/__tests__/documentSettingsDialog.test.tsx +0 -197
  64. package/src/__tests__/drawingShapeRoundTrip.test.ts +0 -49
  65. package/src/__tests__/editorScrollHandoff.test.tsx +0 -102
  66. package/src/__tests__/editorScrollSync.test.ts +0 -65
  67. package/src/__tests__/editorShellCodeContext.test.tsx +0 -86
  68. package/src/__tests__/editorShellProps.test.tsx +0 -550
  69. package/src/__tests__/embeddedMedia.test.ts +0 -48
  70. package/src/__tests__/emojiPicker.test.tsx +0 -93
  71. package/src/__tests__/fileKind.test.ts +0 -112
  72. package/src/__tests__/findMode.test.tsx +0 -104
  73. package/src/__tests__/findModel.test.ts +0 -55
  74. package/src/__tests__/headingTransition.test.ts +0 -176
  75. package/src/__tests__/imageEditAffordance.test.tsx +0 -272
  76. package/src/__tests__/imageEditModalContract.test.tsx +0 -119
  77. package/src/__tests__/imageEditorShell.test.tsx +0 -94
  78. package/src/__tests__/imageEditorState.test.ts +0 -171
  79. package/src/__tests__/inlinePreviewGutter.test.tsx +0 -62
  80. package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +0 -103
  81. package/src/__tests__/jsonEditor.test.tsx +0 -223
  82. package/src/__tests__/layersPanel.test.tsx +0 -167
  83. package/src/__tests__/layoutChildRoundTrip.test.ts +0 -71
  84. package/src/__tests__/linkDialogDocPicker.test.tsx +0 -137
  85. package/src/__tests__/majorApiTypes.test.ts +0 -26
  86. package/src/__tests__/markdownCodeFence.test.ts +0 -45
  87. package/src/__tests__/mediaAttachmentFlow.test.ts +0 -110
  88. package/src/__tests__/mediaBinDrop.test.tsx +0 -90
  89. package/src/__tests__/mediaReferences.test.ts +0 -97
  90. package/src/__tests__/narrationSave.test.ts +0 -148
  91. package/src/__tests__/outlinePanel.test.tsx +0 -169
  92. package/src/__tests__/outlineSource.test.ts +0 -217
  93. package/src/__tests__/plainHtmlPreview.test.tsx +0 -125
  94. package/src/__tests__/presentationMode.test.tsx +0 -290
  95. package/src/__tests__/previewControls.test.tsx +0 -571
  96. package/src/__tests__/previewPanelAudioFailure.test.tsx +0 -46
  97. package/src/__tests__/previewPanelPresentation.test.tsx +0 -126
  98. package/src/__tests__/previewPanelTransforms.test.tsx +0 -117
  99. package/src/__tests__/propertiesPanel.test.tsx +0 -69
  100. package/src/__tests__/rawEditorModelIsolation.test.ts +0 -19
  101. package/src/__tests__/recorderFormats.test.ts +0 -146
  102. package/src/__tests__/recorderMediaInsert.test.ts +0 -86
  103. package/src/__tests__/recorderTheme.test.tsx +0 -42
  104. package/src/__tests__/recorderTimingJson.test.ts +0 -41
  105. package/src/__tests__/resolveBlockVisual.test.ts +0 -43
  106. package/src/__tests__/selectionConversions.test.ts +0 -80
  107. package/src/__tests__/statusBar.test.tsx +0 -27
  108. package/src/__tests__/teleprompter.test.tsx +0 -190
  109. package/src/__tests__/templateAnnotationRoundTrip.test.ts +0 -99
  110. package/src/__tests__/templateContentPreview.test.ts +0 -101
  111. package/src/__tests__/templatePickerMetadata.test.ts +0 -32
  112. package/src/__tests__/templatePickerPortal.test.tsx +0 -62
  113. package/src/__tests__/timelineSource.test.ts +0 -134
  114. package/src/__tests__/tiptapBridge.test.ts +0 -575
  115. package/src/__tests__/tiptapBridgeConformance.test.ts +0 -47
  116. package/src/__tests__/tiptapCodeBlockRoundTrip.test.ts +0 -109
  117. package/src/__tests__/tiptapImageRoundTrip.test.ts +0 -73
  118. package/src/__tests__/toolbarSelectionConversion.test.tsx +0 -190
  119. package/src/__tests__/tooltip.test.tsx +0 -72
  120. package/src/__tests__/transformStyleId.test.ts +0 -13
  121. package/src/__tests__/transitionCatalog.test.ts +0 -64
  122. package/src/__tests__/useBlockNavigator.test.tsx +0 -67
  123. package/src/__tests__/useImageEditor.test.tsx +0 -226
  124. package/src/__tests__/useJsonEditorTokens.test.ts +0 -59
  125. package/src/__tests__/useMediaRecorder.test.ts +0 -302
  126. package/src/__tests__/useTimelineClock.test.ts +0 -21
  127. package/src/__tests__/versionHistory.test.tsx +0 -197
  128. package/src/__tests__/viewMenuPanel.test.tsx +0 -130
  129. package/src/__tests__/writeCanvasSettings.test.ts +0 -15
  130. package/src/__tests__/wysiwygImageUpload.test.ts +0 -69
  131. package/src/__tests__/wysiwygTemplateBadgeFocus.test.tsx +0 -56
  132. package/src/asciiDiagram/AsciiDiagramExtension.ts +0 -343
  133. package/src/asciiDiagram/AsciiDiagramWidget.tsx +0 -254
  134. package/src/asciiDiagram/RepairableDiagramExtension.ts +0 -200
  135. package/src/asciiDiagram/__tests__/AsciiDiagramExtension.test.ts +0 -164
  136. package/src/asciiDiagram/__tests__/RepairableDiagramExtension.test.ts +0 -159
  137. package/src/asciiDiagram/__tests__/asciiDiagramCommands.test.ts +0 -284
  138. package/src/asciiDiagram/__tests__/asciiDiagramOps.test.ts +0 -114
  139. package/src/asciiDiagram/__tests__/asciiPaste.test.ts +0 -43
  140. package/src/asciiDiagram/asciiDiagramCommands.ts +0 -174
  141. package/src/asciiDiagram/asciiDiagramData.ts +0 -149
  142. package/src/asciiDiagram/asciiDiagramOps.ts +0 -238
  143. package/src/asciiDiagram/asciiPaste.ts +0 -19
  144. package/src/blockProperties.ts +0 -88
  145. package/src/blockRange.ts +0 -132
  146. package/src/blockSlice.ts +0 -75
  147. package/src/blockTagActivity.ts +0 -233
  148. package/src/buildDocumentPreviewMarkdown.ts +0 -168
  149. package/src/buildPreviewDoc.ts +0 -407
  150. package/src/codeContext/CodeContextSectionView.tsx +0 -124
  151. package/src/codeContext/CodeContextZoneManager.ts +0 -149
  152. package/src/codeContext/CodeContextZones.tsx +0 -121
  153. package/src/codeContext/diffContextSections.ts +0 -38
  154. package/src/codeContext/types.ts +0 -75
  155. package/src/codeSnippet/CodeSnippetExtension.ts +0 -205
  156. package/src/codeSnippet/CodeSnippetWidget.tsx +0 -109
  157. package/src/codeSnippet/__tests__/CodeSnippetExtension.test.ts +0 -95
  158. package/src/codeSnippet/__tests__/codeSnippetLanguages.test.ts +0 -50
  159. package/src/codeSnippet/codeSnippetCommands.ts +0 -21
  160. package/src/codeSnippet/codeSnippetData.ts +0 -43
  161. package/src/codeSnippet/codeSnippetLanguages.ts +0 -216
  162. package/src/customTemplates/AddBin.tsx +0 -126
  163. package/src/customTemplates/CustomLayoutManager.tsx +0 -234
  164. package/src/customTemplates/CustomTemplateContext.tsx +0 -188
  165. package/src/customTemplates/LayerToolbar.tsx +0 -580
  166. package/src/customTemplates/ShapeGlyph.tsx +0 -47
  167. package/src/customTemplates/TemplateDesigner.tsx +0 -433
  168. package/src/customTemplates/__tests__/library.test.ts +0 -96
  169. package/src/customTemplates/__tests__/normalizePositions.test.ts +0 -109
  170. package/src/customTemplates/__tests__/shapeDefs.test.ts +0 -49
  171. package/src/customTemplates/__tests__/useMemoryLayerAdapter.test.ts +0 -108
  172. package/src/customTemplates/designer.css +0 -732
  173. package/src/customTemplates/index.ts +0 -31
  174. package/src/customTemplates/library.ts +0 -110
  175. package/src/customTemplates/normalizePositions.ts +0 -75
  176. package/src/customTemplates/shapeDefs.ts +0 -131
  177. package/src/customTemplates/thumbnail.tsx +0 -63
  178. package/src/customTemplates/tokenDefs.ts +0 -60
  179. package/src/customTemplates/useDocCustomTemplates.ts +0 -52
  180. package/src/customTemplates/useMemoryLayerAdapter.ts +0 -129
  181. package/src/customThemes/CustomThemeContext.tsx +0 -185
  182. package/src/customThemes/CustomThemeDialog.tsx +0 -316
  183. package/src/customThemes/ImportThemeSection.tsx +0 -178
  184. package/src/customThemes/__tests__/CustomThemeContext.test.tsx +0 -64
  185. package/src/customThemes/__tests__/CustomThemeDialog.test.tsx +0 -47
  186. package/src/customThemes/__tests__/customThemeLibrary.test.ts +0 -60
  187. package/src/customThemes/__tests__/importThemeSection.test.tsx +0 -192
  188. package/src/customThemes/customThemeLibrary.ts +0 -100
  189. package/src/customThemes/index.ts +0 -37
  190. package/src/customThemes/themeControls.tsx +0 -229
  191. package/src/customThemes/themeDraft.ts +0 -288
  192. package/src/customThemes/useDocCustomThemes.ts +0 -49
  193. package/src/detectMarkdown.ts +0 -62
  194. package/src/diagram/DiagramCanvas.tsx +0 -260
  195. package/src/diagram/DiagramMaximizedOverlay.tsx +0 -46
  196. package/src/diagram/diagramCommands.ts +0 -604
  197. package/src/diagram/diagramConstants.ts +0 -17
  198. package/src/diagram/types.ts +0 -35
  199. package/src/editorScrollSync.ts +0 -73
  200. package/src/embeddedMedia.ts +0 -78
  201. package/src/emojiData.ts +0 -1317
  202. package/src/fileKind.ts +0 -158
  203. package/src/find/FindHighlightExtension.ts +0 -81
  204. package/src/find/FindToolbar.tsx +0 -314
  205. package/src/find/findModel.ts +0 -77
  206. package/src/frontmatter.ts +0 -29
  207. package/src/frontmatterSettings.ts +0 -23
  208. package/src/headingTransition.ts +0 -291
  209. package/src/hooks/useFileDrop.ts +0 -266
  210. package/src/imageEditor/CanvasSurface.tsx +0 -703
  211. package/src/imageEditor/ImageVersionHistoryDropdown.tsx +0 -396
  212. package/src/imageEditor/LayersPanel.tsx +0 -218
  213. package/src/imageEditor/PropertiesPanel.tsx +0 -474
  214. package/src/imageEditor/Toolbar.tsx +0 -459
  215. package/src/imageEditor/createShapeLayer.ts +0 -280
  216. package/src/imageEditor/icons.tsx +0 -68
  217. package/src/imageEditor/image-editor.css +0 -574
  218. package/src/imageEditor/layers/EditorImageLayer.tsx +0 -45
  219. package/src/imageEditor/layers/EditorShapeLayer.tsx +0 -62
  220. package/src/imageEditor/layers/EditorTextLayer.tsx +0 -45
  221. package/src/imageEditor/layers/SelectionHandles.tsx +0 -86
  222. package/src/imageEditor/state.ts +0 -173
  223. package/src/imageEditor/useImageEditor.ts +0 -385
  224. package/src/imageEditor/useImageEditorTokens.ts +0 -70
  225. package/src/index.ts +0 -559
  226. package/src/jsonEditor/EmbeddedRichTextField.tsx +0 -81
  227. package/src/jsonEditor/JsonEditor.tsx +0 -81
  228. package/src/jsonEditor/JsonEditorContext.tsx +0 -81
  229. package/src/jsonEditor/RenderNode.tsx +0 -87
  230. package/src/jsonEditor/editors.tsx +0 -745
  231. package/src/jsonEditor/index.ts +0 -2
  232. package/src/jsonEditor/json-editor.css +0 -463
  233. package/src/jsonEditor/useJsonEditorTokens.ts +0 -33
  234. package/src/markdownCodeFence.ts +0 -72
  235. package/src/mediaDragMime.ts +0 -32
  236. package/src/mediaEntries.ts +0 -12
  237. package/src/mediaReferences.ts +0 -301
  238. package/src/mermaid/MermaidDiagramCanvas.tsx +0 -693
  239. package/src/mermaid/MermaidDiagramExtension.ts +0 -243
  240. package/src/mermaid/MermaidDiagramTypeThumbnail.tsx +0 -184
  241. package/src/mermaid/MermaidDiagramWidget.tsx +0 -653
  242. package/src/mermaid/MermaidShapePalette.tsx +0 -245
  243. package/src/mermaid/__tests__/MermaidDiagramExtension.test.ts +0 -361
  244. package/src/mermaid/__tests__/mermaidDiagramTypes.test.ts +0 -35
  245. package/src/mermaid/__tests__/mermaidRenderer.test.ts +0 -49
  246. package/src/mermaid/__tests__/mermaidSourceOps.test.ts +0 -213
  247. package/src/mermaid/__tests__/mermaidSyntax.test.ts +0 -71
  248. package/src/mermaid/mermaidCommands.ts +0 -34
  249. package/src/mermaid/mermaidData.ts +0 -31
  250. package/src/mermaid/mermaidDiagramTypes.ts +0 -325
  251. package/src/mermaid/mermaidModel.ts +0 -31
  252. package/src/mermaid/mermaidRenderer.ts +0 -181
  253. package/src/mermaid/mermaidShapes.ts +0 -113
  254. package/src/mermaid/mermaidSourceOps.ts +0 -454
  255. package/src/monaco.ts +0 -35
  256. package/src/monacoWorkers.ts +0 -89
  257. package/src/outlineSource.ts +0 -171
  258. package/src/presentation/PresentationMode.tsx +0 -596
  259. package/src/rawEditorIsolation.ts +0 -18
  260. package/src/recorder/RecorderButton.tsx +0 -80
  261. package/src/recorder/RecorderModal.tsx +0 -706
  262. package/src/recorder/RecorderPanel.tsx +0 -77
  263. package/src/recorder/formats.ts +0 -159
  264. package/src/recorder/hooks/useMediaRecorder.ts +0 -436
  265. package/src/recorder/hooks/useStreamPreview.ts +0 -47
  266. package/src/recorder/insertMediaBlock.ts +0 -30
  267. package/src/recorder/sources/cameraStream.ts +0 -32
  268. package/src/recorder/sources/micStream.ts +0 -25
  269. package/src/recorder/sources/screenStream.ts +0 -162
  270. package/src/recorder/timingJson.ts +0 -66
  271. package/src/resolveBlockVisual.ts +0 -39
  272. package/src/scene/Scene.tsx +0 -647
  273. package/src/scene/SceneBlockExtension.ts +0 -205
  274. package/src/scene/SceneBlockToolbar.tsx +0 -216
  275. package/src/scene/SceneBlockWidget.tsx +0 -441
  276. package/src/scene/ScenePropsBar.tsx +0 -85
  277. package/src/scene/SceneSelection.tsx +0 -111
  278. package/src/scene/SceneSideToolbar.tsx +0 -89
  279. package/src/scene/SceneViewControls.tsx +0 -43
  280. package/src/scene/SceneViewport.tsx +0 -106
  281. package/src/scene/ShapePalette.tsx +0 -196
  282. package/src/scene/__tests__/DiagramAdapter.test.ts +0 -142
  283. package/src/scene/__tests__/SceneBlockExtension.test.ts +0 -33
  284. package/src/scene/__tests__/bezierEdit.test.ts +0 -85
  285. package/src/scene/__tests__/blockLayers.test.ts +0 -57
  286. package/src/scene/__tests__/fitScale.test.ts +0 -19
  287. package/src/scene/__tests__/sceneIsolation.test.tsx +0 -119
  288. package/src/scene/__tests__/shapeLayers.test.ts +0 -106
  289. package/src/scene/__tests__/useSceneHitTest.test.ts +0 -90
  290. package/src/scene/__tests__/useScenePanZoom.test.ts +0 -130
  291. package/src/scene/adapters/DiagramAdapter.ts +0 -79
  292. package/src/scene/adapters/DrawingAdapter.ts +0 -420
  293. package/src/scene/adapters/LayoutAdapter.ts +0 -313
  294. package/src/scene/adapters/blockLayers.ts +0 -159
  295. package/src/scene/commands/SceneCommand.ts +0 -84
  296. package/src/scene/commands/drawingCommands.ts +0 -318
  297. package/src/scene/commands/layoutCommands.ts +0 -301
  298. package/src/scene/fitScale.ts +0 -17
  299. package/src/scene/hooks/useSceneHitTest.ts +0 -105
  300. package/src/scene/hooks/useScenePanZoom.ts +0 -154
  301. package/src/scene/hooks/useSceneSelection.ts +0 -62
  302. package/src/scene/index.ts +0 -90
  303. package/src/scene/layers/DiagramEdges.tsx +0 -142
  304. package/src/scene/layers/edgeGeometry.ts +0 -104
  305. package/src/scene/layers/nodeCard.tsx +0 -164
  306. package/src/scene/layers/renderLayer.tsx +0 -70
  307. package/src/scene/layers/shapeLayers.ts +0 -201
  308. package/src/scene/paths/bezierEdit.ts +0 -208
  309. package/src/scene/scene.css +0 -874
  310. package/src/scene/text/SceneTextOverlay.tsx +0 -161
  311. package/src/scene/text/sceneTextChannel.ts +0 -46
  312. package/src/scene/text/sceneTextConfig.ts +0 -31
  313. package/src/scene/text/sceneTiptap.ts +0 -36
  314. package/src/scene/text/useSceneTextEditing.ts +0 -39
  315. package/src/scene/tools/ConnectTool.ts +0 -209
  316. package/src/scene/tools/DrawingConnectTool.ts +0 -231
  317. package/src/scene/tools/PathTool.ts +0 -158
  318. package/src/scene/tools/PlaceTool.ts +0 -47
  319. package/src/scene/tools/SceneTool.ts +0 -85
  320. package/src/scene/tools/SelectTool.ts +0 -300
  321. package/src/scene/tools/ShapeTool.ts +0 -143
  322. package/src/scene/tools/TextTool.ts +0 -72
  323. package/src/scene/tools/TokenTool.ts +0 -95
  324. package/src/scene/tools/createDrawShapeTool.ts +0 -82
  325. package/src/selectionConversions.ts +0 -155
  326. package/src/styles/ascii-diagram.css +0 -79
  327. package/src/styles/ascii-timeline.css +0 -596
  328. package/src/styles/code-context.css +0 -155
  329. package/src/styles/code-snippet.css +0 -76
  330. package/src/styles/diagram.css +0 -183
  331. package/src/styles/editor.css +0 -7131
  332. package/src/styles/folder-view.css +0 -210
  333. package/src/styles/image-edit-affordance.css +0 -201
  334. package/src/styles/index.css +0 -20
  335. package/src/styles/mermaid-diagram.css +0 -487
  336. package/src/styles/tree-view.css +0 -189
  337. package/src/teleprompter/TeleprompterControls.tsx +0 -218
  338. package/src/teleprompter/TeleprompterSelfView.tsx +0 -22
  339. package/src/teleprompter/TeleprompterSurface.tsx +0 -267
  340. package/src/teleprompter/TeleprompterView.tsx +0 -338
  341. package/src/teleprompter/canvasRenderer.ts +0 -161
  342. package/src/teleprompter/floatingWindow.ts +0 -352
  343. package/src/teleprompter/index.ts +0 -61
  344. package/src/teleprompter/pcmWorklet.ts +0 -62
  345. package/src/teleprompter/recording/insertPreamble.ts +0 -80
  346. package/src/teleprompter/recording/narrationSave.ts +0 -134
  347. package/src/teleprompter/recording/useNarrationRecorder.ts +0 -367
  348. package/src/teleprompter/scrollModel.ts +0 -85
  349. package/src/teleprompter/teleprompterTheme.ts +0 -303
  350. package/src/teleprompter/types.ts +0 -38
  351. package/src/teleprompter/useFloatingWindow.ts +0 -74
  352. package/src/teleprompter/useMicAnalysis.ts +0 -211
  353. package/src/teleprompter/useTeleprompter.ts +0 -421
  354. package/src/templateContentPreviewResolver.ts +0 -360
  355. package/src/timeline/TimelineEditorWidget.tsx +0 -861
  356. package/src/timeline/TimelineViewExtension.ts +0 -252
  357. package/src/timeline/__tests__/TimelineEditorWidget.test.tsx +0 -414
  358. package/src/timeline/__tests__/TimelineViewExtension.test.ts +0 -163
  359. package/src/timeline/__tests__/timelineCommands.test.ts +0 -359
  360. package/src/timeline/__tests__/timelineOps.test.ts +0 -277
  361. package/src/timeline/__tests__/timelinePaste.test.ts +0 -34
  362. package/src/timeline/timelineCommands.ts +0 -421
  363. package/src/timeline/timelineData.ts +0 -54
  364. package/src/timeline/timelineOps.ts +0 -381
  365. package/src/timeline/timelinePaste.ts +0 -8
  366. package/src/timelineSource.ts +0 -244
  367. package/src/tiptap/TiptapAudio.tsx +0 -86
  368. package/src/tiptap/TiptapVideo.tsx +0 -119
  369. package/src/tiptap/useResolvedMediaSrc.ts +0 -47
  370. package/src/tiptapBridge.ts +0 -986
  371. package/src/tooltipPlacement.ts +0 -13
  372. package/src/transformStyleId.ts +0 -17
  373. package/src/transitionCatalog.ts +0 -159
  374. package/src/treeview/TreeOutlineWidget.tsx +0 -390
  375. package/src/treeview/TreeViewExtension.ts +0 -250
  376. package/src/treeview/__tests__/TreeOutlineWidget.test.tsx +0 -156
  377. package/src/treeview/__tests__/TreeViewExtension.test.ts +0 -122
  378. package/src/treeview/__tests__/treeOps.test.ts +0 -177
  379. package/src/treeview/__tests__/treePaste.test.ts +0 -40
  380. package/src/treeview/__tests__/treeViewCommands.test.ts +0 -179
  381. package/src/treeview/treeOps.ts +0 -231
  382. package/src/treeview/treePaste.ts +0 -13
  383. package/src/treeview/treeViewCommands.ts +0 -99
  384. package/src/treeview/treeViewData.ts +0 -41
  385. package/src/types/monaco-shims.d.ts +0 -10
  386. package/src/useBlockNavigator.ts +0 -153
  387. package/src/useHeadingLayout.ts +0 -294
  388. package/src/useMonacoLoader.ts +0 -82
  389. package/src/useTimelineClock.ts +0 -76
  390. package/src/utils/collectInlineFontAwesomeCss.ts +0 -69
  391. package/src/utils/dropUtils.ts +0 -136
  392. package/src/utils/normalizeMalformedAssetUrl.ts +0 -22
  393. package/src/writeCanvasSettings.ts +0 -30
  394. 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
- }