@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,7 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from "./ThemeContext.js";
|
|
3
|
+
import { Avatar } from "./Avatar.js";
|
|
4
|
+
export function PostCard({ post, onClick, showAuthor = false }) {
|
|
5
|
+
const { t } = useTheme();
|
|
6
|
+
return (_jsxs("button", { onClick: onClick, className: `w-full text-left p-4 rounded-xl ${t.card} border ${t.border} hover:border-opacity-50 transition`, children: [post.featured_image_url && (_jsx("img", { src: post.featured_image_url, alt: "", className: "w-full h-40 object-cover rounded-lg mb-3" })), _jsx("h2", { className: "font-medium mb-1", children: post.title }), _jsx("p", { className: `text-sm ${t.muted} line-clamp-2`, children: post.excerpt || post.content }), _jsxs("div", { className: `flex items-center gap-2 text-xs ${t.muted} mt-2`, children: [showAuthor && post.author_name && (_jsxs(_Fragment, { children: [_jsx(Avatar, { name: post.author_name, src: post.author?.avatar_url, size: "sm" }), _jsx("span", { children: post.author_name }), _jsx("span", { children: "\u2022" })] })), post.published !== undefined && _jsxs("span", { children: [post.published ? 'Published' : 'Draft', " \u2022"] }), _jsx("span", { children: new Date(post.created_at).toLocaleDateString() })] })] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TextareaHTMLAttributes } from 'react';
|
|
2
|
+
interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
3
|
+
rows?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function Textarea({ rows, className, ...props }: TextareaProps): import("react").JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from "./ThemeContext.js";
|
|
3
|
+
export function Textarea({ rows = 5, className = '', ...props }) {
|
|
4
|
+
const { t } = useTheme();
|
|
5
|
+
return (_jsx("textarea", { rows: rows, className: `w-full px-3 py-2 text-sm rounded-lg ${t.card} border ${t.border} focus:outline-none resize-none ${className}`, ...props }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface ThemeStyles {
|
|
2
|
+
bg: string;
|
|
3
|
+
text: string;
|
|
4
|
+
muted: string;
|
|
5
|
+
border: string;
|
|
6
|
+
card: string;
|
|
7
|
+
btn: string;
|
|
8
|
+
btnHover: string;
|
|
9
|
+
btnSecondary: string;
|
|
10
|
+
}
|
|
11
|
+
interface ThemeContextType {
|
|
12
|
+
t: ThemeStyles;
|
|
13
|
+
dark: boolean;
|
|
14
|
+
setDark: (dark: boolean) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const ThemeContext: import("react").Context<ThemeContextType | null>;
|
|
17
|
+
export declare const useTheme: () => ThemeContextType;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
export const ThemeContext = createContext(null);
|
|
3
|
+
export const useTheme = () => {
|
|
4
|
+
const context = useContext(ThemeContext);
|
|
5
|
+
if (!context)
|
|
6
|
+
throw new Error('useTheme must be used within ThemeProvider');
|
|
7
|
+
return context;
|
|
8
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface AdminIconProps {
|
|
3
|
+
/** Menu path, used to pick the icon. */
|
|
4
|
+
path?: string;
|
|
5
|
+
/** Icon name, when there is no route to key off. */
|
|
6
|
+
name?: string;
|
|
7
|
+
/** What a listener supplied; shown when the path is not one of ours. */
|
|
8
|
+
fallback?: string;
|
|
9
|
+
/** SVG path data from a feature's manifest, drawn like the built-in icons. */
|
|
10
|
+
iconPath?: string;
|
|
11
|
+
}
|
|
12
|
+
export default function AdminIcon({ path, name, fallback, iconPath }: AdminIconProps): React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Line icons for the admin navigation.
|
|
4
|
+
*
|
|
5
|
+
* Emoji were doing this job, which is why the sidebar never looked like the
|
|
6
|
+
* rest of the interface: they carry their own colour, render differently on
|
|
7
|
+
* every platform, and cannot inherit the text colour of the item they sit in.
|
|
8
|
+
* These are stroked paths, so they take `currentColor` and match whatever the
|
|
9
|
+
* nav item is doing.
|
|
10
|
+
*
|
|
11
|
+
* A listener can add menu items through the `admin.menu` hook and supply an
|
|
12
|
+
* emoji, so anything unrecognised falls back to that, and then to a dot.
|
|
13
|
+
*/
|
|
14
|
+
const paths = {
|
|
15
|
+
dashboard: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "3", y: "3", width: "7", height: "7", rx: "1" }), _jsx("rect", { x: "14", y: "3", width: "7", height: "7", rx: "1" }), _jsx("rect", { x: "14", y: "14", width: "7", height: "7", rx: "1" }), _jsx("rect", { x: "3", y: "14", width: "7", height: "7", rx: "1" })] })),
|
|
16
|
+
posts: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M4 4h16v16H4z" }), _jsx("path", { d: "M8 9h8M8 13h8M8 17h5" })] })),
|
|
17
|
+
pages: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z" }), _jsx("path", { d: "M14 3v5h5" })] })),
|
|
18
|
+
categories: _jsx("path", { d: "M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" }),
|
|
19
|
+
tags: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M3 11V5a2 2 0 0 1 2-2h6l10 10-8 8z" }), _jsx("circle", { cx: "7.5", cy: "7.5", r: "1.5" })] })),
|
|
20
|
+
comments: _jsx("path", { d: "M21 12a8 8 0 0 1-8 8H4l2-3a8 8 0 1 1 15-5z" }),
|
|
21
|
+
media: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }), _jsx("circle", { cx: "8.5", cy: "9.5", r: "1.5" }), _jsx("path", { d: "M21 16l-5-5-5 5-3-3-5 5" })] })),
|
|
22
|
+
tokens: (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "8", cy: "12", r: "4" }), _jsx("path", { d: "M12 12h9M17 12v3M21 12v2" })] })),
|
|
23
|
+
profile: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M20 21v-1.5a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4V21" }), _jsx("circle", { cx: "12", cy: "7", r: "3.5" })] })),
|
|
24
|
+
settings: (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "12", cy: "12", r: "3" }), _jsx("path", { d: "M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-2.9 1.2 2 2 0 1 1-4 0 1.7 1.7 0 0 0-2.9-1.2l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1A1.7 1.7 0 0 0 4 15a2 2 0 1 1 0-4 1.7 1.7 0 0 0 1.2-2.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1A1.7 1.7 0 0 0 11 4a2 2 0 1 1 4 0 1.7 1.7 0 0 0 2.9 1.2l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1A1.7 1.7 0 0 0 20 11a2 2 0 1 1 0 4z" })] })),
|
|
25
|
+
users: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M16 21v-1.5a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4V21" }), _jsx("circle", { cx: "9", cy: "7", r: "3.5" }), _jsx("path", { d: "M22 21v-1.5a4 4 0 0 0-3-3.9M16 3.6a3.5 3.5 0 0 1 0 6.8" })] })),
|
|
26
|
+
snippets: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M8 4H6a2 2 0 0 0-2 2v4l-2 2 2 2v4a2 2 0 0 0 2 2h2" }), _jsx("path", { d: "M16 4h2a2 2 0 0 1 2 2v4l2 2-2 2v4a2 2 0 0 1-2 2h-2" })] })),
|
|
27
|
+
navigation: (_jsx(_Fragment, { children: _jsx("path", { d: "M4 6h16M4 12h16M4 18h10" }) })),
|
|
28
|
+
redirects: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M4 17V9a4 4 0 0 1 4-4h11" }), _jsx("path", { d: "M15 1l4 4-4 4" }), _jsx("path", { d: "M4 21h8" })] })),
|
|
29
|
+
taxonomies: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M4 6h16M4 12h10M4 18h6" }), _jsx("circle", { cx: "18", cy: "16", r: "3" })] })),
|
|
30
|
+
contentTypes: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "3", y: "3", width: "7", height: "7", rx: "1" }), _jsx("rect", { x: "14", y: "3", width: "7", height: "7", rx: "1" }), _jsx("rect", { x: "3", y: "14", width: "7", height: "7", rx: "1" }), _jsx("rect", { x: "14", y: "14", width: "7", height: "7", rx: "1" })] })),
|
|
31
|
+
health: _jsx("path", { d: "M3 12h4l2-5 4 10 2-5h6" }),
|
|
32
|
+
tools: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M12 3v12M7 10l5 5 5-5" }), _jsx("path", { d: "M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2" })] })),
|
|
33
|
+
site: (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "12", cy: "12", r: "9" }), _jsx("path", { d: "M3 12h18M12 3a15 15 0 0 1 0 18a15 15 0 0 1 0-18z" })] }))
|
|
34
|
+
};
|
|
35
|
+
/** Menu paths are stable, so the icon is chosen from the route rather than a label. */
|
|
36
|
+
const byPath = {
|
|
37
|
+
'/admin': 'dashboard',
|
|
38
|
+
'/admin/posts': 'posts',
|
|
39
|
+
'/admin/pages': 'pages',
|
|
40
|
+
'/admin/categories': 'categories',
|
|
41
|
+
'/admin/tags': 'tags',
|
|
42
|
+
'/admin/taxonomies': 'taxonomies',
|
|
43
|
+
'/admin/content-types': 'contentTypes',
|
|
44
|
+
'/admin/comments': 'comments',
|
|
45
|
+
'/admin/media': 'media',
|
|
46
|
+
'/admin/tokens': 'tokens',
|
|
47
|
+
'/admin/snippets': 'snippets',
|
|
48
|
+
'/admin/navigation': 'navigation',
|
|
49
|
+
'/admin/redirects': 'redirects',
|
|
50
|
+
// Outside /admin, because it is the one screen every account has, admin area
|
|
51
|
+
// or not. It still belongs in this map — an item without one falls back to
|
|
52
|
+
// the emoji the server supplied, which is the look these icons replaced.
|
|
53
|
+
'/profile': 'profile',
|
|
54
|
+
'/admin/settings': 'settings',
|
|
55
|
+
'/admin/users': 'users',
|
|
56
|
+
'/admin/tools': 'tools',
|
|
57
|
+
'/admin/health': 'health'
|
|
58
|
+
};
|
|
59
|
+
export default function AdminIcon({ path, name, fallback, iconPath }) {
|
|
60
|
+
const key = name || (path ? byPath[path] : undefined);
|
|
61
|
+
const glyph = key ? paths[key] : iconPath ? _jsx("path", { d: iconPath }) : undefined;
|
|
62
|
+
if (!glyph) {
|
|
63
|
+
return (_jsx("span", { className: "admin-nav-icon admin-nav-icon-fallback", "aria-hidden": "true", children: fallback || '•' }));
|
|
64
|
+
}
|
|
65
|
+
return (_jsx("svg", { className: "admin-nav-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: glyph }));
|
|
66
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AdminContentType } from '../../hooks/useContentTypes.ts';
|
|
3
|
+
/** One input per declared field, typed to match what the server validates. */
|
|
4
|
+
export declare function CustomFieldsPanel({ type, values, onChange, disabled }: {
|
|
5
|
+
type: AdminContentType | undefined;
|
|
6
|
+
values: Record<string, unknown>;
|
|
7
|
+
onChange: (values: Record<string, unknown>) => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}): React.JSX.Element | null;
|
|
10
|
+
/**
|
|
11
|
+
* A picker per custom taxonomy attached to the type.
|
|
12
|
+
*
|
|
13
|
+
* `onReady` reports once the taxonomies have loaded, so the editor only sends
|
|
14
|
+
* `term_ids` when it actually knows the selection — a failed load must not
|
|
15
|
+
* look like "no terms" and clear them on save.
|
|
16
|
+
*/
|
|
17
|
+
export declare function CustomTermsPanel({ typeKey, selected, onChange, onReady }: {
|
|
18
|
+
typeKey: string;
|
|
19
|
+
selected: number[];
|
|
20
|
+
onChange: (ids: number[]) => void;
|
|
21
|
+
onReady: (ready: boolean) => void;
|
|
22
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { api } from "../../../helpers/api.js";
|
|
4
|
+
import TermPicker from "./TermPicker.js";
|
|
5
|
+
import { useT } from "../../i18n/index.js";
|
|
6
|
+
/** One input per declared field, typed to match what the server validates. */
|
|
7
|
+
export function CustomFieldsPanel({ type, values, onChange, disabled }) {
|
|
8
|
+
const { t } = useT();
|
|
9
|
+
if (!type || !type.supports.custom_fields || type.fields.length === 0)
|
|
10
|
+
return null;
|
|
11
|
+
const set = (key, value) => onChange({ ...values, [key]: value });
|
|
12
|
+
return (_jsxs("div", { className: "admin-card", children: [_jsx("h3", { className: "admin-card-title", children: t('{type} details', { type: type.singular_label }) }), type.fields.map(field => (_jsxs("div", { className: "admin-form-group", children: [field.type === 'boolean' ? (_jsxs("label", { style: { display: 'flex', gap: '0.5rem', alignItems: 'center' }, children: [_jsx("input", { type: "checkbox", checked: Boolean(values[field.key]), disabled: disabled, onChange: e => set(field.key, e.target.checked) }), field.label, field.required ? ' *' : ''] })) : (_jsxs(_Fragment, { children: [_jsxs("label", { className: "admin-label", htmlFor: `field-${field.key}`, children: [field.label, field.required ? ' *' : ''] }), _jsx(FieldInput, { field: field, value: values[field.key], disabled: disabled, onChange: value => set(field.key, value) })] })), field.help_text && _jsx("small", { style: { color: 'var(--fg-muted)' }, children: field.help_text })] }, field.key)))] }));
|
|
13
|
+
}
|
|
14
|
+
function FieldInput({ field, value, onChange, disabled }) {
|
|
15
|
+
const id = `field-${field.key}`;
|
|
16
|
+
const text = value === undefined || value === null ? '' : String(value);
|
|
17
|
+
switch (field.type) {
|
|
18
|
+
case 'textarea':
|
|
19
|
+
return _jsx("textarea", { id: id, className: "admin-textarea", value: text, required: field.required, disabled: disabled, onChange: e => onChange(e.target.value), style: { minHeight: '100px' } });
|
|
20
|
+
case 'select':
|
|
21
|
+
return (_jsxs("select", { id: id, className: "admin-input", value: text, required: field.required, disabled: disabled, onChange: e => onChange(e.target.value), children: [_jsx("option", { value: "", children: "\u2014" }), field.options.map(option => _jsx("option", { value: option, children: option }, option))] }));
|
|
22
|
+
case 'number':
|
|
23
|
+
// Sent as typed; the server turns it into a number or refuses it.
|
|
24
|
+
return _jsx("input", { id: id, type: "number", step: "any", className: "admin-input", value: text, required: field.required, disabled: disabled, onChange: e => onChange(e.target.value) });
|
|
25
|
+
case 'date':
|
|
26
|
+
return _jsx("input", { id: id, type: "date", className: "admin-input", value: text, required: field.required, disabled: disabled, onChange: e => onChange(e.target.value) });
|
|
27
|
+
case 'url':
|
|
28
|
+
return _jsx("input", { id: id, type: "url", className: "admin-input", value: text, required: field.required, disabled: disabled, onChange: e => onChange(e.target.value), placeholder: "https://" });
|
|
29
|
+
default:
|
|
30
|
+
return _jsx("input", { id: id, type: "text", className: "admin-input", value: text, required: field.required, disabled: disabled, onChange: e => onChange(e.target.value) });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A picker per custom taxonomy attached to the type.
|
|
35
|
+
*
|
|
36
|
+
* `onReady` reports once the taxonomies have loaded, so the editor only sends
|
|
37
|
+
* `term_ids` when it actually knows the selection — a failed load must not
|
|
38
|
+
* look like "no terms" and clear them on save.
|
|
39
|
+
*/
|
|
40
|
+
export function CustomTermsPanel({ typeKey, selected, onChange, onReady }) {
|
|
41
|
+
const { t } = useT();
|
|
42
|
+
const [taxonomies, setTaxonomies] = useState([]);
|
|
43
|
+
const [terms, setTerms] = useState({});
|
|
44
|
+
const [busy, setBusy] = useState(false);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
let live = true;
|
|
47
|
+
onReady(false);
|
|
48
|
+
(async () => {
|
|
49
|
+
try {
|
|
50
|
+
const res = await api.get(`/api/taxonomies?type=${encodeURIComponent(typeKey)}`);
|
|
51
|
+
const list = res?.taxonomies || [];
|
|
52
|
+
const loaded = {};
|
|
53
|
+
for (const taxonomy of list) {
|
|
54
|
+
const termRes = await api.get(`/api/taxonomies/${taxonomy.id}/terms`);
|
|
55
|
+
loaded[taxonomy.id] = termRes?.terms || [];
|
|
56
|
+
}
|
|
57
|
+
if (!live)
|
|
58
|
+
return;
|
|
59
|
+
setTaxonomies(list);
|
|
60
|
+
setTerms(loaded);
|
|
61
|
+
onReady(true);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
if (live)
|
|
65
|
+
setTaxonomies([]);
|
|
66
|
+
}
|
|
67
|
+
})();
|
|
68
|
+
return () => { live = false; };
|
|
69
|
+
}, [typeKey]);
|
|
70
|
+
const toggle = (id) => onChange(selected.includes(id) ? selected.filter(x => x !== id) : [...selected, id]);
|
|
71
|
+
const add = async (taxonomy, name) => {
|
|
72
|
+
if (!name || busy)
|
|
73
|
+
return false;
|
|
74
|
+
setBusy(true);
|
|
75
|
+
try {
|
|
76
|
+
const res = await api.post(`/api/taxonomies/${taxonomy.id}/terms`, { name });
|
|
77
|
+
const created = res?.term;
|
|
78
|
+
if (!created)
|
|
79
|
+
return false;
|
|
80
|
+
setTerms(prev => ({ ...prev, [taxonomy.id]: [...(prev[taxonomy.id] || []), created].sort((a, b) => a.name.localeCompare(b.name)) }));
|
|
81
|
+
onChange([...selected, created.id]);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
alert(error.message || t('Could not add that {term}.', { term: taxonomy.singular_label.toLowerCase() }));
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
setBusy(false);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
return (_jsx(_Fragment, { children: taxonomies.map(taxonomy => (_jsx(TermPicker, { title: taxonomy.plural_label, noun: taxonomy.singular_label.toLowerCase(), terms: terms[taxonomy.id] || [], selected: selected, onToggle: toggle, onAdd: name => add(taxonomy, name), busy: busy, emptyText: t('No {terms} yet.', { terms: taxonomy.plural_label.toLowerCase() }) }, taxonomy.id))) }));
|
|
93
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The featured image panel, for posts and for pages.
|
|
3
|
+
*
|
|
4
|
+
* One component rather than one per content type: the two editors would
|
|
5
|
+
* otherwise each grow their own copy, and the second would be the one that
|
|
6
|
+
* forgets to send null when the image is removed.
|
|
7
|
+
*
|
|
8
|
+
* What it stores is a media id. The preview needs a URL, which the server
|
|
9
|
+
* resolves through the storage adapter — so both travel: `value` is what gets
|
|
10
|
+
* saved, `url` is what gets shown.
|
|
11
|
+
*/
|
|
12
|
+
interface FeaturedImageBoxProps {
|
|
13
|
+
value: number | null;
|
|
14
|
+
url: string | null;
|
|
15
|
+
onChange: (image: {
|
|
16
|
+
id: number;
|
|
17
|
+
url: string;
|
|
18
|
+
} | null) => void;
|
|
19
|
+
}
|
|
20
|
+
export default function FeaturedImageBox({ value, url, onChange }: FeaturedImageBoxProps): import("react").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import MediaPicker from "./MediaPicker.js";
|
|
4
|
+
import { isImage, mediaUrl } from "../../hooks/useMediaLibrary.js";
|
|
5
|
+
import { useT } from "../../i18n/index.js";
|
|
6
|
+
export default function FeaturedImageBox({ value, url, onChange }) {
|
|
7
|
+
const { t } = useT();
|
|
8
|
+
const [picking, setPicking] = useState(false);
|
|
9
|
+
const choose = (item) => {
|
|
10
|
+
// A PDF as a hero image is a broken <img>, not a design decision.
|
|
11
|
+
if (!isImage(item.mime_type)) {
|
|
12
|
+
alert(t('A featured image has to be an image.'));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
onChange({ id: item.id, url: mediaUrl(item) });
|
|
16
|
+
setPicking(false);
|
|
17
|
+
};
|
|
18
|
+
return (_jsxs("div", { className: "admin-card", children: [_jsx("h3", { className: "admin-card-title", children: t('Featured image') }), value && url ? (_jsxs("div", { children: [_jsx("img", { src: url, alt: "", style: {
|
|
19
|
+
width: '100%',
|
|
20
|
+
borderRadius: '0.375rem',
|
|
21
|
+
display: 'block',
|
|
22
|
+
marginBottom: '0.5rem'
|
|
23
|
+
} }), _jsxs("div", { style: { display: 'flex', gap: '0.5rem' }, children: [_jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => setPicking(true), children: t('Replace') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-danger", onClick: () => onChange(null), children: t('Remove') })] })] })) : (_jsx("button", { type: "button", className: "admin-term-add", onClick: () => setPicking(true), children: t('+ Set featured image') })), picking && _jsx(MediaPicker, { onSelect: choose, onClose: () => setPicking(false) })] }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MediaItem } from '../../hooks/useMediaLibrary.ts';
|
|
3
|
+
/**
|
|
4
|
+
* A scrollable grid of media that fetches the next page as it nears the bottom.
|
|
5
|
+
*
|
|
6
|
+
* The library is paginated, so a grid that only ever rendered what it was first
|
|
7
|
+
* given would silently stop at the first page — which is what the admin page
|
|
8
|
+
* did: twenty files, and no way to reach the twenty-first.
|
|
9
|
+
*/
|
|
10
|
+
interface MediaGridProps {
|
|
11
|
+
items: MediaItem[];
|
|
12
|
+
selectedIds: number[];
|
|
13
|
+
onSelect: (item: MediaItem) => void;
|
|
14
|
+
onLoadMore: () => void;
|
|
15
|
+
hasMore: boolean;
|
|
16
|
+
loadingMore: boolean;
|
|
17
|
+
view?: 'grid' | 'list';
|
|
18
|
+
/** Rendered top-right of each tile; used for the bulk-select checkbox. */
|
|
19
|
+
renderBadge?: (item: MediaItem) => React.ReactNode;
|
|
20
|
+
emptyMessage?: string;
|
|
21
|
+
}
|
|
22
|
+
export default function MediaGrid({ items, selectedIds, onSelect, onLoadMore, hasMore, loadingMore, view, renderBadge, emptyMessage }: MediaGridProps): React.JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { isImage, mediaUrl } from "../../hooks/useMediaLibrary.js";
|
|
4
|
+
import { useT } from "../../i18n/index.js";
|
|
5
|
+
export default function MediaGrid({ items, selectedIds, onSelect, onLoadMore, hasMore, loadingMore, view = 'grid', renderBadge, emptyMessage }) {
|
|
6
|
+
const { t } = useT();
|
|
7
|
+
const sentinel = useRef(null);
|
|
8
|
+
// A sentinel below the last row rather than a scroll listener: the observer
|
|
9
|
+
// fires only when the element is actually reachable, so it works the same
|
|
10
|
+
// whether the grid scrolls itself or the page does.
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const node = sentinel.current;
|
|
13
|
+
if (!node || !hasMore)
|
|
14
|
+
return;
|
|
15
|
+
const observer = new IntersectionObserver(entries => {
|
|
16
|
+
if (entries[0]?.isIntersecting)
|
|
17
|
+
onLoadMore();
|
|
18
|
+
}, { rootMargin: '200px' });
|
|
19
|
+
observer.observe(node);
|
|
20
|
+
return () => observer.disconnect();
|
|
21
|
+
}, [hasMore, onLoadMore, items.length]);
|
|
22
|
+
if (items.length === 0) {
|
|
23
|
+
return (_jsx("p", { style: { color: 'var(--fg-muted)', textAlign: 'center', padding: '2rem' }, children: emptyMessage ?? t('No media files yet. Upload some!') }));
|
|
24
|
+
}
|
|
25
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { style: view === 'list'
|
|
26
|
+
? { display: 'flex', flexDirection: 'column', gap: '0.25rem' }
|
|
27
|
+
: {
|
|
28
|
+
display: 'grid',
|
|
29
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(150px, 1fr))',
|
|
30
|
+
gap: '1rem'
|
|
31
|
+
}, children: items.map(item => {
|
|
32
|
+
const selected = selectedIds.includes(item.id);
|
|
33
|
+
return (_jsxs("div", { onClick: () => onSelect(item), style: {
|
|
34
|
+
position: 'relative',
|
|
35
|
+
cursor: 'pointer',
|
|
36
|
+
border: selected ? '2px solid var(--accent)' : '1px solid var(--border)',
|
|
37
|
+
borderRadius: '0.375rem',
|
|
38
|
+
overflow: 'hidden',
|
|
39
|
+
backgroundColor: 'var(--surface-hover)',
|
|
40
|
+
display: view === 'list' ? 'flex' : 'block',
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
gap: view === 'list' ? '0.75rem' : undefined
|
|
43
|
+
}, children: [renderBadge && (_jsx("div", { style: { position: 'absolute', top: '0.25rem', left: '0.25rem', zIndex: 1 }, onClick: event => event.stopPropagation(), children: renderBadge(item) })), isImage(item.mime_type) ? (_jsx("img", { src: mediaUrl(item), alt: item.alt_text || item.original_name,
|
|
44
|
+
// Nothing generates thumbnails, so every tile is the full
|
|
45
|
+
// original. Deferring off-screen ones is what keeps a library
|
|
46
|
+
// of large photographs from loading all of them at once.
|
|
47
|
+
loading: "lazy", decoding: "async", style: {
|
|
48
|
+
width: view === 'list' ? '48px' : '100%',
|
|
49
|
+
height: view === 'list' ? '48px' : '120px',
|
|
50
|
+
objectFit: 'cover',
|
|
51
|
+
flexShrink: 0
|
|
52
|
+
} })) : (_jsx("div", { style: {
|
|
53
|
+
width: view === 'list' ? '48px' : '100%',
|
|
54
|
+
height: view === 'list' ? '48px' : '120px',
|
|
55
|
+
display: 'flex',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
fontSize: view === 'list' ? '1.25rem' : '2rem',
|
|
59
|
+
flexShrink: 0
|
|
60
|
+
}, children: "\uD83D\uDCC4" })), _jsx("div", { style: {
|
|
61
|
+
padding: view === 'list' ? '0' : '0.5rem',
|
|
62
|
+
fontSize: '0.75rem',
|
|
63
|
+
color: 'var(--fg-muted)',
|
|
64
|
+
overflow: 'hidden',
|
|
65
|
+
textOverflow: 'ellipsis',
|
|
66
|
+
whiteSpace: 'nowrap'
|
|
67
|
+
}, title: item.original_name, children: item.original_name })] }, item.id));
|
|
68
|
+
}) }), _jsx("div", { ref: sentinel, style: { height: '1px' } }), loadingMore && (_jsx("p", { style: { textAlign: 'center', color: 'var(--fg-muted)', padding: '1rem' }, children: t('Loading more…') }))] }));
|
|
69
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MediaItem } from '../../hooks/useMediaLibrary.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Choose a file, or upload one, without leaving the editor.
|
|
5
|
+
*
|
|
6
|
+
* Before this the library was a filing cabinet: you uploaded on one screen,
|
|
7
|
+
* copied a URL, then came back and typed the Markdown by hand. Putting a file
|
|
8
|
+
* into a post is the reason the library exists, so it belongs here.
|
|
9
|
+
*/
|
|
10
|
+
interface MediaPickerProps {
|
|
11
|
+
onSelect: (item: MediaItem) => void;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
}
|
|
14
|
+
export default function MediaPicker({ onSelect, onClose }: MediaPickerProps): React.JSX.Element;
|
|
15
|
+
/** The Markdown for a chosen file: an image embed, or a link to anything else. */
|
|
16
|
+
export declare function markdownFor(item: MediaItem): string;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
3
|
+
import { isImage, mediaUrl, useMediaLibrary } from "../../hooks/useMediaLibrary.js";
|
|
4
|
+
import MediaGrid from "./MediaGrid.js";
|
|
5
|
+
import { useT } from "../../i18n/index.js";
|
|
6
|
+
export default function MediaPicker({ onSelect, onClose }) {
|
|
7
|
+
const { t } = useT();
|
|
8
|
+
const library = useMediaLibrary();
|
|
9
|
+
const [dragging, setDragging] = useState(false);
|
|
10
|
+
const fileInput = useRef(null);
|
|
11
|
+
const uploadAndSelect = async (files) => {
|
|
12
|
+
const uploaded = await library.upload(files);
|
|
13
|
+
// Choosing the first of a batch is the common case: you dropped the image
|
|
14
|
+
// you wanted in order to use it.
|
|
15
|
+
if (uploaded[0])
|
|
16
|
+
onSelect(uploaded[0]);
|
|
17
|
+
};
|
|
18
|
+
return (_jsx("div", { role: "dialog", "aria-modal": "true", "aria-label": t('Media library'), onClick: onClose, style: {
|
|
19
|
+
position: 'fixed',
|
|
20
|
+
inset: 0,
|
|
21
|
+
background: 'rgba(0,0,0,0.5)',
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
justifyContent: 'center',
|
|
25
|
+
zIndex: 50,
|
|
26
|
+
padding: '1rem'
|
|
27
|
+
}, children: _jsxs("div", { onClick: event => event.stopPropagation(), onDragOver: event => {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
setDragging(true);
|
|
30
|
+
}, onDragLeave: () => setDragging(false), onDrop: event => {
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
setDragging(false);
|
|
33
|
+
void uploadAndSelect(Array.from(event.dataTransfer.files));
|
|
34
|
+
}, style: {
|
|
35
|
+
background: 'var(--surface)',
|
|
36
|
+
borderRadius: '0.5rem',
|
|
37
|
+
width: 'min(880px, 100%)',
|
|
38
|
+
maxHeight: '85vh',
|
|
39
|
+
display: 'flex',
|
|
40
|
+
flexDirection: 'column',
|
|
41
|
+
outline: dragging ? '2px dashed var(--accent)' : 'none'
|
|
42
|
+
}, children: [_jsxs("div", { style: {
|
|
43
|
+
display: 'flex',
|
|
44
|
+
gap: '0.5rem',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
padding: '1rem',
|
|
47
|
+
borderBottom: '1px solid var(--border)'
|
|
48
|
+
}, children: [_jsx("strong", { style: { marginRight: 'auto' }, children: t('Media library') }), _jsx("input", { type: "search", value: library.search, onChange: event => library.setSearch(event.target.value), placeholder: t('Search files'), className: "admin-input", style: { maxWidth: '200px' } }), _jsxs("select", { value: library.type, onChange: event => library.setType(event.target.value), className: "admin-input", style: { maxWidth: '140px' }, children: [_jsx("option", { value: "", children: t('All types') }), _jsx("option", { value: "image", children: t('Images') }), _jsx("option", { value: "video", children: t('Video') }), _jsx("option", { value: "audio", children: t('Audio') }), _jsx("option", { value: "other", children: t('Documents') })] }), _jsx("input", { ref: fileInput, type: "file", multiple: true, accept: "image/*,video/*,audio/*,.pdf,.doc,.docx", style: { display: 'none' }, onChange: event => {
|
|
49
|
+
void uploadAndSelect(Array.from(event.target.files || []));
|
|
50
|
+
event.target.value = '';
|
|
51
|
+
} }), _jsx("button", { className: "admin-btn admin-btn-primary", onClick: () => fileInput.current?.click(), children: t('Upload') }), _jsx("button", { className: "admin-btn admin-btn-secondary", onClick: onClose, children: t('Close') })] }), library.uploads.length > 0 && (_jsx("div", { style: { padding: '0.75rem 1rem', borderBottom: '1px solid var(--border)' }, children: library.uploads.map(upload => (_jsxs("div", { style: { fontSize: '0.8rem', marginBottom: '0.25rem' }, children: [upload.name, ' ', upload.error ? (_jsx("span", { style: { color: 'var(--danger)' }, children: upload.error })) : (_jsx("span", { style: { color: 'var(--fg-muted)' }, children: upload.percent === null ? t('starting…') : `${upload.percent}%` }))] }, upload.name))) })), _jsx("div", { style: { overflowY: 'auto', padding: '1rem' }, children: library.loading ? (_jsx("p", { style: { color: 'var(--fg-muted)', textAlign: 'center' }, children: t('Loading…') })) : (_jsx(MediaGrid, { items: library.items, selectedIds: [], onSelect: onSelect, onLoadMore: library.loadMore, hasMore: library.hasMore, loadingMore: library.loadingMore, emptyMessage: library.search || library.type
|
|
52
|
+
? t('Nothing matches that.')
|
|
53
|
+
: t('No media yet — upload or drop a file here.') })) })] }) }));
|
|
54
|
+
}
|
|
55
|
+
/** The Markdown for a chosen file: an image embed, or a link to anything else. */
|
|
56
|
+
export function markdownFor(item) {
|
|
57
|
+
const url = mediaUrl(item);
|
|
58
|
+
return isImage(item.mime_type)
|
|
59
|
+
? ``
|
|
60
|
+
: `[${item.original_name}](${url})`;
|
|
61
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface PageMeta {
|
|
2
|
+
page: number;
|
|
3
|
+
per_page: number;
|
|
4
|
+
total: number;
|
|
5
|
+
total_pages: number;
|
|
6
|
+
}
|
|
7
|
+
interface PaginationProps {
|
|
8
|
+
meta: PageMeta;
|
|
9
|
+
onChange: (page: number) => void;
|
|
10
|
+
/**
|
|
11
|
+
* What is being counted, for the summary line. The listings pass the English
|
|
12
|
+
* plural ("posts"), which is translated here; anything else is shown as given.
|
|
13
|
+
*/
|
|
14
|
+
noun?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Pager for the admin tables.
|
|
18
|
+
*
|
|
19
|
+
* The listings were unpaginated: every row came back on every load, so the
|
|
20
|
+
* query, the response and the table all grew with the content. This pages on
|
|
21
|
+
* the server — the count in `meta` comes from the database, not from the rows
|
|
22
|
+
* on screen, so "241 posts" stays true when only twenty are rendered.
|
|
23
|
+
*
|
|
24
|
+
* Renders nothing at a single page. A pager that shows "1 of 1" is furniture.
|
|
25
|
+
*/
|
|
26
|
+
export declare function Pagination({ meta, onChange, noun }: PaginationProps): import("react").JSX.Element | null;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useT } from "../../i18n/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Pager for the admin tables.
|
|
5
|
+
*
|
|
6
|
+
* The listings were unpaginated: every row came back on every load, so the
|
|
7
|
+
* query, the response and the table all grew with the content. This pages on
|
|
8
|
+
* the server — the count in `meta` comes from the database, not from the rows
|
|
9
|
+
* on screen, so "241 posts" stays true when only twenty are rendered.
|
|
10
|
+
*
|
|
11
|
+
* Renders nothing at a single page. A pager that shows "1 of 1" is furniture.
|
|
12
|
+
*/
|
|
13
|
+
export function Pagination({ meta, onChange, noun = 'items' }) {
|
|
14
|
+
const { t } = useT();
|
|
15
|
+
if (meta.total_pages <= 1)
|
|
16
|
+
return null;
|
|
17
|
+
const nouns = {
|
|
18
|
+
items: t('items'),
|
|
19
|
+
posts: t('posts'),
|
|
20
|
+
pages: t('pages'),
|
|
21
|
+
comments: t('comments'),
|
|
22
|
+
members: t('members'),
|
|
23
|
+
users: t('users'),
|
|
24
|
+
redirects: t('redirects')
|
|
25
|
+
};
|
|
26
|
+
const first = (meta.page - 1) * meta.per_page + 1;
|
|
27
|
+
const last = Math.min(meta.page * meta.per_page, meta.total);
|
|
28
|
+
return (_jsxs("div", { className: "admin-pagination", children: [_jsx("p", { className: "admin-pagination-summary", children: t('{first}–{last} of {total} {noun}', { first, last, total: meta.total, noun: nouns[noun] ?? noun }) }), _jsxs("div", { className: "admin-pagination-controls", children: [_jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => onChange(meta.page - 1), disabled: meta.page <= 1, children: t('Previous') }), _jsx("span", { className: "admin-pagination-position", children: t('Page {page} of {pages}', { page: meta.page, pages: meta.total_pages }) }), _jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => onChange(meta.page + 1), disabled: meta.page >= meta.total_pages, children: t('Next') })] })] }));
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface SnippetItem {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
content: string;
|
|
6
|
+
author_name: string | null;
|
|
7
|
+
can_edit: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface SnippetPickerProps {
|
|
10
|
+
/** Drops the snippet's Markdown in at the editor's caret. */
|
|
11
|
+
onInsert: (text: string) => void;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The "Insert snippet" toolbar button and the list it opens.
|
|
16
|
+
*
|
|
17
|
+
* Lives in the Markdown editor's toolbar, beside the media button, because
|
|
18
|
+
* that is where the caret is: the snippet goes in where you were typing, not
|
|
19
|
+
* at the end of the post. The text is copied in — editing the snippet later
|
|
20
|
+
* does not change posts that already used it.
|
|
21
|
+
*
|
|
22
|
+
* The list loads when first opened rather than with the editor, so a post
|
|
23
|
+
* that never uses a snippet costs no request. A 403 (a contributor) is shown
|
|
24
|
+
* as an explanation rather than an empty list that looks broken.
|
|
25
|
+
*/
|
|
26
|
+
export default function SnippetPicker({ onInsert, disabled }: SnippetPickerProps): React.JSX.Element;
|
|
27
|
+
export {};
|