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/cook-text.js.es6
Guo Xiang Tan f0620e7118 FEATURE: Support [description|attachment](upload://<short-sha>) in MD take 2.
Previous attempt was missing `post_uploads` records.
2019-05-29 09:26:32 +08:00

26 lines
630 B
JavaScript

import { cookAsync } from "discourse/lib/text";
import { ajax } from "discourse/lib/ajax";
const CookText = Ember.Component.extend({
tagName: "",
cooked: null,
didReceiveAttrs() {
this._super(...arguments);
cookAsync(this.rawText).then(cooked => {
this.set("cooked", cooked);
// no choice but to defer this cause
// pretty text may only be loaded now
Ember.run.next(() =>
window
.requireModule("pretty-text/upload-short-url")
.resolveAllShortUrls(ajax)
);
});
}
});
CookText.reopenClass({ positionalParams: ["rawText"] });
export default CookText;