Expand all

ve.ce.SelectionManager

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

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 Description
color string

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

wrapperClass string

Additional CSS class string to add to the $selections wrapper. mapped to the same index.

label string

Label shown above each selection

Source:
Draw selections.

getDrawnSelection(name, selection, [options]) → {jQuery} #

Get an already drawn selection from the cache

Parameters:

Name Type Attributes Description
name string

Name of selection group

selection ve.dm.Selection

Selection model

options Object optional

Selection options

Source:

Returns:

Drawn selection

Type
jQuery
Get an already drawn selection from the cache

getDrawnSelectionCacheKey(name, selection, [options]) → {string} #

Get a cache key for a drawn selection

Parameters:

Name Type Attributes Description
name string

Name of selection group

selection ve.dm.Selection

Selection model

options Object optional

Selection options

Source:

Returns:

Cache key

Type
string
Get a cache key for a 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() #

Respond to a position event on this surface

Source:
Respond to a position event on this surface

onSynchronizerAuthorDisconnect(authorId) #

Called when the synchronizer receives a remote author disconnect

Parameters:

Name Type Description
authorId number

The author ID

Source:
Called when the synchronizer receives a remote author disconnect

onSynchronizerAuthorUpdate(authorId) #

Called when the synchronizer receives a remote author selection or name change

Parameters:

Name Type Description
authorId number

The author ID

Source:
Called when the synchronizer receives a remote author selection or name change

paintAuthor(authorId) #

Paint a remote author's current selection, as stored in the synchronizer

Parameters:

Name Type Description
authorId number

The author ID

Source:
Paint a remote author's current selection, as stored in the synchronizer

redrawSelections() #

Redraw selections

This is triggered by a surface 'position' event, which fires when the surface changes size, or when the document is modified. The drawnSelectionCache is cleared as these two things will cause any previously calculated rectangles to be incorrect.

Source:

Redraw selections

This is triggered by a surface 'position' event, which fires when the surface changes size, or when the document is modified.

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

storeDrawnSelection($selection, name, selection, [options]) → {string} #

Store an already drawn selection in the cache

Parameters:

Name Type Attributes Description
$selection jQuery

Drawn selection

name string

Name of selection group

selection ve.dm.Selection

Selection model

options Object optional

Selection options

Source:

Returns:

Cache key

Type
string
Store an already drawn selection in the cache

Events

update(hasSelections) #

Parameters:

Name Type Description
hasSelections boolean

The selection manager has some non-collapsed selections

Source: