Commit 90d75c83 authored by techird's avatar techird

Merge branch 'dev' of github.com:fex-team/kityminder into dev

parents f54afaa9 22a17341
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
1. 添加了剪贴板操作的支持 1. 添加了剪贴板操作的支持
2. 添加了本地自动保存草稿的功能 2. 添加了本地自动保存草稿的功能
3. 发布版本上添加了 Github 地址 3. 发布版本上添加了 Github 地址
4. 优化了文字选中效果
### 功能调整 ### 功能调整
......
...@@ -22,7 +22,7 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -22,7 +22,7 @@ Minder.Receiver = kity.createClass('Receiver',{
_div.setAttribute('contenteditable',true); _div.setAttribute('contenteditable',true);
_div.className = 'km_receiver'; _div.className = 'km_receiver';
this.container = document.body.insertBefore(_div,document.body.firstChild); this.container = document.body.insertBefore(_div,document.body.firstChild);
utils.addCssRule('km_receiver_css',' .km_receiver{position:absolute;padding:0;margin:0;word-wrap:break-word;clip:rect(1em 1em 1em 1em);}');// utils.addCssRule('km_receiver_css',' .km_receiver{position:absolute;padding:0;margin:0;word-wrap:break-word;}');//clip:rect(1em 1em 1em 1em);
this.km.on('textedit.beforekeyup textedit.keydown textedit.paste', utils.proxy(this.keyboardEvents,this)); this.km.on('textedit.beforekeyup textedit.keydown textedit.paste', utils.proxy(this.keyboardEvents,this));
this.timer = null; this.timer = null;
this.index = 0; this.index = 0;
...@@ -275,16 +275,27 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -275,16 +275,27 @@ 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)) if(offset.x <= v.x + v.width/2){
me.selection.collapse()
}else {
me.selection.setEndOffset(i + (me.selection.endOffset > i || dir == 1 ? 1 : 0))
}
}else if(i > me.index){ }else if(i > me.index){
me.selection.setStartOffset(me.index); me.selection.setStartOffset(me.index);
me.selection.setEndOffset(i + (dir == 1 ? 1 : 0)) me.selection.setEndOffset(i + 1)
}else{ }else{
me.selection.setStartOffset(i + (dir == 1 ? 1 : 0)); if(dir == 1){
me.selection.setStartOffset(i + (offset.x >= v.x + v.width/2 ? 1 : 0));
}else{
me.selection.setStartOffset(i);
}
me.selection.setEndOffset(me.index) me.selection.setEndOffset(me.index)
} }
...@@ -298,7 +309,6 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -298,7 +309,6 @@ Minder.Receiver = kity.createClass('Receiver',{
endOffset = this.textData[this.selection.endOffset], endOffset = this.textData[this.selection.endOffset],
width = 0 ; width = 0 ;
if(this.selection.collapsed){ if(this.selection.collapsed){
this.selection.updateShow(startOffset||this.textData[this.textData.length-1],0); this.selection.updateShow(startOffset||this.textData[this.textData.length-1],0);
return this; return this;
} }
......
...@@ -63,6 +63,12 @@ Minder.Selection = kity.createClass( 'Selection', { ...@@ -63,6 +63,12 @@ Minder.Selection = kity.createClass( 'Selection', {
this.setShowHold(); this.setShowHold();
} }
this.setPosition(offset).setWidth(width); this.setPosition(offset).setWidth(width);
//解决在框选内容时,出现很窄的光标
if(width == 0){
this.setOpacity(0);
}else{
this.setOpacity(0.5);
}
return this; return this;
}, },
setPosition: function ( offset ) { setPosition: function ( offset ) {
...@@ -73,7 +79,6 @@ Minder.Selection = kity.createClass( 'Selection', { ...@@ -73,7 +79,6 @@ Minder.Selection = kity.createClass( 'Selection', {
} catch ( e ) { } catch ( e ) {
console.log(e) console.log(e)
} }
return this.update(); return this.update();
}, },
setHeight: function ( height ) { setHeight: function ( height ) {
......
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