Commit f95f1796 authored by campaign's avatar campaign

改进history的性能

parent ead205d7
...@@ -77,6 +77,7 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -77,6 +77,7 @@ KityMinder.registerModule( "TextEditModule", function () {
if ( this.isSingleSelect() && node.isSelected()) {// && e.kityEvent.targetShape.getType().toLowerCase()== 'text' if ( this.isSingleSelect() && node.isSelected()) {// && e.kityEvent.targetShape.getType().toLowerCase()== 'text'
sel.collapse(); sel.collapse();
sel.setSelectionShowStatus(true);
node.getTextShape().setStyle('cursor','text'); node.getTextShape().setStyle('cursor','text');
km.setStatus('textedit'); km.setStatus('textedit');
receiver.setTextEditStatus(true) receiver.setTextEditStatus(true)
...@@ -112,6 +113,7 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -112,6 +113,7 @@ KityMinder.registerModule( "TextEditModule", function () {
var nativeRange = range.nativeSel.getRangeAt(0); var nativeRange = range.nativeSel.getRangeAt(0);
if(nativeRange && (nativeRange.startContainer === receiver.container || receiver.container.contains(nativeRange.startContainer ))){ if(nativeRange && (nativeRange.startContainer === receiver.container || receiver.container.contains(nativeRange.startContainer ))){
km.setStatus('textedit'); km.setStatus('textedit');
sel.setSelectionShowStatus(true);
km.fire('saveScene'); km.fire('saveScene');
} }
...@@ -127,14 +129,13 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -127,14 +129,13 @@ KityMinder.registerModule( "TextEditModule", function () {
var orgEvt = e.originEvent,keyCode = orgEvt.keyCode; var orgEvt = e.originEvent,keyCode = orgEvt.keyCode;
if(keymap.isSelectedNodeKey[keyCode] && km.getStatus() != 'textedit' && !orgEvt.ctrlKey && !orgEvt.metaKey && !orgEvt.shiftKey && !orgEvt.altKey){ if(keymap.isSelectedNodeKey[keyCode] && km.getStatus() != 'textedit' && !orgEvt.ctrlKey && !orgEvt.metaKey && !orgEvt.shiftKey && !orgEvt.altKey){
//准备输入状态 //准备输入状态
var textShape = node.getTextShape(); var textShape = node.getTextShape();
sel.setHide(); sel.setHide();
sel.setStartOffset(0); sel.setStartOffset(0);
sel.setEndOffset(textShape.getContent().length); sel.setEndOffset(textShape.getContent().length);
sel.setSelectionShowStatus(true);
receiver.setTextEditStatus(true) receiver.setTextEditStatus(true)
.setSelection(sel) .setSelection(sel)
.setKityMinder(this) .setKityMinder(this)
...@@ -237,7 +238,7 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -237,7 +238,7 @@ KityMinder.registerModule( "TextEditModule", function () {
sel.setHide(); sel.setHide();
sel.setStartOffset(0); sel.setStartOffset(0);
sel.setEndOffset(textShape.getContent().length); sel.setEndOffset(textShape.getContent().length);
sel.setSelectionShowStatus(false);
receiver.setTextEditStatus(true) receiver.setTextEditStatus(true)
.setSelection(sel) .setSelection(sel)
.setKityMinder(this) .setKityMinder(this)
...@@ -249,6 +250,7 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -249,6 +250,7 @@ KityMinder.registerModule( "TextEditModule", function () {
.setSelectionHeight() .setSelectionHeight()
.setContainerTxt(textShape.getContent()) .setContainerTxt(textShape.getContent())
.updateRange(range).setTextEditStatus(true); .updateRange(range).setTextEditStatus(true);
km.setStatus('normal');
sel.setData('relatedNode',node); sel.setData('relatedNode',node);
}else { }else {
......
...@@ -112,11 +112,15 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -112,11 +112,15 @@ Minder.Receiver = kity.createClass( 'Receiver', {
me.updateTextData(); me.updateTextData();
me.updateIndex(); me.updateIndex();
me.updateSelection();
me.timer = setTimeout( function () {
me.selection.setShow() if( me.selection.getSelectionShowStatus()) {
}, 500 ); me.updateSelection();
me.timer = setTimeout(function () {
me.selection.setShow()
}, 500)
}
} }
var isTypeText = false; var isTypeText = false;
var isKeypress = false; var isKeypress = false;
...@@ -379,7 +383,7 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -379,7 +383,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
var lastOffset = this.textData[ this.textData.length - 1 ]; var lastOffset = this.textData[ this.textData.length - 1 ];
width = lastOffset.x - startOffset.x + lastOffset.width; width = lastOffset.x - startOffset.x + lastOffset.width;
} catch ( e ) { } catch ( e ) {
console.log( 'e' ) console.log( e )
} }
} else { } else {
...@@ -404,4 +408,5 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -404,4 +408,5 @@ Minder.Receiver = kity.createClass( 'Receiver', {
this.container.textContent = txt; this.container.textContent = txt;
return this; return this;
} }
} ); } );
\ No newline at end of file
...@@ -15,6 +15,7 @@ Minder.Selection = kity.createClass( 'Selection', { ...@@ -15,6 +15,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this.setOpacity(0.5); this.setOpacity(0.5);
this.setStyle('cursor','text'); this.setStyle('cursor','text');
this._show = false; this._show = false;
this.selectionShowStatus = true;
}, },
collapse : function(toEnd){ collapse : function(toEnd){
...@@ -103,6 +104,7 @@ Minder.Selection = kity.createClass( 'Selection', { ...@@ -103,6 +104,7 @@ Minder.Selection = kity.createClass( 'Selection', {
var me = this, var me = this,
state = ''; state = '';
me.setStyle( 'display', '' ); me.setStyle( 'display', '' );
this.setSelectionShowStatus(true);
me._show = true; me._show = true;
if(this.collapsed){ if(this.collapsed){
me.setOpacity(1); me.setOpacity(1);
...@@ -133,5 +135,11 @@ Minder.Selection = kity.createClass( 'Selection', { ...@@ -133,5 +135,11 @@ Minder.Selection = kity.createClass( 'Selection', {
}, },
updatePosition: function ( index ) { updatePosition: function ( index ) {
},
setSelectionShowStatus:function(status){
this.selectionShowStatus = status;
},
getSelectionShowStatus:function(){
return this.selectionShowStatus
} }
} ); } );
\ No newline at end of file
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