@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
package/src/EditorShell.tsx
CHANGED
|
@@ -6,19 +6,26 @@
|
|
|
6
6
|
* in an EditorProvider for shared state.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { useEffect, useState, useCallback } from 'react';
|
|
9
|
+
import { useEffect, useRef, useState, useCallback, useMemo } from 'react';
|
|
10
10
|
import {
|
|
11
11
|
EditorProvider,
|
|
12
12
|
useEditorContext,
|
|
13
13
|
type EditorView,
|
|
14
14
|
type ImageDisplayMode,
|
|
15
15
|
type MentionProvider,
|
|
16
|
+
type DocumentLinkProvider,
|
|
17
|
+
type ViewPreferences,
|
|
18
|
+
type ThemeInheritance,
|
|
16
19
|
} from './EditorContext';
|
|
17
20
|
import { Toolbar } from './Toolbar';
|
|
18
21
|
import { StatusBar } from './StatusBar';
|
|
19
22
|
import { RawEditor } from './RawEditor';
|
|
20
23
|
import { WysiwygEditor } from './WysiwygEditor';
|
|
24
|
+
import { InlinePreviewGutter } from './InlinePreviewGutter';
|
|
25
|
+
import { OutlinePanel } from './OutlinePanel';
|
|
21
26
|
import { PreviewPanel } from './PreviewPanel';
|
|
27
|
+
import { ImageViewer } from './ImageViewer';
|
|
28
|
+
import { ImageEditor } from './ImageEditor';
|
|
22
29
|
import { PreviewSettingsProvider, PreviewToolbarControls } from './PreviewControls';
|
|
23
30
|
import { MediaBin } from './MediaBin';
|
|
24
31
|
import { DropZoneOverlay } from './DropZoneOverlay';
|
|
@@ -30,8 +37,15 @@ import {
|
|
|
30
37
|
processTextFile,
|
|
31
38
|
processTextFiles,
|
|
32
39
|
} from './utils/dropUtils';
|
|
33
|
-
import type { MediaProvider } from '@bendyline/squisq/schemas';
|
|
40
|
+
import type { MediaProvider, Theme } from '@bendyline/squisq/schemas';
|
|
41
|
+
import { DARK_SURFACE, LIGHT_SURFACE } from '@bendyline/squisq/schemas';
|
|
34
42
|
import type { ContentContainer } from '@bendyline/squisq/storage';
|
|
43
|
+
import {
|
|
44
|
+
MemoryContentContainer,
|
|
45
|
+
scopeContainer,
|
|
46
|
+
createMediaProviderFromContainer,
|
|
47
|
+
} from '@bendyline/squisq/storage';
|
|
48
|
+
import type { PrunePolicy, SaveVersionResult } from '@bendyline/squisq/versions';
|
|
35
49
|
import type { CSSProperties, ReactNode } from 'react';
|
|
36
50
|
|
|
37
51
|
export type { EditorTheme } from './EditorContext';
|
|
@@ -54,10 +68,74 @@ export interface EditorShellProps {
|
|
|
54
68
|
className?: string;
|
|
55
69
|
/** CSS height for the shell container (default: '100vh') */
|
|
56
70
|
height?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Minimum CSS height for the shell. When either `minHeight` or
|
|
73
|
+
* `maxHeight` is set, the shell switches to **auto-grow mode**:
|
|
74
|
+
* `height` is ignored, the root becomes `height: auto` between the
|
|
75
|
+
* bounds, and the content area scrolls internally when content
|
|
76
|
+
* exceeds `maxHeight`. Useful for chat composers that should grow
|
|
77
|
+
* with content up to some cap.
|
|
78
|
+
*/
|
|
79
|
+
minHeight?: string;
|
|
80
|
+
/** See `minHeight`. Upper bound of the auto-grow range. */
|
|
81
|
+
maxHeight?: string;
|
|
57
82
|
/** Optional MediaProvider for the Files panel. When set (even to null), a Files toggle appears in the toolbar. */
|
|
58
83
|
mediaProvider?: MediaProvider | null;
|
|
59
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* The workspace-scoped `ContentContainer` for this document — the
|
|
86
|
+
* folder that contains the doc, its `_files/` sidecar, sibling
|
|
87
|
+
* documents, and any version snapshots. Used for:
|
|
88
|
+
* - audio mapping (MP3 discovery + timing.json reading);
|
|
89
|
+
* - version history snapshots (when `allowVersioning` is true);
|
|
90
|
+
* - reading sibling `.md` files for the recursive HTML export;
|
|
91
|
+
* - resolving per-document scoped views (e.g. the image-edit
|
|
92
|
+
* sidecar derived via `scopeContainer`).
|
|
93
|
+
* Doc-scoped concerns (per-doc media URLs, per-doc asset writes)
|
|
94
|
+
* flow through `mediaProvider` instead — typically derived from
|
|
95
|
+
* this container via `createMediaProviderFromContainer`.
|
|
96
|
+
*/
|
|
97
|
+
workspaceContainer?: ContentContainer | null;
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated Renamed to `workspaceContainer` to make the workspace-
|
|
100
|
+
* vs. doc-scoped distinction explicit. Still accepted as a fallback
|
|
101
|
+
* for now; remove in the next breaking release.
|
|
102
|
+
*/
|
|
60
103
|
container?: ContentContainer | null;
|
|
104
|
+
/**
|
|
105
|
+
* Enable version history. Snapshots are stored at
|
|
106
|
+
* `.versions/<basename>.<timestamp>.md` inside the same
|
|
107
|
+
* `workspaceContainer`, so they ride along with the document when
|
|
108
|
+
* the host serializes.
|
|
109
|
+
*
|
|
110
|
+
* Snapshots fire on idle (controlled by `versioningAutoSaveIdleMs`)
|
|
111
|
+
* and can also be triggered host-side via the manager exposed in the
|
|
112
|
+
* context (`useEditorContext().versioning`). Has no effect without a
|
|
113
|
+
* `workspaceContainer` — a `console.warn` flags the misconfiguration
|
|
114
|
+
* in dev.
|
|
115
|
+
*/
|
|
116
|
+
allowVersioning?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Override the document basename used in version filenames. Defaults
|
|
119
|
+
* to the basename of the container's primary document path.
|
|
120
|
+
*/
|
|
121
|
+
versionBasename?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Prune policy applied after each successful save. Defaults to
|
|
124
|
+
* `{ type: 'keep-last-n', n: 50 }` so the snapshot count stays bounded.
|
|
125
|
+
*/
|
|
126
|
+
versioningPrunePolicy?: PrunePolicy;
|
|
127
|
+
/**
|
|
128
|
+
* Idle delay (ms) before the editor auto-saves a version. `0` disables
|
|
129
|
+
* auto-save entirely (snapshots are then only saved when the host
|
|
130
|
+
* calls `versioning.saveVersion()` from the context). Default: 5000.
|
|
131
|
+
*/
|
|
132
|
+
versioningAutoSaveIdleMs?: number;
|
|
133
|
+
/**
|
|
134
|
+
* Notified after each `saveVersion` attempt. Fires for both successful
|
|
135
|
+
* saves (`reason: 'saved'`) and skips (`'unchanged'`, `'no-document'`,
|
|
136
|
+
* `'empty'`). Useful for hosts that want a "Last saved" indicator.
|
|
137
|
+
*/
|
|
138
|
+
onSaveVersion?: (result: SaveVersionResult) => void;
|
|
61
139
|
/** Show the Files toggle in the toolbar. Defaults to true when mediaProvider is passed. */
|
|
62
140
|
showFilesToggle?: boolean;
|
|
63
141
|
/** Content rendered at the left edge of the toolbar, before the view tabs. */
|
|
@@ -149,6 +227,24 @@ export interface EditorShellProps {
|
|
|
149
227
|
* inline. Omit to disable mentions entirely.
|
|
150
228
|
*/
|
|
151
229
|
mentionProvider?: MentionProvider | null;
|
|
230
|
+
/**
|
|
231
|
+
* Optional async provider for sibling-document suggestions in the
|
|
232
|
+
* link insert dialog. When supplied, the dialog gains a "Browse
|
|
233
|
+
* documents" picker so authors can pick a neighbor `.md` by name and
|
|
234
|
+
* insert a relative-path link without typing the URL by hand. Hosts
|
|
235
|
+
* that organize docs in a workspace (file-system, IndexedDB slot,
|
|
236
|
+
* remote API, …) implement this; the editor stays agnostic.
|
|
237
|
+
*/
|
|
238
|
+
documentLinkProvider?: DocumentLinkProvider | null;
|
|
239
|
+
/**
|
|
240
|
+
* Whether the in-editor media recorder is surfaced in the toolbar.
|
|
241
|
+
* Defaults to true — when a `mediaProvider` is wired, a record
|
|
242
|
+
* button appears next to the version history. Pass `false` to
|
|
243
|
+
* suppress it (read-only embeds, surfaces where camera/screen
|
|
244
|
+
* permission prompts would be jarring). Without a `mediaProvider`,
|
|
245
|
+
* the button is hidden regardless of this prop.
|
|
246
|
+
*/
|
|
247
|
+
allowRecording?: boolean;
|
|
152
248
|
/**
|
|
153
249
|
* Placeholder text shown in the WYSIWYG editor while the document is
|
|
154
250
|
* empty. When omitted, the editor rotates through its own generic
|
|
@@ -165,6 +261,103 @@ export interface EditorShellProps {
|
|
|
165
261
|
* accidental edits.
|
|
166
262
|
*/
|
|
167
263
|
readOnly?: boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Image source URL used when the resolved file mode is `image` (PNG,
|
|
266
|
+
* JPEG, GIF, WebP, BMP, ICO, AVIF). When this prop is set, the shell
|
|
267
|
+
* replaces its text-editing surfaces with a dedicated `ImageViewer`.
|
|
268
|
+
*
|
|
269
|
+
* Lifecycle of the URL is the caller's responsibility — when fed a
|
|
270
|
+
* `blob:` URL, the host should `URL.revokeObjectURL` on unmount or
|
|
271
|
+
* src change.
|
|
272
|
+
*/
|
|
273
|
+
imageSrc?: string;
|
|
274
|
+
/** Alt text passed through to the underlying ImageViewer. */
|
|
275
|
+
imageAlt?: string;
|
|
276
|
+
/**
|
|
277
|
+
* Whether the image surface should render as a read-only viewer
|
|
278
|
+
* (`'view'`, default) or as the editable {@link ImageEditor}
|
|
279
|
+
* (`'edit'`). Editing requires {@link EditorShellProps.imageEditorContainer}
|
|
280
|
+
* — without it the shell falls back to view mode and logs a warning.
|
|
281
|
+
*/
|
|
282
|
+
imageMode?: 'view' | 'edit';
|
|
283
|
+
/**
|
|
284
|
+
* Sidecar `ContentContainer` for the image being edited. Conventionally
|
|
285
|
+
* scoped to `<basename>_files/` via
|
|
286
|
+
* `scopeContainer(parentContainer, basename + '_files')`. The image
|
|
287
|
+
* editor persists `state.json`, layer assets in `assets/`, and (when
|
|
288
|
+
* `allowVersioning` is true) snapshots in `.versions/` inside it.
|
|
289
|
+
*/
|
|
290
|
+
imageEditorContainer?: ContentContainer;
|
|
291
|
+
/**
|
|
292
|
+
* Called after the user clicks Export in the image editor and the
|
|
293
|
+
* raster blob is produced. When omitted, the editor triggers a
|
|
294
|
+
* default browser download.
|
|
295
|
+
*/
|
|
296
|
+
onImageExport?: (blob: Blob, format: 'png' | 'jpeg' | 'webp') => void;
|
|
297
|
+
/**
|
|
298
|
+
* Show an inline preview gutter to the right of the WYSIWYG editor.
|
|
299
|
+
* The gutter renders one small SVG card per template-annotated block in
|
|
300
|
+
* the document, letting authors see their rendered output without
|
|
301
|
+
* leaving Edit mode. Auto-hidden via container query when the editor
|
|
302
|
+
* body is narrower than ~720px. Defaults to `false`.
|
|
303
|
+
*/
|
|
304
|
+
inlinePreview?: boolean;
|
|
305
|
+
/**
|
|
306
|
+
* Width in pixels for the inline preview gutter. Defaults to 320.
|
|
307
|
+
* Only takes effect when {@link EditorShellProps.inlinePreview} is true.
|
|
308
|
+
*/
|
|
309
|
+
inlinePreviewWidth?: number;
|
|
310
|
+
/**
|
|
311
|
+
* Show an outline pane on the left of the WYSIWYG editor — a
|
|
312
|
+
* hierarchical tree of the document's headings (h1 → h2 → h3) with
|
|
313
|
+
* click-to-scroll. Auto-hidden via container query on narrow editors.
|
|
314
|
+
* Defaults to `false`. The toolbar's View menu can toggle this at
|
|
315
|
+
* runtime regardless of the initial value.
|
|
316
|
+
*/
|
|
317
|
+
outline?: boolean;
|
|
318
|
+
/**
|
|
319
|
+
* Width in pixels for the outline pane. Defaults to 240. Only takes
|
|
320
|
+
* effect when {@link EditorShellProps.outline} is true (or the View
|
|
321
|
+
* menu has toggled it on).
|
|
322
|
+
*/
|
|
323
|
+
outlineWidth?: number;
|
|
324
|
+
/**
|
|
325
|
+
* Initial visibility of inline block-template tags on headings — the
|
|
326
|
+
* chip rendered next to each heading in the WYSIWYG view that opens
|
|
327
|
+
* the block-template picker. Defaults to true; the View menu can
|
|
328
|
+
* toggle it at runtime regardless of the initial value.
|
|
329
|
+
*/
|
|
330
|
+
blockTags?: boolean;
|
|
331
|
+
/**
|
|
332
|
+
* How much of the active Squisq theme the WYSIWYG editing surface
|
|
333
|
+
* mirrors. Defaults to `'fonts'` — the historical behavior of
|
|
334
|
+
* inheriting body / heading fonts only. The View menu can change it
|
|
335
|
+
* at runtime.
|
|
336
|
+
*/
|
|
337
|
+
themeInheritance?: ThemeInheritance;
|
|
338
|
+
/**
|
|
339
|
+
* Bundled view preferences — a serializable JSON blob covering the
|
|
340
|
+
* runtime-toggleable view options surfaced in the View menu. When
|
|
341
|
+
* provided, fields here override the corresponding individual props
|
|
342
|
+
* (`outline`, `inlinePreview`, `showStatusBar`). Pair with
|
|
343
|
+
* {@link onViewPreferencesChange} to externalize storage of these
|
|
344
|
+
* preferences in the host.
|
|
345
|
+
*/
|
|
346
|
+
viewPreferences?: ViewPreferences;
|
|
347
|
+
/**
|
|
348
|
+
* Notified after each user-driven toggle in the View menu. The
|
|
349
|
+
* argument is a full snapshot of all view preferences — hosts can
|
|
350
|
+
* persist it as-is. Not called when {@link viewPreferences} is
|
|
351
|
+
* changed externally.
|
|
352
|
+
*/
|
|
353
|
+
onViewPreferencesChange?: (prefs: ViewPreferences) => void;
|
|
354
|
+
/**
|
|
355
|
+
* Override the preview theme with an explicit `Theme` object. When set,
|
|
356
|
+
* `Doc.themeId` and the user's theme dropdown selection are ignored for
|
|
357
|
+
* the preview surface. Used by the theme customizer to live-preview an
|
|
358
|
+
* in-progress theme without mutating the document.
|
|
359
|
+
*/
|
|
360
|
+
themeOverride?: Theme | null;
|
|
168
361
|
}
|
|
169
362
|
|
|
170
363
|
/**
|
|
@@ -180,8 +373,16 @@ export function EditorShell({
|
|
|
180
373
|
theme = 'light',
|
|
181
374
|
className,
|
|
182
375
|
height = '100vh',
|
|
376
|
+
minHeight,
|
|
377
|
+
maxHeight,
|
|
183
378
|
mediaProvider,
|
|
379
|
+
workspaceContainer,
|
|
184
380
|
container,
|
|
381
|
+
allowVersioning = false,
|
|
382
|
+
versionBasename,
|
|
383
|
+
versioningPrunePolicy,
|
|
384
|
+
versioningAutoSaveIdleMs,
|
|
385
|
+
onSaveVersion,
|
|
185
386
|
showFilesToggle,
|
|
186
387
|
toolbarSlotLeft,
|
|
187
388
|
toolbarSlotAfterActions,
|
|
@@ -196,11 +397,39 @@ export function EditorShell({
|
|
|
196
397
|
fileName,
|
|
197
398
|
language,
|
|
198
399
|
mentionProvider,
|
|
400
|
+
documentLinkProvider,
|
|
401
|
+
allowRecording = true,
|
|
199
402
|
placeholder,
|
|
200
403
|
readOnly = false,
|
|
404
|
+
imageSrc,
|
|
405
|
+
imageAlt,
|
|
406
|
+
imageMode = 'view',
|
|
407
|
+
imageEditorContainer,
|
|
408
|
+
onImageExport,
|
|
409
|
+
inlinePreview = false,
|
|
410
|
+
inlinePreviewWidth = 320,
|
|
411
|
+
outline = false,
|
|
412
|
+
outlineWidth = 240,
|
|
413
|
+
blockTags = true,
|
|
414
|
+
themeInheritance = 'fonts',
|
|
415
|
+
viewPreferences,
|
|
416
|
+
onViewPreferencesChange,
|
|
417
|
+
themeOverride = null,
|
|
201
418
|
}: EditorShellProps) {
|
|
419
|
+
const effectiveContainer = workspaceContainer ?? container ?? null;
|
|
420
|
+
|
|
421
|
+
// If the host gave us a `workspaceContainer` but no explicit `mediaProvider`,
|
|
422
|
+
// derive one automatically. Without this, drag-and-drop of an image
|
|
423
|
+
// into the editor silently failed (no provider \u2192 nothing to upload to)
|
|
424
|
+
// even though we had a perfectly good ContentContainer to write into.
|
|
425
|
+
const effectiveMediaProvider = useMemo<MediaProvider | null | undefined>(() => {
|
|
426
|
+
if (mediaProvider !== undefined) return mediaProvider;
|
|
427
|
+
if (effectiveContainer) return createMediaProviderFromContainer(effectiveContainer);
|
|
428
|
+
return undefined;
|
|
429
|
+
}, [mediaProvider, effectiveContainer]);
|
|
430
|
+
|
|
202
431
|
// Show the toggle when explicitly opted in, or when mediaProvider prop was passed at all
|
|
203
|
-
const filesToggleEnabled = showFilesToggle ??
|
|
432
|
+
const filesToggleEnabled = showFilesToggle ?? effectiveMediaProvider !== undefined;
|
|
204
433
|
|
|
205
434
|
// If the host hides the Play tab but asked for it as the initial view,
|
|
206
435
|
// fall back to wysiwyg so we don't boot into a tab the user can't leave.
|
|
@@ -213,20 +442,37 @@ export function EditorShell({
|
|
|
213
442
|
initialView={effectiveInitialView}
|
|
214
443
|
articleId={articleId}
|
|
215
444
|
theme={theme}
|
|
216
|
-
|
|
445
|
+
workspaceContainer={effectiveContainer}
|
|
446
|
+
allowVersioning={allowVersioning}
|
|
447
|
+
versionBasename={versionBasename}
|
|
448
|
+
versioningPrunePolicy={versioningPrunePolicy}
|
|
449
|
+
versioningAutoSaveIdleMs={versioningAutoSaveIdleMs}
|
|
450
|
+
onSaveVersion={onSaveVersion}
|
|
451
|
+
mediaProvider={effectiveMediaProvider}
|
|
217
452
|
imageDisplayMode={imageDisplayMode}
|
|
218
453
|
mentionProvider={mentionProvider}
|
|
454
|
+
documentLinkProvider={documentLinkProvider}
|
|
455
|
+
allowRecording={allowRecording}
|
|
219
456
|
fileName={fileName}
|
|
220
457
|
language={language}
|
|
458
|
+
inlinePreview={inlinePreview}
|
|
459
|
+
showStatusBar={showStatusBar}
|
|
460
|
+
outline={outline}
|
|
461
|
+
blockTags={blockTags}
|
|
462
|
+
themeInheritance={themeInheritance}
|
|
463
|
+
viewPreferences={viewPreferences}
|
|
464
|
+
onViewPreferencesChange={onViewPreferencesChange}
|
|
221
465
|
>
|
|
222
466
|
<EditorShellInner
|
|
223
467
|
basePath={basePath}
|
|
224
468
|
onChange={onChange}
|
|
225
469
|
className={className}
|
|
226
470
|
height={height}
|
|
471
|
+
minHeight={minHeight}
|
|
472
|
+
maxHeight={maxHeight}
|
|
227
473
|
placeholder={placeholder}
|
|
228
|
-
mediaProvider={
|
|
229
|
-
|
|
474
|
+
mediaProvider={effectiveMediaProvider ?? null}
|
|
475
|
+
workspaceContainer={effectiveContainer}
|
|
230
476
|
filesToggleEnabled={filesToggleEnabled}
|
|
231
477
|
toolbarSlotLeft={toolbarSlotLeft}
|
|
232
478
|
toolbarSlotAfterActions={toolbarSlotAfterActions}
|
|
@@ -236,8 +482,17 @@ export function EditorShell({
|
|
|
236
482
|
fullWidth={fullWidth}
|
|
237
483
|
uxFont={uxFont}
|
|
238
484
|
thinMargins={thinMargins}
|
|
239
|
-
showStatusBar={showStatusBar}
|
|
240
485
|
readOnly={readOnly}
|
|
486
|
+
imageSrc={imageSrc}
|
|
487
|
+
imageAlt={imageAlt}
|
|
488
|
+
imageMode={imageMode}
|
|
489
|
+
imageEditorContainer={imageEditorContainer}
|
|
490
|
+
onImageExport={onImageExport}
|
|
491
|
+
allowVersioning={allowVersioning}
|
|
492
|
+
versioningAutoSaveIdleMs={versioningAutoSaveIdleMs}
|
|
493
|
+
inlinePreviewWidth={inlinePreviewWidth}
|
|
494
|
+
outlineWidth={outlineWidth}
|
|
495
|
+
themeOverride={themeOverride}
|
|
241
496
|
/>
|
|
242
497
|
</EditorProvider>
|
|
243
498
|
);
|
|
@@ -248,9 +503,11 @@ interface EditorShellInnerProps {
|
|
|
248
503
|
onChange?: (source: string) => void;
|
|
249
504
|
className?: string;
|
|
250
505
|
height: string;
|
|
506
|
+
minHeight?: string;
|
|
507
|
+
maxHeight?: string;
|
|
251
508
|
placeholder?: string;
|
|
252
509
|
mediaProvider: MediaProvider | null;
|
|
253
|
-
|
|
510
|
+
workspaceContainer?: ContentContainer | null;
|
|
254
511
|
filesToggleEnabled: boolean;
|
|
255
512
|
toolbarSlotLeft?: ReactNode;
|
|
256
513
|
toolbarSlotAfterActions?: ReactNode;
|
|
@@ -260,8 +517,17 @@ interface EditorShellInnerProps {
|
|
|
260
517
|
fullWidth: boolean;
|
|
261
518
|
uxFont?: string;
|
|
262
519
|
thinMargins: boolean;
|
|
263
|
-
showStatusBar: boolean;
|
|
264
520
|
readOnly: boolean;
|
|
521
|
+
imageSrc?: string;
|
|
522
|
+
imageAlt?: string;
|
|
523
|
+
imageMode: 'view' | 'edit';
|
|
524
|
+
imageEditorContainer?: ContentContainer;
|
|
525
|
+
onImageExport?: (blob: Blob, format: 'png' | 'jpeg' | 'webp') => void;
|
|
526
|
+
allowVersioning: boolean;
|
|
527
|
+
versioningAutoSaveIdleMs?: number;
|
|
528
|
+
inlinePreviewWidth: number;
|
|
529
|
+
outlineWidth: number;
|
|
530
|
+
themeOverride: Theme | null;
|
|
265
531
|
}
|
|
266
532
|
|
|
267
533
|
function EditorShellInner({
|
|
@@ -269,9 +535,11 @@ function EditorShellInner({
|
|
|
269
535
|
onChange,
|
|
270
536
|
className,
|
|
271
537
|
height,
|
|
538
|
+
minHeight,
|
|
539
|
+
maxHeight,
|
|
272
540
|
placeholder,
|
|
273
541
|
mediaProvider,
|
|
274
|
-
|
|
542
|
+
workspaceContainer,
|
|
275
543
|
filesToggleEnabled,
|
|
276
544
|
toolbarSlotLeft,
|
|
277
545
|
toolbarSlotAfterActions,
|
|
@@ -281,15 +549,52 @@ function EditorShellInner({
|
|
|
281
549
|
fullWidth,
|
|
282
550
|
uxFont,
|
|
283
551
|
thinMargins,
|
|
284
|
-
showStatusBar,
|
|
285
552
|
readOnly,
|
|
553
|
+
imageSrc,
|
|
554
|
+
imageAlt,
|
|
555
|
+
imageMode,
|
|
556
|
+
imageEditorContainer,
|
|
557
|
+
onImageExport,
|
|
558
|
+
allowVersioning,
|
|
559
|
+
versioningAutoSaveIdleMs,
|
|
560
|
+
inlinePreviewWidth,
|
|
561
|
+
outlineWidth,
|
|
562
|
+
themeOverride,
|
|
286
563
|
}: EditorShellInnerProps) {
|
|
287
|
-
const {
|
|
288
|
-
|
|
564
|
+
const {
|
|
565
|
+
activeView,
|
|
566
|
+
markdownSource,
|
|
567
|
+
doc,
|
|
568
|
+
theme,
|
|
569
|
+
editorMode,
|
|
570
|
+
insertAtCursor,
|
|
571
|
+
replaceAll,
|
|
572
|
+
tiptapEditor,
|
|
573
|
+
monacoEditor,
|
|
574
|
+
setMarkdownSource,
|
|
575
|
+
inlinePreviewVisible,
|
|
576
|
+
statusBarVisible,
|
|
577
|
+
outlineVisible,
|
|
578
|
+
imageEditTarget,
|
|
579
|
+
closeImageEdit,
|
|
580
|
+
bumpMediaRevision,
|
|
581
|
+
} = useEditorContext();
|
|
289
582
|
const isPreview = activeView === 'preview';
|
|
290
583
|
const isCodeMode = editorMode === 'code';
|
|
584
|
+
const isImageMode = editorMode === 'image';
|
|
585
|
+
const isMarkdownMode = editorMode === 'markdown';
|
|
291
586
|
const [showFiles, setShowFiles] = useState(false);
|
|
292
587
|
const [mediaRefreshKey, setMediaRefreshKey] = useState(0);
|
|
588
|
+
// Persistent fallback container for image-edit sidecars when the host
|
|
589
|
+
// didn't supply one. Lifted to shell scope so opening the same image
|
|
590
|
+
// multiple times sees the same `.imageEdits/<sanitized>/.versions/...`
|
|
591
|
+
// snapshots — otherwise each modal mount would start from an empty
|
|
592
|
+
// in-memory container and history would vanish on close.
|
|
593
|
+
const imageEditFallbackContainerRef = useRef<MemoryContentContainer | null>(null);
|
|
594
|
+
if (imageEditFallbackContainerRef.current === null) {
|
|
595
|
+
imageEditFallbackContainerRef.current = new MemoryContentContainer();
|
|
596
|
+
}
|
|
597
|
+
const imageEditFallbackContainer = imageEditFallbackContainerRef.current;
|
|
293
598
|
const isDark = theme === 'dark';
|
|
294
599
|
|
|
295
600
|
const handleToggleFiles = useCallback(() => {
|
|
@@ -298,6 +603,57 @@ function EditorShellInner({
|
|
|
298
603
|
|
|
299
604
|
// ── Drag-and-drop file handling ──
|
|
300
605
|
|
|
606
|
+
/**
|
|
607
|
+
* Insert an uploaded media file at the editor's current cursor.
|
|
608
|
+
*
|
|
609
|
+
* - In **WYSIWYG** mode, insert an actual tiptap image node via
|
|
610
|
+
* `setImage({src, alt})` (images) or a link mark (non-images).
|
|
611
|
+
* Going through `setImage` directly mirrors the Toolbar's image
|
|
612
|
+
* button and avoids the round-trip through `markdownToTiptap`
|
|
613
|
+
* that historically lost `<img>` tags to tag-strip passes.
|
|
614
|
+
* - In **raw (Monaco)** or **preview** mode, fall back to
|
|
615
|
+
* `insertAtCursor` which emits the markdown snippet.
|
|
616
|
+
*
|
|
617
|
+
* Without this, upload-via-MediaBin and upload-via-drop both
|
|
618
|
+
* added the file to the bin and nowhere else — the composer sent
|
|
619
|
+
* an empty body and the downstream gezel reported "nothing came
|
|
620
|
+
* through."
|
|
621
|
+
*/
|
|
622
|
+
const insertMediaRef = useCallback(
|
|
623
|
+
(relativePath: string, name: string, mimeType: string) => {
|
|
624
|
+
const alt = name.replace(/\.[^.]+$/, '').replace(/[-_]/g, ' ');
|
|
625
|
+
const isImage = mimeType.startsWith('image/');
|
|
626
|
+
const snippet = isImage ? `` : `[${alt}](${relativePath})`;
|
|
627
|
+
|
|
628
|
+
if (activeView === 'wysiwyg' && tiptapEditor) {
|
|
629
|
+
if (isImage) {
|
|
630
|
+
tiptapEditor.chain().focus().setImage({ src: relativePath, alt }).run();
|
|
631
|
+
} else {
|
|
632
|
+
tiptapEditor
|
|
633
|
+
.chain()
|
|
634
|
+
.focus()
|
|
635
|
+
.insertContent([
|
|
636
|
+
{
|
|
637
|
+
type: 'text',
|
|
638
|
+
marks: [{ type: 'link', attrs: { href: relativePath } }],
|
|
639
|
+
text: alt,
|
|
640
|
+
},
|
|
641
|
+
])
|
|
642
|
+
.run();
|
|
643
|
+
}
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
if (activeView === 'raw' && monacoEditor) {
|
|
647
|
+
insertAtCursor(snippet);
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
// Preview mode — no interactive editor to insert into. Append
|
|
651
|
+
// to markdown source so the ref is still in the buffer.
|
|
652
|
+
setMarkdownSource(markdownSource ? `${markdownSource}\n\n${snippet}` : snippet);
|
|
653
|
+
},
|
|
654
|
+
[activeView, tiptapEditor, monacoEditor, insertAtCursor, markdownSource, setMarkdownSource],
|
|
655
|
+
);
|
|
656
|
+
|
|
301
657
|
const handleFileDrop = useCallback(
|
|
302
658
|
async (files: File[], target: DropTarget) => {
|
|
303
659
|
try {
|
|
@@ -305,10 +661,21 @@ function EditorShellInner({
|
|
|
305
661
|
|
|
306
662
|
// Process media files
|
|
307
663
|
if (media.length > 0 && mediaProvider) {
|
|
308
|
-
await processMediaFiles(media, mediaProvider);
|
|
664
|
+
const paths = await processMediaFiles(media, mediaProvider);
|
|
309
665
|
setMediaRefreshKey((k) => k + 1);
|
|
310
666
|
// Auto-open the media bin so the user sees the new files
|
|
311
667
|
if (!showFiles) setShowFiles(true);
|
|
668
|
+
// Insert each uploaded file as a markdown ref at the cursor so
|
|
669
|
+
// the body actually contains the attachment. Without this the
|
|
670
|
+
// bin holds the file but the serialized markdown stays empty,
|
|
671
|
+
// and anything downstream (chat send, document save) sees no
|
|
672
|
+
// reference to the upload.
|
|
673
|
+
for (let i = 0; i < media.length; i++) {
|
|
674
|
+
const file = media[i];
|
|
675
|
+
const path = paths[i];
|
|
676
|
+
if (!file || !path) continue;
|
|
677
|
+
insertMediaRef(path, file.name, file.type || 'application/octet-stream');
|
|
678
|
+
}
|
|
312
679
|
}
|
|
313
680
|
|
|
314
681
|
// Process text files
|
|
@@ -327,7 +694,7 @@ function EditorShellInner({
|
|
|
327
694
|
console.error('Failed to process dropped files:', err instanceof Error ? err.message : err);
|
|
328
695
|
}
|
|
329
696
|
},
|
|
330
|
-
[mediaProvider, showFiles, replaceAll, insertAtCursor],
|
|
697
|
+
[mediaProvider, showFiles, replaceAll, insertAtCursor, insertMediaRef],
|
|
331
698
|
);
|
|
332
699
|
|
|
333
700
|
const { isDragging, dragContentType, containerProps, zoneProps } = useFileDrop({
|
|
@@ -364,89 +731,350 @@ function EditorShellInner({
|
|
|
364
731
|
return () => window.removeEventListener('keydown', handler);
|
|
365
732
|
}, [showPlayTab]);
|
|
366
733
|
|
|
734
|
+
const autoGrow = minHeight !== undefined || maxHeight !== undefined;
|
|
735
|
+
|
|
367
736
|
return (
|
|
368
737
|
<div
|
|
369
738
|
className={`squisq-editor-shell ${className || ''}`}
|
|
370
739
|
data-theme={theme}
|
|
371
740
|
data-full-width={fullWidth ? 'true' : undefined}
|
|
372
741
|
data-thin-margins={thinMargins ? 'true' : undefined}
|
|
742
|
+
data-outline-visible={isMarkdownMode && outlineVisible ? 'true' : undefined}
|
|
373
743
|
style={{
|
|
374
744
|
display: 'flex',
|
|
375
745
|
flexDirection: 'column',
|
|
376
|
-
height,
|
|
377
746
|
overflow: 'hidden',
|
|
747
|
+
...(autoGrow ? { minHeight, maxHeight } : { height }),
|
|
378
748
|
// When a consumer supplies a UX font stack, expose it to the
|
|
379
749
|
// editor CSS via this custom property. Chrome elements (toolbar,
|
|
380
750
|
// tabs, status bar) consume `--squisq-ux-font` as their
|
|
381
751
|
// `font-family`, falling back to the system stack when unset.
|
|
382
752
|
...(uxFont ? ({ '--squisq-ux-font': uxFont } as CSSProperties) : {}),
|
|
753
|
+
// Exposed so the toolbar's view-tabs section can match the outline
|
|
754
|
+
// pane's width, lining up its right-edge separator with the
|
|
755
|
+
// outline's right edge. The variable is set unconditionally so the
|
|
756
|
+
// outline pane itself can also read it if needed; the
|
|
757
|
+
// `data-outline-visible` gate above keeps the toolbar override
|
|
758
|
+
// scoped to the case where alignment matters.
|
|
759
|
+
...({ '--squisq-outline-width': `${outlineWidth}px` } as CSSProperties),
|
|
383
760
|
}}
|
|
384
761
|
{...containerProps}
|
|
385
762
|
>
|
|
386
|
-
<PreviewSettingsProvider doc={doc}>
|
|
387
|
-
{/* Header
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
763
|
+
<PreviewSettingsProvider doc={doc} themeOverride={themeOverride}>
|
|
764
|
+
{/* Header. In image mode the full markdown/code Toolbar is replaced
|
|
765
|
+
with a minimal slot bar — view tabs, formatting, and preview
|
|
766
|
+
controls don't apply to a binary asset. */}
|
|
767
|
+
{isImageMode ? (
|
|
768
|
+
(toolbarSlotLeft || toolbarSlotRight) && (
|
|
769
|
+
<div className="squisq-editor-header squisq-editor-header--image">
|
|
770
|
+
{toolbarSlotLeft}
|
|
771
|
+
<div style={{ flex: 1 }} />
|
|
772
|
+
{toolbarSlotRight}
|
|
773
|
+
</div>
|
|
774
|
+
)
|
|
775
|
+
) : (
|
|
776
|
+
<div className="squisq-editor-header">
|
|
777
|
+
<Toolbar
|
|
778
|
+
showFiles={showFiles}
|
|
779
|
+
onToggleFiles={!isCodeMode && filesToggleEnabled ? handleToggleFiles : undefined}
|
|
780
|
+
slotLeft={toolbarSlotLeft}
|
|
781
|
+
slotAfterActions={
|
|
782
|
+
<>
|
|
783
|
+
{toolbarSlotAfterActions}
|
|
784
|
+
{!isCodeMode && isPreview && <PreviewToolbarControls />}
|
|
785
|
+
</>
|
|
786
|
+
}
|
|
787
|
+
slotRight={toolbarSlotRight}
|
|
788
|
+
showPlayTab={showPlayTab}
|
|
789
|
+
/>
|
|
790
|
+
</div>
|
|
791
|
+
)}
|
|
403
792
|
|
|
404
793
|
{/* Main content area */}
|
|
405
794
|
<div
|
|
406
795
|
className="squisq-editor-content"
|
|
407
|
-
style={{
|
|
796
|
+
style={{
|
|
797
|
+
flex: autoGrow ? '1 1 auto' : 1,
|
|
798
|
+
overflowY: autoGrow ? 'auto' : 'hidden',
|
|
799
|
+
overflowX: 'hidden',
|
|
800
|
+
minHeight: 0,
|
|
801
|
+
position: 'relative',
|
|
802
|
+
display: 'flex',
|
|
803
|
+
}}
|
|
408
804
|
>
|
|
409
|
-
<div
|
|
410
|
-
{
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
805
|
+
<div
|
|
806
|
+
style={{
|
|
807
|
+
flex: autoGrow ? '1 1 auto' : 1,
|
|
808
|
+
overflow: autoGrow ? 'visible' : 'hidden',
|
|
809
|
+
minHeight: 0,
|
|
810
|
+
position: 'relative',
|
|
811
|
+
}}
|
|
812
|
+
>
|
|
813
|
+
{isImageMode &&
|
|
814
|
+
imageSrc &&
|
|
815
|
+
(imageMode === 'edit' && imageEditorContainer ? (
|
|
816
|
+
<ImageEditor
|
|
817
|
+
filesContainer={imageEditorContainer}
|
|
818
|
+
initialSrc={imageSrc}
|
|
819
|
+
allowVersioning={allowVersioning}
|
|
820
|
+
versioningAutoSaveIdleMs={versioningAutoSaveIdleMs}
|
|
821
|
+
onExport={onImageExport}
|
|
822
|
+
/>
|
|
823
|
+
) : (
|
|
824
|
+
<ImageViewer src={imageSrc} alt={imageAlt} theme={theme} />
|
|
825
|
+
))}
|
|
826
|
+
{/* Raw (Monaco) view. Always wrapped in `.squisq-editor-with-gutter`
|
|
827
|
+
so toggling a pane on/off doesn't change the editor's tree
|
|
828
|
+
position — Monaco stays mounted and `monacoEditor` in
|
|
829
|
+
context stays stable, which is what `useHeadingLayout` needs
|
|
830
|
+
to compute positions. */}
|
|
831
|
+
{!isImageMode && activeView === 'raw' && (
|
|
832
|
+
<div className="squisq-editor-with-gutter" key="raw-shell">
|
|
833
|
+
{isMarkdownMode && outlineVisible && (
|
|
834
|
+
<OutlinePanel key="outline" width={outlineWidth} />
|
|
835
|
+
)}
|
|
836
|
+
<div key="raw-editor" className="squisq-raw-editor-container">
|
|
837
|
+
<RawEditor
|
|
838
|
+
theme={theme === 'dark' ? 'vs-dark' : 'vs'}
|
|
839
|
+
submitOnEnter={submitOnEnter}
|
|
840
|
+
readOnly={readOnly}
|
|
841
|
+
/>
|
|
842
|
+
</div>
|
|
843
|
+
{isMarkdownMode && inlinePreviewVisible && (
|
|
844
|
+
<InlinePreviewGutter
|
|
845
|
+
key="inline"
|
|
846
|
+
width={inlinePreviewWidth}
|
|
847
|
+
basePath={basePath}
|
|
848
|
+
mediaProvider={mediaProvider}
|
|
849
|
+
/>
|
|
850
|
+
)}
|
|
851
|
+
</div>
|
|
416
852
|
)}
|
|
417
853
|
{/* WYSIWYG + Preview are markdown-only surfaces — skip them
|
|
418
|
-
entirely in code mode so Tiptap never initializes
|
|
419
|
-
preview pipeline stays idle.
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
854
|
+
entirely in code or image mode so Tiptap never initializes
|
|
855
|
+
and the preview pipeline stays idle. Same always-wrapped
|
|
856
|
+
pattern as the Raw branch above so pane toggles don't
|
|
857
|
+
remount Tiptap. */}
|
|
858
|
+
{isMarkdownMode && activeView === 'wysiwyg' && (
|
|
859
|
+
<div className="squisq-editor-with-gutter" key="wysiwyg-shell">
|
|
860
|
+
{outlineVisible && <OutlinePanel key="outline" width={outlineWidth} />}
|
|
861
|
+
<WysiwygEditor
|
|
862
|
+
key="wysiwyg-editor"
|
|
863
|
+
submitOnEnter={submitOnEnter}
|
|
864
|
+
placeholder={placeholder}
|
|
865
|
+
readOnly={readOnly}
|
|
866
|
+
/>
|
|
867
|
+
{inlinePreviewVisible && (
|
|
868
|
+
<InlinePreviewGutter
|
|
869
|
+
key="inline"
|
|
870
|
+
width={inlinePreviewWidth}
|
|
871
|
+
basePath={basePath}
|
|
872
|
+
mediaProvider={mediaProvider}
|
|
873
|
+
/>
|
|
874
|
+
)}
|
|
875
|
+
</div>
|
|
876
|
+
)}
|
|
877
|
+
{isMarkdownMode && isPreview && (
|
|
878
|
+
<PreviewPanel basePath={basePath} workspaceContainer={workspaceContainer} />
|
|
426
879
|
)}
|
|
427
|
-
{!isCodeMode && isPreview && <PreviewPanel basePath={basePath} container={container} />}
|
|
428
880
|
</div>
|
|
429
881
|
|
|
430
|
-
{
|
|
431
|
-
<MediaBin
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
<DropZoneOverlay
|
|
437
|
-
dragContentType={dragContentType}
|
|
438
|
-
zoneProps={zoneProps}
|
|
439
|
-
hasMediaProvider={mediaProvider !== null}
|
|
882
|
+
{isMarkdownMode && showFiles && (
|
|
883
|
+
<MediaBin
|
|
884
|
+
mediaProvider={mediaProvider}
|
|
885
|
+
isDark={isDark}
|
|
886
|
+
refreshKey={mediaRefreshKey}
|
|
887
|
+
onMediaUploaded={insertMediaRef}
|
|
440
888
|
/>
|
|
441
889
|
)}
|
|
890
|
+
|
|
891
|
+
{/* Drop zone overlay — image / text drop UX is markdown-specific.
|
|
892
|
+
In WYSIWYG, image drops are handled directly by Tiptap's
|
|
893
|
+
`handleDrop` (uploads to the MediaProvider and inserts an
|
|
894
|
+
image node at the mouse position). The overlay would sit on
|
|
895
|
+
top with z-index: 50 and intercept the drop, so we skip it
|
|
896
|
+
when the dragged content is media-only on the WYSIWYG view —
|
|
897
|
+
the user gets a one-step "drop where you want it" flow
|
|
898
|
+
instead of a two-step "drop in bin, then insert" flow. */}
|
|
899
|
+
{isMarkdownMode &&
|
|
900
|
+
isDragging &&
|
|
901
|
+
!(activeView === 'wysiwyg' && dragContentType === 'media') && (
|
|
902
|
+
<DropZoneOverlay
|
|
903
|
+
dragContentType={dragContentType}
|
|
904
|
+
zoneProps={zoneProps}
|
|
905
|
+
hasMediaProvider={mediaProvider !== null}
|
|
906
|
+
/>
|
|
907
|
+
)}
|
|
442
908
|
</div>
|
|
443
909
|
|
|
444
910
|
{/* Status bar — word / char / line / block counts. Host can
|
|
445
911
|
suppress via `showStatusBar={false}` for embedded chat-style
|
|
446
|
-
composers where the stats are noise.
|
|
447
|
-
|
|
912
|
+
composers where the stats are noise. The image viewer has its
|
|
913
|
+
own dimension/zoom status row, so suppress here too. */}
|
|
914
|
+
{statusBarVisible && !isImageMode && <StatusBar />}
|
|
448
915
|
</PreviewSettingsProvider>
|
|
449
916
|
<TooltipLayer />
|
|
917
|
+
{imageEditTarget !== null && mediaProvider && (
|
|
918
|
+
<ImageEditModal
|
|
919
|
+
relativePath={imageEditTarget}
|
|
920
|
+
container={workspaceContainer ?? imageEditFallbackContainer}
|
|
921
|
+
mediaProvider={mediaProvider}
|
|
922
|
+
onClose={closeImageEdit}
|
|
923
|
+
onSaved={() => {
|
|
924
|
+
bumpMediaRevision();
|
|
925
|
+
closeImageEdit();
|
|
926
|
+
}}
|
|
927
|
+
allowVersioning={allowVersioning}
|
|
928
|
+
versioningAutoSaveIdleMs={versioningAutoSaveIdleMs}
|
|
929
|
+
shellTheme={theme}
|
|
930
|
+
/>
|
|
931
|
+
)}
|
|
932
|
+
</div>
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// ─── ImageEditModal ────────────────────────────────────────
|
|
937
|
+
|
|
938
|
+
interface ImageEditModalProps {
|
|
939
|
+
relativePath: string;
|
|
940
|
+
/**
|
|
941
|
+
* Host's `ContentContainer`. When non-null the editor's per-image
|
|
942
|
+
* sidecar is scoped underneath it as `.imageEdits/<sanitized>/` so
|
|
943
|
+
* version snapshots travel with the doc. When null (host wired only a
|
|
944
|
+
* `mediaProvider`) the modal creates a fresh in-memory container for
|
|
945
|
+
* the edit session — export still writes the result back through
|
|
946
|
+
* `mediaProvider`.
|
|
947
|
+
*/
|
|
948
|
+
container: ContentContainer | null;
|
|
949
|
+
mediaProvider: MediaProvider;
|
|
950
|
+
onClose: () => void;
|
|
951
|
+
onSaved: () => void;
|
|
952
|
+
allowVersioning: boolean;
|
|
953
|
+
versioningAutoSaveIdleMs?: number;
|
|
954
|
+
/** EditorShell's `theme` prop — 'light' or 'dark'. Threaded through so
|
|
955
|
+
* the image editor chrome matches the host shell. */
|
|
956
|
+
shellTheme?: 'light' | 'dark';
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* Modal overlay that mounts a full `<ImageEditor>` against a sidecar
|
|
961
|
+
* container scoped under `.imageEdits/<sanitized-path>/` of the document's
|
|
962
|
+
* `ContentContainer`. Opens when a user clicks the "Edit" affordance on an
|
|
963
|
+
* image in the WYSIWYG view; on Export, rewrites the original image bytes
|
|
964
|
+
* via `mediaProvider.addMedia(relativePath, blob, mime)` and bumps
|
|
965
|
+
* `mediaRevision` so live `<img>` nodes pick up the new content.
|
|
966
|
+
*/
|
|
967
|
+
function ImageEditModal({
|
|
968
|
+
relativePath,
|
|
969
|
+
container,
|
|
970
|
+
mediaProvider,
|
|
971
|
+
onClose,
|
|
972
|
+
onSaved,
|
|
973
|
+
allowVersioning,
|
|
974
|
+
versioningAutoSaveIdleMs,
|
|
975
|
+
shellTheme,
|
|
976
|
+
}: ImageEditModalProps) {
|
|
977
|
+
// Each unique image path gets its own sidecar so multiple images in the
|
|
978
|
+
// same doc can be edited independently without colliding state. When the
|
|
979
|
+
// host didn't supply a `container`, fall back to a fresh in-memory one
|
|
980
|
+
// — the edit session is transient anyway and the final raster is what
|
|
981
|
+
// gets written back through `mediaProvider`.
|
|
982
|
+
const sidecar = useMemo(() => {
|
|
983
|
+
const sanitized = relativePath.replace(/[^a-zA-Z0-9._-]+/g, '_');
|
|
984
|
+
const parent: ContentContainer = container ?? new MemoryContentContainer();
|
|
985
|
+
return scopeContainer(parent, `.imageEdits/${sanitized}`);
|
|
986
|
+
}, [container, relativePath]);
|
|
987
|
+
|
|
988
|
+
const [initialSrc, setInitialSrc] = useState<string | null>(null);
|
|
989
|
+
const [resolveError, setResolveError] = useState<string | null>(null);
|
|
990
|
+
useEffect(() => {
|
|
991
|
+
let cancelled = false;
|
|
992
|
+
mediaProvider.resolveUrl(relativePath).then(
|
|
993
|
+
(url) => {
|
|
994
|
+
if (!cancelled) setInitialSrc(url);
|
|
995
|
+
},
|
|
996
|
+
(err: unknown) => {
|
|
997
|
+
if (!cancelled) {
|
|
998
|
+
setResolveError(err instanceof Error ? err.message : String(err));
|
|
999
|
+
}
|
|
1000
|
+
},
|
|
1001
|
+
);
|
|
1002
|
+
return () => {
|
|
1003
|
+
cancelled = true;
|
|
1004
|
+
};
|
|
1005
|
+
}, [mediaProvider, relativePath]);
|
|
1006
|
+
|
|
1007
|
+
const handleExport = useCallback(
|
|
1008
|
+
(blob: Blob, format: 'png' | 'jpeg' | 'webp') => {
|
|
1009
|
+
const mime = `image/${format}`;
|
|
1010
|
+
mediaProvider.addMedia(relativePath, blob, mime).then(
|
|
1011
|
+
() => onSaved(),
|
|
1012
|
+
(err: unknown) => {
|
|
1013
|
+
console.error('Failed to write image back:', err instanceof Error ? err.message : err);
|
|
1014
|
+
},
|
|
1015
|
+
);
|
|
1016
|
+
},
|
|
1017
|
+
[mediaProvider, relativePath, onSaved],
|
|
1018
|
+
);
|
|
1019
|
+
|
|
1020
|
+
// Close on Escape — global listener so it works regardless of focus.
|
|
1021
|
+
useEffect(() => {
|
|
1022
|
+
const handler = (e: KeyboardEvent) => {
|
|
1023
|
+
if (e.key === 'Escape') onClose();
|
|
1024
|
+
};
|
|
1025
|
+
window.addEventListener('keydown', handler);
|
|
1026
|
+
return () => window.removeEventListener('keydown', handler);
|
|
1027
|
+
}, [onClose]);
|
|
1028
|
+
|
|
1029
|
+
return (
|
|
1030
|
+
<div
|
|
1031
|
+
className="squisq-image-edit-modal"
|
|
1032
|
+
data-testid="image-edit-modal"
|
|
1033
|
+
role="dialog"
|
|
1034
|
+
aria-modal="true"
|
|
1035
|
+
aria-label={`Edit ${relativePath}`}
|
|
1036
|
+
onClick={(e) => {
|
|
1037
|
+
// Click on the dim backdrop (but not on the surface) → close.
|
|
1038
|
+
if (e.target === e.currentTarget) onClose();
|
|
1039
|
+
}}
|
|
1040
|
+
>
|
|
1041
|
+
<div className="squisq-image-edit-modal__surface">
|
|
1042
|
+
<header className="squisq-image-edit-modal__header">
|
|
1043
|
+
<span className="squisq-image-edit-modal__title">Edit image</span>
|
|
1044
|
+
<span className="squisq-image-edit-modal__path">{relativePath}</span>
|
|
1045
|
+
<button
|
|
1046
|
+
type="button"
|
|
1047
|
+
className="squisq-image-edit-modal__close"
|
|
1048
|
+
data-testid="image-edit-modal-close"
|
|
1049
|
+
onClick={onClose}
|
|
1050
|
+
aria-label="Close image editor"
|
|
1051
|
+
>
|
|
1052
|
+
×
|
|
1053
|
+
</button>
|
|
1054
|
+
</header>
|
|
1055
|
+
<div className="squisq-image-edit-modal__body">
|
|
1056
|
+
{resolveError ? (
|
|
1057
|
+
<div className="squisq-image-edit-modal__error">
|
|
1058
|
+
Failed to load image: {resolveError}
|
|
1059
|
+
</div>
|
|
1060
|
+
) : !initialSrc ? (
|
|
1061
|
+
<div className="squisq-image-edit-modal__loading">Loading image…</div>
|
|
1062
|
+
) : (
|
|
1063
|
+
<ImageEditor
|
|
1064
|
+
filesContainer={sidecar}
|
|
1065
|
+
initialSrc={initialSrc}
|
|
1066
|
+
allowVersioning={allowVersioning}
|
|
1067
|
+
versioningAutoSaveIdleMs={versioningAutoSaveIdleMs}
|
|
1068
|
+
onExport={handleExport}
|
|
1069
|
+
saveBehavior="export"
|
|
1070
|
+
saveFormat="png"
|
|
1071
|
+
saveLabel="Save and close"
|
|
1072
|
+
saveTitle="Save changes back to the image and close"
|
|
1073
|
+
surface={shellTheme === 'dark' ? DARK_SURFACE : LIGHT_SURFACE}
|
|
1074
|
+
/>
|
|
1075
|
+
)}
|
|
1076
|
+
</div>
|
|
1077
|
+
</div>
|
|
450
1078
|
</div>
|
|
451
1079
|
);
|
|
452
1080
|
}
|