feat(core): support mentions in comments (#13000)

fix AF-2706, PD-2687

<img width="412" alt="image"
src="https://github.com/user-attachments/assets/b796f543-1c42-452a-8f65-9dddfa751ab4"
/>
<img width="384" alt="image"
src="https://github.com/user-attachments/assets/7ac3bcc5-6cf1-49bb-9786-1eb33fad7225"
/>
<img width="347" alt="image"
src="https://github.com/user-attachments/assets/02babd37-4740-4770-8be8-e253be18bb5a"
/>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

* **New Features**
* Added support for mentions in comments and replies, including
detection and notification when users are mentioned.
* Introduced new notification types for comments and comment mentions,
with dedicated notification components and localized messages.
  * Enabled navigation directly to specific comments from notifications.
* Sidebar comment tab and comment features now depend on both feature
flags and server support.

* **Improvements**
  * Comment creation and reply workflows now support optional mentions.
* Menu configurations for linked widgets can now selectively include
specific menu groups.
* Enhanced navigation helper with a function to jump directly to a page
comment.
  * Improved comment entity lifecycle management for proper cleanup.

* **Bug Fixes**
* Improved lifecycle management for comment entities to ensure proper
cleanup.

* **Style**
* Updated mention styling to use a dynamic font size based on theme
variables.
  * Adjusted comment preview container underline highlight color.

* **Localization**
* Added English translations for comment and mention notification
messages.

* **Configuration**
* Updated feature flag logic for comment features, making configuration
more flexible and environment-aware.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->





#### PR Dependency Tree


* **PR #13000** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)
This commit is contained in:
Peng Xiao
2025-07-03 14:44:14 +08:00
committed by GitHub
parent a7aa761e43
commit 532ea6af07
15 changed files with 317 additions and 26 deletions

View File

@@ -11,6 +11,7 @@ import {
} from '@affine/core/blocksuite/editors';
import { getViewManager } from '@affine/core/blocksuite/manager/view';
import { useEnableAI } from '@affine/core/components/hooks/affine/use-enable-ai';
import { ServerService } from '@affine/core/modules/cloud';
import type { DocCustomPropertyInfo } from '@affine/core/modules/db';
import type {
DatabaseRow,
@@ -21,6 +22,7 @@ import { FeatureFlagService } from '@affine/core/modules/feature-flag';
import { JournalService } from '@affine/core/modules/journal';
import { useInsidePeekView } from '@affine/core/modules/peek-view';
import { WorkspaceService } from '@affine/core/modules/workspace';
import { ServerFeature } from '@affine/graphql';
import track from '@affine/track';
import type { DocTitle } from '@blocksuite/affine/fragments/doc-title';
import type { DocMode } from '@blocksuite/affine/model';
@@ -80,7 +82,13 @@ const usePatchSpecs = (mode: DocMode) => {
featureFlagService.flags.enable_pdf_embed_preview.$
);
const enableComment = useLiveData(featureFlagService.flags.enable_comment.$);
const serverService = useService(ServerService);
const serverConfig = useLiveData(serverService.server.config$);
const enableComment =
useLiveData(featureFlagService.flags.enable_comment.$) &&
// comment may not be supported by the server
serverConfig.features.includes(ServerFeature.Comment);
const patchedSpecs = useMemo(() => {
const manager = getViewManager()

View File

@@ -1,11 +1,17 @@
import { AtMenuConfigService } from '@affine/core/modules/at-menu-config/services';
import {
AtMenuConfigService,
type LinkedMenuGroupType,
} from '@affine/core/modules/at-menu-config/services';
import type { LinkedWidgetConfig } from '@blocksuite/affine/widgets/linked-doc';
import { type FrameworkProvider } from '@toeverything/infra';
export function createLinkedWidgetConfig(
framework: FrameworkProvider
framework: FrameworkProvider,
options?: {
includedGroups?: LinkedMenuGroupType[];
}
): Partial<LinkedWidgetConfig> | undefined {
const service = framework.getOptional(AtMenuConfigService);
if (!service) return;
return service.getConfig();
return service.getConfig(options?.includedGroups);
}