public class ListBehaviorAdjuster extends KeyboardAdaptor implements CommandListener
| Modifier and Type | Field and Description |
|---|---|
protected static String |
LIST_ITEM_TAG
List item element name.
|
protected static 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 String |
UNORDERED_LIST_TAG
Unordered list element name.
|
| Constructor and Description |
|---|
ListBehaviorAdjuster(RichTextArea textArea)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
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 |
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.
|
protected void |
handleEmptyListItem(Element li)
Handles a list item which void by adding a placeholder to render this element editable.
|
void |
handleKeyRelease(Event event) |
protected void |
handleRepeatableKey(Event event) |
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,
String param) |
void |
onCommand(CommandManager sender,
Command command,
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.
|
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.
|
onKeyDown, onKeyPress, onKeyUpprotected static final String LIST_ITEM_TAG
protected static final String UNORDERED_LIST_TAG
protected static final String ORDERED_LIST_TAG
protected static final Command RESET_COMMAND
public ListBehaviorAdjuster(RichTextArea textArea)
textArea - the rich text area to do adjustments forprotected 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 editableelement - 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 handleprotected void onDelete(Element li, Event event)
li - the list item in which the delete key is hitevent - the native event that was firedprotected void onBackspace(Element li, Event event)
li - the list item in which the backspace key is hitevent - the native event that was firedprotected boolean needsDeleteAdjustment(Element sourceListItem, Element destListItem)
sourceListItem - the list item from which content should be moveddestListItem - the list item to which content should be movedtrue if the delete / backspace between the two needs special handling, false otherwiseprotected 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 notprotected void handleRepeatableKey(Event event)
handleRepeatableKey in class KeyboardAdaptorpublic void handleKeyRelease(Event event)
handleKeyRelease in class KeyboardAdaptorpublic boolean onBeforeCommand(CommandManager sender, Command command, String param)
onBeforeCommand in interface CommandListenerCommandListener.onBeforeCommand(CommandManager, Command, String)public void onCommand(CommandManager sender, Command command, String param)
onCommand in interface CommandListenerCommandListener.onCommand(CommandManager, Command, String)Copyright © 2004–2014 XWiki. All rights reserved.