mardi 21 novembre 2017

Referencing global libraries from an ember component

I am using ember-remarkable because I want to add both markdown parsing and syntax highlighting to my project. The only thing it's missing is line numbers, which I want to add by using this library: highlightjs-line-numbers.js

I override ember-remarkable's md-text component with the following:

import MDTextComponent from 'ember-remarkable/components/md-text';

export default MDTextComponent.extend({
  tagName: null,

  didRender() {
    this._super(...arguments);

    this.$("code[class*='language-']").each((i, block) => {
      this.$(block).addClass('hljs');
      hljs.lineNumbersBlock(block);
    });
  }
});

Everything works! However, my editor complains that hljs is not defined, even though it is available on the page.

How do I avoid this error?




Aucun commentaire:

Enregistrer un commentaire