Commit 1c0bf6d7 authored by yancend's avatar yancend

Merge branch 'dev' of https://github.com/fex-team/kityminder into dev

parents 5bbe38de c6f94031
......@@ -2,13 +2,18 @@
## v1.1.2
### 功能更新
1. 支持本地格式文件导入
* 支持文件拖拽和网盘文件导入
* 格式支持xmind/freemind/mindmanager,其他格式不支持
* 格式支持 xmind/freemind/mindmanager,其他格式不支持
* 支持标签,包括优先级和任务进度
2. 新增节点移动到视野中
### 问题修复
1. 导出png和svg图片时,文本中如果包含 字符会报错的问题
1. 导出 png 和 svg 图片时,文本中如果包含 ` ` 字符会报错的问题
2. 删除中心节点导致页面卡住
## v1.1.1
......
The MIT License (MIT)
Copyright (c) 2014, FEX,Baidu.
All rights reserved.
Copyright (c) 2013 KityMinder
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Neither the name of the {organization} nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
......@@ -13,14 +13,14 @@
<script src="../dev/import.php" charset="utf-8"></script>
<script src="../kityminder.config.js" charset="utf-8"></script>
<script src="../lang/zh-cn/zh-cn.js" charset="utf-8"></script>
<script src="../lib/zip.js" charset="utf-8"></script>
<script src="../lib/jquery.xml2json.js" charset="utf-8"></script>
<script src="../lib/baidu-frontia-js-full-1.0.0.js" charset="utf-8"></script>
<script src="../social/draftmanager.js" charset="utf-8"></script>
<script src="../social/social.js" charset="utf-8"></script>
<link href="../social/social.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="favicon.ico" type="image/x-icon" rel="shortcut icon">
......@@ -44,7 +44,8 @@
<a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
</p>
</div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdMini":"2","bdMiniList":[],"bdPic":"","bdStyle":"1","bdSize":"32"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdMini":"2","bdMiniList":[],"bdPic":"","bdStyle":"1","bdSize":"32"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
</body>
<script>
// create km instance
......
......@@ -2,14 +2,20 @@
<html>
<head>
<meta charset="utf-8">
<script src="../lib/jquery-2.1.0.min.js" charset="utf-8"></script>
<script src="../lib/ZeroClipboard.min.js" charset="utf-8"></script>
<script type="text/javascript">
ZeroClipboard.setDefaults( { moviePath: '../lib/ZeroClipboard.swf' } );
</script>
<script src="../kity/dist/kitygraph.all.min.js" charset="utf-8"></script>
<script src="../dist/kityminder.all.min.js" charset="utf-8"></script>
<script src="../kityminder.config.js" charset="utf-8"></script>
<script src="../lang/zh-cn/zh-cn.js" charset="utf-8"></script>
<script src="../lib/zip.js" charset="utf-8"></script>
<script src="../lib/jquery.xml2json.js" charset="utf-8"></script>
<script src="../lib/baidu-frontia-js-full-1.0.0.js" charset="utf-8"></script>
<script src="../social/draftmanager.js" charset="utf-8"></script>
<script src="../social/social.js" charset="utf-8"></script>
......@@ -30,7 +36,7 @@
<h3>URL分享:</h3>
<p>
<input id="share-url" type="url" value="" />
<button id="copy-share-url" type="button">复制</button>
<button id="copy-share-url" data-clipboard-target="share-url" type="button">复制</button>
</p>
<h3>社交分享:</h3>
<p id="share-platform" class="bdsharebuttonbox">
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -62,11 +62,12 @@
window.KITYMINDER_CONFIG = {
'KITYMINDER_HOME_URL': getKMBasePath()
//定义工具栏
,toolbars: [
,
toolbars: [
'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers | node | switchlayout | help'
]
],
//只读模式,默认是false
//readOnly : false
//readOnly: true
//设置主题
//,defaultlayoutstyle : 'default' //设置默认的主题
......@@ -81,4 +82,4 @@
//设置km整体的z-index大小
//,zIndex : 1000
};
} )()
\ No newline at end of file
} )();
\ No newline at end of file
......@@ -55,8 +55,11 @@ utils.extend( KityMinder, function () {
} );
btns.length && $toolbar.kmui().appendToBtnmenu( btns );
} );
$toolbar.append( $( '<div class="kmui-dialog-container"></div>' ) );
}else{
$toolbar.hide()
}
$toolbar.append( $( '<div class="kmui-dialog-container"></div>' ) );
},
_createStatusbar: function ( $statusbar, km ) {
......
......@@ -22,7 +22,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
});
//实例化
$combox = $.kmuibuttoncombobox( options ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
comboboxWidget = $combox.kmui();
var comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( name, res.value );
......@@ -37,6 +37,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
var state = this.queryCommandState( name ),
value = this.queryCommandValue( name );
//设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
if ( value ) {
......@@ -44,6 +45,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
value = value.replace( /['"]/g, '' ).toLowerCase().split( /['|"]?\s*,\s*[\1]?/ );
comboboxWidget.selectItemByLabel( value );
}
} );
var data = [];
......
......@@ -25,7 +25,7 @@ KM.registerToolbarUI( 'node', function ( name ) {
//实例化
$combox = $.kmuibuttoncombobox( transForInserttopic( options ) ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
comboboxWidget = $combox.kmui();
var comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( res.value, new MinderNode( me.getLang().topic ), true );
......@@ -43,7 +43,20 @@ KM.registerToolbarUI( 'node', function ( name ) {
}
} )
} );
//状态反射
me.on( 'interactchange', function () {
var state = 0;
utils.each(shortcutKeys,function(k){
state = me.queryCommandState(k);
if(state!=-1){
return false;
}
});
//设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
} );
//comboboxWidget.button().kmui().disabled(-1);
return comboboxWidget.button().addClass( 'kmui-combobox' );
......
......@@ -17,7 +17,7 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
utils.each( KityMinder.getAllRegisteredProtocals(), function ( k ) {
var p = KityMinder.findProtocal( k );
if( p.encode ){
if ( p.encode ) {
var text = p.fileDescription + '(' + p.fileExtension + ')';
options.value.push( k );
options.items.push( text );
......@@ -39,11 +39,11 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
var data = me.exportData( res.value );
console.log( data );
var p = KityMinder.findProtocal( res.value );
var filename = me.getMinderTitle() + p.fileExtension;
if ( typeof ( data ) == 'string' ) {
var url = 'data:text/plain; utf-8,' + encodeURI( data );
var url = 'data:text/plain; utf-8,' + encodeURIComponent( data );
doDownload( url, filename );
} else if ( data && data.then ) {
data.then( function ( url ) {
......
......@@ -10,7 +10,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._initContextmenu();
this._initModules();
if(this.getOptions('readOnly') === true){
if ( this.getOptions( 'readOnly' ) === true ) {
this.setDisabled();
}
this.fire( 'ready' );
......@@ -31,6 +31,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._paper = new kity.Paper();
this._paper.getNode().setAttribute( 'contenteditable', true );
this._paper.setStyle( 'font-family', 'Arial,MicrosoftYaHei,sans-serif' );
this._paper.getNode().ondragstart = function ( e ) {
e.preventDefault();
};
......@@ -170,45 +171,45 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
getStatus: function () {
return this._status;
},
setDisabled : function(){
setDisabled: function () {
var me = this;
//禁用命令
me.bkqueryCommandState = me.queryCommandState;
me.bkqueryCommandValue = me.queryCommandValue;
me.queryCommandState = function (type) {
var cmd = this._getCommand(type);
if(cmd && cmd.enableReadOnly === false){
return me.bkqueryCommandState.apply(me, arguments);
me.queryCommandState = function ( type ) {
var cmd = this._getCommand( type );
if ( cmd && cmd.enableReadOnly === false ) {
return me.bkqueryCommandState.apply( me, arguments );
}
return -1;
};
me.queryCommandValue = function (type) {
var cmd = this._getCommand(type);
if(cmd && cmd.enableReadOnly === false){
return me.bkqueryCommandValue.apply(me, arguments);
me.queryCommandValue = function ( type ) {
var cmd = this._getCommand( type );
if ( cmd && cmd.enableReadOnly === false ) {
return me.bkqueryCommandValue.apply( me, arguments );
}
return null;
};
this.setStatus('readonly');
this.setStatus( 'readonly' );
me.fire('interactchange');
me.fire( 'interactchange' );
},
setEnabled : function(){
setEnabled: function () {
var me = this;
if (me.bkqueryCommandState) {
if ( me.bkqueryCommandState ) {
me.queryCommandState = me.bkqueryCommandState;
delete me.bkqueryCommandState;
}
if (me.bkqueryCommandValue) {
if ( me.bkqueryCommandValue ) {
me.queryCommandValue = me.bkqueryCommandValue;
delete me.bkqueryCommandValue;
}
this.rollbackStatus();
me.fire('interactchange');
me.fire( 'interactchange' );
}
} );
......
KityMinder.registerModule( "basestylemodule", function () {
var km = this;
return {
"commands": {
"bold": kity.createClass( "boldCommand", {
base: Command,
execute: function ( ) {
execute: function () {
var nodes = km.getSelectedNodes();
if(this.queryState('bold') == 1){
utils.each(nodes,function(i,n){
n.setData('bold');
n.getTextShape().setAttr('font-weight');
km.updateLayout(n)
})
}else{
utils.each(nodes,function(i,n){
n.setData('bold',true);
n.getTextShape().setAttr('font-weight','bold');
km.updateLayout(n)
})
if ( this.queryState( 'bold' ) == 1 ) {
utils.each( nodes, function ( i, n ) {
n.setData( 'bold' );
n.getTextShape().setAttr( 'font-weight' );
km.updateLayout( n )
} )
} else {
utils.each( nodes, function ( i, n ) {
n.setData( 'bold', true );
n.getTextShape().setAttr( 'font-weight', 'bold' );
km.updateLayout( n )
} )
}
},
queryState: function ( ) {
queryState: function () {
var nodes = km.getSelectedNodes(),
result = 0;
if(nodes.length == 0){
if ( nodes.length == 0 ) {
return -1;
}
utils.each(nodes,function(i,n){
if( n && n.getData('bold') ){
utils.each( nodes, function ( i, n ) {
if ( n && n.getData( 'bold' ) ) {
result = 1;
return false;
}
});
} );
return result;
}
} ),
"italic": kity.createClass( "italicCommand", {
base: Command,
execute: function ( ) {
execute: function () {
var nodes = km.getSelectedNodes();
if(this.queryState('italic') == 1){
utils.each(nodes,function(i,n){
n.setData('italic');
n.getTextShape().setAttr('font-style');
km.updateLayout(n)
})
}else{
utils.each(nodes,function(i,n){
n.setData('italic',true);
n.getTextShape().setAttr('font-style','italic');
km.updateLayout(n)
})
if ( this.queryState( 'italic' ) == 1 ) {
utils.each( nodes, function ( i, n ) {
n.setData( 'italic' );
n.getTextShape().setAttr( 'font-style' );
km.updateLayout( n )
} )
} else {
utils.each( nodes, function ( i, n ) {
n.setData( 'italic', true );
n.getTextShape().setAttr( 'font-style', 'italic' );
km.updateLayout( n )
} )
}
},
queryState: function ( ) {
queryState: function () {
var nodes = km.getSelectedNodes(),
result = 0;
if(nodes.length == 0){
if ( nodes.length == 0 ) {
return -1;
}
utils.each(nodes,function(i,n){
if( n && n.getData('italic') ){
utils.each( nodes, function ( i, n ) {
if ( n && n.getData( 'italic' ) ) {
result = 1;
return false;
}
});
} );
return result;
}
} )
......@@ -81,12 +80,12 @@ KityMinder.registerModule( "basestylemodule", function () {
"events": {
"beforeRenderNode": function ( e ) {
//加粗
if(e.node.getData('bold')){
e.node.getTextShape().setAttr('font-weight','bold');
if ( e.node.getData( 'bold' ) ) {
e.node.getTextShape().setAttr( 'font-weight', 'bold' );
}
if(e.node.getData('italic')){
e.node.getTextShape().setAttr('font-style','italic');
if ( e.node.getData( 'italic' ) ) {
e.node.getTextShape().setAttr( 'font-style', 'italic' );
}
}
}
......
......@@ -143,8 +143,8 @@ KityMinder.registerModule( "KeyboardModule", function () {
break;
case keys.Backspace:
case keys.Del:
this.execCommand( 'removenode' );
e.preventDefault();
if ( this.queryCommandState( 'removenode' ) !== -1 ) this.execCommand( 'removenode' );
break;
case keys.Left:
......
......@@ -10,97 +10,96 @@ KityMinder.registerProtocal( 'mindmanager', function () {
// 标签 map
var markerMap = {
'urn:mindjet:Prio1' : ['PriorityIcon', 1]
,'urn:mindjet:Prio2' : ['PriorityIcon', 2]
,'urn:mindjet:Prio3' : ['PriorityIcon', 3]
,'urn:mindjet:Prio4' : ['PriorityIcon', 4]
,'urn:mindjet:Prio5' : ['PriorityIcon', 5]
,'0' : ['ProgressIcon', 1]
,'25' : ['ProgressIcon', 2]
,'50' : ['ProgressIcon', 3]
,'75' : ['ProgressIcon', 4]
,'100' : ['ProgressIcon', 5]
'urn:mindjet:Prio1': [ 'PriorityIcon', 1 ],
'urn:mindjet:Prio2': [ 'PriorityIcon', 2 ],
'urn:mindjet:Prio3': [ 'PriorityIcon', 3 ],
'urn:mindjet:Prio4': [ 'PriorityIcon', 4 ],
'urn:mindjet:Prio5': [ 'PriorityIcon', 5 ],
'0': [ 'ProgressIcon', 1 ],
'25': [ 'ProgressIcon', 2 ],
'50': [ 'ProgressIcon', 3 ],
'75': [ 'ProgressIcon', 4 ],
'100': [ 'ProgressIcon', 5 ]
};
function processTopic(topic, obj){
function processTopic( topic, obj ) {
//处理文本
obj.data = { text : topic.Text && topic.Text.PlainText || '' }; // 节点默认的文本,没有Text属性
obj.data = {
text: topic.Text && topic.Text.PlainText || ''
}; // 节点默认的文本,没有Text属性
// 处理标签
if(topic.Task){
if ( topic.Task ) {
var type;
if(topic.Task.TaskPriority){
if ( topic.Task.TaskPriority ) {
type = markerMap[ topic.Task.TaskPriority ];
type && (obj.data[ type[0] ] = type[1]);
type && ( obj.data[ type[ 0 ] ] = type[ 1 ] );
}
if(topic.Task.TaskPercentage){
if ( topic.Task.TaskPercentage ) {
type = markerMap[ topic.Task.TaskPercentage ];
type && (obj.data[ type[0] ] = type[1]);
type && ( obj.data[ type[ 0 ] ] = type[ 1 ] );
}
}
//处理子节点
if( topic.SubTopics && topic.SubTopics.Topic ){
if ( topic.SubTopics && topic.SubTopics.Topic ) {
var tmp = topic.SubTopics.Topic;
if( tmp.length && tmp.length > 0 ){ //多个子节点
if ( tmp.length && tmp.length > 0 ) { //多个子节点
obj.children = [];
for(var i in tmp){
obj.children.push({});
processTopic(tmp[i], obj.children[i]);
for ( var i in tmp ) {
obj.children.push( {} );
processTopic( tmp[ i ], obj.children[ i ] );
}
}else{ //一个子节点
obj.children = [{}];
processTopic(tmp, obj.children[0]);
} else { //一个子节点
obj.children = [ {} ];
processTopic( tmp, obj.children[ 0 ] );
}
}
}
function xml2km(xml){
var json = $.xml2json(xml);
function xml2km( xml ) {
var json = $.xml2json( xml );
var result = {};
processTopic(json.OneTopic.Topic, result);
processTopic( json.OneTopic.Topic, result );
return result;
}
function getEntries(file, onend) {
zip.createReader(new zip.BlobReader(file), function(zipReader) {
zipReader.getEntries(onend);
}, onerror);
function getEntries( file, onend ) {
zip.createReader( new zip.BlobReader( file ), function ( zipReader ) {
zipReader.getEntries( onend );
}, onerror );
}
return {
fileDescription: 'mindmanager格式文件',
fileExtension: '.mmap',
decode: function ( local ) {
return {
then : function(local, callback){
getEntries( local, function( entries ) {
entries.forEach(function( entry ) {
if(entry.filename == 'Document.xml'){
entry.getData(new zip.TextWriter(), function(text) {
var km = xml2km($.parseXML(text));
callback && callback( km );
});
}
});
});
}
};
},
// recognize: recognize,
recognizePriority: -1
};
} );
return {
fileDescription: 'mindmanager格式文件',
fileExtension: '.mmap',
decode: function ( local ) {
return {
then: function ( local, callback ) {
getEntries( local, function ( entries ) {
entries.forEach( function ( entry ) {
if ( entry.filename == 'Document.xml' ) {
entry.getData( new zip.TextWriter(), function ( text ) {
var km = xml2km( $.parseXML( text ) );
callback && callback( km );
} );
}
} );
} );
}
};
},
// recognize: recognize,
recognizePriority: -1
};
} );
\ No newline at end of file
......@@ -42,10 +42,10 @@ KityMinder.registerProtocal( "png", function () {
} );
// need a xml with width and height
svgXml = $( '<div></div' ).append( $svg ).html();
svgXml = $( '<div></div>' ).append( $svg ).html();
// svg 含有 &nbsp; 符号导出报错 Entity 'nbsp' not defined
svgXml = svgXml.replace(/&nbsp;/g, '&#xa0;');
svgXml = svgXml.replace( /&nbsp;/g, '&#xa0;' );
blob = new Blob( [ svgXml ], {
type: "image/svg+xml;charset=utf-8"
......
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