fix: resolve text settings not applied
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user