Skip to content

Commit ae1143e

Browse files
vins01-4sciencedavide-negretti
authored andcommitted
[IIIF-104] New canvasId for mirador viewer
1 parent 0a0227f commit ae1143e

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/app/item-page/mirador-viewer/mirador-viewer.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ export class MiradorViewerComponent implements OnInit {
3131
*/
3232
@Input() searchable: boolean;
3333

34+
/**
35+
* Is used as index of the element to show.
36+
*/
37+
@Input() canvasIndex: number;
38+
3439
/**
3540
* Hides embedded viewer in dev mode.
3641
*/
@@ -87,6 +92,9 @@ export class MiradorViewerComponent implements OnInit {
8792
if (this.notMobile) {
8893
viewerPath += '&notMobile=true';
8994
}
95+
if (this.canvasIndex) {
96+
viewerPath += `&canvasId=${this.canvasIndex}`;
97+
}
9098

9199
// TODO: Should the query term be trusted here?
92100
return this.sanitizer.bypassSecurityTrustResourceUrl(viewerPath);

src/mirador-viewer/config.default.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ 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';
1919

20+
const MANIFEST_URL_PART = /\/manifest$/;
21+
2022
const embedURL = location.href;
2123
const params = new URLSearchParams(location.search);
2224
const manifest = params.get('manifest');
2325
const searchOption = params.get('searchable');
2426
const query = params.get('query');
2527
const multi = params.get('multi');
2628
const notMobile = params.get('notMobile');
29+
const canvasId = params.get('canvasId');
2730

2831
let windowSettings = {};
2932
let sidbarPanel = 'info';
@@ -52,6 +55,10 @@ windowSettings.manifestId = manifest;
5255
}
5356
}
5457
}
58+
if (canvasId != null && canvasId !== 'null' && +canvasId >= 0) {
59+
windowSettings.canvasId =
60+
`${(manifest.replace(MANIFEST_URL_PART, ''))}/canvas/c${canvasId}`;
61+
}
5562
})();
5663

5764
(Mirador.viewer(

0 commit comments

Comments
 (0)