Beiträge mit dem Baukasten der Seiten, Galerie-Großansicht mit Blättern
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m42s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m3s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m32s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m9s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m41s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m5s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m57s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m59s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m35s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m42s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m3s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m32s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m9s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m41s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m5s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m57s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m59s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m35s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3b72b5327e
commit
bdd21a38cb
164 changed files with 1276 additions and 623 deletions
|
|
@ -1,29 +1,61 @@
|
|||
<script setup>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { Link, router, useForm, usePage } from '@inertiajs/vue3';
|
||||
import { ArrowLeft, CalendarClock, Eye, ImagePlus, LoaderCircle, MessageSquareWarning, Save, Send, Trash2, Undo2, X } from '@lucide/vue';
|
||||
import { computed, onBeforeUnmount, onMounted, provide, reactive, ref, watch } from 'vue';
|
||||
import { Head, Link, router, useForm, usePage } from '@inertiajs/vue3';
|
||||
import {
|
||||
ArrowLeft,
|
||||
CalendarClock,
|
||||
EllipsisVertical,
|
||||
Eye,
|
||||
ImagePlus,
|
||||
LoaderCircle,
|
||||
MessageSquareWarning,
|
||||
Monitor,
|
||||
Redo2,
|
||||
Save,
|
||||
Send,
|
||||
Smartphone,
|
||||
Tablet,
|
||||
Trash2,
|
||||
Undo2,
|
||||
X,
|
||||
} from '@lucide/vue';
|
||||
import { toast } from 'vue-sonner';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { Toaster } from '@/components/ui/sonner';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
|
||||
import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@/components/ui/sheet';
|
||||
import FormField from '@/components/FormField.vue';
|
||||
import NativeSelect from '@/components/NativeSelect.vue';
|
||||
import Panel from '@/components/Panel.vue';
|
||||
import RichTextEditor from '@/components/RichTextEditor.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import BlockPalette from '@/pagebuilder/editor/BlockPalette.vue';
|
||||
import BlockSettings from '@/pagebuilder/editor/BlockSettings.vue';
|
||||
import EditorBlockList from '@/pagebuilder/editor/EditorBlockList.vue';
|
||||
import { clone, createBlock, duplicate as duplicateBlock, locate, walk } from '@/pagebuilder/editor/tree';
|
||||
import { http } from '@/lib/http';
|
||||
|
||||
/**
|
||||
* Beitrag schreiben – mit demselben Baukasten wie die Seiten. Titelbild, Titel
|
||||
* und Kurztext stehen direkt auf der Arbeitsfläche, die übrigen Angaben im Reiter
|
||||
* „Beitrag“. Gespeichert wird ausdrücklich (keine Entwürfe im Hintergrund).
|
||||
*/
|
||||
const props = defineProps({
|
||||
post: { type: Object, default: null },
|
||||
content: { type: Object, default: () => ({ blocks: [] }) },
|
||||
categories: { type: Array, required: true },
|
||||
canPublishWithoutCategory: { type: Boolean, default: false },
|
||||
canDelete: { type: Boolean, default: false },
|
||||
forms: { type: Array, default: () => [] },
|
||||
blockTypes: { type: Array, required: true },
|
||||
blockGroups: { type: Object, required: true },
|
||||
audienceOptions: { type: Object, required: true },
|
||||
uploadsUrl: { type: String, required: true },
|
||||
});
|
||||
|
||||
const page = usePage();
|
||||
const types = Object.fromEntries(props.blockTypes.map((type) => [type.key, type]));
|
||||
|
||||
function localValue(iso) {
|
||||
if (!iso) return '';
|
||||
|
|
@ -36,7 +68,6 @@ function localValue(iso) {
|
|||
const form = useForm({
|
||||
title: props.post?.title ?? '',
|
||||
teaser: props.post?.teaser ?? '',
|
||||
body: props.post?.body ?? '',
|
||||
category_id: props.post?.category_id ?? (props.categories.length === 1 ? props.categories[0].id : null),
|
||||
cover: null,
|
||||
remove_cover: false,
|
||||
|
|
@ -46,18 +77,263 @@ const form = useForm({
|
|||
action: 'draft',
|
||||
});
|
||||
|
||||
const working = reactive({ content: clone(props.content ?? { blocks: [] }) });
|
||||
|
||||
const category = computed(() => props.categories.find((c) => c.id === Number(form.category_id)));
|
||||
const canPublish = computed(() => (category.value ? category.value.can_publish : props.canPublishWithoutCategory));
|
||||
const isPending = computed(() => props.post?.status === 'pending');
|
||||
const isPublished = computed(() => props.post?.status === 'published');
|
||||
const categoryOptions = computed(() => props.categories.map((c) => ({ value: c.id, label: c.name })));
|
||||
const scheduled = computed(() => form.published_at && new Date(form.published_at) > new Date());
|
||||
|
||||
// Titelbild
|
||||
// ——— Blockbaum (wie im Seiten-Editor) ———
|
||||
const selectedId = ref(null);
|
||||
const hoveredId = ref(null);
|
||||
const previews = reactive({});
|
||||
const readOnly = ref(false);
|
||||
const sidebarTab = ref('post');
|
||||
const sheetOpen = ref(false);
|
||||
const device = ref('desktop');
|
||||
|
||||
const selected = computed(() => (selectedId.value ? locate(working.content.blocks, selectedId.value)?.block ?? null : null));
|
||||
|
||||
watch(selectedId, (id) => {
|
||||
sidebarTab.value = id ? 'block' : sidebarTab.value === 'block' ? 'blocks' : sidebarTab.value;
|
||||
});
|
||||
|
||||
function select(id) {
|
||||
selectedId.value = id ?? null;
|
||||
}
|
||||
|
||||
function insert(list, index, type) {
|
||||
const block = createBlock(type);
|
||||
list.splice(index, 0, block);
|
||||
select(block.id);
|
||||
}
|
||||
|
||||
function insertFromPalette(type) {
|
||||
const found = selected.value ? locate(working.content.blocks, selected.value.id) : null;
|
||||
found ? insert(found.list, found.index + 1, type) : insert(working.content.blocks, working.content.blocks.length, type);
|
||||
sheetOpen.value = false;
|
||||
requestAnimationFrame(() => document.querySelector(`[data-block-id="${selectedId.value}"]`)?.scrollIntoView({ behavior: 'smooth', block: 'center' }));
|
||||
}
|
||||
|
||||
function remove(id) {
|
||||
const found = locate(working.content.blocks, id);
|
||||
|
||||
if (!found) return;
|
||||
|
||||
found.list.splice(found.index, 1);
|
||||
|
||||
if (selectedId.value === id) select(null);
|
||||
}
|
||||
|
||||
function move(id, direction) {
|
||||
const found = locate(working.content.blocks, id);
|
||||
const target = found ? found.index + direction : -1;
|
||||
|
||||
if (found && target >= 0 && target < found.list.length) {
|
||||
found.list.splice(target, 0, found.list.splice(found.index, 1)[0]);
|
||||
}
|
||||
}
|
||||
|
||||
function duplicate(id) {
|
||||
const found = locate(working.content.blocks, id);
|
||||
|
||||
if (!found) return;
|
||||
|
||||
const copy = duplicateBlock(found.block);
|
||||
found.list.splice(found.index + 1, 0, copy);
|
||||
Object.assign(previews, { [copy.id]: previews[id] });
|
||||
select(copy.id);
|
||||
}
|
||||
|
||||
function containsActive(item) {
|
||||
const candidates = [selected.value, hoveredId.value ? locate(working.content.blocks, hoveredId.value)?.block : null].filter(Boolean);
|
||||
|
||||
return candidates.some((block) => block.items?.includes(item) || locate(item.blocks, block.id));
|
||||
}
|
||||
|
||||
async function uploadImage(file) {
|
||||
const body = new FormData();
|
||||
body.append('image', file);
|
||||
|
||||
try {
|
||||
return await http.post('/redaktion/neuigkeiten/bilder', body);
|
||||
} catch (error) {
|
||||
toast.error(error.fieldErrors?.image ?? error.message);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function uploadFile() {
|
||||
toast.error('Dateien zum Herunterladen gehören in den Bereich „Downloads“ – dort hochladen und hier mit dem Downloads-Block verlinken.');
|
||||
throw new Error('not supported');
|
||||
}
|
||||
|
||||
provide('pagebuilder:editor', {
|
||||
types,
|
||||
groups: props.blockGroups,
|
||||
selectedId,
|
||||
hoveredId,
|
||||
previews,
|
||||
readOnly,
|
||||
files: ref([]),
|
||||
peopleCache: reactive({}),
|
||||
audienceOptions: props.audienceOptions,
|
||||
select,
|
||||
insert,
|
||||
remove,
|
||||
move,
|
||||
duplicate,
|
||||
containsActive,
|
||||
uploadImage,
|
||||
uploadFile,
|
||||
imageUrl: (path) => `${props.uploadsUrl}/${path}`,
|
||||
});
|
||||
provide('pagebuilder:list', EditorBlockList);
|
||||
provide('pagebuilder:types', types);
|
||||
provide('pagebuilder:editing', computed(() => true));
|
||||
|
||||
// ——— Vorschau dynamischer Blöcke ———
|
||||
const previewHashes = {};
|
||||
let previewTimer;
|
||||
|
||||
function refreshPreviews() {
|
||||
const changed = [];
|
||||
|
||||
walk(working.content.blocks, (block) => {
|
||||
if (!types[block.type]?.dynamic) return;
|
||||
|
||||
const hash = JSON.stringify(block.data);
|
||||
|
||||
if (previewHashes[block.id] !== hash) {
|
||||
previewHashes[block.id] = hash;
|
||||
changed.push({ id: block.id, type: block.type, data: block.data });
|
||||
}
|
||||
});
|
||||
|
||||
if (changed.length) {
|
||||
http.post('/redaktion/neuigkeiten/vorschau', { blocks: changed.slice(0, 100) })
|
||||
.then((data) => Object.assign(previews, data.props))
|
||||
.catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
// ——— Rückgängig / Wiederholen ———
|
||||
const undoStack = ref([]);
|
||||
const redoStack = ref([]);
|
||||
let historyBase = JSON.stringify(working.content);
|
||||
let applyingHistory = false;
|
||||
let historyTimer;
|
||||
|
||||
function recordHistory() {
|
||||
const current = JSON.stringify(working.content);
|
||||
|
||||
if (current !== historyBase) {
|
||||
undoStack.value = [...undoStack.value.slice(-49), historyBase];
|
||||
redoStack.value = [];
|
||||
historyBase = current;
|
||||
}
|
||||
}
|
||||
|
||||
function applySnapshot(snapshot) {
|
||||
applyingHistory = true;
|
||||
working.content = JSON.parse(snapshot);
|
||||
historyBase = snapshot;
|
||||
|
||||
if (selectedId.value && !locate(working.content.blocks, selectedId.value)) select(null);
|
||||
|
||||
setTimeout(() => (applyingHistory = false));
|
||||
}
|
||||
|
||||
function undo() {
|
||||
recordHistory();
|
||||
|
||||
if (!undoStack.value.length) return;
|
||||
|
||||
redoStack.value = [...redoStack.value, JSON.stringify(working.content)];
|
||||
applySnapshot(undoStack.value.at(-1));
|
||||
undoStack.value = undoStack.value.slice(0, -1);
|
||||
}
|
||||
|
||||
function redo() {
|
||||
if (!redoStack.value.length) return;
|
||||
|
||||
undoStack.value = [...undoStack.value, JSON.stringify(working.content)];
|
||||
applySnapshot(redoStack.value.at(-1));
|
||||
redoStack.value = redoStack.value.slice(0, -1);
|
||||
}
|
||||
|
||||
// ——— Ungespeicherte Änderungen ———
|
||||
let savedContent = JSON.stringify(working.content);
|
||||
const contentDirty = ref(false);
|
||||
const dirty = computed(() => contentDirty.value || form.isDirty);
|
||||
|
||||
watch(
|
||||
() => working.content,
|
||||
() => {
|
||||
contentDirty.value = JSON.stringify(working.content) !== savedContent;
|
||||
clearTimeout(previewTimer);
|
||||
previewTimer = setTimeout(refreshPreviews, 500);
|
||||
|
||||
if (!applyingHistory) {
|
||||
clearTimeout(historyTimer);
|
||||
historyTimer = setTimeout(recordHistory, 700);
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
function beforeUnload(event) {
|
||||
if (dirty.value && !form.processing) {
|
||||
event.preventDefault();
|
||||
event.returnValue = '';
|
||||
}
|
||||
}
|
||||
|
||||
const removeNavigationGuard = router.on('before', (event) => {
|
||||
if (dirty.value && !form.processing && event.detail.visit.method === 'get' && !window.confirm('Ungespeicherte Änderungen verwerfen?')) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
function onKeydown(event) {
|
||||
const typing = event.target.closest?.('input, textarea, select, [contenteditable="true"]');
|
||||
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 's') {
|
||||
event.preventDefault();
|
||||
submit(isPublished.value && canPublish.value ? 'publish' : isPublished.value ? 'submit' : 'draft');
|
||||
} else if (!typing && (event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'z') {
|
||||
event.preventDefault();
|
||||
event.shiftKey ? redo() : undo();
|
||||
} else if (!typing && (event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'y') {
|
||||
event.preventDefault();
|
||||
redo();
|
||||
} else if (event.key === 'Escape' && !typing) {
|
||||
select(null);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
refreshPreviews();
|
||||
window.addEventListener('keydown', onKeydown);
|
||||
window.addEventListener('beforeunload', beforeUnload);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('keydown', onKeydown);
|
||||
window.removeEventListener('beforeunload', beforeUnload);
|
||||
removeNavigationGuard();
|
||||
});
|
||||
|
||||
// ——— Titelbild ———
|
||||
const coverPreview = ref(props.post?.cover_url ?? null);
|
||||
const coverInput = ref(null);
|
||||
|
||||
function chooseCover(event) {
|
||||
const file = event.target.files?.[0];
|
||||
event.target.value = '';
|
||||
|
||||
if (!file) return;
|
||||
|
||||
|
|
@ -72,22 +348,18 @@ function removeCover() {
|
|||
coverPreview.value = null;
|
||||
}
|
||||
|
||||
async function uploadImage(file) {
|
||||
const body = new FormData();
|
||||
body.append('image', file);
|
||||
|
||||
try {
|
||||
return (await http.post('/redaktion/neuigkeiten/bilder', body)).url;
|
||||
} catch (error) {
|
||||
toast.error(error.fieldErrors?.image ?? error.message);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// ——— Speichern ———
|
||||
function submit(action) {
|
||||
if (!form.title.trim()) {
|
||||
toast.error('Bitte zuerst einen Titel eingeben.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
form.action = action;
|
||||
form.transform((data) => ({
|
||||
...data,
|
||||
content: JSON.stringify(working.content),
|
||||
published_at: data.published_at ? new Date(data.published_at).toISOString() : null,
|
||||
category_id: data.category_id ? Number(data.category_id) : null,
|
||||
form_id: data.form_id ? Number(data.form_id) : '',
|
||||
|
|
@ -96,16 +368,18 @@ function submit(action) {
|
|||
forceFormData: true,
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
savedContent = JSON.stringify(working.content);
|
||||
contentDirty.value = false;
|
||||
form.cover = null;
|
||||
form.defaults();
|
||||
},
|
||||
onError: (errors) => errors.action && toast.error(errors.action),
|
||||
onError: (errors) => toast.error(errors.action ?? errors.title ?? errors.category_id ?? errors.content ?? Object.values(errors)[0] ?? 'Speichern fehlgeschlagen.'),
|
||||
});
|
||||
}
|
||||
|
||||
watch(() => page.props.flash.status, (status) => status && toast.success(status), { immediate: true });
|
||||
|
||||
// Freigabe durch die Redaktion
|
||||
// ——— Freigabe durch die Redaktion ———
|
||||
const rejecting = ref(false);
|
||||
const rejectForm = useForm({ note: '' });
|
||||
|
||||
|
|
@ -119,61 +393,202 @@ function reject() {
|
|||
|
||||
function destroy() {
|
||||
if (window.confirm('Beitrag endgültig löschen?')) {
|
||||
contentDirty.value = false;
|
||||
form.defaults();
|
||||
router.delete(`/redaktion/neuigkeiten/${props.post.id}`);
|
||||
}
|
||||
}
|
||||
|
||||
const scheduled = computed(() => form.published_at && new Date(form.published_at) > new Date());
|
||||
const status = computed(() => {
|
||||
if (!props.post) return { label: 'Neu', class: 'bg-muted text-muted-foreground' };
|
||||
if (props.post.status === 'pending' || props.post.status_label === 'Geplant') return { label: props.post.status_label, class: 'bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200' };
|
||||
if (props.post.status_label === 'Veröffentlicht') return { label: 'Veröffentlicht', class: 'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200' };
|
||||
|
||||
return { label: props.post.status_label ?? 'Entwurf', class: 'bg-muted text-muted-foreground' };
|
||||
});
|
||||
|
||||
const devices = [
|
||||
{ key: 'desktop', label: 'Desktop', icon: Monitor, width: 'max-w-[900px]' },
|
||||
{ key: 'tablet', label: 'Tablet', icon: Tablet, width: 'max-w-[768px]' },
|
||||
{ key: 'mobile', label: 'Smartphone', icon: Smartphone, width: 'max-w-[390px]' },
|
||||
];
|
||||
const canvasWidth = computed(() => devices.find((d) => d.key === device.value).width);
|
||||
|
||||
const tabs = computed(() => [
|
||||
{ key: 'post', label: 'Beitrag' },
|
||||
{ key: 'blocks', label: 'Blöcke' },
|
||||
{ key: 'block', label: 'Block', disabled: !selected.value },
|
||||
]);
|
||||
|
||||
// Kurztext wächst mit
|
||||
function autoGrow(event) {
|
||||
event.target.style.height = 'auto';
|
||||
event.target.style.height = `${event.target.scrollHeight}px`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout :title="post ? `Bearbeiten: ${post.title}` : 'Neuer Beitrag'">
|
||||
<div class="mb-6 flex flex-wrap items-center justify-between gap-4">
|
||||
<div class="min-w-0">
|
||||
<Link href="/redaktion" class="mb-2 inline-flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground"><ArrowLeft class="size-4" /> Redaktion</Link>
|
||||
<h1 class="text-2xl font-semibold tracking-tight">{{ post ? 'Beitrag bearbeiten' : 'Neuer Beitrag' }}</h1>
|
||||
</div>
|
||||
<div v-if="post" class="flex items-center gap-2">
|
||||
<span class="rounded px-2 py-1 text-xs font-medium" :class="{
|
||||
'bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200': post.status === 'pending' || post.status_label === 'Geplant',
|
||||
'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200': post.status_label === 'Veröffentlicht',
|
||||
'bg-muted text-muted-foreground': post.status === 'draft',
|
||||
}">{{ post.status_label }}</span>
|
||||
<Button v-if="post.url" variant="outline" size="sm" as-child><a :href="post.url"><Eye /> Ansehen</a></Button>
|
||||
</div>
|
||||
</div>
|
||||
<Head :title="post ? `Bearbeiten: ${form.title || post.title}` : 'Neuer Beitrag'" />
|
||||
|
||||
<div v-if="post?.review_note" class="mb-6 flex gap-3 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-950 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-100">
|
||||
<div class="flex h-dvh flex-col bg-background">
|
||||
<!-- Kopfleiste -->
|
||||
<header class="z-30 flex h-14 shrink-0 items-center gap-2 border-b bg-card px-2 sm:px-3">
|
||||
<Link href="/redaktion" class="grid size-9 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground" title="Zur Redaktion">
|
||||
<ArrowLeft class="size-5" />
|
||||
</Link>
|
||||
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="truncate text-sm font-semibold">{{ form.title || 'Neuer Beitrag' }}</span>
|
||||
<span class="hidden shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium sm:inline" :class="status.class">{{ status.label }}</span>
|
||||
</div>
|
||||
<p class="truncate text-xs text-muted-foreground" aria-live="polite">
|
||||
<template v-if="form.processing"><LoaderCircle class="inline size-3 animate-spin" /> Speichert …</template>
|
||||
<template v-else-if="dirty">Ungespeicherte Änderungen</template>
|
||||
<template v-else-if="post">Alle Änderungen gespeichert</template>
|
||||
<template v-else>Noch nicht gespeichert</template>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="hidden items-center gap-0.5 md:flex">
|
||||
<button type="button" class="grid size-9 place-items-center rounded-md text-muted-foreground hover:bg-accent disabled:opacity-40" title="Rückgängig (Strg+Z)" :disabled="!undoStack.length" @click="undo"><Undo2 class="size-4" /></button>
|
||||
<button type="button" class="grid size-9 place-items-center rounded-md text-muted-foreground hover:bg-accent disabled:opacity-40" title="Wiederholen (Strg+Y)" :disabled="!redoStack.length" @click="redo"><Redo2 class="size-4" /></button>
|
||||
<span class="mx-1 h-6 w-px bg-border" />
|
||||
<div class="flex rounded-md border p-0.5" role="group" aria-label="Vorschau">
|
||||
<button
|
||||
v-for="d in devices"
|
||||
:key="d.key"
|
||||
type="button"
|
||||
class="grid size-8 place-items-center rounded"
|
||||
:class="device === d.key ? 'bg-brand-soft text-brand-soft-foreground' : 'text-muted-foreground hover:bg-accent'"
|
||||
:title="d.label"
|
||||
:aria-pressed="device === d.key"
|
||||
@click="device = d.key"
|
||||
>
|
||||
<component :is="d.icon" class="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger class="grid size-9 place-items-center rounded-md text-muted-foreground hover:bg-accent" aria-label="Weitere Aktionen">
|
||||
<EllipsisVertical class="size-5" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" class="w-60">
|
||||
<DropdownMenuItem v-if="post?.url" as-child><a :href="post.url" target="_blank"><Eye /> Veröffentlichten Beitrag ansehen</a></DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="!isPublished || canPublish" :disabled="form.processing" @select="submit('draft')">
|
||||
<Save /> {{ isPublished ? 'Offline nehmen (Entwurf)' : 'Als Entwurf speichern' }}
|
||||
</DropdownMenuItem>
|
||||
<template v-if="canDelete">
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem class="text-destructive" @select="destroy"><Trash2 /> Beitrag löschen</DropdownMenuItem>
|
||||
</template>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
||||
<Button v-if="!isPublished" variant="outline" class="hidden sm:inline-flex" :disabled="form.processing" @click="submit('draft')">
|
||||
<Save /> Entwurf speichern
|
||||
</Button>
|
||||
<Button v-if="canPublish" :disabled="form.processing" @click="submit('publish')">
|
||||
<LoaderCircle v-if="form.processing && form.action === 'publish'" class="animate-spin" />
|
||||
<CalendarClock v-else-if="scheduled" /><Send v-else />
|
||||
<span class="hidden sm:inline">{{ scheduled ? 'Planen' : isPublished ? 'Aktualisieren' : 'Veröffentlichen' }}</span>
|
||||
</Button>
|
||||
<Button v-else :disabled="form.processing || isPending" @click="submit('submit')">
|
||||
<Send /> <span class="hidden sm:inline">{{ isPending ? 'Liegt zur Freigabe vor' : 'Zur Freigabe einreichen' }}</span>
|
||||
</Button>
|
||||
</header>
|
||||
|
||||
<div v-if="post?.review_note" class="flex gap-3 border-b border-amber-200 bg-amber-50 px-4 py-2.5 text-sm text-amber-950 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-100">
|
||||
<MessageSquareWarning class="mt-0.5 size-4 shrink-0" />
|
||||
<div><p class="font-medium">Zurückgegeben mit Anmerkung</p><p class="mt-0.5 whitespace-pre-line">{{ post.review_note }}</p></div>
|
||||
<p><span class="font-medium">Zurückgegeben mit Anmerkung:</span> <span class="whitespace-pre-line">{{ post.review_note }}</span></p>
|
||||
</div>
|
||||
|
||||
<div v-if="isPending && canPublish" class="mb-6 flex flex-wrap items-center gap-3 rounded-lg border border-brand-200 bg-brand-soft px-4 py-3 text-sm">
|
||||
<div v-if="isPending && canPublish" class="flex flex-wrap items-center gap-3 border-b bg-brand-soft px-4 py-2.5 text-sm">
|
||||
<p class="flex-1">{{ post.author }} hat diesen Beitrag zur Freigabe eingereicht.</p>
|
||||
<Button size="sm" variant="outline" class="bg-card" @click="rejecting = true"><Undo2 /> Zurückgeben</Button>
|
||||
<Button size="sm" @click="approve"><Send /> {{ scheduled ? 'Freigeben und planen' : 'Freigeben' }}</Button>
|
||||
</div>
|
||||
|
||||
<div class="grid items-start gap-6 lg:grid-cols-12">
|
||||
<Panel class="lg:col-span-8">
|
||||
<div class="grid gap-5">
|
||||
<FormField id="title" label="Titel" :error="form.errors.title">
|
||||
<Input id="title" v-model="form.title" maxlength="160" class="h-11 text-lg font-semibold" />
|
||||
</FormField>
|
||||
<FormField id="teaser" label="Kurztext" :error="form.errors.teaser" hint="Erscheint in Listen und auf der Startseite. 1–2 Sätze.">
|
||||
<Textarea id="teaser" v-model="form.teaser" rows="2" maxlength="300" />
|
||||
</FormField>
|
||||
<div class="grid gap-1.5">
|
||||
<span class="text-[13px] font-medium">Text</span>
|
||||
<RichTextEditor v-model="form.body" bordered :upload-image="uploadImage" placeholder="Beitrag schreiben …" min-height="[&_.tiptap]:min-h-72" />
|
||||
<p v-if="form.errors.body" class="text-[13px] text-destructive">{{ form.errors.body }}</p>
|
||||
<div class="flex min-h-0 flex-1">
|
||||
<!-- Arbeitsfläche: so, wie der Beitrag später aussieht -->
|
||||
<main class="min-w-0 flex-1 overflow-y-auto" @click="select(null)">
|
||||
<div class="mx-auto px-4 py-8 transition-[max-width] duration-300 sm:px-8" :class="canvasWidth">
|
||||
<!-- Titelbild -->
|
||||
<div v-if="coverPreview" class="group relative mb-6 overflow-hidden rounded-xl border" @click.stop>
|
||||
<img :src="coverPreview" alt="" class="aspect-video w-full object-cover" />
|
||||
<div class="absolute top-3 right-3 flex gap-2 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100">
|
||||
<Button size="sm" variant="outline" class="bg-card/95" @click="coverInput?.click()"><ImagePlus /> Ändern</Button>
|
||||
<Button size="icon" variant="outline" class="size-8 bg-card/95" title="Titelbild entfernen" @click="removeCover"><X /></Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Panel>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="mb-6 flex aspect-[21/9] w-full flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed text-sm text-muted-foreground transition-colors hover:border-brand-300 hover:bg-brand-soft/40 hover:text-foreground"
|
||||
@click.stop="coverInput?.click()"
|
||||
>
|
||||
<ImagePlus class="size-7" />
|
||||
<span class="font-medium">Titelbild hinzufügen</span>
|
||||
<span class="text-xs">Querformat, am besten 1600 × 900 Pixel</span>
|
||||
</button>
|
||||
<input ref="coverInput" type="file" accept="image/jpeg,image/png,image/webp" class="hidden" @change="chooseCover" />
|
||||
<p v-if="form.errors.cover" class="-mt-4 mb-4 text-[13px] text-destructive">{{ form.errors.cover }}</p>
|
||||
|
||||
<div class="grid gap-6 lg:col-span-4">
|
||||
<Panel title="Veröffentlichung">
|
||||
<div class="grid gap-4">
|
||||
<input
|
||||
v-model="form.title"
|
||||
class="w-full bg-transparent text-3xl leading-tight font-semibold tracking-tight outline-none placeholder:text-muted-foreground/60 sm:text-4xl"
|
||||
placeholder="Titel des Beitrags"
|
||||
maxlength="160"
|
||||
aria-label="Titel"
|
||||
@click.stop
|
||||
/>
|
||||
<textarea
|
||||
v-model="form.teaser"
|
||||
rows="1"
|
||||
maxlength="300"
|
||||
placeholder="Kurztext – erscheint in Listen und auf der Startseite (1–2 Sätze)"
|
||||
aria-label="Kurztext"
|
||||
class="mt-3 mb-8 w-full resize-none overflow-hidden bg-transparent text-lg leading-relaxed text-muted-foreground outline-none placeholder:text-muted-foreground/50"
|
||||
@input="autoGrow"
|
||||
@focus="autoGrow"
|
||||
@click.stop
|
||||
/>
|
||||
|
||||
<div class="@container">
|
||||
<EditorBlockList :item="working.content" root />
|
||||
</div>
|
||||
<p v-if="!working.content.blocks.length" class="mt-4 text-center text-sm text-muted-foreground">
|
||||
Rechts unter „Blöcke“ Text, Bilder, Galerien und mehr hinzufügen.
|
||||
</p>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- Seitenleiste -->
|
||||
<aside class="hidden w-[340px] shrink-0 flex-col border-l bg-card lg:flex">
|
||||
<div class="flex shrink-0 border-b px-2" role="tablist">
|
||||
<button
|
||||
v-for="tab in tabs"
|
||||
:key="tab.key"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="relative px-3 py-3 text-sm font-medium disabled:opacity-40"
|
||||
:class="sidebarTab === tab.key ? 'text-foreground' : 'text-muted-foreground hover:text-foreground'"
|
||||
:aria-selected="sidebarTab === tab.key"
|
||||
:disabled="tab.disabled"
|
||||
@click="sidebarTab = tab.key"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<span v-if="sidebarTab === tab.key" class="absolute inset-x-2 bottom-0 h-[3px] rounded-t-full bg-brand" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="min-h-0 flex-1 overflow-y-auto p-4">
|
||||
<BlockSettings v-if="sidebarTab === 'block' && selected" :key="selected.id" :block="selected" />
|
||||
<template v-else-if="sidebarTab === 'blocks'">
|
||||
<p class="mb-4 text-xs text-muted-foreground">Klicken fügt den Block unter dem ausgewählten ein. Blöcke lassen sich auch an jede Stelle ziehen.</p>
|
||||
<BlockPalette @pick="insertFromPalette" />
|
||||
</template>
|
||||
<div v-else class="grid gap-4">
|
||||
<FormField id="category" label="Kategorie" :error="form.errors.category_id">
|
||||
<NativeSelect id="category" v-model="form.category_id" :options="categoryOptions" :placeholder="canPublishWithoutCategory ? 'Ohne Kategorie' : 'Kategorie wählen …'" />
|
||||
</FormField>
|
||||
|
|
@ -186,49 +601,52 @@ const scheduled = computed(() => form.published_at && new Date(form.published_at
|
|||
Auf der Startseite hervorheben
|
||||
<Switch v-model="form.is_featured" />
|
||||
</label>
|
||||
<p class="-mt-2 text-xs text-muted-foreground">Hervorgehobene Beiträge mit Titelbild erscheinen groß im Slider.</p>
|
||||
</template>
|
||||
<p v-else class="rounded-md bg-muted px-3 py-2 text-[13px] text-muted-foreground">
|
||||
In dieser Kategorie veröffentlicht die Redaktion. Reichen Sie den Beitrag zur Freigabe ein, wenn er fertig ist.
|
||||
</p>
|
||||
|
||||
<FormField v-if="forms.length" id="form_id" label="Formular unter dem Beitrag" :error="form.errors.form_id" hint="Z. B. Anmeldung oder Rückmeldung zum Beitrag.">
|
||||
<NativeSelect id="form_id" v-model="form.form_id" :options="forms" placeholder="– kein Formular –" />
|
||||
</FormField>
|
||||
|
||||
<div class="grid gap-2 border-t pt-4">
|
||||
<Button v-if="canPublish" :disabled="form.processing || !form.title" @click="submit('publish')">
|
||||
<LoaderCircle v-if="form.processing && form.action === 'publish'" class="animate-spin" />
|
||||
<CalendarClock v-else-if="scheduled" /><Send v-else />
|
||||
{{ scheduled ? 'Planen' : isPublished ? 'Aktualisieren' : 'Veröffentlichen' }}
|
||||
</Button>
|
||||
<Button v-else :disabled="form.processing || !form.title || isPending" @click="submit('submit')">
|
||||
<Send /> {{ isPending ? 'Liegt zur Freigabe vor' : 'Zur Freigabe einreichen' }}
|
||||
</Button>
|
||||
<Button variant="outline" :disabled="form.processing || !form.title" @click="submit('draft')">
|
||||
<Save /> {{ isPublished ? 'Offline nehmen (Entwurf)' : 'Als Entwurf speichern' }}
|
||||
</Button>
|
||||
<Button v-if="canDelete" variant="ghost" class="text-destructive hover:text-destructive" @click="destroy"><Trash2 /> Löschen</Button>
|
||||
<span class="text-[13px] font-medium">Titelbild</span>
|
||||
<div class="flex gap-2">
|
||||
<Button variant="outline" size="sm" @click="coverInput?.click()"><ImagePlus /> {{ coverPreview ? 'Anderes Bild' : 'Bild hochladen' }}</Button>
|
||||
<Button v-if="coverPreview" variant="ghost" size="sm" @click="removeCover"><X /> Entfernen</Button>
|
||||
</div>
|
||||
<p class="text-xs text-muted-foreground">Wird auf 16:9 zugeschnitten.</p>
|
||||
</div>
|
||||
</div>
|
||||
</Panel>
|
||||
|
||||
<Panel v-if="forms.length" title="Formular">
|
||||
<FormField id="form_id" label="Formular unter dem Beitrag" :error="form.errors.form_id" hint="Z. B. Anmeldung zum Sommerfest oder Rückmeldung. Formulare legt die Redaktion unter „Formulare“ an.">
|
||||
<NativeSelect id="form_id" v-model="form.form_id" :options="forms" placeholder="– kein Formular –" />
|
||||
</FormField>
|
||||
</Panel>
|
||||
|
||||
<Panel title="Titelbild">
|
||||
<div class="grid gap-3">
|
||||
<div v-if="coverPreview" class="relative overflow-hidden rounded-md border">
|
||||
<img :src="coverPreview" alt="" class="aspect-video w-full object-cover" />
|
||||
<button type="button" class="absolute top-2 right-2 grid size-8 place-items-center rounded-md bg-card/90 shadow-sm hover:bg-card" title="Titelbild entfernen" @click="removeCover"><X class="size-4" /></button>
|
||||
</div>
|
||||
<Button variant="outline" @click="coverInput?.click()"><ImagePlus /> {{ coverPreview ? 'Anderes Bild wählen' : 'Bild hochladen' }}</Button>
|
||||
<input ref="coverInput" type="file" accept="image/jpeg,image/png,image/webp" class="hidden" @change="chooseCover" />
|
||||
<p class="text-xs text-muted-foreground">Querformat, am besten 1600 × 900 Pixel. Wird auf 16:9 zugeschnitten.</p>
|
||||
<p v-if="form.errors.cover" class="text-[13px] text-destructive">{{ form.errors.cover }}</p>
|
||||
</div>
|
||||
</Panel>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<!-- Kleine Bildschirme: Seitenleiste als Blatt -->
|
||||
<div class="fixed right-4 bottom-4 z-30 flex gap-2 lg:hidden">
|
||||
<Button variant="outline" class="bg-card shadow-md" @click="sidebarTab = 'post'; sheetOpen = true">Beitrag</Button>
|
||||
<Button variant="outline" class="bg-card shadow-md" @click="sidebarTab = 'blocks'; sheetOpen = true">Block hinzufügen</Button>
|
||||
<Button v-if="selected" class="shadow-md" @click="sidebarTab = 'block'; sheetOpen = true">Einstellungen</Button>
|
||||
</div>
|
||||
<Sheet v-model:open="sheetOpen">
|
||||
<SheetContent side="right" class="w-[340px] overflow-y-auto p-4 sm:max-w-[340px]">
|
||||
<SheetHeader class="p-0"><SheetTitle>{{ sidebarTab === 'block' ? 'Block' : sidebarTab === 'blocks' ? 'Blöcke' : 'Beitrag' }}</SheetTitle></SheetHeader>
|
||||
<BlockSettings v-if="sidebarTab === 'block' && selected" :key="selected.id" :block="selected" />
|
||||
<BlockPalette v-else-if="sidebarTab === 'blocks'" @pick="insertFromPalette" />
|
||||
<div v-else class="grid gap-4">
|
||||
<FormField id="category-m" label="Kategorie">
|
||||
<NativeSelect id="category-m" v-model="form.category_id" :options="categoryOptions" :placeholder="canPublishWithoutCategory ? 'Ohne Kategorie' : 'Kategorie wählen …'" />
|
||||
</FormField>
|
||||
<FormField v-if="canPublish" id="published_at-m" label="Veröffentlichen am">
|
||||
<Input id="published_at-m" v-model="form.published_at" type="datetime-local" />
|
||||
</FormField>
|
||||
<label v-if="canPublish" class="flex items-center justify-between gap-3 text-[13px] font-medium">Auf der Startseite hervorheben <Switch v-model="form.is_featured" /></label>
|
||||
</div>
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
|
||||
<Dialog v-model:open="rejecting">
|
||||
<DialogContent class="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
|
|
@ -244,5 +662,7 @@ const scheduled = computed(() => form.published_at && new Date(form.published_at
|
|||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</AppLayout>
|
||||
</div>
|
||||
|
||||
<Toaster position="bottom-left" />
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ const props = defineProps({
|
|||
related: { type: Object, required: true },
|
||||
editUrl: { type: String, default: null },
|
||||
form: { type: Object, default: null },
|
||||
content: { type: Object, default: null },
|
||||
});
|
||||
|
||||
// Lesefortschritt: Anteil des Artikels, der schon oben aus dem Bild gescrollt ist
|
||||
|
|
@ -90,7 +91,10 @@ const mailLink = () => `mailto:?subject=${encodeURIComponent(props.post.title)}&
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Mit dem Baukasten geschrieben: Blöcke wie auf Seiten -->
|
||||
<PageContent v-if="content" :content="content" />
|
||||
<div
|
||||
v-else
|
||||
class="prose prose-neutral max-w-none prose-headings:tracking-tight prose-h2:mt-10 prose-a:text-brand-text prose-blockquote:border-l-brand prose-blockquote:bg-brand-soft/50 prose-blockquote:py-1 prose-blockquote:not-italic prose-img:rounded-lg dark:prose-invert first-of-type:prose-p:text-lg"
|
||||
v-html="post.body_html"
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue