2
0

♻️ Simplify text bubble content shape

Remove html and plainText field because it was redundant

Closes #386
This commit is contained in:
Baptiste Arnaud
2023-04-13 17:04:21 +02:00
parent 2cbf8348c3
commit e0a9824913
70 changed files with 545 additions and 1030 deletions

View File

@ -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']