Vorschau: Bild-speichern in die Großansicht + Kugelschreiber-Optik (blau, dicker, dezentes Papier)

This commit is contained in:
Lucas Orth
2026-08-24 13:01:02 +02:00
parent 94e79f12ac
commit 21a43a9d88

View File

@@ -80,7 +80,7 @@ const NeuAuftrag = defineComponent({
// Kuvert-Adresse je Empfänger: '5zeilen' (5 Zeilen) oder 'individuell' (einzeilig).
adressModus: '5zeilen', kuverts: false, realistic: true, customer_email: '', text: '', rows: [leereZeile()],
importOpen: false, importText: '',
docs: [], previewSession: null, pLaedt: false, msg: '', err: '', hinweis: '', lb: '',
docs: [], previewSession: null, pLaedt: false, msg: '', err: '', hinweis: '', lb: '', lbDoc: null,
});
// Kuverts nur generieren, wenn angehakt (Beschriftung aus der Empfängeradresse).
const kuvertPayload = () => (neu.kuverts
@@ -324,11 +324,19 @@ const NeuAuftrag = defineComponent({
const sel = (val, opts, on, extra) => h('select', { style: WSELECT + 'width:100%;' + (extra || ''), value: val, onChange: on },
opts.map((o) => h('option', { value: o.v, selected: String(val) === String(o.v) }, o.t)));
const svgUri = (svg) => { try { return 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svg))); } catch { return null; } };
// Vorschau-Optik „Kugelschreiber": NUR für die Anzeige die schwarzen Striche
// in Kuli-Blau umfärben. Die generierten/gecachten SVGs bleiben schwarz –
// Vorschau-Optik „Kugelschreiber": NUR für die Anzeige – Striche in Kuli-Blau,
// etwas dicker, und der weiße Untergrund wird transparent, damit das dezente
// Papier (CSS) durchscheint. Die generierten/gecachten SVGs bleiben schwarz –
// die Produktion (die die gezeigten Dokumente 1:1 übernimmt) ist unberührt.
const BALLPOINT = '#1a2a6c';
const inkify = (svg) => (typeof svg === 'string' ? svg.replace(/stroke="#0{3,6}"/gi, `stroke="${BALLPOINT}"`) : svg);
const inkify = (svg) => (typeof svg === 'string'
? svg
.replace(/stroke="#0{3,6}"/gi, `stroke="${BALLPOINT}"`)
.replace(/stroke-width="0\.6"/gi, 'stroke-width="0.9"')
.replace(/fill="#FFFFFF"/gi, 'fill="transparent"')
: svg);
// Dezentes, leicht strukturiertes Papier hinter der (nun transparenten) Vorschau.
const PAPIER = "background-color:#fbfaf6;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='0.05'/%3E%3C/svg%3E\");";
// Vorschau als PNG speichern (wie in der App); Fallback: SVG.
function bildSpeichern(d) {
const svg = d && typeof d.svg === 'string' ? inkify(d.svg) : null;
@@ -341,7 +349,7 @@ const NeuAuftrag = defineComponent({
const cv = document.createElement('canvas');
cv.width = (img.naturalWidth || 800) * scale; cv.height = (img.naturalHeight || 1130) * scale;
const ctx = cv.getContext('2d');
ctx.fillStyle = '#fff'; ctx.fillRect(0, 0, cv.width, cv.height);
ctx.fillStyle = '#fbfaf6'; ctx.fillRect(0, 0, cv.width, cv.height);
ctx.drawImage(img, 0, 0, cv.width, cv.height);
cv.toBlob((blob) => {
if (!blob) return;
@@ -363,12 +371,9 @@ const NeuAuftrag = defineComponent({
const seite = (d?.page && d?.pageCount) ? ` · Seite ${d.page}/${d.pageCount}` : '';
const txt = (d?.art === 'umschlag' ? '✉ Kuvert' : '📄 Schriftstück') + seite;
return h('div', { style: 'display:flex;flex-direction:column;align-items:center;gap:4px;' }, [
src ? h('img', { src, onClick: () => { neu.lb = src; }, style: 'width:100%;max-height:260px;object-fit:contain;border-radius:6px;background:#fff;cursor:zoom-in;box-shadow:0 1px 3px rgba(0,0,0,.12);' })
src ? h('img', { src, onClick: () => { neu.lb = src; neu.lbDoc = d; }, style: 'width:100%;max-height:260px;object-fit:contain;border-radius:6px;' + PAPIER + 'cursor:zoom-in;box-shadow:0 1px 3px rgba(0,0,0,.12);' })
: h('div', { style: 'width:100%;height:200px;border-radius:6px;display:flex;align-items:center;justify-content:center;background:#fff;color:var(--foreground-subdued);' }, 'Dok.'),
h('div', { style: 'display:flex;align-items:center;gap:8px;' }, [
h('span', { style: 'font-size:11px;color:var(--foreground-subdued);' }, txt),
svg ? h('button', { type: 'button', onClick: () => bildSpeichern(d), style: 'cursor:pointer;border:1px solid var(--border-normal);background:var(--background-page);border-radius:6px;padding:2px 8px;font:inherit;font-size:11px;color:var(--foreground-normal);' }, '💾 Speichern') : null,
]),
h('span', { style: 'font-size:11px;color:var(--foreground-subdued);' }, txt),
]);
};
// Weißes, einzeiliges Zellenfeld (feste Breite → Zeile scrollt bei Bedarf).
@@ -703,9 +708,15 @@ const NeuAuftrag = defineComponent({
ansicht.value === 'signatur' ? signaturPanel() : (!geladen.value ? subdued('Lädt …') : formular())),
neu.lb ? h(Teleport, { to: 'body' }, [
h('div', {
onClick: () => { neu.lb = ''; },
style: 'position:fixed;inset:0;background:rgba(0,0,0,.8);z-index:1100;display:flex;align-items:center;justify-content:center;padding:4vh 4vw;cursor:zoom-out;',
}, [h('img', { src: neu.lb, style: 'max-width:100%;max-height:90vh;object-fit:contain;background:#fff;border-radius:8px;' })]),
onClick: () => { neu.lb = ''; neu.lbDoc = null; },
style: 'position:fixed;inset:0;background:rgba(0,0,0,.8);z-index:1100;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:4vh 4vw;cursor:zoom-out;',
}, [
h('img', { src: neu.lb, onClick: (e) => e.stopPropagation(),
style: 'max-width:100%;max-height:82vh;object-fit:contain;border-radius:8px;cursor:default;' + PAPIER }),
// Aktion wie in der App: „Bild speichern" unter der großen Vorschau.
neu.lbDoc ? h('button', { type: 'button', onClick: (e) => { e.stopPropagation(); bildSpeichern(neu.lbDoc); },
style: 'cursor:pointer;border:none;background:#fff;color:#1a1a1a;border-radius:8px;padding:10px 20px;font:inherit;font-size:14px;font-weight:600;box-shadow:0 2px 8px rgba(0,0,0,.3);' }, '💾 Bild speichern') : null,
]),
]) : null,
],
});