Class core.Cursor
A cursor is a dom node that visually represents a cursor in a DOM tree.
It should stay synchronized with the selection in the document. When
there is only one collapsed selection range, a cursor should be shown at
that point.
Putting the cursor in the DOM tree modifies the DOM, so care should be taken
to keep the selection consistent. If e.g. a selection is drawn over the
cursor, and the cursor is updated to the selection, the cursor is removed
from the DOM because the selection is not collapsed. This means that the
offsets of the selection may have to be changed.
When the selection is collapsed, the cursor is placed after the point of the
selection and the selection will stay valid. However, if the cursor was
placed in the DOM tree and was counted in the offset, the offset in the
selection should be decreased by one.
Even when the selection allows for a cursor, it might be desireable to hide
the cursor by not letting it be part of the DOM.
Defined in: Cursor.js.
Constructor Attributes | Constructor Name and Description |
---|---|
core.Cursor(document, memberId)
|
Method Attributes | Method Name and Description |
---|---|
Obtain the node representing the selection start point.
|
|
<inner> |
Gets the latest selection node in the document
|
getNode()
Obtain the node representing the cursor.
|
|
Obtain the selection to which the cursor corresponds.
|
|
<inner> |
Gets the earliest selection node in the document
|
Returns if the selection of this cursor has the
same direction as the direction of the range
|
|
<inner> |
putIntoTextNode(node, container, offset)
Split a text node and put the cursor into it.
|
<inner> |
putNode(node, container, offset)
Put the cursor at a particular position.
|
remove()
Remove the cursor from the document tree.
|
|
<inner> |
removeNode(node)
Remove the cursor from the tree.
|
setSelectedRange(range, isForwardSelection)
Synchronize the cursor to a specific range
If there is a single collapsed selection range, the cursor will be placed
there.
|
- Parameters:
- {!Document} document
- The DOM document in which the cursor is placed
- {!string} memberId
- The memberid this cursor is assigned to
- Returns:
- {!Element}
- Returns:
- {!Node}
- Returns:
- {!Element}
- Returns:
- {!Range}
- Returns:
- {!Node}
- Returns:
- {boolean}
- Parameters:
- {!Node} node
- {!Text} container
- {!number} offset
- Returns:
- {undefined}
- Parameters:
- {!Node} node
- {!Node} container
- {!number} offset
- Returns:
- {undefined}
- Returns:
- {undefined}
- Parameters:
- {!Element} node
- Parameters:
- {!Range} range
- {boolean=} isForwardSelection
- Set to true to indicate the direction of the range is startContainer => endContainer. This should be false if the user creates a selection that ends before it starts in the document (i.e., drags the range backwards from the start point)
- Returns:
- {undefined}