diff --git a/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts b/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts index fce0dc3ee3..033e4a7de1 100644 --- a/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts +++ b/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts @@ -8,6 +8,7 @@ import { mdiOpenInNew, } from "@mdi/js"; import deepFreeze from "deep-freeze"; +import { dump, load } from "js-yaml"; import { CSSResultGroup, LitElement, @@ -23,6 +24,7 @@ import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-button"; import "../../../../components/ha-button-menu-new"; import "../../../../components/ha-circular-progress"; +import "../../../../components/ha-code-editor"; import "../../../../components/ha-dialog"; import "../../../../components/ha-dialog-header"; import "../../../../components/ha-icon-button"; @@ -82,7 +84,7 @@ export class HuiDialogEditCard @query("hui-card-editor") private _cardEditorEl?: HuiCardElementEditor; - @state() private _yamlMode = true; + @state() private _yamlMode = false; @state() private _documentationURL?: string; @@ -92,8 +94,7 @@ export class HuiDialogEditCard public async showDialog(params: EditCardDialogParams): Promise { this._params = params; - this._yamlMode = true; - this._guiModeAvailable = true; + this._yamlMode = false; const containerConfig = findLovelaceContainer( params.lovelaceConfig, @@ -275,17 +276,33 @@ export class HuiDialogEditCard
- - + ${this._yamlMode + ? html` + + ` + : html` + + + `}
${this._isInSection @@ -361,17 +378,20 @@ export class HuiDialogEditCard ev.stopPropagation(); } + private _handleYAMLChanged(ev: CustomEvent) { + this._cardConfig = load(ev.detail.value) as LovelaceCardConfig; + this._dirty = true; + } + private _handleConfigChanged(ev: HASSDomEvent) { this._cardConfig = deepFreeze(ev.detail.config); this._error = ev.detail.error; - this._guiModeAvailable = ev.detail.guiModeAvailable; this._dirty = true; } private _handleGUIModeChanged(ev: HASSDomEvent): void { ev.stopPropagation(); this._yamlMode = ev.detail.guiMode; - this._guiModeAvailable = ev.detail.guiModeAvailable; } private _opened() {