mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 16:26:43 +00:00
YAML editor fixes (#2737)
* YAML editor fixes * Fix auto height in dialog * remove height from paper-dialog-buttons * wait for next paint instead of fixed time * resize again after codemirror is updated * afternextrender merge
This commit is contained in:
parent
2ae30ac024
commit
b384d17fd3
@ -32,9 +32,12 @@ export class HuiYamlEditor extends HTMLElement {
|
|||||||
<style>
|
<style>
|
||||||
${codeMirrorCSS}
|
${codeMirrorCSS}
|
||||||
.CodeMirror {
|
.CodeMirror {
|
||||||
height: var(--code-mirror-height, 300px);
|
height: var(--code-mirror-height, auto);
|
||||||
direction: var(--code-mirror-direction, ltr);
|
direction: var(--code-mirror-direction, ltr);
|
||||||
}
|
}
|
||||||
|
.CodeMirror-scroll {
|
||||||
|
max-height: var(--code-mirror-max-height, --code-mirror-height);
|
||||||
|
}
|
||||||
.CodeMirror-gutters {
|
.CodeMirror-gutters {
|
||||||
border-right: 1px solid var(--paper-input-container-color, var(--secondary-text-color));
|
border-right: 1px solid var(--paper-input-container-color, var(--secondary-text-color));
|
||||||
background-color: var(--paper-dialog-background-color, var(--primary-background-color));
|
background-color: var(--paper-dialog-background-color, var(--primary-background-color));
|
||||||
@ -46,7 +49,6 @@ export class HuiYamlEditor extends HTMLElement {
|
|||||||
.CodeMirror-linenumber {
|
.CodeMirror-linenumber {
|
||||||
color: var(--paper-dialog-color, var(--primary-text-color));
|
color: var(--paper-dialog-color, var(--primary-text-color));
|
||||||
}
|
}
|
||||||
|
|
||||||
.rtl .CodeMirror-vscrollbar {
|
.rtl .CodeMirror-vscrollbar {
|
||||||
right: auto;
|
right: auto;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
@ -89,12 +91,7 @@ export class HuiYamlEditor extends HTMLElement {
|
|||||||
mode: "yaml",
|
mode: "yaml",
|
||||||
tabSize: 2,
|
tabSize: 2,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
extraKeys: {
|
viewportMargin: Infinity,
|
||||||
Tab: (cm: CodeMirror) => {
|
|
||||||
const spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
|
||||||
cm.replaceSelection(spaces);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
gutters:
|
gutters:
|
||||||
this._hass && computeRTL(this._hass!)
|
this._hass && computeRTL(this._hass!)
|
||||||
? ["rtl-gutter", "CodeMirror-linenumbers"]
|
? ["rtl-gutter", "CodeMirror-linenumbers"]
|
||||||
|
@ -36,6 +36,7 @@ import { ConfigValue, ConfigError } from "../types";
|
|||||||
import { EntityConfig } from "../../entity-rows/types";
|
import { EntityConfig } from "../../entity-rows/types";
|
||||||
import { getCardElementTag } from "../../common/get-card-element-tag";
|
import { getCardElementTag } from "../../common/get-card-element-tag";
|
||||||
import { addCard, replaceCard } from "../config-util";
|
import { addCard, replaceCard } from "../config-util";
|
||||||
|
import { afterNextRender } from "../../../../common/util/render-status";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HASSDomEvents {
|
interface HASSDomEvents {
|
||||||
@ -182,8 +183,8 @@ export class HuiEditCard extends LitElement {
|
|||||||
?active="${this._saving}"
|
?active="${this._saving}"
|
||||||
alt="Saving"
|
alt="Saving"
|
||||||
></paper-spinner>
|
></paper-spinner>
|
||||||
${this.hass!.localize("ui.common.save")}</mwc-button
|
${this.hass!.localize("ui.common.save")}
|
||||||
>
|
</mwc-button>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
@ -196,9 +197,10 @@ export class HuiEditCard extends LitElement {
|
|||||||
this._loading = false;
|
this._loading = false;
|
||||||
this._resizeDialog();
|
this._resizeDialog();
|
||||||
if (!this._uiEditor) {
|
if (!this._uiEditor) {
|
||||||
setTimeout(() => {
|
afterNextRender(() => {
|
||||||
this.yamlEditor.codemirror.refresh();
|
this.yamlEditor.codemirror.refresh();
|
||||||
}, 1);
|
this._resizeDialog();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,6 +413,10 @@ export class HuiEditCard extends LitElement {
|
|||||||
return [
|
return [
|
||||||
haStyleDialog,
|
haStyleDialog,
|
||||||
css`
|
css`
|
||||||
|
:host {
|
||||||
|
--code-mirror-max-height: calc(100vh - 176px);
|
||||||
|
}
|
||||||
|
|
||||||
@media all and (max-width: 450px), all and (max-height: 500px) {
|
@media all and (max-width: 450px), all and (max-height: 500px) {
|
||||||
/* overrule the ha-style-dialog max-height on small screens */
|
/* overrule the ha-style-dialog max-height on small screens */
|
||||||
paper-dialog {
|
paper-dialog {
|
||||||
@ -456,12 +462,14 @@ export class HuiEditCard extends LitElement {
|
|||||||
.content {
|
.content {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
.content .element-editor {
|
.content > * {
|
||||||
flex: auto;
|
flex-basis: 0;
|
||||||
|
flex-grow: 1;
|
||||||
|
flex-shrink: 1;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
.content hui-card-preview {
|
.content hui-card-preview {
|
||||||
margin: 0 10px;
|
margin: 0 10px;
|
||||||
flex: 490px;
|
|
||||||
max-width: 490px;
|
max-width: 490px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,6 @@ export const haStyleDialog = css`
|
|||||||
}
|
}
|
||||||
|
|
||||||
.paper-dialog-buttons {
|
.paper-dialog-buttons {
|
||||||
height: 56px;
|
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user