Commit f5d4355f authored by Akikonata's avatar Akikonata

Merge branch 'dev' of https://github.com/kitygraph/kityminder into dev

parents d2e7e66f 99014b48
...@@ -59,12 +59,20 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -59,12 +59,20 @@ KityMinder.registerModule( "TextEditModule", function () {
'beforemousemove':function(e){ 'beforemousemove':function(e){
if(mouseDownStatus){ if(mouseDownStatus){
e.stopPropagationImmediately(); e.stopPropagationImmediately();
var offset = e.getPosition(); var offset = e.getPosition();
if(Math.abs(offset.y - lastEvtPosition.y) > 2){
sel.setHide();
mouseDownStatus = false;
return;
}
dir = offset.x > lastEvtPosition.x ? 1 : (offset.x < lastEvtPosition.x ? -1 : dir); dir = offset.x > lastEvtPosition.x ? 1 : (offset.x < lastEvtPosition.x ? -1 : dir);
receiver.updateSelectionByMousePosition(offset,dir) receiver.updateSelectionByMousePosition(offset,dir)
.updateSelectionShow(dir); .updateSelectionShow(dir);
sel.stroke('none',0); sel.stroke('none',0);
lastEvtPosition = e.getPosition(); lastEvtPosition = e.getPosition();
} }
}, },
'dblclick':function(e){ 'dblclick':function(e){
...@@ -75,8 +83,8 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -75,8 +83,8 @@ KityMinder.registerModule( "TextEditModule", function () {
sel.setStartOffset(0); sel.setStartOffset(0);
sel.setEndOffset(text.getContent().length); sel.setEndOffset(text.getContent().length);
sel.setShow(); sel.setShow();
receiver.updateSelectionShow(1) receiver.setContainerTxt(text.getContent()).updateSelectionShow(1)
.updateRange(range); .updateRange(range).setTextEditStatus(true)
} }
}, },
......
...@@ -16,7 +16,12 @@ Minder.Range = kity.createClass('Range',{ ...@@ -16,7 +16,12 @@ Minder.Range = kity.createClass('Range',{
return this; return this;
}, },
setStart:function(node,index){ setStart:function(node,index){
this.nativeRange.setStart(node,index); try{
this.nativeRange.setStart(node,index);
}catch(e){
console.log(e)
}
return this; return this;
}, },
setEnd:function(node,index){ setEnd:function(node,index){
......
...@@ -223,16 +223,17 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -223,16 +223,17 @@ Minder.Receiver = kity.createClass('Receiver',{
return false; return false;
} }
if(offset.x >= v.x && offset.x <= v.x + v.width){ if(offset.x >= v.x && offset.x <= v.x + v.width){
if(me.index == i){ if(me.index == i){
if(i == 0){ if(i == 0){
me.selection.setStartOffset(i) me.selection.setStartOffset(i)
} }
me.selection.setEndOffset(i + (dir == 1 ? 1 : 0)) me.selection.setEndOffset(i + (dir == 1 ? 1 : 0))
}else if(i > me.index){ }else if(i > me.index){
me.selection.setStartOffset(me.index);
me.selection.setEndOffset(i + (dir == 1 ? 1 : 0)) me.selection.setEndOffset(i + (dir == 1 ? 1 : 0))
}else{ }else{
me.selection.setStartOffset(i + (dir == 1 ? 1 : 0)) me.selection.setStartOffset(i + (dir == 1 ? 1 : 0));
me.selection.setEndOffset(me.index)
} }
return false; return false;
...@@ -246,7 +247,7 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -246,7 +247,7 @@ Minder.Receiver = kity.createClass('Receiver',{
width = 0 ; width = 0 ;
if(this.selection.collapsed){ if(this.selection.collapsed){
this.selection.updateShow(startOffset,0); this.selection.updateShow(startOffset||this.textData[this.textData.length-1],0);
return this; return this;
} }
if(!endOffset){ if(!endOffset){
...@@ -269,5 +270,9 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -269,5 +270,9 @@ Minder.Receiver = kity.createClass('Receiver',{
setIndex:function(index){ setIndex:function(index){
this.index = index; this.index = index;
return this return this
},
setContainerTxt:function(txt){
this.container.textContent = txt;
return this;
} }
}); });
\ No newline at end of file
...@@ -12,7 +12,8 @@ Minder.Selection = kity.createClass( 'Selection', { ...@@ -12,7 +12,8 @@ Minder.Selection = kity.createClass( 'Selection', {
this.timer = null; this.timer = null;
this.collapsed = true; this.collapsed = true;
this.startOffset = this.endOffset = 0; this.startOffset = this.endOffset = 0;
this.setOpacity(0.5) this.setOpacity(0.5);
this.setStyle('cursor','text');
}, },
collapse : function(toEnd){ collapse : function(toEnd){
...@@ -64,7 +65,7 @@ Minder.Selection = kity.createClass( 'Selection', { ...@@ -64,7 +65,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this.y = offset.y; this.y = offset.y;
} catch ( e ) { } catch ( e ) {
console.log(e) debugger
} }
return this.update(); return this.update();
......
...@@ -29,7 +29,9 @@ KityMinder.registerModule( "Select", function () { ...@@ -29,7 +29,9 @@ KityMinder.registerModule( "Select", function () {
startPosition = g.snapToSharp( e.getPosition() ); startPosition = g.snapToSharp( e.getPosition() );
}, },
selectMove: function ( e ) { selectMove: function ( e ) {
if(minder.isTextEditStatus()){
return;
}
if ( !startPosition ) return; if ( !startPosition ) return;
var p1 = startPosition, var p1 = startPosition,
......
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