Loheide-eu-mitarbeiterplatt.../public/build/assets/SnippetEditor-BtJ864xf.js
Friederich Loheide d5b7b1e0a8
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m51s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 6m48s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m16s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 7m21s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 9m30s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 9m44s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 8m49s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 8m37s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 44s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m8s
Redaktion mit Bereichsleiste und Übersicht (0.42.0)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 18:38:44 +00:00

1 line
No EOL
8.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{D as e,E as t,Ht as n,On as r,Yt as i,Zn as ee,_ as a,b as o,bt as te,ct as s,g as c,gn as l,gt as u,it as ne,mt as d,o as f,qt as p,tr as m,v as h,vn as g,y as _}from"./runtime-core.esm-bundler-B8D2lM98.js";import{w as v,x as y}from"./runtime-dom.esm-bundler-BEWGoe8n.js";import{i as re,r as ie}from"./dist--2OKCVzt.js";import{t as ae}from"./arrow-left-DROE4wuA.js";import{a as oe,c as se,i as ce,n as b,o as le,r as x,s as S,t as C}from"./EditorBlockList-CMSuwhQJ.js";import{d as ue,o as de}from"./useMediaList-DU8HbK2c.js";import{t as fe}from"./component-5v7AiJbe.js";import{t as pe}from"./file-stack-CDegUTxJ.js";import{t as me}from"./loader-circle-Wr6tQn-J.js";import{a as he}from"./PopoverTrigger-Cah311ye.js";import{t as ge}from"./plus-CQwC4vy-.js";import{t as _e}from"./save-Bjo-pGWz.js";import{n as w}from"./lib-Be7KNAML.js";import{$ as ve,P as ye,X as be,Z as xe,et as Se,g as T,z as E}from"./app-Ofei4p_N.js";import{n as Ce,t as we}from"./useMediaPicker-_1LEx4xM.js";var Te={class:`flex h-dvh flex-col bg-background`},Ee={class:`flex shrink-0 items-center gap-3 border-b bg-card px-3 py-2 sm:px-4`},De={class:`inline-flex shrink-0 items-center gap-1.5 rounded bg-brand-soft px-2 py-0.5 text-xs font-medium text-brand-soft-foreground`},Oe={class:`hidden min-w-0 flex-1 truncate text-xs text-muted-foreground sm:block`},ke={key:2,class:`size-1.5 rounded-full bg-current`,"aria-label":`ungespeicherte Änderungen`},Ae={class:`flex min-h-0 flex-1`},je={class:`mx-auto max-w-[1100px] px-4 py-8 sm:px-8`},Me=[`placeholder`],Ne={class:`@container`},Pe={class:`hidden w-[340px] shrink-0 flex-col border-l bg-card lg:flex`},Fe={class:`flex shrink-0 border-b px-2`,role:`tablist`},Ie=[`aria-selected`,`disabled`,`onClick`],Le={key:0,class:`absolute inset-x-2 bottom-0 h-[3px] rounded-t-full bg-brand`},Re={class:`min-h-0 flex-1 overflow-y-auto p-4`},D=`/redaktion/bausteine`,O={__name:`SnippetEditor`,props:{snippet:{type:Object,required:!0},kinds:{type:Object,required:!0},usages:{type:Array,default:()=>[]},blockTypes:{type:Array,required:!0},blockGroups:{type:Object,required:!0},audienceOptions:{type:Object,required:!0},uploadsUrl:{type:String,required:!0}},setup(O){let k=O,A=Object.fromEntries(k.blockTypes.map(e=>[e.key,e])),j=k.snippet.kind===`block`,M=l({name:k.snippet.name,description:k.snippet.description??``,content:ce(k.snippet.content)}),N=g(null),P=g(null),F=l({}),I=g(`blocks`),L=g(!1),R=g(k.snippet.updated_at),z=c(()=>N.value?S(M.content.blocks,N.value)?.block??null:null);n(N,e=>I.value=e?`block`:`blocks`);let B=e=>N.value=e??null;function V(e,t,n){let r=oe(n);e.splice(t,0,r),B(r.id)}function H(e){let t=z.value?S(M.content.blocks,z.value.id):null;t?V(t.list,t.index+1,e):V(M.content.blocks,M.content.blocks.length,e),L.value=!1}function ze(e){let t=S(M.content.blocks,e);t&&(t.list.splice(t.index,1),N.value===e&&B(null))}function Be(e,t){let n=S(M.content.blocks,e),r=n?n.index+t:-1;n&&r>=0&&r<n.list.length&&n.list.splice(r,0,n.list.splice(n.index,1)[0])}function Ve(e){let t=S(M.content.blocks,e);if(!t)return;let n=le(t.block);t.list.splice(t.index+1,0,n),B(n.id)}function He(e){return[z.value,P.value?S(M.content.blocks,P.value)?.block:null].filter(Boolean).some(t=>t.items?.includes(e)||S(e.blocks,t.id))}let U=(e,t)=>ue(`${D}/bilder`,e,{onProgress:t}),W=we({upload:U,contextLabel:j?`In diesem Baustein`:`In dieser Vorlage`,contextPaths:()=>de(M.content)});u(`pagebuilder:editor`,{types:A,groups:k.blockGroups,selectedId:N,hoveredId:P,previews:F,readOnly:g(!1),files:g([]),peopleCache:l({}),audienceOptions:k.audienceOptions,select:B,insert:V,remove:ze,move:Be,duplicate:Ve,containsActive:He,uploadImage:U,uploadFile:()=>Promise.reject(Error(`Dateien zum Herunterladen gehören zu einer Seite – bitte dort hochladen.`)),pickMedia:e=>W.pick(e),imageUrl:e=>`${k.uploadsUrl}/${e}`,saveAsSnippet:null}),u(`pagebuilder:list`,C),u(`pagebuilder:types`,A),u(`pagebuilder:editing`,c(()=>!0));let G={},K;function q(){let e=[];se(M.content.blocks,t=>{if(!A[t.type]?.dynamic)return;let n=JSON.stringify(t.data);G[t.id]!==n&&(G[t.id]=n,e.push({id:t.id,type:t.type,data:t.data}))}),e.length&&E.post(`${D}/vorschau`,{blocks:e.slice(0,100)}).then(e=>Object.assign(F,e.props)).catch(()=>{})}let J=g(!1),Y=JSON.stringify(M),X=g(!1);n(M,()=>{X.value=JSON.stringify(M)!==Y,clearTimeout(K),K=setTimeout(q,500)},{deep:!0});async function Z(){if(!J.value){J.value=!0;try{let e=await E.put(`${D}/${k.snippet.id}`,{name:M.name,description:M.description||null,content:M.content});Y=JSON.stringify(M),X.value=!1,R.value=e.updated_at,w.success(j&&k.usages.length?`Gespeichert – gilt jetzt auf ${k.usages.length} ${k.usages.length===1?`Seite`:`Seiten`}`:`Gespeichert`)}catch(e){w.error(e.data?.errors?.name?.[0]??e.message??`Speichern fehlgeschlagen`)}finally{J.value=!1}}}function Q(e){(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),Z())}let $=e=>X.value&&e.preventDefault();return s(()=>{q(),window.addEventListener(`keydown`,Q),window.addEventListener(`beforeunload`,$)}),ne(()=>{window.removeEventListener(`keydown`,Q),window.removeEventListener(`beforeunload`,$)}),(n,s)=>(d(),o(f,null,[e(r(ie),{title:`${O.kinds[O.snippet.kind]}: ${M.name}`},null,8,[`title`]),a(`div`,Te,[a(`header`,Ee,[e(r(re),{href:`/redaktion`,class:`grid size-9 place-items-center rounded-md text-muted-foreground hover:bg-accent`,"aria-label":`Zurück zur Redaktion`},{default:p(()=>[e(r(ae),{class:`size-5`})]),_:1}),a(`span`,De,[j?(d(),h(r(fe),{key:0,class:`size-3.5`})):(d(),h(r(pe),{key:1,class:`size-3.5`})),t(` `+m(O.kinds[O.snippet.kind]),1)]),a(`p`,Oe,[j?(d(),o(f,{key:0},[t(m(O.usages.length?`Eingebunden auf: ${O.usages.map(e=>e.title).join(`, `)}`:`Noch auf keiner Seite eingebunden`),1)],64)):(d(),o(f,{key:1},[t(`Neue Seiten können mit diesem Inhalt starten.`)],64)),R.value?(d(),o(f,{key:2},[t(` · gespeichert `+m(r(ye)(R.value)),1)],64)):_(``,!0)]),s[8]||=a(`span`,{class:`flex-1 sm:hidden`},null,-1),e(r(T),{variant:`outline`,size:`icon`,class:`lg:hidden`,"aria-label":`Block hinzufügen`,onClick:s[0]||=e=>L.value=!0},{default:p(()=>[e(r(ge))]),_:1}),e(r(T),{disabled:J.value||!M.name.trim(),onClick:Z},{default:p(()=>[J.value?(d(),h(r(me),{key:0,class:`animate-spin`})):(d(),h(r(_e),{key:1})),s[7]||=t(` Speichern`,-1),X.value?(d(),o(`span`,ke)):_(``,!0)]),_:1},8,[`disabled`])]),a(`div`,Ae,[a(`main`,{class:`min-w-0 flex-1 overflow-y-auto`,onClick:s[5]||=e=>B(null)},[a(`div`,je,[i(a(`input`,{"onUpdate:modelValue":s[1]||=e=>M.name=e,class:`w-full bg-transparent text-3xl font-semibold tracking-tight outline-none placeholder:text-muted-foreground/60`,placeholder:j?`Name des Bausteins`:`Name der Vorlage`,maxlength:`120`,"aria-label":`Name`,onClick:s[2]||=v(()=>{},[`stop`])},null,8,Me),[[y,M.name]]),i(a(`input`,{"onUpdate:modelValue":s[3]||=e=>M.description=e,class:`mt-1 mb-6 w-full bg-transparent text-sm text-muted-foreground outline-none placeholder:text-muted-foreground/60`,placeholder:`Kurze Beschreibung (optional) – erscheint bei der Auswahl`,maxlength:`300`,"aria-label":`Beschreibung`,onClick:s[4]||=v(()=>{},[`stop`])},null,512),[[y,M.description]]),a(`div`,Ne,[e(C,{item:M.content,root:``},null,8,[`item`])])])]),a(`aside`,Pe,[a(`div`,Fe,[(d(),o(f,null,te([{key:`blocks`,label:`Blöcke`},{key:`block`,label:`Ausgewählter Block`}],e=>a(`button`,{key:e.key,type:`button`,role:`tab`,class:ee([`relative px-3 py-3 text-sm font-medium disabled:opacity-40`,I.value===e.key?`text-foreground`:`text-muted-foreground hover:text-foreground`]),"aria-selected":I.value===e.key,disabled:e.key===`block`&&!z.value,onClick:t=>I.value=e.key},[t(m(e.label)+` `,1),I.value===e.key?(d(),o(`span`,Le)):_(``,!0)],10,Ie)),64))]),a(`div`,Re,[I.value===`block`&&z.value?(d(),h(b,{key:z.value.id,block:z.value},null,8,[`block`])):(d(),h(x,{key:1,onPick:H}))])])]),e(r(Se),{open:L.value,"onUpdate:open":s[6]||=e=>L.value=e},{default:p(()=>[e(r(ve),{side:`right`,class:`w-[340px] overflow-y-auto p-4`},{default:p(()=>[e(r(xe),{class:`p-0`},{default:p(()=>[e(r(be),null,{default:p(()=>[t(m(z.value?`Block bearbeiten`:`Block hinzufügen`),1)]),_:1})]),_:1}),z.value?(d(),h(b,{key:z.value.id,block:z.value},null,8,[`block`])):(d(),h(x,{key:1,onPick:H}))]),_:1})]),_:1},8,[`open`])]),e(Ce,{picker:r(W)},null,8,[`picker`]),e(r(he),{position:`bottom-left`})],64))}};export{O as default};