0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-14 05:52:52 +01:00
discourse-custom-wizard/assets/javascripts/wizard/lib/text-lite.js.es6

29 Zeilen
878 B
Text

import loadScript from "./load-script";
import { default as PrettyText, buildOptions } from "pretty-text/pretty-text";
import Handlebars from "handlebars";
import getURL from "discourse-common/lib/get-url";
import { getOwner } from "discourse-common/lib/get-owner";
2018-02-08 05:30:55 +01:00
export function cook(text, options) {
if (!options) {
options = buildOptions({
2021-10-27 16:05:09 +02:00
getURL,
siteSettings: getOwner(this).lookup("site-settings:main"),
});
}
2018-02-08 05:30:55 +01:00
return new Handlebars.SafeString(new PrettyText(options).cook(text));
}
// everything should eventually move to async API and this should be renamed
// cook
export function cookAsync(text, options) {
if (Discourse.MarkdownItURL) {
return loadScript(Discourse.MarkdownItURL)
.then(() => cook(text, options))
.catch((e) => Ember.Logger.error(e));
2018-02-08 05:30:55 +01:00
} else {
return Ember.RSVP.Promise.resolve(cook(text));
}
}