@bendyline/squisq-editor-react 2.1.0 → 2.3.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/LICENSE +21 -0
- package/NOTICE.md +40 -0
- package/dist/chunk-54UGTQBO.js +862 -0
- package/dist/chunk-5JMHFAVW.js +2408 -0
- package/dist/chunk-5Q4JN4I5.js +132 -0
- package/dist/chunk-6VDYKI3L.js +49 -0
- package/dist/chunk-GS7QWYFT.js +9 -0
- package/dist/chunk-MJJK7YQB.js +949 -0
- package/dist/chunk-NITZVAXL.js +986 -0
- package/dist/chunk-TRCKHRBS.js +35234 -0
- package/dist/chunk-V44VP242.js +3256 -0
- package/dist/image-editor/index.d.ts +223 -0
- package/dist/image-editor/index.js +15 -0
- package/dist/index.d.ts +2060 -4040
- package/dist/index.js +496 -40014
- package/dist/json-editor/index.d.ts +27 -0
- package/dist/json-editor/index.js +7 -0
- package/dist/monaco.d.ts +1 -1
- package/dist/monaco.js +1 -2
- package/dist/recorder/index.d.ts +407 -0
- package/dist/recorder/index.js +43 -0
- package/dist/shell/index.d.ts +9 -0
- package/dist/shell/index.js +22 -0
- package/dist/shell-BxSCBm4H.d.ts +1064 -0
- package/dist/styles/index.css +598 -161
- package/dist/teleprompter/index.d.ts +497 -0
- package/dist/teleprompter/index.js +57 -0
- package/package.json +34 -8
- package/dist/index.js.map +0 -1
- package/dist/monaco.js.map +0 -1
- package/src/BlockCardView.tsx +0 -121
- package/src/BlockPreviewPanel.tsx +0 -69
- package/src/BlockPropertiesPopover.tsx +0 -222
- package/src/DocumentSettingsDialog.tsx +0 -272
- package/src/DropZoneOverlay.tsx +0 -137
- package/src/EditorContext.tsx +0 -1274
- package/src/EditorShell.tsx +0 -1358
- package/src/EmojiPicker.tsx +0 -332
- package/src/FolderView.tsx +0 -131
- package/src/Icon.tsx +0 -26
- package/src/ImageEditor.tsx +0 -395
- package/src/ImageNodeView.tsx +0 -284
- package/src/ImageViewer.tsx +0 -221
- package/src/InlineIcon.ts +0 -84
- package/src/InlinePreviewGutter.tsx +0 -590
- package/src/LinkDialog.tsx +0 -276
- package/src/MediaBin.tsx +0 -500
- package/src/MentionExtension.tsx +0 -261
- package/src/OutlinePanel.tsx +0 -547
- package/src/PlainHtmlPreview.tsx +0 -277
- package/src/PreviewControls.tsx +0 -1265
- package/src/PreviewPanel.tsx +0 -426
- package/src/RawEditor.tsx +0 -743
- package/src/RecorderEntry.tsx +0 -162
- package/src/StatusBar.tsx +0 -51
- package/src/TemplateAnnotation.ts +0 -167
- package/src/TemplateContentPreview.tsx +0 -56
- package/src/TemplatePicker.tsx +0 -1314
- package/src/ThemeCustomizerPanel.tsx +0 -304
- package/src/ThemePicker.tsx +0 -433
- package/src/TimelineBlockPreview.tsx +0 -37
- package/src/TimelineTrack.tsx +0 -671
- package/src/Toolbar.tsx +0 -2885
- package/src/Tooltip.tsx +0 -142
- package/src/TransitionPicker.tsx +0 -390
- package/src/VersionHistoryPanel.tsx +0 -359
- package/src/ViewMenuPanel.tsx +0 -189
- package/src/ViewSwitcher.tsx +0 -56
- package/src/WysiwygEditor.tsx +0 -806
- package/src/__tests__/blockProperties.test.ts +0 -92
- package/src/__tests__/blockPropertiesPopoverTheme.test.tsx +0 -33
- package/src/__tests__/blockRange.test.ts +0 -105
- package/src/__tests__/blockTagActivity.test.ts +0 -183
- package/src/__tests__/buildDocumentPreviewMarkdown.test.ts +0 -75
- package/src/__tests__/buildPreviewDocContent.test.ts +0 -65
- package/src/__tests__/buildPreviewDocTransition.test.ts +0 -92
- package/src/__tests__/canvasSurfaceTextEditing.test.tsx +0 -60
- package/src/__tests__/codeContextSectionView.test.tsx +0 -97
- package/src/__tests__/codeContextZoneManager.test.ts +0 -127
- package/src/__tests__/createShapeLayer.test.ts +0 -46
- package/src/__tests__/customLayoutManagerTheme.test.tsx +0 -34
- package/src/__tests__/detectMarkdown.test.ts +0 -73
- package/src/__tests__/diffContextSections.test.ts +0 -39
- package/src/__tests__/documentSettingsDialog.test.tsx +0 -197
- package/src/__tests__/drawingShapeRoundTrip.test.ts +0 -49
- package/src/__tests__/editorScrollHandoff.test.tsx +0 -102
- package/src/__tests__/editorScrollSync.test.ts +0 -65
- package/src/__tests__/editorShellCodeContext.test.tsx +0 -86
- package/src/__tests__/editorShellProps.test.tsx +0 -550
- package/src/__tests__/embeddedMedia.test.ts +0 -48
- package/src/__tests__/emojiPicker.test.tsx +0 -93
- package/src/__tests__/fileKind.test.ts +0 -112
- package/src/__tests__/findMode.test.tsx +0 -104
- package/src/__tests__/findModel.test.ts +0 -55
- package/src/__tests__/headingTransition.test.ts +0 -176
- package/src/__tests__/imageEditAffordance.test.tsx +0 -272
- package/src/__tests__/imageEditModalContract.test.tsx +0 -119
- package/src/__tests__/imageEditorShell.test.tsx +0 -94
- package/src/__tests__/imageEditorState.test.ts +0 -171
- package/src/__tests__/inlinePreviewGutter.test.tsx +0 -62
- package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +0 -103
- package/src/__tests__/jsonEditor.test.tsx +0 -223
- package/src/__tests__/layersPanel.test.tsx +0 -167
- package/src/__tests__/layoutChildRoundTrip.test.ts +0 -71
- package/src/__tests__/linkDialogDocPicker.test.tsx +0 -137
- package/src/__tests__/majorApiTypes.test.ts +0 -26
- package/src/__tests__/markdownCodeFence.test.ts +0 -45
- package/src/__tests__/mediaAttachmentFlow.test.ts +0 -110
- package/src/__tests__/mediaBinDrop.test.tsx +0 -90
- package/src/__tests__/mediaReferences.test.ts +0 -97
- package/src/__tests__/narrationSave.test.ts +0 -148
- package/src/__tests__/outlinePanel.test.tsx +0 -169
- package/src/__tests__/outlineSource.test.ts +0 -217
- package/src/__tests__/plainHtmlPreview.test.tsx +0 -125
- package/src/__tests__/presentationMode.test.tsx +0 -290
- package/src/__tests__/previewControls.test.tsx +0 -571
- package/src/__tests__/previewPanelAudioFailure.test.tsx +0 -46
- package/src/__tests__/previewPanelPresentation.test.tsx +0 -126
- package/src/__tests__/previewPanelTransforms.test.tsx +0 -117
- package/src/__tests__/propertiesPanel.test.tsx +0 -69
- package/src/__tests__/rawEditorModelIsolation.test.ts +0 -19
- package/src/__tests__/recorderFormats.test.ts +0 -146
- package/src/__tests__/recorderMediaInsert.test.ts +0 -86
- package/src/__tests__/recorderTheme.test.tsx +0 -42
- package/src/__tests__/recorderTimingJson.test.ts +0 -41
- package/src/__tests__/resolveBlockVisual.test.ts +0 -43
- package/src/__tests__/selectionConversions.test.ts +0 -80
- package/src/__tests__/statusBar.test.tsx +0 -27
- package/src/__tests__/teleprompter.test.tsx +0 -190
- package/src/__tests__/templateAnnotationRoundTrip.test.ts +0 -99
- package/src/__tests__/templateContentPreview.test.ts +0 -101
- package/src/__tests__/templatePickerMetadata.test.ts +0 -32
- package/src/__tests__/templatePickerPortal.test.tsx +0 -62
- package/src/__tests__/timelineSource.test.ts +0 -134
- package/src/__tests__/tiptapBridge.test.ts +0 -575
- package/src/__tests__/tiptapBridgeConformance.test.ts +0 -47
- package/src/__tests__/tiptapCodeBlockRoundTrip.test.ts +0 -109
- package/src/__tests__/tiptapImageRoundTrip.test.ts +0 -73
- package/src/__tests__/toolbarSelectionConversion.test.tsx +0 -190
- package/src/__tests__/tooltip.test.tsx +0 -72
- package/src/__tests__/transformStyleId.test.ts +0 -13
- package/src/__tests__/transitionCatalog.test.ts +0 -64
- package/src/__tests__/useBlockNavigator.test.tsx +0 -67
- package/src/__tests__/useImageEditor.test.tsx +0 -226
- package/src/__tests__/useJsonEditorTokens.test.ts +0 -59
- package/src/__tests__/useMediaRecorder.test.ts +0 -302
- package/src/__tests__/useTimelineClock.test.ts +0 -21
- package/src/__tests__/versionHistory.test.tsx +0 -197
- package/src/__tests__/viewMenuPanel.test.tsx +0 -130
- package/src/__tests__/writeCanvasSettings.test.ts +0 -15
- package/src/__tests__/wysiwygImageUpload.test.ts +0 -69
- package/src/__tests__/wysiwygTemplateBadgeFocus.test.tsx +0 -56
- package/src/asciiDiagram/AsciiDiagramExtension.ts +0 -343
- package/src/asciiDiagram/AsciiDiagramWidget.tsx +0 -254
- package/src/asciiDiagram/RepairableDiagramExtension.ts +0 -200
- package/src/asciiDiagram/__tests__/AsciiDiagramExtension.test.ts +0 -164
- package/src/asciiDiagram/__tests__/RepairableDiagramExtension.test.ts +0 -159
- package/src/asciiDiagram/__tests__/asciiDiagramCommands.test.ts +0 -284
- package/src/asciiDiagram/__tests__/asciiDiagramOps.test.ts +0 -114
- package/src/asciiDiagram/__tests__/asciiPaste.test.ts +0 -43
- package/src/asciiDiagram/asciiDiagramCommands.ts +0 -174
- package/src/asciiDiagram/asciiDiagramData.ts +0 -149
- package/src/asciiDiagram/asciiDiagramOps.ts +0 -238
- package/src/asciiDiagram/asciiPaste.ts +0 -19
- package/src/blockProperties.ts +0 -88
- package/src/blockRange.ts +0 -132
- package/src/blockSlice.ts +0 -75
- package/src/blockTagActivity.ts +0 -233
- package/src/buildDocumentPreviewMarkdown.ts +0 -168
- package/src/buildPreviewDoc.ts +0 -407
- package/src/codeContext/CodeContextSectionView.tsx +0 -124
- package/src/codeContext/CodeContextZoneManager.ts +0 -149
- package/src/codeContext/CodeContextZones.tsx +0 -121
- package/src/codeContext/diffContextSections.ts +0 -38
- package/src/codeContext/types.ts +0 -75
- package/src/codeSnippet/CodeSnippetExtension.ts +0 -205
- package/src/codeSnippet/CodeSnippetWidget.tsx +0 -109
- package/src/codeSnippet/__tests__/CodeSnippetExtension.test.ts +0 -95
- package/src/codeSnippet/__tests__/codeSnippetLanguages.test.ts +0 -50
- package/src/codeSnippet/codeSnippetCommands.ts +0 -21
- package/src/codeSnippet/codeSnippetData.ts +0 -43
- package/src/codeSnippet/codeSnippetLanguages.ts +0 -216
- package/src/customTemplates/AddBin.tsx +0 -126
- package/src/customTemplates/CustomLayoutManager.tsx +0 -234
- package/src/customTemplates/CustomTemplateContext.tsx +0 -188
- package/src/customTemplates/LayerToolbar.tsx +0 -580
- package/src/customTemplates/ShapeGlyph.tsx +0 -47
- package/src/customTemplates/TemplateDesigner.tsx +0 -433
- package/src/customTemplates/__tests__/library.test.ts +0 -96
- package/src/customTemplates/__tests__/normalizePositions.test.ts +0 -109
- package/src/customTemplates/__tests__/shapeDefs.test.ts +0 -49
- package/src/customTemplates/__tests__/useMemoryLayerAdapter.test.ts +0 -108
- package/src/customTemplates/designer.css +0 -732
- package/src/customTemplates/index.ts +0 -31
- package/src/customTemplates/library.ts +0 -110
- package/src/customTemplates/normalizePositions.ts +0 -75
- package/src/customTemplates/shapeDefs.ts +0 -131
- package/src/customTemplates/thumbnail.tsx +0 -63
- package/src/customTemplates/tokenDefs.ts +0 -60
- package/src/customTemplates/useDocCustomTemplates.ts +0 -52
- package/src/customTemplates/useMemoryLayerAdapter.ts +0 -129
- package/src/customThemes/CustomThemeContext.tsx +0 -185
- package/src/customThemes/CustomThemeDialog.tsx +0 -316
- package/src/customThemes/ImportThemeSection.tsx +0 -178
- package/src/customThemes/__tests__/CustomThemeContext.test.tsx +0 -64
- package/src/customThemes/__tests__/CustomThemeDialog.test.tsx +0 -47
- package/src/customThemes/__tests__/customThemeLibrary.test.ts +0 -60
- package/src/customThemes/__tests__/importThemeSection.test.tsx +0 -192
- package/src/customThemes/customThemeLibrary.ts +0 -100
- package/src/customThemes/index.ts +0 -37
- package/src/customThemes/themeControls.tsx +0 -229
- package/src/customThemes/themeDraft.ts +0 -288
- package/src/customThemes/useDocCustomThemes.ts +0 -49
- package/src/detectMarkdown.ts +0 -62
- package/src/diagram/DiagramCanvas.tsx +0 -260
- package/src/diagram/DiagramMaximizedOverlay.tsx +0 -46
- package/src/diagram/diagramCommands.ts +0 -604
- package/src/diagram/diagramConstants.ts +0 -17
- package/src/diagram/types.ts +0 -35
- package/src/editorScrollSync.ts +0 -73
- package/src/embeddedMedia.ts +0 -78
- package/src/emojiData.ts +0 -1317
- package/src/fileKind.ts +0 -158
- package/src/find/FindHighlightExtension.ts +0 -81
- package/src/find/FindToolbar.tsx +0 -314
- package/src/find/findModel.ts +0 -77
- package/src/frontmatter.ts +0 -29
- package/src/frontmatterSettings.ts +0 -23
- package/src/headingTransition.ts +0 -291
- package/src/hooks/useFileDrop.ts +0 -266
- package/src/imageEditor/CanvasSurface.tsx +0 -703
- package/src/imageEditor/ImageVersionHistoryDropdown.tsx +0 -396
- package/src/imageEditor/LayersPanel.tsx +0 -218
- package/src/imageEditor/PropertiesPanel.tsx +0 -474
- package/src/imageEditor/Toolbar.tsx +0 -459
- package/src/imageEditor/createShapeLayer.ts +0 -280
- package/src/imageEditor/icons.tsx +0 -68
- package/src/imageEditor/image-editor.css +0 -574
- package/src/imageEditor/layers/EditorImageLayer.tsx +0 -45
- package/src/imageEditor/layers/EditorShapeLayer.tsx +0 -62
- package/src/imageEditor/layers/EditorTextLayer.tsx +0 -45
- package/src/imageEditor/layers/SelectionHandles.tsx +0 -86
- package/src/imageEditor/state.ts +0 -173
- package/src/imageEditor/useImageEditor.ts +0 -385
- package/src/imageEditor/useImageEditorTokens.ts +0 -70
- package/src/index.ts +0 -559
- package/src/jsonEditor/EmbeddedRichTextField.tsx +0 -81
- package/src/jsonEditor/JsonEditor.tsx +0 -81
- package/src/jsonEditor/JsonEditorContext.tsx +0 -81
- package/src/jsonEditor/RenderNode.tsx +0 -87
- package/src/jsonEditor/editors.tsx +0 -745
- package/src/jsonEditor/index.ts +0 -2
- package/src/jsonEditor/json-editor.css +0 -463
- package/src/jsonEditor/useJsonEditorTokens.ts +0 -33
- package/src/markdownCodeFence.ts +0 -72
- package/src/mediaDragMime.ts +0 -32
- package/src/mediaEntries.ts +0 -12
- package/src/mediaReferences.ts +0 -301
- package/src/mermaid/MermaidDiagramCanvas.tsx +0 -693
- package/src/mermaid/MermaidDiagramExtension.ts +0 -243
- package/src/mermaid/MermaidDiagramTypeThumbnail.tsx +0 -184
- package/src/mermaid/MermaidDiagramWidget.tsx +0 -653
- package/src/mermaid/MermaidShapePalette.tsx +0 -245
- package/src/mermaid/__tests__/MermaidDiagramExtension.test.ts +0 -361
- package/src/mermaid/__tests__/mermaidDiagramTypes.test.ts +0 -35
- package/src/mermaid/__tests__/mermaidRenderer.test.ts +0 -49
- package/src/mermaid/__tests__/mermaidSourceOps.test.ts +0 -213
- package/src/mermaid/__tests__/mermaidSyntax.test.ts +0 -71
- package/src/mermaid/mermaidCommands.ts +0 -34
- package/src/mermaid/mermaidData.ts +0 -31
- package/src/mermaid/mermaidDiagramTypes.ts +0 -325
- package/src/mermaid/mermaidModel.ts +0 -31
- package/src/mermaid/mermaidRenderer.ts +0 -181
- package/src/mermaid/mermaidShapes.ts +0 -113
- package/src/mermaid/mermaidSourceOps.ts +0 -454
- package/src/monaco.ts +0 -35
- package/src/monacoWorkers.ts +0 -89
- package/src/outlineSource.ts +0 -171
- package/src/presentation/PresentationMode.tsx +0 -596
- package/src/rawEditorIsolation.ts +0 -18
- package/src/recorder/RecorderButton.tsx +0 -80
- package/src/recorder/RecorderModal.tsx +0 -706
- package/src/recorder/RecorderPanel.tsx +0 -77
- package/src/recorder/formats.ts +0 -159
- package/src/recorder/hooks/useMediaRecorder.ts +0 -436
- package/src/recorder/hooks/useStreamPreview.ts +0 -47
- package/src/recorder/insertMediaBlock.ts +0 -30
- package/src/recorder/sources/cameraStream.ts +0 -32
- package/src/recorder/sources/micStream.ts +0 -25
- package/src/recorder/sources/screenStream.ts +0 -162
- package/src/recorder/timingJson.ts +0 -66
- package/src/resolveBlockVisual.ts +0 -39
- package/src/scene/Scene.tsx +0 -647
- package/src/scene/SceneBlockExtension.ts +0 -205
- package/src/scene/SceneBlockToolbar.tsx +0 -216
- package/src/scene/SceneBlockWidget.tsx +0 -441
- package/src/scene/ScenePropsBar.tsx +0 -85
- package/src/scene/SceneSelection.tsx +0 -111
- package/src/scene/SceneSideToolbar.tsx +0 -89
- package/src/scene/SceneViewControls.tsx +0 -43
- package/src/scene/SceneViewport.tsx +0 -106
- package/src/scene/ShapePalette.tsx +0 -196
- package/src/scene/__tests__/DiagramAdapter.test.ts +0 -142
- package/src/scene/__tests__/SceneBlockExtension.test.ts +0 -33
- package/src/scene/__tests__/bezierEdit.test.ts +0 -85
- package/src/scene/__tests__/blockLayers.test.ts +0 -57
- package/src/scene/__tests__/fitScale.test.ts +0 -19
- package/src/scene/__tests__/sceneIsolation.test.tsx +0 -119
- package/src/scene/__tests__/shapeLayers.test.ts +0 -106
- package/src/scene/__tests__/useSceneHitTest.test.ts +0 -90
- package/src/scene/__tests__/useScenePanZoom.test.ts +0 -130
- package/src/scene/adapters/DiagramAdapter.ts +0 -79
- package/src/scene/adapters/DrawingAdapter.ts +0 -420
- package/src/scene/adapters/LayoutAdapter.ts +0 -313
- package/src/scene/adapters/blockLayers.ts +0 -159
- package/src/scene/commands/SceneCommand.ts +0 -84
- package/src/scene/commands/drawingCommands.ts +0 -318
- package/src/scene/commands/layoutCommands.ts +0 -301
- package/src/scene/fitScale.ts +0 -17
- package/src/scene/hooks/useSceneHitTest.ts +0 -105
- package/src/scene/hooks/useScenePanZoom.ts +0 -154
- package/src/scene/hooks/useSceneSelection.ts +0 -62
- package/src/scene/index.ts +0 -90
- package/src/scene/layers/DiagramEdges.tsx +0 -142
- package/src/scene/layers/edgeGeometry.ts +0 -104
- package/src/scene/layers/nodeCard.tsx +0 -164
- package/src/scene/layers/renderLayer.tsx +0 -70
- package/src/scene/layers/shapeLayers.ts +0 -201
- package/src/scene/paths/bezierEdit.ts +0 -208
- package/src/scene/scene.css +0 -874
- package/src/scene/text/SceneTextOverlay.tsx +0 -161
- package/src/scene/text/sceneTextChannel.ts +0 -46
- package/src/scene/text/sceneTextConfig.ts +0 -31
- package/src/scene/text/sceneTiptap.ts +0 -36
- package/src/scene/text/useSceneTextEditing.ts +0 -39
- package/src/scene/tools/ConnectTool.ts +0 -209
- package/src/scene/tools/DrawingConnectTool.ts +0 -231
- package/src/scene/tools/PathTool.ts +0 -158
- package/src/scene/tools/PlaceTool.ts +0 -47
- package/src/scene/tools/SceneTool.ts +0 -85
- package/src/scene/tools/SelectTool.ts +0 -300
- package/src/scene/tools/ShapeTool.ts +0 -143
- package/src/scene/tools/TextTool.ts +0 -72
- package/src/scene/tools/TokenTool.ts +0 -95
- package/src/scene/tools/createDrawShapeTool.ts +0 -82
- package/src/selectionConversions.ts +0 -155
- package/src/styles/ascii-diagram.css +0 -79
- package/src/styles/ascii-timeline.css +0 -596
- package/src/styles/code-context.css +0 -155
- package/src/styles/code-snippet.css +0 -76
- package/src/styles/diagram.css +0 -183
- package/src/styles/editor.css +0 -7131
- package/src/styles/folder-view.css +0 -210
- package/src/styles/image-edit-affordance.css +0 -201
- package/src/styles/index.css +0 -20
- package/src/styles/mermaid-diagram.css +0 -487
- package/src/styles/tree-view.css +0 -189
- package/src/teleprompter/TeleprompterControls.tsx +0 -218
- package/src/teleprompter/TeleprompterSelfView.tsx +0 -22
- package/src/teleprompter/TeleprompterSurface.tsx +0 -267
- package/src/teleprompter/TeleprompterView.tsx +0 -338
- package/src/teleprompter/canvasRenderer.ts +0 -161
- package/src/teleprompter/floatingWindow.ts +0 -352
- package/src/teleprompter/index.ts +0 -61
- package/src/teleprompter/pcmWorklet.ts +0 -62
- package/src/teleprompter/recording/insertPreamble.ts +0 -80
- package/src/teleprompter/recording/narrationSave.ts +0 -134
- package/src/teleprompter/recording/useNarrationRecorder.ts +0 -367
- package/src/teleprompter/scrollModel.ts +0 -85
- package/src/teleprompter/teleprompterTheme.ts +0 -303
- package/src/teleprompter/types.ts +0 -38
- package/src/teleprompter/useFloatingWindow.ts +0 -74
- package/src/teleprompter/useMicAnalysis.ts +0 -211
- package/src/teleprompter/useTeleprompter.ts +0 -421
- package/src/templateContentPreviewResolver.ts +0 -360
- package/src/timeline/TimelineEditorWidget.tsx +0 -861
- package/src/timeline/TimelineViewExtension.ts +0 -252
- package/src/timeline/__tests__/TimelineEditorWidget.test.tsx +0 -414
- package/src/timeline/__tests__/TimelineViewExtension.test.ts +0 -163
- package/src/timeline/__tests__/timelineCommands.test.ts +0 -359
- package/src/timeline/__tests__/timelineOps.test.ts +0 -277
- package/src/timeline/__tests__/timelinePaste.test.ts +0 -34
- package/src/timeline/timelineCommands.ts +0 -421
- package/src/timeline/timelineData.ts +0 -54
- package/src/timeline/timelineOps.ts +0 -381
- package/src/timeline/timelinePaste.ts +0 -8
- package/src/timelineSource.ts +0 -244
- package/src/tiptap/TiptapAudio.tsx +0 -86
- package/src/tiptap/TiptapVideo.tsx +0 -119
- package/src/tiptap/useResolvedMediaSrc.ts +0 -47
- package/src/tiptapBridge.ts +0 -986
- package/src/tooltipPlacement.ts +0 -13
- package/src/transformStyleId.ts +0 -17
- package/src/transitionCatalog.ts +0 -159
- package/src/treeview/TreeOutlineWidget.tsx +0 -390
- package/src/treeview/TreeViewExtension.ts +0 -250
- package/src/treeview/__tests__/TreeOutlineWidget.test.tsx +0 -156
- package/src/treeview/__tests__/TreeViewExtension.test.ts +0 -122
- package/src/treeview/__tests__/treeOps.test.ts +0 -177
- package/src/treeview/__tests__/treePaste.test.ts +0 -40
- package/src/treeview/__tests__/treeViewCommands.test.ts +0 -179
- package/src/treeview/treeOps.ts +0 -231
- package/src/treeview/treePaste.ts +0 -13
- package/src/treeview/treeViewCommands.ts +0 -99
- package/src/treeview/treeViewData.ts +0 -41
- package/src/types/monaco-shims.d.ts +0 -10
- package/src/useBlockNavigator.ts +0 -153
- package/src/useHeadingLayout.ts +0 -294
- package/src/useMonacoLoader.ts +0 -82
- package/src/useTimelineClock.ts +0 -76
- package/src/utils/collectInlineFontAwesomeCss.ts +0 -69
- package/src/utils/dropUtils.ts +0 -136
- package/src/utils/normalizeMalformedAssetUrl.ts +0 -22
- package/src/writeCanvasSettings.ts +0 -30
- package/src/wysiwygImageUpload.ts +0 -113
|
@@ -1,745 +0,0 @@
|
|
|
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
|
-
appendPointer,
|
|
12
|
-
arrayItemKind,
|
|
13
|
-
type ControlKind,
|
|
14
|
-
type SquisqAnnotatedSchema,
|
|
15
|
-
} from '@bendyline/squisq/jsonForm';
|
|
16
|
-
import { useJsonEditor } from './JsonEditorContext';
|
|
17
|
-
import { RenderNode } from './RenderNode';
|
|
18
|
-
import { EmbeddedRichTextField } from './EmbeddedRichTextField';
|
|
19
|
-
|
|
20
|
-
export interface EditorProps {
|
|
21
|
-
value: unknown;
|
|
22
|
-
schema: SquisqAnnotatedSchema;
|
|
23
|
-
pointer: string;
|
|
24
|
-
disabled: boolean;
|
|
25
|
-
controlId?: string;
|
|
26
|
-
labelledBy?: string;
|
|
27
|
-
describedBy?: string;
|
|
28
|
-
invalid?: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function accessibilityProps(props: EditorProps) {
|
|
32
|
-
return {
|
|
33
|
-
id: props.controlId,
|
|
34
|
-
'aria-labelledby': props.labelledBy,
|
|
35
|
-
'aria-describedby': props.describedBy,
|
|
36
|
-
'aria-invalid': props.invalid || undefined,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// ── Helpers ───────────────────────────────────────────────────────
|
|
41
|
-
|
|
42
|
-
function asString(v: unknown): string {
|
|
43
|
-
if (v === undefined || v === null) return '';
|
|
44
|
-
return String(v);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function asNumber(v: unknown): number | '' {
|
|
48
|
-
if (v === undefined || v === null || v === '') return '';
|
|
49
|
-
const n = Number(v);
|
|
50
|
-
return Number.isFinite(n) ? n : '';
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// ── Primitive editors ────────────────────────────────────────────
|
|
54
|
-
|
|
55
|
-
export function TextEditor(props: EditorProps) {
|
|
56
|
-
const { value, schema, pointer, disabled } = props;
|
|
57
|
-
const { setAtPath } = useJsonEditor();
|
|
58
|
-
return (
|
|
59
|
-
<input
|
|
60
|
-
{...accessibilityProps(props)}
|
|
61
|
-
type="text"
|
|
62
|
-
className="squisq-jf-input"
|
|
63
|
-
value={asString(value)}
|
|
64
|
-
placeholder={schema.squisq?.placeholder}
|
|
65
|
-
disabled={disabled}
|
|
66
|
-
onChange={(e) => setAtPath(pointer, e.target.value)}
|
|
67
|
-
/>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function MultilineEditor(props: EditorProps) {
|
|
72
|
-
const { value, schema, pointer, disabled } = props;
|
|
73
|
-
const { setAtPath } = useJsonEditor();
|
|
74
|
-
const ref = useRef<HTMLTextAreaElement>(null);
|
|
75
|
-
// Auto-grow vertically.
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
const ta = ref.current;
|
|
78
|
-
if (!ta) return;
|
|
79
|
-
ta.style.height = 'auto';
|
|
80
|
-
ta.style.height = `${ta.scrollHeight + 2}px`;
|
|
81
|
-
}, [value]);
|
|
82
|
-
return (
|
|
83
|
-
<textarea
|
|
84
|
-
{...accessibilityProps(props)}
|
|
85
|
-
ref={ref}
|
|
86
|
-
className="squisq-jf-textarea"
|
|
87
|
-
value={asString(value)}
|
|
88
|
-
placeholder={schema.squisq?.placeholder}
|
|
89
|
-
disabled={disabled}
|
|
90
|
-
onChange={(e) => setAtPath(pointer, e.target.value)}
|
|
91
|
-
/>
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function RichTextEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
96
|
-
const { setAtPath } = useJsonEditor();
|
|
97
|
-
return (
|
|
98
|
-
<EmbeddedRichTextField
|
|
99
|
-
value={asString(value)}
|
|
100
|
-
placeholder={schema.squisq?.placeholder}
|
|
101
|
-
readOnly={disabled}
|
|
102
|
-
onChange={(md) => setAtPath(pointer, md)}
|
|
103
|
-
/>
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function NumberStepperEditor(props: EditorProps) {
|
|
108
|
-
const { value, schema, pointer, disabled } = props;
|
|
109
|
-
const { setAtPath } = useJsonEditor();
|
|
110
|
-
const isInt = schema.type === 'integer';
|
|
111
|
-
const step = schema.squisq?.step ?? schema.multipleOf ?? (isInt ? 1 : 0.1);
|
|
112
|
-
const num = asNumber(value);
|
|
113
|
-
const update = (next: number) => {
|
|
114
|
-
const min = schema.minimum ?? schema.exclusiveMinimum;
|
|
115
|
-
const max = schema.maximum ?? schema.exclusiveMaximum;
|
|
116
|
-
let clamped = next;
|
|
117
|
-
if (typeof min === 'number') clamped = Math.max(min, clamped);
|
|
118
|
-
if (typeof max === 'number') clamped = Math.min(max, clamped);
|
|
119
|
-
setAtPath(pointer, isInt ? Math.round(clamped) : clamped);
|
|
120
|
-
};
|
|
121
|
-
return (
|
|
122
|
-
<span className="squisq-jf-stepper">
|
|
123
|
-
<button
|
|
124
|
-
type="button"
|
|
125
|
-
className="squisq-jf-stepper__btn"
|
|
126
|
-
disabled={disabled}
|
|
127
|
-
onClick={() => update((typeof num === 'number' ? num : 0) - step)}
|
|
128
|
-
aria-label="Decrease"
|
|
129
|
-
>
|
|
130
|
-
−
|
|
131
|
-
</button>
|
|
132
|
-
<input
|
|
133
|
-
{...accessibilityProps(props)}
|
|
134
|
-
className="squisq-jf-stepper__input"
|
|
135
|
-
type="number"
|
|
136
|
-
value={num === '' ? '' : num}
|
|
137
|
-
step={step}
|
|
138
|
-
disabled={disabled}
|
|
139
|
-
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
|
140
|
-
if (e.target.value === '') {
|
|
141
|
-
setAtPath(pointer, undefined);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
const n = Number(e.target.value);
|
|
145
|
-
if (Number.isFinite(n)) update(n);
|
|
146
|
-
}}
|
|
147
|
-
/>
|
|
148
|
-
<button
|
|
149
|
-
type="button"
|
|
150
|
-
className="squisq-jf-stepper__btn"
|
|
151
|
-
disabled={disabled}
|
|
152
|
-
onClick={() => update((typeof num === 'number' ? num : 0) + step)}
|
|
153
|
-
aria-label="Increase"
|
|
154
|
-
>
|
|
155
|
-
+
|
|
156
|
-
</button>
|
|
157
|
-
</span>
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export function SliderEditor(props: EditorProps) {
|
|
162
|
-
const { value, schema, pointer, disabled } = props;
|
|
163
|
-
const { setAtPath } = useJsonEditor();
|
|
164
|
-
const min = (schema.minimum ?? schema.exclusiveMinimum ?? 0) as number;
|
|
165
|
-
const max = (schema.maximum ?? schema.exclusiveMaximum ?? 100) as number;
|
|
166
|
-
const step = schema.squisq?.step ?? schema.multipleOf ?? (schema.type === 'integer' ? 1 : 1);
|
|
167
|
-
const num = asNumber(value);
|
|
168
|
-
const display = typeof num === 'number' ? num : min;
|
|
169
|
-
return (
|
|
170
|
-
<span className="squisq-jf-slider-row">
|
|
171
|
-
<input
|
|
172
|
-
{...accessibilityProps(props)}
|
|
173
|
-
type="range"
|
|
174
|
-
className="squisq-jf-slider"
|
|
175
|
-
min={min}
|
|
176
|
-
max={max}
|
|
177
|
-
step={step}
|
|
178
|
-
value={display}
|
|
179
|
-
disabled={disabled}
|
|
180
|
-
onChange={(e) => setAtPath(pointer, Number(e.target.value))}
|
|
181
|
-
/>
|
|
182
|
-
<span className="squisq-jf-slider-readout">{display}</span>
|
|
183
|
-
</span>
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export function ToggleEditor(props: EditorProps) {
|
|
188
|
-
const { value, schema, pointer, disabled } = props;
|
|
189
|
-
const { setAtPath } = useJsonEditor();
|
|
190
|
-
const on = Boolean(value);
|
|
191
|
-
return (
|
|
192
|
-
<button
|
|
193
|
-
{...accessibilityProps(props)}
|
|
194
|
-
type="button"
|
|
195
|
-
className={`squisq-jf-toggle${on ? ' squisq-jf-toggle--on' : ''}`}
|
|
196
|
-
disabled={disabled}
|
|
197
|
-
onClick={() => setAtPath(pointer, !on)}
|
|
198
|
-
aria-pressed={on}
|
|
199
|
-
>
|
|
200
|
-
<span className="squisq-jf-toggle__track">
|
|
201
|
-
<span className="squisq-jf-toggle__thumb" />
|
|
202
|
-
</span>
|
|
203
|
-
<span className="squisq-jf-toggle__label">
|
|
204
|
-
{on
|
|
205
|
-
? schema.squisq?.label
|
|
206
|
-
? `${schema.squisq.label}: On`
|
|
207
|
-
: 'On'
|
|
208
|
-
: schema.squisq?.label
|
|
209
|
-
? `${schema.squisq.label}: Off`
|
|
210
|
-
: 'Off'}
|
|
211
|
-
</span>
|
|
212
|
-
</button>
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export function CheckboxEditor(props: EditorProps) {
|
|
217
|
-
const { value, schema, pointer, disabled } = props;
|
|
218
|
-
const { setAtPath } = useJsonEditor();
|
|
219
|
-
const generatedId = useId();
|
|
220
|
-
const id = props.controlId ?? generatedId;
|
|
221
|
-
return (
|
|
222
|
-
<label htmlFor={id} className="squisq-jf-toggle">
|
|
223
|
-
<input
|
|
224
|
-
aria-labelledby={props.labelledBy}
|
|
225
|
-
aria-describedby={props.describedBy}
|
|
226
|
-
aria-invalid={props.invalid || undefined}
|
|
227
|
-
id={id}
|
|
228
|
-
type="checkbox"
|
|
229
|
-
checked={Boolean(value)}
|
|
230
|
-
disabled={disabled}
|
|
231
|
-
onChange={(e) => setAtPath(pointer, e.target.checked)}
|
|
232
|
-
/>
|
|
233
|
-
{schema.squisq?.label ?? schema.title ?? ''}
|
|
234
|
-
</label>
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function enumOptions(schema: SquisqAnnotatedSchema): { value: unknown; label: string }[] {
|
|
239
|
-
const labels = schema.squisq?.enumLabels;
|
|
240
|
-
return (schema.enum ?? []).map((v) => ({
|
|
241
|
-
value: v,
|
|
242
|
-
label: labels && typeof v === 'string' ? (labels[v] ?? String(v)) : String(v),
|
|
243
|
-
}));
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
export function SegmentedEditor(props: EditorProps) {
|
|
247
|
-
const { value, schema, pointer, disabled } = props;
|
|
248
|
-
const { setAtPath } = useJsonEditor();
|
|
249
|
-
const options = enumOptions(schema);
|
|
250
|
-
return (
|
|
251
|
-
<span {...accessibilityProps(props)} className="squisq-jf-segmented" role="group">
|
|
252
|
-
{options.map((opt, i) => {
|
|
253
|
-
const active = value === opt.value;
|
|
254
|
-
return (
|
|
255
|
-
<button
|
|
256
|
-
key={i}
|
|
257
|
-
type="button"
|
|
258
|
-
className={`squisq-jf-segmented__btn${active ? ' squisq-jf-segmented__btn--active' : ''}`}
|
|
259
|
-
disabled={disabled}
|
|
260
|
-
onClick={() => setAtPath(pointer, opt.value)}
|
|
261
|
-
aria-pressed={active}
|
|
262
|
-
>
|
|
263
|
-
{opt.label}
|
|
264
|
-
</button>
|
|
265
|
-
);
|
|
266
|
-
})}
|
|
267
|
-
</span>
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export function RadioEditor(props: EditorProps) {
|
|
272
|
-
const { value, schema, pointer, disabled } = props;
|
|
273
|
-
const { setAtPath } = useJsonEditor();
|
|
274
|
-
const options = enumOptions(schema);
|
|
275
|
-
const name = useId();
|
|
276
|
-
return (
|
|
277
|
-
<div {...accessibilityProps(props)} className="squisq-jf-radio" role="radiogroup">
|
|
278
|
-
{options.map((opt, i) => {
|
|
279
|
-
const active = value === opt.value;
|
|
280
|
-
return (
|
|
281
|
-
<label key={i} className="squisq-jf-radio__option">
|
|
282
|
-
<input
|
|
283
|
-
type="radio"
|
|
284
|
-
name={name}
|
|
285
|
-
checked={active}
|
|
286
|
-
disabled={disabled}
|
|
287
|
-
onChange={() => setAtPath(pointer, opt.value)}
|
|
288
|
-
/>
|
|
289
|
-
{opt.label}
|
|
290
|
-
</label>
|
|
291
|
-
);
|
|
292
|
-
})}
|
|
293
|
-
</div>
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export function ComboboxEditor(props: EditorProps) {
|
|
298
|
-
const { value, schema, pointer, disabled } = props;
|
|
299
|
-
const { setAtPath } = useJsonEditor();
|
|
300
|
-
const options = enumOptions(schema);
|
|
301
|
-
return (
|
|
302
|
-
<select
|
|
303
|
-
{...accessibilityProps(props)}
|
|
304
|
-
className="squisq-jf-select"
|
|
305
|
-
value={asString(value)}
|
|
306
|
-
disabled={disabled}
|
|
307
|
-
onChange={(e) => {
|
|
308
|
-
const raw = e.target.value;
|
|
309
|
-
const matched = options.find((opt) => String(opt.value) === raw);
|
|
310
|
-
setAtPath(pointer, matched ? matched.value : raw);
|
|
311
|
-
}}
|
|
312
|
-
>
|
|
313
|
-
{options.map((opt, i) => (
|
|
314
|
-
<option key={i} value={String(opt.value)}>
|
|
315
|
-
{opt.label}
|
|
316
|
-
</option>
|
|
317
|
-
))}
|
|
318
|
-
</select>
|
|
319
|
-
);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export function ColorEditor(props: EditorProps) {
|
|
323
|
-
const { value, pointer, disabled } = props;
|
|
324
|
-
const { setAtPath } = useJsonEditor();
|
|
325
|
-
const hex = typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value) ? value : '#000000';
|
|
326
|
-
return (
|
|
327
|
-
<span className="squisq-jf-color">
|
|
328
|
-
<input
|
|
329
|
-
{...accessibilityProps(props)}
|
|
330
|
-
type="color"
|
|
331
|
-
className="squisq-jf-color__input"
|
|
332
|
-
value={hex}
|
|
333
|
-
disabled={disabled}
|
|
334
|
-
onChange={(e) => setAtPath(pointer, e.target.value)}
|
|
335
|
-
/>
|
|
336
|
-
<input
|
|
337
|
-
type="text"
|
|
338
|
-
className="squisq-jf-input squisq-jf-color__hex"
|
|
339
|
-
value={asString(value)}
|
|
340
|
-
disabled={disabled}
|
|
341
|
-
onChange={(e) => setAtPath(pointer, e.target.value)}
|
|
342
|
-
/>
|
|
343
|
-
</span>
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
export function DateEditor(props: EditorProps) {
|
|
348
|
-
const { value, schema, pointer, disabled } = props;
|
|
349
|
-
const { setAtPath } = useJsonEditor();
|
|
350
|
-
const fmt = schema.format;
|
|
351
|
-
const inputType = fmt === 'time' ? 'time' : fmt === 'date' ? 'date' : 'datetime-local';
|
|
352
|
-
// datetime-local needs YYYY-MM-DDTHH:mm; if the value is an ISO string we
|
|
353
|
-
// strip the trailing Z + seconds for the input, then write back the full
|
|
354
|
-
// value the user picked.
|
|
355
|
-
const display =
|
|
356
|
-
inputType === 'datetime-local' && typeof value === 'string' && value.includes('T')
|
|
357
|
-
? value.replace(/Z$|:\d{2}\.\d+Z?$/, '').slice(0, 16)
|
|
358
|
-
: asString(value);
|
|
359
|
-
return (
|
|
360
|
-
<input
|
|
361
|
-
{...accessibilityProps(props)}
|
|
362
|
-
type={inputType}
|
|
363
|
-
className="squisq-jf-input"
|
|
364
|
-
value={display}
|
|
365
|
-
disabled={disabled}
|
|
366
|
-
onChange={(e) => setAtPath(pointer, e.target.value)}
|
|
367
|
-
/>
|
|
368
|
-
);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// ── Composite editors ────────────────────────────────────────────
|
|
372
|
-
|
|
373
|
-
export function GroupEditor(props: EditorProps & { suppressTitle?: boolean }) {
|
|
374
|
-
const { value, schema, pointer, disabled, suppressTitle } = props;
|
|
375
|
-
const title = !suppressTitle ? (schema.squisq?.label ?? schema.title) : undefined;
|
|
376
|
-
const help = schema.squisq?.help ?? schema.description;
|
|
377
|
-
const obj = (value && typeof value === 'object' ? (value as Record<string, unknown>) : {}) ?? {};
|
|
378
|
-
const propEntries = Object.entries(schema.properties ?? {});
|
|
379
|
-
|
|
380
|
-
return (
|
|
381
|
-
<section className="squisq-jf-group">
|
|
382
|
-
{title ? <h3 className="squisq-jf-group__title">{title}</h3> : null}
|
|
383
|
-
{help ? <p className="squisq-jf-group__help">{help}</p> : null}
|
|
384
|
-
{propEntries.map(([key, propSchema]) => (
|
|
385
|
-
<RenderNode
|
|
386
|
-
key={key}
|
|
387
|
-
value={obj[key]}
|
|
388
|
-
schema={propSchema}
|
|
389
|
-
pointer={appendPointer(pointer, key)}
|
|
390
|
-
parentDisabled={disabled}
|
|
391
|
-
/>
|
|
392
|
-
))}
|
|
393
|
-
</section>
|
|
394
|
-
);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
export function ChipBinEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
398
|
-
const { setAtPath } = useJsonEditor();
|
|
399
|
-
const items: unknown[] = Array.isArray(value) ? value : [];
|
|
400
|
-
const itemSchema = (Array.isArray(schema.items) ? schema.items[0] : schema.items) ?? {
|
|
401
|
-
type: 'string',
|
|
402
|
-
};
|
|
403
|
-
const labels = itemSchema.squisq?.enumLabels;
|
|
404
|
-
const enumOpts = itemSchema.enum;
|
|
405
|
-
const [draft, setDraft] = useState('');
|
|
406
|
-
|
|
407
|
-
const remove = (index: number) => {
|
|
408
|
-
const next = items.slice();
|
|
409
|
-
next.splice(index, 1);
|
|
410
|
-
setAtPath(pointer, next);
|
|
411
|
-
};
|
|
412
|
-
const add = (raw: string) => {
|
|
413
|
-
if (raw === '') return;
|
|
414
|
-
const coerced = coerceToSchema(raw, itemSchema);
|
|
415
|
-
setAtPath(pointer, [...items, coerced]);
|
|
416
|
-
setDraft('');
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
return (
|
|
420
|
-
<div className="squisq-jf-chip-bin">
|
|
421
|
-
{items.map((item, i) => {
|
|
422
|
-
const display =
|
|
423
|
-
labels && typeof item === 'string' ? (labels[item] ?? String(item)) : String(item);
|
|
424
|
-
return (
|
|
425
|
-
<span key={i} className="squisq-jf-chip">
|
|
426
|
-
{display}
|
|
427
|
-
<button
|
|
428
|
-
type="button"
|
|
429
|
-
className="squisq-jf-chip__remove"
|
|
430
|
-
disabled={disabled}
|
|
431
|
-
onClick={() => remove(i)}
|
|
432
|
-
aria-label={`Remove ${display}`}
|
|
433
|
-
>
|
|
434
|
-
×
|
|
435
|
-
</button>
|
|
436
|
-
</span>
|
|
437
|
-
);
|
|
438
|
-
})}
|
|
439
|
-
{!disabled && enumOpts && enumOpts.length > 0 ? (
|
|
440
|
-
<select
|
|
441
|
-
className="squisq-jf-select"
|
|
442
|
-
value=""
|
|
443
|
-
onChange={(e) => add(e.target.value)}
|
|
444
|
-
style={{ width: 'auto' }}
|
|
445
|
-
>
|
|
446
|
-
<option value="" disabled>
|
|
447
|
-
{schema.squisq?.addLabel ?? '+ Add'}
|
|
448
|
-
</option>
|
|
449
|
-
{enumOpts
|
|
450
|
-
.filter((v: unknown) => !items.includes(v))
|
|
451
|
-
.map((v: unknown, i: number) => (
|
|
452
|
-
<option key={i} value={String(v)}>
|
|
453
|
-
{labels && typeof v === 'string' ? (labels[v] ?? String(v)) : String(v)}
|
|
454
|
-
</option>
|
|
455
|
-
))}
|
|
456
|
-
</select>
|
|
457
|
-
) : !disabled ? (
|
|
458
|
-
<input
|
|
459
|
-
type="text"
|
|
460
|
-
className="squisq-jf-chip-bin__add-input"
|
|
461
|
-
placeholder={schema.squisq?.addLabel ?? '+ Add'}
|
|
462
|
-
value={draft}
|
|
463
|
-
onChange={(e) => setDraft(e.target.value)}
|
|
464
|
-
onKeyDown={(e) => {
|
|
465
|
-
if (e.key === 'Enter' || e.key === ',') {
|
|
466
|
-
e.preventDefault();
|
|
467
|
-
add(draft.trim());
|
|
468
|
-
}
|
|
469
|
-
}}
|
|
470
|
-
onBlur={() => add(draft.trim())}
|
|
471
|
-
/>
|
|
472
|
-
) : null}
|
|
473
|
-
</div>
|
|
474
|
-
);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
function coerceToSchema(raw: string, schema: SquisqAnnotatedSchema): unknown {
|
|
478
|
-
switch (schema.type) {
|
|
479
|
-
case 'integer':
|
|
480
|
-
return parseInt(raw, 10);
|
|
481
|
-
case 'number':
|
|
482
|
-
return Number(raw);
|
|
483
|
-
case 'boolean':
|
|
484
|
-
return raw === 'true' || raw === '1';
|
|
485
|
-
default:
|
|
486
|
-
return raw;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
export function CardStackEditor({ value, schema, pointer, disabled }: EditorProps) {
|
|
491
|
-
const { setAtPath } = useJsonEditor();
|
|
492
|
-
const items: unknown[] = Array.isArray(value) ? value : [];
|
|
493
|
-
const itemSchema = (Array.isArray(schema.items) ? schema.items[0] : schema.items) ?? {
|
|
494
|
-
type: 'object',
|
|
495
|
-
};
|
|
496
|
-
const itemLabel = itemSchema.squisq?.itemLabel;
|
|
497
|
-
const addLabel = schema.squisq?.addLabel ?? '+ Add';
|
|
498
|
-
|
|
499
|
-
const updateItems = (next: unknown[]) => setAtPath(pointer, next);
|
|
500
|
-
const addItem = () => updateItems([...items, defaultForSchema(itemSchema)]);
|
|
501
|
-
const removeItem = (i: number) => {
|
|
502
|
-
const next = items.slice();
|
|
503
|
-
next.splice(i, 1);
|
|
504
|
-
updateItems(next);
|
|
505
|
-
};
|
|
506
|
-
const moveItem = (i: number, delta: number) => {
|
|
507
|
-
const j = i + delta;
|
|
508
|
-
if (j < 0 || j >= items.length) return;
|
|
509
|
-
const next = items.slice();
|
|
510
|
-
[next[i], next[j]] = [next[j], next[i]];
|
|
511
|
-
updateItems(next);
|
|
512
|
-
};
|
|
513
|
-
|
|
514
|
-
return (
|
|
515
|
-
<div>
|
|
516
|
-
<div className="squisq-jf-card-stack">
|
|
517
|
-
{items.map((item, i) => {
|
|
518
|
-
const title = resolveItemTitle(itemLabel, item, i);
|
|
519
|
-
return (
|
|
520
|
-
<div key={i} className="squisq-jf-card">
|
|
521
|
-
<div className="squisq-jf-card__header">
|
|
522
|
-
<h4 className="squisq-jf-card__title">{title}</h4>
|
|
523
|
-
{!disabled ? (
|
|
524
|
-
<span className="squisq-jf-card__actions">
|
|
525
|
-
<button
|
|
526
|
-
type="button"
|
|
527
|
-
className="squisq-jf-icon-btn"
|
|
528
|
-
onClick={() => moveItem(i, -1)}
|
|
529
|
-
disabled={i === 0}
|
|
530
|
-
aria-label="Move up"
|
|
531
|
-
title="Move up"
|
|
532
|
-
>
|
|
533
|
-
↑
|
|
534
|
-
</button>
|
|
535
|
-
<button
|
|
536
|
-
type="button"
|
|
537
|
-
className="squisq-jf-icon-btn"
|
|
538
|
-
onClick={() => moveItem(i, +1)}
|
|
539
|
-
disabled={i === items.length - 1}
|
|
540
|
-
aria-label="Move down"
|
|
541
|
-
title="Move down"
|
|
542
|
-
>
|
|
543
|
-
↓
|
|
544
|
-
</button>
|
|
545
|
-
<button
|
|
546
|
-
type="button"
|
|
547
|
-
className="squisq-jf-icon-btn squisq-jf-icon-btn--danger"
|
|
548
|
-
onClick={() => removeItem(i)}
|
|
549
|
-
aria-label={schema.squisq?.removeLabel ?? 'Remove'}
|
|
550
|
-
title={schema.squisq?.removeLabel ?? 'Remove'}
|
|
551
|
-
>
|
|
552
|
-
×
|
|
553
|
-
</button>
|
|
554
|
-
</span>
|
|
555
|
-
) : null}
|
|
556
|
-
</div>
|
|
557
|
-
<RenderNode
|
|
558
|
-
value={item}
|
|
559
|
-
schema={itemSchema}
|
|
560
|
-
pointer={`${pointer}/${i}`}
|
|
561
|
-
parentDisabled={disabled}
|
|
562
|
-
suppressTopGroupTitle
|
|
563
|
-
/>
|
|
564
|
-
</div>
|
|
565
|
-
);
|
|
566
|
-
})}
|
|
567
|
-
</div>
|
|
568
|
-
{!disabled ? (
|
|
569
|
-
<button
|
|
570
|
-
type="button"
|
|
571
|
-
className="squisq-jf-add-btn"
|
|
572
|
-
onClick={addItem}
|
|
573
|
-
style={{ marginTop: 8 }}
|
|
574
|
-
>
|
|
575
|
-
{addLabel}
|
|
576
|
-
</button>
|
|
577
|
-
) : null}
|
|
578
|
-
</div>
|
|
579
|
-
);
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
function resolveItemTitle(
|
|
583
|
-
spec: string | { fromField: string } | undefined,
|
|
584
|
-
item: unknown,
|
|
585
|
-
index: number,
|
|
586
|
-
): string {
|
|
587
|
-
if (!spec) return `Item ${index + 1}`;
|
|
588
|
-
if (typeof spec === 'string') return spec;
|
|
589
|
-
if (item && typeof item === 'object') {
|
|
590
|
-
const v = (item as Record<string, unknown>)[spec.fromField];
|
|
591
|
-
if (typeof v === 'string' && v !== '') return v;
|
|
592
|
-
if (typeof v === 'number') return String(v);
|
|
593
|
-
}
|
|
594
|
-
return `Item ${index + 1}`;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
function defaultForSchema(schema: SquisqAnnotatedSchema): unknown {
|
|
598
|
-
if (schema.default !== undefined) return schema.default;
|
|
599
|
-
const t = Array.isArray(schema.type) ? schema.type.find((x) => x !== 'null') : schema.type;
|
|
600
|
-
switch (t) {
|
|
601
|
-
case 'object': {
|
|
602
|
-
const out: Record<string, unknown> = {};
|
|
603
|
-
for (const [k, v] of Object.entries(schema.properties ?? {})) {
|
|
604
|
-
out[k] = defaultForSchema(v);
|
|
605
|
-
}
|
|
606
|
-
return out;
|
|
607
|
-
}
|
|
608
|
-
case 'array':
|
|
609
|
-
return [];
|
|
610
|
-
case 'string':
|
|
611
|
-
return '';
|
|
612
|
-
case 'number':
|
|
613
|
-
case 'integer':
|
|
614
|
-
return (schema.minimum ?? 0) as number;
|
|
615
|
-
case 'boolean':
|
|
616
|
-
return false;
|
|
617
|
-
default:
|
|
618
|
-
return undefined;
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
export function TabsEditor(props: EditorProps) {
|
|
623
|
-
const { value, schema, pointer, disabled } = props;
|
|
624
|
-
const tabsId = useId().replace(/:/g, '');
|
|
625
|
-
const branches = (schema.oneOf ?? schema.anyOf ?? []) as readonly SquisqAnnotatedSchema[];
|
|
626
|
-
const initial = pickMatchingBranch(branches, value);
|
|
627
|
-
const [active, setActive] = useState(initial);
|
|
628
|
-
// Sync if value changes externally to a different branch shape.
|
|
629
|
-
useEffect(() => {
|
|
630
|
-
setActive(pickMatchingBranch(branches, value));
|
|
631
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
632
|
-
}, [value]);
|
|
633
|
-
|
|
634
|
-
const branch = branches[active];
|
|
635
|
-
if (!branch) return null;
|
|
636
|
-
const activateTab = (index: number) => {
|
|
637
|
-
const next = (index + branches.length) % branches.length;
|
|
638
|
-
setActive(next);
|
|
639
|
-
requestAnimationFrame(() => document.getElementById(`${tabsId}-tab-${next}`)?.focus());
|
|
640
|
-
};
|
|
641
|
-
return (
|
|
642
|
-
<div {...accessibilityProps(props)}>
|
|
643
|
-
<div className="squisq-jf-tabs__strip" role="tablist">
|
|
644
|
-
{branches.map((b, i) => (
|
|
645
|
-
<button
|
|
646
|
-
key={i}
|
|
647
|
-
type="button"
|
|
648
|
-
className={`squisq-jf-tabs__tab${i === active ? ' squisq-jf-tabs__tab--active' : ''}`}
|
|
649
|
-
disabled={disabled}
|
|
650
|
-
onClick={() => setActive(i)}
|
|
651
|
-
onKeyDown={(event) => {
|
|
652
|
-
if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {
|
|
653
|
-
event.preventDefault();
|
|
654
|
-
activateTab(i + 1);
|
|
655
|
-
} else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {
|
|
656
|
-
event.preventDefault();
|
|
657
|
-
activateTab(i - 1);
|
|
658
|
-
} else if (event.key === 'Home') {
|
|
659
|
-
event.preventDefault();
|
|
660
|
-
activateTab(0);
|
|
661
|
-
} else if (event.key === 'End') {
|
|
662
|
-
event.preventDefault();
|
|
663
|
-
activateTab(branches.length - 1);
|
|
664
|
-
}
|
|
665
|
-
}}
|
|
666
|
-
role="tab"
|
|
667
|
-
id={`${tabsId}-tab-${i}`}
|
|
668
|
-
aria-selected={i === active}
|
|
669
|
-
aria-controls={`${tabsId}-panel`}
|
|
670
|
-
tabIndex={i === active ? 0 : -1}
|
|
671
|
-
>
|
|
672
|
-
{b.squisq?.label ?? b.title ?? `Option ${i + 1}`}
|
|
673
|
-
</button>
|
|
674
|
-
))}
|
|
675
|
-
</div>
|
|
676
|
-
<div id={`${tabsId}-panel`} role="tabpanel" aria-labelledby={`${tabsId}-tab-${active}`}>
|
|
677
|
-
<RenderNode value={value} schema={branch} pointer={pointer} parentDisabled={disabled} />
|
|
678
|
-
</div>
|
|
679
|
-
</div>
|
|
680
|
-
);
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
function pickMatchingBranch(branches: readonly SquisqAnnotatedSchema[], value: unknown): number {
|
|
684
|
-
for (let i = 0; i < branches.length; i++) {
|
|
685
|
-
if (matchesShape(branches[i], value)) return i;
|
|
686
|
-
}
|
|
687
|
-
return 0;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
function matchesShape(schema: SquisqAnnotatedSchema, value: unknown): boolean {
|
|
691
|
-
const t = schema.type;
|
|
692
|
-
const target = Array.isArray(t) ? t.find((x) => x !== 'null') : t;
|
|
693
|
-
if (!target) return true;
|
|
694
|
-
switch (target) {
|
|
695
|
-
case 'string':
|
|
696
|
-
return typeof value === 'string';
|
|
697
|
-
case 'number':
|
|
698
|
-
case 'integer':
|
|
699
|
-
return typeof value === 'number';
|
|
700
|
-
case 'boolean':
|
|
701
|
-
return typeof value === 'boolean';
|
|
702
|
-
case 'null':
|
|
703
|
-
return value === null;
|
|
704
|
-
case 'array':
|
|
705
|
-
return Array.isArray(value);
|
|
706
|
-
case 'object':
|
|
707
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
708
|
-
default:
|
|
709
|
-
return false;
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
// ── Registry ──────────────────────────────────────────────────────
|
|
714
|
-
|
|
715
|
-
// eslint-disable-next-line react-refresh/only-export-components
|
|
716
|
-
export const EDITORS: Record<ControlKind, React.ComponentType<EditorProps>> = {
|
|
717
|
-
text: TextEditor,
|
|
718
|
-
multiline: MultilineEditor,
|
|
719
|
-
richtext: RichTextEditor,
|
|
720
|
-
color: ColorEditor,
|
|
721
|
-
date: DateEditor,
|
|
722
|
-
time: DateEditor,
|
|
723
|
-
datetime: DateEditor,
|
|
724
|
-
slider: SliderEditor,
|
|
725
|
-
stepper: NumberStepperEditor,
|
|
726
|
-
segmented: SegmentedEditor,
|
|
727
|
-
radio: RadioEditor,
|
|
728
|
-
combobox: ComboboxEditor,
|
|
729
|
-
toggle: ToggleEditor,
|
|
730
|
-
checkbox: CheckboxEditor,
|
|
731
|
-
card: GroupEditor,
|
|
732
|
-
group: GroupEditor,
|
|
733
|
-
'card-stack': CardStackEditor,
|
|
734
|
-
'chip-bin': ChipBinEditor,
|
|
735
|
-
tabs: TabsEditor,
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
/** True when this control kind handles its own grouping/heading. */
|
|
739
|
-
// eslint-disable-next-line react-refresh/only-export-components
|
|
740
|
-
export function isCompositeControl(kind: ControlKind, schema: SquisqAnnotatedSchema): boolean {
|
|
741
|
-
if (kind === 'group' || kind === 'card' || kind === 'tabs' || kind === 'card-stack') return true;
|
|
742
|
-
if (kind === 'richtext') return true;
|
|
743
|
-
if (kind === 'chip-bin') return arrayItemKind(schema) === 'object';
|
|
744
|
-
return false;
|
|
745
|
-
}
|