Skip to content

Commit

Permalink
Merge pull request #124 from recogito/develop
Browse files Browse the repository at this point in the history
Merge develop into main
  • Loading branch information
lwjameson authored Jan 19, 2024
2 parents 258ec03 + f6984d4 commit 366a897
Show file tree
Hide file tree
Showing 164 changed files with 4,860 additions and 2,532 deletions.
8 changes: 8 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ export default defineConfig({
ssr: {
noExternal: ['@radix-ui/*', '@phosphor-icons/*'],
},
resolve: {
mainFields: [] // react-moment fails without this!
},
optimizeDeps: {
esbuildOptions: {
target: 'esnext'
}
}
},
});
10 changes: 5 additions & 5 deletions astro.config.node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export default defineConfig({
integrations: [react()],
output: 'server',
adapter: node({
mode: 'standalone'
mode: 'standalone',
}),
vite: {
ssr: {
noExternal: ['@radix-ui/*', '@phosphor-icons/*']
}
}
});
noExternal: ['@radix-ui/*', '@phosphor-icons/*'],
},
},
});
1,458 changes: 680 additions & 778 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"start": "astro dev --host",
"build": "astro build",
"build-node": "astro build --config astro.config.node.mjs",
"preview-node": "node ./dist/server/entry.mjs",
"astro": "astro"
},
"dependencies": {
"@annotorious/react": "^3.0.0-rc.1",
"@annotorious/react": "^3.0.0-rc.18",
"@astrojs/netlify": "^2.2.3",
"@astrojs/node": "^5.3.3",
"@astrojs/react": "^2.2.0",
"@emotion/react": "^11.11.1",
"@phosphor-icons/react": "^2.0.9",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-avatar": "^1.0.3",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.4",
Expand All @@ -27,10 +28,11 @@
"@radix-ui/react-select": "^1.2.2",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.3",
"@radix-ui/react-tooltip": "^1.0.7",
"@react-spring/web": "^9.7.3",
"@recogito/annotorious-supabase": "^3.0.0-rc.1",
"@recogito/react-pdf-annotator": "^0.1.0",
"@recogito/react-text-annotator": "^3.0.0-rc.1",
"@recogito/annotorious-supabase": "^3.0.0-rc.7",
"@recogito/react-pdf-annotator": "1.0.0-rc.7",
"@recogito/react-text-annotator": "^3.0.0-rc.10",
"@supabase/auth-helpers-shared": "^0.3.4",
"@supabase/supabase-js": "^2.32.0",
"@table-library/react-table-library": "^4.1.7",
Expand All @@ -46,13 +48,15 @@
"eslint-plugin-react": "^7.33.2",
"formik": "^2.4.1",
"linkedom": "^0.15.6",
"moment": "^2.29.4",
"openseadragon": "^3.1.0",
"papaparse": "^5.4.1",
"quill": "^1.3.7",
"react": "^18.2.0",
"react-contenteditable": "^3.3.7",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-moment": "^1.1.3",
"react-quill": "^2.0.0",
"react-textarea-autosize": "^8.4.1",
"timeago-react": "^3.0.6",
Expand Down
34 changes: 32 additions & 2 deletions src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export interface Group {

name: string;

is_admin: boolean;

is_default: boolean;

members: Array<{
user: UserProfile;

Expand Down Expand Up @@ -121,15 +125,25 @@ export interface Document {

content_type?: ContentType;

is_private: boolean;

collection_id?: string;

meta_data?: {
protocol: Protocol;

url: string;

meta?: object;
meta?: {
author?: string;
};
};
}

collection_metadata?: {
revision_number: number;
document_id: string;
};
}
export interface DocumentInContext extends Document {
layers: Layer[];
}
Expand Down Expand Up @@ -201,6 +215,10 @@ export interface ExtendedAssignmentData extends Context {

description?: string;

is_admin: boolean;

is_default: boolean;

members: Array<{
user: UserProfile;

Expand Down Expand Up @@ -285,3 +303,15 @@ export type LoginMethod = {
type: 'username_password' | 'saml' | 'oauth' | 'magic_link' | 'keycloak';
domain: string;
};

export type Collection = {
created_at?: string;
created_by?: string;
updated_at?: string;
updated_by?: string;
id: string;
name: string;
extension_id?: string;
extension_metadata?: object;
custom_css?: string;
};
5 changes: 5 additions & 0 deletions src/apps/annotation-image/ImageAnnotationDesktop.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
@import '@annotorious/react/annotorious-react.css';

.ia-desktop {
height: 100%;
width: 100%;
}

.ia-osd-container {
height: 100%;
position: relative;
Expand Down
39 changes: 27 additions & 12 deletions src/apps/annotation-image/ImageAnnotationDesktop.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { useEffect, useMemo, useState } from 'react';
import type { Layer } from 'src/Types';
import type OpenSeadragon from 'openseadragon';
import { getAllDocumentLayersInProject, isDefaultContext } from '@backend/helpers';
import { useLayerPolicies, useTagVocabulary } from '@backend/hooks';
import { supabase } from '@backend/supabaseBrowserClient';
import { Annotation } from '@components/Annotation';
import { LoadingOverlay } from '@components/LoadingOverlay';
import { createAppearenceProvider, PresenceStack } from '@components/Presence';
import { AnnotationDesktop, ViewMenuPanel } from '@components/AnnotationDesktop';
import type { PrivacyMode } from '@components/PrivacySelector';
import { SupabasePlugin } from '@components/SupabasePlugin';
import type { Layer } from 'src/Types';
import { Toolbar } from './Toolbar';
import type { ImageAnnotationProps } from './ImageAnnotation';
import {
Expand Down Expand Up @@ -38,6 +40,8 @@ export const ImageAnnotationDesktop = (props: ImageAnnotationProps) => {

const policies = useLayerPolicies(props.document.layers[0].id);

const [loading, setLoading] = useState(true);

const [present, setPresent] = useState<PresentUser[]>([]);

const [tool, setTool] = useState<string>('rectangle');
Expand All @@ -46,6 +50,8 @@ export const ImageAnnotationDesktop = (props: ImageAnnotationProps) => {

const [style, setStyle] = useState<((a: Anno) => DrawingStyle) | undefined>(undefined);

const [filter, setFilter] = useState<((a: Anno) => boolean) | undefined>(undefined);

const [usePopup, setUsePopup] = useState(true);

const [privacy, setPrivacy] = useState<PrivacyMode>('PUBLIC');
Expand Down Expand Up @@ -87,8 +93,6 @@ export const ImageAnnotationDesktop = (props: ImageAnnotationProps) => {
window.location.href = `/${props.i18n.lang}/sign-in`;

const onChangeTool = (tool: string | null) => {
console.log('changing tool');

if (tool) {
if (!drawingEnabled) setDrawingEnabled(true);
setTool(tool);
Expand Down Expand Up @@ -129,15 +133,31 @@ export const ImageAnnotationDesktop = (props: ImageAnnotationProps) => {
return canEdit ? PointerSelectAction.EDIT : PointerSelectAction.SELECT;
}

// TODO since Annotorious 3.0.0-rc.2 this needs to be
// memo-ized which is a pain - need to fix this inside
// Annotorious!
const options: OpenSeadragon.Options = useMemo(() => ({
tileSources: props.document.meta_data?.url,
gestureSettingsMouse: {
clickToZoom: false
},
showNavigationControl: false,
crossOriginPolicy: 'Anonymous'
}), [props.document.meta_data?.url]);

return (
<div className="anno-desktop ia-desktop">
{loading && (
<LoadingOverlay />
)}

{policies && (
<OpenSeadragonAnnotator
autoSave
drawingMode="click"
drawingEnabled={drawingEnabled}
pointerSelectAction={selectAction}
tool={tool}
filter={filter}
style={style}>

<AnnotationDesktop.UndoStack
Expand All @@ -151,21 +171,15 @@ export const ImageAnnotationDesktop = (props: ImageAnnotationProps) => {
defaultLayer={defaultLayer?.id}
layerIds={layers.map(layer => layer.id)}
appearanceProvider={appearance}
onInitialLoad={() => setLoading(false)}
onPresence={setPresent}
onConnectError={onConnectError}
privacyMode={privacy === 'PRIVATE'} />
}

<OpenSeadragonViewer
className="ia-osd-container"
options={{
tileSources: props.document.meta_data?.url,
gestureSettingsMouse: {
clickToZoom: false
},
showNavigationControl: false,
crossOriginPolicy: 'Anonymous'
}} />
options={options} />

{usePopup && (
<OpenSeadragonPopup
Expand Down Expand Up @@ -197,6 +211,7 @@ export const ImageAnnotationDesktop = (props: ImageAnnotationProps) => {
channel={props.channelId}
tagVocabulary={vocabulary}
onChangePanel={onChangeViewMenuPanel}
onChangeAnnotationFilter={f => setFilter(() => f)}
onChangeAnnotationStyle={s => setStyle(() => s)}
beforeSelectAnnotation={beforeSelectAnnotation} />
</div>
Expand Down
Loading

0 comments on commit 366a897

Please sign in to comment.