Commit d6f01c94 authored by campaign's avatar campaign

添加换行机制

parent e3d55a0f
......@@ -83,7 +83,6 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
// }
//重新渲染节点
me.minderNode.setText(text);
me.re.setContainerStyle();
me.minderNode.getRenderContainer().bringTop();
......@@ -109,10 +108,11 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
me.timer = setTimeout(function() {
if(me.selection.isShow()){
me.selection.setShow();
}
}, 200);
......@@ -227,7 +227,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
case keymap.F2:
if(browser.ipad){
if(this.selection.isShow()){
this.clear();
this.re.clear();
this.km.setStatus('inputready');
clearTimeout(me.inputTextTimer);
e.preventDefault();
......@@ -237,12 +237,13 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
}
return;
}
if (keymap.Enter == keyCode && (this.isTypeText || browser.mac && browser.gecko)) {
me._setTextToContainer(keyCode);
}
if (this.keydownNode === this.minderNode) {
this.rollbackStatus();
this.clear();
if (this.re.keydownNode === this.re.minderNode) {
this.km.rollbackStatus();
this.re.clear();
}
e.preventDefault();
return;
......@@ -317,9 +318,20 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
rng.insertNode(br);
rng.setStartAfter(br);
rng.collapse(true);
var start = rng.startContainer.childNodes[rng.startOffset];
if(start && start.nodeType == 3 && start.nodeValue.length === 0){
start.parentNode.removeChild(start);
if(!rng.startContainer.childNodes[rng.startOffset]){
br = br.cloneNode(false);
rng.startContainer.appendChild(br);
rng.setStartBefore(br);
rng.collapse(true);
}
}
rng.select();
me._setTextToContainer(keymap.Enter);
}
};
......
......@@ -71,6 +71,13 @@ Minder.Range = kity.createClass('Range',function(){
start.appendChild(char);
this.nativeRange.setStart(char,1);
this.nativeRange.collapse(true);
}else if(this.collapsed && start.nodeType == 1){
start = start.childNodes[this.startOffset];
if(start && start.nodeType == 3 && start.nodeValue.length === 0){
this.nativeRange.setStart(start,1);
this.nativeRange.collapse(true);
}
}
try{
this.nativeSel.removeAllRanges();
......@@ -84,6 +91,7 @@ Minder.Range = kity.createClass('Range',function(){
_updateBoundary : function(){
var nRange = this.nativeRange;
this.startContainer = nRange.startContainer;
this.startContainer = nRange.startContainer;
this.endContainer = nRange.endContainer;
this.startOffset = nRange.startOffset;
this.endOffset = nRange.endOffset;
......@@ -108,6 +116,9 @@ Minder.Range = kity.createClass('Range',function(){
setStartAfter:function(node){
return this.setStart(node.parentNode,utils.getNodeIndex(node) + 1);
},
setStartBefore:function(node){
return this.setStart(node.parentNode,utils.getNodeIndex(node));
},
setEnd:function(node,offset){
this.nativeRange.setEnd(node,offset);
this._updateBoundary();
......
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