Dec
Free WYSIWYG TextArea HTML Editor
A dead simple, fast loading, light weight and easy to use html markup editor for your projects. It is the ultimate textarea replacement. It does not use iframes instead it just replaces textarea into an editor where you can insert basic html markup codes like bold, italic, hyperlink, image, blockquote and more..
Much of the inspiration of this editor came from the editor used in wordpress forums. I really loved the simplicity of the editor used there. The reason i kept as textarea editor instead of using iframes (which gives rich html) is because iframe based editors are subjected too many injection attacks.
Features
- Inserts HTML codes in textarea
- No iFrames
- Fast loading and lightweight (code just under 2kb)
- Works on all major browsers
- No popup html window for inserting hyperlinks.
- Easy to integrate
- Inserts quick html code
- Inserts ordered and unordered lists (new feature)
This editor is 100% FREE and feel free to use this editor in your projects or do whatever you want. Please spread word by any means possible.
Note:This editor inserts html code. If you want a same editor, capable of inserting bbcode, you can download free bbcode editor
Free Icons
If you want to customize the editor with new icons you can download silk icons set. It is free!
How to Install
1. Just extract the folder and upload editor folder to your server. All the editor code and images are inside that folder. You should not run any php scripts inside this folder. Any html or php script calling this editor must above and outside this folder
2. Create a PHP script or html page (ex: example.php ) and initialize the editor with the below code.
Starting the Editor
To initialize the editor, you have insert the following lines
1. Place this code inside the
of the html page inside head tag.<script type="text/javascript" src="editor/ed.js"></script>
2. Place this 2 lines of code within the form or wherever you want the textarea editor to appear. The name and id of textarea could be anything, just make sure that both are same.
....
<script>edToolbar('mytxtarea'); </script>
<textarea name="mytxtarea" id="mytxtarea" class="ed"></textarea>
.....
Note: Make sure that the id value and the value inside of edToolbar () is same.
If you want multiple instances of editors, on same page
<form name="form1" method="post" action="">
<p>
<script>edToolbar('mytxtarea'); </script>
<textarea name="mytxtarea" id="mytxtarea" class="ed">This is a sample text</textarea>
</p>
<p>
<script>edToolbar('mytxtarea2'); </script>
<textarea name="mytxtarea2" id="mytxtarea2" class="ed">This is a sample text</textarea>
</p>
<p>
<script>edToolbar('mytxtarea3'); </script>
<textarea name="mytxtarea3" id="mytxtarea3" class="ed">This is a sample text</textarea>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
The default height and width of text area is specified in styles.css. It is 400px width and 150 height. You can open styles.css and modify the width and height of text area.
Frequently Asked Questions
1. How do i customize the editor with stylesheet?
It is easy to customize the images and editor with stylesheet. Just change stylesheet code in styles.css
2. Images does not appear or does not load.
There could be a problem in the path of images the editor relative to your PHP script. Just place the bbeditor folder below / assuming that php script is in /example.php and the editor is /bbeditor/images
if you want to manually change the path of images, open ed.js and you will need to change lines like this indicating the correct path of images.
document.write("<img class="button" src="editor/images/bold.gif" name="btnBold" onClick="doAddTags('<strong>','</strong>')">");
.....
3. How do i load the data stored in database to the editor for editing?
This is a very important question. Suppose you have inserted the content with bbcodes to the database but what if you want to make changes to the content. You might want to pull the content from database and load it in editor to make editing and changes to it. In that case you will need to output the javascript initialization with php. In this way you will load the content when the editor starts.
<form name="form1" method="post" action="">
<p>
<script>edToolbar('mytxtarea'); </script>
<textarea name="mytxtarea" id="mytxtarea" class="ed">//PHP CODE HERE//</textarea>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
Disclaimer: use of this script is at your own risk.
You can also discuss about this script in my forum. Although i cannot provide support because of my busy schedule, i would be happy to discuss in the forum.




















