@bendyline/squisq-editor-react 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (415) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +40 -0
  3. package/dist/chunk-54UGTQBO.js +862 -0
  4. package/dist/chunk-5JMHFAVW.js +2408 -0
  5. package/dist/chunk-5Q4JN4I5.js +132 -0
  6. package/dist/chunk-6VDYKI3L.js +49 -0
  7. package/dist/chunk-GS7QWYFT.js +9 -0
  8. package/dist/chunk-MJJK7YQB.js +949 -0
  9. package/dist/chunk-NITZVAXL.js +986 -0
  10. package/dist/chunk-TRCKHRBS.js +35234 -0
  11. package/dist/chunk-V44VP242.js +3256 -0
  12. package/dist/image-editor/index.d.ts +223 -0
  13. package/dist/image-editor/index.js +15 -0
  14. package/dist/index.d.ts +2060 -4040
  15. package/dist/index.js +496 -40014
  16. package/dist/json-editor/index.d.ts +27 -0
  17. package/dist/json-editor/index.js +7 -0
  18. package/dist/monaco.d.ts +1 -1
  19. package/dist/monaco.js +1 -2
  20. package/dist/recorder/index.d.ts +407 -0
  21. package/dist/recorder/index.js +43 -0
  22. package/dist/shell/index.d.ts +9 -0
  23. package/dist/shell/index.js +22 -0
  24. package/dist/shell-BxSCBm4H.d.ts +1064 -0
  25. package/dist/styles/index.css +598 -161
  26. package/dist/teleprompter/index.d.ts +497 -0
  27. package/dist/teleprompter/index.js +57 -0
  28. package/package.json +34 -8
  29. package/dist/index.js.map +0 -1
  30. package/dist/monaco.js.map +0 -1
  31. package/src/BlockCardView.tsx +0 -121
  32. package/src/BlockPreviewPanel.tsx +0 -69
  33. package/src/BlockPropertiesPopover.tsx +0 -222
  34. package/src/DocumentSettingsDialog.tsx +0 -272
  35. package/src/DropZoneOverlay.tsx +0 -137
  36. package/src/EditorContext.tsx +0 -1274
  37. package/src/EditorShell.tsx +0 -1358
  38. package/src/EmojiPicker.tsx +0 -332
  39. package/src/FolderView.tsx +0 -131
  40. package/src/Icon.tsx +0 -26
  41. package/src/ImageEditor.tsx +0 -395
  42. package/src/ImageNodeView.tsx +0 -284
  43. package/src/ImageViewer.tsx +0 -221
  44. package/src/InlineIcon.ts +0 -84
  45. package/src/InlinePreviewGutter.tsx +0 -590
  46. package/src/LinkDialog.tsx +0 -276
  47. package/src/MediaBin.tsx +0 -500
  48. package/src/MentionExtension.tsx +0 -261
  49. package/src/OutlinePanel.tsx +0 -547
  50. package/src/PlainHtmlPreview.tsx +0 -277
  51. package/src/PreviewControls.tsx +0 -1265
  52. package/src/PreviewPanel.tsx +0 -426
  53. package/src/RawEditor.tsx +0 -743
  54. package/src/RecorderEntry.tsx +0 -162
  55. package/src/StatusBar.tsx +0 -51
  56. package/src/TemplateAnnotation.ts +0 -167
  57. package/src/TemplateContentPreview.tsx +0 -56
  58. package/src/TemplatePicker.tsx +0 -1314
  59. package/src/ThemeCustomizerPanel.tsx +0 -304
  60. package/src/ThemePicker.tsx +0 -433
  61. package/src/TimelineBlockPreview.tsx +0 -37
  62. package/src/TimelineTrack.tsx +0 -671
  63. package/src/Toolbar.tsx +0 -2885
  64. package/src/Tooltip.tsx +0 -142
  65. package/src/TransitionPicker.tsx +0 -390
  66. package/src/VersionHistoryPanel.tsx +0 -359
  67. package/src/ViewMenuPanel.tsx +0 -189
  68. package/src/ViewSwitcher.tsx +0 -56
  69. package/src/WysiwygEditor.tsx +0 -806
  70. package/src/__tests__/blockProperties.test.ts +0 -92
  71. package/src/__tests__/blockPropertiesPopoverTheme.test.tsx +0 -33
  72. package/src/__tests__/blockRange.test.ts +0 -105
  73. package/src/__tests__/blockTagActivity.test.ts +0 -183
  74. package/src/__tests__/buildDocumentPreviewMarkdown.test.ts +0 -75
  75. package/src/__tests__/buildPreviewDocContent.test.ts +0 -65
  76. package/src/__tests__/buildPreviewDocTransition.test.ts +0 -92
  77. package/src/__tests__/canvasSurfaceTextEditing.test.tsx +0 -60
  78. package/src/__tests__/codeContextSectionView.test.tsx +0 -97
  79. package/src/__tests__/codeContextZoneManager.test.ts +0 -127
  80. package/src/__tests__/createShapeLayer.test.ts +0 -46
  81. package/src/__tests__/customLayoutManagerTheme.test.tsx +0 -34
  82. package/src/__tests__/detectMarkdown.test.ts +0 -73
  83. package/src/__tests__/diffContextSections.test.ts +0 -39
  84. package/src/__tests__/documentSettingsDialog.test.tsx +0 -197
  85. package/src/__tests__/drawingShapeRoundTrip.test.ts +0 -49
  86. package/src/__tests__/editorScrollHandoff.test.tsx +0 -102
  87. package/src/__tests__/editorScrollSync.test.ts +0 -65
  88. package/src/__tests__/editorShellCodeContext.test.tsx +0 -86
  89. package/src/__tests__/editorShellProps.test.tsx +0 -550
  90. package/src/__tests__/embeddedMedia.test.ts +0 -48
  91. package/src/__tests__/emojiPicker.test.tsx +0 -93
  92. package/src/__tests__/fileKind.test.ts +0 -112
  93. package/src/__tests__/findMode.test.tsx +0 -104
  94. package/src/__tests__/findModel.test.ts +0 -55
  95. package/src/__tests__/headingTransition.test.ts +0 -176
  96. package/src/__tests__/imageEditAffordance.test.tsx +0 -272
  97. package/src/__tests__/imageEditModalContract.test.tsx +0 -119
  98. package/src/__tests__/imageEditorShell.test.tsx +0 -94
  99. package/src/__tests__/imageEditorState.test.ts +0 -171
  100. package/src/__tests__/inlinePreviewGutter.test.tsx +0 -62
  101. package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +0 -103
  102. package/src/__tests__/jsonEditor.test.tsx +0 -223
  103. package/src/__tests__/layersPanel.test.tsx +0 -167
  104. package/src/__tests__/layoutChildRoundTrip.test.ts +0 -71
  105. package/src/__tests__/linkDialogDocPicker.test.tsx +0 -137
  106. package/src/__tests__/majorApiTypes.test.ts +0 -26
  107. package/src/__tests__/markdownCodeFence.test.ts +0 -45
  108. package/src/__tests__/mediaAttachmentFlow.test.ts +0 -110
  109. package/src/__tests__/mediaBinDrop.test.tsx +0 -90
  110. package/src/__tests__/mediaReferences.test.ts +0 -97
  111. package/src/__tests__/narrationSave.test.ts +0 -148
  112. package/src/__tests__/outlinePanel.test.tsx +0 -169
  113. package/src/__tests__/outlineSource.test.ts +0 -217
  114. package/src/__tests__/plainHtmlPreview.test.tsx +0 -125
  115. package/src/__tests__/presentationMode.test.tsx +0 -290
  116. package/src/__tests__/previewControls.test.tsx +0 -571
  117. package/src/__tests__/previewPanelAudioFailure.test.tsx +0 -46
  118. package/src/__tests__/previewPanelPresentation.test.tsx +0 -126
  119. package/src/__tests__/previewPanelTransforms.test.tsx +0 -117
  120. package/src/__tests__/propertiesPanel.test.tsx +0 -69
  121. package/src/__tests__/rawEditorModelIsolation.test.ts +0 -19
  122. package/src/__tests__/recorderFormats.test.ts +0 -146
  123. package/src/__tests__/recorderMediaInsert.test.ts +0 -86
  124. package/src/__tests__/recorderTheme.test.tsx +0 -42
  125. package/src/__tests__/recorderTimingJson.test.ts +0 -41
  126. package/src/__tests__/resolveBlockVisual.test.ts +0 -43
  127. package/src/__tests__/selectionConversions.test.ts +0 -80
  128. package/src/__tests__/statusBar.test.tsx +0 -27
  129. package/src/__tests__/teleprompter.test.tsx +0 -190
  130. package/src/__tests__/templateAnnotationRoundTrip.test.ts +0 -99
  131. package/src/__tests__/templateContentPreview.test.ts +0 -101
  132. package/src/__tests__/templatePickerMetadata.test.ts +0 -32
  133. package/src/__tests__/templatePickerPortal.test.tsx +0 -62
  134. package/src/__tests__/timelineSource.test.ts +0 -134
  135. package/src/__tests__/tiptapBridge.test.ts +0 -575
  136. package/src/__tests__/tiptapBridgeConformance.test.ts +0 -47
  137. package/src/__tests__/tiptapCodeBlockRoundTrip.test.ts +0 -109
  138. package/src/__tests__/tiptapImageRoundTrip.test.ts +0 -73
  139. package/src/__tests__/toolbarSelectionConversion.test.tsx +0 -190
  140. package/src/__tests__/tooltip.test.tsx +0 -72
  141. package/src/__tests__/transformStyleId.test.ts +0 -13
  142. package/src/__tests__/transitionCatalog.test.ts +0 -64
  143. package/src/__tests__/useBlockNavigator.test.tsx +0 -67
  144. package/src/__tests__/useImageEditor.test.tsx +0 -226
  145. package/src/__tests__/useJsonEditorTokens.test.ts +0 -59
  146. package/src/__tests__/useMediaRecorder.test.ts +0 -302
  147. package/src/__tests__/useTimelineClock.test.ts +0 -21
  148. package/src/__tests__/versionHistory.test.tsx +0 -197
  149. package/src/__tests__/viewMenuPanel.test.tsx +0 -130
  150. package/src/__tests__/writeCanvasSettings.test.ts +0 -15
  151. package/src/__tests__/wysiwygImageUpload.test.ts +0 -69
  152. package/src/__tests__/wysiwygTemplateBadgeFocus.test.tsx +0 -56
  153. package/src/asciiDiagram/AsciiDiagramExtension.ts +0 -343
  154. package/src/asciiDiagram/AsciiDiagramWidget.tsx +0 -254
  155. package/src/asciiDiagram/RepairableDiagramExtension.ts +0 -200
  156. package/src/asciiDiagram/__tests__/AsciiDiagramExtension.test.ts +0 -164
  157. package/src/asciiDiagram/__tests__/RepairableDiagramExtension.test.ts +0 -159
  158. package/src/asciiDiagram/__tests__/asciiDiagramCommands.test.ts +0 -284
  159. package/src/asciiDiagram/__tests__/asciiDiagramOps.test.ts +0 -114
  160. package/src/asciiDiagram/__tests__/asciiPaste.test.ts +0 -43
  161. package/src/asciiDiagram/asciiDiagramCommands.ts +0 -174
  162. package/src/asciiDiagram/asciiDiagramData.ts +0 -149
  163. package/src/asciiDiagram/asciiDiagramOps.ts +0 -238
  164. package/src/asciiDiagram/asciiPaste.ts +0 -19
  165. package/src/blockProperties.ts +0 -88
  166. package/src/blockRange.ts +0 -132
  167. package/src/blockSlice.ts +0 -75
  168. package/src/blockTagActivity.ts +0 -233
  169. package/src/buildDocumentPreviewMarkdown.ts +0 -168
  170. package/src/buildPreviewDoc.ts +0 -407
  171. package/src/codeContext/CodeContextSectionView.tsx +0 -124
  172. package/src/codeContext/CodeContextZoneManager.ts +0 -149
  173. package/src/codeContext/CodeContextZones.tsx +0 -121
  174. package/src/codeContext/diffContextSections.ts +0 -38
  175. package/src/codeContext/types.ts +0 -75
  176. package/src/codeSnippet/CodeSnippetExtension.ts +0 -205
  177. package/src/codeSnippet/CodeSnippetWidget.tsx +0 -109
  178. package/src/codeSnippet/__tests__/CodeSnippetExtension.test.ts +0 -95
  179. package/src/codeSnippet/__tests__/codeSnippetLanguages.test.ts +0 -50
  180. package/src/codeSnippet/codeSnippetCommands.ts +0 -21
  181. package/src/codeSnippet/codeSnippetData.ts +0 -43
  182. package/src/codeSnippet/codeSnippetLanguages.ts +0 -216
  183. package/src/customTemplates/AddBin.tsx +0 -126
  184. package/src/customTemplates/CustomLayoutManager.tsx +0 -234
  185. package/src/customTemplates/CustomTemplateContext.tsx +0 -188
  186. package/src/customTemplates/LayerToolbar.tsx +0 -580
  187. package/src/customTemplates/ShapeGlyph.tsx +0 -47
  188. package/src/customTemplates/TemplateDesigner.tsx +0 -433
  189. package/src/customTemplates/__tests__/library.test.ts +0 -96
  190. package/src/customTemplates/__tests__/normalizePositions.test.ts +0 -109
  191. package/src/customTemplates/__tests__/shapeDefs.test.ts +0 -49
  192. package/src/customTemplates/__tests__/useMemoryLayerAdapter.test.ts +0 -108
  193. package/src/customTemplates/designer.css +0 -732
  194. package/src/customTemplates/index.ts +0 -31
  195. package/src/customTemplates/library.ts +0 -110
  196. package/src/customTemplates/normalizePositions.ts +0 -75
  197. package/src/customTemplates/shapeDefs.ts +0 -131
  198. package/src/customTemplates/thumbnail.tsx +0 -63
  199. package/src/customTemplates/tokenDefs.ts +0 -60
  200. package/src/customTemplates/useDocCustomTemplates.ts +0 -52
  201. package/src/customTemplates/useMemoryLayerAdapter.ts +0 -129
  202. package/src/customThemes/CustomThemeContext.tsx +0 -185
  203. package/src/customThemes/CustomThemeDialog.tsx +0 -316
  204. package/src/customThemes/ImportThemeSection.tsx +0 -178
  205. package/src/customThemes/__tests__/CustomThemeContext.test.tsx +0 -64
  206. package/src/customThemes/__tests__/CustomThemeDialog.test.tsx +0 -47
  207. package/src/customThemes/__tests__/customThemeLibrary.test.ts +0 -60
  208. package/src/customThemes/__tests__/importThemeSection.test.tsx +0 -192
  209. package/src/customThemes/customThemeLibrary.ts +0 -100
  210. package/src/customThemes/index.ts +0 -37
  211. package/src/customThemes/themeControls.tsx +0 -229
  212. package/src/customThemes/themeDraft.ts +0 -288
  213. package/src/customThemes/useDocCustomThemes.ts +0 -49
  214. package/src/detectMarkdown.ts +0 -62
  215. package/src/diagram/DiagramCanvas.tsx +0 -260
  216. package/src/diagram/DiagramMaximizedOverlay.tsx +0 -46
  217. package/src/diagram/diagramCommands.ts +0 -604
  218. package/src/diagram/diagramConstants.ts +0 -17
  219. package/src/diagram/types.ts +0 -35
  220. package/src/editorScrollSync.ts +0 -73
  221. package/src/embeddedMedia.ts +0 -78
  222. package/src/emojiData.ts +0 -1317
  223. package/src/fileKind.ts +0 -158
  224. package/src/find/FindHighlightExtension.ts +0 -81
  225. package/src/find/FindToolbar.tsx +0 -314
  226. package/src/find/findModel.ts +0 -77
  227. package/src/frontmatter.ts +0 -29
  228. package/src/frontmatterSettings.ts +0 -23
  229. package/src/headingTransition.ts +0 -291
  230. package/src/hooks/useFileDrop.ts +0 -266
  231. package/src/imageEditor/CanvasSurface.tsx +0 -703
  232. package/src/imageEditor/ImageVersionHistoryDropdown.tsx +0 -396
  233. package/src/imageEditor/LayersPanel.tsx +0 -218
  234. package/src/imageEditor/PropertiesPanel.tsx +0 -474
  235. package/src/imageEditor/Toolbar.tsx +0 -459
  236. package/src/imageEditor/createShapeLayer.ts +0 -280
  237. package/src/imageEditor/icons.tsx +0 -68
  238. package/src/imageEditor/image-editor.css +0 -574
  239. package/src/imageEditor/layers/EditorImageLayer.tsx +0 -45
  240. package/src/imageEditor/layers/EditorShapeLayer.tsx +0 -62
  241. package/src/imageEditor/layers/EditorTextLayer.tsx +0 -45
  242. package/src/imageEditor/layers/SelectionHandles.tsx +0 -86
  243. package/src/imageEditor/state.ts +0 -173
  244. package/src/imageEditor/useImageEditor.ts +0 -385
  245. package/src/imageEditor/useImageEditorTokens.ts +0 -70
  246. package/src/index.ts +0 -559
  247. package/src/jsonEditor/EmbeddedRichTextField.tsx +0 -81
  248. package/src/jsonEditor/JsonEditor.tsx +0 -81
  249. package/src/jsonEditor/JsonEditorContext.tsx +0 -81
  250. package/src/jsonEditor/RenderNode.tsx +0 -87
  251. package/src/jsonEditor/editors.tsx +0 -745
  252. package/src/jsonEditor/index.ts +0 -2
  253. package/src/jsonEditor/json-editor.css +0 -463
  254. package/src/jsonEditor/useJsonEditorTokens.ts +0 -33
  255. package/src/markdownCodeFence.ts +0 -72
  256. package/src/mediaDragMime.ts +0 -32
  257. package/src/mediaEntries.ts +0 -12
  258. package/src/mediaReferences.ts +0 -301
  259. package/src/mermaid/MermaidDiagramCanvas.tsx +0 -693
  260. package/src/mermaid/MermaidDiagramExtension.ts +0 -243
  261. package/src/mermaid/MermaidDiagramTypeThumbnail.tsx +0 -184
  262. package/src/mermaid/MermaidDiagramWidget.tsx +0 -653
  263. package/src/mermaid/MermaidShapePalette.tsx +0 -245
  264. package/src/mermaid/__tests__/MermaidDiagramExtension.test.ts +0 -361
  265. package/src/mermaid/__tests__/mermaidDiagramTypes.test.ts +0 -35
  266. package/src/mermaid/__tests__/mermaidRenderer.test.ts +0 -49
  267. package/src/mermaid/__tests__/mermaidSourceOps.test.ts +0 -213
  268. package/src/mermaid/__tests__/mermaidSyntax.test.ts +0 -71
  269. package/src/mermaid/mermaidCommands.ts +0 -34
  270. package/src/mermaid/mermaidData.ts +0 -31
  271. package/src/mermaid/mermaidDiagramTypes.ts +0 -325
  272. package/src/mermaid/mermaidModel.ts +0 -31
  273. package/src/mermaid/mermaidRenderer.ts +0 -181
  274. package/src/mermaid/mermaidShapes.ts +0 -113
  275. package/src/mermaid/mermaidSourceOps.ts +0 -454
  276. package/src/monaco.ts +0 -35
  277. package/src/monacoWorkers.ts +0 -89
  278. package/src/outlineSource.ts +0 -171
  279. package/src/presentation/PresentationMode.tsx +0 -596
  280. package/src/rawEditorIsolation.ts +0 -18
  281. package/src/recorder/RecorderButton.tsx +0 -80
  282. package/src/recorder/RecorderModal.tsx +0 -706
  283. package/src/recorder/RecorderPanel.tsx +0 -77
  284. package/src/recorder/formats.ts +0 -159
  285. package/src/recorder/hooks/useMediaRecorder.ts +0 -436
  286. package/src/recorder/hooks/useStreamPreview.ts +0 -47
  287. package/src/recorder/insertMediaBlock.ts +0 -30
  288. package/src/recorder/sources/cameraStream.ts +0 -32
  289. package/src/recorder/sources/micStream.ts +0 -25
  290. package/src/recorder/sources/screenStream.ts +0 -162
  291. package/src/recorder/timingJson.ts +0 -66
  292. package/src/resolveBlockVisual.ts +0 -39
  293. package/src/scene/Scene.tsx +0 -647
  294. package/src/scene/SceneBlockExtension.ts +0 -205
  295. package/src/scene/SceneBlockToolbar.tsx +0 -216
  296. package/src/scene/SceneBlockWidget.tsx +0 -441
  297. package/src/scene/ScenePropsBar.tsx +0 -85
  298. package/src/scene/SceneSelection.tsx +0 -111
  299. package/src/scene/SceneSideToolbar.tsx +0 -89
  300. package/src/scene/SceneViewControls.tsx +0 -43
  301. package/src/scene/SceneViewport.tsx +0 -106
  302. package/src/scene/ShapePalette.tsx +0 -196
  303. package/src/scene/__tests__/DiagramAdapter.test.ts +0 -142
  304. package/src/scene/__tests__/SceneBlockExtension.test.ts +0 -33
  305. package/src/scene/__tests__/bezierEdit.test.ts +0 -85
  306. package/src/scene/__tests__/blockLayers.test.ts +0 -57
  307. package/src/scene/__tests__/fitScale.test.ts +0 -19
  308. package/src/scene/__tests__/sceneIsolation.test.tsx +0 -119
  309. package/src/scene/__tests__/shapeLayers.test.ts +0 -106
  310. package/src/scene/__tests__/useSceneHitTest.test.ts +0 -90
  311. package/src/scene/__tests__/useScenePanZoom.test.ts +0 -130
  312. package/src/scene/adapters/DiagramAdapter.ts +0 -79
  313. package/src/scene/adapters/DrawingAdapter.ts +0 -420
  314. package/src/scene/adapters/LayoutAdapter.ts +0 -313
  315. package/src/scene/adapters/blockLayers.ts +0 -159
  316. package/src/scene/commands/SceneCommand.ts +0 -84
  317. package/src/scene/commands/drawingCommands.ts +0 -318
  318. package/src/scene/commands/layoutCommands.ts +0 -301
  319. package/src/scene/fitScale.ts +0 -17
  320. package/src/scene/hooks/useSceneHitTest.ts +0 -105
  321. package/src/scene/hooks/useScenePanZoom.ts +0 -154
  322. package/src/scene/hooks/useSceneSelection.ts +0 -62
  323. package/src/scene/index.ts +0 -90
  324. package/src/scene/layers/DiagramEdges.tsx +0 -142
  325. package/src/scene/layers/edgeGeometry.ts +0 -104
  326. package/src/scene/layers/nodeCard.tsx +0 -164
  327. package/src/scene/layers/renderLayer.tsx +0 -70
  328. package/src/scene/layers/shapeLayers.ts +0 -201
  329. package/src/scene/paths/bezierEdit.ts +0 -208
  330. package/src/scene/scene.css +0 -874
  331. package/src/scene/text/SceneTextOverlay.tsx +0 -161
  332. package/src/scene/text/sceneTextChannel.ts +0 -46
  333. package/src/scene/text/sceneTextConfig.ts +0 -31
  334. package/src/scene/text/sceneTiptap.ts +0 -36
  335. package/src/scene/text/useSceneTextEditing.ts +0 -39
  336. package/src/scene/tools/ConnectTool.ts +0 -209
  337. package/src/scene/tools/DrawingConnectTool.ts +0 -231
  338. package/src/scene/tools/PathTool.ts +0 -158
  339. package/src/scene/tools/PlaceTool.ts +0 -47
  340. package/src/scene/tools/SceneTool.ts +0 -85
  341. package/src/scene/tools/SelectTool.ts +0 -300
  342. package/src/scene/tools/ShapeTool.ts +0 -143
  343. package/src/scene/tools/TextTool.ts +0 -72
  344. package/src/scene/tools/TokenTool.ts +0 -95
  345. package/src/scene/tools/createDrawShapeTool.ts +0 -82
  346. package/src/selectionConversions.ts +0 -155
  347. package/src/styles/ascii-diagram.css +0 -79
  348. package/src/styles/ascii-timeline.css +0 -596
  349. package/src/styles/code-context.css +0 -155
  350. package/src/styles/code-snippet.css +0 -76
  351. package/src/styles/diagram.css +0 -183
  352. package/src/styles/editor.css +0 -7131
  353. package/src/styles/folder-view.css +0 -210
  354. package/src/styles/image-edit-affordance.css +0 -201
  355. package/src/styles/index.css +0 -20
  356. package/src/styles/mermaid-diagram.css +0 -487
  357. package/src/styles/tree-view.css +0 -189
  358. package/src/teleprompter/TeleprompterControls.tsx +0 -218
  359. package/src/teleprompter/TeleprompterSelfView.tsx +0 -22
  360. package/src/teleprompter/TeleprompterSurface.tsx +0 -267
  361. package/src/teleprompter/TeleprompterView.tsx +0 -338
  362. package/src/teleprompter/canvasRenderer.ts +0 -161
  363. package/src/teleprompter/floatingWindow.ts +0 -352
  364. package/src/teleprompter/index.ts +0 -61
  365. package/src/teleprompter/pcmWorklet.ts +0 -62
  366. package/src/teleprompter/recording/insertPreamble.ts +0 -80
  367. package/src/teleprompter/recording/narrationSave.ts +0 -134
  368. package/src/teleprompter/recording/useNarrationRecorder.ts +0 -367
  369. package/src/teleprompter/scrollModel.ts +0 -85
  370. package/src/teleprompter/teleprompterTheme.ts +0 -303
  371. package/src/teleprompter/types.ts +0 -38
  372. package/src/teleprompter/useFloatingWindow.ts +0 -74
  373. package/src/teleprompter/useMicAnalysis.ts +0 -211
  374. package/src/teleprompter/useTeleprompter.ts +0 -421
  375. package/src/templateContentPreviewResolver.ts +0 -360
  376. package/src/timeline/TimelineEditorWidget.tsx +0 -861
  377. package/src/timeline/TimelineViewExtension.ts +0 -252
  378. package/src/timeline/__tests__/TimelineEditorWidget.test.tsx +0 -414
  379. package/src/timeline/__tests__/TimelineViewExtension.test.ts +0 -163
  380. package/src/timeline/__tests__/timelineCommands.test.ts +0 -359
  381. package/src/timeline/__tests__/timelineOps.test.ts +0 -277
  382. package/src/timeline/__tests__/timelinePaste.test.ts +0 -34
  383. package/src/timeline/timelineCommands.ts +0 -421
  384. package/src/timeline/timelineData.ts +0 -54
  385. package/src/timeline/timelineOps.ts +0 -381
  386. package/src/timeline/timelinePaste.ts +0 -8
  387. package/src/timelineSource.ts +0 -244
  388. package/src/tiptap/TiptapAudio.tsx +0 -86
  389. package/src/tiptap/TiptapVideo.tsx +0 -119
  390. package/src/tiptap/useResolvedMediaSrc.ts +0 -47
  391. package/src/tiptapBridge.ts +0 -986
  392. package/src/tooltipPlacement.ts +0 -13
  393. package/src/transformStyleId.ts +0 -17
  394. package/src/transitionCatalog.ts +0 -159
  395. package/src/treeview/TreeOutlineWidget.tsx +0 -390
  396. package/src/treeview/TreeViewExtension.ts +0 -250
  397. package/src/treeview/__tests__/TreeOutlineWidget.test.tsx +0 -156
  398. package/src/treeview/__tests__/TreeViewExtension.test.ts +0 -122
  399. package/src/treeview/__tests__/treeOps.test.ts +0 -177
  400. package/src/treeview/__tests__/treePaste.test.ts +0 -40
  401. package/src/treeview/__tests__/treeViewCommands.test.ts +0 -179
  402. package/src/treeview/treeOps.ts +0 -231
  403. package/src/treeview/treePaste.ts +0 -13
  404. package/src/treeview/treeViewCommands.ts +0 -99
  405. package/src/treeview/treeViewData.ts +0 -41
  406. package/src/types/monaco-shims.d.ts +0 -10
  407. package/src/useBlockNavigator.ts +0 -153
  408. package/src/useHeadingLayout.ts +0 -294
  409. package/src/useMonacoLoader.ts +0 -82
  410. package/src/useTimelineClock.ts +0 -76
  411. package/src/utils/collectInlineFontAwesomeCss.ts +0 -69
  412. package/src/utils/dropUtils.ts +0 -136
  413. package/src/utils/normalizeMalformedAssetUrl.ts +0 -22
  414. package/src/writeCanvasSettings.ts +0 -30
  415. package/src/wysiwygImageUpload.ts +0 -113
