Expand all

CodeMirrorVisualEditorHighlightLineNumbering

Line-number gutter for a VisualEditor source-mode surface, drawn beside VisualEditor's own paragraphs: the custom-highlight controller has no EditorView to host CodeMirror's gutter. Uses only public VE API, so it needs no support in VE core.

In source mode each line is its own paragraph (ve.dm.SourceConverter), so a line's number is its index in the document node. Bounded to the viewport, so long documents stay cheap.

Inert until CodeMirrorVisualEditorHighlightLineNumbering#setEnabled is called.

Constructor

new CodeMirrorVisualEditorHighlightLineNumbering(surfaceView, [formatNumber]) #

Parameters:

Name Type Attributes Description
surfaceView ve.ce.Surface
formatNumber function optional

( number ) => string, e.g. for localised digits

Source:

Properties

$documentNode :jQuery|null #

Cached while enabled.

contentPadding :number #

The document node's own edge padding, which the gutter sits in.

Type:

  • number
Source:
The document node's own edge padding, which the gutter sits in.

digitCount :number #

Digit count the width was last sized for.

Type:

  • number
Source:
Digit count the width was last sized for.

formatNumber :function #

paintedViewport :Object|null #

The pixel band, in surface coordinates, of the last draw. Null if the gutter must draw the numbers again.

Type:

Source:
The pixel band, in surface coordinates, of the last draw.

side :string|null #

'left' or 'right'; null until applySide() settles it.

Type:

  • string | null
Source:
'left' or 'right'; null until applySide() settles it.

surfaceView :ve.ce.Surface|null #

Null once destroyed.

Methods

destroy() #

Destroy the gutter.

invalidate() #

Make update draw the numbers again, even if the viewport did not move. Use this when the lines move, because the band monitors only the viewport.

Source:
Make update draw the numbers again, even if the viewport did not move.

repaint() #

Drop the band and draw the numbers again now.

Source:
Drop the band and draw the numbers again now.

setEnabled(enabled) #

Enable or disable the gutter.

Parameters:

Name Type Description
enabled boolean
Source:
Enable or disable the gutter.

update() #

Repaint the numbers for the visible lines, positioning each at its line's top.

Source:
Repaint the numbers for the visible lines, positioning each at its line's top.