-
Notifications
You must be signed in to change notification settings - Fork 33
0599 Drag and Drop #647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
triplingual
wants to merge
7
commits into
master
Choose a base branch
from
0599-drag-and-drop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
0599 Drag and Drop #647
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c10de71
Started with the barest of possibly workable content ➕
triplingual 251105e
Switched to use IIIF icon for tractable CORS troubleshooting 🔀🖼️
triplingual 9359dbe
Added drag-and-drop recipe to links and ToC 📝
triplingual c2872dd
Extremely rough draft of a use case 📝
triplingual 4d30998
Started restrictions, rolled back draggable image 📝🖼️
triplingual c474dce
Added `JSON.stringify()` per @glenrobson ✨
triplingual b3bf320
Moved restriction text ➡️ implementation and drafted new restriction …
triplingual File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,53 @@ | ||
| --- | ||
| title: Name of Recipe | ||
| id: -1 | ||
| layout: recipe | ||
| tags: [tbc] | ||
| summary: "tbc" | ||
| viewers: | ||
| topic: | ||
| - basic | ||
| --- | ||
|
|
||
| ## Use Case | ||
|
|
||
| As a person wanting to annotate a IIIF resource, you would like to open a manifest in a viewer not present or available in the web interface where you first find the resource. | ||
|
|
||
| ## Implementation Notes | ||
|
|
||
| Implementing this recipe requires a resource provider and a viewer provider each to implement their part. The resource provider must have a draggable item that can have a `dataTransfer.setData` method attached to the item's `dragstart` event and the viewer provider must have an interface capable of handling the data in its `drop` event. | ||
|
|
||
| ## Restrictions | ||
|
|
||
| Because implementation is two-part, you may only have control over one half of the ability to drag and drop. Consequently, and since this action is only in a GUI environment, you will need to consider whether visitors to your IIIF interface would benefit from some kind of support text. | ||
|
|
||
| ## Example | ||
|
|
||
| Describe the solution in prose and provide an example. | ||
| The example json document must be an external document, and imported with the following: | ||
|
|
||
| {% include manifest_links.html viewers="" manifest="manifest.json" %} | ||
|
|
||
| <img src="https://iiif.io/api/cookbook/assets/images/logos/logo-sm.png" draggable="true" ondragstart="drag(event)" alt="IIIF logo; drag and drop onto a supporting viewer to see this resource in that viewer"> | ||
|
|
||
| <script> | ||
| function drag(ev) { | ||
| ev.dataTransfer.setData("text/plain", JSON.stringify({ | ||
| "@context": "http://iiif.io/api/presentation/3/context.json", | ||
| "id": "https://example.org/content-states/1", | ||
| "type": "Annotation", | ||
| "motivation": ["contentState"], | ||
| "target": { | ||
| "id": "https://iiif.io/api/cookbook/recipe/0006-text-language/manifest.json", | ||
| "type": "Manifest" | ||
| } | ||
| })); | ||
| } | ||
| </script> | ||
|
|
||
| ## Related Recipes | ||
|
|
||
| Provide a bulleted list of related recipes and why they are relevant. | ||
|
|
||
| {% include acronyms.md %} | ||
| {% include links.md %} | ||
This file contains hidden or 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,54 @@ | ||
| { | ||
| "@context": "http://iiif.io/api/presentation/3/context.json", | ||
| "id": "{{ id.url }}", | ||
| "type": "Manifest", | ||
| "label": { "en": [ "Visible Text Annotation" ] }, | ||
| "items": [ | ||
| { | ||
| "id": "{{ id.path }}/canvas", | ||
| "type": "Canvas", | ||
| "height": 31722, | ||
| "width": 70399, | ||
| "items": [ | ||
| { | ||
| "id": "{{ id.path }}/page/p1/1", | ||
| "type": "AnnotationPage", | ||
| "items": [ | ||
| { | ||
| "id": "{{ id.path }}/annotation/p0001-image", | ||
| "type": "Annotation", | ||
| "motivation": "painting", | ||
| "body": { | ||
| "id": "https://iiif.io/api/image/3.0/example/reference/36ca0a3370db128ec984b33d71a1543d-100320001004/full/max/0/default.jpg", | ||
| "type": "Image", | ||
| "format": "image/jpeg", | ||
| "height": 31722, | ||
| "width": 70399, | ||
| "service": [ | ||
| { | ||
| "id": "https://iiif.io/api/image/3.0/example/reference/36ca0a3370db128ec984b33d71a1543d-100320001004", | ||
| "profile": "level1", | ||
| "type": "ImageService3" | ||
| } | ||
| ] | ||
| }, | ||
| "target": "{{ id.path }}/canvas" | ||
| }, | ||
| { | ||
| "id": "{{ id.path }}/annotation/p0001-text", | ||
| "type": "Annotation", | ||
| "motivation": "painting", | ||
| "body": { | ||
| "type": "TextualBody", | ||
| "format": "text/html", | ||
| "value": "<p style='font-size:1000px; background-color: rgba(16, 16, 16, 0.5); padding:300px'>The koto is to the right, carried in a cloth wrapping.</p>", | ||
| "language": "en" | ||
| }, | ||
| "target": "{{ id.path }}/canvas#xywh=5500,12200,8000,5000" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was testing this with my demo site: https://iiif.gdmrdigital.com/import_to_viewers/DragDropDestination.html to see if I could get it working. I had to make an update as you set the data type as text/plain which I think is correct but my app didn't use that value so that should be fixed now.
The other issue I came across is that I think dataTransfer only transfers Strings so when you put the JSON in as the data it converts it to a string of
object [object]and you loose the data. I think you need to wrap that inJSON.stringify()to ensure the annotation is converted into a String before passing it .There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I was starting with the bits from that Slack conversation, so I'm happy to get updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logo image has disappeared
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand, when I drag from the recipe in progress I get a strange error in the browser tools:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://newspapers.library.wales/iiif/2.0/image/3412218/info.json. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 403.Even though the manifest in the script in the recipe is https://iiif.io/api/cookbook/recipe/0006-text-language/manifest.json, not the Wales library one.