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:60
Type Parameters
ANNOTATION
ANNOTATION
Parameters
annotation
ANNOTATION
Returns
object
background?
optional
background:string
backgroundActive?
optional
backgroundActive:string
border?
optional
border:string
borderActive?
optional
borderActive:string
color?
optional
color:string
gutterColor?
optional
gutterColor:string
Inherited from
config?
optional
config:object
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:59
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:50
If true, creation of annotations is enabled.
Param
Inherited from
defaultRender
defaultRender:
DefaultRenders
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:63
Inherited from
AnnotationAdapter
.defaultRender
edit
edit:
boolean
=false
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:55
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:61
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
protected
readonly
originalAnnotations:Map
<string
|number
, {color
: {background
:string
;backgroundActive
:string
;border
:string
;borderActive
:string
;color
:string
;gutterColor
: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:44
Inherited from
AnnotationAdapter
.originalAnnotations
renderFn()
renderFn: <
ANNOTATION
>(annotation
,isGutter
,rendererName
) =>AnnotationRender
=DefaultAnnotationRender
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:62
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:72
Use a word snapper function to adjust the start and end indices of an annotation.
Param
Param
Inherited from
text
protected
text:string
=""
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:65
Inherited from
Methods
addAnnotation()
addAnnotation(
annotationId
,originalAnnotation
):void
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:161
Parameters
annotationId
string
| number
originalAnnotation
color?
{ background
: string
; backgroundActive
: string
; border
: string
; borderActive
: string
; color
: string
; gutterColor
: string
; } = ...
color.background?
string
= ...
color.backgroundActive?
string
= ...
color.border?
string
= ...
color.borderActive?
string
= ...
color.color?
string
= ...
color.gutterColor?
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:104
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
color?
{ background
: string
; backgroundActive
: string
; border
: string
; borderActive
: string
; color
: string
; gutterColor
: string
; } = ...
color.background?
string
= ...
color.backgroundActive?
string
= ...
color.border?
string
= ...
color.borderActive?
string
= ...
color.color?
string
= ...
color.gutterColor?
string
= ...
end
number
= ...
id
string
| number
= annotationIdSchema
isGutter
boolean
= ...
label?
string
= ...
start
number
= ...
target?
"text"
| "gutter"
= ...
textSelection?
string
= ...
weight?
number
= ...
Returns
object
background?
optional
background:string
backgroundActive?
optional
backgroundActive:string
border?
optional
border:string
borderActive?
optional
borderActive:string
color?
optional
color:string
gutterColor?
optional
gutterColor:string
Inherited from
createAnnotation()
createAnnotation():
object
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:122
Create a new annotation object with default values.
Returns
object
color?
optional
color:object
color.background?
optional
background:string
color.backgroundActive?
optional
backgroundActive:string
color.border?
optional
border:string
color.borderActive?
optional
borderActive:string
color.color?
optional
color:string
color.gutterColor?
optional
gutterColor:string
end
end:
number
id
id:
string
|number
=annotationIdSchema
isGutter
isGutter:
boolean
label?
optional
label:string
start
start:
number
target?
optional
target:"text"
|"gutter"
textSelection?
optional
textSelection:string
weight?
optional
weight: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
; } = ...
color.background?
string
= ...
color.backgroundActive?
string
= ...
color.border?
string
= ...
color.borderActive?
string
= ...
color.color?
string
= ...
color.gutterColor?
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?
optional
color:object
color.background?
optional
background:string
color.backgroundActive?
optional
backgroundActive:string
color.border?
optional
border:string
color.borderActive?
optional
borderActive:string
color.color?
optional
color:string
color.gutterColor?
optional
gutterColor:string
end
end:
number
id
id:
string
|number
=annotationIdSchema
label?
optional
label:string
start
start:
number
target?
optional
target:"text"
|"gutter"
textSelection?
optional
textSelection:string
weight?
optional
weight:number
Overrides
getAnnotation()
getAnnotation(
annotationId
):object
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:165
Parameters
annotationId
string
| number
Returns
object
color?
optional
color:object
color.background?
optional
background:string
color.backgroundActive?
optional
backgroundActive:string
color.border?
optional
border:string
color.borderActive?
optional
borderActive:string
color.color?
optional
color:string
color.gutterColor?
optional
gutterColor:string
end
end:
number
id
id:
string
|number
=annotationIdSchema
label?
optional
label:string
start
start:
number
target?
optional
target:"text"
|"gutter"
textSelection?
optional
textSelection:string
weight?
optional
weight:number
Inherited from
AnnotationAdapter
.getAnnotation
hover()
hover(
annotation
):boolean
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:115
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
; } = ...
color.background?
string
= ...
color.backgroundActive?
string
= ...
color.border?
string
= ...
color.borderActive?
string
= ...
color.color?
string
= ...
color.gutterColor?
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:108
Parameters
annotation
color?
{ background
: string
; backgroundActive
: string
; border
: string
; borderActive
: string
; color
: string
; gutterColor
: string
; } = ...
color.background?
string
= ...
color.backgroundActive?
string
= ...
color.border?
string
= ...
color.borderActive?
string
= ...
color.color?
string
= ...
color.gutterColor?
string
= ...
end
number
= ...
id
string
| number
= annotationIdSchema
isGutter
boolean
= ...
label?
string
= ...
start
number
= ...
target?
"text"
| "gutter"
= ...
textSelection?
string
= ...
weight?
number
= ...
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
; } = ...
color.background?
string
= ...
color.backgroundActive?
string
= ...
color.border?
string
= ...
color.borderActive?
string
= ...
color.color?
string
= ...
color.gutterColor?
string
= ...
end
number
= ...
id
string
| number
= annotationIdSchema
label?
string
= ...
start
number
= ...
target?
"text"
| "gutter"
= ...
textSelection?
string
= ...
weight?
number
= ...
Returns
object
color?
optional
color:object
color.background?
optional
background:string
color.backgroundActive?
optional
backgroundActive:string
color.border?
optional
border:string
color.borderActive?
optional
borderActive:string
color.color?
optional
color:string
color.gutterColor?
optional
gutterColor:string
end
end:
number
id
id:
string
|number
=annotationIdSchema
isGutter
isGutter:
boolean
label?
optional
label:string
start
start:
number
target?
optional
target:"text"
|"gutter"
textSelection?
optional
textSelection:string
weight?
optional
weight:number
Overrides
setConfig()
setConfig<
KEY
>(key
,value
):void
Defined in: libs/core/src/lib/adapter/annotation/AnnotationAdapter.ts:136
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:74
Parameters
text
string
Returns
void