@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.
- package/LICENSE +21 -0
- package/NOTICE.md +40 -0
- package/dist/chunk-54UGTQBO.js +862 -0
- package/dist/chunk-5JMHFAVW.js +2408 -0
- package/dist/chunk-5Q4JN4I5.js +132 -0
- package/dist/chunk-6VDYKI3L.js +49 -0
- package/dist/chunk-GS7QWYFT.js +9 -0
- package/dist/chunk-MJJK7YQB.js +949 -0
- package/dist/chunk-NITZVAXL.js +986 -0
- package/dist/chunk-TRCKHRBS.js +35234 -0
- package/dist/chunk-V44VP242.js +3256 -0
- package/dist/image-editor/index.d.ts +223 -0
- package/dist/image-editor/index.js +15 -0
- package/dist/index.d.ts +2060 -4040
- package/dist/index.js +496 -40014
- package/dist/json-editor/index.d.ts +27 -0
- package/dist/json-editor/index.js +7 -0
- package/dist/monaco.d.ts +1 -1
- package/dist/monaco.js +1 -2
- package/dist/recorder/index.d.ts +407 -0
- package/dist/recorder/index.js +43 -0
- package/dist/shell/index.d.ts +9 -0
- package/dist/shell/index.js +22 -0
- package/dist/shell-BxSCBm4H.d.ts +1064 -0
- package/dist/styles/index.css +598 -161
- package/dist/teleprompter/index.d.ts +497 -0
- package/dist/teleprompter/index.js +57 -0
- package/package.json +34 -8
- package/dist/index.js.map +0 -1
- package/dist/monaco.js.map +0 -1
- package/src/BlockCardView.tsx +0 -121
- package/src/BlockPreviewPanel.tsx +0 -69
- package/src/BlockPropertiesPopover.tsx +0 -222
- package/src/DocumentSettingsDialog.tsx +0 -272
- package/src/DropZoneOverlay.tsx +0 -137
- package/src/EditorContext.tsx +0 -1274
- package/src/EditorShell.tsx +0 -1358
- package/src/EmojiPicker.tsx +0 -332
- package/src/FolderView.tsx +0 -131
- package/src/Icon.tsx +0 -26
- package/src/ImageEditor.tsx +0 -395
- package/src/ImageNodeView.tsx +0 -284
- package/src/ImageViewer.tsx +0 -221
- package/src/InlineIcon.ts +0 -84
- package/src/InlinePreviewGutter.tsx +0 -590
- package/src/LinkDialog.tsx +0 -276
- package/src/MediaBin.tsx +0 -500
- package/src/MentionExtension.tsx +0 -261
- package/src/OutlinePanel.tsx +0 -547
- package/src/PlainHtmlPreview.tsx +0 -277
- package/src/PreviewControls.tsx +0 -1265
- package/src/PreviewPanel.tsx +0 -426
- package/src/RawEditor.tsx +0 -743
- package/src/RecorderEntry.tsx +0 -162
- package/src/StatusBar.tsx +0 -51
- package/src/TemplateAnnotation.ts +0 -167
- package/src/TemplateContentPreview.tsx +0 -56
- package/src/TemplatePicker.tsx +0 -1314
- package/src/ThemeCustomizerPanel.tsx +0 -304
- package/src/ThemePicker.tsx +0 -433
- package/src/TimelineBlockPreview.tsx +0 -37
- package/src/TimelineTrack.tsx +0 -671
- package/src/Toolbar.tsx +0 -2885
- package/src/Tooltip.tsx +0 -142
- package/src/TransitionPicker.tsx +0 -390
- package/src/VersionHistoryPanel.tsx +0 -359
- package/src/ViewMenuPanel.tsx +0 -189
- package/src/ViewSwitcher.tsx +0 -56
- package/src/WysiwygEditor.tsx +0 -806
- package/src/__tests__/blockProperties.test.ts +0 -92
- package/src/__tests__/blockPropertiesPopoverTheme.test.tsx +0 -33
- package/src/__tests__/blockRange.test.ts +0 -105
- package/src/__tests__/blockTagActivity.test.ts +0 -183
- package/src/__tests__/buildDocumentPreviewMarkdown.test.ts +0 -75
- package/src/__tests__/buildPreviewDocContent.test.ts +0 -65
- package/src/__tests__/buildPreviewDocTransition.test.ts +0 -92
- package/src/__tests__/canvasSurfaceTextEditing.test.tsx +0 -60
- package/src/__tests__/codeContextSectionView.test.tsx +0 -97
- package/src/__tests__/codeContextZoneManager.test.ts +0 -127
- package/src/__tests__/createShapeLayer.test.ts +0 -46
- package/src/__tests__/customLayoutManagerTheme.test.tsx +0 -34
- package/src/__tests__/detectMarkdown.test.ts +0 -73
- package/src/__tests__/diffContextSections.test.ts +0 -39
- package/src/__tests__/documentSettingsDialog.test.tsx +0 -197
- package/src/__tests__/drawingShapeRoundTrip.test.ts +0 -49
- package/src/__tests__/editorScrollHandoff.test.tsx +0 -102
- package/src/__tests__/editorScrollSync.test.ts +0 -65
- package/src/__tests__/editorShellCodeContext.test.tsx +0 -86
- package/src/__tests__/editorShellProps.test.tsx +0 -550
- package/src/__tests__/embeddedMedia.test.ts +0 -48
- package/src/__tests__/emojiPicker.test.tsx +0 -93
- package/src/__tests__/fileKind.test.ts +0 -112
- package/src/__tests__/findMode.test.tsx +0 -104
- package/src/__tests__/findModel.test.ts +0 -55
- package/src/__tests__/headingTransition.test.ts +0 -176
- package/src/__tests__/imageEditAffordance.test.tsx +0 -272
- package/src/__tests__/imageEditModalContract.test.tsx +0 -119
- package/src/__tests__/imageEditorShell.test.tsx +0 -94
- package/src/__tests__/imageEditorState.test.ts +0 -171
- package/src/__tests__/inlinePreviewGutter.test.tsx +0 -62
- package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +0 -103
- package/src/__tests__/jsonEditor.test.tsx +0 -223
- package/src/__tests__/layersPanel.test.tsx +0 -167
- package/src/__tests__/layoutChildRoundTrip.test.ts +0 -71
- package/src/__tests__/linkDialogDocPicker.test.tsx +0 -137
- package/src/__tests__/majorApiTypes.test.ts +0 -26
- package/src/__tests__/markdownCodeFence.test.ts +0 -45
- package/src/__tests__/mediaAttachmentFlow.test.ts +0 -110
- package/src/__tests__/mediaBinDrop.test.tsx +0 -90
- package/src/__tests__/mediaReferences.test.ts +0 -97
- package/src/__tests__/narrationSave.test.ts +0 -148
- package/src/__tests__/outlinePanel.test.tsx +0 -169
- package/src/__tests__/outlineSource.test.ts +0 -217
- package/src/__tests__/plainHtmlPreview.test.tsx +0 -125
- package/src/__tests__/presentationMode.test.tsx +0 -290
- package/src/__tests__/previewControls.test.tsx +0 -571
- package/src/__tests__/previewPanelAudioFailure.test.tsx +0 -46
- package/src/__tests__/previewPanelPresentation.test.tsx +0 -126
- package/src/__tests__/previewPanelTransforms.test.tsx +0 -117
- package/src/__tests__/propertiesPanel.test.tsx +0 -69
- package/src/__tests__/rawEditorModelIsolation.test.ts +0 -19
- package/src/__tests__/recorderFormats.test.ts +0 -146
- package/src/__tests__/recorderMediaInsert.test.ts +0 -86
- package/src/__tests__/recorderTheme.test.tsx +0 -42
- package/src/__tests__/recorderTimingJson.test.ts +0 -41
- package/src/__tests__/resolveBlockVisual.test.ts +0 -43
- package/src/__tests__/selectionConversions.test.ts +0 -80
- package/src/__tests__/statusBar.test.tsx +0 -27
- package/src/__tests__/teleprompter.test.tsx +0 -190
- package/src/__tests__/templateAnnotationRoundTrip.test.ts +0 -99
- package/src/__tests__/templateContentPreview.test.ts +0 -101
- package/src/__tests__/templatePickerMetadata.test.ts +0 -32
- package/src/__tests__/templatePickerPortal.test.tsx +0 -62
- package/src/__tests__/timelineSource.test.ts +0 -134
- package/src/__tests__/tiptapBridge.test.ts +0 -575
- package/src/__tests__/tiptapBridgeConformance.test.ts +0 -47
- package/src/__tests__/tiptapCodeBlockRoundTrip.test.ts +0 -109
- package/src/__tests__/tiptapImageRoundTrip.test.ts +0 -73
- package/src/__tests__/toolbarSelectionConversion.test.tsx +0 -190
- package/src/__tests__/tooltip.test.tsx +0 -72
- package/src/__tests__/transformStyleId.test.ts +0 -13
- package/src/__tests__/transitionCatalog.test.ts +0 -64
- package/src/__tests__/useBlockNavigator.test.tsx +0 -67
- package/src/__tests__/useImageEditor.test.tsx +0 -226
- package/src/__tests__/useJsonEditorTokens.test.ts +0 -59
- package/src/__tests__/useMediaRecorder.test.ts +0 -302
- package/src/__tests__/useTimelineClock.test.ts +0 -21
- package/src/__tests__/versionHistory.test.tsx +0 -197
- package/src/__tests__/viewMenuPanel.test.tsx +0 -130
- package/src/__tests__/writeCanvasSettings.test.ts +0 -15
- package/src/__tests__/wysiwygImageUpload.test.ts +0 -69
- package/src/__tests__/wysiwygTemplateBadgeFocus.test.tsx +0 -56
- package/src/asciiDiagram/AsciiDiagramExtension.ts +0 -343
- package/src/asciiDiagram/AsciiDiagramWidget.tsx +0 -254
- package/src/asciiDiagram/RepairableDiagramExtension.ts +0 -200
- package/src/asciiDiagram/__tests__/AsciiDiagramExtension.test.ts +0 -164
- package/src/asciiDiagram/__tests__/RepairableDiagramExtension.test.ts +0 -159
- package/src/asciiDiagram/__tests__/asciiDiagramCommands.test.ts +0 -284
- package/src/asciiDiagram/__tests__/asciiDiagramOps.test.ts +0 -114
- package/src/asciiDiagram/__tests__/asciiPaste.test.ts +0 -43
- package/src/asciiDiagram/asciiDiagramCommands.ts +0 -174
- package/src/asciiDiagram/asciiDiagramData.ts +0 -149
- package/src/asciiDiagram/asciiDiagramOps.ts +0 -238
- package/src/asciiDiagram/asciiPaste.ts +0 -19
- package/src/blockProperties.ts +0 -88
- package/src/blockRange.ts +0 -132
- package/src/blockSlice.ts +0 -75
- package/src/blockTagActivity.ts +0 -233
- package/src/buildDocumentPreviewMarkdown.ts +0 -168
- package/src/buildPreviewDoc.ts +0 -407
- package/src/codeContext/CodeContextSectionView.tsx +0 -124
- package/src/codeContext/CodeContextZoneManager.ts +0 -149
- package/src/codeContext/CodeContextZones.tsx +0 -121
- package/src/codeContext/diffContextSections.ts +0 -38
- package/src/codeContext/types.ts +0 -75
- package/src/codeSnippet/CodeSnippetExtension.ts +0 -205
- package/src/codeSnippet/CodeSnippetWidget.tsx +0 -109
- package/src/codeSnippet/__tests__/CodeSnippetExtension.test.ts +0 -95
- package/src/codeSnippet/__tests__/codeSnippetLanguages.test.ts +0 -50
- package/src/codeSnippet/codeSnippetCommands.ts +0 -21
- package/src/codeSnippet/codeSnippetData.ts +0 -43
- package/src/codeSnippet/codeSnippetLanguages.ts +0 -216
- package/src/customTemplates/AddBin.tsx +0 -126
- package/src/customTemplates/CustomLayoutManager.tsx +0 -234
- package/src/customTemplates/CustomTemplateContext.tsx +0 -188
- package/src/customTemplates/LayerToolbar.tsx +0 -580
- package/src/customTemplates/ShapeGlyph.tsx +0 -47
- package/src/customTemplates/TemplateDesigner.tsx +0 -433
- package/src/customTemplates/__tests__/library.test.ts +0 -96
- package/src/customTemplates/__tests__/normalizePositions.test.ts +0 -109
- package/src/customTemplates/__tests__/shapeDefs.test.ts +0 -49
- package/src/customTemplates/__tests__/useMemoryLayerAdapter.test.ts +0 -108
- package/src/customTemplates/designer.css +0 -732
- package/src/customTemplates/index.ts +0 -31
- package/src/customTemplates/library.ts +0 -110
- package/src/customTemplates/normalizePositions.ts +0 -75
- package/src/customTemplates/shapeDefs.ts +0 -131
- package/src/customTemplates/thumbnail.tsx +0 -63
- package/src/customTemplates/tokenDefs.ts +0 -60
- package/src/customTemplates/useDocCustomTemplates.ts +0 -52
- package/src/customTemplates/useMemoryLayerAdapter.ts +0 -129
- package/src/customThemes/CustomThemeContext.tsx +0 -185
- package/src/customThemes/CustomThemeDialog.tsx +0 -316
- package/src/customThemes/ImportThemeSection.tsx +0 -178
- package/src/customThemes/__tests__/CustomThemeContext.test.tsx +0 -64
- package/src/customThemes/__tests__/CustomThemeDialog.test.tsx +0 -47
- package/src/customThemes/__tests__/customThemeLibrary.test.ts +0 -60
- package/src/customThemes/__tests__/importThemeSection.test.tsx +0 -192
- package/src/customThemes/customThemeLibrary.ts +0 -100
- package/src/customThemes/index.ts +0 -37
- package/src/customThemes/themeControls.tsx +0 -229
- package/src/customThemes/themeDraft.ts +0 -288
- package/src/customThemes/useDocCustomThemes.ts +0 -49
- package/src/detectMarkdown.ts +0 -62
- package/src/diagram/DiagramCanvas.tsx +0 -260
- package/src/diagram/DiagramMaximizedOverlay.tsx +0 -46
- package/src/diagram/diagramCommands.ts +0 -604
- package/src/diagram/diagramConstants.ts +0 -17
- package/src/diagram/types.ts +0 -35
- package/src/editorScrollSync.ts +0 -73
- package/src/embeddedMedia.ts +0 -78
- package/src/emojiData.ts +0 -1317
- package/src/fileKind.ts +0 -158
- package/src/find/FindHighlightExtension.ts +0 -81
- package/src/find/FindToolbar.tsx +0 -314
- package/src/find/findModel.ts +0 -77
- package/src/frontmatter.ts +0 -29
- package/src/frontmatterSettings.ts +0 -23
- package/src/headingTransition.ts +0 -291
- package/src/hooks/useFileDrop.ts +0 -266
- package/src/imageEditor/CanvasSurface.tsx +0 -703
- package/src/imageEditor/ImageVersionHistoryDropdown.tsx +0 -396
- package/src/imageEditor/LayersPanel.tsx +0 -218
- package/src/imageEditor/PropertiesPanel.tsx +0 -474
- package/src/imageEditor/Toolbar.tsx +0 -459
- package/src/imageEditor/createShapeLayer.ts +0 -280
- package/src/imageEditor/icons.tsx +0 -68
- package/src/imageEditor/image-editor.css +0 -574
- package/src/imageEditor/layers/EditorImageLayer.tsx +0 -45
- package/src/imageEditor/layers/EditorShapeLayer.tsx +0 -62
- package/src/imageEditor/layers/EditorTextLayer.tsx +0 -45
- package/src/imageEditor/layers/SelectionHandles.tsx +0 -86
- package/src/imageEditor/state.ts +0 -173
- package/src/imageEditor/useImageEditor.ts +0 -385
- package/src/imageEditor/useImageEditorTokens.ts +0 -70
- package/src/index.ts +0 -559
- package/src/jsonEditor/EmbeddedRichTextField.tsx +0 -81
- package/src/jsonEditor/JsonEditor.tsx +0 -81
- package/src/jsonEditor/JsonEditorContext.tsx +0 -81
- package/src/jsonEditor/RenderNode.tsx +0 -87
- package/src/jsonEditor/editors.tsx +0 -745
- package/src/jsonEditor/index.ts +0 -2
- package/src/jsonEditor/json-editor.css +0 -463
- package/src/jsonEditor/useJsonEditorTokens.ts +0 -33
- package/src/markdownCodeFence.ts +0 -72
- package/src/mediaDragMime.ts +0 -32
- package/src/mediaEntries.ts +0 -12
- package/src/mediaReferences.ts +0 -301
- package/src/mermaid/MermaidDiagramCanvas.tsx +0 -693
- package/src/mermaid/MermaidDiagramExtension.ts +0 -243
- package/src/mermaid/MermaidDiagramTypeThumbnail.tsx +0 -184
- package/src/mermaid/MermaidDiagramWidget.tsx +0 -653
- package/src/mermaid/MermaidShapePalette.tsx +0 -245
- package/src/mermaid/__tests__/MermaidDiagramExtension.test.ts +0 -361
- package/src/mermaid/__tests__/mermaidDiagramTypes.test.ts +0 -35
- package/src/mermaid/__tests__/mermaidRenderer.test.ts +0 -49
- package/src/mermaid/__tests__/mermaidSourceOps.test.ts +0 -213
- package/src/mermaid/__tests__/mermaidSyntax.test.ts +0 -71
- package/src/mermaid/mermaidCommands.ts +0 -34
- package/src/mermaid/mermaidData.ts +0 -31
- package/src/mermaid/mermaidDiagramTypes.ts +0 -325
- package/src/mermaid/mermaidModel.ts +0 -31
- package/src/mermaid/mermaidRenderer.ts +0 -181
- package/src/mermaid/mermaidShapes.ts +0 -113
- package/src/mermaid/mermaidSourceOps.ts +0 -454
- package/src/monaco.ts +0 -35
- package/src/monacoWorkers.ts +0 -89
- package/src/outlineSource.ts +0 -171
- package/src/presentation/PresentationMode.tsx +0 -596
- package/src/rawEditorIsolation.ts +0 -18
- package/src/recorder/RecorderButton.tsx +0 -80
- package/src/recorder/RecorderModal.tsx +0 -706
- package/src/recorder/RecorderPanel.tsx +0 -77
- package/src/recorder/formats.ts +0 -159
- package/src/recorder/hooks/useMediaRecorder.ts +0 -436
- package/src/recorder/hooks/useStreamPreview.ts +0 -47
- package/src/recorder/insertMediaBlock.ts +0 -30
- package/src/recorder/sources/cameraStream.ts +0 -32
- package/src/recorder/sources/micStream.ts +0 -25
- package/src/recorder/sources/screenStream.ts +0 -162
- package/src/recorder/timingJson.ts +0 -66
- package/src/resolveBlockVisual.ts +0 -39
- package/src/scene/Scene.tsx +0 -647
- package/src/scene/SceneBlockExtension.ts +0 -205
- package/src/scene/SceneBlockToolbar.tsx +0 -216
- package/src/scene/SceneBlockWidget.tsx +0 -441
- package/src/scene/ScenePropsBar.tsx +0 -85
- package/src/scene/SceneSelection.tsx +0 -111
- package/src/scene/SceneSideToolbar.tsx +0 -89
- package/src/scene/SceneViewControls.tsx +0 -43
- package/src/scene/SceneViewport.tsx +0 -106
- package/src/scene/ShapePalette.tsx +0 -196
- package/src/scene/__tests__/DiagramAdapter.test.ts +0 -142
- package/src/scene/__tests__/SceneBlockExtension.test.ts +0 -33
- package/src/scene/__tests__/bezierEdit.test.ts +0 -85
- package/src/scene/__tests__/blockLayers.test.ts +0 -57
- package/src/scene/__tests__/fitScale.test.ts +0 -19
- package/src/scene/__tests__/sceneIsolation.test.tsx +0 -119
- package/src/scene/__tests__/shapeLayers.test.ts +0 -106
- package/src/scene/__tests__/useSceneHitTest.test.ts +0 -90
- package/src/scene/__tests__/useScenePanZoom.test.ts +0 -130
- package/src/scene/adapters/DiagramAdapter.ts +0 -79
- package/src/scene/adapters/DrawingAdapter.ts +0 -420
- package/src/scene/adapters/LayoutAdapter.ts +0 -313
- package/src/scene/adapters/blockLayers.ts +0 -159
- package/src/scene/commands/SceneCommand.ts +0 -84
- package/src/scene/commands/drawingCommands.ts +0 -318
- package/src/scene/commands/layoutCommands.ts +0 -301
- package/src/scene/fitScale.ts +0 -17
- package/src/scene/hooks/useSceneHitTest.ts +0 -105
- package/src/scene/hooks/useScenePanZoom.ts +0 -154
- package/src/scene/hooks/useSceneSelection.ts +0 -62
- package/src/scene/index.ts +0 -90
- package/src/scene/layers/DiagramEdges.tsx +0 -142
- package/src/scene/layers/edgeGeometry.ts +0 -104
- package/src/scene/layers/nodeCard.tsx +0 -164
- package/src/scene/layers/renderLayer.tsx +0 -70
- package/src/scene/layers/shapeLayers.ts +0 -201
- package/src/scene/paths/bezierEdit.ts +0 -208
- package/src/scene/scene.css +0 -874
- package/src/scene/text/SceneTextOverlay.tsx +0 -161
- package/src/scene/text/sceneTextChannel.ts +0 -46
- package/src/scene/text/sceneTextConfig.ts +0 -31
- package/src/scene/text/sceneTiptap.ts +0 -36
- package/src/scene/text/useSceneTextEditing.ts +0 -39
- package/src/scene/tools/ConnectTool.ts +0 -209
- package/src/scene/tools/DrawingConnectTool.ts +0 -231
- package/src/scene/tools/PathTool.ts +0 -158
- package/src/scene/tools/PlaceTool.ts +0 -47
- package/src/scene/tools/SceneTool.ts +0 -85
- package/src/scene/tools/SelectTool.ts +0 -300
- package/src/scene/tools/ShapeTool.ts +0 -143
- package/src/scene/tools/TextTool.ts +0 -72
- package/src/scene/tools/TokenTool.ts +0 -95
- package/src/scene/tools/createDrawShapeTool.ts +0 -82
- package/src/selectionConversions.ts +0 -155
- package/src/styles/ascii-diagram.css +0 -79
- package/src/styles/ascii-timeline.css +0 -596
- package/src/styles/code-context.css +0 -155
- package/src/styles/code-snippet.css +0 -76
- package/src/styles/diagram.css +0 -183
- package/src/styles/editor.css +0 -7131
- package/src/styles/folder-view.css +0 -210
- package/src/styles/image-edit-affordance.css +0 -201
- package/src/styles/index.css +0 -20
- package/src/styles/mermaid-diagram.css +0 -487
- package/src/styles/tree-view.css +0 -189
- package/src/teleprompter/TeleprompterControls.tsx +0 -218
- package/src/teleprompter/TeleprompterSelfView.tsx +0 -22
- package/src/teleprompter/TeleprompterSurface.tsx +0 -267
- package/src/teleprompter/TeleprompterView.tsx +0 -338
- package/src/teleprompter/canvasRenderer.ts +0 -161
- package/src/teleprompter/floatingWindow.ts +0 -352
- package/src/teleprompter/index.ts +0 -61
- package/src/teleprompter/pcmWorklet.ts +0 -62
- package/src/teleprompter/recording/insertPreamble.ts +0 -80
- package/src/teleprompter/recording/narrationSave.ts +0 -134
- package/src/teleprompter/recording/useNarrationRecorder.ts +0 -367
- package/src/teleprompter/scrollModel.ts +0 -85
- package/src/teleprompter/teleprompterTheme.ts +0 -303
- package/src/teleprompter/types.ts +0 -38
- package/src/teleprompter/useFloatingWindow.ts +0 -74
- package/src/teleprompter/useMicAnalysis.ts +0 -211
- package/src/teleprompter/useTeleprompter.ts +0 -421
- package/src/templateContentPreviewResolver.ts +0 -360
- package/src/timeline/TimelineEditorWidget.tsx +0 -861
- package/src/timeline/TimelineViewExtension.ts +0 -252
- package/src/timeline/__tests__/TimelineEditorWidget.test.tsx +0 -414
- package/src/timeline/__tests__/TimelineViewExtension.test.ts +0 -163
- package/src/timeline/__tests__/timelineCommands.test.ts +0 -359
- package/src/timeline/__tests__/timelineOps.test.ts +0 -277
- package/src/timeline/__tests__/timelinePaste.test.ts +0 -34
- package/src/timeline/timelineCommands.ts +0 -421
- package/src/timeline/timelineData.ts +0 -54
- package/src/timeline/timelineOps.ts +0 -381
- package/src/timeline/timelinePaste.ts +0 -8
- package/src/timelineSource.ts +0 -244
- package/src/tiptap/TiptapAudio.tsx +0 -86
- package/src/tiptap/TiptapVideo.tsx +0 -119
- package/src/tiptap/useResolvedMediaSrc.ts +0 -47
- package/src/tiptapBridge.ts +0 -986
- package/src/tooltipPlacement.ts +0 -13
- package/src/transformStyleId.ts +0 -17
- package/src/transitionCatalog.ts +0 -159
- package/src/treeview/TreeOutlineWidget.tsx +0 -390
- package/src/treeview/TreeViewExtension.ts +0 -250
- package/src/treeview/__tests__/TreeOutlineWidget.test.tsx +0 -156
- package/src/treeview/__tests__/TreeViewExtension.test.ts +0 -122
- package/src/treeview/__tests__/treeOps.test.ts +0 -177
- package/src/treeview/__tests__/treePaste.test.ts +0 -40
- package/src/treeview/__tests__/treeViewCommands.test.ts +0 -179
- package/src/treeview/treeOps.ts +0 -231
- package/src/treeview/treePaste.ts +0 -13
- package/src/treeview/treeViewCommands.ts +0 -99
- package/src/treeview/treeViewData.ts +0 -41
- package/src/types/monaco-shims.d.ts +0 -10
- package/src/useBlockNavigator.ts +0 -153
- package/src/useHeadingLayout.ts +0 -294
- package/src/useMonacoLoader.ts +0 -82
- package/src/useTimelineClock.ts +0 -76
- package/src/utils/collectInlineFontAwesomeCss.ts +0 -69
- package/src/utils/dropUtils.ts +0 -136
- package/src/utils/normalizeMalformedAssetUrl.ts +0 -22
- package/src/writeCanvasSettings.ts +0 -30
- package/src/wysiwygImageUpload.ts +0 -113
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DrawingConnectTool — create and re-target connectors between shapes.
|
|
3
|
-
*
|
|
4
|
-
* Mirrors `ConnectTool` but works on drawing shape layers (`dshape-<id>`)
|
|
5
|
-
* and supports two gestures:
|
|
6
|
-
* - Press empty-on a shape, drag to another shape, release → `addEdge`.
|
|
7
|
-
* - Press on a selected connector's endpoint handle, drag to a shape,
|
|
8
|
-
* release → re-target that endpoint (via the `onRetarget` callback,
|
|
9
|
-
* since the generic SceneCommand vocabulary has no retarget command).
|
|
10
|
-
*
|
|
11
|
-
* Current edges / selection / shape boxes change every render, so the
|
|
12
|
-
* host passes `endpointAt` (reads the live selected-edge handles) rather
|
|
13
|
-
* than baking them into the memoized tool.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { createElement, type JSX } from 'react';
|
|
17
|
-
import type { SceneTool, SceneToolContext } from './SceneTool';
|
|
18
|
-
import { shapeIdFromLayerId, isPrimaryShapeLayer } from '../layers/shapeLayers';
|
|
19
|
-
import {
|
|
20
|
-
edgeEndpoints,
|
|
21
|
-
snapPointToward,
|
|
22
|
-
straightPath,
|
|
23
|
-
type EdgeNodeBox,
|
|
24
|
-
} from '../layers/edgeGeometry';
|
|
25
|
-
|
|
26
|
-
/** A grab on the selected connector's endpoint handle. */
|
|
27
|
-
export interface EndpointHit {
|
|
28
|
-
connectorId: string;
|
|
29
|
-
/** Which end the handle controls. */
|
|
30
|
-
end: 'from' | 'to';
|
|
31
|
-
/** The shape id of the *other* (fixed) endpoint — anchors the drag. */
|
|
32
|
-
fixedShapeId: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface DrawingConnectOptions {
|
|
36
|
-
/** Endpoint handle (of the selected connector) near `point`, if any. */
|
|
37
|
-
endpointAt?: (point: { x: number; y: number }) => EndpointHit | null;
|
|
38
|
-
/** Commit an endpoint re-target. */
|
|
39
|
-
onRetarget?: (connectorId: string, end: 'from' | 'to', newTargetId: string) => void;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
type DragState =
|
|
43
|
-
| {
|
|
44
|
-
mode: 'new';
|
|
45
|
-
sourceId: string;
|
|
46
|
-
sourceBox: EdgeNodeBox;
|
|
47
|
-
start: { x: number; y: number };
|
|
48
|
-
end: { x: number; y: number };
|
|
49
|
-
hovered: string | null;
|
|
50
|
-
}
|
|
51
|
-
| {
|
|
52
|
-
mode: 'retarget';
|
|
53
|
-
connectorId: string;
|
|
54
|
-
end: 'from' | 'to';
|
|
55
|
-
fixedShapeId: string;
|
|
56
|
-
fixedBox: EdgeNodeBox;
|
|
57
|
-
start: { x: number; y: number };
|
|
58
|
-
endPoint: { x: number; y: number };
|
|
59
|
-
hovered: string | null;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export function createDrawingConnectTool(options: DrawingConnectOptions = {}): SceneTool {
|
|
63
|
-
let drag: DragState | null = null;
|
|
64
|
-
|
|
65
|
-
function pointer(e: React.PointerEvent): { sx: number; sy: number } {
|
|
66
|
-
const rect = (e.currentTarget as Element).getBoundingClientRect();
|
|
67
|
-
return { sx: e.clientX - rect.left, sy: e.clientY - rect.top };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function shapeBox(ctx: SceneToolContext, shapeId: string): EdgeNodeBox | null {
|
|
71
|
-
const it = ctx.hitItems.find((h) => h.id === `dshape-${shapeId}`);
|
|
72
|
-
if (!it) return null;
|
|
73
|
-
return {
|
|
74
|
-
id: shapeId,
|
|
75
|
-
x: it.bounds.x,
|
|
76
|
-
y: it.bounds.y,
|
|
77
|
-
width: it.bounds.width,
|
|
78
|
-
height: it.bounds.height,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function shapeAt(ctx: SceneToolContext, v: { x: number; y: number }): string | null {
|
|
83
|
-
const hitId = ctx.hit(v);
|
|
84
|
-
if (!hitId || !isPrimaryShapeLayer(hitId)) return null;
|
|
85
|
-
return shapeIdFromLayerId(hitId);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function previewNew(
|
|
89
|
-
sourceBox: EdgeNodeBox,
|
|
90
|
-
current: { x: number; y: number },
|
|
91
|
-
targetBox: EdgeNodeBox | null,
|
|
92
|
-
): { start: { x: number; y: number }; end: { x: number; y: number } } {
|
|
93
|
-
if (targetBox) {
|
|
94
|
-
return (
|
|
95
|
-
edgeEndpoints([sourceBox, targetBox], sourceBox.id, targetBox.id) ?? {
|
|
96
|
-
start: current,
|
|
97
|
-
end: current,
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
start: snapPointToward([sourceBox], sourceBox.id, current) ?? current,
|
|
103
|
-
end: current,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function previewRetarget(
|
|
108
|
-
fixedBox: EdgeNodeBox,
|
|
109
|
-
movedEnd: 'from' | 'to',
|
|
110
|
-
current: { x: number; y: number },
|
|
111
|
-
targetBox: EdgeNodeBox | null,
|
|
112
|
-
): { start: { x: number; y: number }; end: { x: number; y: number } } {
|
|
113
|
-
if (targetBox) {
|
|
114
|
-
const source = movedEnd === 'from' ? targetBox : fixedBox;
|
|
115
|
-
const target = movedEnd === 'from' ? fixedBox : targetBox;
|
|
116
|
-
return (
|
|
117
|
-
edgeEndpoints([source, target], source.id, target.id) ?? {
|
|
118
|
-
start: current,
|
|
119
|
-
end: current,
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
const fixed = snapPointToward([fixedBox], fixedBox.id, current) ?? current;
|
|
124
|
-
return movedEnd === 'from' ? { start: current, end: fixed } : { start: fixed, end: current };
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
id: 'connect',
|
|
129
|
-
label: 'Connect',
|
|
130
|
-
cursor: 'crosshair',
|
|
131
|
-
shortcut: 'c',
|
|
132
|
-
|
|
133
|
-
onPointerDown(e, ctx) {
|
|
134
|
-
if (e.button !== 0) return;
|
|
135
|
-
const { sx, sy } = pointer(e);
|
|
136
|
-
const v = ctx.screenToViewport(sx, sy);
|
|
137
|
-
|
|
138
|
-
// Endpoint handle of the selected connector → re-target gesture.
|
|
139
|
-
const ep = options.endpointAt?.(v);
|
|
140
|
-
if (ep) {
|
|
141
|
-
const fixedBox = shapeBox(ctx, ep.fixedShapeId);
|
|
142
|
-
if (!fixedBox) return;
|
|
143
|
-
const preview = previewRetarget(fixedBox, ep.end, v, null);
|
|
144
|
-
drag = {
|
|
145
|
-
mode: 'retarget',
|
|
146
|
-
connectorId: ep.connectorId,
|
|
147
|
-
end: ep.end,
|
|
148
|
-
fixedShapeId: ep.fixedShapeId,
|
|
149
|
-
fixedBox,
|
|
150
|
-
start: preview.start,
|
|
151
|
-
endPoint: preview.end,
|
|
152
|
-
hovered: null,
|
|
153
|
-
};
|
|
154
|
-
(e.currentTarget as Element).setPointerCapture?.(e.pointerId);
|
|
155
|
-
e.stopPropagation();
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Otherwise start a new connection from the shape under the pointer.
|
|
160
|
-
const src = shapeAt(ctx, v);
|
|
161
|
-
if (!src) return;
|
|
162
|
-
const sourceBox = shapeBox(ctx, src);
|
|
163
|
-
if (!sourceBox) return;
|
|
164
|
-
const preview = previewNew(sourceBox, v, null);
|
|
165
|
-
drag = {
|
|
166
|
-
mode: 'new',
|
|
167
|
-
sourceId: src,
|
|
168
|
-
sourceBox,
|
|
169
|
-
start: preview.start,
|
|
170
|
-
end: preview.end,
|
|
171
|
-
hovered: null,
|
|
172
|
-
};
|
|
173
|
-
(e.currentTarget as Element).setPointerCapture?.(e.pointerId);
|
|
174
|
-
e.stopPropagation();
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
onPointerMove(e, ctx) {
|
|
178
|
-
if (!drag) return;
|
|
179
|
-
const { sx, sy } = pointer(e);
|
|
180
|
-
const v = ctx.screenToViewport(sx, sy);
|
|
181
|
-
const tgt = shapeAt(ctx, v);
|
|
182
|
-
const exclude = drag.mode === 'new' ? drag.sourceId : drag.fixedShapeId;
|
|
183
|
-
const targetId = tgt && tgt !== exclude ? tgt : null;
|
|
184
|
-
const targetBox = targetId ? shapeBox(ctx, targetId) : null;
|
|
185
|
-
if (drag.mode === 'new') {
|
|
186
|
-
const preview = previewNew(drag.sourceBox, v, targetBox);
|
|
187
|
-
drag.start = preview.start;
|
|
188
|
-
drag.end = preview.end;
|
|
189
|
-
} else {
|
|
190
|
-
const preview = previewRetarget(drag.fixedBox, drag.end, v, targetBox);
|
|
191
|
-
drag.start = preview.start;
|
|
192
|
-
drag.endPoint = preview.end;
|
|
193
|
-
}
|
|
194
|
-
drag.hovered = targetBox?.id ?? null;
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
onPointerUp(e, ctx) {
|
|
198
|
-
if (!drag) return;
|
|
199
|
-
const finished = drag;
|
|
200
|
-
drag = null;
|
|
201
|
-
(e.currentTarget as Element).releasePointerCapture?.(e.pointerId);
|
|
202
|
-
if (!finished.hovered) return;
|
|
203
|
-
if (finished.mode === 'new') {
|
|
204
|
-
ctx.dispatch({ kind: 'addEdge', source: finished.sourceId, target: finished.hovered });
|
|
205
|
-
} else {
|
|
206
|
-
options.onRetarget?.(finished.connectorId, finished.end, finished.hovered);
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
renderOverlay(): JSX.Element | null {
|
|
211
|
-
if (!drag) return null;
|
|
212
|
-
const a = drag.start;
|
|
213
|
-
const b = drag.mode === 'new' ? drag.end : drag.endPoint;
|
|
214
|
-
return createElement(
|
|
215
|
-
'g',
|
|
216
|
-
{ key: 'drawing-connect-preview' },
|
|
217
|
-
createElement('path', {
|
|
218
|
-
d: straightPath(a, b),
|
|
219
|
-
className: 'squisq-scene-connect-preview',
|
|
220
|
-
fill: 'none',
|
|
221
|
-
}),
|
|
222
|
-
createElement('circle', {
|
|
223
|
-
cx: b.x,
|
|
224
|
-
cy: b.y,
|
|
225
|
-
r: 4,
|
|
226
|
-
className: 'squisq-scene-connect-preview',
|
|
227
|
-
}),
|
|
228
|
-
);
|
|
229
|
-
},
|
|
230
|
-
};
|
|
231
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PathTool — drag to draw a freehand path.
|
|
3
|
-
*
|
|
4
|
-
* Captures pointer samples on move; on release, simplifies the polyline
|
|
5
|
-
* into a smooth cubic bezier sequence (a one-pass Catmull–Rom-style
|
|
6
|
-
* pass) and dispatches an `addLayer` for a new PathLayer.
|
|
7
|
-
*
|
|
8
|
-
* v1 emits an open path (no Z). Closed paths can be added by a later
|
|
9
|
-
* tool variant or via the SelectTool's properties panel.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { createElement, type JSX } from 'react';
|
|
13
|
-
import type { PathLayer } from '@bendyline/squisq/schemas';
|
|
14
|
-
import type { SceneTool } from './SceneTool';
|
|
15
|
-
import { serializePath, type ParsedPath, type PathPoint } from '../paths/bezierEdit';
|
|
16
|
-
|
|
17
|
-
interface PathToolOptions {
|
|
18
|
-
/** Stroke color. Default '#1e293b'. */
|
|
19
|
-
stroke?: string;
|
|
20
|
-
/** Stroke width. Default 2. */
|
|
21
|
-
strokeWidth?: number;
|
|
22
|
-
/** Minimum distance (viewport units) between captured samples. */
|
|
23
|
-
sampleDistance?: number;
|
|
24
|
-
/** Override id / label / shortcut. */
|
|
25
|
-
id?: string;
|
|
26
|
-
label?: string;
|
|
27
|
-
shortcut?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function createPathTool(options: PathToolOptions = {}): SceneTool {
|
|
31
|
-
const stroke = options.stroke ?? '#1e293b';
|
|
32
|
-
const strokeWidth = options.strokeWidth ?? 2;
|
|
33
|
-
const sampleDistance = options.sampleDistance ?? 4;
|
|
34
|
-
|
|
35
|
-
let samples: { x: number; y: number }[] | null = null;
|
|
36
|
-
|
|
37
|
-
function pointer(e: React.PointerEvent): { sx: number; sy: number } {
|
|
38
|
-
const rect = (e.currentTarget as Element).getBoundingClientRect();
|
|
39
|
-
return { sx: e.clientX - rect.left, sy: e.clientY - rect.top };
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
id: options.id ?? 'path',
|
|
44
|
-
label: options.label ?? 'Pen',
|
|
45
|
-
cursor: 'crosshair',
|
|
46
|
-
shortcut: options.shortcut ?? 'p',
|
|
47
|
-
|
|
48
|
-
onPointerDown(e, ctx) {
|
|
49
|
-
if (e.button !== 0) return;
|
|
50
|
-
const { sx, sy } = pointer(e);
|
|
51
|
-
const v = ctx.screenToViewport(sx, sy);
|
|
52
|
-
samples = [v];
|
|
53
|
-
(e.currentTarget as Element).setPointerCapture?.(e.pointerId);
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
onPointerMove(e, ctx) {
|
|
57
|
-
if (!samples) return;
|
|
58
|
-
const { sx, sy } = pointer(e);
|
|
59
|
-
const v = ctx.screenToViewport(sx, sy);
|
|
60
|
-
const last = samples[samples.length - 1];
|
|
61
|
-
if (Math.hypot(v.x - last.x, v.y - last.y) >= sampleDistance) samples.push(v);
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
onPointerUp(e, ctx) {
|
|
65
|
-
if (!samples) return;
|
|
66
|
-
const captured = samples;
|
|
67
|
-
samples = null;
|
|
68
|
-
(e.currentTarget as Element).releasePointerCapture?.(e.pointerId);
|
|
69
|
-
if (captured.length < 2) return;
|
|
70
|
-
const parsed = smoothPolyline(captured);
|
|
71
|
-
const d = serializePath(parsed);
|
|
72
|
-
const bounds = polylineBounds(captured);
|
|
73
|
-
const layer: PathLayer = {
|
|
74
|
-
id: `path-${Date.now().toString(36)}-${Math.floor(Math.random() * 1e6).toString(36)}`,
|
|
75
|
-
type: 'path',
|
|
76
|
-
position: {
|
|
77
|
-
x: bounds.x,
|
|
78
|
-
y: bounds.y,
|
|
79
|
-
width: bounds.width,
|
|
80
|
-
height: bounds.height,
|
|
81
|
-
},
|
|
82
|
-
content: {
|
|
83
|
-
d,
|
|
84
|
-
stroke,
|
|
85
|
-
strokeWidth,
|
|
86
|
-
fill: 'none',
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
ctx.dispatch({ kind: 'addLayer', layer });
|
|
90
|
-
ctx.setActiveTool?.('select');
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
renderOverlay(): JSX.Element | null {
|
|
94
|
-
if (!samples || samples.length < 2) return null;
|
|
95
|
-
// Live polyline — cheaper than re-smoothing on every move.
|
|
96
|
-
const d = polylineToD(samples);
|
|
97
|
-
return createElement('path', {
|
|
98
|
-
key: 'path-preview',
|
|
99
|
-
d,
|
|
100
|
-
className: 'squisq-scene-connect-preview',
|
|
101
|
-
fill: 'none',
|
|
102
|
-
});
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function polylineToD(pts: { x: number; y: number }[]): string {
|
|
108
|
-
if (pts.length === 0) return '';
|
|
109
|
-
const parts = [`M ${pts[0].x} ${pts[0].y}`];
|
|
110
|
-
for (let i = 1; i < pts.length; i++) parts.push(`L ${pts[i].x} ${pts[i].y}`);
|
|
111
|
-
return parts.join(' ');
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Catmull–Rom → cubic bezier conversion. Each interior segment becomes a
|
|
116
|
-
* C with control points derived from the surrounding samples, producing
|
|
117
|
-
* a smooth curve that passes through every input point. Endpoints reuse
|
|
118
|
-
* the adjacent sample as a virtual control.
|
|
119
|
-
*/
|
|
120
|
-
function smoothPolyline(pts: { x: number; y: number }[]): ParsedPath {
|
|
121
|
-
if (pts.length === 0) return { points: [], closed: false };
|
|
122
|
-
if (pts.length === 1)
|
|
123
|
-
return { points: [{ kind: 'move', x: pts[0].x, y: pts[0].y }], closed: false };
|
|
124
|
-
const points: PathPoint[] = [{ kind: 'move', x: pts[0].x, y: pts[0].y }];
|
|
125
|
-
for (let i = 0; i < pts.length - 1; i++) {
|
|
126
|
-
const p0 = pts[i - 1] ?? pts[i];
|
|
127
|
-
const p1 = pts[i];
|
|
128
|
-
const p2 = pts[i + 1];
|
|
129
|
-
const p3 = pts[i + 2] ?? p2;
|
|
130
|
-
const tension = 6;
|
|
131
|
-
const cp1 = { x: p1.x + (p2.x - p0.x) / tension, y: p1.y + (p2.y - p0.y) / tension };
|
|
132
|
-
const cp2 = { x: p2.x - (p3.x - p1.x) / tension, y: p2.y - (p3.y - p1.y) / tension };
|
|
133
|
-
// Attach cpOut to the previous point and cpIn to the new point.
|
|
134
|
-
const prev = points[points.length - 1];
|
|
135
|
-
if (prev) prev.cpOut = cp1;
|
|
136
|
-
points.push({ kind: 'curve', x: p2.x, y: p2.y, cpIn: cp2 });
|
|
137
|
-
}
|
|
138
|
-
return { points, closed: false };
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function polylineBounds(pts: { x: number; y: number }[]): {
|
|
142
|
-
x: number;
|
|
143
|
-
y: number;
|
|
144
|
-
width: number;
|
|
145
|
-
height: number;
|
|
146
|
-
} {
|
|
147
|
-
let minX = Infinity;
|
|
148
|
-
let minY = Infinity;
|
|
149
|
-
let maxX = -Infinity;
|
|
150
|
-
let maxY = -Infinity;
|
|
151
|
-
for (const p of pts) {
|
|
152
|
-
if (p.x < minX) minX = p.x;
|
|
153
|
-
if (p.y < minY) minY = p.y;
|
|
154
|
-
if (p.x > maxX) maxX = p.x;
|
|
155
|
-
if (p.y > maxY) maxY = p.y;
|
|
156
|
-
}
|
|
157
|
-
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
158
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PlaceTool — a generic "click the canvas to drop one pre-built layer"
|
|
3
|
-
* tool. The palette arms a place tool; the next canvas click drops the
|
|
4
|
-
* layer its `build` function returns at the click point, then hands
|
|
5
|
-
* control back to Select so the user can immediately reposition it.
|
|
6
|
-
*
|
|
7
|
-
* This is the shared mechanism behind both the placeholder-token tools
|
|
8
|
-
* (see `createTokenTool`) and the shape tools in the template designer's
|
|
9
|
-
* "Add" bin — anything that places a single layer at a point.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import type { Layer } from '@bendyline/squisq/schemas';
|
|
13
|
-
import type { SceneTool } from './SceneTool';
|
|
14
|
-
|
|
15
|
-
export interface PlaceToolOptions {
|
|
16
|
-
/** Stable tool id (e.g. `'token-title'`, `'shape-diamond'`). */
|
|
17
|
-
id: string;
|
|
18
|
-
/** Label shown in the toolbar / palette button. */
|
|
19
|
-
label: string;
|
|
20
|
-
/** Optional keyboard shortcut. */
|
|
21
|
-
shortcut?: string;
|
|
22
|
-
/** Cursor while the tool is armed. Default `'crosshair'`. */
|
|
23
|
-
cursor?: string;
|
|
24
|
-
/** Build the layer to drop, given the click point in viewport units. */
|
|
25
|
-
build: (point: { x: number; y: number }) => Layer;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function createPlaceTool(options: PlaceToolOptions): SceneTool {
|
|
29
|
-
return {
|
|
30
|
-
id: options.id,
|
|
31
|
-
label: options.label,
|
|
32
|
-
cursor: options.cursor ?? 'crosshair',
|
|
33
|
-
shortcut: options.shortcut,
|
|
34
|
-
|
|
35
|
-
onPointerDown(e, ctx) {
|
|
36
|
-
if (e.button !== 0) return;
|
|
37
|
-
const rect = (e.currentTarget as Element).getBoundingClientRect();
|
|
38
|
-
const sx = e.clientX - rect.left;
|
|
39
|
-
const sy = e.clientY - rect.top;
|
|
40
|
-
const v = ctx.screenToViewport(sx, sy);
|
|
41
|
-
ctx.dispatch({ kind: 'addLayer', layer: options.build(v) });
|
|
42
|
-
// Hand control back to Select so the user can immediately
|
|
43
|
-
// reposition the newly-added layer.
|
|
44
|
-
ctx.setActiveTool?.('select');
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SceneTool — the contract every editing mode (select, connect, draw,
|
|
3
|
-
* shape, text) implements. A tool is plain data + handlers, not a React
|
|
4
|
-
* component, so adapters can compose toolsets without reaching into JSX.
|
|
5
|
-
*
|
|
6
|
-
* The Scene component owns event binding, pan/zoom, and selection state;
|
|
7
|
-
* tools receive a `SceneToolContext` with helpers for hit-testing,
|
|
8
|
-
* coordinate conversion, and command dispatch.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { JSX } from 'react';
|
|
12
|
-
import type { Layer } from '@bendyline/squisq/schemas';
|
|
13
|
-
import type { SceneCommand, SceneEdge } from '../commands/SceneCommand';
|
|
14
|
-
import type { HitTestable } from '../hooks/useSceneHitTest';
|
|
15
|
-
import type { SceneTransform } from '../hooks/useScenePanZoom';
|
|
16
|
-
|
|
17
|
-
/** Mutable gesture storage owned by one Scene instance. */
|
|
18
|
-
export interface SceneInteractionState {
|
|
19
|
-
selectDrag?: unknown;
|
|
20
|
-
connect?: unknown;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface SceneToolContext {
|
|
24
|
-
/** Gesture state private to the owning Scene instance. */
|
|
25
|
-
interaction: SceneInteractionState;
|
|
26
|
-
/** Current viewport size in viewport units. */
|
|
27
|
-
viewport: { width: number; height: number };
|
|
28
|
-
/** Current pan/zoom transform. */
|
|
29
|
-
transform: SceneTransform;
|
|
30
|
-
/** All currently rendered layers, in back-to-front order. */
|
|
31
|
-
layers: readonly Layer[];
|
|
32
|
-
/** Optional diagram edges (diagram mode only). */
|
|
33
|
-
edges: readonly SceneEdge[];
|
|
34
|
-
/** Currently selected layer ids. */
|
|
35
|
-
selection: ReadonlySet<string>;
|
|
36
|
-
/** Hit-testable bounding boxes for every layer (precomputed by Scene). */
|
|
37
|
-
hitItems: readonly HitTestable[];
|
|
38
|
-
/** Convert a screen-pixel point (relative to the Scene root) → viewport units. */
|
|
39
|
-
screenToViewport: (sx: number, sy: number) => { x: number; y: number };
|
|
40
|
-
/** Convert a viewport-unit point → screen-pixel point. */
|
|
41
|
-
viewportToScreen: (vx: number, vy: number) => { x: number; y: number };
|
|
42
|
-
/** Topmost layer id at the given viewport-unit point, or null. */
|
|
43
|
-
hit: (point: { x: number; y: number }) => string | null;
|
|
44
|
-
/** Replace selection. */
|
|
45
|
-
setSelection: (ids: Iterable<string>) => void;
|
|
46
|
-
/** Dispatch a SceneCommand to the host adapter. */
|
|
47
|
-
dispatch: (cmd: SceneCommand) => void;
|
|
48
|
-
/** Optional setter for the active tool id (e.g. ConnectTool fall-through to SelectTool). */
|
|
49
|
-
setActiveTool?: (id: string) => void;
|
|
50
|
-
/**
|
|
51
|
-
* Open the shared inline text editor for the given hit layer id (the host
|
|
52
|
-
* must supply a `textEditing` config). Used by SelectTool's double-click.
|
|
53
|
-
*/
|
|
54
|
-
beginTextEdit?: (hitLayerId: string) => void;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface SceneTool {
|
|
58
|
-
/** Stable id, e.g. `'select'`, `'connect'`. */
|
|
59
|
-
id: string;
|
|
60
|
-
/** Human-readable label for the toolbar. */
|
|
61
|
-
label: string;
|
|
62
|
-
/** CSS cursor while the tool is active. */
|
|
63
|
-
cursor: string;
|
|
64
|
-
/** Optional keyboard accelerator (single-character, lowercase). */
|
|
65
|
-
shortcut?: string;
|
|
66
|
-
/** Hide resize handles on selected layers while this tool is active. */
|
|
67
|
-
hideSelectionHandles?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Optional icon — JSX rendered inside a fixed-size toolbar button. Keep
|
|
70
|
-
* it light (a single SVG path is ideal); the toolbar wrapper handles
|
|
71
|
-
* sizing and active-state styling.
|
|
72
|
-
*/
|
|
73
|
-
icon?: JSX.Element;
|
|
74
|
-
onPointerDown?(e: React.PointerEvent, ctx: SceneToolContext): void;
|
|
75
|
-
onPointerMove?(e: React.PointerEvent, ctx: SceneToolContext): void;
|
|
76
|
-
onPointerUp?(e: React.PointerEvent, ctx: SceneToolContext): void;
|
|
77
|
-
onDoubleClick?(e: React.MouseEvent, ctx: SceneToolContext): void;
|
|
78
|
-
onKeyDown?(e: KeyboardEvent, ctx: SceneToolContext): void;
|
|
79
|
-
/**
|
|
80
|
-
* Optional overlay rendered above the scene (e.g. marquee box, in-flight
|
|
81
|
-
* connection preview, drag ghost). Returned JSX is appended into the
|
|
82
|
-
* Scene's overlay SVG layer.
|
|
83
|
-
*/
|
|
84
|
-
renderOverlay?(ctx: SceneToolContext): JSX.Element | null;
|
|
85
|
-
}
|