@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,115 @@
|
|
|
1
|
+
import { getContentAPIClient, useLocalizedContent } from '@conloca/content-api-client';
|
|
2
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { contentWriteOwner } from '../../write-access.js';
|
|
5
|
+
const pendingWrites = new WeakMap();
|
|
6
|
+
/** A request can finish after its editor unmounts; keep its lifetime scoped to the same content client. */
|
|
7
|
+
export function trackFragmentSave(client, id, locale, request) {
|
|
8
|
+
const owner = contentWriteOwner(client);
|
|
9
|
+
const key = JSON.stringify([id, locale]);
|
|
10
|
+
const writes = pendingWrites.get(owner) ?? new Map();
|
|
11
|
+
const requests = writes.get(key) ?? new Set();
|
|
12
|
+
const settled = request.then(() => undefined, () => undefined);
|
|
13
|
+
requests.add(settled);
|
|
14
|
+
writes.set(key, requests);
|
|
15
|
+
pendingWrites.set(owner, writes);
|
|
16
|
+
void settled.then(() => {
|
|
17
|
+
requests.delete(settled);
|
|
18
|
+
if (requests.size === 0)
|
|
19
|
+
writes.delete(key);
|
|
20
|
+
if (writes.size === 0)
|
|
21
|
+
pendingWrites.delete(owner);
|
|
22
|
+
});
|
|
23
|
+
return request;
|
|
24
|
+
}
|
|
25
|
+
/** Wait for every write already sent for this document without retaining its text or treating a rejection as saved. */
|
|
26
|
+
export function pendingFragmentSave(client, id, locale) {
|
|
27
|
+
const requests = pendingWrites.get(contentWriteOwner(client))?.get(JSON.stringify([id, locale]));
|
|
28
|
+
return requests?.size ? Promise.all(requests).then(() => undefined) : null;
|
|
29
|
+
}
|
|
30
|
+
const SAVE_WAIT_TIMEOUT_MS = 30_000;
|
|
31
|
+
const SAVE_WAIT_FAILURE = 'The previous save has not finished. Try again or go back.';
|
|
32
|
+
/** A deadline reports an unknown write outcome; it never forgets or releases that write. */
|
|
33
|
+
export function waitForFragmentSave(pending) {
|
|
34
|
+
if (!pending)
|
|
35
|
+
return Promise.resolve();
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
const timer = setTimeout(() => reject(new Error(SAVE_WAIT_FAILURE)), SAVE_WAIT_TIMEOUT_MS);
|
|
38
|
+
void pending.then(() => {
|
|
39
|
+
clearTimeout(timer);
|
|
40
|
+
resolve();
|
|
41
|
+
}, (error) => {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
reject(error);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** A reopened editor must read after earlier writes settle, before MDX takes its one-time initial value. */
|
|
48
|
+
export function useFragmentContent(id, locale) {
|
|
49
|
+
const client = contentWriteOwner(getContentAPIClient());
|
|
50
|
+
const queryClient = useQueryClient();
|
|
51
|
+
const [snapshot, setSnapshot] = useState(() => ({
|
|
52
|
+
client,
|
|
53
|
+
id,
|
|
54
|
+
locale,
|
|
55
|
+
pending: pendingFragmentSave(client, id, locale),
|
|
56
|
+
}));
|
|
57
|
+
let current = snapshot;
|
|
58
|
+
if (snapshot.client !== client || snapshot.id !== id || snapshot.locale !== locale) {
|
|
59
|
+
current = { client, id, locale, pending: pendingFragmentSave(client, id, locale) };
|
|
60
|
+
setSnapshot(current);
|
|
61
|
+
}
|
|
62
|
+
// This is the arrival snapshot, not a disposable memo: the editor's own later saves cannot unmount its surface.
|
|
63
|
+
const [resolution, setResolution] = useState(null);
|
|
64
|
+
const isSettled = resolution?.arrival === current && resolution.settled;
|
|
65
|
+
const waitError = resolution?.arrival === current ? resolution.waitError : undefined;
|
|
66
|
+
const waitingForSave = !isSettled && (current.pending !== null || resolution?.arrival === current);
|
|
67
|
+
// Even an idle arrival must wait until passive cleanup has revoked the previous editor's flush handler.
|
|
68
|
+
const loaded = useLocalizedContent(isSettled ? id : '', locale);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
// The previous editor can start its first write or queue another after render, before passive cleanup.
|
|
71
|
+
const committedSave = pendingFragmentSave(current.client, current.id, current.locale);
|
|
72
|
+
if (!current.pending && !committedSave && !current.refresh) {
|
|
73
|
+
setResolution({ arrival: current, settled: true });
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
let active = true;
|
|
77
|
+
setResolution({ arrival: current, settled: false });
|
|
78
|
+
void waitForFragmentSave(Promise.all([current.pending, committedSave]).then(() => undefined))
|
|
79
|
+
.then(async () => {
|
|
80
|
+
if (!active)
|
|
81
|
+
return;
|
|
82
|
+
// Cancel an older read and drop its cached snapshot before enabling the fresh read. A failed write may
|
|
83
|
+
// still have reached storage, and a successful reply alone cannot describe a later external write.
|
|
84
|
+
await queryClient.resetQueries({ queryKey: ['content', current.id, current.locale], exact: true });
|
|
85
|
+
if (active)
|
|
86
|
+
setResolution({ arrival: current, settled: true });
|
|
87
|
+
})
|
|
88
|
+
.catch(() => {
|
|
89
|
+
if (active)
|
|
90
|
+
setResolution({ arrival: current, settled: false, waitError: SAVE_WAIT_FAILURE });
|
|
91
|
+
});
|
|
92
|
+
return () => {
|
|
93
|
+
active = false;
|
|
94
|
+
};
|
|
95
|
+
}, [current, queryClient]);
|
|
96
|
+
const retrySaveWait = () => {
|
|
97
|
+
setSnapshot({ client, id, locale, pending: pendingFragmentSave(client, id, locale), refresh: true });
|
|
98
|
+
};
|
|
99
|
+
// Only the same editor's guarded locale handoff may call this, after awaiting old writes and reading the locale.
|
|
100
|
+
const markLocaleLoaded = (nextLocale) => {
|
|
101
|
+
const arrival = { client, id, locale: nextLocale, pending: null };
|
|
102
|
+
setSnapshot(arrival);
|
|
103
|
+
setResolution({ arrival, settled: true });
|
|
104
|
+
};
|
|
105
|
+
return {
|
|
106
|
+
data: loaded.data,
|
|
107
|
+
error: loaded.error,
|
|
108
|
+
isLoading: !isSettled || loaded.isLoading,
|
|
109
|
+
waitingForSave,
|
|
110
|
+
waitError,
|
|
111
|
+
retrySaveWait,
|
|
112
|
+
markLocaleLoaded,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=fragment-save-lifetime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragment-save-lifet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,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC,CAAC;QAChG,CAAC,CAAC,CAAC;QACL,OAAO,GAAG,EAAE;YACV,MAAM,GAAG,KAAK,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;IAE3B,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACvG,CAAC,CAAC;IACF,iHAAiH;IACjH,MAAM,gBAAgB,GAAG,CAAC,UAAkB,EAAE,EAAE;QAC9C,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAClE,WAAW,CAAC,OAAO,CAAC,CAAC;QACrB,aAAa,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS;QACzC,cAAc;QACd,SAAS;QACT,aAAa;QACb,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-wrapper-plugin.d.ts","sourceRoot":"","sources":["../../../../src/components/editor/host-wrapper-plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"host-wrapper-plugin.d.ts","sourceRoot":"","sources":["../../../../src/components/editor/host-wrapper-plugin.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;wEACwE;AACxE,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AA0BD;;;;;;;;;2DAS2D;AAC3D,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;CAC7C;AAoBD,eAAO,MAAM,iBAAiB,2FAM5B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { codeBlockWrapperInfo$ } from '@conloca/mdx';
|
|
2
|
-
import { addEditorWrapper$, Cell, realmPlugin, useCellValue } from '@mdxeditor/editor';
|
|
2
|
+
import { addEditorWrapper$, Cell, contentEditableClassName$, realmPlugin, useCellValue, } from '@mdxeditor/editor';
|
|
3
3
|
import { createElement, Fragment } from 'react';
|
|
4
4
|
/** Private Cell holding the currently-active host wrapper info. The
|
|
5
5
|
* renderer below subscribes to it; the plugin's `update` writes to
|
|
@@ -24,15 +24,28 @@ const HostWrapperRenderer = ({ children }) => {
|
|
|
24
24
|
// HTML elements per JSX semantics.
|
|
25
25
|
return createElement(info.tagName, { className: info.className }, children);
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* The wrapper's classes also go on the contenteditable itself: on the page the
|
|
29
|
+
* prose blocks are the wrapper's own children, so the site's flow rules
|
|
30
|
+
* (`.prose > * + *`, `.prose > p + p`) only reach the editor's blocks from
|
|
31
|
+
* their parent. The clone stays for tag-qualified and descendant selectors;
|
|
32
|
+
* main.css keeps the wrapper's box off the contenteditable so it paints once.
|
|
33
|
+
* Runs after the core plugin, which publishes the editor's own classes first on
|
|
34
|
+
* every init and update, so the wrapper's are added once.
|
|
35
|
+
*/
|
|
36
|
+
function publishWrapper(realm, params) {
|
|
37
|
+
const wrapper = params?.wrapper ?? null;
|
|
38
|
+
realm.pub(hostWrapperInfo$, wrapper);
|
|
39
|
+
realm.pub(codeBlockWrapperInfo$, params?.codeBlockWrapper ?? null);
|
|
40
|
+
if (wrapper?.className) {
|
|
41
|
+
realm.pub(contentEditableClassName$, `${realm.getValue(contentEditableClassName$)} ${wrapper.className}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
27
44
|
export const hostWrapperPlugin = realmPlugin({
|
|
28
45
|
init(realm, params) {
|
|
29
46
|
realm.pub(addEditorWrapper$, HostWrapperRenderer);
|
|
30
|
-
realm
|
|
31
|
-
realm.pub(codeBlockWrapperInfo$, params?.codeBlockWrapper ?? null);
|
|
32
|
-
},
|
|
33
|
-
update(realm, params) {
|
|
34
|
-
realm.pub(hostWrapperInfo$, params?.wrapper ?? null);
|
|
35
|
-
realm.pub(codeBlockWrapperInfo$, params?.codeBlockWrapper ?? null);
|
|
47
|
+
publishWrapper(realm, params);
|
|
36
48
|
},
|
|
49
|
+
update: publishWrapper,
|
|
37
50
|
});
|
|
38
51
|
//# sourceMappingURL=host-wrapper-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-wrapper-plugin.js","sourceRoot":"","sources":["../../../../src/components/editor/host-wrapper-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,
|
|
1
|
+
{"version":3,"file":"host-wrapper-plugin.js","sourceRoot":"","sources":["../../../../src/components/editor/host-wrapper-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EACL,iBAAiB,EACjB,IAAI,EACJ,yBAAyB,EAEzB,WAAW,EACX,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAsB,aAAa,EAAE,QAAQ,EAAqC,MAAM,OAAO,CAAC;AAuCvG;;oDAEoD;AACpD,MAAM,gBAAgB,GAAG,IAAI,CAAyB,IAAI,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,mBAAmB,GAA2C,CAA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
2
2
|
export { CMSMDXEditor } from './CMSMDXEditor.js';
|
|
3
|
-
export { ContentDiff } from './ContentDiff.js';
|
|
4
3
|
export { CreateFragmentDialog } from './CreateFragmentDialog.js';
|
|
5
4
|
export { ImagePickerDialog } from './ImagePickerDialog.js';
|
|
6
5
|
export { LocaleSelector } from './LocaleSelector.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/editor/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/editor/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { CMSMDXEditor } from './CMSMDXEditor.js';
|
|
2
|
-
export { ContentDiff } from './ContentDiff.js';
|
|
3
2
|
export { CreateFragmentDialog } from './CreateFragmentDialog.js';
|
|
4
3
|
export { ImagePickerDialog } from './ImagePickerDialog.js';
|
|
5
4
|
export { LocaleSelector } from './LocaleSelector.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/editor/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/editor/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InsertMdxComponentButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/editor/insert-menu/InsertMdxComponentButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InsertMdxComponentButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/editor/insert-menu/InsertMdxComponentButton.tsx"],"names":[],"mappings":"AA0CA;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,uCAyFvC"}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// IMPORTANT: Import gurx hooks from @mdxeditor/editor, NOT from @mdxeditor/gurx directly.
|
|
3
|
-
// @mdxeditor/editor re-exports gurx, and using that ensures we get the same module instance
|
|
4
|
-
// as the editor internals, avoiding React context isolation issues.
|
|
5
|
-
import { usePublisher } from '@mdxeditor/editor';
|
|
6
2
|
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
|
|
7
3
|
import { Plus } from 'lucide-react';
|
|
8
4
|
import { useMemo } from 'react';
|
|
9
|
-
import {
|
|
10
|
-
import { dispatchInsert,
|
|
5
|
+
import { useOfferedMdxComponents } from '../offered-mdx-components.js';
|
|
6
|
+
import { dispatchInsert, useInsertPublishers } from './insert-payload.js';
|
|
11
7
|
/**
|
|
12
8
|
* Group descriptors by `insert.category`. Descriptors with no category land
|
|
13
9
|
* in the leading ungrouped bucket so the dropdown still feels flat when no
|
|
@@ -53,9 +49,8 @@ function groupByCategory(descriptors) {
|
|
|
53
49
|
* components and snippets sees them sectioned (e.g. "Components" / "Patterns").
|
|
54
50
|
*/
|
|
55
51
|
export function InsertMdxComponentButton() {
|
|
56
|
-
const allComponents =
|
|
57
|
-
const
|
|
58
|
-
const publishMarkdown = usePublisher(insertMarkdown$);
|
|
52
|
+
const allComponents = useOfferedMdxComponents();
|
|
53
|
+
const publishers = useInsertPublishers();
|
|
59
54
|
const groups = useMemo(() => {
|
|
60
55
|
const visible = allComponents
|
|
61
56
|
.filter((d) => {
|
|
@@ -84,8 +79,8 @@ export function InsertMdxComponentButton() {
|
|
|
84
79
|
if (total === 0)
|
|
85
80
|
return null;
|
|
86
81
|
const onSelect = (descriptor) => {
|
|
87
|
-
dispatchInsert(descriptor,
|
|
82
|
+
dispatchInsert(descriptor, publishers);
|
|
88
83
|
};
|
|
89
|
-
return (_jsxs(DropdownMenu.Root, { children: [_jsx(DropdownMenu.Trigger, { asChild: true, children: _jsx("button", { type: "button", "aria-label": "Insert component", title: "Insert component", className: "inline-flex items-center justify-center h-7 w-7 rounded hover:bg-hover", children: _jsx(Plus, { size: 16, "aria-hidden": true }) }) }), _jsx(DropdownMenu.Portal, { children: _jsx(DropdownMenu.Content, { sideOffset: 4, align: "start", className: "z-50 min-w-[14rem] max-h-
|
|
84
|
+
return (_jsxs(DropdownMenu.Root, { children: [_jsx(DropdownMenu.Trigger, { asChild: true, children: _jsx("button", { type: "button", "aria-label": "Insert component", title: "Insert component", className: "inline-flex items-center justify-center h-7 w-7 rounded hover:bg-hover", children: _jsx(Plus, { size: 16, "aria-hidden": true }) }) }), _jsx(DropdownMenu.Portal, { children: _jsx(DropdownMenu.Content, { sideOffset: 4, align: "start", className: "scrollbar-visible z-50 min-w-[14rem] max-h-[min(18rem,var(--radix-dropdown-menu-content-available-height))] overflow-auto rounded-md border border-line bg-panel shadow-md py-1 text-sm text-foreground", children: groups.map((group, groupIndex) => (_jsxs("div", { children: [group.category ? (_jsx(DropdownMenu.Label, { className: "px-3 pt-2 pb-1 text-[10px] uppercase tracking-wide text-muted", children: group.category })) : null, group.descriptors.map((descriptor) => (_jsxs(DropdownMenu.Item, { onSelect: () => onSelect(descriptor), className: "block px-3 py-1.5 cursor-default outline-none data-[highlighted]:bg-selected", children: [_jsx("div", { className: "font-medium", children: descriptor.insert?.label ?? descriptor.name }), descriptor.insert?.description ? (_jsx("div", { className: "text-xs text-muted", children: descriptor.insert.description })) : null] }, descriptor.name))), groupIndex < groups.length - 1 ? _jsx(DropdownMenu.Separator, { className: "my-1 h-px bg-hover" }) : null] }, group.category || '__ungrouped__'))) }) })] }));
|
|
90
85
|
}
|
|
91
86
|
//# sourceMappingURL=InsertMdxComponentButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InsertMdxComponentButton.js","sourceRoot":"","sources":["../../../../../src/components/editor/insert-menu/InsertMdxComponentButton.tsx"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"InsertMdxComponentButton.js","sourceRoot":"","sources":["../../../../../src/components/editor/insert-menu/InsertMdxComponentButton.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAQ1E;;;;;GAKG;AACH,SAAS,eAAe,CAAC,WAAqC;IAC5D,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoC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E,CAAC,EACb,KAAK,EAAC,OAAO,EACb,SAAS,EAAC,yMAAyM,YAElN,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC,CACjC,0BACG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAChB,KAAC,YAAY,CAAC,KAAK,IAAC,SAAS,EAAC,+DAA+D,YAC1F,KAAK,CAAC,QAAQ,GACI,CACtB,CAAC,CAAC,CAAC,IAAI,EACP,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CACrC,MAAC,YAAY,CAAC,IAAI,IAEhB,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EACpC,SAAS,EAAC,8EAA8E,aAExF,cAAK,SAAS,EAAC,aAAa,YAAE,UAAU,CAAC,MAAM,EAAE,KAAK,IAAI,UAAU,CAAC,IAAI,GAAO,EAC/E,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAChC,cAAK,SAAS,EAAC,oBAAoB,YAAE,UAAU,CAAC,MAAM,CAAC,WAAW,GAAO,CAC1E,CAAC,CAAC,CAAC,IAAI,KAPH,UAAU,CAAC,IAAI,CAQF,CACrB,CAAC,EACD,UAAU,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAC,YAAY,CAAC,SAAS,IAAC,SAAS,EAAC,oBAAoB,GAAG,CAAC,CAAC,CAAC,IAAI,KAlB1F,KAAK,CAAC,QAAQ,IAAI,eAAe,CAmBrC,CACP,CAAC,GACmB,GACH,IACJ,CACrB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlashMenuPlugin.d.ts","sourceRoot":"","sources":["../../../../../src/components/editor/insert-menu/SlashMenuPlugin.tsx"],"names":[],"mappings":"AAgCA;;;;;;;;;GASG;AACH,wBAAgB,eAAe,
|
|
1
|
+
{"version":3,"file":"SlashMenuPlugin.d.ts","sourceRoot":"","sources":["../../../../../src/components/editor/insert-menu/SlashMenuPlugin.tsx"],"names":[],"mappings":"AAgCA;;;;;;;;;GASG;AACH,wBAAgB,eAAe,uCA2G9B"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { LexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
3
|
import { LexicalTypeaheadMenuPlugin, MenuOption, useBasicTypeaheadTriggerMatch, } from '@lexical/react/LexicalTypeaheadMenuPlugin';
|
|
4
|
-
import {
|
|
5
|
-
import { useCallback, useContext, useMemo, useState } from 'react';
|
|
4
|
+
import { useCallback, useContext, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
6
5
|
import { createPortal } from 'react-dom';
|
|
7
|
-
import {
|
|
8
|
-
import { dispatchInsert,
|
|
6
|
+
import { useOfferedMdxComponents } from '../offered-mdx-components.js';
|
|
7
|
+
import { dispatchInsert, useInsertPublishers } from './insert-payload.js';
|
|
9
8
|
class MdxComponentOption extends MenuOption {
|
|
10
9
|
descriptor;
|
|
11
10
|
constructor(descriptor) {
|
|
@@ -48,9 +47,8 @@ export function SlashMenuPlugin() {
|
|
|
48
47
|
// to re-render with a populated context.
|
|
49
48
|
const ctx = useContext(LexicalComposerContext);
|
|
50
49
|
const editor = ctx?.[0] ?? null;
|
|
51
|
-
const allComponents =
|
|
52
|
-
const
|
|
53
|
-
const publishMarkdown = usePublisher(insertMarkdown$);
|
|
50
|
+
const allComponents = useOfferedMdxComponents();
|
|
51
|
+
const publishers = useInsertPublishers();
|
|
54
52
|
const [queryString, setQueryString] = useState(null);
|
|
55
53
|
const triggerFn = useBasicTypeaheadTriggerMatch('/', { minLength: 0, maxLength: 32 });
|
|
56
54
|
const options = useMemo(() => {
|
|
@@ -68,8 +66,11 @@ export function SlashMenuPlugin() {
|
|
|
68
66
|
...d,
|
|
69
67
|
insert: { label: d.name, category: d.kind === 'flow' ? 'Components' : 'Patterns' },
|
|
70
68
|
});
|
|
71
|
-
const
|
|
72
|
-
|
|
69
|
+
const query = (queryString ?? '').toLowerCase();
|
|
70
|
+
const exact = (d) => query !== '' && (d.name.toLowerCase() === query || d.insert?.label.toLowerCase() === query);
|
|
71
|
+
// An entry named exactly what the author typed goes first; the rest keep the site's order.
|
|
72
|
+
const matching = visible.filter((d) => matchesQuery(d, query));
|
|
73
|
+
return [...matching.filter(exact), ...matching.filter((d) => !exact(d))].map((d) => new MdxComponentOption(d));
|
|
73
74
|
}, [allComponents, queryString]);
|
|
74
75
|
const onSelectOption = useCallback((option, nodeToReplace, closeMenu) => {
|
|
75
76
|
if (!editor)
|
|
@@ -78,9 +79,9 @@ export function SlashMenuPlugin() {
|
|
|
78
79
|
if (nodeToReplace)
|
|
79
80
|
nodeToReplace.remove();
|
|
80
81
|
});
|
|
81
|
-
dispatchInsert(option.descriptor,
|
|
82
|
+
dispatchInsert(option.descriptor, publishers);
|
|
82
83
|
closeMenu();
|
|
83
|
-
}, [editor,
|
|
84
|
+
}, [editor, publishers]);
|
|
84
85
|
if (!editor)
|
|
85
86
|
return null;
|
|
86
87
|
return (_jsx(LexicalTypeaheadMenuPlugin, { onQueryChange: setQueryString, onSelectOption: onSelectOption, triggerFn: triggerFn, options: options, menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex, options: opts }) => {
|
|
@@ -95,7 +96,7 @@ export function SlashMenuPlugin() {
|
|
|
95
96
|
// CSS that ships its own bare-utility class names. Semantic tokens
|
|
96
97
|
// map to CSS vars the host's Tailwind never generates, so
|
|
97
98
|
// collisions are impossible by construction.
|
|
98
|
-
return createPortal(_jsx(
|
|
99
|
+
return createPortal(_jsx(SlashMenuList, { anchor: anchor, optionCount: opts.length, children: opts.map((opt, index) => {
|
|
99
100
|
const isSelected = selectedIndex === index;
|
|
100
101
|
return (_jsxs("button", { type: "button", ref: (el) => opt.setRefElement(el), role: "option", "aria-selected": isSelected, className: `block w-full text-left px-3 py-1.5 ${isSelected ? 'bg-selected' : 'hover:bg-hover'}`, onMouseDown: (event) => {
|
|
101
102
|
event.preventDefault();
|
|
@@ -104,4 +105,57 @@ export function SlashMenuPlugin() {
|
|
|
104
105
|
}) }), anchor);
|
|
105
106
|
} }));
|
|
106
107
|
}
|
|
108
|
+
/** The tallest the menu gets (Tailwind's `max-h-72`); longer lists scroll inside it. */
|
|
109
|
+
const MENU_MAX_HEIGHT = 288;
|
|
110
|
+
/** Room kept between the menu and the caret, and between the menu and the viewport's edges. */
|
|
111
|
+
const MENU_GAP = 4;
|
|
112
|
+
const VIEWPORT_MARGIN = 8;
|
|
113
|
+
/**
|
|
114
|
+
* Where the menu fits: under the caret, or above it when there is more room there, never past the editor's viewport.
|
|
115
|
+
* Lexical flips its menu only within the editor's own element, a few lines tall in a component's body, so a menu under
|
|
116
|
+
* a body near the bottom of the screen ran past it.
|
|
117
|
+
*/
|
|
118
|
+
function placeMenu(anchor, menu) {
|
|
119
|
+
const doc = anchor.ownerDocument;
|
|
120
|
+
const view = doc.defaultView ?? window;
|
|
121
|
+
const selection = doc.getSelection();
|
|
122
|
+
const range = selection && selection.rangeCount > 0 ? selection.getRangeAt(0).getBoundingClientRect() : null;
|
|
123
|
+
// Lexical's anchor sits a line under the caret; it stands in only when the caret has no box.
|
|
124
|
+
const caret = range && range.height > 0 ? range : anchor.getBoundingClientRect();
|
|
125
|
+
const below = view.innerHeight - caret.bottom - MENU_GAP - VIEWPORT_MARGIN;
|
|
126
|
+
const above = caret.top - MENU_GAP - VIEWPORT_MARGIN;
|
|
127
|
+
const wanted = Math.min(menu.scrollHeight, MENU_MAX_HEIGHT);
|
|
128
|
+
const left = Math.max(VIEWPORT_MARGIN, Math.min(caret.left, view.innerWidth - menu.offsetWidth - VIEWPORT_MARGIN));
|
|
129
|
+
if (below >= wanted || below >= above) {
|
|
130
|
+
return { top: caret.bottom + MENU_GAP, left, maxHeight: Math.min(MENU_MAX_HEIGHT, below) };
|
|
131
|
+
}
|
|
132
|
+
return { bottom: view.innerHeight - caret.top + MENU_GAP, left, maxHeight: Math.min(MENU_MAX_HEIGHT, above) };
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The menu, fixed beside the caret and kept there while anything scrolls or the window resizes. It sits in a plain
|
|
136
|
+
* wrapper because Lexical writes the style of its anchor's first child.
|
|
137
|
+
*/
|
|
138
|
+
function SlashMenuList({ anchor, optionCount, children }) {
|
|
139
|
+
const menuRef = useRef(null);
|
|
140
|
+
const [placement, setPlacement] = useState(null);
|
|
141
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a different number of options changes the menu's height.
|
|
142
|
+
useLayoutEffect(() => {
|
|
143
|
+
const doc = anchor.ownerDocument;
|
|
144
|
+
const view = doc.defaultView ?? window;
|
|
145
|
+
const place = () => {
|
|
146
|
+
if (menuRef.current)
|
|
147
|
+
setPlacement(placeMenu(anchor, menuRef.current));
|
|
148
|
+
};
|
|
149
|
+
place();
|
|
150
|
+
view.addEventListener('resize', place);
|
|
151
|
+
doc.addEventListener('scroll', place, { capture: true, passive: true });
|
|
152
|
+
return () => {
|
|
153
|
+
view.removeEventListener('resize', place);
|
|
154
|
+
doc.removeEventListener('scroll', place, { capture: true });
|
|
155
|
+
};
|
|
156
|
+
}, [anchor, optionCount]);
|
|
157
|
+
return (_jsx("div", { children: _jsx("div", { ref: menuRef, role: "listbox", className: "scrollbar-visible z-50 min-w-[14rem] overflow-auto rounded-md border border-line bg-panel shadow-md py-1 text-sm text-foreground",
|
|
158
|
+
// Hidden at the top left for the first measurement, before the layout effect places it.
|
|
159
|
+
style: { position: 'fixed', ...(placement ?? { top: 0, left: 0, visibility: 'hidden' }) }, "data-slash-menu": true, children: children }) }));
|
|
160
|
+
}
|
|
107
161
|
//# sourceMappingURL=SlashMenuPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlashMenuPlugin.js","sourceRoot":"","sources":["../../../../../src/components/editor/insert-menu/SlashMenuPlugin.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EACL,0BAA0B,EAC1B,UAAU,EACV,6BAA6B,GAC9B,MAAM,2CAA2C,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"SlashMenuPlugin.js","sourceRoot":"","sources":["../../../../../src/components/editor/insert-menu/SlashMenuPlugin.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EACL,0BAA0B,EAC1B,UAAU,EACV,6BAA6B,GAC9B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAkB,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5G,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1E,MAAM,kBAAmB,SAAQ,UAAU;IACtB,UAAU;IAA7B,YAAmB,UAAkC;QACnD,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;0BADN,UAAU;IAE7B,CAAC;CACF;AAED,SAAS,YAAY,CAAC,UAAkC,EAAE,KAAa;IACrE,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAC9B,MAAM,QAAQ,GAAG;QACf,UAAU,CAAC,IAAI;QACf,UAAU,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;QAC9B,UAAU,CAAC,MAAM,EAAE,WAAW,IAAI,EAAE;QACpC,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,IAAI,EAAE,CAAC;KACvC;SACE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,CAAC,CAAC;QACvC,GAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACxE,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC1C,GAAG,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IAC1B,OAAO,CACL,wBACE,cACE,GAAG,EAAE,OAAO,EACZ,IAAI,EAAC,SAAS,EACd,SAAS,EAAC,kIAAkI;YAC5I,wFAAwF;YACxF,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,EAAE,qCAGxF,QAAQ,GACL,GACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type JsonValue } from '@conloca/mdx/render';
|
|
2
2
|
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
3
3
|
import { type MdxComponentDescriptor, type MdxJsxComponentDescriptor } from '../../../mdx-components.js';
|
|
4
4
|
type InsertJsxAttrValue = string | {
|
|
@@ -31,30 +31,30 @@ export type InsertJsxPayload = {
|
|
|
31
31
|
* Build the payload accepted by @mdxeditor/editor's `insertJsx$` signal.
|
|
32
32
|
*
|
|
33
33
|
* Strings round-trip as plain attributes; numbers/booleans become
|
|
34
|
-
* expression attributes (`{2}`, `{true}`)
|
|
35
|
-
* `mdxJsxAttribute.value` shape is
|
|
36
|
-
* `{ type: 'expression', value: string }` object.
|
|
34
|
+
* expression attributes (`{2}`, `{true}`) and lists/objects JSON
|
|
35
|
+
* expressions, because the upstream `mdxJsxAttribute.value` shape is
|
|
36
|
+
* either a string or an `{ type: 'expression', value: string }` object.
|
|
37
37
|
*
|
|
38
|
-
* `descriptor.defaults.children` is parsed
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* author build the body via in-place editing.
|
|
38
|
+
* `descriptor.defaults.children` is parsed by `parseFragmentMdx`, the parse
|
|
39
|
+
* the save check reads a fragment with, so component tags in a default
|
|
40
|
+
* become JSX nodes exactly as they would in a loaded fragment.
|
|
42
41
|
*/
|
|
43
|
-
export declare function buildInsertPayload(descriptor: MdxJsxComponentDescriptor, overrides?: Record<string,
|
|
42
|
+
export declare function buildInsertPayload(descriptor: MdxJsxComponentDescriptor, overrides?: Record<string, JsonValue>): InsertJsxPayload;
|
|
44
43
|
/** Whether the JSX descriptor has any required props the inserter must prompt for. */
|
|
45
44
|
export declare function hasRequiredProps(descriptor: MdxJsxComponentDescriptor): boolean;
|
|
46
45
|
/**
|
|
47
|
-
* Publisher bundle accepted by `dispatchInsert
|
|
48
|
-
*
|
|
49
|
-
* (hooks can't be conditional) and pass the pair in; the dispatcher then
|
|
50
|
-
* routes by descriptor kind. Keeping the two publishers together in one
|
|
51
|
-
* value also makes future signal additions a single-line change at the
|
|
52
|
-
* call sites.
|
|
46
|
+
* Publisher bundle accepted by `dispatchInsert`, one per insert signal; the
|
|
47
|
+
* dispatcher routes by descriptor kind.
|
|
53
48
|
*/
|
|
54
49
|
export interface InsertPublishers {
|
|
55
50
|
jsx: (payload: InsertJsxPayload) => void;
|
|
56
51
|
markdown: (value: string) => void;
|
|
57
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* The slash menu's and toolbar's publishers. Each insert lands in the editor the author was last in (a component's
|
|
55
|
+
* body is its own editor), at its caret, or right after the component selected there.
|
|
56
|
+
*/
|
|
57
|
+
export declare function useInsertPublishers(): InsertPublishers;
|
|
58
58
|
/**
|
|
59
59
|
* Insert a descriptor's content into the editor. JSX descriptors go
|
|
60
60
|
* through `insertJsx$` so they land as a proper Lexical decorator node
|
|
@@ -67,10 +67,5 @@ export interface InsertPublishers {
|
|
|
67
67
|
* we don't need the get/rewrite/set dance the previous snippet path used.
|
|
68
68
|
*/
|
|
69
69
|
export declare function dispatchInsert(descriptor: MdxComponentDescriptor, publishers: InsertPublishers): void;
|
|
70
|
-
|
|
71
|
-
* Convenience re-export of the upstream signals so call sites don't need
|
|
72
|
-
* to import them separately. Keeping both signal references in one module
|
|
73
|
-
* also documents which library symbols the insert pipeline depends on.
|
|
74
|
-
*/
|
|
75
|
-
export { insertJsx$, insertMarkdown$ };
|
|
70
|
+
export {};
|
|
76
71
|
//# sourceMappingURL=insert-payload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insert-payload.d.ts","sourceRoot":"","sources":["../../../../../src/components/editor/insert-menu/insert-payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"insert-payload.d.ts","sourceRoot":"","sources":["../../../../../src/components/editor/insert-menu/insert-payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,qBAAqB,CAAC;AAMvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,OAAO,EAGL,KAAK,sBAAsB,EAE3B,KAAK,yBAAyB,EAC/B,MAAM,4BAA4B,CAAC;AAEpC,KAAK,kBAAkB,GAAG,MAAM,GAAG;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAEzD;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GACxB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAA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