2016-02-17 17:17:43 -05:00
|
|
|
import debounce from 'discourse/lib/debounce';
|
2015-07-14 13:34:23 -04:00
|
|
|
import highlightSyntax from 'discourse/lib/highlight-syntax';
|
2016-11-09 11:58:18 -05:00
|
|
|
import { bufferedRender } from 'discourse-common/lib/buffered-render';
|
2015-07-14 13:34:23 -04:00
|
|
|
|
2016-11-09 11:58:18 -05:00
|
|
|
export default Ember.Component.extend(bufferedRender({
|
|
|
|
buildBuffer(buffer) {
|
2015-07-14 13:34:23 -04:00
|
|
|
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();
|
2015-07-14 13:34:23 -04:00
|
|
|
}, 50).observes('value'),
|
|
|
|
|
|
|
|
_applyHighlight: function() {
|
|
|
|
highlightSyntax(this.$());
|
|
|
|
}.on('didInsertElement')
|
2016-11-09 11:58:18 -05:00
|
|
|
}));
|