Skip to content

Commit 616c2f0

Browse files
committed
[IIIF-148] WIP add custom plugin to interact with canvas changes
1 parent 89cd362 commit 616c2f0

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

src/mirador-viewer/config.default.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import miradorShareDialogPlugin from 'mirador-share-plugin/es/MiradorShareDialog
1616
import miradorSharePlugin from 'mirador-share-plugin/es/miradorSharePlugin';
1717
import miradorDownloadPlugin from 'mirador-dl-plugin/es/miradorDownloadPlugin';
1818
import miradorDownloadDialog from 'mirador-dl-plugin/es/MiradorDownloadDialog';
19+
import myPlugin from './locationPlugin';
1920

2021
const MANIFEST_URL_PART = /\/manifest$/;
2122

@@ -185,6 +186,7 @@ let miradorPlugins = [
185186
miradorShareDialogPlugin,
186187
miradorSharePlugin,
187188
miradorDownloadDialog,
189+
myPlugin
188190
];
189191

190192
(() => {
@@ -195,3 +197,14 @@ let miradorPlugins = [
195197
})();
196198

197199
Mirador.viewer(miradorConfiguration, miradorPlugins);
200+
/*miradorInstance?.store?.subscribe((store) => {
201+
console.log(miradorInstance?.store, store);
202+
const state = store?.getState();
203+
const lastAction = state?.lastAction;
204+
console.log(state, lastAction);
205+
206+
if (lastAction && lastAction.type === 'SELECT_CANVAS') {
207+
const canvasId = lastAction.canvasId;
208+
console.log('Canvas cliccato:', canvasId);
209+
}
210+
});*/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import takeEvery from 'redux-saga/effects';
2+
import ActionTypes from 'mirador/dist/es/src/state/actions/action-types';
3+
4+
/** This will be called every time the SET_CANVAS action is dispatched */
5+
const onCanvasChange = function* (action) {
6+
console.log(action);
7+
}
8+
9+
const pluginSaga = function* () {
10+
/* `takeEvery` calls the associated function every time the action is dispatched */
11+
yield takeEvery([
12+
ActionTypes.SET_CANVAS,
13+
ActionTypes.RECEIVE_SEARCH,
14+
ActionTypes.REMOVE_SEARCH,
15+
ActionTypes.SET_WINDOW_VIEW_TYPE,
16+
], onCanvasChange);
17+
}
18+
19+
const myPlugin = {
20+
component: () => null,
21+
saga: pluginSaga,
22+
}
23+
24+
export default myPlugin;

0 commit comments

Comments
 (0)