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.
This component requires a Universal Dashboard Enterprise License.
The Code Editor component is published to the PowerShell Gallery. You can install it with the following command line.
Install-Module UniversalDashboard.CodeEditor -AllowPrerelease
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" -ReadOnlyNew-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-darkNew-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-darkNew-UDButton -Text "Set Text" -OnClick {Set-UDElement -Id 'editor' -Attributes @{code = 'Get-Service'}}