Overview
The Range component highlights ranges with the Marker class, such as a selection range and match results. This component provides the way to emphasize any texts in the editor.
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
.
selection
readonly selection: SelectionMarker
Holds the SelectionMarker instance.
ranges
readonly ranges: Record<string, RangeData[]>
Stores ranges with categorizing them into arbitrary groups.
groups
readonly groups: Record<string, HTMLDivElement>
Stores wrapper elements of markers.
Methods
register()
register( group: string, ranges: Range[], concat: boolean, constructor: ): void
Registers ranges to the group and draw them as markers.
They will remain until they are explicitly cleared by the clear()
method.
If concat
is true
, sequential ranges will be concatenated as a single range.
const ryuseiCode = new RyuseiCode(); ryuseiCode.apply( 'textarea' ); const { Range } = ryuseiCode.Editor.Components; Range.register( 'my-ranges', [ { start: [ 0, 0 ], end: [ 0, 5 ] }, { start: [ 1, 0 ], end: [ 1, 3 ] }, ] ); // Clear ranges after 2 seconds. setTimeout( () => { Range.clear( 'my-ranges' ); }, 2000 );
Params
group | A group name. |
---|---|
ranges | A range or ranges to draw. |
concat | Optional. Determines whether to concat sequential ranges into the single one or not. |
constructor | Optional. Specifies the Marker constructor. |
clear()
clear( group?: string ): void
Clears ranges and rendered markers that belong to the specified group. If the group name is omitted, this method clears all ranges.
Params
group | Optional. A group name to clear. |
---|
clearRanges()
clearRanges( group: string ): void
Clears ranges in the specified group, but rendered markers will remain.
Params
group | A group name to clear. |
---|