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

View File

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

View File

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