Files
AFFiNE/blocksuite/framework/std/src/__tests__/test-gfx-element.ts
doouding d7268ce04c test: add std gfx test (#11442)
### Changed
- Move some intergraion tests to std as they are more like basic tests
- Add some basic gfx-related tests
2025-04-08 16:20:36 +00:00

45 lines
796 B
TypeScript

import type { SerializedXYWH } from '@blocksuite/global/gfx';
import {
convert,
derive,
field,
GfxLocalElementModel,
GfxPrimitiveElementModel,
} from '../gfx/index.js';
export class TestShapeElement extends GfxPrimitiveElementModel {
get type() {
return 'testShape';
}
@field()
accessor rotate: number = 0;
@field()
accessor xywh: SerializedXYWH = '[0,0,10,10]';
@convert(val => {
if (['rect', 'triangle'].includes(val)) {
return val;
}
return 'rect';
})
@derive(val => {
if (val === 'triangle') {
return {
rotate: 0,
};
}
return {};
})
@field()
accessor shapeType: 'rect' | 'triangle' = 'rect';
}
export class TestLocalElement extends GfxLocalElementModel {
override type: string = 'testLocal';
}