ToolJet/docs/versioned_docs/version-2.10.0/widgets/code-editor.md

220 lines
6.6 KiB
Markdown
Raw Normal View History

---
id: code-editor
title: Code Editor
---
# Code Editor
Code Editor widget is a versatile text editor for editing code and supports several languages.
<div style={{textAlign: 'center'}}>
<img className="screenshot-full" src="/img/widgets/code-editor/editor.png" alt="ToolJet - Widget Reference - Code editor" />
</div>
## Properties
:::info
Any property having `Fx` button next to its field can be **programmatically configured**.
:::
<div style={{textAlign: 'center'}}>
<img className="screenshot-full" src="/img/widgets/code-editor/prop.png" alt="ToolJet - Widget Reference - Code editor" />
</div>
| properties | description | Expected value |
| ----------- | ----------- | ----------------- |
| Placeholder | It specifies a hint that describes the expected value.| This field requires a `String` value |
| Mode | It is used to specify the language to be used for the code-editor.| See `info` below for the list of all supported languages |
| Show Line Number | This property is used to show or hide line numbers to the left of the editor.| This fields expects a boolean value `{{true}}` or `{{false}}` |
:::info
<details>
<summary>Supporting all commonly used languages.</summary>
<ul>
<li>APL</li>
<li>ASN.1</li>
<li>Asterisk dialplan</li>
<li>Brainfuck</li>
<li>C, C++, C#</li>
<li>Ceylon</li>
<li>Clojure</li>
<li>Closure Stylesheets (GSS)</li>
<li>CMake</li>
<li>COBOL</li>
<li>CoffeeScript</li>
<li>Common Lisp</li>
<li>Crystal</li>
<li>CSS</li>
<li>Cypher</li>
<li>Cython</li>
<li>D</li>
<li>Dart</li>
<li>Django (templating language)</li>
<li>Dockerfile</li>
<li>diff</li>
<li>DTD</li>
<li>Dylan</li>
<li>EBNF</li>
<li>ECL</li>
<li>Eiffel</li>
<li>Elixir</li>
<li>Elm</li>
<li>Erlang</li>
<li>Factor</li>
<li>FCL</li>
<li>Forth</li>
<li>Fortran</li>
<li>F#</li>
<li>Gas (AT&amp;T-style assembly)</li>
<li>Gherkin</li>
<li>Go</li>
<li>Groovy</li>
<li>HAML</li>
<li>Handlebars</li>
<li>Haskell</li>
<li>Haxe</li>
<li>HTML embedded (JSP, ASP.NET)</li>
<li>HTML mixed-mode</li>
<li>HTTP</li>
<li>IDL</li>
<li>Java</li>
<li>JavaScript (JSX)</li>
<li>Jinja2</li>
<li>Julia</li>
<li>Kotlin</li>
<li>LESS</li>
<li>LiveScript</li>
<li>Lua</li>
<li>Markdown (GitHub-flavour)</li>
<li>Mathematica</li>
<li>mbox</li>
<li>mIRC</li>
<li>Modelica</li>
<li>MscGen</li>
<li>MUMPS</li>
<li>Nginx</li>
<li>NSIS</li>
<li>N-Triples/N-Quads</li>
<li>Objective C</li>
<li>OCaml</li>
<li>Octave (MATLAB)</li>
<li>Oz</li>
<li>Pascal</li>
<li>PEG.js</li>
<li>Perl</li>
<li>PGP (ASCII armor)</li>
<li>PHP</li>
<li>Pig Latin</li>
<li>PowerShell</li>
<li>Properties files</li>
<li>ProtoBuf</li>
<li>Pug</li>
<li>Puppet</li>
<li>Python</li>
<li>Q</li>
<li>R</li>
<li>RPM</li>
<li>reStructuredText</li>
<li>Ruby</li>
<li>Rust</li>
<li>SAS</li>
<li>Sass</li>
<li>Spreadsheet</li>
<li>Scala</li>
<li>Scheme</li>
<li>SCSS</li>
<li>Shell</li>
<li>Sieve</li>
<li>Slim</li>
<li>Smalltalk</li>
<li>Smarty</li>
<li>Solr</li>
<li>Soy</li>
<li>Stylus</li>
<li>SQL (several dialects)</li>
<li>SPARQL</li>
<li>Squirrel</li>
<li>Swift</li>
<li>sTeX, LaTeX</li>
<li>Tcl</li>
<li>Textile</li>
<li>Tiddlywiki</li>
<li>Tiki wiki</li>
<li>TOML</li>
<li>Tornado (templating language)</li>
<li>troff (for manpages)</li>
<li>TTCN</li>
<li>TTCN Configuration</li>
<li>Turtle</li>
<li>Twig</li>
<li>VB.NET</li>
<li>VBScript</li>
<li>Velocity</li>
<li>Verilog/SystemVerilog</li>
<li>VHDL</li>
<li>Vue.js app</li>
<li>Web IDL</li>
<li>WebAssembly Text Format</li>
<li>XML/HTML</li>
<li>XQuery</li>
<li>Yacas</li>
<li>YAML</li>
<li>YAML frontmatter</li>
<li>Z80</li>
</ul>
</details>
:::
### General
#### Tooltip
A Tooltip is often used to specify extra information about something when the user hovers the mouse pointer over the widget.
Under the <b>General</b> accordion, you can set the value in the string format. Now hovering over the widget will display the string as the tooltip.
<div style={{textAlign: 'center'}}>
<img className="screenshot-full" src="/img/tooltip.png" alt="ToolJet - Widget Reference - Code editor" />
</div>
## Layout
<div style={{textAlign: 'center'}}>
<img className="screenshot-full" src="/img/widgets/code-editor/layout.png" alt="ToolJet - Widget Reference - Code editor" />
</div>
| Layout | description |
| ----------- | ----------- |
| Show on desktop | Toggle on or off to display the widget in desktop view. You can programmatically determine the value by clicking on Fx to set the value `{{true}}` or `{{false}}`. |
| Show on mobile | Toggle on or off to display the widget in mobile view. You can programmatically determine the value by clicking on Fx to set the value `{{true}}` or `{{false}}`. |
## Styles
<div style={{textAlign: 'center'}}>
<img className="screenshot-full" src="/img/widgets/code-editor/styles.png" alt="ToolJet - Widget Reference - Code editor" />
</div>
| Styles | description |
| ----------- | ----------- |
| Visibility | Toggle on or off to control the visibility of the widget. You can programmatically change its value by clicking on the `Fx` button next to it. If `{{false}}` the widget will not be visible after the app is deployed. By default, it's set to `{{true}}`. |
| Disable | This is `off` by default, toggle `on` the switch to lock the widget and make it non-functional. You can also programmatically set the value by clicking on the `Fx` button next to it. If set to `{{true}}`, the widget will be locked and becomes non-functional. By default, its value is set to `{{false}}`. |
| Border radius | Use this property to modify the border radius of the editor. The field expects only numerical value from `1` to `100`, default is `0`. |
## Exposed Variables
| Variables | Description |
| ----------- | ----------- |
| value | This variable holds the value whenever the user inputs anything on the code-editor . You can access the value dynamically using JS: `{{components.codeeditor1.value}}`|
## Component specific actions (CSA)
There are currently no CSA (Component-Specific Actions) implemented to regulate or control the component.