import { PageId } from "../ContentTypes/PageId/PageId"; import { IBlock } from "./Block.interface"; export abstract class Block implements IBlock { readonly raw: any readonly object = 'block' readonly id: string; readonly parent: PageId readonly createdTime: Date readonly lastEditedTime: Date readonly createdBy: string readonly lastEditedBy: string readonly archived: boolean readonly type: string readonly content: unknown children: IBlock[] prevBlock: IBlock | null; nextBlock: IBlock | null; constructor(blockJson: any) { this.raw = blockJson this.id = blockJson['id'] this.createdTime = blockJson['created_time'] ? new Date(blockJson['created_time']) : new Date(0) this.lastEditedTime = blockJson['last_edited_time'] ? new Date(blockJson['last_edited_time']) : new Date(0) this.createdBy = blockJson['created_by'] ? blockJson['created_by'].id : '' this.lastEditedBy = blockJson['last_edited_by'] ? blockJson['last_edited_by'].id : '' this.parent = blockJson['parent'] this.archived = blockJson['archived'] this.type = blockJson['type'] this.content = blockJson[this.type] this.children = [] this.prevBlock = null this.nextBlock = null } abstract toHTML(): string }