diff --git a/.github/readme/blueprint.md b/.github/readme/blueprint.md new file mode 100644 index 00000000..f4d8ae9e --- /dev/null +++ b/.github/readme/blueprint.md @@ -0,0 +1,96 @@ +# Contentstack Extensions SDK + +The Extensions SDK allows you to extend Contentstack’s UI by helping you create Custom Fields, Custom Widgets, and Dashboard Widgets. + +**Custom Fields** enable users to introduce simpler interface controls, such as color picker, code editor, video selector, and more, or maybe complex micro web applications such as Shopify or Snipkart. Because of their dissociated nature, custom fields can be reused multiple times. + +**Custom Widgets** are like micro content-processing apps that help you analyze the entry content and provide recommendations. Some of the useful widgets you can create using this type of extension are text intelligence, SEO recommendations, language translation, grammar checker and more. + +**Dashboard Widgets** let you add powerful widgets to the stack’s dashboard that let users do more from a centralized location. Some examples of this type of extension include personal notes, recently published content, notification centre, and stack usage summary. + +This SDK overview document introduces you to the concept of custom extensions. + +## Getting started + +Include the compiled version of the extension client library by adding the following line to your application. + +```html + +``` + +## Extensions examples + +### Custom Fields + +Some of the examples of custom field extensions are: + +- **[Color Picker](https://github.com/contentstack/extensions/tree/master/color-picker)** - Displays a native color picker polyfill that allows users to select color as input value and saves the color code in the backend + +- **[Ace Editor](https://github.com/contentstack/extensions/tree/master/ace-editor)** - Displays a code editor written in JavaScript, allowing you to edit HTML, PHP, JavaScript and more easily + +- **[JSON Editor](https://github.com/contentstack/extensions/tree/master/json-editor)** - Displays a simple editor that lets you view, edit and format JSON code within the field of your content type + +- **[Key-value Field](https://github.com/contentstack/extensions/tree/master/key-value-field)** - Lets you add key-value as input value of a field of your content type + +- **[Progress Bar](https://github.com/contentstack/extensions/tree/master/progress-bar)** - Allows users to set value of a field by sliding the progress bar to the left or right + +- **[Star Ratings](https://github.com/contentstack/extensions/tree/master/ratings)** - Lets you provide rating by choosing number of stars + +- **[Brightcove](https://github.com/contentstack/extensions/tree/master/brightcove)** - Lets you fetch and display your Brightcove videos into a field of your content type. + +- **[Shopify](https://github.com/contentstack/extensions/tree/master/shopify)** - Lets you load products of your Shopify store into the field of your content type. + +- **[Egnyte](https://github.com/contentstack/extensions/tree/master/egnyte)** - Allows you to fetch files of your Egnyte account and display them into a field of your content type. + +- **[Ooyala](https://github.com/contentstack/extensions/tree/master/ooyala)** - Lets you fetch and display your Ooyala videos into a field of your content type. + +- **[Optimizely](https://github.com/contentstack/extensions/tree/master/optimizely)** - Lets you serve personalized content by allowing you to select the audience for each entry. + +- **[Youtube](https://github.com/contentstack/extensions/tree/master/youtube)** - Lets you fetch and display your Youtube videos into a field of your content type. + +- **[External API Lookup](https://github.com/contentstack/extensions/tree/master/external-api-lookup-template)** - Lets you fetch data from an external API and display the data as possible values for the field on an entry page in Contentstack. + +### Custom Widgets + +Some of the examples of custom widget extensions are: + +- [**Text Intelligence**](https://github.com/contentstack/extensions/tree/master/text-intelligence) - Lets you use MonekyLearn APIs to provide helpful recommendations such as content summarizer, keyword extractor, retail classifier, etc. + +- [**Google Analytics**](https://github.com/contentstack/extensions/tree/master/google-analytics) - Displays the traffic analysis and statistics of your entry (using Google Analytics data) on the sidebar of the entry. + +- [**Optimizely Experiments**](https://github.com/contentstack/extensions/tree/master/optimizely-experiments) - Lets you retrieve and display Optimizely Experiments and their details in your entry. + +### Dashboard Widgets + +Some of the examples of the dashboard widget extensions are: + +- [**Google Analytics**](https://github.com/contentstack/extensions/tree/master/dashboard-widget-google-analytics) - Displays the traffic analysis and statistics of your site on the stack dashboard. + +## Using Contentstack styles + +Extensions are rendered within an iframe, you will need to include the ui-extension-sdk.min.css library within your custom extension in order to use any of the styles provided by Contentstack. + +Include the CSS file in your extension code as follows: + +```html + +``` + +For more information on styling your extension, refer to our [style guide](https://www.contentstack.com/docs/extensions/style-guide/). + +## More information + +- [Extensions SDK API reference](https://github.com/contentstack/ui-extensions-sdk/blob/2.2.0/docs/ui-extensions-api-reference.md) +- [Extensions documentation ](https://www.contentstack.com/docs/guide/extensions) + +{{template:license}} diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 00000000..44ef28a0 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,33 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.github/workflows/update-copyright-years-in-license-file.yml b/.github/workflows/update-copyright-years-in-license-file.yml new file mode 100644 index 00000000..3bab84d3 --- /dev/null +++ b/.github/workflows/update-copyright-years-in-license-file.yml @@ -0,0 +1,17 @@ +name: Update copyright year(s) in license file + +on: + schedule: + - cron: "0 3 1 1 *" + workflow_dispatch: + +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: FantasticFiasco/action-update-license-year@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/CODEOWNERS b/CODEOWNERS index da6db11c..bba0ea58 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @contentstack/security-admin @contentstack/ecosystem-admin +* @contentstack/security-admin @contentstack/ghost-admin diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..4ba8915e --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ +The MIT License (MIT) +Copyright © 2019-2022 Contentstack. All Rights Reserved + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 6050fb9d..c9fe1f77 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ + +[](#contentstack-extensions-sdk) # Contentstack Extensions SDK -The Extensions SDK allows you to extend Contentstack’s UI by helping you create Custom Fields, Custom Widgets, and Dashboard Widgets. +The Extensions SDK allows you to extend Contentstack’s UI by helping you create Custom Fields, Custom Widgets, and Dashboard Widgets. **Custom Fields** enable users to introduce simpler interface controls, such as color picker, code editor, video selector, and more, or maybe complex micro web applications such as Shopify or Snipkart. Because of their dissociated nature, custom fields can be reused multiple times. @@ -11,80 +13,104 @@ The Extensions SDK allows you to extend Contentstack’s UI by helping you creat This SDK overview document introduces you to the concept of custom extensions. + +[](#getting-started) + ## Getting started Include the compiled version of the extension client library by adding the following line to your application. ```html - + ``` + +[](#extensions-examples) + ## Extensions examples + ### Custom Fields + Some of the examples of custom field extensions are: -- **[Color Picker](https://github.com/contentstack/extensions/tree/master/color-picker)** - Displays a native color picker polyfill that allows users to select color as input value and saves the color code in the backend +- **[Color Picker](https://github.com/contentstack/extensions/tree/master/color-picker)** - Displays a native color picker polyfill that allows users to select color as input value and saves the color code in the backend -- **[Ace Editor](https://github.com/contentstack/extensions/tree/master/ace-editor)** - Displays a code editor written in JavaScript, allowing you to edit HTML, PHP, JavaScript and more easily +- **[Ace Editor](https://github.com/contentstack/extensions/tree/master/ace-editor)** - Displays a code editor written in JavaScript, allowing you to edit HTML, PHP, JavaScript and more easily -- **[JSON Editor](https://github.com/contentstack/extensions/tree/master/json-editor)** - Displays a simple editor that lets you view, edit and format JSON code within the field of your content type +- **[JSON Editor](https://github.com/contentstack/extensions/tree/master/json-editor)** - Displays a simple editor that lets you view, edit and format JSON code within the field of your content type -- **[Key-value Field](https://github.com/contentstack/extensions/tree/master/key-value-field)** - Lets you add key-value as input value of a field of your content type +- **[Key-value Field](https://github.com/contentstack/extensions/tree/master/key-value-field)** - Lets you add key-value as input value of a field of your content type -- **[Progress Bar](https://github.com/contentstack/extensions/tree/master/progress-bar)** - Allows users to set value of a field by sliding the progress bar to the left or right +- **[Progress Bar](https://github.com/contentstack/extensions/tree/master/progress-bar)** - Allows users to set value of a field by sliding the progress bar to the left or right -- **[Star Ratings](https://github.com/contentstack/extensions/tree/master/ratings)** - Lets you provide rating by choosing number of stars +- **[Star Ratings](https://github.com/contentstack/extensions/tree/master/ratings)** - Lets you provide rating by choosing number of stars -- **[Brightcove](https://github.com/contentstack/extensions/tree/master/brightcove)** - Lets you fetch and display your Brightcove videos into a field of your content type. +- **[Brightcove](https://github.com/contentstack/extensions/tree/master/brightcove)** - Lets you fetch and display your Brightcove videos into a field of your content type. -- **[Shopify](https://github.com/contentstack/extensions/tree/master/shopify)** - Lets you load products of your Shopify store into the field of your content type. +- **[Shopify](https://github.com/contentstack/extensions/tree/master/shopify)** - Lets you load products of your Shopify store into the field of your content type. -- **[Egnyte](https://github.com/contentstack/extensions/tree/master/egnyte)** - Allows you to fetch files of your Egnyte account and display them into a field of your content type. +- **[Egnyte](https://github.com/contentstack/extensions/tree/master/egnyte)** - Allows you to fetch files of your Egnyte account and display them into a field of your content type. -- **[Ooyala](https://github.com/contentstack/extensions/tree/master/ooyala)** - Lets you fetch and display your Ooyala videos into a field of your content type. +- **[Ooyala](https://github.com/contentstack/extensions/tree/master/ooyala)** - Lets you fetch and display your Ooyala videos into a field of your content type. -- **[Optimizely](https://github.com/contentstack/extensions/tree/master/optimizely)** - Lets you serve personalized content by allowing you to select the audience for each entry. +- **[Optimizely](https://github.com/contentstack/extensions/tree/master/optimizely)** - Lets you serve personalized content by allowing you to select the audience for each entry. -- **[Youtube](https://github.com/contentstack/extensions/tree/master/youtube)** - Lets you fetch and display your Youtube videos into a field of your content type. +- **[Youtube](https://github.com/contentstack/extensions/tree/master/youtube)** - Lets you fetch and display your Youtube videos into a field of your content type. -- **[External API Lookup](https://github.com/contentstack/extensions/tree/master/external-api-lookup-template)** - Lets you fetch data from an external API and display the data as possible values for the field on an entry page in Contentstack. +- **[External API Lookup](https://github.com/contentstack/extensions/tree/master/external-api-lookup-template)** - Lets you fetch data from an external API and display the data as possible values for the field on an entry page in Contentstack. ### Custom Widgets + Some of the examples of custom widget extensions are: -- [**Text Intelligence**](https://github.com/contentstack/extensions/tree/master/text-intelligence) - Lets you use MonekyLearn APIs to provide helpful recommendations such as content summarizer, keyword extractor, retail classifier, etc. +- [**Text Intelligence**](https://github.com/contentstack/extensions/tree/master/text-intelligence) - Lets you use MonekyLearn APIs to provide helpful recommendations such as content summarizer, keyword extractor, retail classifier, etc. -- [**Google Analytics**](https://github.com/contentstack/extensions/tree/master/google-analytics) - Displays the traffic analysis and statistics of your entry (using Google Analytics data) on the sidebar of the entry. +- [**Google Analytics**](https://github.com/contentstack/extensions/tree/master/google-analytics) - Displays the traffic analysis and statistics of your entry (using Google Analytics data) on the sidebar of the entry. -- [**Optimizely Experiments**](https://github.com/contentstack/extensions/tree/master/optimizely-experiments) - Lets you retrieve and display Optimizely Experiments and their details in your entry. +- [**Optimizely Experiments**](https://github.com/contentstack/extensions/tree/master/optimizely-experiments) - Lets you retrieve and display Optimizely Experiments and their details in your entry. ### Dashboard Widgets + Some of the examples of the dashboard widget extensions are: -- [**Google Analytics**](https://github.com/contentstack/extensions/tree/master/dashboard-widget-google-analytics) - Displays the traffic analysis and statistics of your site on the stack dashboard. +- [**Google Analytics**](https://github.com/contentstack/extensions/tree/master/dashboard-widget-google-analytics) - Displays the traffic analysis and statistics of your site on the stack dashboard. + + +[](#using-contentstack-styles) ## Using Contentstack styles + Extensions are rendered within an iframe, you will need to include the ui-extension-sdk.min.css library within your custom extension in order to use any of the styles provided by Contentstack. Include the CSS file in your extension code as follows: ```html - + ``` For more information on styling your extension, refer to our [style guide](https://www.contentstack.com/docs/extensions/style-guide/). -## More information -- [Extensions SDK API reference](https://github.com/contentstack/ui-extensions-sdk/blob/2.2.0/docs/ui-extensions-api-reference.md) -- [Extensions documentation ](https://www.contentstack.com/docs/guide/extensions -) -### The MIT License (MIT) +[](#more-information) + +## More information -Copyright © 2019 [Contentstack](https://www.contentstack.com/). All Rights Reserved +- [Extensions SDK API reference](https://github.com/contentstack/ui-extensions-sdk/blob/2.2.0/docs/ui-extensions-api-reference.md) +- [Extensions documentation ](https://www.contentstack.com/docs/guide/extensions) -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +[](#license) -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +## License + +Licensed under [MIT](https://opensource.org/licenses/MIT). diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..1c5ea16e --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,27 @@ +## Security + +Contentstack takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations. + +If you believe you have found a security vulnerability in any Contentstack-owned repository, please report it to us as described below. + +## Reporting Security Issues + +**Please do not report security vulnerabilities through public GitHub issues.** + +Send email to [security@contentstack.com](mailto:security@contentstack.com). + +You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. + +Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: + +- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) +- Full paths of source file(s) related to the manifestation of the issue +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- Step-by-step instructions to reproduce the issue +- Proof-of-concept or exploit code (if possible) +- Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +[https://www.contentstack.com/trust/](https://www.contentstack.com/trust/) diff --git a/blueprint.json b/blueprint.json new file mode 100644 index 00000000..7692f418 --- /dev/null +++ b/blueprint.json @@ -0,0 +1,12 @@ +{ + "input": "./.github/readme/blueprint.md", + "headingPrefix": { + "1": "", + "2": "" + }, + "line": "none", + "subresourceIntegrity": { + "js": "sha512-Zvd/rx8MHdudDeY916W50kakd+G/7Z/L4VvG0A/NBWVtmAlD7FPHcWDHc5a4WpGSXoXDgy2SLLDVrASxM7IpNQ==", + "css": "sha512-YFrH8bTpkhIRTf8jgGmJDWvd56LA9GnRzirfMr/K78ldxsyrfedaMxMCZMC9A9d0LzuVFhkkHWo10HWEoAgjjg==" + } +} diff --git a/coverage/html/base.css b/coverage/html/base.css index 417c7adc..f418035b 100644 --- a/coverage/html/base.css +++ b/coverage/html/base.css @@ -152,9 +152,15 @@ table.coverage td span.cline-any { background-position: 0 -10px; } .status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } /* dark red */ .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } .low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} /* medium red */ .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } /* light red */ @@ -166,19 +172,25 @@ table.coverage td span.cline-any { /* dark green */ .status-line.high, .high .cover-fill { background:rgb(77,146,33) } .high .chart { border:1px solid rgb(77,146,33) } - - -.medium .chart { border:1px solid #666; } -.medium .cover-fill { background: #666; } - -.cbranch-no { background: yellow !important; color: #111; } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } .cstat-skip { background: #ddd; color: #111; } .fstat-skip { background: #ddd; color: #111 !important; } .cbranch-skip { background: #ddd !important; color: #111; } span.cline-neutral { background: #eaeaea; } -.medium { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} .cover-fill, .cover-empty { display:inline-block; diff --git a/coverage/html/block-navigation.js b/coverage/html/block-navigation.js index 0c719038..cc121302 100644 --- a/coverage/html/block-navigation.js +++ b/coverage/html/block-navigation.js @@ -1,63 +1,87 @@ -var jumpToCode = (function init () { - // Classes of code we would like to highlight - var missingCoverageClasses = [ '.cbranch-no', '.cstat-no', '.fstat-no' ]; - - // We don't want to select elements that are direct descendants of another match - var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` - - // Selecter that finds elements on the page to which we can jump - var selector = notSelector + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` - - // The NodeList of matching elements - var missingCoverageElements = document.querySelectorAll(selector); - - var currentIndex; - - function toggleClass(index) { - missingCoverageElements.item(currentIndex).classList.remove('highlighted'); - missingCoverageElements.item(index).classList.add('highlighted'); - } - - function makeCurrent(index) { - toggleClass(index); - currentIndex = index; - missingCoverageElements.item(index) - .scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' }); - } - - function goToPrevious() { - var nextIndex = 0; - if (typeof currentIndex !== 'number' || currentIndex === 0) { - nextIndex = missingCoverageElements.length - 1; - } else if (missingCoverageElements.length > 1) { - nextIndex = currentIndex - 1; +/* eslint-disable */ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selecter that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); } - makeCurrent(nextIndex); - } + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } - function goToNext() { - var nextIndex = 0; + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } - if (typeof currentIndex === 'number' && currentIndex < (missingCoverageElements.length - 1)) { - nextIndex = currentIndex + 1; + makeCurrent(nextIndex); } - makeCurrent(nextIndex); - } - - return function jump(event) { - switch (event.which) { - case 78: // n - case 74: // j - goToNext(); - break; - case 66: // b - case 75: // k - case 80: // p - goToPrevious(); - break; + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); } - }; -}()); + + return function jump(event) { + if ( + document.getElementById('fileSearch') === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); window.addEventListener('keydown', jumpToCode); diff --git a/coverage/html/favicon.png b/coverage/html/favicon.png new file mode 100644 index 00000000..66918178 Binary files /dev/null and b/coverage/html/favicon.png differ diff --git a/coverage/html/index.html b/coverage/html/index.html index 9e486236..5ce5cc9e 100644 --- a/coverage/html/index.html +++ b/coverage/html/index.html @@ -1,48 +1,68 @@ + +
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +| lib | -
+
+ |
100% | -158/158 | +217/217 | 100% | -92/92 | +133/133 | 100% | -44/44 | +55/55 | 100% | -150/150 | +208/208 | ||||
| lib/stack | -
+
+ |
100% | -103/103 | +102/102 | 100% | -78/78 | +76/76 | 100% | 27/27 | 100% | -102/102 | +101/101 | |||||
| lib/stack/api | -
+
+ |
100% | 134/134 | 100% | @@ -99,7 +125,9 @@|||||||||||||
| lib/stack/api/asset | -
+
+ |
100% | 27/27 | 100% | @@ -112,7 +140,9 @@|||||||||||||
| lib/stack/api/content-type | -
+
+ |
100% | 45/45 | 100% | @@ -125,21 +155,22 @@