This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/pagedown-editor.js.es6

26 lines
746 B
JavaScript

import { observes, on } from 'ember-addons/ember-computed-decorators';
import loadScript from 'discourse/lib/load-script';
export default Ember.Component.extend({
classNameBindings: [':pagedown-editor'],
@on("didInsertElement")
_initializeWmd() {
loadScript('defer/html-sanitizer-bundle').then(() => {
this.$('.wmd-input').data('init', true);
this._editor = Discourse.Markdown.createEditor({ containerElement: this.element });
this._editor.run();
Ember.run.scheduleOnce('afterRender', this, this._refreshPreview);
});
},
@observes("value")
observeValue() {
Ember.run.scheduleOnce('afterRender', this, this._refreshPreview);
},
_refreshPreview() {
this._editor.refreshPreview();
}
});