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

自定义HTML节点可以自适应宽高吗 #1340

Closed
balabll opened this issue Sep 14, 2023 · 3 comments
Closed

自定义HTML节点可以自适应宽高吗 #1340

balabll opened this issue Sep 14, 2023 · 3 comments

Comments

@balabll
Copy link

balabll commented Sep 14, 2023

问题描述
自定义HTML节点需要设置宽高,有没有可以节点自适应大小的方案?

场景
我希望我的节点中有一个按钮,点击按钮可以添加一行数据, 如果行数超出代码中设置的260px,超出的部分将会被隐藏,希望可以根据内容自适应宽高

class VueHtmlNodeModel extends HtmlNodeModel {
  setAttributes() {
    this.width = 280;
    this.height = 260;
    this.text.editable = false;
    this.inputData = this.text.value;
  }
  getOutlineStyle() {
    const style = super.getOutlineStyle();
    style.stroke = "none";
    style!.hover!.stroke = "none";
    return style;
  }
  getDefaultAnchor() {
    return [];
  }
  getData() {
    const data = super.getData();
    data.text!.value = this.inputData;
    return data;
  }
}

Originally posted by @balabll in #1338

@balabll balabll changed the title **问题描述** **自定义HTML节点可以自适应宽高吗** Sep 14, 2023
@balabll balabll changed the title **自定义HTML节点可以自适应宽高吗** 自定义HTML节点可以自适应宽高吗 Sep 14, 2023
@wumail
Copy link
Collaborator

wumail commented Sep 14, 2023

触发新增->获取元素的预设宽高或者通过DOM获取新增元素高度->更新节点宽高

@boyongjiong
Copy link
Collaborator

boyongjiong commented Sep 14, 2023

https://codesandbox.io/s/logicflow-base15-forked-rmrtxf?file=/step_15_sqlNode/index.js

看下这个示例是否符合预期呢

@wumail wumail closed this as completed Sep 19, 2023
@balabll
Copy link
Author

balabll commented Sep 19, 2023

@boyongjiong @wumail 感谢两位的解答和例子

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants