import { SequenceEvent } from "@fluidframework/sequence" ; import { emptyObject } from "../util" ; import { Layout } from "./layout" ; export interface IFormatterState { } export abstract class Formatter < TState extends IFormatterState > { public abstract begin ( layout , init , prevState ) ; public abstract visit ( layout , state ) ; public abstract end ( layout , state ) ; public toString ( ) { return this . constructor . name ; } } export abstract class RootFormatter < TState extends IFormatterState > extends Formatter < TState > { public abstract onChange ( layout , e ) ; public prepare ( layout , start , end ) { return { start , end } ; } } export class BootstrapFormatter < TFormatter extends RootFormatter < TState > , TState extends IFormatterState > extends RootFormatter < IFormatterState > { constructor ( private readonly formatter ) { super ( ) ; } public begin ( ) { throw new Error ( ) ; } public visit ( layout , state ) { layout . pushFormat ( this . formatter , emptyObject ) ; return { state , consumed : false } ; } public end ( ) { throw new Error ( ) ; } public onChange ( layout , e ) { this . formatter . onChange ( layout , e ) ; } public prepare ( layout , start , end ) { return this . formatter . prepare ( layout , start , end ) ; } }