Commit d6f01c94 authored by campaign's avatar campaign

添加换行机制

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