@annotorious/core 3.0.0-pre-alpha-54 → 3.0.0-pre-alpha-56

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@annotorious/core",
3
- "version": "3.0.0-pre-alpha-54",
3
+ "version": "3.0.0-pre-alpha-56",
4
4
  "description": "Annotorious core types and functions",
5
5
  "author": "Rainer Simon",
6
6
  "license": "BSD-3-Clause",
@@ -12,4 +12,8 @@ export interface DrawingStyle {
12
12
 
13
13
  fillOpacity?: number;
14
14
 
15
+ stroke?: Color;
16
+
17
+ strokeOpacity?: number;
18
+
15
19
  }
@@ -83,7 +83,7 @@ export const parseW3CBodies = (
83
83
  ): AnnotationBody[] => (Array.isArray(body) ? body : [body]).map(body => {
84
84
 
85
85
  // Exctract properties that conform to the internal model, but keep custom props
86
- const { id, type, purpose, value, created, creator, ...rest} = body;
86
+ const { id, type, purpose, value, created, creator, ...rest } = body;
87
87
 
88
88
  // The internal model strictly requires IDs. (Because multi-user scenarios
89
89
  // will have problems without them.) In the W3C model, bodys *may* have IDs.
@@ -91,7 +91,7 @@ export const parseW3CBodies = (
91
91
  // generating the ID is idempotent: the same body should always get the same ID.
92
92
  // This will avoid unexpected results when checking for equality.
93
93
  return {
94
- id: id || hashCode(body),
94
+ id: id || `temp-${hashCode(body)}`,
95
95
  annotation: annotationId,
96
96
  type,
97
97
  purpose,
@@ -105,11 +105,14 @@ export const parseW3CBodies = (
105
105
 
106
106
  });
107
107
 
108
+ /** Serialization helper to remove core-specific fields from the annotation body **/
108
109
  export const serializeW3CBodies = (bodies: AnnotationBody[]): W3CAnnotationBody[] =>
109
110
  bodies.map(b => {
110
111
  const w3c = { ...b };
111
112
  delete w3c.annotation;
112
- delete w3c.id;
113
- return w3c;
114
- });
115
113
 
114
+ if (w3c.id?.startsWith('temp-'))
115
+ delete w3c.id;
116
+
117
+ return w3c;
118
+ });
@@ -16,7 +16,7 @@ export enum PointerSelectAction {
16
16
 
17
17
  EDIT = 'EDIT', // Make annotation target(s) editable on pointer select
18
18
 
19
- HIGHLIGHT = 'HIGHLIGHT', // Just hightlight on select, but don't make editable
19
+ SELECT = 'SELECT', // Just select, but don't make editable
20
20
 
21
21
  NONE = 'NONE' // Click won't select - annotation is completely inert
22
22
 
@@ -53,7 +53,7 @@ export const createSelectionState = <T extends Annotation>(
53
53
  const action = onPointerSelect(annotation, selectAction);
54
54
  if (action === PointerSelectAction.EDIT)
55
55
  set({ selected: [{ id, editable: true }], pointerEvent });
56
- else if (action === PointerSelectAction.HIGHLIGHT)
56
+ else if (action === PointerSelectAction.SELECT)
57
57
  set({ selected: [{ id }], pointerEvent });
58
58
  else
59
59
  set({ selected: [], pointerEvent });