Commit 5eda0bb6 authored by techird's avatar techird

fix export issue

parent b3fb7421
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<meta name="title" content="百度脑图(KityMinder)"> <meta name="title" content="百度脑图(KityMinder)">
<meta name="keyword" content="kityminder,脑图,思维导图,kity,svg,minder,百度,fex,前端,在线"> <meta name="keyword" content="kityminder,脑图,思维导图,kity,svg,minder,百度,fex,前端,在线">
<meta name="description" content="百度脑图,便捷的脑图编辑工具。让您在线上直接创建、保存并分享你的思路。"> <meta name="description" content="百度脑图,便捷的脑图编辑工具。让您在线上直接创建、保存并分享你的思路。">
<meta name="viewport" content="width=device-width, height=content-height, initial-scale=1, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<script src="lib/jquery-2.1.0.min.js" charset="utf-8"></script> <script src="lib/jquery-2.1.0.min.js" charset="utf-8"></script>
<script src="lib/ZeroClipboard.min.js" charset="utf-8"></script> <script src="lib/ZeroClipboard.min.js" charset="utf-8"></script>
......
...@@ -5,39 +5,46 @@ KityMinder.registerModule('Zoom', function() { ...@@ -5,39 +5,46 @@ KityMinder.registerModule('Zoom', function() {
me.setDefaultOptions('zoom', [50, 80, 100, 120, 150, 200]); me.setDefaultOptions('zoom', [50, 80, 100, 120, 150, 200]);
function fixPaperCTM() { function fixPaperCTM(paper) {
var paper = me.getPaper();
var node = paper.shapeNode; var node = paper.shapeNode;
var ctm = node.getCTM(); var ctm = node.getCTM();
var matrix = new kity.Matrix(ctm.a, ctm.b, ctm.c, ctm.d, (ctm.e | 0) + 0.5, (ctm.f | 0) + 0.5); var matrix = new kity.Matrix(ctm.a, ctm.b, ctm.c, ctm.d, (ctm.e | 0) + 0.5, (ctm.f | 0) + 0.5);
node.setAttribute('transform', 'matrix(' + matrix.toString() + ')'); node.setAttribute('transform', 'matrix(' + matrix.toString() + ')');
} }
function zoomMinder(minder, zoom) { kity.extendClass(Minder, {
zoom: function(value) {
var paper = this.getPaper();
var viewport = paper.getViewPort();
viewport.zoom = value / 100;
viewport.center = {
x: viewport.center.x,
y: viewport.center.y
};
paper.setViewPort(viewport);
fixPaperCTM(paper);
}
});
function zoomMinder(minder, value) {
var paper = minder.getPaper(); var paper = minder.getPaper();
var viewport = paper.getViewPort(); var viewport = paper.getViewPort();
if (!zoom) return; if (!value) return;
var animator = new kity.Animator({ var animator = new kity.Animator({
beginValue: viewport.zoom, beginValue: minder._zoomValue,
finishValue: zoom / 100, finishValue: value,
setter: function(target, value) { setter: function(target, value) {
viewport.zoom = value; target.zoom(value);
viewport.center = {
x: viewport.center.x,
y: viewport.center.y
};
target.setViewPort(viewport);
fixPaperCTM();
} }
}); });
minder.zoom = zoom; minder._zoomValue = value;
if (timeline) { if (timeline) {
timeline.pause(); timeline.pause();
} }
timeline = animator.start(paper, 500, 'ease', function() { timeline = animator.start(minder, 100, 'ease', function() {
minder.refresh(500); minder.refresh(100);
}); });
} }
...@@ -45,7 +52,7 @@ KityMinder.registerModule('Zoom', function() { ...@@ -45,7 +52,7 @@ KityMinder.registerModule('Zoom', function() {
base: Command, base: Command,
execute: zoomMinder, execute: zoomMinder,
queryValue: function(minder) { queryValue: function(minder) {
return minder.zoom; return minder._zoomValue;
} }
}); });
...@@ -61,7 +68,7 @@ KityMinder.registerModule('Zoom', function() { ...@@ -61,7 +68,7 @@ KityMinder.registerModule('Zoom', function() {
var stack = minder.getOptions('zoom'), var stack = minder.getOptions('zoom'),
i; i;
for (i = 0; i < stack.length; i++) { for (i = 0; i < stack.length; i++) {
if (stack[i] > minder.zoom) return stack[i]; if (stack[i] > minder._zoomValue) return stack[i];
} }
return 0; return 0;
}, },
...@@ -80,7 +87,7 @@ KityMinder.registerModule('Zoom', function() { ...@@ -80,7 +87,7 @@ KityMinder.registerModule('Zoom', function() {
var stack = minder.getOptions('zoom'), var stack = minder.getOptions('zoom'),
i; i;
for (i = stack.length - 1; i >= 0; i--) { for (i = stack.length - 1; i >= 0; i--) {
if (stack[i] < minder.zoom) return stack[i]; if (stack[i] < minder._zoomValue) return stack[i];
} }
return 0; return 0;
}, },
...@@ -89,7 +96,7 @@ KityMinder.registerModule('Zoom', function() { ...@@ -89,7 +96,7 @@ KityMinder.registerModule('Zoom', function() {
return { return {
init: function() { init: function() {
this.zoom = 100; this._zoomValue = 100;
}, },
commands: { commands: {
'zoom-in': ZoomInCommand, 'zoom-in': ZoomInCommand,
...@@ -113,9 +120,6 @@ KityMinder.registerModule('Zoom', function() { ...@@ -113,9 +120,6 @@ KityMinder.registerModule('Zoom', function() {
} }
}, },
'ready': function() {
this._zoomValue = 1;
},
'normal.mousewheel readonly.mousewheel': function(e) { 'normal.mousewheel readonly.mousewheel': function(e) {
if (!e.originEvent.ctrlKey) return; if (!e.originEvent.ctrlKey) return;
var delta = e.originEvent.wheelDelta; var delta = e.originEvent.wheelDelta;
......
...@@ -10,14 +10,11 @@ if (!kity.Browser.ie) { ...@@ -10,14 +10,11 @@ if (!kity.Browser.ie) {
fileDescription: 'PNG 图片', fileDescription: 'PNG 图片',
fileExtension: '.png', fileExtension: '.png',
encode: function(json, km) { encode: function(json, km) {
var paper = km.getPaper(); var originZoom = km._zoomValue;
var viewport = paper.getViewPort();
var originZoom = viewport.zoom;
viewport.zoom = 1; var paper = km.getPaper(),
paper.setViewPort(viewport); paperTransform = paper.shapeNode.getAttribute('transform'),
domContainer = paper.container,
var domContainer = km.getPaper().container,
svgXml, svgXml,
$svg, $svg,
...@@ -27,27 +24,27 @@ if (!kity.Browser.ie) { ...@@ -27,27 +24,27 @@ if (!kity.Browser.ie) {
renderContainer = km.getRenderContainer(), renderContainer = km.getRenderContainer(),
renderBox = renderContainer.getRenderBox(), renderBox = renderContainer.getRenderBox(),
transform = renderContainer.getTransform(), width = renderBox.width + 1,
width = renderBox.width, height = renderBox.height + 1,
height = renderBox.height,
padding = 20, padding = 20,
canvas = document.createElement('canvas'), canvas = document.createElement('canvas'),
ctx = canvas.getContext('2d'), ctx = canvas.getContext('2d'),
blob, DomURL, url, img, finishCallback; blob, DomURL, url, img, finishCallback;
paper.shapeNode.setAttribute('transform', 'translate(0.5, 0.5)');
renderContainer.translate(-renderBox.x, -renderBox.y); renderContainer.translate(-renderBox.x, -renderBox.y);
svgXml = km.getPaper().container.innerHTML; svgXml = paper.container.innerHTML;
renderContainer.translate(renderBox.x, renderBox.y); renderContainer.translate(renderBox.x, renderBox.y);
viewport.zoom = originZoom;
paper.setViewPort(viewport); paper.shapeNode.setAttribute('transform', paperTransform);
$svg = $(svgXml).filter('svg'); $svg = $(svgXml).filter('svg');
$svg.attr({ $svg.attr({
width: renderBox.width, width: renderBox.width + 1,
height: renderBox.height, height: renderBox.height + 1,
style: 'font-family: Arial, "Microsoft Yahei","Heiti SC";' style: 'font-family: Arial, "Microsoft Yahei","Heiti SC";'
}); });
......
...@@ -6,14 +6,9 @@ if (!kity.Browser.ie) { ...@@ -6,14 +6,9 @@ if (!kity.Browser.ie) {
fileExtension: '.svg', fileExtension: '.svg',
mineType: 'image/svg+xml', mineType: 'image/svg+xml',
encode: function(json, km) { encode: function(json, km) {
var paper = km.getPaper();
var viewport = paper.getViewPort();
var originZoom = viewport.zoom;
viewport.zoom = 1; var paper = km.getPaper(),
paper.setViewPort(viewport); paperTransform = paper.shapeNode.getAttribute('transform'),
var domContainer = km.getPaper().container,
svgXml, svgXml,
$svg, $svg,
...@@ -24,13 +19,15 @@ if (!kity.Browser.ie) { ...@@ -24,13 +19,15 @@ if (!kity.Browser.ie) {
height = renderBox.height, height = renderBox.height,
padding = 20; padding = 20;
paper.shapeNode.setAttribute('transform', 'translate(0.5, 0.5)');
svgXml = km.getPaper().container.innerHTML; svgXml = km.getPaper().container.innerHTML;
paper.shapeNode.setAttribute('transform', paperTransform);
$svg = $(svgXml).filter('svg'); $svg = $(svgXml).filter('svg');
$svg.attr({ $svg.attr({
width: width + padding * 2 | 0, width: width + padding * 2 | 0,
height: height + padding * 2 | 0, height: height + padding * 2 | 0,
style: 'font-family: Arial, "Microsoft Yahei", "Heiti SC";' style: 'font-family: Arial, "Microsoft Yahei", "Heiti SC"; background: ' + km.getStyle('background')
}); });
$svg[0].setAttribute('viewBox', [renderBox.x - padding | 0, $svg[0].setAttribute('viewBox', [renderBox.x - padding | 0,
renderBox.y - padding | 0, renderBox.y - padding | 0,
...@@ -42,8 +39,6 @@ if (!kity.Browser.ie) { ...@@ -42,8 +39,6 @@ if (!kity.Browser.ie) {
svgXml = $('<div></div>').append($svg).html(); svgXml = $('<div></div>').append($svg).html();
svgXml = $('<div></div>').append($svg).html(); svgXml = $('<div></div>').append($svg).html();
viewport.zoom = originZoom;
paper.setViewPort(viewport);
// svg 含有 &nbsp; 符号导出报错 Entity 'nbsp' not defined // svg 含有 &nbsp; 符号导出报错 Entity 'nbsp' not defined
svgXml = svgXml.replace(/&nbsp;/g, '&#xa0;'); svgXml = svgXml.replace(/&nbsp;/g, '&#xa0;');
......
KityMinder.registerTheme('classic', { KityMinder.registerTheme('classic', {
'background': 'url(themes/default/images/grid.png) repeat', 'background': '#3A4144 url(themes/default/images/grid.png) repeat',
'root-color': '#430', 'root-color': '#430',
'root-background': '#e9df98', 'root-background': '#e9df98',
......
KityMinder.registerTheme('snow', { KityMinder.registerTheme('snow', {
'background': 'url(themes/default/images/grid.png) repeat', 'background': '#3A4144 url(themes/default/images/grid.png) repeat',
'root-color': '#430', 'root-color': '#430',
'root-background': '#e9df98', 'root-background': '#e9df98',
......
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