2018-10-10 17:26:23 +05:30
|
|
|
import debounce from "discourse/lib/debounce";
|
|
|
|
|
import highlightSyntax from "discourse/lib/highlight-syntax";
|
|
|
|
|
import { bufferedRender } from "discourse-common/lib/buffered-render";
|
2015-07-14 10:34:23 -07:00
|
|
|
|
2018-10-10 17:26:23 +05:30
|
|
|
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>");
|
|
|
|
|
},
|
2015-07-14 10:34:23 -07:00
|
|
|
|
2018-10-10 17:26:23 +05:30
|
|
|
_refreshHighlight: debounce(function() {
|
|
|
|
|
this.rerenderBuffer();
|
|
|
|
|
}, 50).observes("value"),
|
2015-07-14 10:34:23 -07:00
|
|
|
|
2018-10-10 17:26:23 +05:30
|
|
|
_applyHighlight: function() {
|
|
|
|
|
highlightSyntax(this.$());
|
|
|
|
|
}.on("didInsertElement")
|
|
|
|
|
})
|
|
|
|
|
);
|