diff options
author | MCMXC <16797721+mcmxcdev@users.noreply.github.com> | 2023-07-26 06:29:03 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-26 17:59:03 +0530 |
commit | 9b8f01716774a960073e944823ab727cc867a8f6 (patch) | |
tree | 732b83770baa78f5cf12776aaa33ce65bebfa418 /recipes/franz-custom-website/webview.js | |
parent | Add Excalidraw recipe (#393) (diff) | |
download | ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.gz ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.zst ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.zip |
chore: improve lint setup (#397)
- update eslint config to closely mirror the ones from ferdium-app
- add .eslintignore
- opt in to eslint `reportUnusedDisableDirectives` config option
- remove `trailingComma: all` from `prettier` config which is default in `prettier` v3
- autofix or disable a lot of lint issues throughout codebase
- add `volta` configuration to `package.json` to autoload correct `node` and `pnpm` versions
- upgrade all `eslint` and `prettier` related dependencies to latest
- update lint:fix npm script
- reformat touched files with prettier
- bumped up minor version for all recipes that have changes
- introduced injection of 'service.css' where it was missing in many recipes
---------
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'recipes/franz-custom-website/webview.js')
-rw-r--r-- | recipes/franz-custom-website/webview.js | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/recipes/franz-custom-website/webview.js b/recipes/franz-custom-website/webview.js index 072fed5..18f16a3 100644 --- a/recipes/franz-custom-website/webview.js +++ b/recipes/franz-custom-website/webview.js | |||
@@ -1,30 +1,36 @@ | |||
1 | const _path = _interopRequireDefault(require('path')); | ||
2 | |||
3 | function _interopRequireDefault(obj) { | 1 | function _interopRequireDefault(obj) { |
4 | return obj && obj.__esModule ? obj : { default: obj }; | 2 | return obj && obj.__esModule ? obj : { default: obj }; |
5 | } | 3 | } |
6 | 4 | ||
5 | const _path = _interopRequireDefault(require('path')); | ||
6 | |||
7 | module.exports = (Ferdium, settings) => { | 7 | module.exports = (Ferdium, settings) => { |
8 | Ferdium.injectCSS(_path.default.join(__dirname, 'style.css')); | 8 | Ferdium.injectCSS(_path.default.join(__dirname, 'style.css')); |
9 | 9 | ||
10 | // TODO: See how this can be moved into the main ferdium app and sent as an ipc message for opening with a new window or same Ferdium recipe's webview based on user's preferences | 10 | // TODO: See how this can be moved into the main ferdium app and sent as an ipc message for opening with a new window or same Ferdium recipe's webview based on user's preferences |
11 | document.addEventListener('click', event => { | 11 | document.addEventListener( |
12 | const link = event.target.closest('a[href^="http"]'); | 12 | 'click', |
13 | const button = event.target.closest('button[title^="http"]'); | 13 | event => { |
14 | const link = event.target.closest('a[href^="http"]'); | ||
15 | const button = event.target.closest('button[title^="http"]'); | ||
14 | 16 | ||
15 | if (link || button) { | 17 | if (link || button) { |
16 | const url = link ? link.getAttribute('href') : button.getAttribute('title'); | 18 | const url = link |
19 | ? link.getAttribute('href') | ||
20 | : button.getAttribute('title'); | ||
17 | 21 | ||
18 | if (!Ferdium.isImage(link)) { | 22 | if (!Ferdium.isImage(link)) { |
19 | event.preventDefault(); | 23 | event.preventDefault(); |
20 | event.stopPropagation(); | 24 | event.stopPropagation(); |
21 | 25 | ||
22 | if (settings.trapLinkClicks === true) { | 26 | if (settings.trapLinkClicks === true) { |
23 | window.location.href = url; | 27 | window.location.href = url; |
24 | } else { | 28 | } else { |
25 | Ferdium.openNewWindow(url); | 29 | Ferdium.openNewWindow(url); |
30 | } | ||
26 | } | 31 | } |
27 | } | 32 | } |
28 | } | 33 | }, |
29 | }, true); | 34 | true, |
35 | ); | ||
30 | }; | 36 | }; |