Load RTF content into HTML component

1

I'm using the SCEditor API to make a text editor available on the page, but I need to fill it out (with the value) with the content of a string in RTF. I did this, but it already made a mistake in the quotation marks ...

    var textarea = document.getElementById('example');
    sceditor.create(textarea, {
        format: 'xhtml',
        style: 'minified/themes/content/default.min.css'
    });
    
asked by anonymous 08.01.2018 / 14:31

1 answer

1

It does not work because the SCEditor plugin creates a iframe to display the contents of textarea . You can not directly change the textarea , or if you do, you should also update the sceditor plugin.

To update the textarea along with the sceditor you must retrieve the instance that the object creates and use val() to insert the values and updateOriginal() to update the DOM object textarea:

var textarea = document.getElementById('example');
sceditor.create(textarea, {
    format : 'xhtml',
    style: 'minified/themes/content/default.min.css'
});
sceditor.instance(textarea).val("string que você quer inserir aqui");
sceditor.instance(textarea).updateOriginal(); // atualiza o DOM textarea
    
08.01.2018 / 15:52