M
M
MOst_532011-10-12 00:06:48
JavaScript
MOst_53, 2011-10-12 00:06:48

How to do WYSIWYG with jQuery?

Explain on your fingers how to make a simple vizivig editor like TinyMCE or CKEditor. I am interested in the idea without all the subtleties. Thank you.

Answer the question

In order to leave comments, you need to log in

11 answer(s)
K
Kobs, 2011-10-12
@Kobs

You need to use the designMode document property. You can open a document in designMode in an iframe.
Something like this: in the code, the parser eats "<" and ">" ( I once wrote WYSIWYG from scratch, if necessary I can look for the source code.
document.writeln(' iframe id="' + editor + '" /iframe ');
var edit = document.getElementById(editor).contentWindow.document;
edit.designMode = "On";

F
Finom, 2011-10-13
@Finom

There was an idea to write a short article, presenting the simplest editor in 2 KB using jQuery, but then I scored (the editor itself is, too lazy to design). If you are interested, I will give the code in a personal correspondence.

S
Stalker_RED, 2011-10-12
@Stalker_RED

you can still dig into the imperavi sources

A
Alexey Blyshko, 2011-10-12
@nekt

When I was tinkering with this, I didn’t really like the designMode option - an abundance of left tags, difficulties with their overlap, and the like. I end up leaning towards creating and positioning various inputs and styling them to match the element being edited.
And Googledocs, as far as I remember, simply catch the events of pressing the keyboard keys, substituting them with javascript in the place where the cursor is set. The cursor, by the way, is also drawn there manually - it is not native.

I
Ivan Klimchuk, 2011-10-12
@Alroniks

Have a look at imperavi . Maybe you don't need to write anything. And if necessary, the license is open there, you can see the implementation and finish it or make your own with blackjack.

A
aps, 2011-10-13
@aps

+1 for imperavi. Most understandable code. Best for studying.
But the idea of ​​writing CKEditor is obviously unhealthy - you will drown in cross-browser.
The same imperavi has to be finished

U
un1t, 2012-11-12
@un1t

I wrote my own WYSIWYG though it doesn't fully work in IE yet, but it's enough for my purposes.
github.com/un1t/pencil
The code is small, easy to understand. It’s hard to write, visivig yourself, but to finish someone else’s is even more difficult. If you fix a couple of broken moments in IE, then you can use it quite normally.
If you want, you can help me finish it.

O
Oleg Yakovenko, 2011-10-12
@Apx

nicEdit. You can select the elements that will be displayed on the panel. If you still want to reinvent the wheel, look at its sorts and write in jquery (although the option is not very good, jquery as an additional dependency ...)

H
homm, 2011-10-12
@homm

Here's an article to get you started: blog.whatwg.org/the-road-to-html-5-contenteditable

D
dio, 2011-10-12
@dio

If you are interested in seeing the source code, you can dig into our monster github.com/Studio-42/elRTE

S
Sergey, 2018-09-17
Gorbulev @gorbulevsv

Guys, I recently came across a site where it is written how easy it is to implement this wysing. To be honest, I was delighted.
Here is the link: www.pvsm.ru/javascript/24443 . Or the same: https://habr.com/post/161715/ .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question