Examples

RichTextEditor Methods

RichTextEditor exposes the following methods.

Method Description
execCommand(cmd,value) Executes a command on the current selection, or the given range.
attachEvent(name,handler) Registers an event handler.You can interact with it once the editor is loaded and running.
detachEvent(name,handler) Removes an EventHandler from an event.
getHTMLCode() This method is used for retrieving the content of RichTextEditor as HTML.
setHTMLCode(html) This method is used for setting the content of RichTextEditor.
getReadOnly() Returns a value indicating whether the editor's state is read-only on the client-side.
setReadOnly(bReadOnly) Allows you to enable/disable read-only mode.
isCommandEnabled(cmd) Gets whether the specified command is enabled.
isCommandActive(cmd) Checks whether this command can currently be performed.
focus() Attempt to set the focus of the editor content window.
setContentCssText(text) This method is used for setting inline CSS text that will be used by the editable area.
insertRootParagraph(tagname) This method is used for inserting a new paragraph at the bottom of editor.
insertByTagName(tagName) Inserts an element by tag name.
surroundByTagName(tagName) Get the content of selection and place it into an element. Then insert this new element.
insertElement(element) Inserts an element. This element must be created by editor.document.
surroundElement(element) Creates an element using editor.document. Places the content of selection into the element. Then insert this new element.
insertText(text) This method is used for inserting the specified plain text into editor document.
insertHTML(text) This method is used for inserting the specified HTML into a range within an editor document. If anything is selected, the selection is replaced with the new HTML and text.
selectControl(element) Selects a control.
selectDoc(bStart) Selects the document. The bStart is a boolean value: true moves the selection to its start, false to its end. If omitted, it defaults to false.
collapse(bStart) Collapses the current selection to a single point. The bStart is a boolean value: true collapses the Range to its start, false to its end. If omitted, it defaults to false.
delete() Deletes a selection.
commitBookmark() Creates a bookmark for undo record.
clearHistory() Clears all undo/redo records.
notifySelectionChange() Notifies the editor about any content change.
htmlEncode(text) Converts a string into an HTML-encoded string.
htmlDecode(html) Converts a string that has been HTML-encoded for HTTP transmission into a decoded string.
getSelection() Returns the editor.selection object.
getDocument() Returns the editor.document object.
getEditable() Returns the root element of the editable area.
getPlainText() Returns the editor.document.body.innerText object.
getSelectedControl() Returns the selected control object.
getSelectionElement() Returns the selected element object.
getSelectedText() Returns the selected plain text.
createToolbarButton(cmd) Creating a button in toolbar with default styles. For details, please refer to plugin example.
createToolbarDropDown(cmd) Creating a dropDown in toolbar with default styles. For details, please refer to plugin example.
createDialog(title,className) Creating a dialog with default styles. For details, please refer to plugin example.
closeCurrentPopup() Attempt to close all popups/dropdowns/menus/dialogs.
setImageForCommand(element,cmdname) Adds an image (svg or png) for cmdname to the element.