@ -0,0 +1,5 @@
|
||||
import { AudioBubbleBlock } from './schema'
|
||||
|
||||
export const defaultAudioBubbleContent = {
|
||||
isAutoplayEnabled: true,
|
||||
} as const satisfies AudioBubbleBlock['content']
|
1
packages/schemas/features/blocks/bubbles/audio/index.ts
Normal file
1
packages/schemas/features/blocks/bubbles/audio/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './schema'
|
@ -1,6 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { BubbleBlockType } from './enums'
|
||||
import { blockBaseSchema } from '../../shared'
|
||||
import { BubbleBlockType } from '../constants'
|
||||
|
||||
export const audioBubbleContentSchema = z.object({
|
||||
url: z.string().optional(),
|
||||
@ -10,11 +10,9 @@ export const audioBubbleContentSchema = z.object({
|
||||
export const audioBubbleBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([BubbleBlockType.AUDIO]),
|
||||
content: audioBubbleContentSchema,
|
||||
content: audioBubbleContentSchema.optional(),
|
||||
})
|
||||
)
|
||||
|
||||
export const defaultAudioBubbleContent = {}
|
||||
|
||||
export type AudioBubbleBlock = z.infer<typeof audioBubbleBlockSchema>
|
||||
export type AudioBubbleContent = z.infer<typeof audioBubbleContentSchema>
|
@ -1,21 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
import { variableStringSchema } from '../../utils'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { BubbleBlockType } from './enums'
|
||||
|
||||
export const embedBubbleContentSchema = z.object({
|
||||
url: z.string().optional(),
|
||||
height: z.number().or(variableStringSchema),
|
||||
})
|
||||
|
||||
export const embedBubbleBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([BubbleBlockType.EMBED]),
|
||||
content: embedBubbleContentSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export const defaultEmbedBubbleContent: EmbedBubbleContent = { height: 400 }
|
||||
|
||||
export type EmbedBubbleBlock = z.infer<typeof embedBubbleBlockSchema>
|
||||
export type EmbedBubbleContent = z.infer<typeof embedBubbleContentSchema>
|
@ -0,0 +1,5 @@
|
||||
import { EmbedBubbleBlock } from './schema'
|
||||
|
||||
export const defaultEmbedBubbleContent = {
|
||||
height: 400,
|
||||
} as const satisfies EmbedBubbleBlock['content']
|
1
packages/schemas/features/blocks/bubbles/embed/index.ts
Normal file
1
packages/schemas/features/blocks/bubbles/embed/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './schema'
|
18
packages/schemas/features/blocks/bubbles/embed/schema.ts
Normal file
18
packages/schemas/features/blocks/bubbles/embed/schema.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { z } from 'zod'
|
||||
import { variableStringSchema } from '../../../utils'
|
||||
import { blockBaseSchema } from '../../shared'
|
||||
import { BubbleBlockType } from '../constants'
|
||||
|
||||
export const embedBubbleContentSchema = z.object({
|
||||
url: z.string().optional(),
|
||||
height: z.number().or(variableStringSchema).optional(),
|
||||
})
|
||||
|
||||
export const embedBubbleBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([BubbleBlockType.EMBED]),
|
||||
content: embedBubbleContentSchema.optional(),
|
||||
})
|
||||
)
|
||||
|
||||
export type EmbedBubbleBlock = z.infer<typeof embedBubbleBlockSchema>
|
@ -0,0 +1,7 @@
|
||||
import { ImageBubbleBlock } from './schema'
|
||||
|
||||
export const defaultImageBubbleContent = {
|
||||
clickLink: {
|
||||
alt: 'Bubble image',
|
||||
},
|
||||
} as const satisfies ImageBubbleBlock['content']
|
1
packages/schemas/features/blocks/bubbles/image/index.ts
Normal file
1
packages/schemas/features/blocks/bubbles/image/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './schema'
|
@ -1,6 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { BubbleBlockType } from './enums'
|
||||
import { BubbleBlockType } from '../constants'
|
||||
import { blockBaseSchema } from '../../shared'
|
||||
|
||||
export const imageBubbleContentSchema = z.object({
|
||||
url: z.string().optional(),
|
||||
@ -15,11 +15,8 @@ export const imageBubbleContentSchema = z.object({
|
||||
export const imageBubbleBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([BubbleBlockType.IMAGE]),
|
||||
content: imageBubbleContentSchema,
|
||||
content: imageBubbleContentSchema.optional(),
|
||||
})
|
||||
)
|
||||
|
||||
export const defaultImageBubbleContent: ImageBubbleContent = {}
|
||||
|
||||
export type ImageBubbleBlock = z.infer<typeof imageBubbleBlockSchema>
|
||||
export type ImageBubbleContent = z.infer<typeof imageBubbleContentSchema>
|
@ -3,4 +3,4 @@ export * from './embed'
|
||||
export * from './image'
|
||||
export * from './text'
|
||||
export * from './video'
|
||||
export * from './enums'
|
||||
export * from './schema'
|
||||
|
21
packages/schemas/features/blocks/bubbles/schema.ts
Normal file
21
packages/schemas/features/blocks/bubbles/schema.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { z } from 'zod'
|
||||
import { audioBubbleBlockSchema } from './audio'
|
||||
import { embedBubbleBlockSchema } from './embed'
|
||||
import { imageBubbleBlockSchema } from './image'
|
||||
import { textBubbleBlockSchema } from './text'
|
||||
import { videoBubbleBlockSchema } from './video'
|
||||
|
||||
export const bubbleBlockSchemas = [
|
||||
textBubbleBlockSchema,
|
||||
imageBubbleBlockSchema,
|
||||
videoBubbleBlockSchema,
|
||||
embedBubbleBlockSchema,
|
||||
audioBubbleBlockSchema,
|
||||
] as const
|
||||
|
||||
export const bubbleBlockSchema = z.discriminatedUnion('type', [
|
||||
...bubbleBlockSchemas,
|
||||
])
|
||||
|
||||
export type BubbleBlock = z.infer<typeof bubbleBlockSchema>
|
||||
export type BubbleBlockContent = BubbleBlock['content']
|
1
packages/schemas/features/blocks/bubbles/text/index.ts
Normal file
1
packages/schemas/features/blocks/bubbles/text/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './schema'
|
@ -1,22 +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 = {
|
||||
richText: [],
|
||||
}
|
||||
import { blockBaseSchema } from '../../shared'
|
||||
import { BubbleBlockType } from '../constants'
|
||||
|
||||
export const textBubbleContentSchema = z.object({
|
||||
html: z.string().optional(),
|
||||
richText: z.array(z.any()),
|
||||
richText: z.array(z.any()).optional(),
|
||||
plainText: z.string().optional(),
|
||||
})
|
||||
|
||||
export const textBubbleBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([BubbleBlockType.TEXT]),
|
||||
content: textBubbleContentSchema,
|
||||
content: textBubbleContentSchema.optional(),
|
||||
})
|
||||
)
|
||||
|
||||
@ -24,6 +20,5 @@ export type TextBubbleBlock = Omit<
|
||||
z.infer<typeof textBubbleBlockSchema>,
|
||||
'content'
|
||||
> & {
|
||||
content: { richText: TElement[]; html?: string; plainText?: string }
|
||||
content?: { richText?: TElement[]; html?: string; plainText?: string }
|
||||
}
|
||||
export type TextBubbleContent = TextBubbleBlock['content']
|
@ -3,3 +3,7 @@ export enum VideoBubbleContentType {
|
||||
YOUTUBE = 'youtube',
|
||||
VIMEO = 'vimeo',
|
||||
}
|
||||
|
||||
export const defaultVideoBubbleContent = {
|
||||
height: 400,
|
||||
} as const
|
@ -1,2 +1 @@
|
||||
export * from './enums'
|
||||
export * from './schemas'
|
||||
export * from './schema'
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema } from '../../baseSchemas'
|
||||
import { BubbleBlockType } from '../enums'
|
||||
import { VideoBubbleContentType } from './enums'
|
||||
import { blockBaseSchema } from '../../shared'
|
||||
import { VideoBubbleContentType } from './constants'
|
||||
import { variableStringSchema } from '../../../utils'
|
||||
import { BubbleBlockType } from '../constants'
|
||||
|
||||
export const videoBubbleContentSchema = z.object({
|
||||
url: z.string().optional(),
|
||||
@ -14,11 +14,8 @@ export const videoBubbleContentSchema = z.object({
|
||||
export const videoBubbleBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([BubbleBlockType.VIDEO]),
|
||||
content: videoBubbleContentSchema,
|
||||
content: videoBubbleContentSchema.optional(),
|
||||
})
|
||||
)
|
||||
|
||||
export const defaultVideoBubbleContent: VideoBubbleContent = {}
|
||||
|
||||
export type VideoBubbleBlock = z.infer<typeof videoBubbleBlockSchema>
|
||||
export type VideoBubbleContent = z.infer<typeof videoBubbleContentSchema>
|
Reference in New Issue
Block a user