2022-06-07 08:49:12 +02:00
|
|
|
import { z } from 'zod'
|
2023-04-13 17:04:21 +02:00
|
|
|
import type { TElement } from '@udecode/plate-common'
|
2023-11-08 15:34:16 +01:00
|
|
|
import { blockBaseSchema } from '../../shared'
|
|
|
|
import { BubbleBlockType } from '../constants'
|
2022-06-07 08:49:12 +02:00
|
|
|
|
|
|
|
export const textBubbleContentSchema = z.object({
|
2023-04-13 17:04:21 +02:00
|
|
|
html: z.string().optional(),
|
2023-11-08 15:34:16 +01:00
|
|
|
richText: z.array(z.any()).optional(),
|
2023-04-13 17:04:21 +02:00
|
|
|
plainText: z.string().optional(),
|
2022-06-07 08:49:12 +02:00
|
|
|
})
|
|
|
|
|
2023-03-14 16:42:12 +01:00
|
|
|
export const textBubbleBlockSchema = blockBaseSchema.merge(
|
2022-06-07 08:49:12 +02:00
|
|
|
z.object({
|
2022-06-11 07:27:38 +02:00
|
|
|
type: z.enum([BubbleBlockType.TEXT]),
|
2023-11-08 15:34:16 +01:00
|
|
|
content: textBubbleContentSchema.optional(),
|
2022-06-07 08:49:12 +02:00
|
|
|
})
|
|
|
|
)
|
|
|
|
|
2023-04-13 17:04:21 +02:00
|
|
|
export type TextBubbleBlock = Omit<
|
|
|
|
z.infer<typeof textBubbleBlockSchema>,
|
|
|
|
'content'
|
|
|
|
> & {
|
2023-11-08 15:34:16 +01:00
|
|
|
content?: { richText?: TElement[]; html?: string; plainText?: string }
|
2023-04-13 17:04:21 +02:00
|
|
|
}
|