Commit db5f981f authored by campaign's avatar campaign

添加全选功能

parent 825fb382
...@@ -96,5 +96,6 @@ var keymap = KityMinder.keymap = (function(origin) { ...@@ -96,5 +96,6 @@ var keymap = KityMinder.keymap = (function(origin) {
40: 1, 40: 1,
13: 1, 13: 1,
9: 1 9: 1
} },
'a':65
}); });
\ No newline at end of file
...@@ -233,10 +233,12 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -233,10 +233,12 @@ Minder.Receiver = kity.createClass('Receiver', {
case keymap.F2: case keymap.F2:
// case keymap.Del: // case keymap.Del:
// case keymap.Backspace: // case keymap.Backspace:
if(this.selection.isHide()){ if(this.selection.isHide()){
this.km.setStatus('normal'); this.km.setStatus('normal');
return;
} }
return;
} }
//针对按住shift+方向键进行处理 //针对按住shift+方向键进行处理
if(orgEvt.shiftKey && keymap.direction[keyCode] && this.selection.isShow()){ if(orgEvt.shiftKey && keymap.direction[keyCode] && this.selection.isShow()){
...@@ -317,15 +319,32 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -317,15 +319,32 @@ Minder.Receiver = kity.createClass('Receiver', {
me.range.setStart(me.container.firstChild, index).collapse(true).select(); me.range.setStart(me.container.firstChild, index).collapse(true).select();
setTextToContainer(keyCode); setTextToContainer(keyCode);
}, 100); }, 100);
return;
} }
//剪切 //剪切
if (keyCode == keymap.x) { if (keyCode == keymap.x) {
setTimeout(function() { setTimeout(function() {
setTextToContainer(keyCode); setTextToContainer(keyCode);
}, 100); }, 100);
return;
} }
return; //全选键位监控
if (keymap.a == keyCode) {
if(me.selection.isHide()){
return;
}else{
me.selection
.setStartOffset(0)
.setEndOffset(me.textShape.getContent().length);
me.updateContainerRangeBySel().updateSelectionShow();
return;
}
}
} }
//针对不能连续删除做处理 //针对不能连续删除做处理
if(keymap.Del || keymap.Backspace) if(keymap.Del || keymap.Backspace)
setTextToContainer(keyCode); setTextToContainer(keyCode);
...@@ -379,7 +398,7 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -379,7 +398,7 @@ Minder.Receiver = kity.createClass('Receiver', {
setTextToContainer(keyCode); setTextToContainer(keyCode);
return; return;
} }
if(this.selection.baseOffset === null) if(this.selection.baseOffset === null && this.selection.collapsed)
setTextToContainer(keyCode); setTextToContainer(keyCode);
return true; return true;
} }
...@@ -588,7 +607,7 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -588,7 +607,7 @@ Minder.Receiver = kity.createClass('Receiver', {
return this; return this;
}, },
updateContainerRangeBySel:function(){ updateContainerRangeBySel:function(){
this.updateRange(this.range); return this.updateRange(this.range);
}, },
setIndex: function(index) { setIndex: function(index) {
this.index = index; this.index = index;
......
...@@ -146,6 +146,21 @@ KityMinder.registerModule('Select', function() { ...@@ -146,6 +146,21 @@ KityMinder.registerModule('Select', function() {
// 清理一下选择状态 // 清理一下选择状态
marqueeActivator.selectEnd(e); marqueeActivator.selectEnd(e);
},
//全选操作
'normal.keydown inputready.keydown':function(e){
var keyEvent = e.originEvent;
if ( (keyEvent.ctrlKey || keyEvent.metaKey) && keymap.a == keyEvent.keyCode){
var selectedNodes = [];
this.getRoot().traverse(function(node){
selectedNodes.push(node);
});
this.select(selectedNodes,true);
}
} }
} }
}; };
......
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