Javascript Functions

This is for advanced users. The object editAreaLoader has some public functions that can be called from the page in order to manage the EditArea editors.

editAreaLoader.getValue(editor_id)

This method return the content text of the editor. Works on normal textarea if the EditArea is toggled off.

Parameters
editor_id The id of the converted textarea

Returns: the content text of the editor. String

editAreaLoader.setValue(editor_id, new_text)

This method allow to update the content text of an editor. Works on normal textarea if the EditArea is toggled off.

Parameters
editor_id The id of the converted textarea
new_text The new text that will replace the Editor content.

Returns: Nothing.

editAreaLoader.insertTags(editor_id, open_tag, close_tag)

This method allow to insert tags at the current position. If no text was selected, the cursor is then displayed between the open and the close tags. Otherwise, the cursor is positionned after the close tag. Works on normal textarea if the EditArea is toggled off.

Parameters
editor_id The id of the converted textarea
open_tag The open tag string.
close_tag The close tag string.

Returns: Nothing.

editAreaLoader.getSelectedText(editor_id)

This method return the text contained in the the selection range. Works on normal textarea if the EditArea is toggled off.

Parameters
editor_id The id of the converted textarea

Returns: The text contained in the the selection range. String

editAreaLoader.setSelectedText(editor_id, new_text)

This method allow to replace the text contained in the selection range with a given string. The selection range will then contain the new string. Works on normal textarea if the EditArea is toggled off.

Parameters
editor_id The id of the converted textarea
new_text The string that will replace the current selected text.

Returns: Nothing.

editAreaLoader.getSelectionRange(editor_id)

This method return the position start and position end of the selection range in the editor. Works on normal textarea if the EditArea is toggled off.

Parameters
editor_id The id of the converted textarea

Returns: An array containing the index of the selection start and end. Array("start", "end")

editAreaLoader.setSelectionRange(editor_id, new_start, new_end)

This method allow to set the selection range with the given start and end positions. Works on normal textarea if the EditArea is toggled off.

Parameters
editor_id The id of the converted textarea
new_start The character position determining the start of the selection range.
new_end The character position determining the end of the selection range.

Returns: Nothing.

editAreaLoader.execCommand(editor_id, command, command_param)

Allow to access to EditArea functions and datas (for advanced users only).

Parameters
editor_id The id of the converted textarea on which the command should be executed.
command The function or the parameter of the EditArea object that will be returned.
command_param (optionnal) If command is a function, the you can pass one parameter to the function with command_param

Returns: the value of the executed command or data. unknown

Examples
Change edit mode

Allow to toggle EditArea etit mode from normal edition to readonly with no toolbars.

editAreaLoader.execCommand('editor_id', 'set_editable', !editAreaLoader.execCommand('editor_id', 'is_editable'));
Insert tags

Insert tags arround selected text or at current cursor position if not text is selected

editAreaLoader.insertTags('editor_id', "[OPEN]", "[CLOSE]");

editAreaLoader.delete_instance(editor_id)

Delete an instance of EditArea and restore simple textarea.

Parameters
editor_id The id of the converted textarea on which the command should be executed.

Returns: Nothing.

editAreaLoader.hide(editor_id)

Hide a textarea and it's related EditArea.

Parameters
editor_id The id of the converted textarea on which the command should be executed.

Returns: Nothing.

editAreaLoader.show(editor_id)

Restore a textarea and it's related EditArea hidden with the hide() function.

Parameters
editor_id The id of the converted textarea on which the command should be executed.

Returns: Nothing.

editAreaLoader.openFile(editor_id, file_infos)

Parameters
editor_id The id of the converted textarea on which the command should be executed.
file_infos An object containing datas of the file that will be openned. Here are the main fields (for the other possible fields see the returned Object of the getFile function):
  • id : (required) A string that will identify the file. it's the only required field.
    Type: String
  • title : (optionnal) The title that will be displayed in the tab area.
    Type: String
    Default: set with the id field value
  • text : (optionnal) The text content of the file.
    Type: String
    Default: ""
  • syntax : (optionnal) The syntax to use for this file.
    Type: String
    Default: ""
  • do_highlight : (optionnal) Set if the file should start highlighted or not
    Type: String
    Default: ""

Returns: Nothing.

editAreaLoader.getCurrentFile(editor_id)

Return datas of the currently selected file (for multi file editing mode).

Parameters
editor_id The id of the converted textarea on which the command should be executed.

Returns: An object containing datas related to the file.Object

editAreaLoader.getFile(editor_id, file_id)

Return datas of the file identified by file_id (for multi file editing mode).

Parameters
editor_id The id of the converted textarea on which the command should be executed.
file_id The id of the file to close.

Returns: An object containing datas related to the file.Object

editAreaLoader.getAllFiles(editor_id)

Return datas of all the currently openned files (for multi file editing mode).

Parameters
editor_id The id of the converted textarea on which the command should be executed.

Returns: An object containing datas of each files.Object

editAreaLoader.closeFile(editor_id, file_id)

Close the file identified by file_id (for multi file editing mode).

Parameters
editor_id The id of the converted textarea on which the command should be executed.
file_id The id of the file to close.

Returns: Nothing.

editAreaLoader.setFileEditedMode(editor_id, file_id, edited_mode)

Define is the file should appears as edited or not.

Parameters
editor_id The id of the converted textarea on which the command should be executed.
file_id The id of the file to close.
edited_mode A boolean that indicate if the file should be set edited or not edited.

Returns: Nothing.