Commit ee0677b8 authored by campaign's avatar campaign

修复光标的方向键问题

parent 97b7b458
......@@ -48,7 +48,7 @@ KityMinder.registerModule('TextEditModule', function() {
return {
'events': {
'ready': function() {
this._renderTarget.appendChild(receiver.container);
document.body.appendChild(receiver.container);
},
'normal.beforemousedown textedit.beforemousedown inputready.beforemousedown': function(e) {
......@@ -83,7 +83,6 @@ KityMinder.registerModule('TextEditModule', function() {
if (this.isSingleSelect() && node.isSelected()) {
sel.collapse();
sel.setColor(node.getStyle('text-selection-color'));
receiver
.setMinderNode(node)
.setCurrentIndex(e.getPosition(this.getRenderContainer()))
......@@ -133,6 +132,7 @@ KityMinder.registerModule('TextEditModule', function() {
}
},
'normal.mouseup textedit.mouseup inputready.mouseup': function(e) {
mouseDownStatus = false;
var node = e.getTargetNode();
......@@ -160,7 +160,11 @@ KityMinder.registerModule('TextEditModule', function() {
inputStatusReady(e.getTargetNode());
}else {
//当有光标时,要同步选区
receiver.updateContainerRangeBySel();
if(!sel.collapsed){
receiver.updateContainerRangeBySel();
}
}
......
......@@ -40,6 +40,7 @@ Minder.Receiver = kity.createClass('Receiver', {
this.range = range;
range.setStart(text || this.container, this.index).collapse(true);
var me = this;
setTimeout(function() {
me.container.focus();
range.select();
......@@ -327,25 +328,11 @@ Minder.Receiver = kity.createClass('Receiver', {
return this;
},
setContainerStyle: function() {
var textShapeBox = this.getBaseOffset('paper');
var textShapeBox = this.getBaseOffset('screen');
this.container.style.cssText = ';left:' + (browser.ipad ? '-' : '') +
textShapeBox.x + 'px;top:' + (textShapeBox.y + textShapeBox.height * 0.1 ) +
textShapeBox.x + 'px;top:' + (textShapeBox.y ) +
'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
if (!this.selection.isShow()) {
var paperContainer = this.km.getPaper();
var width = paperContainer.node.parentNode.clientWidth;
var height = paperContainer.node.parentNode.clientHeight;
if (width < this.container.offsetWidth + this.container.offsetLeft) {
this.km.getRenderContainer().translate(width / -3, 0);
this.setContainerStyle();
} else if (height < this.container.offsetTop + this.container.offsetHeight) {
this.km.getRenderContainer().translate(0, height / -3);
this.setContainerStyle();
}
}
return this;
},
getTextOffsetData: function() {
......
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