Commit 42512cd0 authored by campaign's avatar campaign

修复粘贴

parent 4803fcb3
......@@ -81,9 +81,9 @@ KityMinder.registerModule( "ClipboardModule", function () {
'paste': PasteCommand
},
'commandShortcutKeys': {
'copy': 'ctrl+c',
'cut': 'ctrl+x',
'paste': 'ctrl+v'
'copy': 'normal::ctrl+c|',
'cut': 'normal::ctrl+x',
'paste': 'normal::ctrl+v'
}
};
} );
\ No newline at end of file
......@@ -128,15 +128,16 @@ KityMinder.registerModule('TextEditModule', function() {
receiver.clear();
},
'inputready.keyup':function(e){
'inputready.keyup':function(){
if(sel.isHide()){
inputStatusReady(me.getSelectedNode());
inputStatusReady(this.getSelectedNode());
}
},
//当节点选区通过键盘发生变化时,输入状态要准备好
'normal.keyup': function(e) {
var node = this.getSelectedNode();
var keyCode = e.getKeyCode();
if (node) {
if (this.isSingleSelect() && node.isSelected() && !sel.isShow() ) {
var orgEvt = e.originEvent;
......
......@@ -12,6 +12,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
this.lastMinderNode = null;
this.isTypeText = false;
this._initEvent();
this.isShortcutCopyKey = false;
},
//给接受容器绑定事件
_initEvent: function(){
......@@ -118,7 +119,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
}, 200);
me.km.setStatus('textedit');
},
_input:function(e){
_input:function(){
var me = this;
if (browser.ipad) {
setTimeout(function() {
......@@ -139,7 +140,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
me._handlerEnterkey();
e.preventDefault();
return false;
}
};
case keymap.Tab:
if(this.selection.isShow()){
this.re.clear();
......@@ -168,7 +169,8 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
case keymap.Alt:
case keymap.Cmd:
case keymap.F2:
if(this.selection.isHide() && this.km.getStatus() != 'textedit'){
if(this.selection.isHide() && this.km.getStatus() != 'textedit' && this.km.getStatus() !='inputready'){
this.km.setStatus('normal');
return;
}
......@@ -183,8 +185,10 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
88:1,
67:1
}[keyCode]){
//修正在cvs方式下_keyup会把节点文字选中
this.isShortcutCopyKey = true;
this.km.setStatus('normal');
return;
}
......@@ -193,24 +197,38 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
setTimeout(function () {
me.range.updateNativeRange().insertNode($('<span>$$_kityminder_bookmark_$$</span>')[0]);
me.container.innerHTML = utils.unhtml(me.container.textContent.replace(/[\u200b\t\r\n]/g, ''));
var index = me.container.textContent.indexOf('$$_kityminder_bookmark_$$');
me.container.textContent = me.container.textContent.replace('$$_kityminder_bookmark_$$', '');
me.range.setStart(me.container.firstChild, index).collapse(true).select();
var brArr = [];
utils.each(me.container.getElementsByTagName('br'),function(i,br){
brArr.push(br);
});
utils.each(brArr,function(i,br){
var textNode = document.createTextNode('\n');
br.parentNode.insertBefore(textNode,br);
br.parentNode.removeChild(br);
});
var textContent = me.container.textContent.replace(/[\u200b\t\r]/g,'');
var index = textContent.indexOf('$$_kityminder_bookmark_$$');
me.re.setContainerTxt(textContent.replace('$$_kityminder_bookmark_$$',''));
me.range.setStartOffset(index).collapse(true).select();
me._setTextToContainer(keyCode);
}, 100);
},50);
return;
}
//剪切
if (keyCode == keymap.x) {
setTimeout(function () {
me._setTextToContainer(keyCode);
}, 100);
},50);
return;
}
}
this.isShortcutCopyKey = false;
//针对不能连续删除做处理
if(keymap.Del == keyCode || keymap.Backspace == keyCode)
me._setTextToContainer(keyCode);
......@@ -260,6 +278,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
me._setTextToContainer(keyCode);
return;
}
if (this.isTypeText) {
me._setTextToContainer(keyCode);
return;
......@@ -277,6 +296,13 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
var timer;
var node = this.km.getSelectedNode();
if(this.km.getStatus() == 'normal' && node && this.selection.isHide()){
if(this.isShortcutCopyKey){
console.log(this.km.getStatus())
return;
}
if (node && this.km.isSingleSelect() && node.isSelected()) {
this.re.updateByMinderNode(node);
......@@ -333,6 +359,8 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
rng.setStartBefore(br);
rng.collapse(true);
}
rng.select();
me._setTextToContainer(keymap.Enter);
......
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