Files
AFFiNE-Mirror/blocksuite/affine/model/src/consts/shape.ts
T
L-Sun 7223d35c89 fix(editor): shape tool should be the last used shape (#12425)
Close [BS-3305](https://linear.app/affine-design/issue/BS-3305/白板按s应该使用上次的shape形状)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added a method to cycle through shape types when using the shape tool.

- **Bug Fixes**
  - Improved shape tool behavior to ensure the selected shape type does not change unexpectedly after adding a new shape.

- **Tests**
  - Added an end-to-end test to verify that the shape tool retains the selected shape type after adding a new shape.
  - Enhanced shortcut tests to verify cycling shapes forward and backward using 's' and 'Shift+s' keys.

- **Refactor**
  - Streamlined the logic for cycling through shape types and connector modes for improved maintainability.
  - Removed external utility for cycling shapes, integrating the functionality directly into the shape tool.
  - Updated keyboard shortcut handling to use the new cycling method within the shape tool.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-23 16:31:02 +00:00

47 lines
913 B
TypeScript

export const DEFAULT_ROUGHNESS = 1.4;
// TODO: need to check the default central area ratio
export const DEFAULT_CENTRAL_AREA_RATIO = 0.3;
export enum ShapeTextFontSize {
LARGE = 28,
MEDIUM = 20,
SMALL = 12,
XLARGE = 36,
}
export enum ShapeType {
Rect = 'rect',
Ellipse = 'ellipse',
Diamond = 'diamond',
Triangle = 'triangle',
}
export type ShapeName = ShapeType | 'roundedRect';
export function getShapeName(type: ShapeType, radius: number): ShapeName {
if (type === ShapeType.Rect && radius > 0) {
return 'roundedRect';
}
return type;
}
export function getShapeType(name: ShapeName): ShapeType {
if (name === 'roundedRect') {
return ShapeType.Rect;
}
return name;
}
export function getShapeRadius(name: ShapeName): number {
if (name === 'roundedRect') {
return 0.1;
}
return 0;
}
export enum ShapeStyle {
General = 'General',
Scribbled = 'Scribbled',
}