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.
1
Install-Module UniversalDashboard.CodeEditor -AllowPrerelease
Copied!

Usage

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