mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-02 14:07:55 +00:00
Lint and tab
This commit is contained in:
parent
d76ffd343e
commit
13aa0568a6
@ -1,6 +1,6 @@
|
|||||||
import CodeMirror from "codemirror";
|
import * as CodeMirror from "codemirror";
|
||||||
import "codemirror/mode/yaml/yaml";
|
import "codemirror/mode/yaml/yaml";
|
||||||
// tslint:disable-next-line
|
// @ts-ignore
|
||||||
import codeMirrorCSS from "codemirror/lib/codemirror.css";
|
import codeMirrorCSS from "codemirror/lib/codemirror.css";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
declare global {
|
declare global {
|
||||||
@ -51,6 +51,12 @@ export class HuiYamlEditor extends HTMLElement {
|
|||||||
mode: "yaml",
|
mode: "yaml",
|
||||||
tabSize: 2,
|
tabSize: 2,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
|
extraKeys: {
|
||||||
|
Tab: (cm: CodeMirror) => {
|
||||||
|
const spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||||
|
cm.replaceSelection(spaces);
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
fireEvent(this, "yaml-changed", { value: this._value });
|
fireEvent(this, "yaml-changed", { value: this._value });
|
||||||
this.codemirror.on("changes", () => this._onChange());
|
this.codemirror.on("changes", () => this._onChange());
|
||||||
|
@ -84,7 +84,7 @@ class LovelaceFullConfigEditor extends LitElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
yamlEditor.addEventListener("yaml-changed", (e) => {
|
yamlEditor.addEventListener("yaml-changed", () => {
|
||||||
this._hash = this._hashAdded || this.yamlEditor.value.includes("#");
|
this._hash = this._hashAdded || this.yamlEditor.value.includes("#");
|
||||||
if (this._changed) {
|
if (this._changed) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user