Overview
The Chunk component splits code into small chunks and display only around the viewport.
Properties
lines
Returns the latest Lines instance.
This is an alias of Code#Lines
.
i18n
Returns the i18n collection.
This is an alias of this.options.i18n
.
start
readonly start: number
Indicates what row corresponds with the first line element. The number can be negative.
margin
readonly margin: number
The number of margin lines before and after visible lines.
The total number of lines will be margin * 2 + visibleLines
.
visibleLines
readonly visibleLines: number
The number of visible lines calculated by the editor height and the line height.
offsetY
readonly offsetY: number
The current offset amount from the top of the scroller element in pixel.
end
Returns the end index of the chunk lines. This may be greater than the actual total number of lines.
length
Returns the number of chunk lines without preserved ones.
elms
Returns chunk lines without preserved ones.
Methods
getBoundary()
getBoundary( focus: boolean ): LineBoundaryData
Returns the focus or anchor boundary data object which contains the line element and the row index.
Params
focus | Determines whether to return the focus or anchor boundary data. |
---|
Return
The boundary data object.
sync()
sync( elms: Element[], start: number ): void
Updates HTML of elements with the latest HTML of lines. If omitting elements, updates all elements in the chunk.
Params
elms | Optional. Elements to update. |
---|---|
start | Optional. A start index that corresponds with the first element. |
syncDiff()
syncDiff( row: number, diff: number ): void
Syncs difference of the number of lines before syncing each HTML for performance.
If the diff
length is greater than the margin
, this method does nothing.
Params
row | A row index. |
---|---|
diff | Difference of the number of lines before and after editing. |
refresh()
refresh(): void
Refreshes the chunk.
getRow()
getRow( elm: HTMLElement ): number
Returns the row index which the provided line element corresponds with.
Params
elm | A line element. |
---|
Return
The row index of the line element if available, or otherwise -1
.
getLine()
getLine( row: number ): Element
Returns the line at the specified row if available.
Params
row | A row index. |
---|
Return
A line element if available, or undefined
if not.
includes()
includes( row: number ): boolean
Checks if the chunk includes the specified row or not.
Params
row | A row index. |
---|
Return
true
if the chunk includes the row, or otherwise false
.