2
0
Files
bot/packages/schemas/features/blocks/bubbles/text.ts

30 lines
789 B
TypeScript
Raw Normal View History

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({
2022-06-11 07:27:38 +02:00
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']