From 8938ad8f8d783c586adf43faff16e4180a51486b Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 8 Feb 2019 04:33:53 +0100 Subject: [PATCH] Add ctrl/cmd +s support back to editor (#2694) * Add ctrl/cmd +s support back to editor * Update hui-yaml-editor.ts --- src/panels/lovelace/components/hui-yaml-editor.ts | 4 ++++ src/panels/lovelace/editor/card-editor/hui-edit-card.ts | 1 + src/panels/lovelace/hui-editor.ts | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/panels/lovelace/components/hui-yaml-editor.ts b/src/panels/lovelace/components/hui-yaml-editor.ts index f83d392bee..ae2a9b65ad 100644 --- a/src/panels/lovelace/components/hui-yaml-editor.ts +++ b/src/panels/lovelace/components/hui-yaml-editor.ts @@ -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 = ` diff --git a/src/panels/lovelace/editor/card-editor/hui-edit-card.ts b/src/panels/lovelace/editor/card-editor/hui-edit-card.ts index 3898e7b9ac..0022c045b2 100644 --- a/src/panels/lovelace/editor/card-editor/hui-edit-card.ts +++ b/src/panels/lovelace/editor/card-editor/hui-edit-card.ts @@ -121,6 +121,7 @@ export class HuiEditCard extends LitElement { `} diff --git a/src/panels/lovelace/hui-editor.ts b/src/panels/lovelace/hui-editor.ts index fcdb102773..87bdd6daed 100644 --- a/src/panels/lovelace/hui-editor.ts +++ b/src/panels/lovelace/hui-editor.ts @@ -61,7 +61,10 @@ class LovelaceFullConfigEditor extends LitElement {
- +