Introduction# I implemented functionality in Mirador, a widely used IIIF (International Image Interoperability Framework) viewer, to meet the following requirements:
Display the canvas (page) specified by URL parameters on initial load 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 ) n w } ; s i ] t n m c d , d a a e m o n n f i w i v a r s f a u a : e s l d s I t o [ t d S r { I : e V d a i : c r e a c w m n h e a v Q r n a u i s e = f I r e d y M s , : i t r U ' a r s d l e o , a r r . c v h i e t w e e r r m ( ' { ,
This option is a convenient feature that automatically executes a search, but for this use case, the following points needed to be considered:
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 canvasIdKnowing when the search completes - Since the search is executed asynchronously, monitoring Redux state is needed if you want to perform processing after completionA More Direct Approach# After consideration, I adopted an approach that directly uses the receiveSearch action. With this approach:
Call the Search API directly to get only hits matching the specified canvas Build a response in IIIF Search API format 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 : ; n m c q t } } s a a u P r t n n e r y c i c c c ) i c c c i c c c f } r c c r i v r o o f o o o ; f o o o f o o o o e a o e g f a y m { n n n n ( n n n n n n r c i } t t n t e e s : i G s ( s F s s s ( s s s ( s s E s o f u c s u t s I s e t ! t i t t : ! t t t ! t t x t ( n h } r h o r S t d s e t m n s r t c s ( i ) n l n e U : t < m a m d s s { e s s r e d r r h o t r t i c x ; ( e a r r { t a n a e e a e e e s a e a i n e s d h y h e . [ r l s i h n i n t r a p r a a s p t s c t s [ s . : a w i r e ] c : t n i e i f i h v r r c r r p o a o t s t r o p r h t r r ; h r g d f e f e i c o h c c o n u : e u u r s : s o r H s i : s e s e c h f S h h n s = r o r s r s e : ; r o i t n e s t s I e S i e B U s e c n { e o c h s f ) r t r g s a t R t I s e l r a r e . a e l s u e ( o r r ( s i , t r R e I r e v s l o w s y i o r C { u e a { ' F n r c e s = F = v ? i e = k a d u c a r s g F o g i h s p i : c U = ) i = h : r e n c o m a r , n p o a S m c e r a t i c C v e u e i C g s o n w e a e s ) l ` w r d t s e a a [ r n l a ; e n s a a n t $ a e r a s t n s ' c t e n r s e i r i = r r = { i t e t r o v @ e . d v c v e . t c f i e s t u s a m i f a = i . r a h i o h e ( n t s e r p . a n s = d r e t s a c = k m s A g u e a f n o r t g r , = ' e p o r e ) a A t r r a r e n e c ; e ] s l = s a n P . r } n r c t [ s s h s f c o a f : U w r i I s a ) c h c ] e o i c o r a u c e a R a e f e y [ h B h ; . u n h u a n r e t s s L i t e s r . = ] S a ( j r g a r g v c ( c y t t u s e v i > ; e s s s c r c m a r e ' h n r f r t r i s r e e o e t s e e s e ? x c i r f n R v c A s v U a n s h : s n I s . y s n o e e i e r . i r r ( e ) t d o c w e ( g m t [ s c r p c l c s ] u h h a ; c ] p e a r e } h ; s t { & r a = r t h ; o y o [ ? U p r = & c r ' c x h ( n ( f ' q r [ e i e s , h y e m s [ s i @ = l ] c n r f . w a e ] e l i $ ) ; i g e r i h h m n . ; r e d { ; f ; s a d i : a i j v ? ' e i o g , ) t n f s i . ] n e x u m q , s s i e o c i c d y r e u : t f s n e n w c n e ' r e t ( s c d c h e t r , i s U ) ) l e a : . ) y n t r ; u s U n o , e g l ? d e R v s n { r ) e a I a t . r } ; s s r C s r s o [ e ( c o i p r ] r ' h m n l ) > v s S p g i ; i e e o t = c a r n } ( > e r v e [ ' s c i n ] # { h c t ' : ' e ( = ) ) . q ; [ i u [ s d e ] e ; r ; r y v ) i } c ` e ; s ] ) . f i n d ( 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 ) f n i w } w } w } ; c i } I s d i ] i , o , A ( o f n t : n i m c t , n a a s r e d s n c c ) i } i d d a a h d l l i k n d e s ( o o f t m ' o : n n u o l l d s a a t h n n w c s s = c } c ) c } m c c ) i } i i m w i v m w o o e p b h r i s s i o e e > ( o ; o o ) i o o ; f a r i s ' f a b : w w B a l i c h t t t n m a a r n ' ' ' w } r } n w p = n c p ; r n n i c ) m l a r : w e s n F C a c e g h i s d p r r R e B s @ @ @ i , e ) A s i a > s o o a G s s d ( o ; i i d a i s I a { u l r e d h Q t . M r o a c c e c u t c i t t ' t s ' ' m r } o ) d t n y t n s d e t t s n ' s ` s r z o d [ n t d i l o O C : l u s l e w n h h c e i o d y h @ o o @ @ o e , n , d d l R t i o t = e R s w e $ e a e r o { d I : l l s p o i e e = c I i I J o i l s n ' p i t t u i t t s ' c : a o o e a e t r s s > a e t i a { a d V r o d N s e e n f g r = n e d o d s r v d e t : e n y a r d y i o @ h t d w a c d n i V t t e r g n r c r o M i - w : c a c : n t a h y g w i : n : o d e a e ' : p l c ' p v u t a ` h d I d o d t o i h a a s c i s d c a c r i e v - a v r : r l t a t i v W n < S a r x ` : e : e : e a r y r $ e C d : r A : n e e t r t h s e o h n h V r w i 1 m n i e f o s s & w h n e s i s : s e c t $ { ' s ' t c p s { o : d c : w e c a C t a w C v R i a e e ' a v g e a t l e & a d S t n t t a r h ' { ' : h : ` : i e e : c s m { < t ' e c h t o e r - o a e e d r w , n a a n l r P , i i > o e r d r u r r e R : c s i $ o : ' a e p s s i s ' r o = C e m r c 1 m s s w o e i s t : s u a f c t w a i o i n i c s e a c ' t h { n : h n a a t c t o e r . m o . p h ' p I p e r = r f I i e e n a 0 . r n w n k n h p s ' n : s s i c o : { i v r n r o r n a i s p m m c a t A , a d o r ' e d o t , , e s n g ) M c g I g n g ) o p h v A c . t a a ' t a c i i n i r g t a i p o n h c n } n . w , s , n r l e v e i h , d , o , n o t a n : l s n : ' c . s h o n t n = c h o n r a m i e t i s s i t P u : a a t { r : w { s n t s n L e . v A s n c I n g e g h t r i a n p o i s e t n U e r s S a = n u e s p I o a n m a n c t h d p W , n , a ' ' e o d i a n s o n e o d r s , { c I e d s n e : d t y g a s n : : a } a i t d , , . n o o n W e n W a r o l i h d a o M t k i / } a e t p I o p C r # n n : u d d W r n i i a i r e w , t ) r r . r n n = / / t r h ( d t a o s x e d n C i i V W o n r = n c . . D i t c r i o i s i ' , ( } a i n , y l o s k o s n i i n d c d h d M i o e { h a e n w I { i e o , h / t n t w w t n m p d e n W o h r o ? i i s n r H s c g n I i a n i s i t e h t r o p a o w d i w e w q s r p : m i e , > I f r L t e o i n = o = i w a t w e o n I r c I = p a l t R i ; F . c i , a n n t $ n n n c I r w d d e e d $ a d a ' a s e v i h s r ' g A { t M g > i h d . I o ) s i , { t o y f n F c e S o ? t i c , ' s h h . ; ; o ( s d w u v e c r a d o o S e / q ' n h , T i e a n a t s { l e n h . t r r r e a a = , d - e t d p W d o = [ t S c ( v h - c C d a r p $ e r x . r d o i d r i s e o s i e r a a < r c i { x e t x i C s n A e O d a d e e i n n s c h / e ) s ' y g o i d c . b ] r e a w s g v v t h s n u , w h m t o t g j . c U r e p h a a r A e c = l h t p i w i e e c h R c r e t s s i a P a o > t } a o ( o t c o ( I h ( c ' ( n s I r d - ` s n n ' n S t n C A { i , a m g c e ( $ , i i : w ) t . t o c f r a , ( f h U { { d o i ; a k e m t i e n o / R i e n s n t e n p i e i u r 1 I n W t d e y t o o d s f n m / C d i r o ( s n n p e k a c o e n i w ) ( = e ) c e s n t o m x d n - ; s = n ; a c t o n p } o g 1 t = t n i U w t o ` w ' a ( v f r n e n , } , t ' s a i l > x e a e s e s e , ; t n s { . e a d . t c a r c j ( ( o r c a s s m c h n o e p h Q v n a a ' u a ' r n e s , c i r I h o y d Q n ) , u W } e i ` s r n , e y d a ) o r } w c ` s h , ) Q . u f e i r n y d ) ( ; Key Points# 1. Accessing Mirador’s Action Functions# In Mirador 4, action functions can be accessed directly from the global object:
c c c o o o n n n s s s t t t M r a e d = c d e C w i o i v m n e p d S a o e n w a i . r o M c n i h W r i a = n d d o M o r . w r a e = s c e M R i . e v a c e d o S d r e C d a o < r m s c p t h a r ; n i i n o g n , W i u n n d k o n w o ; w n > ;
Note that you access them directly as Mirador.receiveSearch, not through Mirador.actions.
The JSON passed to receiveSearch must conform to the IIIF Search API 1.0 format:
{ } " " " ] @ @ r c t e { } o y s n p o " " " } " t e u @ m r , o e " r t o e " " n x : c y t s @ c " t e p i o t h : " " s e v u y a : s " " a r p r " c : : t c e s c " : i e " " a h A [ " o " : : n t n o n : v t n a " " " a p o : : { c m s : t A n a U / a n " t t R / t n s : c I i i o c C h # i o t : o e x i n a p n d y f L t a t w . i i i e t h i s o n n e = o t n t t x x / " " i A t , a , , n s " y p g T , i " e w / , x i s t d e " t a , h r , c h h e / i 1 g / h c t o " n t e x t . j s o n " ,
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 sideA 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:
Canvas display control - Can add highlights while displaying the specified canvas on initial loadImmediate highlight display - Highlights are displayed immediately because search results are registered directlyPanel placement control - The position of the search panel can be freely configuredThis method leverages Mirador’s Redux store mechanism and allows for flexible customization.
Reference Links#