|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xwiki.gwt.user.client.KeyboardAdaptor org.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 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 Summary | |
---|---|
ListBehaviorAdjuster(RichTextArea textArea)
Creates a new instance. |
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 |
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)
Handles a key release. |
protected void |
handleRepeatableKey(Event event)
Handles a repeatable key press. |
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)
Notifies that the given command is about to be executed with the given parameter by the specified command manager. |
void |
onCommand(CommandManager sender,
Command command,
String param)
Notifies that the given command has been executed with the given parameter by the specified command manager. |
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. |
Methods inherited from class org.xwiki.gwt.user.client.KeyboardAdaptor |
---|
onKeyDown, onKeyPress, onKeyUp |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected 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
Constructor Detail |
---|
public ListBehaviorAdjuster(RichTextArea textArea)
textArea
- the rich text area to do adjustments forMethod 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 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 moved
true
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 not
protected void handleRepeatableKey(Event event)
KeyboardAdaptor
handleRepeatableKey
in class KeyboardAdaptor
event
- the native event that was firedpublic void handleKeyRelease(Event event)
KeyboardAdaptor
handleKeyRelease
in class KeyboardAdaptor
event
- the native event that was firedpublic boolean onBeforeCommand(CommandManager sender, Command command, String param)
onBeforeCommand
in interface CommandListener
sender
- The command manager that is about to execute the specified command.command
- The command that will be executed.param
- The parameter that will be passed to the command.
CommandListener.onBeforeCommand(CommandManager, Command, String)
public void onCommand(CommandManager sender, Command command, String param)
onCommand
in interface CommandListener
sender
- The command manager that executed the command.command
- The command executed.param
- The parameter used when the command was executed.CommandListener.onCommand(CommandManager, Command, String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |