From e9ab6340fa9af769cf8b3795935f71ed1cb95f3f Mon Sep 17 00:00:00 2001 From: Rob Gordon Date: Sun, 22 Dec 2024 20:28:48 -0500 Subject: [PATCH] Text-max-width for fixed width elements --- api/prompt/_shared.ts | 2 +- app/src/lib/getElements.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/api/prompt/_shared.ts b/api/prompt/_shared.ts index 2492405ee..a2f1f0b38 100644 --- a/api/prompt/_shared.ts +++ b/api/prompt/_shared.ts @@ -39,7 +39,7 @@ export async function handleRateLimit( redis: kv, limiter: isPro ? Ratelimit.slidingWindow(3, "1m") - : Ratelimit.fixedWindow(3, "15d"), + : Ratelimit.fixedWindow(2, "30d"), }); const rateLimitKey = isPro ? `pro_${customerId}` : `unauth_${ip}`; diff --git a/app/src/lib/getElements.ts b/app/src/lib/getElements.ts index 3efdf894f..85818c45e 100644 --- a/app/src/lib/getElements.ts +++ b/app/src/lib/getElements.ts @@ -14,12 +14,18 @@ export function getElements(text: string): ElementDefinition[] { if ("source" in element.data) return element; let size: ReturnType; + let style: any = {}; if ("w" in element.data || "h" in element.data) { size = { - width: element.data.w || "label", - height: element.data.h || "label", + width: "label", + height: "label", }; + if ("w" in element.data) { + size.width = element.data.w; + style["text-max-width"] = element.data.w; + } + if ("h" in element.data) size.height = element.data.h; } else { const classes = element.classes ? Array.isArray(element.classes) @@ -39,6 +45,7 @@ export function getElements(text: string): ElementDefinition[] { return { ...element, + style, data: { ...element.data, ...size,