diff --git a/bericht_card.php b/bericht_card.php index b684297..7dd2517 100644 --- a/bericht_card.php +++ b/bericht_card.php @@ -272,8 +272,8 @@ if (!$bericht) { print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -283,7 +283,7 @@ if (!$bericht) { print '
'; // Text-Optionen - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; // Zoom - print ''; - print '100%'; - print ''; - print ''; + print ''; + print '100%'; + print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print '
'; print ''; diff --git a/js/editor.js b/js/editor.js index caa8988..823131a 100644 --- a/js/editor.js +++ b/js/editor.js @@ -41,15 +41,58 @@ const pdfCanvas = document.getElementById('pdf-canvas'); let currentTool = 'select'; + /* ---------- Settings-Persistenz (localStorage) ---------- */ + const SETTINGS_KEY = 'bericht.editor.settings.v1'; + function loadSettings() { + try { + const raw = localStorage.getItem(SETTINGS_KEY); + if (!raw) return {}; + return JSON.parse(raw) || {}; + } catch (e) { return {}; } + } + function saveSettings(patch) { + try { + const cur = loadSettings(); + const merged = Object.assign({}, cur, patch); + localStorage.setItem(SETTINGS_KEY, JSON.stringify(merged)); + } catch (e) { /* localStorage full/blocked */ } + } + /* ---------- Init ---------- */ function init() { + // Gespeicherte Einstellungen anwenden — VOR Fabric-Init + const s = loadSettings(); + const colorEl = document.getElementById('tool-color'); + const strokeEl = document.getElementById('tool-stroke'); + const ffEl = document.getElementById('tool-fontfamily'); + const fsEl = document.getElementById('tool-fontsize'); + const boldEl = document.getElementById('tool-bold'); + const italicEl = document.getElementById('tool-italic'); + + if (s.color) colorEl.value = s.color; + if (s.stroke) strokeEl.value = s.stroke; + if (s.fontFamily) ffEl.value = s.fontFamily; + if (s.fontSize) fsEl.value = s.fontSize; + if (typeof s.bold !== 'undefined') boldEl.checked = !!s.bold; + if (typeof s.italic !== 'undefined') italicEl.checked = !!s.italic; + if (s.zoom) currentZoom = parseFloat(s.zoom) || 1.0; + document.getElementById('zoom-label').textContent = Math.round(currentZoom * 100) + '%'; + // Fabric initialisieren (wird beim ersten Seitenrendern dimensioniert) fabricCanvas = new fabric.Canvas('fabric-canvas', { isDrawingMode: false, selection: true, }); - fabricCanvas.freeDrawingBrush.color = document.getElementById('tool-color').value; - fabricCanvas.freeDrawingBrush.width = parseInt(document.getElementById('tool-stroke').value, 10); + fabricCanvas.freeDrawingBrush.color = colorEl.value; + fabricCanvas.freeDrawingBrush.width = parseInt(strokeEl.value, 10); + + // Listener: speichern bei jeder Änderung + colorEl.addEventListener('change', () => saveSettings({ color: colorEl.value })); + strokeEl.addEventListener('change', () => saveSettings({ stroke: parseInt(strokeEl.value, 10) })); + ffEl.addEventListener('change', () => saveSettings({ fontFamily: ffEl.value })); + fsEl.addEventListener('change', () => saveSettings({ fontSize: parseInt(fsEl.value, 10) })); + boldEl.addEventListener('change', () => saveSettings({ bold: boldEl.checked })); + italicEl.addEventListener('change', () => saveSettings({ italic: italicEl.checked })); // Erste Seite laden (wenn vorhanden) const firstThumb = document.querySelector('#bericht-page-list .page-thumb'); @@ -312,6 +355,7 @@ async function setZoom(z) { currentZoom = Math.max(0.25, Math.min(3.0, Math.round(z * 100) / 100)); document.getElementById('zoom-label').textContent = Math.round(currentZoom * 100) + '%'; + saveSettings({ zoom: currentZoom }); await rerenderCurrent(); }