import { BlockId } from "./BlockId/BlockId" import { DateContent } from "./DateContent/DateContent" import { Equation } from "./Equation/Equation" import { Icon } from "./Icon/Icon" import { Mention } from "./Mention/Mention" import { PageId } from "./PageId/PageId" import { RichText } from "./RichText/RichText" import { UnsupportedContent } from "./Unsupported/UnsupportedContent" import {User} from "./User/User"; export abstract class ContentTypeFactory { static transformWithType(blockRawJson: any) { if (!blockRawJson || !blockRawJson.type) { console.log('UN---------- ') return new UnsupportedContent() } if (blockRawJson.raw) { const alreadyTypedObject = blockRawJson return alreadyTypedObject } switch (blockRawJson.type) { case 'block_id': return new BlockId(blockRawJson) case 'caption': return new RichText(blockRawJson) case 'mention': return new Mention(blockRawJson) case 'text': return new RichText(blockRawJson) case 'date': return new DateContent(blockRawJson) case 'equation': return new Equation(blockRawJson) case 'icon': return new Icon(blockRawJson) case 'user': return new User(blockRawJson) case 'page_id': return new PageId(blockRawJson) } return new UnsupportedContent() } }