@conloca/cms-spa 0.2.6 → 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,245 @@
|
|
|
1
|
+
import { $createHeadingNode, $createQuoteNode } from '@lexical/rich-text';
|
|
2
|
+
import {
|
|
3
|
+
activeEditor$,
|
|
4
|
+
allowedHeadingLevels$,
|
|
5
|
+
codeBlockEditorDescriptors$,
|
|
6
|
+
convertSelectionToNode$,
|
|
7
|
+
currentBlockType$,
|
|
8
|
+
defaultCodeBlockLanguage$,
|
|
9
|
+
directiveDescriptors$,
|
|
10
|
+
exportLexicalTreeToMdast,
|
|
11
|
+
exportVisitors$,
|
|
12
|
+
importMdastTreeToLexical,
|
|
13
|
+
importVisitors$,
|
|
14
|
+
jsxComponentDescriptors$,
|
|
15
|
+
jsxIsAvailable$,
|
|
16
|
+
jsxKindMismatchPolicy$,
|
|
17
|
+
NESTED_EDITOR_UPDATED_COMMAND,
|
|
18
|
+
type Realm,
|
|
19
|
+
Select,
|
|
20
|
+
useCellValues,
|
|
21
|
+
useRealm,
|
|
22
|
+
} from '@mdxeditor/editor';
|
|
23
|
+
import {
|
|
24
|
+
$createNodeSelection,
|
|
25
|
+
$createParagraphNode,
|
|
26
|
+
$getEditor,
|
|
27
|
+
$getNearestNodeFromDOMNode,
|
|
28
|
+
$getNodeByKey,
|
|
29
|
+
$getRoot,
|
|
30
|
+
$getSelection,
|
|
31
|
+
$isDecoratorNode,
|
|
32
|
+
$isElementNode,
|
|
33
|
+
$isRangeSelection,
|
|
34
|
+
$isRootOrShadowRoot,
|
|
35
|
+
$setSelection,
|
|
36
|
+
getNearestEditorFromDOMNode,
|
|
37
|
+
type LexicalEditor,
|
|
38
|
+
type LexicalNode,
|
|
39
|
+
type RootNode,
|
|
40
|
+
} from 'lexical';
|
|
41
|
+
import type * as Mdast from 'mdast';
|
|
42
|
+
import type { MdxJsxComponentDescriptor } from '../../mdx-components.js';
|
|
43
|
+
|
|
44
|
+
const COMPONENT = 'jsx:';
|
|
45
|
+
|
|
46
|
+
/** A block-type component the caret is in: its node in the parent editor, and the component's own editor. */
|
|
47
|
+
interface Host {
|
|
48
|
+
name: string;
|
|
49
|
+
key: string;
|
|
50
|
+
parent: LexicalEditor;
|
|
51
|
+
body: LexicalEditor;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The block-type component whose body the caret is in, if any. A body is its own editor inside the component's
|
|
56
|
+
* element, which `FragmentComponentBlock` marks with `data-mdx-block`; the editor around that element holds the
|
|
57
|
+
* component. (`editorInFocus$` names the outermost component instead: a nested body's selection change bubbles up to
|
|
58
|
+
* every enclosing body.)
|
|
59
|
+
*/
|
|
60
|
+
function hostOf(body: LexicalEditor | null, names: ReadonlySet<string>): Host | null {
|
|
61
|
+
const element = body?.getRootElement();
|
|
62
|
+
const wrapper = element?.closest('[data-mdx-block]');
|
|
63
|
+
const name = wrapper?.getAttribute('data-mdx-block');
|
|
64
|
+
const parent = wrapper?.parentElement ? getNearestEditorFromDOMNode(wrapper.parentElement) : null;
|
|
65
|
+
if (!body || !wrapper || !name || !names.has(name) || !parent) return null;
|
|
66
|
+
// Finding a node from the DOM needs the editor the state belongs to.
|
|
67
|
+
const key = parent.read(() => {
|
|
68
|
+
const node = $getNearestNodeFromDOMNode(wrapper);
|
|
69
|
+
return node && $blockOf(node) ? node.getKey() : null;
|
|
70
|
+
});
|
|
71
|
+
return key ? { name, key, parent, body } : null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The block a component stands for: itself, or, for a one-line `<Eyebrow>text</Eyebrow>` (inline JSX alone in its
|
|
76
|
+
* paragraph, the way the posts write it), that paragraph. Null for a component inside a line of other text.
|
|
77
|
+
*/
|
|
78
|
+
function $blockOf(node: LexicalNode): LexicalNode | null {
|
|
79
|
+
if (!node.isInline()) return node;
|
|
80
|
+
const paragraph = node.getParent();
|
|
81
|
+
return paragraph && !$isRootOrShadowRoot(paragraph) && paragraph.getChildrenSize() === 1 ? paragraph : null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** A line of text's inline content: a paragraph's or a heading's. Anything else is not a line of text. */
|
|
85
|
+
function phrasingOf(node: Mdast.Nodes): Mdast.PhrasingContent[] | null {
|
|
86
|
+
return node.type === 'paragraph' || node.type === 'heading' ? node.children : null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The block `value` names, holding `phrasing`. A component holding one line is written on one line,
|
|
91
|
+
* `<Eyebrow>text</Eyebrow>`, the way authors write it: Markdown reads that as the component alone in a paragraph.
|
|
92
|
+
*/
|
|
93
|
+
function blockOf(value: string, phrasing: Mdast.PhrasingContent[]): Mdast.RootContent {
|
|
94
|
+
const paragraph: Mdast.Paragraph = { type: 'paragraph', children: phrasing };
|
|
95
|
+
if (value.startsWith(COMPONENT)) {
|
|
96
|
+
const name = value.slice(COMPONENT.length);
|
|
97
|
+
return { type: 'paragraph', children: [{ type: 'mdxJsxTextElement', name, attributes: [], children: phrasing }] };
|
|
98
|
+
}
|
|
99
|
+
if (value === 'quote') return { type: 'blockquote', children: [paragraph] };
|
|
100
|
+
const depth = ([1, 2, 3, 4, 5, 6] as const).find((level) => value === `h${level}`);
|
|
101
|
+
return depth ? { type: 'heading', depth, children: phrasing } : paragraph;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function exportOf(realm: Realm, root: RootNode): Mdast.Root {
|
|
105
|
+
return exportLexicalTreeToMdast({
|
|
106
|
+
root,
|
|
107
|
+
visitors: realm.getValue(exportVisitors$),
|
|
108
|
+
jsxComponentDescriptors: realm.getValue(jsxComponentDescriptors$),
|
|
109
|
+
jsxIsAvailable: realm.getValue(jsxIsAvailable$),
|
|
110
|
+
addImportStatements: false,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Lexical nodes for `blocks`, made the way the editor loads a document. Call inside an update. */
|
|
115
|
+
function $nodesOf(realm: Realm, blocks: Mdast.RootContent[]): LexicalNode[] {
|
|
116
|
+
const nodes: LexicalNode[] = [];
|
|
117
|
+
importMdastTreeToLexical({
|
|
118
|
+
root: { append: (node) => nodes.push(node), getType: () => 'root' },
|
|
119
|
+
mdastRoot: { type: 'root', children: blocks },
|
|
120
|
+
visitors: realm.getValue(importVisitors$),
|
|
121
|
+
jsxComponentDescriptors: realm.getValue(jsxComponentDescriptors$),
|
|
122
|
+
jsxKindMismatchPolicy: realm.getValue(jsxKindMismatchPolicy$),
|
|
123
|
+
directiveDescriptors: realm.getValue(directiveDescriptors$),
|
|
124
|
+
codeBlockEditorDescriptors: realm.getValue(codeBlockEditorDescriptors$),
|
|
125
|
+
defaultCodeBlockLanguage: realm.getValue(defaultCodeBlockLanguage$),
|
|
126
|
+
});
|
|
127
|
+
return nodes;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Put `nodes` where `node` was, and the caret in the last one: a component's caret goes into its body. */
|
|
131
|
+
function $replaceWith(node: LexicalNode, nodes: LexicalNode[]): void {
|
|
132
|
+
const [first, ...rest] = nodes;
|
|
133
|
+
if (!first) return;
|
|
134
|
+
node.replace(first);
|
|
135
|
+
let previous = first;
|
|
136
|
+
for (const next of rest) previous = previous.insertAfter(next);
|
|
137
|
+
// A one-line component sits alone in its paragraph; the caret goes into the component, not after it.
|
|
138
|
+
const only = $isElementNode(previous) && previous.getChildrenSize() === 1 ? previous.getFirstChild() : null;
|
|
139
|
+
const target = $isDecoratorNode(only) ? only : previous;
|
|
140
|
+
if ($isElementNode(target)) {
|
|
141
|
+
target.selectEnd();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
// The replaced block held the selection; Lexical refuses an update that leaves it on a removed node.
|
|
145
|
+
const selection = $createNodeSelection();
|
|
146
|
+
selection.add(target.getKey());
|
|
147
|
+
$setSelection(selection);
|
|
148
|
+
// The body's editor mounts over the next renders; select() focuses it once it listens, as the library's own
|
|
149
|
+
// admonition type switch waits for its node. Only the node's latest version reaches the rendered body.
|
|
150
|
+
const editor = $getEditor();
|
|
151
|
+
const key = target.getKey();
|
|
152
|
+
setTimeout(() => {
|
|
153
|
+
// select() focuses the body, which updates editors, so it runs after the read.
|
|
154
|
+
const latest = editor.getEditorState().read(() => $getNodeByKey(key));
|
|
155
|
+
if (latest && 'select' in latest && typeof latest.select === 'function') latest.select();
|
|
156
|
+
}, 80);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** The top-level blocks the selection touches, in the editor the caret is in. Call inside an update. */
|
|
160
|
+
function $selectedBlocks(): LexicalNode[] {
|
|
161
|
+
const selection = $getSelection();
|
|
162
|
+
if (!$isRangeSelection(selection)) return [];
|
|
163
|
+
const blocks = new Map<string, LexicalNode>();
|
|
164
|
+
for (const node of selection.getNodes()) {
|
|
165
|
+
const block = node.getTopLevelElement();
|
|
166
|
+
if (block) blocks.set(block.getKey(), block);
|
|
167
|
+
}
|
|
168
|
+
return [...blocks.values()];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The fragment editor's Block type dropdown: Paragraph, Quote and the headings, then the site's block-type components
|
|
173
|
+
* (`blockType: true`). Choosing a component turns each selected line of text into that component holding the line;
|
|
174
|
+
* with the caret in one, it shows the component, and choosing another type turns the component's lines into it.
|
|
175
|
+
*/
|
|
176
|
+
export function FragmentBlockTypeSelect({ components }: { components: ReadonlyArray<MdxJsxComponentDescriptor> }) {
|
|
177
|
+
const realm = useRealm();
|
|
178
|
+
const [currentBlockType, active, headingLevels] = useCellValues(
|
|
179
|
+
currentBlockType$,
|
|
180
|
+
activeEditor$,
|
|
181
|
+
allowedHeadingLevels$,
|
|
182
|
+
);
|
|
183
|
+
const host = hostOf(active, new Set(components.map((d) => d.name)));
|
|
184
|
+
const value = host ? `${COMPONENT}${host.name}` : currentBlockType;
|
|
185
|
+
|
|
186
|
+
const convert = (next: string) => {
|
|
187
|
+
if (next === value) return;
|
|
188
|
+
if (host) {
|
|
189
|
+
// The body is read from its own editor: the copy in the parent is only written back when the body loses focus.
|
|
190
|
+
const body = host.body.getEditorState().read(() => exportOf(realm, $getRoot()).children);
|
|
191
|
+
// Each line of the body becomes the chosen block: a one-line component, a paragraph or a heading.
|
|
192
|
+
const blocks = body.map((block) => {
|
|
193
|
+
const phrasing = phrasingOf(block);
|
|
194
|
+
return phrasing ? blockOf(next, phrasing) : block;
|
|
195
|
+
});
|
|
196
|
+
host.parent.update(
|
|
197
|
+
() => {
|
|
198
|
+
const node = $getNodeByKey(host.key);
|
|
199
|
+
const block = node && $blockOf(node);
|
|
200
|
+
if (block) $replaceWith(block, $nodesOf(realm, blocks));
|
|
201
|
+
},
|
|
202
|
+
{ discrete: true },
|
|
203
|
+
);
|
|
204
|
+
// A component's body writes back to the document only on blur or this command; the root editor ignores it.
|
|
205
|
+
host.parent.dispatchCommand(NESTED_EDITOR_UPDATED_COMMAND, undefined);
|
|
206
|
+
host.parent.focus();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (!next.startsWith(COMPONENT)) {
|
|
210
|
+
// No component either side: the stock conversion, which also takes a quote apart.
|
|
211
|
+
const level = ([1, 2, 3, 4, 5, 6] as const).find((n) => next === `h${n}`);
|
|
212
|
+
const make =
|
|
213
|
+
next === 'quote' ? $createQuoteNode : level ? () => $createHeadingNode(`h${level}`) : $createParagraphNode;
|
|
214
|
+
realm.pub(convertSelectionToNode$, make);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const editor = realm.getValue(activeEditor$);
|
|
218
|
+
editor?.update(
|
|
219
|
+
() => {
|
|
220
|
+
// shortcut: assumes one exported block per top-level node, true unless an exporter joins siblings (none of
|
|
221
|
+
// the text blocks converted here do); export each block alone if one ever does.
|
|
222
|
+
const exported = exportOf(realm, $getRoot()).children;
|
|
223
|
+
for (const block of $selectedBlocks()) {
|
|
224
|
+
const source = exported[block.getIndexWithinParent()];
|
|
225
|
+
const phrasing = source ? phrasingOf(source) : null;
|
|
226
|
+
if (phrasing) $replaceWith(block, $nodesOf(realm, [blockOf(next, phrasing)]));
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
{ discrete: true },
|
|
230
|
+
);
|
|
231
|
+
editor?.dispatchCommand(NESTED_EDITOR_UPDATED_COMMAND, undefined);
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
const items: Array<{ label: string; value: string } | 'separator'> = [
|
|
235
|
+
{ label: 'Paragraph', value: 'paragraph' },
|
|
236
|
+
{ label: 'Quote', value: 'quote' },
|
|
237
|
+
...headingLevels.map((level) => ({ label: `Heading ${level}`, value: `h${level}` })),
|
|
238
|
+
];
|
|
239
|
+
if (components.length > 0) items.push('separator');
|
|
240
|
+
for (const d of components) items.push({ label: d.insert?.label ?? d.name, value: `${COMPONENT}${d.name}` });
|
|
241
|
+
|
|
242
|
+
return (
|
|
243
|
+
<Select value={value} onChange={convert} triggerTitle="Select block type" placeholder="Block type" items={items} />
|
|
244
|
+
);
|
|
245
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type FragmentVocabulary,
|
|
3
|
+
fragmentComponentProps,
|
|
4
|
+
fragmentHeadingIds,
|
|
5
|
+
type JsonValue,
|
|
6
|
+
parseFragmentMdx,
|
|
7
|
+
} from '@conloca/mdx/render';
|
|
8
|
+
import {
|
|
9
|
+
type JsxEditorProps,
|
|
10
|
+
markdown$,
|
|
11
|
+
NestedLexicalEditor,
|
|
12
|
+
useLexicalNodeRemove,
|
|
13
|
+
useMdastNodeUpdater,
|
|
14
|
+
useNestedEditorContext,
|
|
15
|
+
useRealm,
|
|
16
|
+
} from '@mdxeditor/editor';
|
|
17
|
+
import type * as Mdast from 'mdast';
|
|
18
|
+
import { Component, type ReactNode, useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
|
|
19
|
+
import {
|
|
20
|
+
isJsxDescriptor,
|
|
21
|
+
readStringAttribute,
|
|
22
|
+
useMdxComponents,
|
|
23
|
+
withOutlineId,
|
|
24
|
+
writeAttribute,
|
|
25
|
+
} from '../../mdx-components.js';
|
|
26
|
+
import { getSelectedBlock, setSelectedBlock } from '../../selected-block.js';
|
|
27
|
+
import { useSiteRender } from '../../site-render.js';
|
|
28
|
+
import { readAttrs } from '../../utils/mdast-tree.js';
|
|
29
|
+
import { preventLinkNavigation } from './InlinePreviewFrame.js';
|
|
30
|
+
import { useOfferedMdxComponents } from './offered-mdx-components.js';
|
|
31
|
+
|
|
32
|
+
interface BoundaryProps {
|
|
33
|
+
name: string;
|
|
34
|
+
/** Changing it retries a component that failed, eg after a prop edit. */
|
|
35
|
+
resetKey: string;
|
|
36
|
+
editable: ReactNode;
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface BoundaryState {
|
|
41
|
+
error: Error | null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class ComponentBoundary extends Component<BoundaryProps, BoundaryState> {
|
|
45
|
+
override state: BoundaryState = { error: null };
|
|
46
|
+
|
|
47
|
+
static getDerivedStateFromError(error: unknown) {
|
|
48
|
+
return { error: error instanceof Error ? error : new Error(String(error)) };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
override componentDidUpdate(previous: BoundaryProps) {
|
|
52
|
+
if (this.state.error && previous.resetKey !== this.props.resetKey) this.setState({ error: null });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
override render() {
|
|
56
|
+
const { error } = this.state;
|
|
57
|
+
if (!error) return this.props.children;
|
|
58
|
+
return (
|
|
59
|
+
<span className="conloca-generic-block__fallback" data-mdx-block={this.props.name} role="alert">
|
|
60
|
+
<span className="conloca-generic-block__fallback-label">{`${this.props.name} failed to render: ${error.message}`}</span>
|
|
61
|
+
{this.props.editable}
|
|
62
|
+
</span>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A fragment's component, rendered by the site's own component from its fragment vocabulary, with the same props
|
|
69
|
+
* publish passes it. Its children are a nested editor, so the author types inside the real component.
|
|
70
|
+
*/
|
|
71
|
+
export function FragmentComponentBlock({ mdastNode }: JsxEditorProps) {
|
|
72
|
+
const node = mdastNode;
|
|
73
|
+
const name = node.name ?? '';
|
|
74
|
+
const updater = useMdastNodeUpdater<typeof mdastNode>();
|
|
75
|
+
const removeNode = useLexicalNodeRemove();
|
|
76
|
+
const { lexicalNode } = useNestedEditorContext();
|
|
77
|
+
const { vocabulary } = useSiteRender();
|
|
78
|
+
const realm = useRealm();
|
|
79
|
+
const offered = useOfferedMdxComponents().find((d) => d.name === name);
|
|
80
|
+
const descriptor = offered && isJsxDescriptor(offered) ? offered : undefined;
|
|
81
|
+
const registered = useMdxComponents().some((d) => d.name === name);
|
|
82
|
+
const SiteComponent = Object.keys(vocabulary.components).includes(name) ? vocabulary.components[name] : undefined;
|
|
83
|
+
const block = mdastNode.type === 'mdxJsxFlowElement';
|
|
84
|
+
const Wrapper = block ? 'div' : 'span';
|
|
85
|
+
|
|
86
|
+
/** `attributes` with the outline anchor made from the contents label if missing; the document is read only then. */
|
|
87
|
+
const withAnchor = useCallback(
|
|
88
|
+
(attributes: typeof node.attributes) => {
|
|
89
|
+
const outline = vocabulary.outline?.[name];
|
|
90
|
+
if (!outline) return attributes;
|
|
91
|
+
return withOutlineId(
|
|
92
|
+
attributes,
|
|
93
|
+
outline,
|
|
94
|
+
takenAnchors(() => realm.getValue(markdown$), vocabulary),
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
[name, realm, vocabulary],
|
|
98
|
+
);
|
|
99
|
+
// The callbacks read the latest node and updater, so a prop edit after typing in the body, a second prop edit, or a
|
|
100
|
+
// body written back twice before the block re-renders never builds on a stale snapshot.
|
|
101
|
+
const bindings = useRef({ node, updater });
|
|
102
|
+
bindings.current = { node, updater };
|
|
103
|
+
// A component with no descriptor is inserted without a body: inventing children would crash a void component.
|
|
104
|
+
// Sites declare a descriptor with `hasChildren` to get an editable body.
|
|
105
|
+
const hasChildren = descriptor?.hasChildren === true && (registered || node.children.length > 0);
|
|
106
|
+
// On the published page the body's blocks are the site component's own children, which the site spaces with rules
|
|
107
|
+
// like `.section > * + *`; here they are the nested editor's children. The nested editor carries the component's
|
|
108
|
+
// classes so those rules reach them (main.css keeps the component's box off it), as the root contenteditable
|
|
109
|
+
// carries the page wrapper's classes. Read off the rendered element: only the site component knows its classes.
|
|
110
|
+
// Written straight onto the element rather than through state, and only when a class is missing or stale: a
|
|
111
|
+
// re-render of the block, or a class write the element already had, as its body mounts raced the author's first
|
|
112
|
+
// caret placement in it.
|
|
113
|
+
const bodyRef = useRef<HTMLElement | null>(null);
|
|
114
|
+
const bodyClasses = useRef<string[]>([]);
|
|
115
|
+
const syncBodyClass = useCallback(() => {
|
|
116
|
+
const body = bodyRef.current;
|
|
117
|
+
if (!body?.parentElement) return;
|
|
118
|
+
const next = Array.from(body.parentElement.classList);
|
|
119
|
+
const stale = bodyClasses.current.filter((token) => !next.includes(token));
|
|
120
|
+
const missing = next.filter((token) => !body.classList.contains(token));
|
|
121
|
+
if (stale.length > 0) body.classList.remove(...stale);
|
|
122
|
+
if (missing.length > 0) body.classList.add(...missing);
|
|
123
|
+
bodyClasses.current = next;
|
|
124
|
+
}, []);
|
|
125
|
+
const attachBody = useCallback(
|
|
126
|
+
(element: HTMLElement | null) => {
|
|
127
|
+
bodyRef.current = element;
|
|
128
|
+
syncBodyClass();
|
|
129
|
+
},
|
|
130
|
+
[syncBodyClass],
|
|
131
|
+
);
|
|
132
|
+
// The component's classes may follow its props.
|
|
133
|
+
useLayoutEffect(syncBodyClass);
|
|
134
|
+
// The fallback card's classes are Conloca's chrome, not the site's.
|
|
135
|
+
const bodyProps = useMemo(() => (SiteComponent ? { ref: attachBody } : undefined), [SiteComponent, attachBody]);
|
|
136
|
+
// The body has its own boundary: a body that fails to load shows the card without a body, where the component's
|
|
137
|
+
// boundary would remount the same failing body in its card forever.
|
|
138
|
+
const editable = hasChildren ? (
|
|
139
|
+
<ComponentBoundary name={name} resetKey="" editable={null}>
|
|
140
|
+
<NestedLexicalEditor<typeof mdastNode>
|
|
141
|
+
getContent={(n) => n.children}
|
|
142
|
+
// An edit to the body is an edit to the component: one read without an anchor gets it now. Leaving the body
|
|
143
|
+
// writes it back unedited too, which is no edit.
|
|
144
|
+
getUpdatedMdastNode={(_, children) => {
|
|
145
|
+
const current = bindings.current.node;
|
|
146
|
+
const edited = contentOf(children) !== contentOf(current.children);
|
|
147
|
+
const next = withChildren(
|
|
148
|
+
{ ...current, attributes: edited ? withAnchor(current.attributes) : current.attributes },
|
|
149
|
+
children,
|
|
150
|
+
);
|
|
151
|
+
bindings.current.node = next;
|
|
152
|
+
return next;
|
|
153
|
+
}}
|
|
154
|
+
block={block}
|
|
155
|
+
contentEditableProps={bodyProps}
|
|
156
|
+
/>
|
|
157
|
+
</ComponentBoundary>
|
|
158
|
+
) : null;
|
|
159
|
+
|
|
160
|
+
const blockKey = lexicalNode.getKey();
|
|
161
|
+
const publish = useCallback(() => {
|
|
162
|
+
if (!descriptor) return;
|
|
163
|
+
setSelectedBlock({
|
|
164
|
+
key: blockKey,
|
|
165
|
+
name,
|
|
166
|
+
descriptor,
|
|
167
|
+
// readAttrs reads only the attributes, which flow and text elements share.
|
|
168
|
+
attrs: readAttrs({ type: 'mdxJsxFlowElement', name, attributes: bindings.current.node.attributes, children: [] }),
|
|
169
|
+
onPropChange: (propName: string, value: JsonValue | null | undefined) => {
|
|
170
|
+
const current = bindings.current.node;
|
|
171
|
+
const attributes = withAnchor(writeAttribute(current.attributes, propName, value));
|
|
172
|
+
// Until the block re-renders, a second edit in the same tick builds on this one.
|
|
173
|
+
bindings.current.node = { ...current, attributes };
|
|
174
|
+
bindings.current.updater({ attributes });
|
|
175
|
+
},
|
|
176
|
+
onRemove: removeNode,
|
|
177
|
+
});
|
|
178
|
+
}, [descriptor, blockKey, name, removeNode, withAnchor]);
|
|
179
|
+
// A component made in the editor gets its anchor at once. One read from the file keeps its tag as written until it
|
|
180
|
+
// is edited, so opening and saving changes nothing.
|
|
181
|
+
const made = node.type === 'mdxJsxFlowElement' && !node.data?.sourceLayout;
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if (!made) return;
|
|
184
|
+
const attributes = withAnchor(node.attributes);
|
|
185
|
+
if (attributes !== node.attributes) bindings.current.updater({ attributes });
|
|
186
|
+
}, [made, node, withAnchor]);
|
|
187
|
+
const signature = JSON.stringify(node);
|
|
188
|
+
// Keep the panel's attrs current while this block stays selected.
|
|
189
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: republish when the node's content changes.
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
if (getSelectedBlock()?.key === blockKey) publish();
|
|
192
|
+
}, [signature, blockKey]);
|
|
193
|
+
const select = publish;
|
|
194
|
+
|
|
195
|
+
// React never passes `key` as a prop; publish's renderer drops it the same way.
|
|
196
|
+
const { key: _key, ...props } = fragmentComponentProps(node.attributes);
|
|
197
|
+
|
|
198
|
+
return (
|
|
199
|
+
<Wrapper
|
|
200
|
+
className="conloca-fragment-block"
|
|
201
|
+
data-mdx-block={name}
|
|
202
|
+
onFocusCapture={select}
|
|
203
|
+
onClickCapture={(event) => {
|
|
204
|
+
preventLinkNavigation(event);
|
|
205
|
+
select();
|
|
206
|
+
}}
|
|
207
|
+
onAuxClickCapture={preventLinkNavigation}
|
|
208
|
+
onSubmitCapture={preventLinkNavigation}
|
|
209
|
+
>
|
|
210
|
+
{SiteComponent ? (
|
|
211
|
+
<ComponentBoundary name={name} resetKey={JSON.stringify(props)} editable={editable}>
|
|
212
|
+
<SiteComponent {...props}>{editable}</SiteComponent>
|
|
213
|
+
</ComponentBoundary>
|
|
214
|
+
) : (
|
|
215
|
+
<span className="conloca-generic-block__fallback" data-mdx-block={name}>
|
|
216
|
+
<span className="conloca-generic-block__fallback-label">{name}</span>
|
|
217
|
+
{editable}
|
|
218
|
+
</span>
|
|
219
|
+
)}
|
|
220
|
+
</Wrapper>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** What `nodes` say, without where they were read from or the layout they were read in, to tell an edit apart. */
|
|
225
|
+
function contentOf(nodes: readonly Mdast.Nodes[]): string {
|
|
226
|
+
return JSON.stringify(nodes, (key, value) => (key === 'position' || key === 'data' ? undefined : value));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** `node` with the nested editor's children; the editor writes the content kind the element holds. */
|
|
230
|
+
function withChildren<T extends object>(node: T, children: Mdast.RootContent[]): T {
|
|
231
|
+
const next = { ...node };
|
|
232
|
+
return Object.assign(next, { children });
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** The anchors `markdown` already uses, outlined components' and headings': a generated anchor must not take one. */
|
|
236
|
+
function anchorIdsIn(markdown: string, vocabulary: FragmentVocabulary): string[] {
|
|
237
|
+
const outline = vocabulary.outline ?? {};
|
|
238
|
+
let pending: Mdast.Nodes[];
|
|
239
|
+
try {
|
|
240
|
+
pending = [parseFragmentMdx(markdown)];
|
|
241
|
+
} catch {
|
|
242
|
+
return [];
|
|
243
|
+
}
|
|
244
|
+
const ids = fragmentHeadingIds(markdown, vocabulary);
|
|
245
|
+
for (let node = pending.pop(); node !== undefined; node = pending.pop()) {
|
|
246
|
+
const entry = node.type === 'mdxJsxFlowElement' && node.name ? outline[node.name] : undefined;
|
|
247
|
+
const id = entry && node.type === 'mdxJsxFlowElement' ? readStringAttribute(node, entry.id) : '';
|
|
248
|
+
if (id) ids.push(id);
|
|
249
|
+
if ('children' in node) pending.push(...node.children);
|
|
250
|
+
}
|
|
251
|
+
return ids;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** `anchorIdsIn`, parsed only once iterated: `withOutlineId` reads it only when it makes an anchor, not on each edit. */
|
|
255
|
+
function* takenAnchors(markdown: () => string, vocabulary: FragmentVocabulary): Generator<string> {
|
|
256
|
+
yield* anchorIdsIn(markdown(), vocabulary);
|
|
257
|
+
}
|