@jant/core 1.0.1 → 1.2.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/bin/lib/site-snapshot.js +10 -0
- package/dist/{app-Gt7_skt6.js → app-CbOZ2Irh.js} +8704 -5180
- package/dist/client/.vite/manifest.json +125 -85
- package/dist/client/_assets/chunks/{confirm-D7GrwsCN.js → confirm-CMe01lne.js} +1 -1
- package/dist/client/_assets/chunks/{create-editor-5Y49x7h5.js → create-editor-hWapNE40.js} +26 -26
- package/dist/client/_assets/chunks/footnote-rail-9zwl6jtV.js +2 -0
- package/dist/client/_assets/chunks/{jant-locale-picker-DL6mIOT5.js → jant-locale-picker-2L4rkDaz.js} +1 -1
- package/dist/client/_assets/chunks/lit-Bw_voPoW.js +2 -0
- package/dist/client/_assets/chunks/preload-helper-Czpn1I53.js +1 -0
- package/dist/client/_assets/chunks/runtime-paths-y0_gHowM.js +1 -0
- package/dist/client/_assets/chunks/{settings-paths-h6RjIe3C.js → settings-paths-BBVT8zKj.js} +1 -1
- package/dist/client/_assets/chunks/slug-format-BuCPjSrB.js +1 -0
- package/dist/client/_assets/chunks/sortable-list-DJXwkaOv.js +2 -0
- package/dist/client/_assets/chunks/types-DrYFqJH2.js +1 -0
- package/dist/client/_assets/chunks/{unsafe-html-B5ZEXaxg.js → unsafe-html-CWos3v6N.js} +1 -1
- package/dist/client/_assets/chunks/unsafe-svg-CUrgo4Xg.js +1 -0
- package/dist/client/_assets/client-BO8GOFfT.js +354 -0
- package/dist/client/_assets/client-D8Rrsd73.css +2 -0
- package/dist/client/_assets/client-auth-CsUGM718.js +859 -0
- package/dist/client/_assets/client-author-QPm1whbO.css +2 -0
- package/dist/client/_assets/client-compose-BB4U7Wz0.js +2004 -0
- package/dist/client/_assets/{client-manage-C1eDB1Rc.js → client-manage-CI9-eh-8.js} +176 -176
- package/dist/client/_assets/{client-settings-DIM44Zqh.js → client-settings-BnGPuqwc.js} +166 -166
- package/dist/client/_assets/client-share-0DICJjAc.css +1 -0
- package/dist/client/_assets/client-share-C59mOLJ1.js +149 -0
- package/dist/index.js +1 -1
- package/dist/node.js +3 -2
- package/package.json +2 -1
- package/src/app.tsx +9 -0
- package/src/client/components/compose-types.ts +1 -0
- package/src/client/components/jant-compose-dialog.ts +1 -0
- package/src/client/components/jant-compose-editor.ts +30 -0
- package/src/client/components/jant-compose-fullscreen.ts +1 -0
- package/src/client/components/jant-post-menu.ts +80 -13
- package/src/client/components/jant-share-dialog.ts +422 -0
- package/src/client/components/jant-share-menu.ts +188 -0
- package/src/client/compose-bridge.ts +61 -1
- package/src/client/feed-video-player.ts +6 -0
- package/src/client/lazy-entries.ts +21 -1
- package/src/client/post-menu-shared.ts +100 -0
- package/src/client/share-capture.ts +443 -0
- package/src/client/share-launch.ts +133 -0
- package/src/client/tiptap/bubble-menu.ts +25 -2
- package/src/client/tiptap/create-editor.ts +2 -0
- package/src/client/tiptap/extensions.ts +4 -0
- package/src/client/video-processor.ts +106 -52
- package/src/client/view-confirm.ts +108 -0
- package/src/client-share.ts +8 -0
- package/src/client.ts +2 -0
- package/src/db/migrations/0035_brainy_next_avengers.sql +9 -0
- package/src/db/migrations/0036_gorgeous_smasher.sql +7 -0
- package/src/db/migrations/meta/0035_snapshot.json +2877 -0
- package/src/db/migrations/meta/0036_snapshot.json +2924 -0
- package/src/db/migrations/meta/_journal.json +14 -0
- package/src/db/migrations/pg/0033_cute_magdalene.sql +10 -0
- package/src/db/migrations/pg/0034_material_agent_brand.sql +8 -0
- package/src/db/migrations/pg/meta/0033_snapshot.json +3719 -0
- package/src/db/migrations/pg/meta/0034_snapshot.json +3766 -0
- package/src/db/migrations/pg/meta/_journal.json +14 -0
- package/src/db/pg/schema.ts +40 -0
- package/src/db/schema.ts +61 -0
- package/src/i18n/locales/public/en.po +5 -0
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +5 -0
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +5 -0
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +149 -0
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +149 -0
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +149 -0
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/lib/discover.ts +31 -0
- package/src/lib/env.ts +20 -0
- package/src/lib/github-app-state.ts +1 -1
- package/src/lib/github-app.ts +183 -1
- package/src/lib/markdown-manager.ts +129 -1
- package/src/lib/post-meta.ts +13 -3
- package/src/lib/referrer-aliases.ts +311 -0
- package/src/lib/render.tsx +10 -0
- package/src/lib/resolve-config.ts +14 -0
- package/src/lib/share-card.ts +653 -0
- package/src/lib/summary.ts +152 -54
- package/src/lib/tiptap-render.ts +1 -0
- package/src/lib/upload.ts +21 -1
- package/src/lib/version.ts +2 -0
- package/src/lib/video-playback.ts +55 -0
- package/src/lib/view-buffer.ts +201 -0
- package/src/lib/view-counting.ts +539 -0
- package/src/lib/view-token.ts +177 -0
- package/src/lib/view.ts +13 -1
- package/src/middleware/view-counter.ts +140 -0
- package/src/node/runtime.ts +4 -0
- package/src/preset.css +31 -14
- package/src/routes/api/media.ts +21 -3
- package/src/routes/auth/setup.tsx +37 -1
- package/src/routes/dash/settings.tsx +433 -168
- package/src/routes/pages/archive.tsx +1 -0
- package/src/routes/pages/collection.tsx +6 -0
- package/src/routes/pages/collections.tsx +1 -0
- package/src/routes/pages/featured.tsx +1 -0
- package/src/routes/pages/home.tsx +1 -0
- package/src/routes/pages/page.tsx +3 -0
- package/src/routes/pages/partials.tsx +23 -0
- package/src/routes/pages/smart-collection.tsx +2 -0
- package/src/routes/pages/subscribe.tsx +1 -0
- package/src/routes/view-confirm.ts +63 -0
- package/src/services/export-theme/assets/client-site.js +1 -1
- package/src/services/export-theme/styles/main.css +39 -21
- package/src/services/export.ts +2 -0
- package/src/services/index.ts +17 -0
- package/src/services/mcp.ts +31 -1
- package/src/services/media.ts +63 -0
- package/src/services/stats.ts +1130 -0
- package/src/style-share.css +16 -0
- package/src/styles/components-author.css +177 -0
- package/src/styles/components.css +25 -3
- package/src/styles/share.css +1103 -0
- package/src/styles/tokens.css +65 -30
- package/src/styles/ui.css +62 -13
- package/src/types/app-context.ts +9 -0
- package/src/types/bindings.ts +5 -0
- package/src/types/config.ts +54 -0
- package/src/types/views.ts +6 -0
- package/src/ui/compose/ComposeDialog.tsx +6 -0
- package/src/ui/dash/settings/SettingsRootContent.tsx +24 -6
- package/src/ui/dash/settings/StatsContent.tsx +855 -0
- package/src/ui/font-themes.ts +39 -6
- package/src/ui/layouts/BaseLayout.tsx +11 -2
- package/src/ui/layouts/SiteLayout.tsx +9 -3
- package/src/ui/share/ShareCard.tsx +298 -0
- package/src/ui/shared/Icon.tsx +23 -3
- package/src/ui/shared/MediaGallery.tsx +31 -4
- package/src/ui/shared/PostFooter.tsx +20 -4
- package/src/ui/shared/icon-collector.ts +28 -0
- package/src/ui/shared/post-article-attributes.ts +3 -0
- package/dist/client/_assets/chunks/footnote-rail-BJwswtVQ.js +0 -1
- package/dist/client/_assets/chunks/lit-DW8VmJAT.js +0 -2
- package/dist/client/_assets/chunks/slug-format-Dsi0e9Xn.js +0 -1
- package/dist/client/_assets/chunks/sortable-list-DWNKv782.js +0 -2
- package/dist/client/_assets/chunks/types-D5iF3H1a.js +0 -1
- package/dist/client/_assets/chunks/unsafe-svg-DTZZEvLU.js +0 -2
- package/dist/client/_assets/client-BaqmpPQ-.css +0 -2
- package/dist/client/_assets/client-C6melOtG.js +0 -296
- package/dist/client/_assets/client-auth-Ccq8kSqq.js +0 -828
- package/dist/client/_assets/client-author-CGVvrNZ8.css +0 -2
- package/dist/client/_assets/client-compose-oxzPb3SS.js +0 -2004
|
@@ -0,0 +1,859 @@
|
|
|
1
|
+
import{i as e,l as t,n,p as r,r as i,s as a}from"./chunks/runtime-paths-y0_gHowM.js";import{a as o}from"./chunks/footnote-rail-9zwl6jtV.js";import{i as s,n as c,t as l,u}from"./chunks/lit-Bw_voPoW.js";import{a as ee,i as te,n as ne,o as re,r as ie,t as ae}from"./client-BO8GOFfT.js";import{n as d,t as oe}from"./chunks/confirm-CMe01lne.js";import{_ as f,a as se,d as p,f as m,g as h,h as g,i as ce,l as _,m as le,n as ue,p as de,r as fe,t as v,u as pe,v as y}from"./chunks/unsafe-svg-CUrgo4Xg.js";import{h as b,l as me,u as x}from"./chunks/types-DrYFqJH2.js";import{r as S}from"./chunks/slug-format-BuCPjSrB.js";import{t as he}from"./chunks/settings-paths-BBVT8zKj.js";var C=`M12 3 10.1 10.1 3 12l7.1 1.9L12 21l1.9-7.1L21 12l-7.1-1.9Z`,ge=`M4 4 20 20`,_e=200,ve=class extends l{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)},_e)}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 c;let t=e.minQueryLength??2,n=this._query.trim().length<t;return s`
|
|
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?s`<p class="picker-dialog-hint">${e.hint}</p>`:c}
|
|
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=>s`
|
|
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?s`<span class="picker-dialog-option-meta"
|
|
41
|
+
>${e.meta}</span
|
|
42
|
+
>`:c}
|
|
43
|
+
</button>
|
|
44
|
+
`)}
|
|
45
|
+
${this._loading?s`<p class="picker-dialog-status">Searching…</p>`:c}
|
|
46
|
+
${!this._loading&&this._searched&&this._items.length===0?s`<p class="picker-dialog-status">
|
|
47
|
+
${this._note||e.emptyHint}
|
|
48
|
+
</p>`:c}
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<footer
|
|
52
|
+
class=${S({"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`,ve);var w=`jant-post-picker`;function ye(){let e=document.querySelector(w);if(e)return e;let t=document.createElement(w);return document.body.appendChild(t),t}function be(e){return ye().pick(e)}var T=`[data-post-menu-translation] a, [data-post-menu-translation-first], [data-post-menu-open-language-switch]`,xe=360;function E(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 D(e){return!e.isDraft&&e.visibility!==`private`}function O(e){return Array.from(document.querySelectorAll(`article[data-post-id]`)).find(t=>t.dataset.postId===e)??null}function k(e){let t=e.dataset.postId;if(!t)return null;let n=e.dataset.threadRootId??t,r=O(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,permalink:e.dataset.postPermalink??null}}var Se=class extends l{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=re(t,xe),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.#H();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=k(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]`),D(n)&&ne();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.#B(t);return}e.key===`Enter`&&(e.preventDefault(),this.#k())};#d=(e,t)=>{e.detail!==0&&this.#B(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(T),await this.#S(),this.contains(document.activeElement)||this.#s(T))}#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 n=await fetch(i(`/api/posts/${t.threadId}/language`),{method:`PUT`,headers:{"Content-Type":`application/json`},credentials:`same-origin`,body:JSON.stringify({language:e})});if(!n.ok){u(await b(n,`Could not change the language. Try again.`),`error`);return}let r=document.querySelector(`article[data-post-id="${t.threadId}"]`);r&&(r.dataset.postLanguage=e),this._data={...t,language:e},u(`Thread is now in ${this.#g(e)}.`),this.#k()}catch{u(`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(i(`/api/posts/${e.threadId}/translations`),{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();this._translations=n.translations??[]}catch{this._translations=[]}finally{this._translationsLoading=!1}}}async#C(e){let t=this._data;if(!t)return;this.#k({restoreFocus:!1});let n=await _();if(n){await n.openTranslation(t.threadId,e);return}let r=new URLSearchParams({translationOf:t.threadId,lang:e});window.location.assign(i(`/new?${r.toString()}`))}async#w(){let e=this._data;if(!e)return;this.#k({restoreFocus:!1});let n=await be({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 n=>{if(t(n))return this.#T(e.threadId,n);let r=await fetch(i(`/api/posts/${e.threadId}/translations/candidates?q=${encodeURIComponent(n)}`),{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:[]}}});n&&(this._data=e,await this.#D(n),window.location.reload())}async#T(e,t){let n;try{let r=await fetch(i(`/api/posts/${e}/translations/resolve?url=${encodeURIComponent(t)}`),{credentials:`same-origin`});if(!r.ok)throw Error(`HTTP ${r.status}`);({resolution:n}=await r.json())}catch{return{items:[],note:`Could not check that address. Try again in a moment.`}}return n?n.kind===`ok`?{items:[{id:n.candidate.id,label:n.candidate.label,meta:this.#g(n.candidate.language)}]}:{items:[],note:this.#E(n)}:{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 n=await fetch(i(`/api/posts/${t.threadId}/translations`),{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`same-origin`,body:JSON.stringify({postId:e})});if(!n.ok){u(await b(n,`Could not link those posts. Try again.`),`error`);return}await this.#S(),u(`Posts linked as translations.`)}catch{u(`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 n=this.#g(e.language);if(!await d({message:`Unlink the ${n} 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 n=await fetch(i(`/api/posts/${e.id}/translations`),{method:`DELETE`,credentials:`same-origin`});if(!n.ok){u(await b(n,`Could not unlink. Try again.`),`error`),t?.focus();return}u(`Translation link removed.`),window.location.reload()}catch{u(`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=k(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.#z()}async#A(){if(!this._data)return;let e=this._data.id;this.#k({restoreFocus:!1});let t=await _();t&&await t.openEdit(e)}#j(){let e=this._data?.permalink;this.#k(),e&&ie(e)}#M(){if(!this._data)return;let e=this._data.id,t=this._triggerEl;this.#k({restoreFocus:!1}),ae(e,t)}async#N(){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();u(`Draft published.`),(!n||!await se(n))&&globalThis.location.reload()}catch{u(`Could not publish the draft. Try again.`,`error`),t?.focus()}}#P(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},u({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),u(`Could not update visibility. Try again.`,`error`)})}#F(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},u(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`,``)),u(`Could not update post. Try again.`,`error`)})}#I(){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},u(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`,``)),u(`Could not update post. Try again.`,`error`)})}#L(){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=O(e);r&&(n?r.setAttribute(`data-post-pinned-in-collection`,``):r.removeAttribute(`data-post-pinned-in-collection`)),this._data={...this._data,pinnedInCollection:n},u(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=O(e);t&&(n?t.removeAttribute(`data-post-pinned-in-collection`):t.setAttribute(`data-post-pinned-in-collection`,``)),u(`Could not update pin. Try again.`,`error`)})}async#R(){if(!this._data)return;let e=this._triggerEl;if(this.#k({restoreFocus:!1}),!await d({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(),E(t)}}else{let t=e?.closest(`.feed-item`),n=t?.parentElement??null;(t??e)?.remove(),E(n)}u(`Post deleted.`)}catch{u(`Could not delete post. Try again.`,`error`),e?.focus()}}async#z(){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=ce(r,i),this._collections=r,this._threadCollectionIds=i}catch{this._collections=this._collections??[],u(`Could not load collections.`,`error`)}this._collectionsLoading=!1,this.#s(`.post-menu-picker-search input, .post-menu-picker-option, [data-post-menu-add-collection]`)}#B(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,u(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.#K()}).catch(()=>{this._threadCollectionIds.includes(e)||(this._threadCollectionIds=[...this._threadCollectionIds,e]),u(`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.#K();throw Error()}return this.#K()}).catch(()=>{this._threadCollectionIds=this._threadCollectionIds.filter(t=>t!==e),u(`Could not add to collection. Try again.`,`error`)})}#V(){this._addCollectionPanelOpen=!0,this.updateComplete.then(()=>{let e=this.querySelector(`[data-collection-quick-dialog] [data-collection-title-input]`);e?.focus(),e?.select()})}#H(){this._addCollectionPanelOpen=!1,this.#r(),this.updateComplete.then(()=>{(this.querySelector(`[data-post-menu-add-collection]`)??this._triggerEl)?.focus()})}async#U(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.#K(),this.#e=!0,this.#H(),u(this.#W()?.createdLabel??`Collection created.`)}catch(e){u(e instanceof Error?e.message:`Could not create collection. Try again.`,`error`)}finally{r&&(r.loading=!1)}}#W(){return y()?.collectionFormLabels??null}#G(){return y()?.addCollection??`Add Collection`}async#K(){await(await _())?.refreshCollections()}#q(e){switch(e){case`private`:return`Private`;case`latest_hidden`:return`Hidden from Latest`;default:return`Public`}}#J(){return s`<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>`}#Y(){return s`<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>`}#X(){return s`<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=${C} />
|
|
96
|
+
</svg>`}#Z(){return s`<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=${C} />
|
|
107
|
+
<path d=${ge} />
|
|
108
|
+
</svg>`}#Q(){return s`<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>`}#$(){return s`<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>`}#ee(){return s`<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>`}#te(){return s`<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>`}#ne(){return s`<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>`}#re(){return s`<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>`}#ie(){return s`<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>`}#ae(){let e=this._collections??[],t=ue(e,this.#t),n=this._collectionSearch.trim().length>0,r=fe(t,this._collectionSearch);return s`
|
|
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.#te()}
|
|
201
|
+
</button>
|
|
202
|
+
<div class="post-menu-panel-heading">
|
|
203
|
+
<span>Collections</span>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
${e.length>0?s`<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>`:c}
|
|
231
|
+
<div
|
|
232
|
+
class="post-menu-picker-list"
|
|
233
|
+
role="listbox"
|
|
234
|
+
aria-multiselectable="true"
|
|
235
|
+
>
|
|
236
|
+
${this._collectionsLoading?s`<div class="post-menu-picker-empty">Loading...</div>`:r.length>0?r.map(e=>{let t=this._threadCollectionIds.includes(e.id);return s`
|
|
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?s`<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>`:s`<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
|
+
`}):s`<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.#V()}
|
|
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
|
+
`}#oe(){if(!this._data||this._data.isReply)return c;let{current:e,linked:t,free:n}=this.#b();return s`
|
|
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.#te()}
|
|
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
|
+
${n.length>0?s`
|
|
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.#ne()}</span
|
|
357
|
+
>
|
|
358
|
+
</button>
|
|
359
|
+
</div>
|
|
360
|
+
<div class="post-menu-section">
|
|
361
|
+
${n.map((e,t)=>s`
|
|
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.#ne()}</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.#ne()}</span
|
|
390
|
+
>
|
|
391
|
+
</button>
|
|
392
|
+
</div>
|
|
393
|
+
`:c}
|
|
394
|
+
${t.length>0?s`
|
|
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 s`
|
|
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=${i(`/${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??c}
|
|
411
|
+
>${t}</span
|
|
412
|
+
>
|
|
413
|
+
<span
|
|
414
|
+
class="post-menu-item-trailing post-menu-item-chevron"
|
|
415
|
+
>${this.#ie()}</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
|
+
`:c}
|
|
433
|
+
${this._translationsLoading?s`<p class="post-menu-hint">Loading…</p>`:c}
|
|
434
|
+
</div>
|
|
435
|
+
</div>
|
|
436
|
+
`}#se(){if(!this._data||this._data.isReply)return c;let{current:e,selectable:t}=this.#b();return s`
|
|
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.#te()}
|
|
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 s`
|
|
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?s`<span
|
|
473
|
+
class="post-menu-item-trailing post-menu-item-check"
|
|
474
|
+
>${this.#re()}</span
|
|
475
|
+
>`:c}
|
|
476
|
+
</button>
|
|
477
|
+
`})}
|
|
478
|
+
</div>
|
|
479
|
+
</div>
|
|
480
|
+
</div>
|
|
481
|
+
`}#ce(){if(!this._data||this._data.isReply)return c;let e=this._data.visibility;return s`
|
|
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.#te()}
|
|
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.#P(`public`)}
|
|
509
|
+
>
|
|
510
|
+
<span class="post-menu-item-label">Public</span>
|
|
511
|
+
${e===`public`?s`<span
|
|
512
|
+
class="post-menu-item-trailing post-menu-item-check"
|
|
513
|
+
>${this.#re()}</span
|
|
514
|
+
>`:c}
|
|
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.#P(`latest_hidden`)}
|
|
525
|
+
>
|
|
526
|
+
<span class="post-menu-item-label">Hidden from Latest</span>
|
|
527
|
+
${e===`latest_hidden`?s`<span
|
|
528
|
+
class="post-menu-item-trailing post-menu-item-check"
|
|
529
|
+
>${this.#re()}</span
|
|
530
|
+
>`:c}
|
|
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.#P(`private`)}
|
|
541
|
+
>
|
|
542
|
+
<span class="post-menu-item-label">Private</span>
|
|
543
|
+
${e===`private`?s`<span
|
|
544
|
+
class="post-menu-item-trailing post-menu-item-check"
|
|
545
|
+
>${this.#re()}</span
|
|
546
|
+
>`:c}
|
|
547
|
+
</button>
|
|
548
|
+
</div>
|
|
549
|
+
</div>
|
|
550
|
+
</div>
|
|
551
|
+
`}#le(){let e=this.#W();return e?s`
|
|
552
|
+
<div
|
|
553
|
+
class="collection-quick-dialog-backdrop"
|
|
554
|
+
@click=${()=>this.#H()}
|
|
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.#G()}
|
|
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.#G()}
|
|
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.#H()}
|
|
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=${i(`/api/collections`)}
|
|
585
|
+
cancel-href="javascript:void(0)"
|
|
586
|
+
@jant:collection-submit=${e=>this.#U(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
|
+
`:c}#ue(){if(!this._data)return c;let e=this._data.visibility,t=this._data.pinned,n=this._data.pinnedInCollection,r=document.querySelector(`[data-collection-id]`)?.dataset.collectionId,i=this._data.featured,a=!this._data.isDraft&&!!this._data.permalink,o=D(this._data);return s`
|
|
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.#Y()}</span>
|
|
612
|
+
</button>
|
|
613
|
+
|
|
614
|
+
${this._data.isDraft?s`
|
|
615
|
+
<button
|
|
616
|
+
type="button"
|
|
617
|
+
role="menuitem"
|
|
618
|
+
class="post-menu-item"
|
|
619
|
+
@click=${()=>this.#N()}
|
|
620
|
+
>
|
|
621
|
+
<span class="post-menu-item-label">Publish</span>
|
|
622
|
+
<span class="post-menu-item-trailing"
|
|
623
|
+
>${this.#J()}</span
|
|
624
|
+
>
|
|
625
|
+
</button>
|
|
626
|
+
`:c}
|
|
627
|
+
${this._data.isReply?c:s`
|
|
628
|
+
<button
|
|
629
|
+
type="button"
|
|
630
|
+
role="menuitem"
|
|
631
|
+
class="post-menu-item"
|
|
632
|
+
data-post-menu-open-collections
|
|
633
|
+
@click=${()=>this.#z()}
|
|
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.#ne()}</span
|
|
641
|
+
>
|
|
642
|
+
</button>
|
|
643
|
+
`}
|
|
644
|
+
${this._data.isReply?c:s`
|
|
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.#q(e)}</span
|
|
655
|
+
>
|
|
656
|
+
<span
|
|
657
|
+
class="post-menu-item-trailing post-menu-item-chevron"
|
|
658
|
+
>${this.#ne()}</span
|
|
659
|
+
>
|
|
660
|
+
</button>
|
|
661
|
+
`}
|
|
662
|
+
${this._data.isReply||!this.#h?c:s`
|
|
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.#ne()}</span
|
|
677
|
+
>
|
|
678
|
+
</button>
|
|
679
|
+
`}
|
|
680
|
+
</div>
|
|
681
|
+
|
|
682
|
+
<div class="post-menu-section">
|
|
683
|
+
${this._data.isDraft?c:s`
|
|
684
|
+
<button
|
|
685
|
+
type="button"
|
|
686
|
+
role="menuitem"
|
|
687
|
+
class="post-menu-item"
|
|
688
|
+
@click=${()=>this.#F(!i)}
|
|
689
|
+
>
|
|
690
|
+
<span class="post-menu-item-label"
|
|
691
|
+
>${i?`Remove from Featured`:`Add to Featured`}</span
|
|
692
|
+
>
|
|
693
|
+
<span class="post-menu-item-trailing"
|
|
694
|
+
>${i?this.#Z():this.#X()}</span
|
|
695
|
+
>
|
|
696
|
+
</button>
|
|
697
|
+
`}
|
|
698
|
+
${this._data.isReply?c:s`
|
|
699
|
+
<button
|
|
700
|
+
type="button"
|
|
701
|
+
role="menuitem"
|
|
702
|
+
class="post-menu-item"
|
|
703
|
+
@click=${()=>this.#I()}
|
|
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.#$():this.#Q()}</span
|
|
710
|
+
>
|
|
711
|
+
</button>
|
|
712
|
+
`}
|
|
713
|
+
${r&&!this._data.isReply?s`
|
|
714
|
+
<button
|
|
715
|
+
type="button"
|
|
716
|
+
role="menuitem"
|
|
717
|
+
class="post-menu-item"
|
|
718
|
+
@click=${()=>this.#L()}
|
|
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.#$():this.#Q()}</span
|
|
725
|
+
>
|
|
726
|
+
</button>
|
|
727
|
+
`:c}
|
|
728
|
+
</div>
|
|
729
|
+
|
|
730
|
+
${a||o?s`
|
|
731
|
+
<div class="post-menu-section">
|
|
732
|
+
${a?s`<button
|
|
733
|
+
type="button"
|
|
734
|
+
role="menuitem"
|
|
735
|
+
class="post-menu-item"
|
|
736
|
+
data-post-menu-copy-link
|
|
737
|
+
@click=${()=>this.#j()}
|
|
738
|
+
>
|
|
739
|
+
<span class="post-menu-item-label">Copy link</span>
|
|
740
|
+
<span class="post-menu-item-trailing"
|
|
741
|
+
>${ee()}</span
|
|
742
|
+
>
|
|
743
|
+
</button>`:c}
|
|
744
|
+
${o?s`<button
|
|
745
|
+
type="button"
|
|
746
|
+
role="menuitem"
|
|
747
|
+
class="post-menu-item"
|
|
748
|
+
data-post-menu-share-image
|
|
749
|
+
@click=${()=>this.#M()}
|
|
750
|
+
>
|
|
751
|
+
<span class="post-menu-item-label"
|
|
752
|
+
>Share as image</span
|
|
753
|
+
>
|
|
754
|
+
<span class="post-menu-item-trailing"
|
|
755
|
+
>${te()}</span
|
|
756
|
+
>
|
|
757
|
+
</button>`:c}
|
|
758
|
+
</div>
|
|
759
|
+
`:c}
|
|
760
|
+
|
|
761
|
+
<div class="post-menu-section post-menu-section-danger">
|
|
762
|
+
<button
|
|
763
|
+
type="button"
|
|
764
|
+
role="menuitem"
|
|
765
|
+
class="post-menu-item post-menu-item-danger"
|
|
766
|
+
@click=${()=>this.#R()}
|
|
767
|
+
>
|
|
768
|
+
<span class="post-menu-item-label"
|
|
769
|
+
>${this._data.isDraft?`Discard`:`Delete`}</span
|
|
770
|
+
>
|
|
771
|
+
<span class="post-menu-item-trailing">${this.#ee()}</span>
|
|
772
|
+
</button>
|
|
773
|
+
</div>
|
|
774
|
+
</div>
|
|
775
|
+
</div>
|
|
776
|
+
`}render(){if(!this._open||!this._data)return c;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 s`
|
|
777
|
+
${n?s`
|
|
778
|
+
<div
|
|
779
|
+
class="post-menu-backdrop"
|
|
780
|
+
@click=${()=>this.#k({restoreFocus:!1})}
|
|
781
|
+
></div>
|
|
782
|
+
<div class="dropdown-menu" style=${t}>
|
|
783
|
+
<div
|
|
784
|
+
data-popover
|
|
785
|
+
aria-hidden="false"
|
|
786
|
+
class="!static post-menu-panel"
|
|
787
|
+
>
|
|
788
|
+
${this._view===`collections`?this.#ae():this._view===`visibility`?this.#ce():this._view===`language`?this.#oe():this._view===`language-switch`?this.#se():this.#ue()}
|
|
789
|
+
</div>
|
|
790
|
+
</div>
|
|
791
|
+
`:c}
|
|
792
|
+
${this._addCollectionPanelOpen?this.#le():c}
|
|
793
|
+
`}};customElements.define(`jant-post-menu`,Se);var A=`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"`,j={post:`<svg ${A}><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 ${A} 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 ${A}><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 ${A}><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 ${A}><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 ${A}><polyline points="15 10 20 15 15 20"/><path d="M4 4v7a4 4 0 0 0 4 4h12"/></svg>`,search:`<svg ${A}><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`};function Ce(e){let t=e.trim().replace(/^[//]+/,``);return t?`/${t}`:`/`}function M(t){let n=t.trim();return a(n)?r(n,{siteOrigins:[window.location.origin],sitePathPrefix:e(),keepQuery:!0}):null}function we(e){return e.trim().replace(/^[//]+/,``).trim()}var Te=5;function N(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 P(e,t){let n=N(e).filter(e=>e!==t);n.unshift(t),globalThis.localStorage.setItem(e,JSON.stringify(n.slice(0,Te)))}var F=`jant:nav-history`,I=`jant:search-history`,Ee=[{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:he,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`}],De=[{label:`New Post`,icon:j.command,action:()=>void h()}],Oe=class extends l{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===`/`||M(this._query)?`path`:`navigate`}get#r(){let e=x(this._query),t=[...this.#e??[],...Ee];if(!e){let e=N(F);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:me([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=x(this._query.slice(1));return De.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:j.search,searchQuery:e}]:N(I).map(e=>({label:e,icon:j.search,searchQuery:e}))}if(e===`path`){let e=M(this._query),t=e??Ce(this._query),n=e?``:we(this._query),r=[{label:`Go to ${t}`,icon:j.path,pathTarget:t}];return n&&r.push({label:`Search for "${n}"`,icon:j.search,searchQuery:n}),r}let t=x(this._query),n=this.#r.map(e=>({label:e.title,secondary:e.status===`draft`?`Draft · ${e.path}`:e.path,icon:j[e.type]}));return t&&n.push({label:`Search all content for "${this._query.trim()}"`,icon:j.search,searchQuery:this._query.trim(),placement:`footer`,...n.length>0?{shortcut:`⌘/Ctrl ↵`}:{}}),n}#o(e){P(I,e),this.close(),window.location.href=n(`/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){P(F,t.pathTarget),this.close(),window.location.href=n(t.pathTarget);return}t?.searchQuery&&this.#o(t.searchQuery);return}let r=this.#a[e];if(r?.searchQuery){this.#o(r.searchQuery);return}let i=this.#r[e];i&&(P(F,i.path),this.close(),i.type===`system`?window.location.href=n(i.path):i.type===`collection`?window.location.href=n(`/collections/${i.path}`):i.type===`smart_collection`?window.location.href=n(`/${i.path}`):window.location.href=n(i.status===`draft`?`/preview/${i.path}?edit=1`:`/${i.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 s`
|
|
794
|
+
<div
|
|
795
|
+
id="command-palette-item-${t}"
|
|
796
|
+
class=${S({"command-palette-result":!0,"command-palette-result-selected":t===this._selectedIndex,"command-palette-search-action":n})}
|
|
797
|
+
role="option"
|
|
798
|
+
aria-selected=${t===this._selectedIndex}
|
|
799
|
+
@click=${this.#f(t)}
|
|
800
|
+
>
|
|
801
|
+
<span class="command-palette-result-icon">${v(e.icon)}</span>
|
|
802
|
+
<span class="command-palette-result-body">
|
|
803
|
+
<span class="command-palette-result-title">${e.label}</span>
|
|
804
|
+
${e.secondary?s`<span class="command-palette-result-path"
|
|
805
|
+
>${e.secondary}</span
|
|
806
|
+
>`:c}
|
|
807
|
+
</span>
|
|
808
|
+
${e.shortcut?s`<kbd
|
|
809
|
+
class="command-palette-result-shortcut"
|
|
810
|
+
aria-label="Command or Control plus Enter"
|
|
811
|
+
>${e.shortcut}</kbd
|
|
812
|
+
>`:c}
|
|
813
|
+
</div>
|
|
814
|
+
`}render(){if(!this._open)return c;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 s`
|
|
815
|
+
<dialog
|
|
816
|
+
class="command-palette"
|
|
817
|
+
@cancel=${this.#u}
|
|
818
|
+
@click=${this.#d}
|
|
819
|
+
@keydown=${this.#l}
|
|
820
|
+
>
|
|
821
|
+
<div
|
|
822
|
+
class="command-palette-panel"
|
|
823
|
+
@click=${e=>e.stopPropagation()}
|
|
824
|
+
>
|
|
825
|
+
<div class="command-palette-input-wrapper">
|
|
826
|
+
<span class="command-palette-search-icon"
|
|
827
|
+
>${v(j.search)}</span
|
|
828
|
+
>
|
|
829
|
+
<input
|
|
830
|
+
type="text"
|
|
831
|
+
class="command-palette-input"
|
|
832
|
+
.value=${this._query}
|
|
833
|
+
@input=${this.#c}
|
|
834
|
+
placeholder="Type to navigate, > for commands, ? to search..."
|
|
835
|
+
role="combobox"
|
|
836
|
+
aria-expanded="true"
|
|
837
|
+
aria-controls="command-palette-results"
|
|
838
|
+
aria-activedescendant=${e.length>0?`command-palette-item-${this._selectedIndex}`:``}
|
|
839
|
+
autocomplete="off"
|
|
840
|
+
spellcheck="false"
|
|
841
|
+
/>
|
|
842
|
+
${this._loading?s`<span class="command-palette-spinner"></span>`:c}
|
|
843
|
+
</div>
|
|
844
|
+
|
|
845
|
+
${e.length>0?s`
|
|
846
|
+
<div
|
|
847
|
+
id="command-palette-results"
|
|
848
|
+
class="command-palette-results-container"
|
|
849
|
+
role="listbox"
|
|
850
|
+
>
|
|
851
|
+
${t.length>0?s`<div class="command-palette-results">
|
|
852
|
+
${t.map(({item:e,index:t})=>this.#m(e,t))}
|
|
853
|
+
</div>`:c}
|
|
854
|
+
${n.map(({item:e,index:t})=>this.#m(e,t,!0))}
|
|
855
|
+
</div>
|
|
856
|
+
`:this._query.trim()&&!this._loading?s`<div class="command-palette-empty">No results</div>`:c}
|
|
857
|
+
</div>
|
|
858
|
+
</dialog>
|
|
859
|
+
`}};customElements.get(`jant-command-palette`)||customElements.define(`jant-command-palette`,Oe),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;h(e?{collectionId:e}:void 0);return}let r=t.closest(`[data-reply-trigger]`);if(r){let e=r.closest(`article[data-post]`);e&&f(e);return}let i=t.closest(`[data-draft-continue]`);if(i){let e=i.dataset.postId??i.closest(`article[data-post]`)?.dataset.postId;e&&g(e)}});var L=`.compose-prompt`,ke=`.compose-prompt-trigger`,R=`jant.composeOpenShortcutDiscovery`,Ae=`/api/settings/discovery/compose-open-shortcut`,je=350,Me=1800,z=3,B=`compose-prompt-discovery-visible`,V=!1,H=null,U=null,W=null;function G(){try{return globalThis.localStorage!==void 0}catch{return!1}}function K(){if(!G())return{shownCount:0,completed:!1};let e=globalThis.localStorage.getItem(R);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(R),{shownCount:0,completed:!1}}}function q(e){if(G())try{globalThis.localStorage.setItem(R,JSON.stringify(e))}catch{}}function J(){H!==null&&(clearTimeout(H),H=null)}function Ne(){U!==null&&(clearTimeout(U),U=null)}function Pe(){return typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(min-width: 700px)`).matches}function Fe(e){return K().completed?!0:e?.dataset.composeOpenShortcutDiscovered===`true`}function Ie(e){e&&(e.dataset.composeOpenShortcutDiscovered=`true`,e.classList.remove(B)),document.querySelectorAll(L).forEach(e=>{e.dataset.composeOpenShortcutDiscovered=`true`,e.classList.remove(B)})}function Le(){let e=K();e.completed||V||e.shownCount>=z||(V=!0,q({...e,shownCount:e.shownCount+1}))}function Y(e){return!Pe()||Fe(e)?!1:K().shownCount<z||V}function X(e){J(),Ne(),e?e.classList.remove(B):W&&W.classList.remove(B),(!e||e===W)&&(W=null)}function Re(e){Y(e)&&(X(W),W=e,e.classList.add(B),Le(),U=setTimeout(()=>{X(e)},Me))}function Z(e){Y(e)&&(e.classList.contains(B)||(J(),H=setTimeout(()=>{Re(e)},je)))}function ze(e){if(e.dataset.composeOpenShortcutDiscoveryBound===`true`)return;let t=e.querySelector(ke);t&&(e.dataset.composeOpenShortcutDiscoveryBound=`true`,t.addEventListener(`pointerenter`,()=>{Z(e)}),t.addEventListener(`pointerleave`,()=>{X(e)}),t.addEventListener(`focusin`,()=>{Z(e)}),t.addEventListener(`focusout`,()=>{X(e)}))}function Q(e=document){e.querySelectorAll(L).forEach(e=>ze(e))}function Be(){let e=K();e.completed||q({shownCount:Math.max(e.shownCount,z),completed:!0}),Ie(W),X(W),typeof globalThis.fetch==`function`&&globalThis.fetch(Ae,{method:`POST`,headers:{Accept:`application/json`},credentials:`same-origin`}).catch(()=>{})}var Ve=[`input`,`textarea`,`select`,`button`,`a[href]`,`[contenteditable='']`,`[contenteditable='true']`,`[role='textbox']`,`.ProseMirror`].join(`, `);function $(e){return e instanceof globalThis.Element&&e.closest(Ve)!==null}function He(e){if(e.defaultPrevented||e.isComposing||e.repeat||e.metaKey||e.ctrlKey||e.altKey||!p()||document.querySelector(`.compose-page`)||document.querySelector(`dialog[open]`))return!0;let t=document.activeElement;return $(e.target)||t!==e.target&&$(t)}function Ue(){return new URL(window.location.href).searchParams.get(`edit`)===`1`}function We(){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 Ge(){if(!document.body?.hasAttribute(`data-authenticated`)||!Ue())return;let e=m()?.dataset.postId;e&&p()&&(We(),document.querySelector(`[data-preview-status]`)?le(e):g(e))}async function Ke(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`),u(t?`Added to Featured.`:`Removed from Featured.`)}catch{u(`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`||He(e))return;if(t===`n`||t===`l`||t===`q`){e.preventDefault(),Be();let n=pe(),r=t===`l`?`link`:t===`q`?`quote`:void 0;h({...n?{collectionId:n}:void 0,...r?{initialFormat:r}:void 0});return}if(t===`r`){let t=de();if(!t)return;e.preventDefault(),f(t);return}let n=m();if(n){if(t===`e`){let t=n.dataset.postId;if(!t)return;e.preventDefault(),g(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(),Ke(t,!n.hasAttribute(`data-post-featured`),n);return}}}),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,Ge,{once:!0}):Ge(),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>{Q()}):Q(),oe(),document.querySelector(`jant-command-palette`)||document.body.appendChild(document.createElement(`jant-command-palette`)),o();
|