shared-library/payload/blocks.ts

48 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-07-13 11:05:20 +00:00
import type { RichTextContent } from "./rich-text";
2024-07-13 08:55:10 +00:00
export interface TranscriptBlock extends GenericBlock {
lines: (LineBlock | CueBlock)[];
blockType: "transcriptBlock";
}
export interface BreakBlock extends GenericBlock {
type: "Scene break" | "Empty space" | "Solid line" | "Dotted line";
blockType: "breakBlock";
}
export interface SectionBlock extends GenericBlock {
content: RichTextContent;
blockType: "sectionBlock";
}
export interface CueBlock extends GenericBlock {
content: RichTextContent;
blockType: "cueBlock";
}
export interface LineBlock extends GenericBlock {
content: RichTextContent;
blockType: "lineBlock";
}
export interface GenericBlock {
id?: string | null;
blockName?: string | null;
blockType: string;
}
export const isBlockTranscriptBlock = (block: GenericBlock): block is TranscriptBlock =>
block.blockType === "transcriptBlock";
export const isBlockBreakBlock = (block: GenericBlock): block is BreakBlock =>
block.blockType === "breakBlock";
export const isBlockSectionBlock = (block: GenericBlock): block is SectionBlock =>
block.blockType === "sectionBlock";
export const isBlockCueBlock = (block: GenericBlock): block is CueBlock =>
block.blockType === "cueBlock";
export const isBlockLineBlock = (block: GenericBlock): block is LineBlock =>
block.blockType === "lineBlock";