import Ember from 'ember';

const {
  Component,
  on,
  observer,
  get,
  run: { once }
} = Ember;

export default Component.extend({
  tagName: 'span',
  classNames: 'latex-maths',

  expr: null,
  display: false,

  _initialTypeset: on('didInsertElement', function() {
    this.typeset();
  }),

  _observer: observer('expr', 'display', function() {
    once(this, 'typeset');
  }),

  typeset() {
    const expr = get(this, 'expr');
    const el = get(this, 'element');
    const display = get(this, 'display');

    if (expr && el) {
      window.katex.render(expr, el, {
        displayMode: display
      });
    }
  }
});

import Ember from 'ember';

const {
  Component,
  on,
  observer,
  get,
  run: { once }
} = Ember;

export default Component.extend({
  tagName: 'span',
  classNames: 'latex-maths',

  expr: null,
  display: false,
  throwOnError: true,
  errorColor: "#cc0000",

  _initialTypeset: on('didInsertElement', function() {
    this.typeset();
  }),

  _observer: observer('expr', 'display', function() {
    once(this, 'typeset');
  }),

  typeset() {
    const expr = get(this, 'expr');
    const el = get(this, 'element');
    const display = get(this, 'display');

    if (expr && el) {
      window.katex.render(expr, el, {
        displayMode: display,
        throwOnError: throwOnError,
        errorColor: errorColor,
      });
    }
  }
});

Add Katex options to component
Add Katex options to component

Latex allows the following 2 options:

throwOnError
errorColor

This addition allows these options to be specified in the latex-maths component, defaulting to their standard default values if they are not specified.
