mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-07 20:31:33 +08:00
1f45cc5dec
**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`
30 lines
790 B
TypeScript
30 lines
790 B
TypeScript
import { getShapeName, type ShapeProps } from '@blocksuite/affine-model';
|
|
import type {
|
|
LastProps,
|
|
LastPropsKey,
|
|
} from '@blocksuite/affine-shared/services';
|
|
import { NodePropsSchema } from '@blocksuite/affine-shared/utils';
|
|
|
|
const LastPropsSchema = NodePropsSchema;
|
|
|
|
export function getLastPropsKey(
|
|
modelType: string,
|
|
modelProps: Partial<LastProps[LastPropsKey]>
|
|
): LastPropsKey | null {
|
|
if (modelType === 'shape') {
|
|
const { shapeType, radius } = modelProps as ShapeProps;
|
|
const shapeName = getShapeName(shapeType, radius);
|
|
return `${modelType}:${shapeName}`;
|
|
}
|
|
|
|
if (isLastPropsKey(modelType)) {
|
|
return modelType;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
function isLastPropsKey(key: string): key is LastPropsKey {
|
|
return Object.keys(LastPropsSchema.shape).includes(key);
|
|
}
|