feat(editor): enable block meta for code, image, list block (#10905)

This commit is contained in:
Saul-Mirone
2025-03-17 03:29:51 +00:00
parent 8822acf041
commit 8bd4125c96
4 changed files with 33 additions and 15 deletions

View File

@@ -5,12 +5,14 @@ import {
type Text,
} from '@blocksuite/store';
interface CodeBlockProps {
import type { BlockMeta } from '../../utils/types';
type CodeBlockProps = {
text: Text;
language: string | null;
wrap: boolean;
caption: string;
}
} & BlockMeta;
export const CodeBlockSchema = defineBlockSchema({
flavour: 'affine:code',
@@ -20,6 +22,10 @@ export const CodeBlockSchema = defineBlockSchema({
language: null,
wrap: false,
caption: '',
'meta:createdAt': undefined,
'meta:createdBy': undefined,
'meta:updatedAt': undefined,
'meta:updatedBy': undefined,
}) as CodeBlockProps,
metadata: {
version: 1,

View File

@@ -9,6 +9,7 @@ import {
defineBlockSchema,
} from '@blocksuite/store';
import type { BlockMeta } from '../../utils/types.js';
import { ImageBlockTransformer } from './image-transformer.js';
export type ImageBlockProps = {
@@ -18,7 +19,8 @@ export type ImageBlockProps = {
height?: number;
rotate: number;
size?: number;
} & Omit<GfxCommonBlockProps, 'scale'>;
} & Omit<GfxCommonBlockProps, 'scale'> &
BlockMeta;
const defaultImageProps: ImageBlockProps = {
caption: '',
@@ -30,6 +32,10 @@ const defaultImageProps: ImageBlockProps = {
lockedBySelf: false,
rotate: 0,
size: -1,
'meta:createdAt': undefined,
'meta:createdBy': undefined,
'meta:updatedAt': undefined,
'meta:updatedBy': undefined,
};
export const ImageBlockSchema = defineBlockSchema({

View File

@@ -5,16 +5,18 @@ import {
defineBlockSchema,
} from '@blocksuite/store';
import type { BlockMeta } from '../../utils/types';
// `toggle` type has been deprecated, do not use it
export type ListType = 'bulleted' | 'numbered' | 'todo' | 'toggle';
export interface ListProps {
export type ListProps = {
type: ListType;
text: Text;
checked: boolean;
collapsed: boolean;
order: number | null;
}
} & BlockMeta;
export const ListBlockSchema = defineBlockSchema({
flavour: 'affine:list',
@@ -27,6 +29,10 @@ export const ListBlockSchema = defineBlockSchema({
// number type only for numbered list
order: null,
'meta:createdAt': undefined,
'meta:createdBy': undefined,
'meta:updatedAt': undefined,
'meta:updatedBy': undefined,
}) as ListProps,
metadata: {
version: 1,