make cook-text async friendly
This commit is contained in:
parent
bd7fbe6ad9
commit
301731ef24
|
@ -1,4 +1,18 @@
|
||||||
import { cook } from 'discourse/lib/text';
|
import { cookAsync } from 'discourse/lib/text';
|
||||||
|
import guid from 'pretty-text/guid';
|
||||||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||||
|
|
||||||
registerUnbound('cook-text', cook);
|
function cookText(text) {
|
||||||
|
const id = `${guid().replace(/-/g, '')}`;
|
||||||
|
|
||||||
|
cookAsync(text)
|
||||||
|
.then(cooked => {
|
||||||
|
Em.run.next(()=>{
|
||||||
|
$('#' + id).html(cooked.string);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Handlebars.SafeString(`<div id='${id}'></div>`);
|
||||||
|
}
|
||||||
|
|
||||||
|
registerUnbound('cook-text', cookText);
|
||||||
|
|
Loading…
Reference in New Issue