PageSourceSearch

https://rightcount.org/assets/PostEditor-DEs7WL9r.js

js rightcount.org collected 2026-10-06 09:02:37 UTC 10,077 bytes, 7 lines download raw bytes

1import{d as E,y as I,z as P,r as m,s as g,j as e,a as h}from"./index-EYSU2zfc.js";import{B as f}from"./button-XRX96e6V.js";import{I as x}from"./input-DGa7jSEt.js";import{S as A,T as b}from"./textarea-0DY-gi8P.js";import{L as i}from"./label-tsTKFyPL.js";import{t as L}from"./topicLabels-l8HuCwwA.js";import{I as T}from"./ImageUpload-D4XtlDqG.js";import{M as R}from"./MediaPickerDialog-B2mjHD1J.js";import{A as $}from"./arrow-left-CEZrjOiy.js";import{E as O}from"./eye-ezEedJgH.js";import{E as M}from"./external-link-C8gRhcXN.js";import{I as D}from"./image-DMSIq4Pv.js";import"./loader-circle-BDXtkFMj.js";import"./upload-Bqzp_cAQ.js";import"./dialog-DDaMFRmf.js";import"./search-BKecaBNn.js";import"./check-DNmAqmzE.js";import"./trash-2-DhgoRVPP.js";const q=["Article","Research","Op-Ed","Press Release","In the News"],z=["","Arizona","Georgia","Michigan","Nevada","North Carolina","Pennsylvania","Wisconsin"],F=Object.entries(L).map(([d,a])=>({value:d,label:a})),U=d=>{let a=d.trim().toLowerCase();return a?(a=a.replace(/^https?:\/\/[^/]+/,""),a.startsWith("/")||(a="/"+a),a=a.replace(/\/+$/,""),a||null):null},ne=()=>{const{id:d}=E(),a=d==="new",j=I(),{user:p}=P(),[s,l]=m.useState({title:"",slug:"",excerpt:"",content:"",category:"Article",state:"",topics:[],featured_image:"",original_url:"",published:!1,published_at:"",aliases:""}),[v,N]=m.useState(!1),w=m.useRef(null);m.useEffect(()=>{!a&&d&&g.from("news_posts").select("*").eq("id",d).single().then(({data:t})=>{t&&l({title:t.title||"",slug:t.slug||"",excerpt:t.excerpt||"",content:t.content||"",category:t.category||"Article",state:t.state||"",topics:t.topics||[],featured_image:t.featured_image||"",original_url:t.original_url||"",published:t.published||!1,published_at:t.published_at||"",aliases:(t.aliases||[]).join(`
2`)})})},[d,a]);const _=t=>t.toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").slice(0,80),y=t=>{l(r=>({...r,topics:r.topics.includes(t)?r.topics.filter(o=>o!==t):[...r.topics,t]}))},S=async()=>{if(!s.title.trim()){h.error("Title is required");return}N(!0);const t=s.slug||_(s.title),r=Array.from(new Set(s.aliases.split(/[\n,]/).map(U).filter(c=>!!c))),o={title:s.title,slug:t,excerpt:s.excerpt||null,content:s.content||null,category:s.category,state:s.state||null,topics:s.topics.length>0?s.topics:null,featured_image:s.featured_image||null,original_url:s.original_url||null,aliases:r,published:s.published,published_at:s.published_at?s.published_at:s.published?new Date().toISOString():null,...a?{created_by:p==null?void 0:p.id}:{}};let n;a?n=(await g.from("news_posts").insert(o)).error:n=(await g.from("news_posts").update(o).eq("id",d)).error,n?h.error(n.message):(h.success(a?"Post created!":"Post saved!"),j("/admin/posts")),N(!1)},k="w-full rounded-lg border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent/20";return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>j("/admin/posts"),className:"flex items-center gap-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx($,{className:"h-4 w-4"})," Back to Posts"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!a&&s.slug&&e.jsxs("a",{href:`/news/${s.slug}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-2 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[e.jsx(O,{className:"h-3.5 w-3.5"})," Preview",e.jsx(M,{className:"h-3 w-3"})]}),e.jsx(f,{variant:"outline",onClick:()=>l(t=>({...t,published:!t.published,published_at:t.published?t.published_at:t.published_at||new Date().toISOString()})),children:s.published?"Unpublish":"Publish"}),e.jsxs(f,{onClick:S,disabled:v,children:[e.jsx(A,{className:"mr-2 h-4 w-4"}),v?"Saving...":"Save"]})]})]}),e.jsx("h1",{className:"mt-6 font-display text-2xl font-bold text-foreground",children:a?"New Post":"Edit Post"}),e.jsxs("div",{className:"mt-6 grid gap-8 lg:grid-cols-3",children:[e.jsx("div",{className:"space-y-6 lg:col-span-2",children:e.jsxs("div",{className:"rounded-xl border border-border bg-background p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx(i,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Title"}),e.jsx(x,{value:s.title,onChange:t=>{l(r=>({...r,title:t.target.value,slug:a?_(t.target.value):r.slug}))},className:"mt-1.5 text-lg font-semibold",placeholder:"Enter post title..."})]}),e.jsxs("div",{children:[e.jsx(i,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Slug"}),e.jsx(x,{value:s.slug,onChange:t=>l(r=>({...r,slug:t.target.value})),className:"mt-1.5 font-mono text-sm",placeholder:"auto-generated-from-title"})]}),e.jsxs("div",{children:[e.jsx(i,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Excerpt"}),e.jsx(b,{value:s.excerpt,onChange:t=>l(r=>({...r,excerpt:t.target.value})),rows:3,className:"mt-1.5",placeholder:"Brief summary of the post..."})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(i,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Content"}),e.jsx(R,{mode:"pick",defaultFolder:"posts/inline",onSelect:t=>{const r=w.current,o=`
3
4![](${t})
5
6`;if(r){const n=r.selectionStart??s.content.length,c=r.selectionEnd??s.content.length,C=s.content.slice(0,n)+o+s.content.slice(c);l(u=>({...u,content:C})),requestAnimationFrame(()=>{r.focus();const u=n+o.length;r.setSelectionRange(u,u)})}else l(n=>({...n,content:n.content+o}))},trigger:e.jsxs(f,{type:"button",variant:"outline",size:"sm",children:[e.jsx(D,{className:"mr-1.5 h-3.5 w-3.5"})," Insert Image"]})})]}),e.jsx(b,{ref:w,value:s.content,onChange:t=>l(r=>({...r,content:t.target.value})),rows:16,className:"mt-1.5 font-mono text-sm leading-relaxed",placeholder:"Full article content. Markdown and HTML supported (headings, lists, > blockquotes, tables, images)."}),e.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground",children:"Supports Markdown (**bold**, # headings, > blockquote, lists, tables) and inline HTML."})]})]})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"rounded-xl border border-border bg-background p-5",children:[e.jsx("h3",{className:"mb-3 text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Status"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${s.published?"bg-emerald-500":"bg-amber-500"}`}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:s.published?"Published":"Draft"})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx(i,{className:"text-xs text-muted-foreground",children:"Publish Date"}),e.jsx(x,{type:"datetime-local",value:s.published_at?(()=>{const t=new Date(s.published_at),r=o=>String(o).padStart(2,"0");return`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())}T${r(t.getHours())}:${r(t.getMinutes())}`}
6)():"",onChange:t=>l(r=>({...r,published_at:t.target.value?new Date(t.target.value).toISOString():""})),className:"mt-1.5"}),e.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground",children:"Set or backdate. Leave blank to auto-set on publish."})]})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-background p-5 space-y-4",children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Classification"}),e.jsxs("div",{children:[e.jsx(i,{className:"text-xs text-muted-foreground",children:"Category"}),e.jsx("select",{value:s.category,onChange:t=>l(r=>({...r,category:t.target.value})),className:`mt-1 ${k}`,children:q.map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsxs("div",{children:[e.jsx(i,{className:"text-xs text-muted-foreground",children:"State"}),e.jsx("select",{value:s.state,onChange:t=>l(r=>({...r,state:t.target.value})),className:`mt-1 ${k}`,children:z.map(t=>e.jsx("option",{value:t,children:t||"None"},t))})]})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-background p-5",children:[e.jsx("h3",{className:"mb-3 text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Topics"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:F.map(t=>e.jsx("button",{type:"button",onClick:()=>y(t.value),className:`rounded-full px-3 py-1.5 text-xs font-medium transition-all ${s.topics.includes(t.value)?"bg-accent text-accent-foreground shadow-sm":"bg-muted text-muted-foreground hover:bg-muted/80"}`,children:t.label},t.value))})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-background p-5 space-y-4",children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Media & Links"}),e.jsxs("div",{children:[e.jsx(i,{className:"text-xs text-muted-foreground",children:"Featured Image"}),e.jsx("div",{className:"mt-1",children:e.jsx(T,{value:s.featured_image,onChange:t=>l(r=>({...r,featured_image:t})),folder:"posts"})})]}),e.jsxs("div",{children:[e.jsx(i,{className:"text-xs text-muted-foreground",children:"Original Source URL"}),e.jsx(x,{value:s.original_url,onChange:t=>l(r=>({...r,original_url:t.target.value})),className:"mt-1",placeholder:"https://..."}),e.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:['External article being quoted or summarized. Renders as a "Read the original" card. ',e.jsx("strong",{children:"Not"})," a redirect — use URL Aliases below for that."]})]}),e.jsxs("div",{children:[e.jsx(i,{className:"text-xs text-muted-foreground",children:"URL Aliases"}),e.jsx(b,{value:s.aliases,onChange:t=>l(r=>({...r,aliases:t.target.value})),rows:3,className:"mt-1 font-mono text-xs",placeholder:`/old-post-slug
7/2024/05/headline`}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Old paths (one per line) that should 301 to this article. Leading slash auto-added."})]})]})]})]})]})};export{ne as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.