Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mirador annotations
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Loïs Poujade
Mirador annotations
Commits
bfedb5b8
Commit
bfedb5b8
authored
May 8, 2020
by
Jack Reed
Browse files
Options
Downloads
Patches
Plain Diff
Breakout WebAnnotation model
parent
930e6211
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
demo/src/index.js
+4
-0
4 additions, 0 deletions
demo/src/index.js
src/AnnotationCreation.js
+10
-11
10 additions, 11 deletions
src/AnnotationCreation.js
src/WebAnnotation.js
+45
-0
45 additions, 0 deletions
src/WebAnnotation.js
with
59 additions
and
11 deletions
demo/src/index.js
+
4
−
0
View file @
bfedb5b8
...
@@ -9,6 +9,10 @@ const config = {
...
@@ -9,6 +9,10 @@ const config = {
adapter
:
(
canvasId
)
=>
new
LocalStorageAdapter
(
`localStorage://?canvasId=
${
canvasId
}
`
),
adapter
:
(
canvasId
)
=>
new
LocalStorageAdapter
(
`localStorage://?canvasId=
${
canvasId
}
`
),
},
},
id
:
'
demo
'
,
id
:
'
demo
'
,
window
:
{
defaultSideBarPanel
:
'
annotations
'
,
sideBarOpenByDefault
:
true
,
},
windows
:
[{
windows
:
[{
loadedManifest
:
'
https://iiif.harvardartmuseums.org/manifests/object/299843
'
,
loadedManifest
:
'
https://iiif.harvardartmuseums.org/manifests/object/299843
'
,
}],
}],
...
...
This diff is collapsed.
Click to expand it.
src/AnnotationCreation.js
+
10
−
11
View file @
bfedb5b8
...
@@ -10,6 +10,7 @@ import { v4 as uuid } from 'uuid';
...
@@ -10,6 +10,7 @@ import { v4 as uuid } from 'uuid';
import
{
PaperContainer
}
from
'
@psychobolt/react-paperjs
'
;
import
{
PaperContainer
}
from
'
@psychobolt/react-paperjs
'
;
import
{
RectangleTool
}
from
'
@psychobolt/react-paperjs-editor
'
;
import
{
RectangleTool
}
from
'
@psychobolt/react-paperjs-editor
'
;
import
OpenSeadragon
from
'
openseadragon
'
;
import
OpenSeadragon
from
'
openseadragon
'
;
import
WebAnnotation
from
'
./WebAnnotation
'
;
/** */
/** */
class
AnnotationCreation
extends
Component
{
class
AnnotationCreation
extends
Component
{
/** */
/** */
...
@@ -40,17 +41,12 @@ class AnnotationCreation extends Component {
...
@@ -40,17 +41,12 @@ class AnnotationCreation extends Component {
canvases
.
forEach
((
canvas
)
=>
{
canvases
.
forEach
((
canvas
)
=>
{
const
localStorageAdapter
=
config
.
annotation
.
adapter
(
canvas
.
id
);
const
localStorageAdapter
=
config
.
annotation
.
adapter
(
canvas
.
id
);
const
anno
=
{
const
anno
=
new
WebAnnotation
({
body
:
{
body
:
annoBody
,
language
:
'
en
'
,
canvasId
:
canvas
.
id
,
type
:
'
TextualBody
'
,
value
:
annoBody
,
},
id
:
`https://example.org/iiif/book1/page/manifest/
${
uuid
()}
`
,
id
:
`https://example.org/iiif/book1/page/manifest/
${
uuid
()}
`
,
motivation
:
'
commenting
'
,
xywh
,
target
:
`
${
canvas
.
id
}
#xywh=
${
xywh
}
`
,
}).
toJson
();
type
:
'
Annotation
'
,
};
const
newAnnoPage
=
localStorageAdapter
.
create
(
anno
);
const
newAnnoPage
=
localStorageAdapter
.
create
(
anno
);
receiveAnnotation
(
canvas
.
id
,
localStorageAdapter
.
annotationPageId
,
newAnnoPage
);
receiveAnnotation
(
canvas
.
id
,
localStorageAdapter
.
annotationPageId
,
newAnnoPage
);
});
});
...
@@ -73,13 +69,16 @@ class AnnotationCreation extends Component {
...
@@ -73,13 +69,16 @@ class AnnotationCreation extends Component {
/** */
/** */
addPath
(
path
)
{
addPath
(
path
)
{
//
console.log(path);
console
.
log
(
path
);
const
{
bounds
}
=
path
;
const
{
bounds
}
=
path
;
const
{
const
{
x
,
y
,
width
,
height
,
x
,
y
,
width
,
height
,
}
=
bounds
;
}
=
bounds
;
const
point1
=
new
OpenSeadragon
.
Point
(
x
,
y
);
const
point1
=
new
OpenSeadragon
.
Point
(
x
,
y
);
const
point2
=
new
OpenSeadragon
.
Point
(
x
+
width
,
y
+
height
);
const
point2
=
new
OpenSeadragon
.
Point
(
x
+
width
,
y
+
height
);
const
osdBounds
=
this
.
OSDReference
.
viewer
.
viewport
.
getBoundsNoRotate
();
console
.
log
(
osdBounds
);
console
.
log
(
path
.
project
.
view
.
bounds
);
const
viewportPoint1
=
this
.
OSDReference
.
viewer
.
viewport
.
pointFromPixel
(
point1
);
const
viewportPoint1
=
this
.
OSDReference
.
viewer
.
viewport
.
pointFromPixel
(
point1
);
const
viewportPoint2
=
this
.
OSDReference
.
viewer
.
viewport
.
pointFromPixel
(
point2
);
const
viewportPoint2
=
this
.
OSDReference
.
viewer
.
viewport
.
pointFromPixel
(
point2
);
const
viewportWidth
=
viewportPoint2
.
x
-
viewportPoint1
.
x
;
const
viewportWidth
=
viewportPoint2
.
x
-
viewportPoint1
.
x
;
...
...
This diff is collapsed.
Click to expand it.
src/WebAnnotation.js
0 → 100644
+
45
−
0
View file @
bfedb5b8
/** */
export
default
class
WebAnnotation
{
/** */
constructor
({
canvasId
,
id
,
xywh
,
body
,
svg
,
})
{
this
.
id
=
id
;
this
.
canvasId
=
canvasId
;
this
.
xywh
=
xywh
;
this
.
body
=
body
;
this
.
svg
=
svg
;
}
/** */
toJson
()
{
return
{
body
:
{
language
:
'
en
'
,
type
:
'
TextualBody
'
,
value
:
this
.
body
,
},
id
:
this
.
id
,
motivation
:
'
commenting
'
,
target
:
this
.
target
(),
type
:
'
Annotation
'
,
};
}
/** */
target
()
{
let
target
=
this
.
canvasId
;
if
(
this
.
svg
)
{
target
=
{};
target
.
selector
=
{
type
:
'
SvgSelector
'
,
value
:
this
.
svg
,
};
return
target
;
}
if
(
this
.
xywh
)
{
target
+=
`#xywh=
${
this
.
xywh
}
`
;
}
return
target
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment