<commit_before>///<reference path="../../../node_modules/@types/mathjax/index.d.ts"/>


import {Component, AfterViewInit, Input, Output, EventEmitter, ElementRef} from '@angular/core';

import {LatexEquation} from '../latex-equation';
import {WindowRefService} from '../services/window-ref/window-ref.service';


@Component( {
  selector: 'app-math-element',
  templateUrl: './math-element.component.html',
  styleUrls: [ './math-element.component.css' ]
} )
export class MathElementComponent implements AfterViewInit {


  @Input() latexEquation: LatexEquation;

  @Output() OnClick = new EventEmitter<LatexEquation>();



  constructor( private elem: ElementRef, private windowRef: WindowRefService ) {


  }


  ngAfterViewInit(): void {



    // noinspection TypeScriptUnresolvedVariable
    // MathJax is attached to global window object accesssed via WindowRef service
    this.windowRef.nativeWindow.MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, this.elem.nativeElement ] );
  }

  emitLatexEquation(): void {
    this.OnClick.emit( this.latexEquation );
    console.log( 'MathElementComponent--emitLatexEquation: emitted click event' );
  }


  getDisplayStyleEquation( ): string {
    return '$$\\bf '.concat( this.latexEquation.equation).concat( ' $$' );
  }
}<commit_msg>added typesetFinished event and associated mathjax callbacks<commit_after>///<reference path="../../../node_modules/@types/mathjax/index.d.ts"/>


import {Component, AfterViewInit, Input, Output, EventEmitter, ElementRef} from '@angular/core';

import {LatexEquation} from '../latex-equation';
import {WindowRefService} from '../services/window-ref/window-ref.service';


@Component( {
  selector: 'app-math-element',
  templateUrl: './math-element.component.html',
  styleUrls: [ './math-element.component.css' ]
} )
export class MathElementComponent implements AfterViewInit {


  @Input() latexEquation: LatexEquation;

  @Output() OnClick = new EventEmitter<LatexEquation>();

  @Output() typesetFinished = new EventEmitter<boolean>()




  constructor( private elem: ElementRef, private windowRef: WindowRefService ) {


  }


  ngAfterViewInit(): void {



    // noinspection TypeScriptUnresolvedVariable
    // MathJax is attached to global window object accesssed via WindowRef service
    this.windowRef.nativeWindow.MathJax.Hub.Queue(
      [ 'Typeset', MathJax.Hub, this.elem.nativeElement ],
      ()=> this.typesetFinished_callback() );
  }

  typesetFinished_callback(): void {

    this.typesetFinished.emit( true);
  }

  emitLatexEquation(): void {
    this.OnClick.emit( this.latexEquation );
    console.log( 'MathElementComponent--emitLatexEquation: emitted click event' );
  }


  getDisplayStyleEquation( ): string {
    return '$$\\bf '.concat( this.latexEquation.equation).concat( ' $$' );
  }
}
{'fraction_non_alphanumeric': 0.14061384725196288, 'fraction_numerical': 0.0, 'mean_word_length': 4.219739292364991, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1887926', 'n_tokens_mistral': 878, 'n_tokens_neox': 807, 'n_words': 173}