♻️ Simplify text bubble content shape
Remove html and plainText field because it was redundant Closes #386
This commit is contained in:
@ -1,21 +1,18 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { BubbleBlockType } from './enums'
|
||||
import type { TElement } from '@udecode/plate-common'
|
||||
|
||||
export const defaultTextBubbleContent: TextBubbleContent = {
|
||||
html: '',
|
||||
richText: [],
|
||||
plainText: '',
|
||||
}
|
||||
|
||||
export const textBubbleContentSchema = z.object({
|
||||
html: z.string(),
|
||||
html: z.string().optional(),
|
||||
richText: z.array(z.any()),
|
||||
plainText: z.string(),
|
||||
plainText: z.string().optional(),
|
||||
})
|
||||
|
||||
export type TextBubbleContent = z.infer<typeof textBubbleContentSchema>
|
||||
|
||||
export const textBubbleBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([BubbleBlockType.TEXT]),
|
||||
@ -23,4 +20,10 @@ export const textBubbleBlockSchema = blockBaseSchema.merge(
|
||||
})
|
||||
)
|
||||
|
||||
export type TextBubbleBlock = z.infer<typeof textBubbleBlockSchema>
|
||||
export type TextBubbleBlock = Omit<
|
||||
z.infer<typeof textBubbleBlockSchema>,
|
||||
'content'
|
||||
> & {
|
||||
content: { richText: TElement[]; html?: string; plainText?: string }
|
||||
}
|
||||
export type TextBubbleContent = TextBubbleBlock['content']
|
||||
|
@ -73,9 +73,7 @@ const chatSessionSchema = z.object({
|
||||
|
||||
const textMessageSchema = z.object({
|
||||
type: z.literal(BubbleBlockType.TEXT),
|
||||
content: textBubbleContentSchema.omit({
|
||||
richText: true,
|
||||
}),
|
||||
content: textBubbleContentSchema,
|
||||
})
|
||||
|
||||
const imageMessageSchema = z.object({
|
||||
|
Reference in New Issue
Block a user