import { Box } from '../core/box' ; import { Context } from '../core/context' ; import { Style } from '../public/core' ; import { Atom , ToLatexOptions } from '../core/atom-class' ; /**
 * Atom for raw latex character, while in Latex editing mode
 */ export class LatexAtom extends Atom { isSuggestion : boolean ; isError : boolean ; constructor ( value , options ? ) { super ( 'latex' , { value , mode : 'latex' } ) ; this . isSuggestion = options ?. isSuggestion ?? false ; this . isError = false ; this . verbatimLatex = value ; } get computedStyle ( ) : Style { return { } ; } render ( context ) { const result = new Box ( this . value , { classes : this . isSuggestion ? 'ML__suggestion' : this . isError ? 'ML__error' : '' , type : 'latex' , maxFontSize : 1.0 , } ) ; if ( ! result ) return null ; if ( this . caret ) result . caret = this . caret ; return this . bind ( context , result ) ; } } /**
 * A group that represents a raw Latex editing zone.
 * There is only one LatexGroupAtom at a time in an expression.
 */ export class LatexGroupAtom extends Atom { constructor ( latex ) { super ( 'group' , { mode : 'latex' } ) ; this . body = [ ... latex ] . map ( ( x ) => new LatexAtom ( x ) ) ; this . skipBoundary = false ; } render ( context ) { const box = Atom . createBox ( context , this . body , { newList : true } ) ; if ( ! box ) return null ; if ( this . caret ) box . caret = this . caret ; return this . bind ( context , box ) ; } serialize ( _options ) { return this . body ?. map ( ( x ) => x . value ) . join ( '' ) ?? '' ; } }