Sahi Documentation

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 ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
3.527.0.1NANANANA

Available for modes: Browser

_rte($identifier[, $relation])

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

Returns
null

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 ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
3.527.0.1NANANANA

Available for modes: Browser

_rteText($el)

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

Returns
stringText inside a rich text editor (without the html formatting)

Details

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


_rteHTML

Since: Sahi ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
3.527.0.1NANANANA

Available for modes: Browser

_rteHTML($el)

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

Returns
stringHTML content inside a rich text editor (without the html formatting)

Details

// 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 ProSahi OSSahi Pro StarterDesktop Add-OnMobile Add-OnSAP Add-OnAI Assist Add-On
3.527.0.1NANANANA

Available for modes: Browser

_rteWrite($rte, $html)

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

Returns
null

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