Files
AFFiNE-Mirror/blocksuite/affine/foundation/src/view.ts
T
L-Sun 1d865f16fe feat(editor): comment for edgeless element (#13098)
#### PR Dependency Tree


* **PR #13098** 👈

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**
* Added support for comments on graphical elements, allowing users to
comment on both blocks and graphical elements within surfaces.
* Enhanced comment previews to include graphical elements in selection
summaries.
* Improved editor navigation to focus on commented graphical elements in
addition to blocks and inline texts.

* **Bug Fixes**
* Updated comment highlighting and management to consistently use the
new comment manager across all block and element types.

* **Refactor**
* Renamed and extended the comment manager to handle both block and
element comments.
* Streamlined toolbar configurations by removing outdated comment button
entries and adding a consolidated comment button in the root toolbar.

* **Tests**
* Disabled the mock comment provider integration in the test editor
environment to refine testing setup.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-08 10:33:09 +00:00

106 lines
2.9 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,
BlockElementCommentManager,
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,
BlockElementCommentManager,
]);
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));
}
}
}