6

I am creating a new project which needs a simple html editor. How can I create simple text editor using jquery?

7 Answers 7

13

I suggest that: jqueryte

This is wonderful and simple ;)

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the suggestion, I forked it and made it jQuery Mobile optimized, I will post an answer.
How do I implement it?
7

I forked the jQueryTE plugin (a great, minimal rich text editor) and made it jQuery Mobile compatible - it now resizes with the browser, and the panel will span 2 lines if necessary (portrait-view on iPhone for instance).

https://github.com/jeffijoe/jQuery-TE

A screenie of what this looks like:

Portrait

Portrait

Landscape

enter image description here

Comments

4

I was looking for perfect answer. But didn't found any of them. At last went through basics.

Here's how i did it.

HTML:

<div id="editor" contenteditable="true">Lorem Ipsum is simply dummy text</div>
<button id="make-bold">Make bold</button>

JS:

document.getElementById('make-bold').addEventListener('click', function(event){
    event.preventDefault();

    var selection = window.getSelection();
    var range = selection.getRangeAt(0).cloneRange();
    var tag = document.createElement('strong');

    range.surroundContents(tag);
    selection.addRange(range);
});

Live demo - https://jsfiddle.net/im4aLL/Lyusxq3p/

I pullout the basic idea by this and finally made something which i use in my future projects.

I made EasyEditor - https://github.com/im4aLL/easyeditor from above concept. There are lot more things to do. Like when are wrapping a node you need to check wheather that selection already wrapped with other node or same node. Also there are lot of functions you need to overcome.

Or you may try my lightweight plugin which i made for guys like you who need full flexible solution to integrate it with another application.

Here's the demo and documentation for use EasyEditor

Usage

http://habibhadi.com/lab/easyeditor/default-example.html

1 Comment

@NaveenSaroye here is the es6 version github.com/im4aLL/roolith-editor
2

for it you can directly download code of text editor and out it in your application you can download it from following sites:

http://www.intrepidstudios.com/projects/jquery-rich-text-editor/demo.aspx http://freshcode.co/plugins/jquery.contenteditable/demo.html

Comments

1

By a simple search you can find a lot of editors so I recommend this one 10 jQuery Text Editor Plugins

Comments

0

You may choose one of these: http://www.queness.com/post/212/10-jquery-and-non-jquery-javascript-rich-text-editors

I personally prefer TinyMCE, non jquery editor.

Comments

0

CKEditor is my option for decent Editor.

1 Comment

CKEditor is not simple, in fact it's very bloated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.