This method retrieves the currently selected text within the EditLive! applet. The method will retrieve the currently selected text and any inline tags within the current selection; it will not retrieve the parent tags of the selected text.
Prior to version 8.1 this function had no return value and the function was asynchronous. While asynchronous use is still supported, since version 8.1 this function can now be used synchronously with a return value.
This parameter is optional.
The selected text.
Example Synchronous (EditLive 8.1+)
Calling getSelectedText synchronously returns the currently selected text (including inline tags) as a string. This example retrieves the currently selected text and then saves the retrieved contents to a <textarea> with the name selectedText. The name of the EditLive applet is editlive_js.
Example Asynchronous (EditLive 8.0+)
This method is designed for use when selecting text within a single parent block tag. Using the method outside of this context may result in unexpected behaviour.
If using this method with selections which span multiple block tags, the opening parent tag of the block at the start of the selection and the closing parent tag of the block at the end of the selection will both be stripped from the retrieved content. For example:
If the following markup existed inside an instance of EditLive!:
And the selection extended from the word START in the first paragraph to the word END in the last paragraph, the following content would be returned: