mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
feat: ctrl click to open embeded doc in new tab (#8401)
fix AF-1176 depends on https://github.com/toeverything/blocksuite/pull/8478
This commit is contained in:
@@ -44,6 +44,7 @@ import { BlocksuiteEditorJournalDocTitle } from './journal-doc-title';
|
||||
import {
|
||||
patchDocModeService,
|
||||
patchEdgelessClipboard,
|
||||
patchEmbedLinkedDocBlockConfig,
|
||||
patchForSharedPage,
|
||||
patchNotificationService,
|
||||
patchParseDocUrlExtension,
|
||||
@@ -135,6 +136,7 @@ const usePatchSpecs = (shared: boolean, mode: DocMode) => {
|
||||
patched = patched.concat(patchEdgelessClipboard());
|
||||
patched = patched.concat(patchParseDocUrlExtension(framework));
|
||||
patched = patched.concat(patchQuickSearchService(framework));
|
||||
patched = patched.concat(patchEmbedLinkedDocBlockConfig(framework));
|
||||
if (shared) {
|
||||
patched = patched.concat(patchForSharedPage());
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import {
|
||||
RecentDocsQuickSearchSession,
|
||||
} from '@affine/core/modules/quicksearch';
|
||||
import { ExternalLinksQuickSearchSession } from '@affine/core/modules/quicksearch/impls/external-links';
|
||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||
import { isNewTabTrigger } from '@affine/core/utils';
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
import { track } from '@affine/track';
|
||||
import {
|
||||
@@ -41,6 +43,7 @@ import {
|
||||
DocModeExtension,
|
||||
EdgelessRootBlockComponent,
|
||||
EmbedLinkedDocBlockComponent,
|
||||
EmbedLinkedDocBlockConfigExtension,
|
||||
NotificationExtension,
|
||||
ParseDocUrlExtension,
|
||||
PeekViewExtension,
|
||||
@@ -224,6 +227,20 @@ export function patchNotificationService({
|
||||
});
|
||||
}
|
||||
|
||||
export function patchEmbedLinkedDocBlockConfig(framework: FrameworkProvider) {
|
||||
const getWorkbench = () => framework.get(WorkbenchService).workbench;
|
||||
|
||||
return EmbedLinkedDocBlockConfigExtension({
|
||||
handleClick(e, _, refInfo) {
|
||||
if (isNewTabTrigger(e)) {
|
||||
const workbench = getWorkbench();
|
||||
workbench.openDoc(refInfo.pageId, { at: 'new-tab' });
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function patchPeekViewService(service: PeekViewService) {
|
||||
return PeekViewExtension({
|
||||
peek: (target: ActivePeekView['target'], template?: TemplateResult) => {
|
||||
|
||||
@@ -13,6 +13,6 @@ export function stopEvent(event: BaseSyntheticEvent) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
export function isNewTabTrigger(event?: React.MouseEvent) {
|
||||
export function isNewTabTrigger(event?: React.MouseEvent | MouseEvent) {
|
||||
return event ? event.ctrlKey || event.metaKey || event.button === 1 : false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user