triiiceratops 0.9.13 → 0.10.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.
- package/dist/ArrowCounterClockwise-C6n_F9YZ.js +136 -0
- package/dist/X-BUzsFa3u.js +886 -0
- package/dist/annotation_tool_point-CCJi2I8J.js +290 -0
- package/dist/components/AnnotationOverlay.svelte +179 -86
- package/dist/components/LeftFab.svelte +21 -9
- package/dist/components/OSDViewer.svelte +20 -3
- package/dist/components/ThumbnailGallery.svelte +4 -4
- package/dist/components/TriiiceratopsViewer.svelte +167 -49
- package/dist/components/TriiiceratopsViewer.svelte.d.ts +5 -5
- package/dist/components/TriiiceratopsViewerElement.svelte +2 -2
- package/dist/components/TriiiceratopsViewerElement.svelte.d.ts +2 -2
- package/dist/custom-element.d.ts +10 -0
- package/dist/custom-element.js +13 -0
- package/dist/image_filters_reset-CWe7vTJU.js +108 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +0 -1
- package/dist/paraglide/messages/_index.d.ts +30 -0
- package/dist/paraglide/messages/_index.js +31 -1
- package/dist/paraglide/messages/annotation_editor_add_content.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_add_content.js +34 -0
- package/dist/paraglide/messages/annotation_editor_cancel.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_cancel.js +34 -0
- package/dist/paraglide/messages/annotation_editor_create_mode.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_create_mode.js +34 -0
- package/dist/paraglide/messages/annotation_editor_delete.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_delete.js +34 -0
- package/dist/paraglide/messages/annotation_editor_delete_message.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_delete_message.js +34 -0
- package/dist/paraglide/messages/annotation_editor_delete_title.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_delete_title.js +34 -0
- package/dist/paraglide/messages/annotation_editor_delete_tooltip.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_delete_tooltip.js +34 -0
- package/dist/paraglide/messages/annotation_editor_edit_mode.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_edit_mode.js +34 -0
- package/dist/paraglide/messages/annotation_editor_edit_section.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_edit_section.js +34 -0
- package/dist/paraglide/messages/annotation_editor_instruction_create.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_instruction_create.js +34 -0
- package/dist/paraglide/messages/annotation_editor_instruction_edit.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_instruction_edit.js +34 -0
- package/dist/paraglide/messages/annotation_editor_link_placeholder.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_link_placeholder.js +34 -0
- package/dist/paraglide/messages/annotation_editor_redo.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_redo.js +34 -0
- package/dist/paraglide/messages/annotation_editor_save.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_save.js +34 -0
- package/dist/paraglide/messages/annotation_editor_tag_placeholder.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_tag_placeholder.js +34 -0
- package/dist/paraglide/messages/annotation_editor_text_placeholder.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_text_placeholder.js +34 -0
- package/dist/paraglide/messages/annotation_editor_title.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_title.js +34 -0
- package/dist/paraglide/messages/annotation_editor_tool_label.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_tool_label.js +34 -0
- package/dist/paraglide/messages/annotation_editor_undo.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_undo.js +34 -0
- package/dist/paraglide/messages/annotation_tool_point.d.ts +4 -0
- package/dist/paraglide/messages/annotation_tool_point.js +34 -0
- package/dist/paraglide/messages/annotation_tool_polygon.d.ts +4 -0
- package/dist/paraglide/messages/annotation_tool_polygon.js +34 -0
- package/dist/paraglide/messages/annotation_tool_rectangle.d.ts +4 -0
- package/dist/paraglide/messages/annotation_tool_rectangle.js +34 -0
- package/dist/paraglide/messages/image_adjustments_title.d.ts +4 -0
- package/dist/paraglide/messages/image_adjustments_title.js +34 -0
- package/dist/paraglide/messages/image_filters_brightness.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_brightness.js +34 -0
- package/dist/paraglide/messages/image_filters_contrast.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_contrast.js +34 -0
- package/dist/paraglide/messages/image_filters_effects.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_effects.js +34 -0
- package/dist/paraglide/messages/image_filters_grayscale.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_grayscale.js +34 -0
- package/dist/paraglide/messages/image_filters_invert.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_invert.js +34 -0
- package/dist/paraglide/messages/image_filters_reset.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_reset.js +34 -0
- package/dist/paraglide/messages/image_filters_saturation.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_saturation.js +34 -0
- package/dist/paraglide/messages/plugins_tooltip.js +1 -1
- package/dist/plugins/annotation-editor/AnnotationEditorController.svelte +166 -0
- package/dist/plugins/annotation-editor/AnnotationEditorController.svelte.d.ts +9 -0
- package/dist/plugins/annotation-editor/AnnotationEditorPanel.svelte +315 -0
- package/dist/plugins/annotation-editor/AnnotationEditorPanel.svelte.d.ts +24 -0
- package/dist/plugins/annotation-editor/AnnotationManager.svelte.d.ts +39 -0
- package/dist/plugins/annotation-editor/AnnotationManager.svelte.js +433 -0
- package/dist/plugins/annotation-editor/adapters/LocalStorageAdapter.d.ts +20 -0
- package/dist/plugins/annotation-editor/adapters/LocalStorageAdapter.js +67 -0
- package/dist/plugins/annotation-editor/adapters/index.d.ts +2 -0
- package/dist/plugins/annotation-editor/adapters/index.js +1 -0
- package/dist/plugins/annotation-editor/adapters/types.d.ts +23 -0
- package/dist/plugins/annotation-editor/adapters/types.js +1 -0
- package/dist/plugins/annotation-editor/iife-entry.d.ts +15 -0
- package/dist/plugins/annotation-editor/iife-entry.js +35 -0
- package/dist/plugins/annotation-editor/index.d.ts +41 -0
- package/dist/plugins/annotation-editor/index.js +57 -0
- package/dist/plugins/annotation-editor/loader.svelte.d.ts +7 -0
- package/dist/plugins/annotation-editor/loader.svelte.js +32 -0
- package/dist/plugins/annotation-editor/types.d.ts +41 -0
- package/dist/plugins/annotation-editor/types.js +13 -0
- package/dist/plugins/annotation-editor.js +32824 -0
- package/dist/plugins/image-manipulation/ImageManipulationController.svelte +54 -0
- package/dist/plugins/image-manipulation/ImageManipulationController.svelte.d.ts +6 -0
- package/dist/plugins/image-manipulation/ImageManipulationPanel.svelte +19 -9
- package/dist/plugins/image-manipulation/ImageManipulationPanel.svelte.d.ts +1 -0
- package/dist/plugins/image-manipulation/iife-entry.d.ts +13 -0
- package/dist/plugins/image-manipulation/iife-entry.js +17 -0
- package/dist/plugins/image-manipulation/index.d.ts +15 -1
- package/dist/plugins/image-manipulation/index.js +21 -1
- package/dist/plugins/image-manipulation.js +265 -0
- package/dist/state/i18n.svelte.js +4 -2
- package/dist/state/manifests.svelte.d.ts +7 -2
- package/dist/state/manifests.svelte.js +45 -13
- package/dist/state/viewer.svelte.d.ts +16 -13
- package/dist/state/viewer.svelte.js +75 -84
- package/dist/triiiceratops-bundle.js +3260 -3155
- package/dist/triiiceratops-element.css +1 -0
- package/dist/triiiceratops-element.iife.js +99 -0
- package/dist/triiiceratops.css +1 -1
- package/dist/types/plugin.d.ts +21 -62
- package/dist/types/plugin.js +1 -23
- package/dist/utils/annotationAdapter.d.ts +12 -1
- package/dist/utils/annotationAdapter.js +98 -39
- package/package.json +13 -6
- package/dist/chunks/TriiiceratopsViewer-EViTQO_n.js +0 -10437
- package/dist/chunks/openseadragon-CHvATAD9.js +0 -12427
- package/dist/components/TriiiceratopsViewerElementImage.svelte +0 -143
- package/dist/components/TriiiceratopsViewerElementImage.svelte.d.ts +0 -27
- package/dist/custom-element-image.d.ts +0 -1
- package/dist/custom-element-image.js +0 -2
- package/dist/plugins/image-manipulation/ImageManipulationPlugin.svelte.d.ts +0 -19
- package/dist/plugins/image-manipulation/ImageManipulationPlugin.svelte.js +0 -87
- package/dist/triiiceratops-element-image.js +0 -555
- package/dist/triiiceratops-element.js +0 -114
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,28 +1,5 @@
|
|
|
1
1
|
import type { Component } from 'svelte';
|
|
2
|
-
import type OpenSeadragon from 'openseadragon';
|
|
3
2
|
import type { ViewerState } from '../state/viewer.svelte';
|
|
4
|
-
/**
|
|
5
|
-
* Context object passed to plugins during registration.
|
|
6
|
-
* This is the stable public API that plugins depend on.
|
|
7
|
-
*/
|
|
8
|
-
export interface PluginContext {
|
|
9
|
-
/** The ViewerState instance for accessing/modifying viewer state */
|
|
10
|
-
viewerState: ViewerState;
|
|
11
|
-
/** Get the OpenSeadragon viewer instance (null until ready) */
|
|
12
|
-
getOSDViewer(): OpenSeadragon.Viewer | null;
|
|
13
|
-
/** Register a menu button in the FloatingMenu */
|
|
14
|
-
registerMenuButton(button: PluginMenuButton): void;
|
|
15
|
-
/** Unregister a menu button by ID */
|
|
16
|
-
unregisterMenuButton(buttonId: string): void;
|
|
17
|
-
/** Register a panel component */
|
|
18
|
-
registerPanel(panel: PluginPanel): void;
|
|
19
|
-
/** Unregister a panel by ID */
|
|
20
|
-
unregisterPanel(panelId: string): void;
|
|
21
|
-
/** Emit a custom event that other plugins can listen to */
|
|
22
|
-
emit(eventName: string, data?: unknown): void;
|
|
23
|
-
/** Subscribe to custom events from other plugins */
|
|
24
|
-
on(eventName: string, handler: (data: unknown) => void): () => void;
|
|
25
|
-
}
|
|
26
3
|
/**
|
|
27
4
|
* Menu button configuration for plugin UI injection.
|
|
28
5
|
*/
|
|
@@ -30,7 +7,7 @@ export interface PluginMenuButton {
|
|
|
30
7
|
/** Unique identifier (convention: `pluginId:buttonName`) */
|
|
31
8
|
id: string;
|
|
32
9
|
/** Phosphor icon component */
|
|
33
|
-
icon: Component
|
|
10
|
+
icon: Component<any>;
|
|
34
11
|
/** Tooltip text */
|
|
35
12
|
tooltip: string;
|
|
36
13
|
/** Click handler */
|
|
@@ -49,7 +26,7 @@ export interface PluginPanel {
|
|
|
49
26
|
/** Unique identifier (convention: `pluginId:panelName`) */
|
|
50
27
|
id: string;
|
|
51
28
|
/** Svelte component to render */
|
|
52
|
-
component: Component
|
|
29
|
+
component: Component<any>;
|
|
53
30
|
/** Props passed to the component */
|
|
54
31
|
props?: Record<string, unknown>;
|
|
55
32
|
/** Panel position in the viewer */
|
|
@@ -58,44 +35,26 @@ export interface PluginPanel {
|
|
|
58
35
|
isVisible: () => boolean;
|
|
59
36
|
}
|
|
60
37
|
/**
|
|
61
|
-
*
|
|
38
|
+
* Simplified definition for a plugin.
|
|
39
|
+
* This allows plugins to be defined as simple objects with a component and icon.
|
|
62
40
|
*/
|
|
63
|
-
export interface
|
|
64
|
-
/** Unique
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* Called when OpenSeadragon viewer is ready.
|
|
77
|
-
* Attach OSD event handlers here.
|
|
78
|
-
*/
|
|
79
|
-
onViewerReady?(viewer: OpenSeadragon.Viewer): void;
|
|
41
|
+
export interface PluginDef {
|
|
42
|
+
/** Unique ID (optional, will be auto-generated if missing) */
|
|
43
|
+
id?: string;
|
|
44
|
+
/** Name/Tooltip for the menu button */
|
|
45
|
+
name: string;
|
|
46
|
+
/** Icon component */
|
|
47
|
+
icon: Component<any>;
|
|
48
|
+
/** Panel component */
|
|
49
|
+
panel: Component<any>;
|
|
50
|
+
/** Preferred position (default: 'left') */
|
|
51
|
+
position?: 'left' | 'right' | 'bottom' | 'overlay';
|
|
52
|
+
/** Props to pass to the panel component */
|
|
53
|
+
props?: Record<string, unknown>;
|
|
80
54
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
55
|
+
* Lifecycle hook called when the plugin is registered.
|
|
56
|
+
* Use this to set up background logic, reactive effects, or event listeners
|
|
57
|
+
* that should run regardless of whether the plugin's UI is open.
|
|
83
58
|
*/
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Optional base class providing common plugin functionality.
|
|
88
|
-
*/
|
|
89
|
-
export declare abstract class BasePlugin implements TriiiceratopsPlugin {
|
|
90
|
-
abstract readonly id: string;
|
|
91
|
-
abstract readonly name: string;
|
|
92
|
-
abstract readonly version: string;
|
|
93
|
-
protected context: PluginContext | null;
|
|
94
|
-
onRegister(context: PluginContext): void;
|
|
95
|
-
onViewerReady?(viewer: OpenSeadragon.Viewer): void;
|
|
96
|
-
onDestroy(): void;
|
|
97
|
-
/** Convenience getter for ViewerState */
|
|
98
|
-
protected get viewerState(): ViewerState;
|
|
99
|
-
/** Convenience getter for OSD viewer */
|
|
100
|
-
protected get osdViewer(): OpenSeadragon.Viewer | null;
|
|
59
|
+
onInit?: (viewerState: ViewerState) => void;
|
|
101
60
|
}
|
package/dist/types/plugin.js
CHANGED
|
@@ -1,23 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Optional base class providing common plugin functionality.
|
|
3
|
-
*/
|
|
4
|
-
export class BasePlugin {
|
|
5
|
-
context = null;
|
|
6
|
-
onRegister(context) {
|
|
7
|
-
this.context = context;
|
|
8
|
-
}
|
|
9
|
-
onDestroy() {
|
|
10
|
-
this.context = null;
|
|
11
|
-
}
|
|
12
|
-
/** Convenience getter for ViewerState */
|
|
13
|
-
get viewerState() {
|
|
14
|
-
if (!this.context) {
|
|
15
|
-
throw new Error(`Plugin ${this.id} accessed viewerState before registration`);
|
|
16
|
-
}
|
|
17
|
-
return this.context.viewerState;
|
|
18
|
-
}
|
|
19
|
-
/** Convenience getter for OSD viewer */
|
|
20
|
-
get osdViewer() {
|
|
21
|
-
return this.context?.getOSDViewer() ?? null;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
1
|
+
export {};
|
|
@@ -7,7 +7,9 @@ export interface ParsedAnnotation {
|
|
|
7
7
|
body: {
|
|
8
8
|
value: string;
|
|
9
9
|
isHtml: boolean;
|
|
10
|
-
|
|
10
|
+
purpose?: string;
|
|
11
|
+
format?: string;
|
|
12
|
+
}[];
|
|
11
13
|
isSearchHit: boolean;
|
|
12
14
|
}
|
|
13
15
|
export interface RectangleGeometry {
|
|
@@ -21,6 +23,15 @@ export interface PolygonGeometry {
|
|
|
21
23
|
type: 'POLYGON';
|
|
22
24
|
points: [number, number][];
|
|
23
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Extract annotation body content (text, label, etc)
|
|
28
|
+
*/
|
|
29
|
+
export declare function extractBody(annotation: any): {
|
|
30
|
+
value: string;
|
|
31
|
+
isHtml: boolean;
|
|
32
|
+
purpose?: string;
|
|
33
|
+
format?: string;
|
|
34
|
+
}[];
|
|
24
35
|
/**
|
|
25
36
|
* Parse Manifesto/IIIF annotation to internal format
|
|
26
37
|
*/
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* Handles Manifesto objects and raw JSON
|
|
4
4
|
*/
|
|
5
5
|
function getAnnotationId(anno) {
|
|
6
|
-
return anno.id ||
|
|
6
|
+
return (anno.id ||
|
|
7
|
+
anno['@id'] ||
|
|
8
|
+
(typeof anno.getId === 'function' ? anno.getId() : ''));
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* Parse xywh media fragment from target string
|
|
@@ -12,13 +14,14 @@ function getAnnotationId(anno) {
|
|
|
12
14
|
function parseXywh(targetStr) {
|
|
13
15
|
if (!targetStr)
|
|
14
16
|
return null;
|
|
15
|
-
|
|
17
|
+
// Match xywh= optionally followed by "pixel:" and handle floats
|
|
18
|
+
const match = targetStr.match(/xywh=(?:pixel:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)/);
|
|
16
19
|
if (match) {
|
|
17
20
|
return {
|
|
18
|
-
x:
|
|
19
|
-
y:
|
|
20
|
-
w:
|
|
21
|
-
h:
|
|
21
|
+
x: parseFloat(match[1]),
|
|
22
|
+
y: parseFloat(match[2]),
|
|
23
|
+
w: parseFloat(match[3]),
|
|
24
|
+
h: parseFloat(match[4]),
|
|
22
25
|
};
|
|
23
26
|
}
|
|
24
27
|
return null;
|
|
@@ -89,8 +92,19 @@ function extractSvgFromTarget(target) {
|
|
|
89
92
|
function extractSvgValue(target) {
|
|
90
93
|
if (!target)
|
|
91
94
|
return null;
|
|
95
|
+
// Check for selector property or use target itself
|
|
96
|
+
let selector = target.selector || target;
|
|
97
|
+
// Handle array of selectors
|
|
98
|
+
if (Array.isArray(selector)) {
|
|
99
|
+
// Determine which selector to use?
|
|
100
|
+
// Usually SvgSelector is preferred if present
|
|
101
|
+
const svgSel = selector.find((s) => s.type === 'SvgSelector');
|
|
102
|
+
if (svgSel && svgSel.value)
|
|
103
|
+
return svgSel.value;
|
|
104
|
+
// Or just look for any with value?
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
92
107
|
// Check for SvgSelector
|
|
93
|
-
const selector = target.selector || target;
|
|
94
108
|
if (selector?.type === 'SvgSelector' && selector.value) {
|
|
95
109
|
return selector.value;
|
|
96
110
|
}
|
|
@@ -140,6 +154,15 @@ function convertSvgToPolygon(svgString) {
|
|
|
140
154
|
const circlePoints = generateCirclePoints(cx, cy, r);
|
|
141
155
|
points.push(...circlePoints);
|
|
142
156
|
}
|
|
157
|
+
// Extract points from rect elements
|
|
158
|
+
const rects = doc.querySelectorAll('rect');
|
|
159
|
+
for (const rect of rects) {
|
|
160
|
+
const x = parseFloat(rect.getAttribute('x') || '0');
|
|
161
|
+
const y = parseFloat(rect.getAttribute('y') || '0');
|
|
162
|
+
const w = parseFloat(rect.getAttribute('width') || '0');
|
|
163
|
+
const h = parseFloat(rect.getAttribute('height') || '0');
|
|
164
|
+
points.push([x, y], [x + w, y], [x + w, y + h], [x, y + h]);
|
|
165
|
+
}
|
|
143
166
|
if (points.length === 0) {
|
|
144
167
|
return null;
|
|
145
168
|
}
|
|
@@ -244,9 +267,25 @@ function extractXywhFromRawTarget(target) {
|
|
|
244
267
|
}
|
|
245
268
|
// Handle object with selector
|
|
246
269
|
if (target.selector) {
|
|
247
|
-
|
|
270
|
+
let sel = target.selector;
|
|
271
|
+
// Handle array of selectors
|
|
272
|
+
if (Array.isArray(sel)) {
|
|
273
|
+
// Prefer FragmentSelector
|
|
274
|
+
const fragment = sel.find((s) => s.type === 'FragmentSelector' &&
|
|
275
|
+
s.value &&
|
|
276
|
+
s.value.includes('xywh='));
|
|
277
|
+
if (fragment)
|
|
278
|
+
return parseXywh(fragment.value);
|
|
279
|
+
// Or generic
|
|
280
|
+
const anyXywh = sel.find((s) => s.value && s.value.includes('xywh='));
|
|
281
|
+
if (anyXywh)
|
|
282
|
+
return parseXywh(anyXywh.value);
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
248
285
|
const item = sel.item || sel;
|
|
249
|
-
if (item.value &&
|
|
286
|
+
if (item.value &&
|
|
287
|
+
typeof item.value === 'string' &&
|
|
288
|
+
item.value.includes('xywh=')) {
|
|
250
289
|
return parseXywh(item.value);
|
|
251
290
|
}
|
|
252
291
|
}
|
|
@@ -255,60 +294,80 @@ function extractXywhFromRawTarget(target) {
|
|
|
255
294
|
/**
|
|
256
295
|
* Extract annotation body content (text, label, etc)
|
|
257
296
|
*/
|
|
258
|
-
function extractBody(annotation) {
|
|
259
|
-
|
|
260
|
-
let isHtml = false;
|
|
297
|
+
export function extractBody(annotation) {
|
|
298
|
+
const bodies = [];
|
|
261
299
|
// Try Manifesto getBody method
|
|
262
300
|
if (typeof annotation.getBody === 'function') {
|
|
263
301
|
const body = annotation.getBody();
|
|
264
|
-
if (body
|
|
265
|
-
const
|
|
266
|
-
for (const b of
|
|
302
|
+
if (body) {
|
|
303
|
+
const bodyArr = Array.isArray(body) ? body : [body];
|
|
304
|
+
for (const b of bodyArr) {
|
|
267
305
|
const val = b.getValue ? b.getValue() : '';
|
|
268
306
|
if (val) {
|
|
269
|
-
values.push(val);
|
|
270
307
|
const format = b.getFormat ? b.getFormat() : '';
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
308
|
+
const purpose = b.getPurpose ? b.getPurpose() : undefined;
|
|
309
|
+
bodies.push({
|
|
310
|
+
value: val,
|
|
311
|
+
isHtml: format === 'text/html' ||
|
|
312
|
+
format === 'application/html',
|
|
313
|
+
purpose: purpose,
|
|
314
|
+
format: format,
|
|
315
|
+
});
|
|
274
316
|
}
|
|
275
317
|
}
|
|
276
|
-
value = values.join(' ');
|
|
277
318
|
}
|
|
278
319
|
}
|
|
279
320
|
else {
|
|
280
321
|
// Handle raw JSON body/resource
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
322
|
+
const processResource = (r) => {
|
|
323
|
+
const val = r.chars || r.value || r['cnt:chars'] || '';
|
|
324
|
+
if (val) {
|
|
325
|
+
const isHtml = r.format === 'text/html' || r.type === 'TextualBody';
|
|
326
|
+
bodies.push({
|
|
327
|
+
value: val,
|
|
328
|
+
isHtml,
|
|
329
|
+
purpose: r.purpose,
|
|
330
|
+
format: r.format,
|
|
331
|
+
});
|
|
332
|
+
}
|
|
290
333
|
};
|
|
291
334
|
if (annotation.resource) {
|
|
292
|
-
const resources = Array.isArray(annotation.resource)
|
|
293
|
-
|
|
294
|
-
|
|
335
|
+
const resources = Array.isArray(annotation.resource)
|
|
336
|
+
? annotation.resource
|
|
337
|
+
: [annotation.resource];
|
|
338
|
+
resources.forEach(processResource);
|
|
295
339
|
}
|
|
296
340
|
else if (annotation.body) {
|
|
297
|
-
const bodyArr = Array.isArray(annotation.body)
|
|
298
|
-
|
|
299
|
-
|
|
341
|
+
const bodyArr = Array.isArray(annotation.body)
|
|
342
|
+
? annotation.body
|
|
343
|
+
: [annotation.body];
|
|
344
|
+
bodyArr.forEach(processResource);
|
|
300
345
|
}
|
|
301
346
|
}
|
|
302
|
-
//
|
|
303
|
-
if (
|
|
347
|
+
// fallback for label if no bodies found
|
|
348
|
+
if (bodies.length === 0) {
|
|
349
|
+
let value = '';
|
|
304
350
|
if (typeof annotation.getLabel === 'function') {
|
|
305
351
|
value = annotation.getLabel() || '';
|
|
306
352
|
}
|
|
307
353
|
else if (annotation.label) {
|
|
308
|
-
value = Array.isArray(annotation.label)
|
|
354
|
+
value = Array.isArray(annotation.label)
|
|
355
|
+
? annotation.label.join(' ')
|
|
356
|
+
: annotation.label;
|
|
309
357
|
}
|
|
358
|
+
if (value) {
|
|
359
|
+
bodies.push({ value, isHtml: false, purpose: 'commenting' });
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
// Default if still nothing
|
|
363
|
+
if (bodies.length === 0) {
|
|
364
|
+
bodies.push({
|
|
365
|
+
value: 'Annotation',
|
|
366
|
+
isHtml: false,
|
|
367
|
+
purpose: 'commenting',
|
|
368
|
+
});
|
|
310
369
|
}
|
|
311
|
-
return
|
|
370
|
+
return bodies;
|
|
312
371
|
}
|
|
313
372
|
/**
|
|
314
373
|
* Parse Manifesto/IIIF annotation to internal format
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "triiiceratops",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,10 +31,14 @@
|
|
|
31
31
|
"svelte": "./dist/plugins/image-manipulation.js",
|
|
32
32
|
"import": "./dist/plugins/image-manipulation.js"
|
|
33
33
|
},
|
|
34
|
-
"./
|
|
35
|
-
"
|
|
34
|
+
"./plugins/annotation-editor": {
|
|
35
|
+
"types": "./dist/plugins/annotation-editor/index.d.ts",
|
|
36
|
+
"svelte": "./dist/plugins/annotation-editor.js",
|
|
37
|
+
"import": "./dist/plugins/annotation-editor.js"
|
|
36
38
|
},
|
|
37
|
-
"./element
|
|
39
|
+
"./element": "./dist/triiiceratops-element.iife.js",
|
|
40
|
+
"./plugins/image-manipulation.iife": "./dist/triiiceratops-plugin-image-manipulation.iife.js",
|
|
41
|
+
"./plugins/annotation-editor.iife": "./dist/triiiceratops-plugin-annotation-editor.iife.js",
|
|
38
42
|
"./style.css": "./dist/triiiceratops.css"
|
|
39
43
|
},
|
|
40
44
|
"peerDependencies": {
|
|
@@ -68,6 +72,8 @@
|
|
|
68
72
|
"vitest": "^4.0.15"
|
|
69
73
|
},
|
|
70
74
|
"dependencies": {
|
|
75
|
+
"@annotorious/annotorious": "^3.7.19",
|
|
76
|
+
"@annotorious/openseadragon": "^3.7.19",
|
|
71
77
|
"@tailwindcss/vite": "^4.1.17",
|
|
72
78
|
"daisyui": "^5.5.8",
|
|
73
79
|
"manifesto.js": "^4.3.0",
|
|
@@ -81,8 +87,9 @@
|
|
|
81
87
|
"build:lib": "paraglide-js compile --project ./project.inlang --outdir ./src/lib/paraglide && svelte-package --tsconfig ./tsconfig.app.json && rm -f dist/paraglide/.gitignore dist/paraglide/.prettierignore && vite build --config vite.config.lib.ts",
|
|
82
88
|
"build:element": "vite build --config vite.config.element.ts",
|
|
83
89
|
"build:demo": "vite build --config vite.config.demo.ts",
|
|
84
|
-
"build:consumer": "
|
|
85
|
-
"build:
|
|
90
|
+
"build:consumer": "rm -rf docs/demo-consumer && mkdir -p docs/demo-consumer && cp src/demo-consumer/index.html docs/demo-consumer/index.html && cp src/demo-consumer/app.css docs/demo-consumer/app.css && rm -rf docs/dist && cp -r dist docs/dist",
|
|
91
|
+
"build:plugins-iife": "PLUGIN_NAME=image-manipulation vite build --config vite.config.plugins-iife.ts && PLUGIN_NAME=annotation-editor vite build --config vite.config.plugins-iife.ts",
|
|
92
|
+
"build:all": "pnpm build:lib && pnpm build:element && pnpm build:plugins-iife && pnpm build:demo && pnpm build:consumer",
|
|
86
93
|
"preview": "vite preview",
|
|
87
94
|
"dev:consumer": "vite --config vite.config.demo-consumer.ts",
|
|
88
95
|
"check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json",
|