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/app/components/cook-text.js
Joffrey JAFFEUX 530d9ab071
DEV: enforces eslint’s curly rule to the codebase (#10720)
eslint --fix is capable of fix it automatically for you, ensure prettier is run after eslint as eslint --fix could leave the code in an invalid prettier state.
2020-09-22 16:28:28 +02:00

45 lines
1.0 KiB
JavaScript

import Component from "@ember/component";
import { afterRender } from "discourse-common/utils/decorators";
import { ajax } from "discourse/lib/ajax";
import { cookAsync } from "discourse/lib/text";
import { loadOneboxes } from "discourse/lib/load-oneboxes";
import { resolveAllShortUrls } from "pretty-text/upload-short-url";
const CookText = Component.extend({
cooked: null,
didReceiveAttrs() {
this._super(...arguments);
cookAsync(this.rawText).then((cooked) => {
this.set("cooked", cooked);
if (this.paintOneboxes) {
this._loadOneboxes();
}
this._resolveUrls();
});
},
@afterRender
_loadOneboxes() {
const refresh = false;
loadOneboxes(
this.element,
ajax,
this.topicId,
this.categoryId,
this.siteSettings.max_oneboxes_per_post,
refresh
);
},
@afterRender
_resolveUrls() {
resolveAllShortUrls(ajax, this.siteSettings, this.element, this.opts);
},
});
CookText.reopenClass({ positionalParams: ["rawText"] });
export default CookText;