feat: mid click links to open in new tab (#7784)

fix AF-1200
This commit is contained in:
pengx17
2024-08-08 09:43:35 +00:00
parent fd6e198295
commit 7fca13076a
22 changed files with 163 additions and 78 deletions
@@ -2,14 +2,17 @@ import { type DependencyList, type SyntheticEvent } from 'react';
import { useAsyncCallback } from './affine-async-hooks';
export const useCatchEventCallback = <E extends SyntheticEvent>(
cb: (e: E) => void | Promise<void>,
export const useCatchEventCallback = <
E extends SyntheticEvent,
Args extends any[],
>(
cb: (e: E, ...args: Args) => void | Promise<void>,
deps: DependencyList
) => {
return useAsyncCallback(
async (e: E) => {
async (e: E, ...args: Args) => {
e.stopPropagation();
await cb(e);
await cb(e, ...args);
},
// eslint-disable-next-line react-hooks/exhaustive-deps
deps