mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-07 12:29:50 +08:00
refactor(editor): unify directories naming (#11516)
**Directory Structure Changes** - Renamed multiple block-related directories by removing the "block-" prefix: - `block-attachment` → `attachment` - `block-bookmark` → `bookmark` - `block-callout` → `callout` - `block-code` → `code` - `block-data-view` → `data-view` - `block-database` → `database` - `block-divider` → `divider` - `block-edgeless-text` → `edgeless-text` - `block-embed` → `embed`
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import type { PropertyMetaConfig } from '@blocksuite/data-view';
|
||||
import type { DisposableMember } from '@blocksuite/global/disposable';
|
||||
import type { Block, BlockModel } from '@blocksuite/store';
|
||||
|
||||
type PropertyMeta<
|
||||
T extends BlockModel = BlockModel,
|
||||
RawValue = unknown,
|
||||
JsonValue = unknown,
|
||||
ColumnData extends NonNullable<unknown> = NonNullable<unknown>,
|
||||
> = {
|
||||
name: string;
|
||||
key: string;
|
||||
metaConfig: PropertyMetaConfig<string, ColumnData, RawValue, JsonValue>;
|
||||
getColumnData?: (block: T) => ColumnData;
|
||||
setColumnData?: (block: T, data: ColumnData) => void;
|
||||
get: (block: T) => RawValue;
|
||||
set?: (block: T, value: RawValue) => void;
|
||||
updated: (block: T, callback: () => void) => DisposableMember;
|
||||
};
|
||||
export type BlockMeta<T extends BlockModel = BlockModel> = {
|
||||
selector: (block: Block) => boolean;
|
||||
properties: PropertyMeta<T>[];
|
||||
};
|
||||
export const createBlockMeta = <T extends BlockModel>(
|
||||
options: Omit<BlockMeta<T>, 'properties'>
|
||||
) => {
|
||||
const meta: BlockMeta = {
|
||||
...options,
|
||||
properties: [],
|
||||
};
|
||||
return {
|
||||
...meta,
|
||||
addProperty: <Value>(property: PropertyMeta<T, Value>) => {
|
||||
meta.properties.push(property as PropertyMeta);
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { BlockMeta } from './base.js';
|
||||
import { todoMeta } from './todo.js';
|
||||
|
||||
export const blockMetaMap = {
|
||||
todo: todoMeta,
|
||||
} satisfies Record<string, BlockMeta>;
|
||||
@@ -0,0 +1,13 @@
|
||||
import { type ListBlockModel, ListBlockSchema } from '@blocksuite/affine-model';
|
||||
|
||||
import { createBlockMeta } from './base.js';
|
||||
|
||||
export const todoMeta = createBlockMeta<ListBlockModel>({
|
||||
selector: block => {
|
||||
if (block.flavour !== ListBlockSchema.model.flavour) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (block.model as ListBlockModel).props.type === 'todo';
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user