Links

Code Editor

Universal Dashboard is now a part of PowerShell Universal. This documentation is for reference to the v2 version of Universal Dashboard and is no longer maintained.
PowerShell Universal Documentation can be found here.

description: Documentation for the Code Editor component.

Code Editor

This component requires a Universal Dashboard Enterprise License.
Code Editor Control in Universal Dashboard.

Installation

The Code Editor component is published to the PowerShell Gallery. You can install it with the following command line.
Install-Module UniversalDashboard.CodeEditor -AllowPrerelease

Usage

Creating an editor
New-UDCodeEditor -Language 'powershell' -Height '100ch' -Width '100cw' -Code 'Start-Process'
Read only editor
New-UDCodeEditor -Language 'powershell' -Height '100ch' -Width '100ch' -Theme vs-dark -Code "Get-Process" -ReadOnly
Dynamically adding content to the editor
New-UDCodeEditor -Id 'editor' -Language 'powershell' -Height '100ch' -Width '100ch' -Theme vs-dark -Code "Get-Process" -ReadOnly
New-UDButton -Text 'Add Text' -OnClick {
Add-UDElement -ParentId 'editor' -Content {
'Get-Process'
}
}
Dynamically getting content from the editor
New-UDCodeEditor -Id 'editor' -Language 'powershell' -Height '100ch' -Width '100ch' -Theme vs-dark
New-UDButton -Text "Get Text" -OnClick {
Show-UDToast -Message (Get-UDElement -Id 'editor').Attributes["code"]
}
Dynamically setting the content of the editor
New-UDCodeEditor -Id 'editor' -Language 'powershell' -Height '100ch' -Width '100ch' -Theme vs-dark
New-UDButton -Text "Set Text" -OnClick {
Set-UDElement -Id 'editor' -Attributes @{
code = 'Get-Service'
}
}
Last modified 1yr ago