Loheide-eu-mitarbeiterplatt.../public/build/assets/SnippetEditor-UOAILI7g.js
Friederich Loheide e211db9f30
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.3 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.4 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.4 (pull_request) Has been skipped
CI / Browser-Tests (pull_request) Failing after 7m34s
CI / PHP 8.3 / mysql:8.4-1 (pull_request) Successful in 11m55s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 16m43s
CI / Build-Artefakte aktuell (pull_request) Successful in 13m17s
Automatische Updates, Browser-Tests, CI grün (0.63.0)
- Opt-in „Updates automatisch installieren“ (AutoUpdate, alle 10 Minuten)
- Playwright-Tests in tests/Browser, CI-Job „Browser-Tests“
- CI: volle Matrix nur auf main, PRs mit einem MySQL-Job
- MySQL-JSON-Reihenfolge in zwei Tests, QM-Suchausschnitt ohne <mark>, h1 auf Startseite/Editor

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 17:29:20 +00:00

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