mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-09 13:15:51 +08:00
fix(core): some ux enhancements on comments (#13105)
fix PD-2688 #### PR Dependency Tree * **PR #13105** 👈 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 ## Summary by CodeRabbit * **New Features** * Added configurable support for enabling or disabling inline comments. * Introduced visual indication (strikethrough) for deleted comments in the comment sidebar. * Sidebar now shows when a comment is no longer present in the editor. * Added a localized placeholder prompt ("What are your thoughts?") in the comment editor. * Integrated detailed event tracking for comment actions: create, edit, delete, and resolve. * **Improvements** * Inline comments are now disabled in shared mode. * Enhanced synchronization between editor comments and provider state to remove stale comments. * Inline comment features now respect the document’s read-only state. * Improved mention handling and tracking in comment creation and editing. * Comment manager and entities now dynamically track comments present in the editor. * Comment configuration updated to enable or disable inline comments based on settings. * **Bug Fixes** * Prevented comment block creation when in read-only mode. * **Localization** * Added English localization for the comment prompt. <!-- end of auto-generated comment: release notes by coderabbit.ai --> #### PR Dependency Tree * **PR #13105** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal)
This commit is contained in:
@@ -2,21 +2,41 @@ import {
|
||||
type ViewExtensionContext,
|
||||
ViewExtensionProvider,
|
||||
} from '@blocksuite/affine-ext-loader';
|
||||
import z from 'zod';
|
||||
|
||||
import { effects } from './effects';
|
||||
import { InlineCommentManager } from './inline-comment-manager';
|
||||
import { CommentInlineSpecExtension } from './inline-spec';
|
||||
import {
|
||||
CommentInlineSpecExtension,
|
||||
NullCommentInlineSpecExtension,
|
||||
} from './inline-spec';
|
||||
|
||||
export class InlineCommentViewExtension extends ViewExtensionProvider {
|
||||
const optionsSchema = z.object({
|
||||
enabled: z.boolean().optional().default(true),
|
||||
});
|
||||
|
||||
export class InlineCommentViewExtension extends ViewExtensionProvider<
|
||||
z.infer<typeof optionsSchema>
|
||||
> {
|
||||
override name = 'affine-inline-comment';
|
||||
|
||||
override schema = optionsSchema;
|
||||
|
||||
override effect(): void {
|
||||
super.effect();
|
||||
effects();
|
||||
}
|
||||
|
||||
override setup(context: ViewExtensionContext) {
|
||||
super.setup(context);
|
||||
context.register([CommentInlineSpecExtension, InlineCommentManager]);
|
||||
override setup(
|
||||
context: ViewExtensionContext,
|
||||
options?: z.infer<typeof optionsSchema>
|
||||
) {
|
||||
super.setup(context, options);
|
||||
context.register([
|
||||
options?.enabled
|
||||
? CommentInlineSpecExtension
|
||||
: NullCommentInlineSpecExtension,
|
||||
InlineCommentManager,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user