X6 icon indicating copy to clipboard operation
X6 copied to clipboard

自定义vue节点,使用el-input组件, type为textarea,导出图片时,textarea的内容没有导出,显示为空

Open leixinglong opened this issue 1 year ago • 7 comments

问题描述

自定义vue节点,使用el-input组件, type为textarea,到处图片时,textarea的内容没有导出,显示为空,有一个issue,说的是input标签,内容显示为空,没有设置value属性,已经尝试设置了value属性,导出还是显示未空。

重现链接

见代码

重现步骤

使用toPng()进行图片导出

预期行为

自定义vue节点,使用el-input组件, type为textarea,导出图片时,textarea的内容需要显示

平台

  • 操作系统: [Windows]
  • 网页浏览器: [Google Chrome]
  • X6 版本: [2.16.1]

屏幕截图或视频(可选)

画布显示: image 导出显示: image

补充说明(可选)

自定义Node组件: <ElInput class="input-text" v-model="text" type="textarea" @blur="blur" resize="none" maxlength="255" :show-word-limit="true" />

leixinglong avatar Jul 18 '24 03:07 leixinglong

👋 @leixinglong

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. To help make it easier for us to investigate your issue, please follow the contributing guidelines. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

x6-bot[bot] avatar Jul 18 '24 03:07 x6-bot[bot]

楼主,这个问题解决了吗?我也遇到了

zlecheng avatar Aug 05 '24 06:08 zlecheng

没有,没人响应。。。。

leixinglong avatar Aug 08 '24 03:08 leixinglong

如果只是想导出图片的话,就使用html-to-image吧

PalmerShuai avatar Dec 12 '24 06:12 PalmerShuai

不知道是不是没有样式的问题,我使用的react+antd自定义组件,导出的input是有值的,代码仅供参考

function injectStylesToSvg(svg) {
  const style = document.createElement("style");
  style.innerHTML = Array.from(document.styleSheets)
    .filter(
      (styleSheet) =>
        // Prevent CORS errors
        !styleSheet.href || styleSheet.href.startsWith(document.location.origin)
    )
    .map((styleSheet) =>
      Array.from(styleSheet.cssRules)
        .map((rule) => rule.cssText)
        .join(" ")
    )
    .join(" ");
  svg.prepend(style);
}

graph.exportPNG("xflow", {
  padding: 20,
  copyStyles: false,
  beforeSerialize(svg) {
    injectStylesToSvg(svg);
  },
});

xflow (1)

zcrun avatar Jan 09 '25 02:01 zcrun

不知道是不是没有样式的问题,我使用的react+antd自定义组件,导出的input是有值的,代码仅供参考

function injectStylesToSvg(svg) {
  const style = document.createElement("style");
  style.innerHTML = Array.from(document.styleSheets)
    .filter(
      (styleSheet) =>
        // Prevent CORS errors
        !styleSheet.href || styleSheet.href.startsWith(document.location.origin)
    )
    .map((styleSheet) =>
      Array.from(styleSheet.cssRules)
        .map((rule) => rule.cssText)
        .join(" ")
    )
    .join(" ");
  svg.prepend(style);
}

graph.exportPNG("xflow", {
  padding: 20,
  copyStyles: false,
  beforeSerialize(svg) {
    injectStylesToSvg(svg);
  },
});

xflow (1)

input标签是可以导出的,但是textarea就会导出为空了~~~

leixinglong avatar Mar 28 '25 07:03 leixinglong

@leixinglong 测试了textarea也是有样式的 Image

zcrun avatar Mar 31 '25 06:03 zcrun