I need a simple text editor on my site, just with the following options:
- ordered and unordered lists
- heading or bold characters
- horizontal rule
Is there any way to get the above by coding, inside an existing textarea tag
I tried with contentEditable div but there is a lot of problems there, for example return changes the format of preceding text and so on.
You can use ckeditor, it's very simple and customizable
https://ckeditor.com/ckeditor-5/
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CKEditor 5 – Classic editor</title>
<script src="https://cdn.ckeditor.com/ckeditor5/11.0.1/classic/ckeditor.js"></script>
</head>
<body>
<h1>Classic editor</h1>
<textarea name="content" id="editor">
<p>This is some sample content.</p>
</textarea>
<script>
ClassicEditor
.create( document.querySelector( '#editor' ) )
.catch( error => {
console.error( error );
} );
</script>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With