Skip to content
Get Free Trial

Rich Text Editors (RTE)

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.

Since
Sahi Pro 3.5

Modes Browser

_rte($identifier[, $relation])

Arguments

NameTypeDescription
$identifierstringCan be name, id or index of iframe which houses the RTE.
$relationrelationoptionalRelation functions

Returns

null
_rte("editor") // using id
_rte(0, _in(_div("editorDiv"))) // using index and _in
Since
Sahi Pro 3.5

Modes Browser

_rteText($el)

Arguments

NameTypeDescription
$elHTML DOM elementElement which is content editable (eg. _rte(0))

Returns

stringText inside a rich text editor (without the html formatting)
// get the rich text editor's text content
var $rteText = _rteText(_rte("rteId"));
// $rteText may look like "Hi there"
Since
Sahi Pro 3.5

Modes Browser

_rteHTML($el)

Arguments

NameTypeDescription
$elHTML DOM elementElement which is content editable (eg. _rte(0))

Returns

stringHTML content inside a rich text editor (without the html formatting)
// get the rich text editor's HTML content
var $rteHTML = _rteHTML(_rte("rteId"));
// $rteHTML may look like "Hi <b>there</b>"
Since
Sahi Pro 3.5

Modes Browser

_rteWrite($rte, $html)

Arguments

NameTypeDescription
$rteHTML DOM elementRTE to write into
$htmlstringhtml to write

Returns

null

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

_rteWrite(_rte("editor"), "Hi <b>user</b>");