Add ctrl/cmd +s support back to editor (#2694)

* Add ctrl/cmd +s support back to editor

* Update hui-yaml-editor.ts
This commit is contained in:
Bram Kragten 2019-02-08 04:33:53 +01:00 committed by Paulus Schoutsen
parent 102cb06d28
commit 8938ad8f8d
3 changed files with 9 additions and 1 deletions

View File

@ -9,6 +9,7 @@ declare global {
"yaml-changed": {
value: string;
};
"yaml-save": undefined;
}
}
@ -18,6 +19,9 @@ export class HuiYamlEditor extends HTMLElement {
public constructor() {
super();
CodeMirror.commands.save = (cm: CodeMirror) => {
fireEvent(cm.getWrapperElement(), "yaml-save");
};
this._value = "";
const shadowRoot = this.attachShadow({ mode: "open" });
shadowRoot.innerHTML = `

View File

@ -121,6 +121,7 @@ export class HuiEditCard extends LitElement {
<hui-yaml-editor
.value="${this._configValue!.value}"
@yaml-changed="${this._handleYamlChanged}"
@yaml-save="${this._save}"
></hui-yaml-editor>
`}
</div>

View File

@ -61,7 +61,10 @@ class LovelaceFullConfigEditor extends LitElement {
</app-toolbar>
</app-header>
<div class="content">
<hui-yaml-editor @yaml-changed="${this._yamlChanged}">
<hui-yaml-editor
@yaml-changed="${this._yamlChanged}"
@yaml-save="${this._handleSave}"
>
</hui-yaml-editor>
</div>
</app-header-layout>