Intro
You can write raw HTML, CSS, and JavaScript in The.com by adding Raw HTML, Stylesheet, and Script elements to your pages or Blocks, respectively.
Each of these elements will open a code editor when opening their text cell by pressing CMD/CTRL + Enter
.
This feature lets you write formatted code with HTML, CSS, and JS syntax highlighting and checking.
The Preformatted Text element also supports this code editor.
How To
The overall features for the code editor are the same across Raw HTML, Stylesheet, and Script elements. For the purpose of this article, we'll focus on using the Script element.
- Add an element that supports the code editor. In this case, we've added a Script Element.
- Click into the element's text cell.
- Use the keyboard shortcut
CMD/CTRL + Enter
to open the full-screen code editor. - Type or paste code.
- Close the code editor by pressing
CMD/CTRL + Enter
or clicking the check in the top left of the editor.
Autofill
When typing in the code editor, a box will appear with suggestions for JavaScript variables, functions, or keywords based on whichever language you are writing. Pressing Enter
will auto complete the suggestion.
You can also use the arrow keys to move the selected suggestion.
Formatting
If the code you've written or pasted in has some whitespace or new line issues, simply click the Format button in the top right corner of the editor. This will format the code with proper indentation and line breaks.
After clicking the button, a green checkmark will appear if there are no syntax errors.
If there are any syntax errors, a red message will appear next to this button. In the JavaScript editor, it will even highlight the lines where such errors exist.
Settings
Click on the gear icon in the top right corner of the editor to open the code editor settings.
Here, you can toggle the VIM mode on or off if you like that sort of thing.
Comments
0 comments
Please sign in to leave a comment.