2
0
Files
bot/packages/schemas/features/blocks/bubbles/text.ts
Baptiste Arnaud e0a9824913 ♻️ Simplify text bubble content shape
Remove html and plainText field because it was redundant

Closes #386
2023-04-13 17:10:59 +02:00

30 lines
789 B
TypeScript

import { z } from 'zod'
import { blockBaseSchema } from '../baseSchemas'
import { BubbleBlockType } from './enums'
import type { TElement } from '@udecode/plate-common'
export const defaultTextBubbleContent: TextBubbleContent = {
richText: [],
}
export const textBubbleContentSchema = z.object({
html: z.string().optional(),
richText: z.array(z.any()),
plainText: z.string().optional(),
})
export const textBubbleBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([BubbleBlockType.TEXT]),
content: textBubbleContentSchema,
})
)
export type TextBubbleBlock = Omit<
z.infer<typeof textBubbleBlockSchema>,
'content'
> & {
content: { richText: TElement[]; html?: string; plainText?: string }
}
export type TextBubbleContent = TextBubbleBlock['content']