Introduction

I implemented functionality in Mirador, a widely used IIIF (International Image Interoperability Framework) viewer, to meet the following requirements:

  1. Display the canvas (page) specified by URL parameters on initial load
  2. Highlight search terms within the specified canvas

This article shares the approach and implementation method for achieving these requirements.

Exploring Approaches

defaultSearchQuery Option

In Mirador 4, you can automatically execute a search at initialization by specifying the defaultSearchQuery option in the window settings:

c}o)nw};si]tnmcd,daaemonnfiwivarsfaua:esldsIto[tdSr{I:eVdai:creacwmnheavQrnauise=fIredyMs,:itrU'arsdleo,arr.cvhietweerrm('{,

This option is a convenient feature that automatically executes a search, but for this use case, the following points needed to be considered:

  1. Page navigation control - Since the specification automatically navigates to the page of the first hit when a search is executed, additional control is needed if you want to stay on the page specified by canvasId
  2. Knowing when the search completes - Since the search is executed asynchronously, monitoring Redux state is needed if you want to perform processing after completion

A More Direct Approach

After consideration, I adopted an approach that directly uses the receiveSearch action. With this approach:

  1. Call the Search API directly to get only hits matching the specified canvas
  2. Build a response in IIIF Search API format
  3. Register it as search results in Mirador using the receiveSearch action

This allows leveraging Mirador’s search highlight feature as-is while maintaining the display of the specified canvas.

Implementation

1. Function to Get Hits from the Search API

c)}o:;nmcqt}}saauPrtnneryciccc)icccicccf}rccrivroofooo;fooofooooeaoegfaym{nnnn(nnnnnnrci}ttntees:iGs(sFsss(sss(ssEsofucsutsIset!titt:!ttt!ttxt(nh}rhorStdsetmnsrtcs(i)nlneU:t<mamdss{essredrrhotrticx;(earr{tanaeeaeeesaeainesdhyhe.[rlsihnintrapraasptscts[s.:awire]c:tnieifihvrrcrrpoaotstroprhtrr;hrgdfefeicohcconu:euurs:sorHsi:sesechfShhns=rorsrse:;roitnestsIeSieBUsecn{eochsf)rtrgsatRtIselrare.aelsue(orr(si,trReIrevslowsyiorC{uea{'Fnrces=F=v?ie=kaducarsgFogihspi:cU=)i=h:rencomar,npoaSmceraticCveueiCgsonweaes)l`wrdtseaa[rnla;ensaant$aerastns'ctenrseiri=rr={itetrov@e.dvcve.tcfiestusamifa=i.rahiohe(ntserp.ans=dretsac=kmsAgueafnortgr,='epore)aAtrrarenec;e]sl=sanP.r}nrct[sshsfcoaf:UwriIsa)chc]eoicorauceaRaefey[hBh;.unhuanretssLitesr.=]Sa(jrgargvc(cyttusevi>;essscrcmare'hnrfrtrisreeoetseese?xcirfnRvcAsvUansh:snIs.ysnoeeier.irr(e)tdocwe(gmt[scrpclcs]uhha;c]peare}h;st{&ra=rth;oyo[?Upr=&cr'cxh(n(f'qr[eies,hyems[si@=l]cnrf.wae]eli$);igerihhmn.;red{;f;sadi:aijv?'eiog,)tnfsi.]nexumq,ssieocicdyreu:tfsnenwcne'ret(scdchetr,isU))lea:.)yntr;usUno,egl?deRvsn{r)eaIat.r};ssrCsrso[e(coipr]r'hmnl)>vsSpgi;ieeot=carn}(>erve['scin]#{hct':'e(=)).q;[iu[sde]e;r;ryv)i}c`e;s]).find(

This implementation dynamically retrieves the IIIF Search API endpoint from the manifest’s service property. This allows it to work with any IIIF-compliant server.

2. Mirador Initialization and Highlight Registration

c}i}o)fniw}w}w};ci}Isdi]i,o,A(ofnt:nimct,naasredsncc)i}iddaahdllikndes(ooftm'o:nnuolldsaathnnwcss=c}c)c}mcc)i}iimwivmwooepbhrissioee>(o;oo)ioo;faris'fab:wwBalichtttnmaarn'''w}r}nwp=ncp;rnnic)mlar:wesnFCaceghisdprrReBs@@@i,e)Asia>sooaGssd(o;iidaisIa{ulredhQt.Mroaccecutcitt'ts''mr}o)dtnytnsdettsn's`srzod[ntdiloOC:luslewnhhceiodyh@oo@@oe,n,ddlRtiot=eRswe$eaero{dI:llspoiee=cIiIJoilsn'pittuitts'c:aooeaetrss>aetia{adVrodNseenfgr=nedodsrvdet:enyardyio@htdwacdniVttergnrcroMi-w:cac:ntahygwi:n:odeae':plc'pvuta`hdIdodtoihaascisdcacriev-avr:rltativWn<Sarx`:e:e:earyr$eCd:rA:neetrthseohnhVrwi1mniefoss&whnesis:sect${'s'tcps{o:dc:wecaCtawCvRiaee'avgeatle&adStnttarh'{':h:`:iee:csm{<t'echtoer-oaeedrw,naanlrP,ii>oerdrurreR:csi$o:'aepssis'ro=Cemrc1msswoeist:suafctwaioinicseac'th{n:hnaatctoer.mo.ph'pIper=rfIieena0.rnwnknhps'n:ssico:{ivrnrornaispmmcatA,ador'edot,,esng)McgIgng)ophvAc.taa'taciinirgtaiponhcn}n.w,s,nrleveih,d,o,notan:lsn:'c.shontn=chonramietissitPu:aat{r:w{sntsnLe.vAsncIngeghtrianpoisetnUersSa=nuespIoanmancthdpW,n,a''eodiansoneodrs,{cIedsne:dtygasn::a}aitd,,.noonWenWarolihdaoMtki/}aetpIopCr#nn:uddWrniiairew,t)rr.rnn=//trh(dtaosxednCiiVWonr=nc..Ditcrioisi',(}ain,yloskosniindcdhdMioe{haenwI{ieo,h/tntwwtnmpdenWohro?iisnrHscgnIianisitehtropaowdiwewqsrp:mie,>IfrLteoin=o=iwatweonIrcI=paltRi;F.ci,annt$nnncIrwddeed$ada'asevihsr'gA{tMg>ihd.Io)si,{toyfnFceSo?tic,'shh.;;o(sdwuvecradooSe/q'nh,Tieanats{lenh.trrreaa=,d-etdpWdo=[tSc(vh-cCdarp$erx.rdoidriseosieraa<rci{xetxiCsnAeOdadeeinnsch/e)s'ygoidc.b]reawsgvvthsnu,whmtotgj.cUrephaarAec=lhtpiwieechRcretssiaPao>t}ao(otco(Ih(c'(nsIrd-`snn'nStnCA{i,amgce($,ii:w)t.tocfra,(fhU{{doi;akemtieno/Riensntenpieiur1InWtdeytoodsfnm/Cdiro(snnpekacoeniw)(=e)cesntomxdn-;s=n;actonp}og1t=tniUwto`w'a(vfrnen,},t'sail>xeaesese,;tns{.ead.tcarcj((orcassmchnoephQvnaa'ua'rnes,cirIhoydQn),uW}ei`srn,eyda)or}wc`sh,)Q.ufeirnyd)(;

Key Points

1. Accessing Mirador’s Action Functions

In Mirador 4, action functions can be accessed directly from the global object:

cccooonnnssstttMraed=cdeCwioivmnepdSaoenwai.roMcnihWria=nddoMor.wrae=sceMRi.evacedoSdreCdao<rmscpthar;niinogn,Wiunndkonwo;wn>;

Note that you access them directly as Mirador.receiveSearch, not through Mirador.actions.

2. IIIF Search API Format Response

The JSON passed to receiveSearch must conform to the IIIF Search API 1.0 format:

{}"""]@@rcte{}oysnpo"""}"teu@mr,oe"rtoe""nx:cyts@c"tepioth:""sevuya:s""arpr"c::tcesc":ie""ahA["o"::ntnon:vtna"""apo::{cms:tAnaU/an"ttR/tns:cIiiocCh#iot:oexinapndyfLtatw.iiiethisonne=otnttxx/""iAt,a,,ns"ypgT,i"ew/,xistde"ta,hr,chhe/i1g/hcto"ntext.json",

3. CompanionWindow Placement

The placement of the search panel can be controlled with the position parameter:

  • left: Left side (same position as the metadata panel)
  • right: Right side

A natural layout is metadata on the left and search results on the right.

Conclusion

By directly calling the receiveSearch action, the following benefits were achieved:

  1. Canvas display control - Can add highlights while displaying the specified canvas on initial load
  2. Immediate highlight display - Highlights are displayed immediately because search results are registered directly
  3. Panel placement control - The position of the search panel can be freely configured

This method leverages Mirador’s Redux store mechanism and allows for flexible customization.