execCommand

Like many before me I have tried and largely failed to build a rich text editor in HTML.    I saw the paper by  Johannes Wilm <mailto:johannes@fiduswriter.org> trying to formally spec the execCommand method, and would like to add my thoughts on the subject.   I am assuming (hoping) this is the right place to do it.

Firstly, it seems that using contentEditable and execCommand is the only current way to build a rich text editor (RTE) without heroic measures..   It seems to an outsider like me that execCommand is the API to contentEditable elements.    It is unspecified and deprecated, but it clearly should not be removed until some alternative is provided.   It is currently widely in use and removing it would break a lot of websites.

Second, :   Rather than try and modify what exists, how about starting fresh with a  new HTML  element called , say, <editor>  .  It would be a block element a bit like <textarea> or a contentEditable <div>.   

The real difference is that the edit functions would be instance methods of the element, corresponding roughly to and replacing the execCommand calls.  I realize the specification of these methods would be tricky, but this approach allows a new fresh run at it without the concerns of backward compatibility.

It should be completely controllable from JS so we can build our own buttons and controls which simply call the element's methods.   

It would be styled using standard CSS, including the elements added to the document in the editing process. 

Having beaten myself nearly senseless trying to do this myself, I would think such a new element would be warmly accepted by the developer community.  I would be more than happy to contribute in any way I can.

Respectfully
John Page
jdpsaratoga@gmail.com <mailto:jdpsaratoga@gmail.com>

Received on Tuesday, 10 September 2024 09:30:13 UTC