Commit 20c7f489 authored by Akikonata's avatar Akikonata

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

parents b038022f 5071ea9f
......@@ -72,6 +72,7 @@
,'adapter/contextmenu.js'
,'adapter/dialog.js'
,'adapter/hyperlink.js'
,'adapter/zoom.js'
,'protocal/xmind.js'
,'protocal/freemind.js'
,'protocal/mindmanager.js'
......
......@@ -63,7 +63,7 @@
'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏
toolbars: [
'hand zoom-in zoom-out collapsenode expandnode | undo redo | bold italic | fontfamily fontsize forecolor | saveto | hyperlink unhyperlink | markers | node | help'
'hand zoom | collapsenode expandnode | undo redo | bold italic | fontfamily fontsize forecolor | saveto | hyperlink unhyperlink | markers | node | help'
]
//只读模式,默认是false
//readOnly: true
......@@ -87,5 +87,7 @@
// defaultLayer: 2,
// defaultSubShow: 5
// }
//配置放大缩小的比例
//,zoom:[50,80,100,120,150,200]
};
} )();
\ No newline at end of file
......@@ -13,8 +13,7 @@ KityMinder.LANG[ 'zh-cn' ] = {
'node': '节点操作',
'saveto': '导出',
'hand': '允许拖拽',
'zoom-in': '放大',
'zoom-out': '缩小',
'zoom': '放大缩小',
'markers': '添加标签',
'switchlayout': '切换主题',
'help': '帮助',
......
KM.registerToolbarUI( 'zoom', function ( name ) {
var me = this,
label = me.getLang( 'tooltips.' + name ),
options = {
label: label,
title: label,
comboboxName: name,
items: me.getOptions( name ) || [],
itemStyles: [],
value: me.getOptions( name ),
autowidthitem: [],
enabledRecord: false,
enabledSelected: false
},
$combox = null;
if ( options.items.length == 0 ) {
return null;
}
//实例化
$combox = $.kmuibuttoncombobox( transForInserttopic( options ) ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
var comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand('zoom', res.value );
} ).on( "beforeshow", function () {
if ( $combox.parent().length === 0 ) {
$combox.appendTo( me.$container.find( '.kmui-dialog-container' ) );
}
} );
//状态反射
me.on( 'interactchange', function () {
var state = 0;
//设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
} );
//comboboxWidget.button().kmui().disabled(-1);
return comboboxWidget.button().addClass( 'kmui-combobox' );
function transForInserttopic( options ) {
var tempItems = [];
utils.each( options.items, function ( k, v ) {
options.value.push( v );
tempItems.push( v + '%' );
options.autowidthitem.push( $.wordCountAdaptive( tempItems[ tempItems.length - 1 ] ) );
} );
options.items = tempItems;
return options;
}
} );
\ No newline at end of file
......@@ -268,6 +268,21 @@ var utils = Utils = KityMinder.Utils = {
}
return target;
},
unhtml:function (str, reg) {
return str ? str.replace(reg || /[&<">'](?:(amp|lt|quot|gt|#39|nbsp);)?/g, function (a, b) {
if (b) {
return a;
} else {
return {
'<':'&lt;',
'&':'&amp;',
'"':'&quot;',
'>':'&gt;',
"'":'&#39;'
}[a]
}
}) : '';
}
};
......
......@@ -46,7 +46,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
textShape = new kity.Text();
}
this.textShape = textShape;
this.container.innerHTML = textShape.getContent();
this.container.innerHTML = utils.unhtml(textShape.getContent());
return this;
},
setTextShapeSize: function ( size ) {
......@@ -90,9 +90,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
me.setContainerStyle();
me.minderNode.setText( text );
if ( text.length == 0 ) {
me.minderNode.setText( 'a' );
}
me.km.updateLayout( me.minderNode );
......@@ -142,7 +140,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
setTimeout( function () {
me.range.updateNativeRange().insertNode( $( '<span>$$_kityminder_bookmark_$$</span>' )[ 0 ] );
me.container.innerHTML = me.container.textContent.replace( /[\u200b\t\r\n]/g, '' );
me.container.innerHTML = utils.unhtml(me.container.textContent.replace( /[\u200b\t\r\n]/g, '' ));
var index = me.container.textContent.indexOf( '$$_kityminder_bookmark_$$' );
me.container.textContent = me.container.textContent.replace( '$$_kityminder_bookmark_$$', '' );
me.range.setStart( me.container.firstChild, index ).collapse( true ).select();
......
KityMinder.registerModule( 'Zoom', function () {
var me = this;
me.setOptions('zoom',[50,80,100,120,150,200]);
var MAX_ZOOM = 2,
MIN_ZOOM = kity.Browser.chrome ? 1 : 0.5,
ZOOM_STEP = Math.sqrt( 2 );
......
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