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

# Éditeur de code

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éation d'un éditeur de code

Vous pouvez créer un nouvel éditeur de code avec le cmdlet `New-UDCodeEditor`. La spécification du paramètre `-Language` activera la coloration syntaxique pour ce langage. Vous devez spécifier une hauteur en pixels.

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

![](/files/nVKMd4LNqKe93foKaQzx)

## Remplissage du code

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

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

## Récupération du code depuis un autre composant

Vous pouvez récupérer le code depuis un autre composant en utilisant le cmdlet `Get-UDElement` et en accédant à la propriété code de la table de hachage 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éfinition du code depuis un autre composant

Vous pouvez définir le code depuis un autre composant en utilisant le cmdlet `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 sur le cmdlet `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](https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDCodeEditor.txt)


---

# 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:

```
GET https://docs.devolutions.net/powershell-universal/fr/apps/components/inputs/code-editor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
