Extending RTE with its JavaScript API

Rich Text Editor for PHP

RichTextEditor makes it easy for you to extend RichTextEditor with it's JavaScript API.

Getting the RichTextEditor Instance by ID

In order to find the active editor by its ID, you would type:

// get the rich text editor instance
var editor1 = document.getElementById('<?php echo $rte->ID; ?>').editor;

Please note that there are other methods to get the editor instance. For details, please check editor events.

Getting the Active Editor Window

In order to find the active editor window, you would type:

// get the active editor window
var editor1 = document.getElementById('<?php echo $rte->ID; ?>').editor;
var editwin = editor1.GetWindow();

Getting the Active Editor Document

In order to find the active editor document, you would type:

// get the active editor document
var editor1 = document.getElementById('<?php echo $rte->ID; ?>').editor;
var editwin = editor1.GetWindow();
var editdoc = editwin.document;

Getting an Array of the Selected Nodes

In order to an array of the selected nodes, you would type:

// get an array of the selected nodes
var editor1 = document.getElementById('<?php echo $rte->ID; ?>').editor;
var selnodes = editor1.ExtractRangeNodes();

Retrieves the HTML contained within the selection range

In order to get the HTML contained within the selection range, you would type:

// get the HTML contained within the selection
var editor1 = document.getElementById('<?php echo $rte->ID; ?>').editor;
var selhtml = editor1.ExtractRangeHTML();

Send feedback about this topic to CuteSoft. © 2003 - 2012 CuteSoft Components Inc. All rights reserved.