alibaba / GGEditor

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

请问Mind如何设置三级和四级的样式 #204

Open suwu150 opened 5 years ago

suwu150 commented 5 years ago

这个功能解决了什么问题

看了你这个例子,https://codesandbox.io/s/3kpn6p09xm,发现一级节点和二级节点设置样式的方式如下:

    <GGEditor className="editor">
      <Mind
        className="mind"
        data={data}
        firstSubShape="custom-node"
        secondSubShape="custom-node"
      />
      <CustomNode />
    </GGEditor>

我目前需要自定义到四级,请问如何设置三级和四级的样式?还是暂时不支持? 我自己在项目中进行了如下尝试,一二级起作用了,三四级不起作用 image

-- image

你所期望的 API 是怎样的

如果可能,能否支持自定义三四级节点

gaoli commented 5 years ago

@suwu150 我更新了下 DEMO,需要覆盖 mind-base 节点 :)

<Fragment>
  <RegisterNode name="mind-base" config={config} extend={"mind-base"} />
  <RegisterNode name="custom-node" config={config} extend={"mind-base"} />
</Fragment>
suwu150 commented 5 years ago

@suwu150 我更新了下 DEMO,需要覆盖 mind-base 节点 :)

<Fragment>
  <RegisterNode name="mind-base" config={config} extend={"mind-base"} />
  <RegisterNode name="custom-node" config={config} extend={"mind-base"} />
</Fragment>

这样修改会影响到默认样式吧,我试了下,通过设置 name=“mind-base”的时候,能够对第三层和第四层起作用,但是并没有指定第三层用哪一个配置,第四层用哪一个配置,我希望能够进行自定义第三层样式和第四层样式,而非修改全局的,这种做法是修改了全局的吧

wellingfine commented 5 years ago

在数据里面写一个样式标记就行了,这样的话,可以针对任意的节点进行控制,但是需要对data进行一下处理。然后再改写下他的getStyle getLabelStyle 等几个方法,根据不同的data样式返回不同的值

roots:[{
  label:'root',
  style:'style-a'
}]
//覆盖样式
      getStyle(item) {
          var model =item.getModel()
          if(model['style-a']){return {...styleA}}
          return this.useStyle(item,'node')
    },