Commit 4f8c1fb1 authored by Akikonata's avatar Akikonata

merge from dev

parents 62242512 1869f542
# KityMinder 更新日志 # KityMinder 更新日志
## v1.2.0
### 功能更新
1. 支持本地格式文件导入
* 支持文件拖拽和网盘文件导入
* 格式支持xmind/freemind/mindmanager,其他格式不支持
* 支持标签,包括优先级和任务进度
2. 新增节点移动到视野中
## v1.1.1 ## v1.1.1
### 功能更新 ### 功能更新
...@@ -15,6 +25,7 @@ ...@@ -15,6 +25,7 @@
1. 修复切换文件时,回复历史没有清空的问题 1. 修复切换文件时,回复历史没有清空的问题
2. 修复在添加 markers 时,会出现 js 报错的问题 2. 修复在添加 markers 时,会出现 js 报错的问题
3. 仅有根节点,将其删除,再添加节点报错
## v1.1.0 ## v1.1.0
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<link href="../themes/default/css/import.css" type="text/css" rel="stylesheet" /> <link href="../themes/default/css/import.css" type="text/css" rel="stylesheet" />
<link href="../dialogs/dialogs.css" rel="stylesheet" type="text/css" /> <link href="../dialogs/dialogs.css" rel="stylesheet" type="text/css" />
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon">
</head> </head>
<body> <body>
......
...@@ -115,6 +115,9 @@ $( function () { ...@@ -115,6 +115,9 @@ $( function () {
click: function () { click: function () {
window.open( 'http://pan.baidu.com/disk/home#dir/path=/apps/kityminder' ); window.open( 'http://pan.baidu.com/disk/home#dir/path=/apps/kityminder' );
} }
}, {
label: '注销',
click: logout
}, { }, {
divider: true divider: true
} ] } ]
...@@ -261,16 +264,27 @@ $( function () { ...@@ -261,16 +264,27 @@ $( function () {
} ); } );
} }
function logout() {
baidu.frontia.logOutCurrentAccount();
setAccount( null );
}
// 设置用户后为其初始化 // 设置用户后为其初始化
function setAccount( account ) { function setAccount( account ) {
currentAccount = account; currentAccount = account;
$user_btn.prependTo( $panel ); if ( account ) {
$save_btn.appendTo( $panel ); $user_btn.prependTo( $panel );
$share_btn.appendTo( $panel ); $save_btn.appendTo( $panel );
$login_btn.detach(); $share_btn.appendTo( $panel );
loadAvator(); $login_btn.detach();
loadRecent(); loadAvator();
window.location.hash = ''; loadRecent();
window.location.hash = '';
} else {
$user_btn.detach();
$save_btn.detach();
$login_btn.prependTo( $panel );
}
} }
// 加载用户头像 // 加载用户头像
......
...@@ -28,7 +28,7 @@ KM.registerToolbarUI( 'node', function ( name ) { ...@@ -28,7 +28,7 @@ KM.registerToolbarUI( 'node', function ( name ) {
comboboxWidget = $combox.kmui(); comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) { comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( res.value, new MinderNode( me.getLang().topic ) ); me.execCommand( res.value, new MinderNode( me.getLang().topic ), true );
} ).on( "beforeshow", function () { } ).on( "beforeshow", function () {
if ( $combox.parent().length === 0 ) { if ( $combox.parent().length === 0 ) {
$combox.appendTo( me.$container.find( '.kmui-dialog-container' ) ); $combox.appendTo( me.$container.find( '.kmui-dialog-container' ) );
......
// 选区管理 // 选区管理
kity.extendClass( Minder, function () { kity.extendClass( Minder, function () {
function highlightNode( km, node ) { function highlightNode( km, node ) {
node.setTmpData( "highlight", true ); if( node ){
km.highlightNode( node ); node.setTmpData( "highlight", true );
km.highlightNode( node );
}
} }
function unhighlightNode( km, node ) { function unhighlightNode( km, node ) {
node.setTmpData( "highlight", false ); if( node ){
km.highlightNode( node ); node.setTmpData( "highlight", false );
km.highlightNode( node );
}
} }
return { return {
_initSelection: function () { _initSelection: function () {
......
...@@ -30,7 +30,7 @@ KityMinder.registerModule( "basestylemodule", function () { ...@@ -30,7 +30,7 @@ KityMinder.registerModule( "basestylemodule", function () {
return -1; return -1;
} }
utils.each(nodes,function(i,n){ utils.each(nodes,function(i,n){
if(n.getData('bold')){ if( n && n.getData('bold') ){
result = 1; result = 1;
return false; return false;
} }
...@@ -65,7 +65,7 @@ KityMinder.registerModule( "basestylemodule", function () { ...@@ -65,7 +65,7 @@ KityMinder.registerModule( "basestylemodule", function () {
return -1; return -1;
} }
utils.each(nodes,function(i,n){ utils.each(nodes,function(i,n){
if(n.getData('italic')){ if( n && n.getData('italic') ){
result = 1; result = 1;
return false; return false;
} }
......
...@@ -142,6 +142,9 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -142,6 +142,9 @@ KityMinder.registerModule( "TextEditModule", function () {
if(cmds[e.commandName]){ if(cmds[e.commandName]){
var node = km.getSelectedNode(); var node = km.getSelectedNode();
if( !node ){
return;
}
var textShape = node.getTextShape(); var textShape = node.getTextShape();
......
...@@ -49,32 +49,16 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -49,32 +49,16 @@ KityMinder.registerModule( "KeyboardModule", function () {
}; };
} }
function coefForX( a, b ) {
return 0.1 * min( abs( a.top - b.top ), abs( a.bottom - b.bottom ) ) + 1;
}
function coefForY( a, b ) {
return 0.1 * min( abs( a.left - b.left ), abs( a.right - b.right ) ) + 1;
}
function findClosestPointsFor( pointIndexes, iFind ) { function findClosestPointsFor( pointIndexes, iFind ) {
var find = pointIndexes[ iFind ]; var find = pointIndexes[ iFind ];
var most = {}, quad; var most = {}, quad;
var current, dist; var current, dist;
var table = [];
console.log( 'table for ' + find.text );
for ( var i = 0; i < pointIndexes.length; i++ ) { for ( var i = 0; i < pointIndexes.length; i++ ) {
if ( i == iFind ) continue; if ( i == iFind ) continue;
current = pointIndexes[ i ]; current = pointIndexes[ i ];
dist = getCoefedDistance( current, find ); dist = getCoefedDistance( current, find );
table.push( {
text: current.text,
dist: dist.cx
} );
// left check // left check
if ( current.right < find.left ) { if ( current.right < find.left ) {
if ( !most.left || dist.cx < most.left.dist ) { if ( !most.left || dist.cx < most.left.dist ) {
...@@ -115,7 +99,6 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -115,7 +99,6 @@ KityMinder.registerModule( "KeyboardModule", function () {
} }
} }
} }
console.table( table );
find.node._nearestNodes = { find.node._nearestNodes = {
right: most.right && most.right.node || null, right: most.right && most.right.node || null,
top: most.top && most.top.node || null, top: most.top && most.top.node || null,
...@@ -151,11 +134,11 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -151,11 +134,11 @@ KityMinder.registerModule( "KeyboardModule", function () {
this.receiver.keydownNode = node; this.receiver.keydownNode = node;
switch ( e.originEvent.keyCode ) { switch ( e.originEvent.keyCode ) {
case keys.Enter: case keys.Enter:
this.execCommand( 'appendSiblingNode', new MinderNode( this.getLang().topic ) ); this.execCommand( 'appendSiblingNode', new MinderNode( this.getLang().topic ), true );
e.preventDefault(); e.preventDefault();
break; break;
case keys.Tab: case keys.Tab:
this.execCommand( 'appendChildNode', new MinderNode( this.getLang().topic ) ); this.execCommand( 'appendChildNode', new MinderNode( this.getLang().topic ), true );
e.preventDefault(); e.preventDefault();
break; break;
case keys.Backspace: case keys.Backspace:
......
...@@ -393,6 +393,21 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -393,6 +393,21 @@ KityMinder.registerModule( "LayoutDefault", function () {
Layout.shicon.update(); Layout.shicon.update();
} }
}; };
var showNodeInView = function( node ){
var padding = 5;
var viewport = minder.getPaper().getViewPort();
var offset = node.getRenderContainer().getRenderBox( minder.getRenderContainer() );
var tmpX = viewport.center.x * 2 - (offset.x + offset.width);
var tmpY = viewport.center.y * 2 - (offset.y + offset.height);
var dx = offset.x < 0 ? -offset.x : Math.min(tmpX, 0);
var dy = offset.y < 0 ? -offset.y : Math.min(tmpY, 0);
km.getRenderContainer().fxTranslate( dx, dy, 100, "easeOutQuint" );
};
var _style = { var _style = {
highlightNode: function ( node ) { highlightNode: function ( node ) {
var highlight = node.isHighlight(); var highlight = node.isHighlight();
...@@ -485,7 +500,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -485,7 +500,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
} }
_root.setPoint( _root.getLayout().x, _root.getLayout().y ); _root.setPoint( _root.getLayout().x, _root.getLayout().y );
}, },
appendChildNode: function ( parent, node, sibling ) { appendChildNode: function ( parent, node, focus, sibling ) {
minder.handelNodeInsert( node ); minder.handelNodeInsert( node );
node.clearLayout(); node.clearLayout();
var Layout = node.getLayout(); var Layout = node.getLayout();
...@@ -569,10 +584,14 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -569,10 +584,14 @@ KityMinder.registerModule( "LayoutDefault", function () {
translateNode( set[ i ] ); translateNode( set[ i ] );
updateConnectAndshIcon( set[ i ] ); updateConnectAndshIcon( set[ i ] );
} }
if( focus ){
showNodeInView( node );
}
}, },
appendSiblingNode: function ( sibling, node ) { appendSiblingNode: function ( sibling, node, focus ) {
var parent = sibling.getParent(); var parent = sibling.getParent();
this.appendChildNode( parent, node, sibling ); this.appendChildNode( parent, node, focus, sibling );
}, },
removeNode: function ( nodes ) { removeNode: function ( nodes ) {
while ( nodes.length !== 0 ) { while ( nodes.length !== 0 ) {
......
...@@ -40,13 +40,13 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -40,13 +40,13 @@ KityMinder.registerModule( "LayoutModule", function () {
} ); } );
this.getLayoutStyle( curStyle ).initStyle.call( this ); this.getLayoutStyle( curStyle ).initStyle.call( this );
}, },
appendChildNode: function ( parent, node, index ) { appendChildNode: function ( parent, node, focus, index ) {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).appendChildNode.call( this, parent, node, index ); this.getLayoutStyle( curStyle ).appendChildNode.call( this, parent, node, focus, index );
}, },
appendSiblingNode: function ( sibling, node ) { appendSiblingNode: function ( sibling, node, focus ) {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).appendSiblingNode.call( this, sibling, node ); this.getLayoutStyle( curStyle ).appendSiblingNode.call( this, sibling, node, focus );
}, },
removeNode: function ( nodes ) { removeNode: function ( nodes ) {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
...@@ -104,12 +104,18 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -104,12 +104,18 @@ KityMinder.registerModule( "LayoutModule", function () {
var AppendChildNodeCommand = kity.createClass( "AppendChildNodeCommand", ( function () { var AppendChildNodeCommand = kity.createClass( "AppendChildNodeCommand", ( function () {
return { return {
base: Command, base: Command,
execute: function ( km, node ) { execute: function ( km, node, focus, silbling ) {
var parent = km.getSelectedNode(); var parent = km.getSelectedNode();
if( !parent ){
return null;
}
if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && parent.getData( "expand" ) === false ) { if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && parent.getData( "expand" ) === false ) {
km.expandNode( parent ); km.expandNode( parent );
} }
km.appendChildNode( parent, node );
km.appendChildNode( parent, node, focus, silbling );
km.select( node, true ); km.select( node, true );
return node; return node;
}, },
...@@ -126,13 +132,17 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -126,13 +132,17 @@ KityMinder.registerModule( "LayoutModule", function () {
var AppendSiblingNodeCommand = kity.createClass( "AppendSiblingNodeCommand", ( function () { var AppendSiblingNodeCommand = kity.createClass( "AppendSiblingNodeCommand", ( function () {
return { return {
base: Command, base: Command,
execute: function ( km, node ) { execute: function ( km, node, focus ) {
var selectedNode = km.getSelectedNode(); var selectedNode = km.getSelectedNode();
if( !selectedNode ){
return null;
}
if ( selectedNode.isRoot() ) { if ( selectedNode.isRoot() ) {
node.setType( "main" ); node.setType( "main" );
km.appendChildNode( selectedNode, node ); km.appendChildNode( selectedNode, node, focus );
} else { } else {
km.appendSiblingNode( selectedNode, node ); km.appendSiblingNode( selectedNode, node, focus );
} }
km.select( node, true ); km.select( node, true );
return node; return node;
...@@ -152,6 +162,11 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -152,6 +162,11 @@ KityMinder.registerModule( "LayoutModule", function () {
return { return {
base: Command, base: Command,
execute: function ( km ) { execute: function ( km ) {
if( km.getRoot().children.length == 0 ){
return;
}
var selectedNodes = km.getSelectedNodes(); var selectedNodes = km.getSelectedNodes();
var _root = km.getRoot(); var _root = km.getRoot();
var _buffer = []; var _buffer = [];
......
...@@ -31,6 +31,8 @@ KityMinder.registerProtocal( "png", function () { ...@@ -31,6 +31,8 @@ KityMinder.registerProtocal( "png", function () {
renderContainer.translate( -renderBox.x, -renderBox.y ); renderContainer.translate( -renderBox.x, -renderBox.y );
svgXml = km.getPaper().container.innerHTML; svgXml = km.getPaper().container.innerHTML;
// svg 含有 &nbsp; 符号导出报错 Entity 'nbsp' not defined
svgXml = svgXml.replace(/&nbsp;/g, ' ').replace(/\s+/g, ' ');
renderContainer.translate( renderBox.x, renderBox.y ); renderContainer.translate( renderBox.x, renderBox.y );
......
...@@ -3,7 +3,8 @@ KityMinder.registerProtocal( "svg", function () { ...@@ -3,7 +3,8 @@ KityMinder.registerProtocal( "svg", function () {
fileDescription: 'SVG 矢量图', fileDescription: 'SVG 矢量图',
fileExtension: '.svg', fileExtension: '.svg',
encode: function ( json, km ) { encode: function ( json, km ) {
return km.getPaper().container.innerHTML; // svg 含有 &nbsp; 符号导出报错 Entity 'nbsp' not defined
return km.getPaper().container.innerHTML.replace(/&nbsp;/g, '&#xa0;');
}, },
recognizePriority: -1 recognizePriority: -1
}; };
......
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