From bb22853570b91dbbd38c349b62d67f4d2936a3c3 Mon Sep 17 00:00:00 2001 From: Svetlana Terenteva Date: Wed, 30 Nov 2022 15:54:17 +0500 Subject: [PATCH 1/5] #1878 Remove husky --- .husky/pre-commit | 4 ---- .husky/pre-push | 4 ---- package.json | 3 +-- yarn.lock | 21 ++++++++++----------- 4 files changed, 11 insertions(+), 21 deletions(-) delete mode 100644 .husky/pre-commit delete mode 100644 .husky/pre-push diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index 0982f91a45..0000000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -yarn precommit diff --git a/.husky/pre-push b/.husky/pre-push deleted file mode 100644 index 84489edd6a..0000000000 --- a/.husky/pre-push +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -yarn prepush diff --git a/package.json b/package.json index 0289f01520..afa8a2bdac 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,9 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.2.0", "eslint-plugin-workspaces": "^0.7.0", - "husky": "^7.0.4", "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", diff --git a/yarn.lock b/yarn.lock index 614f42eb63..4ad0e3a2d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9108,15 +9108,6 @@ __metadata: languageName: node linkType: hard -"husky@npm:^7.0.4": - version: 7.0.4 - resolution: "husky@npm:7.0.4" - bin: - husky: lib/bin.js - checksum: c6ec4af63da2c9522da8674a20ad9b48362cc92704896cc8a58c6a2a39d797feb2b806f93fbd83a6d653fbdceb2c3b6e0b602c6b2e8565206ffc2882ef7db9e9 - languageName: node - linkType: hard - "iconv-lite@npm:0.4.24": version: 0.4.24 resolution: "iconv-lite@npm:0.4.24" @@ -14469,6 +14460,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" @@ -15792,10 +15792,9 @@ __metadata: eslint-plugin-node: ^11.1.0 eslint-plugin-promise: ^5.2.0 eslint-plugin-workspaces: ^0.7.0 - husky: ^7.0.4 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 From fb39619e23820f30243175dbe9877b7b34523980 Mon Sep 17 00:00:00 2001 From: Svetlana Terenteva Date: Wed, 30 Nov 2022 18:46:24 +0500 Subject: [PATCH 2/5] #1878 Re-install husky, test commit --- .husky/pre-commit | 4 +++ package.json | 9 ++++-- .../ui/state/{hotkeys.js => hotkeys.ts} | 13 ++++---- yarn.lock | 30 +++++++++++++++++++ 4 files changed, 47 insertions(+), 9 deletions(-) create mode 100755 .husky/pre-commit rename packages/ketcher-react/src/script/ui/state/{hotkeys.js => hotkeys.ts} (96%) diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000000..303dd1fce8 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +yarn run precommit diff --git a/package.json b/package.json index afa8a2bdac..ee5b152d4d 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,7 @@ ], "scripts": { "postinstall": "husky install", - "precommit": "lint-staged --allow-empty", - "prepush": "yarn workspaces foreach -pv run test:eslint", + "precommit": "lint-staged --allow-empty && yarn workspaces foreach -pv run prettier:write", "build": "yarn workspaces foreach -ptvR --from ketcher-react-app run build", "build:demo": "yarn workspaces foreach -ptvR --from demo run build", "test": "yarn workspaces foreach -v run test", @@ -27,6 +26,7 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.2.0", "eslint-plugin-workspaces": "^0.7.0", + "husky": "^8.0.2", "lint-staged": "^12.1.2", "npm-run-all": "^4.1.5", "prettier": "2.8.0", @@ -38,5 +38,8 @@ "resolutions": { "react-error-overlay": "6.0.9" }, - "packageManager": "yarn@3.1.0" + "packageManager": "yarn@3.1.0", + "dependencies": { + "react-device-detect": "^2.2.2" + } } diff --git a/packages/ketcher-react/src/script/ui/state/hotkeys.js b/packages/ketcher-react/src/script/ui/state/hotkeys.ts similarity index 96% rename from packages/ketcher-react/src/script/ui/state/hotkeys.js rename to packages/ketcher-react/src/script/ui/state/hotkeys.ts index b7d0fd64eb..6656c2b5a9 100644 --- a/packages/ketcher-react/src/script/ui/state/hotkeys.js +++ b/packages/ketcher-react/src/script/ui/state/hotkeys.ts @@ -28,6 +28,7 @@ import { load, onAction } from './shared' import actions from '../action' import keyNorm from '../data/convert/keynorm' import { openDialog } from './modal' +import { isIE } from 'react-device-detect' export function initKeydownListener(element) { return function (dispatch, getState) { @@ -49,7 +50,7 @@ function keyHandle(dispatch, state, hotKeys, event) { const key = keyNorm(event) const atomsSelected = editor.selection() && editor.selection().atoms - let group = null + let group if (key && key.length === 1 && atomsSelected && key.match(/\w/)) { openDialog(dispatch, 'labelEdit', { letter: key }) @@ -71,7 +72,7 @@ function keyHandle(dispatch, state, hotKeys, event) { const newAction = actions[actName].action dispatch(onAction(newAction)) event.preventDefault() - } else if (window.clipboardData) { + } else if (isIE) { // IE support clipArea.exec(event) } @@ -116,7 +117,7 @@ function checkGroupOnTool(group, actionTool) { const rxnTextPlain = /\$RXN\n+\s+0\s+0\s+0\n*/ /* ClipArea */ -export function initClipboard(dispatch, getState) { +export function initClipboard(dispatch, _getState) { const formats = Object.keys(formatProperties).map( (format) => formatProperties[format].mime ) @@ -169,7 +170,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' @@ -189,8 +190,8 @@ function clipData(editor) { // res['chemical/x-daylight-smiles'] = smiles.stringify(struct); return res - } catch (ex) { - errorHandler(ex.message) + } catch (e: any) { + errorHandler(e.message) } return null diff --git a/yarn.lock b/yarn.lock index 4ad0e3a2d8..70b3a340f1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9108,6 +9108,15 @@ __metadata: languageName: node linkType: hard +"husky@npm:^8.0.2": + version: 8.0.2 + resolution: "husky@npm:8.0.2" + bin: + husky: lib/bin.js + checksum: e101656fcb56163d610488f186448c78b132626aa427094489d886ce9374955a90274912b0f3a34af3326eaa74977883b032e5f701d7aaf4554daa5a7931be43 + languageName: node + linkType: hard + "iconv-lite@npm:0.4.24": version: 0.4.24 resolution: "iconv-lite@npm:0.4.24" @@ -14868,6 +14877,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 +15813,12 @@ __metadata: eslint-plugin-node: ^11.1.0 eslint-plugin-promise: ^5.2.0 eslint-plugin-workspaces: ^0.7.0 + husky: ^8.0.2 lint-staged: ^12.1.2 npm-run-all: ^4.1.5 prettier: 2.8.0 prettier-config-standard: ^4.0.0 + react-device-detect: ^2.2.2 stylelint: 13.13.1 stylelint-config-prettier: ^9.0.3 stylelint-config-standard: 22.0.0 @@ -17747,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" From 9a5e8d33046688a9fa6abd44eda1c9d037142731 Mon Sep 17 00:00:00 2001 From: Svetlana Terenteva Date: Wed, 30 Nov 2022 18:54:48 +0500 Subject: [PATCH 3/5] #1878 add pre-push hook --- .husky/pre-push | 4 ++++ package.json | 1 + 2 files changed, 5 insertions(+) create mode 100755 .husky/pre-push diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 0000000000..57db2274ed --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +yarn run prepush diff --git a/package.json b/package.json index ee5b152d4d..5f6e4e02dd 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "scripts": { "postinstall": "husky install", "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", "test": "yarn workspaces foreach -v run test", From 5a695e289cb698ba4c741e17dc84ddae8268ea37 Mon Sep 17 00:00:00 2001 From: Svetlana Terenteva Date: Thu, 1 Dec 2022 13:10:25 +0500 Subject: [PATCH 4/5] #1878 Fixes on comments --- package.json | 1 - packages/ketcher-react/package.json | 1 + packages/ketcher-react/src/script/ui/state/hotkeys.ts | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 5f6e4e02dd..3b9e8db2d0 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "resolutions": { "react-error-overlay": "6.0.9" }, - "packageManager": "yarn@3.1.0", "dependencies": { "react-device-detect": "^2.2.2" } diff --git a/packages/ketcher-react/package.json b/packages/ketcher-react/package.json index c9bcf70c7c..05b6c7adc5 100644 --- a/packages/ketcher-react/package.json +++ b/packages/ketcher-react/package.json @@ -130,6 +130,7 @@ "ts-jest": "^27.1.2", "typescript": "^4.5.2" }, + "packageManager": "yarn@3.1.0", "files": [ "dist" ] diff --git a/packages/ketcher-react/src/script/ui/state/hotkeys.ts b/packages/ketcher-react/src/script/ui/state/hotkeys.ts index 6656c2b5a9..9776897246 100644 --- a/packages/ketcher-react/src/script/ui/state/hotkeys.ts +++ b/packages/ketcher-react/src/script/ui/state/hotkeys.ts @@ -73,7 +73,6 @@ function keyHandle(dispatch, state, hotKeys, event) { dispatch(onAction(newAction)) event.preventDefault() } else if (isIE) { - // IE support clipArea.exec(event) } } From 514004b2640a232d966ea439132cf1c7c6779b1b Mon Sep 17 00:00:00 2001 From: Svetlana Terenteva Date: Thu, 1 Dec 2022 15:59:22 +0500 Subject: [PATCH 5/5] #1878 Fix deps --- package.json | 4 +--- packages/ketcher-react/package.json | 2 +- yarn.lock | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3b9e8db2d0..ef7576a3eb 100644 --- a/package.json +++ b/package.json @@ -36,10 +36,8 @@ "stylelint-config-prettier": "^9.0.3", "stylelint-config-standard": "22.0.0" }, + "packageManager": "yarn@3.1.0", "resolutions": { "react-error-overlay": "6.0.9" - }, - "dependencies": { - "react-device-detect": "^2.2.2" } } diff --git a/packages/ketcher-react/package.json b/packages/ketcher-react/package.json index 05b6c7adc5..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", @@ -130,7 +131,6 @@ "ts-jest": "^27.1.2", "typescript": "^4.5.2" }, - "packageManager": "yarn@3.1.0", "files": [ "dist" ] diff --git a/yarn.lock b/yarn.lock index 70b3a340f1..a9f5f99d5e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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 @@ -15818,7 +15819,6 @@ __metadata: npm-run-all: ^4.1.5 prettier: 2.8.0 prettier-config-standard: ^4.0.0 - react-device-detect: ^2.2.2 stylelint: 13.13.1 stylelint-config-prettier: ^9.0.3 stylelint-config-standard: 22.0.0