Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top