| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,32 @@ | |||
| 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'; | |||
| 2 | 2 | import './utils/polyfills/symbol-polyfill'; | |
| 3 | 3 | import './components/modal-styleguide'; | |
| 4 | 4 | import './components/pl-search/pl-search.iframe-helper'; | |
| 5 | + import './components/pl-nav/pl-nav.iframe-helper'; | ||
| 5 | 6 | import './utils/share-inner-iframe-data'; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments