Classes
- SelectionElements
- SelectionElements: Holds cached selection/overlay jQuery elements.
- SelectionGroup
- SelectionGroup: Holds all data for a rendered selection group.
Extends
Constructor
new ve.ce.SelectionManager(surface)
#
Hierarchy
Selection manager
Handles rendering of fake selections on the surface:
- The deactivated selection stands in the user's native selection when the native selection is moved elsewhere (e.g. an inspector, or a dropdown menu).
- In a multi-user environment, other users' selections from the surface synchronizer are rendered here.
- Other tools can manually render fake selections, e.g. the FindAndReplaceDialog can highlight matched text, by calling #drawSelections directly.
Parameters:
| Name | Type | Description |
|---|---|---|
surface |
ve.ce.Surface |
- Mixes in:
- Source:
Selection manager
Handles rendering of fake selections on the surface:
- The deactivated selection stands in the user's native selection when the native selection is moved elsewhere (e.g.
Methods
cacheSelectionElements(selectionElements, name, selectionModel, [options]) → {string}
#
Store an recently drawn selection in the cache
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
selectionElements |
Selection elements containing $selection and $overlay |
||
name |
string | Name of selection group |
|
selectionModel |
ve.dm.Selection | Selection model |
|
options |
Object |
optional |
Selection options |
- Source:
Returns:
Cache key
- Type
- string
destroy()
#
Destroy the selection manager
- Source:
drawSelections(name, selections, [options])
#
Draw selections.
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Unique name for the selection being drawn |
||||||||||||||||||||||||||||||||||||||||||||||
selections |
Array.<ve.ce.Selection> | Selections to draw |
||||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
optional |
Properties:
|
- Source:
getCachedSelectionElements(name, selectionModel, [options]) → {|null}
#
null}
#
Get a recently drawn selection from the cache
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | Name of selection group |
|
selectionModel |
ve.dm.Selection | Selection model |
|
options |
Object |
optional |
Selection options |
- Source:
Returns:
Selection elements containing $selection and $overlay, null if not found
- Type
-
|
null
getSelectionElementsCacheKey(name, selectionModel, [options]) → {string}
#
Get a cache key for a recently drawn selection
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | Name of selection group |
|
selectionModel |
ve.dm.Selection | Selection model |
|
options |
Object |
optional |
Selection options |
- Source:
Returns:
Cache key
- Type
- string
getSurface() → {ve.ce.Surface}
#
hideDeactivatedSelection()
#
Hide the deactivated selection
- Source:
onSurfacePosition()
#
Handle position events from the surface
- Source:
onWindowScroll()
#
Handle window scroll events
- Source:
redrawSelections([fromScroll])
#
Redraw selections
When triggered by a surface 'position' event (which fires when the surface changes size, or when the document is modified), the selectionElementsCache is cleared as these two things will cause any previously calculated rectangles to be incorrect.
When triggered by a scroll event, the cache is not cleared, and only selection groups that are clipped to the viewport are redrawn.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
fromScroll |
boolean |
optional |
false | The redraw was triggered by a scroll event |
- Source:
Redraw selections
When triggered by a surface 'position' event (which fires when the surface changes size, or when the document is modified), the selectionElementsCache is cleared as these two things will cause any previously calculated rectangles to be incorrect.
setOptions(name, options)
#
Change the rendering options for a selection group, if it exists
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of selection group |
options |
Object |
- Source:
showDeactivatedSelection([showAsActivated])
#
Start showing the deactivated selection
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
showAsActivated |
boolean |
optional |
true | Selection should still show as activated |
- Source:
updateDeactivatedSelection()
#
Update the deactivated selection
- Source:
Events
update(hasSelections)
#
Parameters:
| Name | Type | Description |
|---|---|---|
hasSelections |
boolean | The selection manager has some non-collapsed selections |
- Source: