customNode.js
655 Bytes
import { RectNode, RectNodeModel } from "@logicflow/core";
class CustomNodeModel extends RectNodeModel {
// 重写获取文本位置的方法
getTextStyle() {
const style = super.getTextStyle();
style.textWidth = 200; // 设置更大的文本宽度
return style;
}
}
class CustomNode extends RectNode {
// 扩大文本点击区域
getTextBBox() {
const { model } = this.props;
const { x, y, width, height } = model;
return {
x: x - width / 2,
y: y - height / 2,
width: width,
height: height,
};
}
}
export default {
type: "custom-rect",
view: CustomNode,
model: CustomNodeModel,
};