import { register } from "@antv/x6-react-shape"; import { Node } from "@antv/x6"; import CustomInput from "../../CustomInput"; import { useSizeHook, useShapeProps } from "../../../hooks"; const component = ({ node }: { node: Node }) => { const { label, text1, text2, text, fill, stroke, opacity } = node.getData(); const { size, ref } = useSizeHook(); const { fillContent, defsContent, strokeColor, strokeWidth, strokeDasharray, } = useShapeProps(fill, size, stroke); const { width, height } = size || { width: 0, height: 0 }; return ( <>
{defsContent} {/* 类名 */}
{/* 属性 */}
{ node.setData({ text1: val }); }} />
{/* 方法 */}
{ node.setData({ text2: val }); }} />
); }; register({ shape: "custom-react-class1", width: 230, height: 150, effect: ["data"], component: component, }); const class1 = { name: "类", icon: require("./image/class1.png"), node: { shape: "custom-react-class1", data: { label: "类名", // 属性 text1: `+ attribute1:type = defaultValue + attribute2:type - attribute3:type`, // 方法 text2: `+ operation1(params):returnType - operation2(params) - operation3()`, text: { bold: true } }, }, }; export default class1;