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/helpers/dir-span.js
2020-03-12 13:29:55 -04:00

17 lines
518 B
JavaScript

import { registerUnbound } from "discourse-common/lib/helpers";
import { isRTL } from "discourse/lib/text-direction";
import { htmlSafe } from "@ember/template";
function setDir(text) {
let content = text ? text : "";
if (content && Discourse.SiteSettings.support_mixed_text_direction) {
let textDir = isRTL(content) ? "rtl" : "ltr";
return `<span dir="${textDir}">${content}</span>`;
}
return content;
}
export default registerUnbound("dir-span", function(str) {
return htmlSafe(setDir(str));
});