@conloca/cms-spa 0.2.5 → 0.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/dist/spa/main.css +262 -21
- package/dist/ts/.build-inputs.json +99 -57
- package/dist/ts/CmsSpaApp.d.ts +4 -6
- package/dist/ts/CmsSpaApp.d.ts.map +1 -1
- package/dist/ts/CmsSpaApp.js +19 -8
- package/dist/ts/CmsSpaApp.js.map +1 -1
- package/dist/ts/components/conflicts/EditorNoticeStrip.d.ts +44 -0
- package/dist/ts/components/conflicts/EditorNoticeStrip.d.ts.map +1 -0
- package/dist/ts/components/conflicts/EditorNoticeStrip.js +55 -0
- package/dist/ts/components/conflicts/EditorNoticeStrip.js.map +1 -0
- package/dist/ts/components/conflicts/FieldConflictList.d.ts +20 -0
- package/dist/ts/components/conflicts/FieldConflictList.d.ts.map +1 -0
- package/dist/ts/components/conflicts/FieldConflictList.js +14 -0
- package/dist/ts/components/conflicts/FieldConflictList.js.map +1 -0
- package/dist/ts/components/conflicts/FieldConflictPicker.d.ts +28 -0
- package/dist/ts/components/conflicts/FieldConflictPicker.d.ts.map +1 -0
- package/dist/ts/components/conflicts/FieldConflictPicker.js +52 -0
- package/dist/ts/components/conflicts/FieldConflictPicker.js.map +1 -0
- package/dist/ts/components/conflicts/OverwriteNotice.d.ts +11 -0
- package/dist/ts/components/conflicts/OverwriteNotice.d.ts.map +1 -0
- package/dist/ts/components/conflicts/OverwriteNotice.js +8 -0
- package/dist/ts/components/conflicts/OverwriteNotice.js.map +1 -0
- package/dist/ts/components/conflicts/PageDraftMenu.d.ts +11 -0
- package/dist/ts/components/conflicts/PageDraftMenu.d.ts.map +1 -0
- package/dist/ts/components/conflicts/PageDraftMenu.js +20 -0
- package/dist/ts/components/conflicts/PageDraftMenu.js.map +1 -0
- package/dist/ts/components/conflicts/PeerAvatars.d.ts +9 -0
- package/dist/ts/components/conflicts/PeerAvatars.d.ts.map +1 -0
- package/dist/ts/components/conflicts/PeerAvatars.js +29 -0
- package/dist/ts/components/conflicts/PeerAvatars.js.map +1 -0
- package/dist/ts/components/conflicts/PuckConflicts.d.ts +13 -0
- package/dist/ts/components/conflicts/PuckConflicts.d.ts.map +1 -0
- package/dist/ts/components/conflicts/PuckConflicts.js +59 -0
- package/dist/ts/components/conflicts/PuckConflicts.js.map +1 -0
- package/dist/ts/components/conflicts/RecentVersionsDialog.d.ts +15 -0
- package/dist/ts/components/conflicts/RecentVersionsDialog.d.ts.map +1 -0
- package/dist/ts/components/conflicts/RecentVersionsDialog.js +94 -0
- package/dist/ts/components/conflicts/RecentVersionsDialog.js.map +1 -0
- package/dist/ts/components/conflicts/conflict-label.d.ts +12 -0
- package/dist/ts/components/conflicts/conflict-label.d.ts.map +1 -0
- package/dist/ts/components/conflicts/conflict-label.js +120 -0
- package/dist/ts/components/conflicts/conflict-label.js.map +1 -0
- package/dist/ts/components/conflicts/use-page-conflicts.d.ts +26 -0
- package/dist/ts/components/conflicts/use-page-conflicts.d.ts.map +1 -0
- package/dist/ts/components/conflicts/use-page-conflicts.js +93 -0
- package/dist/ts/components/conflicts/use-page-conflicts.js.map +1 -0
- package/dist/ts/components/conflicts/version-copy.d.ts +7 -0
- package/dist/ts/components/conflicts/version-copy.d.ts.map +1 -0
- package/dist/ts/components/conflicts/version-copy.js +31 -0
- package/dist/ts/components/conflicts/version-copy.js.map +1 -0
- package/dist/ts/components/dashboard/RecentActivity.d.ts.map +1 -1
- package/dist/ts/components/dashboard/RecentActivity.js +2 -1
- package/dist/ts/components/dashboard/RecentActivity.js.map +1 -1
- package/dist/ts/components/dialogs/CreatePageDialog.js +1 -1
- package/dist/ts/components/dialogs/CreatePageDialog.js.map +1 -1
- package/dist/ts/components/dialogs/DataPropertiesDialog.d.ts +2 -1
- package/dist/ts/components/dialogs/DataPropertiesDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/DataPropertiesDialog.js +15 -3
- package/dist/ts/components/dialogs/DataPropertiesDialog.js.map +1 -1
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.d.ts +2 -1
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.js +16 -3
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.js.map +1 -1
- package/dist/ts/components/dialogs/PageMetadataDialog.d.ts +9 -2
- package/dist/ts/components/dialogs/PageMetadataDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/PageMetadataDialog.js +63 -16
- package/dist/ts/components/dialogs/PageMetadataDialog.js.map +1 -1
- package/dist/ts/components/dialogs/UnsavedChangesDialog.d.ts +16 -1
- package/dist/ts/components/dialogs/UnsavedChangesDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/UnsavedChangesDialog.js +90 -2
- package/dist/ts/components/dialogs/UnsavedChangesDialog.js.map +1 -1
- package/dist/ts/components/dialogs/unsaved-guard.d.ts +9 -0
- package/dist/ts/components/dialogs/unsaved-guard.d.ts.map +1 -0
- package/dist/ts/components/dialogs/unsaved-guard.js +14 -0
- package/dist/ts/components/dialogs/unsaved-guard.js.map +1 -0
- package/dist/ts/components/editor/CMSMDXEditor.d.ts +6 -1
- package/dist/ts/components/editor/CMSMDXEditor.d.ts.map +1 -1
- package/dist/ts/components/editor/CMSMDXEditor.js +32 -15
- package/dist/ts/components/editor/CMSMDXEditor.js.map +1 -1
- package/dist/ts/components/editor/EditorFrame.d.ts +22 -0
- package/dist/ts/components/editor/EditorFrame.d.ts.map +1 -0
- package/dist/ts/components/editor/EditorFrame.js +72 -0
- package/dist/ts/components/editor/EditorFrame.js.map +1 -0
- package/dist/ts/components/editor/FragmentBlockTypeSelect.d.ts +10 -0
- package/dist/ts/components/editor/FragmentBlockTypeSelect.d.ts.map +1 -0
- package/dist/ts/components/editor/FragmentBlockTypeSelect.js +187 -0
- package/dist/ts/components/editor/FragmentBlockTypeSelect.js.map +1 -0
- package/dist/ts/components/editor/FragmentComponentBlock.d.ts +7 -0
- package/dist/ts/components/editor/FragmentComponentBlock.d.ts.map +1 -0
- package/dist/ts/components/editor/FragmentComponentBlock.js +180 -0
- package/dist/ts/components/editor/FragmentComponentBlock.js.map +1 -0
- package/dist/ts/components/editor/FragmentEditor.d.ts +3 -1
- package/dist/ts/components/editor/FragmentEditor.d.ts.map +1 -1
- package/dist/ts/components/editor/FragmentEditor.js +545 -130
- package/dist/ts/components/editor/FragmentEditor.js.map +1 -1
- package/dist/ts/components/editor/FragmentEditorHeaderActions.d.ts +20 -0
- package/dist/ts/components/editor/FragmentEditorHeaderActions.d.ts.map +1 -0
- package/dist/ts/components/editor/FragmentEditorHeaderActions.js +49 -0
- package/dist/ts/components/editor/FragmentEditorHeaderActions.js.map +1 -0
- package/dist/ts/components/editor/GenericBlock.d.ts.map +1 -1
- package/dist/ts/components/editor/GenericBlock.js +109 -12
- package/dist/ts/components/editor/GenericBlock.js.map +1 -1
- package/dist/ts/components/editor/InlinePreviewFrame.d.ts +19 -0
- package/dist/ts/components/editor/InlinePreviewFrame.d.ts.map +1 -0
- package/dist/ts/components/editor/InlinePreviewFrame.js +65 -0
- package/dist/ts/components/editor/InlinePreviewFrame.js.map +1 -0
- package/dist/ts/components/editor/JsxPropsPanel.d.ts.map +1 -1
- package/dist/ts/components/editor/JsxPropsPanel.js +62 -2
- package/dist/ts/components/editor/JsxPropsPanel.js.map +1 -1
- package/dist/ts/components/editor/LocaleSelector.d.ts +2 -1
- package/dist/ts/components/editor/LocaleSelector.d.ts.map +1 -1
- package/dist/ts/components/editor/LocaleSelector.js +2 -2
- package/dist/ts/components/editor/LocaleSelector.js.map +1 -1
- package/dist/ts/components/editor/MDXLivePreview.d.ts +2 -0
- package/dist/ts/components/editor/MDXLivePreview.d.ts.map +1 -1
- package/dist/ts/components/editor/MDXLivePreview.js +30 -38
- package/dist/ts/components/editor/MDXLivePreview.js.map +1 -1
- package/dist/ts/components/editor/MdxPageEditor.d.ts +7 -2
- package/dist/ts/components/editor/MdxPageEditor.d.ts.map +1 -1
- package/dist/ts/components/editor/MdxPageEditor.js +136 -10
- package/dist/ts/components/editor/MdxPageEditor.js.map +1 -1
- package/dist/ts/components/editor/PageEditor.d.ts +4 -1
- package/dist/ts/components/editor/PageEditor.d.ts.map +1 -1
- package/dist/ts/components/editor/PageEditor.js +78 -100
- package/dist/ts/components/editor/PageEditor.js.map +1 -1
- package/dist/ts/components/editor/PageEditorHeaderActions.d.ts +15 -4
- package/dist/ts/components/editor/PageEditorHeaderActions.d.ts.map +1 -1
- package/dist/ts/components/editor/PageEditorHeaderActions.js +13 -7
- package/dist/ts/components/editor/PageEditorHeaderActions.js.map +1 -1
- package/dist/ts/components/editor/PageEditorWrapper.d.ts +8 -2
- package/dist/ts/components/editor/PageEditorWrapper.d.ts.map +1 -1
- package/dist/ts/components/editor/PageEditorWrapper.js +99 -41
- package/dist/ts/components/editor/PageEditorWrapper.js.map +1 -1
- package/dist/ts/components/editor/body-sync-plugin.d.ts +2 -0
- package/dist/ts/components/editor/body-sync-plugin.d.ts.map +1 -0
- package/dist/ts/components/editor/body-sync-plugin.js +32 -0
- package/dist/ts/components/editor/body-sync-plugin.js.map +1 -0
- package/dist/ts/components/editor/draft-media-config.d.ts +6 -0
- package/dist/ts/components/editor/draft-media-config.d.ts.map +1 -1
- package/dist/ts/components/editor/draft-media-config.js +21 -0
- package/dist/ts/components/editor/draft-media-config.js.map +1 -1
- package/dist/ts/components/editor/fragment-save-check.d.ts +7 -0
- package/dist/ts/components/editor/fragment-save-check.d.ts.map +1 -0
- package/dist/ts/components/editor/fragment-save-check.js +13 -0
- package/dist/ts/components/editor/fragment-save-check.js.map +1 -0
- package/dist/ts/components/editor/fragment-save-lifetime.d.ts +18 -0
- package/dist/ts/components/editor/fragment-save-lifetime.d.ts.map +1 -0
- package/dist/ts/components/editor/fragment-save-lifetime.js +115 -0
- package/dist/ts/components/editor/fragment-save-lifetime.js.map +1 -0
- package/dist/ts/components/editor/host-wrapper-plugin.d.ts.map +1 -1
- package/dist/ts/components/editor/host-wrapper-plugin.js +20 -7
- package/dist/ts/components/editor/host-wrapper-plugin.js.map +1 -1
- package/dist/ts/components/editor/index.d.ts +0 -1
- package/dist/ts/components/editor/index.d.ts.map +1 -1
- package/dist/ts/components/editor/index.js +0 -1
- package/dist/ts/components/editor/index.js.map +1 -1
- package/dist/ts/components/editor/insert-menu/InsertMdxComponentButton.d.ts.map +1 -1
- package/dist/ts/components/editor/insert-menu/InsertMdxComponentButton.js +6 -11
- package/dist/ts/components/editor/insert-menu/InsertMdxComponentButton.js.map +1 -1
- package/dist/ts/components/editor/insert-menu/SlashMenuPlugin.d.ts.map +1 -1
- package/dist/ts/components/editor/insert-menu/SlashMenuPlugin.js +66 -12
- package/dist/ts/components/editor/insert-menu/SlashMenuPlugin.js.map +1 -1
- package/dist/ts/components/editor/insert-menu/insert-payload.d.ts +16 -21
- package/dist/ts/components/editor/insert-menu/insert-payload.d.ts.map +1 -1
- package/dist/ts/components/editor/insert-menu/insert-payload.js +75 -22
- package/dist/ts/components/editor/insert-menu/insert-payload.js.map +1 -1
- package/dist/ts/components/editor/insert-menu/mdx-components-plugin.d.ts +3 -1
- package/dist/ts/components/editor/insert-menu/mdx-components-plugin.d.ts.map +1 -1
- package/dist/ts/components/editor/insert-menu/mdx-components-plugin.js +5 -3
- package/dist/ts/components/editor/insert-menu/mdx-components-plugin.js.map +1 -1
- package/dist/ts/components/editor/jsx-layout-plugin.d.ts +25 -0
- package/dist/ts/components/editor/jsx-layout-plugin.d.ts.map +1 -0
- package/dist/ts/components/editor/jsx-layout-plugin.js +77 -0
- package/dist/ts/components/editor/jsx-layout-plugin.js.map +1 -0
- package/dist/ts/components/editor/offered-mdx-components.d.ts +11 -0
- package/dist/ts/components/editor/offered-mdx-components.d.ts.map +1 -0
- package/dist/ts/components/editor/offered-mdx-components.js +27 -0
- package/dist/ts/components/editor/offered-mdx-components.js.map +1 -0
- package/dist/ts/components/editor/page-setting-targets.d.ts.map +1 -1
- package/dist/ts/components/editor/page-setting-targets.js +2 -1
- package/dist/ts/components/editor/page-setting-targets.js.map +1 -1
- package/dist/ts/components/editor/preview-availability.d.ts +16 -1
- package/dist/ts/components/editor/preview-availability.d.ts.map +1 -1
- package/dist/ts/components/editor/preview-availability.js +16 -1
- package/dist/ts/components/editor/preview-availability.js.map +1 -1
- package/dist/ts/components/editor/prop-field-hint.d.ts +13 -0
- package/dist/ts/components/editor/prop-field-hint.d.ts.map +1 -0
- package/dist/ts/components/editor/prop-field-hint.js +70 -0
- package/dist/ts/components/editor/prop-field-hint.js.map +1 -0
- package/dist/ts/components/editor/soft-break-plugin.d.ts +21 -0
- package/dist/ts/components/editor/soft-break-plugin.d.ts.map +1 -0
- package/dist/ts/components/editor/soft-break-plugin.js +52 -0
- package/dist/ts/components/editor/soft-break-plugin.js.map +1 -0
- package/dist/ts/components/editor/use-live-page-settings.d.ts +13 -0
- package/dist/ts/components/editor/use-live-page-settings.d.ts.map +1 -0
- package/dist/ts/components/editor/use-live-page-settings.js +76 -0
- package/dist/ts/components/editor/use-live-page-settings.js.map +1 -0
- package/dist/ts/components/editor/usePagePreview.d.ts +32 -0
- package/dist/ts/components/editor/usePagePreview.d.ts.map +1 -0
- package/dist/ts/components/editor/usePagePreview.js +252 -0
- package/dist/ts/components/editor/usePagePreview.js.map +1 -0
- package/dist/ts/components/editors/DataEditor.d.ts +6 -3
- package/dist/ts/components/editors/DataEditor.d.ts.map +1 -1
- package/dist/ts/components/editors/DataEditor.js +153 -19
- package/dist/ts/components/editors/DataEditor.js.map +1 -1
- package/dist/ts/components/fields/MDXEditField.d.ts +1 -1
- package/dist/ts/components/fields/MDXEditField.js +2 -2
- package/dist/ts/components/fields/MDXEditField.js.map +1 -1
- package/dist/ts/components/forms/SchemaForm.d.ts.map +1 -1
- package/dist/ts/components/forms/SchemaForm.js +1 -9
- package/dist/ts/components/forms/SchemaForm.js.map +1 -1
- package/dist/ts/components/media/AssetDetailSidebar.d.ts.map +1 -1
- package/dist/ts/components/media/AssetDetailSidebar.js +43 -5
- package/dist/ts/components/media/AssetDetailSidebar.js.map +1 -1
- package/dist/ts/components/pages/DataList.d.ts.map +1 -1
- package/dist/ts/components/pages/DataList.js +16 -4
- package/dist/ts/components/pages/DataList.js.map +1 -1
- package/dist/ts/components/pages/FragmentList.d.ts.map +1 -1
- package/dist/ts/components/pages/FragmentList.js +10 -0
- package/dist/ts/components/pages/FragmentList.js.map +1 -1
- package/dist/ts/components/pages/PageList.d.ts.map +1 -1
- package/dist/ts/components/pages/PageList.js +54 -118
- package/dist/ts/components/pages/PageList.js.map +1 -1
- package/dist/ts/components/pages/PageRow.d.ts +21 -0
- package/dist/ts/components/pages/PageRow.d.ts.map +1 -0
- package/dist/ts/components/pages/PageRow.js +70 -0
- package/dist/ts/components/pages/PageRow.js.map +1 -0
- package/dist/ts/components/pages/PageTable.d.ts +21 -0
- package/dist/ts/components/pages/PageTable.d.ts.map +1 -0
- package/dist/ts/components/pages/PageTable.js +12 -0
- package/dist/ts/components/pages/PageTable.js.map +1 -0
- package/dist/ts/components/pages/page-list-model.d.ts +20 -0
- package/dist/ts/components/pages/page-list-model.d.ts.map +1 -0
- package/dist/ts/components/pages/page-list-model.js +78 -0
- package/dist/ts/components/pages/page-list-model.js.map +1 -0
- package/dist/ts/components/puck/MDXContent.d.ts +3 -3
- package/dist/ts/components/puck/MDXContent.d.ts.map +1 -1
- package/dist/ts/components/puck/MDXContent.js +24 -72
- package/dist/ts/components/puck/MDXContent.js.map +1 -1
- package/dist/ts/components/puck/csp-frame-harness.d.ts +14 -0
- package/dist/ts/components/puck/csp-frame-harness.d.ts.map +1 -0
- package/dist/ts/components/puck/csp-frame-harness.js +85 -0
- package/dist/ts/components/puck/csp-frame-harness.js.map +1 -0
- package/dist/ts/components/puck/use-fragment-render.d.ts +9 -0
- package/dist/ts/components/puck/use-fragment-render.d.ts.map +1 -0
- package/dist/ts/components/puck/use-fragment-render.js +70 -0
- package/dist/ts/components/puck/use-fragment-render.js.map +1 -0
- package/dist/ts/components/sandbox/ContentSandbox.d.ts +3 -5
- package/dist/ts/components/sandbox/ContentSandbox.d.ts.map +1 -1
- package/dist/ts/components/sandbox/ContentSandbox.js +6 -8
- package/dist/ts/components/sandbox/ContentSandbox.js.map +1 -1
- package/dist/ts/components/sandbox/frame-runtime.d.ts +1 -1
- package/dist/ts/components/sandbox/frame-runtime.d.ts.map +1 -1
- package/dist/ts/components/sandbox/frame-runtime.js +1 -1
- package/dist/ts/components/sandbox/frame-runtime.js.map +1 -1
- package/dist/ts/components/toast.d.ts +8 -4
- package/dist/ts/components/toast.d.ts.map +1 -1
- package/dist/ts/components/toast.js +6 -1
- package/dist/ts/components/toast.js.map +1 -1
- package/dist/ts/components/ui/Card.d.ts +3 -5
- package/dist/ts/components/ui/Card.d.ts.map +1 -1
- package/dist/ts/components/ui/Card.js +3 -5
- package/dist/ts/components/ui/Card.js.map +1 -1
- package/dist/ts/components/ui/Select.d.ts.map +1 -1
- package/dist/ts/components/ui/Select.js +12 -3
- package/dist/ts/components/ui/Select.js.map +1 -1
- package/dist/ts/draft-tools.d.ts +76 -0
- package/dist/ts/draft-tools.d.ts.map +1 -0
- package/dist/ts/draft-tools.js +2 -0
- package/dist/ts/draft-tools.js.map +1 -0
- package/dist/ts/frame/channel.d.ts +1 -1
- package/dist/ts/frame/channel.d.ts.map +1 -1
- package/dist/ts/frame/channel.js +3 -0
- package/dist/ts/frame/channel.js.map +1 -1
- package/dist/ts/frame/editor-frame.d.ts.map +1 -1
- package/dist/ts/frame/editor-frame.js +188 -30
- package/dist/ts/frame/editor-frame.js.map +1 -1
- package/dist/ts/frame/protocol.d.ts +73 -4
- package/dist/ts/frame/protocol.d.ts.map +1 -1
- package/dist/ts/frame/protocol.js +54 -16
- package/dist/ts/frame/protocol.js.map +1 -1
- package/dist/ts/hooks/useUnsavedChangesGuard.d.ts +5 -3
- package/dist/ts/hooks/useUnsavedChangesGuard.d.ts.map +1 -1
- package/dist/ts/hooks/useUnsavedChangesGuard.js +17 -7
- package/dist/ts/hooks/useUnsavedChangesGuard.js.map +1 -1
- package/dist/ts/host-style-probe.d.ts.map +1 -1
- package/dist/ts/host-style-probe.js +160 -40
- package/dist/ts/host-style-probe.js.map +1 -1
- package/dist/ts/index.d.ts +13 -0
- package/dist/ts/index.d.ts.map +1 -1
- package/dist/ts/index.js +14 -0
- package/dist/ts/index.js.map +1 -1
- package/dist/ts/live/data-binding.d.ts +67 -0
- package/dist/ts/live/data-binding.d.ts.map +1 -0
- package/dist/ts/live/data-binding.js +215 -0
- package/dist/ts/live/data-binding.js.map +1 -0
- package/dist/ts/live/doc-channel.d.ts +74 -0
- package/dist/ts/live/doc-channel.d.ts.map +1 -0
- package/dist/ts/live/doc-channel.js +293 -0
- package/dist/ts/live/doc-channel.js.map +1 -0
- package/dist/ts/live/held-fragment-edits.d.ts +15 -0
- package/dist/ts/live/held-fragment-edits.d.ts.map +1 -0
- package/dist/ts/live/held-fragment-edits.js +47 -0
- package/dist/ts/live/held-fragment-edits.js.map +1 -0
- package/dist/ts/live/markdown-binding.d.ts +54 -0
- package/dist/ts/live/markdown-binding.d.ts.map +1 -0
- package/dist/ts/live/markdown-binding.js +618 -0
- package/dist/ts/live/markdown-binding.js.map +1 -0
- package/dist/ts/live/markdown-live-plugin.d.ts +42 -0
- package/dist/ts/live/markdown-live-plugin.d.ts.map +1 -0
- package/dist/ts/live/markdown-live-plugin.js +918 -0
- package/dist/ts/live/markdown-live-plugin.js.map +1 -0
- package/dist/ts/live/messages.d.ts +142 -0
- package/dist/ts/live/messages.d.ts.map +1 -0
- package/dist/ts/live/messages.js +266 -0
- package/dist/ts/live/messages.js.map +1 -0
- package/dist/ts/live/puck-binding.d.ts +88 -0
- package/dist/ts/live/puck-binding.d.ts.map +1 -0
- package/dist/ts/live/puck-binding.js +467 -0
- package/dist/ts/live/puck-binding.js.map +1 -0
- package/dist/ts/live/undo.d.ts +29 -0
- package/dist/ts/live/undo.d.ts.map +1 -0
- package/dist/ts/live/undo.js +104 -0
- package/dist/ts/live/undo.js.map +1 -0
- package/dist/ts/live/use-live.d.ts +77 -0
- package/dist/ts/live/use-live.d.ts.map +1 -0
- package/dist/ts/live/use-live.js +207 -0
- package/dist/ts/live/use-live.js.map +1 -0
- package/dist/ts/mdx-components-define.d.ts +52 -15
- package/dist/ts/mdx-components-define.d.ts.map +1 -1
- package/dist/ts/mdx-components-define.js +136 -0
- package/dist/ts/mdx-components-define.js.map +1 -1
- package/dist/ts/mdx-components.d.ts +11 -19
- package/dist/ts/mdx-components.d.ts.map +1 -1
- package/dist/ts/mdx-components.js +23 -32
- package/dist/ts/mdx-components.js.map +1 -1
- package/dist/ts/media/AssetScopePill.d.ts.map +1 -1
- package/dist/ts/media/AssetScopePill.js +2 -1
- package/dist/ts/media/AssetScopePill.js.map +1 -1
- package/dist/ts/merge-default-props.d.ts.map +1 -1
- package/dist/ts/merge-default-props.js +3 -0
- package/dist/ts/merge-default-props.js.map +1 -1
- package/dist/ts/selected-block.d.ts +27 -2
- package/dist/ts/selected-block.d.ts.map +1 -1
- package/dist/ts/selected-block.js +43 -1
- package/dist/ts/selected-block.js.map +1 -1
- package/dist/ts/site-render.d.ts +60 -0
- package/dist/ts/site-render.d.ts.map +1 -0
- package/dist/ts/site-render.js +87 -0
- package/dist/ts/site-render.js.map +1 -0
- package/dist/ts/types.d.ts +3 -0
- package/dist/ts/types.d.ts.map +1 -1
- package/dist/ts/ui-config.d.ts +29 -13
- package/dist/ts/ui-config.d.ts.map +1 -1
- package/dist/ts/ui-config.js +14 -3
- package/dist/ts/ui-config.js.map +1 -1
- package/dist/ts/utils/apply-clash.d.ts +44 -0
- package/dist/ts/utils/apply-clash.d.ts.map +1 -0
- package/dist/ts/utils/apply-clash.js +102 -0
- package/dist/ts/utils/apply-clash.js.map +1 -0
- package/dist/ts/utils/mdast-tree.d.ts +5 -7
- package/dist/ts/utils/mdast-tree.d.ts.map +1 -1
- package/dist/ts/utils/mdast-tree.js +8 -13
- package/dist/ts/utils/mdast-tree.js.map +1 -1
- package/dist/ts/utils/pageMetadata.d.ts +6 -2
- package/dist/ts/utils/pageMetadata.d.ts.map +1 -1
- package/dist/ts/utils/pageMetadata.js +25 -7
- package/dist/ts/utils/pageMetadata.js.map +1 -1
- package/dist/ts/utils/schema-fields.d.ts +2 -0
- package/dist/ts/utils/schema-fields.d.ts.map +1 -1
- package/dist/ts/utils/schema-fields.js +8 -0
- package/dist/ts/utils/schema-fields.js.map +1 -1
- package/dist/ts/write-access.d.ts +2 -0
- package/dist/ts/write-access.d.ts.map +1 -1
- package/dist/ts/write-access.js +9 -4
- package/dist/ts/write-access.js.map +1 -1
- package/package.json +18 -7
- package/src/CmsSpaApp.tsx +20 -11
- package/src/components/conflicts/EditorNoticeStrip.tsx +135 -0
- package/src/components/conflicts/FieldConflictList.tsx +59 -0
- package/src/components/conflicts/FieldConflictPicker.tsx +158 -0
- package/src/components/conflicts/OverwriteNotice.tsx +30 -0
- package/src/components/conflicts/PageDraftMenu.tsx +51 -0
- package/src/components/conflicts/PeerAvatars.tsx +51 -0
- package/src/components/conflicts/PuckConflicts.tsx +92 -0
- package/src/components/conflicts/RecentVersionsDialog.tsx +154 -0
- package/src/components/conflicts/conflict-label.ts +124 -0
- package/src/components/conflicts/use-page-conflicts.ts +112 -0
- package/src/components/conflicts/version-copy.ts +33 -0
- package/src/components/dashboard/RecentActivity.tsx +3 -2
- package/src/components/dialogs/CreatePageDialog.tsx +1 -1
- package/src/components/dialogs/DataPropertiesDialog.tsx +22 -4
- package/src/components/dialogs/FragmentPropertiesDialog.tsx +23 -4
- package/src/components/dialogs/PageMetadataDialog.tsx +157 -65
- package/src/components/dialogs/UnsavedChangesDialog.tsx +171 -21
- package/src/components/dialogs/unsaved-guard.ts +15 -0
- package/src/components/editor/CMSMDXEditor.tsx +238 -198
- package/src/components/editor/EditorFrame.tsx +116 -0
- package/src/components/editor/FragmentBlockTypeSelect.tsx +245 -0
- package/src/components/editor/FragmentComponentBlock.tsx +257 -0
- package/src/components/editor/FragmentEditor.tsx +899 -213
- package/src/components/editor/FragmentEditorHeaderActions.tsx +77 -0
- package/src/components/editor/GenericBlock.tsx +127 -16
- package/src/components/editor/InlinePreviewFrame.tsx +78 -0
- package/src/components/editor/JsxPropsPanel.tsx +90 -6
- package/src/components/editor/LocaleSelector.tsx +4 -2
- package/src/components/editor/MDXLivePreview.tsx +44 -46
- package/src/components/editor/MdxPageEditor.tsx +247 -7
- package/src/components/editor/PageEditor.tsx +154 -121
- package/src/components/editor/PageEditorHeaderActions.tsx +65 -27
- package/src/components/editor/PageEditorWrapper.tsx +122 -45
- package/src/components/editor/body-sync-plugin.ts +44 -0
- package/src/components/editor/draft-media-config.ts +22 -0
- package/src/components/editor/fragment-save-check.ts +26 -0
- package/src/components/editor/fragment-save-lifetime.ts +142 -0
- package/src/components/editor/host-wrapper-plugin.ts +28 -7
- package/src/components/editor/index.ts +0 -1
- package/src/components/editor/insert-menu/InsertMdxComponentButton.tsx +7 -11
- package/src/components/editor/insert-menu/SlashMenuPlugin.tsx +95 -18
- package/src/components/editor/insert-menu/insert-payload.ts +79 -30
- package/src/components/editor/insert-menu/mdx-components-plugin.ts +5 -3
- package/src/components/editor/jsx-layout-plugin.ts +103 -0
- package/src/components/editor/offered-mdx-components.ts +35 -0
- package/src/components/editor/page-setting-targets.tsx +2 -0
- package/src/components/editor/preview-availability.ts +21 -1
- package/src/components/editor/prop-field-hint.ts +75 -0
- package/src/components/editor/soft-break-plugin.ts +55 -0
- package/src/components/editor/use-live-page-settings.ts +80 -0
- package/src/components/editor/usePagePreview.ts +291 -0
- package/src/components/editors/DataEditor.tsx +257 -22
- package/src/components/fields/MDXEditField.tsx +2 -2
- package/src/components/forms/SchemaForm.tsx +1 -10
- package/src/components/media/AssetDetailSidebar.tsx +47 -6
- package/src/components/pages/DataList.tsx +14 -4
- package/src/components/pages/FragmentList.tsx +8 -0
- package/src/components/pages/PageList.tsx +90 -337
- package/src/components/pages/PageRow.tsx +290 -0
- package/src/components/pages/PageTable.tsx +71 -0
- package/src/components/pages/page-list-model.ts +98 -0
- package/src/components/puck/MDXContent.tsx +37 -113
- package/src/components/puck/csp-frame-harness.tsx +99 -0
- package/src/components/puck/use-fragment-render.ts +82 -0
- package/src/components/sandbox/ContentSandbox.tsx +6 -11
- package/src/components/sandbox/frame-runtime.ts +0 -2
- package/src/components/toast.tsx +23 -5
- package/src/components/ui/Card.tsx +3 -5
- package/src/components/ui/Select.tsx +14 -6
- package/src/draft-tools.ts +77 -0
- package/src/frame/channel.ts +3 -1
- package/src/frame/editor-frame.ts +210 -30
- package/src/frame/protocol.ts +98 -15
- package/src/hooks/useUnsavedChangesGuard.ts +17 -6
- package/src/host-style-probe.ts +157 -37
- package/src/index.ts +90 -0
- package/src/live/data-binding.ts +252 -0
- package/src/live/doc-channel.ts +343 -0
- package/src/live/held-fragment-edits.ts +47 -0
- package/src/live/markdown-binding.ts +630 -0
- package/src/live/markdown-live-plugin.tsx +1037 -0
- package/src/live/messages.ts +370 -0
- package/src/live/puck-binding.tsx +579 -0
- package/src/live/undo.ts +112 -0
- package/src/live/use-live.ts +264 -0
- package/src/main.css +184 -4
- package/src/mdx-components-define.ts +170 -24
- package/src/mdx-components.ts +29 -30
- package/src/media/AssetScopePill.tsx +2 -1
- package/src/merge-default-props.ts +4 -0
- package/src/selected-block.ts +55 -3
- package/src/site-render.ts +146 -0
- package/src/types.ts +3 -0
- package/src/ui-config.ts +51 -15
- package/src/utils/apply-clash.ts +113 -0
- package/src/utils/mdast-tree.ts +8 -12
- package/src/utils/pageMetadata.ts +25 -7
- package/src/utils/schema-fields.ts +9 -0
- package/src/write-access.ts +10 -4
- package/styles/tailwind-theme.css +11 -0
- package/dist/ts/components/editor/ContentDiff.d.ts +0 -10
- package/dist/ts/components/editor/ContentDiff.d.ts.map +0 -1
- package/dist/ts/components/editor/ContentDiff.js +0 -52
- package/dist/ts/components/editor/ContentDiff.js.map +0 -1
- package/src/components/editor/ContentDiff.tsx +0 -251
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Check } from 'lucide-react';
|
|
2
|
+
import type { SaveState } from '../../types.js';
|
|
3
|
+
|
|
4
|
+
/** Save edits persists this fragment; the editor's back arrow owns navigation. */
|
|
5
|
+
interface FragmentStatusFacts {
|
|
6
|
+
saveState: SaveState;
|
|
7
|
+
isDirty: boolean;
|
|
8
|
+
/** A save has succeeded since this fragment and locale were opened. */
|
|
9
|
+
savedSinceOpen: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Fresh edits can be saved immediately; a clean buffer no longer carries an old failure. */
|
|
13
|
+
function visibleSaveState(saveState: SaveState, isDirty: boolean): SaveState {
|
|
14
|
+
if (isDirty && saveState === 'saved') return 'idle';
|
|
15
|
+
return !isDirty && (saveState === 'error' || saveState === 'conflict') ? 'idle' : saveState;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The fragment's save state does not assume which actions an embedding application supplies. */
|
|
19
|
+
export function fragmentStatusText({ saveState, isDirty, savedSinceOpen }: FragmentStatusFacts): string {
|
|
20
|
+
const displayState = visibleSaveState(saveState, isDirty);
|
|
21
|
+
if (displayState === 'saving') return 'Saving…';
|
|
22
|
+
if (displayState === 'conflict') return 'Someone else changed this fragment. Your changes are not saved.';
|
|
23
|
+
if (displayState === 'error') return 'Save failed. Your changes are still here.';
|
|
24
|
+
if (isDirty) return 'Unsaved changes.';
|
|
25
|
+
if (savedSinceOpen) return 'All changes saved.';
|
|
26
|
+
return 'No unsaved changes.';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function saveButtonLabel(saveState: SaveState): string {
|
|
30
|
+
switch (saveState) {
|
|
31
|
+
case 'saving':
|
|
32
|
+
return 'Saving…';
|
|
33
|
+
case 'saved':
|
|
34
|
+
return 'Saved';
|
|
35
|
+
case 'error':
|
|
36
|
+
return 'Retry save';
|
|
37
|
+
case 'conflict':
|
|
38
|
+
return 'Conflict';
|
|
39
|
+
default:
|
|
40
|
+
return 'Save edits';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface FragmentEditorHeaderActionsProps extends Pick<FragmentStatusFacts, 'saveState' | 'isDirty'> {
|
|
45
|
+
/** The host's chrome is the only save affordance. */
|
|
46
|
+
saveHidden: boolean;
|
|
47
|
+
onSave: () => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Id of the status line, so the control can point at the reason it is disabled. */
|
|
51
|
+
export const FRAGMENT_STATUS_ID = 'fragment-editor-status';
|
|
52
|
+
|
|
53
|
+
export function FragmentEditorHeaderActions({
|
|
54
|
+
saveState,
|
|
55
|
+
isDirty,
|
|
56
|
+
saveHidden,
|
|
57
|
+
onSave,
|
|
58
|
+
}: FragmentEditorHeaderActionsProps) {
|
|
59
|
+
const displayState = visibleSaveState(saveState, isDirty);
|
|
60
|
+
const saving = displayState === 'saving';
|
|
61
|
+
if (saveHidden) return null;
|
|
62
|
+
return (
|
|
63
|
+
<button
|
|
64
|
+
type="button"
|
|
65
|
+
onClick={onSave}
|
|
66
|
+
// An in-flight save or a clean buffer has no new write to submit.
|
|
67
|
+
disabled={saving || !isDirty}
|
|
68
|
+
aria-describedby={FRAGMENT_STATUS_ID}
|
|
69
|
+
title="Save your changes to this fragment."
|
|
70
|
+
className="px-3 py-1.5 text-sm bg-accent text-accent-foreground rounded hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1"
|
|
71
|
+
data-testid="fragment-editor-save"
|
|
72
|
+
>
|
|
73
|
+
{displayState === 'saved' && <Check aria-hidden className="h-4 w-4" />}
|
|
74
|
+
{saveButtonLabel(displayState)}
|
|
75
|
+
</button>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JsonValue } from '@conloca/mdx/render';
|
|
1
2
|
import type { JsxEditorProps } from '@mdxeditor/editor';
|
|
2
3
|
import {
|
|
3
4
|
NestedLexicalEditor,
|
|
@@ -5,7 +6,7 @@ import {
|
|
|
5
6
|
useMdastNodeUpdater,
|
|
6
7
|
useNestedEditorContext,
|
|
7
8
|
} from '@mdxeditor/editor';
|
|
8
|
-
import { $getNodeByKey } from 'lexical';
|
|
9
|
+
import { $getNodeByKey, getNearestEditorFromDOMNode } from 'lexical';
|
|
9
10
|
import type * as Mdast from 'mdast';
|
|
10
11
|
import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
|
|
11
12
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
@@ -18,7 +19,13 @@ import {
|
|
|
18
19
|
writeAttribute,
|
|
19
20
|
} from '../../mdx-components.js';
|
|
20
21
|
import { useSandboxPreviewStyles } from '../../sandbox-preview-styles.js';
|
|
21
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
getSelectedBlock,
|
|
24
|
+
isLiveEditing,
|
|
25
|
+
setSelectedBlock,
|
|
26
|
+
trackDraft,
|
|
27
|
+
useSelectedBlock,
|
|
28
|
+
} from '../../selected-block.js';
|
|
22
29
|
import { getCmsRoute } from '../../ui-config.js';
|
|
23
30
|
import { bodyNeedsStaticHtml, isHtmlTag, mdastToHtml } from '../../utils/mdast-to-html.js';
|
|
24
31
|
import {
|
|
@@ -228,6 +235,19 @@ function wireInlinePropEditors(
|
|
|
228
235
|
}
|
|
229
236
|
}
|
|
230
237
|
|
|
238
|
+
/**
|
|
239
|
+
* A field that commits on blur holds typed text only while focused: tracked then, so co-editing can commit it first.
|
|
240
|
+
* A field that left the page without a blur is released unwritten: its commit holds a stale snapshot of the block.
|
|
241
|
+
*/
|
|
242
|
+
function trackDraftWhileFocused(field: HTMLElement, commit: () => void): void {
|
|
243
|
+
let release: (() => void) | undefined;
|
|
244
|
+
field.addEventListener('focus', () => {
|
|
245
|
+
release?.();
|
|
246
|
+
release = trackDraft(() => (field.isConnected ? commit() : release?.()));
|
|
247
|
+
});
|
|
248
|
+
field.addEventListener('blur', () => release?.());
|
|
249
|
+
}
|
|
250
|
+
|
|
231
251
|
/**
|
|
232
252
|
* Attach the inline-prop event listeners to a target element. Pulled
|
|
233
253
|
* out of `wireInlinePropEditors` so both the selector-driven path
|
|
@@ -262,6 +282,7 @@ function bindInlinePropEditor(
|
|
|
262
282
|
}
|
|
263
283
|
};
|
|
264
284
|
target.addEventListener('blur', commit);
|
|
285
|
+
trackDraftWhileFocused(target, commit);
|
|
265
286
|
target.addEventListener('keydown', (e: KeyboardEvent) => {
|
|
266
287
|
// Enter commits (string props are single-line); Escape reverts.
|
|
267
288
|
if (e.key === 'Enter') {
|
|
@@ -385,6 +406,19 @@ function cacheKey(req: RenderRequest): string {
|
|
|
385
406
|
return `${req.documentIndex}::${req.inline ? 'inline::' : ''}${stableStringify(stripBodyFields(req.tree as unknown as AnyProps) as AnyProps)}`;
|
|
386
407
|
}
|
|
387
408
|
|
|
409
|
+
/** `req`'s cache key without the text of item `item` of its list body, which is typed in place. */
|
|
410
|
+
function keyApartFrom(req: RenderRequest, item: number | null): string {
|
|
411
|
+
const tree = { ...req.tree };
|
|
412
|
+
if (item !== null && tree.bodyHtml) {
|
|
413
|
+
const body = document.createElement('template');
|
|
414
|
+
body.innerHTML = tree.bodyHtml;
|
|
415
|
+
// Only flat lists are edited in place (see `wireListItemEditors`), so the body's items are its `li`s in order.
|
|
416
|
+
body.content.querySelectorAll('li').item(item)?.replaceChildren();
|
|
417
|
+
tree.bodyHtml = body.innerHTML;
|
|
418
|
+
}
|
|
419
|
+
return cacheKey({ ...req, tree });
|
|
420
|
+
}
|
|
421
|
+
|
|
388
422
|
function stableStringify(obj: AnyProps): string {
|
|
389
423
|
// Stable across key order so attribute reordering doesn't bust the cache.
|
|
390
424
|
// For nested objects/arrays (children trees) JSON.stringify already
|
|
@@ -483,9 +517,10 @@ function findTopLevelList(
|
|
|
483
517
|
|
|
484
518
|
/**
|
|
485
519
|
* Wire each `<li>` of the first ordered/unordered list in the
|
|
486
|
-
* rendered preview as a contenteditable
|
|
487
|
-
*
|
|
488
|
-
*
|
|
520
|
+
* rendered preview as a contenteditable that rewrites the corresponding
|
|
521
|
+
* mdast `listItem`: on blur, or co-edited as it is typed (see
|
|
522
|
+
* `wireInlinePropEditors`; `onTyping` names the item typed in). Used
|
|
523
|
+
* for strict-slot list components (Starlight `<Steps>`, `<FileTree>`) where the
|
|
489
524
|
* framework rejects `<conloca-slot>` children — we can't portal a
|
|
490
525
|
* Lexical editor into them, so we edit the rendered HTML in place.
|
|
491
526
|
*
|
|
@@ -507,6 +542,7 @@ function wireListItemEditors(
|
|
|
507
542
|
node: MdxJsxFlowElement,
|
|
508
543
|
updater: (partial: Partial<MdxJsxFlowElement>) => void,
|
|
509
544
|
pendingFocusIndexRef: { current: number | null },
|
|
545
|
+
onTyping: (item: number | null) => void,
|
|
510
546
|
): void {
|
|
511
547
|
const found = findTopLevelList(node);
|
|
512
548
|
if (!found) return;
|
|
@@ -553,6 +589,7 @@ function wireListItemEditors(
|
|
|
553
589
|
li.setAttribute('contenteditable', 'plaintext-only');
|
|
554
590
|
li.classList.add('conloca-listitem');
|
|
555
591
|
let committed = (li.textContent ?? '').trim();
|
|
592
|
+
let atFocus = committed;
|
|
556
593
|
const itemIndex = i;
|
|
557
594
|
const commit = () => {
|
|
558
595
|
const next = (li.textContent ?? '').trim();
|
|
@@ -606,7 +643,20 @@ function wireListItemEditors(
|
|
|
606
643
|
writeListChildren(newListChildren);
|
|
607
644
|
};
|
|
608
645
|
|
|
609
|
-
li.addEventListener('
|
|
646
|
+
li.addEventListener('focus', () => {
|
|
647
|
+
atFocus = (li.textContent ?? '').trim();
|
|
648
|
+
});
|
|
649
|
+
// Co-edited, it writes as it is typed, as a prop typed in place does.
|
|
650
|
+
li.addEventListener('input', () => {
|
|
651
|
+
if (!isLiveEditing()) return;
|
|
652
|
+
onTyping(itemIndex);
|
|
653
|
+
commit();
|
|
654
|
+
});
|
|
655
|
+
li.addEventListener('blur', () => {
|
|
656
|
+
commit();
|
|
657
|
+
onTyping(null);
|
|
658
|
+
});
|
|
659
|
+
trackDraftWhileFocused(li, commit);
|
|
610
660
|
li.addEventListener('keydown', (e) => {
|
|
611
661
|
if (e.key === 'Enter' && !e.shiftKey) {
|
|
612
662
|
// Enter splits the list: commit current text, append a new
|
|
@@ -623,8 +673,9 @@ function wireListItemEditors(
|
|
|
623
673
|
removeSelf();
|
|
624
674
|
}
|
|
625
675
|
} else if (e.key === 'Escape') {
|
|
676
|
+
// Puts back the text the item had when focused.
|
|
626
677
|
e.preventDefault();
|
|
627
|
-
li.textContent =
|
|
678
|
+
li.textContent = atFocus;
|
|
628
679
|
li.blur();
|
|
629
680
|
}
|
|
630
681
|
});
|
|
@@ -920,9 +971,22 @@ export function GenericBlock({ mdastNode }: JsxEditorProps) {
|
|
|
920
971
|
previewBindingsRef.current.node = node;
|
|
921
972
|
previewBindingsRef.current.updater = updater;
|
|
922
973
|
|
|
974
|
+
/** The list item typed in place in this block's preview while co-edited, until it is left. */
|
|
975
|
+
const [typingItem, setTypingItem] = useState<number | null>(null);
|
|
976
|
+
const requested = useRef<RenderRequest | null>(null);
|
|
977
|
+
|
|
923
978
|
// Fetch (or serve from cache) the rendered HTML on prop changes.
|
|
924
979
|
useEffect(() => {
|
|
925
980
|
if (!renderReq) return;
|
|
981
|
+
// The author's typing in a list item of the preview needs no render while they type: the item shows it, and a render
|
|
982
|
+
// would take the item from under the caret. Anything else changed still renders; leaving the item renders it.
|
|
983
|
+
if (
|
|
984
|
+
typingItem !== null &&
|
|
985
|
+
requested.current &&
|
|
986
|
+
keyApartFrom(renderReq, typingItem) === keyApartFrom(requested.current, typingItem)
|
|
987
|
+
)
|
|
988
|
+
return;
|
|
989
|
+
requested.current = renderReq;
|
|
926
990
|
let cancelled = false;
|
|
927
991
|
setError(null);
|
|
928
992
|
fetchRendered(renderReq)
|
|
@@ -937,7 +1001,7 @@ export function GenericBlock({ mdastNode }: JsxEditorProps) {
|
|
|
937
1001
|
return () => {
|
|
938
1002
|
cancelled = true;
|
|
939
1003
|
};
|
|
940
|
-
}, [renderReq]);
|
|
1004
|
+
}, [renderReq, typingItem]);
|
|
941
1005
|
|
|
942
1006
|
// Imperatively swap the wrapper's inner HTML when the rendered
|
|
943
1007
|
// string changes, then locate every body slot in the SSR'd markup.
|
|
@@ -955,7 +1019,7 @@ export function GenericBlock({ mdastNode }: JsxEditorProps) {
|
|
|
955
1019
|
const wrap = wrapperRef.current;
|
|
956
1020
|
if (!wrap || html == null) return;
|
|
957
1021
|
const { attrs: currentAttrs, node: currentNode, updater: currentUpdater } = previewBindingsRef.current;
|
|
958
|
-
const currentOnPropChange = (propName: string, value:
|
|
1022
|
+
const currentOnPropChange = (propName: string, value: JsonValue | null | undefined) => {
|
|
959
1023
|
currentUpdater({
|
|
960
1024
|
attributes: writeAttribute(currentNode.attributes, propName, value) as typeof currentNode.attributes,
|
|
961
1025
|
});
|
|
@@ -972,7 +1036,23 @@ export function GenericBlock({ mdastNode }: JsxEditorProps) {
|
|
|
972
1036
|
// handlers, dangerous URL schemes, and CSS `url()` beacons. Escaped entities
|
|
973
1037
|
// survive untouched, so legitimate prop text (`5 < 10`) still renders;
|
|
974
1038
|
// `conloca-slot` stays allowlisted so the inline-editing slots survive.
|
|
1039
|
+
// A new render (a teammate's insert above shifts every block's index, which re-renders it) must not take the
|
|
1040
|
+
// author's place. A field that commits on blur (an inline prop or a list item) is committed first, and an inline
|
|
1041
|
+
// prop is refocused below with its text; the body slots move into the new markup as they are, so their editors
|
|
1042
|
+
// stay mounted, and focus goes back into them.
|
|
1043
|
+
const focused =
|
|
1044
|
+
document.activeElement instanceof HTMLElement && wrap.contains(document.activeElement)
|
|
1045
|
+
? document.activeElement
|
|
1046
|
+
: null;
|
|
1047
|
+
const typedProp = focused?.getAttribute('data-conloca-prop');
|
|
1048
|
+
const typed = focused?.textContent ?? '';
|
|
1049
|
+
if (focused?.matches('[data-conloca-prop], [data-conloca-listitem]')) focused.blur();
|
|
1050
|
+
const slots = new Map(Array.from(wrap.querySelectorAll(SLOT_TAG), (el) => [el.getAttribute('data-slot-id'), el]));
|
|
975
1051
|
wrap.innerHTML = sanitizeComponentHtml(html);
|
|
1052
|
+
for (const el of Array.from(wrap.querySelectorAll(SLOT_TAG))) {
|
|
1053
|
+
const kept = slots.get(el.getAttribute('data-slot-id'));
|
|
1054
|
+
if (kept) el.replaceWith(kept);
|
|
1055
|
+
}
|
|
976
1056
|
// After replacing the preview HTML, scan for string-prop values that
|
|
977
1057
|
// appear exactly once as a leaf element's textContent and wire those
|
|
978
1058
|
// elements as contenteditable. Authors edit eg LinkCard's `description`
|
|
@@ -1018,7 +1098,7 @@ export function GenericBlock({ mdastNode }: JsxEditorProps) {
|
|
|
1018
1098
|
// the right region.
|
|
1019
1099
|
region.setAttribute('data-conloca-child-path', slotId);
|
|
1020
1100
|
const childAttrs = readAttrs(childNode);
|
|
1021
|
-
const childOnPropChange = (propName: string, value:
|
|
1101
|
+
const childOnPropChange = (propName: string, value: JsonValue | null | undefined) => {
|
|
1022
1102
|
const newChild = {
|
|
1023
1103
|
...childNode,
|
|
1024
1104
|
attributes: writeAttribute(childNode.attributes, propName, value),
|
|
@@ -1034,14 +1114,30 @@ export function GenericBlock({ mdastNode }: JsxEditorProps) {
|
|
|
1034
1114
|
// FileTree, anything else whose framework component validates
|
|
1035
1115
|
// its slot as a real `<ol>` / `<ul>` and rejects `<conloca-slot>`
|
|
1036
1116
|
// children). For those, we wire each `<li>` as a contenteditable
|
|
1037
|
-
//
|
|
1117
|
+
// that commits on blur (as typed when co-edited) — no DOM mutation, no portal collision
|
|
1038
1118
|
// with React. Trade-off: plaintext-only commits (loses bold/
|
|
1039
1119
|
// italic on edit). Future enhancement: parse inline markdown
|
|
1040
1120
|
// back from contenteditable text so formatting round-trips.
|
|
1041
|
-
wireListItemEditors(wrap, currentNode, currentUpdater, pendingListItemFocusRef);
|
|
1121
|
+
wireListItemEditors(wrap, currentNode, currentUpdater, pendingListItemFocusRef, setTypingItem);
|
|
1042
1122
|
setContainerSlots(new Map());
|
|
1043
1123
|
setSlotEl(wrap.querySelector(SLOT_TAG));
|
|
1044
1124
|
}
|
|
1125
|
+
const field = typedProp
|
|
1126
|
+
? Array.from(wrap.querySelectorAll<HTMLElement>('[data-conloca-prop]')).find(
|
|
1127
|
+
(el) => el.getAttribute('data-conloca-prop') === typedProp,
|
|
1128
|
+
)
|
|
1129
|
+
: undefined;
|
|
1130
|
+
if (field) {
|
|
1131
|
+
field.textContent = typed;
|
|
1132
|
+
field.focus();
|
|
1133
|
+
document.getSelection()?.selectAllChildren(field);
|
|
1134
|
+
document.getSelection()?.collapseToEnd();
|
|
1135
|
+
} else if (focused?.isConnected && document.activeElement !== focused) {
|
|
1136
|
+
// A body's editor keeps its caret; focusing it through Lexical puts the caret back on the page.
|
|
1137
|
+
const body = getNearestEditorFromDOMNode(focused);
|
|
1138
|
+
if (body) body.focus();
|
|
1139
|
+
else focused.focus();
|
|
1140
|
+
}
|
|
1045
1141
|
// `previewBindingsRef` supplies the current attrs, node, and updater
|
|
1046
1142
|
// without making their render-local identities effect triggers.
|
|
1047
1143
|
// This preserves focus while preventing stale editor callbacks.
|
|
@@ -1055,7 +1151,7 @@ export function GenericBlock({ mdastNode }: JsxEditorProps) {
|
|
|
1055
1151
|
);
|
|
1056
1152
|
|
|
1057
1153
|
const onPropChange = useCallback(
|
|
1058
|
-
(propName: string, next:
|
|
1154
|
+
(propName: string, next: JsonValue | null | undefined) => {
|
|
1059
1155
|
// Route through the type-aware writer so booleans become JSX
|
|
1060
1156
|
// shorthand (`<CardGrid stagger />`), numbers become expressions
|
|
1061
1157
|
// (`<Box columns={3} />`), and strings stay as string literals.
|
|
@@ -1139,7 +1235,7 @@ export function GenericBlock({ mdastNode }: JsxEditorProps) {
|
|
|
1139
1235
|
const childDescriptor = descriptorsByName.get(childNode.name);
|
|
1140
1236
|
if (!childDescriptor || !isJsxDescriptor(childDescriptor)) return;
|
|
1141
1237
|
const childAttrs = readAttrs(childNode);
|
|
1142
|
-
const childOnPropChange = (propName: string, value:
|
|
1238
|
+
const childOnPropChange = (propName: string, value: JsonValue | null | undefined) => {
|
|
1143
1239
|
const newChild = {
|
|
1144
1240
|
...childNode,
|
|
1145
1241
|
attributes: writeAttribute(childNode.attributes, propName, value),
|
|
@@ -1165,6 +1261,21 @@ export function GenericBlock({ mdastNode }: JsxEditorProps) {
|
|
|
1165
1261
|
// Render-local editor bindings are read from the ref above.
|
|
1166
1262
|
}, [selectionSignature, descriptor, name, blockKey, containerMode, descriptorsByName]);
|
|
1167
1263
|
|
|
1264
|
+
// A block that goes (a teammate's change rebuilt the block around it, or it was removed) leaves the side panel
|
|
1265
|
+
// bound to nothing, where a prop change would silently go nowhere. Checked after the commit: StrictMode's rehearsal
|
|
1266
|
+
// unmount leaves the block in place, and a rebuilt top-level block has already handed its selection on.
|
|
1267
|
+
useEffect(
|
|
1268
|
+
() => () => {
|
|
1269
|
+
queueMicrotask(() => {
|
|
1270
|
+
const gone =
|
|
1271
|
+
parentEditor.getRootElement() === null ||
|
|
1272
|
+
!parentEditor.getEditorState().read(() => $getNodeByKey(blockKey) !== null);
|
|
1273
|
+
if (gone && getSelectedBlock()?.key.split(':')[0] === blockKey) setSelectedBlock(null);
|
|
1274
|
+
});
|
|
1275
|
+
},
|
|
1276
|
+
[parentEditor, blockKey],
|
|
1277
|
+
);
|
|
1278
|
+
|
|
1168
1279
|
const handleSelect = useCallback(
|
|
1169
1280
|
(e?: React.SyntheticEvent) => {
|
|
1170
1281
|
if (!descriptor) return;
|
|
@@ -1194,7 +1305,7 @@ export function GenericBlock({ mdastNode }: JsxEditorProps) {
|
|
|
1194
1305
|
if (childDescriptor && isJsxDescriptor(childDescriptor)) {
|
|
1195
1306
|
const childAttrs = readAttrs(childNode);
|
|
1196
1307
|
const childKey = `${blockKey}:${childPath.join('.')}`;
|
|
1197
|
-
const childOnPropChange = (propName: string, value:
|
|
1308
|
+
const childOnPropChange = (propName: string, value: JsonValue | null | undefined) => {
|
|
1198
1309
|
const newChild = {
|
|
1199
1310
|
...childNode,
|
|
1200
1311
|
attributes: writeAttribute(childNode.attributes, propName, value),
|
|
@@ -1283,7 +1394,7 @@ export function GenericBlock({ mdastNode }: JsxEditorProps) {
|
|
|
1283
1394
|
onMouseDownCapture={handleSelect}
|
|
1284
1395
|
onFocusCapture={handleSelect}
|
|
1285
1396
|
>
|
|
1286
|
-
<ContentSandbox
|
|
1397
|
+
<ContentSandbox content={rawHtml} styles={sandboxStyles} />
|
|
1287
1398
|
</div>
|
|
1288
1399
|
);
|
|
1289
1400
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type ReactNode, useEffect, useState } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import { useSandboxPreviewStyles } from '../../sandbox-preview-styles.js';
|
|
4
|
+
|
|
5
|
+
// flow-root keeps child margins inside the body, so its box is the content height and can shrink.
|
|
6
|
+
const EMPTY_DOCUMENT = '<!doctype html><html><head></head><body style="margin:0;display:flow-root"></body></html>';
|
|
7
|
+
|
|
8
|
+
// Duck-typed, not `instanceof Element`: the target usually belongs to another frame's realm.
|
|
9
|
+
const isElement = (target: EventTarget | null): target is Element =>
|
|
10
|
+
target !== null && 'closest' in target && typeof target.closest === 'function';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A preview never navigates: a followed link or image-map area would replace the frame (with target=_top or
|
|
14
|
+
* _parent, the editor), and a form submit would too. A submit control's click is cancelled as well, since its
|
|
15
|
+
* `form` attribute may name a form outside the preview whose submit event never passes through it. Cancelling the
|
|
16
|
+
* click only stops the submit or reset; the control's own click handlers still run. Handles click, auxclick and
|
|
17
|
+
* submit.
|
|
18
|
+
*/
|
|
19
|
+
export function preventLinkNavigation(event: Pick<Event, 'type' | 'target' | 'preventDefault'>): void {
|
|
20
|
+
if (event.type === 'submit') {
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const { target } = event;
|
|
25
|
+
if (isElement(target) && target.closest('a, area, button, input[type=submit], input[type=image]')) {
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A same-origin frame the children render into, so the site's styles (and the
|
|
32
|
+
* prose floor) apply to them without reaching the editor's own UI. Its height
|
|
33
|
+
* follows its body.
|
|
34
|
+
*/
|
|
35
|
+
export function InlinePreviewFrame({ children, title }: { children: ReactNode; title: string }) {
|
|
36
|
+
const styles = useSandboxPreviewStyles();
|
|
37
|
+
const [frame, setFrame] = useState<HTMLIFrameElement | null>(null);
|
|
38
|
+
const [body, setBody] = useState<HTMLElement | null>(null);
|
|
39
|
+
const [height, setHeight] = useState(0);
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!frame) return undefined;
|
|
43
|
+
const ready = () => {
|
|
44
|
+
const doc = frame.contentDocument;
|
|
45
|
+
// The initial about:blank document is replaced once the srcdoc loads; only the srcdoc one is kept.
|
|
46
|
+
if (doc?.URL === 'about:srcdoc' && doc.readyState === 'complete' && doc.body) setBody(doc.body);
|
|
47
|
+
};
|
|
48
|
+
ready();
|
|
49
|
+
frame.addEventListener('load', ready);
|
|
50
|
+
return () => frame.removeEventListener('load', ready);
|
|
51
|
+
}, [frame]);
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!body) return undefined;
|
|
55
|
+
const doc = body.ownerDocument;
|
|
56
|
+
for (const type of ['click', 'auxclick', 'submit']) doc.addEventListener(type, preventLinkNavigation, true);
|
|
57
|
+
const observer = new ResizeObserver(() => setHeight(Math.ceil(body.getBoundingClientRect().height)));
|
|
58
|
+
observer.observe(body);
|
|
59
|
+
return () => {
|
|
60
|
+
for (const type of ['click', 'auxclick', 'submit']) doc.removeEventListener(type, preventLinkNavigation, true);
|
|
61
|
+
observer.disconnect();
|
|
62
|
+
};
|
|
63
|
+
}, [body]);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
<iframe
|
|
68
|
+
ref={setFrame}
|
|
69
|
+
title={title}
|
|
70
|
+
srcDoc={EMPTY_DOCUMENT}
|
|
71
|
+
className="block w-full border-0"
|
|
72
|
+
style={{ height }}
|
|
73
|
+
/>
|
|
74
|
+
{body && createPortal(<style data-conloca-preview-styles="">{styles}</style>, body.ownerDocument.head)}
|
|
75
|
+
{body && createPortal(children, body)}
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { JsonValue } from '@conloca/mdx/render';
|
|
1
2
|
import { Trash2 } from 'lucide-react';
|
|
2
3
|
import { useEffect, useRef, useState } from 'react';
|
|
3
4
|
import { containsMarkdownMarkers, type MdxComponentProp } from '../../mdx-components.js';
|
|
4
|
-
import { useSelectedBlock } from '../../selected-block.js';
|
|
5
|
+
import { useSelectedBlock, useTrackedDraft } from '../../selected-block.js';
|
|
6
|
+
import { HintForm } from '../forms/HintForm.js';
|
|
7
|
+
import { normalizeFieldValue, propFieldHint } from './prop-field-hint.js';
|
|
5
8
|
import { SearchableSelect } from './SearchableSelect.js';
|
|
6
9
|
|
|
7
10
|
/**
|
|
@@ -39,23 +42,26 @@ export function JsxPropsPanel() {
|
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
const { descriptor, attrs, onPropChange, onRemove } = selected;
|
|
45
|
+
const props = descriptor.props?.filter((prop) => !prop.hidden) ?? [];
|
|
46
|
+
// The name authors see in the menus, not the tag in the file.
|
|
47
|
+
const title = descriptor.insert?.label ?? descriptor.name;
|
|
42
48
|
|
|
43
49
|
return (
|
|
44
50
|
<aside className="conloca-jsx-props-panel">
|
|
45
51
|
<header className="conloca-jsx-props-panel__header">
|
|
46
|
-
<h3 className="conloca-jsx-props-panel__title">{
|
|
52
|
+
<h3 className="conloca-jsx-props-panel__title">{title}</h3>
|
|
47
53
|
<button
|
|
48
54
|
type="button"
|
|
49
55
|
onClick={onRemove}
|
|
50
|
-
aria-label={`Remove ${
|
|
56
|
+
aria-label={`Remove ${title}`}
|
|
51
57
|
className="conloca-jsx-props-panel__remove"
|
|
52
58
|
>
|
|
53
59
|
<Trash2 size={14} aria-hidden /> Remove
|
|
54
60
|
</button>
|
|
55
61
|
</header>
|
|
56
|
-
{
|
|
62
|
+
{props.length > 0 ? (
|
|
57
63
|
<div className="conloca-jsx-props-panel__fields">
|
|
58
|
-
{
|
|
64
|
+
{props.map((prop) => (
|
|
59
65
|
<PropField
|
|
60
66
|
key={prop.name}
|
|
61
67
|
prop={prop}
|
|
@@ -79,7 +85,7 @@ interface PropFieldProps {
|
|
|
79
85
|
rawValue: unknown;
|
|
80
86
|
/** Apply a prop change. The block's bound handler accepts the full
|
|
81
87
|
* value-type union; see `selected-block.ts` for the contract. */
|
|
82
|
-
onChange: (value:
|
|
88
|
+
onChange: (value: JsonValue | null | undefined) => void;
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
/**
|
|
@@ -140,6 +146,10 @@ function PropField({ prop, rawValue, onChange }: PropFieldProps) {
|
|
|
140
146
|
);
|
|
141
147
|
}
|
|
142
148
|
|
|
149
|
+
if (prop.type === 'list' || prop.type === 'object') {
|
|
150
|
+
return <StructuredField prop={prop} rawValue={rawValue} onChange={onChange} />;
|
|
151
|
+
}
|
|
152
|
+
|
|
143
153
|
// String (default). With options → select; without → text input.
|
|
144
154
|
const stringValue = typeof rawValue === 'string' ? rawValue : rawValue == null ? '' : String(rawValue);
|
|
145
155
|
// Mirror the inline-prop wiring's bail rule (see `containsMarkdownMarkers`
|
|
@@ -186,6 +196,78 @@ function PropField({ prop, rawValue, onChange }: PropFieldProps) {
|
|
|
186
196
|
);
|
|
187
197
|
}
|
|
188
198
|
|
|
199
|
+
/**
|
|
200
|
+
* A list or object prop as `HintForm` fields, never JSON text. Edits stay in a local draft and commit
|
|
201
|
+
* once focus leaves the field, or at once for discrete controls, so typing never refocuses the editor.
|
|
202
|
+
*/
|
|
203
|
+
function StructuredField({ prop, rawValue, onChange }: PropFieldProps) {
|
|
204
|
+
const container = useRef<HTMLFieldSetElement>(null);
|
|
205
|
+
const [draft, setDraft] = useState<unknown>(rawValue);
|
|
206
|
+
// Only a real edit may write: tabbing or clicking through the field leaves the attribute alone.
|
|
207
|
+
const dirty = useRef(false);
|
|
208
|
+
const rawKey = JSON.stringify(rawValue ?? null);
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
dirty.current = false;
|
|
211
|
+
setDraft(JSON.parse(rawKey));
|
|
212
|
+
}, [rawKey]);
|
|
213
|
+
|
|
214
|
+
const commit = (value: unknown) => {
|
|
215
|
+
if (!dirty.current) return;
|
|
216
|
+
dirty.current = false;
|
|
217
|
+
const normalized = normalizeFieldValue(prop, value);
|
|
218
|
+
// A cleared object removes the attribute; an empty list stays `[]`.
|
|
219
|
+
const next = prop.type === 'object' && Object.keys(normalized ?? {}).length === 0 ? null : normalized;
|
|
220
|
+
if (JSON.stringify(next) !== rawKey) onChange(next);
|
|
221
|
+
};
|
|
222
|
+
useTrackedDraft(() => commit(draft));
|
|
223
|
+
|
|
224
|
+
// shortcut: checks only the top-level shape; a nested mismatch is still edited, upgrade if that shows up.
|
|
225
|
+
const editable =
|
|
226
|
+
rawValue === undefined ||
|
|
227
|
+
(prop.type === 'list'
|
|
228
|
+
? Array.isArray(rawValue)
|
|
229
|
+
: rawValue !== null && typeof rawValue === 'object' && !Array.isArray(rawValue));
|
|
230
|
+
if (!editable) {
|
|
231
|
+
return (
|
|
232
|
+
<div className="conloca-jsx-props-panel__field">
|
|
233
|
+
<span className="conloca-jsx-props-panel__label">{prop.label ?? prop.name}</span>
|
|
234
|
+
<small className="conloca-jsx-props-panel__help">
|
|
235
|
+
This value is code, not data, so it is not published; fix it in source mode.
|
|
236
|
+
</small>
|
|
237
|
+
</div>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<fieldset
|
|
243
|
+
ref={container}
|
|
244
|
+
aria-label={prop.label ?? prop.name}
|
|
245
|
+
className="conloca-jsx-props-panel__field m-0 min-w-0 border-0 p-0"
|
|
246
|
+
onBlur={(e) => {
|
|
247
|
+
if (!(e.relatedTarget instanceof Node && container.current?.contains(e.relatedTarget))) commit(draft);
|
|
248
|
+
}}
|
|
249
|
+
>
|
|
250
|
+
<HintForm
|
|
251
|
+
hints={{ [prop.name]: propFieldHint(prop) }}
|
|
252
|
+
values={{ [prop.name]: draft }}
|
|
253
|
+
onChange={(values) => {
|
|
254
|
+
const next = values[prop.name];
|
|
255
|
+
dirty.current = true;
|
|
256
|
+
setDraft(next);
|
|
257
|
+
// Typing commits on blur; any other control (Add item, Remove, switch, select) commits now.
|
|
258
|
+
// A list length change is always discrete: Safari does not focus a clicked button.
|
|
259
|
+
const lengthChanged = Array.isArray(next) && (!Array.isArray(draft) || next.length !== draft.length);
|
|
260
|
+
const active = document.activeElement;
|
|
261
|
+
const typing =
|
|
262
|
+
active instanceof HTMLTextAreaElement ||
|
|
263
|
+
(active instanceof HTMLInputElement && active.type !== 'checkbox' && active.type !== 'radio');
|
|
264
|
+
if (lengthChanged || !(typing && container.current?.contains(active))) commit(next);
|
|
265
|
+
}}
|
|
266
|
+
/>
|
|
267
|
+
</fieldset>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
189
271
|
/**
|
|
190
272
|
* Controlled text input with on-blur commit. Keeps a local draft so
|
|
191
273
|
* typing doesn't trigger the mdast-update → Lexical-refocus path
|
|
@@ -218,6 +300,7 @@ function TextInput({
|
|
|
218
300
|
onCommit(draft);
|
|
219
301
|
}
|
|
220
302
|
};
|
|
303
|
+
useTrackedDraft(commit);
|
|
221
304
|
return (
|
|
222
305
|
<input
|
|
223
306
|
type="text"
|
|
@@ -272,6 +355,7 @@ function NumberInput({
|
|
|
272
355
|
if (!Number.isFinite(n)) return;
|
|
273
356
|
onCommit(n);
|
|
274
357
|
};
|
|
358
|
+
useTrackedDraft(commit);
|
|
275
359
|
return (
|
|
276
360
|
<input
|
|
277
361
|
type="number"
|
|
@@ -4,6 +4,7 @@ import { cn } from '../../utils/cn.js';
|
|
|
4
4
|
|
|
5
5
|
interface LocaleSelectorProps {
|
|
6
6
|
currentLocale: string;
|
|
7
|
+
disabled?: boolean;
|
|
7
8
|
availableLocales: string[];
|
|
8
9
|
missingLocales?: string[];
|
|
9
10
|
onChange: (locale: string) => void;
|
|
@@ -11,6 +12,7 @@ interface LocaleSelectorProps {
|
|
|
11
12
|
|
|
12
13
|
export function LocaleSelector({
|
|
13
14
|
currentLocale,
|
|
15
|
+
disabled = false,
|
|
14
16
|
availableLocales,
|
|
15
17
|
missingLocales = [],
|
|
16
18
|
onChange,
|
|
@@ -18,10 +20,10 @@ export function LocaleSelector({
|
|
|
18
20
|
if (availableLocales.length <= 1) return null;
|
|
19
21
|
|
|
20
22
|
return (
|
|
21
|
-
<Select.Root value={currentLocale} onValueChange={onChange}>
|
|
23
|
+
<Select.Root disabled={disabled} value={currentLocale} onValueChange={onChange}>
|
|
22
24
|
<Select.Trigger
|
|
23
25
|
aria-label="Locale"
|
|
24
|
-
className="flex items-center gap-1.5 px-3 py-1.5 rounded text-sm border border-line text-foreground hover:bg-hover transition-colors cursor-pointer"
|
|
26
|
+
className="flex items-center gap-1.5 px-3 py-1.5 rounded text-sm border border-line text-foreground enabled:hover:bg-hover transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
|
|
25
27
|
>
|
|
26
28
|
<Select.Value />
|
|
27
29
|
<Select.Icon>
|