|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xwiki.gwt.wysiwyg.client.plugin.list.ListBehaviorAdjuster
public class ListBehaviorAdjuster
Handles keyboard actions on valid HTML lists, to ensure that the lists stay valid even after keyboard changes such as adding or deleting list items (enter or delete / backspace). Also ensures that all the list items which only contain a sublist inside are editable.
| Field Summary | |
|---|---|
protected static java.lang.String |
LIST_ITEM_TAG
List item element name. |
protected static java.lang.String |
ORDERED_LIST_TAG
Ordered list element name. |
protected static Command |
RESET_COMMAND
The command that notifies when the content of the rich text area has been reset. |
protected static java.lang.String |
UNORDERED_LIST_TAG
Unordered list element name. |
| Constructor Summary | |
|---|---|
ListBehaviorAdjuster()
|
|
| Method Summary | |
|---|---|
protected void |
cleanUp(Element element)
Executes lists clean up on the subtree rooted in the element passed as parameter. |
protected void |
cleanUpLists(com.google.gwt.dom.client.NodeList<com.google.gwt.dom.client.Element> listElements)
Helper function to handle a list of list elements and clean them. |
protected void |
dispatchKey(com.google.gwt.user.client.ui.Widget sender,
int keyCode,
Event originalEvent)
Dispatches the passed key pressed on the specified sender, with the specified modifiers. |
protected void |
executeDelete(com.google.gwt.dom.client.Node reference,
Element nextLi,
com.google.gwt.dom.client.Node skippedEmptyPlaceHolder,
Range range)
Effectively executes the delete operation at the end of a list item by moving the next list item in this one, for the passed parameters. |
RichTextArea |
getTextArea()
|
protected void |
handleEmptyListItem(Element li)
Handles a list item which void by adding a placeholder to render this element editable. |
boolean |
isEmptyListItemPlaceholder(com.google.gwt.dom.client.Node node)
Determines if a node is an empty list item placeholder. |
protected boolean |
needsDeleteAdjustment(Element sourceListItem,
Element destListItem)
Helper function to determine whether deleting at the end / backspacing at the beginning of one of the list items when next list item / previous list item is the other needs special handling or will fall back on the browser default. |
protected void |
onBackspace(Element li,
Event event)
Handles the backspace key inside a list item, such that it meets the following behavior when hit at the beginning of a list item: The list item in which the delete backspace button is hit is always deleted, if there is another list item preceeding it. |
boolean |
onBeforeCommand(CommandManager sender,
Command command,
java.lang.String param)
|
void |
onCommand(CommandManager sender,
Command command,
java.lang.String param)
|
protected void |
onDelete(Element li,
Event event)
Handles the delete key inside a list item, such that it meets the following behavior when hit at the end of a list item: The list item in which the delete button is hit is never deleted, if there is another list item following it. |
void |
onKeyDown(com.google.gwt.event.dom.client.KeyDownEvent event)
|
void |
onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent event)
|
void |
onKeyUp(com.google.gwt.event.dom.client.KeyUpEvent event)
|
void |
setTextArea(RichTextArea textArea)
|
protected void |
wrapList(Element listElement)
Tries to reposition a list element that appears in another list element: if there is a previous sibling, it tries to add it as a sublist, else it wraps it in a new list item. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.lang.String LIST_ITEM_TAG
protected static final java.lang.String UNORDERED_LIST_TAG
protected static final java.lang.String ORDERED_LIST_TAG
protected static final Command RESET_COMMAND
| Constructor Detail |
|---|
public ListBehaviorAdjuster()
| Method Detail |
|---|
protected void cleanUp(Element element)
ul or ol tags which are in another ul or ol and adding a
li wrapper around eachul or ol tags which are at the beginning (first child) of a list item and
making the parent list items editable
element - the root element of the subtree in which to execute cleanup.protected void cleanUpLists(com.google.gwt.dom.client.NodeList<com.google.gwt.dom.client.Element> listElements)
listElements - the list elements to clean up, according to the description at cleanUp(Element)protected void wrapList(Element listElement)
listElement - the list node to wrapprotected void handleEmptyListItem(Element li)
li - the empty list item to handle
protected void onDelete(Element li,
Event event)
li - the list item in which the delete key is hitevent - the native event that was fired
protected void onBackspace(Element li,
Event event)
li - the list item in which the backspace key is hitevent - the native event that was fired
protected boolean needsDeleteAdjustment(Element sourceListItem,
Element destListItem)
sourceListItem - the list item from which content should be moveddestListItem - the list item to which content should be moved
true if the delete / backspace between the two needs special handling, false otherwise
protected void executeDelete(com.google.gwt.dom.client.Node reference,
Element nextLi,
com.google.gwt.dom.client.Node skippedEmptyPlaceHolder,
Range range)
reference - the reference element, to move the content of the nextLi after itnextLi - the next list item after the current list item end, to move in the current list itemrange - the selection range for which this operation is executed, used to determine where the nextLi
needs to be inserted and how selection needs to be restoredskippedEmptyPlaceHolder - the first empty list item placeholder that was skipped by the next leaf lookup
algorithm in this delete operation, and which needs to be removed with the execution of the deletepublic boolean isEmptyListItemPlaceholder(com.google.gwt.dom.client.Node node)
node - the node for which to check if it is the empty list item placeholder or not
public void onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent event)
onKeyPress in interface com.google.gwt.event.dom.client.KeyPressHandlerKeyPressHandler.onKeyPress(KeyPressEvent)
protected void dispatchKey(com.google.gwt.user.client.ui.Widget sender,
int keyCode,
Event originalEvent)
sender - the sender widget of the key press eventkeyCode - the code of the key to dispatchoriginalEvent - the original native key event that was firedpublic void onKeyUp(com.google.gwt.event.dom.client.KeyUpEvent event)
onKeyUp in interface com.google.gwt.event.dom.client.KeyUpHandlerKeyUpHandler.onKeyUp(KeyUpEvent)public void onKeyDown(com.google.gwt.event.dom.client.KeyDownEvent event)
onKeyDown in interface com.google.gwt.event.dom.client.KeyDownHandlerKeyDownHandler.onKeyDown(KeyDownEvent)public RichTextArea getTextArea()
public void setTextArea(RichTextArea textArea)
textArea - the textArea to operate on
public boolean onBeforeCommand(CommandManager sender,
Command command,
java.lang.String param)
onBeforeCommand in interface CommandListenerCommandListener.onBeforeCommand(CommandManager, Command, String)
public void onCommand(CommandManager sender,
Command command,
java.lang.String param)
onCommand in interface CommandListenerCommandListener.onCommand(CommandManager, Command, String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||