Move save to the instance

This commit is contained in:
Bram Kragten 2019-01-30 20:00:13 +01:00
parent 95e9d6164d
commit e789380126

View File

@ -19,9 +19,6 @@ export class HuiYamlEditor extends HTMLElement {
public constructor() {
super();
CodeMirror.commands.save = () => {
fireEvent(this, "yaml-save");
};
this._value = "";
const shadowRoot = this.attachShadow({ mode: "open" });
shadowRoot.innerHTML = `
@ -77,6 +74,9 @@ export class HuiYamlEditor extends HTMLElement {
},
},
});
this.codemirror.commands.save = () => {
fireEvent(this, "yaml-save");
};
fireEvent(this, "yaml-changed", { value: this._value });
this.codemirror.on("changes", () => this._onChange());
} else {