December 19th, 2008 at 7:12 am
If this one will be easy to edit(extend) I think I have some plans for it!
Great job man!
December 19th, 2008 at 7:31 am
When you click on the add image or link and you select cancel, the link tags or image tags are still inserted in the textarea.
a quick fix:
function doImage()
{
var url = prompt('Enter the Image URL:','http://');
if (url)
{
if (document.selection)
{
textarea.focus();
var sel = document.selection.createRange();
sel.text = '[img]' + url + '[/img]';
}
else
{
var len = textarea.value.length;
var start = textarea.selectionStart;
var end = textarea.selectionEnd;
var sel = textarea.value.substring(start, end);
var rep = '[img]' + url + '[/img]';
textarea.value = textarea.value.substring(0,start) + rep + textarea.value.substring(end,len);
}
}
}
the same for the doURL function.
hth
December 19th, 2008 at 10:25 am
Thanks costan. I spotted the bug. I fixed it now.
December 23rd, 2008 at 11:42 am
Great editor, thanks. How would you go about adding a bullet and numeric list? I assume one is similar to the other, but if not please correct me. I understand the functionality of adding tags before and after selected text, but in the case of lists, there are multiple items to be tagged. Can you post some suggestions? Thanks again.
December 25th, 2008 at 10:00 pm
Hi,
I like this simple editor, but I have a problem with “WYSIWYG”, you can’t call it like that…
A WYSIWYG is an editor where you can see the result in the textarea, and this is not the case with this one…
But goo job guy !
December 26th, 2008 at 3:28 pm
Sorry, wordpress has deleted my labels example.
Good job, but this textarea editor not generates well formated xhtml output. This could be a great editor if you can revert this. Go ahead.
Regards,
Juan Pablo
December 26th, 2008 at 3:28 pm
your editor generate a BR instead P (paragraph). That.
January 10th, 2009 at 5:54 pm
Hey,
First of all, this is exactly the editor I was looking for!
I do have one problem however…
I try to load content from my database as you described (echo the javascript through php) But still it doesn’t work.
I discoverd this is because of line breaks in the content. I tried to strip_tags from my content and than str_replace all \n with but still it won’t initialise the textarea…
Do you have any idea what i can do?
Thanks!
Greetz,
Chris
January 10th, 2009 at 6:43 pm
i think you have to escape any special characters instead of str_replace. Try it!
January 11th, 2009 at 12:24 pm
Ok, but how do I do that?
January 16th, 2009 at 10:56 am
Hi, we are using your script on features.opensuse.org to edit the richtext fields. It’s very useful, thanks!
We patched it to work with multiple textareas on the same page, and added some more icons.
Diff:
10c10
15,23c14,22
‘,’‘)\”>”);
‘,’‘)\”>”);
‘,”)\”>”);
“);
“);
‘,’‘)\”>”);
‘,’‘)\”>”);
—
> function Init(obj_id,obj_name,width,height, val) {
>
> document.write(”‘,’‘)\”>”);
> document.write(”‘,’‘)\”>”);
> document.write(”‘,”)\”>”);
> document.write(”");
> document.write(”");
> document.write(”‘,’‘)\”>”);
> document.write(”‘,’‘)\”>”);
25,29c24,29
“);
document.write(”");
>
> textarea = document.getElementById(obj_id);
> textarea.innerHTML = val;
> }
>
60c60
function doURL(area)
63a64,65
> if (url == null) return;
> var textarea = document.getElementById(area);
66d67
function doAddTags(area, tag1,tag2)
106a108
> var textarea = document.getElementById(area);
January 16th, 2009 at 10:58 am
oops, the diff got destroyed by the blog…
Can see the changed script here:
https://features.opensuse.org/javascripts/ed.js
(needs opensuse login)
January 16th, 2009 at 7:06 pm
yeah! saw that tom! good to know my work used in opensusse! enjoy the script.
January 23rd, 2009 at 8:58 pm
sorry for my English.
I have the same problem of Costin
this is my solution:
function doURL()
{
var sel;
var url = prompt(’Inserisci URL del link:’,'http://’,'target’);
// change Eros
// ask if in the same window or in new window
//
var openNew = confirm(’Vuoi che il LINK si apra in una nuova finestra?\n\nOK = Apre in una NUOVA finestra\nCancel = Apre in QUESTA finestra’);
if(openNew) {
target = “blank”;
} else {
target = “self”;
}
var scrollTop = textarea.scrollTop;
var scrollLeft = textarea.scrollLeft;
if (document.selection)
{
textarea.focus();
var sel = document.selection.createRange();
if(sel.text==”"){
sel.text = ‘‘ + url + ‘‘;
} else {
sel.text = ‘‘ + sel.text + ‘‘;
}
//alert(sel.text);
}
else
{
var len = textarea.value.length;
var start = textarea.selectionStart;
var end = textarea.selectionEnd;
var sel = textarea.value.substring(start, end);
if(sel==”"){
sel=url;
} else
{
var sel = textarea.value.substring(start, end);
}
alert(sel);
var rep = ‘‘ + sel + ‘‘;;
textarea.value = textarea.value.substring(0,start) + rep + textarea.value.substring(end,len);
textarea.scrollTop = scrollTop;
textarea.scrollLeft = scrollLeft;
}
}
January 24th, 2009 at 7:12 pm
UPDATE: i fixed the problem of loading data within the editor. Now you can directly embedd php code inside textarea of editor to load data from database.
I struggled a number of days to fix this and changed the editor initialisation type and solution was surprisingly simple.
Enjoy!
January 24th, 2009 at 11:13 pm
With this data don’t crash:
echo “Init(\”obj\”,460,50,\”". str_replace(’”‘,’`',$text) .”\”); “;
How is it possible to use more than one EDITOR in the same webpage?
When I click an icon, the TAG is inserted in the last EDITOR of the webpage. I need three EDITOR in the same page. Thank you!
January 26th, 2009 at 1:17 pm
UPDATE: This editor as of v1.3 now works in multiple instances on same page. Thanks Ers!
February 25th, 2009 at 10:18 am
[…] Lightweight and very fast loading editor, which just inserts bbcode or html markup codes on the selected text. License: Free Homepage | Download […]
March 4th, 2009 at 6:34 pm
Hi There Balakrishnan!
I’ve see you’ve don’t give a email for contact with you,so ill ask here.
Can I get Your permission for edit and you this software of your.I’ve really need a response from you.
Thank You
With Big Respect,
Alirius.
March 4th, 2009 at 7:04 pm
yes, you are free to modify the script as you wish. Just dont remove the copyright.
March 4th, 2009 at 7:09 pm
No i won’t remove it,ill put link to here to can and other people to use this great script, thank you again.Have a nice day.
With Bi Respect,
Alirius
April 20th, 2009 at 7:19 pm
Can I make some more buttons based on yours? I really need , , and so on.
PS. Great editor.
April 20th, 2009 at 7:22 pm
Ups. Something went wrong. Here`s that missing part …[P], [CENTER], [HR]…
Hope it will work now.
April 20th, 2009 at 8:45 pm
go ahead! no problem.
And of the errors, just make sure you have closed html tags.
April 27th, 2009 at 2:30 am
well, my client is kinda dumb (pardon the offense - I mean an non-internet savvy person) and I’m still not very sure if he’ll be able to use it properly.
anyways, thanks for this wonderfully simple code!
May 28th, 2009 at 6:09 pm
How would one go about adding more html tags in the editor?
June 8th, 2009 at 4:56 pm
This WYSIWYG program is like many others I’ve found. Nice but does not have the one feature that most Web developers are looking for in a textarea WYSIWYG editor replacement program.
What it is lacking is the ability for a user to include an image in their content.
This program was likened to WordPress, but in WordPress I can easily include a picture in my article. The main image is uploaded and a thumbnail image is automatically created and included in the article where the author placed it. It is also automatically linked to the larger image.
So this program is similar to WordPress only in the respect that it can make words Bold, Italicized, etc. While it does have an image button, it is nothing more than you linking to an existing image on the server or Web. In fact, it could be considered to a device to aid a user to “Hotlink” (steal bandwidth from other websites).
This type of Image linking should be illegal in my opinion. If a WYSIWYG editor is going to have an image device, it should be one that uploads an image to that server and links to that image only on that server.
June 8th, 2009 at 8:16 pm
hi david,
What you are suggesting is easy to implement. All you have to do is first upload the file, get the file path and pass it to the editor url variable to insert the image.
June 30th, 2009 at 9:03 am
This looks good.
However, although my buttons are controlled by the stylesheet, the textarea ignores it.
This is on a Linux (Ubuntu) server. I had to modify the image paths for the buttons slightly. Anyone got any ideas?
July 3rd, 2009 at 6:55 am
Have resolved my own problem, caused by my sloppy use of names. All works lovely now.
I have added a button. This is the only way I know to stop the text clumping together like unstirred porage. Very conveniently it only took a couple of minutes to edit the B gif to P using The Gimp.
Thanks again for a super bit of software.
July 3rd, 2009 at 6:57 am
re previous entry, it was a Paragraph button. my para html tag was of course clipped out by the machinery.