discourse-data-explorer/assets/javascripts/discourse/components/hljs-code-view.js.es6

20 lines
635 B
Plaintext
Raw Normal View History

2016-02-17 17:17:43 -05:00
import debounce from 'discourse/lib/debounce';
import highlightSyntax from 'discourse/lib/highlight-syntax';
2016-11-09 11:58:18 -05:00
import { bufferedRender } from 'discourse-common/lib/buffered-render';
2016-11-09 11:58:18 -05:00
export default Ember.Component.extend(bufferedRender({
buildBuffer(buffer) {
buffer.push("<pre><code class='" + this.get('codeClass') + "'>");
buffer.push(Handlebars.Utils.escapeExpression(this.get('value')));
buffer.push("</code></pre>");
},
2016-02-17 17:17:43 -05:00
_refreshHighlight: debounce(function() {
2016-11-09 11:58:18 -05:00
this.rerenderBuffer();
}, 50).observes('value'),
_applyHighlight: function() {
highlightSyntax(this.$());
}.on('didInsertElement')
2016-11-09 11:58:18 -05:00
}));