Files
SPA-landing/symbols/js/text-generator/state.js
architeur acfd23ec57 Fix Gitea Issue #1: Text-Generator Verbesserungen
- Rahmenform Standard auf 'Rechteck' gesetzt (statt 'Keiner')
- Pfeile werden nun korrekt im SVG-Bereich dargestellt (viewBox + Padding)
- Numerische Eingabefelder neben allen Slidern hinzugefügt
- Text-Positionierung im Rahmen ermöglicht (horizontal + vertikal)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-14 21:51:20 +01:00

100 lines
2.3 KiB
JavaScript

/**
* Text-Generator State Management
* Zentrale Zustandsverwaltung für alle Text-Symbol-Einstellungen
*/
const TextGenState = {
// Aktuelle Werte
current: {
text: 'Text',
fontSize: 14,
textColor: '#000000',
frameColor: '#000000',
shape: 'rect',
frameScale: 120,
paddingTop: 10,
paddingRight: 10,
paddingBottom: 10,
paddingLeft: 10,
textAlignX: 'center',
textAlignY: 'center',
lineStyle: 'solid',
lineWeight: 2,
arrow: 'none',
arrowLength: 40,
arrowAngle: 0,
arrowBend: 50,
arrowSize: 10,
arrowTipLength: 15
},
// Standardwerte für Reset
defaults: {
text: 'Text',
fontSize: 14,
textColor: '#000000',
frameColor: '#000000',
shape: 'rect',
frameScale: 120,
paddingTop: 10,
paddingRight: 10,
paddingBottom: 10,
paddingLeft: 10,
textAlignX: 'center',
textAlignY: 'center',
lineStyle: 'solid',
lineWeight: 2,
arrow: 'none',
arrowLength: 40,
arrowAngle: 0,
arrowBend: 50,
arrowSize: 10,
arrowTipLength: 15
},
// State aktualisieren
set(key, value) {
if (key in this.current) {
this.current[key] = value;
this.onChange(key, value);
}
},
// Mehrere Werte setzen
setMultiple(updates) {
Object.entries(updates).forEach(([key, value]) => {
if (key in this.current) {
this.current[key] = value;
}
});
this.onChange('multiple', updates);
},
// Auf Defaults zurücksetzen
reset() {
this.current = { ...this.defaults };
this.onChange('reset', this.current);
},
// Getter
get(key) {
return this.current[key];
},
// Alle Werte
getAll() {
return { ...this.current };
},
// Change-Callback (wird von außen gesetzt)
onChange: function(key, value) {
// Wird von ui-bindings überschrieben
}
};
// Export für ES6 Module und globalen Zugriff
if (typeof module !== 'undefined' && module.exports) {
module.exports = TextGenState;
}
window.TextGenState = TextGenState;