> 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/fr/applis/components/inputs/code-editor.md).

# Éditeur de code

Intégrez l'éditeur de code Monaco dans les applis PowerShell Universal pour l'édition de code avec coloration syntaxique, la récupération et les mises à jour dynamiques à partir d'autres composants.

Le composant éditeur de code vous permet d'héberger l'éditeur [Microsoft Monaco ](https://microsoft.github.io/monaco-editor/)dans vos tableaux de bord.

## Créer un éditeur de code

Vous pouvez créer un nouvel éditeur de code avec l'applet de commande `New-UDCodeEditor`. Spécifier le paramètre `-Language` activera la coloration syntaxique pour ce langage. Vous devrez spécifier une hauteur en pixels.

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

## Remplir du code

Utilisez le paramètre `-Code` pour spécifier le code qui sera rempli dans l'éditeur de code lors de son chargement.

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

## Récupérer du code à partir d'un autre composant

Vous pouvez récupérer du code à partir d'un autre composant en utilisant l'applet de commande `Get-UDElement` et en accédant à la propriété code de la table de hachage qui est retournée.

```
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
}
```

## Définir du code à partir d'un autre composant

Vous pouvez définir du code à partir d'un autre composant en utilisant l'applet de commande `Set-UDElement`. Spécifiez la valeur du code dans une table de hachage passée au paramètre `-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!"
    }
}
```

## Options

L'éditeur Monaco prend en charge un large éventail d'options. Si vous souhaitez utiliser des options qui ne sont pas disponibles dans l'applet de commande `New-UDCodeEditor`, vous pouvez utiliser le paramètre `-Options` et passer une table de hachage d'options à la place.

Pour une liste complète des options, consultez l'interface [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/fr/commandes-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/fr/applis/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.
