> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/it/app/components/inputs/code-editor.md).

# Editor di codice

Il componente editor di codice consente di ospitare l'editor [Microsoft Monaco ](https://microsoft.github.io/monaco-editor/)all'interno delle sue dashboard.

## Creazione di un editor di codice

È possibile creare un nuovo editor di codice con il cmdlet `New-UDCodeEditor`. Specificando il parametro `-Language` si abiliterà l'evidenziazione della sintassi per quel linguaggio. Sarà necessario specificare un'altezza in pixel.

```
New-UDCodeEditor -Height '500' -Language 'powershell'
```

![](/files/1bjj4uSowpLODhF1ZVSt)

## Popolamento del codice

Utilizzi il parametro `-Code` per specificare il codice che verrà popolato all'interno dell'editor di codice al caricamento.

```
New-UDCodeEditor -Height '500' -Language 'powershell' -Code '#Hello, world!'
```

## Recupero del codice da un altro componente

È possibile recuperare il codice da un altro componente utilizzando il cmdlet `Get-UDElement` e accedendo alla proprietà code della hashtable restituita.

```
New-UDCodeEditor -Height '500' -Language 'powershell' -Code '#Hello, world!' -Id 'editor'

New-UDButton -Text 'Get Code' -OnClick {
    Show-UDToast -Message (Get-UDElement -id 'editor').Code
}
```

## Impostazione del codice da un altro componente

È possibile impostare il codice da un altro componente utilizzando il cmdlet `Set-UDElement`. Specifichi il valore del codice in una hashtable passata al parametro `-Properties`.

```
New-UDCodeEditor -Height '500' -Language 'powershell' -Code '#Hello, world!' -Id 'editor'

New-UDButton -Text 'Get Code' -OnClick {
    Set-UDElement -Id 'editor' -Properties @{
        code = "# Hello!"
    }
}
```

## Opzioni

L'editor Monaco supporta un'ampia gamma di opzioni. Se desidera utilizzare opzioni non disponibili nel cmdlet `New-UDCodeEditor`, può utilizzare il parametro `-Options` e passare invece una hashtable di opzioni.

Per un elenco completo delle opzioni, consulti l'interfaccia [IEditorConsturctionOptions](https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IEditorConstructionOptions.html).

```powershell
New-UDCodeEditor -Language powershell -Height 100 -Options @{ fontSize = 10 }
```

## API

* [New-UDCodeEditor](/powershell-universal/it/comandi-powershell/new-udcodeeditor.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.devolutions.net/powershell-universal/it/app/components/inputs/code-editor.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
