Home Reference Source Repository
import DecorationManagement from 'minimap/lib/mixins/decoration-management.js'
public class | source

DecorationManagement

Extends:

mixto~Mixin → DecorationManagement

The mixin that provides the decorations API to the minimap editor view.

This mixin is injected into the Minimap prototype, so every methods defined in this file will be available on any Minimap instance.

Method Summary

Public Methods
public

decorateMarker(marker: Marker, decorationParams: Object): Decoration

Adds a decoration that tracks a Marker.

public

Returns the decoration with the passed-in id.

public

Returns the decorations that intersects the passed-in row range in a structured way.

public

decorationsForScreenRowRange(startScreenRow: number, endScreenRow: number): Array<Decoration>

Returns all the decorations that intersect the passed-in row range.

public

Returns all the decorations registered in the current Minimap.

public

Initializes the decorations related properties.

public

Invalidates the decoration by screen rows cache.

public

onDidAddDecoration(callback: function(event: Object): void): Disposable

Registers an event listener to the did-add-decoration event.

public

onDidChangeDecoration(callback: function(event: Object): void): Disposable

Registers an event listener to the did-change-decoration event.

public

onDidChangeDecorationRange(callback: function(event: Object): void): Disposable

Registers an event listener to the did-change-decoration-range event.

public

onDidRemoveDecoration(callback: function(event: Object): void): Disposable

Registers an event listener to the did-remove-decoration event.

public

onDidUpdateDecoration(callback: function(decoration: Decoration): void): Disposable

Registers an event listener to the did-update-decoration event.

public

Removes all the decorations that was created in the current Minimap.

public

Removes all the decorations registered for the passed-in marker.

public

Removes a Decoration from this minimap.

Public Methods

public decorateMarker(marker: Marker, decorationParams: Object): Decoration source

Adds a decoration that tracks a Marker. When the marker moves, is invalidated, or is destroyed, the decoration will be updated to reflect the marker's state.

Params:

NameTypeAttributeDescription
marker Marker

the marker you want this decoration to follow

decorationParams Object

the decoration properties

decorationParams.type string

the decoration type in the following list:

  • line: Fills the line background with the decoration color.
  • highlight: Renders a colored rectangle on the minimap. The highlight is rendered above the line's text.
  • highlight-over: Same as highlight.
  • highlight-under: Renders a colored rectangle on the minimap. The highlight is rendered below the line's text.
  • highlight-outline: Renders a colored outline on the minimap. The highlight box is rendered above the line's text.
decorationParams.class string

the CSS class to use to retrieve the background color of the decoration by building a scop corresponding to .minimap .editor <your-class>

decorationParams.scope string

the scope to use to retrieve the decoration background. Note that if the scope property is set, the class won't be used.

decorationParams.color string

the CSS color to use to render the decoration. When set, neither scope nor class are used.

Return:

Decoration

the created decoration

Emit:

did-add-decoration

when the decoration is created successfully

did-change

when the decoration is created successfully

public decorationForId(id: number): Decoration source

Returns the decoration with the passed-in id.

Params:

NameTypeAttributeDescription
id number

the decoration id

Return:

Decoration

the decoration with the given id

public decorationsByTypeThenRows(): Object source

Returns the decorations that intersects the passed-in row range in a structured way.

At the first level, the keys are the available decoration types. At the second level, the keys are the row index for which there are decorations available. The value is an array containing the decorations that intersects with the corresponding row.

Return:

Object

the decorations grouped by type and then rows

Return Properties:

NameTypeAttributeDescription
line Object

all the line decorations by row

line[row] Array<Decoration>

all the line decorations at a given row

highlight-under Object

all the highlight-under decorations by row

highlight-under[row] Array<Decoration>

all the highlight-under decorations at a given row

highlight-over Object

all the highlight-over decorations by row

highlight-over[row] Array<Decoration>

all the highlight-over decorations at a given row

highlight-outine Object

all the highlight-outine decorations by row

highlight-outine[row] Array<Decoration>

all the highlight-outine decorations at a given row

public decorationsForScreenRowRange(startScreenRow: number, endScreenRow: number): Array<Decoration> source

Returns all the decorations that intersect the passed-in row range.

Params:

NameTypeAttributeDescription
startScreenRow number

the first row of the range

endScreenRow number

the last row of the range

Return:

Array<Decoration>

the decorations that intersect the passed-in range

public getDecorations(): Array<Decoration> source

Returns all the decorations registered in the current Minimap.

Return:

Array<Decoration>

all the decorations in this Minimap

public initializeDecorations() source

Initializes the decorations related properties.

public invalidateDecorationForScreenRowsCache() source

Invalidates the decoration by screen rows cache.

public onDidAddDecoration(callback: function(event: Object): void): Disposable source

Registers an event listener to the did-add-decoration event.

Params:

NameTypeAttributeDescription
callback function(event: Object): void

a function to call when the event is triggered. the callback will be called with an event object with the following properties:

  • marker: the marker object that was decorated
  • decoration: the decoration object that was created

Return:

Disposable

a disposable to stop listening to the event

public onDidChangeDecoration(callback: function(event: Object): void): Disposable source

Registers an event listener to the did-change-decoration event.

This event is triggered when the marker targeted by the decoration was changed.

Params:

NameTypeAttributeDescription
callback function(event: Object): void

a function to call when the event is triggered. the callback will be called with an event object with the following properties:

  • marker: the marker object that was decorated
  • decoration: the decoration object that was created

Return:

Disposable

a disposable to stop listening to the event

public onDidChangeDecorationRange(callback: function(event: Object): void): Disposable source

Registers an event listener to the did-change-decoration-range event.

This event is triggered when the marker range targeted by the decoration was changed.

Params:

NameTypeAttributeDescription
callback function(event: Object): void

a function to call when the event is triggered. the callback will be called with an event object with the following properties:

  • marker: the marker object that was decorated
  • decoration: the decoration object that was created

Return:

Disposable

a disposable to stop listening to the event

public onDidRemoveDecoration(callback: function(event: Object): void): Disposable source

Registers an event listener to the did-remove-decoration event.

Params:

NameTypeAttributeDescription
callback function(event: Object): void

a function to call when the event is triggered. the callback will be called with an event object with the following properties:

  • marker: the marker object that was decorated
  • decoration: the decoration object that was created

Return:

Disposable

a disposable to stop listening to the event

public onDidUpdateDecoration(callback: function(decoration: Decoration): void): Disposable source

Registers an event listener to the did-update-decoration event.

This event is triggered when the decoration itself is modified.

Params:

NameTypeAttributeDescription
callback function(decoration: Decoration): void

a function to call when the event is triggered

Return:

Disposable

a disposable to stop listening to the event

public removeAllDecorations() source

Removes all the decorations that was created in the current Minimap.

public removeAllDecorationsForMarker(marker: Marker) source

Removes all the decorations registered for the passed-in marker.

Params:

NameTypeAttributeDescription
marker Marker

the marker for which removing its decorations

Emit:

did-change

when a decoration have been removed

did-remove-decoration

when a decoration have been removed

public removeDecoration(decoration: Decoration) source

Removes a Decoration from this minimap.

Params:

NameTypeAttributeDescription
decoration Decoration

the decoration to remove

Emit:

did-change

when the decoration is removed

did-remove-decoration

when the decoration is removed