x
1
<div data-react-class="Editor" data-react-props="{"mode":"ruby","name":"code_editor","storedValue":"# @param context: a hash containing any context information that might be required for this decision block.\n# Usually the `item_id` is passed here.\n# @return [nil, string]: the token to be used in the next block\n\ndef decide(context)\n # Context should have item_id\n item = Item.find_by(id: context[:item_id]) if context[:item_id].present?\n return nil if item.nil?\n item.forward_item_id.present? ? :forward_item : default_output_token\nend\n \ndef output_tokens\n [:forward_item, :without_forward_item]\nend\n \ndef default_output_token\n :without_forward_item\nend","readOnly":false,"className":"ruby-editor"}" data-react-cache-id="Editor-0" style="width:100%"></div>Code Editor
The Code Editor component is a specialized text editor for code within a user interface. It’s commonly used in development environments, configuration panels, or any interface where users need to edit code, scripts, or configuration files directly.
Related components
| Used Components | Components where is Used |
|---|---|
| Ace Editor |
Usage rules
- ✅ Do
- Use in environments where users need to write or modify code directly
- ❌ Don't
- Don’t use if users only need basic text input or settings fields
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<% code = "# @param context: a hash containing any context information that might be required for this decision block.# Usually the `item_id` is passed here.# @return [nil, string]: the token to be used in the next blockdef decide(context) # Context should have item_id item = Item.find_by(id: context[:item_id]) if context[:item_id].present? return nil if item.nil? item.forward_item_id.present? ? :forward_item : default_output_tokenend def output_tokens [:forward_item, :without_forward_item]end def default_output_token :without_forward_itemend"%><%= render LooposUi::CodeEditor.new( type: "ruby", code: code, readonly: params[:read_only] || false)%>No notes provided.
| Param | Description | Input |
|---|---|---|
|
Deny changes. |
|
|
|
Show Edit button |
|
Code Editor
The Code Editor component is a specialized text editor for code within a user interface. It’s commonly used in development environments, configuration panels, or any interface where users need to edit code, scripts, or configuration files directly.
Arguments
| Property | Default | Description |
|---|---|---|
type |
`` | Language for editor [:ruby, :json] |
code |
`` | Value that goes inside the editor |
readonly |
true |
Enables or disables edition |
extra_options |
`` | Extra props to use on Ace Editor component. Oficial docs: https://github.com/securingsincity/react-ace/blob/master/docs/Ace.md |