The Code Editor Component is a specialized form control that provides a powerful code editing experience within forms. It offers syntax highlighting, language detection, and a modern editor interface for working with various code formats like JSON, YAML, and plain text. This component is ideal for configuration interfaces, API testing tools, template editors, or any scenario requiring user input of structured text or code snippets.
height - Sets the height of the code editor in pixels or percentage. For example, setting to "400px" creates a fixed-height editor that provides adequate space for code viewing and editing, while "100%" makes it fill its container, adapting to the available space.
theme - Determines the visual appearance of the code editor with options for "Dark" or "Light" themes. For example, setting to "upw-theme-dark" provides a dark background with light text, which reduces eye strain during extended coding sessions, while "upw-theme-light" offers better visibility in well-lit environments.
defaultLanguage - Sets the default syntax highlighting language when automatic detection fails. Options include plain text, JSON, YAML, and Nginx configuration formats. For example, setting to "json" will apply JSON syntax highlighting to help users more easily identify structure and syntax errors in JSON data.
hidden - Controls whether the component is visible in the form. When set to true, the component remains in the form structure but is not displayed, which is useful for conditional rendering based on other field values or application states.
saveInLocalStorage - Determines whether the editor's content is preserved in local storage between sessions. When enabled, user input persists between page reloads, improving user experience for complex editing tasks that may take time to complete.
defaultValue - Sets the initial code content that will be used when the form is reset or first displayed. For example, setting to { "example": "value" } would pre-populate the editor with this JSON structure to provide users with a starting template.
readonly - Controls whether the code can be edited by users. When set to true, the editor displays the code but prohibits modifications, which is useful for code display or review scenarios where changes should not be permitted.
dataField - Defines the field name that will be used when submitting form data. For example, setting to "configurationJson" ensures the code content is submitted with this field name in the data object.
controlsRequestType - Specifies how the field data is sent in HTTP requests: 'BODY', 'HEADER', or 'PATH'. For example, setting to "BODY" includes the code content in the request body, which is standard for most form submissions involving complex data.