Commit 5071ea9f authored by campaign's avatar campaign

fixed #10

parent 3884420c
...@@ -268,6 +268,21 @@ var utils = Utils = KityMinder.Utils = { ...@@ -268,6 +268,21 @@ var utils = Utils = KityMinder.Utils = {
} }
return target; 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', { ...@@ -46,7 +46,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
textShape = new kity.Text(); textShape = new kity.Text();
} }
this.textShape = textShape; this.textShape = textShape;
this.container.innerHTML = textShape.getContent(); this.container.innerHTML = utils.unhtml(textShape.getContent());
return this; return this;
}, },
setTextShapeSize: function ( size ) { setTextShapeSize: function ( size ) {
...@@ -90,9 +90,7 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -90,9 +90,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
me.setContainerStyle(); me.setContainerStyle();
me.minderNode.setText( text ); me.minderNode.setText( text );
if ( text.length == 0 ) { if ( text.length == 0 ) {
me.minderNode.setText( 'a' ); me.minderNode.setText( 'a' );
} }
me.km.updateLayout( me.minderNode ); me.km.updateLayout( me.minderNode );
...@@ -142,7 +140,7 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -142,7 +140,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
setTimeout( function () { setTimeout( function () {
me.range.updateNativeRange().insertNode( $( '<span>$$_kityminder_bookmark_$$</span>' )[ 0 ] ); 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_$$' ); var index = me.container.textContent.indexOf( '$$_kityminder_bookmark_$$' );
me.container.textContent = me.container.textContent.replace( '$$_kityminder_bookmark_$$', '' ); me.container.textContent = me.container.textContent.replace( '$$_kityminder_bookmark_$$', '' );
me.range.setStart( me.container.firstChild, index ).collapse( true ).select(); me.range.setStart( me.container.firstChild, index ).collapse( true ).select();
......
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