Expand all

ve.ce.SelectionManager

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) #

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
Store an recently drawn selection in the cache

destroy() #

Destroy the selection manager

Source:
Destroy the selection manager

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:
Name Type Attributes Default Description
color string optional

CSS color for the selection. Should usually be set in a stylesheet using the generated class name.

wrapperClass string optional

Additional CSS class string to add to the $selections wrapper.

showRects boolean optional
true

Show individual selection rectangles (default)

showBounding boolean optional
false

Show a bounding rectangle around the selection

showCursor boolean optional
false

Show a separate rectangle at the cursor ('to' position in a non-collapsed selection)

showGutter boolean optional
false

Show a vertical gutter bar matching the bounding rect

overlay boolean optional
false

Render all of the selection above the text

label string optional

Label shown above each selection

Source:
Draw selections.

getCachedSelectionElements(name, selectionModel, [options]) → {|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
Get a recently drawn selection from the cache

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
Get a cache key for a recently drawn selection

getSurface() → {ve.ce.Surface} #

Get the surface

Source:

Returns:

Type
ve.ce.Surface
Get the surface

hideDeactivatedSelection() #

Hide the deactivated selection

Source:
Hide the deactivated selection

onSurfacePosition() #

Handle position events from the surface

Source:
Handle position events from the surface

onWindowScroll() #

Handle window scroll events

Source:
Handle window scroll events

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:
Change the rendering options for a selection group, if it exists

showDeactivatedSelection([showAsActivated]) #

Start showing the deactivated selection

Parameters:

Name Type Attributes Default Description
showAsActivated boolean optional
true

Selection should still show as activated

Source:
Start showing the deactivated selection

updateDeactivatedSelection() #

Update the deactivated selection

Source:
Update the deactivated selection

Events

update(hasSelections) #

Parameters:

Name Type Description
hasSelections boolean

The selection manager has some non-collapsed selections

Source: