Class: DefaultAnnotationAdapterImpl
@ghentcdh/annotated-text / DefaultAnnotationAdapterImpl
Class: DefaultAnnotationAdapterImpl
Defined in: libs/core/src/lib/adapter/annotation/DefaultAnnotationAdapter.ts:13
Extends
Constructors
Constructor
new DefaultAnnotationAdapterImpl():
DefaultAnnotationAdapterImpl
Returns
DefaultAnnotationAdapterImpl
Inherited from
Properties
colorFn()
colorFn: <
ANNOTATION>(annotation) =>object=DefaultAnnotationColor
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:62
Type Parameters
ANNOTATION
ANNOTATION
Parameters
annotation
ANNOTATION
Returns
object
background?
optionalbackground:string
backgroundActive?
optionalbackgroundActive:string
border?
optionalborder:string
borderActive?
optionalborderActive:string
color?
optionalcolor:string
gutterColor?
optionalgutterColor:string
tagBackground?
optionaltagBackground:string
tagColor?
optionaltagColor:string
Inherited from
config?
optionalconfig:object
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:61
Configuration for styling the annotations, can be used to override default styles.
edit
edit:
object
edit.color
color:
object
edit.color.border
border:
string="rgba(255,0,0,0.9)"
gutter
gutter:
object
gutter.gap
gap:
number=6
gutter.width
width:
number=3
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)"
text
text:
object
text.border
border:
number=2
text.borderRadius
borderRadius:
number=6
text.handleRadius
handleRadius:
number=6
text.lineHeight
lineHeight:
number=22
text.padding
padding:
number=6
Inherited from
create
create:
boolean=false
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:52
If true, creation of annotations is enabled.
Param
Inherited from
defaultRender
defaultRender:
DefaultRenders
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:66
Inherited from
AnnotationAdapter.defaultRender
edit
edit:
boolean=false
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:57
If true, edit of annotations is enabled.
Param
Inherited from
gutterFn()
gutterFn: <
ANNOTATION>(annotation) =>boolean=DefaultAnnotationGutter
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:63
Type Parameters
ANNOTATION
ANNOTATION
Parameters
annotation
ANNOTATION
Returns
boolean
Inherited from
name
name:
string="DefaultAnnotationAdapter"
Defined in: libs/core/src/lib/adapter/annotation/DefaultAnnotationAdapter.ts:14
Name of the adapter. Be unique 😃.
Overrides
originalAnnotations
protectedreadonlyoriginalAnnotations:Map<string|number, {color?: {background?:string;backgroundActive?:string;border?:string;borderActive?:string;color?:string;gutterColor?:string;tagBackground?:string;tagColor?:string; };end:number;id?:string|number;label?:string;start:number;target?:"text"|"gutter";textSelection?:string;weight?:number; }>
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:46
Inherited from
AnnotationAdapter.originalAnnotations
renderFn()
renderFn: <
ANNOTATION>(annotation,isGutter,rendererName) =>AnnotationRender=DefaultAnnotationRender
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:64
Type Parameters
ANNOTATION
ANNOTATION
Parameters
annotation
ANNOTATION
isGutter
boolean
rendererName
DefaultRenders
Returns
AnnotationRender
Inherited from
snapper
snapper:
Snapper
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:75
Use a word snapper function to adjust the start and end indices of an annotation.
Param
Param
Inherited from
tagConfig
tagConfig:
TagConfig<{color?: {background?:string;backgroundActive?:string;border?:string;borderActive?:string;color?:string;gutterColor?:string;tagBackground?:string;tagColor?:string; };end:number;id?:string|number;label?:string;start:number;target?:"text"|"gutter";textSelection?:string;weight?:number; }>
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:65
Inherited from
text
protectedtext:string=""
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:68
Inherited from
Methods
addAnnotation()
addAnnotation(
annotationId,originalAnnotation):void
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:177
Parameters
annotationId
string | number
originalAnnotation
color?
{ background?: string; backgroundActive?: string; border?: string; borderActive?: string; color?: string; gutterColor?: string; tagBackground?: string; tagColor?: string; } = ...
color.background?
string = ...
color.backgroundActive?
string = ...
color.border?
string = ...
color.borderActive?
string = ...
color.color?
string = ...
color.gutterColor?
string = ...
color.tagBackground?
string = ...
color.tagColor?
string = ...
end
number = ...
id?
string | number = annotationIdSchema
label?
string = ...
start
number = ...
target?
"text" | "gutter" = ...
textSelection?
string = ...
weight?
number = ...
Returns
void
Inherited from
AnnotationAdapter.addAnnotation
changeConfig()
changeConfig():
void
Defined in: libs/core/src/lib/adapter/BaseAdapter.ts:16
Returns
void
Inherited from
AnnotationAdapter.changeConfig
color()
color(
annotation):object
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:107
Get the color of the annotation, it uses the color function to determine the color. By default it uses the DefaultAnnotationColor function, which returns the color field of on the annotation. If not provided it will render a color.
Parameters
annotation
Pick<TextAnnotation, "id">
Returns
object
background?
optionalbackground:string
backgroundActive?
optionalbackgroundActive:string
border?
optionalborder:string
borderActive?
optionalborderActive:string
color?
optionalcolor:string
gutterColor?
optionalgutterColor:string
tagBackground?
optionaltagBackground:string
tagColor?
optionaltagColor:string
Inherited from
createAnnotation()
createAnnotation():
object
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:138
Create a new annotation object with default values.
Returns
object
color?
optionalcolor:object
color.background?
optionalbackground:string
color.backgroundActive?
optionalbackgroundActive:string
color.border?
optionalborder:string
color.borderActive?
optionalborderActive:string
color.color?
optionalcolor:string
color.gutterColor?
optionalgutterColor:string
color.tagBackground?
optionaltagBackground:string
color.tagColor?
optionaltagColor:string
end
end:
number
id?
optionalid:string|number=annotationIdSchema
isGutter
isGutter:
boolean
label?
optionallabel:string
start
start:
number
target?
optionaltarget:"text"|"gutter"
textSelection?
optionaltextSelection:string
weight?
optionalweight:number
Inherited from
AnnotationAdapter.createAnnotation
format()
format(
annotation,isNew,hasChanged):object
Defined in: libs/core/src/lib/adapter/annotation/DefaultAnnotationAdapter.ts:31
Format a TextAnnotation into an annotation object.
Parameters
annotation
color?
{ background?: string; backgroundActive?: string; border?: string; borderActive?: string; color?: string; gutterColor?: string; tagBackground?: string; tagColor?: string; } = ...
color.background?
string = ...
color.backgroundActive?
string = ...
color.border?
string = ...
color.borderActive?
string = ...
color.color?
string = ...
color.gutterColor?
string = ...
color.tagBackground?
string = ...
color.tagColor?
string = ...
end
number = ...
id?
string | number = annotationIdSchema
isGutter
boolean = ...
label?
string = ...
start
number = ...
target?
"text" | "gutter" = ...
textSelection?
string = ...
weight?
number = ...
isNew
boolean
hasChanged
boolean
if the annotation has changes then create the annotation again, otherwise return the original annotation that has been cached.
Returns
object
color?
optionalcolor:object
color.background?
optionalbackground:string
color.backgroundActive?
optionalbackgroundActive:string
color.border?
optionalborder:string
color.borderActive?
optionalborderActive:string
color.color?
optionalcolor:string
color.gutterColor?
optionalgutterColor:string
color.tagBackground?
optionaltagBackground:string
color.tagColor?
optionaltagColor:string
end
end:
number
id?
optionalid:string|number=annotationIdSchema
label?
optionallabel:string
start
start:
number
target?
optionaltarget:"text"|"gutter"
textSelection?
optionaltextSelection:string
weight?
optionalweight:number
Overrides
getAnnotation()
getAnnotation(
annotationId):object
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:181
Parameters
annotationId
string | number
Returns
object
color?
optionalcolor:object
color.background?
optionalbackground:string
color.backgroundActive?
optionalbackgroundActive:string
color.border?
optionalborder:string
color.borderActive?
optionalborderActive:string
color.color?
optionalcolor:string
color.gutterColor?
optionalgutterColor:string
color.tagBackground?
optionaltagBackground:string
color.tagColor?
optionaltagColor:string
end
end:
number
id?
optionalid:string|number=annotationIdSchema
label?
optionallabel:string
start
start:
number
target?
optionaltarget:"text"|"gutter"
textSelection?
optionaltextSelection:string
weight?
optionalweight:number
Inherited from
AnnotationAdapter.getAnnotation
hover()
hover(
annotation):boolean
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:131
If return true, then on hover it becomes the active color
Parameters
annotation
color?
{ background?: string; backgroundActive?: string; border?: string; borderActive?: string; color?: string; gutterColor?: string; tagBackground?: string; tagColor?: string; } = ...
color.background?
string = ...
color.backgroundActive?
string = ...
color.border?
string = ...
color.borderActive?
string = ...
color.color?
string = ...
color.gutterColor?
string = ...
color.tagBackground?
string = ...
color.tagColor?
string = ...
end
number = ...
id?
string | number = annotationIdSchema
label?
string = ...
start
number = ...
target?
"text" | "gutter" = ...
textSelection?
string = ...
weight?
number = ...
Returns
boolean
Inherited from
isGutter()
isGutter(
annotation):boolean
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:116
Get if the annotation is a gutter annotation, it uses the gutter function to determine if it is a gutter annotation. By default it uses the DefaultAnnotationGutter function, which returns the isGutter field of on the annotation.
Parameters
annotation
Pick<TextAnnotation, "id">
Returns
boolean
Inherited from
parse()
parse(
annotation):object
Defined in: libs/core/src/lib/adapter/annotation/DefaultAnnotationAdapter.ts:16
Parse an annotation object into a TextAnnotation.
Parameters
annotation
color?
{ background?: string; backgroundActive?: string; border?: string; borderActive?: string; color?: string; gutterColor?: string; tagBackground?: string; tagColor?: string; } = ...
color.background?
string = ...
color.backgroundActive?
string = ...
color.border?
string = ...
color.borderActive?
string = ...
color.color?
string = ...
color.gutterColor?
string = ...
color.tagBackground?
string = ...
color.tagColor?
string = ...
end
number = ...
id?
string | number = annotationIdSchema
label?
string = ...
start
number = ...
target?
"text" | "gutter" = ...
textSelection?
string = ...
weight?
number = ...
Returns
object
color?
optionalcolor:object
color.background?
optionalbackground:string
color.backgroundActive?
optionalbackgroundActive:string
color.border?
optionalborder:string
color.borderActive?
optionalborderActive:string
color.color?
optionalcolor:string
color.gutterColor?
optionalgutterColor:string
color.tagBackground?
optionaltagBackground:string
color.tagColor?
optionaltagColor:string
end
end:
number
id?
optionalid:string|number=annotationIdSchema
isGutter
isGutter:
boolean
label?
optionallabel:string
start
start:
number
target?
optionaltarget:"text"|"gutter"
textSelection?
optionaltextSelection:string
weight?
optionalweight:number
Overrides
setConfig()
setConfig<
KEY>(key,value):void
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:152
Change the configuration of the adapter, it will update the eventlistener if rerendering of the annotations is needed. f.e. if the text direction changes, the adapter will emit a change event to update the annotations.
Type Parameters
KEY
KEY extends keyof AnnotationAdapter<unknown>
Parameters
key
KEY
value
Returns
void
Inherited from
setConfigListener()
setConfigListener(
callback):void
Defined in: libs/core/src/lib/adapter/BaseAdapter.ts:12
Set a listener for configuration changes.
Parameters
callback
() => void
Returns
void
Inherited from
AnnotationAdapter.setConfigListener
setText()
setText(
text):void
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:77
Parameters
text
string
Returns
void
Inherited from
tagLabel()
tagLabel(
annotation):string
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:124
Get the tag label of the annotation, it uses the tag function to determine the tag label.
Parameters
annotation
Pick<TextAnnotation, "id">
Returns
string