This repository was archived by the owner on May 13, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
packages/uikit-workshop/src/scripts Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Tiny helper script to listen for keyboard combos and to communicate back to the main Search component (via the Pattern Lab iframe)
2+ import Mousetrap from 'mousetrap' ;
3+ import { targetOrigin } from '../../utils' ;
4+
5+ document . addEventListener ( 'click' , function ( ) {
6+ try {
7+ const obj = JSON . stringify ( {
8+ event : 'patternLab.pageClick' ,
9+ } ) ;
10+ window . parent . postMessage ( obj , targetOrigin ) ;
11+ } catch ( error ) {
12+ // @todo : how do we want to handle exceptions here?
13+ }
14+ } ) ;
15+
16+ Mousetrap . bind ( 'esc' , function ( e ) {
17+ try {
18+ const obj = JSON . stringify ( {
19+ event : 'patternLab.keyPress' ,
20+ key : e . key ,
21+ altKey : e . altKey ,
22+ ctrlKey : e . ctrlKey ,
23+ metaKey : e . metaKey ,
24+ shiftKey : e . shiftKey ,
25+ } ) ;
26+ window . parent . postMessage ( obj , targetOrigin ) ;
27+ } catch ( error ) {
28+ // @todo : how do we want to handle exceptions here?
29+ }
30+
31+ return false ;
32+ } ) ;
Original file line number Diff line number Diff line change @@ -2,4 +2,5 @@ import './utils/polyfills/custom-event-polyfill';
22import './utils/polyfills/symbol-polyfill' ;
33import './components/modal-styleguide' ;
44import './components/pl-search/pl-search.iframe-helper' ;
5+ import './components/pl-nav/pl-nav.iframe-helper' ;
56import './utils/share-inner-iframe-data' ;
You can’t perform that action at this time.
0 commit comments