Rich Text Editors (RTE)

abstract Rich Text Editors (RTEs) are iframes/divs whose designMode or contentEditable property is set to true. Such components allow input of text and formatting them (making text bold, inserting images etc.)
Rich Text Editors do not respond to regular events and need to be handled specifically.

Identification



warning Sahi does NOT identify iframes on CTRL-Hover. Use the browser's Developer Tools to identify some element inside the RTE, and look up in the heirarchy to find the relevant iframe. "View Source" will not help identify iframes in most cases because, RTEs are mostly built dynamically at run time and replace existing textareas.

RTE Fetch APIs

Rte Text


Parameters
$elHTML DOM element Element which is content editable (eg. _rte(0))
Return Value
stringText inside a rich text editor (without the html formatting)

Modes Supported :
Raw Script
// get the rich text editor's text content
var $rteText = _rteText(_rte("rteId"));
// $rteText may look like "Hi there"

Sahi Pro Classic API :_rteText


Rte HTML


Parameters
$elHTML DOM element Element which is content editable (eg. _rte(0))
Return Value
stringHTML content inside a rich text editor (without the html formatting)

Modes Supported :
Raw Script
// get the rich text editor's HTML content
var $rteHTML = _rteHTML(_rte("rteId"));
// $rteHTML may look like "Hi <b>there</b>"

Sahi Pro Classic API :_rteHTML


RTE Action APIs

Rte Write

Replaces the content of the RTE with given HTML. Note that this does not simulate all events like other Sahi APIs. Rte Write only replaces the content of the iframe.

Parameters
$rteHTML DOM element RTE to write into
$htmlstring html to write
Return Value

Modes Supported :
Raw Script
_rteWrite(_rte("editor"), "Hi <b>user</b>");

Sahi Pro Classic API :_rteWrite


RTE Text Selection APIs