Factsheet
/ October 23, 2025; 51 days ago (2025-10-23)
/ October 23, 2025; 51 days ago (2025-10-23)
Hi. I do a web based app where people can write simple messages to others. It basically supports html but the editor is just a textarea for now. Now I want to give it some very basic formatting options.
I know TinyMCE, CKEditor, Editor.js and some others, but they are all so full blown and big. I need a WYSIWYG editor with the following features:
Must have:
Working in all major Web Browsers.
Support Bold, Italic, Underline.
Enter key must end <p> paragraph, Shift+Enter must create <br> tag only.
Export HTML (or let me get HTML).
Small footprint.
Open Source (like MIT or Apache licence).
No other dependencies (like Vue, jQuery, React, Angular etc).
Not abandoned (eg ideally updated in the last 6 Months).
Nice to have but not mandatory:
Support bullet list and numbered list.
Support font selection (only one Normal and one Mono-Spaced needed).
Support text foreground color selection.
Can someone point me to such feature limited and small WYSIWYG editor please? I'm sure there is some out there, but maybe well hidden...
I found one close candidate on GitHub (https://github.com/taufik-nurrohman/rich-text-editor/), but it was not updated for 3 years now and does not support Enter key like described.
[AskJS] on a scale of 1-10, how hard is building a WYSIWYG editor from scratch?
javascript - How to make an HTML/JS WYSIWYG editor? - Stack Overflow
javascript - How to build an own WYSIWYG editor (RTE) using Vanilla JS - Stack Overflow
Choosing the best WYSIWYG editor: Slate vs Quill vs ProseMirror.
I'm getting into ProseMirror at the moment. Its document model is more advanced and flexible than Quill. The Quill author admitted this in some HN comments. Even today Quill cannot produce nested lists and fakes it with CSS.
So far ProseMirror is very deep and flexible, but low level and tedious. Atlassian built an utils library to help with this.
Since I'm working with Vue on my current project I haven't really spent much time at looking into Slate, but it seems very interesting and well done. I'm still evaluating ProseMirror, but I'd try Slate next if it doesn't work out for me.
More on reddit.comWhere can I find the Syncfusion JavaScript Rich Text Editor demo?
How do I get started with the Syncfusion JavaScript Rich Text Editor?
Why should you choose Syncfusion JavaScript Rich Text Editor?
Videos
Trying to understand how big of a challenge that is. Thank you :)
Javascript WYSIWYG editors do not use a textarea (at least not externally, it is likely that behind the scenes there is a textarea that is populated with the code that makes up the WYSIWYG content so that it can be posted in a form).
Rather, there are two properties that are used to make an editable area in a webpage: designMode, which applies to a whole document, or contentEditable, which applies to a specific element. Both properties were originally Microsoft innovations, but have been adopted by all major browsers (contentEditable is now part of HTML5).
Once a document (in terms of rich text editors this generally means embedding an iframe with designMode set into your page) or element is made editable, formatting is done by using the execCommand method (for which there are a number of different modes -- bold, italics, etc. -- which are not necessarily the same across all browsers. See this table for more info).
In order to pass content from the editable element to the server, generally the innerHTML of the editable element, is loaded into a textarea, which is posted. The makeup of the HTML generated depends on the browser.
Resources:
- http://blog.whatwg.org/the-road-to-html-5-contenteditable
- http://www.mozilla.org/editor/ie2midas.html
I have a good idea take this code to make a cool WYSIWYG editor-
To make a nice editor I have made a code with JavaScript that will open a new window containing the result-
Let's start with the Body-
<body>
<textarea style="height:400px;width:750px;overflow:auto;"onblur="x=this.value"></textarea>
<br />
<button onclick="ShowResult()">see result!</button>
</body>
Now we continue with the JavaScript-
function ShowResult()
{
my_window = window.open("about:blank", "mywindow1");
//By the above line code we have opened a new window
my_window.document.write(x);
//Here we have added the value of the textarea to the new window
}
Let's see the code on-whole:-
<html>
<script type="text/javascript">
function ShowResult()
{
my_window = window.open("about:blank", "mywindow1");
my_window.document.write(x);
}
</script>
<body>
<textarea style="height:400px;width:750px;overflow:auto;" onblur="x=this.value">
</textarea><br />
<button onclick="ShowResult()">see result!</button>
</body>
</html>
If i can help you in any way i am very happy doing that.
Thank you for asking this question and for increasing my curiosity towards JavaScript.
I think it is a possible solution.
- I wrote a function to not replicate the code.
- You can modify it to fit your problem and also I apply the function to just italic, bold and underline the css style. The align buttons will not work, you have to implement the logic but it's very similar as this function
- You can try apply another function to remove the style when click again in the button.
As said before, the textarea not allow modify style of some part of the text, so I'm using
spanto avoid issues. I trydivbut I got some unlike behaviors.
function addEventEditionButton(btnId,cssProperty, cssPropertieValy) {
let buttonTarget = document.getElementById(btnId);
buttonTarget.addEventListener("click", function () {
let selection = window.getSelection().getRangeAt(0);
let selectedText = selection.extractContents();
let span = document.createElement("span");
try{
span.style[cssProperty] = cssPropertieValy;
}catch(e){
console.trace(e);
}
span.appendChild(selectedText);
selection.insertNode(span);
});
}
addEventEditionButton("bold", "fontWeight", "bold");
addEventEditionButton("italic", "fontStyle", "italic");
addEventEditionButton("underline", "textDecoration", "underline");
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- <link rel="stylesheet" href="./style/style.css" /> -->
<link
rel="stylesheet"
href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css"
integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p"
crossorigin="anonymous"
/>
<title>TextEditor</title>
<style>
.input-container {
border: 1px solid black;
width: 223px;
height: 103px;
overflow: scroll;
}
</style>
</head>
<body>
<header>
<h1>Text Editor</h1>
</header>
<main>
<div class="functionality">
<div class="container">
<button class="btn" id="bold"><i class="fas fa-bold"></i></button>
<button class="btn" id="italic"><i class="fas fa-italic"></i></button>
<button class="btn" id="underline">
<i class="fas fa-underline"></i>
</button>
<button class="btn" id="align-left">
<i class="fas fa-align-left"></i>
</button>
<button class="btn" id="justify">
<i class="fas fa-align-justify"></i>
</button>
<button class="btn" id="align-right">
<i class="fas fa-align-right"></i>
</button>
</div>
</div>
<div contenteditable class="input-container">
<span name="text-input-c1" id="text-input"></span>
</div>
</main>
</body>
<script src="./stackoverflow.js"></script>
</html>
Be aware in this HTML chages:
<div contenteditable class="input-container">
<span name="text-input-c1" id="text-input"></span>
</div>
My suggestion:
const formatText = (tag) => {
var start = textarea.selectionStart,
end = textarea.selectionEnd,
len = textarea.value.length,
text = textarea.value.substring(start, end);
if (text) textarea.value = textarea.value.substring(0, start) + `<${tag}>${text}</${tag}>` + textarea.value.substring(end, len);
}
form {
display: flex;
flex-direction: column;
}
textarea {
width: 100%;
height: 100px;
margin-bottom: 20px;
}
button {
margin-bottom: 20px;
}
<form id="form">
<textarea id="textarea">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean venenatis justo ante, sed condimentum dui lobortis nec. Morbi ut aliquam turpis. Aliquam elementum urna diam. Morbi ullamcorper dolor ipsum, quis porttitor tortor bibendum nec. Donec imperdiet neque nec est faucibus, ac congue ligula hendrerit. Cras quis metus ullamcorper, commodo est vel, elementum nulla. In hac habitasse platea dictumst. Morbi posuere pulvinar tellus, quis tincidunt felis condimentum at. Maecenas eu molestie lorem. Nullam finibus luctus mauris, ut tincidunt diam ultrices id. Curabitur vitae vehicula mi, et tincidunt nulla. Sed vitae rhoncus sem, quis aliquet quam. Etiam dignissim lacus eget ex dictum scelerisque. Quisque id ornare odio, non placerat odio.
</textarea>
<button type="button" onclick="formatText('i');">Italic</button>
<button type="button" onclick="formatText('b');">Bold</button>
<button type="button" onclick="formatText('u');">Underlined</button>
</form>
Select the text you want italic/bold/underlined, and click on the button.