fix: resolve text settings not applied

This commit is contained in:
2026-02-04 18:41:43 +05:00
parent 0dd397818a
commit cc6fae9a55
5 changed files with 87 additions and 34 deletions
+26 -7
View File
@@ -4,6 +4,20 @@ import { type Panel, type TextItem } from "../lib/types/panel";
export const panelStore: Writable<Panel | undefined> = writable(undefined);
// Store for common text settings that should apply to all texts
export const textSettingsStore = writable<Partial<TextItem>>({
fontSize: 18,
fontFamily: "Arial",
color: "#ffffff",
textAlign: "left",
paddingX: 10,
verticalOffset: 0,
});
export const updateAllTextSettings = (settings: Partial<TextItem>) => {
textSettingsStore.update((current) => ({ ...current, ...settings }));
};
// Panel creation should go through panelService.updatePanelsFromTexts()
// These functions are kept for backward compatibility but should be avoided
export const createEmptyPanel = (height: number = 100): Panel => {
@@ -48,16 +62,21 @@ export const updateTextProperties = (panel: Panel, updates: Partial<TextItem>):
});
};
export const createPanelFromText = (backgroundImage: string, text: string, height: number = 100): Panel => {
export const createPanelFromText = (
backgroundImage: string,
text: string,
height: number = 100,
textSettings?: Partial<TextItem>,
): Panel => {
const newText: TextItem = {
id: uuidv4(),
text,
fontSize: 18,
fontFamily: "Arial",
color: "#ffffff",
textAlign: "center",
paddingX: 10,
verticalOffset: 0,
fontSize: textSettings?.fontSize ?? 18,
fontFamily: textSettings?.fontFamily ?? "Arial",
color: textSettings?.color ?? "#ffffff",
textAlign: textSettings?.textAlign ?? "center",
paddingX: textSettings?.paddingX ?? 10,
verticalOffset: textSettings?.verticalOffset ?? 0,
};
return {