/*
|
* @Description: file content
|
* @Author: your name
|
* @version:
|
* @Date: 2024-04-30 14:35:47
|
* @LastEditors: your name
|
* @LastEditTime: 2024-06-15 18:15:59
|
*/
|
import { RectNode, RectNodeModel } from '@logicflow/core';
|
|
class CustomRectNode extends RectNode {}
|
|
class CustomRectModel extends RectNodeModel {
|
override setAttributes() {
|
this.width = 120;
|
this.height = 40;
|
this.radius = 20;
|
}
|
override getTextStyle(): LogicFlow.TextNodeTheme {
|
const { refX = 0, refY = 0 } = this.properties as CustomProperties;
|
const style = super.getTextStyle();
|
|
// 通过 transform 重新设置 text 的位置
|
return {
|
...style,
|
transform: `matrix(1 0 0 1 ${refX} ${refY + 2})`,
|
};
|
}
|
override getNodeStyle() {
|
const style = super.getNodeStyle();
|
style.stroke = 'blue';
|
return style;
|
}
|
}
|
|
export default {
|
type: 'custom-rect',
|
view: CustomRectNode,
|
model: CustomRectModel,
|
};
|