Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report]: 自定义dynamicGroup节点会报Cannot read properties of undefined (reading 'gridSize')错误 #2054

Open
xiaozhaoCcz opened this issue Jan 22, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@xiaozhaoCcz
Copy link

发生了什么?

自定义dynamicGroup节点会报Cannot read properties of undefined (reading 'gridSize')错误

Image

//这是CustomGroup.ts文件的代码
import { dynamicGroup } from "@logicflow/extension";

class CustomGroup extends dynamicGroup.view {}

class CustomGroupModel extends dynamicGroup.model {
  getNodeStyle() {
    const style = super.getNodeStyle();
    style.stroke = "#AEAFAE";
    style.strokeDasharray = "3 3";
    style.strokeWidth = 1;
    return style;
  }
}

export default {
  type: "CustomGroup",
  model: CustomGroup,
  view: CustomGroupModel,
};
//这是CustomGroup.ts文件的代码


import LogicFlow from "@logicflow/core";
import {
  Control,
  Menu,
  DndPanel,
  DynamicGroup,
  SelectionSelect,
  MiniMap,
} from "@logicflow/extension";
import "@logicflow/core/lib/style/index.css";
import "@logicflow/extension/lib/style/index.css";

const lf = ref<any>(null);
const lfRef = ref<any>(null);

const nodes = ref([
  {
    id: "dynamic-group_1",
    type: "CustomGroup",
    x: 500,
    y: 140,
    // children: ["rect_3"],
    text: "dynamic-group_1",
    resizable: true,
    properties: {
      // resizable: true,
      collapsible: true,
      width: 420,
      height: 250,
      radius: 5,
      isCollapsed: true,
    },
  },
]);

const edges = ref([]);

onMounted(() => {
 lf.value = new LogicFlow({
    container: lfRef.value,
    grid: true,
    multipleSelectKey: "alt",
    autoExpand: false,
    allowResize: true,
    allowRotate: true,
    keyboard: {
      enabled: true,
    },
    plugins: [DynamicGroup, DndPanel, SelectionSelect, Menu],
  });

 lf.value.register(CustomGroup);
  lf.value.render({
    nodes: nodes.value,
    edges: edges.value,
  });
})

logicflow/core版本

2.0.10

logicflow/extension版本

2.0.14

logicflow/engine版本

No response

浏览器&环境

No response

@xiaozhaoCcz xiaozhaoCcz added the bug Something isn't working label Jan 22, 2025
@xiaozhaoCcz
Copy link
Author

需要自定义dynamicgroup节点实现锚点的功能,dynamicgroup节点也可以做出发节点

@DymoneLewis DymoneLewis self-assigned this Jan 23, 2025
@DymoneLewis
Copy link
Collaborator

这边先看下,稍等

@DymoneLewis
Copy link
Collaborator

需要自定义dynamicgroup节点实现锚点的功能,dynamicgroup节点也可以做出发节点

朋友这里model和view写反了
export default {
type: "CustomGroup",
model: CustomGroup,
view: CustomGroupModel,
};
应该是
export default {
type: "CustomGroup",
view: CustomGroup,
model: CustomGroupModel,
};

@DymoneLewis
Copy link
Collaborator

然后目前Group节点的锚点是透明的,如果要显示的话还需要重写getAnchorStyle,让锚点显示出来,可以参考这个demo里的customGroup2054.ts的实现看下
https://codesandbox.io/p/devbox/logicflow2-0demo-kv7vn5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants