Skip to content

Commit

Permalink
Text-max-width for fixed width elements
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-gordon committed Dec 23, 2024
1 parent 7bcb0a7 commit e9ab634
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/prompt/_shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down
11 changes: 9 additions & 2 deletions app/src/lib/getElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ export function getElements(text: string): ElementDefinition[] {
if ("source" in element.data) return element;

let size: ReturnType<typeof getSize>;
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)
Expand All @@ -39,6 +45,7 @@ export function getElements(text: string): ElementDefinition[] {

return {
...element,
style,
data: {
...element.data,
...size,
Expand Down

0 comments on commit e9ab634

Please sign in to comment.