-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from recogito/develop
Merge develop into main for new release
- Loading branch information
Showing
201 changed files
with
6,317 additions
and
2,254 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
src/apps/annotation-image/AnnotatedImage/AnnotatedImage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
import { forwardRef, useMemo, useState } from 'react'; | ||
import type OpenSeadragon from 'openseadragon'; | ||
import { Annotation } from '@components/Annotation'; | ||
import { UndoStack } from '@components/AnnotationDesktop'; | ||
import { createAppearenceProvider } from '@components/Presence'; | ||
import type { PrivacyMode } from '@components/PrivacySelector'; | ||
import { SupabasePlugin } from '@components/SupabasePlugin'; | ||
import type { DocumentInTaggedContext, Layer, Policies, Translations } from 'src/Types'; | ||
import { Toolpanel } from '../Toolpanel'; | ||
import { | ||
AnnotoriousOpenSeadragonAnnotator, | ||
DrawingStyle, | ||
ImageAnnotation, | ||
OpenSeadragonAnnotator, | ||
OpenSeadragonPopup, | ||
OpenSeadragonViewer, | ||
PointerSelectAction, | ||
PresentUser, | ||
useAnnotator | ||
} from '@annotorious/react'; | ||
|
||
const SUPABASE: string = import.meta.env.PUBLIC_SUPABASE; | ||
|
||
const SUPABASE_API_KEY: string = import.meta.env.PUBLIC_SUPABASE_API_KEY; | ||
|
||
interface AnnotatedImageProps { | ||
|
||
channelId: string; | ||
|
||
defaultLayer?: Layer; | ||
|
||
imageManifestURL: string; | ||
|
||
isPresentationManifest?: boolean; | ||
|
||
filter?: (a: ImageAnnotation) => boolean; | ||
|
||
i18n: Translations; | ||
|
||
layers?: Layer[]; | ||
|
||
policies: Policies; | ||
|
||
present: PresentUser[]; | ||
|
||
style?: (a: ImageAnnotation) => DrawingStyle; | ||
|
||
tagVocabulary: string[]; | ||
|
||
usePopup: boolean; | ||
|
||
onChangePresent(present: PresentUser[]): void; | ||
|
||
onConnectionError(): void; | ||
|
||
onSaveError(): void; | ||
|
||
onLoad(): void; | ||
|
||
} | ||
|
||
export const AnnotatedImage = forwardRef<OpenSeadragon.Viewer, AnnotatedImageProps>((props, ref) => { | ||
|
||
const { i18n, policies, present, tagVocabulary } = props; | ||
|
||
const anno = useAnnotator<AnnotoriousOpenSeadragonAnnotator>(); | ||
|
||
const [drawingEnabled, setDrawingEnabled] = useState(false); | ||
|
||
const [tool, setTool] = useState<string>('rectangle'); | ||
|
||
const [privacy, setPrivacy] = useState<PrivacyMode>('PUBLIC'); | ||
|
||
const appearance = useMemo(() => createAppearenceProvider(), []); | ||
|
||
const options: OpenSeadragon.Options = useMemo(() => ({ | ||
tileSources: props.imageManifestURL, | ||
gestureSettingsMouse: { | ||
clickToZoom: false | ||
}, | ||
showNavigationControl: false, | ||
crossOriginPolicy: 'Anonymous', | ||
minZoomLevel: 0.4, | ||
visibilityRatio: 0.2, | ||
preserveImageSizeOnResize: true | ||
}), [props.imageManifestURL]); | ||
|
||
const selectAction = (annotation: ImageAnnotation) => { | ||
// Annotation targets are editable for creators and admins | ||
const me = anno?.getUser()?.id; | ||
|
||
const canEdit = annotation.target.creator?.id === me || | ||
policies.get('layers').has('INSERT'); | ||
|
||
return canEdit ? PointerSelectAction.EDIT : PointerSelectAction.SELECT; | ||
} | ||
|
||
const onChangeTool = (tool: string | null) => { | ||
if (tool) { | ||
if (!drawingEnabled) setDrawingEnabled(true); | ||
setTool(tool); | ||
} else { | ||
setDrawingEnabled(false); | ||
} | ||
} | ||
|
||
return ( | ||
<OpenSeadragonAnnotator | ||
autoSave | ||
drawingEnabled={drawingEnabled} | ||
pointerSelectAction={selectAction} | ||
tool={tool} | ||
filter={props.filter} | ||
style={props.style}> | ||
|
||
<UndoStack | ||
undoEmpty={true} /> | ||
|
||
{props.layers && | ||
<SupabasePlugin | ||
supabaseUrl={SUPABASE} | ||
apiKey={SUPABASE_API_KEY} | ||
channel={props.channelId} | ||
defaultLayer={props.defaultLayer?.id} | ||
layerIds={props.layers.map(layer => layer.id)} | ||
appearanceProvider={appearance} | ||
privacyMode={privacy === 'PRIVATE'} | ||
source={props.isPresentationManifest ? props.imageManifestURL : undefined} | ||
onInitialLoad={props.onLoad} | ||
onPresence={props.onChangePresent} | ||
onConnectError={props.onConnectionError} | ||
onInitialLoadError={props.onConnectionError} | ||
onSaveError={props.onSaveError} /> | ||
} | ||
|
||
<OpenSeadragonViewer | ||
ref={ref} | ||
className="ia-osd-container" | ||
options={options} /> | ||
|
||
{props.usePopup && ( | ||
<OpenSeadragonPopup | ||
popup ={props => ( | ||
<Annotation.Popup | ||
{...props} | ||
i18n={i18n} | ||
policies={policies} | ||
present={present} | ||
tagVocabulary={tagVocabulary} /> )} /> | ||
)} | ||
|
||
<Toolpanel | ||
i18n={i18n} | ||
isAdmin={policies.get('layers').has('INSERT')} | ||
privacy={privacy} | ||
onChangeTool={onChangeTool} | ||
onChangePrivacy={setPrivacy} /> | ||
</OpenSeadragonAnnotator> | ||
) | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './AnnotatedImage'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { Resource } from 'manifesto.js'; | ||
|
||
interface IIIFThumnailProps { | ||
|
||
image: Resource; | ||
|
||
} | ||
|
||
export const IIIFThumbnail = (props: IIIFThumnailProps) => { | ||
|
||
const src = `${props.image.getServices()[0].id}/full/120,/0/default.jpg`; | ||
|
||
return ( | ||
<div className="thumbnail-wrapper"> | ||
<div className="thumbnail"> | ||
<img src={src} /> | ||
</div> | ||
</div> | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.ia-thumbnail-strip .thumbnail-strip-item { | ||
align-items: center; | ||
display: flex; | ||
flex-direction: column; | ||
font-size: var(--font-tiny); | ||
} | ||
|
||
.ia-thumbnail-strip .thumbnail-wrapper { | ||
box-sizing: border-box; | ||
cursor: pointer; | ||
display: flex; | ||
justify-content: center; | ||
padding: 10px 10px 0px 10px; | ||
width: 100%; | ||
} | ||
|
||
.ia-thumbnail-strip .thumbnail-strip-item .label { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
|
||
.ia-thumbnail-strip .thumbnail { | ||
padding: 3px; | ||
border-radius: calc(var(--border-radius) + 5px); | ||
} | ||
|
||
.ia-thumbnail-strip .thumbnail-strip-item.selected .thumbnail { | ||
background-color: var(--brighter-blue); | ||
} | ||
|
||
.ia-thumbnail-strip .thumbnail:hover { | ||
background-color: var(--gray-300); | ||
} | ||
|
||
.ia-thumbnail-strip .thumbnail img { | ||
border: 2px solid #fff; | ||
border-radius: calc(var(--border-radius) + 3px); | ||
display: block; | ||
height: 120px; | ||
object-fit: cover; | ||
width: 120px; | ||
} |
Oops, something went wrong.