⚡ (embedBubble) Enable variable embed height
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
import { z } from 'zod'
|
||||
import { variableStringSchema } from '../../utils'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { BubbleBlockType } from './enums'
|
||||
|
||||
export const embedBubbleContentSchema = z.object({
|
||||
url: z.string().optional(),
|
||||
height: z.number(),
|
||||
height: z.number().or(variableStringSchema),
|
||||
})
|
||||
|
||||
export const embedBubbleBlockSchema = blockBaseSchema.and(
|
||||
|
@ -84,7 +84,11 @@ const audioMessageSchema = z.object({
|
||||
|
||||
const embedMessageSchema = z.object({
|
||||
type: z.enum([BubbleBlockType.EMBED]),
|
||||
content: embedBubbleContentSchema,
|
||||
content: embedBubbleContentSchema
|
||||
.omit({
|
||||
height: true,
|
||||
})
|
||||
.and(z.object({ height: z.number().optional() })),
|
||||
})
|
||||
|
||||
const chatMessageSchema = z
|
||||
|
@ -7,3 +7,9 @@ export const schemaForType =
|
||||
<S extends z.ZodType<T, any, any>>(arg: S) => {
|
||||
return arg
|
||||
}
|
||||
|
||||
export const variableStringSchema = z.custom<`{{${string}}}`>((val) =>
|
||||
/^{{.+}}$/g.test(val as string)
|
||||
)
|
||||
|
||||
export type VariableString = z.infer<typeof variableStringSchema>
|
||||
|
Reference in New Issue
Block a user