Commit be73a534 authored by campaign's avatar campaign

Merge remote-tracking branch 'origin/dev' into dev

parents 04b2edfe 635f2491
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
# KityMinder 更新日志 # KityMinder 更新日志
##1.1.3 ##1.1.3
###功能更新 ###功能更新
1. 添加保存时可修改文件名 1. 保存时可自定义文件名
2. 添加超链接功能 2. 添加/删除超链接,导入第三方格式支持超链接
3. 选中节点时,按F2直接进入文字编辑状态 3. 选中节点时,按F2直接进入文字编辑状态
4. 添加展开收起节点 4. "展开全部节点""收起全部节点"功能
5. 当前选中的高亮的节点可直接进行文字编辑 5. 当前选中的高亮的节点可直接进行文字编辑
6. 添加右键选中节点,显示编辑节点的快捷键和菜单
##问题修复 ##问题修复
1. 修复当滚动鼠标滚轮时,光标不跟着移动的问题 1. 修复当滚动鼠标滚轮时,光标不跟着移动的问题
......
...@@ -79,7 +79,7 @@ $( function () { ...@@ -79,7 +79,7 @@ $( function () {
minder = window.km, minder = window.km,
// 草稿箱实例 // 草稿箱实例
draftManager = window.draftManager || ( window.draftManager = new window.DraftManager( minder ) ), draftManager,
// 当前是否要检测文档内容是否变化的开关 // 当前是否要检测文档内容是否变化的开关
watchingChanges = true, watchingChanges = true,
...@@ -99,8 +99,8 @@ $( function () { ...@@ -99,8 +99,8 @@ $( function () {
loadShare(); loadShare();
bindShortCuts(); bindShortCuts();
bindDraft(); bindDraft();
watchChanges(); draftManager && watchChanges();
if ( !loadPath() && !isShareLink ) loadDraft( 0 ); if ( draftManager && !loadPath() && !isShareLink ) loadDraft( 0 );
} }
// 创建 UI // 创建 UI
...@@ -159,6 +159,7 @@ $( function () { ...@@ -159,6 +159,7 @@ $( function () {
}, 30 ); }, 30 );
} ); } );
if ( window.ZeroClipboard ) {
var clip = new window.ZeroClipboard( $copy_url_btn, { var clip = new window.ZeroClipboard( $copy_url_btn, {
hoverClass: 'hover', hoverClass: 'hover',
activeClass: 'active' activeClass: 'active'
...@@ -168,6 +169,7 @@ $( function () { ...@@ -168,6 +169,7 @@ $( function () {
clearTimeout( copyTrickTimer ); clearTimeout( copyTrickTimer );
} ); } );
} }
}
// 初始化云平台 frontia // 初始化云平台 frontia
function initFrontia() { function initFrontia() {
...@@ -207,6 +209,8 @@ $( function () { ...@@ -207,6 +209,8 @@ $( function () {
$share_btn.loading( false ); $share_btn.loading( false );
return notice( '加载分享内容失败!请确认分享链接正确。' ); return notice( '加载分享内容失败!请确认分享链接正确。' );
} }
if ( draftManager ) {
var draft = draftManager.openByPath( 'share/' + shareId ); var draft = draftManager.openByPath( 'share/' + shareId );
if ( draft ) { if ( draft ) {
draftManager.load(); draftManager.load();
...@@ -214,6 +218,9 @@ $( function () { ...@@ -214,6 +218,9 @@ $( function () {
draftManager.create( 'share/' + shareId ); draftManager.create( 'share/' + shareId );
minder.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' ); minder.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' );
} }
} else {
minder.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' );
}
setRemotePath( null, false ); setRemotePath( null, false );
$share_btn.loading( false ); $share_btn.loading( false );
}, },
...@@ -537,11 +544,14 @@ $( function () { ...@@ -537,11 +544,14 @@ $( function () {
minder.importData( data, format ); minder.importData( data, format );
if ( draftManager ) {
if ( !draftManager.openByPath( remotePath ) ) { if ( !draftManager.openByPath( remotePath ) ) {
draftManager.create(); draftManager.create();
} }
draftManager.save( remotePath ); draftManager.save( remotePath );
draftManager.sync(); draftManager.sync();
}
minder.execCommand( 'camera', minder.getRoot() ); minder.execCommand( 'camera', minder.getRoot() );
$user_btn.loading( false ).text( getFileName( remotePath ) ); $user_btn.loading( false ).text( getFileName( remotePath ) );
...@@ -570,13 +580,13 @@ $( function () { ...@@ -570,13 +580,13 @@ $( function () {
// 点击文件菜单 // 点击文件菜单
function openFile( e ) { function openFile( e ) {
var path = $( this ).data( 'value' ); var path = $( this ).data( 'value' );
var draft = draftManager.getCurrent(); var draft = draftManager && draftManager.getCurrent();
if ( draft && draft.path == path ) { if ( draft && draft.path == path ) {
if ( !draft.sync && window.confirm( '“' + getFileName( path ) + '”在草稿箱包含未保存的更改,确定加载网盘版本覆盖草稿箱中的版本吗?' ) ) { if ( !draft.sync && window.confirm( '“' + getFileName( path ) + '”在草稿箱包含未保存的更改,确定加载网盘版本覆盖草稿箱中的版本吗?' ) ) {
setRemotePath( path, true ); setRemotePath( path, true );
loadRemote(); loadRemote();
} }
} else { } else if ( draftManager ) {
draft = draftManager.openByPath( path ); draft = draftManager.openByPath( path );
setRemotePath( path, !draft || draft.sync ); setRemotePath( path, !draft || draft.sync );
if ( draft ) { if ( draft ) {
...@@ -586,6 +596,9 @@ $( function () { ...@@ -586,6 +596,9 @@ $( function () {
} else { } else {
loadRemote(); loadRemote();
} }
} else {
setRemotePath( path, true );
loadRemote();
} }
} }
...@@ -625,8 +638,10 @@ $( function () { ...@@ -625,8 +638,10 @@ $( function () {
addToRecentMenu( [ savedFile ] ); addToRecentMenu( [ savedFile ] );
} }
setRemotePath( savedFile.path, true ); setRemotePath( savedFile.path, true );
if ( draftManager ) {
draftManager.save( remotePath ); draftManager.save( remotePath );
draftManager.sync(); draftManager.sync();
}
clearTimeout( timeout ); clearTimeout( timeout );
} else { } else {
error( '保存到云盘失败,可能是网络问题导致!' ); error( '保存到云盘失败,可能是网络问题导致!' );
...@@ -751,6 +766,12 @@ $( function () { ...@@ -751,6 +766,12 @@ $( function () {
} }
function bindDraft() { function bindDraft() {
if ( !draftManager ) {
if ( window.DraftManager ) {
draftManager = new window.DraftManager( minder );
}
}
$draft_menu.delegate( 'a.delete', 'click', function ( e ) { $draft_menu.delegate( 'a.delete', 'click', function ( e ) {
var $li = $( this ).closest( 'li.draft-item' ); var $li = $( this ).closest( 'li.draft-item' );
draftManager.remove( +$li.data( 'draft-index' ) ); draftManager.remove( +$li.data( 'draft-index' ) );
......
...@@ -120,7 +120,7 @@ kity.extendClass( Minder, { ...@@ -120,7 +120,7 @@ kity.extendClass( Minder, {
return d; return d;
} }
var t1 = ts( new Date(), '开始解析' ); //var t1 = ts( new Date(), '开始解析' );
//******************* //*******************
json = params.json || ( params.json = protocal.decode( local ) ); json = params.json || ( params.json = protocal.decode( local ) );
...@@ -129,20 +129,20 @@ kity.extendClass( Minder, { ...@@ -129,20 +129,20 @@ kity.extendClass( Minder, {
var self = this; var self = this;
json.then( local, function ( data ) { json.then( local, function ( data ) {
//******************* //*******************
var t2 = ts( new Date(), '解压解析耗时', t1 ); //var t2 = ts( new Date(), '解压解析耗时', t1 );
//******************* //*******************
self._afterImportData( data, params ); self._afterImportData( data, params );
//******************* //*******************
ts( new Date(), '渲染耗时', t2 ); //ts( new Date(), '渲染耗时', t2 );
//******************* //*******************
} ); } );
} else { } else {
//******************* //*******************
var t2 = ts( new Date(), '解压解析耗时', t1 ); //var t2 = ts( new Date(), '解压解析耗时', t1 );
//******************* //*******************
this._afterImportData( json, params ); this._afterImportData( json, params );
//******************* //*******************
ts( new Date(), '渲染耗时', t2 ); //ts( new Date(), '渲染耗时', t2 );
//******************* //*******************
} }
return this; return this;
......
...@@ -22,6 +22,9 @@ var MoveToParentCommand = kity.createClass( 'MoveToParentCommand', { ...@@ -22,6 +22,9 @@ var MoveToParentCommand = kity.createClass( 'MoveToParentCommand', {
node = nodes[ i ]; node = nodes[ i ];
if ( node.getParent() ) { if ( node.getParent() ) {
minder.removeNode( [ node ] ); minder.removeNode( [ node ] );
if ( !parent.isExpanded() && parent.getChildren().length > 0 && parent.getType() !== 'root' ) {
minder.expandNode( parent );
}
minder.appendChildNode( parent, node ); minder.appendChildNode( parent, node );
} }
} }
......
...@@ -210,7 +210,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -210,7 +210,7 @@ KityMinder.registerModule( "LayoutModule", function () {
return null; return null;
} }
km.select( selectedNode, true ); km.select( selectedNode, true );
km.textEditNode(selectedNode); km.textEditNode( selectedNode );
}, },
queryState: function ( km ) { queryState: function ( km ) {
var selectedNode = km.getSelectedNode(); var selectedNode = km.getSelectedNode();
...@@ -244,6 +244,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -244,6 +244,7 @@ KityMinder.registerModule( "LayoutModule", function () {
var ico = e.kityEvent.targetShape && e.kityEvent.targetShape.container; var ico = e.kityEvent.targetShape && e.kityEvent.targetShape.container;
if ( ico && ico.class === "shicon" ) { if ( ico && ico.class === "shicon" ) {
this.expandNode( ico ); this.expandNode( ico );
this.fire( 'contentchange' );
} }
}, },
"resize": function ( e ) { "resize": function ( e ) {
......
...@@ -27,13 +27,14 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -27,13 +27,14 @@ var ViewDragger = kity.createClass( "ViewDragger", {
lastPosition = null, lastPosition = null,
currentPosition = null; currentPosition = null;
this._minder.on( 'normal.beforemousedown readonly.beforemousedown', function ( e ) { this._minder.on( 'normal.beforemousedown readonly.beforemousedown readonly.beforetouchstart', function ( e ) {
// 点击未选中的根节点临时开启 // 点击未选中的根节点临时开启
if ( e.getTargetNode() == this.getRoot() && if ( e.getTargetNode() == this.getRoot() &&
( !this.getRoot().isSelected() || !this.isSingleSelect() ) ) { ( !this.getRoot().isSelected() || !this.isSingleSelect() ) ) {
lastPosition = e.getPosition(); lastPosition = e.getPosition();
dragger.setEnabled( true ); dragger.setEnabled( true );
isRootDrag = true; isRootDrag = true;
e.originEvent.preventDefault();
var me = this; var me = this;
setTimeout( function () { setTimeout( function () {
me.setStatus( 'hand' ); me.setStatus( 'hand' );
...@@ -41,16 +42,15 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -41,16 +42,15 @@ var ViewDragger = kity.createClass( "ViewDragger", {
} }
} ) } )
.on( 'hand.beforemousedown', function ( e ) { .on( 'hand.beforemousedown hand.beforetouchend', function ( e ) {
// 已经被用户打开拖放模式 // 已经被用户打开拖放模式
if ( dragger.isEnabled() ) { if ( dragger.isEnabled() ) {
lastPosition = e.getPosition(); lastPosition = e.getPosition();
e.stopPropagation(); e.stopPropagation();
e.originEvent.preventDefault();
} }
} ) } )
.on( 'hand.beforemousemove', function ( e ) { .on( 'hand.beforemousemove hand.beforetouchmove', function ( e ) {
if ( lastPosition ) { if ( lastPosition ) {
currentPosition = e.getPosition(); currentPosition = e.getPosition();
...@@ -58,6 +58,8 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -58,6 +58,8 @@ var ViewDragger = kity.createClass( "ViewDragger", {
var offset = kity.Vector.fromPoints( lastPosition, currentPosition ); var offset = kity.Vector.fromPoints( lastPosition, currentPosition );
dragger.move( offset ); dragger.move( offset );
e.stopPropagation(); e.stopPropagation();
e.preventDefault();
e.originEvent.preventDefault();
lastPosition = currentPosition; lastPosition = currentPosition;
} }
} ) } )
...@@ -102,7 +104,7 @@ KityMinder.registerModule( 'View', function () { ...@@ -102,7 +104,7 @@ KityMinder.registerModule( 'View', function () {
base: Command, base: Command,
execute: function ( km, focusNode ) { execute: function ( km, focusNode ) {
var viewport = km.getPaper().getViewPort(); var viewport = km.getPaper().getViewPort();
var offset = focusNode.getRenderContainer().getRenderBox( 'paper' ); var offset = focusNode.getRenderContainer().getRenderBox( 'view' );
var dx = viewport.center.x - offset.x - offset.width / 2, var dx = viewport.center.x - offset.x - offset.width / 2,
dy = viewport.center.y - offset.y; dy = viewport.center.y - offset.y;
km.getRenderContainer().fxTranslate( dx, dy, 1000, "easeOutQuint" ); km.getRenderContainer().fxTranslate( dx, dy, 1000, "easeOutQuint" );
......
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