Date: August 9, 2023 /  Author: Ralf Eichinger

Build a IIIF Mirador viewer with plugins

Checkout project https://github.com/ProjectMirador/mirador-integration and customize it by adding plugins. Make sure you have all tools in place: see “Installation and usage of webpack with npm (and nvm)”

The basic Mirador integration already has the mirador-image-tools integrated.

Here is the list of available plugins (at time of writing this post):

To add a plugin to the mirador-integration project, e.g. mirador-share-plugin:

$ npm install mirador-share-plugin

added 1 package, changed 1 package, and audited 1109 packages in 7s
...
$

Now the plugin is added as a dependency to package.json:

"dependencies": {
    "css-loader": "^3.6.0",
    "mirador": "^3.3.0",
    "mirador-image-tools": "^0.11.0",
    "mirador-share-plugin": "^0.11.0",
    "parcel-bundler": "^1.12.4",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "style-loader": "^1.2.1",
    "webpack": "^4.43.0",
    "webpack-cli": "^3.3.12"
  }

Now we can add it to the initialisation code for Mirador in src/index.js:

import Mirador from 'mirador/dist/es/src/index';
import { miradorImageToolsPlugin } from 'mirador-image-tools';
import miradorSharePlugin from 'mirador-share-plugin';

const config = {
  id: 'demo',
  windows: [{
    imageToolsEnabled: true,
    imageToolsOpen: true,
    manifestId: 'https://purl.stanford.edu/sn904cj3429/iiif/manifest',
  }],
  theme: {
    palette: {
      primary: {
        main: '#1967d2',
      },
    },
  },
};

Mirador.viewer(config, [
  ...miradorImageToolsPlugin,
  ...miradorSharePlugin
]);

Lets pack the changed Mirador:

$ npm run webpack

And test the new plugin by opening webpack/index.html in a browser.

 Tags:  topics development javascript

Previous
⏪ PostgreSql - Backup and Restore of complete database cluster

Next
Installation and usage of webpack with npm (and nvm) ⏩