Class: GutterAnnotationRender
@ghentcdh/annotated-text / GutterAnnotationRender
Class: GutterAnnotationRender
Defined in: libs/core/src/lib/adapter/annotation/renderer/GutterAnnotationRender.ts:105
Abstract base class for all annotation renderers.
Custom renderers must extend this class and implement all abstract members. The class handles style management and provides a contract for rendering annotations.
Example
class HighlightRenderer extends AnnotationRender<AnnotationRenderStyle> {
weightOrder = 1;
name = 'highlight';
isGutter = false;
constructor() {
super(DefaultAnnotationRenderStyle);
}
render(params, parentDimensions, annotation) {
// Implementation
return { draws, isGutter, startPosition, color };
}
}Extends
Constructors
Constructor
new GutterAnnotationRender(
name,style):GutterAnnotationRender
Defined in: libs/core/src/lib/adapter/annotation/renderer/GutterAnnotationRender.ts:109
Parameters
name
string
style
Partial<GutterAnnotationRenderStyle> = {}
Returns
GutterAnnotationRender
Overrides
Properties
annotationAdapter
protectedannotationAdapter:AnnotationAdapter<any>
Defined in: libs/core/src/lib/di/BaseAnnotationDiFn.ts:51
Inherited from
AnnotationRender.annotationAdapter
annotationModule
protectedannotationModule:AnnotationModule
Defined in: libs/core/src/lib/di/BaseAnnotationDiFn.ts:27
Inherited from
AnnotationRender.annotationModule
isGutter
readonlyisGutter:boolean=true
Defined in: libs/core/src/lib/adapter/annotation/renderer/GutterAnnotationRender.ts:107
Indicates whether this renderer displays content in the gutter (margin) or inline with the text.
- true: Renders in the gutter/margin area
- false: Renders inline with the text content
Default
falseOverrides
name
readonlyname:string
Defined in: libs/core/src/lib/adapter/annotation/renderer/annotation-render.ts:151
name of the renderer, used for identifying it in the style configuration
Inherited from
style
style:
object
Defined in: libs/core/src/lib/adapter/annotation/renderer/annotation-render.ts:126
Current style configuration for this renderer instance.
Can be updated using the updateStyle() method. Initialized as a deep clone of the defaultStyle provided in the constructor.
edit
edit:
object
edit.color
color:
object
edit.color.border
border:
string='rgba(255,0,0,0.9)'
gap
gap:
number=6
hover
hover:
object
hover.color
color:
object
hover.color.border
border:
string='rgba(100, 100, 100, 0.5)'
hover.color.fill
fill:
string='rgba(1, 1, 1, 0.1)'
width
width:
number=3
Inherited from
svgModel
protectedsvgModel:SvgModel
Defined in: libs/core/src/lib/di/BaseAnnotationDiFn.ts:52
Inherited from
textAdapter
protectedtextAdapter:TextAdapter
Defined in: libs/core/src/lib/di/BaseAnnotationDiFn.ts:50
Inherited from
weightOrder
readonlyweightOrder:number=1
Defined in: libs/core/src/lib/adapter/annotation/renderer/GutterAnnotationRender.ts:106
Determines the rendering priority when multiple renderers apply to overlapping annotations.
Lower values are rendered first (bottom layer), higher values render on top. Use consistent ranges for different renderer types:
- 1-5: Inline background annotations
- 6-9: Inline foreground annotations
- 10+: Gutter annotations
Example
weightOrder = 1; // Background highlight
weightOrder = 5; // Foreground underline
weightOrder = 10; // Gutter commentOverrides
Methods
createDraws()
createDraws(
annotation):object
Defined in: libs/core/src/lib/adapter/annotation/renderer/GutterAnnotationRender.ts:113
Renders the annotation and returns draw instructions.
This method is called for each annotation that uses this renderer. It should return all information needed to visually represent the annotation.
Parameters
annotation
The annotation being rendered
_drawMetadata
{ color?: { active: { border?: string; borderWidth: number; fill?: string; }; default: { border?: string; borderWidth: number; fill?: string; }; edit: { border?: string; borderWidth: number; fill?: string; }; hover: { border?: string; borderWidth: number; fill?: string; }; tag: { border?: string; borderWidth: number; fill?: string; text?: string; }; }; dimensions?: { x: number; y1: number; y2: number; }; draws: object[]; } = annotationDrawMetadataSchema
_drawMetadata.color?
{ active: { border?: string; borderWidth: number; fill?: string; }; default: { border?: string; borderWidth: number; fill?: string; }; edit: { border?: string; borderWidth: number; fill?: string; }; hover: { border?: string; borderWidth: number; fill?: string; }; tag: { border?: string; borderWidth: number; fill?: string; text?: string; }; } = ...
_drawMetadata.color.active
{ border?: string; borderWidth: number; fill?: string; } = annotationDrawColorSchema
_drawMetadata.color.active.border?
string = ...
_drawMetadata.color.active.borderWidth
number = ...
_drawMetadata.color.active.fill?
string = ...
_drawMetadata.color.default
{ border?: string; borderWidth: number; fill?: string; } = annotationDrawColorSchema
_drawMetadata.color.default.border?
string = ...
_drawMetadata.color.default.borderWidth
number = ...
_drawMetadata.color.default.fill?
string = ...
_drawMetadata.color.edit
{ border?: string; borderWidth: number; fill?: string; } = annotationDrawColorSchema
_drawMetadata.color.edit.border?
string = ...
_drawMetadata.color.edit.borderWidth
number = ...
_drawMetadata.color.edit.fill?
string = ...
_drawMetadata.color.hover
{ border?: string; borderWidth: number; fill?: string; } = annotationDrawColorSchema
_drawMetadata.color.hover.border?
string = ...
_drawMetadata.color.hover.borderWidth
number = ...
_drawMetadata.color.hover.fill?
string = ...
_drawMetadata.color.tag
{ border?: string; borderWidth: number; fill?: string; text?: string; } = tagColorSchema
_drawMetadata.color.tag.border?
string = ...
_drawMetadata.color.tag.borderWidth
number = ...
_drawMetadata.color.tag.fill?
string = ...
_drawMetadata.color.tag.text?
string = ...
_drawMetadata.dimensions?
{ x: number; y1: number; y2: number; } = ...
_drawMetadata.dimensions.x
number = ...
_drawMetadata.dimensions.y1
number = ...
_drawMetadata.dimensions.y2
number = ...
_drawMetadata.draws
object[] = ...
_render
{ isGutter: boolean; lines: object[]; render: string; style: { color: { background?: string; backgroundActive?: string; border?: string; borderActive?: string; color?: string; gutterColor?: string; tagBackground?: string; tagColor?: string; }; renderStyle: any; }; weight?: number; } = renderSchema
_render.isGutter
boolean = ...
_render.lines
object[] = ...
_render.render
string = ...
_render.style
{ color: { background?: string; backgroundActive?: string; border?: string; borderActive?: string; color?: string; gutterColor?: string; tagBackground?: string; tagColor?: string; }; renderStyle: any; } = renderStyleSchema
_render.style.color
{ background?: string; backgroundActive?: string; border?: string; borderActive?: string; color?: string; gutterColor?: string; tagBackground?: string; tagColor?: string; } = annotationColorSchema
_render.style.color.background?
string = ...
_render.style.color.backgroundActive?
string = ...
_render.style.color.border?
string = ...
_render.style.color.borderActive?
string = ...
_render.style.color.color?
string = ...
_render.style.color.gutterColor?
string = ...
_render.style.color.tagBackground?
string = ...
_render.style.color.tagColor?
string = ...
_render.style.renderStyle
any = ...
_render.weight?
number = ...
end
number = ...
id?
string | number = annotationIdSchema
label?
string = ...
start
number = ...
textSelection?
string = ...
Returns
object
An object containing:
- draws: Array of draw instructions (rectangles, lines, text, etc.)
- isGutter: Whether this annotation is rendered in the gutter
- startPosition: The position and dimensions where rendering starts
- color: The color scheme used for drawing
color
color:
object
color.active
active:
object=annotationDrawColorSchema
color.active.border?
optionalborder:string
color.active.borderWidth
borderWidth:
number
color.active.fill?
optionalfill:string
color.default
default:
object=annotationDrawColorSchema
color.default.border?
optionalborder:string
color.default.borderWidth
borderWidth:
number
color.default.fill?
optionalfill:string
color.edit
edit:
object=annotationDrawColorSchema
color.edit.border?
optionalborder:string
color.edit.borderWidth
borderWidth:
number
color.edit.fill?
optionalfill:string
color.hover
hover:
object=annotationDrawColorSchema
color.hover.border?
optionalborder:string
color.hover.borderWidth
borderWidth:
number
color.hover.fill?
optionalfill:string
color.tag
tag:
object=tagColorSchema
color.tag.border?
optionalborder:string
color.tag.borderWidth
borderWidth:
number
color.tag.fill?
optionalfill:string
color.tag.text?
optionaltext:string
dimensions
dimensions:
object
dimensions.x
x:
number
dimensions.y1
y1:
number
dimensions.y2
y2:
number
draws
draws:
object[]
Example
render(params, parentDimensions, annotation) {
return {
draws: [
{
type: 'rect',
x: parentDimensions.x,
y: parentDimensions.y,
width: 100,
height: 20,
fill: 'rgba(255, 0, 0, 0.3)'
}
],
isGutter: false,
startPosition: { x: 0, y: 0, width: 100, height: 20 },
color: { primary: '#ff0000', border: '#cc0000' }
};
}Overrides
inject()
inject<
T>(token):T
Defined in: libs/core/src/lib/di/BaseAnnotationDiFn.ts:46
Inject a dependency from the annotation module's container.
Type Parameters
T
T
Parameters
token
Token<T>
The token identifying the service to inject
Returns
T
The service instance
Inherited from
setModule()
setModule(
module):void
Defined in: libs/core/src/lib/di/BaseAnnotationDiFn.ts:33
Set the annotation module for dependency injection. This must be called before using inject().
Parameters
module
AnnotationModule
Returns
void
Inherited from
updateStyle()
updateStyle(
style):void
Defined in: libs/core/src/lib/adapter/annotation/renderer/annotation-render.ts:232
Updates the renderer's style configuration.
Performs a deep merge with the default style, so only specified properties are overridden while preserving all other default values.
Uses lodash merge to handle nested objects properly.
Parameters
style
Partial<STYLE>
Partial style object containing properties to update
Returns
void
Example
// Update only specific properties
renderer.updateStyle({
borderWidth: 3,
borderRadius: 8
});
// Update nested properties
renderer.updateStyle({
hover: {
color: {
border: 'rgba(255, 0, 0, 0.8)'
}
}
});