Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How reliable is using contenteditable on a div for a WYSIWYG editor?

I believe the title is pretty self-explanatory but still, maybe, I should ask in detail. I'm building a WYSIWYG editor and I'm really at the beginning of it. So, I realized that maybe knowing the pros and cons would enlighten me. Basically, my question is, since I want an editor that would work at least with 90% in all major browsers, how further I can go using contenteditable within a div and what are the cons and pros of using contenteditable when compared with designMode and iframe? Also, while researching I've found this editor. I believe it is not using any of these attributes and it's moving the location of textarea. Is this a better approach? Well, I know that there are lots of factors that influence the answer on the last question, but as I mentioned, the most important thing I look up in the editor is that it can be used by the 90% of the users. NB: I do not want to use any third party libraries.

like image 575
Shaokan Avatar asked Apr 16 '11 09:04

Shaokan


People also ask

Is Contenteditable safe to use?

Its totally secure. The contenteditable attribute is an enumerated attribute whose keywords are the empty string, true, and false.

What is Contenteditable div?

Definition and Usage The contenteditable attribute specifies whether the content of an element is editable or not.

What is false about Contenteditable attribute?

The contentEditable property of the HTMLElement interface specifies whether or not the element is editable. This enumerated attribute can have the following values: ' true ' indicates that the element is contenteditable . ' false ' indicates that the element cannot be edited.

What does Contenteditable attribute do?

The contenteditable global attribute is an enumerated attribute indicating if the element should be editable by the user. If so, the browser modifies its widget to allow editing.


1 Answers

contentEditable does not work with floats in IE:

<p>
  <img style="float:left" src="foo">
  <p contentEditable="true">very long text here ...
    ... this text won't flow round the image</p>
</p>

This is because contentEditable triggers the infamous hasLayout. Other than that, everything works pretty well.

like image 79
user123444555621 Avatar answered Sep 28 '22 01:09

user123444555621