@jant/core 0.6.16 → 0.7.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/README.md +11 -11
- package/bin/commands/assets/upload.js +192 -15
- package/bin/commands/import-site.js +60 -4
- package/bin/commands/reset-password.js +21 -8
- package/bin/commands/site/snapshot/export.js +1 -1
- package/bin/commands/site/snapshot/import.js +1 -1
- package/bin/lib/d1-query.js +5 -16
- package/bin/lib/node-env.js +40 -4
- package/bin/lib/site-selection.js +85 -29
- package/bin/lib/wrangler-cli.js +28 -2
- package/bin/lib/wrangler-json.js +35 -0
- package/dist/{app-C7_4oab9.js → app-K_Aa1MMn.js} +52476 -13330
- package/dist/client/.vite/manifest.json +255 -90
- package/dist/client/_assets/chunks/confirm-D7GrwsCN.js +45 -0
- package/dist/client/_assets/chunks/create-editor-CD3FhrOB.js +257 -0
- package/dist/client/_assets/chunks/{native-DpcrFAPh.js → emoji-mart-C4RpRKcU.js} +716 -1
- package/dist/client/_assets/chunks/footnote-rail-CmeoVtnU.js +1 -0
- package/dist/client/_assets/chunks/heic-to-CuP2Qlsw.js +1 -0
- package/dist/client/_assets/chunks/jant-locale-picker-DL6mIOT5.js +69 -0
- package/dist/client/_assets/chunks/lit-DW8VmJAT.js +2 -0
- package/dist/client/_assets/chunks/mediabunny-DRaCQ1r-.js +31 -0
- package/dist/client/_assets/chunks/rolldown-runtime-hePW80VL.js +1 -0
- package/dist/client/_assets/chunks/settings-paths-BcdySNx6.js +84 -0
- package/dist/client/_assets/chunks/site-header-nav-DzXsFk05.js +1 -0
- package/dist/client/_assets/chunks/slug-format-CRXO1AL5.js +1 -0
- package/dist/client/_assets/chunks/slugify-373citbs.js +1 -0
- package/dist/client/_assets/chunks/sortable-list-CgaL2jCs.js +2 -0
- package/dist/client/_assets/chunks/types-D5iF3H1a.js +1 -0
- package/dist/client/_assets/chunks/unsafe-html-B5ZEXaxg.js +1 -0
- package/dist/client/_assets/chunks/unsafe-svg-0QCkP0vZ.js +2 -0
- package/dist/client/_assets/client-GiYENVw8.css +2 -0
- package/dist/client/_assets/client-VnFxJN7G.js +295 -0
- package/dist/client/_assets/client-auth-k8gJ6QJj.js +828 -0
- package/dist/client/_assets/client-author-DQ8R-8KR.css +2 -0
- package/dist/client/_assets/client-compose-B_kDtWkW.js +2004 -0
- package/dist/client/_assets/client-manage-M90aSTOk.js +2170 -0
- package/dist/client/_assets/client-settings-DfYs9n1F.js +1112 -0
- package/dist/{export-Dl5KCiEs.js → github-sync-BPAvT999.js} +2254 -107
- package/dist/index.js +2 -5
- package/dist/node.js +5 -7
- package/package.json +3 -3
- package/src/__tests__/auth-session-freshness.test.ts +57 -0
- package/src/__tests__/basecoat-variants.test.ts +121 -0
- package/src/__tests__/bin/assets-upload.test.ts +68 -0
- package/src/__tests__/export-hugo-build.test.ts +260 -0
- package/src/__tests__/export-service.test.ts +231 -0
- package/src/__tests__/helpers/component-css.ts +91 -0
- package/src/__tests__/helpers/db.ts +33 -0
- package/src/__tests__/helpers/export-fixtures.ts +3 -0
- package/src/__tests__/stylesheet-audience.test.ts +159 -0
- package/src/__tests__/stylesheet-breakpoints.test.ts +183 -0
- package/src/app.tsx +71 -16
- package/src/auth.ts +18 -1
- package/src/client/__tests__/collection-page-actions.test.ts +51 -2
- package/src/client/__tests__/compose-bridge-image-upload.test.ts +196 -0
- package/src/client/__tests__/compose-bridge-video-poster.test.ts +159 -0
- package/src/client/__tests__/compose-bridge.test.ts +272 -0
- package/src/client/__tests__/compose-launch.test.ts +62 -1
- package/src/client/__tests__/compose-shortcuts.test.ts +38 -9
- package/src/client/__tests__/compose-triggers.test.ts +90 -0
- package/src/client/__tests__/copy-field.test.ts +162 -0
- package/src/client/__tests__/custom-url-menu.test.ts +127 -6
- package/src/client/__tests__/image-processor.test.ts +324 -2
- package/src/client/__tests__/lazy-entries.test.ts +92 -0
- package/src/client/__tests__/media-scroll-hint.test.ts +155 -0
- package/src/client/__tests__/runtime-paths.test.ts +84 -0
- package/src/client/__tests__/smart-collection-page-actions.test.ts +158 -0
- package/src/client/__tests__/toast.test.ts +23 -0
- package/src/client/__tests__/video-processor-probe.test.ts +175 -0
- package/src/client/__tests__/video-processor.test.ts +181 -0
- package/src/client/audio-processor.ts +24 -15
- package/src/client/audio-waveform.ts +49 -0
- package/src/client/collection-dialog-host.ts +72 -0
- package/src/client/collection-navigation.ts +51 -16
- package/src/client/collection-page-actions.ts +26 -0
- package/src/client/components/__tests__/jant-collection-dialog.test.ts +329 -0
- package/src/client/components/__tests__/jant-collection-directory.test.ts +274 -10
- package/src/client/components/__tests__/jant-collection-form.test.ts +59 -178
- package/src/client/components/__tests__/jant-command-palette.test.ts +28 -0
- package/src/client/components/__tests__/jant-compose-dialog-draft-storage.test.ts +340 -0
- package/src/client/components/__tests__/jant-compose-dialog.test.ts +1250 -53
- package/src/client/components/__tests__/jant-compose-editor.test.ts +544 -40
- package/src/client/components/__tests__/jant-compose-fullscreen.test.ts +0 -1
- package/src/client/components/__tests__/jant-locale-picker.test.ts +207 -0
- package/src/client/components/__tests__/jant-nav-manager.test.ts +234 -15
- package/src/client/components/__tests__/jant-post-menu.test.ts +413 -2
- package/src/client/components/__tests__/jant-post-picker.test.ts +197 -0
- package/src/client/components/__tests__/jant-settings-avatar.test.ts +15 -12
- package/src/client/components/__tests__/jant-settings-general.test.ts +541 -172
- package/src/client/components/__tests__/jant-settings-language.test.ts +851 -0
- package/src/client/components/__tests__/jant-smart-collection-dialog.test.ts +665 -0
- package/src/client/components/collection-dialog-types.ts +49 -0
- package/src/client/components/collection-manager-types.ts +32 -1
- package/src/client/components/collection-types.ts +1 -15
- package/src/client/components/compose-types.ts +75 -1
- package/src/client/components/jant-collection-dialog.ts +722 -0
- package/src/client/components/jant-collection-directory.ts +567 -182
- package/src/client/components/jant-collection-form.ts +53 -232
- package/src/client/components/jant-command-palette.ts +100 -49
- package/src/client/components/jant-compose-dialog.ts +1486 -707
- package/src/client/components/jant-compose-editor.ts +673 -336
- package/src/client/components/jant-compose-fullscreen.ts +51 -43
- package/src/client/components/jant-config-editor.ts +65 -53
- package/src/client/components/jant-confirm-dialog.ts +13 -11
- package/src/client/components/jant-locale-picker.ts +418 -0
- package/src/client/components/jant-media-lightbox.ts +146 -136
- package/src/client/components/jant-nav-manager.ts +690 -366
- package/src/client/components/jant-post-menu.ts +1086 -282
- package/src/client/components/jant-post-picker.ts +324 -0
- package/src/client/components/jant-repo-picker.ts +138 -106
- package/src/client/components/jant-settings-avatar.ts +31 -27
- package/src/client/components/jant-settings-general.ts +617 -543
- package/src/client/components/jant-settings-language.ts +1087 -0
- package/src/client/components/jant-smart-collection-dialog.ts +1021 -0
- package/src/client/components/jant-text-preview.ts +94 -86
- package/src/client/components/nav-manager-types.ts +62 -1
- package/src/client/components/settings-types.ts +14 -29
- package/src/client/components/smart-collection-conditions.ts +285 -0
- package/src/client/components/smart-collection-dialog-types.ts +68 -0
- package/src/client/compose-bridge.ts +214 -141
- package/src/client/compose-launch.ts +76 -2
- package/src/client/compose-shortcuts.ts +6 -8
- package/src/client/compose-triggers.ts +50 -0
- package/src/client/copy-field.ts +108 -0
- package/src/client/custom-url-menu.ts +60 -4
- package/src/client/icons.ts +14 -0
- package/src/client/image-plan.ts +165 -0
- package/src/client/image-processor.ts +195 -117
- package/src/client/image-worker-client.ts +45 -0
- package/src/client/image-worker.ts +135 -0
- package/src/client/lazy-entries.ts +95 -0
- package/src/client/lazy-slugify.ts +2 -2
- package/src/client/media-scroll-hint.ts +43 -2
- package/src/client/mediabunny.ts +29 -0
- package/src/client/post-picker.ts +41 -0
- package/src/client/runtime-paths.ts +74 -1
- package/src/client/settings-bridge.ts +4 -10
- package/src/client/site-header-nav.js +18 -6
- package/src/client/smart-collection-dialog-host.ts +116 -0
- package/src/client/smart-collection-page-actions.ts +208 -0
- package/src/client/tiptap/__tests__/bubble-menu.test.ts +110 -0
- package/src/client/tiptap/__tests__/floating-position.test.ts +136 -1
- package/src/client/tiptap/__tests__/inline-image-upload.test.ts +37 -0
- package/src/client/tiptap/bubble-menu.ts +47 -16
- package/src/client/tiptap/floating-position.ts +216 -2
- package/src/client/tiptap/inline-image-upload.ts +7 -3
- package/src/client/tiptap/link-toolbar.ts +22 -9
- package/src/client/toast.ts +13 -0
- package/src/client/types/vite-worker.d.ts +12 -0
- package/src/client/upload-with-metadata.ts +3 -13
- package/src/client/video-processor.ts +351 -107
- package/src/client-auth.ts +14 -31
- package/src/client-compose.ts +19 -0
- package/src/client-manage.ts +13 -0
- package/src/client-settings.ts +14 -0
- package/src/client-site.ts +10 -3
- package/src/client.ts +4 -0
- package/src/db/__tests__/backfill-nav-label-mirrors.test.ts +149 -0
- package/src/db/__tests__/schema-enum-sources.test.ts +33 -0
- package/src/db/__tests__/smart-collection-placement.test.ts +402 -0
- package/src/db/backfills/0006_clear_mirrored_page_nav_labels.sql +31 -0
- package/src/db/migrations/0032_married_tomas.sql +3 -0
- package/src/db/migrations/0033_busy_johnny_storm.sql +198 -0
- package/src/db/migrations/0034_cheerful_rumiko_fujikawa.sql +35 -0
- package/src/db/migrations/meta/0032_snapshot.json +2582 -0
- package/src/db/migrations/meta/0033_snapshot.json +2816 -0
- package/src/db/migrations/meta/0034_snapshot.json +2816 -0
- package/src/db/migrations/meta/_journal.json +21 -0
- package/src/db/migrations/pg/0030_abandoned_nighthawk.sql +3 -0
- package/src/db/migrations/pg/0031_strong_ultimatum.sql +128 -0
- package/src/db/migrations/pg/0032_furry_multiple_man.sql +6 -0
- package/src/db/migrations/pg/meta/0030_snapshot.json +3329 -0
- package/src/db/migrations/pg/meta/0031_snapshot.json +3660 -0
- package/src/db/migrations/pg/meta/0032_snapshot.json +3660 -0
- package/src/db/migrations/pg/meta/_journal.json +21 -0
- package/src/db/pg/schema.ts +195 -27
- package/src/db/post-visibility.ts +117 -0
- package/src/db/schema.ts +222 -27
- package/src/i18n/__tests__/detect.test.ts +26 -81
- package/src/i18n/__tests__/supported-locales.test.ts +83 -0
- package/src/i18n/context.tsx +12 -2
- package/src/i18n/detect.ts +7 -66
- package/src/i18n/locales/glossary.zh-Hans.yml +44 -4
- package/src/i18n/locales/glossary.zh-Hant.yml +44 -4
- package/src/i18n/locales/public/en.po +490 -158
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +487 -155
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +487 -155
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +551 -69
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +597 -115
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +610 -128
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/i18n/locales.ts +94 -0
- package/src/i18n/middleware.ts +12 -2
- package/src/i18n/supported-locales.ts +80 -0
- package/src/lib/__tests__/api-settings.test.ts +11 -2
- package/src/lib/__tests__/asset-path.test.ts +92 -0
- package/src/lib/__tests__/deferred.test.ts +90 -0
- package/src/lib/__tests__/discover-ping.test.ts +89 -0
- package/src/lib/__tests__/discover.test.ts +410 -0
- package/src/lib/__tests__/feed-policy.test.ts +26 -0
- package/src/lib/__tests__/feed.test.ts +1526 -15
- package/src/lib/__tests__/filter-dimensions.test.ts +341 -0
- package/src/lib/__tests__/hosted-signin.test.ts +1 -1
- package/src/lib/__tests__/http-cache.test.ts +162 -0
- package/src/lib/__tests__/jant-docs-dev.test.ts +21 -0
- package/src/lib/__tests__/jant-docs.test.ts +23 -0
- package/src/lib/__tests__/lang-detect.test.ts +231 -0
- package/src/lib/__tests__/media-helpers.test.ts +81 -0
- package/src/lib/__tests__/navigation.test.ts +135 -1
- package/src/lib/__tests__/resolve-config.test.ts +64 -3
- package/src/lib/__tests__/schemas.test.ts +42 -4
- package/src/lib/__tests__/site-unavailable-page.test.ts +25 -0
- package/src/lib/__tests__/slug.test.ts +70 -0
- package/src/lib/__tests__/slugify.test.ts +85 -0
- package/src/lib/__tests__/storage.test.ts +32 -0
- package/src/lib/__tests__/thread-fold.test.ts +113 -0
- package/src/lib/__tests__/upload-sideload.test.ts +14 -0
- package/src/lib/__tests__/url-fetch.test.ts +1 -2
- package/src/lib/__tests__/url.test.ts +78 -72
- package/src/lib/__tests__/view-language.test.ts +413 -0
- package/src/lib/__tests__/worker-response-cache.test.ts +90 -0
- package/src/lib/address.ts +57 -0
- package/src/lib/api-posts.ts +12 -0
- package/src/lib/asset-path.ts +98 -1
- package/src/lib/build-env.ts +16 -0
- package/src/lib/collection-groups.ts +5 -1
- package/src/lib/collection-paths.ts +3 -10
- package/src/lib/constants.ts +28 -3
- package/src/lib/copy-field.ts +36 -0
- package/src/lib/crypto.ts +40 -0
- package/src/lib/csp-builder.ts +2 -1
- package/src/lib/deferred.ts +79 -0
- package/src/lib/discover-ping.ts +141 -0
- package/src/lib/discover.ts +437 -0
- package/src/lib/env.ts +134 -0
- package/src/lib/errors.ts +33 -0
- package/src/lib/feed-policy.ts +236 -2
- package/src/lib/feed.ts +926 -73
- package/src/lib/filter-dimensions.ts +1349 -0
- package/src/lib/github-sync-site-config.ts +3 -0
- package/src/lib/hosted-signin.ts +1 -1
- package/src/lib/http-cache.ts +148 -0
- package/src/lib/hugo-markdown.ts +16 -0
- package/src/lib/icons.ts +9 -2
- package/src/lib/ids.ts +3 -0
- package/src/lib/jant-docs.ts +42 -0
- package/src/lib/lang-detect.ts +308 -0
- package/src/lib/media-helpers.ts +13 -1
- package/src/lib/navigation.ts +78 -11
- package/src/lib/pagination.ts +28 -24
- package/src/lib/per-language-surfaces.ts +67 -0
- package/src/lib/post-meta.ts +19 -0
- package/src/lib/render.tsx +55 -7
- package/src/lib/resolve-config.ts +53 -5
- package/src/lib/schemas.ts +201 -10
- package/src/lib/site-header-fragment.tsx +2 -1
- package/src/lib/site-unavailable-page.ts +47 -0
- package/src/lib/slug.ts +51 -7
- package/src/lib/slugify.ts +113 -0
- package/src/lib/startup-config.ts +4 -6
- package/src/lib/storage.ts +7 -0
- package/src/lib/summary.ts +50 -0
- package/src/lib/thread-fold.ts +161 -0
- package/src/lib/time.ts +32 -0
- package/src/lib/timeline.ts +42 -1
- package/src/lib/tiptap-render.ts +1 -2
- package/src/lib/upload.ts +16 -13
- package/src/lib/url.ts +139 -86
- package/src/lib/version.ts +10 -8
- package/src/lib/view-language.ts +436 -0
- package/src/lib/view.ts +51 -23
- package/src/lib/viewer-context.ts +62 -0
- package/src/middleware/__tests__/auth.test.ts +70 -2
- package/src/middleware/__tests__/cache-control.test.ts +71 -3
- package/src/middleware/__tests__/onboarding.test.ts +76 -5
- package/src/middleware/__tests__/secure-headers.test.ts +1 -1
- package/src/middleware/__tests__/session.test.ts +181 -33
- package/src/middleware/auth.ts +50 -31
- package/src/middleware/cache-control.ts +75 -10
- package/src/middleware/config.ts +6 -6
- package/src/middleware/error-handler.ts +12 -0
- package/src/middleware/onboarding.ts +32 -10
- package/src/middleware/secure-headers.ts +1 -1
- package/src/middleware/session.ts +96 -8
- package/src/node/__tests__/cli-migrate.test.ts +21 -19
- package/src/node/__tests__/cli-reset-password.test.ts +81 -8
- package/src/node/__tests__/cli-runtime-target.test.ts +48 -1
- package/src/node/__tests__/cli-site-selection.test.ts +128 -38
- package/src/node/__tests__/runtime.test.ts +37 -0
- package/src/node/index.ts +1 -0
- package/src/preset.css +76 -22
- package/src/routes/__tests__/feed-validator.test.ts +156 -0
- package/src/routes/api/__tests__/collections.test.ts +114 -0
- package/src/routes/api/__tests__/discover.test.ts +222 -0
- package/src/routes/api/__tests__/nav-items.test.ts +212 -2
- package/src/routes/api/__tests__/post-translations.test.ts +829 -0
- package/src/routes/api/__tests__/settings.test.ts +24 -3
- package/src/routes/api/__tests__/telegram.test.ts +6 -5
- package/src/routes/api/collections.ts +49 -6
- package/src/routes/api/custom-urls.ts +0 -1
- package/src/routes/api/discover.ts +95 -0
- package/src/routes/api/export.ts +3 -0
- package/src/routes/api/internal/__tests__/sites.test.ts +42 -2
- package/src/routes/api/nav-items.ts +55 -8
- package/src/routes/api/posts.ts +159 -0
- package/src/routes/api/public/__tests__/archive.test.ts +111 -0
- package/src/routes/api/public/archive.ts +77 -81
- package/src/routes/api/public/posts.ts +23 -6
- package/src/routes/api/smart-collections.ts +132 -0
- package/src/routes/api/telegram.ts +2 -40
- package/src/routes/api/uploads.ts +1 -2
- package/src/routes/auth/__tests__/setup-auth.test.ts +137 -0
- package/src/routes/auth/__tests__/setup-discover.test.ts +204 -0
- package/src/routes/auth/__tests__/setup-flow.test.ts +270 -0
- package/src/routes/auth/__tests__/setup-page.test.tsx +329 -0
- package/src/routes/auth/__tests__/setup-steps.test.ts +310 -0
- package/src/routes/auth/__tests__/setup.test.ts +278 -26
- package/src/routes/auth/__tests__/signin.test.ts +135 -0
- package/src/routes/auth/setup.tsx +934 -186
- package/src/routes/auth/signin.tsx +10 -8
- package/src/routes/compose.tsx +5 -0
- package/src/routes/dash/__tests__/custom-urls-archive.test.ts +44 -0
- package/src/routes/dash/__tests__/custom-urls-page.test.ts +49 -0
- package/src/routes/dash/__tests__/delete-account.test.ts +106 -0
- package/src/routes/dash/__tests__/settings-discover.test.ts +213 -0
- package/src/routes/dash/custom-urls.tsx +1 -37
- package/src/routes/dash/settings.tsx +502 -41
- package/src/routes/discover-announce.ts +96 -0
- package/src/routes/feed/__tests__/feed.test.ts +165 -2
- package/src/routes/feed/feed.ts +69 -40
- package/src/routes/feed/sitemap.ts +95 -11
- package/src/routes/pages/__tests__/archive-indexing.test.ts +200 -0
- package/src/routes/pages/__tests__/archive-params.test.ts +370 -6
- package/src/routes/pages/__tests__/collection-routing.test.ts +16 -0
- package/src/routes/pages/__tests__/collections-feed-links.test.ts +72 -0
- package/src/routes/pages/__tests__/collections.test.ts +9 -3
- package/src/routes/pages/__tests__/custom-archive-url.test.ts +119 -0
- package/src/routes/pages/__tests__/feed-autodiscovery.test.ts +148 -0
- package/src/routes/pages/__tests__/language-routing.test.ts +679 -0
- package/src/routes/pages/__tests__/post-preview-partial.test.ts +96 -0
- package/src/routes/pages/__tests__/smart-collection.test.ts +298 -0
- package/src/routes/pages/__tests__/subscribe.test.ts +248 -0
- package/src/routes/pages/archive.tsx +471 -369
- package/src/routes/pages/collection.tsx +94 -96
- package/src/routes/pages/collections.tsx +38 -50
- package/src/routes/pages/featured.tsx +32 -13
- package/src/routes/pages/home.tsx +25 -6
- package/src/routes/pages/language.tsx +113 -0
- package/src/routes/pages/latest.tsx +26 -16
- package/src/routes/pages/new.tsx +3 -0
- package/src/routes/pages/page.tsx +178 -17
- package/src/routes/pages/partials.tsx +41 -0
- package/src/routes/pages/search.tsx +18 -3
- package/src/routes/pages/smart-collection.tsx +340 -0
- package/src/routes/pages/subscribe.tsx +182 -0
- package/src/runtime/__tests__/index.test.ts +19 -0
- package/src/runtime/__tests__/node.test.ts +129 -4
- package/src/runtime/cloudflare.ts +21 -2
- package/src/runtime/index.ts +27 -1
- package/src/runtime/node.ts +18 -1
- package/src/runtime/site.ts +95 -24
- package/src/services/__tests__/auth.test.ts +116 -7
- package/src/services/__tests__/collection.test.ts +108 -4
- package/src/services/__tests__/language.test.ts +495 -0
- package/src/services/__tests__/navigation.test.ts +213 -10
- package/src/services/__tests__/path.test.ts +180 -0
- package/src/services/__tests__/post-language.test.ts +830 -0
- package/src/services/__tests__/post.test.ts +46 -9
- package/src/services/__tests__/settings.test.ts +228 -17
- package/src/services/__tests__/site-admin.test.ts +5 -5
- package/src/services/__tests__/smart-collection.test.ts +651 -0
- package/src/services/about-page.ts +22 -1
- package/src/services/auth.ts +51 -49
- package/src/services/bootstrap.ts +188 -38
- package/src/services/collection-directory-position.ts +76 -0
- package/src/services/collection.ts +331 -46
- package/src/services/custom-url.ts +27 -22
- package/src/services/export-theme/assets/client-site.css +1 -1
- package/src/services/export-theme/assets/client-site.js +123 -123
- package/src/services/export-theme/layouts/_default/rss.xml +77 -1
- package/src/services/export-theme/layouts/partials/feed-post-content.xml +105 -2
- package/src/services/export-theme/layouts/partials/media-gallery.html +35 -21
- package/src/services/export-theme/layouts/partials/pagination.html +14 -13
- package/src/services/export-theme/layouts/partials/post-card.html +8 -4
- package/src/services/export-theme/layouts/partials/reply.html +2 -1
- package/src/services/export-theme/layouts/partials/thread-preview.html +40 -30
- package/src/services/export-theme/styles/main.css +13 -1
- package/src/services/export.ts +278 -19
- package/src/services/index.ts +34 -3
- package/src/services/language.ts +412 -0
- package/src/services/mcp.ts +3 -1
- package/src/services/media.ts +14 -6
- package/src/services/navigation.ts +429 -67
- package/src/services/path.ts +221 -6
- package/src/services/post.ts +1021 -152
- package/src/services/search.ts +39 -2
- package/src/services/settings.ts +238 -43
- package/src/services/site-admin.ts +24 -7
- package/src/services/site.ts +77 -1
- package/src/services/smart-collection.ts +636 -0
- package/src/services/telegram.ts +20 -22
- package/src/services/upload-session.ts +1 -3
- package/src/style-author.css +27 -0
- package/src/styles/components-author.css +1622 -0
- package/src/styles/components.css +24 -1571
- package/src/styles/site-media.css +16 -2
- package/src/styles/tokens.css +82 -12
- package/src/styles/ui-author.css +7602 -0
- package/src/styles/ui.css +1087 -7219
- package/src/types/app-context.ts +7 -0
- package/src/types/bindings.ts +3 -0
- package/src/types/config.ts +94 -15
- package/src/types/constants.ts +188 -16
- package/src/types/entities.ts +87 -1
- package/src/types/operations.ts +64 -2
- package/src/types/props.ts +157 -31
- package/src/types/views.ts +55 -1
- package/src/ui/__tests__/font-themes.test.ts +52 -12
- package/src/ui/compose/ComposeDialog.tsx +201 -7
- package/src/ui/compose/ComposePrompt.tsx +1 -5
- package/src/ui/compose/__tests__/ComposeDialog.test.tsx +125 -0
- package/src/ui/dash/appearance/AdvancedContent.tsx +2 -2
- package/src/ui/dash/appearance/CodeInjectionContent.tsx +12 -16
- package/src/ui/dash/appearance/NavigationContent.tsx +117 -16
- package/src/ui/dash/appearance/__tests__/NavigationContent.test.tsx +33 -11
- package/src/ui/dash/appearance/__tests__/system-nav-descriptions.test.ts +44 -0
- package/src/ui/dash/appearance/system-nav-descriptions.ts +75 -0
- package/src/ui/dash/settings/AccountMenuContent.tsx +2 -2
- package/src/ui/dash/settings/ApiTokensContent.tsx +2 -1
- package/src/ui/dash/settings/ConfigEditorContent.tsx +35 -16
- package/src/ui/dash/settings/GeneralContent.tsx +275 -113
- package/src/ui/dash/settings/LanguageContent.tsx +409 -0
- package/src/ui/dash/settings/SettingsRootContent.tsx +19 -1
- package/src/ui/dash/settings/__tests__/GeneralContent.test.tsx +324 -4
- package/src/ui/dash/settings/__tests__/LanguageContent.test.tsx +144 -0
- package/src/ui/dash/settings/__tests__/discover-copy.test.ts +66 -0
- package/src/ui/dash/settings/discover-copy.ts +116 -0
- package/src/ui/feed/LinkCard.tsx +55 -45
- package/src/ui/feed/NoteCard.tsx +9 -4
- package/src/ui/feed/PostStatusBadges.tsx +90 -43
- package/src/ui/feed/QuoteCard.tsx +55 -30
- package/src/ui/feed/ThreadPreview.tsx +6 -2
- package/src/ui/feed/__tests__/thread-preview.test.ts +13 -16
- package/src/ui/feed/__tests__/timeline-cards.test.ts +314 -49
- package/src/ui/feed/thread-preview-state.ts +20 -6
- package/src/ui/font-themes.ts +39 -29
- package/src/ui/layouts/BaseLayout.tsx +155 -10
- package/src/ui/layouts/SiteLayout.tsx +192 -34
- package/src/ui/layouts/__tests__/BaseLayout.test.tsx +196 -17
- package/src/ui/layouts/__tests__/SiteLayout.test.tsx +109 -85
- package/src/ui/pages/ArchivePage.tsx +282 -289
- package/src/ui/pages/CollectionPage.tsx +86 -76
- package/src/ui/pages/CollectionsPage.tsx +5 -0
- package/src/ui/pages/ComposePage.tsx +8 -0
- package/src/ui/pages/PostPage.tsx +47 -0
- package/src/ui/pages/SearchPage.tsx +3 -3
- package/src/ui/pages/SmartCollectionPage.tsx +434 -0
- package/src/ui/pages/SubscribePage.tsx +236 -0
- package/src/ui/pages/__tests__/ArchivePage.test.tsx +65 -9
- package/src/ui/pages/__tests__/collections-directory-rows.test.tsx +92 -0
- package/src/ui/pages/__tests__/collections-view-links.test.tsx +81 -0
- package/src/ui/shared/CollectionDirectory.tsx +178 -3
- package/src/ui/shared/CollectionsManager.tsx +70 -17
- package/src/ui/shared/CopyField.tsx +127 -0
- package/src/ui/shared/EmptyPostContent.tsx +23 -0
- package/src/ui/shared/MediaGallery.tsx +125 -46
- package/src/ui/shared/Pagination.tsx +20 -5
- package/src/ui/shared/PostFooter.tsx +20 -11
- package/src/ui/shared/__tests__/archive-labels.test.ts +100 -0
- package/src/ui/shared/__tests__/media-gallery.test.ts +210 -2
- package/src/ui/shared/__tests__/navigation-labels.test.ts +16 -22
- package/src/ui/shared/__tests__/pagination.test.ts +38 -24
- package/src/ui/shared/__tests__/post-footer.test.ts +32 -0
- package/src/ui/shared/archive-labels.ts +98 -0
- package/src/ui/shared/collection-management-labels.ts +94 -16
- package/src/ui/shared/navigation-labels.ts +45 -71
- package/src/ui/shared/post-article-attributes.ts +2 -0
- package/src/ui/shared/smart-collection-labels.ts +343 -0
- package/dist/app-C75Zc8dD.js +0 -6
- package/dist/client/_assets/chunks/heic-to-DUUaO23q.js +0 -1
- package/dist/client/_assets/chunks/module-DcsAZQZ_.js +0 -716
- package/dist/client/_assets/chunks/url-CU9pEbk5.js +0 -1
- package/dist/client/_assets/client-Bq0vre8Y.js +0 -296
- package/dist/client/_assets/client-D3VZyG4L.css +0 -2
- package/dist/client/_assets/client-auth-F2rb9WfF.js +0 -5571
- package/dist/env-BPYViDJJ.js +0 -281
- package/dist/github-api-BNF35Lkx.js +0 -176
- package/dist/github-app-DdiD-bC4.js +0 -275
- package/dist/github-sync-Bqg62IvV.js +0 -4
- package/dist/github-sync-HdK2EgvJ.js +0 -431
- package/dist/url-CbLAtlZe.js +0 -900
- package/src/client/__tests__/collection-created-notice.test.ts +0 -36
- package/src/client/__tests__/collection-form-bridge.test.ts +0 -216
- package/src/client/__tests__/post-form-bridge.test.ts +0 -82
- package/src/client/collection-created-notice.ts +0 -66
- package/src/client/collection-form-bridge.ts +0 -191
- package/src/client/components/__tests__/jant-post-form.test.ts +0 -193
- package/src/client/components/jant-post-form.ts +0 -422
- package/src/client/components/post-form-template.ts +0 -352
- package/src/client/components/post-form-types.ts +0 -96
- package/src/client/media-metadata.ts +0 -247
- package/src/client/post-form-bridge.ts +0 -193
- package/src/ui/pages/CollectionEditorPage.tsx +0 -175
|
@@ -0,0 +1,828 @@
|
|
|
1
|
+
import{T as e,g as t,h as n,i as r,m as i,n as a,t as o,u as s,x as ee,y as te}from"./chunks/lit-DW8VmJAT.js";import"./client-VnFxJN7G.js";import{n as c,t as ne}from"./chunks/confirm-D7GrwsCN.js";import{_ as l,a as re,d as u,f as d,g as f,h as p,i as ie,l as m,m as ae,n as oe,p as se,r as ce,t as h,u as g,v as _,y as le}from"./chunks/unsafe-svg-0QCkP0vZ.js";import{r as v}from"./chunks/slug-format-CRXO1AL5.js";import{h as y,l as ue,u as b}from"./chunks/types-D5iF3H1a.js";import{t as de}from"./chunks/settings-paths-BcdySNx6.js";var x=`M12 3 10.1 10.1 3 12l7.1 1.9L12 21l1.9-7.1L21 12l-7.1-1.9Z`,fe=`M4 4 20 20`,pe=200,me=class extends o{static properties={_open:{state:!0},_query:{state:!0},_items:{state:!0},_note:{state:!0},_loading:{state:!0},_searched:{state:!0}};#e=null;#t=null;#n=0;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this._open=!1,this._query=``,this._items=[],this._note=``,this._loading=!1,this._searched=!1}disconnectedCallback(){super.disconnectedCallback();let e=this.#e;this.#e=null,e?.resolve(null)}pick(e){return this.#e?.resolve(null),this._query=``,this._items=[],this._note=``,this._loading=!1,this._searched=!1,this._open=!0,new Promise(t=>{this.#e={...e,resolve:t},this.updateComplete.then(()=>{let e=this.querySelector(`.picker-dialog`);e&&!e.open&&e.showModal(),this.querySelector(`.picker-dialog-input`)?.focus()})})}#r(e){this.#t&&clearTimeout(this.#t),this.#t=null,this.#n+=1;let t=this.querySelector(`.picker-dialog`);t?.open&&t.close();let n=this.#e;this.#e=null,this._open=!1,n?.resolve(e)}#i(e){let t=this.#e;if(!t)return;let n=e.target.value;this._query=n,this.#t&&clearTimeout(this.#t);let r=t.minQueryLength??2;if(n.trim().length<r){this.#n+=1,this._items=[],this._note=``,this._loading=!1,this._searched=!1;return}this._loading=!0,this.#t=setTimeout(()=>{this.#a(n,t)},pe)}async#a(e,t){let n=++this.#n;try{let r=await t.search(e);if(n!==this.#n)return;this._items=r.items,this._note=r.note??``}catch{if(n!==this.#n)return;this._items=[],this._note=``}finally{n===this.#n&&(this._loading=!1,this._searched=!0)}}#o(e){if(e.key===`Escape`){e.preventDefault(),this.#r(null);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=Array.from(this.querySelectorAll(`.picker-dialog-option`));if(t.length===0)return;e.preventDefault();let n=document.activeElement,r=t.findIndex(e=>e===n),i=e.key===`ArrowDown`?r<0?0:Math.min(r+1,t.length-1):r<=0?-1:r-1;if(i<0){this.querySelector(`.picker-dialog-input`)?.focus();return}t[i]?.focus()}#s(e){e.target===e.currentTarget&&this.#r(null)}render(){let e=this.#e;if(!this._open||!e)return a;let t=e.minQueryLength??2,n=this._query.trim().length<t;return r`
|
|
2
|
+
<dialog
|
|
3
|
+
class="dialog picker-dialog"
|
|
4
|
+
@cancel=${e=>{e.preventDefault(),this.#r(null)}}
|
|
5
|
+
@click=${this.#s}
|
|
6
|
+
@keydown=${this.#o}
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
class="picker-dialog-panel"
|
|
10
|
+
role="document"
|
|
11
|
+
aria-labelledby="picker-dialog-title"
|
|
12
|
+
>
|
|
13
|
+
<header class="picker-dialog-header">
|
|
14
|
+
<h2 id="picker-dialog-title" class="picker-dialog-title">
|
|
15
|
+
${e.heading}
|
|
16
|
+
</h2>
|
|
17
|
+
${e.hint?r`<p class="picker-dialog-hint">${e.hint}</p>`:a}
|
|
18
|
+
</header>
|
|
19
|
+
|
|
20
|
+
<input
|
|
21
|
+
type="search"
|
|
22
|
+
class="input picker-dialog-input"
|
|
23
|
+
placeholder=${e.placeholder}
|
|
24
|
+
aria-label=${e.heading}
|
|
25
|
+
autocomplete="off"
|
|
26
|
+
.value=${this._query}
|
|
27
|
+
@input=${this.#i}
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
<div class="picker-dialog-results" role="listbox">
|
|
31
|
+
${this._items.map(e=>r`
|
|
32
|
+
<button
|
|
33
|
+
type="button"
|
|
34
|
+
role="option"
|
|
35
|
+
aria-selected="false"
|
|
36
|
+
class="picker-dialog-option"
|
|
37
|
+
@click=${()=>this.#r(e.id)}
|
|
38
|
+
>
|
|
39
|
+
<span class="picker-dialog-option-label">${e.label}</span>
|
|
40
|
+
${e.meta?r`<span class="picker-dialog-option-meta"
|
|
41
|
+
>${e.meta}</span
|
|
42
|
+
>`:a}
|
|
43
|
+
</button>
|
|
44
|
+
`)}
|
|
45
|
+
${this._loading?r`<p class="picker-dialog-status">Searching…</p>`:a}
|
|
46
|
+
${!this._loading&&this._searched&&this._items.length===0?r`<p class="picker-dialog-status">
|
|
47
|
+
${this._note||e.emptyHint}
|
|
48
|
+
</p>`:a}
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<footer
|
|
52
|
+
class=${v({"picker-dialog-actions":!0,"picker-dialog-actions-quiet":n})}
|
|
53
|
+
>
|
|
54
|
+
<button
|
|
55
|
+
type="button"
|
|
56
|
+
class="btn-outline"
|
|
57
|
+
@click=${()=>this.#r(null)}
|
|
58
|
+
>
|
|
59
|
+
Cancel
|
|
60
|
+
</button>
|
|
61
|
+
</footer>
|
|
62
|
+
</div>
|
|
63
|
+
</dialog>
|
|
64
|
+
`}};customElements.get(`jant-post-picker`)||customElements.define(`jant-post-picker`,me);var S=`jant-post-picker`;function he(){let e=document.querySelector(S);if(e)return e;let t=document.createElement(S);return document.body.appendChild(t),t}function ge(e){return he().pick(e)}var C=`[data-post-menu-translation] a, [data-post-menu-translation-first], [data-post-menu-open-language-switch]`,_e=360,w=12;function ve(e){let t=window.innerHeight-e.bottom-w,n=e.top-w;return t<_e&&n>t}function T(e){let t=Array.from(e?.children??[]).find(e=>e instanceof HTMLElement&&e.classList.contains(`feed-item`));Array.from(t?.children??[]).find(e=>e instanceof HTMLElement&&e.classList.contains(`feed-divider`))?.remove()}function E(e){return Array.from(document.querySelectorAll(`article[data-post-id]`)).find(t=>t.dataset.postId===e)??null}function D(e){let t=e.dataset.postId;if(!t)return null;let n=e.dataset.threadRootId??t,r=E(n)??e;return{id:t,threadId:n,pinned:e.hasAttribute(`data-post-pinned`),pinnedInCollection:r.hasAttribute(`data-post-pinned-in-collection`),featured:e.hasAttribute(`data-post-featured`),visibility:e.dataset.postVisibility??`public`,isReply:n!==t||e.hasAttribute(`data-post-reply`),isDraft:e.hasAttribute(`data-post-draft`),language:r.dataset.postLanguage??null}}var ye=class extends o{static properties={languages:{type:Array},_open:{state:!0},_data:{state:!0},_x:{state:!0},_y:{state:!0},_openAbove:{state:!0},_view:{state:!0},_collections:{state:!0},_collectionsLoading:{state:!0},_collectionSearch:{state:!0},_threadCollectionIds:{state:!0},_addCollectionPanelOpen:{state:!0},_translations:{state:!0},_translationsLoading:{state:!0},_translationBusy:{state:!0}};#e=!1;#t=[];#n=!0;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this.languages=[],this._open=!1,this._data=null,this._x=0,this._y=0,this._openAbove=!0,this._view=`menu`,this._collections=null,this._collectionsLoading=!1,this._collectionSearch=``,this._threadCollectionIds=[],this._addCollectionPanelOpen=!1,this._translations=null,this._translationsLoading=!1,this._translationBusy=!1,this._triggerEl=null}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.#o),document.addEventListener(`keydown`,this.#a),window.addEventListener(`resize`,this.#i)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`click`,this.#o),document.removeEventListener(`keydown`,this.#a),window.removeEventListener(`resize`,this.#i)}#r(){let e=this._triggerEl;if(!e?.isConnected){this._open&&this.#k({restoreFocus:!1});return}let t=e.getBoundingClientRect();this._openAbove=ve(t),this._x=window.scrollX+t.right,this._y=window.scrollY+(this._openAbove?t.top-6:t.bottom+6)}#i=()=>{this._open&&!this._addCollectionPanelOpen&&this.#r()};#a=e=>{let t=e;if(!(t.isComposing||t.keyCode===229)&&t.key===`Escape`){if(this._addCollectionPanelOpen){this.#B();return}let e=document.querySelector(`[data-collection-popover].open`);if(e){e.classList.remove(`open`);return}if(this._open){if(this._view===`language-switch`){this.#v();return}if(this._view!==`menu`){this.#p();return}this.#k()}}};#o=e=>{let t=e.target,n=t.closest(`[data-collection-popover-trigger]`);if(n){e.preventDefault(),e.stopPropagation();let t=n.parentElement?.querySelector(`[data-collection-popover]`);t&&t.classList.toggle(`open`);return}if(t.closest(`[data-collection-popover]`)||t.closest(`[data-collection-quick-dialog]`)||t.classList.contains(`collection-quick-dialog-backdrop`))return;let r=document.querySelector(`[data-collection-popover].open`);r&&r.classList.remove(`open`);let i=t.closest(`[data-post-menu-trigger]`);if(i){e.preventDefault(),e.stopPropagation();let t=i.closest(`article[data-post]`);if(!t)return;let n=D(t);if(!n)return;if(this._open&&this._data?.id===n.id){this.#k();return}this._data=n,this._triggerEl=i,this.#n=!0,this.#r(),i.setAttribute(`aria-expanded`,`true`),this._view=`menu`,this._open=!0,this.#s(`[data-post-menu-item-primary]`);return}this._open&&t.closest?.(`.post-menu-view, .post-menu-panel`)||this._open&&this.#k({restoreFocus:!1})};#s(e){this.updateComplete.then(()=>{this.querySelector(e)?.focus()})}#c(){return Array.from(this.querySelectorAll(`.post-menu-picker-option`))}#l=e=>{if(e.defaultPrevented||e.isComposing||e.altKey||e.ctrlKey||e.metaKey)return;if(e.key===`Enter`){e.preventDefault(),this.#k();return}if(e.key!==`ArrowDown`)return;let[t]=this.#c(),n=this.querySelector(`[data-post-menu-add-collection]`),r=t??n;r&&(e.preventDefault(),r.focus())};#u=(e,t)=>{if(e.defaultPrevented||e.isComposing||e.altKey||e.ctrlKey||e.metaKey)return;let n=this.#c(),r=e.currentTarget,i=r?n.indexOf(r):-1;if(e.key===`ArrowDown`){let t=this.querySelector(`[data-post-menu-add-collection]`),r=i>=0?n[i+1]??t:n[0];if(!r)return;e.preventDefault(),r.focus();return}if(e.key===`ArrowUp`){let t=this.querySelector(`.post-menu-picker-search input`),r=i>0?n[i-1]:t;if(!r)return;e.preventDefault(),r.focus();return}if(e.key===` `||e.key===`Spacebar`){e.preventDefault(),this.#R(t);return}e.key===`Enter`&&(e.preventDefault(),this.#k())};#d=(e,t)=>{e.detail!==0&&this.#R(t)};#f=e=>{if(e.defaultPrevented||e.isComposing||e.altKey||e.ctrlKey||e.metaKey||e.key!==`ArrowUp`)return;let t=this.#c(),n=this.querySelector(`.post-menu-picker-search input`),r=t.at(-1)??n;r&&(e.preventDefault(),r.focus())};#p(e=`[data-post-menu-item-primary]`){this._view=`menu`,this.#s(e)}#m(){this._data?.isReply||(this._view=`visibility`,this.#s(`[data-post-menu-visibility-current='true'], [data-post-menu-visibility-option]`))}get#h(){return this.languages.length>1}#g(e){return e?this.languages.find(t=>t.tag===e)?.label??e:`Not set`}async#_(){this._data?.isReply||(this._view=`language`,this.#s(C),await this.#S(),this.contains(document.activeElement)||this.#s(C))}#v(e=`[data-post-menu-open-language-switch]`){this._view=`language`,this.#s(e)}#y(){this._data?.isReply||(this._view=`language-switch`,this.#s(`[data-post-menu-language-current='true'], [data-post-menu-language-option]`))}#b(){let e=this._data?.language??null,t=this._translations??[],n=new Set(t.flatMap(e=>e.language?[e.language]:[]));return{current:e,linked:t,selectable:this.languages.filter(t=>t.tag===e||!n.has(t.tag)),free:this.languages.filter(t=>t.tag!==e&&!n.has(t.tag))}}async#x(e){let t=this._data;if(t&&!this._translationBusy){this._translationBusy=!0;try{let r=await fetch(n(`/api/posts/${t.threadId}/language`),{method:`PUT`,headers:{"Content-Type":`application/json`},credentials:`same-origin`,body:JSON.stringify({language:e})});if(!r.ok){s(await y(r,`Could not change the language. Try again.`),`error`);return}let i=document.querySelector(`article[data-post-id="${t.threadId}"]`);i&&(i.dataset.postLanguage=e),this._data={...t,language:e},s(`Thread is now in ${this.#g(e)}.`),this.#k()}catch{s(`Could not change the language. Try again.`,`error`)}finally{this._translationBusy=!1}}}async#S(){let e=this._data;if(e){this._translationsLoading=!0;try{let t=await fetch(n(`/api/posts/${e.threadId}/translations`),{credentials:`same-origin`});if(!t.ok)return;let r=await t.json();this._translations=r.translations??[]}catch{this._translations=[]}finally{this._translationsLoading=!1}}}async#C(e){let t=this._data;if(!t)return;this.#k({restoreFocus:!1});let r=await m();if(r){await r.openTranslation(t.threadId,e);return}let i=new URLSearchParams({translationOf:t.threadId,lang:e});window.location.assign(n(`/new?${i.toString()}`))}async#w(){let e=this._data;if(!e)return;this.#k({restoreFocus:!1});let t=await ge({heading:`Link a translation`,hint:`Only posts you could actually link are listed: published, and in a language this one's group does not already have.`,placeholder:`Search your posts, or paste a URL…`,emptyHint:`Nothing matched that you could link.`,search:async t=>{if(ee(t))return this.#T(e.threadId,t);let r=await fetch(n(`/api/posts/${e.threadId}/translations/candidates?q=${encodeURIComponent(t)}`),{credentials:`same-origin`});return r.ok?{items:((await r.json()).candidates??[]).map(e=>({id:e.id,label:e.label,meta:this.#g(e.language)}))}:{items:[]}}});t&&(this._data=e,await this.#D(t),window.location.reload())}async#T(e,t){let r;try{let i=await fetch(n(`/api/posts/${e}/translations/resolve?url=${encodeURIComponent(t)}`),{credentials:`same-origin`});if(!i.ok)throw Error(`HTTP ${i.status}`);({resolution:r}=await i.json())}catch{return{items:[],note:`Could not check that address. Try again in a moment.`}}return r?r.kind===`ok`?{items:[{id:r.candidate.id,label:r.candidate.label,meta:this.#g(r.candidate.language)}]}:{items:[],note:this.#E(r)}:{items:[]}}#E(e){let t=this.#g(`language`in e?e.language:null);switch(e.kind){case`external`:return`That address is somewhere else. Only posts on this site can be linked.`;case`not_found`:return`Nothing at ${e.address}. Check the address, or search by title.`;case`not_a_post`:return`That address is not a post. Translations link posts to posts.`;case`same_thread`:return`That is this post.`;case`unpublished`:return`That post is a draft. Publish it, then link it.`;case`no_language`:return`That post has no language yet. Set one on it first.`;case`same_language`:return`That post is written in ${this.#g(this._data?.language??null)} too. A translation has to be in another language.`;case`language_taken`:return`A ${t} version is already linked here. Unlink that one first.`;case`group_conflict`:return`That post belongs to another translation group. Unlink it first.`;case`group_language_taken`:return`Its translation group already has a ${t} version.`;default:return`That post cannot be linked.`}}async#D(e){let t=this._data;if(t&&!this._translationBusy){this._translationBusy=!0;try{let r=await fetch(n(`/api/posts/${t.threadId}/translations`),{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`same-origin`,body:JSON.stringify({postId:e})});if(!r.ok){s(await y(r,`Could not link those posts. Try again.`),`error`);return}await this.#S(),s(`Posts linked as translations.`)}catch{s(`Could not link those posts. Try again.`,`error`)}finally{this._translationBusy=!1}}}async#O(e){if(!this._data||this._translationBusy)return;let t=this._triggerEl;this.#k({restoreFocus:!1});let r=this.#g(e.language);if(!await c({message:`Unlink the ${r} version, “${e.label}”? Both posts stay published — they just stop pointing at each other.`,confirmLabel:`Unlink`,cancelLabel:`Cancel`,tone:`danger`})){t?.focus();return}this._translationBusy=!0;try{let r=await fetch(n(`/api/posts/${e.id}/translations`),{method:`DELETE`,credentials:`same-origin`});if(!r.ok){s(await y(r,`Could not unlink. Try again.`),`error`),t?.focus();return}s(`Translation link removed.`),window.location.reload()}catch{s(`Could not unlink. Try again.`,`error`),t?.focus()}finally{this._translationBusy=!1}}#k(e={}){let t=e.restoreFocus??this.#n,n=this._triggerEl;if(n?.setAttribute(`aria-expanded`,`false`),this._triggerEl=null,this.#n=!0,this._open=!1,this._view=`menu`,this._addCollectionPanelOpen=!1,this._collectionSearch=``,this._translations=null,this.#e){this.#e=!1,window.location.reload();return}t&&n?.focus()}openCollectionsForPost(e){let t=D(e);if(!t||t.isReply)return;this._data=t;let n=e.querySelector(`[data-post-menu-trigger]`);n&&(this._triggerEl=n,this.#n=!1,this.#r(),n.setAttribute(`aria-expanded`,`true`)),this._open=!0,this.#L()}async#A(){if(!this._data)return;let e=this._data.id;this.#k({restoreFocus:!1});let t=await m();t&&await t.openEdit(e)}async#j(){if(!this._data)return;let e=this._data.id,t=this._triggerEl;this.#k({restoreFocus:!1});let n=document.querySelector(`article[data-post-id="${e}"]`);try{if(!(await fetch(`/api/posts/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({status:`published`})})).ok)throw Error();s(`Draft published.`),(!n||!await re(n))&&globalThis.location.reload()}catch{s(`Could not publish the draft. Try again.`,`error`),t?.focus()}}#M(e){if(!this._data)return;let t=this._data.id,n=this._data.visibility,r=document.querySelector(`article[data-post-id="${t}"]`);r&&(r.dataset.postVisibility=e),this._data={...this._data,visibility:e},s({public:`Post made public.`,latest_hidden:`Hidden from Latest.`,private:`Post made private.`}[e]??`Visibility updated.`),this.#k(),fetch(`/api/posts/${t}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({visibility:e})}).then(e=>{if(!e.ok)throw Error()}).catch(()=>{let e=document.querySelector(`article[data-post-id="${t}"]`);e&&(e.dataset.postVisibility=n),s(`Could not update visibility. Try again.`,`error`)})}#N(e){if(!this._data)return;let t=this._data.id,n=document.querySelector(`article[data-post-id="${t}"]`);n&&(e?n.setAttribute(`data-post-featured`,``):n.removeAttribute(`data-post-featured`)),this._data={...this._data,featured:e},s(e?`Added to Featured.`:`Removed from Featured.`),this.#k(),fetch(`/api/posts/${t}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({featured:e})}).then(e=>{if(!e.ok)throw Error()}).catch(()=>{let n=document.querySelector(`article[data-post-id="${t}"]`);n&&(e?n.removeAttribute(`data-post-featured`):n.setAttribute(`data-post-featured`,``)),s(`Could not update post. Try again.`,`error`)})}#P(){if(!this._data)return;let e=this._data.id,t=!this._data.pinned,n=document.querySelector(`article[data-post-id="${e}"]`);n&&(t?n.setAttribute(`data-post-pinned`,``):n.removeAttribute(`data-post-pinned`)),this._data={...this._data,pinned:t},s(t?`Post pinned.`:`Post unpinned.`),this.#k(),fetch(`/api/posts/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pinned:t})}).then(e=>{if(!e.ok)throw Error()}).catch(()=>{let n=document.querySelector(`article[data-post-id="${e}"]`);n&&(t?n.removeAttribute(`data-post-pinned`):n.setAttribute(`data-post-pinned`,``)),s(`Could not update post. Try again.`,`error`)})}#F(){if(!this._data)return;let e=this._data.threadId,t=document.querySelector(`[data-collection-id]`)?.dataset.collectionId;if(!t)return;let n=!this._data.pinnedInCollection,r=E(e);r&&(n?r.setAttribute(`data-post-pinned-in-collection`,``):r.removeAttribute(`data-post-pinned-in-collection`)),this._data={...this._data,pinnedInCollection:n},s(n?`Pinned in collection.`:`Unpinned from collection.`),this.#k();let i=n?`PUT`:`DELETE`;fetch(`/api/collections/${t}/threads/${e}/pin`,{method:i}).then(e=>{if(!e.ok)throw Error()}).catch(()=>{let t=E(e);t&&(n?t.removeAttribute(`data-post-pinned-in-collection`):t.setAttribute(`data-post-pinned-in-collection`,``)),s(`Could not update pin. Try again.`,`error`)})}async#I(){if(!this._data)return;let e=this._triggerEl;if(this.#k({restoreFocus:!1}),!await c({message:this._data.isDraft?`Discard this draft permanently? This can't be undone.`:`Delete this post permanently? This can't be undone.`,confirmLabel:this._data.isDraft?`Discard`:`Delete`,cancelLabel:`Cancel`,tone:`danger`})){e?.focus();return}try{if(!(await fetch(`/api/posts/${this._data.id}`,{method:`DELETE`})).ok)throw Error();let e=document.querySelector(`article[data-post-id="${this._data.id}"]`),t=e?.closest(`.thread-item`),n=t?.closest(`.thread-group`);if(t&&n){if(t.remove(),n.querySelectorAll(`.thread-item:not(.thread-item-gap)`).length===0){let e=n.closest(`.feed-item`),t=e?.parentElement??null;(e??n).remove(),T(t)}}else{let t=e?.closest(`.feed-item`),n=t?.parentElement??null;(t??e)?.remove(),T(n)}s(`Post deleted.`)}catch{s(`Could not delete post. Try again.`,`error`),e?.focus()}}async#L(){if(!this._data||this._data.isReply)return;let e=this._data.id;this._view=`collections`,this._collectionSearch=``,this._collectionsLoading=!0,this.#s(`.post-menu-picker-search input, .post-menu-picker-option, [data-post-menu-add-collection]`);try{let[t,n]=await Promise.all([fetch(`/api/collections?view=compose`,{cache:`no-store`,headers:{Accept:`application/json`}}),fetch(`/api/posts/${e}`)]);if(!t.ok)throw Error();let r=(await t.json()).collections??[],i=this._threadCollectionIds;n.ok&&(i=(await n.json()).collectionIds??[]),this.#t=ie(r,i),this._collections=r,this._threadCollectionIds=i}catch{this._collections=this._collections??[],s(`Could not load collections.`,`error`)}this._collectionsLoading=!1,this.#s(`.post-menu-picker-search input, .post-menu-picker-option, [data-post-menu-add-collection]`)}#R(e){if(!this._data)return;let t=this._data.threadId,n=this._threadCollectionIds.includes(e);this._threadCollectionIds=n?this._threadCollectionIds.filter(t=>t!==e):[...this._threadCollectionIds,e],this.#e=!0,s(n?`Removed from collection.`:`Added to collection.`),n?fetch(`/api/collections/${e}/threads/${t}`,{method:`DELETE`}).then(e=>{if(!e.ok)throw Error();return this.#W()}).catch(()=>{this._threadCollectionIds.includes(e)||(this._threadCollectionIds=[...this._threadCollectionIds,e]),s(`Could not remove from collection. Try again.`,`error`)}):fetch(`/api/collections/${e}/threads`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:t})}).then(e=>{if(!e.ok){if(e.status===409)return this.#W();throw Error()}return this.#W()}).catch(()=>{this._threadCollectionIds=this._threadCollectionIds.filter(t=>t!==e),s(`Could not add to collection. Try again.`,`error`)})}#z(){this._addCollectionPanelOpen=!0,this.updateComplete.then(()=>{let e=this.querySelector(`[data-collection-quick-dialog] [data-collection-title-input]`);e?.focus(),e?.select()})}#B(){this._addCollectionPanelOpen=!1,this.#r(),this.updateComplete.then(()=>{(this.querySelector(`[data-post-menu-add-collection]`)??this._triggerEl)?.focus()})}async#V(e){let t=e;t.stopPropagation();let n=t.detail;if(!n)return;let r=this.querySelector(`jant-collection-form`);r&&(r.loading=!0);try{let e=await fetch(`/api/collections`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n.data)}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`Could not create collection. Try again.`);if(!t?.id||!t.title||!t.slug)throw Error(`Could not create collection. Try again.`);let r={id:t.id,title:t.title,slug:t.slug};this._collections=[...this._collections??[],r],this._data&&(await fetch(`/api/collections/${t.id}/threads`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:this._data.threadId})}),this._threadCollectionIds=[...this._threadCollectionIds,t.id]),await this.#W(),this.#e=!0,this.#B(),s(this.#H()?.createdLabel??`Collection created.`)}catch(e){s(e instanceof Error?e.message:`Could not create collection. Try again.`,`error`)}finally{r&&(r.loading=!1)}}#H(){return _()?.collectionFormLabels??null}#U(){return _()?.addCollection??`Add Collection`}async#W(){await(await m())?.refreshCollections()}#G(e){switch(e){case`private`:return`Private`;case`latest_hidden`:return`Hidden from Latest`;default:return`Public`}}#K(){return r`<svg
|
|
65
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
66
|
+
viewBox="0 0 24 24"
|
|
67
|
+
fill="none"
|
|
68
|
+
stroke="currentColor"
|
|
69
|
+
stroke-width="1.75"
|
|
70
|
+
stroke-linecap="round"
|
|
71
|
+
stroke-linejoin="round"
|
|
72
|
+
>
|
|
73
|
+
<path d="M12 19V5" />
|
|
74
|
+
<path d="m5 12 7-7 7 7" />
|
|
75
|
+
</svg>`}#q(){return r`<svg
|
|
76
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
77
|
+
viewBox="0 0 24 24"
|
|
78
|
+
fill="none"
|
|
79
|
+
stroke="currentColor"
|
|
80
|
+
stroke-width="1.75"
|
|
81
|
+
stroke-linecap="round"
|
|
82
|
+
stroke-linejoin="round"
|
|
83
|
+
>
|
|
84
|
+
<path d="M12 20h9" />
|
|
85
|
+
<path d="M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4Z" />
|
|
86
|
+
</svg>`}#J(){return r`<svg
|
|
87
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
88
|
+
viewBox="0 0 24 24"
|
|
89
|
+
fill="none"
|
|
90
|
+
stroke="currentColor"
|
|
91
|
+
stroke-width="1.75"
|
|
92
|
+
stroke-linecap="round"
|
|
93
|
+
stroke-linejoin="round"
|
|
94
|
+
>
|
|
95
|
+
<path d=${x} />
|
|
96
|
+
</svg>`}#Y(){return r`<svg
|
|
97
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
98
|
+
viewBox="0 0 24 24"
|
|
99
|
+
fill="none"
|
|
100
|
+
stroke="currentColor"
|
|
101
|
+
stroke-width="1.75"
|
|
102
|
+
style="--icon-stroke: 1.5"
|
|
103
|
+
stroke-linecap="round"
|
|
104
|
+
stroke-linejoin="round"
|
|
105
|
+
>
|
|
106
|
+
<path d=${x} />
|
|
107
|
+
<path d=${fe} />
|
|
108
|
+
</svg>`}#X(){return r`<svg
|
|
109
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
110
|
+
viewBox="0 0 24 24"
|
|
111
|
+
fill="none"
|
|
112
|
+
stroke="currentColor"
|
|
113
|
+
stroke-width="1.75"
|
|
114
|
+
stroke-linecap="round"
|
|
115
|
+
stroke-linejoin="round"
|
|
116
|
+
>
|
|
117
|
+
<line x1="12" x2="12" y1="17" y2="22" />
|
|
118
|
+
<path
|
|
119
|
+
d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"
|
|
120
|
+
/>
|
|
121
|
+
</svg>`}#Z(){return r`<svg
|
|
122
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
123
|
+
viewBox="0 0 24 24"
|
|
124
|
+
fill="none"
|
|
125
|
+
stroke="currentColor"
|
|
126
|
+
stroke-width="1.75"
|
|
127
|
+
stroke-linecap="round"
|
|
128
|
+
stroke-linejoin="round"
|
|
129
|
+
>
|
|
130
|
+
<line x1="2" x2="22" y1="2" y2="22" />
|
|
131
|
+
<line x1="12" x2="12" y1="17" y2="22" />
|
|
132
|
+
<path d="M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h12" />
|
|
133
|
+
<path d="M15 9.34V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0-1.4.6" />
|
|
134
|
+
</svg>`}#Q(){return r`<svg
|
|
135
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
136
|
+
viewBox="0 0 24 24"
|
|
137
|
+
fill="none"
|
|
138
|
+
stroke="currentColor"
|
|
139
|
+
stroke-width="1.75"
|
|
140
|
+
stroke-linecap="round"
|
|
141
|
+
stroke-linejoin="round"
|
|
142
|
+
>
|
|
143
|
+
<path d="M3 6h18" />
|
|
144
|
+
<path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" />
|
|
145
|
+
<path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" />
|
|
146
|
+
</svg>`}#$(){return r`<svg
|
|
147
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
148
|
+
viewBox="0 0 24 24"
|
|
149
|
+
fill="none"
|
|
150
|
+
stroke="currentColor"
|
|
151
|
+
stroke-width="1.9"
|
|
152
|
+
stroke-linecap="round"
|
|
153
|
+
stroke-linejoin="round"
|
|
154
|
+
>
|
|
155
|
+
<path d="m15 18-6-6 6-6" />
|
|
156
|
+
</svg>`}#ee(){return r`<svg
|
|
157
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
158
|
+
viewBox="0 0 24 24"
|
|
159
|
+
fill="none"
|
|
160
|
+
stroke="currentColor"
|
|
161
|
+
stroke-width="1.9"
|
|
162
|
+
stroke-linecap="round"
|
|
163
|
+
stroke-linejoin="round"
|
|
164
|
+
>
|
|
165
|
+
<path d="m9 18 6-6-6-6" />
|
|
166
|
+
</svg>`}#te(){return r`<svg
|
|
167
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
168
|
+
viewBox="0 0 24 24"
|
|
169
|
+
fill="none"
|
|
170
|
+
stroke="currentColor"
|
|
171
|
+
stroke-width="2.3"
|
|
172
|
+
stroke-linecap="round"
|
|
173
|
+
stroke-linejoin="round"
|
|
174
|
+
>
|
|
175
|
+
<path d="M20 6 9 17l-5-5" />
|
|
176
|
+
</svg>`}#ne(){return r`<svg
|
|
177
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
178
|
+
viewBox="0 0 24 24"
|
|
179
|
+
fill="none"
|
|
180
|
+
stroke="currentColor"
|
|
181
|
+
stroke-width="1.9"
|
|
182
|
+
stroke-linecap="round"
|
|
183
|
+
stroke-linejoin="round"
|
|
184
|
+
>
|
|
185
|
+
<path d="M14 4h6v6" />
|
|
186
|
+
<path d="M20 4 11 13" />
|
|
187
|
+
<path d="M18 14v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4" />
|
|
188
|
+
</svg>`}#re(){let e=this._collections??[],t=oe(e,this.#t),n=this._collectionSearch.trim().length>0,i=ce(t,this._collectionSearch);return r`
|
|
189
|
+
<div
|
|
190
|
+
data-collection-picker
|
|
191
|
+
class="post-menu-view post-menu-collection-picker"
|
|
192
|
+
>
|
|
193
|
+
<div class="post-menu-panel-header">
|
|
194
|
+
<button
|
|
195
|
+
type="button"
|
|
196
|
+
class="post-menu-panel-back"
|
|
197
|
+
aria-label="Back"
|
|
198
|
+
@click=${()=>this.#p(`[data-post-menu-open-collections]`)}
|
|
199
|
+
>
|
|
200
|
+
${this.#$()}
|
|
201
|
+
</button>
|
|
202
|
+
<div class="post-menu-panel-heading">
|
|
203
|
+
<span>Collections</span>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
${e.length>0?r`<div class="post-menu-picker-search">
|
|
207
|
+
<svg
|
|
208
|
+
width="14"
|
|
209
|
+
height="14"
|
|
210
|
+
viewBox="0 0 24 24"
|
|
211
|
+
fill="none"
|
|
212
|
+
stroke="currentColor"
|
|
213
|
+
stroke-width="2"
|
|
214
|
+
stroke-linecap="round"
|
|
215
|
+
stroke-linejoin="round"
|
|
216
|
+
>
|
|
217
|
+
<circle cx="11" cy="11" r="8" />
|
|
218
|
+
<path d="m21 21-4.3-4.3" />
|
|
219
|
+
</svg>
|
|
220
|
+
<input
|
|
221
|
+
type="text"
|
|
222
|
+
placeholder="Search collections..."
|
|
223
|
+
autocomplete="off"
|
|
224
|
+
autocorrect="off"
|
|
225
|
+
spellcheck="false"
|
|
226
|
+
.value=${this._collectionSearch}
|
|
227
|
+
@keydown=${this.#l}
|
|
228
|
+
@input=${e=>{this._collectionSearch=e.target.value}}
|
|
229
|
+
/>
|
|
230
|
+
</div>`:a}
|
|
231
|
+
<div
|
|
232
|
+
class="post-menu-picker-list"
|
|
233
|
+
role="listbox"
|
|
234
|
+
aria-multiselectable="true"
|
|
235
|
+
>
|
|
236
|
+
${this._collectionsLoading?r`<div class="post-menu-picker-empty">Loading...</div>`:i.length>0?i.map(e=>{let t=this._threadCollectionIds.includes(e.id);return r`
|
|
237
|
+
<button
|
|
238
|
+
type="button"
|
|
239
|
+
role="option"
|
|
240
|
+
aria-selected=${t?`true`:`false`}
|
|
241
|
+
class=${`post-menu-picker-option${t?` post-menu-picker-option-selected`:``}`}
|
|
242
|
+
@keydown=${t=>this.#u(t,e.id)}
|
|
243
|
+
@click=${t=>this.#d(t,e.id)}
|
|
244
|
+
>
|
|
245
|
+
<span class="post-menu-picker-title">${e.title}</span>
|
|
246
|
+
${t?r`<span
|
|
247
|
+
class="post-menu-picker-marker post-menu-picker-marker-selected"
|
|
248
|
+
>
|
|
249
|
+
<svg
|
|
250
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
251
|
+
viewBox="0 0 24 24"
|
|
252
|
+
fill="none"
|
|
253
|
+
aria-hidden="true"
|
|
254
|
+
>
|
|
255
|
+
<circle
|
|
256
|
+
cx="12"
|
|
257
|
+
cy="12"
|
|
258
|
+
r="10"
|
|
259
|
+
fill="currentColor"
|
|
260
|
+
/>
|
|
261
|
+
<path
|
|
262
|
+
d="M8 12.5 10.7 15.2 16.4 9.5"
|
|
263
|
+
stroke="var(--site-page-bg)"
|
|
264
|
+
stroke-width="2.3"
|
|
265
|
+
stroke-linecap="round"
|
|
266
|
+
stroke-linejoin="round"
|
|
267
|
+
/>
|
|
268
|
+
</svg>
|
|
269
|
+
</span>`:r`<span
|
|
270
|
+
class="post-menu-picker-marker post-menu-picker-marker-add"
|
|
271
|
+
>
|
|
272
|
+
<svg
|
|
273
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
274
|
+
viewBox="0 0 24 24"
|
|
275
|
+
fill="none"
|
|
276
|
+
aria-hidden="true"
|
|
277
|
+
>
|
|
278
|
+
<circle
|
|
279
|
+
cx="12"
|
|
280
|
+
cy="12"
|
|
281
|
+
r="9"
|
|
282
|
+
stroke="currentColor"
|
|
283
|
+
stroke-width="1.8"
|
|
284
|
+
/>
|
|
285
|
+
<path
|
|
286
|
+
d="M12 8v8M8 12h8"
|
|
287
|
+
stroke="currentColor"
|
|
288
|
+
stroke-width="1.9"
|
|
289
|
+
stroke-linecap="round"
|
|
290
|
+
/>
|
|
291
|
+
</svg>
|
|
292
|
+
</span>`}
|
|
293
|
+
</button>
|
|
294
|
+
`}):r`<div class="post-menu-picker-empty">
|
|
295
|
+
${n?`No matching collections`:`No collections yet`}
|
|
296
|
+
</div>`}
|
|
297
|
+
</div>
|
|
298
|
+
<div class="post-menu-picker-footer">
|
|
299
|
+
<button
|
|
300
|
+
type="button"
|
|
301
|
+
class="post-menu-picker-add"
|
|
302
|
+
data-post-menu-add-collection
|
|
303
|
+
@keydown=${this.#f}
|
|
304
|
+
@click=${()=>this.#z()}
|
|
305
|
+
>
|
|
306
|
+
<svg
|
|
307
|
+
width="14"
|
|
308
|
+
height="14"
|
|
309
|
+
viewBox="0 0 16 16"
|
|
310
|
+
fill="none"
|
|
311
|
+
stroke="currentColor"
|
|
312
|
+
stroke-width="1.5"
|
|
313
|
+
stroke-linecap="round"
|
|
314
|
+
stroke-linejoin="round"
|
|
315
|
+
>
|
|
316
|
+
<path d="M8 3v10M3 8h10" />
|
|
317
|
+
</svg>
|
|
318
|
+
Add Collection
|
|
319
|
+
</button>
|
|
320
|
+
</div>
|
|
321
|
+
</div>
|
|
322
|
+
`}#ie(){if(!this._data||this._data.isReply)return a;let{current:e,linked:t,free:i}=this.#b();return r`
|
|
323
|
+
<div class="post-menu-view post-menu-language-panel">
|
|
324
|
+
<div class="post-menu-panel-header">
|
|
325
|
+
<button
|
|
326
|
+
type="button"
|
|
327
|
+
class="post-menu-panel-back"
|
|
328
|
+
aria-label="Back"
|
|
329
|
+
@click=${()=>this.#p(`[data-post-menu-open-language]`)}
|
|
330
|
+
>
|
|
331
|
+
${this.#$()}
|
|
332
|
+
</button>
|
|
333
|
+
<div class="post-menu-panel-heading">
|
|
334
|
+
<span>Language</span>
|
|
335
|
+
</div>
|
|
336
|
+
</div>
|
|
337
|
+
<div role="menu" class="post-menu-list">
|
|
338
|
+
<!-- Both sections stand or fall together: with every other language
|
|
339
|
+
spoken for there is nothing to switch to and nothing to add. -->
|
|
340
|
+
${i.length>0?r`
|
|
341
|
+
<div class="post-menu-section">
|
|
342
|
+
<button
|
|
343
|
+
type="button"
|
|
344
|
+
role="menuitem"
|
|
345
|
+
class="post-menu-item"
|
|
346
|
+
data-post-menu-open-language-switch
|
|
347
|
+
?disabled=${this._translationBusy}
|
|
348
|
+
@click=${()=>this.#y()}
|
|
349
|
+
>
|
|
350
|
+
<span class="post-menu-item-label">Change language</span>
|
|
351
|
+
<span class="post-menu-item-meta"
|
|
352
|
+
>${this.#g(e)}</span
|
|
353
|
+
>
|
|
354
|
+
<span
|
|
355
|
+
class="post-menu-item-trailing post-menu-item-chevron"
|
|
356
|
+
>${this.#ee()}</span
|
|
357
|
+
>
|
|
358
|
+
</button>
|
|
359
|
+
</div>
|
|
360
|
+
<div class="post-menu-section">
|
|
361
|
+
${i.map((e,t)=>r`
|
|
362
|
+
<button
|
|
363
|
+
type="button"
|
|
364
|
+
role="menuitem"
|
|
365
|
+
class="post-menu-item"
|
|
366
|
+
?data-post-menu-translation-first=${t===0}
|
|
367
|
+
@click=${()=>this.#C(e.tag)}
|
|
368
|
+
>
|
|
369
|
+
<span class="post-menu-item-label"
|
|
370
|
+
>Write the ${e.label} version</span
|
|
371
|
+
>
|
|
372
|
+
<span
|
|
373
|
+
class="post-menu-item-trailing post-menu-item-chevron"
|
|
374
|
+
>${this.#ee()}</span
|
|
375
|
+
>
|
|
376
|
+
</button>
|
|
377
|
+
`)}
|
|
378
|
+
<button
|
|
379
|
+
type="button"
|
|
380
|
+
role="menuitem"
|
|
381
|
+
class="post-menu-item"
|
|
382
|
+
@click=${()=>this.#w()}
|
|
383
|
+
>
|
|
384
|
+
<span class="post-menu-item-label"
|
|
385
|
+
>Link a version you already wrote</span
|
|
386
|
+
>
|
|
387
|
+
<span
|
|
388
|
+
class="post-menu-item-trailing post-menu-item-chevron"
|
|
389
|
+
>${this.#ee()}</span
|
|
390
|
+
>
|
|
391
|
+
</button>
|
|
392
|
+
</div>
|
|
393
|
+
`:a}
|
|
394
|
+
${t.length>0?r`
|
|
395
|
+
<div class="post-menu-section">
|
|
396
|
+
<p class="post-menu-section-label">Other versions</p>
|
|
397
|
+
${t.map(e=>{let t=this.#g(e.language);return r`
|
|
398
|
+
<div class="post-menu-row" data-post-menu-translation>
|
|
399
|
+
<a
|
|
400
|
+
role="menuitem"
|
|
401
|
+
class="post-menu-item post-menu-row-main"
|
|
402
|
+
href=${n(`/${e.slug}`)}
|
|
403
|
+
target="_blank"
|
|
404
|
+
rel="noopener noreferrer"
|
|
405
|
+
title=${e.label}
|
|
406
|
+
aria-label=${`Open the ${t} version, ${e.label}, in a new tab`}
|
|
407
|
+
>
|
|
408
|
+
<span
|
|
409
|
+
class="post-menu-item-label"
|
|
410
|
+
lang=${e.language??a}
|
|
411
|
+
>${t}</span
|
|
412
|
+
>
|
|
413
|
+
<span
|
|
414
|
+
class="post-menu-item-trailing post-menu-item-chevron"
|
|
415
|
+
>${this.#ne()}</span
|
|
416
|
+
>
|
|
417
|
+
</a>
|
|
418
|
+
<button
|
|
419
|
+
type="button"
|
|
420
|
+
role="menuitem"
|
|
421
|
+
class="post-menu-row-action post-menu-row-action-danger"
|
|
422
|
+
data-post-menu-translation-unlink
|
|
423
|
+
?disabled=${this._translationBusy}
|
|
424
|
+
aria-label=${`Unlink the ${t} version`}
|
|
425
|
+
@click=${()=>this.#O(e)}
|
|
426
|
+
>
|
|
427
|
+
Unlink
|
|
428
|
+
</button>
|
|
429
|
+
</div>
|
|
430
|
+
`})}
|
|
431
|
+
</div>
|
|
432
|
+
`:a}
|
|
433
|
+
${this._translationsLoading?r`<p class="post-menu-hint">Loading…</p>`:a}
|
|
434
|
+
</div>
|
|
435
|
+
</div>
|
|
436
|
+
`}#ae(){if(!this._data||this._data.isReply)return a;let{current:e,selectable:t}=this.#b();return r`
|
|
437
|
+
<div
|
|
438
|
+
class="post-menu-view post-menu-language-panel post-menu-language-switch-panel"
|
|
439
|
+
>
|
|
440
|
+
<div class="post-menu-panel-header">
|
|
441
|
+
<button
|
|
442
|
+
type="button"
|
|
443
|
+
class="post-menu-panel-back"
|
|
444
|
+
aria-label="Back"
|
|
445
|
+
@click=${()=>this.#v()}
|
|
446
|
+
>
|
|
447
|
+
${this.#$()}
|
|
448
|
+
</button>
|
|
449
|
+
<div class="post-menu-panel-heading">
|
|
450
|
+
<span>Change language</span>
|
|
451
|
+
</div>
|
|
452
|
+
</div>
|
|
453
|
+
<div role="menu" class="post-menu-list">
|
|
454
|
+
<div
|
|
455
|
+
class="post-menu-section"
|
|
456
|
+
role="radiogroup"
|
|
457
|
+
aria-label="Language"
|
|
458
|
+
>
|
|
459
|
+
${t.map(t=>{let n=t.tag===e;return r`
|
|
460
|
+
<button
|
|
461
|
+
type="button"
|
|
462
|
+
role="menuitemradio"
|
|
463
|
+
lang=${t.tag}
|
|
464
|
+
aria-checked=${n?`true`:`false`}
|
|
465
|
+
?disabled=${this._translationBusy}
|
|
466
|
+
data-post-menu-language-option
|
|
467
|
+
data-post-menu-language-current=${n?`true`:`false`}
|
|
468
|
+
class=${`post-menu-item${n?` post-menu-item-active`:``}`}
|
|
469
|
+
@click=${()=>n?this.#v():this.#x(t.tag)}
|
|
470
|
+
>
|
|
471
|
+
<span class="post-menu-item-label">${t.label}</span>
|
|
472
|
+
${n?r`<span
|
|
473
|
+
class="post-menu-item-trailing post-menu-item-check"
|
|
474
|
+
>${this.#te()}</span
|
|
475
|
+
>`:a}
|
|
476
|
+
</button>
|
|
477
|
+
`})}
|
|
478
|
+
</div>
|
|
479
|
+
</div>
|
|
480
|
+
</div>
|
|
481
|
+
`}#oe(){if(!this._data||this._data.isReply)return a;let e=this._data.visibility;return r`
|
|
482
|
+
<div
|
|
483
|
+
data-visibility-panel
|
|
484
|
+
class="post-menu-view post-menu-visibility-panel"
|
|
485
|
+
>
|
|
486
|
+
<div class="post-menu-panel-header">
|
|
487
|
+
<button
|
|
488
|
+
type="button"
|
|
489
|
+
class="post-menu-panel-back"
|
|
490
|
+
aria-label="Back"
|
|
491
|
+
@click=${()=>this.#p(`[data-post-menu-open-visibility]`)}
|
|
492
|
+
>
|
|
493
|
+
${this.#$()}
|
|
494
|
+
</button>
|
|
495
|
+
<div class="post-menu-panel-heading">
|
|
496
|
+
<span>Visibility</span>
|
|
497
|
+
</div>
|
|
498
|
+
</div>
|
|
499
|
+
<div role="menu" class="post-menu-list">
|
|
500
|
+
<div class="post-menu-section">
|
|
501
|
+
<button
|
|
502
|
+
type="button"
|
|
503
|
+
role="menuitemradio"
|
|
504
|
+
aria-checked=${e===`public`?`true`:`false`}
|
|
505
|
+
data-post-menu-visibility-option
|
|
506
|
+
data-post-menu-visibility-current=${e===`public`?`true`:`false`}
|
|
507
|
+
class=${`post-menu-item${e===`public`?` post-menu-item-active`:``}`}
|
|
508
|
+
@click=${()=>e===`public`?this.#p(`[data-post-menu-open-visibility]`):this.#M(`public`)}
|
|
509
|
+
>
|
|
510
|
+
<span class="post-menu-item-label">Public</span>
|
|
511
|
+
${e===`public`?r`<span
|
|
512
|
+
class="post-menu-item-trailing post-menu-item-check"
|
|
513
|
+
>${this.#te()}</span
|
|
514
|
+
>`:a}
|
|
515
|
+
</button>
|
|
516
|
+
|
|
517
|
+
<button
|
|
518
|
+
type="button"
|
|
519
|
+
role="menuitemradio"
|
|
520
|
+
aria-checked=${e===`latest_hidden`?`true`:`false`}
|
|
521
|
+
data-post-menu-visibility-option
|
|
522
|
+
data-post-menu-visibility-current=${e===`latest_hidden`?`true`:`false`}
|
|
523
|
+
class=${`post-menu-item${e===`latest_hidden`?` post-menu-item-active`:``}`}
|
|
524
|
+
@click=${()=>e===`latest_hidden`?this.#p(`[data-post-menu-open-visibility]`):this.#M(`latest_hidden`)}
|
|
525
|
+
>
|
|
526
|
+
<span class="post-menu-item-label">Hidden from Latest</span>
|
|
527
|
+
${e===`latest_hidden`?r`<span
|
|
528
|
+
class="post-menu-item-trailing post-menu-item-check"
|
|
529
|
+
>${this.#te()}</span
|
|
530
|
+
>`:a}
|
|
531
|
+
</button>
|
|
532
|
+
|
|
533
|
+
<button
|
|
534
|
+
type="button"
|
|
535
|
+
role="menuitemradio"
|
|
536
|
+
aria-checked=${e===`private`?`true`:`false`}
|
|
537
|
+
data-post-menu-visibility-option
|
|
538
|
+
data-post-menu-visibility-current=${e===`private`?`true`:`false`}
|
|
539
|
+
class=${`post-menu-item${e===`private`?` post-menu-item-active`:``}`}
|
|
540
|
+
@click=${()=>e===`private`?this.#p(`[data-post-menu-open-visibility]`):this.#M(`private`)}
|
|
541
|
+
>
|
|
542
|
+
<span class="post-menu-item-label">Private</span>
|
|
543
|
+
${e===`private`?r`<span
|
|
544
|
+
class="post-menu-item-trailing post-menu-item-check"
|
|
545
|
+
>${this.#te()}</span
|
|
546
|
+
>`:a}
|
|
547
|
+
</button>
|
|
548
|
+
</div>
|
|
549
|
+
</div>
|
|
550
|
+
</div>
|
|
551
|
+
`}#se(){let e=this.#H();return e?r`
|
|
552
|
+
<div
|
|
553
|
+
class="collection-quick-dialog-backdrop"
|
|
554
|
+
@click=${()=>this.#B()}
|
|
555
|
+
></div>
|
|
556
|
+
<div
|
|
557
|
+
class="collection-quick-dialog"
|
|
558
|
+
data-collection-quick-dialog
|
|
559
|
+
role="dialog"
|
|
560
|
+
aria-modal="true"
|
|
561
|
+
aria-label=${this.#U()}
|
|
562
|
+
@click=${e=>e.stopPropagation()}
|
|
563
|
+
>
|
|
564
|
+
<div class="collection-quick-dialog-header">
|
|
565
|
+
<div class="collection-quick-dialog-title-block">
|
|
566
|
+
<h2 class="collection-quick-dialog-title">
|
|
567
|
+
${this.#U()}
|
|
568
|
+
</h2>
|
|
569
|
+
<p class="collection-quick-dialog-note">${e.quickHint}</p>
|
|
570
|
+
</div>
|
|
571
|
+
<button
|
|
572
|
+
type="button"
|
|
573
|
+
class="collection-quick-dialog-cancel"
|
|
574
|
+
@click=${()=>this.#B()}
|
|
575
|
+
>
|
|
576
|
+
${e.cancelLabel}
|
|
577
|
+
</button>
|
|
578
|
+
</div>
|
|
579
|
+
<div class="collection-quick-dialog-body">
|
|
580
|
+
<jant-collection-form
|
|
581
|
+
variant="quick"
|
|
582
|
+
.labels=${e}
|
|
583
|
+
.initial=${{title:``,slug:``,description:``,sortOrder:`newest`,icon:``}}
|
|
584
|
+
action=${n(`/api/collections`)}
|
|
585
|
+
cancel-href="javascript:void(0)"
|
|
586
|
+
@jant:collection-submit=${e=>this.#V(e)}
|
|
587
|
+
></jant-collection-form>
|
|
588
|
+
</div>
|
|
589
|
+
<div class="collection-quick-dialog-footer">
|
|
590
|
+
<button
|
|
591
|
+
type="button"
|
|
592
|
+
class="compose-post-btn collection-quick-dialog-submit"
|
|
593
|
+
@click=${()=>{this.querySelector(`[data-collection-quick-dialog] form`)?.requestSubmit()}}
|
|
594
|
+
>
|
|
595
|
+
${e.quickSubmitLabel}
|
|
596
|
+
</button>
|
|
597
|
+
</div>
|
|
598
|
+
</div>
|
|
599
|
+
`:a}#ce(){if(!this._data)return a;let e=this._data.visibility,t=this._data.pinned,n=this._data.pinnedInCollection,i=document.querySelector(`[data-collection-id]`)?.dataset.collectionId,o=this._data.featured;return r`
|
|
600
|
+
<div class="post-menu-view post-menu-main">
|
|
601
|
+
<div role="menu" class="post-menu-list">
|
|
602
|
+
<div class="post-menu-section">
|
|
603
|
+
<button
|
|
604
|
+
type="button"
|
|
605
|
+
role="menuitem"
|
|
606
|
+
class="post-menu-item"
|
|
607
|
+
data-post-menu-item-primary
|
|
608
|
+
@click=${()=>this.#A()}
|
|
609
|
+
>
|
|
610
|
+
<span class="post-menu-item-label">Edit</span>
|
|
611
|
+
<span class="post-menu-item-trailing">${this.#q()}</span>
|
|
612
|
+
</button>
|
|
613
|
+
|
|
614
|
+
${this._data.isDraft?r`
|
|
615
|
+
<button
|
|
616
|
+
type="button"
|
|
617
|
+
role="menuitem"
|
|
618
|
+
class="post-menu-item"
|
|
619
|
+
@click=${()=>this.#j()}
|
|
620
|
+
>
|
|
621
|
+
<span class="post-menu-item-label">Publish</span>
|
|
622
|
+
<span class="post-menu-item-trailing"
|
|
623
|
+
>${this.#K()}</span
|
|
624
|
+
>
|
|
625
|
+
</button>
|
|
626
|
+
`:a}
|
|
627
|
+
${this._data.isReply?a:r`
|
|
628
|
+
<button
|
|
629
|
+
type="button"
|
|
630
|
+
role="menuitem"
|
|
631
|
+
class="post-menu-item"
|
|
632
|
+
data-post-menu-open-collections
|
|
633
|
+
@click=${()=>this.#L()}
|
|
634
|
+
>
|
|
635
|
+
<span class="post-menu-item-label"
|
|
636
|
+
>Add to collection</span
|
|
637
|
+
>
|
|
638
|
+
<span
|
|
639
|
+
class="post-menu-item-trailing post-menu-item-chevron"
|
|
640
|
+
>${this.#ee()}</span
|
|
641
|
+
>
|
|
642
|
+
</button>
|
|
643
|
+
`}
|
|
644
|
+
${this._data.isReply?a:r`
|
|
645
|
+
<button
|
|
646
|
+
type="button"
|
|
647
|
+
role="menuitem"
|
|
648
|
+
class="post-menu-item"
|
|
649
|
+
data-post-menu-open-visibility
|
|
650
|
+
@click=${()=>this.#m()}
|
|
651
|
+
>
|
|
652
|
+
<span class="post-menu-item-label">Visibility</span>
|
|
653
|
+
<span class="post-menu-item-meta"
|
|
654
|
+
>${this.#G(e)}</span
|
|
655
|
+
>
|
|
656
|
+
<span
|
|
657
|
+
class="post-menu-item-trailing post-menu-item-chevron"
|
|
658
|
+
>${this.#ee()}</span
|
|
659
|
+
>
|
|
660
|
+
</button>
|
|
661
|
+
`}
|
|
662
|
+
${this._data.isReply||!this.#h?a:r`
|
|
663
|
+
<button
|
|
664
|
+
type="button"
|
|
665
|
+
role="menuitem"
|
|
666
|
+
class="post-menu-item"
|
|
667
|
+
data-post-menu-open-language
|
|
668
|
+
@click=${()=>this.#_()}
|
|
669
|
+
>
|
|
670
|
+
<span class="post-menu-item-label">Language</span>
|
|
671
|
+
<span class="post-menu-item-meta"
|
|
672
|
+
>${this.#g(this._data.language)}</span
|
|
673
|
+
>
|
|
674
|
+
<span
|
|
675
|
+
class="post-menu-item-trailing post-menu-item-chevron"
|
|
676
|
+
>${this.#ee()}</span
|
|
677
|
+
>
|
|
678
|
+
</button>
|
|
679
|
+
`}
|
|
680
|
+
</div>
|
|
681
|
+
|
|
682
|
+
<div class="post-menu-section">
|
|
683
|
+
${this._data.isDraft?a:r`
|
|
684
|
+
<button
|
|
685
|
+
type="button"
|
|
686
|
+
role="menuitem"
|
|
687
|
+
class="post-menu-item"
|
|
688
|
+
@click=${()=>this.#N(!o)}
|
|
689
|
+
>
|
|
690
|
+
<span class="post-menu-item-label"
|
|
691
|
+
>${o?`Remove from Featured`:`Add to Featured`}</span
|
|
692
|
+
>
|
|
693
|
+
<span class="post-menu-item-trailing"
|
|
694
|
+
>${o?this.#Y():this.#J()}</span
|
|
695
|
+
>
|
|
696
|
+
</button>
|
|
697
|
+
`}
|
|
698
|
+
${this._data.isReply?a:r`
|
|
699
|
+
<button
|
|
700
|
+
type="button"
|
|
701
|
+
role="menuitem"
|
|
702
|
+
class="post-menu-item"
|
|
703
|
+
@click=${()=>this.#P()}
|
|
704
|
+
>
|
|
705
|
+
<span class="post-menu-item-label"
|
|
706
|
+
>${t?`Unpin`:`Pin this post`}</span
|
|
707
|
+
>
|
|
708
|
+
<span class="post-menu-item-trailing"
|
|
709
|
+
>${t?this.#Z():this.#X()}</span
|
|
710
|
+
>
|
|
711
|
+
</button>
|
|
712
|
+
`}
|
|
713
|
+
${i&&!this._data.isReply?r`
|
|
714
|
+
<button
|
|
715
|
+
type="button"
|
|
716
|
+
role="menuitem"
|
|
717
|
+
class="post-menu-item"
|
|
718
|
+
@click=${()=>this.#F()}
|
|
719
|
+
>
|
|
720
|
+
<span class="post-menu-item-label"
|
|
721
|
+
>${n?`Unpin from collection`:`Pin in collection`}</span
|
|
722
|
+
>
|
|
723
|
+
<span class="post-menu-item-trailing"
|
|
724
|
+
>${n?this.#Z():this.#X()}</span
|
|
725
|
+
>
|
|
726
|
+
</button>
|
|
727
|
+
`:a}
|
|
728
|
+
</div>
|
|
729
|
+
|
|
730
|
+
<div class="post-menu-section post-menu-section-danger">
|
|
731
|
+
<button
|
|
732
|
+
type="button"
|
|
733
|
+
role="menuitem"
|
|
734
|
+
class="post-menu-item post-menu-item-danger"
|
|
735
|
+
@click=${()=>this.#I()}
|
|
736
|
+
>
|
|
737
|
+
<span class="post-menu-item-label"
|
|
738
|
+
>${this._data.isDraft?`Discard`:`Delete`}</span
|
|
739
|
+
>
|
|
740
|
+
<span class="post-menu-item-trailing">${this.#Q()}</span>
|
|
741
|
+
</button>
|
|
742
|
+
</div>
|
|
743
|
+
</div>
|
|
744
|
+
</div>
|
|
745
|
+
`}render(){if(!this._open||!this._data)return a;let e=this._openAbove?`transform:translate(-100%, -100%);`:`transform:translateX(-100%);`,t=`position:absolute;z-index:100;left:${Math.round(this._x)}px;top:${Math.round(this._y)}px;${e}`,n=!this._addCollectionPanelOpen;return r`
|
|
746
|
+
${n?r`
|
|
747
|
+
<div
|
|
748
|
+
class="post-menu-backdrop"
|
|
749
|
+
@click=${()=>this.#k({restoreFocus:!1})}
|
|
750
|
+
></div>
|
|
751
|
+
<div class="dropdown-menu" style=${t}>
|
|
752
|
+
<div
|
|
753
|
+
data-popover
|
|
754
|
+
aria-hidden="false"
|
|
755
|
+
class="!static post-menu-panel"
|
|
756
|
+
>
|
|
757
|
+
${this._view===`collections`?this.#re():this._view===`visibility`?this.#oe():this._view===`language`?this.#ie():this._view===`language-switch`?this.#ae():this.#ce()}
|
|
758
|
+
</div>
|
|
759
|
+
</div>
|
|
760
|
+
`:a}
|
|
761
|
+
${this._addCollectionPanelOpen?this.#se():a}
|
|
762
|
+
`}};customElements.define(`jant-post-menu`,ye);var O=`xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`,k={post:`<svg ${O}><path d="M8 2v4"/><path d="M12 2v4"/><path d="M16 2v4"/><rect width="16" height="18" x="4" y="4" rx="2"/><path d="M8 10h6"/><path d="M8 14h8"/><path d="M8 18h5"/></svg>`,collection:`<svg ${O} viewBox="0 0 16 16" stroke-width="1.35"><rect x="3" y="5.05" width="10" height="8.15" rx="2.2"/><path d="M5.1 5.05V4.2a1.1 1.1 0 0 1 1.1-1.1h3.6a1.1 1.1 0 0 1 1.1 1.1v.85"/></svg>`,smart_collection:`<svg ${O}><path d="M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"/></svg>`,system:`<svg ${O}><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,command:`<svg ${O}><path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/></svg>`,path:`<svg ${O}><polyline points="15 10 20 15 15 20"/><path d="M4 4v7a4 4 0 0 0 4 4h12"/></svg>`,search:`<svg ${O}><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`};function be(e){let t=e.trim().replace(/^[//]+/,``);return t?`/${t}`:`/`}function A(n){let r=n.trim();return te(r)?e(r,{siteOrigins:[window.location.origin],sitePathPrefix:t(),keepQuery:!0}):null}function xe(e){return e.trim().replace(/^[//]+/,``).trim()}var Se=5;function j(e){try{let t=globalThis.localStorage.getItem(e);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e):[]}catch{return[]}}function M(e,t){let n=j(e).filter(e=>e!==t);n.unshift(t),globalThis.localStorage.setItem(e,JSON.stringify(n.slice(0,Se)))}var N=`jant:nav-history`,P=`jant:search-history`,Ce=[{title:`Home`,path:`/`,type:`system`},{title:`Featured`,path:`/featured`,type:`system`},{title:`Latest`,path:`/latest`,type:`system`},{title:`Archive`,path:`/archive`,type:`system`},{title:`Collections`,path:`/collections`,type:`system`},{title:`Settings`,path:`/settings`,type:`system`},{title:`General`,path:`/settings/general`,type:`system`},{title:`Navigation`,path:de,type:`system`},{title:`Appearance`,path:`/settings/appearance/color-theme`,type:`system`},{title:`Custom URLs`,path:`/settings/custom-urls`,type:`system`},{title:`API Tokens`,path:`/settings/api-tokens`,type:`system`},{title:`Sessions`,path:`/settings/sessions`,type:`system`},{title:`Account`,path:`/settings/account`,type:`system`}],we=[{label:`New Post`,icon:k.command,action:()=>void f()}],Te=class extends o{static properties={_open:{state:!0},_query:{state:!0},_selectedIndex:{state:!0},_loading:{state:!0}};#e=null;createRenderRoot(){return this.innerHTML=``,this}constructor(){super(),this._open=!1,this._query=``,this._selectedIndex=0,this._loading=!1}connectedCallback(){super.connectedCallback(),this.#t()}async#t(){if(!this.#e)try{let e=await fetch(`/api/palette`);if(e.ok){let t=await e.json();this.#e=t.items}else this.#e=[]}catch{this.#e=[]}}async open(){if(this._open)return;this.#e||(this._loading=!0,await this.#t(),this._loading=!1),this._open=!0,this._query=``,this._selectedIndex=0,await this.updateComplete;let e=this.querySelector(`.command-palette`);e&&!e.open&&e.showModal(),this.querySelector(`.command-palette-input`)?.focus()}close(){let e=this.querySelector(`.command-palette`);e?.open&&e.close(),this._open=!1,this._query=``,this._selectedIndex=0}get#n(){let e=this._query.charAt(0);return e===`>`||e===`>`?`command`:e===`?`||e===`?`?`search`:e===`/`||e===`/`||A(this._query)?`path`:`navigate`}get#r(){let e=b(this._query),t=[...this.#e??[],...Ce];if(!e){let e=j(N);if(e.length===0)return t;let n=new Set(e),r=[],i=[];for(let e of t)n.has(e.path)?r.push(e):i.push(e);return r.sort((t,n)=>e.indexOf(t.path)-e.indexOf(n.path)),[...r,...i]}return t.map((t,n)=>({item:t,index:n,rank:ue([t.title,t.path],e)})).filter(e=>e.rank!==null).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.item)}get#i(){let e=b(this._query.slice(1));return we.filter(t=>!e||t.label.toLowerCase().includes(e))}get#a(){let e=this.#n;if(e===`command`)return this.#i.map(e=>({label:e.label,icon:e.icon}));if(e===`search`){let e=this._query.slice(1).trim();return e?[{label:`Search for "${e}"`,icon:k.search,searchQuery:e}]:j(P).map(e=>({label:e,icon:k.search,searchQuery:e}))}if(e===`path`){let e=A(this._query),t=e??be(this._query),n=e?``:xe(this._query),r=[{label:`Go to ${t}`,icon:k.path,pathTarget:t}];return n&&r.push({label:`Search for "${n}"`,icon:k.search,searchQuery:n}),r}let t=b(this._query),n=this.#r.map(e=>({label:e.title,secondary:e.status===`draft`?`Draft · ${e.path}`:e.path,icon:k[e.type]}));return t&&n.push({label:`Search all content for "${this._query.trim()}"`,icon:k.search,searchQuery:this._query.trim(),placement:`footer`,...n.length>0?{shortcut:`⌘/Ctrl ↵`}:{}}),n}#o(e){M(P,e),this.close(),window.location.href=i(`/search?q=${encodeURIComponent(e)}`)}#s(e){let t=this.#n;if(t===`command`){let t=this.#i[e];t&&(this.close(),t.action());return}if(t===`search`){let t=this.#a[e]?.searchQuery;t&&this.#o(t);return}if(t===`path`){let t=this.#a[e];if(t?.pathTarget){M(N,t.pathTarget),this.close(),window.location.href=i(t.pathTarget);return}t?.searchQuery&&this.#o(t.searchQuery);return}let n=this.#a[e];if(n?.searchQuery){this.#o(n.searchQuery);return}let r=this.#r[e];r&&(M(N,r.path),this.close(),r.type===`system`?window.location.href=i(r.path):r.type===`collection`?window.location.href=i(`/collections/${r.path}`):r.type===`smart_collection`?window.location.href=i(`/${r.path}`):window.location.href=i(r.status===`draft`?`/preview/${r.path}?edit=1`:`/${r.path}`))}#c=e=>{let t=e.target;this._query=t.value,this._selectedIndex=0};#l=e=>{if(e.isComposing||e.keyCode===229)return;let t=this.#a;if(e.key===`ArrowDown`){e.preventDefault(),this._selectedIndex=t.length>0?(this._selectedIndex+1)%t.length:0,this.#p();return}if(e.key===`ArrowUp`){e.preventDefault(),this._selectedIndex=t.length>0?(this._selectedIndex-1+t.length)%t.length:0,this.#p();return}if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&this.#n===`navigate`){let t=this._query.trim();if(t){e.preventDefault(),this.#o(t);return}}if(e.key===`Enter`){e.preventDefault(),this.#s(this._selectedIndex);return}if(e.key===`Tab`){e.preventDefault();return}if(e.key===`Escape`){e.preventDefault(),this.close();return}};#u=e=>{e.preventDefault(),this.close()};#d=e=>{e.target===e.currentTarget&&this.close()};#f(e){return()=>this.#s(e)}#p(){requestAnimationFrame(()=>{this.querySelector(`.command-palette-result-selected`)?.scrollIntoView({block:`nearest`})})}#m(e,t,n=!1){return r`
|
|
763
|
+
<div
|
|
764
|
+
id="command-palette-item-${t}"
|
|
765
|
+
class=${v({"command-palette-result":!0,"command-palette-result-selected":t===this._selectedIndex,"command-palette-search-action":n})}
|
|
766
|
+
role="option"
|
|
767
|
+
aria-selected=${t===this._selectedIndex}
|
|
768
|
+
@click=${this.#f(t)}
|
|
769
|
+
>
|
|
770
|
+
<span class="command-palette-result-icon">${h(e.icon)}</span>
|
|
771
|
+
<span class="command-palette-result-body">
|
|
772
|
+
<span class="command-palette-result-title">${e.label}</span>
|
|
773
|
+
${e.secondary?r`<span class="command-palette-result-path"
|
|
774
|
+
>${e.secondary}</span
|
|
775
|
+
>`:a}
|
|
776
|
+
</span>
|
|
777
|
+
${e.shortcut?r`<kbd
|
|
778
|
+
class="command-palette-result-shortcut"
|
|
779
|
+
aria-label="Command or Control plus Enter"
|
|
780
|
+
>${e.shortcut}</kbd
|
|
781
|
+
>`:a}
|
|
782
|
+
</div>
|
|
783
|
+
`}render(){if(!this._open)return a;let e=this.#a,t=e.map((e,t)=>({item:e,index:t})).filter(({item:e})=>e.placement!==`footer`),n=e.map((e,t)=>({item:e,index:t})).filter(({item:e})=>e.placement===`footer`);return r`
|
|
784
|
+
<dialog
|
|
785
|
+
class="command-palette"
|
|
786
|
+
@cancel=${this.#u}
|
|
787
|
+
@click=${this.#d}
|
|
788
|
+
@keydown=${this.#l}
|
|
789
|
+
>
|
|
790
|
+
<div
|
|
791
|
+
class="command-palette-panel"
|
|
792
|
+
@click=${e=>e.stopPropagation()}
|
|
793
|
+
>
|
|
794
|
+
<div class="command-palette-input-wrapper">
|
|
795
|
+
<span class="command-palette-search-icon"
|
|
796
|
+
>${h(k.search)}</span
|
|
797
|
+
>
|
|
798
|
+
<input
|
|
799
|
+
type="text"
|
|
800
|
+
class="command-palette-input"
|
|
801
|
+
.value=${this._query}
|
|
802
|
+
@input=${this.#c}
|
|
803
|
+
placeholder="Type to navigate, > for commands, ? to search..."
|
|
804
|
+
role="combobox"
|
|
805
|
+
aria-expanded="true"
|
|
806
|
+
aria-controls="command-palette-results"
|
|
807
|
+
aria-activedescendant=${e.length>0?`command-palette-item-${this._selectedIndex}`:``}
|
|
808
|
+
autocomplete="off"
|
|
809
|
+
spellcheck="false"
|
|
810
|
+
/>
|
|
811
|
+
${this._loading?r`<span class="command-palette-spinner"></span>`:a}
|
|
812
|
+
</div>
|
|
813
|
+
|
|
814
|
+
${e.length>0?r`
|
|
815
|
+
<div
|
|
816
|
+
id="command-palette-results"
|
|
817
|
+
class="command-palette-results-container"
|
|
818
|
+
role="listbox"
|
|
819
|
+
>
|
|
820
|
+
${t.length>0?r`<div class="command-palette-results">
|
|
821
|
+
${t.map(({item:e,index:t})=>this.#m(e,t))}
|
|
822
|
+
</div>`:a}
|
|
823
|
+
${n.map(({item:e,index:t})=>this.#m(e,t,!0))}
|
|
824
|
+
</div>
|
|
825
|
+
`:this._query.trim()&&!this._loading?r`<div class="command-palette-empty">No results</div>`:a}
|
|
826
|
+
</div>
|
|
827
|
+
</dialog>
|
|
828
|
+
`}};customElements.get(`jant-command-palette`)||customElements.define(`jant-command-palette`,Te),document.addEventListener(`keydown`,e=>{if(e.key.toLowerCase()!==`k`||!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey||e.defaultPrevented||e.isComposing)return;e.preventDefault();let t=document.querySelector(`jant-command-palette`);if(t){if(t.querySelector(`dialog[open]`)){t.close();return}document.querySelector(`dialog[open]`)||t.open()}}),document.addEventListener(`click`,e=>{let t=e.target;if(!(t instanceof globalThis.Element)||!t.closest(`.site-header-search-link`)||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0||e.defaultPrevented)return;let n=document.querySelector(`jant-command-palette`);n&&(document.querySelector(`dialog[open]`)||(e.preventDefault(),n.open()))}),document.addEventListener(`click`,e=>{let t=e.target instanceof globalThis.Element?e.target:null;if(!t)return;let n=t.closest(`[data-compose-open]`);if(n){let e=n.dataset.composeCollectionId;f(e?{collectionId:e}:void 0);return}let r=t.closest(`[data-reply-trigger]`);if(r){let e=r.closest(`article[data-post]`);e&&l(e);return}let i=t.closest(`[data-draft-continue]`);if(i){let e=i.dataset.postId??i.closest(`article[data-post]`)?.dataset.postId;e&&p(e)}});var F=`.compose-prompt`,Ee=`.compose-prompt-trigger`,I=`jant.composeOpenShortcutDiscovery`,De=`/api/settings/discovery/compose-open-shortcut`,Oe=350,ke=1800,L=3,R=`compose-prompt-discovery-visible`,z=!1,B=null,V=null,H=null;function U(){try{return globalThis.localStorage!==void 0}catch{return!1}}function W(){if(!U())return{shownCount:0,completed:!1};let e=globalThis.localStorage.getItem(I);if(!e)return{shownCount:0,completed:!1};try{let t=JSON.parse(e);return{shownCount:typeof t.shownCount==`number`&&t.shownCount>=0?t.shownCount:0,completed:t.completed===!0}}catch{return globalThis.localStorage.removeItem(I),{shownCount:0,completed:!1}}}function G(e){if(U())try{globalThis.localStorage.setItem(I,JSON.stringify(e))}catch{}}function K(){B!==null&&(clearTimeout(B),B=null)}function Ae(){V!==null&&(clearTimeout(V),V=null)}function je(){return typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(min-width: 700px)`).matches}function Me(e){return W().completed?!0:e?.dataset.composeOpenShortcutDiscovered===`true`}function Ne(e){e&&(e.dataset.composeOpenShortcutDiscovered=`true`,e.classList.remove(R)),document.querySelectorAll(F).forEach(e=>{e.dataset.composeOpenShortcutDiscovered=`true`,e.classList.remove(R)})}function Pe(){let e=W();e.completed||z||e.shownCount>=L||(z=!0,G({...e,shownCount:e.shownCount+1}))}function q(e){return!je()||Me(e)?!1:W().shownCount<L||z}function J(e){K(),Ae(),e?e.classList.remove(R):H&&H.classList.remove(R),(!e||e===H)&&(H=null)}function Y(e){q(e)&&(J(H),H=e,e.classList.add(R),Pe(),V=setTimeout(()=>{J(e)},ke))}function X(e){q(e)&&(e.classList.contains(R)||(K(),B=setTimeout(()=>{Y(e)},Oe)))}function Fe(e){if(e.dataset.composeOpenShortcutDiscoveryBound===`true`)return;let t=e.querySelector(Ee);t&&(e.dataset.composeOpenShortcutDiscoveryBound=`true`,t.addEventListener(`pointerenter`,()=>{X(e)}),t.addEventListener(`pointerleave`,()=>{J(e)}),t.addEventListener(`focusin`,()=>{X(e)}),t.addEventListener(`focusout`,()=>{J(e)}))}function Z(e=document){e.querySelectorAll(F).forEach(e=>Fe(e))}function Ie(){let e=W();e.completed||G({shownCount:Math.max(e.shownCount,L),completed:!0}),Ne(H),J(H),typeof globalThis.fetch==`function`&&globalThis.fetch(De,{method:`POST`,headers:{Accept:`application/json`},credentials:`same-origin`}).catch(()=>{})}var Le=[`input`,`textarea`,`select`,`button`,`a[href]`,`[contenteditable='']`,`[contenteditable='true']`,`[role='textbox']`,`.ProseMirror`].join(`, `);function Q(e){return e instanceof globalThis.Element&&e.closest(Le)!==null}function Re(e){if(e.defaultPrevented||e.isComposing||e.repeat||e.metaKey||e.ctrlKey||e.altKey||!u()||document.querySelector(`[data-page="compose"]`)||document.querySelector(`dialog[open]`))return!0;let t=document.activeElement;return Q(e.target)||t!==e.target&&Q(t)}function ze(){return new URL(window.location.href).searchParams.get(`edit`)===`1`}function Be(){let e=new URL(window.location.href);e.searchParams.delete(`edit`);let t=e.searchParams.toString();globalThis.history.replaceState(globalThis.history.state,``,`${e.pathname}${t?`?${t}`:``}${e.hash}`)}function $(){if(!document.body?.hasAttribute(`data-authenticated`)||!ze())return;let e=d()?.dataset.postId;e&&u()&&(Be(),document.querySelector(`[data-preview-status]`)?ae(e):p(e))}async function Ve(e,t,n){try{if(!(await fetch(`/api/posts/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({featured:t})})).ok)throw Error();t?n.setAttribute(`data-post-featured`,``):n.removeAttribute(`data-post-featured`),s(t?`Added to Featured.`:`Removed from Featured.`)}catch{s(`Could not update post. Try again.`,`error`)}}document.addEventListener(`keydown`,e=>{let t=e.key.toLowerCase();if(t!==`n`&&t!==`l`&&t!==`q`&&t!==`r`&&t!==`e`&&t!==`c`&&t!==`f`||Re(e))return;if(t===`n`||t===`l`||t===`q`){e.preventDefault(),Ie();let n=g(),r=t===`l`?`link`:t===`q`?`quote`:void 0;f({...n?{collectionId:n}:void 0,...r?{initialFormat:r}:void 0});return}if(t===`r`){let t=se();if(!t)return;e.preventDefault(),l(t);return}let n=d();if(n){if(t===`e`){let t=n.dataset.postId;if(!t)return;e.preventDefault(),p(t);return}if(t===`c`){e.preventDefault();let t=document.querySelector(`jant-post-menu`);t&&t.openCollectionsForPost(n);return}if(t===`f`){let t=n.dataset.postId;if(!t)return;e.preventDefault(),Ve(t,!n.hasAttribute(`data-post-featured`),n);return}}}),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,$,{once:!0}):$(),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>{Z()}):Z(),ne(),document.querySelector(`jant-command-palette`)||document.body.appendChild(document.createElement(`jant-command-palette`)),le();
|