Skip to content

Commit

Permalink
fix: useHotkeyListener not work under mac
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoKam committed Jul 26, 2023
1 parent 6f9ce73 commit a52acbd
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 30 deletions.
8 changes: 8 additions & 0 deletions packages/antd-plus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @orca-fe/painter

## 0.1.9

### Patch Changes

- update dependencies
- Updated dependencies
- @orca-fe/pocket@3.1.8

## 0.1.8

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/antd-plus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/antd-plus",
"version": "0.1.8",
"version": "0.1.9",
"description": "Transformer Container",
"keywords": [
"react",
Expand Down Expand Up @@ -36,9 +36,9 @@
"clear": "rimraf lib es"
},
"dependencies": {
"@orca-fe/hooks": "^1.8.5",
"@orca-fe/hooks": "^1.8.6",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/pocket": "^3.1.7",
"@orca-fe/pocket": "^3.1.8",
"@orca-fe/simple-jss": "^0.0.3",
"@orca-fe/tools": "^0.10.0",
"ahooks": "^3.7.8",
Expand Down
6 changes: 6 additions & 0 deletions packages/hooks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @orca-fe/hooks

## 1.8.6

### Patch Changes

- fix: useHotkeyListener not work under mac

## 1.8.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/hooks",
"version": "1.8.5",
"version": "1.8.6",
"description": "React Hooks Collections",
"keywords": [
"react",
Expand Down
8 changes: 4 additions & 4 deletions packages/hooks/src/hotkey-manager/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ export function toHotkeyStr(event: React.KeyboardEvent | KeyboardEvent) {
if (metaKey) {
keyArr.push('Command');
}
if (shiftKey) {
keyArr.push('Shift');
}
if (ctrlKey) {
keyArr.push('Ctrl');
}
if (shiftKey) {
keyArr.push('Shift');
}
if (/^[a-z]$/.test(key)) {
keyArr.push(key.toUpperCase());
} else {
Expand All @@ -69,7 +69,7 @@ export function toHotkeyStr(event: React.KeyboardEvent | KeyboardEvent) {
keyArr.push(key);
}
}
return keyArr.join('+');
return formatHotKeyStr(keyArr.join('+'));
}

export function divOnlyFilter(e: KeyboardEvent) {
Expand Down
6 changes: 6 additions & 0 deletions packages/hooks/src/useHotkeyListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ export const actionStack: HotkeyActionType[] = [];

const handleKeyDown = (e: KeyboardEvent) => {
const hotkeyStr = toHotkeyStr(e);
if (!hotkeyStr) return;
const keyMapping = isMac() ? mapping.macHotkeyMapping : mapping.hotkeyMapping;
const hotkeyName = keyMapping.get(hotkeyStr);

if (window.sessionStorage.useHotkeyListenerDebug) {
console.warn('hotkeyStr', hotkeyStr);
console.warn('hotkeyName', hotkeyName);
}

// 在监听器中查找 action
for (const action of actionStack) {
// 禁用的监听器,跳过
Expand Down
9 changes: 9 additions & 0 deletions packages/painter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @orca-fe/painter

## 1.4.33

### Patch Changes

- update dependencies
- Updated dependencies
- @orca-fe/transformer@0.3.21
- @orca-fe/pocket@3.1.8

## 1.4.32

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/painter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/painter",
"version": "1.4.32",
"version": "1.4.33",
"description": "Konva Painter",
"keywords": [
"react",
Expand Down Expand Up @@ -37,17 +37,17 @@
"clear": "rimraf lib es"
},
"dependencies": {
"@orca-fe/hooks": "^1.8.5",
"@orca-fe/hooks": "^1.8.6",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/pocket": "^3.1.7",
"@orca-fe/pocket": "^3.1.8",
"@orca-fe/simple-jss": "^0.0.3",
"@orca-fe/tools": "^0.10.0",
"ahooks": "^3.7.8",
"classnames": "^2.3.2",
"color": "^4.2.3",
"react-colorful": "^5.6.1",
"tslib": "^2.6.0",
"@orca-fe/transformer": "^0.3.20"
"@orca-fe/transformer": "^0.3.21"
},
"peerDependencies": {
"@ant-design/icons": "^4.7.0",
Expand Down
9 changes: 9 additions & 0 deletions packages/pdf-viewer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @orca-fe/pdf-viewer

## 1.16.12

### Patch Changes

- update dependencies
- Updated dependencies
- @orca-fe/painter@1.4.33
- @orca-fe/pocket@3.1.8

## 1.16.11

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/pdf-viewer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/pdf-viewer",
"version": "1.16.11",
"version": "1.16.12",
"description": "PDF Viewer",
"keywords": [
"react",
Expand Down Expand Up @@ -38,11 +38,11 @@
"clear": "rimraf lib es"
},
"dependencies": {
"@orca-fe/hooks": "^1.8.5",
"@orca-fe/hooks": "^1.8.6",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/painter": "^1.4.32",
"@orca-fe/painter": "^1.4.33",
"@orca-fe/pdfjs-dist-browserify": "^3.8.24",
"@orca-fe/pocket": "^3.1.7",
"@orca-fe/pocket": "^3.1.8",
"@orca-fe/simple-jss": "^0.0.3",
"@orca-fe/tools": "^0.10.0",
"ahooks": "^3.7.8",
Expand Down
6 changes: 6 additions & 0 deletions packages/pocket/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @orca-fe/pocket

## 3.1.8

### Patch Changes

- update dependencies

## 3.1.7

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/pocket/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/pocket",
"version": "3.1.7",
"version": "3.1.8",
"description": "UI components by orca-team",
"keywords": [
"react",
Expand Down Expand Up @@ -39,7 +39,7 @@
"clear": "rimraf lib es"
},
"dependencies": {
"@orca-fe/hooks": "^1.8.5",
"@orca-fe/hooks": "^1.8.6",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/tools": "^0.10.0",
"@rc-component/trigger": "^1.13.3",
Expand Down
6 changes: 6 additions & 0 deletions packages/transformer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @orca-fe/painter

## 0.3.21

### Patch Changes

- update dependencies

## 0.3.20

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/transformer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/transformer",
"version": "0.3.20",
"version": "0.3.21",
"description": "Transformer Container",
"keywords": [
"react",
Expand Down Expand Up @@ -42,7 +42,7 @@
"gl-matrix": "^3.4.3",
"prefix-classnames": "^0.0.7",
"tslib": "^2.6.0",
"@orca-fe/hooks": "^1.8.5",
"@orca-fe/hooks": "^1.8.6",
"@orca-fe/tools": "^0.10.0"
},
"peerDependencies": {
Expand Down
21 changes: 11 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit a52acbd

@vercel
Copy link

@vercel vercel bot commented on a52acbd Jul 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.