@conloca/cms-spa 0.2.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/spa/main.css +262 -21
- package/dist/ts/.build-inputs.json +99 -57
- package/dist/ts/CmsSpaApp.d.ts +4 -6
- package/dist/ts/CmsSpaApp.d.ts.map +1 -1
- package/dist/ts/CmsSpaApp.js +19 -8
- package/dist/ts/CmsSpaApp.js.map +1 -1
- package/dist/ts/components/conflicts/EditorNoticeStrip.d.ts +44 -0
- package/dist/ts/components/conflicts/EditorNoticeStrip.d.ts.map +1 -0
- package/dist/ts/components/conflicts/EditorNoticeStrip.js +55 -0
- package/dist/ts/components/conflicts/EditorNoticeStrip.js.map +1 -0
- package/dist/ts/components/conflicts/FieldConflictList.d.ts +20 -0
- package/dist/ts/components/conflicts/FieldConflictList.d.ts.map +1 -0
- package/dist/ts/components/conflicts/FieldConflictList.js +14 -0
- package/dist/ts/components/conflicts/FieldConflictList.js.map +1 -0
- package/dist/ts/components/conflicts/FieldConflictPicker.d.ts +28 -0
- package/dist/ts/components/conflicts/FieldConflictPicker.d.ts.map +1 -0
- package/dist/ts/components/conflicts/FieldConflictPicker.js +52 -0
- package/dist/ts/components/conflicts/FieldConflictPicker.js.map +1 -0
- package/dist/ts/components/conflicts/OverwriteNotice.d.ts +11 -0
- package/dist/ts/components/conflicts/OverwriteNotice.d.ts.map +1 -0
- package/dist/ts/components/conflicts/OverwriteNotice.js +8 -0
- package/dist/ts/components/conflicts/OverwriteNotice.js.map +1 -0
- package/dist/ts/components/conflicts/PageDraftMenu.d.ts +11 -0
- package/dist/ts/components/conflicts/PageDraftMenu.d.ts.map +1 -0
- package/dist/ts/components/conflicts/PageDraftMenu.js +20 -0
- package/dist/ts/components/conflicts/PageDraftMenu.js.map +1 -0
- package/dist/ts/components/conflicts/PeerAvatars.d.ts +9 -0
- package/dist/ts/components/conflicts/PeerAvatars.d.ts.map +1 -0
- package/dist/ts/components/conflicts/PeerAvatars.js +29 -0
- package/dist/ts/components/conflicts/PeerAvatars.js.map +1 -0
- package/dist/ts/components/conflicts/PuckConflicts.d.ts +13 -0
- package/dist/ts/components/conflicts/PuckConflicts.d.ts.map +1 -0
- package/dist/ts/components/conflicts/PuckConflicts.js +59 -0
- package/dist/ts/components/conflicts/PuckConflicts.js.map +1 -0
- package/dist/ts/components/conflicts/RecentVersionsDialog.d.ts +15 -0
- package/dist/ts/components/conflicts/RecentVersionsDialog.d.ts.map +1 -0
- package/dist/ts/components/conflicts/RecentVersionsDialog.js +94 -0
- package/dist/ts/components/conflicts/RecentVersionsDialog.js.map +1 -0
- package/dist/ts/components/conflicts/conflict-label.d.ts +12 -0
- package/dist/ts/components/conflicts/conflict-label.d.ts.map +1 -0
- package/dist/ts/components/conflicts/conflict-label.js +120 -0
- package/dist/ts/components/conflicts/conflict-label.js.map +1 -0
- package/dist/ts/components/conflicts/use-page-conflicts.d.ts +26 -0
- package/dist/ts/components/conflicts/use-page-conflicts.d.ts.map +1 -0
- package/dist/ts/components/conflicts/use-page-conflicts.js +93 -0
- package/dist/ts/components/conflicts/use-page-conflicts.js.map +1 -0
- package/dist/ts/components/conflicts/version-copy.d.ts +7 -0
- package/dist/ts/components/conflicts/version-copy.d.ts.map +1 -0
- package/dist/ts/components/conflicts/version-copy.js +31 -0
- package/dist/ts/components/conflicts/version-copy.js.map +1 -0
- package/dist/ts/components/dashboard/RecentActivity.d.ts.map +1 -1
- package/dist/ts/components/dashboard/RecentActivity.js +2 -1
- package/dist/ts/components/dashboard/RecentActivity.js.map +1 -1
- package/dist/ts/components/dialogs/CreatePageDialog.js +1 -1
- package/dist/ts/components/dialogs/CreatePageDialog.js.map +1 -1
- package/dist/ts/components/dialogs/DataPropertiesDialog.d.ts +2 -1
- package/dist/ts/components/dialogs/DataPropertiesDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/DataPropertiesDialog.js +15 -3
- package/dist/ts/components/dialogs/DataPropertiesDialog.js.map +1 -1
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.d.ts +2 -1
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.js +16 -3
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.js.map +1 -1
- package/dist/ts/components/dialogs/PageMetadataDialog.d.ts +9 -2
- package/dist/ts/components/dialogs/PageMetadataDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/PageMetadataDialog.js +63 -16
- package/dist/ts/components/dialogs/PageMetadataDialog.js.map +1 -1
- package/dist/ts/components/dialogs/UnsavedChangesDialog.d.ts +16 -1
- package/dist/ts/components/dialogs/UnsavedChangesDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/UnsavedChangesDialog.js +90 -2
- package/dist/ts/components/dialogs/UnsavedChangesDialog.js.map +1 -1
- package/dist/ts/components/dialogs/unsaved-guard.d.ts +9 -0
- package/dist/ts/components/dialogs/unsaved-guard.d.ts.map +1 -0
- package/dist/ts/components/dialogs/unsaved-guard.js +14 -0
- package/dist/ts/components/dialogs/unsaved-guard.js.map +1 -0
- package/dist/ts/components/editor/CMSMDXEditor.d.ts +6 -1
- package/dist/ts/components/editor/CMSMDXEditor.d.ts.map +1 -1
- package/dist/ts/components/editor/CMSMDXEditor.js +32 -15
- package/dist/ts/components/editor/CMSMDXEditor.js.map +1 -1
- package/dist/ts/components/editor/EditorFrame.d.ts +22 -0
- package/dist/ts/components/editor/EditorFrame.d.ts.map +1 -0
- package/dist/ts/components/editor/EditorFrame.js +72 -0
- package/dist/ts/components/editor/EditorFrame.js.map +1 -0
- package/dist/ts/components/editor/FragmentBlockTypeSelect.d.ts +10 -0
- package/dist/ts/components/editor/FragmentBlockTypeSelect.d.ts.map +1 -0
- package/dist/ts/components/editor/FragmentBlockTypeSelect.js +187 -0
- package/dist/ts/components/editor/FragmentBlockTypeSelect.js.map +1 -0
- package/dist/ts/components/editor/FragmentComponentBlock.d.ts +7 -0
- package/dist/ts/components/editor/FragmentComponentBlock.d.ts.map +1 -0
- package/dist/ts/components/editor/FragmentComponentBlock.js +180 -0
- package/dist/ts/components/editor/FragmentComponentBlock.js.map +1 -0
- package/dist/ts/components/editor/FragmentEditor.d.ts +3 -1
- package/dist/ts/components/editor/FragmentEditor.d.ts.map +1 -1
- package/dist/ts/components/editor/FragmentEditor.js +545 -130
- package/dist/ts/components/editor/FragmentEditor.js.map +1 -1
- package/dist/ts/components/editor/FragmentEditorHeaderActions.d.ts +20 -0
- package/dist/ts/components/editor/FragmentEditorHeaderActions.d.ts.map +1 -0
- package/dist/ts/components/editor/FragmentEditorHeaderActions.js +49 -0
- package/dist/ts/components/editor/FragmentEditorHeaderActions.js.map +1 -0
- package/dist/ts/components/editor/GenericBlock.d.ts.map +1 -1
- package/dist/ts/components/editor/GenericBlock.js +109 -12
- package/dist/ts/components/editor/GenericBlock.js.map +1 -1
- package/dist/ts/components/editor/InlinePreviewFrame.d.ts +19 -0
- package/dist/ts/components/editor/InlinePreviewFrame.d.ts.map +1 -0
- package/dist/ts/components/editor/InlinePreviewFrame.js +65 -0
- package/dist/ts/components/editor/InlinePreviewFrame.js.map +1 -0
- package/dist/ts/components/editor/JsxPropsPanel.d.ts.map +1 -1
- package/dist/ts/components/editor/JsxPropsPanel.js +62 -2
- package/dist/ts/components/editor/JsxPropsPanel.js.map +1 -1
- package/dist/ts/components/editor/LocaleSelector.d.ts +2 -1
- package/dist/ts/components/editor/LocaleSelector.d.ts.map +1 -1
- package/dist/ts/components/editor/LocaleSelector.js +2 -2
- package/dist/ts/components/editor/LocaleSelector.js.map +1 -1
- package/dist/ts/components/editor/MDXLivePreview.d.ts +2 -0
- package/dist/ts/components/editor/MDXLivePreview.d.ts.map +1 -1
- package/dist/ts/components/editor/MDXLivePreview.js +30 -38
- package/dist/ts/components/editor/MDXLivePreview.js.map +1 -1
- package/dist/ts/components/editor/MdxPageEditor.d.ts +7 -2
- package/dist/ts/components/editor/MdxPageEditor.d.ts.map +1 -1
- package/dist/ts/components/editor/MdxPageEditor.js +136 -10
- package/dist/ts/components/editor/MdxPageEditor.js.map +1 -1
- package/dist/ts/components/editor/PageEditor.d.ts +4 -1
- package/dist/ts/components/editor/PageEditor.d.ts.map +1 -1
- package/dist/ts/components/editor/PageEditor.js +78 -100
- package/dist/ts/components/editor/PageEditor.js.map +1 -1
- package/dist/ts/components/editor/PageEditorHeaderActions.d.ts +15 -4
- package/dist/ts/components/editor/PageEditorHeaderActions.d.ts.map +1 -1
- package/dist/ts/components/editor/PageEditorHeaderActions.js +13 -7
- package/dist/ts/components/editor/PageEditorHeaderActions.js.map +1 -1
- package/dist/ts/components/editor/PageEditorWrapper.d.ts +8 -2
- package/dist/ts/components/editor/PageEditorWrapper.d.ts.map +1 -1
- package/dist/ts/components/editor/PageEditorWrapper.js +99 -41
- package/dist/ts/components/editor/PageEditorWrapper.js.map +1 -1
- package/dist/ts/components/editor/body-sync-plugin.d.ts +2 -0
- package/dist/ts/components/editor/body-sync-plugin.d.ts.map +1 -0
- package/dist/ts/components/editor/body-sync-plugin.js +32 -0
- package/dist/ts/components/editor/body-sync-plugin.js.map +1 -0
- package/dist/ts/components/editor/draft-media-config.d.ts +6 -0
- package/dist/ts/components/editor/draft-media-config.d.ts.map +1 -1
- package/dist/ts/components/editor/draft-media-config.js +21 -0
- package/dist/ts/components/editor/draft-media-config.js.map +1 -1
- package/dist/ts/components/editor/fragment-save-check.d.ts +7 -0
- package/dist/ts/components/editor/fragment-save-check.d.ts.map +1 -0
- package/dist/ts/components/editor/fragment-save-check.js +13 -0
- package/dist/ts/components/editor/fragment-save-check.js.map +1 -0
- package/dist/ts/components/editor/fragment-save-lifetime.d.ts +18 -0
- package/dist/ts/components/editor/fragment-save-lifetime.d.ts.map +1 -0
- package/dist/ts/components/editor/fragment-save-lifetime.js +115 -0
- package/dist/ts/components/editor/fragment-save-lifetime.js.map +1 -0
- package/dist/ts/components/editor/host-wrapper-plugin.d.ts.map +1 -1
- package/dist/ts/components/editor/host-wrapper-plugin.js +20 -7
- package/dist/ts/components/editor/host-wrapper-plugin.js.map +1 -1
- package/dist/ts/components/editor/index.d.ts +0 -1
- package/dist/ts/components/editor/index.d.ts.map +1 -1
- package/dist/ts/components/editor/index.js +0 -1
- package/dist/ts/components/editor/index.js.map +1 -1
- package/dist/ts/components/editor/insert-menu/InsertMdxComponentButton.d.ts.map +1 -1
- package/dist/ts/components/editor/insert-menu/InsertMdxComponentButton.js +6 -11
- package/dist/ts/components/editor/insert-menu/InsertMdxComponentButton.js.map +1 -1
- package/dist/ts/components/editor/insert-menu/SlashMenuPlugin.d.ts.map +1 -1
- package/dist/ts/components/editor/insert-menu/SlashMenuPlugin.js +66 -12
- package/dist/ts/components/editor/insert-menu/SlashMenuPlugin.js.map +1 -1
- package/dist/ts/components/editor/insert-menu/insert-payload.d.ts +16 -21
- package/dist/ts/components/editor/insert-menu/insert-payload.d.ts.map +1 -1
- package/dist/ts/components/editor/insert-menu/insert-payload.js +75 -22
- package/dist/ts/components/editor/insert-menu/insert-payload.js.map +1 -1
- package/dist/ts/components/editor/insert-menu/mdx-components-plugin.d.ts +3 -1
- package/dist/ts/components/editor/insert-menu/mdx-components-plugin.d.ts.map +1 -1
- package/dist/ts/components/editor/insert-menu/mdx-components-plugin.js +5 -3
- package/dist/ts/components/editor/insert-menu/mdx-components-plugin.js.map +1 -1
- package/dist/ts/components/editor/jsx-layout-plugin.d.ts +25 -0
- package/dist/ts/components/editor/jsx-layout-plugin.d.ts.map +1 -0
- package/dist/ts/components/editor/jsx-layout-plugin.js +77 -0
- package/dist/ts/components/editor/jsx-layout-plugin.js.map +1 -0
- package/dist/ts/components/editor/offered-mdx-components.d.ts +11 -0
- package/dist/ts/components/editor/offered-mdx-components.d.ts.map +1 -0
- package/dist/ts/components/editor/offered-mdx-components.js +27 -0
- package/dist/ts/components/editor/offered-mdx-components.js.map +1 -0
- package/dist/ts/components/editor/page-setting-targets.d.ts.map +1 -1
- package/dist/ts/components/editor/page-setting-targets.js +2 -1
- package/dist/ts/components/editor/page-setting-targets.js.map +1 -1
- package/dist/ts/components/editor/preview-availability.d.ts +16 -1
- package/dist/ts/components/editor/preview-availability.d.ts.map +1 -1
- package/dist/ts/components/editor/preview-availability.js +16 -1
- package/dist/ts/components/editor/preview-availability.js.map +1 -1
- package/dist/ts/components/editor/prop-field-hint.d.ts +13 -0
- package/dist/ts/components/editor/prop-field-hint.d.ts.map +1 -0
- package/dist/ts/components/editor/prop-field-hint.js +70 -0
- package/dist/ts/components/editor/prop-field-hint.js.map +1 -0
- package/dist/ts/components/editor/soft-break-plugin.d.ts +21 -0
- package/dist/ts/components/editor/soft-break-plugin.d.ts.map +1 -0
- package/dist/ts/components/editor/soft-break-plugin.js +52 -0
- package/dist/ts/components/editor/soft-break-plugin.js.map +1 -0
- package/dist/ts/components/editor/use-live-page-settings.d.ts +13 -0
- package/dist/ts/components/editor/use-live-page-settings.d.ts.map +1 -0
- package/dist/ts/components/editor/use-live-page-settings.js +76 -0
- package/dist/ts/components/editor/use-live-page-settings.js.map +1 -0
- package/dist/ts/components/editor/usePagePreview.d.ts +32 -0
- package/dist/ts/components/editor/usePagePreview.d.ts.map +1 -0
- package/dist/ts/components/editor/usePagePreview.js +252 -0
- package/dist/ts/components/editor/usePagePreview.js.map +1 -0
- package/dist/ts/components/editors/DataEditor.d.ts +6 -3
- package/dist/ts/components/editors/DataEditor.d.ts.map +1 -1
- package/dist/ts/components/editors/DataEditor.js +153 -19
- package/dist/ts/components/editors/DataEditor.js.map +1 -1
- package/dist/ts/components/fields/MDXEditField.d.ts +1 -1
- package/dist/ts/components/fields/MDXEditField.js +2 -2
- package/dist/ts/components/fields/MDXEditField.js.map +1 -1
- package/dist/ts/components/forms/SchemaForm.d.ts.map +1 -1
- package/dist/ts/components/forms/SchemaForm.js +1 -9
- package/dist/ts/components/forms/SchemaForm.js.map +1 -1
- package/dist/ts/components/media/AssetDetailSidebar.d.ts.map +1 -1
- package/dist/ts/components/media/AssetDetailSidebar.js +43 -5
- package/dist/ts/components/media/AssetDetailSidebar.js.map +1 -1
- package/dist/ts/components/pages/DataList.d.ts.map +1 -1
- package/dist/ts/components/pages/DataList.js +16 -4
- package/dist/ts/components/pages/DataList.js.map +1 -1
- package/dist/ts/components/pages/FragmentList.d.ts.map +1 -1
- package/dist/ts/components/pages/FragmentList.js +10 -0
- package/dist/ts/components/pages/FragmentList.js.map +1 -1
- package/dist/ts/components/pages/PageList.d.ts.map +1 -1
- package/dist/ts/components/pages/PageList.js +54 -118
- package/dist/ts/components/pages/PageList.js.map +1 -1
- package/dist/ts/components/pages/PageRow.d.ts +21 -0
- package/dist/ts/components/pages/PageRow.d.ts.map +1 -0
- package/dist/ts/components/pages/PageRow.js +70 -0
- package/dist/ts/components/pages/PageRow.js.map +1 -0
- package/dist/ts/components/pages/PageTable.d.ts +21 -0
- package/dist/ts/components/pages/PageTable.d.ts.map +1 -0
- package/dist/ts/components/pages/PageTable.js +12 -0
- package/dist/ts/components/pages/PageTable.js.map +1 -0
- package/dist/ts/components/pages/page-list-model.d.ts +20 -0
- package/dist/ts/components/pages/page-list-model.d.ts.map +1 -0
- package/dist/ts/components/pages/page-list-model.js +78 -0
- package/dist/ts/components/pages/page-list-model.js.map +1 -0
- package/dist/ts/components/puck/MDXContent.d.ts +3 -3
- package/dist/ts/components/puck/MDXContent.d.ts.map +1 -1
- package/dist/ts/components/puck/MDXContent.js +24 -72
- package/dist/ts/components/puck/MDXContent.js.map +1 -1
- package/dist/ts/components/puck/csp-frame-harness.d.ts +14 -0
- package/dist/ts/components/puck/csp-frame-harness.d.ts.map +1 -0
- package/dist/ts/components/puck/csp-frame-harness.js +85 -0
- package/dist/ts/components/puck/csp-frame-harness.js.map +1 -0
- package/dist/ts/components/puck/use-fragment-render.d.ts +9 -0
- package/dist/ts/components/puck/use-fragment-render.d.ts.map +1 -0
- package/dist/ts/components/puck/use-fragment-render.js +70 -0
- package/dist/ts/components/puck/use-fragment-render.js.map +1 -0
- package/dist/ts/components/sandbox/ContentSandbox.d.ts +3 -5
- package/dist/ts/components/sandbox/ContentSandbox.d.ts.map +1 -1
- package/dist/ts/components/sandbox/ContentSandbox.js +6 -8
- package/dist/ts/components/sandbox/ContentSandbox.js.map +1 -1
- package/dist/ts/components/sandbox/frame-runtime.d.ts +1 -1
- package/dist/ts/components/sandbox/frame-runtime.d.ts.map +1 -1
- package/dist/ts/components/sandbox/frame-runtime.js +1 -1
- package/dist/ts/components/sandbox/frame-runtime.js.map +1 -1
- package/dist/ts/components/toast.d.ts +8 -4
- package/dist/ts/components/toast.d.ts.map +1 -1
- package/dist/ts/components/toast.js +6 -1
- package/dist/ts/components/toast.js.map +1 -1
- package/dist/ts/components/ui/Card.d.ts +3 -5
- package/dist/ts/components/ui/Card.d.ts.map +1 -1
- package/dist/ts/components/ui/Card.js +3 -5
- package/dist/ts/components/ui/Card.js.map +1 -1
- package/dist/ts/components/ui/Select.d.ts.map +1 -1
- package/dist/ts/components/ui/Select.js +12 -3
- package/dist/ts/components/ui/Select.js.map +1 -1
- package/dist/ts/draft-tools.d.ts +76 -0
- package/dist/ts/draft-tools.d.ts.map +1 -0
- package/dist/ts/draft-tools.js +2 -0
- package/dist/ts/draft-tools.js.map +1 -0
- package/dist/ts/frame/channel.d.ts +1 -1
- package/dist/ts/frame/channel.d.ts.map +1 -1
- package/dist/ts/frame/channel.js +3 -0
- package/dist/ts/frame/channel.js.map +1 -1
- package/dist/ts/frame/editor-frame.d.ts.map +1 -1
- package/dist/ts/frame/editor-frame.js +188 -30
- package/dist/ts/frame/editor-frame.js.map +1 -1
- package/dist/ts/frame/protocol.d.ts +73 -4
- package/dist/ts/frame/protocol.d.ts.map +1 -1
- package/dist/ts/frame/protocol.js +54 -16
- package/dist/ts/frame/protocol.js.map +1 -1
- package/dist/ts/hooks/useUnsavedChangesGuard.d.ts +5 -3
- package/dist/ts/hooks/useUnsavedChangesGuard.d.ts.map +1 -1
- package/dist/ts/hooks/useUnsavedChangesGuard.js +17 -7
- package/dist/ts/hooks/useUnsavedChangesGuard.js.map +1 -1
- package/dist/ts/host-style-probe.d.ts.map +1 -1
- package/dist/ts/host-style-probe.js +160 -40
- package/dist/ts/host-style-probe.js.map +1 -1
- package/dist/ts/index.d.ts +13 -0
- package/dist/ts/index.d.ts.map +1 -1
- package/dist/ts/index.js +14 -0
- package/dist/ts/index.js.map +1 -1
- package/dist/ts/live/data-binding.d.ts +67 -0
- package/dist/ts/live/data-binding.d.ts.map +1 -0
- package/dist/ts/live/data-binding.js +215 -0
- package/dist/ts/live/data-binding.js.map +1 -0
- package/dist/ts/live/doc-channel.d.ts +74 -0
- package/dist/ts/live/doc-channel.d.ts.map +1 -0
- package/dist/ts/live/doc-channel.js +293 -0
- package/dist/ts/live/doc-channel.js.map +1 -0
- package/dist/ts/live/held-fragment-edits.d.ts +15 -0
- package/dist/ts/live/held-fragment-edits.d.ts.map +1 -0
- package/dist/ts/live/held-fragment-edits.js +47 -0
- package/dist/ts/live/held-fragment-edits.js.map +1 -0
- package/dist/ts/live/markdown-binding.d.ts +54 -0
- package/dist/ts/live/markdown-binding.d.ts.map +1 -0
- package/dist/ts/live/markdown-binding.js +618 -0
- package/dist/ts/live/markdown-binding.js.map +1 -0
- package/dist/ts/live/markdown-live-plugin.d.ts +42 -0
- package/dist/ts/live/markdown-live-plugin.d.ts.map +1 -0
- package/dist/ts/live/markdown-live-plugin.js +918 -0
- package/dist/ts/live/markdown-live-plugin.js.map +1 -0
- package/dist/ts/live/messages.d.ts +142 -0
- package/dist/ts/live/messages.d.ts.map +1 -0
- package/dist/ts/live/messages.js +266 -0
- package/dist/ts/live/messages.js.map +1 -0
- package/dist/ts/live/puck-binding.d.ts +88 -0
- package/dist/ts/live/puck-binding.d.ts.map +1 -0
- package/dist/ts/live/puck-binding.js +467 -0
- package/dist/ts/live/puck-binding.js.map +1 -0
- package/dist/ts/live/undo.d.ts +29 -0
- package/dist/ts/live/undo.d.ts.map +1 -0
- package/dist/ts/live/undo.js +104 -0
- package/dist/ts/live/undo.js.map +1 -0
- package/dist/ts/live/use-live.d.ts +77 -0
- package/dist/ts/live/use-live.d.ts.map +1 -0
- package/dist/ts/live/use-live.js +207 -0
- package/dist/ts/live/use-live.js.map +1 -0
- package/dist/ts/mdx-components-define.d.ts +52 -15
- package/dist/ts/mdx-components-define.d.ts.map +1 -1
- package/dist/ts/mdx-components-define.js +136 -0
- package/dist/ts/mdx-components-define.js.map +1 -1
- package/dist/ts/mdx-components.d.ts +11 -19
- package/dist/ts/mdx-components.d.ts.map +1 -1
- package/dist/ts/mdx-components.js +23 -32
- package/dist/ts/mdx-components.js.map +1 -1
- package/dist/ts/media/AssetScopePill.d.ts.map +1 -1
- package/dist/ts/media/AssetScopePill.js +2 -1
- package/dist/ts/media/AssetScopePill.js.map +1 -1
- package/dist/ts/merge-default-props.d.ts.map +1 -1
- package/dist/ts/merge-default-props.js +3 -0
- package/dist/ts/merge-default-props.js.map +1 -1
- package/dist/ts/selected-block.d.ts +27 -2
- package/dist/ts/selected-block.d.ts.map +1 -1
- package/dist/ts/selected-block.js +43 -1
- package/dist/ts/selected-block.js.map +1 -1
- package/dist/ts/site-render.d.ts +60 -0
- package/dist/ts/site-render.d.ts.map +1 -0
- package/dist/ts/site-render.js +87 -0
- package/dist/ts/site-render.js.map +1 -0
- package/dist/ts/types.d.ts +3 -0
- package/dist/ts/types.d.ts.map +1 -1
- package/dist/ts/ui-config.d.ts +29 -13
- package/dist/ts/ui-config.d.ts.map +1 -1
- package/dist/ts/ui-config.js +14 -3
- package/dist/ts/ui-config.js.map +1 -1
- package/dist/ts/utils/apply-clash.d.ts +44 -0
- package/dist/ts/utils/apply-clash.d.ts.map +1 -0
- package/dist/ts/utils/apply-clash.js +102 -0
- package/dist/ts/utils/apply-clash.js.map +1 -0
- package/dist/ts/utils/mdast-tree.d.ts +5 -7
- package/dist/ts/utils/mdast-tree.d.ts.map +1 -1
- package/dist/ts/utils/mdast-tree.js +8 -13
- package/dist/ts/utils/mdast-tree.js.map +1 -1
- package/dist/ts/utils/pageMetadata.d.ts +6 -2
- package/dist/ts/utils/pageMetadata.d.ts.map +1 -1
- package/dist/ts/utils/pageMetadata.js +25 -7
- package/dist/ts/utils/pageMetadata.js.map +1 -1
- package/dist/ts/utils/schema-fields.d.ts +2 -0
- package/dist/ts/utils/schema-fields.d.ts.map +1 -1
- package/dist/ts/utils/schema-fields.js +8 -0
- package/dist/ts/utils/schema-fields.js.map +1 -1
- package/dist/ts/write-access.d.ts +2 -0
- package/dist/ts/write-access.d.ts.map +1 -1
- package/dist/ts/write-access.js +9 -4
- package/dist/ts/write-access.js.map +1 -1
- package/package.json +18 -7
- package/src/CmsSpaApp.tsx +20 -11
- package/src/components/conflicts/EditorNoticeStrip.tsx +135 -0
- package/src/components/conflicts/FieldConflictList.tsx +59 -0
- package/src/components/conflicts/FieldConflictPicker.tsx +158 -0
- package/src/components/conflicts/OverwriteNotice.tsx +30 -0
- package/src/components/conflicts/PageDraftMenu.tsx +51 -0
- package/src/components/conflicts/PeerAvatars.tsx +51 -0
- package/src/components/conflicts/PuckConflicts.tsx +92 -0
- package/src/components/conflicts/RecentVersionsDialog.tsx +154 -0
- package/src/components/conflicts/conflict-label.ts +124 -0
- package/src/components/conflicts/use-page-conflicts.ts +112 -0
- package/src/components/conflicts/version-copy.ts +33 -0
- package/src/components/dashboard/RecentActivity.tsx +3 -2
- package/src/components/dialogs/CreatePageDialog.tsx +1 -1
- package/src/components/dialogs/DataPropertiesDialog.tsx +22 -4
- package/src/components/dialogs/FragmentPropertiesDialog.tsx +23 -4
- package/src/components/dialogs/PageMetadataDialog.tsx +157 -65
- package/src/components/dialogs/UnsavedChangesDialog.tsx +171 -21
- package/src/components/dialogs/unsaved-guard.ts +15 -0
- package/src/components/editor/CMSMDXEditor.tsx +238 -198
- package/src/components/editor/EditorFrame.tsx +116 -0
- package/src/components/editor/FragmentBlockTypeSelect.tsx +245 -0
- package/src/components/editor/FragmentComponentBlock.tsx +257 -0
- package/src/components/editor/FragmentEditor.tsx +899 -213
- package/src/components/editor/FragmentEditorHeaderActions.tsx +77 -0
- package/src/components/editor/GenericBlock.tsx +127 -16
- package/src/components/editor/InlinePreviewFrame.tsx +78 -0
- package/src/components/editor/JsxPropsPanel.tsx +90 -6
- package/src/components/editor/LocaleSelector.tsx +4 -2
- package/src/components/editor/MDXLivePreview.tsx +44 -46
- package/src/components/editor/MdxPageEditor.tsx +247 -7
- package/src/components/editor/PageEditor.tsx +154 -121
- package/src/components/editor/PageEditorHeaderActions.tsx +65 -27
- package/src/components/editor/PageEditorWrapper.tsx +122 -45
- package/src/components/editor/body-sync-plugin.ts +44 -0
- package/src/components/editor/draft-media-config.ts +22 -0
- package/src/components/editor/fragment-save-check.ts +26 -0
- package/src/components/editor/fragment-save-lifetime.ts +142 -0
- package/src/components/editor/host-wrapper-plugin.ts +28 -7
- package/src/components/editor/index.ts +0 -1
- package/src/components/editor/insert-menu/InsertMdxComponentButton.tsx +7 -11
- package/src/components/editor/insert-menu/SlashMenuPlugin.tsx +95 -18
- package/src/components/editor/insert-menu/insert-payload.ts +79 -30
- package/src/components/editor/insert-menu/mdx-components-plugin.ts +5 -3
- package/src/components/editor/jsx-layout-plugin.ts +103 -0
- package/src/components/editor/offered-mdx-components.ts +35 -0
- package/src/components/editor/page-setting-targets.tsx +2 -0
- package/src/components/editor/preview-availability.ts +21 -1
- package/src/components/editor/prop-field-hint.ts +75 -0
- package/src/components/editor/soft-break-plugin.ts +55 -0
- package/src/components/editor/use-live-page-settings.ts +80 -0
- package/src/components/editor/usePagePreview.ts +291 -0
- package/src/components/editors/DataEditor.tsx +257 -22
- package/src/components/fields/MDXEditField.tsx +2 -2
- package/src/components/forms/SchemaForm.tsx +1 -10
- package/src/components/media/AssetDetailSidebar.tsx +47 -6
- package/src/components/pages/DataList.tsx +14 -4
- package/src/components/pages/FragmentList.tsx +8 -0
- package/src/components/pages/PageList.tsx +90 -337
- package/src/components/pages/PageRow.tsx +290 -0
- package/src/components/pages/PageTable.tsx +71 -0
- package/src/components/pages/page-list-model.ts +98 -0
- package/src/components/puck/MDXContent.tsx +37 -113
- package/src/components/puck/csp-frame-harness.tsx +99 -0
- package/src/components/puck/use-fragment-render.ts +82 -0
- package/src/components/sandbox/ContentSandbox.tsx +6 -11
- package/src/components/sandbox/frame-runtime.ts +0 -2
- package/src/components/toast.tsx +23 -5
- package/src/components/ui/Card.tsx +3 -5
- package/src/components/ui/Select.tsx +14 -6
- package/src/draft-tools.ts +77 -0
- package/src/frame/channel.ts +3 -1
- package/src/frame/editor-frame.ts +210 -30
- package/src/frame/protocol.ts +98 -15
- package/src/hooks/useUnsavedChangesGuard.ts +17 -6
- package/src/host-style-probe.ts +157 -37
- package/src/index.ts +90 -0
- package/src/live/data-binding.ts +252 -0
- package/src/live/doc-channel.ts +343 -0
- package/src/live/held-fragment-edits.ts +47 -0
- package/src/live/markdown-binding.ts +630 -0
- package/src/live/markdown-live-plugin.tsx +1037 -0
- package/src/live/messages.ts +370 -0
- package/src/live/puck-binding.tsx +579 -0
- package/src/live/undo.ts +112 -0
- package/src/live/use-live.ts +264 -0
- package/src/main.css +184 -4
- package/src/mdx-components-define.ts +170 -24
- package/src/mdx-components.ts +29 -30
- package/src/media/AssetScopePill.tsx +2 -1
- package/src/merge-default-props.ts +4 -0
- package/src/selected-block.ts +55 -3
- package/src/site-render.ts +146 -0
- package/src/types.ts +3 -0
- package/src/ui-config.ts +51 -15
- package/src/utils/apply-clash.ts +113 -0
- package/src/utils/mdast-tree.ts +8 -12
- package/src/utils/pageMetadata.ts +25 -7
- package/src/utils/schema-fields.ts +9 -0
- package/src/write-access.ts +10 -4
- package/styles/tailwind-theme.css +11 -0
- package/dist/ts/components/editor/ContentDiff.d.ts +0 -10
- package/dist/ts/components/editor/ContentDiff.d.ts.map +0 -1
- package/dist/ts/components/editor/ContentDiff.js +0 -52
- package/dist/ts/components/editor/ContentDiff.js.map +0 -1
- package/src/components/editor/ContentDiff.tsx +0 -251
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
MenuOption,
|
|
5
5
|
useBasicTypeaheadTriggerMatch,
|
|
6
6
|
} from '@lexical/react/LexicalTypeaheadMenuPlugin';
|
|
7
|
-
import {
|
|
8
|
-
import { useCallback, useContext, useMemo, useState } from 'react';
|
|
7
|
+
import { type ReactNode, useCallback, useContext, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
9
8
|
import { createPortal } from 'react-dom';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import type { MdxComponentDescriptor } from '../../../mdx-components.js';
|
|
10
|
+
import { useOfferedMdxComponents } from '../offered-mdx-components.js';
|
|
11
|
+
import { dispatchInsert, useInsertPublishers } from './insert-payload.js';
|
|
12
12
|
|
|
13
13
|
class MdxComponentOption extends MenuOption {
|
|
14
14
|
constructor(public descriptor: MdxComponentDescriptor) {
|
|
@@ -51,9 +51,8 @@ export function SlashMenuPlugin() {
|
|
|
51
51
|
// to re-render with a populated context.
|
|
52
52
|
const ctx = useContext(LexicalComposerContext);
|
|
53
53
|
const editor = ctx?.[0] ?? null;
|
|
54
|
-
const allComponents =
|
|
55
|
-
const
|
|
56
|
-
const publishMarkdown = usePublisher(insertMarkdown$);
|
|
54
|
+
const allComponents = useOfferedMdxComponents();
|
|
55
|
+
const publishers = useInsertPublishers();
|
|
57
56
|
const [queryString, setQueryString] = useState<string | null>(null);
|
|
58
57
|
|
|
59
58
|
const triggerFn = useBasicTypeaheadTriggerMatch('/', { minLength: 0, maxLength: 32 });
|
|
@@ -75,8 +74,12 @@ export function SlashMenuPlugin() {
|
|
|
75
74
|
insert: { label: d.name, category: d.kind === 'flow' ? 'Components' : 'Patterns' },
|
|
76
75
|
},
|
|
77
76
|
);
|
|
78
|
-
const
|
|
79
|
-
|
|
77
|
+
const query = (queryString ?? '').toLowerCase();
|
|
78
|
+
const exact = (d: MdxComponentDescriptor) =>
|
|
79
|
+
query !== '' && (d.name.toLowerCase() === query || d.insert?.label.toLowerCase() === query);
|
|
80
|
+
// An entry named exactly what the author typed goes first; the rest keep the site's order.
|
|
81
|
+
const matching = visible.filter((d) => matchesQuery(d, query));
|
|
82
|
+
return [...matching.filter(exact), ...matching.filter((d) => !exact(d))].map((d) => new MdxComponentOption(d));
|
|
80
83
|
}, [allComponents, queryString]);
|
|
81
84
|
|
|
82
85
|
const onSelectOption = useCallback(
|
|
@@ -85,10 +88,10 @@ export function SlashMenuPlugin() {
|
|
|
85
88
|
editor.update(() => {
|
|
86
89
|
if (nodeToReplace) nodeToReplace.remove();
|
|
87
90
|
});
|
|
88
|
-
dispatchInsert(option.descriptor,
|
|
91
|
+
dispatchInsert(option.descriptor, publishers);
|
|
89
92
|
closeMenu();
|
|
90
93
|
},
|
|
91
|
-
[editor,
|
|
94
|
+
[editor, publishers],
|
|
92
95
|
);
|
|
93
96
|
|
|
94
97
|
if (!editor) return null;
|
|
@@ -114,12 +117,7 @@ export function SlashMenuPlugin() {
|
|
|
114
117
|
// map to CSS vars the host's Tailwind never generates, so
|
|
115
118
|
// collisions are impossible by construction.
|
|
116
119
|
return createPortal(
|
|
117
|
-
<
|
|
118
|
-
role="listbox"
|
|
119
|
-
className="z-50 min-w-[14rem] max-h-72 overflow-auto rounded-md border border-line bg-panel shadow-md py-1 text-sm text-foreground"
|
|
120
|
-
style={{ position: 'absolute', top: '100%', left: 0 }}
|
|
121
|
-
data-slash-menu
|
|
122
|
-
>
|
|
120
|
+
<SlashMenuList anchor={anchor} optionCount={opts.length}>
|
|
123
121
|
{opts.map((opt, index) => {
|
|
124
122
|
const isSelected = selectedIndex === index;
|
|
125
123
|
return (
|
|
@@ -143,10 +141,89 @@ export function SlashMenuPlugin() {
|
|
|
143
141
|
</button>
|
|
144
142
|
);
|
|
145
143
|
})}
|
|
146
|
-
</
|
|
144
|
+
</SlashMenuList>,
|
|
147
145
|
anchor,
|
|
148
146
|
);
|
|
149
147
|
}}
|
|
150
148
|
/>
|
|
151
149
|
);
|
|
152
150
|
}
|
|
151
|
+
|
|
152
|
+
/** The tallest the menu gets (Tailwind's `max-h-72`); longer lists scroll inside it. */
|
|
153
|
+
const MENU_MAX_HEIGHT = 288;
|
|
154
|
+
/** Room kept between the menu and the caret, and between the menu and the viewport's edges. */
|
|
155
|
+
const MENU_GAP = 4;
|
|
156
|
+
const VIEWPORT_MARGIN = 8;
|
|
157
|
+
|
|
158
|
+
interface MenuPlacement {
|
|
159
|
+
top?: number;
|
|
160
|
+
bottom?: number;
|
|
161
|
+
left: number;
|
|
162
|
+
maxHeight: number;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Where the menu fits: under the caret, or above it when there is more room there, never past the editor's viewport.
|
|
167
|
+
* Lexical flips its menu only within the editor's own element, a few lines tall in a component's body, so a menu under
|
|
168
|
+
* a body near the bottom of the screen ran past it.
|
|
169
|
+
*/
|
|
170
|
+
function placeMenu(anchor: HTMLElement, menu: HTMLElement): MenuPlacement {
|
|
171
|
+
const doc = anchor.ownerDocument;
|
|
172
|
+
const view = doc.defaultView ?? window;
|
|
173
|
+
const selection = doc.getSelection();
|
|
174
|
+
const range = selection && selection.rangeCount > 0 ? selection.getRangeAt(0).getBoundingClientRect() : null;
|
|
175
|
+
// Lexical's anchor sits a line under the caret; it stands in only when the caret has no box.
|
|
176
|
+
const caret = range && range.height > 0 ? range : anchor.getBoundingClientRect();
|
|
177
|
+
const below = view.innerHeight - caret.bottom - MENU_GAP - VIEWPORT_MARGIN;
|
|
178
|
+
const above = caret.top - MENU_GAP - VIEWPORT_MARGIN;
|
|
179
|
+
const wanted = Math.min(menu.scrollHeight, MENU_MAX_HEIGHT);
|
|
180
|
+
const left = Math.max(VIEWPORT_MARGIN, Math.min(caret.left, view.innerWidth - menu.offsetWidth - VIEWPORT_MARGIN));
|
|
181
|
+
if (below >= wanted || below >= above) {
|
|
182
|
+
return { top: caret.bottom + MENU_GAP, left, maxHeight: Math.min(MENU_MAX_HEIGHT, below) };
|
|
183
|
+
}
|
|
184
|
+
return { bottom: view.innerHeight - caret.top + MENU_GAP, left, maxHeight: Math.min(MENU_MAX_HEIGHT, above) };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
interface SlashMenuListProps {
|
|
188
|
+
anchor: HTMLElement;
|
|
189
|
+
optionCount: number;
|
|
190
|
+
children: ReactNode;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The menu, fixed beside the caret and kept there while anything scrolls or the window resizes. It sits in a plain
|
|
195
|
+
* wrapper because Lexical writes the style of its anchor's first child.
|
|
196
|
+
*/
|
|
197
|
+
function SlashMenuList({ anchor, optionCount, children }: SlashMenuListProps) {
|
|
198
|
+
const menuRef = useRef<HTMLDivElement>(null);
|
|
199
|
+
const [placement, setPlacement] = useState<MenuPlacement | null>(null);
|
|
200
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a different number of options changes the menu's height.
|
|
201
|
+
useLayoutEffect(() => {
|
|
202
|
+
const doc = anchor.ownerDocument;
|
|
203
|
+
const view = doc.defaultView ?? window;
|
|
204
|
+
const place = () => {
|
|
205
|
+
if (menuRef.current) setPlacement(placeMenu(anchor, menuRef.current));
|
|
206
|
+
};
|
|
207
|
+
place();
|
|
208
|
+
view.addEventListener('resize', place);
|
|
209
|
+
doc.addEventListener('scroll', place, { capture: true, passive: true });
|
|
210
|
+
return () => {
|
|
211
|
+
view.removeEventListener('resize', place);
|
|
212
|
+
doc.removeEventListener('scroll', place, { capture: true });
|
|
213
|
+
};
|
|
214
|
+
}, [anchor, optionCount]);
|
|
215
|
+
return (
|
|
216
|
+
<div>
|
|
217
|
+
<div
|
|
218
|
+
ref={menuRef}
|
|
219
|
+
role="listbox"
|
|
220
|
+
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"
|
|
221
|
+
// Hidden at the top left for the first measurement, before the layout effect places it.
|
|
222
|
+
style={{ position: 'fixed', ...(placement ?? { top: 0, left: 0, visibility: 'hidden' }) }}
|
|
223
|
+
data-slash-menu
|
|
224
|
+
>
|
|
225
|
+
{children}
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { type JsonValue, parseFragmentMdx } from '@conloca/mdx/render';
|
|
2
|
+
// Import gurx hooks from @mdxeditor/editor, not @mdxeditor/gurx: its re-export is the module instance the editor's
|
|
3
|
+
// realm context comes from.
|
|
4
|
+
import { activeEditor$, insertJsx$, insertMarkdown$, usePublisher, useRealm } from '@mdxeditor/editor';
|
|
5
|
+
import { $getSelection, $isNodeSelection } from 'lexical';
|
|
6
|
+
import type { Root } from 'mdast';
|
|
3
7
|
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
8
|
+
import { useMemo } from 'react';
|
|
4
9
|
import {
|
|
5
10
|
isJsxDescriptor,
|
|
6
11
|
isSnippetDescriptor,
|
|
@@ -37,28 +42,45 @@ export type InsertJsxPayload =
|
|
|
37
42
|
children?: MdxJsxTextElement['children'];
|
|
38
43
|
};
|
|
39
44
|
|
|
45
|
+
/** A default body as a loaded fragment parses it; one the parser refuses inserts the component with an empty body. */
|
|
46
|
+
function parseDefaultBody(name: string, body: string): Root {
|
|
47
|
+
try {
|
|
48
|
+
return parseFragmentMdx(body);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.warn(`[insert] ${name}: its default body could not be parsed, inserting it empty.`, error);
|
|
51
|
+
return { type: 'root', children: [] };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
40
55
|
/**
|
|
41
56
|
* Build the payload accepted by @mdxeditor/editor's `insertJsx$` signal.
|
|
42
57
|
*
|
|
43
58
|
* Strings round-trip as plain attributes; numbers/booleans become
|
|
44
|
-
* expression attributes (`{2}`, `{true}`)
|
|
45
|
-
* `mdxJsxAttribute.value` shape is
|
|
46
|
-
* `{ type: 'expression', value: string }` object.
|
|
59
|
+
* expression attributes (`{2}`, `{true}`) and lists/objects JSON
|
|
60
|
+
* expressions, because the upstream `mdxJsxAttribute.value` shape is
|
|
61
|
+
* either a string or an `{ type: 'expression', value: string }` object.
|
|
47
62
|
*
|
|
48
|
-
* `descriptor.defaults.children` is parsed
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* author build the body via in-place editing.
|
|
63
|
+
* `descriptor.defaults.children` is parsed by `parseFragmentMdx`, the parse
|
|
64
|
+
* the save check reads a fragment with, so component tags in a default
|
|
65
|
+
* become JSX nodes exactly as they would in a loaded fragment.
|
|
52
66
|
*/
|
|
53
67
|
export function buildInsertPayload(
|
|
54
68
|
descriptor: MdxJsxComponentDescriptor,
|
|
55
|
-
overrides: Record<string,
|
|
69
|
+
overrides: Record<string, JsonValue> = {},
|
|
56
70
|
): InsertJsxPayload {
|
|
57
71
|
const merged = { ...(descriptor.defaults?.attributes ?? {}), ...overrides };
|
|
58
72
|
const props: InsertJsxProps = {};
|
|
59
73
|
for (const [name, value] of Object.entries(merged)) {
|
|
74
|
+
if (value === null) continue;
|
|
60
75
|
const propType = descriptor.props?.find((p) => p.name === name)?.type;
|
|
61
|
-
if (
|
|
76
|
+
if (typeof value === 'object' && value !== null) {
|
|
77
|
+
props[name] = { type: 'expression', value: JSON.stringify(value) };
|
|
78
|
+
} else if (
|
|
79
|
+
propType === 'number' ||
|
|
80
|
+
propType === 'boolean' ||
|
|
81
|
+
typeof value === 'number' ||
|
|
82
|
+
typeof value === 'boolean'
|
|
83
|
+
) {
|
|
62
84
|
props[name] = { type: 'expression', value: String(value) };
|
|
63
85
|
} else {
|
|
64
86
|
props[name] = String(value);
|
|
@@ -67,14 +89,14 @@ export function buildInsertPayload(
|
|
|
67
89
|
|
|
68
90
|
// Parse the optional starter body. The cast on the result narrows the
|
|
69
91
|
// upstream mdast root's `children` to the flow/text element children types
|
|
70
|
-
// the library expects —
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
92
|
+
// the library expects — the parsed Root's children are block-level, which
|
|
93
|
+
// is the same set as `MdxJsxFlowElement` accepts. For text-kind
|
|
94
|
+
// descriptors, callers are responsible for providing markdown that is
|
|
95
|
+
// phrasing-only (the wildcard cast is explicit so the contract is visible
|
|
96
|
+
// at the call site).
|
|
75
97
|
let children: InsertJsxPayload['children'];
|
|
76
98
|
if (descriptor.hasChildren && descriptor.defaults?.children) {
|
|
77
|
-
const root =
|
|
99
|
+
const root = parseDefaultBody(descriptor.name, descriptor.defaults.children);
|
|
78
100
|
children = root.children as InsertJsxPayload['children'];
|
|
79
101
|
}
|
|
80
102
|
|
|
@@ -104,18 +126,52 @@ export function hasRequiredProps(descriptor: MdxJsxComponentDescriptor): boolean
|
|
|
104
126
|
}
|
|
105
127
|
|
|
106
128
|
/**
|
|
107
|
-
* Publisher bundle accepted by `dispatchInsert
|
|
108
|
-
*
|
|
109
|
-
* (hooks can't be conditional) and pass the pair in; the dispatcher then
|
|
110
|
-
* routes by descriptor kind. Keeping the two publishers together in one
|
|
111
|
-
* value also makes future signal additions a single-line change at the
|
|
112
|
-
* call sites.
|
|
129
|
+
* Publisher bundle accepted by `dispatchInsert`, one per insert signal; the
|
|
130
|
+
* dispatcher routes by descriptor kind.
|
|
113
131
|
*/
|
|
114
132
|
export interface InsertPublishers {
|
|
115
133
|
jsx: (payload: InsertJsxPayload) => void;
|
|
116
134
|
markdown: (value: string) => void;
|
|
117
135
|
}
|
|
118
136
|
|
|
137
|
+
/**
|
|
138
|
+
* A caret right after the selected component. An arrow key onto a block component selects the component itself, and
|
|
139
|
+
* MDXEditor inserts only at a caret: `insertJsx$` silently inserts nothing, and `insertMarkdown$` replaces the
|
|
140
|
+
* selected component with the snippet.
|
|
141
|
+
*/
|
|
142
|
+
function $caretAfterSelectedComponent(): void {
|
|
143
|
+
const selection = $getSelection();
|
|
144
|
+
if (!$isNodeSelection(selection)) return;
|
|
145
|
+
const nodes = selection.getNodes();
|
|
146
|
+
const last = nodes[nodes.length - 1];
|
|
147
|
+
if (!last) return;
|
|
148
|
+
const after = last.getIndexWithinParent() + 1;
|
|
149
|
+
last.getParentOrThrow().select(after, after);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The slash menu's and toolbar's publishers. Each insert lands in the editor the author was last in (a component's
|
|
154
|
+
* body is its own editor), at its caret, or right after the component selected there.
|
|
155
|
+
*/
|
|
156
|
+
export function useInsertPublishers(): InsertPublishers {
|
|
157
|
+
const realm = useRealm();
|
|
158
|
+
const publishJsx = usePublisher(insertJsx$);
|
|
159
|
+
const publishMarkdown = usePublisher(insertMarkdown$);
|
|
160
|
+
return useMemo<InsertPublishers>(() => {
|
|
161
|
+
const toCaret = () => realm.getValue(activeEditor$)?.update($caretAfterSelectedComponent, { discrete: true });
|
|
162
|
+
return {
|
|
163
|
+
jsx: (payload) => {
|
|
164
|
+
toCaret();
|
|
165
|
+
publishJsx(payload);
|
|
166
|
+
},
|
|
167
|
+
markdown: (value) => {
|
|
168
|
+
toCaret();
|
|
169
|
+
publishMarkdown(value);
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}, [realm, publishJsx, publishMarkdown]);
|
|
173
|
+
}
|
|
174
|
+
|
|
119
175
|
/**
|
|
120
176
|
* Insert a descriptor's content into the editor. JSX descriptors go
|
|
121
177
|
* through `insertJsx$` so they land as a proper Lexical decorator node
|
|
@@ -141,10 +197,3 @@ export function dispatchInsert(descriptor: MdxComponentDescriptor, publishers: I
|
|
|
141
197
|
const _exhaustive: never = descriptor;
|
|
142
198
|
void _exhaustive;
|
|
143
199
|
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Convenience re-export of the upstream signals so call sites don't need
|
|
147
|
-
* to import them separately. Keeping both signal references in one module
|
|
148
|
-
* also documents which library symbols the insert pipeline depends on.
|
|
149
|
-
*/
|
|
150
|
-
export { insertJsx$, insertMarkdown$ };
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { addComposerChild$, realmPlugin } from '@mdxeditor/editor';
|
|
1
|
+
import { addComposerChild$, addNestedEditorChild$, realmPlugin } from '@mdxeditor/editor';
|
|
2
2
|
import { SlashMenuPlugin } from './SlashMenuPlugin.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Realm plugin that wires the slash menu into @mdxeditor/editor's Lexical
|
|
6
6
|
* composer tree. The plugin's only job is to publish `SlashMenuPlugin`
|
|
7
7
|
* (which itself calls `useLexicalComposerContext`) through
|
|
8
|
-
* `addComposerChild$` so it mounts inside the editor's composer
|
|
8
|
+
* `addComposerChild$` so it mounts inside the editor's composer, and through
|
|
9
|
+
* `addNestedEditorChild$` so a component's body (a nested editor) gets its
|
|
10
|
+
* own menu at its own caret.
|
|
9
11
|
*/
|
|
10
12
|
export const mdxComponentsPlugin = realmPlugin({
|
|
11
13
|
init(realm) {
|
|
12
|
-
realm.
|
|
14
|
+
realm.pubIn({ [addComposerChild$]: SlashMenuPlugin, [addNestedEditorChild$]: SlashMenuPlugin });
|
|
13
15
|
},
|
|
14
16
|
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { addMdastExtension$, addToMarkdownExtension$, realmPlugin } from '@mdxeditor/editor';
|
|
2
|
+
import { type MdxJsxFlowElement, mdxJsxFromMarkdown, mdxJsxToMarkdown } from 'mdast-util-mdx-jsx';
|
|
3
|
+
|
|
4
|
+
/** How a component block was written in the source. Columns and indents count from the block's opening `<`. */
|
|
5
|
+
interface SourceLayout {
|
|
6
|
+
/** The opening tag as written (the whole block when it closes itself), later lines relative to its `<`. */
|
|
7
|
+
open: string;
|
|
8
|
+
/** The attributes `open` spells, to tell whether it still does. */
|
|
9
|
+
attributes: string;
|
|
10
|
+
openEndLine: number;
|
|
11
|
+
/** Line breaks after the opening tag and before the closing tag, and the children's and closing tag's indents. */
|
|
12
|
+
body?: { openBreaks: number; indent: number; closeBreaks: number; closeIndent: number };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare module 'mdast-util-mdx-jsx' {
|
|
16
|
+
interface MdxJsxFlowElementData {
|
|
17
|
+
/** Absent for blocks made in the editor. */
|
|
18
|
+
sourceLayout?: SourceLayout;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const stockExitFlowTag = mdxJsxFromMarkdown().exit?.mdxJsxFlowTag;
|
|
23
|
+
const stockFlowElement = mdxJsxToMarkdown().handlers?.mdxJsxFlowElement;
|
|
24
|
+
if (!stockExitFlowTag || !stockFlowElement) throw new Error('mdast-util-mdx-jsx no longer handles flow elements');
|
|
25
|
+
|
|
26
|
+
// The name too: a renamed block's recorded opening tag would no longer match its closing tag.
|
|
27
|
+
const attributesOf = (element: MdxJsxFlowElement) =>
|
|
28
|
+
JSON.stringify([element.name, element.attributes], (key, value) =>
|
|
29
|
+
key === 'position' || key === 'data' ? undefined : value,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
/** The stock tag exit, plus the source layout of the block the tag opens or closes. */
|
|
33
|
+
const exitFlowTag: typeof stockExitFlowTag = function (token) {
|
|
34
|
+
const tag = this.data.mdxJsxTag;
|
|
35
|
+
// The tag's text buffer sits on top until the stock exit resumes it.
|
|
36
|
+
const closed = this.stack[this.stack.length - 2];
|
|
37
|
+
stockExitFlowTag.call(this, token);
|
|
38
|
+
if (tag?.close) {
|
|
39
|
+
if (closed?.type !== 'mdxJsxFlowElement') return;
|
|
40
|
+
const layout = closed.data?.sourceLayout;
|
|
41
|
+
const start = closed.position?.start;
|
|
42
|
+
const first = closed.children[0]?.position;
|
|
43
|
+
const last = closed.children[closed.children.length - 1]?.position;
|
|
44
|
+
if (layout && start && first && last) {
|
|
45
|
+
layout.body = {
|
|
46
|
+
openBreaks: first.start.line - layout.openEndLine,
|
|
47
|
+
indent: Math.max(0, first.start.column - start.column),
|
|
48
|
+
closeBreaks: token.start.line - last.end.line,
|
|
49
|
+
closeIndent: Math.max(0, token.start.column - start.column),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const top = this.stack[this.stack.length - 1];
|
|
55
|
+
const element = tag?.selfClosing && top && 'children' in top ? top.children[top.children.length - 1] : top;
|
|
56
|
+
if (element?.type !== 'mdxJsxFlowElement') return;
|
|
57
|
+
// Later lines lose the block's own indent, which the parent writes back; each keeps its source line ending.
|
|
58
|
+
const open = this.sliceSerialize(token).replace(
|
|
59
|
+
new RegExp(`(\\r\\n|\\r|\\n) {0,${token.start.column - 1}}`, 'g'),
|
|
60
|
+
'$1',
|
|
61
|
+
);
|
|
62
|
+
element.data = {
|
|
63
|
+
...element.data,
|
|
64
|
+
sourceLayout: { open, attributes: attributesOf(element), openEndLine: token.end.line },
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Writes a component block the way its source laid it out, where the stock handler indents its children by two spaces
|
|
70
|
+
* per level and drops the blank line before its closing tag. Its children are written as usual, so an edit inside
|
|
71
|
+
* changes only what was edited.
|
|
72
|
+
*/
|
|
73
|
+
const flowElement: typeof stockFlowElement = (node: MdxJsxFlowElement, parent, state, info) => {
|
|
74
|
+
const layout = node.data?.sourceLayout;
|
|
75
|
+
// Inside a quote or list item the container indents the block; leave that to the stock handler.
|
|
76
|
+
const contained = state.stack.some((name) => name === 'blockquote' || name === 'listItem');
|
|
77
|
+
const body = layout?.body;
|
|
78
|
+
if (!layout || contained || node.children.length > 0 !== (body !== undefined)) {
|
|
79
|
+
return stockFlowElement(node, parent, state, info);
|
|
80
|
+
}
|
|
81
|
+
const sameAttributes = layout.attributes === attributesOf(node);
|
|
82
|
+
if (!body) return sameAttributes ? layout.open : stockFlowElement(node, parent, state, info);
|
|
83
|
+
// The stock opening tag is the self-closing tag of the block without its children.
|
|
84
|
+
const open = sameAttributes
|
|
85
|
+
? layout.open
|
|
86
|
+
: stockFlowElement({ ...node, children: [] }, parent, state, info)
|
|
87
|
+
.trimStart()
|
|
88
|
+
.replace(/ ?\/>$/, '>');
|
|
89
|
+
const children = state.indentLines(state.containerFlow(node, info), (line, _, blank) =>
|
|
90
|
+
blank ? '' : ' '.repeat(body.indent) + line,
|
|
91
|
+
);
|
|
92
|
+
return `${open}${'\n'.repeat(body.openBreaks)}${children}${'\n'.repeat(body.closeBreaks)}${' '.repeat(body.closeIndent)}</${node.name ?? ''}>`;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/** Saves component blocks in their source layout, so opening and saving a file rewrites none of them. */
|
|
96
|
+
export const jsxLayoutPlugin = realmPlugin({
|
|
97
|
+
init(realm) {
|
|
98
|
+
realm.pubIn({
|
|
99
|
+
[addMdastExtension$]: [{ exit: { mdxJsxFlowTag: exitFlowTag } }],
|
|
100
|
+
[addToMarkdownExtension$]: [{ handlers: { mdxJsxFlowElement: flowElement } }],
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { FragmentVocabulary } from '@conloca/mdx/render';
|
|
2
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
3
|
+
import { isJsxDescriptor, type MdxComponents, useMdxComponents } from '../../mdx-components.js';
|
|
4
|
+
import { useSiteRender } from '../../site-render.js';
|
|
5
|
+
|
|
6
|
+
/** True inside a fragment editor: only the site's fragment vocabulary is offered, rendered by the site's own components. */
|
|
7
|
+
export const FragmentModeContext = createContext(false);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The components an editor offers. A page gets every descriptor; a fragment gets the snippets and the vocabulary's
|
|
11
|
+
* components, with a plain flow descriptor for each vocabulary component the registry does not describe.
|
|
12
|
+
*/
|
|
13
|
+
export function offeredMdxComponents(
|
|
14
|
+
descriptors: MdxComponents,
|
|
15
|
+
vocabulary: FragmentVocabulary | undefined,
|
|
16
|
+
): MdxComponents {
|
|
17
|
+
if (!vocabulary) return descriptors;
|
|
18
|
+
const names = Object.keys(vocabulary.components);
|
|
19
|
+
const kept = descriptors.filter((d) => !isJsxDescriptor(d) || names.includes(d.name));
|
|
20
|
+
const described = new Set(descriptors.filter(isJsxDescriptor).map((d) => d.name));
|
|
21
|
+
const synthesized = names
|
|
22
|
+
.filter((name) => !described.has(name))
|
|
23
|
+
.map((name) => ({ name, kind: 'flow' as const, hasChildren: true }));
|
|
24
|
+
return [...kept, ...synthesized];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function useOfferedMdxComponents(): MdxComponents {
|
|
28
|
+
const fragment = useContext(FragmentModeContext);
|
|
29
|
+
const descriptors = useMdxComponents();
|
|
30
|
+
const { vocabulary } = useSiteRender();
|
|
31
|
+
return useMemo(
|
|
32
|
+
() => offeredMdxComponents(descriptors, fragment ? vocabulary : undefined),
|
|
33
|
+
[descriptors, fragment, vocabulary],
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Overrides, registerOverlayPortal, useGetPuck } from '@puckeditor/core';
|
|
2
2
|
import { createContext, type ReactNode, useContext, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { PAGE_SETTING_ATTRIBUTE } from '../../page-setting-attributes.js';
|
|
4
|
+
import { PageConflictFields } from '../conflicts/PuckConflicts.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The parts of blocks that show one of the page's settings (marked with
|
|
@@ -143,6 +144,7 @@ export const FieldsWithPageSettingsHint: Overrides['fields'] = ({ children, item
|
|
|
143
144
|
|
|
144
145
|
return (
|
|
145
146
|
<>
|
|
147
|
+
<PageConflictFields blockId={blockId} />
|
|
146
148
|
{shows && (
|
|
147
149
|
<p className="px-4 pt-4 text-xs text-grey-04 dark:text-grey-07">
|
|
148
150
|
Parts of this block come from Page settings. Click one on the page to edit it.
|
|
@@ -18,7 +18,27 @@ export const PREVIEW_UNAVAILABLE_TITLE = 'Preview is not available for this bran
|
|
|
18
18
|
* site; it reassures that nothing they did is broken.
|
|
19
19
|
*/
|
|
20
20
|
export const PREVIEW_UNAVAILABLE_DETAIL =
|
|
21
|
-
'
|
|
21
|
+
'Preview is currently unavailable for this branch. Your draft is still saved, and publishing and the live site are unaffected.';
|
|
22
22
|
|
|
23
23
|
/** What the Preview control on a docs (MDX) page says until docs pages render drafts. */
|
|
24
24
|
export const DOCS_PREVIEW_UNAVAILABLE = "Full-page preview isn't available for docs pages yet";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The neutral next step when only an unavailable capability is known. A host's refusal carries its own next step,
|
|
28
|
+
* since confirmation or an upgrade may be needed instead. Names no host button: this editor also runs without one.
|
|
29
|
+
*/
|
|
30
|
+
export const PREVIEW_UNAVAILABLE_NEXT_STEP = 'Choose Check again to ask the site for the current preview status.';
|
|
31
|
+
|
|
32
|
+
/** The toast action that asks the site again, instead of making the person reload the editor to find out. */
|
|
33
|
+
export const PREVIEW_CHECK_AGAIN = 'Check again';
|
|
34
|
+
|
|
35
|
+
/** The toast action for a failure that is not about the site's setup. */
|
|
36
|
+
export const PREVIEW_TRY_AGAIN = 'Try again';
|
|
37
|
+
|
|
38
|
+
/** The browser refused the preview tab: the site is fine, the browser needs to be told it may open one. */
|
|
39
|
+
export const PREVIEW_BLOCKED_TITLE = 'Your browser blocked the preview tab';
|
|
40
|
+
export const PREVIEW_BLOCKED_DETAIL = 'Allow pop-ups for this site, then try again.';
|
|
41
|
+
|
|
42
|
+
/** A genuine fault, which must not read as though the site is misconfigured. */
|
|
43
|
+
export const PREVIEW_FAILED_TITLE = 'Could not open preview';
|
|
44
|
+
export const PREVIEW_FAILED_DETAIL = 'Something went wrong creating the preview link. Please try again.';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { JsonValue } from '@conloca/mdx/render';
|
|
2
|
+
import { isJsonValue } from '../../live/messages.js';
|
|
3
|
+
import type { MdxComponentField } from '../../mdx-components.js';
|
|
4
|
+
import type { FieldHint } from '../../page-schemas.js';
|
|
5
|
+
|
|
6
|
+
function unknownField(field: never): never {
|
|
7
|
+
throw new Error(`Unknown prop type ${JSON.stringify(field)}`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** The `HintForm` control for a descriptor prop, so list and object props get structured fields. */
|
|
11
|
+
export function propFieldHint(prop: MdxComponentField): FieldHint {
|
|
12
|
+
const common = { label: prop.label, help: prop.help };
|
|
13
|
+
switch (prop.type) {
|
|
14
|
+
case 'list':
|
|
15
|
+
return { ...common, control: 'array', of: propFieldHint(prop.of) };
|
|
16
|
+
case 'object':
|
|
17
|
+
return {
|
|
18
|
+
...common,
|
|
19
|
+
control: 'object',
|
|
20
|
+
fields: Object.fromEntries(Object.entries(prop.fields).map(([key, field]) => [key, propFieldHint(field)])),
|
|
21
|
+
};
|
|
22
|
+
case 'string':
|
|
23
|
+
return prop.options?.length
|
|
24
|
+
? { ...common, control: 'select', options: prop.options }
|
|
25
|
+
: { ...common, control: 'text' };
|
|
26
|
+
case 'number':
|
|
27
|
+
return { ...common, control: 'number' };
|
|
28
|
+
case 'boolean':
|
|
29
|
+
return { ...common, control: 'switch' };
|
|
30
|
+
default:
|
|
31
|
+
return unknownField(prop);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function emptyFieldValue(field: MdxComponentField): JsonValue {
|
|
36
|
+
switch (field.type) {
|
|
37
|
+
case 'object':
|
|
38
|
+
return {};
|
|
39
|
+
case 'list':
|
|
40
|
+
return [];
|
|
41
|
+
case 'string':
|
|
42
|
+
return '';
|
|
43
|
+
case 'number':
|
|
44
|
+
return 0;
|
|
45
|
+
case 'boolean':
|
|
46
|
+
return false;
|
|
47
|
+
default:
|
|
48
|
+
return unknownField(field);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The JSON a `HintForm` draft stands for: list items `HintForm`'s Add item leaves `undefined` become
|
|
54
|
+
* the field's empty value, keys a cleared input left `undefined` are dropped, and keys the descriptor
|
|
55
|
+
* does not declare are kept in place, so a no-op edit serializes to the same JSON.
|
|
56
|
+
*/
|
|
57
|
+
export function normalizeFieldValue(field: MdxComponentField, value: unknown): JsonValue {
|
|
58
|
+
if (field.type === 'list') {
|
|
59
|
+
return Array.isArray(value)
|
|
60
|
+
? value.map((item) => (item === undefined ? emptyFieldValue(field.of) : normalizeFieldValue(field.of, item)))
|
|
61
|
+
: [];
|
|
62
|
+
}
|
|
63
|
+
if (field.type === 'object') {
|
|
64
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value)) return {};
|
|
65
|
+
return Object.fromEntries(
|
|
66
|
+
Object.entries(value).flatMap(([key, v]: [string, unknown]): Array<[string, JsonValue]> => {
|
|
67
|
+
if (v === undefined) return [];
|
|
68
|
+
const sub = Object.keys(field.fields).includes(key) ? field.fields[key] : undefined;
|
|
69
|
+
if (sub) return [[key, normalizeFieldValue(sub, v)]];
|
|
70
|
+
return isJsonValue(v) ? [[key, v]] : [];
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
return isJsonValue(value) ? value : emptyFieldValue(field);
|
|
75
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { addImportVisitor$, addLexicalNode$, type MdastImportVisitor, realmPlugin } from '@mdxeditor/editor';
|
|
2
|
+
import { $create, $createTextNode, $isElementNode, type EditorConfig, TextNode } from 'lexical';
|
|
3
|
+
import type * as Mdast from 'mdast';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A source line ending inside a paragraph (a soft break). Its text stays the line ending, so the stock text export
|
|
7
|
+
* writes the paragraph back byte for byte; only its span collapses that ending to a space, the way the published page
|
|
8
|
+
* shows it, where the editable's `pre-wrap` would draw it as a line break.
|
|
9
|
+
*/
|
|
10
|
+
export class SoftBreakNode extends TextNode {
|
|
11
|
+
override $config() {
|
|
12
|
+
return this.config('conloca-soft-break', { extends: TextNode });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
override createDOM(config: EditorConfig): HTMLElement {
|
|
16
|
+
const dom = super.createDOM(config);
|
|
17
|
+
dom.style.whiteSpace = 'normal';
|
|
18
|
+
return dom;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Typing next to the break starts a text node of its own, so typed spaces keep the editable's `pre-wrap`.
|
|
22
|
+
override canInsertTextBefore(): boolean {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override canInsertTextAfter(): boolean {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Splits a text node at its source line endings, each kept as a {@link SoftBreakNode}. */
|
|
32
|
+
const MdastSoftBreakTextVisitor: MdastImportVisitor<Mdast.Text> = {
|
|
33
|
+
testNode: (node) => node.type === 'text' && /[\r\n]/.test(node.value),
|
|
34
|
+
priority: 10,
|
|
35
|
+
visitNode({ mdastNode, lexicalParent, actions }) {
|
|
36
|
+
// mdast `text` is phrasing content, so its Lexical parent is an element (the stock visitor assumes so too).
|
|
37
|
+
if (!$isElementNode(lexicalParent)) throw new Error(`text inside ${lexicalParent.getType()}`);
|
|
38
|
+
const format = actions.getParentFormatting();
|
|
39
|
+
const style = actions.getParentStyle();
|
|
40
|
+
for (const [index, part] of mdastNode.value.split(/(\r\n|\r|\n)/).entries()) {
|
|
41
|
+
if (part === '') continue;
|
|
42
|
+
const node = index % 2 === 1 ? $create(SoftBreakNode).setTextContent(part) : $createTextNode(part);
|
|
43
|
+
node.setFormat(format);
|
|
44
|
+
if (style !== '') node.setStyle(style);
|
|
45
|
+
lexicalParent.append(node);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** Shows a paragraph's source line endings as the spaces the published page shows. */
|
|
51
|
+
export const softBreakPlugin = realmPlugin({
|
|
52
|
+
init(realm) {
|
|
53
|
+
realm.pubIn({ [addImportVisitor$]: [MdastSoftBreakTextVisitor], [addLexicalNode$]: [SoftBreakNode] });
|
|
54
|
+
},
|
|
55
|
+
});
|