REFACTOR: Remove `Discourse.SiteSettings` from highlightSyntax
This commit is contained in:
parent
656abe22c7
commit
98fee7aa50
|
@ -6,6 +6,6 @@ export default Component.extend({
|
|||
@on("didInsertElement")
|
||||
@observes("code")
|
||||
_refresh: function() {
|
||||
highlightSyntax($(this.element));
|
||||
highlightSyntax($(this.element), this.siteSettings);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -321,7 +321,8 @@ const Theme = RestModel.extend({
|
|||
}
|
||||
}
|
||||
);
|
||||
highlightSyntax();
|
||||
// TODO: Models shouldn't be updating the DOM
|
||||
highlightSyntax(undefined, this.siteSettings);
|
||||
} else {
|
||||
return this.save({ remote_update: true }).then(() =>
|
||||
this.set("changed", false)
|
||||
|
|
|
@ -9,9 +9,14 @@ export default {
|
|||
initialize(container) {
|
||||
withPluginApi("0.1", api => {
|
||||
const siteSettings = container.lookup("site-settings:main");
|
||||
api.decorateCooked(highlightSyntax, {
|
||||
id: "discourse-syntax-highlighting"
|
||||
});
|
||||
api.decorateCooked(
|
||||
elem => {
|
||||
return highlightSyntax(elem, siteSettings);
|
||||
},
|
||||
{
|
||||
id: "discourse-syntax-highlighting"
|
||||
}
|
||||
);
|
||||
|
||||
api.decorateCookedElement(
|
||||
elem => {
|
||||
|
|
|
@ -3,8 +3,8 @@ let _moreLanguages = [];
|
|||
|
||||
import loadScript from "discourse/lib/load-script";
|
||||
|
||||
export default function highlightSyntax($elem) {
|
||||
const selector = Discourse.SiteSettings.autohighlight_all_code
|
||||
export default function highlightSyntax($elem, siteSettings) {
|
||||
const selector = siteSettings.autohighlight_all_code
|
||||
? "pre code"
|
||||
: "pre code[class]",
|
||||
path = Discourse.HighlightJSPath;
|
||||
|
|
Loading…
Reference in New Issue