mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-01 06:10:16 +08:00
chore: bump bs (#8227)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { DocMode, EdgelessRootService } from '@blocksuite/blocks';
|
||||
import type { InlineEditor } from '@blocksuite/inline/inline-editor';
|
||||
import type { InlineEditor } from '@blocksuite/inline';
|
||||
import type { AffineEditorContainer, DocTitle } from '@blocksuite/presets';
|
||||
import type { DocService, WorkspaceService } from '@toeverything/infra';
|
||||
import { Entity, LiveData } from '@toeverything/infra';
|
||||
|
||||
@@ -7,7 +7,11 @@ import { EditorOutlineViewer } from '@affine/core/components/blocksuite/outline-
|
||||
import { EditorService } from '@affine/core/modules/editor';
|
||||
import { PageNotFound } from '@affine/core/pages/404';
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
import type { DocMode, EdgelessRootService } from '@blocksuite/blocks';
|
||||
import {
|
||||
type DocMode,
|
||||
type EdgelessRootService,
|
||||
RefNodeSlotsProvider,
|
||||
} from '@blocksuite/blocks';
|
||||
import { Bound, DisposableGroup } from '@blocksuite/global/utils';
|
||||
import type { AffineEditorContainer } from '@blocksuite/presets';
|
||||
import {
|
||||
@@ -87,13 +91,12 @@ function DocPeekPreviewEditor({
|
||||
return;
|
||||
}
|
||||
const disposableGroup = new DisposableGroup();
|
||||
const rootService = editorContainer.host.std.getService('affine:page');
|
||||
if (!rootService) {
|
||||
return;
|
||||
}
|
||||
const refNodeSlots =
|
||||
editorContainer.host.std.getOptional(RefNodeSlotsProvider);
|
||||
if (!refNodeSlots) return;
|
||||
// doc change event inside peek view should be handled by peek view
|
||||
disposableGroup.add(
|
||||
rootService.slots.docLinkClicked.on(options => {
|
||||
refNodeSlots.docLinkClicked.on(options => {
|
||||
peekView
|
||||
.open({
|
||||
type: 'doc',
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import { LinkIcon } from '@blocksuite/icons/rc';
|
||||
import type { WorkspaceService } from '@toeverything/infra';
|
||||
import { Entity, LiveData } from '@toeverything/infra';
|
||||
|
||||
import { resolveLinkToDoc } from '../../navigation';
|
||||
import type { QuickSearchSession } from '../providers/quick-search-provider';
|
||||
import type { QuickSearchItem } from '../types/item';
|
||||
|
||||
type ExternalLinkPayload = {
|
||||
url: string;
|
||||
};
|
||||
|
||||
export class ExternalLinksQuickSearchSession
|
||||
extends Entity
|
||||
implements QuickSearchSession<'external-link', ExternalLinkPayload>
|
||||
{
|
||||
constructor(private readonly workspaceService: WorkspaceService) {
|
||||
super();
|
||||
}
|
||||
|
||||
query$ = new LiveData('');
|
||||
|
||||
items$ = LiveData.computed(get => {
|
||||
const query = get(this.query$);
|
||||
if (!query) return [];
|
||||
|
||||
const isLink = query.startsWith('http://') || query.startsWith('https://');
|
||||
if (!isLink) return [];
|
||||
|
||||
const resolvedDoc = resolveLinkToDoc(query);
|
||||
if (
|
||||
resolvedDoc &&
|
||||
resolvedDoc.workspaceId === this.workspaceService.workspace.id
|
||||
) {
|
||||
// is doc url
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
id: 'external-link:' + query,
|
||||
source: 'external-link',
|
||||
icon: LinkIcon,
|
||||
label: {
|
||||
key: 'com.affine.cmdk.affine.insert-link',
|
||||
},
|
||||
payload: { url: query },
|
||||
} as QuickSearchItem<'external-link', ExternalLinkPayload>,
|
||||
];
|
||||
});
|
||||
|
||||
query(query: string) {
|
||||
this.query$.next(query);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { ReferenceParams } from '@blocksuite/blocks';
|
||||
import { BlockLinkIcon, LinkIcon } from '@blocksuite/icons/rc';
|
||||
import type { DocsService } from '@toeverything/infra';
|
||||
import type { DocMode } from '@blocksuite/blocks';
|
||||
import { BlockLinkIcon, EdgelessIcon, PageIcon } from '@blocksuite/icons/rc';
|
||||
import type { DocsService, WorkspaceService } from '@toeverything/infra';
|
||||
import { Entity, LiveData } from '@toeverything/infra';
|
||||
import { isEmpty, pick, truncate } from 'lodash-es';
|
||||
import { truncate } from 'lodash-es';
|
||||
|
||||
import { resolveLinkToDoc } from '../../navigation';
|
||||
import type { QuickSearchSession } from '../providers/quick-search-provider';
|
||||
@@ -10,16 +10,10 @@ import type { DocDisplayMetaService } from '../services/doc-display-meta';
|
||||
import type { QuickSearchItem } from '../types/item';
|
||||
|
||||
type LinkPayload = {
|
||||
internal?: {
|
||||
docId: string;
|
||||
title?: string;
|
||||
blockId?: string;
|
||||
blockContent?: string;
|
||||
params?: ReferenceParams;
|
||||
};
|
||||
external?: {
|
||||
url: string;
|
||||
};
|
||||
docId: string;
|
||||
blockIds?: string[];
|
||||
elementIds?: string[];
|
||||
mode?: DocMode;
|
||||
};
|
||||
|
||||
export class LinksQuickSearchSession
|
||||
@@ -27,6 +21,7 @@ export class LinksQuickSearchSession
|
||||
implements QuickSearchSession<'link', LinkPayload>
|
||||
{
|
||||
constructor(
|
||||
private readonly workspaceService: WorkspaceService,
|
||||
private readonly docsService: DocsService,
|
||||
private readonly docDisplayMetaService: DocDisplayMetaService
|
||||
) {
|
||||
@@ -43,44 +38,25 @@ export class LinksQuickSearchSession
|
||||
if (!isLink) return [];
|
||||
|
||||
const resolvedDoc = resolveLinkToDoc(query);
|
||||
if (!resolvedDoc) {
|
||||
return [
|
||||
{
|
||||
id: 'link',
|
||||
source: 'link',
|
||||
icon: LinkIcon,
|
||||
label: {
|
||||
key: 'com.affine.cmdk.affine.insert-link',
|
||||
},
|
||||
payload: { external: { url: query } },
|
||||
} as QuickSearchItem<'link', LinkPayload>,
|
||||
];
|
||||
if (
|
||||
!resolvedDoc ||
|
||||
resolvedDoc.workspaceId !== this.workspaceService.workspace.id
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const docId = resolvedDoc.docId;
|
||||
const doc = this.docsService.list.doc$(docId).value;
|
||||
if (!doc || get(doc.trash$)) return [];
|
||||
|
||||
const params = pick(resolvedDoc, ['mode', 'blockIds', 'elementIds']);
|
||||
const { title, icon, updatedDate } =
|
||||
this.docDisplayMetaService.getDocDisplayMeta(doc);
|
||||
const blockId = params?.blockIds?.[0];
|
||||
const linkToNode = Boolean(blockId);
|
||||
const linkToNode = resolvedDoc.blockIds || resolvedDoc.elementIds;
|
||||
const score = 100;
|
||||
const internal = {
|
||||
docId,
|
||||
score,
|
||||
blockId,
|
||||
blockContent: '',
|
||||
};
|
||||
|
||||
if (linkToNode && !isEmpty(params)) {
|
||||
Object.assign(internal, { params });
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
id: ['doc', doc.id, linkToNode ? blockId : ''].join(':'),
|
||||
id: 'links:doc:' + doc.id,
|
||||
source: 'link',
|
||||
group: {
|
||||
id: 'docs',
|
||||
@@ -94,9 +70,20 @@ export class LinksQuickSearchSession
|
||||
title: title,
|
||||
},
|
||||
score,
|
||||
icon: linkToNode ? BlockLinkIcon : icon,
|
||||
icon: linkToNode
|
||||
? BlockLinkIcon
|
||||
: resolvedDoc.mode === 'page'
|
||||
? PageIcon
|
||||
: resolvedDoc.mode === 'edgeless'
|
||||
? EdgelessIcon
|
||||
: icon,
|
||||
timestamp: updatedDate,
|
||||
payload: { internal },
|
||||
payload: {
|
||||
docId,
|
||||
blockIds: resolvedDoc.blockIds,
|
||||
elementIds: resolvedDoc.elementIds,
|
||||
mode: resolvedDoc.mode,
|
||||
},
|
||||
} as QuickSearchItem<'link', LinkPayload>,
|
||||
];
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
GlobalContextService,
|
||||
WorkspaceLocalState,
|
||||
WorkspaceScope,
|
||||
WorkspaceService,
|
||||
} from '@toeverything/infra';
|
||||
|
||||
import { CollectionService } from '../collection';
|
||||
@@ -16,6 +17,7 @@ import { CollectionsQuickSearchSession } from './impls/collections';
|
||||
import { CommandsQuickSearchSession } from './impls/commands';
|
||||
import { CreationQuickSearchSession } from './impls/creation';
|
||||
import { DocsQuickSearchSession } from './impls/docs';
|
||||
import { ExternalLinksQuickSearchSession } from './impls/external-links';
|
||||
import { LinksQuickSearchSession } from './impls/links';
|
||||
import { RecentDocsQuickSearchSession } from './impls/recent-docs';
|
||||
import { TagsQuickSearchSession } from './impls/tags';
|
||||
@@ -30,6 +32,7 @@ export { CollectionsQuickSearchSession } from './impls/collections';
|
||||
export { CommandsQuickSearchSession } from './impls/commands';
|
||||
export { CreationQuickSearchSession } from './impls/creation';
|
||||
export { DocsQuickSearchSession } from './impls/docs';
|
||||
export { ExternalLinksQuickSearchSession } from './impls/external-links';
|
||||
export { LinksQuickSearchSession } from './impls/links';
|
||||
export { RecentDocsQuickSearchSession } from './impls/recent-docs';
|
||||
export { TagsQuickSearchSession } from './impls/tags';
|
||||
@@ -55,7 +58,12 @@ export function configureQuickSearchModule(framework: Framework) {
|
||||
DocsService,
|
||||
DocDisplayMetaService,
|
||||
])
|
||||
.entity(LinksQuickSearchSession, [DocsService, DocDisplayMetaService])
|
||||
.entity(LinksQuickSearchSession, [
|
||||
WorkspaceService,
|
||||
DocsService,
|
||||
DocDisplayMetaService,
|
||||
])
|
||||
.entity(ExternalLinksQuickSearchSession, [WorkspaceService])
|
||||
.entity(CreationQuickSearchSession)
|
||||
.entity(CollectionsQuickSearchSession, [CollectionService])
|
||||
.entity(TagsQuickSearchSession, [TagService])
|
||||
|
||||
@@ -48,13 +48,13 @@ export class CMDKQuickSearchService extends Service {
|
||||
}
|
||||
|
||||
if (result.source === 'link') {
|
||||
if (result.payload.internal) {
|
||||
const { docId, params } = result.payload.internal;
|
||||
this.workbenchService.workbench.openDoc({
|
||||
docId,
|
||||
...params,
|
||||
});
|
||||
}
|
||||
const { docId, blockIds, elementIds, mode } = result.payload;
|
||||
this.workbenchService.workbench.openDoc({
|
||||
docId,
|
||||
blockIds,
|
||||
elementIds,
|
||||
mode,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user