### Changed - Move some intergraion tests to std as they are more like basic tests - Add some basic gfx-related tests
45 lines
796 B
TypeScript
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';
|
|
}
|