Skip to content

Commit

Permalink
add CodeEditor control
Browse files Browse the repository at this point in the history
  • Loading branch information
snootched committed Jan 5, 2025
1 parent 4f8abea commit 3b95c65
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ha-editor-formbuilder-yaml",
"version": "2025.01.2-beta.3",
"version": "2025.01.2-beta.4",
"description": "A reimplementation of ha-editor-formbuilder - supporting YAML configuration of HA Selector controls, conditional expresssions, and more.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
15 changes: 15 additions & 0 deletions src/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ export function generateControl(control: AnyControl, card: EditorForm){
</div>
`;

case 'CodeEditor':
return html`
<div class="form-control">
<ha-code-editor
.hass=${card._hass}
.value=${getNestedProperty(card._config, control.configValue)}
.label=${control.label}
.helper=${control.helper}
.mode=${control.mode}
.disabled=${isDisabled}
.required=${isRequired}
@value-changed=${card._valueChanged}
></ha-code-editor>
</div>
`;
case 'Filler':
return html`<div class="form-control"></div>`;

Expand Down
8 changes: 7 additions & 1 deletion src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ export interface ColorPreviewControl extends Control {
configValue: string;
}

export interface CodeEditorControl extends Control {
type: 'CodeEditor';
mode: string;
}

export interface ControlRow {
label?: string;
type?: string;
Expand Down Expand Up @@ -118,7 +123,8 @@ export type AnyControl =
| RawHTMLControl
| DividerControl
| FillerControl
| ColorPreviewControl;
| ColorPreviewControl
| CodeEditorControl;

export function isSection(row: ControlRow | Section): row is Section {
return row.type === 'Section';
Expand Down

0 comments on commit 3b95c65

Please sign in to comment.