diff --git a/src/CanvasListItem.js b/src/CanvasListItem.js index e2e5bd1e6a6f9fa5e8b1f1cd233cad263da1f538..085b778b809f65dc3da9932036ba84a68cbf8bb5 100644 --- a/src/CanvasListItem.js +++ b/src/CanvasListItem.js @@ -84,8 +84,11 @@ class CanvasListItem extends Component { /** */ handleOpenOtherManifest(manifestId) { console.log('Opening TODO'); - let result = actions.addResource(manifestId); - console.log(result); + const { + addResource, + } = this.context; + + addResource('https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/manifest.json'); } /** */ @@ -154,8 +157,12 @@ class CanvasListItem extends Component { <div> {manifests.length > 0 && manifests.map((o) => ( - <button value={o} onClick={(e) => this.handleOpenOtherManifest(e.target.value)}> Ouvrir {o} </button>)) - } + <button value={o} onClick={(e) => this.handleOpenOtherManifest(e.target.value)}> + {' '} + Ouvrir + {o} + </button> + ))} </div> </div> @@ -169,6 +176,7 @@ CanvasListItem.propTypes = { PropTypes.func, PropTypes.node, ]).isRequired, + }; CanvasListItem.contextType = AnnotationActionsContext; diff --git a/src/plugins/canvasAnnotationsPlugin.js b/src/plugins/canvasAnnotationsPlugin.js index 9102709e50af23b914af0843aa28b7a5bd71998e..ba4724d8d48fcb4d5fae12f62fde6958ff04ca01 100644 --- a/src/plugins/canvasAnnotationsPlugin.js +++ b/src/plugins/canvasAnnotationsPlugin.js @@ -30,7 +30,7 @@ class CanvasAnnotationsWrapper extends Component { render() { const { addCompanionWindow, annotationsOnCanvases, canvases, config, receiveAnnotation, - switchToSingleCanvasView, TargetComponent, targetProps, windowViewType, + switchToSingleCanvasView, TargetComponent, targetProps, windowViewType, addResource } = this.props; const { singleCanvasDialogOpen } = this.state; const props = { @@ -41,6 +41,7 @@ class CanvasAnnotationsWrapper extends Component { <AnnotationActionsContext.Provider value={{ addCompanionWindow, + addResource, annotationsOnCanvases, canvases, config, @@ -68,6 +69,7 @@ class CanvasAnnotationsWrapper extends Component { CanvasAnnotationsWrapper.propTypes = { addCompanionWindow: PropTypes.func.isRequired, + addResource: PropTypes.func.isRequired, annotationsOnCanvases: PropTypes.object, // eslint-disable-line react/forbid-prop-types canvases: PropTypes.arrayOf( PropTypes.shape({ id: PropTypes.string, index: PropTypes.number }), @@ -116,6 +118,9 @@ const mapDispatchToProps = (dispatch, props) => ({ addCompanionWindow: (content, additionalProps) => dispatch( actions.addCompanionWindow(props.targetProps.windowId, { content, ...additionalProps }), ), + addResource: (manifestId) => dispatch( + actions.addResource(props.manifestId), + ), receiveAnnotation: (targetId, id, annotation) => dispatch( actions.receiveAnnotation(targetId, id, annotation), ), diff --git a/src/plugins/miradorAnnotationPlugin.js b/src/plugins/miradorAnnotationPlugin.js index e3a06fc3ddb7200ff602bc605ca96e28fa8c8f45..499129eb73358d50ba5716602e88fbc9359d27ec 100644 --- a/src/plugins/miradorAnnotationPlugin.js +++ b/src/plugins/miradorAnnotationPlugin.js @@ -109,6 +109,7 @@ class MiradorAnnotation extends Component { MiradorAnnotation.propTypes = { addCompanionWindow: PropTypes.func.isRequired, + addResource: PropTypes.func.isRequired, canvases: PropTypes.arrayOf( PropTypes.shape({ id: PropTypes.string, index: PropTypes.number }), ).isRequired, @@ -130,7 +131,7 @@ MiradorAnnotation.propTypes = { /** */ const mapDispatchToProps = (dispatch, props) => ({ addCompanionWindow: (content, additionalProps) => dispatch( - actions.addCompanionWindow(props.targetProps.windowId, { content, ...additionalProps }), + actions.addCompanionWindow(props.targetProps.windowId, {content, ...additionalProps}), ), switchToSingleCanvasView: () => dispatch( actions.setWindowViewType(props.targetProps.windowId, 'single'),