@annotorious/annotorious
Advanced tools
Comparing version 3.0.0-rc.15 to 3.0.0-rc.16
import type { SvelteComponent } from 'svelte'; | ||
import type { Annotator } from '@annotorious/core'; | ||
import { type Annotator } from '@annotorious/core'; | ||
import { type DrawingTool } from './annotation/tools'; | ||
@@ -4,0 +4,0 @@ import type { DrawingToolOpts } from './annotation'; |
@@ -1,3 +0,2 @@ | ||
import { PointerSelectAction } from '@annotorious/core'; | ||
import type { Annotation, DrawingStyle, FormatAdapter } from '@annotorious/core'; | ||
import type { Annotation, DrawingStyle, FormatAdapter, PointerSelectAction } from '@annotorious/core'; | ||
import type { ImageAnnotation } from './model'; | ||
@@ -15,3 +14,3 @@ export interface AnnotoriousOpts<I extends Annotation = ImageAnnotation, E extends unknown = ImageAnnotation> { | ||
export type Theme = 'dark' | 'light' | 'auto'; | ||
export declare const fillDefaults: <I extends ImageAnnotation = ImageAnnotation, E extends unknown = ImageAnnotation>(opts: AnnotoriousOpts<I, E>) => AnnotoriousOpts<I, E>; | ||
export declare const fillDefaults: <I extends ImageAnnotation = ImageAnnotation, E extends unknown = ImageAnnotation>(opts: AnnotoriousOpts<I, E>, defaults: AnnotoriousOpts<I, E>) => AnnotoriousOpts<I, E>; | ||
//# sourceMappingURL=AnnotoriousOpts.d.ts.map |
{ | ||
"name": "@annotorious/annotorious", | ||
"version": "3.0.0-rc.15", | ||
"version": "3.0.0-rc.16", | ||
"description": "Add image annotation functionality to any web page with a few lines of JavaScript", | ||
@@ -5,0 +5,0 @@ "author": "Rainer Simon", |
import type { SvelteComponent } from 'svelte'; | ||
import type { Annotator, DrawingStyle, Filter, User } from '@annotorious/core'; | ||
import { PointerSelectAction, type Annotator, type DrawingStyle, type Filter, type User } from '@annotorious/core'; | ||
import { createAnonymousGuest, createBaseAnnotator, createLifecyleObserver, createUndoStack } from '@annotorious/core'; | ||
@@ -46,3 +46,8 @@ import { registerEditor } from './annotation/editors'; | ||
const opts = fillDefaults<ImageAnnotation, E>(options); | ||
const opts = fillDefaults<ImageAnnotation, E>(options, { | ||
drawingEnabled: true, | ||
drawingMode: 'drag', | ||
pointerSelectAction: PointerSelectAction.EDIT, | ||
theme: 'light' | ||
}); | ||
@@ -49,0 +54,0 @@ const state = createSvelteImageAnnotatorState(opts); |
@@ -1,3 +0,2 @@ | ||
import { PointerSelectAction } from '@annotorious/core'; | ||
import type { Annotation, DrawingStyle, FormatAdapter } from '@annotorious/core'; | ||
import type { Annotation, DrawingStyle, FormatAdapter, PointerSelectAction } from '@annotorious/core'; | ||
import type { ImageAnnotation } from './model'; | ||
@@ -30,3 +29,4 @@ | ||
export const fillDefaults = <I extends ImageAnnotation = ImageAnnotation, E extends unknown = ImageAnnotation> ( | ||
opts: AnnotoriousOpts<I, E> | ||
opts: AnnotoriousOpts<I, E>, | ||
defaults: AnnotoriousOpts<I, E> | ||
): AnnotoriousOpts<I, E> => { | ||
@@ -36,6 +36,6 @@ | ||
...opts, | ||
drawingEnabled: opts.drawingEnabled === undefined ? true : opts.drawingEnabled, | ||
drawingMode: opts.drawingMode || 'drag', | ||
pointerSelectAction: opts.pointerSelectAction || PointerSelectAction.EDIT, | ||
theme: opts.theme || 'light' | ||
drawingEnabled: opts.drawingEnabled === undefined ? defaults.drawingEnabled : opts.drawingEnabled, | ||
drawingMode: opts.drawingMode || defaults.drawingMode, | ||
pointerSelectAction: opts.pointerSelectAction || defaults.pointerSelectAction, | ||
theme: opts.theme || defaults.theme | ||
}; | ||
@@ -42,0 +42,0 @@ |
import { v4 as uuidv4 } from 'uuid'; | ||
import { parseW3CBodies, serializeW3CBodies } from '@annotorious/core'; | ||
import { parseW3CUser, parseW3CBodies, serializeW3CBodies } from '@annotorious/core'; | ||
import type { FormatAdapter, ParseResult, W3CAnnotation } from '@annotorious/core'; | ||
@@ -33,3 +33,10 @@ import { ShapeType } from '../core'; | ||
const { body, ...rest } = annotation; | ||
const { | ||
creator, | ||
created, | ||
updatedBy, | ||
updated, | ||
body, | ||
...rest | ||
} = annotation; | ||
@@ -54,2 +61,4 @@ const bodies = parseW3CBodies(body, annotationId); | ||
target: { | ||
created: created ? new Date(created) : undefined, | ||
creator: parseW3CUser(creator), | ||
...rest.target, | ||
@@ -70,8 +79,15 @@ annotation: annotationId, | ||
): W3CAnnotation => { | ||
const shape = annotation.target.selector; | ||
const { | ||
selector, | ||
creator, | ||
created, | ||
updated, | ||
updatedBy, | ||
...rest | ||
} = annotation.target; | ||
const selector = | ||
shape.type == ShapeType.RECTANGLE ? | ||
serializeFragmentSelector(shape.geometry as RectangleGeometry) : | ||
serializeSVGSelector(shape); | ||
const w3CSelector = | ||
selector.type == ShapeType.RECTANGLE ? | ||
serializeFragmentSelector(selector.geometry as RectangleGeometry) : | ||
serializeSVGSelector(selector); | ||
@@ -84,7 +100,10 @@ return { | ||
body: serializeW3CBodies(annotation.bodies), | ||
creator, | ||
created: created?.toISOString(), | ||
target: { | ||
...rest, | ||
source, | ||
selector | ||
selector: w3CSelector | ||
} | ||
}; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
863576
5659