Commit 88d70148 authored by zhangbobell's avatar zhangbobell

fix(png): traverse the tree to judge if it has image

parent 2e933bd9
...@@ -120,23 +120,20 @@ define(function(require, exports, module) { ...@@ -120,23 +120,20 @@ define(function(require, exports, module) {
//svgUrl = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svgXml); //svgUrl = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svgXml);
var allNodes = minder.getAllNode();
var imagesInfo = []; var imagesInfo = [];
for(var i = 0; i < allNodes.length; i++) { // 遍历取出图片信息
var nodeData = allNodes[i].data; traverse(minder.getRoot());
if (nodeData.image && nodeData.expandState === 'expand') { function traverse(node) {
/* var nodeData = node.data;
* 导出之前渲染这个节点,否则取出的 contentBox 不对
* by zhangbobell if (nodeData.image) {
* */ minder.renderNode(node);
minder.renderNode(allNodes[i]); var nodeData = node.data;
var imageUrl = nodeData.image; var imageUrl = nodeData.image;
var imageSize = nodeData.imageSize; var imageSize = nodeData.imageSize;
var imageRenderBox = node.getRenderBox("ImageRenderer", minder.getRenderContainer());
var imageRenderBox = allNodes[i].getRenderBox('ImageRenderer', minder.getRenderContainer());
var imageInfo = { var imageInfo = {
url: imageUrl, url: imageUrl,
width: imageSize.width, width: imageSize.width,
...@@ -147,6 +144,16 @@ define(function(require, exports, module) { ...@@ -147,6 +144,16 @@ define(function(require, exports, module) {
imagesInfo.push(imageInfo); imagesInfo.push(imageInfo);
} }
// 若节点折叠,则直接返回
if (nodeData.expandState === 'collapse') {
return;
}
var children = node.getChildren();
for (var i = 0; i < children.length; i++) {
traverse(children[i]);
}
} }
return { return {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment