@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,604 +0,0 @@
1
- /**
2
- * Tiptap commands for diagram editing.
3
- *
4
- * Each command finds the relevant heading inside a diagram section (parent
5
- * heading + its direct sub-headings until the next equal-or-shallower
6
- * heading) and mutates either its `data-block-attrs` attribute or its
7
- * text content. All edits flow back into markdown via the existing
8
- * `tiptapBridge` round-trip — no parallel data store.
9
- */
10
-
11
- import type { Editor } from '@tiptap/react';
12
- import type { Node as PMNode } from '@tiptap/pm/model';
13
- import {
14
- parsePandocAttrTokens,
15
- serializePandocAttributes,
16
- quoteAttrValue,
17
- type HeadingAttributes,
18
- } from '@bendyline/squisq/markdown';
19
- import type { Block, BlockConnection } from '@bendyline/squisq/schemas';
20
- import { computeDiagramLayout } from '@bendyline/squisq/doc';
21
-
22
- export interface HeadingLocation {
23
- /** Node start position in the doc (absolute). */
24
- pos: number;
25
- /** The heading PMNode. */
26
- node: PMNode;
27
- /** Parsed attributes derived from the heading's `data-block-attrs` (always defined). */
28
- attrs: HeadingAttributes;
29
- /** Computed id: explicit `#id` if set, otherwise the slugified heading text. */
30
- id: string;
31
- }
32
-
33
- /**
34
- * Slugify heading text the same way `core/src/doc/markdownToDoc.ts` does
35
- * (so an unset `#id` round-trips cleanly).
36
- */
37
- function slugify(text: string): string {
38
- const out = text
39
- .toLowerCase()
40
- .replace(/[^\w\s-]/g, '')
41
- .replace(/[\s_]+/g, '-')
42
- .replace(/-+/g, '-')
43
- .replace(/^-|-$/g, '');
44
- return out || 'block';
45
- }
46
-
47
- function getHeadingText(node: PMNode): string {
48
- let text = '';
49
- node.content.forEach((child) => {
50
- if (child.isText) text += child.text ?? '';
51
- });
52
- return text;
53
- }
54
-
55
- function getHeadingAttrs(node: PMNode): HeadingAttributes {
56
- const raw = (node.attrs as Record<string, unknown>).dataBlockAttrs;
57
- if (typeof raw === 'string' && raw.length > 0) {
58
- return parsePandocAttrTokens(raw);
59
- }
60
- return {};
61
- }
62
-
63
- function computeId(node: PMNode): string {
64
- const attrs = getHeadingAttrs(node);
65
- return attrs.id ?? slugify(getHeadingText(node));
66
- }
67
-
68
- /**
69
- * Find the diagram section that starts at `parentPos` (the position of the
70
- * parent heading with `dataTemplate === 'diagram'`). Returns the headings
71
- * that should appear as diagram nodes — defined as every heading at the
72
- * **shallowest** depth greater than the parent within the section, until
73
- * the next equal-or-shallower heading.
74
- *
75
- * Using the shallowest deeper depth (rather than a strict parentDepth + 1)
76
- * mirrors `markdownToDoc`'s stack behavior: when authors skip a level
77
- * (e.g. `# parent` + `### child`), those `###` headings are still treated
78
- * as direct children of the `#` parent. Any headings deeper than the
79
- * detected child depth are sub-sections of a node and are not surfaced as
80
- * separate diagram nodes.
81
- */
82
- export function listDiagramChildren(editor: Editor, parentPos: number): HeadingLocation[] {
83
- const { state } = editor;
84
- const parent = state.doc.nodeAt(parentPos);
85
- if (!parent || parent.type.name !== 'heading') return [];
86
- const parentDepth = (parent.attrs as { level: number }).level;
87
-
88
- // First pass: find the shallowest heading depth that appears below the
89
- // parent (and before the next ≤parent heading). That's the diagram's
90
- // child level.
91
- let childDepth: number | undefined;
92
- {
93
- let cursor = parentPos + parent.nodeSize;
94
- const docSize = state.doc.content.size;
95
- while (cursor < docSize) {
96
- const node = state.doc.nodeAt(cursor);
97
- if (!node) break;
98
- if (node.type.name === 'heading') {
99
- const level = (node.attrs as { level: number }).level;
100
- if (level <= parentDepth) break;
101
- if (childDepth === undefined || level < childDepth) childDepth = level;
102
- }
103
- cursor += node.nodeSize;
104
- }
105
- }
106
- if (childDepth === undefined) return [];
107
-
108
- // Second pass: emit headings at exactly that child depth.
109
- const results: HeadingLocation[] = [];
110
- let cursor = parentPos + parent.nodeSize;
111
- const docSize = state.doc.content.size;
112
- while (cursor < docSize) {
113
- const node = state.doc.nodeAt(cursor);
114
- if (!node) break;
115
- if (node.type.name === 'heading') {
116
- const level = (node.attrs as { level: number }).level;
117
- if (level <= parentDepth) break;
118
- if (level === childDepth) {
119
- results.push({
120
- pos: cursor,
121
- node,
122
- attrs: getHeadingAttrs(node),
123
- id: computeId(node),
124
- });
125
- }
126
- }
127
- cursor += node.nodeSize;
128
- }
129
- return results;
130
- }
131
-
132
- /**
133
- * Compute the doc position immediately after the last node belonging to the
134
- * diagram section (the parent heading + everything until the next
135
- * equal-or-shallower heading).
136
- */
137
- export function getDiagramSectionEnd(editor: Editor, parentPos: number): number {
138
- const { state } = editor;
139
- const parent = state.doc.nodeAt(parentPos);
140
- if (!parent || parent.type.name !== 'heading') return parentPos;
141
- const parentDepth = (parent.attrs as { level: number }).level;
142
-
143
- let cursor = parentPos + parent.nodeSize;
144
- const docSize = state.doc.content.size;
145
- while (cursor < docSize) {
146
- const node = state.doc.nodeAt(cursor);
147
- if (!node) break;
148
- if (node.type.name === 'heading') {
149
- const level = (node.attrs as { level: number }).level;
150
- if (level <= parentDepth) return cursor;
151
- }
152
- cursor += node.nodeSize;
153
- }
154
- return cursor;
155
- }
156
-
157
- /**
158
- * Read the diagram parent heading's `{[diagram …]}` template params
159
- * (stored in `dataTemplateParams`). Returns an empty object when the
160
- * heading carries no params. Mirrors the per-shape reader in
161
- * `drawingCommands.listDrawingChildren`, but for the parent heading.
162
- */
163
- export function getDiagramParams(editor: Editor, parentPos: number): Record<string, string> {
164
- const node = editor.state.doc.nodeAt(parentPos);
165
- if (!node || node.type.name !== 'heading') return {};
166
- const raw = (node.attrs as { dataTemplateParams?: string | null }).dataTemplateParams;
167
- if (typeof raw === 'string' && raw.length > 0) {
168
- return parsePandocAttrTokens(raw).params ?? {};
169
- }
170
- return {};
171
- }
172
-
173
- /**
174
- * The diagram's pinned canvas height in pixels (the `height=` template
175
- * param), or `null` when unset / invalid. This is an editor-only display
176
- * hint: the SSR `diagramBlock` template scales to its block viewport and
177
- * ignores it, but it round-trips in markdown via the annotation so the
178
- * chosen height is remembered.
179
- */
180
- export function getDiagramHeight(editor: Editor, parentPos: number): number | null {
181
- const raw = getDiagramParams(editor, parentPos).height;
182
- if (raw == null) return null;
183
- const n = Number(raw);
184
- return Number.isFinite(n) && n > 0 ? n : null;
185
- }
186
-
187
- /**
188
- * Pin (or clear) the diagram's canvas height, persisted as a `height=<px>`
189
- * token in the parent heading's `{[diagram …]}` annotation. Pass `null`
190
- * to drop the override and revert to the default height. Other params on
191
- * the heading are preserved.
192
- */
193
- export function setDiagramHeight(
194
- editor: Editor,
195
- parentPos: number,
196
- height: number | null,
197
- ): boolean {
198
- const node = editor.state.doc.nodeAt(parentPos);
199
- if (!node || node.type.name !== 'heading') return false;
200
- const params = getDiagramParams(editor, parentPos);
201
- if (height == null) {
202
- delete params.height;
203
- } else {
204
- params.height = String(Math.round(height));
205
- }
206
- const serialized = Object.entries(params)
207
- .map(([k, v]) => `${k}=${quoteAttrValue(v)}`)
208
- .join(' ');
209
- return editor
210
- .chain()
211
- .command(({ tr }) => {
212
- if (!tr.doc.nodeAt(parentPos)) return false;
213
- tr.setNodeAttribute(
214
- parentPos,
215
- 'dataTemplateParams',
216
- serialized.length > 0 ? serialized : null,
217
- );
218
- return true;
219
- })
220
- .run();
221
- }
222
-
223
- function applyAttrs(editor: Editor, pos: number, attrs: HeadingAttributes): boolean {
224
- // `serializePandocAttributes` returns the full `{…}` block, but
225
- // `data-block-attrs` stores the INSIDE of those braces (matching the
226
- // parser in tiptapBridge.ts that captures the inner text only). Strip
227
- // them here so we round-trip cleanly — otherwise the next save would
228
- // wrap the value in a second pair of braces.
229
- const raw = serializePandocAttributes(attrs);
230
- const inner = stripBraces(raw);
231
- return editor
232
- .chain()
233
- .command(({ tr }) => {
234
- const node = tr.doc.nodeAt(pos);
235
- if (!node) return false;
236
- tr.setNodeAttribute(pos, 'dataBlockAttrs', inner ?? null);
237
- return true;
238
- })
239
- .run();
240
- }
241
-
242
- function stripBraces(s: string | null): string | null {
243
- if (s == null) return null;
244
- // Empty Pandoc marker `{}` collapses to null (no attribute to persist).
245
- if (s === '{}') return null;
246
- if (s.startsWith('{') && s.endsWith('}')) return s.slice(1, -1);
247
- return s;
248
- }
249
-
250
- /**
251
- * Update a node's `x` / `y` attributes from a drag.
252
- *
253
- * Before writing the moved node, this also "freezes" any siblings that
254
- * lack an explicit position by snapshotting their currently-displayed
255
- * (auto-laid) coordinates. Without that, `computeDiagramLayout`'s grid
256
- * auto-placement is relative to the bounding box of pinned nodes — so
257
- * dragging one node would pull every unpinned sibling along behind it.
258
- * Freezing converts the implicit layout into explicit per-node
259
- * positions on the first interaction, after which each node moves
260
- * independently.
261
- */
262
- export function moveNode(
263
- editor: Editor,
264
- parentPos: number,
265
- nodeId: string,
266
- x: number,
267
- y: number,
268
- ): boolean {
269
- const children = listDiagramChildren(editor, parentPos);
270
- const target = children.find((c) => c.id === nodeId);
271
- if (!target) return false;
272
- const positions = computeCurrentPositions(children);
273
- return editor
274
- .chain()
275
- .command(({ tr }) => {
276
- for (const child of children) {
277
- const pos = positions.get(child.id);
278
- if (!pos) continue;
279
- const isMoved = child.id === nodeId;
280
- // Skip siblings that already have an explicit position — they
281
- // weren't moving anyway, and writing the same value back would
282
- // be a noisy no-op.
283
- if (!isMoved && pos.pinned) continue;
284
- const newX = isMoved ? x : pos.x;
285
- const newY = isMoved ? y : pos.y;
286
- writeChildPosition(tr, child, nodeId === child.id ? nodeId : child.id, newX, newY);
287
- }
288
- return true;
289
- })
290
- .run();
291
- }
292
-
293
- /**
294
- * Compute each child's currently-rendered position by running the
295
- * shared `computeDiagramLayout` on a set of synthetic blocks. Returns
296
- * a map of `nodeId → {x, y, pinned}`. `pinned` reflects whether the
297
- * child already had an authored position (so callers can decide
298
- * whether a write is necessary).
299
- */
300
- function computeCurrentPositions(
301
- children: readonly HeadingLocation[],
302
- ): Map<string, { x: number; y: number; pinned: boolean }> {
303
- const blocks: Block[] = children.map((c) => {
304
- const params = c.attrs.params ?? {};
305
- const xRaw = params.x;
306
- const yRaw = params.y;
307
- const xN = xRaw != null ? Number(xRaw) : NaN;
308
- const yN = yRaw != null ? Number(yRaw) : NaN;
309
- return {
310
- id: c.id,
311
- startTime: 0,
312
- duration: 0,
313
- audioSegment: 0,
314
- title: getHeadingText(c.node) || c.id,
315
- ...(Number.isFinite(xN) ? { x: xN } : {}),
316
- ...(Number.isFinite(yN) ? { y: yN } : {}),
317
- } as Block;
318
- });
319
- const layout = computeDiagramLayout(blocks);
320
- const out = new Map<string, { x: number; y: number; pinned: boolean }>();
321
- for (const node of layout.nodes) {
322
- out.set(node.id, { x: node.x, y: node.y, pinned: node.pinned });
323
- }
324
- return out;
325
- }
326
-
327
- /**
328
- * Set a child heading's `data-block-attrs` to the given position. The
329
- * heading's existing attrs (id, classes, other params) are preserved.
330
- * Used by {@link moveNode} when batch-writing the snapshot.
331
- */
332
- function writeChildPosition(
333
- tr: import('@tiptap/pm/state').Transaction,
334
- child: HeadingLocation,
335
- ensureId: string,
336
- x: number,
337
- y: number,
338
- ): void {
339
- const attrs: HeadingAttributes = { ...child.attrs };
340
- if (!attrs.id) attrs.id = ensureId;
341
- const params = { ...(attrs.params ?? {}) };
342
- params.x = String(Math.round(x));
343
- params.y = String(Math.round(y));
344
- attrs.params = params;
345
- const raw = serializePandocAttributes(attrs);
346
- const inner = stripBraces(raw);
347
- tr.setNodeAttribute(child.pos, 'dataBlockAttrs', inner ?? null);
348
- }
349
-
350
- /**
351
- * Update a node's per-node `w` / `h` attributes from a corner-handle
352
- * drag. Nodes without these params fall back to the default card size
353
- * (`NODE_WIDTH` / `NODE_HEIGHT`) at render time, so most authors never
354
- * see them in markdown.
355
- */
356
- export function resizeNode(
357
- editor: Editor,
358
- parentPos: number,
359
- nodeId: string,
360
- width: number,
361
- height: number,
362
- ): boolean {
363
- const target = listDiagramChildren(editor, parentPos).find((c) => c.id === nodeId);
364
- if (!target) return false;
365
- const attrs = { ...target.attrs };
366
- if (!attrs.id) attrs.id = nodeId;
367
- const params = { ...(attrs.params ?? {}) };
368
- params.w = String(Math.round(width));
369
- params.h = String(Math.round(height));
370
- attrs.params = params;
371
- return applyAttrs(editor, target.pos, attrs);
372
- }
373
-
374
- /**
375
- * Add a connection from `sourceId` to `targetId` (optionally typed). No-op
376
- * if the same connection already exists.
377
- */
378
- export function addConnection(
379
- editor: Editor,
380
- parentPos: number,
381
- sourceId: string,
382
- targetId: string,
383
- type?: string,
384
- ): boolean {
385
- const source = listDiagramChildren(editor, parentPos).find((c) => c.id === sourceId);
386
- if (!source) return false;
387
- const attrs = { ...source.attrs };
388
- if (!attrs.id) attrs.id = sourceId;
389
- const params = { ...(attrs.params ?? {}) };
390
- const existing = parseConnectionsList(params.connectsTo);
391
- const dup = existing.find((c) => c.target === targetId && (c.type ?? '') === (type ?? ''));
392
- if (dup) return false;
393
- existing.push(type ? { target: targetId, type } : { target: targetId });
394
- params.connectsTo = serializeConnectionsList(existing);
395
- attrs.params = params;
396
- return applyAttrs(editor, source.pos, attrs);
397
- }
398
-
399
- /**
400
- * Remove a connection from `sourceId` to `targetId`. If `type` is provided,
401
- * only the matching-typed entry is removed; otherwise the first match
402
- * (regardless of type) is removed.
403
- */
404
- export function removeConnection(
405
- editor: Editor,
406
- parentPos: number,
407
- sourceId: string,
408
- targetId: string,
409
- type?: string,
410
- ): boolean {
411
- const source = listDiagramChildren(editor, parentPos).find((c) => c.id === sourceId);
412
- if (!source) return false;
413
- const attrs = { ...source.attrs };
414
- const params = { ...(attrs.params ?? {}) };
415
- const existing = parseConnectionsList(params.connectsTo);
416
- const remaining = existing.filter((c) => {
417
- if (c.target !== targetId) return true;
418
- if (type != null && (c.type ?? '') !== type) return true;
419
- return false;
420
- });
421
- if (remaining.length === existing.length) return false;
422
- if (remaining.length === 0) {
423
- delete params.connectsTo;
424
- } else {
425
- params.connectsTo = serializeConnectionsList(remaining);
426
- }
427
- attrs.params = Object.keys(params).length > 0 ? params : undefined;
428
- return applyAttrs(editor, source.pos, attrs);
429
- }
430
-
431
- /**
432
- * Replace a heading's text content (used when the user renames a node
433
- * via a double-click in the canvas).
434
- */
435
- export function renameNode(
436
- editor: Editor,
437
- parentPos: number,
438
- nodeId: string,
439
- newText: string,
440
- ): boolean {
441
- const target = listDiagramChildren(editor, parentPos).find((c) => c.id === nodeId);
442
- if (!target) return false;
443
- const headingPos = target.pos;
444
- const heading = target.node;
445
- // Replace the heading's content with a single text node containing the
446
- // new text. This preserves heading attrs (including dataBlockAttrs).
447
- return editor
448
- .chain()
449
- .command(({ tr, state }) => {
450
- const from = headingPos + 1;
451
- const to = headingPos + heading.nodeSize - 1;
452
- const textNode = state.schema.text(newText);
453
- tr.replaceWith(from, to, textNode);
454
- return true;
455
- })
456
- .run();
457
- }
458
-
459
- /**
460
- * Insert a new heading node at the end of the diagram section. The new
461
- * heading carries `data-block-attrs` with the supplied id and position,
462
- * so the freshly-inserted node appears in React Flow at the expected
463
- * coordinates.
464
- */
465
- export function addNode(
466
- editor: Editor,
467
- parentPos: number,
468
- id: string,
469
- label: string,
470
- x: number,
471
- y: number,
472
- ): boolean {
473
- const { state } = editor;
474
- const parent = state.doc.nodeAt(parentPos);
475
- if (!parent || parent.type.name !== 'heading') return false;
476
- const parentDepth = (parent.attrs as { level: number }).level;
477
- // Inherit the depth of existing diagram children so a new node is a
478
- // sibling, not an accidental new shallower parent. Falls back to
479
- // parent+1 when the section is empty.
480
- const existing = listDiagramChildren(editor, parentPos);
481
- const inheritedDepth = existing[0]?.node.attrs.level as number | undefined;
482
- const childDepth = Math.min(6, inheritedDepth ?? parentDepth + 1);
483
-
484
- const insertPos = getDiagramSectionEnd(editor, parentPos);
485
- const dataBlockAttrs = serializePandocAttributes({
486
- id,
487
- params: { x: String(Math.round(x)), y: String(Math.round(y)) },
488
- });
489
- // Freeze any unpinned siblings before inserting — see `moveNode` for
490
- // the rationale. Without this, adding a node would shift other
491
- // unpinned siblings as the auto-layout's bounding box grows.
492
- const freezePositions = computeCurrentPositions(existing);
493
-
494
- return editor
495
- .chain()
496
- .command(({ tr, state: s }) => {
497
- for (const child of existing) {
498
- const pos = freezePositions.get(child.id);
499
- if (!pos || pos.pinned) continue;
500
- writeChildPosition(tr, child, child.id, pos.x, pos.y);
501
- }
502
- const headingType = s.schema.nodes.heading;
503
- if (!headingType) return false;
504
- const newHeading = headingType.create(
505
- {
506
- level: childDepth,
507
- dataTemplate: null,
508
- dataTemplateParams: null,
509
- dataBlockAttrs: stripBraces(dataBlockAttrs) ?? null,
510
- },
511
- s.schema.text(label),
512
- );
513
- tr.insert(insertPos, newHeading);
514
- return true;
515
- })
516
- .run();
517
- }
518
-
519
- /**
520
- * Remove a child node's heading (and any body content under it up to the
521
- * next heading). Also strips inbound `connectsTo` references on remaining
522
- * siblings so the diagram doesn't carry dangling targets.
523
- */
524
- export function removeNode(editor: Editor, parentPos: number, nodeId: string): boolean {
525
- const children = listDiagramChildren(editor, parentPos);
526
- const target = children.find((c) => c.id === nodeId);
527
- if (!target) return false;
528
-
529
- // Determine the deletion range: from the heading's start to the start
530
- // of the next heading at any depth (or the diagram section end).
531
- const { state } = editor;
532
- const docSize = state.doc.content.size;
533
- let cursor = target.pos + target.node.nodeSize;
534
- while (cursor < docSize) {
535
- const node = state.doc.nodeAt(cursor);
536
- if (!node) break;
537
- if (node.type.name === 'heading') break;
538
- cursor += node.nodeSize;
539
- }
540
- const deleteFrom = target.pos;
541
- const deleteTo = cursor;
542
-
543
- return editor
544
- .chain()
545
- .command(({ tr }) => {
546
- tr.delete(deleteFrom, deleteTo);
547
- return true;
548
- })
549
- .command(({ tr }) => {
550
- // After deletion, positions for remaining children have shifted;
551
- // re-walk and strip inbound references. We use the live doc from
552
- // the transaction so the positions stay correct.
553
- const stale = listDiagramChildren(editor, parentPos);
554
- for (const sib of stale) {
555
- if (sib.id === nodeId) continue;
556
- const params = { ...(sib.attrs.params ?? {}) };
557
- if (!params.connectsTo) continue;
558
- const entries = parseConnectionsList(params.connectsTo).filter((c) => c.target !== nodeId);
559
- const before = parseConnectionsList(params.connectsTo).length;
560
- if (entries.length === before) continue;
561
- if (entries.length === 0) {
562
- delete params.connectsTo;
563
- } else {
564
- params.connectsTo = serializeConnectionsList(entries);
565
- }
566
- const nextAttrs: HeadingAttributes = { ...sib.attrs };
567
- nextAttrs.params = Object.keys(params).length > 0 ? params : undefined;
568
- const raw = serializePandocAttributes(nextAttrs);
569
- tr.setNodeAttribute(sib.pos, 'dataBlockAttrs', raw ?? null);
570
- }
571
- return true;
572
- })
573
- .run();
574
- }
575
-
576
- // ============================================
577
- // Internal: connection-list parse / serialize
578
- // ============================================
579
- //
580
- // Mirrors `parseConnectionList` from core/annotationCoercion.ts, but
581
- // returns the raw object shape so we can mutate before re-serialising.
582
-
583
- function parseConnectionsList(raw: string | undefined): BlockConnection[] {
584
- if (!raw) return [];
585
- const out: BlockConnection[] = [];
586
- for (const part of raw.split(',')) {
587
- const entry = part.trim();
588
- if (!entry) continue;
589
- const colonIdx = entry.indexOf(':');
590
- if (colonIdx < 0) {
591
- out.push({ target: entry });
592
- } else {
593
- const target = entry.slice(0, colonIdx).trim();
594
- const type = entry.slice(colonIdx + 1).trim();
595
- if (!target) continue;
596
- out.push(type ? { target, type } : { target });
597
- }
598
- }
599
- return out;
600
- }
601
-
602
- function serializeConnectionsList(list: BlockConnection[]): string {
603
- return list.map((c) => (c.type ? `${c.target}:${c.type}` : c.target)).join(',');
604
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Shared diagram constants — kept out of `DiagramCanvas.tsx` so that file can
3
- * export only its component (which keeps React Fast Refresh working).
4
- */
5
-
6
- import { SelectTool, ConnectTool } from '../scene';
7
-
8
- /**
9
- * Viewport size for the diagram canvas — a wide-ish surface in author
10
- * units. The Scene's fit-on-mount centers the diagram inside whatever
11
- * container the canvas is rendered into. Exported so the host can place
12
- * new nodes at the viewport center.
13
- */
14
- export const DIAGRAM_VIEWPORT = { width: 1600, height: 900 };
15
-
16
- /** The diagram's tool vocabulary — surfaced in the shared block toolbar. */
17
- export const DIAGRAM_TOOLS = [SelectTool, ConnectTool];
@@ -1,35 +0,0 @@
1
- /** Data shapes consumed by `DiagramCanvas` / `buildDiagramScene`. */
2
-
3
- import type { DiagramEdgeAnchor } from '@bendyline/squisq/schemas';
4
- import type { ConnectorRouting } from '@bendyline/squisq/doc';
5
-
6
- export interface DiagramNode {
7
- id: string;
8
- position: { x: number; y: number };
9
- data: { label: string };
10
- type?: string;
11
- /** Per-node width override in canvas units. */
12
- width?: number;
13
- /** Per-node height override in canvas units. */
14
- height?: number;
15
- /** Render as a background container card (top-anchored label, muted fill). */
16
- kind?: 'container';
17
- }
18
-
19
- export interface DiagramEdge {
20
- id: string;
21
- source: string;
22
- target: string;
23
- label?: string;
24
- /** False → no end arrowhead. Undefined keeps the diagram default (arrow). */
25
- directed?: boolean;
26
- sourceAnchor?: DiagramEdgeAnchor;
27
- targetAnchor?: DiagramEdgeAnchor;
28
- routing?: ConnectorRouting;
29
- }
30
-
31
- export interface DiagramData {
32
- nodes: DiagramNode[];
33
- edges: DiagramEdge[];
34
- warnings: string[];
35
- }