@annotorious/react-manifold 0.0.16 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,8 +10,11 @@ export interface AnnotoriousManifoldInstance<I extends Annotation = Annotation,
|
|
|
10
10
|
deleteAnnotation(id: string, origin?: Origin): I | undefined;
|
|
11
11
|
deleteBody(body: AnnotationBody, origin?: Origin): void;
|
|
12
12
|
destroy(): void;
|
|
13
|
+
findAnnotator(annotationId: string): Annotator<I, E> | undefined;
|
|
14
|
+
findSource(annotationId: string): string | undefined;
|
|
13
15
|
getAnnotation(id: string): I | undefined;
|
|
14
16
|
getAnnotations(): I[];
|
|
17
|
+
setSelected(annotationId: string): void;
|
|
15
18
|
updateAnnotation(arg1: string | I, arg2?: I | Origin, arg3?: Origin): void;
|
|
16
19
|
}
|
|
17
20
|
export declare const createManifoldInstance: <I extends Annotation = Annotation, E extends {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnnotoriousManifoldInstance.d.ts","sourceRoot":"","sources":["../src/AnnotoriousManifoldInstance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACV,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,2BAA2B,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAAE,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU;IAEnH,UAAU,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IAE9B,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAErD,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,gBAAgB,CAAC,E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,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAExD,OAAO,IAAI,IAAI,CAAC;IAEhB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAEjE,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAErD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAEzC,cAAc,IAAI,CAAC,EAAE,CAAC;IAEtB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAExC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAE5E;AAED,eAAO,MAAM,sBAAsB;QAAuD,MAAM;8FA4H/F,CAAA"}
|
|
@@ -1,39 +1,51 @@
|
|
|
1
|
-
import { Origin as
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
import { Origin as c } from "@annotorious/react";
|
|
2
|
+
const B = (s) => {
|
|
3
|
+
const e = (t) => Array.from(s.entries()).reduce((o, [n, r]) => {
|
|
4
4
|
if (o)
|
|
5
5
|
return o;
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
8
|
-
return { annotation:
|
|
9
|
-
}, void 0) || { annotation: void 0, annotator: void 0 },
|
|
10
|
-
const { annotator: n } =
|
|
6
|
+
const a = r.state.store.getAnnotation(t);
|
|
7
|
+
if (a)
|
|
8
|
+
return { annotation: a, annotator: r, source: n };
|
|
9
|
+
}, void 0) || { annotation: void 0, annotator: void 0, source: void 0 }, i = (t, o = c.LOCAL) => {
|
|
10
|
+
const { annotator: n } = e(t.annotation);
|
|
11
11
|
n && n.state.store.addBody(t, o);
|
|
12
|
-
}, d = (t =
|
|
13
|
-
const { annotation: n, annotator:
|
|
14
|
-
if (
|
|
15
|
-
return
|
|
16
|
-
},
|
|
17
|
-
const { annotator: n } =
|
|
12
|
+
}, d = (t = c.LOCAL) => Array.from(s.values()).forEach((o) => o.state.store.clear(t)), f = (t, o = c.LOCAL) => {
|
|
13
|
+
const { annotation: n, annotator: r } = e(t);
|
|
14
|
+
if (r)
|
|
15
|
+
return r.state.store.deleteAnnotation(t, o), n;
|
|
16
|
+
}, u = (t, o = c.LOCAL) => {
|
|
17
|
+
const { annotator: n } = e(t.annotation);
|
|
18
18
|
n && n.state.store.deleteBody(t, o);
|
|
19
|
-
},
|
|
20
|
-
const
|
|
21
|
-
|
|
19
|
+
}, l = () => Array.from(s.values()).forEach((t) => t.destroy()), A = (t) => {
|
|
20
|
+
const { annotator: o } = e(t);
|
|
21
|
+
return o;
|
|
22
|
+
}, y = (t) => {
|
|
23
|
+
const { source: o } = e(t);
|
|
24
|
+
return o;
|
|
25
|
+
}, v = (t) => e(t).annotation, L = () => Array.from(s.values()).reduce((t, o) => [...t, ...o.state.store.all()], []), m = (t, o, n) => {
|
|
26
|
+
const r = typeof t == "string" ? t : t.id, { annotator: a } = e(r);
|
|
27
|
+
a && a.state.store.updateAnnotation(t, o, n);
|
|
28
|
+
}, p = (t) => {
|
|
29
|
+
const { annotator: o } = e(t);
|
|
30
|
+
o && o.setSelected(t);
|
|
22
31
|
};
|
|
23
32
|
return {
|
|
24
|
-
annotators: [...
|
|
25
|
-
sources: [...
|
|
26
|
-
addBody:
|
|
33
|
+
annotators: [...s.values()],
|
|
34
|
+
sources: [...s.keys()],
|
|
35
|
+
addBody: i,
|
|
27
36
|
clear: d,
|
|
28
37
|
deleteAnnotation: f,
|
|
29
|
-
deleteBody:
|
|
30
|
-
destroy:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
deleteBody: u,
|
|
39
|
+
destroy: l,
|
|
40
|
+
findAnnotator: A,
|
|
41
|
+
findSource: y,
|
|
42
|
+
getAnnotation: v,
|
|
43
|
+
getAnnotations: L,
|
|
44
|
+
setSelected: p,
|
|
45
|
+
updateAnnotation: m
|
|
34
46
|
};
|
|
35
47
|
};
|
|
36
48
|
export {
|
|
37
|
-
|
|
49
|
+
B as createManifoldInstance
|
|
38
50
|
};
|
|
39
51
|
//# sourceMappingURL=annotorious-react-manifold.es4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotorious-react-manifold.es4.js","sources":["../src/AnnotoriousManifoldInstance.ts"],"sourcesContent":["import { Origin } from '@annotorious/react';\nimport type { \n Annotation, \n AnnotationBody, \n Annotator\n} from '@annotorious/react';\n\nexport interface AnnotoriousManifoldInstance<I extends Annotation = Annotation, E extends { id: string } = Annotation> {\n\n annotators: Annotator<I, E>[];\n\n sources: string[];\n\n addBody(body: AnnotationBody, origin?: Origin): void;\n\n clear(origin: Origin): void;\n\n deleteAnnotation(id: string, origin?: Origin): I | undefined;\n\n deleteBody(body: AnnotationBody, origin?: Origin): void;\n\n destroy(): void;\n\n getAnnotation(id: string): I | undefined;\n\n getAnnotations(): I[];\n\n updateAnnotation(arg1: string | I, arg2?: I | Origin, arg3?: Origin): void;\n\n}\n\nexport const createManifoldInstance = <I extends Annotation = Annotation, E extends { id: string } = Annotation>(\n annotators: Map<string, Annotator<I, E>>\n): AnnotoriousManifoldInstance<I, E> => {\n\n const find = (annotationId: string): { annotation?: I, annotator?: Annotator<I, E> } =>\n Array.from(annotators.
|
|
1
|
+
{"version":3,"file":"annotorious-react-manifold.es4.js","sources":["../src/AnnotoriousManifoldInstance.ts"],"sourcesContent":["import { Origin } from '@annotorious/react';\nimport type { \n Annotation, \n AnnotationBody, \n Annotator\n} from '@annotorious/react';\n\nexport interface AnnotoriousManifoldInstance<I extends Annotation = Annotation, E extends { id: string } = Annotation> {\n\n annotators: Annotator<I, E>[];\n\n sources: string[];\n\n addBody(body: AnnotationBody, origin?: Origin): void;\n\n clear(origin: Origin): void;\n\n deleteAnnotation(id: string, origin?: Origin): I | undefined;\n\n deleteBody(body: AnnotationBody, origin?: Origin): void;\n\n destroy(): void;\n\n findAnnotator(annotationId: string): Annotator<I, E> | undefined;\n\n findSource(annotationId: string): string | undefined;\n\n getAnnotation(id: string): I | undefined;\n\n getAnnotations(): I[];\n \n setSelected(annotationId: string): void;\n\n updateAnnotation(arg1: string | I, arg2?: I | Origin, arg3?: Origin): void;\n\n}\n\nexport const createManifoldInstance = <I extends Annotation = Annotation, E extends { id: string } = Annotation>(\n annotators: Map<string, Annotator<I, E>>\n): AnnotoriousManifoldInstance<I, E> => {\n\n const find = (annotationId: string): { annotation?: I, source?: string, annotator?: Annotator<I, E> } =>\n Array.from(annotators.entries()).reduce((found, [source, annotator]) => {\n if (found)\n return found;\n\n const annotation = annotator.state.store.getAnnotation(annotationId);\n if (annotation) \n return { annotation, annotator, source };\n }, undefined as { annotation: I, annotator: Annotator<I, E> } | undefined ) || \n\n { annotation: undefined, annotator: undefined, source: undefined };\n\n /*********/\n /** API **/\n /*********/\n\n const addBody = (body: AnnotationBody, origin = Origin.LOCAL) => {\n const { annotator } = find(body.annotation);\n if (annotator)\n annotator.state.store.addBody(body, origin);\n }\n\n const clear = (origin = Origin.LOCAL) =>\n Array.from(annotators.values()).forEach(a => a.state.store.clear(origin));\n\n const deleteAnnotation = (id: string, origin = Origin.LOCAL) => {\n const { annotation, annotator } = find(id);\n\n if (annotator) {\n annotator.state.store.deleteAnnotation(id, origin);\n return annotation;\n }\n }\n\n const deleteBody = (body: AnnotationBody, origin = Origin.LOCAL) => {\n const { annotator } = find(body.annotation);\n if (annotator)\n annotator.state.store.deleteBody(body, origin);\n }\n\n const destroy = () =>\n Array.from(annotators.values()).forEach(a => a.destroy());\n\n const findAnnotator = (annotationId: string) => {\n const { annotator } = find(annotationId);\n return annotator;\n }\n\n const findSource = (annotationId: string) => {\n const { source } = find(annotationId);\n return source;\n }\n\n const getAnnotation = (id: string) => \n find(id).annotation;\n\n const getAnnotations = () => \n Array.from(annotators.values()).reduce((all, annotator) =>\n [...all, ...annotator.state.store.all()], [] as I[]);\n\n const updateAnnotation = (arg1: string | I, arg2?: I | Origin, arg3?: Origin) => {\n const oldId: string = typeof arg1 === 'string' ? arg1 : arg1.id;\n\n const { annotator } = find(oldId);\n if (annotator)\n annotator.state.store.updateAnnotation(arg1, arg2, arg3);\n }\n\n const setSelected = (id: string) => {\n // Note: keeping this for later - but needs handling in the \n // context provider, because we need to mute selection events!\n /*\n if (Array.isArray(idOrIds)) {\n const resolved = idOrIds.map(find).filter(t => t.annotator);\n\n const groupedByAnnotator = resolved.reduce((grouped, { annotator, annotation }) => {\n const existing = grouped.find(t => t.annotator === annotator);\n if (existing) {\n // Append this annotation\n return grouped.map(t => t.annotator === existing.annotator ? \n { \n annotator, \n annotations: [...t.annotations, annotation ] \n } : t);\n } else {\n // New entry\n return [...grouped, {\n annotator,\n annotations: [ annotation ]\n }];\n } \n }, [] as { annotator: Annotator<I, E>, annotations: I[] }[]);\n\n groupedByAnnotator.forEach(({ annotator, annotations }) => {\n \n })\n } else { \n */\n const { annotator } = find(id);\n if (annotator)\n annotator.setSelected(id);\n // }\n }\n\n return {\n annotators: [...annotators.values()],\n sources: [...annotators.keys()],\n addBody,\n clear,\n deleteAnnotation,\n deleteBody,\n destroy,\n findAnnotator,\n findSource,\n getAnnotation,\n getAnnotations,\n setSelected,\n updateAnnotation\n }\n\n}"],"names":["createManifoldInstance","annotators","find","annotationId","found","source","annotator","annotation","addBody","body","origin","Origin","clear","a","deleteAnnotation","id","deleteBody","destroy","findAnnotator","findSource","getAnnotation","getAnnotations","all","updateAnnotation","arg1","arg2","arg3","oldId","setSelected"],"mappings":";AAqCa,MAAAA,IAAyB,CACpCC,MACsC;AAEtC,QAAMC,IAAO,CAACC,MACZ,MAAM,KAAKF,EAAW,SAAS,EAAE,OAAO,CAACG,GAAO,CAACC,GAAQC,CAAS,MAAM;AAClE,QAAAF;AACK,aAAAA;AAET,UAAMG,IAAaD,EAAU,MAAM,MAAM,cAAcH,CAAY;AAC/D,QAAAI;AACK,aA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