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.
Identification
Section titled “Identification”- Since
- Sahi Pro 3.5
Modes Browser
_rte($identifier[, $relation])Arguments
| Name | Type | Description |
|---|---|---|
$identifier | string | Can be name, id or index of iframe which houses the RTE. |
$relation | relationoptional | Relation functions |
Returns
null |
_rte("editor") // using id_rte(0, _in(_div("editorDiv"))) // using index and _inRTE Fetch Functions
Section titled “RTE Fetch Functions”_rteText
Section titled “_rteText”- Since
- Sahi Pro 3.5
Modes Browser
_rteText($el)Arguments
| Name | Type | Description |
|---|---|---|
$el | HTML DOM element | Element which is content editable (eg. _rte(0)) |
Returns
string | Text inside a rich text editor (without the html formatting) |
// get the rich text editor's text contentvar $rteText = _rteText(_rte("rteId"));// $rteText may look like "Hi there"_rteHTML
Section titled “_rteHTML”- Since
- Sahi Pro 3.5
Modes Browser
_rteHTML($el)Arguments
| Name | Type | Description |
|---|---|---|
$el | HTML DOM element | Element which is content editable (eg. _rte(0)) |
Returns
string | HTML content inside a rich text editor (without the html formatting) |
// get the rich text editor's HTML contentvar $rteHTML = _rteHTML(_rte("rteId"));// $rteHTML may look like "Hi <b>there</b>"RTE Action Functions
Section titled “RTE Action Functions”_rteWrite
Section titled “_rteWrite”- Since
- Sahi Pro 3.5
Modes Browser
_rteWrite($rte, $html)Arguments
| Name | Type | Description |
|---|---|---|
$rte | HTML DOM element | RTE to write into |
$html | string | html 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>");
