Commit 7dc71dce authored by techird's avatar techird

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

parents d18c5145 cc241e11
......@@ -95,7 +95,7 @@ KityMinder.registerModule('TextEditModule', function() {
var textShape = node.getTextShape();
textShape.setStyle('cursor', 'default');
if (this.isSingleSelect() && node.isSelected()) {
sel.collapse();
sel.collapse(true);
sel.setColor(node.getStyle('text-selection-color'));
receiver
.setMinderNode(node)
......
......@@ -200,6 +200,10 @@ Minder.Receiver = kity.createClass('Receiver', {
this.km.setStatus('normal');
return;
}
if(!orgEvt.shiftKey){
this.selection.baseOffset =
this.selection.currentEndOffset = null;
}
break;
// case keymap.Shift:
case keymap.Control:
......@@ -215,9 +219,7 @@ 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;
}
......@@ -292,9 +294,21 @@ Minder.Receiver = kity.createClass('Receiver', {
case keymap.Enter:
case keymap.Tab:
case keymap.F2:
if(browser.ipad){
if(this.selection.isShow()){
this.clear();
this.km.setStatus('inputready');
clearTimeout(me.inputTextTimer);
e.preventDefault();
}else{
this.km.setStatus('normal');
this.km.fire('contentchange');
}
restoreTextContent();
return;
}
if (keymap.Enter == keyCode && (this.isTypeText || browser.mac && browser.gecko)) {
setTextToContainer();
}
if (this.keydownNode === this.minderNode) {
this.rollbackStatus();
......@@ -305,7 +319,6 @@ Minder.Receiver = kity.createClass('Receiver', {
case keymap.Del:
case keymap.Backspace:
case keymap.Spacebar:
setTextToContainer();
return;
}
......@@ -450,7 +463,7 @@ Minder.Receiver = kity.createClass('Receiver', {
me.selection.setStartOffset(i);
}
if (offset.x <= v.x + v.width / 2) {
me.selection.collapse();
me.selection.collapse(true);
} else {
me.selection.setEndOffset(i + ((me.selection.endOffset > i ||
dir == 1) && i != me.textData.length - 1 ? 1 : 0));
......
......@@ -19,25 +19,22 @@ Minder.Selection = kity.createClass( 'Selection', {
setColor:function(color){
this.fill(color);
},
collapse : function(toEnd){
collapse : function(toStart){
this.setOpacity(1);
this.width = 2;
this.collapsed = true;
if(toEnd){
this.startOffset = this.endOffset;
}else{
if(toStart){
this.endOffset = this.startOffset;
}else{
this.startOffset = this.endOffset;
}
return this;
},
setStartOffset:function(offset){
this.startOffset = offset;
var tmpOffset = this.startOffset;
if(this.startOffset > this.endOffset){
this.startOffset = this.endOffset;
this.endOffset = tmpOffset;
}else if(this.startOffset == this.endOffset){
this.collapse();
if(this.startOffset >= this.endOffset){
this.collapse(true);
return this;
}
this.collapsed = false;
......@@ -46,16 +43,12 @@ Minder.Selection = kity.createClass( 'Selection', {
},
setEndOffset:function(offset){
this.endOffset = offset;
var tmpOffset = this.endOffset;
if(this.endOffset < this.startOffset){
this.endOffset = this.startOffset;
this.startOffset = tmpOffset;
}else if(this.startOffset == this.endOffset){
this.collapse();
if(this.endOffset <= this.startOffset){
this.startOffset = offset;
this.collapse(true);
return this;
}
this.collapsed = false;
// this.stroke('none',0);
this.setOpacity(0.5);
return this;
},
......
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