@bendyline/squisq-editor-react 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DocumentSettingsDialog.d.ts +26 -0
- package/dist/DocumentSettingsDialog.d.ts.map +1 -0
- package/dist/DocumentSettingsDialog.js +115 -0
- package/dist/DocumentSettingsDialog.js.map +1 -0
- package/dist/EditorContext.d.ts +248 -4
- package/dist/EditorContext.d.ts.map +1 -1
- package/dist/EditorContext.js +248 -10
- package/dist/EditorContext.js.map +1 -1
- package/dist/EditorShell.d.ts +173 -4
- package/dist/EditorShell.d.ts.map +1 -1
- package/dist/EditorShell.js +110 -10
- package/dist/EditorShell.js.map +1 -1
- package/dist/EmojiPicker.d.ts +50 -0
- package/dist/EmojiPicker.d.ts.map +1 -0
- package/dist/EmojiPicker.js +182 -0
- package/dist/EmojiPicker.js.map +1 -0
- package/dist/ImageEditor.d.ts +68 -0
- package/dist/ImageEditor.d.ts.map +1 -0
- package/dist/ImageEditor.js +166 -0
- package/dist/ImageEditor.js.map +1 -0
- package/dist/ImageNodeView.d.ts +13 -1
- package/dist/ImageNodeView.d.ts.map +1 -1
- package/dist/ImageNodeView.js +172 -19
- package/dist/ImageNodeView.js.map +1 -1
- package/dist/ImageViewer.d.ts +26 -0
- package/dist/ImageViewer.d.ts.map +1 -0
- package/dist/ImageViewer.js +119 -0
- package/dist/ImageViewer.js.map +1 -0
- package/dist/InlineIcon.d.ts +17 -0
- package/dist/InlineIcon.d.ts.map +1 -0
- package/dist/InlineIcon.js +72 -0
- package/dist/InlineIcon.js.map +1 -0
- package/dist/InlinePreviewGutter.d.ts +52 -0
- package/dist/InlinePreviewGutter.d.ts.map +1 -0
- package/dist/InlinePreviewGutter.js +397 -0
- package/dist/InlinePreviewGutter.js.map +1 -0
- package/dist/LinkDialog.d.ts +43 -0
- package/dist/LinkDialog.d.ts.map +1 -0
- package/dist/LinkDialog.js +102 -0
- package/dist/LinkDialog.js.map +1 -0
- package/dist/MentionExtension.js +10 -7
- package/dist/MentionExtension.js.map +1 -1
- package/dist/OutlinePanel.d.ts +17 -0
- package/dist/OutlinePanel.d.ts.map +1 -0
- package/dist/OutlinePanel.js +167 -0
- package/dist/OutlinePanel.js.map +1 -0
- package/dist/PlainHtmlPreview.d.ts +50 -0
- package/dist/PlainHtmlPreview.d.ts.map +1 -0
- package/dist/PlainHtmlPreview.js +155 -0
- package/dist/PlainHtmlPreview.js.map +1 -0
- package/dist/PreviewControls.d.ts +15 -1
- package/dist/PreviewControls.d.ts.map +1 -1
- package/dist/PreviewControls.js +75 -18
- package/dist/PreviewControls.js.map +1 -1
- package/dist/PreviewPanel.d.ts +11 -10
- package/dist/PreviewPanel.d.ts.map +1 -1
- package/dist/PreviewPanel.js +20 -17
- package/dist/PreviewPanel.js.map +1 -1
- package/dist/RawEditor.d.ts.map +1 -1
- package/dist/RawEditor.js +198 -4
- package/dist/RawEditor.js.map +1 -1
- package/dist/RecorderEntry.d.ts +24 -0
- package/dist/RecorderEntry.d.ts.map +1 -0
- package/dist/RecorderEntry.js +139 -0
- package/dist/RecorderEntry.js.map +1 -0
- package/dist/TemplateAnnotation.d.ts.map +1 -1
- package/dist/TemplateAnnotation.js +32 -6
- package/dist/TemplateAnnotation.js.map +1 -1
- package/dist/TemplatePicker.d.ts +53 -0
- package/dist/TemplatePicker.d.ts.map +1 -0
- package/dist/TemplatePicker.js +388 -0
- package/dist/TemplatePicker.js.map +1 -0
- package/dist/ThemeCustomizerPanel.d.ts +32 -0
- package/dist/ThemeCustomizerPanel.d.ts.map +1 -0
- package/dist/ThemeCustomizerPanel.js +256 -0
- package/dist/ThemeCustomizerPanel.js.map +1 -0
- package/dist/ThemePicker.d.ts +33 -0
- package/dist/ThemePicker.d.ts.map +1 -0
- package/dist/ThemePicker.js +148 -0
- package/dist/ThemePicker.js.map +1 -0
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar.js +508 -33
- package/dist/Toolbar.js.map +1 -1
- package/dist/VersionHistoryPanel.d.ts +14 -0
- package/dist/VersionHistoryPanel.d.ts.map +1 -0
- package/dist/VersionHistoryPanel.js +147 -0
- package/dist/VersionHistoryPanel.js.map +1 -0
- package/dist/ViewMenuPanel.d.ts +13 -0
- package/dist/ViewMenuPanel.d.ts.map +1 -0
- package/dist/ViewMenuPanel.js +58 -0
- package/dist/ViewMenuPanel.js.map +1 -0
- package/dist/WysiwygEditor.d.ts.map +1 -1
- package/dist/WysiwygEditor.js +198 -9
- package/dist/WysiwygEditor.js.map +1 -1
- package/dist/__tests__/detectMarkdown.test.js +0 -14
- package/dist/__tests__/detectMarkdown.test.js.map +1 -1
- package/dist/__tests__/documentSettingsDialog.test.d.ts +2 -0
- package/dist/__tests__/documentSettingsDialog.test.d.ts.map +1 -0
- package/dist/__tests__/documentSettingsDialog.test.js +132 -0
- package/dist/__tests__/documentSettingsDialog.test.js.map +1 -0
- package/dist/__tests__/emojiPicker.test.d.ts +2 -0
- package/dist/__tests__/emojiPicker.test.d.ts.map +1 -0
- package/dist/__tests__/emojiPicker.test.js +111 -0
- package/dist/__tests__/emojiPicker.test.js.map +1 -0
- package/dist/__tests__/fileKind.test.js +13 -0
- package/dist/__tests__/fileKind.test.js.map +1 -1
- package/dist/__tests__/imageEditAffordance.test.d.ts +2 -0
- package/dist/__tests__/imageEditAffordance.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditAffordance.test.js +188 -0
- package/dist/__tests__/imageEditAffordance.test.js.map +1 -0
- package/dist/__tests__/imageEditorShell.test.d.ts +2 -0
- package/dist/__tests__/imageEditorShell.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditorShell.test.js +52 -0
- package/dist/__tests__/imageEditorShell.test.js.map +1 -0
- package/dist/__tests__/imageEditorState.test.d.ts +3 -0
- package/dist/__tests__/imageEditorState.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditorState.test.js +148 -0
- package/dist/__tests__/imageEditorState.test.js.map +1 -0
- package/dist/__tests__/inlinePreviewGutter.test.d.ts +2 -0
- package/dist/__tests__/inlinePreviewGutter.test.d.ts.map +1 -0
- package/dist/__tests__/inlinePreviewGutter.test.js +51 -0
- package/dist/__tests__/inlinePreviewGutter.test.js.map +1 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.d.ts +2 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.d.ts.map +1 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.js +63 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.js.map +1 -0
- package/dist/__tests__/jsonEditor.test.d.ts +2 -0
- package/dist/__tests__/jsonEditor.test.d.ts.map +1 -0
- package/dist/__tests__/jsonEditor.test.js +134 -0
- package/dist/__tests__/jsonEditor.test.js.map +1 -0
- package/dist/__tests__/layersPanel.test.d.ts +2 -0
- package/dist/__tests__/layersPanel.test.d.ts.map +1 -0
- package/dist/__tests__/layersPanel.test.js +84 -0
- package/dist/__tests__/layersPanel.test.js.map +1 -0
- package/dist/__tests__/linkDialogDocPicker.test.d.ts +7 -0
- package/dist/__tests__/linkDialogDocPicker.test.d.ts.map +1 -0
- package/dist/__tests__/linkDialogDocPicker.test.js +75 -0
- package/dist/__tests__/linkDialogDocPicker.test.js.map +1 -0
- package/dist/__tests__/outlinePanel.test.d.ts +2 -0
- package/dist/__tests__/outlinePanel.test.d.ts.map +1 -0
- package/dist/__tests__/outlinePanel.test.js +68 -0
- package/dist/__tests__/outlinePanel.test.js.map +1 -0
- package/dist/__tests__/plainHtmlPreview.test.d.ts +2 -0
- package/dist/__tests__/plainHtmlPreview.test.d.ts.map +1 -0
- package/dist/__tests__/plainHtmlPreview.test.js +87 -0
- package/dist/__tests__/plainHtmlPreview.test.js.map +1 -0
- package/dist/__tests__/propertiesPanel.test.d.ts +2 -0
- package/dist/__tests__/propertiesPanel.test.d.ts.map +1 -0
- package/dist/__tests__/propertiesPanel.test.js +64 -0
- package/dist/__tests__/propertiesPanel.test.js.map +1 -0
- package/dist/__tests__/recorderFormats.test.d.ts +2 -0
- package/dist/__tests__/recorderFormats.test.d.ts.map +1 -0
- package/dist/__tests__/recorderFormats.test.js +121 -0
- package/dist/__tests__/recorderFormats.test.js.map +1 -0
- package/dist/__tests__/recorderTimingJson.test.d.ts +2 -0
- package/dist/__tests__/recorderTimingJson.test.d.ts.map +1 -0
- package/dist/__tests__/recorderTimingJson.test.js +37 -0
- package/dist/__tests__/recorderTimingJson.test.js.map +1 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.d.ts +2 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.d.ts.map +1 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.js +31 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.js.map +1 -0
- package/dist/__tests__/tiptapBridge.test.js +13 -0
- package/dist/__tests__/tiptapBridge.test.js.map +1 -1
- package/dist/__tests__/useImageEditor.test.d.ts +2 -0
- package/dist/__tests__/useImageEditor.test.d.ts.map +1 -0
- package/dist/__tests__/useImageEditor.test.js +131 -0
- package/dist/__tests__/useImageEditor.test.js.map +1 -0
- package/dist/__tests__/useMediaRecorder.test.d.ts +2 -0
- package/dist/__tests__/useMediaRecorder.test.d.ts.map +1 -0
- package/dist/__tests__/useMediaRecorder.test.js +153 -0
- package/dist/__tests__/useMediaRecorder.test.js.map +1 -0
- package/dist/__tests__/versionHistory.test.d.ts +2 -0
- package/dist/__tests__/versionHistory.test.d.ts.map +1 -0
- package/dist/__tests__/versionHistory.test.js +124 -0
- package/dist/__tests__/versionHistory.test.js.map +1 -0
- package/dist/blockSlice.d.ts +24 -0
- package/dist/blockSlice.d.ts.map +1 -0
- package/dist/blockSlice.js +63 -0
- package/dist/blockSlice.js.map +1 -0
- package/dist/buildPreviewDoc.d.ts.map +1 -1
- package/dist/buildPreviewDoc.js +52 -2
- package/dist/buildPreviewDoc.js.map +1 -1
- package/dist/emojiData.d.ts +81 -0
- package/dist/emojiData.d.ts.map +1 -0
- package/dist/emojiData.js +1283 -0
- package/dist/emojiData.js.map +1 -0
- package/dist/fileKind.d.ts +6 -2
- package/dist/fileKind.d.ts.map +1 -1
- package/dist/fileKind.js +25 -4
- package/dist/fileKind.js.map +1 -1
- package/dist/hooks/useFileDrop.d.ts.map +1 -1
- package/dist/hooks/useFileDrop.js +40 -4
- package/dist/hooks/useFileDrop.js.map +1 -1
- package/dist/imageEditor/CanvasSurface.d.ts +31 -0
- package/dist/imageEditor/CanvasSurface.d.ts.map +1 -0
- package/dist/imageEditor/CanvasSurface.js +264 -0
- package/dist/imageEditor/CanvasSurface.js.map +1 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.d.ts +39 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.d.ts.map +1 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.js +283 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.js.map +1 -0
- package/dist/imageEditor/LayersPanel.d.ts +14 -0
- package/dist/imageEditor/LayersPanel.d.ts.map +1 -0
- package/dist/imageEditor/LayersPanel.js +43 -0
- package/dist/imageEditor/LayersPanel.js.map +1 -0
- package/dist/imageEditor/PropertiesPanel.d.ts +14 -0
- package/dist/imageEditor/PropertiesPanel.d.ts.map +1 -0
- package/dist/imageEditor/PropertiesPanel.js +97 -0
- package/dist/imageEditor/PropertiesPanel.js.map +1 -0
- package/dist/imageEditor/Toolbar.d.ts +30 -0
- package/dist/imageEditor/Toolbar.d.ts.map +1 -0
- package/dist/imageEditor/Toolbar.js +108 -0
- package/dist/imageEditor/Toolbar.js.map +1 -0
- package/dist/imageEditor/icons.d.ts +24 -0
- package/dist/imageEditor/icons.d.ts.map +1 -0
- package/dist/imageEditor/icons.js +45 -0
- package/dist/imageEditor/icons.js.map +1 -0
- package/dist/imageEditor/layers/EditorImageLayer.d.ts +16 -0
- package/dist/imageEditor/layers/EditorImageLayer.d.ts.map +1 -0
- package/dist/imageEditor/layers/EditorImageLayer.js +37 -0
- package/dist/imageEditor/layers/EditorImageLayer.js.map +1 -0
- package/dist/imageEditor/layers/EditorShapeLayer.d.ts +15 -0
- package/dist/imageEditor/layers/EditorShapeLayer.d.ts.map +1 -0
- package/dist/imageEditor/layers/EditorShapeLayer.js +20 -0
- package/dist/imageEditor/layers/EditorShapeLayer.js.map +1 -0
- package/dist/imageEditor/layers/EditorTextLayer.d.ts +18 -0
- package/dist/imageEditor/layers/EditorTextLayer.d.ts.map +1 -0
- package/dist/imageEditor/layers/EditorTextLayer.js +13 -0
- package/dist/imageEditor/layers/EditorTextLayer.js.map +1 -0
- package/dist/imageEditor/layers/SelectionHandles.d.ts +17 -0
- package/dist/imageEditor/layers/SelectionHandles.d.ts.map +1 -0
- package/dist/imageEditor/layers/SelectionHandles.js +19 -0
- package/dist/imageEditor/layers/SelectionHandles.js.map +1 -0
- package/dist/imageEditor/state.d.ts +76 -0
- package/dist/imageEditor/state.d.ts.map +1 -0
- package/dist/imageEditor/state.js +87 -0
- package/dist/imageEditor/state.js.map +1 -0
- package/dist/imageEditor/useImageEditor.d.ts +53 -0
- package/dist/imageEditor/useImageEditor.d.ts.map +1 -0
- package/dist/imageEditor/useImageEditor.js +244 -0
- package/dist/imageEditor/useImageEditor.js.map +1 -0
- package/dist/imageEditor/useImageEditorTokens.d.ts +16 -0
- package/dist/imageEditor/useImageEditorTokens.d.ts.map +1 -0
- package/dist/imageEditor/useImageEditorTokens.js +45 -0
- package/dist/imageEditor/useImageEditorTokens.js.map +1 -0
- package/dist/index.d.ts +48 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -1
- package/dist/jsonEditor/EmbeddedRichTextField.d.ts +15 -0
- package/dist/jsonEditor/EmbeddedRichTextField.d.ts.map +1 -0
- package/dist/jsonEditor/EmbeddedRichTextField.js +74 -0
- package/dist/jsonEditor/EmbeddedRichTextField.js.map +1 -0
- package/dist/jsonEditor/JsonEditor.d.ts +36 -0
- package/dist/jsonEditor/JsonEditor.d.ts.map +1 -0
- package/dist/jsonEditor/JsonEditor.js +15 -0
- package/dist/jsonEditor/JsonEditor.js.map +1 -0
- package/dist/jsonEditor/JsonEditorContext.d.ts +28 -0
- package/dist/jsonEditor/JsonEditorContext.d.ts.map +1 -0
- package/dist/jsonEditor/JsonEditorContext.js +41 -0
- package/dist/jsonEditor/JsonEditorContext.js.map +1 -0
- package/dist/jsonEditor/RenderNode.d.ts +16 -0
- package/dist/jsonEditor/RenderNode.d.ts.map +1 -0
- package/dist/jsonEditor/RenderNode.js +32 -0
- package/dist/jsonEditor/RenderNode.js.map +1 -0
- package/dist/jsonEditor/editors.d.ts +36 -0
- package/dist/jsonEditor/editors.d.ts.map +1 -0
- package/dist/jsonEditor/editors.js +347 -0
- package/dist/jsonEditor/editors.js.map +1 -0
- package/dist/jsonEditor/index.d.ts +3 -0
- package/dist/jsonEditor/index.d.ts.map +1 -0
- package/dist/jsonEditor/index.js +2 -0
- package/dist/jsonEditor/index.js.map +1 -0
- package/dist/jsonEditor/useJsonEditorTokens.d.ts +13 -0
- package/dist/jsonEditor/useJsonEditorTokens.d.ts.map +1 -0
- package/dist/jsonEditor/useJsonEditorTokens.js +38 -0
- package/dist/jsonEditor/useJsonEditorTokens.js.map +1 -0
- package/dist/recorder/RecorderButton.d.ts +31 -0
- package/dist/recorder/RecorderButton.d.ts.map +1 -0
- package/dist/recorder/RecorderButton.js +24 -0
- package/dist/recorder/RecorderButton.js.map +1 -0
- package/dist/recorder/RecorderModal.d.ts +59 -0
- package/dist/recorder/RecorderModal.d.ts.map +1 -0
- package/dist/recorder/RecorderModal.js +333 -0
- package/dist/recorder/RecorderModal.js.map +1 -0
- package/dist/recorder/RecorderPanel.d.ts +25 -0
- package/dist/recorder/RecorderPanel.d.ts.map +1 -0
- package/dist/recorder/RecorderPanel.js +30 -0
- package/dist/recorder/RecorderPanel.js.map +1 -0
- package/dist/recorder/formats.d.ts +51 -0
- package/dist/recorder/formats.d.ts.map +1 -0
- package/dist/recorder/formats.js +144 -0
- package/dist/recorder/formats.js.map +1 -0
- package/dist/recorder/hooks/useMediaRecorder.d.ts +90 -0
- package/dist/recorder/hooks/useMediaRecorder.d.ts.map +1 -0
- package/dist/recorder/hooks/useMediaRecorder.js +277 -0
- package/dist/recorder/hooks/useMediaRecorder.js.map +1 -0
- package/dist/recorder/hooks/useStreamPreview.d.ts +22 -0
- package/dist/recorder/hooks/useStreamPreview.d.ts.map +1 -0
- package/dist/recorder/hooks/useStreamPreview.js +44 -0
- package/dist/recorder/hooks/useStreamPreview.js.map +1 -0
- package/dist/recorder/sources/cameraStream.d.ts +22 -0
- package/dist/recorder/sources/cameraStream.d.ts.map +1 -0
- package/dist/recorder/sources/cameraStream.js +24 -0
- package/dist/recorder/sources/cameraStream.js.map +1 -0
- package/dist/recorder/sources/micStream.d.ts +15 -0
- package/dist/recorder/sources/micStream.d.ts.map +1 -0
- package/dist/recorder/sources/micStream.js +24 -0
- package/dist/recorder/sources/micStream.js.map +1 -0
- package/dist/recorder/sources/screenStream.d.ts +53 -0
- package/dist/recorder/sources/screenStream.d.ts.map +1 -0
- package/dist/recorder/sources/screenStream.js +114 -0
- package/dist/recorder/sources/screenStream.js.map +1 -0
- package/dist/recorder/timingJson.d.ts +51 -0
- package/dist/recorder/timingJson.d.ts.map +1 -0
- package/dist/recorder/timingJson.js +42 -0
- package/dist/recorder/timingJson.js.map +1 -0
- package/dist/tiptap/TiptapAudio.d.ts +26 -0
- package/dist/tiptap/TiptapAudio.d.ts.map +1 -0
- package/dist/tiptap/TiptapAudio.js +58 -0
- package/dist/tiptap/TiptapAudio.js.map +1 -0
- package/dist/tiptap/TiptapVideo.d.ts +30 -0
- package/dist/tiptap/TiptapVideo.d.ts.map +1 -0
- package/dist/tiptap/TiptapVideo.js +66 -0
- package/dist/tiptap/TiptapVideo.js.map +1 -0
- package/dist/tiptap/useResolvedMediaSrc.d.ts +2 -0
- package/dist/tiptap/useResolvedMediaSrc.d.ts.map +1 -0
- package/dist/tiptap/useResolvedMediaSrc.js +42 -0
- package/dist/tiptap/useResolvedMediaSrc.js.map +1 -0
- package/dist/tiptapBridge.d.ts.map +1 -1
- package/dist/tiptapBridge.js +171 -14
- package/dist/tiptapBridge.js.map +1 -1
- package/dist/useHeadingLayout.d.ts +54 -0
- package/dist/useHeadingLayout.d.ts.map +1 -0
- package/dist/useHeadingLayout.js +260 -0
- package/dist/useHeadingLayout.js.map +1 -0
- package/dist/utils/collectInlineFontAwesomeCss.d.ts +21 -0
- package/dist/utils/collectInlineFontAwesomeCss.d.ts.map +1 -0
- package/dist/utils/collectInlineFontAwesomeCss.js +68 -0
- package/dist/utils/collectInlineFontAwesomeCss.js.map +1 -0
- package/dist/utils/dropUtils.d.ts +21 -2
- package/dist/utils/dropUtils.d.ts.map +1 -1
- package/dist/utils/dropUtils.js +43 -4
- package/dist/utils/dropUtils.js.map +1 -1
- package/dist/utils/normalizeMalformedAssetUrl.d.ts +15 -0
- package/dist/utils/normalizeMalformedAssetUrl.d.ts.map +1 -0
- package/dist/utils/normalizeMalformedAssetUrl.js +27 -0
- package/dist/utils/normalizeMalformedAssetUrl.js.map +1 -0
- package/package.json +8 -5
- package/src/DocumentSettingsDialog.tsx +266 -0
- package/src/EditorContext.tsx +534 -10
- package/src/EditorShell.tsx +571 -55
- package/src/EmojiPicker.tsx +332 -0
- package/src/ImageEditor.tsx +327 -0
- package/src/ImageNodeView.tsx +222 -21
- package/src/ImageViewer.tsx +221 -0
- package/src/InlineIcon.ts +84 -0
- package/src/InlinePreviewGutter.tsx +582 -0
- package/src/LinkDialog.tsx +276 -0
- package/src/MentionExtension.tsx +10 -7
- package/src/OutlinePanel.tsx +295 -0
- package/src/PlainHtmlPreview.tsx +211 -0
- package/src/PreviewControls.tsx +130 -24
- package/src/PreviewPanel.tsx +38 -21
- package/src/RawEditor.tsx +215 -4
- package/src/RecorderEntry.tsx +164 -0
- package/src/TemplateAnnotation.ts +32 -6
- package/src/TemplatePicker.tsx +818 -0
- package/src/ThemeCustomizerPanel.tsx +595 -0
- package/src/ThemePicker.tsx +319 -0
- package/src/Toolbar.tsx +708 -111
- package/src/VersionHistoryPanel.tsx +329 -0
- package/src/ViewMenuPanel.tsx +188 -0
- package/src/WysiwygEditor.tsx +229 -9
- package/src/__tests__/detectMarkdown.test.ts +0 -15
- package/src/__tests__/documentSettingsDialog.test.tsx +147 -0
- package/src/__tests__/emojiPicker.test.tsx +133 -0
- package/src/__tests__/fileKind.test.ts +16 -0
- package/src/__tests__/imageEditAffordance.test.tsx +268 -0
- package/src/__tests__/imageEditorShell.test.tsx +57 -0
- package/src/__tests__/imageEditorState.test.ts +171 -0
- package/src/__tests__/inlinePreviewGutter.test.tsx +62 -0
- package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +103 -0
- package/src/__tests__/jsonEditor.test.tsx +168 -0
- package/src/__tests__/layersPanel.test.tsx +97 -0
- package/src/__tests__/linkDialogDocPicker.test.tsx +137 -0
- package/src/__tests__/outlinePanel.test.tsx +79 -0
- package/src/__tests__/plainHtmlPreview.test.tsx +107 -0
- package/src/__tests__/propertiesPanel.test.tsx +69 -0
- package/src/__tests__/recorderFormats.test.ts +146 -0
- package/src/__tests__/recorderTimingJson.test.ts +41 -0
- package/src/__tests__/templateAnnotationRoundTrip.test.ts +34 -0
- package/src/__tests__/tiptapBridge.test.ts +15 -0
- package/src/__tests__/useImageEditor.test.tsx +159 -0
- package/src/__tests__/useMediaRecorder.test.ts +186 -0
- package/src/__tests__/versionHistory.test.tsx +197 -0
- package/src/blockSlice.ts +75 -0
- package/src/buildPreviewDoc.ts +61 -6
- package/src/emojiData.ts +1337 -0
- package/src/fileKind.ts +30 -6
- package/src/hooks/useFileDrop.ts +40 -4
- package/src/imageEditor/CanvasSurface.tsx +402 -0
- package/src/imageEditor/ImageVersionHistoryDropdown.tsx +396 -0
- package/src/imageEditor/LayersPanel.tsx +143 -0
- package/src/imageEditor/PropertiesPanel.tsx +428 -0
- package/src/imageEditor/Toolbar.tsx +242 -0
- package/src/imageEditor/icons.tsx +144 -0
- package/src/imageEditor/image-editor.css +450 -0
- package/src/imageEditor/layers/EditorImageLayer.tsx +45 -0
- package/src/imageEditor/layers/EditorShapeLayer.tsx +62 -0
- package/src/imageEditor/layers/EditorTextLayer.tsx +45 -0
- package/src/imageEditor/layers/SelectionHandles.tsx +86 -0
- package/src/imageEditor/state.ts +153 -0
- package/src/imageEditor/useImageEditor.ts +328 -0
- package/src/imageEditor/useImageEditorTokens.ts +70 -0
- package/src/index.ts +82 -0
- package/src/jsonEditor/EmbeddedRichTextField.tsx +81 -0
- package/src/jsonEditor/JsonEditor.tsx +81 -0
- package/src/jsonEditor/JsonEditorContext.tsx +75 -0
- package/src/jsonEditor/RenderNode.tsx +66 -0
- package/src/jsonEditor/editors.tsx +678 -0
- package/src/jsonEditor/index.ts +2 -0
- package/src/jsonEditor/json-editor.css +463 -0
- package/src/jsonEditor/useJsonEditorTokens.ts +63 -0
- package/src/recorder/RecorderButton.tsx +72 -0
- package/src/recorder/RecorderModal.tsx +596 -0
- package/src/recorder/RecorderPanel.tsx +93 -0
- package/src/recorder/formats.ts +159 -0
- package/src/recorder/hooks/useMediaRecorder.ts +378 -0
- package/src/recorder/hooks/useStreamPreview.ts +47 -0
- package/src/recorder/sources/cameraStream.ts +32 -0
- package/src/recorder/sources/micStream.ts +25 -0
- package/src/recorder/sources/screenStream.ts +162 -0
- package/src/recorder/timingJson.ts +66 -0
- package/src/styles/editor.css +2490 -51
- package/src/styles/image-edit-affordance.css +201 -0
- package/src/styles/index.css +10 -0
- package/src/tiptap/TiptapAudio.tsx +86 -0
- package/src/tiptap/TiptapVideo.tsx +119 -0
- package/src/tiptap/useResolvedMediaSrc.ts +47 -0
- package/src/tiptapBridge.ts +188 -20
- package/src/useHeadingLayout.ts +294 -0
- package/src/utils/collectInlineFontAwesomeCss.ts +69 -0
- package/src/utils/dropUtils.ts +54 -6
- package/src/utils/normalizeMalformedAssetUrl.ts +22 -0
package/src/index.ts
CHANGED
|
@@ -33,6 +33,10 @@ export type {
|
|
|
33
33
|
ImageDisplayMode,
|
|
34
34
|
MentionCandidate,
|
|
35
35
|
MentionProvider,
|
|
36
|
+
DocumentLinkCandidate,
|
|
37
|
+
DocumentLinkProvider,
|
|
38
|
+
ViewPreferences,
|
|
39
|
+
ThemeInheritance,
|
|
36
40
|
} from './EditorContext.js';
|
|
37
41
|
|
|
38
42
|
// File-kind detection — useful for hosts that want to pre-decide chrome
|
|
@@ -40,6 +44,11 @@ export type {
|
|
|
40
44
|
export { resolveFileKind, detectLanguageFromFileName } from './fileKind.js';
|
|
41
45
|
export type { FileKind } from './fileKind.js';
|
|
42
46
|
|
|
47
|
+
// Image viewer — exported standalone so hosts can use it without the
|
|
48
|
+
// full EditorShell when they already have their own chrome.
|
|
49
|
+
export { ImageViewer } from './ImageViewer.js';
|
|
50
|
+
export type { ImageViewerProps } from './ImageViewer.js';
|
|
51
|
+
|
|
43
52
|
// Individual editors (for custom layouts)
|
|
44
53
|
export { RawEditor } from './RawEditor.js';
|
|
45
54
|
export type { RawEditorProps } from './RawEditor.js';
|
|
@@ -49,6 +58,16 @@ export type { WysiwygEditorProps } from './WysiwygEditor.js';
|
|
|
49
58
|
|
|
50
59
|
export { PreviewPanel } from './PreviewPanel.js';
|
|
51
60
|
export type { PreviewPanelProps } from './PreviewPanel.js';
|
|
61
|
+
export { PlainHtmlPreview } from './PlainHtmlPreview.js';
|
|
62
|
+
export type { PlainHtmlPreviewProps } from './PlainHtmlPreview.js';
|
|
63
|
+
export { EmojiPicker } from './EmojiPicker.js';
|
|
64
|
+
export type { EmojiPickerProps } from './EmojiPicker.js';
|
|
65
|
+
export { DocumentSettingsDialog } from './DocumentSettingsDialog.js';
|
|
66
|
+
export type { DocumentSettingsDialogProps } from './DocumentSettingsDialog.js';
|
|
67
|
+
export { ThemePicker } from './ThemePicker.js';
|
|
68
|
+
export type { ThemePickerProps } from './ThemePicker.js';
|
|
69
|
+
export { EMOJI_CATEGORIES, ALL_EMOJIS, searchEmojis } from './emojiData.js';
|
|
70
|
+
export type { EmojiEntry, EmojiCategory } from './emojiData.js';
|
|
52
71
|
export {
|
|
53
72
|
PreviewSettingsProvider,
|
|
54
73
|
PreviewToolbarControls,
|
|
@@ -63,6 +82,16 @@ export type { ViewSwitcherProps } from './ViewSwitcher.js';
|
|
|
63
82
|
export { Toolbar } from './Toolbar.js';
|
|
64
83
|
export type { ToolbarProps } from './Toolbar.js';
|
|
65
84
|
|
|
85
|
+
export { VersionHistoryPanel } from './VersionHistoryPanel.js';
|
|
86
|
+
export { ViewMenuPanel } from './ViewMenuPanel.js';
|
|
87
|
+
export { OutlinePanel } from './OutlinePanel.js';
|
|
88
|
+
export type { OutlinePanelProps } from './OutlinePanel.js';
|
|
89
|
+
export { ThemeCustomizerPanel } from './ThemeCustomizerPanel.js';
|
|
90
|
+
export type { ThemeCustomizerPanelProps } from './ThemeCustomizerPanel.js';
|
|
91
|
+
export { TemplatePicker, templateLabel } from './TemplatePicker.js';
|
|
92
|
+
export { InlinePreviewGutter } from './InlinePreviewGutter.js';
|
|
93
|
+
export type { InlinePreviewGutterProps } from './InlinePreviewGutter.js';
|
|
94
|
+
|
|
66
95
|
export { MediaBin } from './MediaBin.js';
|
|
67
96
|
export type { MediaBinProps } from './MediaBin.js';
|
|
68
97
|
|
|
@@ -99,3 +128,56 @@ export { buildPreviewDoc } from './buildPreviewDoc.js';
|
|
|
99
128
|
|
|
100
129
|
// Tiptap extension: Heading with template annotation support
|
|
101
130
|
export { HeadingWithTemplate } from './TemplateAnnotation.js';
|
|
131
|
+
|
|
132
|
+
// JSON Form — editable component
|
|
133
|
+
export { JsonEditor } from './jsonEditor/index.js';
|
|
134
|
+
export type { JsonEditorProps } from './jsonEditor/index.js';
|
|
135
|
+
|
|
136
|
+
// Recorder — browser-based audio/camera/screen capture. Components and
|
|
137
|
+
// hooks for capturing media via `MediaRecorder` and persisting the
|
|
138
|
+
// resulting blob into a `ContentContainer` through the host's
|
|
139
|
+
// `MediaProvider`. Previously published as `@bendyline/squisq-recorder-react`;
|
|
140
|
+
// folded into editor-react so it ships with the editor it's wired into.
|
|
141
|
+
export { RecorderModal } from './recorder/RecorderModal.js';
|
|
142
|
+
export type { RecorderModalProps, RecorderSaveResult } from './recorder/RecorderModal.js';
|
|
143
|
+
export { RecorderButton } from './recorder/RecorderButton.js';
|
|
144
|
+
export type { RecorderButtonProps } from './recorder/RecorderButton.js';
|
|
145
|
+
export { RecorderPanel } from './recorder/RecorderPanel.js';
|
|
146
|
+
export type { RecorderPanelProps } from './recorder/RecorderPanel.js';
|
|
147
|
+
export { useMediaRecorder, getCaptureKind } from './recorder/hooks/useMediaRecorder.js';
|
|
148
|
+
export type {
|
|
149
|
+
UseMediaRecorderOptions,
|
|
150
|
+
UseMediaRecorderResult,
|
|
151
|
+
RecorderSource,
|
|
152
|
+
RecorderState,
|
|
153
|
+
} from './recorder/hooks/useMediaRecorder.js';
|
|
154
|
+
export { useStreamPreview } from './recorder/hooks/useStreamPreview.js';
|
|
155
|
+
export { requestMicStream } from './recorder/sources/micStream.js';
|
|
156
|
+
export { requestCameraStream } from './recorder/sources/cameraStream.js';
|
|
157
|
+
export type { CameraStreamOptions } from './recorder/sources/cameraStream.js';
|
|
158
|
+
export { requestScreenStream } from './recorder/sources/screenStream.js';
|
|
159
|
+
export type { ScreenStreamOptions, ScreenStreamHandle } from './recorder/sources/screenStream.js';
|
|
160
|
+
export {
|
|
161
|
+
resolveFormat,
|
|
162
|
+
supportsMediaRecorder,
|
|
163
|
+
supportsUserMedia,
|
|
164
|
+
supportsDisplayMedia,
|
|
165
|
+
buildFilename,
|
|
166
|
+
} from './recorder/formats.js';
|
|
167
|
+
export type { CaptureKind, ResolvedFormat } from './recorder/formats.js';
|
|
168
|
+
export { buildTimingJson, encodeTimingJson, timingPathFor } from './recorder/timingJson.js';
|
|
169
|
+
export type { TimingJson, RecordedBookmark } from './recorder/timingJson.js';
|
|
170
|
+
|
|
171
|
+
// Image editor — layered, sidecar-persisted raster authoring surface.
|
|
172
|
+
// Pairs with `ImageViewer` and the `<basename>_files/` sidecar convention.
|
|
173
|
+
export { ImageEditor } from './ImageEditor.js';
|
|
174
|
+
export type { ImageEditorProps } from './ImageEditor.js';
|
|
175
|
+
export { useImageEditor } from './imageEditor/useImageEditor.js';
|
|
176
|
+
export type { UseImageEditorOptions, UseImageEditorReturn } from './imageEditor/useImageEditor.js';
|
|
177
|
+
export { imageEditorReducer, initialImageEditorState } from './imageEditor/state.js';
|
|
178
|
+
export type {
|
|
179
|
+
ImageEditorState,
|
|
180
|
+
ImageEditorAction,
|
|
181
|
+
ImageEditorTool,
|
|
182
|
+
CanvasRect,
|
|
183
|
+
} from './imageEditor/state.js';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standalone Tiptap-backed rich text field for use inside `<JsonEditor>`.
|
|
3
|
+
* Doesn't share `EditorContext` with the document editor — value is a
|
|
4
|
+
* controlled markdown string. Reuses `markdownToTiptap` /
|
|
5
|
+
* `tiptapToMarkdown` so fidelity matches the WysiwygEditor.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useEffect, useRef } from 'react';
|
|
9
|
+
import { useEditor, EditorContent } from '@tiptap/react';
|
|
10
|
+
import StarterKit from '@tiptap/starter-kit';
|
|
11
|
+
import Table from '@tiptap/extension-table';
|
|
12
|
+
import TableRow from '@tiptap/extension-table-row';
|
|
13
|
+
import TableCell from '@tiptap/extension-table-cell';
|
|
14
|
+
import TableHeader from '@tiptap/extension-table-header';
|
|
15
|
+
import TaskList from '@tiptap/extension-task-list';
|
|
16
|
+
import TaskItem from '@tiptap/extension-task-item';
|
|
17
|
+
import Placeholder from '@tiptap/extension-placeholder';
|
|
18
|
+
import { markdownToTiptap, tiptapToMarkdown } from '../tiptapBridge';
|
|
19
|
+
|
|
20
|
+
export interface EmbeddedRichTextFieldProps {
|
|
21
|
+
value: string;
|
|
22
|
+
onChange: (next: string) => void;
|
|
23
|
+
readOnly?: boolean;
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function EmbeddedRichTextField(props: EmbeddedRichTextFieldProps) {
|
|
29
|
+
const { value, onChange, readOnly = false, placeholder, className } = props;
|
|
30
|
+
const isExternalUpdate = useRef(false);
|
|
31
|
+
const lastValueRef = useRef(value);
|
|
32
|
+
|
|
33
|
+
const editor = useEditor({
|
|
34
|
+
editable: !readOnly,
|
|
35
|
+
extensions: [
|
|
36
|
+
StarterKit.configure({
|
|
37
|
+
codeBlock: { HTMLAttributes: { class: 'squisq-code-block' } },
|
|
38
|
+
}),
|
|
39
|
+
Table.configure({ resizable: false }),
|
|
40
|
+
TableRow,
|
|
41
|
+
TableCell,
|
|
42
|
+
TableHeader,
|
|
43
|
+
TaskList,
|
|
44
|
+
TaskItem.configure({ nested: true }),
|
|
45
|
+
Placeholder.configure({ placeholder: placeholder ?? '' }),
|
|
46
|
+
],
|
|
47
|
+
content: markdownToTiptap(value),
|
|
48
|
+
onUpdate: ({ editor: ed }) => {
|
|
49
|
+
if (isExternalUpdate.current) return;
|
|
50
|
+
const html = ed.getHTML();
|
|
51
|
+
const md = tiptapToMarkdown(html);
|
|
52
|
+
lastValueRef.current = md;
|
|
53
|
+
onChange(md);
|
|
54
|
+
},
|
|
55
|
+
editorProps: {
|
|
56
|
+
attributes: {
|
|
57
|
+
class: 'squisq-jf-richtext-prose',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Sync external value changes back into the editor (e.g., undo at the host level).
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (!editor) return;
|
|
65
|
+
if (value === lastValueRef.current) return;
|
|
66
|
+
isExternalUpdate.current = true;
|
|
67
|
+
try {
|
|
68
|
+
editor.commands.setContent(markdownToTiptap(value), false);
|
|
69
|
+
lastValueRef.current = value;
|
|
70
|
+
} finally {
|
|
71
|
+
isExternalUpdate.current = false;
|
|
72
|
+
}
|
|
73
|
+
}, [editor, value]);
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (editor) editor.setEditable(!readOnly);
|
|
77
|
+
}, [editor, readOnly]);
|
|
78
|
+
|
|
79
|
+
const cls = 'squisq-jf-richtext' + (className ? ` ${className}` : '');
|
|
80
|
+
return <EditorContent editor={editor} className={cls} />;
|
|
81
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <JsonEditor>
|
|
3
|
+
*
|
|
4
|
+
* Friendly, theme-aware editor for any JSON value bound to a Squisq-
|
|
5
|
+
* annotated JSON Schema. Hides JSON syntax behind delightful controls:
|
|
6
|
+
* arrays of objects become card stacks, arrays of primitives become
|
|
7
|
+
* chip bins, color fields become swatches, and so on.
|
|
8
|
+
*
|
|
9
|
+
* Companion to `<JsonView>` from `@bendyline/squisq-react` — both share
|
|
10
|
+
* the same `chooseControl()` dispatcher in core, so view and edit modes
|
|
11
|
+
* always agree on what each field _is_.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type {
|
|
15
|
+
JsonFormValidationError,
|
|
16
|
+
JsonFormValidator,
|
|
17
|
+
SquisqAnnotatedSchema,
|
|
18
|
+
} from '@bendyline/squisq/jsonForm';
|
|
19
|
+
import type { SurfaceScheme, Theme } from '@bendyline/squisq/schemas';
|
|
20
|
+
import { JsonEditorProvider } from './JsonEditorContext';
|
|
21
|
+
import { RenderNode } from './RenderNode';
|
|
22
|
+
import { useJsonEditorTokens } from './useJsonEditorTokens';
|
|
23
|
+
|
|
24
|
+
export interface JsonEditorProps {
|
|
25
|
+
/** Schema describing the value's shape (with optional `squisq` hints). */
|
|
26
|
+
schema: SquisqAnnotatedSchema;
|
|
27
|
+
/** Controlled value. */
|
|
28
|
+
value: unknown;
|
|
29
|
+
/** Called with the new root after each edit. Omit for read-only behavior. */
|
|
30
|
+
onChange?: (next: unknown) => void;
|
|
31
|
+
/** Optional theme. Defaults to `DEFAULT_THEME`. */
|
|
32
|
+
theme?: Theme;
|
|
33
|
+
/** Light/dark surface override; `'auto'` uses `prefers-color-scheme`. */
|
|
34
|
+
surface?: SurfaceScheme | 'auto';
|
|
35
|
+
/** Padding/gap density. Default: 'comfortable'. */
|
|
36
|
+
density?: 'comfortable' | 'compact';
|
|
37
|
+
/** Optional consumer-supplied validator (e.g. ajv-backed). */
|
|
38
|
+
validate?: JsonFormValidator;
|
|
39
|
+
/** Notified after validation runs. */
|
|
40
|
+
onValidate?: (errors: readonly JsonFormValidationError[]) => void;
|
|
41
|
+
/** Optional CSS class for the outer container. */
|
|
42
|
+
className?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function JsonEditor(props: JsonEditorProps) {
|
|
46
|
+
const {
|
|
47
|
+
schema,
|
|
48
|
+
value,
|
|
49
|
+
onChange,
|
|
50
|
+
theme,
|
|
51
|
+
surface,
|
|
52
|
+
density = 'comfortable',
|
|
53
|
+
validate,
|
|
54
|
+
onValidate,
|
|
55
|
+
className,
|
|
56
|
+
} = props;
|
|
57
|
+
const { style } = useJsonEditorTokens(theme, surface);
|
|
58
|
+
|
|
59
|
+
// No onChange → fully inert (still validates if a validator is supplied).
|
|
60
|
+
const handleChange = onChange ?? (() => {});
|
|
61
|
+
|
|
62
|
+
const cls =
|
|
63
|
+
'squisq-jsonform' +
|
|
64
|
+
(density === 'compact' ? ' squisq-jsonform--compact' : '') +
|
|
65
|
+
(className ? ` ${className}` : '');
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div className={cls} style={style}>
|
|
69
|
+
<JsonEditorProvider
|
|
70
|
+
rootSchema={schema}
|
|
71
|
+
rootData={value}
|
|
72
|
+
onRootChange={handleChange}
|
|
73
|
+
density={density}
|
|
74
|
+
validate={validate}
|
|
75
|
+
onValidate={onValidate}
|
|
76
|
+
>
|
|
77
|
+
<RenderNode value={value} schema={schema} pointer="" parentDisabled={!onChange} />
|
|
78
|
+
</JsonEditorProvider>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared state for `<JsonEditor>`. Each editor renderer reads its
|
|
3
|
+
* slice via JSON Pointer and calls `setAtPath` to commit edits — the
|
|
4
|
+
* top-level component owns the canonical value and propagates changes
|
|
5
|
+
* to the host's `onChange`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { createContext, useContext, useMemo, type ReactNode } from 'react';
|
|
9
|
+
import type {
|
|
10
|
+
JsonFormValidationError,
|
|
11
|
+
JsonFormValidator,
|
|
12
|
+
SquisqAnnotatedSchema,
|
|
13
|
+
} from '@bendyline/squisq/jsonForm';
|
|
14
|
+
import { setByPointer } from '@bendyline/squisq/jsonForm';
|
|
15
|
+
|
|
16
|
+
export interface JsonEditorContextValue {
|
|
17
|
+
rootSchema: SquisqAnnotatedSchema;
|
|
18
|
+
rootData: unknown;
|
|
19
|
+
/** Commit a new value at `pointer`, computing & emitting a new root. */
|
|
20
|
+
setAtPath: (pointer: string, value: unknown) => void;
|
|
21
|
+
density: 'comfortable' | 'compact';
|
|
22
|
+
errors: ReadonlyMap<string, JsonFormValidationError[]>;
|
|
23
|
+
/** Optional richtext editor component, supplied internally. */
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const JsonEditorContext = createContext<JsonEditorContextValue | null>(null);
|
|
27
|
+
|
|
28
|
+
export interface JsonEditorProviderProps {
|
|
29
|
+
rootSchema: SquisqAnnotatedSchema;
|
|
30
|
+
rootData: unknown;
|
|
31
|
+
onRootChange: (next: unknown) => void;
|
|
32
|
+
density: 'comfortable' | 'compact';
|
|
33
|
+
validate?: JsonFormValidator;
|
|
34
|
+
onValidate?: (errors: readonly JsonFormValidationError[]) => void;
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function JsonEditorProvider(props: JsonEditorProviderProps) {
|
|
39
|
+
const { rootSchema, rootData, onRootChange, density, validate, onValidate, children } = props;
|
|
40
|
+
|
|
41
|
+
const errors = useMemo(() => {
|
|
42
|
+
if (!validate) return new Map<string, JsonFormValidationError[]>();
|
|
43
|
+
const list = validate(rootData, rootSchema);
|
|
44
|
+
if (onValidate) onValidate(list);
|
|
45
|
+
const grouped = new Map<string, JsonFormValidationError[]>();
|
|
46
|
+
for (const e of list) {
|
|
47
|
+
const arr = grouped.get(e.path) ?? [];
|
|
48
|
+
arr.push(e);
|
|
49
|
+
grouped.set(e.path, arr);
|
|
50
|
+
}
|
|
51
|
+
return grouped;
|
|
52
|
+
}, [validate, rootData, rootSchema, onValidate]);
|
|
53
|
+
|
|
54
|
+
const setAtPath = useMemo(
|
|
55
|
+
() => (pointer: string, value: unknown) => {
|
|
56
|
+
const next = setByPointer(rootData, pointer, value);
|
|
57
|
+
onRootChange(next);
|
|
58
|
+
},
|
|
59
|
+
[rootData, onRootChange],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const value: JsonEditorContextValue = useMemo(
|
|
63
|
+
() => ({ rootSchema, rootData, setAtPath, density, errors }),
|
|
64
|
+
[rootSchema, rootData, setAtPath, density, errors],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return <JsonEditorContext.Provider value={value}>{children}</JsonEditorContext.Provider>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
71
|
+
export function useJsonEditor(): JsonEditorContextValue {
|
|
72
|
+
const ctx = useContext(JsonEditorContext);
|
|
73
|
+
if (!ctx) throw new Error('useJsonEditor must be used inside <JsonEditor>');
|
|
74
|
+
return ctx;
|
|
75
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursive editor dispatcher: looks at a schema slice, evaluates
|
|
3
|
+
* `hidden`/`disabled` rules, picks an editor component, and wraps it
|
|
4
|
+
* with label + help + error chrome unless the editor is composite
|
|
5
|
+
* (group / card-stack / tabs / richtext, which present their own).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
chooseControl,
|
|
10
|
+
resolveFlag,
|
|
11
|
+
resolveRef,
|
|
12
|
+
type SquisqAnnotatedSchema,
|
|
13
|
+
} from '@bendyline/squisq/jsonForm';
|
|
14
|
+
import { useJsonEditor } from './JsonEditorContext';
|
|
15
|
+
import { EDITORS, isCompositeControl } from './editors';
|
|
16
|
+
|
|
17
|
+
export interface RenderNodeProps {
|
|
18
|
+
value: unknown;
|
|
19
|
+
schema: SquisqAnnotatedSchema;
|
|
20
|
+
pointer: string;
|
|
21
|
+
parentDisabled?: boolean;
|
|
22
|
+
suppressTopGroupTitle?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function RenderNode(props: RenderNodeProps): React.ReactElement | null {
|
|
26
|
+
const { rootSchema, rootData, errors } = useJsonEditor();
|
|
27
|
+
const resolved = resolveRef(props.schema, rootSchema) ?? props.schema;
|
|
28
|
+
|
|
29
|
+
if (resolveFlag(resolved.squisq?.hidden, rootData)) return null;
|
|
30
|
+
|
|
31
|
+
const disabled =
|
|
32
|
+
(props.parentDisabled ?? false) || resolveFlag(resolved.squisq?.disabled, rootData);
|
|
33
|
+
const kind = chooseControl(resolved);
|
|
34
|
+
const Editor = EDITORS[kind];
|
|
35
|
+
const label = resolved.squisq?.label ?? resolved.title;
|
|
36
|
+
const help = resolved.squisq?.help ?? resolved.description;
|
|
37
|
+
const fieldErrors = errors.get(props.pointer) ?? [];
|
|
38
|
+
|
|
39
|
+
const editorEl = (
|
|
40
|
+
<Editor
|
|
41
|
+
value={props.value}
|
|
42
|
+
schema={resolved}
|
|
43
|
+
pointer={props.pointer}
|
|
44
|
+
disabled={disabled}
|
|
45
|
+
// GroupEditor honors this — other editors ignore the extra prop.
|
|
46
|
+
// @ts-expect-error optional renderer-specific prop
|
|
47
|
+
suppressTitle={props.suppressTopGroupTitle}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
if (isCompositeControl(kind, resolved)) {
|
|
52
|
+
// Composite editors handle their own labeling.
|
|
53
|
+
return editorEl;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div className={`squisq-jf-field${disabled ? ' squisq-jf-field--disabled' : ''}`}>
|
|
58
|
+
{label ? <label className="squisq-jf-field__label">{label}</label> : null}
|
|
59
|
+
{editorEl}
|
|
60
|
+
{help ? <p className="squisq-jf-field__help">{help}</p> : null}
|
|
61
|
+
{fieldErrors.length > 0 ? (
|
|
62
|
+
<p className="squisq-jf-field__error">{fieldErrors[0].message}</p>
|
|
63
|
+
) : null}
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|