designMode and custom actions?

1k Views Asked by At

So my newest project requires the use of designMode (or similar methods of creating rich text editors), but I am having difficulty using the default commands. I would much rather insert my own HTML at the location of the selector. For example, I would want inserted images to have an align property (with proper CSS, of course), insert HTML5 video tags, etc. Is there a "preferred" method of doing this (with Javascript or jQuery)?

Thanks!

1

There are 1 best solutions below

5
On BEST ANSWER

You don't have to use document.execCommand() for this; it's relatively simple without, and more flexible.

I've provided an answer to a similar question that inserts arbitrary HTML at the current caret position: Insert html at caret in a contenteditable div.