@basicbenframework/cms 0.0.0-stage → 0.6.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/LICENSE +9 -0
- package/README.md +206 -2
- package/db/migrations/001_create_users.js +15 -0
- package/db/migrations/002_create_posts.js +18 -0
- package/db/migrations/003_create_categories.js +19 -0
- package/db/migrations/004_create_tags.js +16 -0
- package/db/migrations/005_create_post_tags.js +16 -0
- package/db/migrations/006_create_pages.js +26 -0
- package/db/migrations/007_create_comments.js +24 -0
- package/db/migrations/008_create_media.js +22 -0
- package/db/migrations/009_update_posts_blogging.js +27 -0
- package/db/migrations/010_create_settings.js +29 -0
- package/db/migrations/011_add_user_roles.js +23 -0
- package/db/migrations/012_create_auth_tokens.js +30 -0
- package/db/migrations/013_add_email_verified.js +24 -0
- package/db/migrations/014_create_user_two_factor.js +30 -0
- package/db/migrations/015_create_user_credentials.js +35 -0
- package/db/migrations/016_create_rate_limits.js +31 -0
- package/db/migrations/017_add_content_html.js +38 -0
- package/db/migrations/018_create_api_tokens.js +34 -0
- package/db/migrations/019_create_post_categories.js +40 -0
- package/db/migrations/020_add_author_profiles.js +60 -0
- package/db/migrations/021_add_page_featured_image.js +23 -0
- package/db/migrations/022_backfill_post_slugs_and_excerpts.js +57 -0
- package/db/migrations/023_add_user_session_controls.js +25 -0
- package/db/migrations/024_add_post_status_and_trash.js +45 -0
- package/db/migrations/025_add_social_and_indexing_fields.js +40 -0
- package/db/migrations/026_create_post_revisions.js +29 -0
- package/db/migrations/027_add_media_dimensions.js +19 -0
- package/db/migrations/028_create_navigation_menus.js +65 -0
- package/db/migrations/029_create_redirects.js +40 -0
- package/db/migrations/030_add_comment_status_and_notifications.js +53 -0
- package/db/migrations/031_create_post_locks.js +38 -0
- package/db/migrations/032_create_snippets.js +31 -0
- package/db/migrations/033_create_members.js +70 -0
- package/db/migrations/034_add_post_visibility.js +28 -0
- package/db/migrations/035_create_newsletters.js +72 -0
- package/db/migrations/036_create_analytics.js +89 -0
- package/db/migrations/037_create_ops_heartbeats.js +30 -0
- package/db/migrations/038_create_content_types.js +84 -0
- package/db/migrations/039_create_content_type_fields.js +47 -0
- package/db/migrations/040_create_taxonomies.js +80 -0
- package/db/migrations/041_add_newsletter_handoff.js +28 -0
- package/db/migrations/042_create_mysendbox_contacts.js +63 -0
- package/lib/cli/backup.d.mts +2 -0
- package/lib/cli/backup.mjs +124 -0
- package/lib/cli/export.d.mts +2 -0
- package/lib/cli/export.mjs +54 -0
- package/lib/cli/import-ghost.d.mts +2 -0
- package/lib/cli/import-ghost.mjs +50 -0
- package/lib/cli/import-json.d.mts +2 -0
- package/lib/cli/import-json.mjs +61 -0
- package/lib/cli/import-wordpress.d.mts +2 -0
- package/lib/cli/import-wordpress.mjs +169 -0
- package/lib/cli/import-wxr.d.mts +2 -0
- package/lib/cli/import-wxr.mjs +55 -0
- package/lib/cli/index.d.mts +2 -0
- package/lib/cli/index.mjs +53 -0
- package/lib/cli/lib/backup.d.mts +112 -0
- package/lib/cli/lib/backup.mjs +297 -0
- package/lib/cli/lib/ghost.d.mts +30 -0
- package/lib/cli/lib/ghost.mjs +201 -0
- package/lib/cli/lib/html-to-markdown.d.mts +61 -0
- package/lib/cli/lib/html-to-markdown.mjs +523 -0
- package/lib/cli/lib/import-common.d.mts +100 -0
- package/lib/cli/lib/import-common.mjs +252 -0
- package/lib/cli/lib/json-import.d.mts +22 -0
- package/lib/cli/lib/json-import.mjs +422 -0
- package/lib/cli/lib/site-import.d.mts +32 -0
- package/lib/cli/lib/site-import.mjs +456 -0
- package/lib/cli/lib/wordpress-rest.d.mts +25 -0
- package/lib/cli/lib/wordpress-rest.mjs +177 -0
- package/lib/cli/lib/wxr.d.mts +18 -0
- package/lib/cli/lib/wxr.mjs +307 -0
- package/lib/cli/lib/xml.d.mts +33 -0
- package/lib/cli/lib/xml.mjs +186 -0
- package/lib/cli/restore.d.mts +2 -0
- package/lib/cli/restore.mjs +98 -0
- package/lib/client/components/Alert.d.ts +7 -0
- package/lib/client/components/Alert.js +8 -0
- package/lib/client/components/Avatar.d.ts +15 -0
- package/lib/client/components/Avatar.js +10 -0
- package/lib/client/components/BackLink.d.ts +7 -0
- package/lib/client/components/BackLink.js +6 -0
- package/lib/client/components/Button.d.ts +7 -0
- package/lib/client/components/Button.js +12 -0
- package/lib/client/components/Card.d.ts +7 -0
- package/lib/client/components/Card.js +6 -0
- package/lib/client/components/CommentThread.d.ts +15 -0
- package/lib/client/components/CommentThread.js +101 -0
- package/lib/client/components/Empty.d.ts +6 -0
- package/lib/client/components/Empty.js +6 -0
- package/lib/client/components/Input.d.ts +6 -0
- package/lib/client/components/Input.js +6 -0
- package/lib/client/components/Link.d.ts +31 -0
- package/lib/client/components/Link.js +49 -0
- package/lib/client/components/Loading.d.ts +1 -0
- package/lib/client/components/Loading.js +6 -0
- package/lib/client/components/Logo.d.ts +5 -0
- package/lib/client/components/Logo.js +4 -0
- package/lib/client/components/MarkdownEditor.d.ts +41 -0
- package/lib/client/components/MarkdownEditor.js +156 -0
- package/lib/client/components/Nav/DarkModeToggle.d.ts +6 -0
- package/lib/client/components/Nav/DarkModeToggle.js +6 -0
- package/lib/client/components/Nav/DesktopNav.d.ts +8 -0
- package/lib/client/components/Nav/DesktopNav.js +9 -0
- package/lib/client/components/Nav/MobileNav.d.ts +9 -0
- package/lib/client/components/Nav/MobileNav.js +15 -0
- package/lib/client/components/NavLink.d.ts +8 -0
- package/lib/client/components/NavLink.js +6 -0
- package/lib/client/components/PageHeader.d.ts +8 -0
- package/lib/client/components/PageHeader.js +6 -0
- package/lib/client/components/PostCard.d.ts +8 -0
- package/lib/client/components/PostCard.js +7 -0
- package/lib/client/components/Textarea.d.ts +6 -0
- package/lib/client/components/Textarea.js +6 -0
- package/lib/client/components/ThemeContext.d.ts +18 -0
- package/lib/client/components/ThemeContext.js +8 -0
- package/lib/client/components/admin/AdminIcons.d.ts +13 -0
- package/lib/client/components/admin/AdminIcons.js +66 -0
- package/lib/client/components/admin/ContentModelPanels.d.ts +22 -0
- package/lib/client/components/admin/ContentModelPanels.js +93 -0
- package/lib/client/components/admin/FeaturedImageBox.d.ts +21 -0
- package/lib/client/components/admin/FeaturedImageBox.js +24 -0
- package/lib/client/components/admin/MediaGrid.d.ts +23 -0
- package/lib/client/components/admin/MediaGrid.js +69 -0
- package/lib/client/components/admin/MediaPicker.d.ts +17 -0
- package/lib/client/components/admin/MediaPicker.js +61 -0
- package/lib/client/components/admin/Pagination.d.ts +27 -0
- package/lib/client/components/admin/Pagination.js +29 -0
- package/lib/client/components/admin/SnippetPicker.d.ts +27 -0
- package/lib/client/components/admin/SnippetPicker.js +65 -0
- package/lib/client/components/admin/TermPicker.d.ts +52 -0
- package/lib/client/components/admin/TermPicker.js +58 -0
- package/lib/client/contexts/ToastContext.d.ts +12 -0
- package/lib/client/contexts/ToastContext.js +49 -0
- package/lib/client/features.d.ts +11 -0
- package/lib/client/features.js +7 -0
- package/lib/client/hooks/useContentTypes.d.ts +48 -0
- package/lib/client/hooks/useContentTypes.js +48 -0
- package/lib/client/hooks/useMediaLibrary.d.ts +46 -0
- package/lib/client/hooks/useMediaLibrary.js +189 -0
- package/lib/client/hooks/usePostLock.d.ts +32 -0
- package/lib/client/hooks/usePostLock.js +107 -0
- package/lib/client/host/index.d.ts +71 -0
- package/lib/client/host/index.js +58 -0
- package/lib/client/i18n/index.d.ts +79 -0
- package/lib/client/i18n/index.js +177 -0
- package/lib/client/i18n/locales/es/content.d.ts +4 -0
- package/lib/client/i18n/locales/es/content.js +220 -0
- package/lib/client/i18n/locales/es/editor.d.ts +9 -0
- package/lib/client/i18n/locales/es/editor.js +144 -0
- package/lib/client/i18n/locales/es/index.d.ts +8 -0
- package/lib/client/i18n/locales/es/index.js +7 -0
- package/lib/client/i18n/locales/es/layout.d.ts +4 -0
- package/lib/client/i18n/locales/es/layout.js +35 -0
- package/lib/client/i18n/locales/es/people.d.ts +4 -0
- package/lib/client/i18n/locales/es/people.js +187 -0
- package/lib/client/i18n/locales/es/site.d.ts +4 -0
- package/lib/client/i18n/locales/es/site.js +208 -0
- package/lib/client/layouts/AdminLayout.d.ts +7 -0
- package/lib/client/layouts/AdminLayout.js +1046 -0
- package/lib/client/layouts/AppLayout.d.ts +6 -0
- package/lib/client/layouts/AppLayout.js +19 -0
- package/lib/client/layouts/AuthLayout.d.ts +6 -0
- package/lib/client/layouts/AuthLayout.js +14 -0
- package/lib/client/layouts/DocsLayout.d.ts +6 -0
- package/lib/client/layouts/DocsLayout.js +28 -0
- package/lib/client/layouts/RootLayout.d.ts +6 -0
- package/lib/client/layouts/RootLayout.js +11 -0
- package/lib/client/pages/AcceptInvite.d.ts +8 -0
- package/lib/client/pages/AcceptInvite.js +60 -0
- package/lib/client/pages/Auth.d.ts +1 -0
- package/lib/client/pages/Auth.js +40 -0
- package/lib/client/pages/Authentication.d.ts +1 -0
- package/lib/client/pages/Authentication.js +230 -0
- package/lib/client/pages/Content.d.ts +1 -0
- package/lib/client/pages/Content.js +21 -0
- package/lib/client/pages/Database.d.ts +1 -0
- package/lib/client/pages/Database.js +264 -0
- package/lib/client/pages/Extending.d.ts +1 -0
- package/lib/client/pages/Extending.js +28 -0
- package/lib/client/pages/Feed.d.ts +1 -0
- package/lib/client/pages/Feed.js +19 -0
- package/lib/client/pages/FeedPost.d.ts +1 -0
- package/lib/client/pages/FeedPost.js +31 -0
- package/lib/client/pages/ForgotPassword.d.ts +8 -0
- package/lib/client/pages/ForgotPassword.js +38 -0
- package/lib/client/pages/GettingStarted.d.ts +1 -0
- package/lib/client/pages/GettingStarted.js +84 -0
- package/lib/client/pages/Headless.d.ts +1 -0
- package/lib/client/pages/Headless.js +49 -0
- package/lib/client/pages/Home.d.ts +1 -0
- package/lib/client/pages/Home.js +67 -0
- package/lib/client/pages/PostForm.d.ts +1 -0
- package/lib/client/pages/PostForm.js +55 -0
- package/lib/client/pages/Posts.d.ts +1 -0
- package/lib/client/pages/Posts.js +35 -0
- package/lib/client/pages/Profile.d.ts +1 -0
- package/lib/client/pages/Profile.js +153 -0
- package/lib/client/pages/ResetPassword.d.ts +8 -0
- package/lib/client/pages/ResetPassword.js +52 -0
- package/lib/client/pages/Routing.d.ts +1 -0
- package/lib/client/pages/Routing.js +192 -0
- package/lib/client/pages/Storage.d.ts +1 -0
- package/lib/client/pages/Storage.js +54 -0
- package/lib/client/pages/Testing.d.ts +1 -0
- package/lib/client/pages/Testing.js +141 -0
- package/lib/client/pages/Validation.d.ts +1 -0
- package/lib/client/pages/Validation.js +123 -0
- package/lib/client/pages/admin/Categories.d.ts +2 -0
- package/lib/client/pages/admin/Categories.js +75 -0
- package/lib/client/pages/admin/Comments.d.ts +11 -0
- package/lib/client/pages/admin/Comments.js +247 -0
- package/lib/client/pages/admin/ContentTypes.d.ts +2 -0
- package/lib/client/pages/admin/ContentTypes.js +163 -0
- package/lib/client/pages/admin/Dashboard.d.ts +2 -0
- package/lib/client/pages/admin/Dashboard.js +66 -0
- package/lib/client/pages/admin/Health.d.ts +12 -0
- package/lib/client/pages/admin/Health.js +148 -0
- package/lib/client/pages/admin/Media.d.ts +2 -0
- package/lib/client/pages/admin/Media.js +101 -0
- package/lib/client/pages/admin/Navigation.d.ts +9 -0
- package/lib/client/pages/admin/Navigation.js +230 -0
- package/lib/client/pages/admin/Pages.d.ts +2 -0
- package/lib/client/pages/admin/Pages.js +53 -0
- package/lib/client/pages/admin/PostEditor.d.ts +17 -0
- package/lib/client/pages/admin/PostEditor.js +532 -0
- package/lib/client/pages/admin/Posts.d.ts +2 -0
- package/lib/client/pages/admin/Posts.js +152 -0
- package/lib/client/pages/admin/Redirects.d.ts +10 -0
- package/lib/client/pages/admin/Redirects.js +87 -0
- package/lib/client/pages/admin/Settings.d.ts +2 -0
- package/lib/client/pages/admin/Settings.js +111 -0
- package/lib/client/pages/admin/Snippets.d.ts +14 -0
- package/lib/client/pages/admin/Snippets.js +85 -0
- package/lib/client/pages/admin/Tags.d.ts +2 -0
- package/lib/client/pages/admin/Tags.js +74 -0
- package/lib/client/pages/admin/Taxonomies.d.ts +2 -0
- package/lib/client/pages/admin/Taxonomies.js +130 -0
- package/lib/client/pages/admin/Tokens.d.ts +9 -0
- package/lib/client/pages/admin/Tokens.js +260 -0
- package/lib/client/pages/admin/Tools.d.ts +12 -0
- package/lib/client/pages/admin/Tools.js +111 -0
- package/lib/client/pages/admin/Users.d.ts +13 -0
- package/lib/client/pages/admin/Users.js +313 -0
- package/lib/client/pages/api-reference.d.ts +33 -0
- package/lib/client/pages/api-reference.js +198 -0
- package/lib/client/styles.css +37 -0
- package/lib/config.d.ts +24 -0
- package/lib/config.js +39 -0
- package/lib/controllers/AdminController.d.ts +46 -0
- package/lib/controllers/AdminController.js +134 -0
- package/lib/controllers/AuthController.d.ts +15 -0
- package/lib/controllers/AuthController.js +194 -0
- package/lib/controllers/AuthorController.d.ts +17 -0
- package/lib/controllers/AuthorController.js +19 -0
- package/lib/controllers/CategoryController.d.ts +10 -0
- package/lib/controllers/CategoryController.js +88 -0
- package/lib/controllers/CommentController.d.ts +68 -0
- package/lib/controllers/CommentController.js +438 -0
- package/lib/controllers/ContentTypeController.d.ts +24 -0
- package/lib/controllers/ContentTypeController.js +91 -0
- package/lib/controllers/EmailVerificationController.d.ts +33 -0
- package/lib/controllers/EmailVerificationController.js +116 -0
- package/lib/controllers/ExportController.d.ts +15 -0
- package/lib/controllers/ExportController.js +41 -0
- package/lib/controllers/FeedController.d.ts +14 -0
- package/lib/controllers/FeedController.js +246 -0
- package/lib/controllers/HealthController.d.ts +21 -0
- package/lib/controllers/HealthController.js +176 -0
- package/lib/controllers/HomeController.d.ts +12 -0
- package/lib/controllers/HomeController.js +16 -0
- package/lib/controllers/MediaController.d.ts +24 -0
- package/lib/controllers/MediaController.js +189 -0
- package/lib/controllers/NavigationController.d.ts +22 -0
- package/lib/controllers/NavigationController.js +176 -0
- package/lib/controllers/PageController.d.ts +13 -0
- package/lib/controllers/PageController.js +172 -0
- package/lib/controllers/PasskeyController.d.ts +36 -0
- package/lib/controllers/PasskeyController.js +201 -0
- package/lib/controllers/PasswordResetController.d.ts +44 -0
- package/lib/controllers/PasswordResetController.js +160 -0
- package/lib/controllers/PostController.d.ts +51 -0
- package/lib/controllers/PostController.js +538 -0
- package/lib/controllers/PostLockController.d.ts +62 -0
- package/lib/controllers/PostLockController.js +101 -0
- package/lib/controllers/ProfileController.d.ts +13 -0
- package/lib/controllers/ProfileController.js +160 -0
- package/lib/controllers/PublicApiController.d.ts +23 -0
- package/lib/controllers/PublicApiController.js +100 -0
- package/lib/controllers/RedirectController.d.ts +32 -0
- package/lib/controllers/RedirectController.js +95 -0
- package/lib/controllers/SettingsController.d.ts +28 -0
- package/lib/controllers/SettingsController.js +105 -0
- package/lib/controllers/SnippetController.d.ts +27 -0
- package/lib/controllers/SnippetController.js +123 -0
- package/lib/controllers/TagController.d.ts +9 -0
- package/lib/controllers/TagController.js +70 -0
- package/lib/controllers/TaxonomyController.d.ts +24 -0
- package/lib/controllers/TaxonomyController.js +149 -0
- package/lib/controllers/TokenController.d.ts +27 -0
- package/lib/controllers/TokenController.js +83 -0
- package/lib/controllers/TwoFactorController.d.ts +31 -0
- package/lib/controllers/TwoFactorController.js +213 -0
- package/lib/controllers/UserController.d.ts +110 -0
- package/lib/controllers/UserController.js +504 -0
- package/lib/features/analytics/AnalyticsPage.d.ts +11 -0
- package/lib/features/analytics/AnalyticsPage.js +123 -0
- package/lib/features/analytics/admin.d.ts +3 -0
- package/lib/features/analytics/admin.js +9 -0
- package/lib/features/analytics/controller.d.ts +19 -0
- package/lib/features/analytics/controller.js +79 -0
- package/lib/features/analytics/helpers.d.ts +84 -0
- package/lib/features/analytics/helpers.js +181 -0
- package/lib/features/analytics/i18n/es.d.ts +4 -0
- package/lib/features/analytics/i18n/es.js +31 -0
- package/lib/features/analytics/index.d.ts +28 -0
- package/lib/features/analytics/index.js +91 -0
- package/lib/features/analytics/manifest.d.ts +8 -0
- package/lib/features/analytics/manifest.js +18 -0
- package/lib/features/analytics/model.d.ts +130 -0
- package/lib/features/analytics/model.js +206 -0
- package/lib/features/members/Member.d.ts +93 -0
- package/lib/features/members/Member.js +194 -0
- package/lib/features/members/MemberAdminController.d.ts +60 -0
- package/lib/features/members/MemberAdminController.js +262 -0
- package/lib/features/members/MemberController.d.ts +88 -0
- package/lib/features/members/MemberController.js +250 -0
- package/lib/features/members/MembersPage.d.ts +10 -0
- package/lib/features/members/MembersPage.js +216 -0
- package/lib/features/members/PostAccessBox.d.ts +15 -0
- package/lib/features/members/PostAccessBox.js +70 -0
- package/lib/features/members/admin.d.ts +3 -0
- package/lib/features/members/admin.js +12 -0
- package/lib/features/members/csv.d.ts +21 -0
- package/lib/features/members/csv.js +74 -0
- package/lib/features/members/events.d.ts +34 -0
- package/lib/features/members/events.js +34 -0
- package/lib/features/members/i18n/es.d.ts +4 -0
- package/lib/features/members/i18n/es.js +106 -0
- package/lib/features/members/index.d.ts +44 -0
- package/lib/features/members/index.js +106 -0
- package/lib/features/members/manifest.d.ts +8 -0
- package/lib/features/members/manifest.js +18 -0
- package/lib/features/members/middleware.d.ts +42 -0
- package/lib/features/members/middleware.js +74 -0
- package/lib/features/members/newsletter.d.ts +177 -0
- package/lib/features/members/newsletter.js +439 -0
- package/lib/features/members/rate-limits.d.ts +34 -0
- package/lib/features/members/rate-limits.js +50 -0
- package/lib/features/members/request.d.ts +13 -0
- package/lib/features/members/request.js +6 -0
- package/lib/features/members/routes.d.ts +15 -0
- package/lib/features/members/routes.js +59 -0
- package/lib/features/members/session.d.ts +102 -0
- package/lib/features/members/session.js +158 -0
- package/lib/features/members/settings.d.ts +14 -0
- package/lib/features/members/settings.js +23 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.d.ts +7 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.js +48 -0
- package/lib/features/mysendbox/admin.d.ts +3 -0
- package/lib/features/mysendbox/admin.js +9 -0
- package/lib/features/mysendbox/broadcasts.d.ts +61 -0
- package/lib/features/mysendbox/broadcasts.js +124 -0
- package/lib/features/mysendbox/client.d.ts +95 -0
- package/lib/features/mysendbox/client.js +61 -0
- package/lib/features/mysendbox/config.d.ts +27 -0
- package/lib/features/mysendbox/config.js +74 -0
- package/lib/features/mysendbox/contacts.d.ts +121 -0
- package/lib/features/mysendbox/contacts.js +378 -0
- package/lib/features/mysendbox/controller.d.ts +11 -0
- package/lib/features/mysendbox/controller.js +47 -0
- package/lib/features/mysendbox/i18n/es.d.ts +4 -0
- package/lib/features/mysendbox/i18n/es.js +28 -0
- package/lib/features/mysendbox/index.d.ts +18 -0
- package/lib/features/mysendbox/index.js +71 -0
- package/lib/features/mysendbox/manifest.d.ts +7 -0
- package/lib/features/mysendbox/manifest.js +6 -0
- package/lib/features/mysendbox/routes.d.ts +6 -0
- package/lib/features/mysendbox/routes.js +14 -0
- package/lib/features/mysendbox/webhook.d.ts +23 -0
- package/lib/features/mysendbox/webhook.js +104 -0
- package/lib/features/theme/OEmbedController.d.ts +31 -0
- package/lib/features/theme/OEmbedController.js +128 -0
- package/lib/features/theme/ThemeController.d.ts +20 -0
- package/lib/features/theme/ThemeController.js +256 -0
- package/lib/features/theme/ThemeSettingsCard.d.ts +7 -0
- package/lib/features/theme/ThemeSettingsCard.js +12 -0
- package/lib/features/theme/admin.d.ts +3 -0
- package/lib/features/theme/admin.js +9 -0
- package/lib/features/theme/html.d.ts +48 -0
- package/lib/features/theme/html.js +97 -0
- package/lib/features/theme/i18n/es.d.ts +4 -0
- package/lib/features/theme/i18n/es.js +9 -0
- package/lib/features/theme/index.d.ts +11 -0
- package/lib/features/theme/index.js +23 -0
- package/lib/features/theme/manifest.d.ts +7 -0
- package/lib/features/theme/manifest.js +6 -0
- package/lib/features/theme/oembed.d.ts +36 -0
- package/lib/features/theme/oembed.js +58 -0
- package/lib/features/theme/routes.d.ts +17 -0
- package/lib/features/theme/routes.js +54 -0
- package/lib/features/theme/templates.d.ts +103 -0
- package/lib/features/theme/templates.js +283 -0
- package/lib/features.d.ts +15 -0
- package/lib/features.js +6 -0
- package/lib/features.manifest.d.ts +10 -0
- package/lib/features.manifest.js +6 -0
- package/lib/helpers/access.d.ts +62 -0
- package/lib/helpers/access.js +92 -0
- package/lib/helpers/api.d.ts +20 -0
- package/lib/helpers/api.js +44 -0
- package/lib/helpers/comment-guard.d.ts +145 -0
- package/lib/helpers/comment-guard.js +253 -0
- package/lib/helpers/comment-mail.d.ts +53 -0
- package/lib/helpers/comment-mail.js +188 -0
- package/lib/helpers/content-model.d.ts +50 -0
- package/lib/helpers/content-model.js +84 -0
- package/lib/helpers/content-paths.d.ts +107 -0
- package/lib/helpers/content-paths.js +200 -0
- package/lib/helpers/export-data.d.ts +85 -0
- package/lib/helpers/export-data.js +229 -0
- package/lib/helpers/gating.d.ts +53 -0
- package/lib/helpers/gating.js +83 -0
- package/lib/helpers/health.d.ts +91 -0
- package/lib/helpers/health.js +279 -0
- package/lib/helpers/heartbeat.d.ts +35 -0
- package/lib/helpers/heartbeat.js +55 -0
- package/lib/helpers/image-size.d.ts +18 -0
- package/lib/helpers/image-size.js +83 -0
- package/lib/helpers/images.d.ts +29 -0
- package/lib/helpers/images.js +41 -0
- package/lib/helpers/mail-templates.d.ts +11 -0
- package/lib/helpers/mail-templates.js +42 -0
- package/lib/helpers/publish-due.d.ts +28 -0
- package/lib/helpers/publish-due.js +67 -0
- package/lib/helpers/redirects.d.ts +43 -0
- package/lib/helpers/redirects.js +80 -0
- package/lib/helpers/seo-fields.d.ts +13 -0
- package/lib/helpers/seo-fields.js +52 -0
- package/lib/helpers/session.d.ts +30 -0
- package/lib/helpers/session.js +27 -0
- package/lib/helpers/site-settings.d.ts +98 -0
- package/lib/helpers/site-settings.js +232 -0
- package/lib/helpers/site.d.ts +14 -0
- package/lib/helpers/site.js +23 -0
- package/lib/helpers/write-hooks.d.ts +33 -0
- package/lib/helpers/write-hooks.js +37 -0
- package/lib/hooks.d.ts +17 -0
- package/lib/hooks.js +101 -0
- package/lib/host/core-tasks.d.ts +4 -0
- package/lib/host/core-tasks.js +26 -0
- package/lib/host/cron.d.ts +39 -0
- package/lib/host/cron.js +85 -0
- package/lib/host/enabled.d.ts +4 -0
- package/lib/host/enabled.js +40 -0
- package/lib/host/index.d.ts +81 -0
- package/lib/host/index.js +87 -0
- package/lib/host/manifest.d.ts +34 -0
- package/lib/host/manifest.js +7 -0
- package/lib/host/menu.d.ts +18 -0
- package/lib/host/menu.js +15 -0
- package/lib/main.d.ts +1 -0
- package/lib/main.js +24 -0
- package/lib/middleware/api-auth.d.ts +59 -0
- package/lib/middleware/api-auth.js +164 -0
- package/lib/middleware/auth.d.ts +49 -0
- package/lib/middleware/auth.js +112 -0
- package/lib/middleware/cache.d.ts +17 -0
- package/lib/middleware/cache.js +52 -0
- package/lib/middleware/rate-limits.d.ts +199 -0
- package/lib/middleware/rate-limits.js +276 -0
- package/lib/middleware/viewer.d.ts +13 -0
- package/lib/middleware/viewer.js +16 -0
- package/lib/models/Category.d.ts +24 -0
- package/lib/models/Category.js +102 -0
- package/lib/models/Comment.d.ts +120 -0
- package/lib/models/Comment.js +283 -0
- package/lib/models/ContentType.d.ts +142 -0
- package/lib/models/ContentType.js +462 -0
- package/lib/models/Credential.d.ts +21 -0
- package/lib/models/Credential.js +31 -0
- package/lib/models/Media.d.ts +53 -0
- package/lib/models/Media.js +132 -0
- package/lib/models/Menu.d.ts +131 -0
- package/lib/models/Menu.js +312 -0
- package/lib/models/Page.d.ts +55 -0
- package/lib/models/Page.js +218 -0
- package/lib/models/Post.d.ts +136 -0
- package/lib/models/Post.js +406 -0
- package/lib/models/PostLock.d.ts +67 -0
- package/lib/models/PostLock.js +112 -0
- package/lib/models/PostRevision.d.ts +45 -0
- package/lib/models/PostRevision.js +82 -0
- package/lib/models/PublicContent.d.ts +283 -0
- package/lib/models/PublicContent.js +577 -0
- package/lib/models/Redirect.d.ts +123 -0
- package/lib/models/Redirect.js +225 -0
- package/lib/models/Settings.d.ts +61 -0
- package/lib/models/Settings.js +128 -0
- package/lib/models/Snippet.d.ts +36 -0
- package/lib/models/Snippet.js +64 -0
- package/lib/models/Tag.d.ts +23 -0
- package/lib/models/Tag.js +117 -0
- package/lib/models/Taxonomy.d.ts +127 -0
- package/lib/models/Taxonomy.js +321 -0
- package/lib/models/TwoFactor.d.ts +26 -0
- package/lib/models/TwoFactor.js +60 -0
- package/lib/models/User.d.ts +49 -0
- package/lib/models/User.js +128 -0
- package/lib/models/derive.d.ts +69 -0
- package/lib/models/derive.js +81 -0
- package/lib/models/pagination.d.ts +30 -0
- package/lib/models/pagination.js +36 -0
- package/lib/models/visibility.d.ts +31 -0
- package/lib/models/visibility.js +47 -0
- package/lib/routes/App.d.ts +2 -0
- package/lib/routes/App.js +146 -0
- package/lib/routes/api/admin.d.ts +6 -0
- package/lib/routes/api/admin.js +11 -0
- package/lib/routes/api/auth.d.ts +6 -0
- package/lib/routes/api/auth.js +24 -0
- package/lib/routes/api/authors.d.ts +5 -0
- package/lib/routes/api/authors.js +8 -0
- package/lib/routes/api/categories.d.ts +8 -0
- package/lib/routes/api/categories.js +15 -0
- package/lib/routes/api/comments.d.ts +8 -0
- package/lib/routes/api/comments.js +35 -0
- package/lib/routes/api/content-model.d.ts +17 -0
- package/lib/routes/api/content-model.js +67 -0
- package/lib/routes/api/cron.d.ts +6 -0
- package/lib/routes/api/cron.js +9 -0
- package/lib/routes/api/export.d.ts +5 -0
- package/lib/routes/api/export.js +11 -0
- package/lib/routes/api/feed.d.ts +5 -0
- package/lib/routes/api/feed.js +16 -0
- package/lib/routes/api/media.d.ts +8 -0
- package/lib/routes/api/media.js +25 -0
- package/lib/routes/api/navigation.d.ts +12 -0
- package/lib/routes/api/navigation.js +17 -0
- package/lib/routes/api/ops.d.ts +9 -0
- package/lib/routes/api/ops.js +19 -0
- package/lib/routes/api/pages.d.ts +8 -0
- package/lib/routes/api/pages.js +21 -0
- package/lib/routes/api/passkeys.d.ts +7 -0
- package/lib/routes/api/passkeys.js +13 -0
- package/lib/routes/api/posts.d.ts +8 -0
- package/lib/routes/api/posts.js +39 -0
- package/lib/routes/api/profile.d.ts +6 -0
- package/lib/routes/api/profile.js +8 -0
- package/lib/routes/api/redirects.d.ts +12 -0
- package/lib/routes/api/redirects.js +13 -0
- package/lib/routes/api/settings.d.ts +8 -0
- package/lib/routes/api/settings.js +15 -0
- package/lib/routes/api/snippets.d.ts +15 -0
- package/lib/routes/api/snippets.js +16 -0
- package/lib/routes/api/tags.d.ts +8 -0
- package/lib/routes/api/tags.js +14 -0
- package/lib/routes/api/tokens.d.ts +7 -0
- package/lib/routes/api/tokens.js +15 -0
- package/lib/routes/api/two-factor.d.ts +7 -0
- package/lib/routes/api/two-factor.js +15 -0
- package/lib/routes/api/users.d.ts +8 -0
- package/lib/routes/api/users.js +25 -0
- package/lib/routes/api/v1.d.ts +12 -0
- package/lib/routes/api/v1.js +55 -0
- package/lib/routes/api/verification.d.ts +6 -0
- package/lib/routes/api/verification.js +11 -0
- package/lib/server/index.d.ts +24 -0
- package/lib/server/index.js +110 -0
- package/lib/types/index.d.ts +298 -0
- package/lib/types/index.js +1 -0
- package/lib/vite.d.ts +2 -0
- package/lib/vite.js +101 -0
- package/mail/comment-moderation.html +27 -0
- package/mail/comment-moderation.txt +13 -0
- package/mail/comment-reply.html +28 -0
- package/mail/comment-reply.txt +14 -0
- package/mail/invitation.html +25 -0
- package/mail/invitation.txt +11 -0
- package/mail/member-magic-link.html +23 -0
- package/mail/member-magic-link.txt +10 -0
- package/mail/newsletter.html +26 -0
- package/mail/newsletter.txt +13 -0
- package/mail/password-reset.html +26 -0
- package/mail/password-reset.txt +10 -0
- package/mail/verify-email.html +25 -0
- package/mail/verify-email.txt +8 -0
- package/package.json +85 -4
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useRef } from 'react';
|
|
3
|
+
import { useAuth, useNavigate, useParams, usePath } from '@basicbenframework/core/client';
|
|
4
|
+
import { api } from "../../../helpers/api.js";
|
|
5
|
+
import AdminLayout from "../../layouts/AdminLayout.js";
|
|
6
|
+
import MarkdownEditor from "../../components/MarkdownEditor.js";
|
|
7
|
+
import { excerpt, slugify } from '@basicbenframework/core/content';
|
|
8
|
+
import FeaturedImageBox from "../../components/admin/FeaturedImageBox.js";
|
|
9
|
+
import { Slot, hasFills } from "../../host/index.js";
|
|
10
|
+
import TermPicker from "../../components/admin/TermPicker.js";
|
|
11
|
+
import SnippetPicker from "../../components/admin/SnippetPicker.js";
|
|
12
|
+
import { usePostLock } from "../../hooks/usePostLock.js";
|
|
13
|
+
import { useContentTypes, typeFromQuery, navigateWithType } from "../../hooks/useContentTypes.js";
|
|
14
|
+
import { CustomFieldsPanel, CustomTermsPanel } from "../../components/admin/ContentModelPanels.js";
|
|
15
|
+
import { Link } from "../../components/Link.js";
|
|
16
|
+
import { can } from '@basicbenframework/core/auth/permissions';
|
|
17
|
+
import { useT, slots } from "../../i18n/index.js";
|
|
18
|
+
/** How often an unsaved change is autosaved, in milliseconds. */
|
|
19
|
+
const AUTOSAVE_EVERY = 30_000;
|
|
20
|
+
/** A stored UTC timestamp as the value a datetime-local input wants. */
|
|
21
|
+
function toLocalInput(value) {
|
|
22
|
+
if (!value)
|
|
23
|
+
return '';
|
|
24
|
+
const date = new Date(/Z|[+-]\d\d:?\d\d$/.test(value) ? value : value.replace(' ', 'T') + 'Z');
|
|
25
|
+
if (Number.isNaN(date.getTime()))
|
|
26
|
+
return '';
|
|
27
|
+
const offset = date.getTimezoneOffset() * 60_000;
|
|
28
|
+
return new Date(date.getTime() - offset).toISOString().slice(0, 16);
|
|
29
|
+
}
|
|
30
|
+
/** A datetime-local value, which is local time, as ISO UTC for the server. */
|
|
31
|
+
function fromLocalInput(value) {
|
|
32
|
+
if (!value)
|
|
33
|
+
return null;
|
|
34
|
+
const date = new Date(value);
|
|
35
|
+
return Number.isNaN(date.getTime()) ? null : date.toISOString();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* What the server would write as the excerpt, shown as a placeholder.
|
|
39
|
+
*
|
|
40
|
+
* The same function it uses, so the preview cannot promise one summary and
|
|
41
|
+
* store another. Trimmed harder than the stored one: this is a hint in a box,
|
|
42
|
+
* not the summary itself.
|
|
43
|
+
*/
|
|
44
|
+
function summaryOf(content) {
|
|
45
|
+
return excerpt(content || '', 120);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A translated sentence with the `{name}` in it set in bold. The placeholder
|
|
49
|
+
* survives `t()` when no value is given for it, so the whole sentence is
|
|
50
|
+
* translated as one and the name is dropped in here.
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* The editor, for a post or for a page.
|
|
54
|
+
*
|
|
55
|
+
* `/admin/pages/new` has always opened this component, and this component has
|
|
56
|
+
* always saved to `/api/posts` — so creating a page from the Pages screen
|
|
57
|
+
* created a post, which then did not appear in the list you came from. The
|
|
58
|
+
* content type is taken from the path instead, the way the router already
|
|
59
|
+
* distinguishes them, and the boxes that only make sense for a post are hidden
|
|
60
|
+
* for a page: a page has no categories, tags, author byline or excerpt.
|
|
61
|
+
*/
|
|
62
|
+
export default function AdminPostEditor() {
|
|
63
|
+
const navigate = useNavigate();
|
|
64
|
+
const params = useParams();
|
|
65
|
+
const path = usePath();
|
|
66
|
+
const { user } = useAuth();
|
|
67
|
+
const { t } = useT();
|
|
68
|
+
const isPage = path.startsWith('/admin/pages');
|
|
69
|
+
const resource = isPage ? 'pages' : 'posts';
|
|
70
|
+
// Content types (Phase 3): a post may be a recipe, a product... The type
|
|
71
|
+
// comes from the saved post, or `?type=` for a new one; its `supports`
|
|
72
|
+
// decide which panels show, and its fields get a panel of their own.
|
|
73
|
+
const { types: contentTypes } = useContentTypes();
|
|
74
|
+
const [postType, setPostType] = useState(typeFromQuery() || 'post');
|
|
75
|
+
const [customFields, setCustomFields] = useState({});
|
|
76
|
+
const [termIds, setTermIds] = useState([]);
|
|
77
|
+
const [termsReady, setTermsReady] = useState(false);
|
|
78
|
+
const contentType = contentTypes.find(type => type.key === postType);
|
|
79
|
+
// Until types load, everything shows: the editor as it was before types.
|
|
80
|
+
const supports = (panel) => isPage || !contentType || contentType.supports[panel];
|
|
81
|
+
// What the thing being edited is called. A page and a post have sentences of
|
|
82
|
+
// their own, because a language with gender needs them; a custom type is
|
|
83
|
+
// named by its label. Until types load, a post is a post.
|
|
84
|
+
const customType = !isPage && contentType && contentType.key !== 'post' ? contentType.singular_label : null;
|
|
85
|
+
const pick = (page, post, custom) => (isPage ? page : customType ? custom : post);
|
|
86
|
+
const typeVars = { type: customType ?? '' };
|
|
87
|
+
const postId = params.id ? parseInt(params.id) : null;
|
|
88
|
+
const isEditing = !!postId;
|
|
89
|
+
const [loading, setLoading] = useState(isEditing);
|
|
90
|
+
const [saving, setSaving] = useState(false);
|
|
91
|
+
const [categories, setCategories] = useState([]);
|
|
92
|
+
const [allTags, setAllTags] = useState([]);
|
|
93
|
+
const [authors, setAuthors] = useState([]);
|
|
94
|
+
// Who the post is filed under when there is no menu to show — the name the
|
|
95
|
+
// API joined for an existing post, or whoever is signed in for a new one.
|
|
96
|
+
const [authorName, setAuthorName] = useState('');
|
|
97
|
+
const [formData, setFormData] = useState({
|
|
98
|
+
title: '',
|
|
99
|
+
content: '',
|
|
100
|
+
excerpt: '',
|
|
101
|
+
slug: '',
|
|
102
|
+
category_ids: [],
|
|
103
|
+
tags: [],
|
|
104
|
+
meta_title: '',
|
|
105
|
+
meta_description: '',
|
|
106
|
+
published: false,
|
|
107
|
+
// Posts only. Pages keep the published checkbox; they are not reviewed or
|
|
108
|
+
// scheduled.
|
|
109
|
+
status: 'draft',
|
|
110
|
+
// Local time, as the datetime-local input holds it. Blank means "now" when
|
|
111
|
+
// publishing, and leaves an already-live post's date alone.
|
|
112
|
+
publish_at: '',
|
|
113
|
+
og_title: '',
|
|
114
|
+
og_description: '',
|
|
115
|
+
og_image: null,
|
|
116
|
+
og_image_url: null,
|
|
117
|
+
twitter_title: '',
|
|
118
|
+
twitter_description: '',
|
|
119
|
+
canonical_url: '',
|
|
120
|
+
noindex: false,
|
|
121
|
+
// Posts only: who may read the body. The levels beyond public, and what
|
|
122
|
+
// they mean, belong to a feature (see the post.editor.sidebar slot below).
|
|
123
|
+
visibility: 'public',
|
|
124
|
+
// The media id that gets saved, and the URL that gets shown. The server
|
|
125
|
+
// resolves the second from the first, because only it knows where files
|
|
126
|
+
// are served from.
|
|
127
|
+
featured_image: null,
|
|
128
|
+
featured_image_url: null,
|
|
129
|
+
// Empty means "leave it alone": the author menu only appears for people who
|
|
130
|
+
// may reassign, and everyone else must not send a user_id at all.
|
|
131
|
+
user_id: ''
|
|
132
|
+
});
|
|
133
|
+
const [revisions, setRevisions] = useState([]);
|
|
134
|
+
const [autosave, setAutosave] = useState(null);
|
|
135
|
+
const [lastAutosaved, setLastAutosaved] = useState(null);
|
|
136
|
+
// Whether the form differs from what was last saved, so autosave only
|
|
137
|
+
// writes when there is something to keep.
|
|
138
|
+
const dirty = useRef(false);
|
|
139
|
+
const mayPublish = can(user, 'post.publish');
|
|
140
|
+
// The soft edit lock, for an existing post. A new post has no id to lock and
|
|
141
|
+
// nobody else can have it open; pages are another controller's and unlocked.
|
|
142
|
+
const lock = usePostLock(postId, !isPage && isEditing);
|
|
143
|
+
const lockedOut = !lock.canSave;
|
|
144
|
+
// The post as loaded, and the fields the sidebar's feature panels set.
|
|
145
|
+
const [loaded, setLoaded] = useState(null);
|
|
146
|
+
const [extra, setExtra] = useState({});
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
loadData();
|
|
149
|
+
}, [postId]);
|
|
150
|
+
// Autosave an existing post while it is being edited. A new post has no id
|
|
151
|
+
// to autosave against until its first save.
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
if (isPage || !postId)
|
|
154
|
+
return;
|
|
155
|
+
const timer = setInterval(async () => {
|
|
156
|
+
if (!dirty.current || lockedOut)
|
|
157
|
+
return;
|
|
158
|
+
dirty.current = false;
|
|
159
|
+
try {
|
|
160
|
+
const res = await api.put(`/api/posts/${postId}/autosave`, {
|
|
161
|
+
title: formData.title,
|
|
162
|
+
content: formData.content,
|
|
163
|
+
excerpt: formData.excerpt
|
|
164
|
+
});
|
|
165
|
+
setLastAutosaved(res?.autosave?.created_at ?? new Date().toISOString());
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
dirty.current = true;
|
|
169
|
+
// Refused because someone else holds the lock: find out who, so the
|
|
170
|
+
// banner appears instead of autosave failing quietly every 30 seconds.
|
|
171
|
+
if (/is editing this post/.test(error.message))
|
|
172
|
+
void lock.retry();
|
|
173
|
+
}
|
|
174
|
+
}, AUTOSAVE_EVERY);
|
|
175
|
+
return () => clearInterval(timer);
|
|
176
|
+
}, [isPage, postId, formData.title, formData.content, formData.excerpt, lockedOut]);
|
|
177
|
+
/**
|
|
178
|
+
* Take the lock from whoever has it.
|
|
179
|
+
*
|
|
180
|
+
* Opening a post someone else is in shows their last *saved* text, which
|
|
181
|
+
* may be behind what they are about to save — so after taking over the post
|
|
182
|
+
* is reloaded, to edit what is really there. If the lock was taken from us
|
|
183
|
+
* mid-edit, the opposite: what is on screen is our unsaved work, and taking
|
|
184
|
+
* the lock back is choosing to keep it, so it is left alone.
|
|
185
|
+
*/
|
|
186
|
+
const takeOver = async () => {
|
|
187
|
+
const reload = !lock.lostIt;
|
|
188
|
+
await lock.takeOver();
|
|
189
|
+
if (reload)
|
|
190
|
+
await loadData();
|
|
191
|
+
};
|
|
192
|
+
/** The other editor has left: load what they saved, then take the lock. */
|
|
193
|
+
const reloadAndEdit = async () => {
|
|
194
|
+
await loadData();
|
|
195
|
+
await lock.retry();
|
|
196
|
+
};
|
|
197
|
+
// Leaving with unsaved changes asks first.
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
const warn = (event) => {
|
|
200
|
+
if (dirty.current)
|
|
201
|
+
event.preventDefault();
|
|
202
|
+
};
|
|
203
|
+
window.addEventListener('beforeunload', warn);
|
|
204
|
+
return () => window.removeEventListener('beforeunload', warn);
|
|
205
|
+
}, []);
|
|
206
|
+
// A new post is yours until somebody reassigns it.
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
if (!isEditing && user?.name)
|
|
209
|
+
setAuthorName(user.name);
|
|
210
|
+
}, [isEditing, user?.name]);
|
|
211
|
+
const loadData = async () => {
|
|
212
|
+
try {
|
|
213
|
+
if (!isPage)
|
|
214
|
+
await loadPostFurniture();
|
|
215
|
+
if (postId) {
|
|
216
|
+
const res = await api.get(`/api/${resource}/${postId}`);
|
|
217
|
+
const record = (isPage ? res?.page : res?.post);
|
|
218
|
+
setLoaded(record ? record : null);
|
|
219
|
+
if (!isPage) {
|
|
220
|
+
setAutosave(res?.autosave ?? null);
|
|
221
|
+
loadRevisions();
|
|
222
|
+
}
|
|
223
|
+
if (record) {
|
|
224
|
+
setFormData(prev => ({
|
|
225
|
+
...prev,
|
|
226
|
+
title: record.title || '',
|
|
227
|
+
content: record.content || '',
|
|
228
|
+
excerpt: record.excerpt || '',
|
|
229
|
+
slug: record.slug || '',
|
|
230
|
+
category_ids: record.category_ids || [],
|
|
231
|
+
tags: record.tag_ids || record.tags?.map((t) => t.id) || [],
|
|
232
|
+
meta_title: record.meta_title || '',
|
|
233
|
+
meta_description: record.meta_description || '',
|
|
234
|
+
published: Boolean(record.published),
|
|
235
|
+
status: record.status || (record.published ? 'published' : 'draft'),
|
|
236
|
+
publish_at: toLocalInput(record.publish_at),
|
|
237
|
+
og_title: record.og_title || '',
|
|
238
|
+
og_description: record.og_description || '',
|
|
239
|
+
og_image: record.og_image ?? null,
|
|
240
|
+
og_image_url: null,
|
|
241
|
+
twitter_title: record.twitter_title || '',
|
|
242
|
+
twitter_description: record.twitter_description || '',
|
|
243
|
+
canonical_url: record.canonical_url || '',
|
|
244
|
+
noindex: Boolean(Number(record.noindex ?? 0)),
|
|
245
|
+
visibility: String(record.visibility || 'public'),
|
|
246
|
+
featured_image: record.featured_image ?? null,
|
|
247
|
+
featured_image_url: record.featured_image_url ?? null,
|
|
248
|
+
user_id: record.user_id ?? ''
|
|
249
|
+
}));
|
|
250
|
+
if (record.author_name)
|
|
251
|
+
setAuthorName(record.author_name);
|
|
252
|
+
if (!isPage) {
|
|
253
|
+
setPostType(record.post_type || 'post');
|
|
254
|
+
setCustomFields(record.fields && typeof record.fields === 'object' ? record.fields : {});
|
|
255
|
+
setTermIds(record.term_ids || []);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
console.error('Failed to load data:', error);
|
|
262
|
+
}
|
|
263
|
+
finally {
|
|
264
|
+
setLoading(false);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Categories, tags and the author menu — the boxes only a post has.
|
|
269
|
+
*
|
|
270
|
+
* The author list is refused to anyone who cannot write, so a failure here is
|
|
271
|
+
* an answer rather than an error: no menu, and the post stays attributed to
|
|
272
|
+
* whoever it already belongs to.
|
|
273
|
+
*/
|
|
274
|
+
const loadPostFurniture = async () => {
|
|
275
|
+
const [catRes, tagRes] = await Promise.all([
|
|
276
|
+
api.get('/api/categories'),
|
|
277
|
+
api.get('/api/tags')
|
|
278
|
+
]);
|
|
279
|
+
setCategories(catRes?.categories || []);
|
|
280
|
+
setAllTags(tagRes?.tags || []);
|
|
281
|
+
try {
|
|
282
|
+
const authorRes = await api.get('/api/authors');
|
|
283
|
+
setAuthors(authorRes?.authors || []);
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
setAuthors([]);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
const loadRevisions = async () => {
|
|
290
|
+
if (!postId)
|
|
291
|
+
return;
|
|
292
|
+
try {
|
|
293
|
+
const res = await api.get(`/api/posts/${postId}/revisions`);
|
|
294
|
+
setRevisions((res?.revisions || []).filter(revision => !revision.autosave));
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
setRevisions([]);
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
/** Put the autosaved text back into the form. Saving is still a separate step. */
|
|
301
|
+
const restoreAutosave = () => {
|
|
302
|
+
if (!autosave)
|
|
303
|
+
return;
|
|
304
|
+
setFormData(prev => ({
|
|
305
|
+
...prev,
|
|
306
|
+
title: autosave.title,
|
|
307
|
+
content: autosave.content,
|
|
308
|
+
excerpt: autosave.excerpt || ''
|
|
309
|
+
}));
|
|
310
|
+
dirty.current = true;
|
|
311
|
+
setAutosave(null);
|
|
312
|
+
};
|
|
313
|
+
const restoreRevision = async (revision) => {
|
|
314
|
+
if (!postId)
|
|
315
|
+
return;
|
|
316
|
+
if (!confirm(t('Replace the current text with the version from {date}? The current text is kept as a revision.', { date: new Date(revision.created_at).toLocaleString() })))
|
|
317
|
+
return;
|
|
318
|
+
try {
|
|
319
|
+
await api.post(`/api/posts/${postId}/revisions/${revision.id}/restore`, {});
|
|
320
|
+
await loadData();
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
alert(error.message || t('Could not restore that revision'));
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
const handleSubmit = async (e, submitStatus) => {
|
|
327
|
+
e.preventDefault();
|
|
328
|
+
setSaving(true);
|
|
329
|
+
try {
|
|
330
|
+
// `featured_image_url` is the server's answer, not the editor's input —
|
|
331
|
+
// sending it back would be asking the API to store a URL in a column that
|
|
332
|
+
// holds a media id.
|
|
333
|
+
const { featured_image_url, og_image_url, user_id, category_ids, tags, excerpt, status, publish_at, published, ...common } = formData;
|
|
334
|
+
const finalStatus = submitStatus ?? status;
|
|
335
|
+
// Posts only: a page has no visibility. `extra` is what the sidebar's
|
|
336
|
+
// feature panels set; see PostEditorSidebarProps.
|
|
337
|
+
const { visibility, ...shared } = common;
|
|
338
|
+
// category_ids and tags are arrays the server syncs; a page has neither,
|
|
339
|
+
// and no excerpt column to put an excerpt in. A page publishes with the
|
|
340
|
+
// checkbox; a post with its status and an optional schedule.
|
|
341
|
+
const payload = isPage
|
|
342
|
+
? { ...shared, published }
|
|
343
|
+
: {
|
|
344
|
+
...shared,
|
|
345
|
+
status: finalStatus,
|
|
346
|
+
// Sent only when there is one: blank means "now" for a post going
|
|
347
|
+
// live, and "unchanged" for one already live.
|
|
348
|
+
...(publish_at ? { publish_at: fromLocalInput(publish_at) } : {}),
|
|
349
|
+
excerpt,
|
|
350
|
+
visibility,
|
|
351
|
+
...extra,
|
|
352
|
+
category_ids,
|
|
353
|
+
tags,
|
|
354
|
+
// Only when the menu was shown and a choice was made. Sending it
|
|
355
|
+
// otherwise would ask the server to reassign a post to its own
|
|
356
|
+
// author, which it ignores, but there is no reason to ask.
|
|
357
|
+
...(user_id === '' ? {} : { user_id }),
|
|
358
|
+
post_type: postType,
|
|
359
|
+
// Only for a type that has fields, and terms only once the
|
|
360
|
+
// pickers know the selection: an unloaded box is not "none".
|
|
361
|
+
...(contentType?.supports.custom_fields && contentType.fields.length ? { fields: customFields } : {}),
|
|
362
|
+
...(termsReady ? { term_ids: termIds } : {})
|
|
363
|
+
};
|
|
364
|
+
if (isEditing) {
|
|
365
|
+
await api.put(`/api/${resource}/${postId}`, payload);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
await api.post(`/api/${resource}`, payload);
|
|
369
|
+
}
|
|
370
|
+
dirty.current = false;
|
|
371
|
+
navigateWithType(navigate, `/admin/${resource}`, isPage ? null : postType);
|
|
372
|
+
}
|
|
373
|
+
catch (error) {
|
|
374
|
+
console.error(`Failed to save ${resource}:`, error);
|
|
375
|
+
// Refused by the edit lock: refresh it so the banner shows who has it.
|
|
376
|
+
if (/is editing this post/.test(error?.message ?? ''))
|
|
377
|
+
void lock.retry();
|
|
378
|
+
alert(error.message || pick(t('Failed to save page'), t('Failed to save post'), t('Failed to save {type}', typeVars)));
|
|
379
|
+
}
|
|
380
|
+
finally {
|
|
381
|
+
setSaving(false);
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
const handleChange = (e) => {
|
|
385
|
+
const { name, value, type } = e.target;
|
|
386
|
+
const checked = e.target.checked;
|
|
387
|
+
// Someone else holds the lock: the form is for reading until it is ours.
|
|
388
|
+
// Toolbar edits arrive here too, so this covers them as well as typing.
|
|
389
|
+
if (lockedOut)
|
|
390
|
+
return;
|
|
391
|
+
dirty.current = true;
|
|
392
|
+
setFormData(prev => ({
|
|
393
|
+
...prev,
|
|
394
|
+
[name]: type === 'checkbox' ? checked : value
|
|
395
|
+
}));
|
|
396
|
+
};
|
|
397
|
+
// What the main button will do, so its label can say so.
|
|
398
|
+
const scheduledFor = formData.publish_at ? new Date(formData.publish_at) : null;
|
|
399
|
+
const isFuture = Boolean(scheduledFor && scheduledFor.getTime() > Date.now());
|
|
400
|
+
const submitLabel = saving
|
|
401
|
+
? t('Saving...')
|
|
402
|
+
: isPage
|
|
403
|
+
? (isEditing ? t('Update') : t('Create'))
|
|
404
|
+
: formData.status === 'published'
|
|
405
|
+
? (isFuture ? t('Schedule') : (isEditing ? t('Update') : t('Publish')))
|
|
406
|
+
: formData.status === 'pending'
|
|
407
|
+
? t('Submit for review')
|
|
408
|
+
: t('Save draft');
|
|
409
|
+
const heading = isEditing
|
|
410
|
+
? pick(t('Edit page'), t('Edit post'), t('Edit {type}', typeVars))
|
|
411
|
+
: pick(t('New page'), t('New post'), t('New {type}', typeVars));
|
|
412
|
+
// Creating a term without leaving the editor. Going to /admin/categories to
|
|
413
|
+
// add one and coming back meant losing an unsaved draft, which is a poor
|
|
414
|
+
// trade for a word you already knew you wanted.
|
|
415
|
+
const [creating, setCreating] = useState(null);
|
|
416
|
+
// Whether it landed, so the field knows to clear itself — a name that was
|
|
417
|
+
// refused stays in the box to be corrected rather than vanishing behind an
|
|
418
|
+
// alert.
|
|
419
|
+
const createCategory = async (name) => {
|
|
420
|
+
if (!name || creating)
|
|
421
|
+
return false;
|
|
422
|
+
setCreating('category');
|
|
423
|
+
try {
|
|
424
|
+
const res = await api.post('/api/categories', { name });
|
|
425
|
+
const created = res?.category;
|
|
426
|
+
if (created) {
|
|
427
|
+
setCategories(prev => [...prev, created].sort((a, b) => a.name.localeCompare(b.name)));
|
|
428
|
+
// Selected straight away: you created it while filing this post.
|
|
429
|
+
setFormData(prev => ({ ...prev, category_ids: [...prev.category_ids, created.id] }));
|
|
430
|
+
}
|
|
431
|
+
return Boolean(created);
|
|
432
|
+
}
|
|
433
|
+
catch (error) {
|
|
434
|
+
console.error('Failed to create category:', error);
|
|
435
|
+
alert(t('Could not create that category. It may already exist.'));
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
finally {
|
|
439
|
+
setCreating(null);
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
/**
|
|
443
|
+
* Attach tags by name, creating the ones that do not exist yet.
|
|
444
|
+
*
|
|
445
|
+
* Typing is the whole point: having to go and create a tag elsewhere before
|
|
446
|
+
* you can use it is the friction this removes. An existing tag is reused
|
|
447
|
+
* rather than re-created — matched case-insensitively, because "Privacy" and
|
|
448
|
+
* "privacy" are the same tag to everyone except a database.
|
|
449
|
+
*/
|
|
450
|
+
const addTags = async (input) => {
|
|
451
|
+
const names = input
|
|
452
|
+
.split(',')
|
|
453
|
+
.map(name => name.trim())
|
|
454
|
+
.filter(Boolean);
|
|
455
|
+
if (names.length === 0 || creating)
|
|
456
|
+
return false;
|
|
457
|
+
setCreating('tag');
|
|
458
|
+
try {
|
|
459
|
+
for (const name of names) {
|
|
460
|
+
const existing = allTags.find(t => t.name.toLowerCase() === name.toLowerCase());
|
|
461
|
+
if (existing) {
|
|
462
|
+
setFormData(prev => prev.tags.includes(existing.id) ? prev : { ...prev, tags: [...prev.tags, existing.id] });
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
const res = await api.post('/api/tags', { name });
|
|
466
|
+
const created = res?.tag;
|
|
467
|
+
if (created) {
|
|
468
|
+
setAllTags(prev => [...prev, created].sort((a, b) => a.name.localeCompare(b.name)));
|
|
469
|
+
setFormData(prev => ({ ...prev, tags: [...prev.tags, created.id] }));
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return true;
|
|
473
|
+
}
|
|
474
|
+
catch (error) {
|
|
475
|
+
console.error('Failed to add tags:', error);
|
|
476
|
+
alert(t('Could not add those tags.'));
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
479
|
+
finally {
|
|
480
|
+
setCreating(null);
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
const handleCategoryToggle = (categoryId) => {
|
|
484
|
+
setFormData(prev => ({
|
|
485
|
+
...prev,
|
|
486
|
+
category_ids: prev.category_ids.includes(categoryId)
|
|
487
|
+
? prev.category_ids.filter(id => id !== categoryId)
|
|
488
|
+
: [...prev.category_ids, categoryId]
|
|
489
|
+
}));
|
|
490
|
+
};
|
|
491
|
+
const handleTagToggle = (tagId) => {
|
|
492
|
+
setFormData(prev => ({
|
|
493
|
+
...prev,
|
|
494
|
+
tags: prev.tags.includes(tagId)
|
|
495
|
+
? prev.tags.filter(id => id !== tagId)
|
|
496
|
+
: [...prev.tags, tagId]
|
|
497
|
+
}));
|
|
498
|
+
};
|
|
499
|
+
// The profile behind the byline, when the list happens to hold it — the
|
|
500
|
+
// avatar is a nicety, and its absence is not worth a request of its own.
|
|
501
|
+
const currentAuthor = authors.find(author => author.id === Number(formData.user_id));
|
|
502
|
+
if (loading) {
|
|
503
|
+
return (_jsx(AdminLayout, { title: heading, children: _jsx("div", { className: "admin-loading", children: t('Loading...') }) }));
|
|
504
|
+
}
|
|
505
|
+
return (_jsx(AdminLayout, { title: heading, children: _jsxs("form", { onSubmit: handleSubmit, children: [lock.status === 'blocked' && (_jsxs("div", { className: "admin-card", role: "alert", style: { display: 'flex', gap: '0.75rem', alignItems: 'center', justifyContent: 'space-between', borderColor: 'var(--warning)', background: 'var(--tint-warning)' }, children: [_jsx("span", { children: lock.lostIt
|
|
506
|
+
? slots(t('{name} has taken over editing this post. Your unsaved changes are still on screen, but cannot be saved unless you take it back.'), { name: _jsx("strong", { children: lock.holder }) })
|
|
507
|
+
: slots(t('{name} is editing this post. You can read it, but saving is paused so neither of you overwrites the other.'), { name: _jsx("strong", { children: lock.holder }) }) }), _jsxs("span", { style: { display: 'flex', gap: '0.5rem' }, children: [_jsx("button", { type: "button", className: "admin-btn admin-btn-primary", onClick: takeOver, children: t('Take over') }), _jsx(Link, { href: "/admin/posts", className: "admin-btn admin-btn-secondary", children: t('Back to posts') })] })] })), lock.status === 'free' && (_jsxs("div", { className: "admin-card", role: "status", style: { display: 'flex', gap: '0.75rem', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsx("span", { children: t('{name} has finished editing. Reload to see their changes and start editing.', { name: lock.holder || t('The other editor') }) }), _jsx("button", { type: "button", className: "admin-btn admin-btn-primary", onClick: reloadAndEdit, children: t('Reload and edit') })] })), autosave && (_jsxs("div", { className: "admin-card", role: "status", style: { display: 'flex', gap: '0.75rem', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsx("span", { children: t('There is an autosave of this post from {date} that is newer than the saved version.', { date: new Date(autosave.created_at).toLocaleString() }) }), _jsxs("span", { style: { display: 'flex', gap: '0.5rem' }, children: [_jsx("button", { type: "button", className: "admin-btn admin-btn-primary", onClick: restoreAutosave, children: t('Restore it') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => setAutosave(null), children: t('Dismiss') })] })] })), _jsxs("div", { className: "admin-grid admin-grid-2", style: { gridTemplateColumns: '2fr 1fr' }, children: [_jsxs("div", { children: [_jsxs("div", { className: "admin-card", children: [_jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", children: t('Title') }), _jsx("input", { type: "text", name: "title", value: formData.title, onChange: handleChange, className: "admin-input", placeholder: pick(t('Enter page title'), t('Enter post title'), t('Enter {type} title', { type: customType?.toLowerCase() ?? '' })), required: true }), _jsxs("div", { className: "admin-slug", children: [_jsx("label", { htmlFor: "slug", children: t('Slug') }), _jsx("input", { id: "slug", type: "text", name: "slug", value: formData.slug, onChange: handleChange, className: "admin-slug-input", placeholder: slugify(formData.title) || pick(t('page-url-slug'), t('post-url-slug'), t('{type}-url-slug', { type: slugify(customType ?? '') })) }), !formData.slug.trim() && _jsx("span", { className: "admin-slug-note", children: t('from the title') })] })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", children: t('Content') }), _jsx(MarkdownEditor, { name: "content", value: formData.content, onChange: handleChange, minHeight: "400px", placeholder: t('Write your content here. Markdown is supported.'), required: true, readOnly: lockedOut, tools: (insert, disabled) => _jsx(SnippetPicker, { onInsert: insert, disabled: disabled }) })] }), !isPage && supports('excerpt') && (_jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", children: t('Excerpt') }), _jsx("textarea", { name: "excerpt", value: formData.excerpt, onChange: handleChange, className: "admin-textarea", style: { minHeight: '100px' }, placeholder: summaryOf(formData.content) || t('Written for you from the content if you leave this blank') })] }))] }), !isPage && (_jsx(CustomFieldsPanel, { type: contentType, values: customFields, disabled: lockedOut, onChange: values => {
|
|
508
|
+
dirty.current = true;
|
|
509
|
+
setCustomFields(values);
|
|
510
|
+
} })), _jsxs("div", { className: "admin-card", children: [_jsx("h3", { className: "admin-card-title", children: t('SEO Settings') }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", children: t('Meta Title') }), _jsx("input", { type: "text", name: "meta_title", value: formData.meta_title, onChange: handleChange, className: "admin-input", placeholder: t('SEO title') })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", children: t('Meta Description') }), _jsx("textarea", { name: "meta_description", value: formData.meta_description, onChange: handleChange, className: "admin-textarea", style: { minHeight: '80px' }, placeholder: t('SEO description') })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", children: t('Canonical URL') }), _jsx("input", { type: "url", name: "canonical_url", value: formData.canonical_url, onChange: handleChange, className: "admin-input", placeholder: t('Only if this was first published somewhere else') })] }), _jsx("div", { className: "admin-form-group", children: _jsxs("label", { style: { display: 'flex', alignItems: 'center', gap: '0.5rem' }, children: [_jsx("input", { type: "checkbox", name: "noindex", checked: formData.noindex, onChange: handleChange }), pick(t('Ask search engines not to index this page'), t('Ask search engines not to index this post'), t('Ask search engines not to index this {type}', { type: customType?.toLowerCase() ?? '' }))] }) })] }), _jsxs("div", { className: "admin-card", children: [_jsx("h3", { className: "admin-card-title", children: t('Social cards') }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", children: t('Open Graph title') }), _jsx("input", { type: "text", name: "og_title", value: formData.og_title, onChange: handleChange, className: "admin-input", placeholder: formData.meta_title || formData.title || t('Falls back to the SEO title') })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", children: t('Open Graph description') }), _jsx("textarea", { name: "og_description", value: formData.og_description, onChange: handleChange, className: "admin-textarea", style: { minHeight: '60px' }, placeholder: formData.meta_description || t('Falls back to the SEO description') })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", children: t('Twitter / X title') }), _jsx("input", { type: "text", name: "twitter_title", value: formData.twitter_title, onChange: handleChange, className: "admin-input", placeholder: t('Falls back to the Open Graph title') })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", children: t('Twitter / X description') }), _jsx("textarea", { name: "twitter_description", value: formData.twitter_description, onChange: handleChange, className: "admin-textarea", style: { minHeight: '60px' }, placeholder: t('Falls back to the Open Graph description') })] })] }), !isPage && isEditing && revisions.length > 0 && (_jsxs("div", { className: "admin-card", children: [_jsx("h3", { className: "admin-card-title", children: t('Revisions') }), _jsx("ul", { style: { listStyle: 'none', padding: 0, margin: 0, display: 'grid', gap: '0.5rem' }, children: revisions.slice(0, 20).map(revision => (_jsxs("li", { style: { display: 'flex', justifyContent: 'space-between', gap: '0.5rem', alignItems: 'center' }, children: [_jsxs("span", { children: [new Date(revision.created_at).toLocaleString(), revision.author_name ? ` — ${revision.author_name}` : '', _jsx("br", {}), _jsx("small", { style: { color: 'var(--fg-muted)' }, children: revision.title })] }), _jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => restoreRevision(revision), children: t('Restore') })] }, revision.id))) })] }))] }), _jsxs("div", { children: [_jsxs("div", { className: "admin-card", children: [_jsx("h3", { className: "admin-card-title", children: t('Publish') }), isPage ? (_jsx("div", { className: "admin-form-group", children: _jsxs("label", { style: { display: 'flex', alignItems: 'center', gap: '0.5rem' }, children: [_jsx("input", { type: "checkbox", name: "published", checked: formData.published, onChange: handleChange }), t('Published')] }) })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", htmlFor: "status", children: t('Status') }), _jsxs("select", { id: "status", name: "status", value: formData.status, onChange: handleChange, className: "admin-input", children: [_jsx("option", { value: "draft", children: t('Draft') }), _jsx("option", { value: "pending", children: t('Pending review') }), _jsx("option", { value: "published", disabled: !mayPublish && formData.status !== 'published', children: mayPublish ? t('Published') : t('Published (an editor publishes)') })] })] }), formData.status === 'published' && (_jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", htmlFor: "publish_at", children: t('Publish on') }), _jsx("input", { id: "publish_at", type: "datetime-local", name: "publish_at", value: formData.publish_at, onChange: handleChange, className: "admin-input" }), _jsx("small", { style: { color: 'var(--fg-muted)' }, children: isFuture
|
|
511
|
+
? t('Scheduled — goes live {date}.', { date: scheduledFor.toLocaleString() })
|
|
512
|
+
: formData.publish_at
|
|
513
|
+
? t('Already live.')
|
|
514
|
+
: t('Blank publishes now. A future date schedules it.') })] })), lastAutosaved && (_jsx("p", { style: { color: 'var(--fg-muted)', fontSize: '0.8rem' }, children: t('Autosaved {time}', { time: new Date(lastAutosaved).toLocaleTimeString() }) }))] })), _jsxs("div", { style: { display: 'flex', gap: '0.5rem' }, children: [_jsx("button", { type: "submit", className: "admin-btn admin-btn-primary", disabled: saving || lockedOut, title: lockedOut ? t('Someone else is editing this post') : undefined, style: { flex: 1 }, children: submitLabel }), _jsx(Link, { href: `/admin/${resource}`, className: "admin-btn admin-btn-secondary", children: t('Cancel') })] })] }), !isPage && (_jsx(Slot, { name: "post.editor.sidebar", kind: "post", postId: postId, record: loaded, values: { visibility: formData.visibility, ...extra }, disabled: lockedOut, onChange: (changes) => {
|
|
515
|
+
dirty.current = true;
|
|
516
|
+
const { visibility, ...rest } = changes;
|
|
517
|
+
if (typeof visibility === 'string')
|
|
518
|
+
setFormData(prev => ({ ...prev, visibility }));
|
|
519
|
+
if (Object.keys(rest).length)
|
|
520
|
+
setExtra(prev => ({ ...prev, ...rest }));
|
|
521
|
+
} })), !isPage && formData.visibility !== 'public' && !hasFills('post.editor.sidebar') && (_jsx("div", { className: "admin-card", children: _jsx("small", { style: { color: 'var(--fg-muted)' }, children: t('Readable by: {level}. This site no longer offers that level, so the body is withheld from every reader.', { level: formData.visibility }) }) })), supports('featured_image') && _jsx(FeaturedImageBox, { value: formData.featured_image, url: formData.featured_image_url, onChange: image => {
|
|
522
|
+
dirty.current = true;
|
|
523
|
+
setFormData(prev => ({
|
|
524
|
+
...prev,
|
|
525
|
+
featured_image: image?.id ?? null,
|
|
526
|
+
featured_image_url: image?.url ?? null
|
|
527
|
+
}));
|
|
528
|
+
} }), !isPage && (_jsxs("div", { className: "admin-card", children: [_jsx("h3", { className: "admin-card-title", children: t('Author') }), authors.length > 1 ? (_jsxs("select", { name: "user_id", value: formData.user_id, onChange: handleChange, className: "admin-input", children: [_jsx("option", { value: "", children: isEditing ? t('Unchanged') : t('Me') }), authors.map(author => (_jsx("option", { value: author.id, children: author.name }, author.id)))] })) : (_jsxs("div", { className: "admin-author", children: [currentAuthor?.avatar_url && (_jsx("img", { src: currentAuthor.avatar_url, alt: "", className: "admin-author-avatar" })), _jsx("span", { children: authorName || t('Unknown') })] }))] })), !isPage && (_jsxs(_Fragment, { children: [supports('categories') && _jsx(TermPicker, { title: t('Categories'), noun: t('category'), terms: categories, selected: formData.category_ids, onToggle: handleCategoryToggle, onAdd: createCategory, busy: creating !== null, emptyText: t('No categories yet.') }), supports('tags') && _jsx(TermPicker, { title: t('Tags'), noun: t('tag'), terms: allTags, selected: formData.tags, onToggle: handleTagToggle, onAdd: addTags, busy: creating !== null, emptyText: t('No tags yet.'), commitOnComma: true }), _jsx(CustomTermsPanel, { typeKey: postType, selected: termIds, onChange: ids => {
|
|
529
|
+
dirty.current = true;
|
|
530
|
+
setTermIds(ids);
|
|
531
|
+
}, onReady: setTermsReady })] }))] })] })] }) }));
|
|
532
|
+
}
|