mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Wrap code editor for template selector (#21104)
* Wrap code editor for template selector
This commit is contained in:
parent
72f989e2bd
commit
27afe9ecb7
@ -47,6 +47,8 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public readOnly = false;
|
@property({ type: Boolean }) public readOnly = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public linewrap = false;
|
||||||
|
|
||||||
@property({ type: Boolean, attribute: "autocomplete-entities" })
|
@property({ type: Boolean, attribute: "autocomplete-entities" })
|
||||||
public autocompleteEntities = false;
|
public autocompleteEntities = false;
|
||||||
|
|
||||||
@ -134,6 +136,13 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (changedProps.has("linewrap")) {
|
||||||
|
transactions.push({
|
||||||
|
effects: this._loadedCodeMirror!.linewrapCompartment!.reconfigure(
|
||||||
|
this.linewrap ? this._loadedCodeMirror!.EditorView.lineWrapping : []
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
if (changedProps.has("_value") && this._value !== this.value) {
|
if (changedProps.has("_value") && this._value !== this.value) {
|
||||||
transactions.push({
|
transactions.push({
|
||||||
changes: {
|
changes: {
|
||||||
@ -181,6 +190,9 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
this._loadedCodeMirror.readonlyCompartment.of(
|
this._loadedCodeMirror.readonlyCompartment.of(
|
||||||
this._loadedCodeMirror.EditorView.editable.of(!this.readOnly)
|
this._loadedCodeMirror.EditorView.editable.of(!this.readOnly)
|
||||||
),
|
),
|
||||||
|
this._loadedCodeMirror.linewrapCompartment.of(
|
||||||
|
this.linewrap ? this._loadedCodeMirror.EditorView.lineWrapping : []
|
||||||
|
),
|
||||||
this._loadedCodeMirror.EditorView.updateListener.of(this._onUpdate),
|
this._loadedCodeMirror.EditorView.updateListener.of(this._onUpdate),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ export class HaTemplateSelector extends LitElement {
|
|||||||
autocomplete-icons
|
autocomplete-icons
|
||||||
@value-changed=${this._handleChange}
|
@value-changed=${this._handleChange}
|
||||||
dir="ltr"
|
dir="ltr"
|
||||||
|
linewrap
|
||||||
></ha-code-editor>
|
></ha-code-editor>
|
||||||
${this.helper
|
${this.helper
|
||||||
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
||||||
|
@ -33,6 +33,7 @@ export const langs = {
|
|||||||
|
|
||||||
export const langCompartment = new Compartment();
|
export const langCompartment = new Compartment();
|
||||||
export const readonlyCompartment = new Compartment();
|
export const readonlyCompartment = new Compartment();
|
||||||
|
export const linewrapCompartment = new Compartment();
|
||||||
|
|
||||||
export const tabKeyBindings: KeyBinding[] = [
|
export const tabKeyBindings: KeyBinding[] = [
|
||||||
{ key: "Tab", run: indentMore },
|
{ key: "Tab", run: indentMore },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user