alibaba / GGEditor

A visual graph editor based on G6 and React
https://ggeditor.com
MIT License
3.41k stars 573 forks source link

自定义Node继承于内置Node,怎么修改对应样式全局配置 #554

Closed umeimmense closed 4 years ago

umeimmense commented 4 years ago

这个功能解决了什么问题

 <RegisterNode
                name="customNode"
                config={{
                    // 设置高度
                    getSize(item: any) {
                        return [270, 84];
                    },
                    setState(name: any, value: any, item: any) {
                        setAnchorPointsState.call(
                            this,
                            name,
                            value,
                            item,
                            (item, anchorPoint) => {
                                const { width, height } = item.getKeyShape().getBBox();
                                const [x, y] = anchorPoint;
                                return {
                                    x: width * x - width / 2,
                                    y: height * y - height / 2,
                                };
                            },
                            (item, anchorPoint) => {
                                const { width, height } = item.getKeyShape().getBBox();
                                const [x, y] = anchorPoint;
                                return {
                                    x: width * x - width / 2,
                                    y: height * y - height / 2,
                                };
                            },
                        );
                    },
                    getAnchorPoints() {
                        return [[0, 0.5]];
                    }
                }}
                extend="modelRect"
            />

你所期望的 API 是怎样的

@gaoli 希望大佬帮忙解答一下