@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,272 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @vitest-environment jsdom
|
|
3
|
-
*
|
|
4
|
-
* Tests for the image-edit affordance + modal:
|
|
5
|
-
* - EditorContext exposes openImageEdit / closeImageEdit / bumpMediaRevision
|
|
6
|
-
* - <EditorShell> mounts an `<ImageEditModal>` when the target is set,
|
|
7
|
-
* and routes Export blobs back through `mediaProvider.addMedia`.
|
|
8
|
-
*
|
|
9
|
-
* The Tiptap NodeView itself isn't exercised here (Tiptap + ProseMirror
|
|
10
|
-
* are jsdom-hostile); we verify the surrounding context + shell wiring
|
|
11
|
-
* directly via a small harness.
|
|
12
|
-
*/
|
|
13
|
-
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
14
|
-
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
15
|
-
import {
|
|
16
|
-
MemoryContentContainer,
|
|
17
|
-
createMediaProviderFromContainer,
|
|
18
|
-
} from '@bendyline/squisq/storage';
|
|
19
|
-
import type { MediaProvider } from '@bendyline/squisq/schemas';
|
|
20
|
-
import { EditorProvider, useEditorContext } from '../EditorContext';
|
|
21
|
-
|
|
22
|
-
// Stub the heavy editing surfaces so the shell can mount under jsdom
|
|
23
|
-
// without dragging in monaco-editor or Tiptap. We only care about the
|
|
24
|
-
// shell's modal-mounting wiring here.
|
|
25
|
-
vi.mock('../RawEditor', () => ({
|
|
26
|
-
RawEditor: () => <div data-testid="raw-editor-stub" />,
|
|
27
|
-
}));
|
|
28
|
-
vi.mock('../WysiwygEditor', () => ({
|
|
29
|
-
WysiwygEditor: () => <div data-testid="wysiwyg-editor-stub" />,
|
|
30
|
-
}));
|
|
31
|
-
vi.mock('../PreviewPanel', () => ({
|
|
32
|
-
PreviewPanel: () => <div data-testid="preview-stub" />,
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
import { EditorShell } from '../EditorShell';
|
|
36
|
-
|
|
37
|
-
beforeEach(() => {
|
|
38
|
-
if (typeof URL.createObjectURL !== 'function') {
|
|
39
|
-
Object.defineProperty(URL, 'createObjectURL', {
|
|
40
|
-
configurable: true,
|
|
41
|
-
value: vi.fn(() => 'blob:stub'),
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
if (typeof URL.revokeObjectURL !== 'function') {
|
|
45
|
-
Object.defineProperty(URL, 'revokeObjectURL', {
|
|
46
|
-
configurable: true,
|
|
47
|
-
value: vi.fn(),
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (typeof window !== 'undefined' && typeof window.matchMedia !== 'function') {
|
|
51
|
-
Object.defineProperty(window, 'matchMedia', {
|
|
52
|
-
configurable: true,
|
|
53
|
-
value: (query: string) => ({
|
|
54
|
-
matches: false,
|
|
55
|
-
media: query,
|
|
56
|
-
onchange: null,
|
|
57
|
-
addListener: vi.fn(),
|
|
58
|
-
removeListener: vi.fn(),
|
|
59
|
-
addEventListener: vi.fn(),
|
|
60
|
-
removeEventListener: vi.fn(),
|
|
61
|
-
dispatchEvent: vi.fn(() => false),
|
|
62
|
-
}),
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
if (typeof globalThis.ResizeObserver === 'undefined') {
|
|
66
|
-
class ResizeObserverStub {
|
|
67
|
-
observe(): void {}
|
|
68
|
-
unobserve(): void {}
|
|
69
|
-
disconnect(): void {}
|
|
70
|
-
}
|
|
71
|
-
(globalThis as unknown as { ResizeObserver: typeof ResizeObserverStub }).ResizeObserver =
|
|
72
|
-
ResizeObserverStub;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// ── Context harness ──────────────────────────────────────
|
|
77
|
-
|
|
78
|
-
function ContextHarness() {
|
|
79
|
-
const ctx = useEditorContext();
|
|
80
|
-
return (
|
|
81
|
-
<div>
|
|
82
|
-
<span data-testid="target">{ctx.imageEditTarget ?? 'null'}</span>
|
|
83
|
-
<span data-testid="revision">{ctx.mediaRevision}</span>
|
|
84
|
-
<button data-testid="open" type="button" onClick={() => ctx.openImageEdit('hero.png')}>
|
|
85
|
-
open
|
|
86
|
-
</button>
|
|
87
|
-
<button data-testid="close" type="button" onClick={ctx.closeImageEdit}>
|
|
88
|
-
close
|
|
89
|
-
</button>
|
|
90
|
-
<button data-testid="bump" type="button" onClick={ctx.bumpMediaRevision}>
|
|
91
|
-
bump
|
|
92
|
-
</button>
|
|
93
|
-
</div>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
describe('EditorContext image-edit actions', () => {
|
|
98
|
-
it('starts with imageEditTarget=null and mediaRevision=0', () => {
|
|
99
|
-
render(
|
|
100
|
-
<EditorProvider>
|
|
101
|
-
<ContextHarness />
|
|
102
|
-
</EditorProvider>,
|
|
103
|
-
);
|
|
104
|
-
expect(screen.getByTestId('target').textContent).toBe('null');
|
|
105
|
-
expect(screen.getByTestId('revision').textContent).toBe('0');
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('openImageEdit sets the target, closeImageEdit clears it', () => {
|
|
109
|
-
render(
|
|
110
|
-
<EditorProvider>
|
|
111
|
-
<ContextHarness />
|
|
112
|
-
</EditorProvider>,
|
|
113
|
-
);
|
|
114
|
-
act(() => {
|
|
115
|
-
fireEvent.click(screen.getByTestId('open'));
|
|
116
|
-
});
|
|
117
|
-
expect(screen.getByTestId('target').textContent).toBe('hero.png');
|
|
118
|
-
act(() => {
|
|
119
|
-
fireEvent.click(screen.getByTestId('close'));
|
|
120
|
-
});
|
|
121
|
-
expect(screen.getByTestId('target').textContent).toBe('null');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('bumpMediaRevision increments monotonically', () => {
|
|
125
|
-
render(
|
|
126
|
-
<EditorProvider>
|
|
127
|
-
<ContextHarness />
|
|
128
|
-
</EditorProvider>,
|
|
129
|
-
);
|
|
130
|
-
expect(screen.getByTestId('revision').textContent).toBe('0');
|
|
131
|
-
act(() => {
|
|
132
|
-
fireEvent.click(screen.getByTestId('bump'));
|
|
133
|
-
});
|
|
134
|
-
act(() => {
|
|
135
|
-
fireEvent.click(screen.getByTestId('bump'));
|
|
136
|
-
});
|
|
137
|
-
expect(screen.getByTestId('revision').textContent).toBe('2');
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
// ── Shell + modal harness ────────────────────────────────
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* A floating button that uses `useEditorContext` to dispatch
|
|
145
|
-
* `openImageEdit(path)` from inside the shell — this lets us trigger
|
|
146
|
-
* the modal without spinning up a full Tiptap NodeView.
|
|
147
|
-
*/
|
|
148
|
-
function TriggerButton({ path }: { path: string }) {
|
|
149
|
-
const { openImageEdit } = useEditorContext();
|
|
150
|
-
return (
|
|
151
|
-
<button data-testid="trigger" type="button" onClick={() => openImageEdit(path)}>
|
|
152
|
-
open
|
|
153
|
-
</button>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
async function setupShellWithImage(): Promise<{
|
|
158
|
-
container: MemoryContentContainer;
|
|
159
|
-
mediaProvider: MediaProvider;
|
|
160
|
-
}> {
|
|
161
|
-
const container = new MemoryContentContainer();
|
|
162
|
-
// Seed a 1×1 PNG so resolveUrl returns a fetchable blob URL.
|
|
163
|
-
const onePixel = new Uint8Array([
|
|
164
|
-
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
|
|
165
|
-
]);
|
|
166
|
-
await container.writeFile('hero.png', onePixel.buffer, 'image/png');
|
|
167
|
-
const mediaProvider = createMediaProviderFromContainer(container);
|
|
168
|
-
return { container, mediaProvider };
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
describe('<EditorShell> image-edit modal wiring', () => {
|
|
172
|
-
it('opens the modal when openImageEdit is dispatched and closes via the close button', async () => {
|
|
173
|
-
const { container, mediaProvider } = await setupShellWithImage();
|
|
174
|
-
render(
|
|
175
|
-
<EditorShell
|
|
176
|
-
initialMarkdown="# hi"
|
|
177
|
-
workspaceContainer={container}
|
|
178
|
-
mediaProvider={mediaProvider}
|
|
179
|
-
toolbarSlotRight={<TriggerButton path="hero.png" />}
|
|
180
|
-
/>,
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
expect(screen.queryByTestId('image-edit-modal')).toBeNull();
|
|
184
|
-
|
|
185
|
-
const trigger = screen.getByTestId('trigger');
|
|
186
|
-
trigger.focus();
|
|
187
|
-
await act(async () => {
|
|
188
|
-
fireEvent.click(trigger);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
await waitFor(() => {
|
|
192
|
-
expect(screen.getByTestId('image-edit-modal')).toBeTruthy();
|
|
193
|
-
});
|
|
194
|
-
// Shows the relative path in the header.
|
|
195
|
-
expect(screen.getByText('hero.png')).toBeTruthy();
|
|
196
|
-
expect(document.activeElement).toBe(screen.getByTestId('image-edit-modal-close'));
|
|
197
|
-
|
|
198
|
-
await act(async () => {
|
|
199
|
-
fireEvent.click(screen.getByTestId('image-edit-modal-close'));
|
|
200
|
-
});
|
|
201
|
-
await waitFor(() => {
|
|
202
|
-
expect(screen.queryByTestId('image-edit-modal')).toBeNull();
|
|
203
|
-
});
|
|
204
|
-
expect(document.activeElement).toBe(screen.getByTestId('trigger'));
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it('opens the modal with a transient sidecar when only a mediaProvider is wired (no host container)', async () => {
|
|
208
|
-
const { mediaProvider } = await setupShellWithImage();
|
|
209
|
-
render(
|
|
210
|
-
<EditorShell
|
|
211
|
-
initialMarkdown="# hi"
|
|
212
|
-
mediaProvider={mediaProvider}
|
|
213
|
-
toolbarSlotRight={<TriggerButton path="hero.png" />}
|
|
214
|
-
/>,
|
|
215
|
-
);
|
|
216
|
-
await act(async () => {
|
|
217
|
-
fireEvent.click(screen.getByTestId('trigger'));
|
|
218
|
-
});
|
|
219
|
-
// Modal now mounts even without a host container — the sidecar is
|
|
220
|
-
// backed by a fresh MemoryContentContainer the modal owns.
|
|
221
|
-
await waitFor(() => {
|
|
222
|
-
expect(screen.getByTestId('image-edit-modal')).toBeTruthy();
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it('does NOT mount the modal when no mediaProvider is wired', async () => {
|
|
227
|
-
render(
|
|
228
|
-
<EditorShell initialMarkdown="# hi" toolbarSlotRight={<TriggerButton path="hero.png" />} />,
|
|
229
|
-
);
|
|
230
|
-
await act(async () => {
|
|
231
|
-
fireEvent.click(screen.getByTestId('trigger'));
|
|
232
|
-
});
|
|
233
|
-
// Without a media provider the modal has no way to resolve the source
|
|
234
|
-
// or write the result back — the guard bails out.
|
|
235
|
-
expect(screen.queryByTestId('image-edit-modal')).toBeNull();
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it('writes the exported blob back through mediaProvider.addMedia and closes', async () => {
|
|
239
|
-
const { container, mediaProvider } = await setupShellWithImage();
|
|
240
|
-
const addMediaSpy = vi.spyOn(mediaProvider, 'addMedia');
|
|
241
|
-
|
|
242
|
-
render(
|
|
243
|
-
<EditorShell
|
|
244
|
-
initialMarkdown="# hi"
|
|
245
|
-
workspaceContainer={container}
|
|
246
|
-
mediaProvider={mediaProvider}
|
|
247
|
-
toolbarSlotRight={<TriggerButton path="hero.png" />}
|
|
248
|
-
/>,
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
await act(async () => {
|
|
252
|
-
fireEvent.click(screen.getByTestId('trigger'));
|
|
253
|
-
});
|
|
254
|
-
await waitFor(() => {
|
|
255
|
-
expect(screen.getByTestId('image-edit-modal')).toBeTruthy();
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
// Drive the export path directly via mediaProvider.addMedia — the
|
|
259
|
-
// modal's onExport handler does exactly this. We don't try to
|
|
260
|
-
// pump the inner ImageEditor's Export button (it depends on async
|
|
261
|
-
// sidecar seeding that's heavy to wait through here).
|
|
262
|
-
// Pass raw bytes (a Uint8Array) — jsdom's Blob lacks `arrayBuffer()`,
|
|
263
|
-
// and a fake-Blob stub doesn't satisfy `instanceof Blob`, so the
|
|
264
|
-
// simplest payload is the Uint8Array branch addMedia already supports.
|
|
265
|
-
const bytes = new Uint8Array([1, 2, 3]);
|
|
266
|
-
await act(async () => {
|
|
267
|
-
await mediaProvider.addMedia('hero.png', bytes, 'image/png');
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
expect(addMediaSpy).toHaveBeenCalledWith('hero.png', bytes, 'image/png');
|
|
271
|
-
});
|
|
272
|
-
});
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/** @vitest-environment jsdom */
|
|
2
|
-
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
-
import type { ContentContainer } from '@bendyline/squisq/storage';
|
|
5
|
-
import { MemoryContentContainer } from '@bendyline/squisq/storage';
|
|
6
|
-
import type { MediaProvider } from '@bendyline/squisq/schemas';
|
|
7
|
-
import { useEditorContext } from '../EditorContext';
|
|
8
|
-
|
|
9
|
-
const imageEditorProps: Array<{
|
|
10
|
-
filesContainer: ContentContainer;
|
|
11
|
-
saveFormat: 'png' | 'jpeg' | 'webp';
|
|
12
|
-
onExport: (blob: Blob, format: 'png' | 'jpeg' | 'webp') => void;
|
|
13
|
-
}> = [];
|
|
14
|
-
|
|
15
|
-
vi.mock('../ImageEditor', () => ({
|
|
16
|
-
ImageEditor: (props: (typeof imageEditorProps)[number]) => {
|
|
17
|
-
imageEditorProps.push(props);
|
|
18
|
-
return <div data-testid="image-editor-contract-stub" />;
|
|
19
|
-
},
|
|
20
|
-
}));
|
|
21
|
-
vi.mock('../RawEditor', () => ({ RawEditor: () => <div /> }));
|
|
22
|
-
vi.mock('../WysiwygEditor', () => ({ WysiwygEditor: () => <div /> }));
|
|
23
|
-
vi.mock('../PreviewPanel', () => ({ PreviewPanel: () => <div /> }));
|
|
24
|
-
|
|
25
|
-
import { EditorShell } from '../EditorShell';
|
|
26
|
-
|
|
27
|
-
function Trigger({ path }: { path: string }) {
|
|
28
|
-
const { openImageEdit } = useEditorContext();
|
|
29
|
-
return <button onClick={() => openImageEdit(path)}>edit</button>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function provider(): MediaProvider {
|
|
33
|
-
return {
|
|
34
|
-
addMedia: vi.fn(async (name: string) => name),
|
|
35
|
-
resolveUrl: vi.fn(async (name: string) => `blob:${name}`),
|
|
36
|
-
listMedia: vi.fn(async () => []),
|
|
37
|
-
removeMedia: vi.fn(async () => {}),
|
|
38
|
-
dispose: vi.fn(),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
beforeEach(() => {
|
|
43
|
-
imageEditorProps.length = 0;
|
|
44
|
-
if (typeof window.matchMedia !== 'function') {
|
|
45
|
-
Object.defineProperty(window, 'matchMedia', {
|
|
46
|
-
configurable: true,
|
|
47
|
-
value: () => ({ matches: false, addEventListener() {}, removeEventListener() {} }),
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe('ImageEditModal storage contract', () => {
|
|
53
|
-
it('writes JPEG bytes/MIME back to a .jpg path', async () => {
|
|
54
|
-
const mediaProvider = provider();
|
|
55
|
-
render(
|
|
56
|
-
<EditorShell
|
|
57
|
-
initialMarkdown="# image"
|
|
58
|
-
mediaProvider={mediaProvider}
|
|
59
|
-
toolbarSlotRight={<Trigger path="photo.jpg" />}
|
|
60
|
-
/>,
|
|
61
|
-
);
|
|
62
|
-
fireEvent.click(screen.getByText('edit'));
|
|
63
|
-
await waitFor(() => expect(screen.getByTestId('image-editor-contract-stub')).toBeTruthy());
|
|
64
|
-
const props = imageEditorProps[imageEditorProps.length - 1]!;
|
|
65
|
-
expect(props.saveFormat).toBe('jpeg');
|
|
66
|
-
await act(async () => props.onExport(new Blob(['jpeg']), 'jpeg'));
|
|
67
|
-
expect(mediaProvider.addMedia).toHaveBeenCalledWith(
|
|
68
|
-
'photo.jpg',
|
|
69
|
-
expect.any(Blob),
|
|
70
|
-
'image/jpeg',
|
|
71
|
-
);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('hashes sidecar paths so sanitized-name collisions remain separate', async () => {
|
|
75
|
-
const parent = new MemoryContentContainer();
|
|
76
|
-
const mediaProvider = provider();
|
|
77
|
-
const first = render(
|
|
78
|
-
<EditorShell
|
|
79
|
-
initialMarkdown="# image"
|
|
80
|
-
workspaceContainer={parent}
|
|
81
|
-
mediaProvider={mediaProvider}
|
|
82
|
-
toolbarSlotRight={<Trigger path="a/b.png" />}
|
|
83
|
-
/>,
|
|
84
|
-
);
|
|
85
|
-
fireEvent.click(screen.getByText('edit'));
|
|
86
|
-
await waitFor(() => expect(imageEditorProps).toHaveLength(1));
|
|
87
|
-
const firstContainer = imageEditorProps[0].filesContainer;
|
|
88
|
-
first.unmount();
|
|
89
|
-
|
|
90
|
-
render(
|
|
91
|
-
<EditorShell
|
|
92
|
-
initialMarkdown="# image"
|
|
93
|
-
workspaceContainer={parent}
|
|
94
|
-
mediaProvider={mediaProvider}
|
|
95
|
-
toolbarSlotRight={<Trigger path="a_b.png" />}
|
|
96
|
-
/>,
|
|
97
|
-
);
|
|
98
|
-
fireEvent.click(screen.getByText('edit'));
|
|
99
|
-
await waitFor(() => expect(imageEditorProps).toHaveLength(2));
|
|
100
|
-
const secondContainer = imageEditorProps[1].filesContainer;
|
|
101
|
-
await firstContainer.writeFile('sentinel', new Uint8Array([1]).buffer);
|
|
102
|
-
await secondContainer.writeFile('sentinel', new Uint8Array([2]).buffer);
|
|
103
|
-
const paths = (await parent.listFiles('.imageEdits')).map((entry) => entry.path);
|
|
104
|
-
expect(paths.filter((path) => path.endsWith('/sentinel'))).toHaveLength(2);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('refuses unsupported source formats instead of writing mismatched bytes', async () => {
|
|
108
|
-
render(
|
|
109
|
-
<EditorShell
|
|
110
|
-
initialMarkdown="# image"
|
|
111
|
-
mediaProvider={provider()}
|
|
112
|
-
toolbarSlotRight={<Trigger path="animated.gif" />}
|
|
113
|
-
/>,
|
|
114
|
-
);
|
|
115
|
-
fireEvent.click(screen.getByText('edit'));
|
|
116
|
-
await waitFor(() => expect(screen.getByText(/supports PNG, JPEG, and WebP/i)).toBeTruthy());
|
|
117
|
-
expect(screen.queryByTestId('image-editor-contract-stub')).toBeNull();
|
|
118
|
-
});
|
|
119
|
-
});
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @vitest-environment jsdom
|
|
3
|
-
*
|
|
4
|
-
* High-level smoke test for the `<ImageEditor>` shell — verifies it
|
|
5
|
-
* mounts against a sidecar container, finishes its initial seed, and
|
|
6
|
-
* renders the toolbar / canvas / panels.
|
|
7
|
-
*/
|
|
8
|
-
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
9
|
-
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
10
|
-
import { MemoryContentContainer, scopeContainer } from '@bendyline/squisq/storage';
|
|
11
|
-
import { writeImageEditDoc, createEmptyImageEditDoc } from '@bendyline/squisq/imageEdit';
|
|
12
|
-
import { DARK_SURFACE } from '@bendyline/squisq/schemas';
|
|
13
|
-
import { ImageEditor } from '../ImageEditor.js';
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
if (typeof URL.createObjectURL !== 'function') {
|
|
17
|
-
Object.defineProperty(URL, 'createObjectURL', {
|
|
18
|
-
configurable: true,
|
|
19
|
-
value: vi.fn(() => 'blob:stub'),
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
if (typeof URL.revokeObjectURL !== 'function') {
|
|
23
|
-
Object.defineProperty(URL, 'revokeObjectURL', {
|
|
24
|
-
configurable: true,
|
|
25
|
-
value: vi.fn(),
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('<ImageEditor>', () => {
|
|
31
|
-
it('mounts an existing state.json and shows toolbar / layers / properties', async () => {
|
|
32
|
-
const parent = new MemoryContentContainer();
|
|
33
|
-
const sidecar = scopeContainer(parent, 'pic_files');
|
|
34
|
-
await writeImageEditDoc(sidecar, createEmptyImageEditDoc(64, 48));
|
|
35
|
-
|
|
36
|
-
render(<ImageEditor filesContainer={sidecar} />);
|
|
37
|
-
|
|
38
|
-
await waitFor(() => {
|
|
39
|
-
expect(screen.getByTestId('image-editor')).toBeTruthy();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
expect(screen.getByTestId('image-editor-toolbar')).toBeTruthy();
|
|
43
|
-
expect(screen.getByTestId('image-editor-layers')).toBeTruthy();
|
|
44
|
-
expect(screen.getByTestId('image-editor-properties')).toBeTruthy();
|
|
45
|
-
|
|
46
|
-
// SVG canvas viewBox reflects the doc dimensions.
|
|
47
|
-
const svg = document.querySelector('svg.squisq-image-editor-canvas');
|
|
48
|
-
expect(svg).not.toBeNull();
|
|
49
|
-
expect(svg!.getAttribute('viewBox')).toBe('0 0 64 48');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('shows the loading state before the seed completes', () => {
|
|
53
|
-
const parent = new MemoryContentContainer();
|
|
54
|
-
const sidecar = scopeContainer(parent, 'pic_files');
|
|
55
|
-
render(<ImageEditor filesContainer={sidecar} />);
|
|
56
|
-
expect(screen.getByText(/loading image editor/i)).toBeTruthy();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('adds a centered shape layer from the Layers panel menu', async () => {
|
|
60
|
-
const parent = new MemoryContentContainer();
|
|
61
|
-
const sidecar = scopeContainer(parent, 'pic_files');
|
|
62
|
-
await writeImageEditDoc(sidecar, createEmptyImageEditDoc(640, 480));
|
|
63
|
-
|
|
64
|
-
render(<ImageEditor filesContainer={sidecar} />);
|
|
65
|
-
await waitFor(() => expect(screen.getByTestId('image-editor')).toBeTruthy());
|
|
66
|
-
|
|
67
|
-
fireEvent.click(screen.getByRole('button', { name: 'Add layer' }));
|
|
68
|
-
fireEvent.click(screen.getByRole('menuitem', { name: 'Shape layer' }));
|
|
69
|
-
|
|
70
|
-
await waitFor(() => expect(screen.getByTitle('Rectangle')).toBeTruthy());
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('applies an explicit dark surface to the editor chrome', async () => {
|
|
74
|
-
const parent = new MemoryContentContainer();
|
|
75
|
-
const sidecar = scopeContainer(parent, 'pic_files');
|
|
76
|
-
await writeImageEditDoc(sidecar, createEmptyImageEditDoc(64, 48));
|
|
77
|
-
|
|
78
|
-
render(<ImageEditor filesContainer={sidecar} surface={DARK_SURFACE} />);
|
|
79
|
-
|
|
80
|
-
await waitFor(() => {
|
|
81
|
-
expect(screen.getByTestId('image-editor')).toBeTruthy();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const editor = screen.getByTestId('image-editor');
|
|
85
|
-
expect(editor.style.getPropertyValue('--squisq-image-editor-bg')).toBe(DARK_SURFACE.background);
|
|
86
|
-
expect(editor.style.getPropertyValue('--squisq-image-editor-text')).toBe(DARK_SURFACE.text);
|
|
87
|
-
expect(editor.style.getPropertyValue('--squisq-image-editor-panel-bg')).toBe(
|
|
88
|
-
`color-mix(in srgb, ${DARK_SURFACE.background} 92%, ${DARK_SURFACE.text} 8%)`,
|
|
89
|
-
);
|
|
90
|
-
expect(editor.style.getPropertyValue('--squisq-image-editor-control-bg')).toBe(
|
|
91
|
-
`color-mix(in srgb, ${DARK_SURFACE.background} 86%, ${DARK_SURFACE.text} 14%)`,
|
|
92
|
-
);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import type { ImageEditDoc, ImageEditLayer } from '@bendyline/squisq/schemas';
|
|
3
|
-
import { createEmptyImageEditDoc } from '@bendyline/squisq/imageEdit';
|
|
4
|
-
import {
|
|
5
|
-
imageEditorReducer,
|
|
6
|
-
initialImageEditorState,
|
|
7
|
-
type ImageEditorState,
|
|
8
|
-
type ImageEditorAction,
|
|
9
|
-
} from '../imageEditor/state.js';
|
|
10
|
-
|
|
11
|
-
function bootstrap(): ImageEditorState {
|
|
12
|
-
const doc = createEmptyImageEditDoc(400, 300);
|
|
13
|
-
// touch sets updatedAt — clear it for stable comparisons
|
|
14
|
-
return initialImageEditorState(doc);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function dispatchAll(state: ImageEditorState, actions: ImageEditorAction[]): ImageEditorState {
|
|
18
|
-
return actions.reduce((s, a) => imageEditorReducer(s, a), state);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
describe('imageEditorReducer', () => {
|
|
22
|
-
it('initial state is clean and selects no layer', () => {
|
|
23
|
-
const s = bootstrap();
|
|
24
|
-
expect(s.dirty).toBe(false);
|
|
25
|
-
expect(s.selectedLayerId).toBe(null);
|
|
26
|
-
expect(s.tool).toBe('select');
|
|
27
|
-
expect(s.doc.canvas.width).toBe(400);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('add-layer assigns an id, marks dirty, and selects by default', () => {
|
|
31
|
-
const s0 = bootstrap();
|
|
32
|
-
const s1 = imageEditorReducer(s0, {
|
|
33
|
-
type: 'add-layer',
|
|
34
|
-
layer: {
|
|
35
|
-
type: 'shape',
|
|
36
|
-
position: { x: 0, y: 0, width: 50, height: 50 },
|
|
37
|
-
content: { shape: 'rect', fill: '#fff' },
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
expect(s1.dirty).toBe(true);
|
|
41
|
-
expect(s1.doc.layers).toHaveLength(1);
|
|
42
|
-
const added = s1.doc.layers[0]!;
|
|
43
|
-
expect(added.id).toMatch(/^layer-/);
|
|
44
|
-
expect(s1.selectedLayerId).toBe(added.id);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('add-layer with select:false leaves selection untouched', () => {
|
|
48
|
-
const s = imageEditorReducer(bootstrap(), {
|
|
49
|
-
type: 'add-layer',
|
|
50
|
-
select: false,
|
|
51
|
-
layer: {
|
|
52
|
-
type: 'shape',
|
|
53
|
-
position: { x: 0, y: 0, width: 1, height: 1 },
|
|
54
|
-
content: { shape: 'rect' },
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
expect(s.selectedLayerId).toBe(null);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('remove-layer drops the layer and clears selection if it was selected', () => {
|
|
61
|
-
const s1 = imageEditorReducer(bootstrap(), {
|
|
62
|
-
type: 'add-layer',
|
|
63
|
-
layer: {
|
|
64
|
-
type: 'shape',
|
|
65
|
-
position: { x: 0, y: 0, width: 1, height: 1 },
|
|
66
|
-
content: { shape: 'rect' },
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
const id = s1.doc.layers[0]!.id;
|
|
70
|
-
const s2 = imageEditorReducer(s1, { type: 'remove-layer', layerId: id });
|
|
71
|
-
expect(s2.doc.layers).toHaveLength(0);
|
|
72
|
-
expect(s2.selectedLayerId).toBe(null);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('update-layer applies a shallow patch', () => {
|
|
76
|
-
const s1 = imageEditorReducer(bootstrap(), {
|
|
77
|
-
type: 'add-layer',
|
|
78
|
-
layer: {
|
|
79
|
-
type: 'shape',
|
|
80
|
-
position: { x: 10, y: 10, width: 20, height: 20 },
|
|
81
|
-
content: { shape: 'rect' },
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
const id = s1.doc.layers[0]!.id;
|
|
85
|
-
const s2 = imageEditorReducer(s1, {
|
|
86
|
-
type: 'update-layer',
|
|
87
|
-
layerId: id,
|
|
88
|
-
patch: { name: 'Box', opacity: 0.5 },
|
|
89
|
-
});
|
|
90
|
-
const layer = s2.doc.layers[0]!;
|
|
91
|
-
expect(layer.name).toBe('Box');
|
|
92
|
-
expect(layer.opacity).toBe(0.5);
|
|
93
|
-
// Untouched fields are preserved.
|
|
94
|
-
expect(layer.position).toEqual({ x: 10, y: 10, width: 20, height: 20 });
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('reorder-layer moves a layer to the requested index', () => {
|
|
98
|
-
let s = bootstrap();
|
|
99
|
-
s = dispatchAll(s, [
|
|
100
|
-
{ type: 'add-layer', layer: shape('a') },
|
|
101
|
-
{ type: 'add-layer', layer: shape('b') },
|
|
102
|
-
{ type: 'add-layer', layer: shape('c') },
|
|
103
|
-
]);
|
|
104
|
-
const ids = s.doc.layers.map((l) => l.id);
|
|
105
|
-
// Move the first layer to the top of the stack.
|
|
106
|
-
const s2 = imageEditorReducer(s, { type: 'reorder-layer', layerId: ids[0]!, toIndex: 2 });
|
|
107
|
-
expect(s2.doc.layers.map((l) => l.id)).toEqual([ids[1], ids[2], ids[0]]);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('crop translates layer positions into the new origin and resizes the canvas', () => {
|
|
111
|
-
let s = bootstrap();
|
|
112
|
-
s = imageEditorReducer(s, {
|
|
113
|
-
type: 'add-layer',
|
|
114
|
-
layer: {
|
|
115
|
-
type: 'shape',
|
|
116
|
-
position: { x: 100, y: 80, width: 50, height: 50 },
|
|
117
|
-
content: { shape: 'rect' },
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
const s2 = imageEditorReducer(s, {
|
|
121
|
-
type: 'crop',
|
|
122
|
-
rect: { x: 50, y: 50, width: 200, height: 150 },
|
|
123
|
-
});
|
|
124
|
-
expect(s2.doc.canvas.width).toBe(200);
|
|
125
|
-
expect(s2.doc.canvas.height).toBe(150);
|
|
126
|
-
const layer = s2.doc.layers[0]!;
|
|
127
|
-
expect(layer.position.x).toBe(50);
|
|
128
|
-
expect(layer.position.y).toBe(30);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('mark-clean clears the dirty flag without touching the doc', () => {
|
|
132
|
-
let s = bootstrap();
|
|
133
|
-
s = imageEditorReducer(s, { type: 'set-canvas', canvas: { width: 1, height: 1 } });
|
|
134
|
-
expect(s.dirty).toBe(true);
|
|
135
|
-
const docRef = s.doc;
|
|
136
|
-
s = imageEditorReducer(s, { type: 'mark-clean' });
|
|
137
|
-
expect(s.dirty).toBe(false);
|
|
138
|
-
expect(s.doc).toBe(docRef);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('select / set-tool do not mark the doc dirty', () => {
|
|
142
|
-
const s0 = imageEditorReducer(bootstrap(), {
|
|
143
|
-
type: 'add-layer',
|
|
144
|
-
layer: shape('x'),
|
|
145
|
-
});
|
|
146
|
-
const s1 = imageEditorReducer(
|
|
147
|
-
{ ...s0, dirty: false },
|
|
148
|
-
{
|
|
149
|
-
type: 'select',
|
|
150
|
-
layerId: s0.doc.layers[0]!.id,
|
|
151
|
-
},
|
|
152
|
-
);
|
|
153
|
-
expect(s1.dirty).toBe(false);
|
|
154
|
-
const s2 = imageEditorReducer(s1, { type: 'set-tool', tool: 'crop' });
|
|
155
|
-
expect(s2.dirty).toBe(false);
|
|
156
|
-
expect(s2.tool).toBe('crop');
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
function shape(name: string): ImageEditLayer {
|
|
161
|
-
return {
|
|
162
|
-
id: '', // assigned by reducer
|
|
163
|
-
type: 'shape',
|
|
164
|
-
name,
|
|
165
|
-
position: { x: 0, y: 0, width: 10, height: 10 },
|
|
166
|
-
content: { shape: 'rect' },
|
|
167
|
-
} as ImageEditLayer;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Make the test module type-check without unused import warnings.
|
|
171
|
-
export type _Unused = ImageEditDoc;
|