mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 13:33:40 +08:00
61ad959212
When editing the files for a theme in the admin dashboard, typing "cmd+s" (a common key-binding to save in most text editors) used to engage the browser's default "save page" dialogue. This commit adds a key-binding to the ace editor that saves the file. Now, the "cmd+s" (and "ctrl+s" for windows) key-binding does the same action as the save button.
58 lines
1.4 KiB
JavaScript
58 lines
1.4 KiB
JavaScript
import Component from "@ember/component";
|
|
import I18n from "I18n";
|
|
import bootbox from "bootbox";
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
import { reads } from "@ember/object/computed";
|
|
|
|
export default Component.extend({
|
|
editorId: reads("fieldName"),
|
|
|
|
@discourseComputed("fieldName")
|
|
currentEditorMode(fieldName) {
|
|
return fieldName === "css" ? "scss" : fieldName;
|
|
},
|
|
|
|
@discourseComputed("fieldName", "styles.html", "styles.css")
|
|
resetDisabled(fieldName) {
|
|
return (
|
|
this.get(`styles.${fieldName}`) ===
|
|
this.get(`styles.default_${fieldName}`)
|
|
);
|
|
},
|
|
|
|
@discourseComputed("styles", "fieldName")
|
|
editorContents: {
|
|
get(styles, fieldName) {
|
|
return styles[fieldName];
|
|
},
|
|
set(value, styles, fieldName) {
|
|
styles.setField(fieldName, value);
|
|
return value;
|
|
},
|
|
},
|
|
|
|
actions: {
|
|
reset() {
|
|
bootbox.confirm(
|
|
I18n.t("admin.customize.email_style.reset_confirm", {
|
|
fieldName: I18n.t(`admin.customize.email_style.${this.fieldName}`),
|
|
}),
|
|
I18n.t("no_value"),
|
|
I18n.t("yes_value"),
|
|
(result) => {
|
|
if (result) {
|
|
this.styles.setField(
|
|
this.fieldName,
|
|
this.styles.get(`default_${this.fieldName}`)
|
|
);
|
|
this.notifyPropertyChange("editorContents");
|
|
}
|
|
}
|
|
);
|
|
},
|
|
save() {
|
|
this.attrs.save();
|
|
},
|
|
},
|
|
});
|