I have tried to make a text editor and wanted to add a syntax highlighter (I am using a ***div*** element).
The code works just fine, but when I type a new character the line thing you type goes at the start of the text. This means that I will type every character at the beginning.  

```js
const editor = document.getElementById("text");
var text = editor.innerText;

editor.addEventListener("input", function() {
  text = editor.innerText;
  editor.innerHTML = text.replaceAll("console", "<font color='green'>console</font>");

  console.log(editor.innerHTML);
});

String.prototype.replaceAll = function(search, replacement) {
  var target = this;
  return target.replace(new RegExp(search, 'g'), replacement);
};
```

```html
<div id="text" contenteditable="true"></div>
```

Is there any solution I can make that the line does not go at the beginning? Do I have to replace or remove something?