@conloca/cms-spa 0.1.14 → 0.1.16
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/App-Bk1LNxbS.mjs +10851 -0
- package/dist/App-Bk1LNxbS.mjs.map +1 -0
- package/dist/App.d.ts +35 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +52 -0
- package/dist/CmsSpaApp.d.ts +13 -0
- package/dist/CmsSpaApp.d.ts.map +1 -0
- package/dist/CmsSpaApp.js +33 -0
- package/dist/cn-dlASUkDY.mjs +10 -0
- package/dist/cn-dlASUkDY.mjs.map +1 -0
- package/dist/components/CMSDashboard.d.ts +2 -0
- package/dist/components/CMSDashboard.d.ts.map +1 -0
- package/dist/components/CMSDashboard.js +20 -0
- package/dist/components/CMSLayout.d.ts +2 -0
- package/dist/components/CMSLayout.d.ts.map +1 -0
- package/dist/components/CMSLayout.js +15 -0
- package/dist/components/ConlocaLogo.d.ts +2 -0
- package/dist/components/ConlocaLogo.d.ts.map +1 -0
- package/dist/components/ConlocaLogo.js +4 -0
- package/dist/components/GitStatusPanel.d.ts +25 -0
- package/dist/components/GitStatusPanel.d.ts.map +1 -0
- package/dist/components/GitStatusPanel.js +77 -0
- package/dist/components/MobileTopBar.d.ts +6 -0
- package/dist/components/MobileTopBar.d.ts.map +1 -0
- package/dist/components/MobileTopBar.js +6 -0
- package/dist/components/Sidebar.d.ts +8 -0
- package/dist/components/Sidebar.d.ts.map +1 -0
- package/dist/components/Sidebar.js +40 -0
- package/dist/components/UserAvatar.d.ts +2 -0
- package/dist/components/UserAvatar.d.ts.map +1 -0
- package/dist/components/UserAvatar.js +14 -0
- package/dist/components/cards/DataEntryCard.d.ts +14 -0
- package/dist/components/cards/DataEntryCard.d.ts.map +1 -0
- package/dist/components/cards/DataEntryCard.js +32 -0
- package/dist/components/cards/SectionCard.d.ts +15 -0
- package/dist/components/cards/SectionCard.d.ts.map +1 -0
- package/dist/components/cards/SectionCard.js +10 -0
- package/dist/components/cards/index.d.ts +2 -0
- package/dist/components/cards/index.d.ts.map +1 -0
- package/dist/components/cards/index.js +1 -0
- package/dist/components/dashboard/RecentActivity.d.ts +2 -0
- package/dist/components/dashboard/RecentActivity.d.ts.map +1 -0
- package/dist/components/dashboard/RecentActivity.js +58 -0
- package/dist/components/dialog.d.ts +53 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +56 -0
- package/dist/components/dialogs/BlockPropertiesDialog.d.ts +12 -0
- package/dist/components/dialogs/BlockPropertiesDialog.d.ts.map +1 -0
- package/dist/components/dialogs/BlockPropertiesDialog.js +42 -0
- package/dist/components/dialogs/ConflictDialog.d.ts +10 -0
- package/dist/components/dialogs/ConflictDialog.d.ts.map +1 -0
- package/dist/components/dialogs/ConflictDialog.js +29 -0
- package/dist/components/dialogs/CreateDataDialog.d.ts +9 -0
- package/dist/components/dialogs/CreateDataDialog.d.ts.map +1 -0
- package/dist/components/dialogs/CreateDataDialog.js +20 -0
- package/dist/components/dialogs/CreateFolderDialog.d.ts +9 -0
- package/dist/components/dialogs/CreateFolderDialog.d.ts.map +1 -0
- package/dist/components/dialogs/CreateFolderDialog.js +33 -0
- package/dist/components/dialogs/CreatePageDialog.d.ts +10 -0
- package/dist/components/dialogs/CreatePageDialog.d.ts.map +1 -0
- package/dist/components/dialogs/CreatePageDialog.js +155 -0
- package/dist/components/dialogs/DataPropertiesDialog.d.ts +10 -0
- package/dist/components/dialogs/DataPropertiesDialog.d.ts.map +1 -0
- package/dist/components/dialogs/DataPropertiesDialog.js +38 -0
- package/dist/components/dialogs/DeleteConfirmDialog.d.ts +12 -0
- package/dist/components/dialogs/DeleteConfirmDialog.d.ts.map +1 -0
- package/dist/components/dialogs/DeleteConfirmDialog.js +7 -0
- package/dist/components/dialogs/ErrorModal.d.ts +14 -0
- package/dist/components/dialogs/ErrorModal.d.ts.map +1 -0
- package/dist/components/dialogs/ErrorModal.js +38 -0
- package/dist/components/dialogs/MoveFolderDialog.d.ts +11 -0
- package/dist/components/dialogs/MoveFolderDialog.d.ts.map +1 -0
- package/dist/components/dialogs/MoveFolderDialog.js +45 -0
- package/dist/components/dialogs/PageMetadataDialog.d.ts +10 -0
- package/dist/components/dialogs/PageMetadataDialog.d.ts.map +1 -0
- package/dist/components/dialogs/PageMetadataDialog.js +85 -0
- package/dist/components/dialogs/UnsavedChangesDialog.d.ts +8 -0
- package/dist/components/dialogs/UnsavedChangesDialog.d.ts.map +1 -0
- package/dist/components/dialogs/UnsavedChangesDialog.js +6 -0
- package/dist/components/dialogs/index.d.ts +9 -0
- package/dist/components/dialogs/index.d.ts.map +1 -0
- package/dist/components/dialogs/index.js +8 -0
- package/dist/components/editor/BlockEditor.d.ts +8 -0
- package/dist/components/editor/BlockEditor.d.ts.map +1 -0
- package/dist/components/editor/BlockEditor.js +262 -0
- package/dist/components/editor/BlockWrappers.d.ts +15 -0
- package/dist/components/editor/BlockWrappers.d.ts.map +1 -0
- package/dist/components/editor/BlockWrappers.js +29 -0
- package/dist/components/editor/CMSMDXEditor.d.ts +13 -0
- package/dist/components/editor/CMSMDXEditor.d.ts.map +1 -0
- package/dist/components/editor/CMSMDXEditor.js +123 -0
- package/dist/components/editor/ContentDiff.d.ts +10 -0
- package/dist/components/editor/ContentDiff.d.ts.map +1 -0
- package/dist/components/editor/ContentDiff.js +51 -0
- package/dist/components/editor/CreateBlockDialog.d.ts +26 -0
- package/dist/components/editor/CreateBlockDialog.d.ts.map +1 -0
- package/dist/components/editor/CreateBlockDialog.js +131 -0
- package/dist/components/editor/DrawerItemOverride.d.ts +8 -0
- package/dist/components/editor/DrawerItemOverride.d.ts.map +1 -0
- package/dist/components/editor/DrawerItemOverride.js +41 -0
- package/dist/components/editor/EditorChromeToggles.d.ts +16 -0
- package/dist/components/editor/EditorChromeToggles.d.ts.map +1 -0
- package/dist/components/editor/EditorChromeToggles.js +16 -0
- package/dist/components/editor/GenericBlock.d.ts +3 -0
- package/dist/components/editor/GenericBlock.d.ts.map +1 -0
- package/dist/components/editor/GenericBlock.js +1067 -0
- package/dist/components/editor/ImagePickerDialog.d.ts +6 -0
- package/dist/components/editor/ImagePickerDialog.d.ts.map +1 -0
- package/dist/components/editor/ImagePickerDialog.js +24 -0
- package/dist/components/editor/JsxPropsPanel.d.ts +16 -0
- package/dist/components/editor/JsxPropsPanel.d.ts.map +1 -0
- package/dist/components/editor/JsxPropsPanel.js +145 -0
- package/dist/components/editor/LocaleSelector.d.ts +9 -0
- package/dist/components/editor/LocaleSelector.d.ts.map +1 -0
- package/dist/components/editor/LocaleSelector.js +13 -0
- package/dist/components/editor/MDXLivePreview.d.ts +14 -0
- package/dist/components/editor/MDXLivePreview.d.ts.map +1 -0
- package/dist/components/editor/MDXLivePreview.js +103 -0
- package/dist/components/editor/MdxPageEditor.d.ts +10 -0
- package/dist/components/editor/MdxPageEditor.d.ts.map +1 -0
- package/dist/components/editor/MdxPageEditor.js +297 -0
- package/dist/components/editor/PageEditor.d.ts +18 -0
- package/dist/components/editor/PageEditor.d.ts.map +1 -0
- package/dist/components/editor/PageEditor.js +288 -0
- package/dist/components/editor/PageEditorHeaderActions.d.ts +16 -0
- package/dist/components/editor/PageEditorHeaderActions.d.ts.map +1 -0
- package/dist/components/editor/PageEditorHeaderActions.js +19 -0
- package/dist/components/editor/PageEditorWrapper.d.ts +7 -0
- package/dist/components/editor/PageEditorWrapper.d.ts.map +1 -0
- package/dist/components/editor/PageEditorWrapper.js +319 -0
- package/dist/components/editor/SearchableSelect.d.ts +34 -0
- package/dist/components/editor/SearchableSelect.d.ts.map +1 -0
- package/dist/components/editor/SearchableSelect.js +116 -0
- package/dist/components/editor/host-wrapper-plugin.d.ts +51 -0
- package/dist/components/editor/host-wrapper-plugin.d.ts.map +1 -0
- package/dist/components/editor/host-wrapper-plugin.js +37 -0
- package/dist/components/editor/index.d.ts +9 -0
- package/dist/components/editor/index.d.ts.map +1 -0
- package/dist/components/editor/index.js +7 -0
- package/dist/components/editor/insert-menu/InsertMdxComponentButton.d.ts +15 -0
- package/dist/components/editor/insert-menu/InsertMdxComponentButton.d.ts.map +1 -0
- package/dist/components/editor/insert-menu/InsertMdxComponentButton.js +90 -0
- package/dist/components/editor/insert-menu/SlashMenuPlugin.d.ts +12 -0
- package/dist/components/editor/insert-menu/SlashMenuPlugin.d.ts.map +1 -0
- package/dist/components/editor/insert-menu/SlashMenuPlugin.js +106 -0
- package/dist/components/editor/insert-menu/insert-payload.d.ts +76 -0
- package/dist/components/editor/insert-menu/insert-payload.d.ts.map +1 -0
- package/dist/components/editor/insert-menu/insert-payload.js +94 -0
- package/dist/components/editor/insert-menu/mdx-components-plugin.d.ts +8 -0
- package/dist/components/editor/insert-menu/mdx-components-plugin.d.ts.map +1 -0
- package/dist/components/editor/insert-menu/mdx-components-plugin.js +13 -0
- package/dist/components/editors/DataEditor.d.ts +19 -0
- package/dist/components/editors/DataEditor.d.ts.map +1 -0
- package/dist/components/editors/DataEditor.js +139 -0
- package/dist/components/fields/ContentBlockSelectorField.d.ts +14 -0
- package/dist/components/fields/ContentBlockSelectorField.d.ts.map +1 -0
- package/dist/components/fields/ContentBlockSelectorField.js +105 -0
- package/dist/components/fields/ImageField.d.ts +16 -0
- package/dist/components/fields/ImageField.d.ts.map +1 -0
- package/dist/components/fields/ImageField.js +39 -0
- package/dist/components/fields/MDXEditField.d.ts +17 -0
- package/dist/components/fields/MDXEditField.d.ts.map +1 -0
- package/dist/components/fields/MDXEditField.js +28 -0
- package/dist/components/forms/ChipArrayField.d.ts +12 -0
- package/dist/components/forms/ChipArrayField.d.ts.map +1 -0
- package/dist/components/forms/ChipArrayField.js +40 -0
- package/dist/components/forms/HintForm.d.ts +22 -0
- package/dist/components/forms/HintForm.d.ts.map +1 -0
- package/dist/components/forms/HintForm.js +162 -0
- package/dist/components/forms/SchemaForm.d.ts +15 -0
- package/dist/components/forms/SchemaForm.d.ts.map +1 -0
- package/dist/components/forms/SchemaForm.js +106 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +13 -0
- package/dist/components/media/AssetCard.d.ts +14 -0
- package/dist/components/media/AssetCard.d.ts.map +1 -0
- package/dist/components/media/AssetCard.js +31 -0
- package/dist/components/media/AssetDetailSidebar.d.ts +11 -0
- package/dist/components/media/AssetDetailSidebar.d.ts.map +1 -0
- package/dist/components/media/AssetDetailSidebar.js +101 -0
- package/dist/components/media/BulkActionBar.d.ts +9 -0
- package/dist/components/media/BulkActionBar.d.ts.map +1 -0
- package/dist/components/media/BulkActionBar.js +8 -0
- package/dist/components/media/FolderNav.d.ts +7 -0
- package/dist/components/media/FolderNav.d.ts.map +1 -0
- package/dist/components/media/FolderNav.js +12 -0
- package/dist/components/media/FolderTreeSidebar.d.ts +9 -0
- package/dist/components/media/FolderTreeSidebar.d.ts.map +1 -0
- package/dist/components/media/FolderTreeSidebar.js +41 -0
- package/dist/components/media/ImagePicker.d.ts +14 -0
- package/dist/components/media/ImagePicker.d.ts.map +1 -0
- package/dist/components/media/ImagePicker.js +45 -0
- package/dist/components/media/MediaLibrary.d.ts +35 -0
- package/dist/components/media/MediaLibrary.d.ts.map +1 -0
- package/dist/components/media/MediaLibrary.js +100 -0
- package/dist/components/media/MediaToolbar.d.ts +21 -0
- package/dist/components/media/MediaToolbar.d.ts.map +1 -0
- package/dist/components/media/MediaToolbar.js +6 -0
- package/dist/components/media/UploadModal.d.ts +9 -0
- package/dist/components/media/UploadModal.d.ts.map +1 -0
- package/dist/components/media/UploadModal.js +42 -0
- package/dist/components/media/UploadZone.d.ts +8 -0
- package/dist/components/media/UploadZone.d.ts.map +1 -0
- package/dist/components/media/UploadZone.js +22 -0
- package/dist/components/media/index.d.ts +11 -0
- package/dist/components/media/index.d.ts.map +1 -0
- package/dist/components/media/index.js +10 -0
- package/dist/components/pages/BlockList.d.ts +2 -0
- package/dist/components/pages/BlockList.d.ts.map +1 -0
- package/dist/components/pages/BlockList.js +280 -0
- package/dist/components/pages/DataList.d.ts +7 -0
- package/dist/components/pages/DataList.d.ts.map +1 -0
- package/dist/components/pages/DataList.js +244 -0
- package/dist/components/pages/MediaPage.d.ts +8 -0
- package/dist/components/pages/MediaPage.d.ts.map +1 -0
- package/dist/components/pages/MediaPage.js +107 -0
- package/dist/components/pages/PageList.d.ts +7 -0
- package/dist/components/pages/PageList.d.ts.map +1 -0
- package/dist/components/pages/PageList.js +308 -0
- package/dist/components/pages/index.d.ts +3 -0
- package/dist/components/pages/index.d.ts.map +1 -0
- package/dist/components/pages/index.js +2 -0
- package/dist/components/puck/MDXContent.d.ts +10 -0
- package/dist/components/puck/MDXContent.d.ts.map +1 -0
- package/dist/components/puck/MDXContent.js +80 -0
- package/dist/components/puck/index.d.ts +2 -0
- package/dist/components/puck/index.d.ts.map +1 -0
- package/dist/components/puck/index.js +1 -0
- package/dist/components/toast.d.ts +44 -0
- package/dist/components/toast.d.ts.map +1 -0
- package/dist/components/toast.js +7 -0
- package/dist/components/ui/Banner.d.ts +76 -0
- package/dist/components/ui/Banner.d.ts.map +1 -0
- package/dist/components/ui/Banner.js +49 -0
- package/dist/components/ui/Button.d.ts +25 -0
- package/dist/components/ui/Button.d.ts.map +1 -0
- package/dist/components/ui/Button.js +33 -0
- package/dist/components/ui/Card.d.ts +72 -0
- package/dist/components/ui/Card.d.ts.map +1 -0
- package/dist/components/ui/Card.js +49 -0
- package/dist/components/ui/FieldError.d.ts +24 -0
- package/dist/components/ui/FieldError.d.ts.map +1 -0
- package/dist/components/ui/FieldError.js +17 -0
- package/dist/components/ui/IconButton.d.ts +13 -0
- package/dist/components/ui/IconButton.d.ts.map +1 -0
- package/dist/components/ui/IconButton.js +10 -0
- package/dist/components/ui/Input.d.ts +37 -0
- package/dist/components/ui/Input.d.ts.map +1 -0
- package/dist/components/ui/Input.js +9 -0
- package/dist/components/ui/SaveIndicator.d.ts +8 -0
- package/dist/components/ui/SaveIndicator.d.ts.map +1 -0
- package/dist/components/ui/SaveIndicator.js +32 -0
- package/dist/components/ui/Select.d.ts +8 -0
- package/dist/components/ui/Select.d.ts.map +1 -0
- package/dist/components/ui/Select.js +9 -0
- package/dist/components/ui/Separator.d.ts +7 -0
- package/dist/components/ui/Separator.d.ts.map +1 -0
- package/dist/components/ui/Separator.js +8 -0
- package/dist/components/ui/Textarea.d.ts +8 -0
- package/dist/components/ui/Textarea.d.ts.map +1 -0
- package/dist/components/ui/Textarea.js +5 -0
- package/dist/components/ui/Tooltip.d.ts +9 -0
- package/dist/components/ui/Tooltip.d.ts.map +1 -0
- package/dist/components/ui/Tooltip.js +7 -0
- package/dist/components/ui/index.d.ts +14 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/index.js +17 -0
- package/dist/data-schemas.d.mts +0 -1
- package/dist/data-schemas.d.mts.map +1 -1
- package/dist/data-schemas.d.ts +22 -0
- package/dist/data-schemas.d.ts.map +1 -0
- package/dist/data-schemas.js +51 -0
- package/dist/data-schemas.mjs +3 -4
- package/dist/data-schemas.mjs.map +1 -1
- package/dist/dev-entry.d.ts +2 -0
- package/dist/dev-entry.d.ts.map +1 -0
- package/dist/dev-entry.js +19 -0
- package/dist/dialog.d.mts +56 -0
- package/dist/dialog.d.mts.map +1 -0
- package/dist/dialog.mjs +67 -0
- package/dist/dialog.mjs.map +1 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/useCanvasTheme.d.ts +12 -0
- package/dist/hooks/useCanvasTheme.d.ts.map +1 -0
- package/dist/hooks/useCanvasTheme.js +33 -0
- package/dist/hooks/useClickOutside.d.ts +7 -0
- package/dist/hooks/useClickOutside.d.ts.map +1 -0
- package/dist/hooks/useClickOutside.js +18 -0
- package/dist/hooks/useDialogState.d.ts +23 -0
- package/dist/hooks/useDialogState.d.ts.map +1 -0
- package/dist/hooks/useDialogState.js +31 -0
- package/dist/hooks/useEditorPref.d.ts +2 -0
- package/dist/hooks/useEditorPref.d.ts.map +1 -0
- package/dist/hooks/useEditorPref.js +49 -0
- package/dist/hooks/useErrorModal.d.ts +15 -0
- package/dist/hooks/useErrorModal.d.ts.map +1 -0
- package/dist/hooks/useErrorModal.js +35 -0
- package/dist/hooks/useSiteBaseUrl.d.ts +10 -0
- package/dist/hooks/useSiteBaseUrl.d.ts.map +1 -0
- package/dist/hooks/useSiteBaseUrl.js +14 -0
- package/dist/hooks/useTheme.d.ts +13 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/hooks/useTheme.js +69 -0
- package/dist/hooks/useUnsavedChangesGuard.d.ts +16 -0
- package/dist/hooks/useUnsavedChangesGuard.d.ts.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard.js +29 -0
- package/dist/hooks/useUpload.d.ts +10 -0
- package/dist/hooks/useUpload.d.ts.map +1 -0
- package/dist/hooks/useUpload.js +42 -0
- package/dist/hooks/useUploadFlow.d.ts +42 -0
- package/dist/hooks/useUploadFlow.d.ts.map +1 -0
- package/dist/hooks/useUploadFlow.js +148 -0
- package/dist/host-style-probe.d.ts +22 -0
- package/dist/host-style-probe.d.ts.map +1 -0
- package/dist/host-style-probe.js +508 -0
- package/dist/index.d.mts +165 -48
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.mjs +36 -2
- package/dist/index.mjs.map +1 -0
- package/dist/lib/utils.d.ts +13 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +47 -0
- package/dist/main-spa-781YUplS.mjs +46 -0
- package/dist/main-spa-781YUplS.mjs.map +1 -0
- package/dist/main-spa.d.ts +8 -0
- package/dist/main-spa.d.ts.map +1 -0
- package/dist/main-spa.js +61 -0
- package/dist/main.d.mts +1 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +13 -0
- package/dist/main.mjs +11 -4998
- package/dist/main.mjs.map +1 -1
- package/dist/mdx-components.d.mts +207 -0
- package/dist/mdx-components.d.mts.map +1 -0
- package/dist/mdx-components.d.ts +204 -0
- package/dist/mdx-components.d.ts.map +1 -0
- package/dist/mdx-components.js +217 -0
- package/dist/mdx-components.mjs +208 -0
- package/dist/mdx-components.mjs.map +1 -0
- package/dist/media/AssetScopePill.d.ts +30 -0
- package/dist/media/AssetScopePill.d.ts.map +1 -0
- package/dist/media/AssetScopePill.js +30 -0
- package/dist/media/MediaIssueBadge.d.ts +33 -0
- package/dist/media/MediaIssueBadge.d.ts.map +1 -0
- package/dist/media/MediaIssueBadge.js +54 -0
- package/dist/media/types.d.ts +101 -0
- package/dist/media/types.d.ts.map +1 -0
- package/dist/media/types.js +1 -0
- package/dist/media/use-asset-scope.d.ts +25 -0
- package/dist/media/use-asset-scope.d.ts.map +1 -0
- package/dist/media/use-asset-scope.js +54 -0
- package/dist/media/use-media-issue.d.ts +24 -0
- package/dist/media/use-media-issue.d.ts.map +1 -0
- package/dist/media/use-media-issue.js +49 -0
- package/dist/mock-puck-config.d.mts +23 -0
- package/dist/mock-puck-config.d.mts.map +1 -0
- package/dist/mock-puck-config.d.ts +21 -0
- package/dist/mock-puck-config.d.ts.map +1 -0
- package/dist/mock-puck-config.js +73 -0
- package/dist/mock-puck-config.mjs +125 -0
- package/dist/mock-puck-config.mjs.map +1 -0
- package/dist/page-schemas.d.mts +139 -6
- package/dist/page-schemas.d.mts.map +1 -1
- package/dist/page-schemas.d.ts +156 -0
- package/dist/page-schemas.d.ts.map +1 -0
- package/dist/page-schemas.js +118 -0
- package/dist/page-schemas.mjs +74 -6
- package/dist/page-schemas.mjs.map +1 -1
- package/dist/puck-config.d.mts +9 -1
- package/dist/puck-config.d.mts.map +1 -1
- package/dist/puck-config.d.ts +31 -0
- package/dist/puck-config.d.ts.map +1 -0
- package/dist/puck-config.js +50 -0
- package/dist/puck-config.mjs +3 -4
- package/dist/puck-config.mjs.map +1 -1
- package/dist/selected-block.d.ts +61 -0
- package/dist/selected-block.d.ts.map +1 -0
- package/dist/selected-block.js +64 -0
- package/dist/site-styles.d.mts +123 -0
- package/dist/site-styles.d.mts.map +1 -0
- package/dist/site-styles.d.ts +121 -0
- package/dist/site-styles.d.ts.map +1 -0
- package/dist/site-styles.js +253 -0
- package/dist/site-styles.mjs +234 -0
- package/dist/site-styles.mjs.map +1 -0
- package/dist/spa/main.css +5497 -4371
- package/dist/toast.d.mts +7 -0
- package/dist/toast.d.mts.map +1 -0
- package/dist/toast.mjs +16 -0
- package/dist/toast.mjs.map +1 -0
- package/dist/types.d.ts +57 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/ui-CIacC6Mv.mjs +318 -0
- package/dist/ui-CIacC6Mv.mjs.map +1 -0
- package/dist/ui-config.d.ts +70 -0
- package/dist/ui-config.d.ts.map +1 -0
- package/dist/ui-config.js +44 -0
- package/dist/ui.d.mts +290 -0
- package/dist/ui.d.mts.map +1 -0
- package/dist/ui.mjs +2 -0
- package/dist/utils/asset-url.d.ts +3 -0
- package/dist/utils/asset-url.d.ts.map +1 -0
- package/dist/utils/asset-url.js +7 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/cn.js +5 -0
- package/dist/utils/format-date.d.ts +15 -0
- package/dist/utils/format-date.d.ts.map +1 -0
- package/dist/utils/format-date.js +37 -0
- package/dist/utils/mdast-to-html.d.ts +55 -0
- package/dist/utils/mdast-to-html.d.ts.map +1 -0
- package/dist/utils/mdast-to-html.js +206 -0
- package/dist/utils/mdast-tree.d.ts +104 -0
- package/dist/utils/mdast-tree.d.ts.map +1 -0
- package/dist/utils/mdast-tree.js +285 -0
- package/dist/utils/pageMetadata.d.ts +67 -0
- package/dist/utils/pageMetadata.d.ts.map +1 -0
- package/dist/utils/pageMetadata.js +161 -0
- package/dist/utils/slugify.d.ts +12 -0
- package/dist/utils/slugify.d.ts.map +1 -0
- package/dist/utils/slugify.js +17 -0
- package/dist/utils/zodIntrospect.d.ts +24 -0
- package/dist/utils/zodIntrospect.d.ts.map +1 -0
- package/dist/utils/zodIntrospect.js +88 -0
- package/package.json +153 -35
- package/styles/styles.css.d.ts +2 -0
- package/styles/tailwind-theme.css +126 -0
- package/styles/tailwind-theme.css.d.ts +2 -0
- package/dist/puck-CvjeYQRH.mjs +0 -1533
- package/dist/puck-CvjeYQRH.mjs.map +0 -1
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Host-style probe — captures the host's computed styles for prose
|
|
4
|
+
* elements directly from the rendered live page, then exposes a
|
|
5
|
+
* stylesheet the editor can inject so its typed elements look like
|
|
6
|
+
* the published ones.
|
|
7
|
+
*
|
|
8
|
+
* Why a probe exists alongside the CSS grabber + wrapper auto-copy:
|
|
9
|
+
*
|
|
10
|
+
* - The CSS grabber + wrapper auto-copy work when the host styles
|
|
11
|
+
* prose through CLASS-on-WRAPPER descendant selectors:
|
|
12
|
+
* `.sl-markdown-content h1 { ... }`, `.prose h1 { ... }`. The editor
|
|
13
|
+
* gets wrapped in a clone of the host's wrapper, and the host's
|
|
14
|
+
* already-grabbed CSS reaches its typed elements via the cascade.
|
|
15
|
+
*
|
|
16
|
+
* - But some hosts style prose differently:
|
|
17
|
+
* - Utility-first Tailwind: `<h1 class="text-5xl font-bold">` — the
|
|
18
|
+
* styling is per-element via utility classes. The editor's typed
|
|
19
|
+
* `<h1>` has no utility classes; cascade can't help.
|
|
20
|
+
* - Inline styles: `<h1 style="...">` — only applies to that one
|
|
21
|
+
* element; not reusable via cascade.
|
|
22
|
+
*
|
|
23
|
+
* For both cases, the FINAL rendered styles still resolve to a
|
|
24
|
+
* normal set of CSS property values. `getComputedStyle()` reads
|
|
25
|
+
* them regardless of source. The probe captures those final values
|
|
26
|
+
* from a real rendered sample on the live page and synthesizes a
|
|
27
|
+
* stylesheet — `.conloca-prose--editor h1 { font-size: ...; ... }`
|
|
28
|
+
* — that styles the editor's typed elements to match.
|
|
29
|
+
*
|
|
30
|
+
* Approach:
|
|
31
|
+
*
|
|
32
|
+
* 1. Open a hidden same-origin iframe to the page's published URL.
|
|
33
|
+
* 2. Find the host's prose wrapper inside the iframe (or fall back
|
|
34
|
+
* to `<main>` / `<body>`).
|
|
35
|
+
* 3. For each prose tag we care about, prefer an existing element
|
|
36
|
+
* in the wrapper (so utility classes / inline styles on real
|
|
37
|
+
* elements are observed). Inject a synthetic probe element when
|
|
38
|
+
* no existing sample is present — descendant-selector hosts
|
|
39
|
+
* style the synthetic via the cascade.
|
|
40
|
+
* 4. Read the relevant computed style properties; build a CSS rule
|
|
41
|
+
* scoped to `.conloca-prose--editor <tag>`.
|
|
42
|
+
* 5. Tear down the iframe.
|
|
43
|
+
*
|
|
44
|
+
* Generic across hosts because it never reads source CSS — it reads
|
|
45
|
+
* the cascade's resolved output. Descendant selectors, utility
|
|
46
|
+
* classes, and inline styles all funnel into `getComputedStyle()`
|
|
47
|
+
* the same way.
|
|
48
|
+
*/
|
|
49
|
+
/** Prose elements whose computed styles we capture, split by how
|
|
50
|
+
* they need to be probed. Block-level tags get probed directly under
|
|
51
|
+
* the prose wrapper (their styles don't depend on inline context).
|
|
52
|
+
* Inline tags get probed INSIDE a synthetic `<p>` so their font-size
|
|
53
|
+
* inherits from paragraph context, not from a heading they might
|
|
54
|
+
* happen to appear inside on the live page (eg an anchor inside an
|
|
55
|
+
* <h2> would otherwise capture 35px as its font-size and the editor's
|
|
56
|
+
* inline links would all render heading-sized).
|
|
57
|
+
*
|
|
58
|
+
* `li`, `th`, `td` are inline-context tags too: they're inside a
|
|
59
|
+
* parent (`ul`/`ol`, `tr`) that establishes their typography. We
|
|
60
|
+
* probe them directly under the wrapper because their parent's
|
|
61
|
+
* styling is captured separately and the cascade handles inheritance. */
|
|
62
|
+
const BLOCK_PROBE_TAGS = [
|
|
63
|
+
'h1',
|
|
64
|
+
'h2',
|
|
65
|
+
'h3',
|
|
66
|
+
'h4',
|
|
67
|
+
'h5',
|
|
68
|
+
'h6',
|
|
69
|
+
'p',
|
|
70
|
+
'pre',
|
|
71
|
+
'ul',
|
|
72
|
+
'ol',
|
|
73
|
+
'li',
|
|
74
|
+
'blockquote',
|
|
75
|
+
'table',
|
|
76
|
+
'th',
|
|
77
|
+
'td',
|
|
78
|
+
'hr',
|
|
79
|
+
];
|
|
80
|
+
const INLINE_PROBE_TAGS = ['a', 'strong', 'em', 'code'];
|
|
81
|
+
/** Computed-style properties to capture per tag. Chosen for breadth —
|
|
82
|
+
* we want enough to make the editor look similar without over-
|
|
83
|
+
* specifying things that vary by selection state or container. Skips
|
|
84
|
+
* `width`, `height`, `display`, etc. which would distort the editor's
|
|
85
|
+
* own layout. */
|
|
86
|
+
const PROBE_PROPS = [
|
|
87
|
+
'font-family',
|
|
88
|
+
'font-size',
|
|
89
|
+
'font-weight',
|
|
90
|
+
'font-style',
|
|
91
|
+
'line-height',
|
|
92
|
+
'letter-spacing',
|
|
93
|
+
'color',
|
|
94
|
+
'background-color',
|
|
95
|
+
'margin-block-start',
|
|
96
|
+
'margin-block-end',
|
|
97
|
+
'margin-inline-start',
|
|
98
|
+
'margin-inline-end',
|
|
99
|
+
'padding-block-start',
|
|
100
|
+
'padding-block-end',
|
|
101
|
+
'padding-inline-start',
|
|
102
|
+
'padding-inline-end',
|
|
103
|
+
'border-radius',
|
|
104
|
+
'border-top-width',
|
|
105
|
+
'border-right-width',
|
|
106
|
+
'border-bottom-width',
|
|
107
|
+
'border-left-width',
|
|
108
|
+
'border-top-style',
|
|
109
|
+
'border-right-style',
|
|
110
|
+
'border-bottom-style',
|
|
111
|
+
'border-left-style',
|
|
112
|
+
'border-top-color',
|
|
113
|
+
'border-right-color',
|
|
114
|
+
'border-bottom-color',
|
|
115
|
+
'border-left-color',
|
|
116
|
+
'text-decoration-line',
|
|
117
|
+
'text-decoration-color',
|
|
118
|
+
'text-decoration-thickness',
|
|
119
|
+
'text-underline-offset',
|
|
120
|
+
'list-style-type',
|
|
121
|
+
'list-style-position',
|
|
122
|
+
];
|
|
123
|
+
const IFRAME_TIMEOUT_MS = 10_000;
|
|
124
|
+
/**
|
|
125
|
+
* Locate the host's prose wrapper inside the iframe's document, given
|
|
126
|
+
* the className the server-side discovery already resolved (eg
|
|
127
|
+
* `sl-markdown-content` for Starlight, `prose` for Tailwind Typography).
|
|
128
|
+
* We avoid duplicating the find-wrapper heuristic here: the server-side
|
|
129
|
+
* `findContentWrapper` does the smart majority+depth walk against raw
|
|
130
|
+
* HTML and gives us the right answer. The probe just resolves that
|
|
131
|
+
* className back to an actual element inside the iframe.
|
|
132
|
+
*
|
|
133
|
+
* Returns null when the class isn't found (probe falls back to no-op)
|
|
134
|
+
* or when no className was provided (host has no classed wrapper).
|
|
135
|
+
*/
|
|
136
|
+
function findWrapperByClass(doc, className) {
|
|
137
|
+
if (!className)
|
|
138
|
+
return doc.querySelector('main');
|
|
139
|
+
// Match an element carrying ALL the classes in the discovered name
|
|
140
|
+
// (preserves Astro scoped-hash matching: `astro-xxxx` must be on the
|
|
141
|
+
// same element). `.foo.bar` requires all listed classes.
|
|
142
|
+
const selector = `.${className.split(/\s+/).filter(Boolean).join('.')}`;
|
|
143
|
+
const found = doc.querySelector(selector);
|
|
144
|
+
return found ?? doc.querySelector('main') ?? null;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Read computed styles for each PROBE_TAG inside a freshly loaded
|
|
148
|
+
* iframe's document. Returns one CSS rule string per tag, scoped to
|
|
149
|
+
* `.conloca-prose--editor <tag>` so it targets the editor's typed
|
|
150
|
+
* elements without leaking into the rest of the admin chrome.
|
|
151
|
+
*/
|
|
152
|
+
function buildProbeStylesheet(doc, wrapperClass) {
|
|
153
|
+
const wrapper = findWrapperByClass(doc, wrapperClass);
|
|
154
|
+
const view = doc.defaultView;
|
|
155
|
+
if (!view || !wrapper)
|
|
156
|
+
return '';
|
|
157
|
+
const rules = [];
|
|
158
|
+
// Wrapper-level: capture inherited typography (font-family, color,
|
|
159
|
+
// line-height, etc.) that the host's prose container resolves through
|
|
160
|
+
// BODY inheritance. The probe can't read the cascade source, only
|
|
161
|
+
// the resolved computed values, but that's exactly what we want here:
|
|
162
|
+
// whatever the host's body/wrapper combination computes to.
|
|
163
|
+
//
|
|
164
|
+
// Why this matters: hosts like Starlight set `font-family: var(--sl-font)`
|
|
165
|
+
// on body and never on `.sl-markdown-content`. On the published page
|
|
166
|
+
// the wrapper inherits Inter. In the editor, MDXEditor's `_editorRoot_*`
|
|
167
|
+
// wrapper rule sets `font-family: var(--font-body)` (a generic system
|
|
168
|
+
// stack) and `color: var(--baseText)` (its own palette). Inheritance
|
|
169
|
+
// flows through THAT to the host's `.sl-markdown-content` clone and
|
|
170
|
+
// then to the contenteditable. Probing the wrapper and emitting a
|
|
171
|
+
// direct `:where(.conloca-prose--editor) { font: ...; color: ... }`
|
|
172
|
+
// rule beats inheritance and restores the host's typography.
|
|
173
|
+
const wrapperRule = probeWrapper(view, wrapper);
|
|
174
|
+
if (wrapperRule)
|
|
175
|
+
rules.push(wrapperRule);
|
|
176
|
+
// Block-level: inject INSIDE a synthetic two-element sequence so
|
|
177
|
+
// adjacent-sibling rules fire during the probe. Hosts like Starlight
|
|
178
|
+
// apply prose spacing via `:not(...) + :not(...) { margin-top: ... }`
|
|
179
|
+
// — the rule only fires when an element has a preceding sibling. A
|
|
180
|
+
// single-sample probe would catch the first-child margin (zero) and
|
|
181
|
+
// override the host's adjacent-sibling rule via specificity, so the
|
|
182
|
+
// editor's later paragraphs/headings would render flush against each
|
|
183
|
+
// other.
|
|
184
|
+
//
|
|
185
|
+
// We always use `<p>` as the preceding sibling because: (a) every
|
|
186
|
+
// prose block tag commonly follows a paragraph in real content; (b)
|
|
187
|
+
// Starlight's spacing rules are sibling-type-agnostic except for the
|
|
188
|
+
// "heading after non-heading" rule, which also fires when the
|
|
189
|
+
// previous sibling is a `<p>`.
|
|
190
|
+
for (const tag of BLOCK_PROBE_TAGS) {
|
|
191
|
+
const rule = probeBlockTagInSiblingContext(view, wrapper, tag);
|
|
192
|
+
if (rule)
|
|
193
|
+
rules.push(rule);
|
|
194
|
+
}
|
|
195
|
+
// Inline: always inject inside a synthetic `<p>` (newly added under
|
|
196
|
+
// the wrapper) so font-size / line-height etc. inherit from a
|
|
197
|
+
// paragraph context. Otherwise an anchor we find inside a heading
|
|
198
|
+
// would tell us "links are 35px," and the editor's inline links
|
|
199
|
+
// would render heading-sized. Removed after probing.
|
|
200
|
+
const synthParent = doc.createElement('p');
|
|
201
|
+
synthParent.setAttribute('data-conloca-probe-parent', 'true');
|
|
202
|
+
wrapper.appendChild(synthParent);
|
|
203
|
+
try {
|
|
204
|
+
for (const tag of INLINE_PROBE_TAGS) {
|
|
205
|
+
const rule = probeInlineTag(view, synthParent, tag);
|
|
206
|
+
if (rule)
|
|
207
|
+
rules.push(rule);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
finally {
|
|
211
|
+
synthParent.remove();
|
|
212
|
+
}
|
|
213
|
+
return rules.join('\n');
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Probe a block tag with an injected `<p>` preceding sibling so any
|
|
217
|
+
* adjacent-sibling spacing rules in the host's CSS fire while reading
|
|
218
|
+
* computed styles. This gives the "this element follows other content"
|
|
219
|
+
* margin context that single-sample probing misses.
|
|
220
|
+
*
|
|
221
|
+
* Special-case: when probing `<p>` itself we use another `<p>` as
|
|
222
|
+
* the preceding sibling. For `<li>` and table-cell tags we need to
|
|
223
|
+
* inject them inside a parent (`<ul>`/`<ol>`/`<table>`), preceded by
|
|
224
|
+
* a sibling of the same kind so list-item and cell adjacency rules fire.
|
|
225
|
+
*/
|
|
226
|
+
function probeBlockTagInSiblingContext(view, wrapper, tag) {
|
|
227
|
+
const doc = wrapper.ownerDocument;
|
|
228
|
+
// Build the synthetic context. The element we read is always
|
|
229
|
+
// `target` — everything before it just creates the right adjacency.
|
|
230
|
+
let host;
|
|
231
|
+
let target;
|
|
232
|
+
if (tag === 'li') {
|
|
233
|
+
host = doc.createElement('ul');
|
|
234
|
+
host.appendChild(makeProbeEl(doc, 'li'));
|
|
235
|
+
target = makeProbeEl(doc, 'li');
|
|
236
|
+
host.appendChild(target);
|
|
237
|
+
}
|
|
238
|
+
else if (tag === 'th' || tag === 'td') {
|
|
239
|
+
host = doc.createElement('table');
|
|
240
|
+
const tr1 = doc.createElement('tr');
|
|
241
|
+
tr1.appendChild(makeProbeEl(doc, tag));
|
|
242
|
+
host.appendChild(tr1);
|
|
243
|
+
const tr2 = doc.createElement('tr');
|
|
244
|
+
target = makeProbeEl(doc, tag);
|
|
245
|
+
tr2.appendChild(target);
|
|
246
|
+
host.appendChild(tr2);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
// Standard "block element after a paragraph" context.
|
|
250
|
+
host = doc.createElement('div');
|
|
251
|
+
host.setAttribute('data-conloca-probe-host', 'true');
|
|
252
|
+
host.appendChild(makeProbeEl(doc, 'p'));
|
|
253
|
+
target = makeProbeEl(doc, tag);
|
|
254
|
+
host.appendChild(target);
|
|
255
|
+
}
|
|
256
|
+
host.setAttribute('data-conloca-probe-host', 'true');
|
|
257
|
+
wrapper.appendChild(host);
|
|
258
|
+
try {
|
|
259
|
+
return generateRule(view, target, tag);
|
|
260
|
+
}
|
|
261
|
+
finally {
|
|
262
|
+
host.remove();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/** Properties read directly off the host's prose wrapper. These are the
|
|
266
|
+
* typography "defaults" that hosts conventionally set on body and let
|
|
267
|
+
* inherit down — the wrapper itself rarely overrides them, so its
|
|
268
|
+
* computed values reflect the host's resolved body typography.
|
|
269
|
+
*
|
|
270
|
+
* Excludes margin/padding/border/background: those are wrapper layout
|
|
271
|
+
* concerns that the editor shouldn't inherit (the editor lives inside
|
|
272
|
+
* the CMS SPA shell, not the host's page layout). */
|
|
273
|
+
const WRAPPER_PROBE_PROPS = [
|
|
274
|
+
'font-family',
|
|
275
|
+
'font-size',
|
|
276
|
+
'font-weight',
|
|
277
|
+
'font-style',
|
|
278
|
+
'line-height',
|
|
279
|
+
'letter-spacing',
|
|
280
|
+
'color',
|
|
281
|
+
];
|
|
282
|
+
/**
|
|
283
|
+
* Emit the host wrapper's computed typography as CSS custom properties
|
|
284
|
+
* on `:root`. The editor's `editor-styles.css` reads these via
|
|
285
|
+
* `var(--conloca-host-*)` on `[class*="_contentEditable_"]` to override
|
|
286
|
+
* MDXEditor's bundled typography (`color: var(--baseTextContrast)`,
|
|
287
|
+
* `font-family: var(--font-body)`).
|
|
288
|
+
*
|
|
289
|
+
* Why route through custom properties instead of styling the wrapper
|
|
290
|
+
* directly: MDXEditor's `._contentEditable_*` rule is unlayered, so any
|
|
291
|
+
* layered probe rule loses the cascade regardless of selector
|
|
292
|
+
* specificity. Custom properties inherit through cascade layers and can
|
|
293
|
+
* be consumed by an unlayered rule in `editor-styles.css`, which DOES
|
|
294
|
+
* compete on equal terms with MDXEditor and wins on source order
|
|
295
|
+
* (editor-styles.css is imported after `@mdxeditor/editor/style.css`).
|
|
296
|
+
*
|
|
297
|
+
* Property names: short, namespaced under `--conloca-host-`. Map 1:1 to
|
|
298
|
+
* the inheritance-eligible typography properties that drive prose look.
|
|
299
|
+
*/
|
|
300
|
+
function probeWrapper(view, wrapper) {
|
|
301
|
+
const cs = view.getComputedStyle(wrapper);
|
|
302
|
+
const propMap = {
|
|
303
|
+
'font-family': '--conloca-host-font-family',
|
|
304
|
+
'font-size': '--conloca-host-font-size',
|
|
305
|
+
'font-weight': '--conloca-host-font-weight',
|
|
306
|
+
'font-style': '--conloca-host-font-style',
|
|
307
|
+
'line-height': '--conloca-host-line-height',
|
|
308
|
+
'letter-spacing': '--conloca-host-letter-spacing',
|
|
309
|
+
color: '--conloca-host-color',
|
|
310
|
+
};
|
|
311
|
+
const decls = [];
|
|
312
|
+
for (const prop of WRAPPER_PROBE_PROPS) {
|
|
313
|
+
const value = cs.getPropertyValue(prop);
|
|
314
|
+
if (value && value !== 'normal' && value !== 'none') {
|
|
315
|
+
decls.push(`${propMap[prop]}: ${value}`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (decls.length === 0)
|
|
319
|
+
return '';
|
|
320
|
+
return `:root { ${decls.join('; ')}; }`;
|
|
321
|
+
}
|
|
322
|
+
function makeProbeEl(doc, tag) {
|
|
323
|
+
const el = doc.createElement(tag);
|
|
324
|
+
el.textContent = 'probe';
|
|
325
|
+
el.setAttribute('data-conloca-probe', 'true');
|
|
326
|
+
return el;
|
|
327
|
+
}
|
|
328
|
+
/** Properties that only carry meaning on list-container tags (ul, ol).
|
|
329
|
+
* Inherited by descendants but only renders a marker on actual list
|
|
330
|
+
* items — emitting it on every tag would override `<ol>`'s `decimal`
|
|
331
|
+
* with `<li>`'s inherited `disc` (since `li` is more specific to the
|
|
332
|
+
* rendered element), making ordered lists show bullets instead of
|
|
333
|
+
* numbers. Filtered out for any tag other than ul/ol. */
|
|
334
|
+
const LIST_STYLE_PROPS = new Set(['list-style-type', 'list-style-position']);
|
|
335
|
+
function generateRule(view, sample, tag) {
|
|
336
|
+
const cs = view.getComputedStyle(sample);
|
|
337
|
+
const decls = [];
|
|
338
|
+
const isListContainer = tag === 'ul' || tag === 'ol';
|
|
339
|
+
for (const prop of PROBE_PROPS) {
|
|
340
|
+
if (LIST_STYLE_PROPS.has(prop) && !isListContainer)
|
|
341
|
+
continue;
|
|
342
|
+
const value = cs.getPropertyValue(prop);
|
|
343
|
+
if (value && value !== 'normal' && value !== 'none') {
|
|
344
|
+
decls.push(`${prop}: ${value}`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (decls.length === 0)
|
|
348
|
+
return '';
|
|
349
|
+
// Wrap the wrapper class in `:where()` so the selector has the same
|
|
350
|
+
// specificity as a bare element selector (0,0,1). Without :where(),
|
|
351
|
+
// `.conloca-prose--editor ol` has specificity (0,1,1) — higher than
|
|
352
|
+
// host component rules like `.sl-steps` (0,1,0), so the probe's
|
|
353
|
+
// "ol defaults" override component-specific styling on `<ol>`
|
|
354
|
+
// elements that carry component classes (Steps, Tabs, etc.).
|
|
355
|
+
// With :where() the probe acts as a defaults layer for BARE prose
|
|
356
|
+
// tags: any host class selector targeting the same element wins.
|
|
357
|
+
return `:where(.conloca-prose--editor) ${tag} { ${decls.join('; ')}; }`;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Probe an inline tag inside the given parent (a synthetic `<p>` from
|
|
361
|
+
* the caller). Inline tags need a paragraph context so font-size etc.
|
|
362
|
+
* inherit from the right place — otherwise an `<a>` found inside an
|
|
363
|
+
* `<h2>` would capture heading-sized text.
|
|
364
|
+
*/
|
|
365
|
+
function probeInlineTag(view, parent, tag) {
|
|
366
|
+
const doc = parent.ownerDocument;
|
|
367
|
+
const sample = makeProbeEl(doc, tag);
|
|
368
|
+
parent.appendChild(sample);
|
|
369
|
+
try {
|
|
370
|
+
return generateRule(view, sample, tag);
|
|
371
|
+
}
|
|
372
|
+
finally {
|
|
373
|
+
sample.remove();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Run a one-shot probe against `routeUrl`. Returns the generated
|
|
378
|
+
* stylesheet, or an empty string when the iframe failed to load or
|
|
379
|
+
* the page had no probable elements.
|
|
380
|
+
*
|
|
381
|
+
* `signal` lets the caller cancel a probe (eg the user navigated to
|
|
382
|
+
* a different page mid-fetch). Cleanup is best-effort.
|
|
383
|
+
*/
|
|
384
|
+
export function probeHostStyles(routeUrl, wrapperClass, theme, signal) {
|
|
385
|
+
return new Promise((resolve) => {
|
|
386
|
+
if (typeof document === 'undefined') {
|
|
387
|
+
resolve('');
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
const iframe = document.createElement('iframe');
|
|
391
|
+
// Width chosen so responsive prose styles resolve at their desktop
|
|
392
|
+
// tier (Starlight's `--sl-text-h2` etc. shift via media queries; a
|
|
393
|
+
// narrower probe captures the mobile-ish values which don't match
|
|
394
|
+
// what the editor's user actually sees). 1440px is a sane "desktop"
|
|
395
|
+
// default. The iframe is off-screen and hidden so width affects
|
|
396
|
+
// only CSS resolution, not user-visible layout.
|
|
397
|
+
iframe.style.cssText = 'position:absolute;left:-9999px;top:0;width:1440px;height:900px;visibility:hidden;border:0';
|
|
398
|
+
iframe.setAttribute('aria-hidden', 'true');
|
|
399
|
+
iframe.setAttribute('tabindex', '-1');
|
|
400
|
+
iframe.setAttribute('data-conloca-probe-iframe', '');
|
|
401
|
+
iframe.src = routeUrl;
|
|
402
|
+
let settled = false;
|
|
403
|
+
const cleanup = () => {
|
|
404
|
+
if (iframe.parentElement)
|
|
405
|
+
iframe.parentElement.removeChild(iframe);
|
|
406
|
+
};
|
|
407
|
+
const settle = (css) => {
|
|
408
|
+
if (settled)
|
|
409
|
+
return;
|
|
410
|
+
settled = true;
|
|
411
|
+
cleanup();
|
|
412
|
+
resolve(css);
|
|
413
|
+
};
|
|
414
|
+
const abortHandler = () => settle('');
|
|
415
|
+
signal?.addEventListener('abort', abortHandler);
|
|
416
|
+
const timeout = window.setTimeout(() => {
|
|
417
|
+
console.warn('[Conloca] Host style probe timed out for', routeUrl);
|
|
418
|
+
settle('');
|
|
419
|
+
}, IFRAME_TIMEOUT_MS);
|
|
420
|
+
iframe.addEventListener('load', () => {
|
|
421
|
+
window.clearTimeout(timeout);
|
|
422
|
+
// Force the iframe's theme to MATCH the editor's currently-active
|
|
423
|
+
// theme — not whatever the website's own theme provider resolved
|
|
424
|
+
// from its own localStorage key. The editor and the published
|
|
425
|
+
// page maintain independent theme preferences (the CMS SPA uses
|
|
426
|
+
// `conloca-theme`; Starlight uses `starlight-theme`), so by default
|
|
427
|
+
// the iframe paints in the website's last-saved scheme regardless
|
|
428
|
+
// of what the user is editing in. We override `data-theme` (and
|
|
429
|
+
// mirror as `.dark` class for Tailwind-style hosts) so the probe
|
|
430
|
+
// captures the scheme the editor is rendering, not the published
|
|
431
|
+
// page's stale scheme.
|
|
432
|
+
try {
|
|
433
|
+
const doc = iframe.contentDocument;
|
|
434
|
+
if (doc && theme) {
|
|
435
|
+
doc.documentElement.dataset.theme = theme;
|
|
436
|
+
doc.documentElement.classList.toggle('dark', theme === 'dark');
|
|
437
|
+
doc.documentElement.style.colorScheme = theme;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
catch (err) {
|
|
441
|
+
// Same-origin iframe access can throw if the dev server emitted
|
|
442
|
+
// a sandboxed page; swallow and proceed with the probe anyway —
|
|
443
|
+
// worst case we capture the website's default theme values.
|
|
444
|
+
console.warn('[Conloca] Could not set probe iframe theme:', err);
|
|
445
|
+
}
|
|
446
|
+
// Two rAFs: first lands us after layout, second after the
|
|
447
|
+
// browser has applied any deferred styles (web fonts, etc.) AND
|
|
448
|
+
// any theme-attribute change applied above has propagated through
|
|
449
|
+
// the cascade. 2× rAF is a common idiom for "next paint with
|
|
450
|
+
// fonts ready."
|
|
451
|
+
requestAnimationFrame(() => {
|
|
452
|
+
requestAnimationFrame(() => {
|
|
453
|
+
if (signal?.aborted) {
|
|
454
|
+
settle('');
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
try {
|
|
458
|
+
const doc = iframe.contentDocument;
|
|
459
|
+
if (!doc) {
|
|
460
|
+
settle('');
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
const css = buildProbeStylesheet(doc, wrapperClass);
|
|
464
|
+
settle(css);
|
|
465
|
+
}
|
|
466
|
+
catch (err) {
|
|
467
|
+
console.warn('[Conloca] Host style probe failed:', err);
|
|
468
|
+
settle('');
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
iframe.addEventListener('error', () => {
|
|
474
|
+
window.clearTimeout(timeout);
|
|
475
|
+
settle('');
|
|
476
|
+
});
|
|
477
|
+
document.body.appendChild(iframe);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* React hook wrapper. Re-probes whenever `routeUrl` changes or the
|
|
482
|
+
* document's theme attribute changes (so dark/light swaps refresh
|
|
483
|
+
* the captured styles).
|
|
484
|
+
*
|
|
485
|
+
* Returns the generated stylesheet as a single string. Callers feed
|
|
486
|
+
* it into `useInjectHostStyles` (or any other stylesheet injector)
|
|
487
|
+
* with a sensible layer name.
|
|
488
|
+
*/
|
|
489
|
+
export function useProbedHostStyles(routeUrl, wrapperClass, options = {}) {
|
|
490
|
+
const [css, setCss] = useState('');
|
|
491
|
+
const theme = options.theme ?? null;
|
|
492
|
+
useEffect(() => {
|
|
493
|
+
if (!routeUrl) {
|
|
494
|
+
setCss('');
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const controller = new AbortController();
|
|
498
|
+
probeHostStyles(routeUrl, wrapperClass, theme, controller.signal).then((result) => {
|
|
499
|
+
if (controller.signal.aborted)
|
|
500
|
+
return;
|
|
501
|
+
setCss(result);
|
|
502
|
+
});
|
|
503
|
+
return () => {
|
|
504
|
+
controller.abort();
|
|
505
|
+
};
|
|
506
|
+
}, [routeUrl, wrapperClass, theme]);
|
|
507
|
+
return css;
|
|
508
|
+
}
|