@blinkk/root-cms 3.0.4 → 3.0.5
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.js +2 -1
- package/dist/{chunk-RLZFZT42.js → chunk-VSPPZPMP.js} +2 -2
- package/dist/core/schema.d.ts +20 -0
- package/dist/plugin.js +1 -1
- package/dist/shared/auto-slug-words.d.ts +7 -0
- package/dist/shared/auto-slug.d.ts +14 -0
- package/dist/ui/{AIPage-YI3RFK5F.js → AIPage-F3NNYM5E.js} +1 -1
- package/dist/ui/{AssetsPage-4JNAOFYF.js → AssetsPage-DZQHAENZ.js} +1 -1
- package/dist/ui/{CollectionPage-JWHH5G55.js → CollectionPage-WVVG62NR.js} +1 -1
- package/dist/ui/{ComparePage-YZE3EMU4.js → ComparePage-CRDHP45W.js} +1 -1
- package/dist/ui/{DataPage-VRCQSZZG.js → DataPage-WMLBCPGF.js} +1 -1
- package/dist/ui/{DataSourcePage-WMSPBZ3W.js → DataSourcePage-POZAQFPU.js} +1 -1
- package/dist/ui/{DocTranslationsPage-RY2LOZBX.js → DocTranslationsPage-UR5D2RF2.js} +1 -1
- package/dist/ui/DocumentPage-SQ7ROBMC.js +1 -0
- package/dist/ui/{EditDataSourcePage-LLCX6K4J.js → EditDataSourcePage-PUA2AJ4C.js} +1 -1
- package/dist/ui/{EditReleasePage-WQYXXMZQ.js → EditReleasePage-CENP46EO.js} +1 -1
- package/dist/ui/{LogsPage-IP2DKEYR.js → LogsPage-FZRN6MBJ.js} +1 -1
- package/dist/ui/{NewDataSourcePage-RDYJC4DH.js → NewDataSourcePage-FTILYFJY.js} +1 -1
- package/dist/ui/{NewReleasePage-DGMFU2JN.js → NewReleasePage-MHJC66KK.js} +1 -1
- package/dist/ui/{NotFoundPage-WDZ2K7EF.js → NotFoundPage-EP2OE4JV.js} +1 -1
- package/dist/ui/{ProjectPage-HYJOQUWR.js → ProjectPage-6J7QCG75.js} +1 -1
- package/dist/ui/{ReleasePage-2KSF23TK.js → ReleasePage-IZ3DNGT4.js} +1 -1
- package/dist/ui/{ReleasesPage-NZIBBXU4.js → ReleasesPage-RWFOJ5VG.js} +1 -1
- package/dist/ui/SettingsPage-M4SIDBTI.js +1 -0
- package/dist/ui/{SidebarToolsPage-5C6YBWJ7.js → SidebarToolsPage-GAX3XJ7W.js} +1 -1
- package/dist/ui/{TaskPage-SPIFPGPP.js → TaskPage-UCATTNZ5.js} +1 -1
- package/dist/ui/{TasksPage-ZOXRPBQV.js → TasksPage-4AQLQ4IT.js} +1 -1
- package/dist/ui/{TranslationsArbPage-UHANA7JD.js → TranslationsArbPage-JGQGATCS.js} +1 -1
- package/dist/ui/{TranslationsEditPage-PQY6W5YG.js → TranslationsEditPage-7AGZGHKS.js} +1 -1
- package/dist/ui/{TranslationsPage-V2PQFCN5.js → TranslationsPage-WIDVSTYF.js} +1 -1
- package/dist/ui/{chunk-FBJURT7Z.js → chunk-7MTDTPYB.js} +1 -1
- package/dist/ui/{chunk-GXSAEPU3.js → chunk-7UIUAHC4.js} +1 -1
- package/dist/ui/{chunk-JT5L6GPZ.js → chunk-AEWL2RWR.js} +1 -1
- package/dist/ui/{chunk-MDUBCXU2.js → chunk-JKCZGT6B.js} +1 -1
- package/dist/ui/chunk-P4U2LUTF.js +1 -0
- package/dist/ui/{chunk-V7S4IAGB.js → chunk-QGBR3J2Y.js} +1 -1
- package/dist/ui/ui.js +1 -1
- package/package.json +3 -3
- package/dist/ui/DocumentPage-EEGTJMIW.js +0 -1
- package/dist/ui/SettingsPage-36XFWV62.js +0 -1
- package/dist/ui/chunk-NXQVLOTK.js +0 -1
- /package/dist/ui/{chunk-JT5L6GPZ.js.LEGAL.txt → chunk-AEWL2RWR.js.LEGAL.txt} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as je}from"./chunk-767BAQ53.js";import{c as Le,i as Ve,j as $e,k as We,m as Fe}from"./chunk-JT5L6GPZ.js";import"./chunk-HHMG665Z.js";import"./chunk-YFA6U2CV.js";import"./chunk-4W73RW5I.js";import"./chunk-P3NETZZP.js";import"./chunk-V7S4IAGB.js";import"./chunk-KFAZBEPV.js";import"./chunk-KYDOSLTO.js";import{a as Ue}from"./chunk-JYFLU7DM.js";import"./chunk-PHBMVORG.js";import{d as Ee}from"./chunk-JZFTZ4X4.js";import"./chunk-HKINZLMW.js";import{a as Me,d as Ae,f as X,h as Oe}from"./chunk-TJBVMFNQ.js";import"./chunk-CGCKJFL4.js";import"./chunk-VMT7JFAM.js";import"./chunk-SKEP5WYH.js";import"./chunk-GXSAEPU3.js";import{b as Re,c as ae,g as Te}from"./chunk-NXQVLOTK.js";import"./chunk-3IYZCUPI.js";import"./chunk-RSVO46S3.js";import"./chunk-54DVDYU6.js";import{a as T}from"./chunk-X2WHBGTP.js";import{b as Be,c as se}from"./chunk-ONTGW2VA.js";import"./chunk-4KE2SZKH.js";import{a as ze}from"./chunk-L4RHGQUG.js";import"./chunk-HRGYNHZ3.js";import"./chunk-W3HIZQ4Z.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import"./chunk-AFWBSIPL.js";import"./chunk-XOQ3KDSR.js";import"./chunk-62UWGWON.js";import"./chunk-I6ICVKEC.js";import"./chunk-HLMBCVRX.js";import"./chunk-ORXEMIQC.js";import{a as He,b as Xe}from"./chunk-FBJURT7Z.js";import"./chunk-5MV6XVGA.js";import"./chunk-EGEB6N4J.js";import{f as I}from"./chunk-AL3TN2KI.js";import{Aa as _e,Ac as Ie,Ga as L,Ha as e,Ja as pe,P as me,Pa as ge,Ra as oe,Ta as fe,Tc as Ne,Uc as ne,Va as ve,Vb as De,W as E,Wb as Ce,_a as Pe,a as y,c as x,ca as he,e as P,ea as H,g as M,h as C,j as te,pc as Se,qb as we,rb as xe,sb as be,tb as ke,tc as ye}from"./chunk-NZHF733K.js";import{d as V,j as ue,k as et}from"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";te();te();async function qe(t,o){let a=await(await fetch("/cms/api/check.test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({check:t,docId:o})})).json();if(!a.success)throw new Error(a.error||"Check failed.");return a.data}function Ke(t){let o=window.__ROOT_CTX.checks||[],n=t.docId.split("/")[0],a=o.filter(c=>!c.collections||c.collections.includes(n)),[i,r]=y({}),s=C(async c=>{r(m=>({...m,[c]:{loading:!0}}));try{let m=await qe(c,t.docId);r(h=>({...h,[c]:{loading:!1,result:m}}))}catch(m){r(h=>({...h,[c]:{loading:!1,error:m.message||"Unknown error."}}))}},[t.docId]),l=C(async()=>{let c={};for(let m of a)c[m.id]={loading:!0};r(c);for(let m of a)try{let h=await qe(m.id,t.docId);r(_=>({..._,[m.id]:{loading:!1,result:h}}))}catch(h){r(_=>({..._,[m.id]:{loading:!1,error:h.message||"Unknown error."}}))}},[t.docId,a]);return e("div",{className:"ChecksPanel",children:[e("div",{className:"ChecksPanel__header",children:[e("div",{className:"ChecksPanel__header__title",children:"Checks"}),e(H,{variant:"default",size:"xs",compact:!0,leftIcon:e(Se,{size:12}),onClick:l,children:"Run All"})]}),e("div",{className:"ChecksPanel__body",children:e("div",{className:"ChecksPanel__checks",children:a.map(c=>{let m=i[c.id];return e(tt,{check:c,state:m,onRun:()=>s(c.id)},c.id)})})})]})}function tt(t){let{check:o,state:n,onRun:a}=t;return e("div",{className:"ChecksPanel__check",children:[e("div",{className:"ChecksPanel__check__header",children:[e("div",{className:"ChecksPanel__check__label",children:[o.label,n?.result&&e(at,{status:n.result.status})]}),e(H,{className:"ChecksPanel__check__runButton",variant:"default",size:"xs",compact:!0,loading:n?.loading,onClick:a,children:"Run"})]}),o.description&&e("div",{className:"ChecksPanel__check__description",children:o.description}),n?.result&&e("div",{className:I("ChecksPanel__check__result",`ChecksPanel__check__result--${n.result.status}`),children:e(Ee,{code:n.result.message})}),n?.error&&e("div",{className:"ChecksPanel__check__error",children:n.error})]})}var ot={success:"green",warning:"yellow",error:"red"},nt={success:Pe,warning:pe,error:ne};function at(t){let o=ot[t.status],n=nt[t.status],a=t.status.charAt(0).toUpperCase()+t.status.slice(1);return e(he,{className:"ChecksPanel__statusBadge",color:o,size:"sm",variant:"filled",leftSection:e(n,{size:10}),children:a})}function Je(t){let{device:o,expandVertically:n,iframeUrl:a,localeOptions:i,selectedLocale:r,onToggleDevice:s,onToggleExpandVertically:l,onReloadClick:c,onOpenNewTab:m,onLocaleChange:h}=t;return e("div",{className:"DocumentPagePreviewBar",children:[e("div",{className:"DocumentPagePreviewBar__devices",children:[e(L,{label:"Mobile",children:e(E,{className:I("DocumentPagePreviewBar__device",o==="mobile"&&"active"),onClick:()=>s("mobile"),children:e(ke,{size:16})})}),e(L,{label:"Tablet",children:e(E,{className:I("DocumentPagePreviewBar__device",o==="tablet"&&"active"),onClick:()=>s("tablet"),children:e(be,{size:16})})}),e(L,{label:"Desktop",children:e(E,{className:I("DocumentPagePreviewBar__device",o==="desktop"&&"active"),onClick:()=>s("desktop"),children:e(we,{size:16})})}),e(L,{label:"Expand",children:e(E,{className:I("DocumentPagePreviewBar__device",n&&"active"),"aria-pressed":n,disabled:o==="",onClick:l,children:e(fe,{size:16})})})]}),e("div",{className:"DocumentPagePreviewBar__navbar",children:e("div",{className:"DocumentPagePreviewBar__navbar__url",children:a})}),e("div",{className:"DocumentPagePreviewBar__locales",children:e(_e,{data:i,placeholder:"Locale",radius:"xl",size:"xs",required:!0,icon:e(Ne,{size:16,strokeWidth:1.5}),value:r,onChange:_=>{h(_)}})}),e("div",{className:"DocumentPagePreviewBar__buttons",children:[e(L,{label:"Reload",children:e(E,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--reload",onClick:c,children:e(ye,{size:16})})}),e(L,{label:"Open new tab",children:e(E,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--openNewTab",onClick:m,children:e(oe,{size:16})})})]})]})}te();function Ye(t){let o=t.docId.split("/")[0],n=Te(o),a=X(),i=P(null),[r,s]=y(""),[l,c]=y([]),[m,h]=y(!1),_=P("");_.current=r;let g=P(n.schema?.fields||[]);g.current=n.schema?.fields||[];let k=P(n.schema?.types||{});k.current=n.schema?.types||{};let w=M(()=>Me(d=>{let b=d.trim();if(!b){c([]),h(!1);return}let S=a.controller?.getData()?.fields||{},z=We(b,S,g.current,k.current);c(z),h(!0)},150),[a.controller]);x(()=>{w(r)},[r,w]),Oe(()=>{_.current.trim()&&w(_.current)}),x(()=>{t.autoFocus&&requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()})},[t.autoFocus]),x(()=>{let d=()=>{i.current?.focus(),i.current?.select()};return window.addEventListener("root:focus-search",d),()=>window.removeEventListener("root:focus-search",d)},[]);let p=d=>{ct(d)};return e("div",{className:"SearchPanel",children:[e("div",{className:"SearchPanel__header",children:[e("div",{className:"SearchPanel__header__title",children:"Search"}),t.onClose&&e(E,{size:"xs",onClick:t.onClose,title:"Close search",children:e(ne,{size:14})})]}),e("div",{className:"SearchPanel__searchInput",children:[e("span",{className:"SearchPanel__searchInput__icon",children:e(Ie,{size:14})}),e("input",{ref:i,type:"text",className:"SearchPanel__searchInput__input",value:r,onInput:d=>s(d.currentTarget.value),onKeyDown:d=>{d.key==="Escape"&&t.onClose&&(d.preventDefault(),t.onClose())},placeholder:"Search field values\u2026",autoComplete:"off",spellcheck:!1})]}),e("div",{className:"SearchPanel__body",children:[!m&&!r.trim()&&e("div",{className:"SearchPanel__empty",children:"Type a query above to search field values in this document."}),m&&l.length===0&&e("div",{className:"SearchPanel__empty",children:["No matches for ",e("strong",{children:r}),"."]}),l.length>0&&e(V,{children:[e("div",{className:"SearchPanel__resultsCount",children:[l.length," ",l.length===1?"match":"matches"]}),e("ul",{className:"SearchPanel__results",children:l.map((d,b)=>e(it,{result:d,onClick:()=>p(d)},`${d.deepKey}:${b}`))})]})]})]})}function it(t){let{result:o}=t;return e("li",{className:"SearchPanel__result",children:e("button",{type:"button",className:"SearchPanel__result__button",onClick:t.onClick,children:[e("div",{className:"SearchPanel__result__label",children:o.label}),e("div",{className:"SearchPanel__result__snippet",children:rt(o.snippet,o.matches)}),e("div",{className:"SearchPanel__result__meta",children:[e("span",{className:"SearchPanel__result__type",children:o.fieldType}),o.richTextBlock&&e("span",{className:"SearchPanel__result__badge",children:"in block"}),o.richTextInline&&e("span",{className:"SearchPanel__result__badge",children:"inline"})]})]})})}function rt(t,o){if(!o||o.length===0)return t;let n=[],a=0;for(let i of o)i.start>a&&n.push({text:t.slice(a,i.start),match:!1}),n.push({text:t.slice(i.start,i.end),match:!0}),a=i.end;return a<t.length&&n.push({text:t.slice(a),match:!1}),n.map((i,r)=>i.match?e("mark",{children:i.text},r):e("span",{children:i.text},r))}function ct(t){if(window.postMessage({scrollToDeeplink:{deepKey:t.deepKey}},"*"),t.richTextBlock){let o=t.richTextBlock;setTimeout(()=>{window.dispatchEvent(new CustomEvent(Ve,{detail:o}))},350)}else if(t.richTextInline){let o=t.richTextInline;setTimeout(()=>{window.dispatchEvent(new CustomEvent($e,{detail:o}))},350)}}et();te();var st=ue(null);function j(t){let{className:o,localStorageId:n,children:a}=t,[i,r]=T(`root::SplitPanel:${n}`,350),[s,l]=y(!1),[c,m]=y(0),h=M(()=>new Set,[]),_=P(null),g=P(null),k={onResize:p=>(h.add(p),()=>{h.delete(p)})};if(x(()=>{let p=()=>l(!1);window.addEventListener("mouseup",p);let d=_.current;return d&&m(d.getBoundingClientRect().left),()=>window.removeEventListener("mouseup",p)},[]),x(()=>{let p=d=>{let b=d.clientX-c;r(b),h.forEach(S=>S())};return s&&window.addEventListener("mousemove",p),()=>window.removeEventListener("mousemove",p)},[s]),a?.length!==2)throw new Error("SplitPanel should have two <SplitPanel.Item> children.");let w={"--panel-size":`${i}px`};return e(st.Provider,{value:k,children:e("div",{className:I(o,"SplitPanel",s&&"dragging"),ref:_,style:w,children:[a[0],e("div",{className:"SplitPanel__divider",ref:g,onMouseDown:()=>l(!0)}),a[1]]})})}j.Item=t=>e("div",{className:I("SplitPanel__item",t.className,t.fluid?"fluid":"static"),children:t.children});function le(t,o,n=""){let a=ae({collectionId:t,slug:o}),i=new URLSearchParams(window.location.search);i.set("preview","true"),i.delete("locale"),i.delete("modal");let r=`${i.toString()}${window.location.hash}`;return n?`${ae({collectionId:t,slug:o,locale:n})}?${r}`:`${a}?${r}`}function Ge(t){let o=t.collection,n=t.slug,a=`${o}/${n}`,{roles:i}=ze(),r=window.firebase.user.email||"",s=Be(i,r);return e(Ae,{docId:a,readOnly:!s,children:e(lt,{...t,canEdit:s})})}function lt(t){let o=t.canEdit,n=t.collection,a=t.slug,i=`${n}/${a}`;He(i);let r=window.__ROOT_CTX.collections[n],s=X(),l=!!r?.url,[c,m]=T(`root::DocumentPage::previewVisible::${n}`,l),h=M(()=>(window.__ROOT_CTX.checks||[]).some(f=>!f.collections||f.collections.includes(n)),[n]),[_,g]=T("root::DocumentPage::checksVisible",!1),k=P(_);k.current=_;let[w,p]=T("root::DocumentPage::searchVisible",!1),d=P(w);d.current=w;let b=!!(window.__ROOT_CTX.ai||window.__ROOT_CTX.experiments?.ai),[S,z]=T("root::DocumentPage::aiVisible",!1),O=P(S);O.current=S,x(()=>{window.dispatchEvent(new CustomEvent("root:checks-visible",{detail:_}))},[_]),x(()=>{window.dispatchEvent(new CustomEvent("root:search-visible",{detail:w}))},[w]),x(()=>{window.dispatchEvent(new CustomEvent("root:ai-visible",{detail:S}))},[S]);let[F,q]=T("root::DocumentPage::searchPanelWidth",360),[U,K]=y(F),[$,J]=y(!1),Y=P(null);if(x(()=>{let v=()=>{let f=!k.current;g(()=>f),f&&(p(()=>!1),z(()=>!1))};return window.addEventListener("root:toggle-checks",v),()=>window.removeEventListener("root:toggle-checks",v)},[]),x(()=>{let v=()=>{let f=!d.current;p(()=>f),f&&(g(()=>!1),z(()=>!1),requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("root:focus-search"))}))};return window.addEventListener("root:toggle-search",v),()=>window.removeEventListener("root:toggle-search",v)},[]),x(()=>{let v=()=>{let f=!O.current;z(()=>f),f&&(g(()=>!1),p(()=>!1))};return window.addEventListener("root:toggle-ai",v),()=>window.removeEventListener("root:toggle-ai",v)},[]),x(()=>{if(!$)return;let v=A=>{let G=Y.current;if(!G)return;let re=G.getBoundingClientRect(),ce=Math.max(240,Math.min(re.right-A.clientX,800));K(ce)},f=()=>{J(!1),K(A=>(q(()=>A),A))};return window.addEventListener("mousemove",v),window.addEventListener("mouseup",f),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",f)}},[$]),!r)return e("div",{children:"Could not find collection."});let ie=C(()=>{if(!l)return;let v=le(n,a),f=window.open(v,"_blank","noopener,noreferrer");f&&f.focus()},[l,n,a]),Q=C(()=>{o&&s.controller&&s.controller.flush()},[o,s.controller]),W=Le(),u=C(()=>{let v=s.controller?.getData()?.fields||{};W.open({data:v,onSave:f=>{s.controller&&f&&typeof f=="object"&&(s.controller.updateKey("fields",f),s.controller.flush()),W.close()}})},[s.controller]),D=C(()=>{window.dispatchEvent(new CustomEvent("root:toggle-search"))},[]),N=C(()=>{b&&window.dispatchEvent(new CustomEvent("root:toggle-ai"))},[b]),R=C(()=>{z(()=>!1)},[z]);return me([["mod+S",Q],["mod+shift+F",D],["mod+I",N]]),e(Xe,{children:e("div",{className:I("DocumentPage__layout",$&&"DocumentPage__layout--dragging"),ref:Y,children:[e(j,{className:"DocumentPage",localStorageId:"DocumentPage",children:[e(j.Item,{className:I("DocumentPage__side",(!l||!c)&&"DocumentPage__side--expanded"),children:[e("div",{className:"DocumentPage__side__header",children:[e("div",{className:"DocumentPage__side__header__nav",children:[e("a",{href:`/cms/content/${n}`,children:e(E,{className:"DocumentPage__side__header__back",children:e(ge,{size:16})})}),e("div",{className:"DocumentPage__side__header__docId",children:i})]}),e("div",{className:"DocumentPage__side__header__buttons",children:[e(se,{label:"You don't have access to edit this document",condition:!o,children:e(H,{className:"DocumentPage__side__header__saveButton",variant:"filled",color:"dark",size:"xs",compact:!0,leftIcon:e(xe,{size:16}),onClick:()=>Q(),disabled:!o,children:"Save"})}),e(se,{label:"You don't have access to edit this document",condition:!o,children:e(L,{label:"Edit JSON",disabled:!o,children:e(E,{className:"DocumentPage__side__header__editJson",onClick:()=>u(),disabled:!o,children:e(ve,{size:14})})})}),l&&e(V,{children:[e(L,{label:c?"Hide preview":"Show preview",children:e(E,{className:"DocumentPage__side__header__previewToggle",onClick:()=>m(!c),children:c?e(De,{size:16}):e(Ce,{size:16})})}),!c&&e(L,{label:"Open preview in new tab",children:e(E,{className:"DocumentPage__side__header__openNewTab",onClick:ie,children:e(oe,{size:16})})})]})]})]}),e("div",{className:I("DocumentPage__side__editor",(!l||!c)&&!_&&!w&&!S&&"DocumentPage__side__editor--centered"),children:e(Fe,{docId:i})})]}),e(j.Item,{className:I("DocumentPage__main",(!l||!c)&&"DocumentPage__main--hidden"),fluid:!0,children:l&&c&&e(Ge.Preview,{docId:i},i)})]}),h&&_&&e(ut,{docId:i}),w&&e(V,{children:[e("div",{className:"DocumentPage__searchDivider",onMouseDown:()=>J(!0)}),e("div",{className:"DocumentPage__search",style:{flexBasis:`${U}px`},children:e(Ye,{docId:i,autoFocus:!0,onClose:()=>p(()=>!1)})})]}),b&&S&&e(dt,{docId:i,onClose:R})]})})}function dt(t){let[o,n]=T("root::DocumentPage::aiPanelWidth",420),[a,i]=y(o),r=P(null),s=P(a),l=P(),c=M(()=>e(Ue,{variant:"panel",docContext:{docId:t.docId},onClose:t.onClose}),[t.docId,t.onClose]),m=C(()=>{let h=r.current?.parentElement;if(!h)return;s.current=a,h.classList.add("DocumentPage__layout--dragging");let _=w=>{let p=r.current?.parentElement;if(!p)return;let d=p.getBoundingClientRect(),b=Math.max(280,Math.min(d.right-w.clientX,800));s.current=b,i(b)},g=()=>{h.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",k),l.current=void 0},k=()=>{g(),n(()=>s.current)};l.current=g,window.addEventListener("mousemove",_),window.addEventListener("mouseup",k)},[a,n]);return x(()=>()=>l.current?.(),[]),e(V,{children:[e("div",{className:"DocumentPage__aiDivider",ref:r,onMouseDown:m}),e("div",{className:"DocumentPage__ai",style:{flexBasis:`${a}px`},children:c})]})}function ut(t){let[o,n]=T("root::DocumentPage::checksPanelWidth",360),[a,i]=y(o),r=P(null),s=P(a),l=P(),c=M(()=>e(Ke,{docId:t.docId}),[t.docId]),m=C(()=>{let h=r.current?.parentElement;if(!h)return;s.current=a,h.classList.add("DocumentPage__layout--dragging");let _=w=>{let p=r.current?.parentElement;if(!p)return;let d=p.getBoundingClientRect(),b=Math.max(200,Math.min(d.right-w.clientX,800));s.current=b,i(b)},g=()=>{h.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",k),l.current=void 0},k=()=>{g(),n(()=>s.current)};l.current=g,window.addEventListener("mousemove",_),window.addEventListener("mouseup",k)},[a,n]);return x(()=>()=>l.current?.(),[]),e(V,{children:[e("div",{className:"DocumentPage__checksDivider",ref:r,onMouseDown:m}),e("div",{className:"DocumentPage__checks",style:{flexBasis:`${a}px`},children:c})]})}var Qe={mobile:[430,932],tablet:[768,1024],desktop:[1440,800]};function mt(t){let o=new Intl.DisplayNames(["en"],{type:"language"}),a=t.split("_")[0];return`${o.of(a)||t} (${t})`}Ge.Preview=t=>{let o=X();if(o.loading)return null;let[n,a]=t.docId.split("/"),r=window.__ROOT_CTX.collections[n];if(!r)throw new Error(`collection not found: ${n}`);if(!r.url)return null;let s=r.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",l=Re({collectionId:n,slug:a}),c=ae({collectionId:n,slug:a}),m=`${s}${l}`,[h,_]=y(m),[g,k]=T("root::DocumentPage::preview::device",""),[w,p]=T("root::DocumentPage::preview::expandVertically",!1),[d,b]=y({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"}),[S,z]=je("locale",""),O=P(null),F=P(null),q=o.controller.getLocales()||[],U=le(n,a,S),K=M(()=>[{value:"",label:"Select locale"},...q.map(u=>({value:u,label:mt(u)}))],[q]);function $(){if(document.hidden)return;let u=O.current;u.src="about:blank",window.requestAnimationFrame(()=>{u.src!==U?u.src=U:u.contentWindow.location.reload()})}x(()=>{let u=O.current;function D(){let R=u.contentWindow;if(R&&c===l&&!R.location.href.startsWith("about:blank")){let v=R.location.pathname;_(`${s}${v}`)}}u.addEventListener("load",D);let N=o.controller?.onFlush(()=>{$()});return()=>{N(),u.removeEventListener("load",D)}},[]),x(()=>{let u=O.current;u.src=U},[S]);let J=C(u=>{k(D=>{let N=D===u?"":u;return N===""&&p(!1),N})},[k,p]),Y=C(()=>{k(u=>(u&&p(D=>!D),u))},[k,p]),ie=C(()=>{o.controller&&o.controller.flush().then(()=>$())},[o.controller]),Q=C(()=>{let u=le(n,a,S),D=window.open(u,"_blank","noopener,noreferrer");D&&D.focus()},[n,a,S]),W=C(()=>{if(g===""){let B={"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"};b(ee=>ee["--iframe-width"]===B["--iframe-width"]&&ee["--iframe-height"]===B["--iframe-height"]&&ee["--iframe-scale"]===B["--iframe-scale"]?ee:B);return}let u=F.current;if(!u)return;let D=u.getBoundingClientRect(),[N,R]=Qe[g],v=20,f=Math.max(D.width-2*v,0),A=Math.max(D.height-2*v,0),G=f>0&&N>0?f/N:1,re=A>0&&R>0?A/R:1,ce=Math.min(G,re,1),de=Number(ce.toFixed(4))||1,Ze=w?`${A/de}px`:`${R}px`,Z={"--iframe-width":`${N}px`,"--iframe-height":Ze,"--iframe-scale":String(de)};b(B=>B["--iframe-width"]===Z["--iframe-width"]&&B["--iframe-height"]===Z["--iframe-height"]&&B["--iframe-scale"]===Z["--iframe-scale"]?B:Z)},[g,w]);return x(()=>{W();let u=F.current;if(!u)return;let D=0,N=()=>{window.cancelAnimationFrame(D),D=window.requestAnimationFrame(W)},R=new window.ResizeObserver(N);return R.observe(u),window.addEventListener("resize",N),()=>{window.cancelAnimationFrame(D),R.disconnect(),window.removeEventListener("resize",N)}},[W]),e("div",{className:"DocumentPage__main__preview",children:[e(Je,{device:g,expandVertically:w,iframeUrl:h,localeOptions:K,selectedLocale:S,onToggleDevice:J,onToggleExpandVertically:Y,onReloadClick:ie,onOpenNewTab:Q,onLocaleChange:z}),e("div",{className:"DocumentPage__main__previewFrame","data-device":g||"full",ref:F,style:d,children:[e("div",{className:"DocumentPage__main__previewFrame__deviceLabel",style:{display:g?void 0:"none"},children:g?`${g}: ${Qe[g].join("x")}`:""}),e("div",{className:"DocumentPage__main__previewFrame__iframeWrap",children:e("iframe",{ref:O,title:"iframe preview"})})]})]})};export{Ge as DocumentPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as ae}from"./chunk-BZIRGB4W.js";import{a as te,c as ne,e as me}from"./chunk-HHMG665Z.js";import{b as ce,c as O,d as de,f as z}from"./chunk-KYDOSLTO.js";import{a as y}from"./chunk-VMT7JFAM.js";import"./chunk-54DVDYU6.js";import{a as le}from"./chunk-L4RHGQUG.js";import"./chunk-W3HIZQ4Z.js";import{a as I}from"./chunk-PJA7YP4A.js";import{b as ee}from"./chunk-62UWGWON.js";import{a as U}from"./chunk-I6ICVKEC.js";import{a as u}from"./chunk-HLMBCVRX.js";import{f as oe}from"./chunk-ORXEMIQC.js";import{a as ue,b as _e}from"./chunk-FBJURT7Z.js";import{c as se}from"./chunk-5MV6XVGA.js";import{c as V,n as Y,p as Q,q as Z}from"./chunk-EGEB6N4J.js";import{f as w}from"./chunk-AL3TN2KI.js";import{Aa as A,Da as q,Ha as e,Pc as ie,U as L,Uc as re,W as $,a as g,c as B,ca as J,e as W,ea as v,g as C,j as T,oa as F,qa as K,ta as X,va as G}from"./chunk-NZHF733K.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";T();T();var be={ADMIN:4,EDITOR:3,CONTRIBUTOR:2,VIEWER:1};function ge(o){return be[o]??0}function Se(o,s){return ge(o)>=ge(s)?o:s}function H(o,s,a){let t=o[s];o[s]=t?Se(t,a):a}function pe(o,s={}){let a={...s},t={};for(let n of o){let d=(n.users||[]).filter(Boolean);if(d.length===0)continue;let _=(n.collections||[]).filter(Boolean);if(_.length===0)for(let c of d)H(a,c,n.role);else{for(let c of d)H(a,c,"VIEWER");for(let c of _){t[c]||(t[c]={});for(let p of d)H(t[c],p,n.role)}}}return{projectRoles:a,collectionRoles:t}}function fe(o={}){return{id:o.id||`g_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,name:o.name||"",role:o.role||"VIEWER",collections:o.collections?[...o.collections]:[],users:o.users?[...o.users]:[]}}T();function k(o){let s=o.size||28,[a,t]=g(!1),n=o.profile?.photoURL||"",d=o.profile?.displayName||o.email,_=w("EmailAvatar",o.className),c={width:s,height:s};return n&&!a?e("img",{className:_,style:c,src:n,alt:d,onError:()=>t(!0)}):e("svg",{className:_,style:c,viewBox:"0 0 28 28",role:"img","aria-label":d,children:[e("circle",{cx:"14",cy:"14",r:"14",fill:de(o.email)}),e("text",{x:"14",y:"14",textAnchor:"middle",dominantBaseline:"central",fill:"#fff",fontSize:"13",fontWeight:"600",children:ce(o.email)})]})}var ye=[{value:"ADMIN",label:"ADMIN"},{value:"EDITOR",label:"EDITOR"},{value:"CONTRIBUTOR",label:"CONTRIBUTOR"},{value:"VIEWER",label:"VIEWER"}];function xe(o){let{groups:s,onChange:a,collections:t,disabled:n}=o,d=C(()=>t.map(l=>({value:l,label:l})),[t]),[_,c]=g({});function p(l,i){a(s.map(m=>m.id===l?i(m):m))}function f(l){a(s.filter(i=>i.id!==l))}function P(){let l=s.length;a([...s,fe({name:"New group"})]),c(i=>({...i,[l]:!0}))}return e("div",{className:w(o.className,"PermissionGroupsBox"),children:[s.length===0?e("div",{className:"PermissionGroupsBox__empty",children:e(u,{size:"body-sm",weight:"semi-bold",color:"gray",children:"No permission groups yet. Create one to organize users by role and optionally scope access to specific collections."})}):e(L,{className:"PermissionGroupsBox__accordion",offsetIcon:!1,multiple:!0,state:_,onChange:c,children:s.map(l=>e(L.Item,{label:e("div",{className:"PermissionGroupsBox__trigger",children:[e("span",{className:"PermissionGroupsBox__trigger__name",children:l.name||"Untitled group"}),e(J,{color:"gray",radius:"sm",size:"xs",variant:"light",className:"PermissionGroupsBox__trigger__badge",children:[l.users.length," ",l.users.length===1?"user":"users"]})]}),children:e(Re,{group:l,collectionOptions:d,disabled:n,onChange:i=>p(l.id,()=>i),onDelete:()=>f(l.id)})},l.id))}),e("div",{className:"PermissionGroupsBox__addGroup",children:e(v,{variant:"default",size:"xs",radius:0,disabled:n,onClick:P,children:"+ Add group"})})]})}function Re(o){let{group:s,collectionOptions:a,disabled:t}=o,[n,d]=g(""),_=s.users.filter(r=>!O(r)),{profiles:c}=z(_);function p(r){o.onChange({...s,name:r})}function f(r){o.onChange({...s,role:r})}function P(r){o.onChange({...s,collections:r})}function l(r){let x=r.trim();if(!x||s.users.includes(x)){d("");return}o.onChange({...s,users:[...s.users,x]}),d("")}function i(r){o.onChange({...s,users:s.users.filter(x=>x!==r)})}function m(){window.confirm(`Delete the "${s.name||"Untitled group"}" group? This will remove its role assignments on next save.`)&&o.onDelete()}return e("div",{className:"PermissionGroupsBox__editor",children:[e("div",{className:"PermissionGroupsBox__editor__row",children:[e(G,{className:"PermissionGroupsBox__editor__name",label:"Group name",placeholder:"e.g. Blog Post Editors",value:s.name,radius:0,size:"xs",disabled:t,onChange:r=>p(r.target.value)}),e(A,{className:"PermissionGroupsBox__editor__role",label:"Role",data:ye,value:s.role,radius:0,size:"xs",disabled:t,onChange:r=>f(r)})]}),e(X,{className:"PermissionGroupsBox__editor__collections",label:"Collections",description:"Leave empty to apply project-wide. Otherwise restrict the group's role to the selected collections.",data:a,value:s.collections,radius:0,size:"xs",searchable:!0,clearable:!0,placeholder:"All collections (project-wide)",disabled:t,onChange:r=>P(r),dropdownComponent:"div"}),e("div",{className:"PermissionGroupsBox__editor__users",children:[e(u,{size:"body-sm",weight:"semi-bold",children:"Users"}),e("form",{className:"PermissionGroupsBox__editor__addUser",onSubmit:r=>{r.preventDefault(),l(n)},children:[e(G,{className:"PermissionGroupsBox__editor__addUser__email",placeholder:"grogu@example.com",type:"email",value:n,onChange:r=>d(r.target.value),radius:0,size:"xs",disabled:t}),e(v,{size:"xs",radius:0,color:"dark",type:"submit",disabled:t||!n.trim(),children:"Add user"})]}),s.users.length>0&&e("ul",{className:"PermissionGroupsBox__editor__userList",children:s.users.map(r=>{let x=c.get(r.toLowerCase())||null;return e("li",{className:"PermissionGroupsBox__editor__userItem",children:[e(k,{className:"PermissionGroupsBox__editor__userItem__avatar",email:r,profile:x,size:24}),e("span",{className:"PermissionGroupsBox__editor__userItem__email",children:r}),e($,{size:"sm",variant:"transparent",disabled:t,onClick:()=>i(r),title:`Remove ${r}`,children:e(re,{size:14})})]},r)})})]}),e("div",{className:"PermissionGroupsBox__editor__footer",children:e(v,{variant:"subtle",size:"xs",color:"red",compact:!0,disabled:t,leftIcon:e(ie,{size:14}),onClick:m,children:"Delete group"})})]})}T();function D(o){let{roles:s,onChange:a,currentUserIsAdmin:t}=o,[n,d]=g(""),_=Object.keys(s).filter(i=>!O(i)),{profiles:c}=z(_);function p(i,m){a({...s,[i]:m})}function f(i){let m={...s};delete m[i],a(m)}function P(i){let m=i.trim();d(""),!(!m||m in s)&&a({...s,[m]:"EDITOR"})}let l=se(Object.keys(s).map(i=>({email:i,role:s[i],profile:c.get(i.toLowerCase())||null})),"email");return e("div",{className:w(o.className,"ShareBox"),children:[e("form",{className:"ShareBox__addUser",onSubmit:i=>{i.preventDefault(),P(n)},children:[e(G,{className:"ShareBox__addUser__email",placeholder:"grogu@example.com",type:"email",value:n,onChange:i=>d(i.target.value),radius:0,size:"xs",disabled:!t}),e(v,{className:"ShareBox__addUser__button",size:"xs",radius:0,color:"dark",type:"submit",disabled:!t,children:"Add user"})]}),e("div",{className:"ShareBox__users",children:l.map(i=>e(D.User,{...i,currentUserIsAdmin:t,onRoleChange:p,onRemove:f},i.email))})]})}D.User=o=>{let s=o.email===window.firebase.user.email;return e("div",{className:"ShareBox__user",children:[e(k,{className:"ShareBox__user__avatar",email:o.email,profile:o.profile,size:24}),e(u,{className:"ShareBox__user__email",size:"body-sm",weight:"semi-bold",color:"gray",children:[o.email,s&&" (you)"]}),e("div",{className:"ShareBox__user__roleSelect",children:e(A,{data:[{value:"ADMIN",label:"ADMIN"},{value:"EDITOR",label:"EDITOR"},{value:"CONTRIBUTOR",label:"CONTRIBUTOR"},{value:"VIEWER",label:"VIEWER"},{value:"REMOVE",label:"REMOVE"}],value:o.role,radius:0,size:"xs",disabled:s||!o.currentUserIsAdmin,onChange:a=>{a==="REMOVE"?o.onRemove(o.email):o.onRoleChange(o.email,a)}})})]})};function we(o){if(!o)return"never";let s=Date.now()-o;return s<6e4?"just now":s<60*6e4?`${Math.floor(s/6e4)} min ago`:s<1440*6e4?`${Math.floor(s/(60*6e4))} hr ago`:new Date(o).toLocaleString()}function he(o){let s=window.firebase?.user?.email;if(!s)return!1;if(o[s]==="ADMIN")return!0;let a=s.split("@").at(-1);return!!(a&&o[`*@${a}`]==="ADMIN")}function Ne(){let o=ae(),[s,a]=g(!1),[t,n]=g(!1),[d,_]=g(!1),c=W(null);function p(){c.current!==null&&(window.clearInterval(c.current),c.current=null),n(!1),_(!1)}B(()=>p,[]),B(()=>{t&&o.running&&_(!0)},[t,o.running]);async function f(x){if(!(s||t)){a(!0);try{let S=await fetch("/cms/api/search.rebuild",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:x})});if(!S.ok){let j=await S.text().catch(()=>"");throw new Error(`HTTP ${S.status}: ${j||"rebuild failed"}`)}U({title:"Search index",message:x?"Full rebuild started.":"Incremental rebuild started.",color:"blue",autoClose:4e3}),n(!0),c.current=window.setInterval(()=>{o.refresh()},2e3),window.setTimeout(p,10*6e4)}catch(S){U({title:"Error",message:S?.message||String(S),color:"red",autoClose:!1})}finally{a(!1)}}}B(()=>{t&&d&&!o.running&&(p(),U({title:"Search index",message:"Rebuild complete.",color:"green",autoClose:3e3}))},[t,d,o.running]);let P=o.status.lastRun,l=o.status.docCount,i=o.status.fieldCount,m=o.status.shardCount,r=o.running||s;return e("div",{className:"SettingsPage__section",children:[e("div",{className:"SettingsPage__section__left",children:[e(y,{className:"SettingsPage__section__left__title",children:"Site Admin"}),e(u,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:"Project-wide administrative actions. Only admins see this section."})})]}),e(I,{className:"SettingsPage__section__right",children:e("div",{className:"SettingsPage__section__setting",children:[e(u,{size:"body",weight:"semi-bold",children:"Search index"}),e(u,{size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:"Powers the Cmd+K global search. Rebuilds run automatically on a schedule; trigger a manual rebuild here if you want immediate results (e.g. after a schema change)."})}),e("div",{className:"SettingsPage__siteAdmin__searchStats",children:[e("div",{children:[e("strong",{children:"Last indexed:"})," ",we(P)]}),e("div",{children:[e("strong",{children:"Indexed docs:"})," ",l.toLocaleString()]}),e("div",{children:[e("strong",{children:"Indexed fields:"})," ",i.toLocaleString()]}),e("div",{children:[e("strong",{children:"Shards:"})," ",m]})]}),e("div",{className:"SettingsPage__siteAdmin__searchButtons",children:[e(v,{variant:"default",size:"xs",compact:!0,loading:r,onClick:()=>f(!1),children:"Rebuild incremental"}),e(v,{variant:"default",size:"xs",compact:!0,loading:r,onClick:()=>{window.confirm("Force a full rebuild? This wipes the existing index and reindexes every doc from scratch.")&&f(!0)},children:"Force full rebuild"})]})]})})]})}function Be(o,s){return JSON.stringify(o)===JSON.stringify(s)}function Ge(){let o=window.__ROOT_CTX.rootConfig.projectId||"default",s=window.__ROOT_CTX.collections||{},a=C(()=>Object.keys(s).sort(),[s]),t=window.firebase.db,n=V(t,"Projects",o),[d,_]=g(!0),[c,p]=g(!1),[f,P]=g({roles:{},permissionGroups:[]}),[l,i]=g({roles:{},permissionGroups:[]});B(()=>{Y(n).then(h=>{let b=h.data()||{},N={roles:b.roles||{},permissionGroups:b.permissionGroups||[]};P(N),i({roles:{...N.roles},permissionGroups:N.permissionGroups.map(E=>({...E}))}),_(!1)})},[]);let m=he(f.roles),r=!Be(f,l);function x(h){i(b=>({...b,roles:h}))}function S(h){i(b=>({...b,permissionGroups:h}))}function j(){i({roles:{...f.roles},permissionGroups:f.permissionGroups.map(h=>({...h}))})}async function ve(){c||!r||(p(!0),await ee(async()=>{let{projectRoles:h,collectionRoles:b}=pe(l.permissionGroups,l.roles);await Z(n,{roles:h,permissionGroups:l.permissionGroups});let N=f.permissionGroups.flatMap(R=>R.collections||[]),E=new Set([...Object.keys(b),...N]);for(let R of E){let Pe=V(t,"Projects",o,"Collections",R);await Q(Pe,{roles:b[R]||{}},{merge:!0})}let M={roles:h,permissionGroups:l.permissionGroups};P(M),i({roles:{...M.roles},permissionGroups:M.permissionGroups.map(R=>({...R}))}),oe("acls.save_groups",{metadata:{groupCount:l.permissionGroups.length,userCount:Object.keys(h).length,collections:Array.from(E)}}),U({title:"Saved",message:"Sharing settings updated.",color:"green",autoClose:3e3})}),p(!1))}return e("div",{className:"SettingsPage__section SettingsPage__section__users",children:[e("div",{className:"SettingsPage__section__left",children:[e(y,{className:"SettingsPage__section__left__title",children:"Share"}),e(u,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:[e("p",{children:"Share access to the CMS. To share with everyone in a domain, use *@example.com."}),e("ul",{children:[e("li",{children:"VIEWER: view docs but not edit"}),e("li",{children:"CONTRIBUTOR: view and edit docs, but not publish"}),e("li",{children:"EDITOR: view, edit, and publish docs"}),e("li",{children:"ADMIN: all of the above and change sharing settings"})]}),e("p",{children:["Use ",e("strong",{children:"groups"})," to manage many users at once and optionally scope a role to specific collections."]})]})]}),e(I,{className:"SettingsPage__section__right",children:e("div",{className:"SettingsPage__share",children:[e(K,{visible:d,loaderProps:{color:"gray",size:"xl"}}),e("div",{className:"SettingsPage__share__subsection",children:[e(y,{className:"SettingsPage__section__right__title",size:"h3",children:"Users"}),e(D,{className:"SettingsPage__section__users__sharebox",roles:l.roles,onChange:x,currentUserIsAdmin:m})]}),e("div",{className:"SettingsPage__share__subsection",children:[e(y,{className:"SettingsPage__section__right__title",size:"h3",children:"Groups"}),e(xe,{groups:l.permissionGroups,onChange:S,collections:a,disabled:!m})]}),e("div",{className:"SettingsPage__share__saveBar",children:[e(u,{size:"body-sm",weight:"semi-bold",color:"gray",children:r?"You have unsaved changes.":"All changes saved."}),e("div",{className:"SettingsPage__share__saveBar__actions",children:[e(v,{variant:"default",size:"xs",radius:0,disabled:!r||c,onClick:j,children:"Discard"}),e(v,{size:"xs",radius:0,color:"dark",loading:c,disabled:!r||!m,onClick:ve,children:"Save changes"})]})]})]})})]})}function Do(){ue("Settings");let o=me(),s=ne(),a=le(),t=!a.loading&&he(a.roles);return e(_e,{children:e("div",{className:"SettingsPage",children:[e(Ge,{}),e("div",{className:"SettingsPage__section",children:[e("div",{className:"SettingsPage__section__left",children:[e(y,{className:"SettingsPage__section__left__title",children:"Site Settings"}),e(u,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:"These settings apply to the project. Only admins can change them."})})]}),e(I,{className:"SettingsPage__section__right",children:te.map(n=>e("div",{className:"SettingsPage__section__setting",children:[e(u,{size:"body",weight:"semi-bold",children:n.name}),e(u,{size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:n.description})}),e(F,{autosize:!0,minRows:2,maxRows:4,value:s.settings[n.key]||"",placeholder:n.placeholder,onChange:d=>s.setSettings(n.key,d.currentTarget.value)}),n.ui&&e("div",{children:n.ui(s.settings[n.key])})]},n.key))})]}),t&&e(Ne,{}),e("div",{className:"SettingsPage__section",children:[e("div",{className:"SettingsPage__section__left",children:[e(y,{className:"SettingsPage__section__left__title",children:"User Preferences"}),e(u,{className:"SettingsPage__section__body",size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:"These settings are for you only."})})]}),e(I,{className:"SettingsPage__section__right",children:e("div",{className:"SettingsPage__section__userPref",children:[e("div",{className:"SettingsPage__section__userPref__description",children:[e(u,{className:"SettingsPage__section__userPref__description__title",size:"body",weight:"semi-bold",children:"Enable EditorJS Editor (legacy)"}),e(u,{className:"SettingsPage__section__userPref__description__body",size:"body-sm",weight:"semi-bold",color:"gray",children:e("p",{children:["Replaces the"," ",e("a",{href:"https://lexical.dev/",target:"_blank",rel:"noopener noreferrer nofollow",children:"Lexical"})," ","(default) rich text editor with the"," ",e("a",{href:"https://editorjs.io/",target:"_blank",rel:"noopener noreferrer nofollow",children:"EditorJS"})," ","(legacy) version."]})})]}),e("div",{className:"SettingsPage__section__userPref__input",children:e(q,{color:"dark",checked:o.preferences.EnableEditorJSEditor,onChange:n=>{let d=n.currentTarget.checked;o.setPreference("EnableEditorJSEditor",d)}})})]})})]})]})})}export{Do as SettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as ie}from"./chunk-54DVDYU6.js";import{a as ee,b as M,c as D}from"./chunk-JDW4UORS.js";import{a as se}from"./chunk-YDO2EDVY.js";import{c as oe,s as ne}from"./chunk-AFWBSIPL.js";import{b as te}from"./chunk-62UWGWON.js";import{a as $}from"./chunk-I6ICVKEC.js";import{a as j}from"./chunk-HLMBCVRX.js";import{a as L}from"./chunk-5MV6XVGA.js";import{b as K,f as U,g as _,i as y,o as Y}from"./chunk-EGEB6N4J.js";import{d as Z,f as re}from"./chunk-AL3TN2KI.js";import{A as G,Aa as J,Ha as d,a as p,c as w,e as C,ea as P,g as B,h as R,i as W,j as T,sa as Q,va as q}from"./chunk-NZHF733K.js";import{j as X,k as pe}from"./chunk-KUCVLANF.js";function z(e){let t=window.__ROOT_CTX.collections[e.collectionId];if(!t)throw new Error(`collection not found: ${e.collectionId}`);if(!t.url)return"";let n=t.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",s=he(e);return`${n}${s}`}function he(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:s}=e,r=o[t];if(!r)throw new Error(`collection not found: ${t}`);if(!r.url)return"";let c=window.__ROOT_CTX.rootConfig,g=c.base||"/",u="/[base]/[path]";s&&(u=c.i18n.urlFormat||"/[locale]/[base]/[path]");let m="",a=r?.url;if(a)if(n){let l=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");l==="/index"&&(l="/"),m=l}else m=a;return ce(u,{base:g,path:m,locale:s||"",slug:n})}function we(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:s}=e,r=o[t];if(!r)throw new Error(`collection not found: ${t}`);let c=window.__ROOT_CTX.rootConfig,g=c.base||"/",u="/[base]/[path]";s&&(u=c.i18n.urlFormat||"/[locale]/[base]/[path]");let m="",a=r?.previewUrl||r?.url;if(a)if(n){let l=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");l==="/index"&&(l="/"),m=l}else m=a;return ce(u,{base:g,path:m,locale:s||"",slug:n})}function ce(e,o){let t=e.replaceAll(/\[\[?(\.\.\.)?([\w\-_]*)\]?\]/g,(n,s,r)=>o[r]??n);return Se(t,{trailingSlash:window.__ROOT_CTX.rootConfig.server.trailingSlash})}function Se(e,o){return e=e.replace(/\/+/g,"/"),o?.trailingSlash===!1&&e!=="/"&&e.endsWith("/")&&(e=e.replace(/\/*$/g,"")),(e.endsWith("/index")||e.endsWith("/index/"))&&(e=e.slice(0,-6)),e.startsWith("/")||(e=`/${e}`),o?.trailingSlash&&!e.endsWith("/")&&(e=`${e}/`),e}T();function Ne(e,o){let[t,n]=p([]),[s,r]=p(!0),g=ie().db,u=window.__ROOT_CTX.rootConfig.projectId||"default",m=o.includeArchived??!1,a=async()=>{r(!0);let l=K(g,"Projects",u,"Collections",e,"Drafts"),i=l,f=o.orderBy;if(f==="modifiedAt")i=_(l,y("sys.modifiedAt","desc"));else if(f==="newest")i=_(l,y("sys.createdAt","desc"));else if(f==="oldest")i=_(l,y("sys.createdAt"));else if(f==="slug")i=_(l,y(U()));else if(f==="slugDesc")i=_(l,y(U(),"desc"));else{let h=window.__ROOT_CTX.collections[e]?.sortOptions?.find(v=>v.id===f);h&&(i=h.direction==="desc"?_(l,y(h.field,"desc")):_(l,y(h.field)))}await te(async()=>{let S=await Y(i),h=[];S.docs.forEach(v=>{let E=v.data(),b=v.id,x=`${e}/${b}`,O={...E,id:x,slug:b};oe(x,O),!(!m&&O?.sys?.archivedAt)&&h.push(O)}),n(h)}),r(!1)};return w(()=>{r(!0),a()},[e,o.orderBy,m]),[s,a,t]}pe();T();var N={CONNECTED:"connected",SCHEMA_CHANGED:"schemaChanged"};function le(e){let t=new URLSearchParams(window.location.search).get("e");return t?t.split(",").includes(e):!1}var Ee="/cms/api/sse.connect",A=le("EnableVerboseLogging"),ae=window.location.hostname==="localhost",F=class{constructor(){this.map=new Map}on(o,t){return this.map.has(o)||this.map.set(o,new Set),this.map.get(o).add(t),()=>{this.map.get(o)?.delete(t)}}emit(o,t,n){this.map.get(o)?.forEach(s=>s(t,n)),this.map.get("*")?.forEach(s=>s({type:o,data:t},n))}},de=X(null);function je(e){let t=C(new F).current,n=C(null),s=C(!1),r=C({attempt:0,timer:0}),c=C(""),g=()=>{n.current&&(n.current.close(),n.current=null)},u=R(()=>{A&&console.log("[sse] connecting..."),g();let a=new EventSource(Ee);n.current=a,a.addEventListener(N.CONNECTED,i=>{if(A&&console.log("[sse] connected"),s.current=!1,r.current.attempt=0,ae){let S=ue(i.data)?.serverVersion||"";c.current?c.current!==S&&(console.log(`server version changed: ${c.current} -> ${S}`),console.log("reloading..."),window.location.reload()):c.current=S}});let l=i=>{if(!i||!i.type)return;let f=ue(i.data);A&&console.log("[sse] event:",i.type,f),t.emit(i.type,f,i)};Object.values(N).forEach(i=>{a.addEventListener(i,l)}),a.addEventListener("error",()=>{A&&console.log("[sse] disconnected"),a.readyState===EventSource.CLOSED&&!s.current&&(s.current=!0,(()=>{let f=++r.current.attempt,S=Math.min(3e4,Math.pow(2,f)*500),h=Math.random()*.3*S,v=S+h;window.clearTimeout(r.current.timer),r.current.timer=window.setTimeout(()=>{s.current=!1,u()},v)})())})},[t]);w(()=>{if(!ae)return;u();let a=()=>{document.visibilityState==="visible"&&n.current?.readyState!==EventSource.OPEN&&u()};return document.addEventListener("visibilitychange",a),()=>{document.removeEventListener("visibilitychange",a),window.clearTimeout(r.current.timer),g()}},[u]);let m=B(()=>({emitter:t}),[t]);return d(de.Provider,{value:m,children:e.children})}function ue(e){try{return JSON.parse(e)}catch{return e}}function fe(e,o){let t=W(de);if(!t)throw new Error("useSSE() must be used within an <SSEProvider>");let n=C(o);w(()=>{n.current=o},[o]),w(()=>t.emitter.on(e,(s,r)=>n.current(s,r)),[t,e])}T();T();function ge(e){let[o,t]=p(!0),[n,s]=p(null),r=R(async()=>{try{let c=await se(e);s(c)}catch(c){console.error(c),$({title:`Failed to load collection: ${e}`,message:String(c),color:"red",autoClose:!1})}t(!1)},[e]);return w(()=>{r()},[e]),fe(N.SCHEMA_CHANGED,async c=>{await r();let g=c.file?`Applied updates from changes to ${c.file}.`:"Applied updates from changes to a .schema.ts file.";$({title:"Updated schema!",message:g})}),{loading:o,schema:n}}function H(e){let o={_array:[]};return e.forEach(t=>{let n=Ce();o._array.push(n),o[n]=t}),o}function Ce(){let e=[],o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=o.length;for(let n=0;n<6;n++)e.push(o.charAt(Math.floor(Math.random()*t)));return e.join("")}function V(e){let o={};return e.fields.forEach(t=>{t.id&&(t.type==="array"&&t.default&&Array.isArray(t.default)?o[t.id]=H(t.default):t.default?o[t.id]=t.default:t.type==="object"&&(o[t.id]=V(t)))}),o}function k(e,o,t){let n={...o};return e.fields.forEach(s=>{if(!s.id)return;let r=n[s.id];if(r!=null){if(s.type==="array"&&Array.isArray(r)){let c=r.map(g=>ve(s.of,g,t));n[s.id]=H(c)}else if(s.type==="object"&&L(r))n[s.id]=k(s,r,t);else if(s.type==="oneof"&&L(r)&&typeof r._type=="string"&&t){let c=t[r._type];c&&(n[s.id]=k(c,r,t))}}}),n}function ve(e,o,t){if(!L(o))return o;if(e.type==="object")return k(e,o,t);if(e.type==="oneof"&&typeof o._type=="string"&&t){let n=t[o._type];if(n)return k(n,o,t)}return o}T();function me(e){let[o,t]=p(e.collectionId||""),n=C(null),[s,r]=p(""),c=window.__ROOT_CTX.collections[o],g=[];e.collectionId&&e.collectionDisabled?g.push({value:e.collectionId,label:e.collectionId}):Object.keys(window.__ROOT_CTX.collections).forEach(i=>{g.push({value:i,label:i})});let u="",m="";if(c?.url){if(s){let i=D(s),f=c?.slugRegex;ee(i,f)?u=z({collectionId:o,slug:i}):m=M(i,f)}else u=z({collectionId:o,slug:"[slug]"});u.endsWith("/index")&&(u=u.replace(/\/index$/,"/"))}function a(i){t(i),e.onChange&&e.onChange({collectionId:i,slug:s})}function l(i){r(i),e.onChange&&e.onChange({collectionId:o,slug:i})}return d("div",{className:re(e.className,"SlugInput"),children:[d("div",{className:"SlugInput__inputs",children:[d(J,{className:"SlugInput__collection",placeholder:"Collection",size:"xs",data:g,onChange:i=>a(i),value:o,disabled:!!e.collectionDisabled}),d("div",{className:"SlugInput__divider",children:"/"}),d(q,{className:"SlugInput__slug",name:"slug",ref:n,value:s,onChange:i=>{l(i.currentTarget.value)},placeholder:"slug",autoComplete:"off",size:"xs"})]}),u&&d(j,{className:"SlugInput__urlHelp",size:"body-sm",children:u}),m&&d(j,{className:"SlugInput__slugError",size:"body-sm",children:m})]})}function wt(e){let{route:o}=Z(),[t,n]=p(""),[s,r]=p(!1),[c,g]=p(""),[u,m]=p(""),a=G(),l=e.collection,i=window.__ROOT_CTX.collections[l];if(!i)throw new Error(`collection not found: ${l}`);let f=ge(l);function S(E){let b=D(E);return b?M(b,i.slugRegex):""}function h(){e.onClose&&e.onClose()}async function v(E){if(E.preventDefault(),r(!0),g(""),S(t)){r(!1);return}let x=D(t),O=`${l}/${x}`;try{let I={};!f.loading&&f.schema&&(I=await V(f.schema)),await ne(O,{fields:I})}catch(I){m(String(I)),r(!1);return}r(!1),e.skipNavigation?h():o(`/cms/content/${e.collection}/${x}`)}return d(Q,{className:"NewDocModal",opened:e.opened||!1,onClose:()=>h(),title:"New",size:"500px",overlayColor:a.colorScheme==="dark"?a.colors.dark[9]:a.colors.gray[2],children:[d("div",{className:"NewDocModal__body",children:"Enter a slug for the new doc. The slug is the ID of the page and is what's used in the URL. Use only lowercase letters, numbers, and dashes."}),d("form",{onSubmit:E=>v(E),children:[d(me,{className:"NewDocModal__slug",collectionId:l,onChange:E=>{n(E.slug),g(S(E.slug)),m("")}}),u&&d("div",{className:"NewDocModal__slugError",children:u}),d("div",{className:"NewDocModal__buttons",children:[d(P,{variant:"outline",onClick:()=>h(),type:"button",size:"xs",color:"dark",children:"Cancel"}),d(P,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:f.loading||s,disabled:!!c||!!u,children:"Submit"})]})]})]})}export{z as a,he as b,we as c,me as d,Ne as e,je as f,ge as g,V as h,k as i,wt as j};
|
|
File without changes
|