@bendyline/squisq-editor-react 1.4.0 → 1.5.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/dist/DocumentSettingsDialog.d.ts +26 -0
- package/dist/DocumentSettingsDialog.d.ts.map +1 -0
- package/dist/DocumentSettingsDialog.js +115 -0
- package/dist/DocumentSettingsDialog.js.map +1 -0
- package/dist/EditorContext.d.ts +248 -4
- package/dist/EditorContext.d.ts.map +1 -1
- package/dist/EditorContext.js +248 -10
- package/dist/EditorContext.js.map +1 -1
- package/dist/EditorShell.d.ts +173 -4
- package/dist/EditorShell.d.ts.map +1 -1
- package/dist/EditorShell.js +110 -10
- package/dist/EditorShell.js.map +1 -1
- package/dist/EmojiPicker.d.ts +50 -0
- package/dist/EmojiPicker.d.ts.map +1 -0
- package/dist/EmojiPicker.js +182 -0
- package/dist/EmojiPicker.js.map +1 -0
- package/dist/ImageEditor.d.ts +68 -0
- package/dist/ImageEditor.d.ts.map +1 -0
- package/dist/ImageEditor.js +166 -0
- package/dist/ImageEditor.js.map +1 -0
- package/dist/ImageNodeView.d.ts +13 -1
- package/dist/ImageNodeView.d.ts.map +1 -1
- package/dist/ImageNodeView.js +172 -19
- package/dist/ImageNodeView.js.map +1 -1
- package/dist/ImageViewer.d.ts +26 -0
- package/dist/ImageViewer.d.ts.map +1 -0
- package/dist/ImageViewer.js +119 -0
- package/dist/ImageViewer.js.map +1 -0
- package/dist/InlineIcon.d.ts +17 -0
- package/dist/InlineIcon.d.ts.map +1 -0
- package/dist/InlineIcon.js +72 -0
- package/dist/InlineIcon.js.map +1 -0
- package/dist/InlinePreviewGutter.d.ts +52 -0
- package/dist/InlinePreviewGutter.d.ts.map +1 -0
- package/dist/InlinePreviewGutter.js +397 -0
- package/dist/InlinePreviewGutter.js.map +1 -0
- package/dist/LinkDialog.d.ts +43 -0
- package/dist/LinkDialog.d.ts.map +1 -0
- package/dist/LinkDialog.js +102 -0
- package/dist/LinkDialog.js.map +1 -0
- package/dist/MentionExtension.js +10 -7
- package/dist/MentionExtension.js.map +1 -1
- package/dist/OutlinePanel.d.ts +17 -0
- package/dist/OutlinePanel.d.ts.map +1 -0
- package/dist/OutlinePanel.js +167 -0
- package/dist/OutlinePanel.js.map +1 -0
- package/dist/PlainHtmlPreview.d.ts +50 -0
- package/dist/PlainHtmlPreview.d.ts.map +1 -0
- package/dist/PlainHtmlPreview.js +155 -0
- package/dist/PlainHtmlPreview.js.map +1 -0
- package/dist/PreviewControls.d.ts +15 -1
- package/dist/PreviewControls.d.ts.map +1 -1
- package/dist/PreviewControls.js +75 -18
- package/dist/PreviewControls.js.map +1 -1
- package/dist/PreviewPanel.d.ts +11 -10
- package/dist/PreviewPanel.d.ts.map +1 -1
- package/dist/PreviewPanel.js +20 -17
- package/dist/PreviewPanel.js.map +1 -1
- package/dist/RawEditor.d.ts.map +1 -1
- package/dist/RawEditor.js +198 -4
- package/dist/RawEditor.js.map +1 -1
- package/dist/RecorderEntry.d.ts +24 -0
- package/dist/RecorderEntry.d.ts.map +1 -0
- package/dist/RecorderEntry.js +139 -0
- package/dist/RecorderEntry.js.map +1 -0
- package/dist/TemplateAnnotation.d.ts.map +1 -1
- package/dist/TemplateAnnotation.js +32 -6
- package/dist/TemplateAnnotation.js.map +1 -1
- package/dist/TemplatePicker.d.ts +53 -0
- package/dist/TemplatePicker.d.ts.map +1 -0
- package/dist/TemplatePicker.js +388 -0
- package/dist/TemplatePicker.js.map +1 -0
- package/dist/ThemeCustomizerPanel.d.ts +32 -0
- package/dist/ThemeCustomizerPanel.d.ts.map +1 -0
- package/dist/ThemeCustomizerPanel.js +256 -0
- package/dist/ThemeCustomizerPanel.js.map +1 -0
- package/dist/ThemePicker.d.ts +33 -0
- package/dist/ThemePicker.d.ts.map +1 -0
- package/dist/ThemePicker.js +148 -0
- package/dist/ThemePicker.js.map +1 -0
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar.js +508 -33
- package/dist/Toolbar.js.map +1 -1
- package/dist/VersionHistoryPanel.d.ts +14 -0
- package/dist/VersionHistoryPanel.d.ts.map +1 -0
- package/dist/VersionHistoryPanel.js +147 -0
- package/dist/VersionHistoryPanel.js.map +1 -0
- package/dist/ViewMenuPanel.d.ts +13 -0
- package/dist/ViewMenuPanel.d.ts.map +1 -0
- package/dist/ViewMenuPanel.js +58 -0
- package/dist/ViewMenuPanel.js.map +1 -0
- package/dist/WysiwygEditor.d.ts.map +1 -1
- package/dist/WysiwygEditor.js +198 -9
- package/dist/WysiwygEditor.js.map +1 -1
- package/dist/__tests__/detectMarkdown.test.js +0 -14
- package/dist/__tests__/detectMarkdown.test.js.map +1 -1
- package/dist/__tests__/documentSettingsDialog.test.d.ts +2 -0
- package/dist/__tests__/documentSettingsDialog.test.d.ts.map +1 -0
- package/dist/__tests__/documentSettingsDialog.test.js +132 -0
- package/dist/__tests__/documentSettingsDialog.test.js.map +1 -0
- package/dist/__tests__/emojiPicker.test.d.ts +2 -0
- package/dist/__tests__/emojiPicker.test.d.ts.map +1 -0
- package/dist/__tests__/emojiPicker.test.js +111 -0
- package/dist/__tests__/emojiPicker.test.js.map +1 -0
- package/dist/__tests__/fileKind.test.js +13 -0
- package/dist/__tests__/fileKind.test.js.map +1 -1
- package/dist/__tests__/imageEditAffordance.test.d.ts +2 -0
- package/dist/__tests__/imageEditAffordance.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditAffordance.test.js +188 -0
- package/dist/__tests__/imageEditAffordance.test.js.map +1 -0
- package/dist/__tests__/imageEditorShell.test.d.ts +2 -0
- package/dist/__tests__/imageEditorShell.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditorShell.test.js +52 -0
- package/dist/__tests__/imageEditorShell.test.js.map +1 -0
- package/dist/__tests__/imageEditorState.test.d.ts +3 -0
- package/dist/__tests__/imageEditorState.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditorState.test.js +148 -0
- package/dist/__tests__/imageEditorState.test.js.map +1 -0
- package/dist/__tests__/inlinePreviewGutter.test.d.ts +2 -0
- package/dist/__tests__/inlinePreviewGutter.test.d.ts.map +1 -0
- package/dist/__tests__/inlinePreviewGutter.test.js +51 -0
- package/dist/__tests__/inlinePreviewGutter.test.js.map +1 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.d.ts +2 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.d.ts.map +1 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.js +63 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.js.map +1 -0
- package/dist/__tests__/jsonEditor.test.d.ts +2 -0
- package/dist/__tests__/jsonEditor.test.d.ts.map +1 -0
- package/dist/__tests__/jsonEditor.test.js +134 -0
- package/dist/__tests__/jsonEditor.test.js.map +1 -0
- package/dist/__tests__/layersPanel.test.d.ts +2 -0
- package/dist/__tests__/layersPanel.test.d.ts.map +1 -0
- package/dist/__tests__/layersPanel.test.js +84 -0
- package/dist/__tests__/layersPanel.test.js.map +1 -0
- package/dist/__tests__/linkDialogDocPicker.test.d.ts +7 -0
- package/dist/__tests__/linkDialogDocPicker.test.d.ts.map +1 -0
- package/dist/__tests__/linkDialogDocPicker.test.js +75 -0
- package/dist/__tests__/linkDialogDocPicker.test.js.map +1 -0
- package/dist/__tests__/outlinePanel.test.d.ts +2 -0
- package/dist/__tests__/outlinePanel.test.d.ts.map +1 -0
- package/dist/__tests__/outlinePanel.test.js +68 -0
- package/dist/__tests__/outlinePanel.test.js.map +1 -0
- package/dist/__tests__/plainHtmlPreview.test.d.ts +2 -0
- package/dist/__tests__/plainHtmlPreview.test.d.ts.map +1 -0
- package/dist/__tests__/plainHtmlPreview.test.js +87 -0
- package/dist/__tests__/plainHtmlPreview.test.js.map +1 -0
- package/dist/__tests__/propertiesPanel.test.d.ts +2 -0
- package/dist/__tests__/propertiesPanel.test.d.ts.map +1 -0
- package/dist/__tests__/propertiesPanel.test.js +64 -0
- package/dist/__tests__/propertiesPanel.test.js.map +1 -0
- package/dist/__tests__/recorderFormats.test.d.ts +2 -0
- package/dist/__tests__/recorderFormats.test.d.ts.map +1 -0
- package/dist/__tests__/recorderFormats.test.js +121 -0
- package/dist/__tests__/recorderFormats.test.js.map +1 -0
- package/dist/__tests__/recorderTimingJson.test.d.ts +2 -0
- package/dist/__tests__/recorderTimingJson.test.d.ts.map +1 -0
- package/dist/__tests__/recorderTimingJson.test.js +37 -0
- package/dist/__tests__/recorderTimingJson.test.js.map +1 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.d.ts +2 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.d.ts.map +1 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.js +31 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.js.map +1 -0
- package/dist/__tests__/tiptapBridge.test.js +13 -0
- package/dist/__tests__/tiptapBridge.test.js.map +1 -1
- package/dist/__tests__/useImageEditor.test.d.ts +2 -0
- package/dist/__tests__/useImageEditor.test.d.ts.map +1 -0
- package/dist/__tests__/useImageEditor.test.js +131 -0
- package/dist/__tests__/useImageEditor.test.js.map +1 -0
- package/dist/__tests__/useMediaRecorder.test.d.ts +2 -0
- package/dist/__tests__/useMediaRecorder.test.d.ts.map +1 -0
- package/dist/__tests__/useMediaRecorder.test.js +153 -0
- package/dist/__tests__/useMediaRecorder.test.js.map +1 -0
- package/dist/__tests__/versionHistory.test.d.ts +2 -0
- package/dist/__tests__/versionHistory.test.d.ts.map +1 -0
- package/dist/__tests__/versionHistory.test.js +124 -0
- package/dist/__tests__/versionHistory.test.js.map +1 -0
- package/dist/blockSlice.d.ts +24 -0
- package/dist/blockSlice.d.ts.map +1 -0
- package/dist/blockSlice.js +63 -0
- package/dist/blockSlice.js.map +1 -0
- package/dist/buildPreviewDoc.d.ts.map +1 -1
- package/dist/buildPreviewDoc.js +52 -2
- package/dist/buildPreviewDoc.js.map +1 -1
- package/dist/emojiData.d.ts +81 -0
- package/dist/emojiData.d.ts.map +1 -0
- package/dist/emojiData.js +1283 -0
- package/dist/emojiData.js.map +1 -0
- package/dist/fileKind.d.ts +6 -2
- package/dist/fileKind.d.ts.map +1 -1
- package/dist/fileKind.js +25 -4
- package/dist/fileKind.js.map +1 -1
- package/dist/hooks/useFileDrop.d.ts.map +1 -1
- package/dist/hooks/useFileDrop.js +40 -4
- package/dist/hooks/useFileDrop.js.map +1 -1
- package/dist/imageEditor/CanvasSurface.d.ts +31 -0
- package/dist/imageEditor/CanvasSurface.d.ts.map +1 -0
- package/dist/imageEditor/CanvasSurface.js +264 -0
- package/dist/imageEditor/CanvasSurface.js.map +1 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.d.ts +39 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.d.ts.map +1 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.js +283 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.js.map +1 -0
- package/dist/imageEditor/LayersPanel.d.ts +14 -0
- package/dist/imageEditor/LayersPanel.d.ts.map +1 -0
- package/dist/imageEditor/LayersPanel.js +43 -0
- package/dist/imageEditor/LayersPanel.js.map +1 -0
- package/dist/imageEditor/PropertiesPanel.d.ts +14 -0
- package/dist/imageEditor/PropertiesPanel.d.ts.map +1 -0
- package/dist/imageEditor/PropertiesPanel.js +97 -0
- package/dist/imageEditor/PropertiesPanel.js.map +1 -0
- package/dist/imageEditor/Toolbar.d.ts +30 -0
- package/dist/imageEditor/Toolbar.d.ts.map +1 -0
- package/dist/imageEditor/Toolbar.js +108 -0
- package/dist/imageEditor/Toolbar.js.map +1 -0
- package/dist/imageEditor/icons.d.ts +24 -0
- package/dist/imageEditor/icons.d.ts.map +1 -0
- package/dist/imageEditor/icons.js +45 -0
- package/dist/imageEditor/icons.js.map +1 -0
- package/dist/imageEditor/layers/EditorImageLayer.d.ts +16 -0
- package/dist/imageEditor/layers/EditorImageLayer.d.ts.map +1 -0
- package/dist/imageEditor/layers/EditorImageLayer.js +37 -0
- package/dist/imageEditor/layers/EditorImageLayer.js.map +1 -0
- package/dist/imageEditor/layers/EditorShapeLayer.d.ts +15 -0
- package/dist/imageEditor/layers/EditorShapeLayer.d.ts.map +1 -0
- package/dist/imageEditor/layers/EditorShapeLayer.js +20 -0
- package/dist/imageEditor/layers/EditorShapeLayer.js.map +1 -0
- package/dist/imageEditor/layers/EditorTextLayer.d.ts +18 -0
- package/dist/imageEditor/layers/EditorTextLayer.d.ts.map +1 -0
- package/dist/imageEditor/layers/EditorTextLayer.js +13 -0
- package/dist/imageEditor/layers/EditorTextLayer.js.map +1 -0
- package/dist/imageEditor/layers/SelectionHandles.d.ts +17 -0
- package/dist/imageEditor/layers/SelectionHandles.d.ts.map +1 -0
- package/dist/imageEditor/layers/SelectionHandles.js +19 -0
- package/dist/imageEditor/layers/SelectionHandles.js.map +1 -0
- package/dist/imageEditor/state.d.ts +76 -0
- package/dist/imageEditor/state.d.ts.map +1 -0
- package/dist/imageEditor/state.js +87 -0
- package/dist/imageEditor/state.js.map +1 -0
- package/dist/imageEditor/useImageEditor.d.ts +53 -0
- package/dist/imageEditor/useImageEditor.d.ts.map +1 -0
- package/dist/imageEditor/useImageEditor.js +244 -0
- package/dist/imageEditor/useImageEditor.js.map +1 -0
- package/dist/imageEditor/useImageEditorTokens.d.ts +16 -0
- package/dist/imageEditor/useImageEditorTokens.d.ts.map +1 -0
- package/dist/imageEditor/useImageEditorTokens.js +45 -0
- package/dist/imageEditor/useImageEditorTokens.js.map +1 -0
- package/dist/index.d.ts +48 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -1
- package/dist/jsonEditor/EmbeddedRichTextField.d.ts +15 -0
- package/dist/jsonEditor/EmbeddedRichTextField.d.ts.map +1 -0
- package/dist/jsonEditor/EmbeddedRichTextField.js +74 -0
- package/dist/jsonEditor/EmbeddedRichTextField.js.map +1 -0
- package/dist/jsonEditor/JsonEditor.d.ts +36 -0
- package/dist/jsonEditor/JsonEditor.d.ts.map +1 -0
- package/dist/jsonEditor/JsonEditor.js +15 -0
- package/dist/jsonEditor/JsonEditor.js.map +1 -0
- package/dist/jsonEditor/JsonEditorContext.d.ts +28 -0
- package/dist/jsonEditor/JsonEditorContext.d.ts.map +1 -0
- package/dist/jsonEditor/JsonEditorContext.js +41 -0
- package/dist/jsonEditor/JsonEditorContext.js.map +1 -0
- package/dist/jsonEditor/RenderNode.d.ts +16 -0
- package/dist/jsonEditor/RenderNode.d.ts.map +1 -0
- package/dist/jsonEditor/RenderNode.js +32 -0
- package/dist/jsonEditor/RenderNode.js.map +1 -0
- package/dist/jsonEditor/editors.d.ts +36 -0
- package/dist/jsonEditor/editors.d.ts.map +1 -0
- package/dist/jsonEditor/editors.js +347 -0
- package/dist/jsonEditor/editors.js.map +1 -0
- package/dist/jsonEditor/index.d.ts +3 -0
- package/dist/jsonEditor/index.d.ts.map +1 -0
- package/dist/jsonEditor/index.js +2 -0
- package/dist/jsonEditor/index.js.map +1 -0
- package/dist/jsonEditor/useJsonEditorTokens.d.ts +13 -0
- package/dist/jsonEditor/useJsonEditorTokens.d.ts.map +1 -0
- package/dist/jsonEditor/useJsonEditorTokens.js +38 -0
- package/dist/jsonEditor/useJsonEditorTokens.js.map +1 -0
- package/dist/recorder/RecorderButton.d.ts +31 -0
- package/dist/recorder/RecorderButton.d.ts.map +1 -0
- package/dist/recorder/RecorderButton.js +24 -0
- package/dist/recorder/RecorderButton.js.map +1 -0
- package/dist/recorder/RecorderModal.d.ts +59 -0
- package/dist/recorder/RecorderModal.d.ts.map +1 -0
- package/dist/recorder/RecorderModal.js +333 -0
- package/dist/recorder/RecorderModal.js.map +1 -0
- package/dist/recorder/RecorderPanel.d.ts +25 -0
- package/dist/recorder/RecorderPanel.d.ts.map +1 -0
- package/dist/recorder/RecorderPanel.js +30 -0
- package/dist/recorder/RecorderPanel.js.map +1 -0
- package/dist/recorder/formats.d.ts +51 -0
- package/dist/recorder/formats.d.ts.map +1 -0
- package/dist/recorder/formats.js +144 -0
- package/dist/recorder/formats.js.map +1 -0
- package/dist/recorder/hooks/useMediaRecorder.d.ts +90 -0
- package/dist/recorder/hooks/useMediaRecorder.d.ts.map +1 -0
- package/dist/recorder/hooks/useMediaRecorder.js +277 -0
- package/dist/recorder/hooks/useMediaRecorder.js.map +1 -0
- package/dist/recorder/hooks/useStreamPreview.d.ts +22 -0
- package/dist/recorder/hooks/useStreamPreview.d.ts.map +1 -0
- package/dist/recorder/hooks/useStreamPreview.js +44 -0
- package/dist/recorder/hooks/useStreamPreview.js.map +1 -0
- package/dist/recorder/sources/cameraStream.d.ts +22 -0
- package/dist/recorder/sources/cameraStream.d.ts.map +1 -0
- package/dist/recorder/sources/cameraStream.js +24 -0
- package/dist/recorder/sources/cameraStream.js.map +1 -0
- package/dist/recorder/sources/micStream.d.ts +15 -0
- package/dist/recorder/sources/micStream.d.ts.map +1 -0
- package/dist/recorder/sources/micStream.js +24 -0
- package/dist/recorder/sources/micStream.js.map +1 -0
- package/dist/recorder/sources/screenStream.d.ts +53 -0
- package/dist/recorder/sources/screenStream.d.ts.map +1 -0
- package/dist/recorder/sources/screenStream.js +114 -0
- package/dist/recorder/sources/screenStream.js.map +1 -0
- package/dist/recorder/timingJson.d.ts +51 -0
- package/dist/recorder/timingJson.d.ts.map +1 -0
- package/dist/recorder/timingJson.js +42 -0
- package/dist/recorder/timingJson.js.map +1 -0
- package/dist/tiptap/TiptapAudio.d.ts +26 -0
- package/dist/tiptap/TiptapAudio.d.ts.map +1 -0
- package/dist/tiptap/TiptapAudio.js +58 -0
- package/dist/tiptap/TiptapAudio.js.map +1 -0
- package/dist/tiptap/TiptapVideo.d.ts +30 -0
- package/dist/tiptap/TiptapVideo.d.ts.map +1 -0
- package/dist/tiptap/TiptapVideo.js +66 -0
- package/dist/tiptap/TiptapVideo.js.map +1 -0
- package/dist/tiptap/useResolvedMediaSrc.d.ts +2 -0
- package/dist/tiptap/useResolvedMediaSrc.d.ts.map +1 -0
- package/dist/tiptap/useResolvedMediaSrc.js +42 -0
- package/dist/tiptap/useResolvedMediaSrc.js.map +1 -0
- package/dist/tiptapBridge.d.ts.map +1 -1
- package/dist/tiptapBridge.js +171 -14
- package/dist/tiptapBridge.js.map +1 -1
- package/dist/useHeadingLayout.d.ts +54 -0
- package/dist/useHeadingLayout.d.ts.map +1 -0
- package/dist/useHeadingLayout.js +260 -0
- package/dist/useHeadingLayout.js.map +1 -0
- package/dist/utils/collectInlineFontAwesomeCss.d.ts +21 -0
- package/dist/utils/collectInlineFontAwesomeCss.d.ts.map +1 -0
- package/dist/utils/collectInlineFontAwesomeCss.js +68 -0
- package/dist/utils/collectInlineFontAwesomeCss.js.map +1 -0
- package/dist/utils/dropUtils.d.ts +21 -2
- package/dist/utils/dropUtils.d.ts.map +1 -1
- package/dist/utils/dropUtils.js +43 -4
- package/dist/utils/dropUtils.js.map +1 -1
- package/dist/utils/normalizeMalformedAssetUrl.d.ts +15 -0
- package/dist/utils/normalizeMalformedAssetUrl.d.ts.map +1 -0
- package/dist/utils/normalizeMalformedAssetUrl.js +27 -0
- package/dist/utils/normalizeMalformedAssetUrl.js.map +1 -0
- package/package.json +8 -5
- package/src/DocumentSettingsDialog.tsx +266 -0
- package/src/EditorContext.tsx +534 -10
- package/src/EditorShell.tsx +571 -55
- package/src/EmojiPicker.tsx +332 -0
- package/src/ImageEditor.tsx +327 -0
- package/src/ImageNodeView.tsx +222 -21
- package/src/ImageViewer.tsx +221 -0
- package/src/InlineIcon.ts +84 -0
- package/src/InlinePreviewGutter.tsx +582 -0
- package/src/LinkDialog.tsx +276 -0
- package/src/MentionExtension.tsx +10 -7
- package/src/OutlinePanel.tsx +295 -0
- package/src/PlainHtmlPreview.tsx +211 -0
- package/src/PreviewControls.tsx +130 -24
- package/src/PreviewPanel.tsx +38 -21
- package/src/RawEditor.tsx +215 -4
- package/src/RecorderEntry.tsx +164 -0
- package/src/TemplateAnnotation.ts +32 -6
- package/src/TemplatePicker.tsx +818 -0
- package/src/ThemeCustomizerPanel.tsx +595 -0
- package/src/ThemePicker.tsx +319 -0
- package/src/Toolbar.tsx +708 -111
- package/src/VersionHistoryPanel.tsx +329 -0
- package/src/ViewMenuPanel.tsx +188 -0
- package/src/WysiwygEditor.tsx +229 -9
- package/src/__tests__/detectMarkdown.test.ts +0 -15
- package/src/__tests__/documentSettingsDialog.test.tsx +147 -0
- package/src/__tests__/emojiPicker.test.tsx +133 -0
- package/src/__tests__/fileKind.test.ts +16 -0
- package/src/__tests__/imageEditAffordance.test.tsx +268 -0
- package/src/__tests__/imageEditorShell.test.tsx +57 -0
- package/src/__tests__/imageEditorState.test.ts +171 -0
- package/src/__tests__/inlinePreviewGutter.test.tsx +62 -0
- package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +103 -0
- package/src/__tests__/jsonEditor.test.tsx +168 -0
- package/src/__tests__/layersPanel.test.tsx +97 -0
- package/src/__tests__/linkDialogDocPicker.test.tsx +137 -0
- package/src/__tests__/outlinePanel.test.tsx +79 -0
- package/src/__tests__/plainHtmlPreview.test.tsx +107 -0
- package/src/__tests__/propertiesPanel.test.tsx +69 -0
- package/src/__tests__/recorderFormats.test.ts +146 -0
- package/src/__tests__/recorderTimingJson.test.ts +41 -0
- package/src/__tests__/templateAnnotationRoundTrip.test.ts +34 -0
- package/src/__tests__/tiptapBridge.test.ts +15 -0
- package/src/__tests__/useImageEditor.test.tsx +159 -0
- package/src/__tests__/useMediaRecorder.test.ts +186 -0
- package/src/__tests__/versionHistory.test.tsx +197 -0
- package/src/blockSlice.ts +75 -0
- package/src/buildPreviewDoc.ts +61 -6
- package/src/emojiData.ts +1337 -0
- package/src/fileKind.ts +30 -6
- package/src/hooks/useFileDrop.ts +40 -4
- package/src/imageEditor/CanvasSurface.tsx +402 -0
- package/src/imageEditor/ImageVersionHistoryDropdown.tsx +396 -0
- package/src/imageEditor/LayersPanel.tsx +143 -0
- package/src/imageEditor/PropertiesPanel.tsx +428 -0
- package/src/imageEditor/Toolbar.tsx +242 -0
- package/src/imageEditor/icons.tsx +144 -0
- package/src/imageEditor/image-editor.css +450 -0
- package/src/imageEditor/layers/EditorImageLayer.tsx +45 -0
- package/src/imageEditor/layers/EditorShapeLayer.tsx +62 -0
- package/src/imageEditor/layers/EditorTextLayer.tsx +45 -0
- package/src/imageEditor/layers/SelectionHandles.tsx +86 -0
- package/src/imageEditor/state.ts +153 -0
- package/src/imageEditor/useImageEditor.ts +328 -0
- package/src/imageEditor/useImageEditorTokens.ts +70 -0
- package/src/index.ts +82 -0
- package/src/jsonEditor/EmbeddedRichTextField.tsx +81 -0
- package/src/jsonEditor/JsonEditor.tsx +81 -0
- package/src/jsonEditor/JsonEditorContext.tsx +75 -0
- package/src/jsonEditor/RenderNode.tsx +66 -0
- package/src/jsonEditor/editors.tsx +678 -0
- package/src/jsonEditor/index.ts +2 -0
- package/src/jsonEditor/json-editor.css +463 -0
- package/src/jsonEditor/useJsonEditorTokens.ts +63 -0
- package/src/recorder/RecorderButton.tsx +72 -0
- package/src/recorder/RecorderModal.tsx +596 -0
- package/src/recorder/RecorderPanel.tsx +93 -0
- package/src/recorder/formats.ts +159 -0
- package/src/recorder/hooks/useMediaRecorder.ts +378 -0
- package/src/recorder/hooks/useStreamPreview.ts +47 -0
- package/src/recorder/sources/cameraStream.ts +32 -0
- package/src/recorder/sources/micStream.ts +25 -0
- package/src/recorder/sources/screenStream.ts +162 -0
- package/src/recorder/timingJson.ts +66 -0
- package/src/styles/editor.css +2490 -51
- package/src/styles/image-edit-affordance.css +201 -0
- package/src/styles/index.css +10 -0
- package/src/tiptap/TiptapAudio.tsx +86 -0
- package/src/tiptap/TiptapVideo.tsx +119 -0
- package/src/tiptap/useResolvedMediaSrc.ts +47 -0
- package/src/tiptapBridge.ts +188 -20
- package/src/useHeadingLayout.ts +294 -0
- package/src/utils/collectInlineFontAwesomeCss.ts +69 -0
- package/src/utils/dropUtils.ts +54 -6
- package/src/utils/normalizeMalformedAssetUrl.ts +22 -0
|
@@ -0,0 +1,268 @@
|
|
|
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
|
+
await act(async () => {
|
|
186
|
+
fireEvent.click(screen.getByTestId('trigger'));
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
await waitFor(() => {
|
|
190
|
+
expect(screen.getByTestId('image-edit-modal')).toBeTruthy();
|
|
191
|
+
});
|
|
192
|
+
// Shows the relative path in the header.
|
|
193
|
+
expect(screen.getByText('hero.png')).toBeTruthy();
|
|
194
|
+
|
|
195
|
+
await act(async () => {
|
|
196
|
+
fireEvent.click(screen.getByTestId('image-edit-modal-close'));
|
|
197
|
+
});
|
|
198
|
+
await waitFor(() => {
|
|
199
|
+
expect(screen.queryByTestId('image-edit-modal')).toBeNull();
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('opens the modal with a transient sidecar when only a mediaProvider is wired (no host container)', async () => {
|
|
204
|
+
const { mediaProvider } = await setupShellWithImage();
|
|
205
|
+
render(
|
|
206
|
+
<EditorShell
|
|
207
|
+
initialMarkdown="# hi"
|
|
208
|
+
mediaProvider={mediaProvider}
|
|
209
|
+
toolbarSlotRight={<TriggerButton path="hero.png" />}
|
|
210
|
+
/>,
|
|
211
|
+
);
|
|
212
|
+
await act(async () => {
|
|
213
|
+
fireEvent.click(screen.getByTestId('trigger'));
|
|
214
|
+
});
|
|
215
|
+
// Modal now mounts even without a host container — the sidecar is
|
|
216
|
+
// backed by a fresh MemoryContentContainer the modal owns.
|
|
217
|
+
await waitFor(() => {
|
|
218
|
+
expect(screen.getByTestId('image-edit-modal')).toBeTruthy();
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('does NOT mount the modal when no mediaProvider is wired', async () => {
|
|
223
|
+
render(
|
|
224
|
+
<EditorShell initialMarkdown="# hi" toolbarSlotRight={<TriggerButton path="hero.png" />} />,
|
|
225
|
+
);
|
|
226
|
+
await act(async () => {
|
|
227
|
+
fireEvent.click(screen.getByTestId('trigger'));
|
|
228
|
+
});
|
|
229
|
+
// Without a media provider the modal has no way to resolve the source
|
|
230
|
+
// or write the result back — the guard bails out.
|
|
231
|
+
expect(screen.queryByTestId('image-edit-modal')).toBeNull();
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('writes the exported blob back through mediaProvider.addMedia and closes', async () => {
|
|
235
|
+
const { container, mediaProvider } = await setupShellWithImage();
|
|
236
|
+
const addMediaSpy = vi.spyOn(mediaProvider, 'addMedia');
|
|
237
|
+
|
|
238
|
+
render(
|
|
239
|
+
<EditorShell
|
|
240
|
+
initialMarkdown="# hi"
|
|
241
|
+
workspaceContainer={container}
|
|
242
|
+
mediaProvider={mediaProvider}
|
|
243
|
+
toolbarSlotRight={<TriggerButton path="hero.png" />}
|
|
244
|
+
/>,
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
await act(async () => {
|
|
248
|
+
fireEvent.click(screen.getByTestId('trigger'));
|
|
249
|
+
});
|
|
250
|
+
await waitFor(() => {
|
|
251
|
+
expect(screen.getByTestId('image-edit-modal')).toBeTruthy();
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// Drive the export path directly via mediaProvider.addMedia — the
|
|
255
|
+
// modal's onExport handler does exactly this. We don't try to
|
|
256
|
+
// pump the inner ImageEditor's Export button (it depends on async
|
|
257
|
+
// sidecar seeding that's heavy to wait through here).
|
|
258
|
+
// Pass raw bytes (a Uint8Array) — jsdom's Blob lacks `arrayBuffer()`,
|
|
259
|
+
// and a fake-Blob stub doesn't satisfy `instanceof Blob`, so the
|
|
260
|
+
// simplest payload is the Uint8Array branch addMedia already supports.
|
|
261
|
+
const bytes = new Uint8Array([1, 2, 3]);
|
|
262
|
+
await act(async () => {
|
|
263
|
+
await mediaProvider.addMedia('hero.png', bytes, 'image/png');
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
expect(addMediaSpy).toHaveBeenCalledWith('hero.png', bytes, 'image/png');
|
|
267
|
+
});
|
|
268
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
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 { 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 { ImageEditor } from '../ImageEditor.js';
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
if (typeof URL.createObjectURL !== 'function') {
|
|
16
|
+
Object.defineProperty(URL, 'createObjectURL', {
|
|
17
|
+
configurable: true,
|
|
18
|
+
value: vi.fn(() => 'blob:stub'),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (typeof URL.revokeObjectURL !== 'function') {
|
|
22
|
+
Object.defineProperty(URL, 'revokeObjectURL', {
|
|
23
|
+
configurable: true,
|
|
24
|
+
value: vi.fn(),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('<ImageEditor>', () => {
|
|
30
|
+
it('mounts an existing state.json and shows toolbar / layers / properties', async () => {
|
|
31
|
+
const parent = new MemoryContentContainer();
|
|
32
|
+
const sidecar = scopeContainer(parent, 'pic_files');
|
|
33
|
+
await writeImageEditDoc(sidecar, createEmptyImageEditDoc(64, 48));
|
|
34
|
+
|
|
35
|
+
render(<ImageEditor filesContainer={sidecar} />);
|
|
36
|
+
|
|
37
|
+
await waitFor(() => {
|
|
38
|
+
expect(screen.getByTestId('image-editor')).toBeTruthy();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
expect(screen.getByTestId('image-editor-toolbar')).toBeTruthy();
|
|
42
|
+
expect(screen.getByTestId('image-editor-layers')).toBeTruthy();
|
|
43
|
+
expect(screen.getByTestId('image-editor-properties')).toBeTruthy();
|
|
44
|
+
|
|
45
|
+
// SVG canvas viewBox reflects the doc dimensions.
|
|
46
|
+
const svg = document.querySelector('svg.squisq-image-editor-canvas');
|
|
47
|
+
expect(svg).not.toBeNull();
|
|
48
|
+
expect(svg!.getAttribute('viewBox')).toBe('0 0 64 48');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('shows the loading state before the seed completes', () => {
|
|
52
|
+
const parent = new MemoryContentContainer();
|
|
53
|
+
const sidecar = scopeContainer(parent, 'pic_files');
|
|
54
|
+
render(<ImageEditor filesContainer={sidecar} />);
|
|
55
|
+
expect(screen.getByText(/loading image editor/i)).toBeTruthy();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
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;
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
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;
|