Commit 5071ea9f authored by campaign's avatar campaign

fixed #10

parent 3884420c
......@@ -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();
......
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