@jant/core 1.0.1 → 1.1.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/dist/{app-Gt7_skt6.js → app-CKQ9PqAr.js} +791 -89
- package/dist/client/.vite/manifest.json +115 -75
- package/dist/client/_assets/chunks/{confirm-D7GrwsCN.js → confirm-CMe01lne.js} +1 -1
- package/dist/client/_assets/chunks/{create-editor-5Y49x7h5.js → create-editor-BQkrw8Ax.js} +4 -4
- package/dist/client/_assets/chunks/footnote-rail-B08scyhW.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-B0bNUaih.js} +1 -1
- package/dist/client/_assets/chunks/slug-format-CYmQE5ln.js +1 -0
- package/dist/client/_assets/chunks/{sortable-list-DWNKv782.js → sortable-list-t11Ma1Ek.js} +1 -1
- package/dist/client/_assets/chunks/{unsafe-html-B5ZEXaxg.js → unsafe-html-CWos3v6N.js} +1 -1
- package/dist/client/_assets/chunks/unsafe-svg-DZl-yjas.js +1 -0
- package/dist/client/_assets/client-B0-s9sqx.css +2 -0
- package/dist/client/_assets/client-Dp46QSht.js +354 -0
- package/dist/client/_assets/client-auth-CG55rWb5.js +859 -0
- package/dist/client/_assets/{client-compose-oxzPb3SS.js → client-compose-DkUTuavR.js} +261 -261
- package/dist/client/_assets/{client-manage-C1eDB1Rc.js → client-manage-DnYdQAhf.js} +176 -176
- package/dist/client/_assets/{client-settings-DIM44Zqh.js → client-settings-CHgsIqXJ.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 +2 -2
- package/package.json +2 -1
- 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/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-share.ts +8 -0
- package/src/client.ts +1 -0
- package/src/lib/discover.ts +31 -0
- package/src/lib/share-card.ts +653 -0
- package/src/lib/version.ts +2 -0
- package/src/routes/auth/setup.tsx +37 -1
- package/src/routes/pages/partials.tsx +23 -0
- package/src/style-share.css +16 -0
- package/src/styles/components.css +14 -0
- package/src/styles/share.css +1103 -0
- package/src/styles/ui.css +6 -0
- package/src/ui/layouts/BaseLayout.tsx +7 -0
- package/src/ui/layouts/SiteLayout.tsx +1 -0
- package/src/ui/share/ShareCard.tsx +298 -0
- package/src/ui/shared/Icon.tsx +23 -3
- package/src/ui/shared/MediaGallery.tsx +12 -1
- 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/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
|
@@ -1,828 +0,0 @@
|
|
|
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-C6melOtG.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-DTZZEvLU.js";import{r as v}from"./chunks/slug-format-Dsi0e9Xn.js";import{h as y,l as ue,u as b}from"./chunks/types-D5iF3H1a.js";import{t as de}from"./chunks/settings-paths-h6RjIe3C.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(`.compose-page`)||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();
|