feat(editor): block comment extension (#12980)

#### PR Dependency Tree


* **PR #12980** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)
This commit is contained in:
L-Sun
2025-07-02 17:42:16 +08:00
committed by GitHub
parent 8ce85f708d
commit d768ad4af0
47 changed files with 432 additions and 38 deletions

View File

@@ -58,6 +58,8 @@ export type AttachmentBlockProps = {
style?: (typeof AttachmentBlockStyles)[number];
footnoteIdentifier: string | null;
comments?: Record<string, boolean>;
} & Omit<GfxCommonBlockProps, 'scale'> &
BlockMeta;
@@ -78,6 +80,7 @@ export const defaultAttachmentProps: AttachmentBlockProps = {
'meta:createdBy': undefined,
'meta:updatedBy': undefined,
footnoteIdentifier: null,
comments: undefined,
};
export const AttachmentBlockSchema = defineBlockSchema({

View File

@@ -28,6 +28,7 @@ export type BookmarkBlockProps = {
url: string;
caption: string | null;
footnoteIdentifier: string | null;
comments?: Record<string, boolean>;
} & LinkPreviewData &
Omit<GfxCommonBlockProps, 'scale'> &
BlockMeta;
@@ -52,6 +53,7 @@ const defaultBookmarkProps: BookmarkBlockProps = {
'meta:updatedBy': undefined,
footnoteIdentifier: null,
comments: undefined,
};
export const BookmarkBlockSchema = defineBlockSchema({

View File

@@ -14,6 +14,7 @@ type CodeBlockProps = {
caption: string;
preview?: boolean;
lineNumber?: boolean;
comments?: Record<string, boolean>;
} & BlockMeta;
export const CodeBlockSchema = defineBlockSchema({
@@ -26,6 +27,7 @@ export const CodeBlockSchema = defineBlockSchema({
caption: '',
preview: undefined,
lineNumber: undefined,
comments: undefined,
'meta:createdAt': undefined,
'meta:createdBy': undefined,
'meta:updatedAt': undefined,

View File

@@ -16,6 +16,7 @@ export type DatabaseBlockProps = {
title: Text;
cells: SerializedCells;
columns: Array<ColumnDataType>;
comments?: Record<string, boolean>;
};
export class DatabaseBlockModel extends BlockModel<DatabaseBlockProps> {}
@@ -27,6 +28,7 @@ export const DatabaseBlockSchema = defineBlockSchema({
title: internal.Text(),
cells: Object.create(null),
columns: [],
comments: undefined,
}),
metadata: {
role: 'hub',

View File

@@ -26,6 +26,7 @@ import { DefaultTheme } from '../../themes/default';
type EdgelessTextProps = {
hasMaxWidth: boolean;
comments?: Record<string, boolean>;
} & Omit<TextStyleProps, 'fontSize'> &
GfxCommonBlockProps;
@@ -54,6 +55,7 @@ export const EdgelessTextBlockSchema = defineBlockSchema({
scale: 1,
rotate: 0,
hasMaxWidth: false,
comments: undefined,
...EdgelessTextZodSchema.parse(undefined),
}),
metadata: {

View File

@@ -30,6 +30,7 @@ export type FrameBlockProps = {
background: Color;
childElementIds?: Record<string, boolean>;
presentationIndex?: string;
comments?: Record<string, boolean>;
} & GfxCompatibleProps;
export const FrameZodSchema = z
@@ -50,6 +51,7 @@ export const FrameBlockSchema = defineBlockSchema({
childElementIds: Object.create(null),
presentationIndex: generateKeyBetweenV2(null, null),
lockedBySelf: false,
comments: undefined,
}),
metadata: {
version: 1,

View File

@@ -19,6 +19,7 @@ export type ImageBlockProps = {
height?: number;
rotate: number;
size?: number;
comments?: Record<string, boolean>;
} & Omit<GfxCommonBlockProps, 'scale'> &
BlockMeta;
@@ -32,6 +33,7 @@ const defaultImageProps: ImageBlockProps = {
lockedBySelf: false,
rotate: 0,
size: -1,
comments: undefined,
'meta:createdAt': undefined,
'meta:createdBy': undefined,
'meta:updatedAt': undefined,

View File

@@ -11,6 +11,7 @@ import {
export type LatexProps = {
latex: string;
comments?: Record<string, boolean>;
} & GfxCommonBlockProps;
export const LatexBlockSchema = defineBlockSchema({
@@ -22,6 +23,7 @@ export const LatexBlockSchema = defineBlockSchema({
scale: 1,
rotate: 0,
latex: '',
comments: undefined,
}),
metadata: {
version: 1,

View File

@@ -16,6 +16,7 @@ export type ListProps = {
checked: boolean;
collapsed: boolean;
order: number | null;
comments?: Record<string, boolean>;
} & BlockMeta;
export const ListBlockSchema = defineBlockSchema({
@@ -29,6 +30,7 @@ export const ListBlockSchema = defineBlockSchema({
// number type only for numbered list
order: null,
comments: undefined,
'meta:createdAt': undefined,
'meta:createdBy': undefined,
'meta:updatedAt': undefined,

View File

@@ -69,6 +69,7 @@ export const NoteBlockSchema = defineBlockSchema({
shadowType: DEFAULT_NOTE_SHADOW,
},
},
comments: undefined,
}),
metadata: {
version: 1,
@@ -91,6 +92,7 @@ export type NoteProps = {
background: Color;
displayMode: NoteDisplayMode;
edgeless: NoteEdgelessProps;
comments?: Record<string, boolean>;
/**
* @deprecated
* use `displayMode` instead

View File

@@ -21,6 +21,7 @@ export type ParagraphProps = {
type: ParagraphType;
text: Text;
collapsed: boolean;
comments?: Record<string, boolean>;
} & BlockMeta;
export const ParagraphBlockSchema = defineBlockSchema({
@@ -29,6 +30,7 @@ export const ParagraphBlockSchema = defineBlockSchema({
type: 'text',
text: internal.Text(),
collapsed: false,
comments: undefined,
'meta:createdAt': undefined,
'meta:createdBy': undefined,
'meta:updatedAt': undefined,

View File

@@ -8,14 +8,16 @@ export type SurfaceRefProps = {
reference: string;
caption: string;
refFlavour: string;
comments?: Record<string, boolean>;
};
export const SurfaceRefBlockSchema = defineBlockSchema({
flavour: 'affine:surface-ref',
props: () => ({
props: (): SurfaceRefProps => ({
reference: '',
caption: '',
refFlavour: '',
comments: undefined,
}),
metadata: {
version: 1,

View File

@@ -29,6 +29,7 @@ export interface TableBlockProps extends BlockMeta {
columns: Record<string, TableColumn>;
// key = `${rowId}:${columnId}`
cells: Record<string, TableCell>;
comments?: Record<string, boolean>;
}
export interface TableCellSerialized {
@@ -51,6 +52,7 @@ export const TableBlockSchema = defineBlockSchema({
rows: {},
columns: {},
cells: {},
comments: undefined,
'meta:createdAt': undefined,
'meta:createdBy': undefined,
'meta:updatedAt': undefined,

View File

@@ -10,7 +10,11 @@ import {
import type { BlockMeta } from './types';
export type EmbedProps<Props = object> = Props & GfxCompatibleProps & BlockMeta;
export type EmbedProps<Props = object> = Props &
GfxCompatibleProps &
BlockMeta & {
comments?: Record<string, boolean>;
};
export function defineEmbedModel<
Props extends object,
@@ -52,6 +56,7 @@ export function createEmbedBlockSchema<
xywh: '[0,0,0,0]',
lockedBySelf: false,
rotate: 0,
comments: undefined,
'meta:createdAt': undefined,
'meta:updatedAt': undefined,
'meta:createdBy': undefined,