Commit ee0677b8 authored by campaign's avatar campaign

修复光标的方向键问题

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