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 @@ ...@@ -2,13 +2,18 @@
## v1.1.2 ## v1.1.2
### 功能更新 ### 功能更新
1. 支持本地格式文件导入 1. 支持本地格式文件导入
* 支持文件拖拽和网盘文件导入 * 支持文件拖拽和网盘文件导入
* 格式支持xmind/freemind/mindmanager,其他格式不支持 * 格式支持 xmind/freemind/mindmanager,其他格式不支持
* 支持标签,包括优先级和任务进度
2. 新增节点移动到视野中 2. 新增节点移动到视野中
### 问题修复 ### 问题修复
1. 导出png和svg图片时,文本中如果包含 字符会报错的问题
1. 导出 png 和 svg 图片时,文本中如果包含 ` ` 字符会报错的问题
2. 删除中心节点导致页面卡住 2. 删除中心节点导致页面卡住
## v1.1.1 ## 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 * Redistributions of source code must retain the above copyright notice, this
this software and associated documentation files (the "Software"), to deal in list of conditions and the following disclaimer.
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:
The above copyright notice and this permission notice shall be included in all * Redistributions in binary form must reproduce the above copyright notice,
copies or substantial portions of the Software. 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 * Neither the name of the {organization} nor the names of its
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS contributors may be used to endorse or promote products derived from
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR this software without specific prior written permission.
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 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 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 @@ ...@@ -13,14 +13,14 @@
<script src="../dev/import.php" charset="utf-8"></script> <script src="../dev/import.php" charset="utf-8"></script>
<script src="../kityminder.config.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="../lang/zh-cn/zh-cn.js" charset="utf-8"></script>
<script src="../lib/zip.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/jquery.xml2json.js" charset="utf-8"></script>
<script src="../lib/baidu-frontia-js-full-1.0.0.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/draftmanager.js" charset="utf-8"></script>
<script src="../social/social.js" charset="utf-8"></script> <script src="../social/social.js" charset="utf-8"></script>
<link href="../social/social.css" rel="stylesheet"> <link href="../social/social.css" rel="stylesheet">
<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"> <link href="favicon.ico" type="image/x-icon" rel="shortcut icon">
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
<a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a> <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
</p> </p>
</div> </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> </body>
<script> <script>
// create km instance // create km instance
......
...@@ -2,14 +2,20 @@ ...@@ -2,14 +2,20 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<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 type="text/javascript">
ZeroClipboard.setDefaults( { moviePath: '../lib/ZeroClipboard.swf' } );
</script>
<script src="../kity/dist/kitygraph.all.min.js" charset="utf-8"></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="../dist/kityminder.all.min.js" charset="utf-8"></script>
<script src="../kityminder.config.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="../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="../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/draftmanager.js" charset="utf-8"></script>
<script src="../social/social.js" charset="utf-8"></script> <script src="../social/social.js" charset="utf-8"></script>
...@@ -30,7 +36,7 @@ ...@@ -30,7 +36,7 @@
<h3>URL分享:</h3> <h3>URL分享:</h3>
<p> <p>
<input id="share-url" type="url" value="" /> <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> </p>
<h3>社交分享:</h3> <h3>社交分享:</h3>
<p id="share-platform" class="bdsharebuttonbox"> <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 @@ ...@@ -62,11 +62,12 @@
window.KITYMINDER_CONFIG = { window.KITYMINDER_CONFIG = {
'KITYMINDER_HOME_URL': getKMBasePath() 'KITYMINDER_HOME_URL': getKMBasePath()
//定义工具栏 //定义工具栏
,toolbars: [ ,
toolbars: [
'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers | node | switchlayout | help' 'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers | node | switchlayout | help'
] ],
//只读模式,默认是false //只读模式,默认是false
//readOnly : false //readOnly: true
//设置主题 //设置主题
//,defaultlayoutstyle : 'default' //设置默认的主题 //,defaultlayoutstyle : 'default' //设置默认的主题
...@@ -81,4 +82,4 @@ ...@@ -81,4 +82,4 @@
//设置km整体的z-index大小 //设置km整体的z-index大小
//,zIndex : 1000 //,zIndex : 1000
}; };
} )() } )();
\ No newline at end of file \ No newline at end of file
...@@ -55,8 +55,11 @@ utils.extend( KityMinder, function () { ...@@ -55,8 +55,11 @@ utils.extend( KityMinder, function () {
} ); } );
btns.length && $toolbar.kmui().appendToBtnmenu( btns ); 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 ) { _createStatusbar: function ( $statusbar, km ) {
......
...@@ -22,7 +22,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) { ...@@ -22,7 +22,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
}); });
//实例化 //实例化
$combox = $.kmuibuttoncombobox( options ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 ); $combox = $.kmuibuttoncombobox( options ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
comboboxWidget = $combox.kmui(); var comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) { comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( name, res.value ); me.execCommand( name, res.value );
...@@ -37,6 +37,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) { ...@@ -37,6 +37,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
var state = this.queryCommandState( name ), var state = this.queryCommandState( name ),
value = this.queryCommandValue( name ); value = this.queryCommandValue( name );
//设置按钮状态 //设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 ); comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
if ( value ) { if ( value ) {
...@@ -44,6 +45,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) { ...@@ -44,6 +45,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
value = value.replace( /['"]/g, '' ).toLowerCase().split( /['|"]?\s*,\s*[\1]?/ ); value = value.replace( /['"]/g, '' ).toLowerCase().split( /['|"]?\s*,\s*[\1]?/ );
comboboxWidget.selectItemByLabel( value ); comboboxWidget.selectItemByLabel( value );
} }
} ); } );
var data = []; var data = [];
......
...@@ -25,7 +25,7 @@ KM.registerToolbarUI( 'node', function ( name ) { ...@@ -25,7 +25,7 @@ KM.registerToolbarUI( 'node', function ( name ) {
//实例化 //实例化
$combox = $.kmuibuttoncombobox( transForInserttopic( options ) ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 ); $combox = $.kmuibuttoncombobox( transForInserttopic( options ) ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
comboboxWidget = $combox.kmui(); var comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) { comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( res.value, new MinderNode( me.getLang().topic ), true ); me.execCommand( res.value, new MinderNode( me.getLang().topic ), true );
...@@ -43,7 +43,20 @@ KM.registerToolbarUI( 'node', function ( name ) { ...@@ -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' ); return comboboxWidget.button().addClass( 'kmui-combobox' );
......
...@@ -17,7 +17,7 @@ KM.registerToolbarUI( 'saveto', function ( name ) { ...@@ -17,7 +17,7 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
utils.each( KityMinder.getAllRegisteredProtocals(), function ( k ) { utils.each( KityMinder.getAllRegisteredProtocals(), function ( k ) {
var p = KityMinder.findProtocal( k ); var p = KityMinder.findProtocal( k );
if( p.encode ){ if ( p.encode ) {
var text = p.fileDescription + '(' + p.fileExtension + ')'; var text = p.fileDescription + '(' + p.fileExtension + ')';
options.value.push( k ); options.value.push( k );
options.items.push( text ); options.items.push( text );
...@@ -39,11 +39,11 @@ KM.registerToolbarUI( 'saveto', function ( name ) { ...@@ -39,11 +39,11 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
comboboxWidget.on( 'comboboxselect', function ( evt, res ) { comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
var data = me.exportData( res.value ); var data = me.exportData( res.value );
console.log( data );
var p = KityMinder.findProtocal( res.value ); var p = KityMinder.findProtocal( res.value );
var filename = me.getMinderTitle() + p.fileExtension; var filename = me.getMinderTitle() + p.fileExtension;
if ( typeof ( data ) == 'string' ) { 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 ); doDownload( url, filename );
} else if ( data && data.then ) { } else if ( data && data.then ) {
data.then( function ( url ) { data.then( function ( url ) {
......
...@@ -10,7 +10,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -10,7 +10,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._initContextmenu(); this._initContextmenu();
this._initModules(); this._initModules();
if(this.getOptions('readOnly') === true){ if ( this.getOptions( 'readOnly' ) === true ) {
this.setDisabled(); this.setDisabled();
} }
this.fire( 'ready' ); this.fire( 'ready' );
...@@ -31,6 +31,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -31,6 +31,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._paper = new kity.Paper(); this._paper = new kity.Paper();
this._paper.getNode().setAttribute( 'contenteditable', true ); this._paper.getNode().setAttribute( 'contenteditable', true );
this._paper.setStyle( 'font-family', 'Arial,MicrosoftYaHei,sans-serif' );
this._paper.getNode().ondragstart = function ( e ) { this._paper.getNode().ondragstart = function ( e ) {
e.preventDefault(); e.preventDefault();
}; };
...@@ -170,45 +171,45 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -170,45 +171,45 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
getStatus: function () { getStatus: function () {
return this._status; return this._status;
}, },
setDisabled : function(){ setDisabled: function () {
var me = this; var me = this;
//禁用命令 //禁用命令
me.bkqueryCommandState = me.queryCommandState; me.bkqueryCommandState = me.queryCommandState;
me.bkqueryCommandValue = me.queryCommandValue; me.bkqueryCommandValue = me.queryCommandValue;
me.queryCommandState = function (type) { me.queryCommandState = function ( type ) {
var cmd = this._getCommand(type); var cmd = this._getCommand( type );
if(cmd && cmd.enableReadOnly === false){ if ( cmd && cmd.enableReadOnly === false ) {
return me.bkqueryCommandState.apply(me, arguments); return me.bkqueryCommandState.apply( me, arguments );
} }
return -1; return -1;
}; };
me.queryCommandValue = function (type) { me.queryCommandValue = function ( type ) {
var cmd = this._getCommand(type); var cmd = this._getCommand( type );
if(cmd && cmd.enableReadOnly === false){ if ( cmd && cmd.enableReadOnly === false ) {
return me.bkqueryCommandValue.apply(me, arguments); return me.bkqueryCommandValue.apply( me, arguments );
} }
return null; return null;
}; };
this.setStatus('readonly'); this.setStatus( 'readonly' );
me.fire('interactchange'); me.fire( 'interactchange' );
}, },
setEnabled : function(){ setEnabled: function () {
var me = this; var me = this;
if (me.bkqueryCommandState) { if ( me.bkqueryCommandState ) {
me.queryCommandState = me.bkqueryCommandState; me.queryCommandState = me.bkqueryCommandState;
delete me.bkqueryCommandState; delete me.bkqueryCommandState;
} }
if (me.bkqueryCommandValue) { if ( me.bkqueryCommandValue ) {
me.queryCommandValue = me.bkqueryCommandValue; me.queryCommandValue = me.bkqueryCommandValue;
delete me.bkqueryCommandValue; delete me.bkqueryCommandValue;
} }
this.rollbackStatus(); this.rollbackStatus();
me.fire('interactchange'); me.fire( 'interactchange' );
} }
} ); } );
......
KityMinder.registerModule( "basestylemodule", function () { KityMinder.registerModule( "basestylemodule", function () {
var km = this; var km = this;
return { return {
"commands": { "commands": {
"bold": kity.createClass( "boldCommand", { "bold": kity.createClass( "boldCommand", {
base: Command, base: Command,
execute: function ( ) { execute: function () {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
if(this.queryState('bold') == 1){ if ( this.queryState( 'bold' ) == 1 ) {
utils.each(nodes,function(i,n){ utils.each( nodes, function ( i, n ) {
n.setData('bold'); n.setData( 'bold' );
n.getTextShape().setAttr('font-weight'); n.getTextShape().setAttr( 'font-weight' );
km.updateLayout(n) km.updateLayout( n )
}) } )
}else{ } else {
utils.each(nodes,function(i,n){ utils.each( nodes, function ( i, n ) {
n.setData('bold',true); n.setData( 'bold', true );
n.getTextShape().setAttr('font-weight','bold'); n.getTextShape().setAttr( 'font-weight', 'bold' );
km.updateLayout(n) km.updateLayout( n )
}) } )
} }
}, },
queryState: function ( ) { queryState: function () {
var nodes = km.getSelectedNodes(), var nodes = km.getSelectedNodes(),
result = 0; result = 0;
if(nodes.length == 0){ if ( nodes.length == 0 ) {
return -1; return -1;
} }
utils.each(nodes,function(i,n){ utils.each( nodes, function ( i, n ) {
if( n && n.getData('bold') ){ if ( n && n.getData( 'bold' ) ) {
result = 1; result = 1;
return false; return false;
} }
}); } );
return result; return result;
} }
} ), } ),
"italic": kity.createClass( "italicCommand", { "italic": kity.createClass( "italicCommand", {
base: Command, base: Command,
execute: function ( ) { execute: function () {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
if(this.queryState('italic') == 1){ if ( this.queryState( 'italic' ) == 1 ) {
utils.each(nodes,function(i,n){ utils.each( nodes, function ( i, n ) {
n.setData('italic'); n.setData( 'italic' );
n.getTextShape().setAttr('font-style'); n.getTextShape().setAttr( 'font-style' );
km.updateLayout(n) km.updateLayout( n )
}) } )
}else{ } else {
utils.each(nodes,function(i,n){ utils.each( nodes, function ( i, n ) {
n.setData('italic',true); n.setData( 'italic', true );
n.getTextShape().setAttr('font-style','italic'); n.getTextShape().setAttr( 'font-style', 'italic' );
km.updateLayout(n) km.updateLayout( n )
}) } )
} }
}, },
queryState: function ( ) { queryState: function () {
var nodes = km.getSelectedNodes(), var nodes = km.getSelectedNodes(),
result = 0; result = 0;
if(nodes.length == 0){ if ( nodes.length == 0 ) {
return -1; return -1;
} }
utils.each(nodes,function(i,n){ utils.each( nodes, function ( i, n ) {
if( n && n.getData('italic') ){ if ( n && n.getData( 'italic' ) ) {
result = 1; result = 1;
return false; return false;
} }
}); } );
return result; return result;
} }
} ) } )
...@@ -81,12 +80,12 @@ KityMinder.registerModule( "basestylemodule", function () { ...@@ -81,12 +80,12 @@ KityMinder.registerModule( "basestylemodule", function () {
"events": { "events": {
"beforeRenderNode": function ( e ) { "beforeRenderNode": function ( e ) {
//加粗 //加粗
if(e.node.getData('bold')){ if ( e.node.getData( 'bold' ) ) {
e.node.getTextShape().setAttr('font-weight','bold'); e.node.getTextShape().setAttr( 'font-weight', 'bold' );
} }
if(e.node.getData('italic')){ if ( e.node.getData( 'italic' ) ) {
e.node.getTextShape().setAttr('font-style','italic'); e.node.getTextShape().setAttr( 'font-style', 'italic' );
} }
} }
} }
......
...@@ -143,8 +143,8 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -143,8 +143,8 @@ KityMinder.registerModule( "KeyboardModule", function () {
break; break;
case keys.Backspace: case keys.Backspace:
case keys.Del: case keys.Del:
this.execCommand( 'removenode' );
e.preventDefault(); e.preventDefault();
if ( this.queryCommandState( 'removenode' ) !== -1 ) this.execCommand( 'removenode' );
break; break;
case keys.Left: case keys.Left:
......
...@@ -10,97 +10,96 @@ KityMinder.registerProtocal( 'mindmanager', function () { ...@@ -10,97 +10,96 @@ KityMinder.registerProtocal( 'mindmanager', function () {
// 标签 map // 标签 map
var markerMap = { var markerMap = {
'urn:mindjet:Prio1' : ['PriorityIcon', 1] 'urn:mindjet:Prio1': [ 'PriorityIcon', 1 ],
,'urn:mindjet:Prio2' : ['PriorityIcon', 2] 'urn:mindjet:Prio2': [ 'PriorityIcon', 2 ],
,'urn:mindjet:Prio3' : ['PriorityIcon', 3] 'urn:mindjet:Prio3': [ 'PriorityIcon', 3 ],
,'urn:mindjet:Prio4' : ['PriorityIcon', 4] 'urn:mindjet:Prio4': [ 'PriorityIcon', 4 ],
,'urn:mindjet:Prio5' : ['PriorityIcon', 5] 'urn:mindjet:Prio5': [ 'PriorityIcon', 5 ],
'0': [ 'ProgressIcon', 1 ],
,'0' : ['ProgressIcon', 1] '25': [ 'ProgressIcon', 2 ],
,'25' : ['ProgressIcon', 2] '50': [ 'ProgressIcon', 3 ],
,'50' : ['ProgressIcon', 3] '75': [ 'ProgressIcon', 4 ],
,'75' : ['ProgressIcon', 4] '100': [ 'ProgressIcon', 5 ]
,'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; var type;
if(topic.Task.TaskPriority){ if ( topic.Task.TaskPriority ) {
type = markerMap[ 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 = 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; var tmp = topic.SubTopics.Topic;
if( tmp.length && tmp.length > 0 ){ //多个子节点 if ( tmp.length && tmp.length > 0 ) { //多个子节点
obj.children = []; obj.children = [];
for(var i in tmp){ for ( var i in tmp ) {
obj.children.push({}); obj.children.push( {} );
processTopic(tmp[i], obj.children[i]); processTopic( tmp[ i ], obj.children[ i ] );
} }
}else{ //一个子节点 } else { //一个子节点
obj.children = [{}]; obj.children = [ {} ];
processTopic(tmp, obj.children[0]); processTopic( tmp, obj.children[ 0 ] );
} }
} }
} }
function xml2km(xml){ function xml2km( xml ) {
var json = $.xml2json(xml); var json = $.xml2json( xml );
var result = {}; var result = {};
processTopic(json.OneTopic.Topic, result); processTopic( json.OneTopic.Topic, result );
return result; return result;
} }
function getEntries(file, onend) { function getEntries( file, onend ) {
zip.createReader(new zip.BlobReader(file), function(zipReader) { zip.createReader( new zip.BlobReader( file ), function ( zipReader ) {
zipReader.getEntries(onend); zipReader.getEntries( onend );
}, onerror); }, onerror );
} }
return { return {
fileDescription: 'mindmanager格式文件', fileDescription: 'mindmanager格式文件',
fileExtension: '.mmap', fileExtension: '.mmap',
decode: function ( local ) { decode: function ( local ) {
return { return {
then : function(local, callback){ then: function ( local, callback ) {
getEntries( local, function( entries ) { getEntries( local, function ( entries ) {
entries.forEach(function( entry ) { entries.forEach( function ( entry ) {
if(entry.filename == 'Document.xml'){ if ( entry.filename == 'Document.xml' ) {
entry.getData(new zip.TextWriter(), function(text) { entry.getData( new zip.TextWriter(), function ( text ) {
var km = xml2km($.parseXML(text)); var km = xml2km( $.parseXML( text ) );
callback && callback( km ); callback && callback( km );
}); } );
} }
}); } );
}); } );
} }
}; };
},
// recognize: recognize,
recognizePriority: -1
};
} );
},
// recognize: recognize,
recognizePriority: -1
};
} );
\ No newline at end of file
...@@ -42,10 +42,10 @@ KityMinder.registerProtocal( "png", function () { ...@@ -42,10 +42,10 @@ KityMinder.registerProtocal( "png", function () {
} ); } );
// need a xml with width and height // 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 // svg 含有 &nbsp; 符号导出报错 Entity 'nbsp' not defined
svgXml = svgXml.replace(/&nbsp;/g, '&#xa0;'); svgXml = svgXml.replace( /&nbsp;/g, '&#xa0;' );
blob = new Blob( [ svgXml ], { blob = new Blob( [ svgXml ], {
type: "image/svg+xml;charset=utf-8" 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