Вопрос

i am using this function to insert text into NicEdit,

function insertAtCursor(editor, value){
var editor = nicEditors.findEditor(editor);
var range = editor.getRng();                    
var editorField = editor.selElm();
editorField.nodeValue = editorField.nodeValue.substring(0, range.startOffset) +
                        value +
                        editorField.nodeValue.substring(range.endOffset, editorField.nodeValue.length);}

This code works fine for simple text but when i pass HTML content into it, it does not render the HTML output in div instead it dumps the HTML code as it is into the Instance Div.

Example:

<div class="one">Some text here</div>

This must show in the Instance as "Some text here" and remaining code hidden in source code.

Can any one give me a solution to fix this problem?

Это было полезно?

Решение

After working whole night and trying different solutions I had finally got it working! :)

In case any one wants to know solution for this, I had to add a Replace function

replace()

for the content and made it support HTML.

Другие советы

See my answer HERE. It's a plugin I created to insert html at the cursor position.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top