Code Editor
Documentation for the Code Editor component.

Code Editor Control in Universal Dashboard.
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" -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 3yr ago