org.xwiki.gwt.wysiwyg.client
Class WysiwygEditorApi

java.lang.Object
  extended by org.xwiki.gwt.wysiwyg.client.WysiwygEditorApi

public class WysiwygEditorApi
extends Object

This class exposes a WysiwygEditor to the native JavaScript code.

Version:
$Id: 1df5673d93d632f945cecb29884aec710d9cca67 $

Field Summary
static Command SUBMIT
          The command used to submit the value of the rich text area.
 
Constructor Summary
WysiwygEditorApi(JavaScriptObject jsConfig)
          Creates a new WysiwygEditor based on the given configuration object.
 
Method Summary
 com.google.gwt.event.shared.HandlerRegistration addActionHandler(String actionName, JavaScriptObject jsHandler)
          Creates an action handler that wraps the given JavaScript function and registers it for the specified action.
 CommandManagerApi getCommandManagerApi()
           
 String getParameter(String name)
           
 com.google.gwt.core.client.JsArrayString getParameterNames()
           
 com.google.gwt.user.client.Element getPlainTextArea()
           
 com.google.gwt.user.client.Element getRichTextArea()
           
 JavaScriptObject getSelectionRange()
           
 void getSourceText(JavaScriptObject onSuccess, JavaScriptObject onFailure)
          Sends a request to the server to convert the HTML output of the rich text editor to source text and calls one of the given functions when the response is received.
static boolean isRichTextEditingSupported()
           
static void publish()
          Publishes the JavaScript API that can be used to create and control WysiwygEditors.
 void release()
          Releases the editor so that it can be garbage collected before the page is unloaded.
 void setFocus(boolean focused)
          Focuses or blurs the WYSIWYG editor.
 void setSelectionRange(JavaScriptObject jsRange)
          Sets the rich text area's selection range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUBMIT

public static final Command SUBMIT
The command used to submit the value of the rich text area.

Constructor Detail

WysiwygEditorApi

public WysiwygEditorApi(JavaScriptObject jsConfig)
Creates a new WysiwygEditor based on the given configuration object.

Parameters:
jsConfig - the JavaScriptObject used to configure the newly created editor
Method Detail

isRichTextEditingSupported

public static boolean isRichTextEditingSupported()
Returns:
true if the current browser supports rich text editing, false otherwise

release

public void release()
Releases the editor so that it can be garbage collected before the page is unloaded. Call this method before the editor is physically detached from the DOM document.


getPlainTextArea

public com.google.gwt.user.client.Element getPlainTextArea()
Returns:
the plain HTML text area element used by the editor

getRichTextArea

public com.google.gwt.user.client.Element getRichTextArea()
Returns:
the rich text area element used by the editor

getSourceText

public void getSourceText(JavaScriptObject onSuccess,
                          JavaScriptObject onFailure)
Sends a request to the server to convert the HTML output of the rich text editor to source text and calls one of the given functions when the response is received.

Parameters:
onSuccess - the JavaScript function to call on success
onFailure - the JavaScript function to call on failure

getCommandManagerApi

public CommandManagerApi getCommandManagerApi()
Returns:
a JavaScript object that exposes the command manager used by the rich text area

addActionHandler

public com.google.gwt.event.shared.HandlerRegistration addActionHandler(String actionName,
                                                                        JavaScriptObject jsHandler)
Creates an action handler that wraps the given JavaScript function and registers it for the specified action.

Parameters:
actionName - the name of the action to listen to
jsHandler - the JavaScript function to be called when the specified action occurs
Returns:
the registration for the event, to be used for removing the handler

getParameter

public String getParameter(String name)
Parameters:
name - the name of a configuration parameter
Returns:
the value of the specified editor configuration parameter

getParameterNames

public com.google.gwt.core.client.JsArrayString getParameterNames()
Returns:
the list of editor configuration parameters

setFocus

public void setFocus(boolean focused)
Focuses or blurs the WYSIWYG editor.

Parameters:
focused - true to focus the WYSIWYG editor, false to blur it

getSelectionRange

public JavaScriptObject getSelectionRange()
Returns:
the rich text area's selection range

setSelectionRange

public void setSelectionRange(JavaScriptObject jsRange)
Sets the rich text area's selection range.

Parameters:
jsRange - a JavaScript object that has these properties: startContainer, startOffset, endContainer and endOffset

publish

public static void publish()
Publishes the JavaScript API that can be used to create and control WysiwygEditors.



Copyright © 2004–2014 XWiki. All rights reserved.