PageSourceSearch

https://parlez.com/assets/BlogNewPostPage-Bg7oUU1C.js

js parlez.com collected 2026-10-04 10:27:05 UTC 13,996 bytes, 10 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LazyMarkdownEditor-DmGsWOci.js","assets/bootstrap-BFAW_Yh-.js","assets/bootstrap-NaStfFDv.css","assets/DocsMarkdown-DW3dPdlw.js","assets/CloseCircleOutlined-B1dkgyZK.js","assets/useBlogAuthorAccess-CYNwCaNA.js","assets/DocsMarkdown-g8z1cjAK.css","assets/LazyMarkdownEditor-DaV3T2Bj.css"])))=>i.map(i=>d[i]);
2import{c as d,I as q,af as S,dN as te,o as re,ad as oe,ah as ae,ae as se,dO as ie,j as t,bJ as ne,h as w,ac as U,dP as de,bI as le,C,by as G,T as b,f as y,b5 as ce,i as ue,ag as P,bZ as me}from"./bootstrap-BFAW_Yh-.js";import{b as ge}from"./layoutWidth-BG6ulDiJ.js";import{U as z,R as pe}from"./UploadOutlined-_f4fe4_-.js";import{b as he,C as be,c as xe}from"./ConsoleMoreButton-qVmFO1S1.js";import"./RoomHeader.styles-Ba6g-aZ_.js";import"./vendor-avatar-BBlyUxzh.js";import{u as fe,D as ve}from"./DocsMarkdown-DW3dPdlw.js";import{u as we}from"./useBlogAuthorAccess-CYNwCaNA.js";import"./SettingOutlined-DGadAS7a.js";import"./DeleteOutlined-0BBpjAvp.js";import"./ArrowLeftOutlined-DoggSruP.js";import"./CloseCircleOutlined-B1dkgyZK.js";var ye={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zm-40 632H136v-39.9l138.5-164.3 150.1 178L658.1 489 888 761.6V792zm0-129.8L664.2 396.8c-3.2-3.8-9-3.8-12.2 0L424.6 666.4l-144-170.7c-3.2-3.8-9-3.8-12.2 0L136 652.7V232h752v430.2zM304 456a88 88 0 100-176 88 88 0 000 176zm0-116c15.5 0 28 12.5 28 28s-12.5 28-28 28-28-12.5-28-28 12.5-28 28-28z"}}]},name:"picture",theme:"outlined"};function N(){return N=Object.assign?Object.assign.bind():function(e){for(var o=1;o<arguments.length;o++){var i=arguments[o];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},N.apply(this,arguments)}const Se=(e,o)=>d.createElement(q,N({},e,{ref:o,icon:ye})),je=d.forwardRef(Se);var Te={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"defs",attrs:{},children:[{tag:"style",attrs:{}}]},{tag:"path",attrs:{d:"M368 724H252V608c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v116H72c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h116v116c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V788h116c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"}},{tag:"path",attrs:{d:"M912 302.3L784 376V224c0-35.3-28.7-64-64-64H128c-35.3 0-64 28.7-64 64v352h72V232h576v560H448v72h272c35.3 0 64-28.7 64-64V648l128 73.7c21.3 12.3 48-3.1 48-27.6V330c0-24.6-26.7-40-48-27.7zM888 625l-104-59.8V458.9L888 399v226z"}},{tag:"path",attrs:{d:"M320 360c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H208c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h112z"}}]},name:"video-camera-add",theme:"outlined"};function E(){return E=Object.assign?Object.assign.bind():function(e){for(var o=1;o<arguments.length;o++){var i=arguments[o];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},E.apply(this,arguments)}const Ce=(e,o)=>d.createElement(q,E({},e,{ref:o,icon:Te})),Pe=d.forwardRef(Ce),M="".replace(/\/$/,""),Ne=e=>String(e||"").split("/").map(o=>encodeURIComponent(o)).join("/"),R=async e=>{try{const o=(await e.text()).trim();if(!o)return;try{const i=JSON.parse(o);return i.message||i.error||o}catch{return o}}catch{return}},B=()=>{const e=new Headers,o=te();return o&&e.set("Authorization",`Bearer ${o}`),e},Ee=async e=>{const o=B();o.set("Content-Type","application/json");const i=await fetch(`${M}/docs/blog/posts`,{method:"POST",headers:o,body:JSON.stringify(e)});if(!i.ok)throw new S(i.status,await R(i));return await i.json()},Me=async(e,o)=>{const i=B(),n=new FormData;n.set("file",e),"".trim()&&n.set("alt",String(o).trim());const l=await fetch(`${M}/docs/blog/media`,{method:"POST",headers:i,body:n});if(!l.ok)throw new S(l.status,await R(l));return await l.json()},Re=async(e,o)=>{const i=B();i.set("Content-Type","application/json");const n=await fetch(`${M}/docs/blog/posts/${Ne(e)}`,{method:"PUT",headers:i,body:JSON.stringify(o)});if(!n.ok)throw new S(n.status,await R(n));return await n.json()},k=()=>new Date().toISOString().slice(0,10),_=e=>String(e||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),Be=(e,o,i,n)=>{const l=String(e||""),u=Number.isFinite(i)?Math.max(0,Number(i)):l.length,f=Number.isFinite(n)?Math.max(u,Number(n)):u;return{nextValue:`${l.slice(0,u)}${o}${l.slice(f)}`,nextCaret:u+o.length}},{TextArea:Le}=y,Ie=d.lazy(()=>me(()=>import("./LazyMarkdownEditor-DmGsWOci.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]))),De=ue(({token:e,appearance:o})=>({markdownEditor:{"--md-editor-font":e.fontFamily,"--md-editor-text":e.colorText,"--md-editor-heading":e.colorTextHeading,"--md-editor-placeholder":e.colorTextPlaceholder,"--md-editor-border":e.colorBorder,"--md-editor-toolbar-bg":e.colorBg
2Container,"--md-editor-toolbar-hover":e.colorFillTertiary,"--md-editor-surface":e.colorBgContainer,"--md-editor-muted":e.colorTextSecondary,"--md-editor-canvas":o==="dark"?e.colorBgContainer:"#FFFFFF",color:"var(--md-editor-text)",fontFamily:"var(--md-editor-font)","& .w-md-editor":{background:"var(--md-editor-surface)",color:"var(--md-editor-text)",border:`1px solid ${e.colorBorder}`,borderRadius:e.borderRadiusLG,boxShadow:"none",overflow:"hidden"},"& .w-md-editor-toolbar":{background:"var(--md-editor-toolbar-bg)",borderBottom:`1px solid ${e.colorBorder}`,padding:`${e.paddingXS}px ${e.paddingSM}px`,gap:4},"& .w-md-editor-toolbar li > button":{color:e.colorTextSecondary,borderRadius:e.borderRadiusSM},"& .w-md-editor-toolbar li > button:hover":{background:e.colorFillTertiary,color:e.colorTextHeading},"& .w-md-editor-toolbar li.divider":{backgroundColor:e.colorBorder},"& .w-md-editor-content":{background:"var(--md-editor-canvas)",color:"var(--md-editor-text)",fontFamily:"var(--md-editor-font)"},"& .w-md-editor-text-pre, & .w-md-editor-text-input, & .w-md-editor-text":{fontFamily:"var(--md-editor-font) !important",fontSize:e.fontSize,lineHeight:e.lineHeight,color:"var(--md-editor-text) !important",background:"var(--md-editor-canvas) !important"},"& .w-md-editor-text-input, & .w-md-editor-text-pre > code, & .w-md-editor-text":{padding:`${e.paddingMD}px ${e.paddingLG}px !important`,caretColor:e.colorTextHeading},"& .w-md-editor-text-input::placeholder":{color:"var(--md-editor-placeholder) !important"},"& .w-md-editor-text-input::selection, & .w-md-editor-text-pre ::selection":{background:o==="dark"?"rgba(143, 169, 183, 0.42)":"rgba(79, 109, 122, 0.28)",color:o==="dark"?"#F6F7F8":"#121417"},"& .w-md-editor-text-pre, & .w-md-editor-text-input":{minHeight:460},"& .w-md-editor-text-pre > code":{whiteSpace:"pre-wrap !important",wordBreak:"break-word"},"& .token.title, & .token.title.important, & .token.bold":{color:e.colorTextHeading},"& .token.quote, & .token.hr, & .token.url":{color:e.colorTextSecondary},"& .token.list.punctuation, & .token.blockquote.punctuation, & .token.code-block":{color:e.colorPrimary},"& .token.image, & .token.link":{color:e.colorLink}},page:{display:"grid",gap:e.marginXL},shell:{display:"grid",gap:e.marginXL},metadataCard:{borderRadius:e.borderRadiusLG,border:"none",boxShadow:"none"},fieldGroup:{display:"grid",gap:e.marginSM,marginBottom:e.marginLG},label:{fontWeight:e.fontWeightStrong,color:e.colorTextHeading},editorGrid:{display:"grid",gap:e.marginLG,gridTemplateColumns:"minmax(0, 1.05fr) minmax(320px, 0.95fr)",alignItems:"start","@media (max-width: 980px)":{gridTemplateColumns:"minmax(0, 1fr)"}},editorToolbar:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:e.marginMD,flexWrap:"wrap"},editorToolbarActions:{display:"flex",alignItems:"center",gap:e.marginSM,flexWrap:"wrap",justifyContent:"flex-end"},editorCard:{borderRadius:e.borderRadiusLG,border:"none",boxShadow:"none"},previewBody:{minHeight:520},editorSurface:{minHeight:520},editorLoading:{minHeight:520,display:"grid",alignItems:"center"},helperText:{color:e.colorTextSecondary}})),Oe=()=>({title:"",summary:"",tags:[],slug:"",publishedDate:k(),content:""}),$e=e=>e instanceof S?e.message.toLowerCase().includes("blog media storage unavailable")?"Image upload is not configured yet. Set the docs media S3 bucket/public media config and restart the docs service.":e.message:e instanceof Error?e.message:"Unable to publish this post right now.",Xe=()=>{const{styles:e}=De(),o=re(),i=oe(),{resolvedMode:n}=ae(),{canUploadMedia:l}=we(),u=d.useRef(Oe()),f=d.useRef(null),v=d.useRef(""),x=d.useMemo(()=>se(i.slug||""),[i.slug]),c=!!x,[s,p]=d.useState(u.current),[W,L]=d.useState(!1),[I,h]=d.useState(null),[j,D]=d.useState(!1),[O,$]=d.useState(!1),[A,J]=d.useState("editor"),{data:m,isLoading:H}=fe(x,c),X=d.useMemo(()=>{const r=u.current;return s.title!==r.title||s.summary!==r.summary||s.tags.join("|")!==r.tags.join("|")||s.slug!==r.slug||s.publishedDate!==r.publishedDate||s.content!==r.content},[s]);ie(r=>{X&&(r.preventDefault(),r.returnValue="")}
2),d.useEffect(()=>{if(!c||!m||v.current===x)return;const r={title:String(m.title||""),summary:String(m.summary||""),tags:Array.isArray(m.tags)?m.tags:[],slug:String(m.slug||"").replace(/^blog\//,""),publishedDate:String(m.date||k()),content:String(m.content||"")};u.current=r,v.current=x,p(r),L(!1)},[m,c,x]);const Y=r=>{requestAnimationFrame(()=>{var g;const a=(g=f.current)==null?void 0:g.querySelector("textarea");a&&(a.focus(),a.setSelectionRange(r,r))})},F=r=>{var V;const a=(V=f.current)==null?void 0:V.querySelector("textarea"),{nextValue:g,nextCaret:Q}=Be(s.content,r,a==null?void 0:a.selectionStart,a==null?void 0:a.selectionEnd);p(ee=>({...ee,content:g})),Y(Q)},Z=async r=>{h(null),$(!0);try{const a=await Me(r);F(`
3
4${a.markdown}
5
6`),P.success("Image uploaded and inserted.")}catch(a){P.error($e(a))}finally{$(!1)}return z.LIST_IGNORE},K=()=>{const r=window.prompt("Paste a YouTube or Vimeo URL"),a=String(r||"").trim();a&&F(`
7
8@[video](${a})
9
10`)},T=async()=>{if(h(null),!s.title.trim()){h(new Error("Title is required."));return}if(!s.summary.trim()){h(new Error("Summary is required."));return}if(!s.content.trim()){h(new Error("Content is required."));return}if(!s.publishedDate.trim()){h(new Error("Publish date is required."));return}D(!0);try{const r={title:s.title.trim(),summary:s.summary.trim(),tags:s.tags,slug:s.slug.trim()||void 0,publishedDate:s.publishedDate.trim(),content:s.content.trim()},a=c?await Re(x,r):await Ee(r);u.current={...s,tags:a.tags,slug:String(a.slug||"").replace(/^blog\//,"")},v.current=String(a.slug||""),P.success(c?"Post updated.":"Post published."),o(a.path)}catch(r){h(r)}finally{D(!1)}};return t.jsx(he,{maxWidth:780,children:t.jsx(ne,{active:j,description:"Publishing post...",children:t.jsxs("div",{className:e.page,children:[t.jsx(be,{title:c?"Edit blog post":"New blog post",subtitle:c?"Update markdown, media, and metadata for this published post.":"Write in markdown, upload images, and publish directly to the public blog.",backLink:{label:"Back to blog",onClick:()=>{o(de)}},actions:t.jsx(w,{type:"primary",icon:t.jsx(U,{}),onClick:T,loading:j,children:c?"Save changes":"Publish"})}),I?t.jsx(le,{error:I,fallbackMessage:c?"Unable to update this blog post.":"Unable to publish this blog post.",onResubmit:T}):null,c&&H?t.jsx(C,{className:e.editorCard,children:t.jsx(G,{active:!0,paragraph:{rows:12}})}):null,!c||!H?t.jsxs("div",{className:e.shell,children:[t.jsxs(C,{className:e.metadataCard,children:[t.jsxs("div",{className:e.fieldGroup,children:[t.jsx(b.Text,{className:e.label,children:"Title"}),t.jsx(y,{placeholder:"What is this post about?",value:s.title,onChange:r=>{const a=r.target.value;p(g=>({...g,title:a,slug:W?g.slug:_(a)}))}})]}),t.jsxs("div",{className:e.fieldGroup,children:[t.jsx(b.Text,{className:e.label,children:"Summary"}),t.jsx(Le,{rows:4,placeholder:"One concise summary for the archive and SEO description.",value:s.summary,onChange:r=>{p(a=>({...a,summary:r.target.value}))}})]}),t.jsxs("div",{className:e.editorGrid,children:[t.jsxs("div",{className:e.fieldGroup,children:[t.jsx(b.Text,{className:e.label,children:"Slug"}),t.jsx(y,{placeholder:"what-is-couples-counseling",value:s.slug,onChange:r=>{L(!0),p(a=>({...a,slug:_(r.target.value)}))}}),t.jsx(b.Text,{className:e.helperText,children:"Auto-filled from the title until you edit it directly."})]}),t.jsxs("div",{className:e.fieldGroup,children:[t.jsx(b.Text,{className:e.label,children:"Publish date"}),t.jsx(y,{type:"date",value:s.publishedDate,onChange:r=>{p(a=>({...a,publishedDate:r.target.value}))}})]})]}),t.jsxs("div",{className:e.fieldGroup,children:[t.jsx(b.Text,{className:e.label,children:"Tags"}),t.jsx(ce,{mode:"tags",value:s.tags,placeholder:"Add tags",onChange:r=>{p(a=>({...a,tags:r.map(g=>String(g))}))},tokenSeparators:[","]})]})]}),t.jsxs(C,{className:e.editorCard,children:[t.jsxs("div",{className:e.editorToolbar,children:[t.jsx(ge,{value:A,onChange:r=>J(r),options:[{label:"Editor",value:"editor"},{label:"Preview",value:"preview"}]}),t.jsxs("div",{className:e.editorToolbarActions,children:[t.jsx(z,{accept:"image/png,image/jpeg,image/webp,image/gif",showU
10ploadList:!1,beforeUpload:Z,disabled:!l||O,children:t.jsx(w,{icon:l?t.jsx(pe,{}):t.jsx(je,{}),loading:O,disabled:!l,children:"Upload image"})}),t.jsx(w,{icon:t.jsx(Pe,{}),onClick:K,children:"Add video"})]})]}),t.jsx("div",{style:{height:16}}),A==="editor"?t.jsx("div",{ref:f,className:e.editorSurface,children:t.jsx(d.Suspense,{fallback:t.jsx("div",{className:e.editorLoading,children:t.jsx(G,{active:!0,paragraph:{rows:12}})}),children:t.jsx(Ie,{value:s.content,placeholder:"Write your post in markdown.",className:e.markdownEditor,"data-color-mode":n,onChange:r=>{p(a=>({...a,content:r}))}})})}):t.jsx("div",{className:e.previewBody,children:s.content.trim()?t.jsx(ve,{content:s.content,renderMode:"editor"}):t.jsx(b.Text,{type:"secondary",children:"Start writing to see the rendered preview."})})]}),t.jsx(xe,{maxWidth:"100%",centered:!1,right:t.jsx(w,{type:"primary",icon:t.jsx(U,{}),onClick:T,loading:j,children:c?"Save changes":"Publish"})})]}):null]})})})};export{Xe as BlogNewPostPage};

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.