import { Document } from "./Document" ; import { RTFJSError } from "./Helper" ; import { Parser } from "./parser/Parser" ; import { IContainerElement , Renderer } from "./renderer/Renderer" ; export interface ISettings { onHyperlink ? ( create , hyperlink ) : IContainerElement ; param isLegacy param create return onPicture ? ( isLegacy , create ) : HTMLElement ; onImport ? ( relUrls , callback ) : void ; } export class DocumentFacade { private _document : Document ; private _renderer : Renderer ; private _parsed : Promise < void > ; constructor ( blob , settings ) { this . _document = new Document ( settings ) ; this . _renderer = new Renderer ( this . _document ) ; const parser = new Parser ( this . _document , blob , this . _renderer ) ; this . _parsed = parser . parse ( ) ; } public metadata ( ) { return this . _document . _meta ; } public render ( ) { return this . _parsed . then ( ( ) => { return this . _renderer . buildDom ( ) ; } ) . catch ( ( error ) => { throw new RTFJSError ( error ) ; } ) ; } }