@bendyline/squisq-editor-react 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DocumentSettingsDialog.d.ts +26 -0
- package/dist/DocumentSettingsDialog.d.ts.map +1 -0
- package/dist/DocumentSettingsDialog.js +115 -0
- package/dist/DocumentSettingsDialog.js.map +1 -0
- package/dist/EditorContext.d.ts +248 -4
- package/dist/EditorContext.d.ts.map +1 -1
- package/dist/EditorContext.js +248 -10
- package/dist/EditorContext.js.map +1 -1
- package/dist/EditorShell.d.ts +173 -4
- package/dist/EditorShell.d.ts.map +1 -1
- package/dist/EditorShell.js +110 -10
- package/dist/EditorShell.js.map +1 -1
- package/dist/EmojiPicker.d.ts +50 -0
- package/dist/EmojiPicker.d.ts.map +1 -0
- package/dist/EmojiPicker.js +182 -0
- package/dist/EmojiPicker.js.map +1 -0
- package/dist/ImageEditor.d.ts +68 -0
- package/dist/ImageEditor.d.ts.map +1 -0
- package/dist/ImageEditor.js +166 -0
- package/dist/ImageEditor.js.map +1 -0
- package/dist/ImageNodeView.d.ts +13 -1
- package/dist/ImageNodeView.d.ts.map +1 -1
- package/dist/ImageNodeView.js +172 -19
- package/dist/ImageNodeView.js.map +1 -1
- package/dist/ImageViewer.d.ts +26 -0
- package/dist/ImageViewer.d.ts.map +1 -0
- package/dist/ImageViewer.js +119 -0
- package/dist/ImageViewer.js.map +1 -0
- package/dist/InlineIcon.d.ts +17 -0
- package/dist/InlineIcon.d.ts.map +1 -0
- package/dist/InlineIcon.js +72 -0
- package/dist/InlineIcon.js.map +1 -0
- package/dist/InlinePreviewGutter.d.ts +52 -0
- package/dist/InlinePreviewGutter.d.ts.map +1 -0
- package/dist/InlinePreviewGutter.js +397 -0
- package/dist/InlinePreviewGutter.js.map +1 -0
- package/dist/LinkDialog.d.ts +43 -0
- package/dist/LinkDialog.d.ts.map +1 -0
- package/dist/LinkDialog.js +102 -0
- package/dist/LinkDialog.js.map +1 -0
- package/dist/MentionExtension.js +10 -7
- package/dist/MentionExtension.js.map +1 -1
- package/dist/OutlinePanel.d.ts +17 -0
- package/dist/OutlinePanel.d.ts.map +1 -0
- package/dist/OutlinePanel.js +167 -0
- package/dist/OutlinePanel.js.map +1 -0
- package/dist/PlainHtmlPreview.d.ts +50 -0
- package/dist/PlainHtmlPreview.d.ts.map +1 -0
- package/dist/PlainHtmlPreview.js +155 -0
- package/dist/PlainHtmlPreview.js.map +1 -0
- package/dist/PreviewControls.d.ts +15 -1
- package/dist/PreviewControls.d.ts.map +1 -1
- package/dist/PreviewControls.js +75 -18
- package/dist/PreviewControls.js.map +1 -1
- package/dist/PreviewPanel.d.ts +11 -10
- package/dist/PreviewPanel.d.ts.map +1 -1
- package/dist/PreviewPanel.js +20 -17
- package/dist/PreviewPanel.js.map +1 -1
- package/dist/RawEditor.d.ts.map +1 -1
- package/dist/RawEditor.js +198 -4
- package/dist/RawEditor.js.map +1 -1
- package/dist/RecorderEntry.d.ts +24 -0
- package/dist/RecorderEntry.d.ts.map +1 -0
- package/dist/RecorderEntry.js +139 -0
- package/dist/RecorderEntry.js.map +1 -0
- package/dist/TemplateAnnotation.d.ts.map +1 -1
- package/dist/TemplateAnnotation.js +32 -6
- package/dist/TemplateAnnotation.js.map +1 -1
- package/dist/TemplatePicker.d.ts +53 -0
- package/dist/TemplatePicker.d.ts.map +1 -0
- package/dist/TemplatePicker.js +388 -0
- package/dist/TemplatePicker.js.map +1 -0
- package/dist/ThemeCustomizerPanel.d.ts +32 -0
- package/dist/ThemeCustomizerPanel.d.ts.map +1 -0
- package/dist/ThemeCustomizerPanel.js +256 -0
- package/dist/ThemeCustomizerPanel.js.map +1 -0
- package/dist/ThemePicker.d.ts +33 -0
- package/dist/ThemePicker.d.ts.map +1 -0
- package/dist/ThemePicker.js +148 -0
- package/dist/ThemePicker.js.map +1 -0
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar.js +508 -33
- package/dist/Toolbar.js.map +1 -1
- package/dist/VersionHistoryPanel.d.ts +14 -0
- package/dist/VersionHistoryPanel.d.ts.map +1 -0
- package/dist/VersionHistoryPanel.js +147 -0
- package/dist/VersionHistoryPanel.js.map +1 -0
- package/dist/ViewMenuPanel.d.ts +13 -0
- package/dist/ViewMenuPanel.d.ts.map +1 -0
- package/dist/ViewMenuPanel.js +58 -0
- package/dist/ViewMenuPanel.js.map +1 -0
- package/dist/WysiwygEditor.d.ts.map +1 -1
- package/dist/WysiwygEditor.js +198 -9
- package/dist/WysiwygEditor.js.map +1 -1
- package/dist/__tests__/detectMarkdown.test.js +0 -14
- package/dist/__tests__/detectMarkdown.test.js.map +1 -1
- package/dist/__tests__/documentSettingsDialog.test.d.ts +2 -0
- package/dist/__tests__/documentSettingsDialog.test.d.ts.map +1 -0
- package/dist/__tests__/documentSettingsDialog.test.js +132 -0
- package/dist/__tests__/documentSettingsDialog.test.js.map +1 -0
- package/dist/__tests__/emojiPicker.test.d.ts +2 -0
- package/dist/__tests__/emojiPicker.test.d.ts.map +1 -0
- package/dist/__tests__/emojiPicker.test.js +111 -0
- package/dist/__tests__/emojiPicker.test.js.map +1 -0
- package/dist/__tests__/fileKind.test.js +13 -0
- package/dist/__tests__/fileKind.test.js.map +1 -1
- package/dist/__tests__/imageEditAffordance.test.d.ts +2 -0
- package/dist/__tests__/imageEditAffordance.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditAffordance.test.js +188 -0
- package/dist/__tests__/imageEditAffordance.test.js.map +1 -0
- package/dist/__tests__/imageEditorShell.test.d.ts +2 -0
- package/dist/__tests__/imageEditorShell.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditorShell.test.js +52 -0
- package/dist/__tests__/imageEditorShell.test.js.map +1 -0
- package/dist/__tests__/imageEditorState.test.d.ts +3 -0
- package/dist/__tests__/imageEditorState.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditorState.test.js +148 -0
- package/dist/__tests__/imageEditorState.test.js.map +1 -0
- package/dist/__tests__/inlinePreviewGutter.test.d.ts +2 -0
- package/dist/__tests__/inlinePreviewGutter.test.d.ts.map +1 -0
- package/dist/__tests__/inlinePreviewGutter.test.js +51 -0
- package/dist/__tests__/inlinePreviewGutter.test.js.map +1 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.d.ts +2 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.d.ts.map +1 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.js +63 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.js.map +1 -0
- package/dist/__tests__/jsonEditor.test.d.ts +2 -0
- package/dist/__tests__/jsonEditor.test.d.ts.map +1 -0
- package/dist/__tests__/jsonEditor.test.js +134 -0
- package/dist/__tests__/jsonEditor.test.js.map +1 -0
- package/dist/__tests__/layersPanel.test.d.ts +2 -0
- package/dist/__tests__/layersPanel.test.d.ts.map +1 -0
- package/dist/__tests__/layersPanel.test.js +84 -0
- package/dist/__tests__/layersPanel.test.js.map +1 -0
- package/dist/__tests__/linkDialogDocPicker.test.d.ts +7 -0
- package/dist/__tests__/linkDialogDocPicker.test.d.ts.map +1 -0
- package/dist/__tests__/linkDialogDocPicker.test.js +75 -0
- package/dist/__tests__/linkDialogDocPicker.test.js.map +1 -0
- package/dist/__tests__/outlinePanel.test.d.ts +2 -0
- package/dist/__tests__/outlinePanel.test.d.ts.map +1 -0
- package/dist/__tests__/outlinePanel.test.js +68 -0
- package/dist/__tests__/outlinePanel.test.js.map +1 -0
- package/dist/__tests__/plainHtmlPreview.test.d.ts +2 -0
- package/dist/__tests__/plainHtmlPreview.test.d.ts.map +1 -0
- package/dist/__tests__/plainHtmlPreview.test.js +87 -0
- package/dist/__tests__/plainHtmlPreview.test.js.map +1 -0
- package/dist/__tests__/propertiesPanel.test.d.ts +2 -0
- package/dist/__tests__/propertiesPanel.test.d.ts.map +1 -0
- package/dist/__tests__/propertiesPanel.test.js +64 -0
- package/dist/__tests__/propertiesPanel.test.js.map +1 -0
- package/dist/__tests__/recorderFormats.test.d.ts +2 -0
- package/dist/__tests__/recorderFormats.test.d.ts.map +1 -0
- package/dist/__tests__/recorderFormats.test.js +121 -0
- package/dist/__tests__/recorderFormats.test.js.map +1 -0
- package/dist/__tests__/recorderTimingJson.test.d.ts +2 -0
- package/dist/__tests__/recorderTimingJson.test.d.ts.map +1 -0
- package/dist/__tests__/recorderTimingJson.test.js +37 -0
- package/dist/__tests__/recorderTimingJson.test.js.map +1 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.d.ts +2 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.d.ts.map +1 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.js +31 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.js.map +1 -0
- package/dist/__tests__/tiptapBridge.test.js +13 -0
- package/dist/__tests__/tiptapBridge.test.js.map +1 -1
- package/dist/__tests__/useImageEditor.test.d.ts +2 -0
- package/dist/__tests__/useImageEditor.test.d.ts.map +1 -0
- package/dist/__tests__/useImageEditor.test.js +131 -0
- package/dist/__tests__/useImageEditor.test.js.map +1 -0
- package/dist/__tests__/useMediaRecorder.test.d.ts +2 -0
- package/dist/__tests__/useMediaRecorder.test.d.ts.map +1 -0
- package/dist/__tests__/useMediaRecorder.test.js +153 -0
- package/dist/__tests__/useMediaRecorder.test.js.map +1 -0
- package/dist/__tests__/versionHistory.test.d.ts +2 -0
- package/dist/__tests__/versionHistory.test.d.ts.map +1 -0
- package/dist/__tests__/versionHistory.test.js +124 -0
- package/dist/__tests__/versionHistory.test.js.map +1 -0
- package/dist/blockSlice.d.ts +24 -0
- package/dist/blockSlice.d.ts.map +1 -0
- package/dist/blockSlice.js +63 -0
- package/dist/blockSlice.js.map +1 -0
- package/dist/buildPreviewDoc.d.ts.map +1 -1
- package/dist/buildPreviewDoc.js +52 -2
- package/dist/buildPreviewDoc.js.map +1 -1
- package/dist/emojiData.d.ts +81 -0
- package/dist/emojiData.d.ts.map +1 -0
- package/dist/emojiData.js +1283 -0
- package/dist/emojiData.js.map +1 -0
- package/dist/fileKind.d.ts +6 -2
- package/dist/fileKind.d.ts.map +1 -1
- package/dist/fileKind.js +25 -4
- package/dist/fileKind.js.map +1 -1
- package/dist/hooks/useFileDrop.d.ts.map +1 -1
- package/dist/hooks/useFileDrop.js +40 -4
- package/dist/hooks/useFileDrop.js.map +1 -1
- package/dist/imageEditor/CanvasSurface.d.ts +31 -0
- package/dist/imageEditor/CanvasSurface.d.ts.map +1 -0
- package/dist/imageEditor/CanvasSurface.js +264 -0
- package/dist/imageEditor/CanvasSurface.js.map +1 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.d.ts +39 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.d.ts.map +1 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.js +283 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.js.map +1 -0
- package/dist/imageEditor/LayersPanel.d.ts +14 -0
- package/dist/imageEditor/LayersPanel.d.ts.map +1 -0
- package/dist/imageEditor/LayersPanel.js +43 -0
- package/dist/imageEditor/LayersPanel.js.map +1 -0
- package/dist/imageEditor/PropertiesPanel.d.ts +14 -0
- package/dist/imageEditor/PropertiesPanel.d.ts.map +1 -0
- package/dist/imageEditor/PropertiesPanel.js +97 -0
- package/dist/imageEditor/PropertiesPanel.js.map +1 -0
- package/dist/imageEditor/Toolbar.d.ts +30 -0
- package/dist/imageEditor/Toolbar.d.ts.map +1 -0
- package/dist/imageEditor/Toolbar.js +108 -0
- package/dist/imageEditor/Toolbar.js.map +1 -0
- package/dist/imageEditor/icons.d.ts +24 -0
- package/dist/imageEditor/icons.d.ts.map +1 -0
- package/dist/imageEditor/icons.js +45 -0
- package/dist/imageEditor/icons.js.map +1 -0
- package/dist/imageEditor/layers/EditorImageLayer.d.ts +16 -0
- package/dist/imageEditor/layers/EditorImageLayer.d.ts.map +1 -0
- package/dist/imageEditor/layers/EditorImageLayer.js +37 -0
- package/dist/imageEditor/layers/EditorImageLayer.js.map +1 -0
- package/dist/imageEditor/layers/EditorShapeLayer.d.ts +15 -0
- package/dist/imageEditor/layers/EditorShapeLayer.d.ts.map +1 -0
- package/dist/imageEditor/layers/EditorShapeLayer.js +20 -0
- package/dist/imageEditor/layers/EditorShapeLayer.js.map +1 -0
- package/dist/imageEditor/layers/EditorTextLayer.d.ts +18 -0
- package/dist/imageEditor/layers/EditorTextLayer.d.ts.map +1 -0
- package/dist/imageEditor/layers/EditorTextLayer.js +13 -0
- package/dist/imageEditor/layers/EditorTextLayer.js.map +1 -0
- package/dist/imageEditor/layers/SelectionHandles.d.ts +17 -0
- package/dist/imageEditor/layers/SelectionHandles.d.ts.map +1 -0
- package/dist/imageEditor/layers/SelectionHandles.js +19 -0
- package/dist/imageEditor/layers/SelectionHandles.js.map +1 -0
- package/dist/imageEditor/state.d.ts +76 -0
- package/dist/imageEditor/state.d.ts.map +1 -0
- package/dist/imageEditor/state.js +87 -0
- package/dist/imageEditor/state.js.map +1 -0
- package/dist/imageEditor/useImageEditor.d.ts +53 -0
- package/dist/imageEditor/useImageEditor.d.ts.map +1 -0
- package/dist/imageEditor/useImageEditor.js +244 -0
- package/dist/imageEditor/useImageEditor.js.map +1 -0
- package/dist/imageEditor/useImageEditorTokens.d.ts +16 -0
- package/dist/imageEditor/useImageEditorTokens.d.ts.map +1 -0
- package/dist/imageEditor/useImageEditorTokens.js +45 -0
- package/dist/imageEditor/useImageEditorTokens.js.map +1 -0
- package/dist/index.d.ts +48 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -1
- package/dist/jsonEditor/EmbeddedRichTextField.d.ts +15 -0
- package/dist/jsonEditor/EmbeddedRichTextField.d.ts.map +1 -0
- package/dist/jsonEditor/EmbeddedRichTextField.js +74 -0
- package/dist/jsonEditor/EmbeddedRichTextField.js.map +1 -0
- package/dist/jsonEditor/JsonEditor.d.ts +36 -0
- package/dist/jsonEditor/JsonEditor.d.ts.map +1 -0
- package/dist/jsonEditor/JsonEditor.js +15 -0
- package/dist/jsonEditor/JsonEditor.js.map +1 -0
- package/dist/jsonEditor/JsonEditorContext.d.ts +28 -0
- package/dist/jsonEditor/JsonEditorContext.d.ts.map +1 -0
- package/dist/jsonEditor/JsonEditorContext.js +41 -0
- package/dist/jsonEditor/JsonEditorContext.js.map +1 -0
- package/dist/jsonEditor/RenderNode.d.ts +16 -0
- package/dist/jsonEditor/RenderNode.d.ts.map +1 -0
- package/dist/jsonEditor/RenderNode.js +32 -0
- package/dist/jsonEditor/RenderNode.js.map +1 -0
- package/dist/jsonEditor/editors.d.ts +36 -0
- package/dist/jsonEditor/editors.d.ts.map +1 -0
- package/dist/jsonEditor/editors.js +347 -0
- package/dist/jsonEditor/editors.js.map +1 -0
- package/dist/jsonEditor/index.d.ts +3 -0
- package/dist/jsonEditor/index.d.ts.map +1 -0
- package/dist/jsonEditor/index.js +2 -0
- package/dist/jsonEditor/index.js.map +1 -0
- package/dist/jsonEditor/useJsonEditorTokens.d.ts +13 -0
- package/dist/jsonEditor/useJsonEditorTokens.d.ts.map +1 -0
- package/dist/jsonEditor/useJsonEditorTokens.js +38 -0
- package/dist/jsonEditor/useJsonEditorTokens.js.map +1 -0
- package/dist/recorder/RecorderButton.d.ts +31 -0
- package/dist/recorder/RecorderButton.d.ts.map +1 -0
- package/dist/recorder/RecorderButton.js +24 -0
- package/dist/recorder/RecorderButton.js.map +1 -0
- package/dist/recorder/RecorderModal.d.ts +59 -0
- package/dist/recorder/RecorderModal.d.ts.map +1 -0
- package/dist/recorder/RecorderModal.js +333 -0
- package/dist/recorder/RecorderModal.js.map +1 -0
- package/dist/recorder/RecorderPanel.d.ts +25 -0
- package/dist/recorder/RecorderPanel.d.ts.map +1 -0
- package/dist/recorder/RecorderPanel.js +30 -0
- package/dist/recorder/RecorderPanel.js.map +1 -0
- package/dist/recorder/formats.d.ts +51 -0
- package/dist/recorder/formats.d.ts.map +1 -0
- package/dist/recorder/formats.js +144 -0
- package/dist/recorder/formats.js.map +1 -0
- package/dist/recorder/hooks/useMediaRecorder.d.ts +90 -0
- package/dist/recorder/hooks/useMediaRecorder.d.ts.map +1 -0
- package/dist/recorder/hooks/useMediaRecorder.js +277 -0
- package/dist/recorder/hooks/useMediaRecorder.js.map +1 -0
- package/dist/recorder/hooks/useStreamPreview.d.ts +22 -0
- package/dist/recorder/hooks/useStreamPreview.d.ts.map +1 -0
- package/dist/recorder/hooks/useStreamPreview.js +44 -0
- package/dist/recorder/hooks/useStreamPreview.js.map +1 -0
- package/dist/recorder/sources/cameraStream.d.ts +22 -0
- package/dist/recorder/sources/cameraStream.d.ts.map +1 -0
- package/dist/recorder/sources/cameraStream.js +24 -0
- package/dist/recorder/sources/cameraStream.js.map +1 -0
- package/dist/recorder/sources/micStream.d.ts +15 -0
- package/dist/recorder/sources/micStream.d.ts.map +1 -0
- package/dist/recorder/sources/micStream.js +24 -0
- package/dist/recorder/sources/micStream.js.map +1 -0
- package/dist/recorder/sources/screenStream.d.ts +53 -0
- package/dist/recorder/sources/screenStream.d.ts.map +1 -0
- package/dist/recorder/sources/screenStream.js +114 -0
- package/dist/recorder/sources/screenStream.js.map +1 -0
- package/dist/recorder/timingJson.d.ts +51 -0
- package/dist/recorder/timingJson.d.ts.map +1 -0
- package/dist/recorder/timingJson.js +42 -0
- package/dist/recorder/timingJson.js.map +1 -0
- package/dist/tiptap/TiptapAudio.d.ts +26 -0
- package/dist/tiptap/TiptapAudio.d.ts.map +1 -0
- package/dist/tiptap/TiptapAudio.js +58 -0
- package/dist/tiptap/TiptapAudio.js.map +1 -0
- package/dist/tiptap/TiptapVideo.d.ts +30 -0
- package/dist/tiptap/TiptapVideo.d.ts.map +1 -0
- package/dist/tiptap/TiptapVideo.js +66 -0
- package/dist/tiptap/TiptapVideo.js.map +1 -0
- package/dist/tiptap/useResolvedMediaSrc.d.ts +2 -0
- package/dist/tiptap/useResolvedMediaSrc.d.ts.map +1 -0
- package/dist/tiptap/useResolvedMediaSrc.js +42 -0
- package/dist/tiptap/useResolvedMediaSrc.js.map +1 -0
- package/dist/tiptapBridge.d.ts.map +1 -1
- package/dist/tiptapBridge.js +171 -14
- package/dist/tiptapBridge.js.map +1 -1
- package/dist/useHeadingLayout.d.ts +54 -0
- package/dist/useHeadingLayout.d.ts.map +1 -0
- package/dist/useHeadingLayout.js +260 -0
- package/dist/useHeadingLayout.js.map +1 -0
- package/dist/utils/collectInlineFontAwesomeCss.d.ts +21 -0
- package/dist/utils/collectInlineFontAwesomeCss.d.ts.map +1 -0
- package/dist/utils/collectInlineFontAwesomeCss.js +68 -0
- package/dist/utils/collectInlineFontAwesomeCss.js.map +1 -0
- package/dist/utils/dropUtils.d.ts +21 -2
- package/dist/utils/dropUtils.d.ts.map +1 -1
- package/dist/utils/dropUtils.js +43 -4
- package/dist/utils/dropUtils.js.map +1 -1
- package/dist/utils/normalizeMalformedAssetUrl.d.ts +15 -0
- package/dist/utils/normalizeMalformedAssetUrl.d.ts.map +1 -0
- package/dist/utils/normalizeMalformedAssetUrl.js +27 -0
- package/dist/utils/normalizeMalformedAssetUrl.js.map +1 -0
- package/package.json +8 -5
- package/src/DocumentSettingsDialog.tsx +266 -0
- package/src/EditorContext.tsx +534 -10
- package/src/EditorShell.tsx +571 -55
- package/src/EmojiPicker.tsx +332 -0
- package/src/ImageEditor.tsx +327 -0
- package/src/ImageNodeView.tsx +222 -21
- package/src/ImageViewer.tsx +221 -0
- package/src/InlineIcon.ts +84 -0
- package/src/InlinePreviewGutter.tsx +582 -0
- package/src/LinkDialog.tsx +276 -0
- package/src/MentionExtension.tsx +10 -7
- package/src/OutlinePanel.tsx +295 -0
- package/src/PlainHtmlPreview.tsx +211 -0
- package/src/PreviewControls.tsx +130 -24
- package/src/PreviewPanel.tsx +38 -21
- package/src/RawEditor.tsx +215 -4
- package/src/RecorderEntry.tsx +164 -0
- package/src/TemplateAnnotation.ts +32 -6
- package/src/TemplatePicker.tsx +818 -0
- package/src/ThemeCustomizerPanel.tsx +595 -0
- package/src/ThemePicker.tsx +319 -0
- package/src/Toolbar.tsx +708 -111
- package/src/VersionHistoryPanel.tsx +329 -0
- package/src/ViewMenuPanel.tsx +188 -0
- package/src/WysiwygEditor.tsx +229 -9
- package/src/__tests__/detectMarkdown.test.ts +0 -15
- package/src/__tests__/documentSettingsDialog.test.tsx +147 -0
- package/src/__tests__/emojiPicker.test.tsx +133 -0
- package/src/__tests__/fileKind.test.ts +16 -0
- package/src/__tests__/imageEditAffordance.test.tsx +268 -0
- package/src/__tests__/imageEditorShell.test.tsx +57 -0
- package/src/__tests__/imageEditorState.test.ts +171 -0
- package/src/__tests__/inlinePreviewGutter.test.tsx +62 -0
- package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +103 -0
- package/src/__tests__/jsonEditor.test.tsx +168 -0
- package/src/__tests__/layersPanel.test.tsx +97 -0
- package/src/__tests__/linkDialogDocPicker.test.tsx +137 -0
- package/src/__tests__/outlinePanel.test.tsx +79 -0
- package/src/__tests__/plainHtmlPreview.test.tsx +107 -0
- package/src/__tests__/propertiesPanel.test.tsx +69 -0
- package/src/__tests__/recorderFormats.test.ts +146 -0
- package/src/__tests__/recorderTimingJson.test.ts +41 -0
- package/src/__tests__/templateAnnotationRoundTrip.test.ts +34 -0
- package/src/__tests__/tiptapBridge.test.ts +15 -0
- package/src/__tests__/useImageEditor.test.tsx +159 -0
- package/src/__tests__/useMediaRecorder.test.ts +186 -0
- package/src/__tests__/versionHistory.test.tsx +197 -0
- package/src/blockSlice.ts +75 -0
- package/src/buildPreviewDoc.ts +61 -6
- package/src/emojiData.ts +1337 -0
- package/src/fileKind.ts +30 -6
- package/src/hooks/useFileDrop.ts +40 -4
- package/src/imageEditor/CanvasSurface.tsx +402 -0
- package/src/imageEditor/ImageVersionHistoryDropdown.tsx +396 -0
- package/src/imageEditor/LayersPanel.tsx +143 -0
- package/src/imageEditor/PropertiesPanel.tsx +428 -0
- package/src/imageEditor/Toolbar.tsx +242 -0
- package/src/imageEditor/icons.tsx +144 -0
- package/src/imageEditor/image-editor.css +450 -0
- package/src/imageEditor/layers/EditorImageLayer.tsx +45 -0
- package/src/imageEditor/layers/EditorShapeLayer.tsx +62 -0
- package/src/imageEditor/layers/EditorTextLayer.tsx +45 -0
- package/src/imageEditor/layers/SelectionHandles.tsx +86 -0
- package/src/imageEditor/state.ts +153 -0
- package/src/imageEditor/useImageEditor.ts +328 -0
- package/src/imageEditor/useImageEditorTokens.ts +70 -0
- package/src/index.ts +82 -0
- package/src/jsonEditor/EmbeddedRichTextField.tsx +81 -0
- package/src/jsonEditor/JsonEditor.tsx +81 -0
- package/src/jsonEditor/JsonEditorContext.tsx +75 -0
- package/src/jsonEditor/RenderNode.tsx +66 -0
- package/src/jsonEditor/editors.tsx +678 -0
- package/src/jsonEditor/index.ts +2 -0
- package/src/jsonEditor/json-editor.css +463 -0
- package/src/jsonEditor/useJsonEditorTokens.ts +63 -0
- package/src/recorder/RecorderButton.tsx +72 -0
- package/src/recorder/RecorderModal.tsx +596 -0
- package/src/recorder/RecorderPanel.tsx +93 -0
- package/src/recorder/formats.ts +159 -0
- package/src/recorder/hooks/useMediaRecorder.ts +378 -0
- package/src/recorder/hooks/useStreamPreview.ts +47 -0
- package/src/recorder/sources/cameraStream.ts +32 -0
- package/src/recorder/sources/micStream.ts +25 -0
- package/src/recorder/sources/screenStream.ts +162 -0
- package/src/recorder/timingJson.ts +66 -0
- package/src/styles/editor.css +2490 -51
- package/src/styles/image-edit-affordance.css +201 -0
- package/src/styles/index.css +10 -0
- package/src/tiptap/TiptapAudio.tsx +86 -0
- package/src/tiptap/TiptapVideo.tsx +119 -0
- package/src/tiptap/useResolvedMediaSrc.ts +47 -0
- package/src/tiptapBridge.ts +188 -20
- package/src/useHeadingLayout.ts +294 -0
- package/src/utils/collectInlineFontAwesomeCss.ts +69 -0
- package/src/utils/dropUtils.ts +54 -6
- package/src/utils/normalizeMalformedAssetUrl.ts +22 -0
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editable renderers for `<JsonEditor>`. Each editor is a small
|
|
3
|
+
* controlled component that reads its slice from the
|
|
4
|
+
* `JsonEditorContext` via JSON Pointer and writes back via
|
|
5
|
+
* `setAtPath`. Composite renderers (group, card-stack, tabs) recurse
|
|
6
|
+
* into `RenderNode`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useEffect, useId, useRef, useState, type ChangeEvent } from 'react';
|
|
10
|
+
import {
|
|
11
|
+
arrayItemKind,
|
|
12
|
+
type ControlKind,
|
|
13
|
+
type SquisqAnnotatedSchema,
|
|
14
|
+
} from '@bendyline/squisq/jsonForm';
|
|
15
|
+
import { useJsonEditor } from './JsonEditorContext';
|
|
16
|
+
import { RenderNode } from './RenderNode';
|
|
17
|
+
import { EmbeddedRichTextField } from './EmbeddedRichTextField';
|
|
18
|
+
|
|
19
|
+
export interface EditorProps {
|
|
20
|
+
value: unknown;
|
|
21
|
+
schema: SquisqAnnotatedSchema;
|
|
22
|
+
pointer: string;
|
|
23
|
+
disabled: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// ── Helpers ───────────────────────────────────────────────────────
|
|
27
|
+
|
|
28
|
+
function asString(v: unknown): string {
|
|
29
|
+
if (v === undefined || v === null) return '';
|
|
30
|
+
return String(v);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function asNumber(v: unknown): number | '' {
|
|
34
|
+
if (v === undefined || v === null || v === '') return '';
|
|
35
|
+
const n = Number(v);
|
|
36
|
+
return Number.isFinite(n) ? n : '';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ── Primitive editors ────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
export function TextEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
42
|
+
const { setAtPath } = useJsonEditor();
|
|
43
|
+
return (
|
|
44
|
+
<input
|
|
45
|
+
type="text"
|
|
46
|
+
className="squisq-jf-input"
|
|
47
|
+
value={asString(value)}
|
|
48
|
+
placeholder={schema.squisq?.placeholder}
|
|
49
|
+
disabled={disabled}
|
|
50
|
+
onChange={(e) => setAtPath(pointer, e.target.value)}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function MultilineEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
56
|
+
const { setAtPath } = useJsonEditor();
|
|
57
|
+
const ref = useRef<HTMLTextAreaElement>(null);
|
|
58
|
+
// Auto-grow vertically.
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
const ta = ref.current;
|
|
61
|
+
if (!ta) return;
|
|
62
|
+
ta.style.height = 'auto';
|
|
63
|
+
ta.style.height = `${ta.scrollHeight + 2}px`;
|
|
64
|
+
}, [value]);
|
|
65
|
+
return (
|
|
66
|
+
<textarea
|
|
67
|
+
ref={ref}
|
|
68
|
+
className="squisq-jf-textarea"
|
|
69
|
+
value={asString(value)}
|
|
70
|
+
placeholder={schema.squisq?.placeholder}
|
|
71
|
+
disabled={disabled}
|
|
72
|
+
onChange={(e) => setAtPath(pointer, e.target.value)}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function RichTextEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
78
|
+
const { setAtPath } = useJsonEditor();
|
|
79
|
+
return (
|
|
80
|
+
<EmbeddedRichTextField
|
|
81
|
+
value={asString(value)}
|
|
82
|
+
placeholder={schema.squisq?.placeholder}
|
|
83
|
+
readOnly={disabled}
|
|
84
|
+
onChange={(md) => setAtPath(pointer, md)}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function NumberStepperEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
90
|
+
const { setAtPath } = useJsonEditor();
|
|
91
|
+
const isInt = schema.type === 'integer';
|
|
92
|
+
const step = schema.squisq?.step ?? schema.multipleOf ?? (isInt ? 1 : 0.1);
|
|
93
|
+
const num = asNumber(value);
|
|
94
|
+
const update = (next: number) => {
|
|
95
|
+
const min = schema.minimum ?? schema.exclusiveMinimum;
|
|
96
|
+
const max = schema.maximum ?? schema.exclusiveMaximum;
|
|
97
|
+
let clamped = next;
|
|
98
|
+
if (typeof min === 'number') clamped = Math.max(min, clamped);
|
|
99
|
+
if (typeof max === 'number') clamped = Math.min(max, clamped);
|
|
100
|
+
setAtPath(pointer, isInt ? Math.round(clamped) : clamped);
|
|
101
|
+
};
|
|
102
|
+
return (
|
|
103
|
+
<span className="squisq-jf-stepper">
|
|
104
|
+
<button
|
|
105
|
+
type="button"
|
|
106
|
+
className="squisq-jf-stepper__btn"
|
|
107
|
+
disabled={disabled}
|
|
108
|
+
onClick={() => update((typeof num === 'number' ? num : 0) - step)}
|
|
109
|
+
aria-label="Decrease"
|
|
110
|
+
>
|
|
111
|
+
−
|
|
112
|
+
</button>
|
|
113
|
+
<input
|
|
114
|
+
className="squisq-jf-stepper__input"
|
|
115
|
+
type="number"
|
|
116
|
+
value={num === '' ? '' : num}
|
|
117
|
+
step={step}
|
|
118
|
+
disabled={disabled}
|
|
119
|
+
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
|
120
|
+
if (e.target.value === '') {
|
|
121
|
+
setAtPath(pointer, undefined);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const n = Number(e.target.value);
|
|
125
|
+
if (Number.isFinite(n)) update(n);
|
|
126
|
+
}}
|
|
127
|
+
/>
|
|
128
|
+
<button
|
|
129
|
+
type="button"
|
|
130
|
+
className="squisq-jf-stepper__btn"
|
|
131
|
+
disabled={disabled}
|
|
132
|
+
onClick={() => update((typeof num === 'number' ? num : 0) + step)}
|
|
133
|
+
aria-label="Increase"
|
|
134
|
+
>
|
|
135
|
+
+
|
|
136
|
+
</button>
|
|
137
|
+
</span>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function SliderEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
142
|
+
const { setAtPath } = useJsonEditor();
|
|
143
|
+
const min = (schema.minimum ?? schema.exclusiveMinimum ?? 0) as number;
|
|
144
|
+
const max = (schema.maximum ?? schema.exclusiveMaximum ?? 100) as number;
|
|
145
|
+
const step = schema.squisq?.step ?? schema.multipleOf ?? (schema.type === 'integer' ? 1 : 1);
|
|
146
|
+
const num = asNumber(value);
|
|
147
|
+
const display = typeof num === 'number' ? num : min;
|
|
148
|
+
return (
|
|
149
|
+
<span className="squisq-jf-slider-row">
|
|
150
|
+
<input
|
|
151
|
+
type="range"
|
|
152
|
+
className="squisq-jf-slider"
|
|
153
|
+
min={min}
|
|
154
|
+
max={max}
|
|
155
|
+
step={step}
|
|
156
|
+
value={display}
|
|
157
|
+
disabled={disabled}
|
|
158
|
+
onChange={(e) => setAtPath(pointer, Number(e.target.value))}
|
|
159
|
+
/>
|
|
160
|
+
<span className="squisq-jf-slider-readout">{display}</span>
|
|
161
|
+
</span>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function ToggleEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
166
|
+
const { setAtPath } = useJsonEditor();
|
|
167
|
+
const on = Boolean(value);
|
|
168
|
+
return (
|
|
169
|
+
<button
|
|
170
|
+
type="button"
|
|
171
|
+
className={`squisq-jf-toggle${on ? ' squisq-jf-toggle--on' : ''}`}
|
|
172
|
+
disabled={disabled}
|
|
173
|
+
onClick={() => setAtPath(pointer, !on)}
|
|
174
|
+
aria-pressed={on}
|
|
175
|
+
>
|
|
176
|
+
<span className="squisq-jf-toggle__track">
|
|
177
|
+
<span className="squisq-jf-toggle__thumb" />
|
|
178
|
+
</span>
|
|
179
|
+
<span className="squisq-jf-toggle__label">
|
|
180
|
+
{on
|
|
181
|
+
? schema.squisq?.label
|
|
182
|
+
? `${schema.squisq.label}: On`
|
|
183
|
+
: 'On'
|
|
184
|
+
: schema.squisq?.label
|
|
185
|
+
? `${schema.squisq.label}: Off`
|
|
186
|
+
: 'Off'}
|
|
187
|
+
</span>
|
|
188
|
+
</button>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function CheckboxEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
193
|
+
const { setAtPath } = useJsonEditor();
|
|
194
|
+
const id = useId();
|
|
195
|
+
return (
|
|
196
|
+
<label htmlFor={id} className="squisq-jf-toggle">
|
|
197
|
+
<input
|
|
198
|
+
id={id}
|
|
199
|
+
type="checkbox"
|
|
200
|
+
checked={Boolean(value)}
|
|
201
|
+
disabled={disabled}
|
|
202
|
+
onChange={(e) => setAtPath(pointer, e.target.checked)}
|
|
203
|
+
/>
|
|
204
|
+
{schema.squisq?.label ?? schema.title ?? ''}
|
|
205
|
+
</label>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function enumOptions(schema: SquisqAnnotatedSchema): { value: unknown; label: string }[] {
|
|
210
|
+
const labels = schema.squisq?.enumLabels;
|
|
211
|
+
return (schema.enum ?? []).map((v) => ({
|
|
212
|
+
value: v,
|
|
213
|
+
label: labels && typeof v === 'string' ? (labels[v] ?? String(v)) : String(v),
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function SegmentedEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
218
|
+
const { setAtPath } = useJsonEditor();
|
|
219
|
+
const options = enumOptions(schema);
|
|
220
|
+
return (
|
|
221
|
+
<span className="squisq-jf-segmented">
|
|
222
|
+
{options.map((opt, i) => {
|
|
223
|
+
const active = value === opt.value;
|
|
224
|
+
return (
|
|
225
|
+
<button
|
|
226
|
+
key={i}
|
|
227
|
+
type="button"
|
|
228
|
+
className={`squisq-jf-segmented__btn${active ? ' squisq-jf-segmented__btn--active' : ''}`}
|
|
229
|
+
disabled={disabled}
|
|
230
|
+
onClick={() => setAtPath(pointer, opt.value)}
|
|
231
|
+
>
|
|
232
|
+
{opt.label}
|
|
233
|
+
</button>
|
|
234
|
+
);
|
|
235
|
+
})}
|
|
236
|
+
</span>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function RadioEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
241
|
+
const { setAtPath } = useJsonEditor();
|
|
242
|
+
const options = enumOptions(schema);
|
|
243
|
+
const name = useId();
|
|
244
|
+
return (
|
|
245
|
+
<div className="squisq-jf-radio">
|
|
246
|
+
{options.map((opt, i) => {
|
|
247
|
+
const active = value === opt.value;
|
|
248
|
+
return (
|
|
249
|
+
<label key={i} className="squisq-jf-radio__option">
|
|
250
|
+
<input
|
|
251
|
+
type="radio"
|
|
252
|
+
name={name}
|
|
253
|
+
checked={active}
|
|
254
|
+
disabled={disabled}
|
|
255
|
+
onChange={() => setAtPath(pointer, opt.value)}
|
|
256
|
+
/>
|
|
257
|
+
{opt.label}
|
|
258
|
+
</label>
|
|
259
|
+
);
|
|
260
|
+
})}
|
|
261
|
+
</div>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export function ComboboxEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
266
|
+
const { setAtPath } = useJsonEditor();
|
|
267
|
+
const options = enumOptions(schema);
|
|
268
|
+
return (
|
|
269
|
+
<select
|
|
270
|
+
className="squisq-jf-select"
|
|
271
|
+
value={asString(value)}
|
|
272
|
+
disabled={disabled}
|
|
273
|
+
onChange={(e) => {
|
|
274
|
+
const raw = e.target.value;
|
|
275
|
+
const matched = options.find((opt) => String(opt.value) === raw);
|
|
276
|
+
setAtPath(pointer, matched ? matched.value : raw);
|
|
277
|
+
}}
|
|
278
|
+
>
|
|
279
|
+
{options.map((opt, i) => (
|
|
280
|
+
<option key={i} value={String(opt.value)}>
|
|
281
|
+
{opt.label}
|
|
282
|
+
</option>
|
|
283
|
+
))}
|
|
284
|
+
</select>
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function ColorEditor({ value, pointer, disabled }: EditorProps) {
|
|
289
|
+
const { setAtPath } = useJsonEditor();
|
|
290
|
+
const hex = typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value) ? value : '#000000';
|
|
291
|
+
return (
|
|
292
|
+
<span className="squisq-jf-color">
|
|
293
|
+
<input
|
|
294
|
+
type="color"
|
|
295
|
+
className="squisq-jf-color__input"
|
|
296
|
+
value={hex}
|
|
297
|
+
disabled={disabled}
|
|
298
|
+
onChange={(e) => setAtPath(pointer, e.target.value)}
|
|
299
|
+
/>
|
|
300
|
+
<input
|
|
301
|
+
type="text"
|
|
302
|
+
className="squisq-jf-input squisq-jf-color__hex"
|
|
303
|
+
value={asString(value)}
|
|
304
|
+
disabled={disabled}
|
|
305
|
+
onChange={(e) => setAtPath(pointer, e.target.value)}
|
|
306
|
+
/>
|
|
307
|
+
</span>
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export function DateEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
312
|
+
const { setAtPath } = useJsonEditor();
|
|
313
|
+
const fmt = schema.format;
|
|
314
|
+
const inputType = fmt === 'time' ? 'time' : fmt === 'date' ? 'date' : 'datetime-local';
|
|
315
|
+
// datetime-local needs YYYY-MM-DDTHH:mm; if the value is an ISO string we
|
|
316
|
+
// strip the trailing Z + seconds for the input, then write back the full
|
|
317
|
+
// value the user picked.
|
|
318
|
+
const display =
|
|
319
|
+
inputType === 'datetime-local' && typeof value === 'string' && value.includes('T')
|
|
320
|
+
? value.replace(/Z$|:\d{2}\.\d+Z?$/, '').slice(0, 16)
|
|
321
|
+
: asString(value);
|
|
322
|
+
return (
|
|
323
|
+
<input
|
|
324
|
+
type={inputType}
|
|
325
|
+
className="squisq-jf-input"
|
|
326
|
+
value={display}
|
|
327
|
+
disabled={disabled}
|
|
328
|
+
onChange={(e) => setAtPath(pointer, e.target.value)}
|
|
329
|
+
/>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// ── Composite editors ────────────────────────────────────────────
|
|
334
|
+
|
|
335
|
+
export function GroupEditor(props: EditorProps & { suppressTitle?: boolean }) {
|
|
336
|
+
const { value, schema, pointer, disabled, suppressTitle } = props;
|
|
337
|
+
const title = !suppressTitle ? (schema.squisq?.label ?? schema.title) : undefined;
|
|
338
|
+
const help = schema.squisq?.help ?? schema.description;
|
|
339
|
+
const obj = (value && typeof value === 'object' ? (value as Record<string, unknown>) : {}) ?? {};
|
|
340
|
+
const propEntries = Object.entries(schema.properties ?? {});
|
|
341
|
+
|
|
342
|
+
return (
|
|
343
|
+
<section className="squisq-jf-group">
|
|
344
|
+
{title ? <h3 className="squisq-jf-group__title">{title}</h3> : null}
|
|
345
|
+
{help ? <p className="squisq-jf-group__help">{help}</p> : null}
|
|
346
|
+
{propEntries.map(([key, propSchema]) => (
|
|
347
|
+
<RenderNode
|
|
348
|
+
key={key}
|
|
349
|
+
value={obj[key]}
|
|
350
|
+
schema={propSchema}
|
|
351
|
+
pointer={`${pointer}/${key}`}
|
|
352
|
+
parentDisabled={disabled}
|
|
353
|
+
/>
|
|
354
|
+
))}
|
|
355
|
+
</section>
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export function ChipBinEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
360
|
+
const { setAtPath } = useJsonEditor();
|
|
361
|
+
const items: unknown[] = Array.isArray(value) ? value : [];
|
|
362
|
+
const itemSchema = (Array.isArray(schema.items) ? schema.items[0] : schema.items) ?? {
|
|
363
|
+
type: 'string',
|
|
364
|
+
};
|
|
365
|
+
const labels = itemSchema.squisq?.enumLabels;
|
|
366
|
+
const enumOpts = itemSchema.enum;
|
|
367
|
+
const [draft, setDraft] = useState('');
|
|
368
|
+
|
|
369
|
+
const remove = (index: number) => {
|
|
370
|
+
const next = items.slice();
|
|
371
|
+
next.splice(index, 1);
|
|
372
|
+
setAtPath(pointer, next);
|
|
373
|
+
};
|
|
374
|
+
const add = (raw: string) => {
|
|
375
|
+
if (raw === '') return;
|
|
376
|
+
const coerced = coerceToSchema(raw, itemSchema);
|
|
377
|
+
setAtPath(pointer, [...items, coerced]);
|
|
378
|
+
setDraft('');
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
return (
|
|
382
|
+
<div className="squisq-jf-chip-bin">
|
|
383
|
+
{items.map((item, i) => {
|
|
384
|
+
const display =
|
|
385
|
+
labels && typeof item === 'string' ? (labels[item] ?? String(item)) : String(item);
|
|
386
|
+
return (
|
|
387
|
+
<span key={i} className="squisq-jf-chip">
|
|
388
|
+
{display}
|
|
389
|
+
<button
|
|
390
|
+
type="button"
|
|
391
|
+
className="squisq-jf-chip__remove"
|
|
392
|
+
disabled={disabled}
|
|
393
|
+
onClick={() => remove(i)}
|
|
394
|
+
aria-label={`Remove ${display}`}
|
|
395
|
+
>
|
|
396
|
+
×
|
|
397
|
+
</button>
|
|
398
|
+
</span>
|
|
399
|
+
);
|
|
400
|
+
})}
|
|
401
|
+
{!disabled && enumOpts && enumOpts.length > 0 ? (
|
|
402
|
+
<select
|
|
403
|
+
className="squisq-jf-select"
|
|
404
|
+
value=""
|
|
405
|
+
onChange={(e) => add(e.target.value)}
|
|
406
|
+
style={{ width: 'auto' }}
|
|
407
|
+
>
|
|
408
|
+
<option value="" disabled>
|
|
409
|
+
{schema.squisq?.addLabel ?? '+ Add'}
|
|
410
|
+
</option>
|
|
411
|
+
{enumOpts
|
|
412
|
+
.filter((v: unknown) => !items.includes(v))
|
|
413
|
+
.map((v: unknown, i: number) => (
|
|
414
|
+
<option key={i} value={String(v)}>
|
|
415
|
+
{labels && typeof v === 'string' ? (labels[v] ?? String(v)) : String(v)}
|
|
416
|
+
</option>
|
|
417
|
+
))}
|
|
418
|
+
</select>
|
|
419
|
+
) : !disabled ? (
|
|
420
|
+
<input
|
|
421
|
+
type="text"
|
|
422
|
+
className="squisq-jf-chip-bin__add-input"
|
|
423
|
+
placeholder={schema.squisq?.addLabel ?? '+ Add'}
|
|
424
|
+
value={draft}
|
|
425
|
+
onChange={(e) => setDraft(e.target.value)}
|
|
426
|
+
onKeyDown={(e) => {
|
|
427
|
+
if (e.key === 'Enter' || e.key === ',') {
|
|
428
|
+
e.preventDefault();
|
|
429
|
+
add(draft.trim());
|
|
430
|
+
}
|
|
431
|
+
}}
|
|
432
|
+
onBlur={() => add(draft.trim())}
|
|
433
|
+
/>
|
|
434
|
+
) : null}
|
|
435
|
+
</div>
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function coerceToSchema(raw: string, schema: SquisqAnnotatedSchema): unknown {
|
|
440
|
+
switch (schema.type) {
|
|
441
|
+
case 'integer':
|
|
442
|
+
return parseInt(raw, 10);
|
|
443
|
+
case 'number':
|
|
444
|
+
return Number(raw);
|
|
445
|
+
case 'boolean':
|
|
446
|
+
return raw === 'true' || raw === '1';
|
|
447
|
+
default:
|
|
448
|
+
return raw;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export function CardStackEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
453
|
+
const { setAtPath } = useJsonEditor();
|
|
454
|
+
const items: unknown[] = Array.isArray(value) ? value : [];
|
|
455
|
+
const itemSchema = (Array.isArray(schema.items) ? schema.items[0] : schema.items) ?? {
|
|
456
|
+
type: 'object',
|
|
457
|
+
};
|
|
458
|
+
const itemLabel = itemSchema.squisq?.itemLabel;
|
|
459
|
+
const addLabel = schema.squisq?.addLabel ?? '+ Add';
|
|
460
|
+
|
|
461
|
+
const updateItems = (next: unknown[]) => setAtPath(pointer, next);
|
|
462
|
+
const addItem = () => updateItems([...items, defaultForSchema(itemSchema)]);
|
|
463
|
+
const removeItem = (i: number) => {
|
|
464
|
+
const next = items.slice();
|
|
465
|
+
next.splice(i, 1);
|
|
466
|
+
updateItems(next);
|
|
467
|
+
};
|
|
468
|
+
const moveItem = (i: number, delta: number) => {
|
|
469
|
+
const j = i + delta;
|
|
470
|
+
if (j < 0 || j >= items.length) return;
|
|
471
|
+
const next = items.slice();
|
|
472
|
+
[next[i], next[j]] = [next[j], next[i]];
|
|
473
|
+
updateItems(next);
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
return (
|
|
477
|
+
<div>
|
|
478
|
+
<div className="squisq-jf-card-stack">
|
|
479
|
+
{items.map((item, i) => {
|
|
480
|
+
const title = resolveItemTitle(itemLabel, item, i);
|
|
481
|
+
return (
|
|
482
|
+
<div key={i} className="squisq-jf-card">
|
|
483
|
+
<div className="squisq-jf-card__header">
|
|
484
|
+
<h4 className="squisq-jf-card__title">{title}</h4>
|
|
485
|
+
{!disabled ? (
|
|
486
|
+
<span className="squisq-jf-card__actions">
|
|
487
|
+
<button
|
|
488
|
+
type="button"
|
|
489
|
+
className="squisq-jf-icon-btn"
|
|
490
|
+
onClick={() => moveItem(i, -1)}
|
|
491
|
+
disabled={i === 0}
|
|
492
|
+
aria-label="Move up"
|
|
493
|
+
title="Move up"
|
|
494
|
+
>
|
|
495
|
+
↑
|
|
496
|
+
</button>
|
|
497
|
+
<button
|
|
498
|
+
type="button"
|
|
499
|
+
className="squisq-jf-icon-btn"
|
|
500
|
+
onClick={() => moveItem(i, +1)}
|
|
501
|
+
disabled={i === items.length - 1}
|
|
502
|
+
aria-label="Move down"
|
|
503
|
+
title="Move down"
|
|
504
|
+
>
|
|
505
|
+
↓
|
|
506
|
+
</button>
|
|
507
|
+
<button
|
|
508
|
+
type="button"
|
|
509
|
+
className="squisq-jf-icon-btn squisq-jf-icon-btn--danger"
|
|
510
|
+
onClick={() => removeItem(i)}
|
|
511
|
+
aria-label={schema.squisq?.removeLabel ?? 'Remove'}
|
|
512
|
+
title={schema.squisq?.removeLabel ?? 'Remove'}
|
|
513
|
+
>
|
|
514
|
+
×
|
|
515
|
+
</button>
|
|
516
|
+
</span>
|
|
517
|
+
) : null}
|
|
518
|
+
</div>
|
|
519
|
+
<RenderNode
|
|
520
|
+
value={item}
|
|
521
|
+
schema={itemSchema}
|
|
522
|
+
pointer={`${pointer}/${i}`}
|
|
523
|
+
parentDisabled={disabled}
|
|
524
|
+
suppressTopGroupTitle
|
|
525
|
+
/>
|
|
526
|
+
</div>
|
|
527
|
+
);
|
|
528
|
+
})}
|
|
529
|
+
</div>
|
|
530
|
+
{!disabled ? (
|
|
531
|
+
<button
|
|
532
|
+
type="button"
|
|
533
|
+
className="squisq-jf-add-btn"
|
|
534
|
+
onClick={addItem}
|
|
535
|
+
style={{ marginTop: 8 }}
|
|
536
|
+
>
|
|
537
|
+
{addLabel}
|
|
538
|
+
</button>
|
|
539
|
+
) : null}
|
|
540
|
+
</div>
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
function resolveItemTitle(
|
|
545
|
+
spec: string | { fromField: string } | undefined,
|
|
546
|
+
item: unknown,
|
|
547
|
+
index: number,
|
|
548
|
+
): string {
|
|
549
|
+
if (!spec) return `Item ${index + 1}`;
|
|
550
|
+
if (typeof spec === 'string') return spec;
|
|
551
|
+
if (item && typeof item === 'object') {
|
|
552
|
+
const v = (item as Record<string, unknown>)[spec.fromField];
|
|
553
|
+
if (typeof v === 'string' && v !== '') return v;
|
|
554
|
+
if (typeof v === 'number') return String(v);
|
|
555
|
+
}
|
|
556
|
+
return `Item ${index + 1}`;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function defaultForSchema(schema: SquisqAnnotatedSchema): unknown {
|
|
560
|
+
if (schema.default !== undefined) return schema.default;
|
|
561
|
+
const t = Array.isArray(schema.type) ? schema.type.find((x) => x !== 'null') : schema.type;
|
|
562
|
+
switch (t) {
|
|
563
|
+
case 'object': {
|
|
564
|
+
const out: Record<string, unknown> = {};
|
|
565
|
+
for (const [k, v] of Object.entries(schema.properties ?? {})) {
|
|
566
|
+
out[k] = defaultForSchema(v);
|
|
567
|
+
}
|
|
568
|
+
return out;
|
|
569
|
+
}
|
|
570
|
+
case 'array':
|
|
571
|
+
return [];
|
|
572
|
+
case 'string':
|
|
573
|
+
return '';
|
|
574
|
+
case 'number':
|
|
575
|
+
case 'integer':
|
|
576
|
+
return (schema.minimum ?? 0) as number;
|
|
577
|
+
case 'boolean':
|
|
578
|
+
return false;
|
|
579
|
+
default:
|
|
580
|
+
return undefined;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export function TabsEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
585
|
+
const branches = (schema.oneOf ?? schema.anyOf ?? []) as readonly SquisqAnnotatedSchema[];
|
|
586
|
+
const initial = pickMatchingBranch(branches, value);
|
|
587
|
+
const [active, setActive] = useState(initial);
|
|
588
|
+
// Sync if value changes externally to a different branch shape.
|
|
589
|
+
useEffect(() => {
|
|
590
|
+
setActive(pickMatchingBranch(branches, value));
|
|
591
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
592
|
+
}, [value]);
|
|
593
|
+
|
|
594
|
+
const branch = branches[active];
|
|
595
|
+
if (!branch) return null;
|
|
596
|
+
return (
|
|
597
|
+
<div>
|
|
598
|
+
<div className="squisq-jf-tabs__strip">
|
|
599
|
+
{branches.map((b, i) => (
|
|
600
|
+
<button
|
|
601
|
+
key={i}
|
|
602
|
+
type="button"
|
|
603
|
+
className={`squisq-jf-tabs__tab${i === active ? ' squisq-jf-tabs__tab--active' : ''}`}
|
|
604
|
+
disabled={disabled}
|
|
605
|
+
onClick={() => setActive(i)}
|
|
606
|
+
>
|
|
607
|
+
{b.squisq?.label ?? b.title ?? `Option ${i + 1}`}
|
|
608
|
+
</button>
|
|
609
|
+
))}
|
|
610
|
+
</div>
|
|
611
|
+
<RenderNode value={value} schema={branch} pointer={pointer} parentDisabled={disabled} />
|
|
612
|
+
</div>
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
function pickMatchingBranch(branches: readonly SquisqAnnotatedSchema[], value: unknown): number {
|
|
617
|
+
for (let i = 0; i < branches.length; i++) {
|
|
618
|
+
if (matchesShape(branches[i], value)) return i;
|
|
619
|
+
}
|
|
620
|
+
return 0;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function matchesShape(schema: SquisqAnnotatedSchema, value: unknown): boolean {
|
|
624
|
+
const t = schema.type;
|
|
625
|
+
const target = Array.isArray(t) ? t.find((x) => x !== 'null') : t;
|
|
626
|
+
if (!target) return true;
|
|
627
|
+
switch (target) {
|
|
628
|
+
case 'string':
|
|
629
|
+
return typeof value === 'string';
|
|
630
|
+
case 'number':
|
|
631
|
+
case 'integer':
|
|
632
|
+
return typeof value === 'number';
|
|
633
|
+
case 'boolean':
|
|
634
|
+
return typeof value === 'boolean';
|
|
635
|
+
case 'null':
|
|
636
|
+
return value === null;
|
|
637
|
+
case 'array':
|
|
638
|
+
return Array.isArray(value);
|
|
639
|
+
case 'object':
|
|
640
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
641
|
+
default:
|
|
642
|
+
return false;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// ── Registry ──────────────────────────────────────────────────────
|
|
647
|
+
|
|
648
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
649
|
+
export const EDITORS: Record<ControlKind, React.ComponentType<EditorProps>> = {
|
|
650
|
+
text: TextEditor,
|
|
651
|
+
multiline: MultilineEditor,
|
|
652
|
+
richtext: RichTextEditor,
|
|
653
|
+
color: ColorEditor,
|
|
654
|
+
date: DateEditor,
|
|
655
|
+
time: DateEditor,
|
|
656
|
+
datetime: DateEditor,
|
|
657
|
+
slider: SliderEditor,
|
|
658
|
+
stepper: NumberStepperEditor,
|
|
659
|
+
segmented: SegmentedEditor,
|
|
660
|
+
radio: RadioEditor,
|
|
661
|
+
combobox: ComboboxEditor,
|
|
662
|
+
toggle: ToggleEditor,
|
|
663
|
+
checkbox: CheckboxEditor,
|
|
664
|
+
card: GroupEditor,
|
|
665
|
+
group: GroupEditor,
|
|
666
|
+
'card-stack': CardStackEditor,
|
|
667
|
+
'chip-bin': ChipBinEditor,
|
|
668
|
+
tabs: TabsEditor,
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
/** True when this control kind handles its own grouping/heading. */
|
|
672
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
673
|
+
export function isCompositeControl(kind: ControlKind, schema: SquisqAnnotatedSchema): boolean {
|
|
674
|
+
if (kind === 'group' || kind === 'card' || kind === 'tabs' || kind === 'card-stack') return true;
|
|
675
|
+
if (kind === 'richtext') return true;
|
|
676
|
+
if (kind === 'chip-bin') return arrayItemKind(schema) === 'object';
|
|
677
|
+
return false;
|
|
678
|
+
}
|