@bendyline/squisq-editor-react 1.3.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 +184 -4
- package/dist/EditorShell.d.ts.map +1 -1
- package/dist/EditorShell.js +184 -12
- 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/MediaBin.d.ts +12 -1
- package/dist/MediaBin.d.ts.map +1 -1
- package/dist/MediaBin.js +13 -3
- package/dist/MediaBin.js.map +1 -1
- 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__/mediaAttachmentFlow.test.d.ts +2 -0
- package/dist/__tests__/mediaAttachmentFlow.test.d.ts.map +1 -0
- package/dist/__tests__/mediaAttachmentFlow.test.js +99 -0
- package/dist/__tests__/mediaAttachmentFlow.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 +26 -0
- package/dist/__tests__/tiptapBridge.test.js.map +1 -1
- package/dist/__tests__/tiptapImageRoundTrip.test.d.ts +2 -0
- package/dist/__tests__/tiptapImageRoundTrip.test.d.ts.map +1 -0
- package/dist/__tests__/tiptapImageRoundTrip.test.js +68 -0
- package/dist/__tests__/tiptapImageRoundTrip.test.js.map +1 -0
- 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 +210 -16
- 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 +691 -63
- 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/MediaBin.tsx +22 -3
- 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__/mediaAttachmentFlow.test.ts +110 -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 +29 -0
- package/src/__tests__/tiptapImageRoundTrip.test.ts +73 -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 +227 -22
- 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,332 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmojiPicker
|
|
3
|
+
*
|
|
4
|
+
* Toolbar-anchored popover for inserting emoji. The user picks a
|
|
5
|
+
* category from a row of tabs along the top, sees a scrollable grid
|
|
6
|
+
* for that category, and can type into a search box to narrow across
|
|
7
|
+
* all categories at once. Click → `onSelect(char)` → caller is
|
|
8
|
+
* responsible for routing the character into the active editor.
|
|
9
|
+
*
|
|
10
|
+
* Keeps the data flat and the rendering simple: there's no fuzzy
|
|
11
|
+
* search, no recently-used persistence, no skin-tone modifiers — just
|
|
12
|
+
* a fast, predictable picker. We can layer those on later without
|
|
13
|
+
* changing the public surface.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
17
|
+
import type { CSSProperties } from 'react';
|
|
18
|
+
import { PICKER_CATEGORIES, searchPickerEntries } from './emojiData';
|
|
19
|
+
import type { PickerEntry } from './emojiData';
|
|
20
|
+
|
|
21
|
+
export interface EmojiPickerProps {
|
|
22
|
+
/** Whether the picker is visible. */
|
|
23
|
+
open: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Fired when the user picks an entry. Carries either an emoji glyph
|
|
26
|
+
* or a FontAwesome icon descriptor — the caller dispatches on
|
|
27
|
+
* `kind` to insert it into the active editor. The caller is also
|
|
28
|
+
* responsible for closing the popover.
|
|
29
|
+
*/
|
|
30
|
+
onSelect: (entry: PickerEntry) => void;
|
|
31
|
+
/** Fired on Escape, click-outside, or selection so the caller can close. */
|
|
32
|
+
onClose: () => void;
|
|
33
|
+
/** Optional anchor element — used for click-outside detection. When the
|
|
34
|
+
* popover is rendered inside the same container as the trigger, pointer
|
|
35
|
+
* events on the trigger don't fire the outside handler. */
|
|
36
|
+
anchorRef?: React.RefObject<HTMLElement>;
|
|
37
|
+
/** Optional CSS class for the popover root. */
|
|
38
|
+
className?: string;
|
|
39
|
+
/** Optional inline style for the popover root (e.g. positioning). */
|
|
40
|
+
style?: CSSProperties;
|
|
41
|
+
/**
|
|
42
|
+
* Editor theme — `'light'` or `'dark'`. Drives the picker's color
|
|
43
|
+
* palette. Required for the picker to render correctly when portaled
|
|
44
|
+
* outside the editor shell, since CSS custom properties defined on
|
|
45
|
+
* the shell don't cascade to portal targets. Defaults to `'light'`.
|
|
46
|
+
*/
|
|
47
|
+
theme?: 'light' | 'dark';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface PickerPalette {
|
|
51
|
+
bg: string;
|
|
52
|
+
border: string;
|
|
53
|
+
inputBg: string;
|
|
54
|
+
text: string;
|
|
55
|
+
textMuted: string;
|
|
56
|
+
accent: string;
|
|
57
|
+
accentSoft: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const LIGHT_PALETTE: PickerPalette = {
|
|
61
|
+
bg: '#fff',
|
|
62
|
+
border: '#d4cdb5',
|
|
63
|
+
inputBg: '#fff',
|
|
64
|
+
text: '#1f2937',
|
|
65
|
+
textMuted: '#8a7a5a',
|
|
66
|
+
accent: '#8B6914',
|
|
67
|
+
accentSoft: '#f3eedb',
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const DARK_PALETTE: PickerPalette = {
|
|
71
|
+
bg: '#1f2937',
|
|
72
|
+
border: '#4b5563',
|
|
73
|
+
inputBg: '#374151',
|
|
74
|
+
text: '#e5e7eb',
|
|
75
|
+
textMuted: '#9ca3af',
|
|
76
|
+
accent: '#fbbf24',
|
|
77
|
+
accentSoft: '#374151',
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** Default popover dimensions. The Toolbar reads these to position the
|
|
81
|
+
* popover with viewport-aware clamping so it never gets clipped. */
|
|
82
|
+
export const EMOJI_PICKER_WIDTH = 480;
|
|
83
|
+
export const EMOJI_PICKER_MAX_HEIGHT = 560;
|
|
84
|
+
|
|
85
|
+
function buildPopoverStyle(palette: PickerPalette): CSSProperties {
|
|
86
|
+
return {
|
|
87
|
+
position: 'absolute',
|
|
88
|
+
zIndex: 100,
|
|
89
|
+
background: palette.bg,
|
|
90
|
+
border: `1px solid ${palette.border}`,
|
|
91
|
+
borderRadius: 6,
|
|
92
|
+
// Dark mode needs a deeper shadow than the light palette uses,
|
|
93
|
+
// because the popover sits on a dark surface where a soft 15%
|
|
94
|
+
// shadow effectively disappears.
|
|
95
|
+
boxShadow:
|
|
96
|
+
palette === DARK_PALETTE ? '0 8px 32px rgba(0, 0, 0, 0.5)' : '0 6px 24px rgba(0, 0, 0, 0.15)',
|
|
97
|
+
color: palette.text,
|
|
98
|
+
width: EMOJI_PICKER_WIDTH,
|
|
99
|
+
maxWidth: '95vw',
|
|
100
|
+
maxHeight: EMOJI_PICKER_MAX_HEIGHT,
|
|
101
|
+
display: 'flex',
|
|
102
|
+
flexDirection: 'column',
|
|
103
|
+
overflow: 'hidden',
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function EmojiPicker({
|
|
108
|
+
open,
|
|
109
|
+
onSelect,
|
|
110
|
+
onClose,
|
|
111
|
+
anchorRef,
|
|
112
|
+
className,
|
|
113
|
+
style,
|
|
114
|
+
theme = 'light',
|
|
115
|
+
}: EmojiPickerProps) {
|
|
116
|
+
const palette = theme === 'dark' ? DARK_PALETTE : LIGHT_PALETTE;
|
|
117
|
+
const [activeCategory, setActiveCategory] = useState<string>(PICKER_CATEGORIES[0].id);
|
|
118
|
+
const [query, setQuery] = useState('');
|
|
119
|
+
const popoverRef = useRef<HTMLDivElement>(null);
|
|
120
|
+
const searchInputRef = useRef<HTMLInputElement>(null);
|
|
121
|
+
|
|
122
|
+
// Focus the search box when the popover opens; reset query when it
|
|
123
|
+
// closes so the next open starts fresh.
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
if (open) {
|
|
126
|
+
// Defer so the input is mounted.
|
|
127
|
+
const t = setTimeout(() => searchInputRef.current?.focus(), 0);
|
|
128
|
+
return () => clearTimeout(t);
|
|
129
|
+
}
|
|
130
|
+
setQuery('');
|
|
131
|
+
setActiveCategory(PICKER_CATEGORIES[0].id);
|
|
132
|
+
return undefined;
|
|
133
|
+
}, [open]);
|
|
134
|
+
|
|
135
|
+
// Close on outside click and Escape.
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if (!open) return;
|
|
138
|
+
const onPointerDown = (e: MouseEvent) => {
|
|
139
|
+
const target = e.target as Node | null;
|
|
140
|
+
if (!target) return;
|
|
141
|
+
if (popoverRef.current?.contains(target)) return;
|
|
142
|
+
if (anchorRef?.current?.contains(target)) return;
|
|
143
|
+
onClose();
|
|
144
|
+
};
|
|
145
|
+
const onKey = (e: KeyboardEvent) => {
|
|
146
|
+
if (e.key === 'Escape') onClose();
|
|
147
|
+
};
|
|
148
|
+
document.addEventListener('mousedown', onPointerDown);
|
|
149
|
+
document.addEventListener('keydown', onKey);
|
|
150
|
+
return () => {
|
|
151
|
+
document.removeEventListener('mousedown', onPointerDown);
|
|
152
|
+
document.removeEventListener('keydown', onKey);
|
|
153
|
+
};
|
|
154
|
+
}, [open, onClose, anchorRef]);
|
|
155
|
+
|
|
156
|
+
const visibleEntries = useMemo<PickerEntry[]>(() => {
|
|
157
|
+
if (query.trim()) return searchPickerEntries(query);
|
|
158
|
+
const cat = PICKER_CATEGORIES.find((c) => c.id === activeCategory);
|
|
159
|
+
return cat ? cat.entries : [];
|
|
160
|
+
}, [query, activeCategory]);
|
|
161
|
+
|
|
162
|
+
if (!open) return null;
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<div
|
|
166
|
+
ref={popoverRef}
|
|
167
|
+
className={`squisq-emoji-picker ${className ?? ''}`}
|
|
168
|
+
data-theme={theme}
|
|
169
|
+
style={{ ...buildPopoverStyle(palette), ...style }}
|
|
170
|
+
role="dialog"
|
|
171
|
+
aria-label="Insert emoji"
|
|
172
|
+
data-testid="emoji-picker"
|
|
173
|
+
>
|
|
174
|
+
{/* Search */}
|
|
175
|
+
<div
|
|
176
|
+
style={{
|
|
177
|
+
padding: '8px 10px',
|
|
178
|
+
borderBottom: `1px solid ${palette.border}`,
|
|
179
|
+
}}
|
|
180
|
+
>
|
|
181
|
+
<input
|
|
182
|
+
ref={searchInputRef}
|
|
183
|
+
type="text"
|
|
184
|
+
value={query}
|
|
185
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
186
|
+
placeholder="Search emoji & icons…"
|
|
187
|
+
aria-label="Search emoji & icons"
|
|
188
|
+
style={{
|
|
189
|
+
width: '100%',
|
|
190
|
+
padding: '6px 8px',
|
|
191
|
+
fontSize: 13,
|
|
192
|
+
fontFamily: 'inherit',
|
|
193
|
+
border: `1px solid ${palette.border}`,
|
|
194
|
+
borderRadius: 4,
|
|
195
|
+
background: palette.inputBg,
|
|
196
|
+
color: palette.text,
|
|
197
|
+
boxSizing: 'border-box',
|
|
198
|
+
}}
|
|
199
|
+
/>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
{/* Category tabs — hidden when a search is active because the grid
|
|
203
|
+
collapses across categories.
|
|
204
|
+
|
|
205
|
+
Two-row grid layout: with 9 emoji buckets + 3 FA families we'd
|
|
206
|
+
otherwise need a horizontal scrollbar to fit them all in the
|
|
207
|
+
480px-wide picker, and the scrollbar visually obscures the
|
|
208
|
+
tabs themselves. A 6-column grid gives exactly two even rows
|
|
209
|
+
that always fit without scrolling. */}
|
|
210
|
+
{!query.trim() && (
|
|
211
|
+
<div
|
|
212
|
+
role="tablist"
|
|
213
|
+
aria-label="Emoji & icon categories"
|
|
214
|
+
style={{
|
|
215
|
+
display: 'grid',
|
|
216
|
+
gridTemplateColumns: 'repeat(6, 1fr)',
|
|
217
|
+
gap: 2,
|
|
218
|
+
padding: '4px 6px',
|
|
219
|
+
borderBottom: `1px solid ${palette.border}`,
|
|
220
|
+
}}
|
|
221
|
+
>
|
|
222
|
+
{PICKER_CATEGORIES.map((cat) => {
|
|
223
|
+
const active = cat.id === activeCategory;
|
|
224
|
+
return (
|
|
225
|
+
<button
|
|
226
|
+
key={cat.id}
|
|
227
|
+
type="button"
|
|
228
|
+
role="tab"
|
|
229
|
+
aria-selected={active}
|
|
230
|
+
aria-label={cat.label}
|
|
231
|
+
title={cat.label}
|
|
232
|
+
onClick={() => setActiveCategory(cat.id)}
|
|
233
|
+
style={{
|
|
234
|
+
fontSize: 18,
|
|
235
|
+
lineHeight: 1,
|
|
236
|
+
padding: '6px 0',
|
|
237
|
+
cursor: 'pointer',
|
|
238
|
+
background: active ? palette.accentSoft : 'transparent',
|
|
239
|
+
border: '1px solid transparent',
|
|
240
|
+
borderBottom: active ? `2px solid ${palette.accent}` : '2px solid transparent',
|
|
241
|
+
borderRadius: 4,
|
|
242
|
+
color: palette.text,
|
|
243
|
+
display: 'flex',
|
|
244
|
+
alignItems: 'center',
|
|
245
|
+
justifyContent: 'center',
|
|
246
|
+
}}
|
|
247
|
+
>
|
|
248
|
+
{cat.tab.kind === 'emoji' ? (
|
|
249
|
+
cat.tab.char
|
|
250
|
+
) : (
|
|
251
|
+
<i className={`fa-${cat.tab.family} fa-${cat.tab.name}`} aria-hidden="true" />
|
|
252
|
+
)}
|
|
253
|
+
</button>
|
|
254
|
+
);
|
|
255
|
+
})}
|
|
256
|
+
</div>
|
|
257
|
+
)}
|
|
258
|
+
|
|
259
|
+
{/* Grid — grows to fill the picker. The wrapper's `maxHeight`
|
|
260
|
+
caps the popover overall (set on the root element above), so
|
|
261
|
+
the grid scrolls only when the content doesn't fit. With the
|
|
262
|
+
default sizing (480 wide × 560 tall, 10 columns) the common
|
|
263
|
+
categories fit without a scrollbar at all. */}
|
|
264
|
+
<div
|
|
265
|
+
style={{
|
|
266
|
+
padding: 6,
|
|
267
|
+
flex: 1,
|
|
268
|
+
minHeight: 0,
|
|
269
|
+
overflowY: 'auto',
|
|
270
|
+
display: 'grid',
|
|
271
|
+
gridTemplateColumns: 'repeat(10, 1fr)',
|
|
272
|
+
gap: 2,
|
|
273
|
+
}}
|
|
274
|
+
>
|
|
275
|
+
{visibleEntries.length === 0 ? (
|
|
276
|
+
<div
|
|
277
|
+
style={{
|
|
278
|
+
gridColumn: '1 / -1',
|
|
279
|
+
padding: '20px 8px',
|
|
280
|
+
textAlign: 'center',
|
|
281
|
+
color: palette.textMuted,
|
|
282
|
+
fontSize: 13,
|
|
283
|
+
}}
|
|
284
|
+
>
|
|
285
|
+
{query.trim() ? `No matches for "${query.trim()}"` : 'No entries'}
|
|
286
|
+
</div>
|
|
287
|
+
) : (
|
|
288
|
+
visibleEntries.map((entry, idx) => {
|
|
289
|
+
const tooltip = entry.kind === 'emoji' ? entry.name : entry.label;
|
|
290
|
+
const key =
|
|
291
|
+
entry.kind === 'emoji' ? `e-${entry.char}-${idx}` : `i-${entry.token}-${idx}`;
|
|
292
|
+
return (
|
|
293
|
+
<button
|
|
294
|
+
key={key}
|
|
295
|
+
type="button"
|
|
296
|
+
title={tooltip}
|
|
297
|
+
aria-label={tooltip}
|
|
298
|
+
data-picker-kind={entry.kind}
|
|
299
|
+
onClick={() => onSelect(entry)}
|
|
300
|
+
style={{
|
|
301
|
+
fontSize: 22,
|
|
302
|
+
lineHeight: 1,
|
|
303
|
+
padding: 4,
|
|
304
|
+
background: 'transparent',
|
|
305
|
+
border: '1px solid transparent',
|
|
306
|
+
borderRadius: 4,
|
|
307
|
+
cursor: 'pointer',
|
|
308
|
+
color: palette.text,
|
|
309
|
+
display: 'flex',
|
|
310
|
+
alignItems: 'center',
|
|
311
|
+
justifyContent: 'center',
|
|
312
|
+
}}
|
|
313
|
+
onMouseEnter={(e) => {
|
|
314
|
+
e.currentTarget.style.background = palette.accentSoft;
|
|
315
|
+
}}
|
|
316
|
+
onMouseLeave={(e) => {
|
|
317
|
+
e.currentTarget.style.background = 'transparent';
|
|
318
|
+
}}
|
|
319
|
+
>
|
|
320
|
+
{entry.kind === 'emoji' ? (
|
|
321
|
+
entry.char
|
|
322
|
+
) : (
|
|
323
|
+
<i className={`fa-${entry.family} fa-${entry.name}`} aria-hidden="true" />
|
|
324
|
+
)}
|
|
325
|
+
</button>
|
|
326
|
+
);
|
|
327
|
+
})
|
|
328
|
+
)}
|
|
329
|
+
</div>
|
|
330
|
+
</div>
|
|
331
|
+
);
|
|
332
|
+
}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImageEditor — top-level shell that wires together the toolbar,
|
|
3
|
+
* canvas surface, layers panel, and properties panel against an
|
|
4
|
+
* `ImageEditDoc` persisted in a sidecar `ContentContainer`.
|
|
5
|
+
*
|
|
6
|
+
* Hosts pass an already-scoped container (typically built with
|
|
7
|
+
* `scopeContainer(parent, basename + '_files')`). On first mount, if
|
|
8
|
+
* the sidecar has no `state.json`, the editor seeds it from
|
|
9
|
+
* `initialSrc` — the source bytes are copied to `assets/source.<ext>`
|
|
10
|
+
* so the doc is portable and round-trips through ZIP serialization.
|
|
11
|
+
*
|
|
12
|
+
* The export pipeline is `state.json` → SVG → raster blob via
|
|
13
|
+
* `exportImageEditDoc` from `@bendyline/squisq/imageEdit`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { useCallback, useState } from 'react';
|
|
17
|
+
import type { ContentContainer } from '@bendyline/squisq/storage';
|
|
18
|
+
import { exportImageEditDoc, type ImageEditExportFormat } from '@bendyline/squisq/imageEdit';
|
|
19
|
+
import type { SurfaceScheme, Theme } from '@bendyline/squisq/schemas';
|
|
20
|
+
import { CanvasSurface } from './imageEditor/CanvasSurface.js';
|
|
21
|
+
import { ImageVersionHistoryDropdown } from './imageEditor/ImageVersionHistoryDropdown.js';
|
|
22
|
+
import { LayersPanel } from './imageEditor/LayersPanel.js';
|
|
23
|
+
import { PropertiesPanel } from './imageEditor/PropertiesPanel.js';
|
|
24
|
+
import { Toolbar } from './imageEditor/Toolbar.js';
|
|
25
|
+
import { useImageEditor } from './imageEditor/useImageEditor.js';
|
|
26
|
+
import { useImageEditorTokens } from './imageEditor/useImageEditorTokens.js';
|
|
27
|
+
|
|
28
|
+
export interface ImageEditorProps {
|
|
29
|
+
/**
|
|
30
|
+
* Scoped sidecar container for this image — typically
|
|
31
|
+
* `scopeContainer(parent, basename + '_files')`.
|
|
32
|
+
*/
|
|
33
|
+
filesContainer: ContentContainer;
|
|
34
|
+
/**
|
|
35
|
+
* Source URL used to seed `assets/source.<ext>` and layer 0 the
|
|
36
|
+
* first time the sidecar is opened. Ignored once `state.json` exists.
|
|
37
|
+
*/
|
|
38
|
+
initialSrc?: string;
|
|
39
|
+
/** Override the state filename. Default: `state.json`. */
|
|
40
|
+
stateFilename?: string;
|
|
41
|
+
/** Enable version-history snapshots in `.versions/`. Default: `false`. */
|
|
42
|
+
allowVersioning?: boolean;
|
|
43
|
+
/** Auto-save idle delay (ms) for version snapshots. Default: `5000`. */
|
|
44
|
+
versioningAutoSaveIdleMs?: number;
|
|
45
|
+
/** Called after the user clicks Export and the blob is produced. */
|
|
46
|
+
onExport?: (blob: Blob, format: ImageEditExportFormat) => void;
|
|
47
|
+
/**
|
|
48
|
+
* What the toolbar's Save button does:
|
|
49
|
+
* - `'flush'` (default): write `state.json` to the sidecar.
|
|
50
|
+
* - `'export'`: rasterize the canvas in `saveFormat` and fire
|
|
51
|
+
* {@link onExport} — the same code path the Export menu uses.
|
|
52
|
+
* Hosts that want one-click "save and close" semantics use this.
|
|
53
|
+
*/
|
|
54
|
+
saveBehavior?: 'flush' | 'export';
|
|
55
|
+
/** Format used when `saveBehavior === 'export'`. Default: `'png'`. */
|
|
56
|
+
saveFormat?: ImageEditExportFormat;
|
|
57
|
+
/** Override the Save button label. Default: `'Save'`. */
|
|
58
|
+
saveLabel?: string;
|
|
59
|
+
/** Override the Save button tooltip. */
|
|
60
|
+
saveTitle?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Squisq Theme to color the editor chrome (toolbar, panels, controls).
|
|
63
|
+
* Defaults to `DEFAULT_THEME`. Combined with {@link surface} the same
|
|
64
|
+
* way `<JsonView>` and `<LinearDocView>` do.
|
|
65
|
+
*/
|
|
66
|
+
theme?: Theme;
|
|
67
|
+
/**
|
|
68
|
+
* Surface scheme — `LIGHT_SURFACE`, `DARK_SURFACE`, an explicit
|
|
69
|
+
* `SurfaceScheme` object, or `'auto'` to track the user's OS
|
|
70
|
+
* `prefers-color-scheme`. When omitted, the theme's own background is
|
|
71
|
+
* used as-is.
|
|
72
|
+
*/
|
|
73
|
+
surface?: SurfaceScheme | 'auto';
|
|
74
|
+
/** Optional className for the root element. */
|
|
75
|
+
className?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function ImageEditor(props: ImageEditorProps) {
|
|
79
|
+
const {
|
|
80
|
+
filesContainer,
|
|
81
|
+
initialSrc,
|
|
82
|
+
stateFilename,
|
|
83
|
+
allowVersioning,
|
|
84
|
+
versioningAutoSaveIdleMs,
|
|
85
|
+
onExport,
|
|
86
|
+
saveBehavior = 'flush',
|
|
87
|
+
saveFormat = 'png',
|
|
88
|
+
saveLabel,
|
|
89
|
+
saveTitle,
|
|
90
|
+
theme,
|
|
91
|
+
surface,
|
|
92
|
+
className,
|
|
93
|
+
} = props;
|
|
94
|
+
|
|
95
|
+
const tokens = useImageEditorTokens(theme, surface);
|
|
96
|
+
|
|
97
|
+
const { state, dispatch, flush, resolveAssetUrl, uploadAsset, versioning, ready, error } =
|
|
98
|
+
useImageEditor({
|
|
99
|
+
container: filesContainer,
|
|
100
|
+
initialSrc,
|
|
101
|
+
stateFilename,
|
|
102
|
+
allowVersioning,
|
|
103
|
+
versioningAutoSaveIdleMs,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Bumped after every save/version write so the history popover
|
|
107
|
+
// re-lists without polling.
|
|
108
|
+
const [historyRefreshKey, setHistoryRefreshKey] = useState(0);
|
|
109
|
+
|
|
110
|
+
const handleExport = useCallback(
|
|
111
|
+
async (format: ImageEditExportFormat) => {
|
|
112
|
+
if (!state) return;
|
|
113
|
+
try {
|
|
114
|
+
const blob = await exportImageEditDoc(state.doc, filesContainer, { format });
|
|
115
|
+
if (onExport) {
|
|
116
|
+
onExport(blob, format);
|
|
117
|
+
} else {
|
|
118
|
+
// Default behavior: trigger a browser download.
|
|
119
|
+
const url = URL.createObjectURL(blob);
|
|
120
|
+
const a = document.createElement('a');
|
|
121
|
+
a.href = url;
|
|
122
|
+
a.download = `image.${format === 'jpeg' ? 'jpg' : format}`;
|
|
123
|
+
document.body.appendChild(a);
|
|
124
|
+
a.click();
|
|
125
|
+
document.body.removeChild(a);
|
|
126
|
+
URL.revokeObjectURL(url);
|
|
127
|
+
}
|
|
128
|
+
} catch (err: unknown) {
|
|
129
|
+
console.warn(
|
|
130
|
+
'[squisq-editor] image export failed:',
|
|
131
|
+
err instanceof Error ? err.message : err,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
[state, filesContainer, onExport],
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Save-and-close pipeline. Critical: we must `await flush()` *before*
|
|
140
|
+
* triggering the export, otherwise the parent modal may close (via the
|
|
141
|
+
* `onExport` chain) before the debounced state.json write fires —
|
|
142
|
+
* losing any layer/edit changes since the last debounce. We also save
|
|
143
|
+
* a version snapshot so the history dropdown captures the moment of
|
|
144
|
+
* save and the user can revert later.
|
|
145
|
+
*/
|
|
146
|
+
const handleSaveAndClose = useCallback(async () => {
|
|
147
|
+
try {
|
|
148
|
+
await flush();
|
|
149
|
+
if (versioning) {
|
|
150
|
+
try {
|
|
151
|
+
await versioning.saveVersion();
|
|
152
|
+
setHistoryRefreshKey((k) => k + 1);
|
|
153
|
+
} catch (err: unknown) {
|
|
154
|
+
console.warn(
|
|
155
|
+
'[squisq-editor] image-edit save-version failed:',
|
|
156
|
+
err instanceof Error ? err.message : err,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
await handleExport(saveFormat);
|
|
161
|
+
} catch (err: unknown) {
|
|
162
|
+
console.warn(
|
|
163
|
+
'[squisq-editor] image-edit save-and-close failed:',
|
|
164
|
+
err instanceof Error ? err.message : err,
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}, [flush, versioning, handleExport, saveFormat]);
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Revert `state.json` (and the in-memory editor state) to a prior
|
|
171
|
+
* snapshot. We delegate to `versioning.revertToVersion` so the
|
|
172
|
+
* sidecar write happens through the same code path as direct API
|
|
173
|
+
* use, including a snapshot of the *current* state before overwrite
|
|
174
|
+
* — that way the user can undo a revert via the same dropdown.
|
|
175
|
+
*/
|
|
176
|
+
const handleRevertToVersion = useCallback(
|
|
177
|
+
async (version: import('@bendyline/squisq/versions').Version) => {
|
|
178
|
+
if (!versioning) return;
|
|
179
|
+
// Cancel any pending debounced write so it can't clobber the
|
|
180
|
+
// reverted state.json after we replace it.
|
|
181
|
+
try {
|
|
182
|
+
await flush();
|
|
183
|
+
} catch {
|
|
184
|
+
/* swallow — best effort */
|
|
185
|
+
}
|
|
186
|
+
const result = await versioning.revertToVersion(version);
|
|
187
|
+
if (!result.reverted) return;
|
|
188
|
+
const doc = await versioning.readVersion(version);
|
|
189
|
+
if (doc) {
|
|
190
|
+
dispatch({ type: 'load', doc });
|
|
191
|
+
// Bump the history list so the just-saved \"pre-revert\"
|
|
192
|
+
// snapshot shows up in the dropdown.
|
|
193
|
+
setHistoryRefreshKey((k) => k + 1);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
[dispatch, flush, versioning],
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const handleCreateTextAt = useCallback(
|
|
200
|
+
(x: number, y: number) => {
|
|
201
|
+
dispatch({
|
|
202
|
+
type: 'add-layer',
|
|
203
|
+
layer: {
|
|
204
|
+
type: 'text',
|
|
205
|
+
name: 'Text',
|
|
206
|
+
position: { x: Math.round(x), y: Math.round(y), width: 240, height: 48 },
|
|
207
|
+
content: {
|
|
208
|
+
text: 'New text',
|
|
209
|
+
style: { fontSize: 32, color: '#111111', fontFamily: 'sans-serif' },
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
dispatch({ type: 'set-tool', tool: 'select' });
|
|
214
|
+
},
|
|
215
|
+
[dispatch],
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
const handleCreateShapeAt = useCallback(
|
|
219
|
+
(x: number, y: number) => {
|
|
220
|
+
dispatch({
|
|
221
|
+
type: 'add-layer',
|
|
222
|
+
layer: {
|
|
223
|
+
type: 'shape',
|
|
224
|
+
name: 'Rectangle',
|
|
225
|
+
position: {
|
|
226
|
+
x: Math.round(x - 60),
|
|
227
|
+
y: Math.round(y - 40),
|
|
228
|
+
width: 120,
|
|
229
|
+
height: 80,
|
|
230
|
+
},
|
|
231
|
+
content: {
|
|
232
|
+
shape: 'rect',
|
|
233
|
+
fill: '#3399ff',
|
|
234
|
+
stroke: '#1a4d80',
|
|
235
|
+
strokeWidth: 2,
|
|
236
|
+
borderRadius: 8,
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
dispatch({ type: 'set-tool', tool: 'select' });
|
|
241
|
+
},
|
|
242
|
+
[dispatch],
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
if (error) {
|
|
246
|
+
return (
|
|
247
|
+
<div
|
|
248
|
+
className={['squisq-image-editor', className].filter(Boolean).join(' ')}
|
|
249
|
+
style={tokens.style}
|
|
250
|
+
>
|
|
251
|
+
<div className="squisq-image-editor-error">
|
|
252
|
+
Failed to load image editor: {error.message}
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (!ready || !state) {
|
|
259
|
+
return (
|
|
260
|
+
<div
|
|
261
|
+
className={['squisq-image-editor', className].filter(Boolean).join(' ')}
|
|
262
|
+
style={tokens.style}
|
|
263
|
+
>
|
|
264
|
+
<div className="squisq-image-editor-loading">Loading image editor…</div>
|
|
265
|
+
</div>
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return (
|
|
270
|
+
<div
|
|
271
|
+
className={['squisq-image-editor', className].filter(Boolean).join(' ')}
|
|
272
|
+
style={tokens.style}
|
|
273
|
+
data-testid="image-editor"
|
|
274
|
+
>
|
|
275
|
+
<Toolbar
|
|
276
|
+
doc={state.doc}
|
|
277
|
+
tool={state.tool}
|
|
278
|
+
dispatch={dispatch}
|
|
279
|
+
uploadAsset={uploadAsset}
|
|
280
|
+
onExport={handleExport}
|
|
281
|
+
onSave={saveBehavior === 'export' ? handleSaveAndClose : flush}
|
|
282
|
+
saveLabel={saveLabel ?? (saveBehavior === 'export' ? 'Save and close' : 'Save')}
|
|
283
|
+
saveTitle={
|
|
284
|
+
saveTitle ??
|
|
285
|
+
(saveBehavior === 'export'
|
|
286
|
+
? `Rasterize and save as ${saveFormat.toUpperCase()}`
|
|
287
|
+
: 'Save state.json')
|
|
288
|
+
}
|
|
289
|
+
extraTools={
|
|
290
|
+
versioning ? (
|
|
291
|
+
<ImageVersionHistoryDropdown
|
|
292
|
+
versioning={versioning}
|
|
293
|
+
container={filesContainer}
|
|
294
|
+
onRevert={handleRevertToVersion}
|
|
295
|
+
refreshKey={historyRefreshKey}
|
|
296
|
+
/>
|
|
297
|
+
) : null
|
|
298
|
+
}
|
|
299
|
+
/>
|
|
300
|
+
<div className="squisq-image-editor-body">
|
|
301
|
+
<div className="squisq-image-editor-center">
|
|
302
|
+
<CanvasSurface
|
|
303
|
+
doc={state.doc}
|
|
304
|
+
selectedLayerId={state.selectedLayerId}
|
|
305
|
+
tool={state.tool}
|
|
306
|
+
resolveAssetUrl={resolveAssetUrl}
|
|
307
|
+
dispatch={dispatch}
|
|
308
|
+
onCreateTextAt={handleCreateTextAt}
|
|
309
|
+
onCreateShapeAt={handleCreateShapeAt}
|
|
310
|
+
/>
|
|
311
|
+
</div>
|
|
312
|
+
<div className="squisq-image-editor-side">
|
|
313
|
+
<LayersPanel
|
|
314
|
+
doc={state.doc}
|
|
315
|
+
selectedLayerId={state.selectedLayerId}
|
|
316
|
+
dispatch={dispatch}
|
|
317
|
+
/>
|
|
318
|
+
<PropertiesPanel
|
|
319
|
+
doc={state.doc}
|
|
320
|
+
selectedLayerId={state.selectedLayerId}
|
|
321
|
+
dispatch={dispatch}
|
|
322
|
+
/>
|
|
323
|
+
</div>
|
|
324
|
+
</div>
|
|
325
|
+
</div>
|
|
326
|
+
);
|
|
327
|
+
}
|