Commit 5eda0bb6 authored by techird's avatar techird

fix export issue

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