Sahi Pro - 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


_rte

Since Sahi Pro: 3.5
Since Sahi OS: 2

_rte($identifier[, $relation ...])

Arguments
$identifierstring Can be name, id or index of iframe which houses the RTE.
$relation ...relation optional Relation APIs

Details

_rte("editor") // using id
_rte(0, _in(_div("editorDiv"))) // using index and _in
info _rte is the same as _iframe.

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


_rteText

Since Sahi Pro: 3.5
Since Sahi OS: 2

_rteText($el)

Arguments
$elHTML DOM element Element which is content editable (eg. _rte(0))

Details

Returns the text inside a rich text editor (without the html formatting) as a string.
// get the rich text editor's text content
var $rteText = _rteText(_rte("rteId"));
// $rteText may look like "Hi there"

_rteHTML

Since Sahi Pro: 3.5
Since Sahi OS: 2

_rteHTML($el)

Arguments
$elHTML DOM element Element which is content editable (eg. _rte(0))

Details

Returns the HTML content inside a rich text editor (without the html formatting) as a string.
// get the rich text editor's HTML content
var $rteHTML = _rteHTML(_rte("rteId"));
// $rteHTML may look like "Hi <b>there</b>"

RTE Action APIs


_rteWrite

Since Sahi Pro: 3.5
Since Sahi OS: 2

_rteWrite($rte, $html)

Arguments
$rteHTML DOM element RTE to write into
$htmlstring html to write

Details

Replaces the content of the RTE with given HTML.
Note that this does not simulate all events like other Sahi APIs.
_rteWrite only replaces the content of the iframe.
_rteWrite(_rte("editor"), "Hi <b>user</b>");

RTE Text Selection APIs