-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathannotations.ts
71 lines (62 loc) · 1.55 KB
/
annotations.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
import type { JSONValue } from '@lumino/coreutils';
import type { ISignal } from '@lumino/signaling';
/**
* Generic annotation change
*/
export type AnnotationsChange<T> = {
oldValue?: T;
newValue?: T;
};
/**
* Annotation interface.
*/
export interface IAnnotation {
sender: string;
pos: JSONValue;
content: JSONValue;
}
/**
* Annotations interface.
* This interface must be implemented by the shared documents that want
* to include annotations.
*/
export interface IAnnotations<T extends IAnnotation> {
/**
* The annotation changed signal.
*/
readonly annotationChanged: ISignal<this, AnnotationsChange<T>>;
/**
* Return an iterator that yields every annotation key.
*/
readonly annotations: Array<string>;
/**
* Get the value for an annotation
*
* @param key Key to get
*/
getAnnotation(key: string): T | undefined;
/**
* Set the value of an annotation
*
* @param key Key to set
* @param value New value
*/
setAnnotation(key: string, value: T): void;
/**
* Update the value of an existing annotation
*
* @param key Key to update
* @param value New value
*/
updateAnnotation(key: string, value: T): void;
/**
* Delete an annotation
*
* @param key Key to delete
*/
deleteAnnotation(key: string): void;
}