mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-21 00:07:01 +08:00
Closes: [BS-3551](https://linear.app/affine-design/issue/BS-3551/citation埋点) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced citation tracking across attachments, bookmarks, embedded documents, paragraphs, footnotes, rename modals, and toolbars for actions like editing, deleting, expanding, and hovering on citations. - Introduced a centralized citation service to unify citation detection and telemetry event management. - **Chores** - Updated service exports and telemetry modules to include the new citation service and citation-related event types. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
104 lines
2.8 KiB
TypeScript
104 lines
2.8 KiB
TypeScript
import { FileDropExtension } from '@blocksuite/affine-components/drop-indicator';
|
|
import {
|
|
PeekViewExtension,
|
|
type PeekViewService,
|
|
} from '@blocksuite/affine-components/peek';
|
|
import {
|
|
type ViewExtensionContext,
|
|
ViewExtensionProvider,
|
|
} from '@blocksuite/affine-ext-loader';
|
|
import {
|
|
AutoClearSelectionService,
|
|
CitationService,
|
|
DefaultOpenDocExtension,
|
|
DNDAPIExtension,
|
|
DocDisplayMetaService,
|
|
DocModeService,
|
|
EditPropsStore,
|
|
EmbedOptionService,
|
|
FileSizeLimitService,
|
|
FontConfigExtension,
|
|
fontConfigSchema,
|
|
FontLoaderService,
|
|
LinkPreviewCache,
|
|
LinkPreviewCacheConfigSchema,
|
|
LinkPreviewCacheExtension,
|
|
LinkPreviewService,
|
|
PageViewportServiceExtension,
|
|
TelemetryExtension,
|
|
type TelemetryService,
|
|
ThemeService,
|
|
ToolbarRegistryExtension,
|
|
} from '@blocksuite/affine-shared/services';
|
|
import { InteractivityManager, ToolController } from '@blocksuite/std/gfx';
|
|
import { z } from 'zod';
|
|
|
|
import { clipboardConfigs } from './clipboard';
|
|
import { effects } from './effects';
|
|
|
|
const optionsSchema = z.object({
|
|
linkPreviewCacheConfig: z.optional(LinkPreviewCacheConfigSchema),
|
|
fontConfig: z.optional(z.array(fontConfigSchema)),
|
|
telemetry: z.optional(z.custom<TelemetryService>()),
|
|
peekView: z.optional(z.custom<PeekViewService>()),
|
|
});
|
|
|
|
export type FoundationViewExtensionOptions = z.infer<typeof optionsSchema>;
|
|
|
|
export class FoundationViewExtension extends ViewExtensionProvider<FoundationViewExtensionOptions> {
|
|
override name = 'foundation';
|
|
|
|
override schema = optionsSchema;
|
|
|
|
override effect() {
|
|
super.effect();
|
|
effects();
|
|
}
|
|
|
|
override setup(
|
|
context: ViewExtensionContext,
|
|
options?: FoundationViewExtensionOptions
|
|
) {
|
|
super.setup(context, options);
|
|
context.register([
|
|
DocDisplayMetaService,
|
|
EditPropsStore,
|
|
DefaultOpenDocExtension,
|
|
FontLoaderService,
|
|
|
|
DocModeService,
|
|
ThemeService,
|
|
EmbedOptionService,
|
|
PageViewportServiceExtension,
|
|
DNDAPIExtension,
|
|
FileDropExtension,
|
|
ToolbarRegistryExtension,
|
|
AutoClearSelectionService,
|
|
FileSizeLimitService,
|
|
LinkPreviewCache,
|
|
LinkPreviewService,
|
|
CitationService,
|
|
]);
|
|
context.register(clipboardConfigs);
|
|
if (this.isEdgeless(context.scope)) {
|
|
context.register([InteractivityManager, ToolController]);
|
|
}
|
|
const fontConfig = options?.fontConfig;
|
|
if (fontConfig) {
|
|
context.register(FontConfigExtension(fontConfig));
|
|
}
|
|
const linkPreviewCacheConfig = options?.linkPreviewCacheConfig;
|
|
if (linkPreviewCacheConfig) {
|
|
context.register(LinkPreviewCacheExtension(linkPreviewCacheConfig));
|
|
}
|
|
const telemetry = options?.telemetry;
|
|
if (telemetry) {
|
|
context.register(TelemetryExtension(telemetry));
|
|
}
|
|
const peekView = options?.peekView;
|
|
if (peekView) {
|
|
context.register(PeekViewExtension(peekView));
|
|
}
|
|
}
|
|
}
|