@annotorious/react-manifold 0.0.16 → 0.2.0
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,10 @@ 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;
|
|
13
14
|
getAnnotation(id: string): I | undefined;
|
|
14
15
|
getAnnotations(): I[];
|
|
16
|
+
setSelected(annotationId: string): void;
|
|
15
17
|
updateAnnotation(arg1: string | I, arg2?: I | Origin, arg3?: Origin): void;
|
|
16
18
|
}
|
|
17
19
|
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,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC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AI,CAAC;IAExD,OAAO,IAAI,IAAI,CAAC;IAEhB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAEjE,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;8FAsH/F,CAAA"}
|
|
@@ -1,39 +1,47 @@
|
|
|
1
|
-
import { Origin as
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
import { Origin as r } from "@annotorious/react";
|
|
2
|
+
const O = (s) => {
|
|
3
|
+
const e = (t) => Array.from(s.values()).reduce((o, n) => {
|
|
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 = n.state.store.getAnnotation(t);
|
|
7
|
+
if (a)
|
|
8
|
+
return { annotation: a, annotator: n };
|
|
9
|
+
}, void 0) || { annotation: void 0, annotator: void 0 }, i = (t, o = r.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
|
-
}, l = (t, o =
|
|
17
|
-
const { annotator: n } =
|
|
12
|
+
}, d = (t = r.LOCAL) => Array.from(s.values()).forEach((o) => o.state.store.clear(t)), f = (t, o = r.LOCAL) => {
|
|
13
|
+
const { annotation: n, annotator: a } = e(t);
|
|
14
|
+
if (a)
|
|
15
|
+
return a.state.store.deleteAnnotation(t, o), n;
|
|
16
|
+
}, l = (t, o = r.LOCAL) => {
|
|
17
|
+
const { annotator: n } = e(t.annotation);
|
|
18
18
|
n && n.state.store.deleteBody(t, o);
|
|
19
|
-
}, A = () => Array.from(
|
|
20
|
-
const
|
|
21
|
-
|
|
19
|
+
}, A = () => Array.from(s.values()).forEach((t) => t.destroy()), u = (t) => {
|
|
20
|
+
const { annotator: o } = e(t);
|
|
21
|
+
return o;
|
|
22
|
+
}, y = (t) => e(t).annotation, v = () => Array.from(s.values()).reduce((t, o) => [...t, ...o.state.store.all()], []), L = (t, o, n) => {
|
|
23
|
+
const a = typeof t == "string" ? t : t.id, { annotator: c } = e(a);
|
|
24
|
+
c && c.state.store.updateAnnotation(t, o, n);
|
|
25
|
+
}, m = (t) => {
|
|
26
|
+
const { annotator: o } = e(t);
|
|
27
|
+
o && o.setSelected(t);
|
|
22
28
|
};
|
|
23
29
|
return {
|
|
24
|
-
annotators: [...
|
|
25
|
-
sources: [...
|
|
26
|
-
addBody:
|
|
30
|
+
annotators: [...s.values()],
|
|
31
|
+
sources: [...s.keys()],
|
|
32
|
+
addBody: i,
|
|
27
33
|
clear: d,
|
|
28
34
|
deleteAnnotation: f,
|
|
29
35
|
deleteBody: l,
|
|
30
36
|
destroy: A,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
findAnnotator: u,
|
|
38
|
+
getAnnotation: y,
|
|
39
|
+
getAnnotations: v,
|
|
40
|
+
setSelected: m,
|
|
41
|
+
updateAnnotation: L
|
|
34
42
|
};
|
|
35
43
|
};
|
|
36
44
|
export {
|
|
37
|
-
|
|
45
|
+
O as createManifoldInstance
|
|
38
46
|
};
|
|
39
47
|
//# 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.values()).reduce((found, annotator) => {\n if (found)\n return found;\n\n const annotation = annotator.state.store.getAnnotation(annotationId);\n if (annotation) \n return { annotation, annotator };\n }, undefined as { annotation: I, annotator: Annotator<I, E> } | undefined ) || \n\n { annotation: undefined, annotator: 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 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 return {\n annotators: [...annotators.values()],\n sources: [...annotators.keys()],\n addBody,\n clear,\n deleteAnnotation,\n deleteBody,\n destroy,\n getAnnotation,\n getAnnotations,\n updateAnnotation\n }\n\n}"],"names":["createManifoldInstance","annotators","find","annotationId","found","annotator","annotation","addBody","body","origin","Origin","clear","a","deleteAnnotation","id","deleteBody","destroy","getAnnotation","getAnnotations","all","updateAnnotation","arg1","arg2","arg3","oldId"],"mappings":";
|
|
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 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, annotator?: Annotator<I, E> } =>\n Array.from(annotators.values()).reduce((found, annotator) => {\n if (found)\n return found;\n\n const annotation = annotator.state.store.getAnnotation(annotationId);\n if (annotation) \n return { annotation, annotator };\n }, undefined as { annotation: I, annotator: Annotator<I, E> } | undefined ) || \n\n { annotation: undefined, annotator: 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 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 getAnnotation,\n getAnnotations,\n setSelected,\n updateAnnotation\n }\n\n}"],"names":["createManifoldInstance","annotators","find","annotationId","found","annotator","annotation","addBody","body","origin","Origin","clear","a","deleteAnnotation","id","deleteBody","destroy","findAnnotator","getAnnotation","getAnnotations","all","updateAnnotation","arg1","arg2","arg3","oldId","setSelected"],"mappings":";AAmCa,MAAAA,IAAyB,CACpCC,MACsC;AAEtC,QAAMC,IAAO,CAACC,MACZ,MAAM,KAAKF,EAAW,OAAO,CAAC,EAAE,OAAO,CAACG,GAAOC,MAAc;AACvD,QAAAD;AACK,aAAAA;AAET,UAAME,IAAaD,EAAU,MAAM,MAAM,cAAcF,CAAY;AAC/D,QAAAG;AACK,aAAA,EAAE,YAAAA,GAAY,WAAAD;EAAU,GAChC,MAAuE,KAE1E,EAAE,YAAY,QAAW,WAAW,UAMhCE,IAAU,CAACC,GAAsBC,IAASC,EAAO,UAAU;AAC/D,UAAM,EAAE,WAAAL,EAAc,IAAAH,EAAKM,EAAK,UAAU;AACtC,IAAAH,KACFA,EAAU,MAAM,MAAM,QAAQG,GAAMC,CAAM;AAAA,EAAA,GAGxCE,IAAQ,CAACF,IAASC,EAAO,UAC7B,MAAM,KAAKT,EAAW,OAAA,CAAQ,EAAE,QAAQ,CAAKW,MAAAA,EAAE,MAAM,MAAM,MAAMH,CAAM,CAAC,GAEpEI,IAAm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