@bendyline/squisq-editor-react 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE.md +40 -0
- package/dist/index.d.ts +188 -55
- package/dist/index.js +5094 -2948
- package/dist/monaco.js +0 -1
- package/dist/styles/index.css +234 -145
- package/package.json +9 -6
- 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,62 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { EditorProvider } from '../EditorContext';
|
|
4
|
-
import { InlinePreviewGutter } from '../InlinePreviewGutter';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The gutter pulls its data from the EditorContext's parsed Doc. We mount
|
|
8
|
-
* it against a real provider seeded with markdown that contains both an
|
|
9
|
-
* annotated heading (`{[title]}`) and a plain heading. The first
|
|
10
|
-
* should produce a card; the second should be ignored.
|
|
11
|
-
*
|
|
12
|
-
* We deliberately don't snapshot the SVG — the BlockRenderer covers that
|
|
13
|
-
* elsewhere. Here we just assert (a) the gutter mounts, (b) it renders
|
|
14
|
-
* one card per annotated block, and (c) the empty state shows when there
|
|
15
|
-
* are no annotated blocks.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
function renderGutter(markdown: string) {
|
|
19
|
-
return render(
|
|
20
|
-
<EditorProvider initialMarkdown={markdown} initialView="wysiwyg" articleId="test">
|
|
21
|
-
<InlinePreviewGutter />
|
|
22
|
-
</EditorProvider>,
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
describe('InlinePreviewGutter', () => {
|
|
27
|
-
it('renders the empty state when no blocks are template-annotated', async () => {
|
|
28
|
-
renderGutter('# Plain heading\n\nSome body text.\n');
|
|
29
|
-
expect(await screen.findByText(/tag a heading with a template/i)).toBeTruthy();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('renders one card per template-annotated block', async () => {
|
|
33
|
-
const md = [
|
|
34
|
-
'# Welcome {[title]}',
|
|
35
|
-
'',
|
|
36
|
-
'Subtitle goes here.',
|
|
37
|
-
'',
|
|
38
|
-
'## Plain heading',
|
|
39
|
-
'',
|
|
40
|
-
'No template tag — should not produce a card.',
|
|
41
|
-
'',
|
|
42
|
-
'## Big number {[statHighlight]}',
|
|
43
|
-
'',
|
|
44
|
-
'42',
|
|
45
|
-
].join('\n');
|
|
46
|
-
|
|
47
|
-
const { container } = renderGutter(md);
|
|
48
|
-
|
|
49
|
-
// Two annotated headings → two cards.
|
|
50
|
-
await screen.findByTestId('inline-preview-gutter');
|
|
51
|
-
const cards = container.querySelectorAll('.squisq-inline-preview-card');
|
|
52
|
-
expect(cards.length).toBe(2);
|
|
53
|
-
|
|
54
|
-
// Template labels are rendered alongside each card.
|
|
55
|
-
const labels = Array.from(
|
|
56
|
-
container.querySelectorAll('.squisq-inline-preview-card-template'),
|
|
57
|
-
).map((el) => el.textContent);
|
|
58
|
-
// Templates render their human-readable label (via `templateLabel`).
|
|
59
|
-
expect(labels).toContain('Title');
|
|
60
|
-
expect(labels).toContain('Stat Highlight');
|
|
61
|
-
});
|
|
62
|
-
});
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, beforeAll } from 'vitest';
|
|
2
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import { EditorProvider } from '../EditorContext';
|
|
4
|
-
import { InlinePreviewGutter } from '../InlinePreviewGutter';
|
|
5
|
-
|
|
6
|
-
// jsdom lacks ResizeObserver — the gutter's heading-layout hook wires one
|
|
7
|
-
// up to recompute on editor resizes. Stub a no-op for these tests.
|
|
8
|
-
beforeAll(() => {
|
|
9
|
-
if (typeof globalThis.ResizeObserver === 'undefined') {
|
|
10
|
-
globalThis.ResizeObserver = class {
|
|
11
|
-
observe() {}
|
|
12
|
-
unobserve() {}
|
|
13
|
-
disconnect() {}
|
|
14
|
-
} as unknown as typeof ResizeObserver;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The gutter pulls heading data from the parsed Doc (via `useHeadingLayout`)
|
|
20
|
-
* and pairs it to DOM headings inside the `.squisq-wysiwyg-container`.
|
|
21
|
-
* To exercise the all-blocks bracket logic we provide both: real markdown
|
|
22
|
-
* (so the parser populates `doc.blocks`) AND a sibling stub container with
|
|
23
|
-
* matching `<h*>` elements (so the DOM-pairing path finds something to
|
|
24
|
-
* measure).
|
|
25
|
-
*/
|
|
26
|
-
function renderWithMatchingDom(markdown: string, headingHtml: string) {
|
|
27
|
-
return render(
|
|
28
|
-
<EditorProvider initialMarkdown={markdown} initialView="wysiwyg" articleId="test">
|
|
29
|
-
<div className="squisq-editor-with-gutter" style={{ position: 'relative', height: 600 }}>
|
|
30
|
-
<div
|
|
31
|
-
className="squisq-wysiwyg-container"
|
|
32
|
-
style={{ position: 'relative', width: 800, height: 600 }}
|
|
33
|
-
>
|
|
34
|
-
<div
|
|
35
|
-
className="squisq-wysiwyg-editor"
|
|
36
|
-
dangerouslySetInnerHTML={{ __html: headingHtml }}
|
|
37
|
-
/>
|
|
38
|
-
</div>
|
|
39
|
-
<InlinePreviewGutter />
|
|
40
|
-
</div>
|
|
41
|
-
</EditorProvider>,
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
describe('InlinePreviewGutter — all-block bracket lines', () => {
|
|
46
|
-
it('renders a vertical-extent bar per heading even when none are annotated', async () => {
|
|
47
|
-
const md = '# Hello World\n\nBody\n\n## Getting Started\n\nBody\n\n## Tips\n\nBody\n';
|
|
48
|
-
const { container } = renderWithMatchingDom(
|
|
49
|
-
md,
|
|
50
|
-
'<h1>Hello World</h1>' +
|
|
51
|
-
'<p>Body</p>' +
|
|
52
|
-
'<h2>Getting Started</h2>' +
|
|
53
|
-
'<p>Body</p>' +
|
|
54
|
-
'<h2>Tips</h2>' +
|
|
55
|
-
'<p>Body</p>',
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
await waitFor(
|
|
59
|
-
() => {
|
|
60
|
-
const bars = container.querySelectorAll('.squisq-inline-preview-extent');
|
|
61
|
-
expect(bars.length).toBe(3);
|
|
62
|
-
},
|
|
63
|
-
{ timeout: 1000 },
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
// All three should be the untagged variant (no `data-template` on any).
|
|
67
|
-
const bars = container.querySelectorAll('.squisq-inline-preview-extent');
|
|
68
|
-
bars.forEach((bar) =>
|
|
69
|
-
expect(bar.classList.contains('squisq-inline-preview-extent--untagged')).toBe(true),
|
|
70
|
-
);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('renders a strong tagged bar for annotated headings + lighter bars for the rest', async () => {
|
|
74
|
-
const md = '# Welcome\n\n## Getting Started {[sectionHeader]}\n\n## Tips\n';
|
|
75
|
-
const { container } = renderWithMatchingDom(
|
|
76
|
-
md,
|
|
77
|
-
'<h1>Welcome</h1>' +
|
|
78
|
-
'<h2 data-template="sectionHeader">Getting Started</h2>' +
|
|
79
|
-
'<h2>Tips</h2>',
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
await waitFor(
|
|
83
|
-
() => {
|
|
84
|
-
const bars = container.querySelectorAll('.squisq-inline-preview-extent');
|
|
85
|
-
expect(bars.length).toBe(3);
|
|
86
|
-
},
|
|
87
|
-
{ timeout: 1000 },
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const bars = Array.from(container.querySelectorAll('.squisq-inline-preview-extent'));
|
|
91
|
-
const tagged = bars.filter(
|
|
92
|
-
(b) => !b.classList.contains('squisq-inline-preview-extent--untagged'),
|
|
93
|
-
);
|
|
94
|
-
const untagged = bars.filter((b) =>
|
|
95
|
-
b.classList.contains('squisq-inline-preview-extent--untagged'),
|
|
96
|
-
);
|
|
97
|
-
expect(tagged.length).toBe(1);
|
|
98
|
-
expect(untagged.length).toBe(2);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// `screen` import unused but kept to mirror the sibling test file's style.
|
|
103
|
-
void screen;
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
4
|
-
import type { SquisqAnnotatedSchema } from '@bendyline/squisq/jsonForm';
|
|
5
|
-
import { JsonEditor } from '../jsonEditor';
|
|
6
|
-
|
|
7
|
-
function Controlled<T>({
|
|
8
|
-
schema,
|
|
9
|
-
initial,
|
|
10
|
-
onValueChange,
|
|
11
|
-
}: {
|
|
12
|
-
schema: SquisqAnnotatedSchema;
|
|
13
|
-
initial: T;
|
|
14
|
-
onValueChange?: (next: T) => void;
|
|
15
|
-
}) {
|
|
16
|
-
const [value, setValue] = useState<T>(initial);
|
|
17
|
-
return (
|
|
18
|
-
<JsonEditor
|
|
19
|
-
schema={schema}
|
|
20
|
-
value={value}
|
|
21
|
-
onChange={(v) => {
|
|
22
|
-
setValue(v as T);
|
|
23
|
-
onValueChange?.(v as T);
|
|
24
|
-
}}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
describe('JsonEditor', () => {
|
|
30
|
-
it('renders text input and propagates edits through onChange', () => {
|
|
31
|
-
const schema: SquisqAnnotatedSchema = {
|
|
32
|
-
type: 'object',
|
|
33
|
-
properties: { title: { type: 'string', title: 'Title' } },
|
|
34
|
-
};
|
|
35
|
-
const onChange = vi.fn();
|
|
36
|
-
render(<Controlled schema={schema} initial={{ title: 'Hi' }} onValueChange={onChange} />);
|
|
37
|
-
const input = screen.getByDisplayValue('Hi') as HTMLInputElement;
|
|
38
|
-
fireEvent.change(input, { target: { value: 'Hello' } });
|
|
39
|
-
expect(onChange).toHaveBeenLastCalledWith({ title: 'Hello' });
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('toggles a boolean via the toggle control', () => {
|
|
43
|
-
const schema: SquisqAnnotatedSchema = {
|
|
44
|
-
type: 'object',
|
|
45
|
-
properties: { active: { type: 'boolean', title: 'Active' } },
|
|
46
|
-
};
|
|
47
|
-
const onChange = vi.fn();
|
|
48
|
-
render(<Controlled schema={schema} initial={{ active: false }} onValueChange={onChange} />);
|
|
49
|
-
const button = screen.getByRole('button', { pressed: false });
|
|
50
|
-
fireEvent.click(button);
|
|
51
|
-
expect(onChange).toHaveBeenLastCalledWith({ active: true });
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('hides fields whose hidden rule matches', () => {
|
|
55
|
-
const schema: SquisqAnnotatedSchema = {
|
|
56
|
-
type: 'object',
|
|
57
|
-
properties: {
|
|
58
|
-
showAuthor: { type: 'boolean', title: 'Show author' },
|
|
59
|
-
authorName: {
|
|
60
|
-
type: 'string',
|
|
61
|
-
title: 'Author name',
|
|
62
|
-
squisq: { hidden: { field: 'showAuthor', truthy: false } },
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
const { container } = render(
|
|
67
|
-
<Controlled schema={schema} initial={{ showAuthor: false, authorName: 'Alex' }} />,
|
|
68
|
-
);
|
|
69
|
-
expect(container.textContent).not.toContain('Author name');
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('selecting a different segmented option commits the new enum value', () => {
|
|
73
|
-
const schema: SquisqAnnotatedSchema = {
|
|
74
|
-
type: 'object',
|
|
75
|
-
properties: {
|
|
76
|
-
size: { type: 'string', title: 'Size', enum: ['s', 'm', 'l'] },
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
const onChange = vi.fn();
|
|
80
|
-
render(<Controlled schema={schema} initial={{ size: 's' }} onValueChange={onChange} />);
|
|
81
|
-
fireEvent.click(screen.getByRole('button', { name: 'l' }));
|
|
82
|
-
expect(onChange).toHaveBeenLastCalledWith({ size: 'l' });
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('card-stack: + Add appends, × Remove removes, ↑↓ reorder', () => {
|
|
86
|
-
const schema: SquisqAnnotatedSchema = {
|
|
87
|
-
type: 'object',
|
|
88
|
-
properties: {
|
|
89
|
-
sections: {
|
|
90
|
-
type: 'array',
|
|
91
|
-
title: 'Sections',
|
|
92
|
-
items: {
|
|
93
|
-
type: 'object',
|
|
94
|
-
properties: { heading: { type: 'string' } },
|
|
95
|
-
squisq: { itemLabel: { fromField: 'heading' } },
|
|
96
|
-
},
|
|
97
|
-
squisq: { control: 'card-stack', addLabel: '+ Add section' },
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
const onChange = vi.fn();
|
|
102
|
-
render(
|
|
103
|
-
<Controlled
|
|
104
|
-
schema={schema}
|
|
105
|
-
initial={{ sections: [{ heading: 'A' }, { heading: 'B' }] }}
|
|
106
|
-
onValueChange={onChange}
|
|
107
|
-
/>,
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
// + Add appends a new empty item.
|
|
111
|
-
fireEvent.click(screen.getByText('+ Add section'));
|
|
112
|
-
expect(onChange).toHaveBeenLastCalledWith({
|
|
113
|
-
sections: [{ heading: 'A' }, { heading: 'B' }, { heading: '' }],
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
// × on the first card removes it.
|
|
117
|
-
const removeButtons = screen.getAllByLabelText('Remove');
|
|
118
|
-
fireEvent.click(removeButtons[0]);
|
|
119
|
-
expect(onChange).toHaveBeenLastCalledWith({
|
|
120
|
-
sections: [{ heading: 'B' }, { heading: '' }],
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// ↓ on the first card reorders.
|
|
124
|
-
const downs = screen.getAllByLabelText('Move down');
|
|
125
|
-
fireEvent.click(downs[0]);
|
|
126
|
-
expect(onChange).toHaveBeenLastCalledWith({
|
|
127
|
-
sections: [{ heading: '' }, { heading: 'B' }],
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('chip-bin: typing + Enter appends, × removes', () => {
|
|
132
|
-
const schema: SquisqAnnotatedSchema = {
|
|
133
|
-
type: 'object',
|
|
134
|
-
properties: {
|
|
135
|
-
tags: {
|
|
136
|
-
type: 'array',
|
|
137
|
-
items: { type: 'string' },
|
|
138
|
-
squisq: { control: 'chip-bin', addLabel: '+ Add tag' },
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
const onChange = vi.fn();
|
|
143
|
-
render(<Controlled schema={schema} initial={{ tags: ['one'] }} onValueChange={onChange} />);
|
|
144
|
-
|
|
145
|
-
const addInput = screen.getByPlaceholderText('+ Add tag');
|
|
146
|
-
fireEvent.change(addInput, { target: { value: 'two' } });
|
|
147
|
-
fireEvent.keyDown(addInput, { key: 'Enter' });
|
|
148
|
-
expect(onChange).toHaveBeenLastCalledWith({ tags: ['one', 'two'] });
|
|
149
|
-
|
|
150
|
-
fireEvent.click(screen.getByLabelText('Remove one'));
|
|
151
|
-
expect(onChange).toHaveBeenLastCalledWith({ tags: ['two'] });
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('omitting onChange disables every editor', () => {
|
|
155
|
-
const schema: SquisqAnnotatedSchema = {
|
|
156
|
-
type: 'object',
|
|
157
|
-
properties: { title: { type: 'string', title: 'Title' } },
|
|
158
|
-
};
|
|
159
|
-
const onChange = vi.fn();
|
|
160
|
-
// Use a sniffer onChange we can verify is never called by simulating an
|
|
161
|
-
// attempted change. We render WITHOUT passing onChange to JsonEditor.
|
|
162
|
-
render(<JsonEditor schema={schema} value={{ title: 'Hi' }} />);
|
|
163
|
-
const input = screen.getByDisplayValue('Hi') as HTMLInputElement;
|
|
164
|
-
expect(input.disabled).toBe(true);
|
|
165
|
-
fireEvent.change(input, { target: { value: 'changed' } });
|
|
166
|
-
expect(onChange).not.toHaveBeenCalled();
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('escapes object property names as RFC 6901 pointer segments', () => {
|
|
170
|
-
const schema: SquisqAnnotatedSchema = {
|
|
171
|
-
type: 'object',
|
|
172
|
-
properties: { 'a/b~c': { type: 'string', title: 'Odd key' } },
|
|
173
|
-
};
|
|
174
|
-
const onChange = vi.fn();
|
|
175
|
-
render(<Controlled schema={schema} initial={{ 'a/b~c': 'before' }} onValueChange={onChange} />);
|
|
176
|
-
fireEvent.change(screen.getByLabelText('Odd key'), { target: { value: 'after' } });
|
|
177
|
-
expect(onChange).toHaveBeenLastCalledWith({ 'a/b~c': 'after' });
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it('associates labels/help/errors and reports validation after render', async () => {
|
|
181
|
-
const schema: SquisqAnnotatedSchema = {
|
|
182
|
-
type: 'object',
|
|
183
|
-
properties: {
|
|
184
|
-
title: { type: 'string', title: 'Title', description: 'A useful title' },
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
const onValidate = vi.fn();
|
|
188
|
-
render(
|
|
189
|
-
<JsonEditor
|
|
190
|
-
schema={schema}
|
|
191
|
-
value={{ title: '' }}
|
|
192
|
-
onChange={() => {}}
|
|
193
|
-
validate={() => [{ path: '/title', message: 'Required' }]}
|
|
194
|
-
onValidate={onValidate}
|
|
195
|
-
/>,
|
|
196
|
-
);
|
|
197
|
-
const input = screen.getByLabelText('Title');
|
|
198
|
-
expect(input.getAttribute('aria-invalid')).toBe('true');
|
|
199
|
-
const described = input.getAttribute('aria-describedby') ?? '';
|
|
200
|
-
expect(described).toContain('-help');
|
|
201
|
-
expect(described).toContain('-error');
|
|
202
|
-
expect(screen.getByRole('alert').textContent).toBe('Required');
|
|
203
|
-
await waitFor(() =>
|
|
204
|
-
expect(onValidate).toHaveBeenCalledWith([{ path: '/title', message: 'Required' }]),
|
|
205
|
-
);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('adds ARIA state and keyboard navigation to segmented/tabs controls', () => {
|
|
209
|
-
const schema: SquisqAnnotatedSchema = {
|
|
210
|
-
oneOf: [
|
|
211
|
-
{ type: 'string', title: 'Text option' },
|
|
212
|
-
{ type: 'number', title: 'Number option' },
|
|
213
|
-
],
|
|
214
|
-
squisq: { control: 'tabs', label: 'Value type' },
|
|
215
|
-
};
|
|
216
|
-
render(<JsonEditor schema={schema} value="hello" onChange={() => {}} />);
|
|
217
|
-
const tabs = screen.getAllByRole('tab');
|
|
218
|
-
expect(tabs[0].getAttribute('aria-selected')).toBe('true');
|
|
219
|
-
fireEvent.keyDown(tabs[0], { key: 'ArrowRight' });
|
|
220
|
-
expect(tabs[1].getAttribute('aria-selected')).toBe('true');
|
|
221
|
-
expect(screen.getByRole('tabpanel')).toBeTruthy();
|
|
222
|
-
});
|
|
223
|
-
});
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @vitest-environment jsdom
|
|
3
|
-
*/
|
|
4
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
5
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
6
|
-
import type { ImageEditDoc } from '@bendyline/squisq/schemas';
|
|
7
|
-
import { LayersPanel } from '../imageEditor/LayersPanel.js';
|
|
8
|
-
import type { ImageEditorAction } from '../imageEditor/state.js';
|
|
9
|
-
|
|
10
|
-
const ignoreAddLayer = () => {};
|
|
11
|
-
|
|
12
|
-
function buildDoc(): ImageEditDoc {
|
|
13
|
-
return {
|
|
14
|
-
version: 1,
|
|
15
|
-
canvas: { width: 100, height: 100 },
|
|
16
|
-
layers: [
|
|
17
|
-
{
|
|
18
|
-
id: 'a',
|
|
19
|
-
type: 'shape',
|
|
20
|
-
name: 'Bottom',
|
|
21
|
-
position: { x: 0, y: 0, width: 10, height: 10 },
|
|
22
|
-
content: { shape: 'rect' },
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
id: 'b',
|
|
26
|
-
type: 'text',
|
|
27
|
-
name: 'Middle',
|
|
28
|
-
position: { x: 0, y: 0, width: 50, height: 20 },
|
|
29
|
-
content: { text: 'Hi', style: { fontSize: 16, color: '#000' } },
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: 'c',
|
|
33
|
-
type: 'shape',
|
|
34
|
-
name: 'Top',
|
|
35
|
-
visible: false,
|
|
36
|
-
position: { x: 0, y: 0, width: 10, height: 10 },
|
|
37
|
-
content: { shape: 'rect' },
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
describe('LayersPanel', () => {
|
|
44
|
-
it('renders layers with the top of the SVG stack first', () => {
|
|
45
|
-
const dispatch = vi.fn<(a: ImageEditorAction) => void>();
|
|
46
|
-
render(
|
|
47
|
-
<LayersPanel
|
|
48
|
-
doc={buildDoc()}
|
|
49
|
-
selectedLayerId={null}
|
|
50
|
-
dispatch={dispatch}
|
|
51
|
-
onAddLayer={ignoreAddLayer}
|
|
52
|
-
/>,
|
|
53
|
-
);
|
|
54
|
-
const items = screen.getAllByText(/Bottom|Middle|Top/);
|
|
55
|
-
expect(items[0]?.textContent).toContain('Top');
|
|
56
|
-
expect(items[items.length - 1]?.textContent).toContain('Bottom');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('clicking the layer name dispatches a select action', () => {
|
|
60
|
-
const dispatch = vi.fn<(a: ImageEditorAction) => void>();
|
|
61
|
-
render(
|
|
62
|
-
<LayersPanel
|
|
63
|
-
doc={buildDoc()}
|
|
64
|
-
selectedLayerId={null}
|
|
65
|
-
dispatch={dispatch}
|
|
66
|
-
onAddLayer={ignoreAddLayer}
|
|
67
|
-
/>,
|
|
68
|
-
);
|
|
69
|
-
fireEvent.click(screen.getByText('Middle'));
|
|
70
|
-
expect(dispatch).toHaveBeenCalledWith({ type: 'select', layerId: 'b' });
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('exposes the full layer name as a tooltip when the row is truncated', () => {
|
|
74
|
-
const dispatch = vi.fn<(a: ImageEditorAction) => void>();
|
|
75
|
-
render(
|
|
76
|
-
<LayersPanel
|
|
77
|
-
doc={buildDoc()}
|
|
78
|
-
selectedLayerId={null}
|
|
79
|
-
dispatch={dispatch}
|
|
80
|
-
onAddLayer={ignoreAddLayer}
|
|
81
|
-
/>,
|
|
82
|
-
);
|
|
83
|
-
expect(screen.getByTitle('Middle').textContent).toContain('Middle');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('opens the add-layer menu and reports the selected layer kind', () => {
|
|
87
|
-
const dispatch = vi.fn<(a: ImageEditorAction) => void>();
|
|
88
|
-
const onAddLayer = vi.fn();
|
|
89
|
-
render(
|
|
90
|
-
<LayersPanel
|
|
91
|
-
doc={buildDoc()}
|
|
92
|
-
selectedLayerId={null}
|
|
93
|
-
dispatch={dispatch}
|
|
94
|
-
onAddLayer={onAddLayer}
|
|
95
|
-
/>,
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
fireEvent.click(screen.getByRole('button', { name: 'Add layer' }));
|
|
99
|
-
expect(screen.getByRole('menu')).toBeTruthy();
|
|
100
|
-
fireEvent.click(screen.getByRole('menuitem', { name: 'Text layer' }));
|
|
101
|
-
expect(onAddLayer).toHaveBeenCalledWith('text');
|
|
102
|
-
expect(screen.queryByRole('menu')).toBeNull();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('toggling visibility dispatches an update-layer action', () => {
|
|
106
|
-
const dispatch = vi.fn<(a: ImageEditorAction) => void>();
|
|
107
|
-
render(
|
|
108
|
-
<LayersPanel
|
|
109
|
-
doc={buildDoc()}
|
|
110
|
-
selectedLayerId={null}
|
|
111
|
-
dispatch={dispatch}
|
|
112
|
-
onAddLayer={ignoreAddLayer}
|
|
113
|
-
/>,
|
|
114
|
-
);
|
|
115
|
-
// The "Hide layer" buttons exist for visible layers.
|
|
116
|
-
const hideButtons = screen.getAllByRole('button', { name: 'Hide layer' });
|
|
117
|
-
fireEvent.click(hideButtons[0]!); // top-most visible layer is 'b'
|
|
118
|
-
expect(dispatch).toHaveBeenCalledWith({
|
|
119
|
-
type: 'update-layer',
|
|
120
|
-
layerId: 'b',
|
|
121
|
-
patch: { visible: false },
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('move-up button is disabled at the top of the stack', () => {
|
|
126
|
-
const dispatch = vi.fn<(a: ImageEditorAction) => void>();
|
|
127
|
-
render(
|
|
128
|
-
<LayersPanel
|
|
129
|
-
doc={buildDoc()}
|
|
130
|
-
selectedLayerId={null}
|
|
131
|
-
dispatch={dispatch}
|
|
132
|
-
onAddLayer={ignoreAddLayer}
|
|
133
|
-
/>,
|
|
134
|
-
);
|
|
135
|
-
const upButtons = screen.getAllByRole('button', { name: 'Move layer up' });
|
|
136
|
-
// Visual order is c, b, a; layer 'c' is at the top of the stack and cannot move up.
|
|
137
|
-
expect((upButtons[0] as HTMLButtonElement).disabled).toBe(true);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('delete button dispatches a remove-layer action', () => {
|
|
141
|
-
const dispatch = vi.fn<(a: ImageEditorAction) => void>();
|
|
142
|
-
render(
|
|
143
|
-
<LayersPanel
|
|
144
|
-
doc={buildDoc()}
|
|
145
|
-
selectedLayerId={null}
|
|
146
|
-
dispatch={dispatch}
|
|
147
|
-
onAddLayer={ignoreAddLayer}
|
|
148
|
-
/>,
|
|
149
|
-
);
|
|
150
|
-
const delButtons = screen.getAllByRole('button', { name: 'Delete layer' });
|
|
151
|
-
fireEvent.click(delButtons[0]!); // top of stack ('c')
|
|
152
|
-
expect(dispatch).toHaveBeenCalledWith({ type: 'remove-layer', layerId: 'c' });
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it('shows an empty-state message when there are no layers', () => {
|
|
156
|
-
const dispatch = vi.fn<(a: ImageEditorAction) => void>();
|
|
157
|
-
render(
|
|
158
|
-
<LayersPanel
|
|
159
|
-
doc={{ version: 1, canvas: { width: 1, height: 1 }, layers: [] }}
|
|
160
|
-
selectedLayerId={null}
|
|
161
|
-
dispatch={dispatch}
|
|
162
|
-
onAddLayer={ignoreAddLayer}
|
|
163
|
-
/>,
|
|
164
|
-
);
|
|
165
|
-
expect(screen.getByText(/no layers yet/i)).toBeTruthy();
|
|
166
|
-
});
|
|
167
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Layout child sub-blocks round-trip through the markdown ↔ Tiptap bridge.
|
|
3
|
-
*
|
|
4
|
-
* Layouts now persist each layer as a readable `### {#id} {[type …]}` child
|
|
5
|
-
* heading (no base64 `layers=` blob); a text layer's content is the child's
|
|
6
|
-
* markdown body. These tests pin that serialization seam — the same
|
|
7
|
-
* `data-template` / `data-template-params` / `data-block-attrs` attributes the
|
|
8
|
-
* LayoutAdapter reads back — without standing up a full editor.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { describe, it, expect } from 'vitest';
|
|
12
|
-
import { markdownToTiptap, tiptapToMarkdown } from '../tiptapBridge';
|
|
13
|
-
|
|
14
|
-
// Parent title "Pricing" (not "Layout") avoids the bridge's template-label
|
|
15
|
-
// de-dup heuristic, which would strip a title equal to the template's label.
|
|
16
|
-
const LAYOUT = [
|
|
17
|
-
'## Pricing {[layout]}',
|
|
18
|
-
'',
|
|
19
|
-
'### {#text-1} {[text x=360 y=380 width=1200 height=320 align=center]}',
|
|
20
|
-
'',
|
|
21
|
-
'Welcome to the **bold** layout',
|
|
22
|
-
'',
|
|
23
|
-
'- first point',
|
|
24
|
-
'- second point',
|
|
25
|
-
'',
|
|
26
|
-
'### {#box-1} {[rectangle x=760 y=390 width=400 height=300 fill="#e0e7ff"]}',
|
|
27
|
-
'',
|
|
28
|
-
'### {#pic-1} {[image x=40 y=40 width=320 height=240 src=cover.png alt="Cover"]}',
|
|
29
|
-
].join('\n');
|
|
30
|
-
|
|
31
|
-
describe('Layout child sub-block round-trip', () => {
|
|
32
|
-
it('extracts a text layer annotation into the template + block-attr attributes', () => {
|
|
33
|
-
const html = markdownToTiptap('### {#text-1} {[text x=360 y=380 width=1200 height=320]}');
|
|
34
|
-
expect(html).toContain('data-template="text"');
|
|
35
|
-
expect(html).toContain('data-template-params="x=360 y=380 width=1200 height=320"');
|
|
36
|
-
expect(html).toContain('data-block-attrs="#text-1"');
|
|
37
|
-
expect(html).not.toContain('{[text'); // raw annotation text stripped
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('keeps a text layer body (marks + list) as sibling blocks, not in the heading', () => {
|
|
41
|
-
const html = markdownToTiptap(
|
|
42
|
-
['### {#text-1} {[text x=0 y=0]}', '', 'Hello **world**', '', '- a', '- b'].join('\n'),
|
|
43
|
-
);
|
|
44
|
-
// Heading is empty; the body is its own paragraph + list.
|
|
45
|
-
expect(html).toContain('<strong>world</strong>');
|
|
46
|
-
expect(html).toContain('<ul>');
|
|
47
|
-
expect(html).toContain('<li>');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('round-trips a full layout (text + box + image) losslessly and idempotently', () => {
|
|
51
|
-
const back = tiptapToMarkdown(markdownToTiptap(LAYOUT));
|
|
52
|
-
expect(back).toContain('## Pricing {[layout]}');
|
|
53
|
-
// Child sub-blocks keep their id + annotation (empty-text headings get an
|
|
54
|
-
// extra space after `###`, which re-parses identically — assert spacing-free).
|
|
55
|
-
expect(back).toContain('{#text-1} {[text x=360 y=380 width=1200 height=320 align=center]}');
|
|
56
|
-
expect(back).toContain(
|
|
57
|
-
'{#box-1} {[rectangle x=760 y=390 width=400 height=300 fill="#e0e7ff"]}',
|
|
58
|
-
);
|
|
59
|
-
expect(back).toContain(
|
|
60
|
-
'{#pic-1} {[image x=40 y=40 width=320 height=240 src=cover.png alt="Cover"]}',
|
|
61
|
-
);
|
|
62
|
-
// The text layer's body markdown survives as readable content.
|
|
63
|
-
expect(back).toContain('Welcome to the **bold** layout');
|
|
64
|
-
expect(back).toContain('- first point');
|
|
65
|
-
expect(back).toContain('- second point');
|
|
66
|
-
// No base64 layers blob anywhere — the whole point of the change.
|
|
67
|
-
expect(back).not.toContain('layers=');
|
|
68
|
-
// Stable: a second pass reproduces the first exactly.
|
|
69
|
-
expect(tiptapToMarkdown(markdownToTiptap(back))).toBe(back);
|
|
70
|
-
});
|
|
71
|
-
});
|