- This implementation makes users to attract more and they love to work in such websites.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>ACE</title>
<!-- Inline Style starts -->
<style>
#editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
</style>
<!-- Inline style Ends -->
</head>
<body>
<div id="editor"></div>
<!-- javascript code starts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.3/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/javascript");
</script>
<!-- javascript code ends -->
</body>
</html>
-
The below line represents the dark mode theme(monokai)
editor.setTheme("ace/theme/monokai");
-
We can change the editor to suitable for any language by changing setMode() and the above code is for javascript
-
For java, change setMode() as shown
editor.session.setMode("ace/mode/java");
-
For python, change setMode() as shown
editor.session.setMode("ace/mode/python");
-
Some CSS should be present to locate its place and in HTML we created an ID editor in <div> that is used in inline statement
<style>
#editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
</style>
// top, left, right, bottom are margines and position:absolute is positioned relative to the nearest positioned ancestor. # is used for id's.
- Once Run the above code to understand properly by changing their laguages.
- It feels very good to type codes in web pages rather than like text editors.