diff --git a/.husky/pre-commit b/.husky/pre-commit old mode 100644 new mode 100755 index 0982f91a45..303dd1fce8 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" -yarn precommit +yarn run precommit diff --git a/.husky/pre-push b/.husky/pre-push old mode 100644 new mode 100755 index 84489edd6a..57db2274ed --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,4 +1,4 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" -yarn prepush +yarn run prepush diff --git a/package.json b/package.json index 0289f01520..ef7576a3eb 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ ], "scripts": { "postinstall": "husky install", - "precommit": "lint-staged --allow-empty", + "precommit": "lint-staged --allow-empty && yarn workspaces foreach -pv run prettier:write", "prepush": "yarn workspaces foreach -pv run test:eslint", "build": "yarn workspaces foreach -ptvR --from ketcher-react-app run build", "build:demo": "yarn workspaces foreach -ptvR --from demo run build", @@ -27,17 +27,17 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.2.0", "eslint-plugin-workspaces": "^0.7.0", - "husky": "^7.0.4", + "husky": "^8.0.2", "lint-staged": "^12.1.2", "npm-run-all": "^4.1.5", - "prettier": "^2.5.1", + "prettier": "2.8.0", "prettier-config-standard": "^4.0.0", "stylelint": "13.13.1", "stylelint-config-prettier": "^9.0.3", "stylelint-config-standard": "22.0.0" }, + "packageManager": "yarn@3.1.0", "resolutions": { "react-error-overlay": "6.0.9" - }, - "packageManager": "yarn@3.1.0" + } } diff --git a/packages/ketcher-react/package.json b/packages/ketcher-react/package.json index c9bcf70c7c..710c3ee134 100644 --- a/packages/ketcher-react/package.json +++ b/packages/ketcher-react/package.json @@ -63,6 +63,7 @@ "miew-react": "^1.0.0", "react-colorful": "^5.4.0", "react-contextmenu": "^2.14.0", + "react-device-detect": "^2.2.2", "react-dropzone": "^11.7.1", "react-intersection-observer": "^8.32.1", "react-redux": "^7.2.1", diff --git a/packages/ketcher-react/src/script/ui/state/hotkeys.ts b/packages/ketcher-react/src/script/ui/state/hotkeys.ts index a6d96abb1f..455b8ad551 100644 --- a/packages/ketcher-react/src/script/ui/state/hotkeys.ts +++ b/packages/ketcher-react/src/script/ui/state/hotkeys.ts @@ -30,12 +30,7 @@ import { load, onAction } from './shared' import actions from '../action' import keyNorm from '../data/convert/keynorm' import { openDialog } from './modal' - -declare global { - interface Window { - clipboardData: any - } -} +import { isIE } from 'react-device-detect' export function initKeydownListener(element) { return function (dispatch, getState) { @@ -98,8 +93,7 @@ function keyHandle(dispatch, state, hotKeys, event) { } event.preventDefault() - } else if (window.clipboardData) { - // IE support + } else if (isIE) { clipArea.exec(event) } } @@ -203,7 +197,7 @@ function clipData(editor) { const simpleObjectOrText = Boolean( struct.simpleObjects.size || struct.texts.size ) - if (simpleObjectOrText && window.clipboardData) { + if (simpleObjectOrText && isIE) { errorHandler( 'The structure you are trying to copy contains Simple object or/and Text object.' + 'To copy Simple object or Text object in Internet Explorer try "Copy as KET" button' @@ -223,8 +217,8 @@ function clipData(editor) { // res['chemical/x-daylight-smiles'] = smiles.stringify(struct); return res - } catch (ex: any) { - errorHandler(ex.message) + } catch (e: any) { + errorHandler(e.message) } return null diff --git a/yarn.lock b/yarn.lock index 614f42eb63..a9f5f99d5e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9108,12 +9108,12 @@ __metadata: languageName: node linkType: hard -"husky@npm:^7.0.4": - version: 7.0.4 - resolution: "husky@npm:7.0.4" +"husky@npm:^8.0.2": + version: 8.0.2 + resolution: "husky@npm:8.0.2" bin: husky: lib/bin.js - checksum: c6ec4af63da2c9522da8674a20ad9b48362cc92704896cc8a58c6a2a39d797feb2b806f93fbd83a6d653fbdceb2c3b6e0b602c6b2e8565206ffc2882ef7db9e9 + checksum: e101656fcb56163d610488f186448c78b132626aa427094489d886ce9374955a90274912b0f3a34af3326eaa74977883b032e5f701d7aaf4554daa5a7931be43 languageName: node linkType: hard @@ -11395,6 +11395,7 @@ __metadata: prettier: ^2.5.1 react-colorful: ^5.4.0 react-contextmenu: ^2.14.0 + react-device-detect: ^2.2.2 react-dropzone: ^11.7.1 react-intersection-observer: ^8.32.1 react-redux: ^7.2.1 @@ -14469,6 +14470,15 @@ __metadata: languageName: node linkType: hard +"prettier@npm:2.8.0": + version: 2.8.0 + resolution: "prettier@npm:2.8.0" + bin: + prettier: bin-prettier.js + checksum: 72004ce0cc9bb097daf3e3833f62495768724392c1d5b178dd47372337616e9e50ecbb0804f236596223f7b5eb1bbe69cefc8957dca21112c5777e77ef73a564 + languageName: node + linkType: hard + "prettier@npm:^2.5.1": version: 2.6.0 resolution: "prettier@npm:2.6.0" @@ -14868,6 +14878,18 @@ __metadata: languageName: node linkType: hard +"react-device-detect@npm:^2.2.2": + version: 2.2.2 + resolution: "react-device-detect@npm:2.2.2" + dependencies: + ua-parser-js: ^1.0.2 + peerDependencies: + react: ">= 0.14.0" + react-dom: ">= 0.14.0" + checksum: d9245cf5a1c1e565e88523ed6be580497d1f6a972fb100a81092943bb7e44afdcdbae0d67bebe7424c4ba5b27a5d13df7894d122307f070fc26062704f7ec788 + languageName: node + linkType: hard + "react-dom@npm:^17.0.2": version: 17.0.2 resolution: "react-dom@npm:17.0.2" @@ -15792,10 +15814,10 @@ __metadata: eslint-plugin-node: ^11.1.0 eslint-plugin-promise: ^5.2.0 eslint-plugin-workspaces: ^0.7.0 - husky: ^7.0.4 + husky: ^8.0.2 lint-staged: ^12.1.2 npm-run-all: ^4.1.5 - prettier: ^2.5.1 + prettier: 2.8.0 prettier-config-standard: ^4.0.0 stylelint: 13.13.1 stylelint-config-prettier: ^9.0.3 @@ -17748,6 +17770,13 @@ __metadata: languageName: node linkType: hard +"ua-parser-js@npm:^1.0.2": + version: 1.0.32 + resolution: "ua-parser-js@npm:1.0.32" + checksum: 79a80efd9c21511fdafc042ab748e0e93c8cdb0e8925bf6d48ad7dbb08e808c60fcecd49e679670def44ef428c005aa1810810f6773e7d8135a7817338080813 + languageName: node + linkType: hard + "uglify-js@npm:^3.1.4": version: 3.16.1 resolution: "uglify-js@npm:3.16.1"