The object representing the root of the gui tree.
The object representing the root of the data tree.
The HTML element that is the input field.
The GUI updater that is responsible for updating the
tree whose root is guiRoot
.
The layer that holds the caret.
The element that scrolls guiRoot
.
The mode tree from which to get modes.
The object representing the root of the data tree.
This is where you can listen to caret change events.
The object representing the root of the gui tree.
The GUI updater that is responsible for updating the
tree whose root is guiRoot
.
The HTML element that is the input field.
The layer that holds the caret.
The caret mark that represents the caret managed by this manager.
The mode tree from which to get modes.
The element that scrolls guiRoot
.
The anchor of the current selection.
The raw caret. Use getNormalizedCaret if you need it normalized.
This is synonymous with the focus of the current selection. (foo.caret ===
foo.focus === foo.sel.focus
).
The focus of the current selection.
The range formed by the current selection.
A range info object describing the current selection.
The current selection.
Emit a caret change event.
Get the current selection from the DOM tree.
Modify the passed position so that it if appears inside of a placeholder node, the resulting position is moved out of it.
The location to normalize.
The normalized position. If undefined
or null
was passed,
then the return value is the same as what was passed.
Restores the caret and selection from the current selection. This is used to deal with situations in which the caret and range may have been "damaged" due to browser operations, changes of state, etc.
Whether the restoration of the caret and selection is due to regaining focus or not.
This function is meant to be used internally to manipulate the DOM selection directly.
Sets the caret position in the GUI tree.
The new position.
Set of options governing the caret movement.
Clear the selection and caret.
Collapse the selection to the current caret location.
Dump to the console caret-specific information.
Focus the field use for input events. It is used by wed on some occasions where it is needed. Mode authors should never need to call this. If they do find that calling this helps solve a problem they ran into, they probably should file an issue report.
Get the current caret position in the data tree.
Some GUI locations do not correspond to data locations. Like if the location is in a gui element or phantom text. By default, this method will return undefined in such case. If this parameter is true, then this method will return the closest position.
A caret position in the data tree, or undefined
if no such
position exists.
Get a normalized caret.
A normalized caret, or undefined
if there is no caret.
Make a caret from a node and offset pair.
The node from which to make the caret. The node may be in the
GUI tree or the data tree. If offset
is omitted, the resulting location
will point to this node (rather than point to some offset inside the
node.)
The offset into the node.
Whether to normalize the location. (Note that this is normalization in the DLoc sense of the term.)
A new caret. This will be undefined
if the value passed for
node
was undefined or if the node is not in the GUI or data trees.
Move the caret in a specific direction. The caret may not move if it is not possible to move in the specified direction.
The direction in which to move.
Does the same thing as fromDataLocation but must return a defined location.
Same as getNormalizedCaret but must return a location.
Compute the position of the current caret if it were moved according to some direction.
The direction in which the caret would be moved.
The position to the right of the caret position. Or undefined
if there is no valid position to compute.
Compute a position derived from an arbitrary position. Note that this method is meant to be used for positions in the GUI tree. Computing positions in the data tree requires no special algorithm.
This method does not allow movement outside of the GUI tree.
The starting position in the GUI tree.
The direction in which to move.
The position to the right of the starting position. Or
undefined
if the starting position was undefined or if there is no
valid position to compute.
This is called when the editing area is blurred. This is not something you should be calling in a mode's implementation. It is public because other parts of wed need to call it.
Pop the last selection that was pushed with pushSelection
and restore
the current caret and selection on the basis of the popped value.
Pop the last selection that was pushed with pushSelection
but do not
restore the current caret and selection from the popped value.
Save the current selection (and caret) on an internal selection stack.
Set the caret to a new position.
The new position for the caret.
The options for moving the caret.
Set the caret into a normalized label position. There are only some locations in which it is valid to put the caret inside a label:
The element name.
Inside attribute values.
This method is used by DOM event handlers (usually mouse events handlers) to normalize the location of the caret to one of the valid locations listed above.
The target of the DOM event that requires moving the caret.
The label element that contains target
.
The location of the event, which is what is normalized by this method.
Converts a gui location to a data location.
A location in the GUI tree.
Some GUI locations do not correspond to data locations. Like if the location is in a gui element or phantom text. By default, this method will return undefined in such case. If this parameter is true, then this method will return the closest position.
The data location that corresponds to the location passed. This
could be undefined
if the location does not correspond to a location in
the data tree.
Generated using TypeDoc
A caret manager maintains and modifies caret and selection positions. It also manages associated GUI elements like the input field. It is also responsible for converting positions in the GUI tree to positions in the data tree and vice-versa.
Given wed's notion of parallel data and GUI trees. A caret can either point into the GUI tree or into the data tree. In the following documentation, if the caret is not qualified, then it is a GUI caret.
Similarly, a selection can either span a range in the GUI tree or in the data tree. Again, "selection" without qualifier is a GUI selection.