Lint and tab

This commit is contained in:
Bram Kragten 2019-01-29 17:59:42 +01:00
parent d76ffd343e
commit 13aa0568a6
2 changed files with 9 additions and 3 deletions

View File

@ -1,6 +1,6 @@
import CodeMirror from "codemirror";
import * as CodeMirror from "codemirror";
import "codemirror/mode/yaml/yaml";
// tslint:disable-next-line
// @ts-ignore
import codeMirrorCSS from "codemirror/lib/codemirror.css";
import { fireEvent } from "../../../common/dom/fire_event";
declare global {
@ -51,6 +51,12 @@ export class HuiYamlEditor extends HTMLElement {
mode: "yaml",
tabSize: 2,
autofocus: true,
extraKeys: {
Tab: (cm: CodeMirror) => {
const spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
cm.replaceSelection(spaces);
},
},
});
fireEvent(this, "yaml-changed", { value: this._value });
this.codemirror.on("changes", () => this._onChange());

View File

@ -84,7 +84,7 @@ class LovelaceFullConfigEditor extends LitElement {
return;
}
});
yamlEditor.addEventListener("yaml-changed", (e) => {
yamlEditor.addEventListener("yaml-changed", () => {
this._hash = this._hashAdded || this.yamlEditor.value.includes("#");
if (this._changed) {
return;