mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-19 23:37:15 +08:00
fix(editor): middle click open new tab (#12902)
Close [BS-3251](https://linear.app/affine-design/issue/BS-3251/正文的inline链接,chrome中,中键开新窗口的行为丢失了) #### PR Dependency Tree * **PR #12902** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Middle-clicking on links and references now opens them in a new browser tab. - Linux platform detection has been added for improved environment-specific behavior. - **Bug Fixes** - Middle-click paste prevention is now limited to Linux environments when the relevant setting is disabled and excludes clicks on links and references. - **Tests** - Added end-to-end tests to verify that middle-clicking links opens them in a new tab for external links, internal links, and reference documents. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -14,6 +14,7 @@ import track from '@affine/track';
|
||||
import { appendParagraphCommand } from '@blocksuite/affine/blocks/paragraph';
|
||||
import type { DocTitle } from '@blocksuite/affine/fragments/doc-title';
|
||||
import { DisposableGroup } from '@blocksuite/affine/global/disposable';
|
||||
import { IS_LINUX } from '@blocksuite/affine/global/env';
|
||||
import type { DocMode, RootBlockModel } from '@blocksuite/affine/model';
|
||||
import {
|
||||
customImageProxyMiddleware,
|
||||
@@ -178,7 +179,14 @@ const BlockSuiteEditorImpl = ({
|
||||
const editorContainer = rootRef.current;
|
||||
if (editorContainer) {
|
||||
const handleMiddleClick = (e: MouseEvent) => {
|
||||
if (!enableMiddleClickPaste && e.button === 1) {
|
||||
if (
|
||||
e.target instanceof HTMLElement &&
|
||||
(e.target.closest('affine-reference') ||
|
||||
e.target.closest('affine-link'))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (!enableMiddleClickPaste && IS_LINUX && e.button === 1) {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user