Commit 0bd6c8b4 authored by techird's avatar techird

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

parents 053e37b4 d2b688c3
......@@ -93,8 +93,11 @@ KityMinder.registerModule('TextEditModule', function() {
if(selectionReadyShow){
textShape.setStyle('cursor', 'text');
sel.clearBaseOffset();
receiver.updateSelection();
setTimeout(function() {
sel.setShow();
}, 200);
km.setStatus('textedit');
}
......@@ -143,9 +146,14 @@ KityMinder.registerModule('TextEditModule', function() {
sel.setColor(node.getStyle('text-selection-color'));
sel.clearBaseOffset();
node.getTextShape().setStyle('cursor', 'text');
receiver.updateSelection();
setTimeout(function() {
sel.setShow();
}, 200);
lastEvtPosition = e.getPosition(this.getRenderContainer());
......@@ -161,6 +169,7 @@ KityMinder.registerModule('TextEditModule', function() {
}else {
//当有光标时,要同步选区
if(!sel.collapsed){
sel.clearBaseOffset();
receiver.updateContainerRangeBySel();
}
......
......@@ -94,12 +94,13 @@ Minder.Receiver = kity.createClass('Receiver', {
},
keyboardEvents: function(e) {
clearTimeout(this.timer);
var me = this;
var orgEvt = e.originEvent;
var keyCode = orgEvt.keyCode;
function setTextToContainer() {
clearTimeout(me.timer);
if (!me.range.hasNativeRange()) {
return;
}
......@@ -142,9 +143,10 @@ Minder.Receiver = kity.createClass('Receiver', {
me.updateSelection();
me.timer = setTimeout(function() {
me.selection.setShow();
}, 300);
}, 200);
me.km.setStatus('textedit');
me.selection.clearBaseOffset();
}
......@@ -196,32 +198,41 @@ Minder.Receiver = kity.createClass('Receiver', {
}
//针对按住shift+方向键进行处理
if(orgEvt.shiftKey && keymap.direction[keyCode] && this.selection.isShow()){
if(this.selection.baseOffset === null){
this.selection.baseOffset = this.selection.startOffset;
this.selection.currentEndOffset = this.selection.endOffset;
}
var textlength = this.textShape.getContent().length;
if(keymap.right == keyCode ){
var endOffset = this.selection.endOffset+1;
if(endOffset > textlength){
endOffset = textlength;
this.selection.currentEndOffset++;
if(this.selection.currentEndOffset > textlength){
this.selection.currentEndOffset = textlength;
}
this.selection.setEndOffset(endOffset);
}else if(keymap.left == keyCode){
endOffset = this.selection.endOffset-1;
if(endOffset < 0){
endOffset = 0;
}else if(keymap.left == keyCode){
this.selection.currentEndOffset--;
if(this.selection.currentEndOffset < 0){
this.selection.currentEndOffset = 0;
}
if(endOffset <= this.selection.startOffset){
if(endOffset == this.selection.startOffset){
this.selection.setEndOffset(endOffset)
}else if(keymap.up == keyCode){
this.selection.currentEndOffset = 0;
this.selection.baseOffset = this.selection.endOffset;
}else{
this.selection.setStartOffset(endOffset)
this.selection.currentEndOffset = textlength;
}
}else{
this.selection.setEndOffset(endOffset);
if(this.selection.currentEndOffset >= this.selection.baseOffset){
this.selection.setEndOffset(this.selection.currentEndOffset);
if(this.selection.currentEndOffset == this.selection.baseOffset){
this.selection.setStartOffset(this.selection.baseOffset);
}
}else{
this.selection.setStartOffset(this.selection.currentEndOffset);
this.selection.setEndOffset(this.selection.baseOffset);
}
this.updateContainerRangeBySel();
this.updateSelectionShow();
......@@ -448,7 +459,8 @@ Minder.Receiver = kity.createClass('Receiver', {
endOffset = this.textData[this.selection.endOffset],
width = 0;
if (this.selection.collapsed) {
this.selection.updateShow(startOffset || this.textData[this.textData.length - 1], 1);
this.selection.updateShow(startOffset || this.textData[this.textData.length - 1], 2);
return this;
}
if (!endOffset) {
......
......@@ -116,5 +116,8 @@ Minder.Selection = kity.createClass( 'Selection', {
},
isHide:function(){
return !this._show;
},
clearBaseOffset:function(){
this.baseOffset = this.currentEndOffset = null;
}
} );
\ 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