package/src/RawEditor.tsx DELETED
@@ -1,743 +0,0 @@
1
- /**
2
- * RawEditor
3
- *
4
- * Monaco-based raw markdown editor. Provides full VS Code-like editing
5
- * experience with syntax highlighting, minimap, and bracket matching.
6
- * Syncs changes back to EditorContext on every keystroke (debounced).
7
- */
8
-
9
- import { useRef, useCallback, useEffect } from 'react';
10
- import Editor, { type OnMount, type OnChange, type BeforeMount } from '@monaco-editor/react';
11
- import type * as monaco from 'monaco-editor';
12
- import { useEditorContext } from './EditorContext';
13
- import { getAvailableTemplates } from '@bendyline/squisq/doc';
14
- import { suggestIcons, resolveIcon, iconGlyph } from '@bendyline/squisq/icons';
15
- import { BLOCK_META_KEY_DESCRIPTORS, tokenizeAttrTokens } from '@bendyline/squisq/markdown';
16
- import { SQUISQ_MEDIA_MIME, parseSquisqMediaPayload } from './mediaDragMime';
17
- import { canHandleSquisqMediaDrop, ownsMonacoModel } from './rawEditorIsolation';
18
- import { useMonacoLoader } from './useMonacoLoader';
19
- import { isMarkdownFencedCodeLine, markdownFencedCodeLineMask } from './markdownCodeFence';
20
-
21
- // Monaco is loaded lazily through `useMonacoLoader` (see the hook for the
22
- // rationale). The type-only `import type * as monaco from 'monaco-editor'`
23
- // above gives us `monaco.editor.IStandaloneCodeEditor`, `monaco.Range`,
24
- // etc. for typing without pulling the package into the static module
25
- // graph — which is the whole point: a consumer importing `JsonEditor` or
26
- // a type from the package barrel no longer drags ~9MB of language
27
- // services into the resolver.
28
- //
29
- // Consumers that *do* want the raw editor can still slim the bundle by
30
- // aliasing `monaco-editor` to a custom entry in their bundler config.
31
- // For example with Vite:
32
- //
33
- // resolve: { alias: [{ find: /^monaco-editor$/, replacement: './monaco-slim.ts' }] }
34
- //
35
- // Where monaco-slim.ts re-exports 'monaco-editor/esm/vs/editor/editor.api'
36
- // plus only the language contributions actually needed
37
- // (`basic-languages/monaco.contribution` for the broad TM grammars,
38
- // and any of `language/{css,html,json,typescript}/monaco.contribution`
39
- // for the rich language services). Skipping the language contributions
40
- // entirely means `defaultLanguage` becomes inert — no tokenizer
41
- // registered, so every file renders as plain foreground text.
42
-
43
- // Squisq Monaco themes: same syntax highlighting as vs / vs-dark, but with
44
- // Monaco's internal gutter (line numbers + folding margin) and overview
45
- // ruler tinted to match the side-pane "desk" colors so the canvas's
46
- // internal furniture blends with its surroundings. The seam color is the
47
- // 1px line Monaco draws between the white canvas and the overview ruler;
48
- // matches the `::after` border on `.margin` so both sides of the canvas
49
- // frame look the same.
50
- const SQUISQ_LIGHT_GUTTER = '#dcd8d0';
51
- const SQUISQ_DARK_GUTTER = '#0f1219';
52
- const SQUISQ_LIGHT_SEAM = '#b0a99a';
53
- const SQUISQ_DARK_SEAM = '#2a3144';
54
-
55
- const SQUISQ_THEMES: Record<string, string> = {
56
- vs: 'squisq-light',
57
- 'vs-dark': 'squisq-dark',
58
- };
59
-
60
- export interface RawEditorProps {
61
- /**
62
- * Monaco editor theme name (default: `'vs'`). Accepts Monaco's built-in
63
- * theme ids (`'vs'`, `'vs-dark'`, `'hc-black'`) — which are transparently
64
- * mapped to the Squisq-tinted variants — or any custom theme registered
65
- * via `monaco.editor.defineTheme`. This is the *code editor* color
66
- * theme, distinct from the shell's light/dark `colorScheme`.
67
- */
68
- monacoTheme?: string;
69
- /** Show minimap (default: false) */
70
- minimap?: boolean;
71
- /** Font size in pixels (default: 14) */
72
- fontSize?: number;
73
- /** Word wrap setting (default: 'on') */
74
- wordWrap?: 'on' | 'off' | 'wordWrapColumn' | 'bounded';
75
- /** Additional class name for the container */
76
- className?: string;
77
- /**
78
- * Chat-composer mode: Enter fires this callback (submit) and Cmd/Ctrl+Enter
79
- * inserts a newline. When undefined, behaves normally.
80
- */
81
- submitOnEnter?: () => void;
82
- /** Make Monaco read-only (no edits, no cursor blink). */
83
- readOnly?: boolean;
84
- }
85
-
86
- /**
87
- * Raw markdown editor using Monaco Editor.
88
- * Binds to the shared EditorContext for source synchronization.
89
- */
90
- export function RawEditor({
91
- monacoTheme = 'vs',
92
- minimap = false,
93
- fontSize = 14,
94
- wordWrap = 'on',
95
- className,
96
- submitOnEnter,
97
- readOnly = false,
98
- }: RawEditorProps) {
99
- const { editorSource, setEditorSource, setMonacoEditor, language, mentionProvider, doc } =
100
- useEditorContext();
101
- const { monaco: monacoNs, ready: monacoReady } = useMonacoLoader();
102
- const editorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);
103
- const isExternalUpdate = useRef(false);
104
- const completionDisposable = useRef<monaco.IDisposable | null>(null);
105
- const mentionCompletionDisposable = useRef<monaco.IDisposable | null>(null);
106
- const iconCompletionDisposable = useRef<monaco.IDisposable | null>(null);
107
- const attrCompletionDisposable = useRef<monaco.IDisposable | null>(null);
108
- const iconGlyphDecorations = useRef<monaco.editor.IEditorDecorationsCollection | null>(null);
109
- const dropCleanupRef = useRef<(() => void) | null>(null);
110
- const keyDisposable = useRef<monaco.IDisposable | null>(null);
111
- // Ref so the keydown handler always sees the latest callback.
112
- const submitOnEnterRef = useRef(submitOnEnter);
113
- const readOnlyRef = useRef(readOnly);
114
- useEffect(() => {
115
- submitOnEnterRef.current = submitOnEnter;
116
- }, [submitOnEnter]);
117
- useEffect(() => {
118
- readOnlyRef.current = readOnly;
119
- }, [readOnly]);
120
- // Ref so the completion provider — registered once at mount — always
121
- // sees the latest mentionProvider without needing to unregister.
122
- const mentionProviderRef = useRef(mentionProvider);
123
- useEffect(() => {
124
- mentionProviderRef.current = mentionProvider;
125
- }, [mentionProvider]);
126
-
127
- // Template completion list: built-in registry names plus any custom
128
- // templates inlined in the active doc's frontmatter (`doc.customTemplates`
129
- // — the same set that actually renders via `{[name]}`). Held in a ref
130
- // (like mentionProvider above) so the once-registered provider always
131
- // reads the latest set — custom templates created after mount must show
132
- // up without re-mounting Monaco.
133
- const docCustomTemplates = doc?.customTemplates;
134
- const templateEntriesRef = useRef<{ name: string; detail: string }[] | null>(null);
135
- if (templateEntriesRef.current === null) {
136
- templateEntriesRef.current = getAvailableTemplates().map((name) => ({
137
- name,
138
- detail: 'Block template',
139
- }));
140
- }
141
- useEffect(() => {
142
- const builtIns = getAvailableTemplates().map((name) => ({
143
- name,
144
- detail: 'Block template',
145
- }));
146
- const seen = new Set(builtIns.map((b) => b.name));
147
- const custom = (docCustomTemplates ?? [])
148
- .filter((t) => !seen.has(t.name))
149
- .map((t) => ({
150
- name: t.name,
151
- detail: t.label ? `Custom — ${t.label}` : 'Custom template',
152
- }));
153
- templateEntriesRef.current = [...builtIns, ...custom];
154
- }, [docCustomTemplates]);
155
-
156
- const handleBeforeMount: BeforeMount = useCallback((monaco) => {
157
- monaco.editor.defineTheme('squisq-light', {
158
- base: 'vs',
159
- inherit: true,
160
- rules: [],
161
- colors: {
162
- 'editorGutter.background': SQUISQ_LIGHT_GUTTER,
163
- 'editorOverviewRuler.background': SQUISQ_LIGHT_GUTTER,
164
- 'editorOverviewRuler.border': SQUISQ_LIGHT_SEAM,
165
- 'minimap.background': SQUISQ_LIGHT_GUTTER,
166
- },
167
- });
168
- monaco.editor.defineTheme('squisq-dark', {
169
- base: 'vs-dark',
170
- inherit: true,
171
- rules: [],
172
- colors: {
173
- 'editorGutter.background': SQUISQ_DARK_GUTTER,
174
- 'editorOverviewRuler.background': SQUISQ_DARK_GUTTER,
175
- 'editorOverviewRuler.border': SQUISQ_DARK_SEAM,
176
- 'minimap.background': SQUISQ_DARK_GUTTER,
177
- },
178
- });
179
- }, []);
180
-
181
- const handleMount: OnMount = useCallback(
182
- (editor, monaco) => {
183
- editorRef.current = editor;
184
- setMonacoEditor(editor);
185
- editor.focus();
186
-
187
- // Dispose any previous completion provider (from a prior mount)
188
- completionDisposable.current?.dispose();
189
- completionDisposable.current = null;
190
- mentionCompletionDisposable.current?.dispose();
191
- mentionCompletionDisposable.current = null;
192
- iconCompletionDisposable.current?.dispose();
193
- iconCompletionDisposable.current = null;
194
- attrCompletionDisposable.current?.dispose();
195
- attrCompletionDisposable.current = null;
196
-
197
- // Register the `{[template]}` completion provider only for markdown
198
- // files — it's meaningless for TypeScript, JSON, Python, etc.
199
- if (language === 'markdown') {
200
- completionDisposable.current = monaco.languages.registerCompletionItemProvider('markdown', {
201
- triggerCharacters: ['['],
202
- provideCompletionItems(model: monaco.editor.ITextModel, position: monaco.Position) {
203
- if (!ownsMonacoModel(editor, model)) return { suggestions: [] };
204
- if (isMarkdownFencedCodeLine(model.getValue(), position.lineNumber)) {
205
- return { suggestions: [] };
206
- }
207
- const lineContent = model.getLineContent(position.lineNumber);
208
-
209
- // Only trigger inside a heading line that has {[ before the cursor
210
- if (!/^#{1,6}\s/.test(lineContent)) return { suggestions: [] };
211
-
212
- const textBeforeCursor = lineContent.substring(0, position.column - 1);
213
- const textAfterCursor = lineContent.substring(position.column - 1);
214
- const bracketIdx = textBeforeCursor.lastIndexOf('{[');
215
- if (bracketIdx === -1) return { suggestions: [] };
216
-
217
- // Template names are the FIRST token after `{[`. Once a space
218
- // follows the name we're in the `key=value` attribute region —
219
- // the attribute provider handles that, so bail here to avoid
220
- // offering template names mid-attribute.
221
- if (/\s/.test(textBeforeCursor.slice(bracketIdx + 2))) return { suggestions: [] };
222
-
223
- // When Monaco's bracket auto-pair has already produced the
224
- // closing `]}` we just leave it in place and skip the
225
- // suffix — otherwise accepting `sectionHeader` on
226
- // `{[gi]}` would yield `{[sectionHeader]}]}`.
227
- const closingMatch = textAfterCursor.match(/^\]\}/);
228
- const suffix = closingMatch ? '' : ']}';
229
-
230
- const startCol = bracketIdx + 3; // after {[
231
- const range = new monaco.Range(
232
- position.lineNumber,
233
- startCol,
234
- position.lineNumber,
235
- position.column,
236
- );
237
-
238
- const suggestions = (templateEntriesRef.current ?? []).map(({ name, detail }) => ({
239
- label: name,
240
- filterText: name,
241
- kind: monaco.languages.CompletionItemKind.Value,
242
- insertText: name + suffix,
243
- range,
244
- detail,
245
- sortText: name,
246
- }));
247
-
248
- return { suggestions };
249
- },
250
- });
251
-
252
- // `@mention` completion — queries the shared MentionProvider. Keep
253
- // this in its own registration so we can dispose it independently
254
- // of the template provider, and so the trigger character is just
255
- // `@` (not `[`).
256
- mentionCompletionDisposable.current = monaco.languages.registerCompletionItemProvider(
257
- 'markdown',
258
- {
259
- triggerCharacters: ['@'],
260
- async provideCompletionItems(model, position) {
261
- if (!ownsMonacoModel(editor, model)) return { suggestions: [] };
262
- const provider = mentionProviderRef.current;
263
- if (!provider) return { suggestions: [] };
264
- const lineContent = model.getLineContent(position.lineNumber);
265
- const textBeforeCursor = lineContent.substring(0, position.column - 1);
266
- const atIdx = textBeforeCursor.lastIndexOf('@');
267
- if (atIdx === -1) return { suggestions: [] };
268
- // `@` must be at line start or preceded by whitespace/punct —
269
- // skip e.g. email addresses like `foo@bar`.
270
- if (atIdx > 0) {
271
- const prevChar = textBeforeCursor[atIdx - 1];
272
- if (!/[\s\p{P}]/u.test(prevChar)) return { suggestions: [] };
273
- }
274
- const query = textBeforeCursor.slice(atIdx + 1);
275
- // Only fire for short queries — once the user has typed
276
- // a full word, the popover gets noisy.
277
- if (query.length > 40) return { suggestions: [] };
278
- if (/\s/.test(query)) return { suggestions: [] };
279
-
280
- let candidates;
281
- try {
282
- candidates = await provider(query);
283
- } catch {
284
- return { suggestions: [] };
285
- }
286
-
287
- const range = new monaco.Range(
288
- position.lineNumber,
289
- atIdx + 1,
290
- position.lineNumber,
291
- position.column,
292
- );
293
-
294
- return {
295
- suggestions: candidates.map((c) => ({
296
- label: `@${c.label}`,
297
- kind: monaco.languages.CompletionItemKind.User,
298
- insertText: `@[${c.label}](${c.scheme}:${c.id}) `,
299
- range,
300
- ...(c.description ? { detail: c.description } : {}),
301
- sortText: c.label,
302
- })),
303
- };
304
- },
305
- },
306
- );
307
-
308
- // FontAwesome icon completion. Fires inside any `{[…]}` opener
309
- // anywhere in the doc (not just headings — icons are inline).
310
- // Suggestions cover the whole FA Free catalog filtered by the
311
- // partial token; we cap at 50 to keep the popup readable. The
312
- // template provider above still handles heading lines, so on
313
- // a `## Title {[…]}` the user sees both template names AND
314
- // icons interleaved by the regular Monaco filter.
315
- iconCompletionDisposable.current = monaco.languages.registerCompletionItemProvider(
316
- 'markdown',
317
- {
318
- triggerCharacters: ['['],
319
- provideCompletionItems(model, position) {
320
- if (!ownsMonacoModel(editor, model)) return { suggestions: [] };
321
- if (isMarkdownFencedCodeLine(model.getValue(), position.lineNumber)) {
322
- return { suggestions: [] };
323
- }
324
- const lineContent = model.getLineContent(position.lineNumber);
325
- const textBeforeCursor = lineContent.substring(0, position.column - 1);
326
- const textAfterCursor = lineContent.substring(position.column - 1);
327
- const bracketIdx = textBeforeCursor.lastIndexOf('{[');
328
- if (bracketIdx === -1) return { suggestions: [] };
329
- // Bail if any `]` already closes this annotation between
330
- // `{[` and the cursor — we'd be past the token, not in it.
331
- const between = textBeforeCursor.slice(bracketIdx + 2);
332
- if (between.includes(']')) return { suggestions: [] };
333
- // Tokens are alphanumeric + `-_:`; anything else means
334
- // we're not inside an icon (probably a code/link bracket).
335
- if (between && !/^[a-zA-Z0-9_:-]*$/.test(between)) {
336
- return { suggestions: [] };
337
- }
338
- const query = between.toLowerCase();
339
-
340
- // When Monaco's bracket auto-pair has already produced a
341
- // closing `]}` we don't want to insert another — but we
342
- // also don't want to consume the existing one, since
343
- // then we'd have to re-emit it and the round-trip is
344
- // brittle. Leave the closing in place and just insert
345
- // the bare token; if no closing exists yet, append it.
346
- const closingMatch = textAfterCursor.match(/^\]\}/);
347
- const suffix = closingMatch ? '' : ']}';
348
-
349
- const range = new monaco.Range(
350
- position.lineNumber,
351
- bracketIdx + 3, // after `{[`
352
- position.lineNumber,
353
- position.column,
354
- );
355
-
356
- const top = suggestIcons(query, 50);
357
- return {
358
- suggestions: top.map((m, i) => ({
359
- // Embed the FA codepoint as the first character of
360
- // the label. CSS targets the suggest widget with
361
- // FontAwesome as a font fallback, so the codepoint
362
- // renders as the glyph and the name renders in the
363
- // editor's normal font.
364
- label: {
365
- label: `${iconGlyph(m.entry)} ${m.token}`,
366
- description: `fa-${m.entry.family}`,
367
- },
368
- // `filterText` excludes the glyph + spacing so Monaco
369
- // filters against the actual icon name only.
370
- filterText: m.token,
371
- kind: monaco.languages.CompletionItemKind.Constant,
372
- insertText: `${m.token}${suffix}`,
373
- range,
374
- detail: m.entry.label,
375
- // Documentation pane (rendered when Monaco's
376
- // suggestion preview is expanded) shows a large
377
- // version of the glyph alongside the canonical token.
378
- documentation: {
379
- value: `<i class="fa-${m.entry.family} fa-${m.entry.name}" style="font-size: 2em; display: inline-block; margin-right: 8px; vertical-align: middle"></i> **${m.token}** *(${m.entry.label})*`,
380
- isTrusted: true,
381
- supportHtml: true,
382
- },
383
- // Sort key: 1-digit score prefix keeps "starts with"
384
- // matches above "contains" / keyword matches.
385
- sortText: `${m.score}${String(i).padStart(4, '0')}`,
386
- })),
387
- };
388
- },
389
- },
390
- );
391
-
392
- // `{[name key=value]}` block-meta attribute completion. Fires on
393
- // heading lines once the cursor is past the template name (the
394
- // first token), where attributes like `transition=` apply to the
395
- // block. Two modes:
396
- // - bare token → suggest attribute KEYS (insert `key=`)
397
- // - after `key=` → suggest that key's VALUES, when it has a
398
- // closed set (e.g. transition / transitionDirection)
399
- // The descriptor list comes from core so keys and value enums stay
400
- // in lockstep with what `coerceAnnotationValues` actually accepts.
401
- attrCompletionDisposable.current = monaco.languages.registerCompletionItemProvider(
402
- 'markdown',
403
- {
404
- triggerCharacters: ['=', ' '],
405
- provideCompletionItems(model, position) {
406
- if (!ownsMonacoModel(editor, model)) return { suggestions: [] };
407
- if (isMarkdownFencedCodeLine(model.getValue(), position.lineNumber)) {
408
- return { suggestions: [] };
409
- }
410
- const lineContent = model.getLineContent(position.lineNumber);
411
- // Block-meta attributes only mean something on a heading's
412
- // template annotation — same gate as the template provider.
413
- if (!/^#{1,6}\s/.test(lineContent)) return { suggestions: [] };
414
-
415
- const textBeforeCursor = lineContent.substring(0, position.column - 1);
416
- const bracketIdx = textBeforeCursor.lastIndexOf('{[');
417
- if (bracketIdx === -1) return { suggestions: [] };
418
-
419
- // Bail if a `]` already closed the annotation before the
420
- // cursor — we'd be past it, not inside the attribute list.
421
- const innerBefore = textBeforeCursor.slice(bracketIdx + 2);
422
- if (innerBefore.includes(']')) return { suggestions: [] };
423
- // The first token is the template name; attributes only begin
424
- // after a whitespace separator. No space yet → still the name.
425
- if (!/\s/.test(innerBefore)) return { suggestions: [] };
426
-
427
- // Current token = run of non-whitespace ending at the cursor.
428
- const lastWsMatch = innerBefore.match(/\s(\S*)$/);
429
- const currentToken = lastWsMatch ? lastWsMatch[1] : '';
430
- const tokenStartCol = position.column - currentToken.length;
431
-
432
- const eqIdx = currentToken.indexOf('=');
433
- if (eqIdx >= 0) {
434
- // ── Value mode: `key=<partial>` ──
435
- const key = currentToken.slice(0, eqIdx);
436
- const descriptor = BLOCK_META_KEY_DESCRIPTORS.find((d) => d.key === key);
437
- if (!descriptor?.values) return { suggestions: [] };
438
- const range = new monaco.Range(
439
- position.lineNumber,
440
- tokenStartCol + eqIdx + 1, // after `=`
441
- position.lineNumber,
442
- position.column,
443
- );
444
- return {
445
- suggestions: descriptor.values.map((value, i) => ({
446
- label: value,
447
- filterText: value,
448
- kind: monaco.languages.CompletionItemKind.EnumMember,
449
- insertText: value,
450
- range,
451
- detail: descriptor.description,
452
- sortText: String(i).padStart(4, '0'),
453
- })),
454
- };
455
- }
456
-
457
- // ── Key mode: suggest attribute names not already present ──
458
- // Collect keys already set anywhere in the annotation so we
459
- // don't re-offer them; keep the key under the cursor eligible
460
- // so re-editing an existing `key=` still suggests it.
461
- const afterBracket = lineContent.slice(bracketIdx + 2);
462
- const closeIdx = afterBracket.indexOf(']}');
463
- const fullInner = closeIdx === -1 ? afterBracket : afterBracket.slice(0, closeIdx);
464
- const present = new Set(
465
- tokenizeAttrTokens(fullInner)
466
- .map((t) => {
467
- const i = t.indexOf('=');
468
- return i > 0 ? t.slice(0, i) : null;
469
- })
470
- .filter((k): k is string => k != null),
471
- );
472
- present.delete(currentToken);
473
-
474
- const range = new monaco.Range(
475
- position.lineNumber,
476
- tokenStartCol,
477
- position.lineNumber,
478
- position.column,
479
- );
480
- const suggestions = BLOCK_META_KEY_DESCRIPTORS.filter((d) => !present.has(d.key)).map(
481
- (d, i) => ({
482
- label: d.key,
483
- filterText: d.key,
484
- kind: monaco.languages.CompletionItemKind.Property,
485
- insertText: `${d.key}=`,
486
- range,
487
- detail: d.values ? d.description : `${d.description} — ${d.valueHint}`,
488
- sortText: String(i).padStart(4, '0'),
489
- // Closed-set keys chain straight into their value list.
490
- ...(d.values
491
- ? { command: { id: 'editor.action.triggerSuggest', title: '' } }
492
- : {}),
493
- }),
494
- );
495
- return { suggestions };
496
- },
497
- },
498
- );
499
- }
500
-
501
- // Chat-composer mode: intercept Enter before Monaco inserts a newline.
502
- // Cmd/Ctrl+Enter falls through so the native newline still works.
503
- keyDisposable.current?.dispose();
504
- keyDisposable.current = editor.onKeyDown((e) => {
505
- if (e.keyCode !== monaco.KeyCode.Enter) return;
506
- if (!submitOnEnterRef.current) return;
507
- if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
508
- e.preventDefault();
509
- e.stopPropagation();
510
- submitOnEnterRef.current();
511
- });
512
-
513
- // Attach native drop listeners for in-app MediaBin drags. Monaco's own
514
- // drop handling doesn't know about our custom MIME type, so we insert
515
- // markdown image syntax explicitly in the capture phase.
516
- dropCleanupRef.current?.();
517
- const domNode = editor.getDomNode();
518
- if (domNode) {
519
- const onDragOver = (e: DragEvent) => {
520
- const dt = e.dataTransfer;
521
- if (canHandleSquisqMediaDrop(readOnlyRef.current, dt)) {
522
- e.preventDefault();
523
- dt!.dropEffect = 'copy';
524
- }
525
- };
526
- const onDrop = (e: DragEvent) => {
527
- if (!canHandleSquisqMediaDrop(readOnlyRef.current, e.dataTransfer)) return;
528
- const dt = e.dataTransfer;
529
- if (!dt) return;
530
- const raw = dt.getData(SQUISQ_MEDIA_MIME);
531
- if (!raw) return;
532
- const payload = parseSquisqMediaPayload(raw);
533
- if (!payload || !payload.mimeType.startsWith('image/')) return;
534
-
535
- e.preventDefault();
536
- e.stopPropagation();
537
-
538
- const target = editor.getTargetAtClientPoint(e.clientX, e.clientY);
539
- const position = target?.position ?? editor.getPosition();
540
- if (!position) return;
541
-
542
- const markdown = `![${payload.alt}](${payload.name})`;
543
- editor.executeEdits('squisq-media-drop', [
544
- {
545
- range: new monaco.Range(
546
- position.lineNumber,
547
- position.column,
548
- position.lineNumber,
549
- position.column,
550
- ),
551
- text: markdown,
552
- forceMoveMarkers: true,
553
- },
554
- ]);
555
- editor.focus();
556
- };
557
- domNode.addEventListener('dragover', onDragOver, true);
558
- domNode.addEventListener('drop', onDrop, true);
559
- dropCleanupRef.current = () => {
560
- domNode.removeEventListener('dragover', onDragOver, true);
561
- domNode.removeEventListener('drop', onDrop, true);
562
- };
563
- }
564
- },
565
- [setMonacoEditor, language],
566
- );
567
-
568
- // Unregister on unmount
569
- useEffect(() => {
570
- return () => {
571
- setMonacoEditor(null);
572
- completionDisposable.current?.dispose();
573
- completionDisposable.current = null;
574
- mentionCompletionDisposable.current?.dispose();
575
- mentionCompletionDisposable.current = null;
576
- iconCompletionDisposable.current?.dispose();
577
- iconCompletionDisposable.current = null;
578
- attrCompletionDisposable.current?.dispose();
579
- attrCompletionDisposable.current = null;
580
- iconGlyphDecorations.current?.clear();
581
- iconGlyphDecorations.current = null;
582
- dropCleanupRef.current?.();
583
- dropCleanupRef.current = null;
584
- keyDisposable.current?.dispose();
585
- keyDisposable.current = null;
586
- };
587
- }, [setMonacoEditor]);
588
-
589
- const handleChange: OnChange = useCallback(
590
- (value) => {
591
- if (isExternalUpdate.current) return;
592
- if (value !== undefined) {
593
- setEditorSource(value);
594
- }
595
- },
596
- [setEditorSource],
597
- );
598
-
599
- // When external changes happen (e.g. from WYSIWYG, or navigating to another
600
- // block in block-at-a-time mode), update Monaco. In block mode `editorSource`
601
- // is the active block's slice, so this swaps Monaco's content on navigation.
602
- useEffect(() => {
603
- const editor = editorRef.current;
604
- if (editor) {
605
- const currentValue = editor.getValue();
606
- // Ignore trailing-whitespace-only differences from block-mode splice
607
- // normalization — calling setValue for those resets the Monaco cursor.
608
- if (
609
- currentValue !== editorSource &&
610
- currentValue.replace(/\s+$/, '') !== editorSource.replace(/\s+$/, '')
611
- ) {
612
- isExternalUpdate.current = true;
613
- editor.setValue(editorSource);
614
- isExternalUpdate.current = false;
615
- }
616
- }
617
- }, [editorSource]);
618
-
619
- // ── Inline FontAwesome glyph decorations ────────────
620
- // Walk the markdown source on every change, find each resolvable
621
- // `{[icon-name]}` span, and overlay the actual glyph (via Monaco's
622
- // `before:` content decoration) just before the brackets. The CSS
623
- // classes `.fa-glyph-decoration-<family>` set the per-family font
624
- // and weight; the codepoint character is the decoration's content.
625
- useEffect(() => {
626
- const editor = editorRef.current;
627
- // `monacoNs` is read from the lazy loader's state rather than a
628
- // top-level import. Re-run when it transitions from null → loaded
629
- // so decorations show up the moment monaco is in hand.
630
- if (!editor || !monacoNs) return;
631
- if (language !== 'markdown') return;
632
- const model = editor.getModel();
633
- if (!model) return;
634
-
635
- const decorations: monaco.editor.IModelDeltaDecoration[] = [];
636
- const lines = model.getLineCount();
637
- const fencedLines = markdownFencedCodeLineMask(model.getValue());
638
- const re = /\{\[([a-zA-Z0-9_:-]+)\]\}/g;
639
- for (let line = 1; line <= lines; line++) {
640
- if (fencedLines[line - 1]) continue;
641
- const text = model.getLineContent(line);
642
- re.lastIndex = 0;
643
- let match: RegExpExecArray | null;
644
- while ((match = re.exec(text)) !== null) {
645
- const icon = resolveIcon(match[1]);
646
- if (!icon) continue;
647
- const glyph = iconGlyph(icon);
648
- if (!glyph) continue;
649
- // Position the decoration as a zero-width range at the `{`
650
- // of the matched token. `before.contentText` renders the
651
- // glyph as content prepended visually to that position.
652
- const col = match.index + 1; // Monaco columns are 1-based
653
- decorations.push({
654
- range: new monacoNs.Range(line, col, line, col),
655
- options: {
656
- before: {
657
- content: glyph,
658
- inlineClassName: `fa-glyph-decoration-${icon.family}`,
659
- },
660
- },
661
- });
662
- }
663
- }
664
-
665
- if (!iconGlyphDecorations.current) {
666
- iconGlyphDecorations.current = editor.createDecorationsCollection(decorations);
667
- } else {
668
- iconGlyphDecorations.current.set(decorations);
669
- }
670
- }, [editorSource, language, monacoNs]);
671
-
672
- const effectiveTheme = SQUISQ_THEMES[monacoTheme] ?? monacoTheme;
673
-
674
- // Wait for the lazy monaco namespace + `loader.config()` to settle
675
- // before mounting `<Editor>`. Without this gate, the @monaco-editor/
676
- // react singleton loader would fall back to its built-in CDN fetch
677
- // for any consumer that hasn't aliased monaco-editor — which is the
678
- // exact regression the lazy-loading move is meant to avoid.
679
- if (!monacoReady) {
680
- return (
681
- <div
682
- className={className}
683
- style={{
684
- width: '100%',
685
- height: '100%',
686
- display: 'flex',
687
- alignItems: 'center',
688
- justifyContent: 'center',
689
- color: 'var(--squisq-editor-muted-foreground, #6a6258)',
690
- fontSize: 13,
691
- }}
692
- data-testid="raw-editor"
693
- data-monaco-loading
694
- >
695
- Loading editor…
696
- </div>
697
- );
698
- }
699
-
700
- return (
701
- <div className={className} style={{ width: '100%', height: '100%' }} data-testid="raw-editor">
702
- <Editor
703
- defaultLanguage={language}
704
- value={editorSource}
705
- theme={effectiveTheme}
706
- beforeMount={handleBeforeMount}
707
- onMount={handleMount}
708
- onChange={handleChange}
709
- options={{
710
- fontSize,
711
- wordWrap,
712
- minimap: { enabled: minimap },
713
- lineNumbers: 'on',
714
- scrollBeyondLastLine: false,
715
- automaticLayout: true,
716
- tabSize: 2,
717
- renderWhitespace: 'selection',
718
- bracketPairColorization: { enabled: true },
719
- guides: { indentation: true },
720
- padding: { top: 12, bottom: 12 },
721
- // Markdown's tokenizer classifies most body text as "string"
722
- // or "comment" context, which suppresses `quickSuggestions`
723
- // by default. Enable in all three so our `{[icon]}` and
724
- // `@mention` typeaheads keep firing as the user types past
725
- // the trigger character.
726
- quickSuggestions: { other: true, comments: true, strings: true },
727
- suggestOnTriggerCharacters: true,
728
- // Breathing room between the gutter and the first character.
729
- // Done via Monaco's own option so cursor + hit-testing stay in
730
- // sync — CSS-padding `.view-lines` shifts the text but not the
731
- // cursors layer, which causes the cursor to drift left of the
732
- // model column. Monaco's default is 10. We set 22 (12 extra),
733
- // and CSS paints the rightmost 12px of the gutter as canvas
734
- // color so the breathing room looks like it sits *inside* the
735
- // canvas rather than widening the gutter.
736
- lineDecorationsWidth: 22,
737
- readOnly,
738
- domReadOnly: readOnly,
739
- }}
740
- />
741
- </div>
742
- );
743
- }