mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 02:36:37 +00:00
Disable fullscreen editor for editors that are already fullscreen (#25959)
* Disabled fullscreen editor for editors that are already fullscreen * Update ha-code-editor.ts
This commit is contained in:
parent
caaec7d34d
commit
c065efc52f
@ -61,8 +61,8 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public error = false;
|
@property({ type: Boolean }) public error = false;
|
||||||
|
|
||||||
@property({ type: Boolean, attribute: "enable-fullscreen" })
|
@property({ type: Boolean, attribute: "disable-fullscreen" })
|
||||||
public enableFullscreen = true;
|
public disableFullscreen = false;
|
||||||
|
|
||||||
@state() private _value = "";
|
@state() private _value = "";
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
if (changedProps.has("_isFullscreen")) {
|
if (changedProps.has("_isFullscreen")) {
|
||||||
this.classList.toggle("fullscreen", this._isFullscreen);
|
this.classList.toggle("fullscreen", this._isFullscreen);
|
||||||
}
|
}
|
||||||
if (changedProps.has("enableFullscreen")) {
|
if (changedProps.has("disableFullscreen")) {
|
||||||
this._updateFullscreenButton();
|
this._updateFullscreenButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
private _updateFullscreenButton() {
|
private _updateFullscreenButton() {
|
||||||
const existingButton = this.renderRoot.querySelector(".fullscreen-button");
|
const existingButton = this.renderRoot.querySelector(".fullscreen-button");
|
||||||
|
|
||||||
if (!this.enableFullscreen) {
|
if (this.disableFullscreen) {
|
||||||
// Remove button if it exists and fullscreen is disabled
|
// Remove button if it exists and fullscreen is disabled
|
||||||
if (existingButton) {
|
if (existingButton) {
|
||||||
existingButton.remove();
|
existingButton.remove();
|
||||||
@ -317,7 +317,7 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
this._toggleFullscreen();
|
this._toggleFullscreen();
|
||||||
} else if (e.key === "F11" && this.enableFullscreen) {
|
} else if (e.key === "F11" && !this.disableFullscreen) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
this._toggleFullscreen();
|
this._toggleFullscreen();
|
||||||
@ -557,7 +557,7 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 8px;
|
top: 8px;
|
||||||
right: 8px;
|
right: 8px;
|
||||||
z-index: 10;
|
z-index: 1;
|
||||||
color: var(--secondary-text-color);
|
color: var(--secondary-text-color);
|
||||||
background-color: var(--card-background-color);
|
background-color: var(--card-background-color);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
@ -589,17 +589,17 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
right: 0 !important;
|
right: 0 !important;
|
||||||
bottom: 0 !important;
|
bottom: 0 !important;
|
||||||
z-index: 9999 !important;
|
z-index: 9999 !important;
|
||||||
background-color: var(--primary-background-color) !important;
|
background-color: var(
|
||||||
|
--code-editor-background-color,
|
||||||
|
var(--mdc-text-field-fill-color, whitesmoke)
|
||||||
|
) !important;
|
||||||
margin: 0 !important;
|
margin: 0 !important;
|
||||||
padding: 16px !important;
|
padding-top: var(--safe-area-inset-top) !important;
|
||||||
/* Respect iOS safe areas while accounting for header */
|
padding-left: var(--safe-area-inset-left) !important;
|
||||||
padding-top: max(16px, env(safe-area-inset-top)) !important;
|
padding-right: var(--safe-area-inset-right) !important;
|
||||||
padding-left: max(16px, env(safe-area-inset-left)) !important;
|
padding-bottom: var(--safe-area-inset-bottom) !important;
|
||||||
padding-right: max(16px, env(safe-area-inset-right)) !important;
|
|
||||||
padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
|
|
||||||
box-sizing: border-box !important;
|
box-sizing: border-box !important;
|
||||||
display: flex !important;
|
display: block !important;
|
||||||
flex-direction: column !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:host(.fullscreen) .cm-editor {
|
:host(.fullscreen) .cm-editor {
|
||||||
@ -609,12 +609,8 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
:host(.fullscreen) .fullscreen-button {
|
:host(.fullscreen) .fullscreen-button {
|
||||||
position: fixed;
|
top: calc(var(--safe-area-inset-top, 0px) + 8px);
|
||||||
top: calc(
|
right: calc(var(--safe-area-inset-right, 0px) + 8px);
|
||||||
var(--header-height, 56px) + max(8px, env(safe-area-inset-top))
|
|
||||||
);
|
|
||||||
right: max(24px, calc(env(safe-area-inset-right) + 8px));
|
|
||||||
z-index: 10000;
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,9 @@ export class HaYamlEditor extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: "read-only", type: Boolean }) public readOnly = false;
|
@property({ attribute: "read-only", type: Boolean }) public readOnly = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean, attribute: "disable-fullscreen" })
|
||||||
|
public disableFullscreen = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required = false;
|
@property({ type: Boolean }) public required = false;
|
||||||
|
|
||||||
@property({ attribute: "copy-clipboard", type: Boolean })
|
@property({ attribute: "copy-clipboard", type: Boolean })
|
||||||
@ -110,6 +113,7 @@ export class HaYamlEditor extends LitElement {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this._yaml}
|
.value=${this._yaml}
|
||||||
.readOnly=${this.readOnly}
|
.readOnly=${this.readOnly}
|
||||||
|
.disableFullscreen=${this.disableFullscreen}
|
||||||
mode="yaml"
|
mode="yaml"
|
||||||
autocomplete-entities
|
autocomplete-entities
|
||||||
autocomplete-icons
|
autocomplete-icons
|
||||||
|
@ -502,6 +502,7 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
|
|||||||
.readOnly=${this._readOnly}
|
.readOnly=${this._readOnly}
|
||||||
@value-changed=${this._yamlChanged}
|
@value-changed=${this._yamlChanged}
|
||||||
.showErrors=${false}
|
.showErrors=${false}
|
||||||
|
disable-fullscreen
|
||||||
></ha-yaml-editor>`
|
></ha-yaml-editor>`
|
||||||
: nothing}
|
: nothing}
|
||||||
</div>
|
</div>
|
||||||
|
@ -321,6 +321,7 @@ export class HaSceneEditor extends PreventUnsavedMixin(
|
|||||||
.defaultValue=${this._config}
|
.defaultValue=${this._config}
|
||||||
@value-changed=${this._yamlChanged}
|
@value-changed=${this._yamlChanged}
|
||||||
.showErrors=${false}
|
.showErrors=${false}
|
||||||
|
disable-fullscreen
|
||||||
></ha-yaml-editor>`;
|
></ha-yaml-editor>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,6 +440,7 @@ export class HaScriptEditor extends SubscribeMixin(
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.defaultValue=${this._preprocessYaml()}
|
.defaultValue=${this._preprocessYaml()}
|
||||||
.readOnly=${this._readOnly}
|
.readOnly=${this._readOnly}
|
||||||
|
disable-fullscreen
|
||||||
@value-changed=${this._yamlChanged}
|
@value-changed=${this._yamlChanged}
|
||||||
.showErrors=${false}
|
.showErrors=${false}
|
||||||
></ha-yaml-editor>`
|
></ha-yaml-editor>`
|
||||||
|
@ -89,6 +89,7 @@ class LovelaceFullConfigEditor extends LitElement {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@value-changed=${this._yamlChanged}
|
@value-changed=${this._yamlChanged}
|
||||||
@editor-save=${this._handleSave}
|
@editor-save=${this._handleSave}
|
||||||
|
disable-fullscreen
|
||||||
dir="ltr"
|
dir="ltr"
|
||||||
>
|
>
|
||||||
</ha-code-editor>
|
</ha-code-editor>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user