Commit 49821b86 authored by techird's avatar techird

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

parents 7fd89174 ee0677b8
......@@ -26,11 +26,18 @@ var keymap = KityMinder.keymap = (function(origin) {
'End': 35,
'Home': 36,
'Left': 37,
'Up': 38,
'Right': 39,
'Down': 40,
'direction':{
37:1,
38:1,
39:1,
40:1
},
'Insert': 45,
'Del': 46,
......
......@@ -48,7 +48,7 @@ KityMinder.registerModule('TextEditModule', function() {
return {
'events': {
'ready': function() {
this._renderTarget.appendChild(receiver.container);
document.body.appendChild(receiver.container);
},
'normal.beforemousedown textedit.beforemousedown inputready.beforemousedown': function(e) {
......@@ -83,7 +83,6 @@ KityMinder.registerModule('TextEditModule', function() {
if (this.isSingleSelect() && node.isSelected()) {
sel.collapse();
sel.setColor(node.getStyle('text-selection-color'));
receiver
.setMinderNode(node)
.setCurrentIndex(e.getPosition(this.getRenderContainer()))
......@@ -133,13 +132,13 @@ KityMinder.registerModule('TextEditModule', function() {
}
},
'normal.mouseup textedit.mouseup inputready.mouseup': function(e) {
mouseDownStatus = false;
var node = e.getTargetNode();
if (node && !selectionReadyShow && receiver.isReady()) {
sel.collapse();
sel.setColor(node.getStyle('text-selection-color'));
......@@ -159,10 +158,18 @@ KityMinder.registerModule('TextEditModule', function() {
//当选中节点后,输入状态准备
if(sel.isHide()){
inputStatusReady(e.getTargetNode());
}else {
//当有光标时,要同步选区
if(!sel.collapsed){
receiver.updateContainerRangeBySel();
}
}
},
'textedit.beforemousemove inputready.beforemousemove': function(e) {
if(browser.ipad){
......@@ -240,9 +247,9 @@ KityMinder.registerModule('TextEditModule', function() {
km.setStatus('normal');
receiver.clear();
},
// 'blur': function() {
// receiver.clear();
// },
'blur': function() {
receiver.clear();
},
'import': function() {
km.setStatus('normal');
receiver.clear();
......
......@@ -40,6 +40,7 @@ Minder.Receiver = kity.createClass('Receiver', {
this.range = range;
range.setStart(text || this.container, this.index).collapse(true);
var me = this;
setTimeout(function() {
me.container.focus();
range.select();
......@@ -162,10 +163,6 @@ Minder.Receiver = kity.createClass('Receiver', {
switch (keyCode) {
case keymap.Enter:
case keymap.Tab:
case keymap.left:
case keymap.right:
case keymap.up:
case keymap.down:
if(this.selection.isShow()){
this.clear();
this.km.setStatus('inputready');
......@@ -176,7 +173,16 @@ Minder.Receiver = kity.createClass('Receiver', {
this.km.fire('contentchange');
}
return;
case keymap.Shift:
case keymap.left:
case keymap.right:
case keymap.up:
case keymap.down:
if(this.selection.isHide()){
this.km.setStatus('normal');
return;
}
break;
// case keymap.Shift:
case keymap.Control:
case keymap.Alt:
case keymap.Cmd:
......@@ -188,7 +194,40 @@ Minder.Receiver = kity.createClass('Receiver', {
}
return;
}
//针对按住shift+方向键进行处理
if(orgEvt.shiftKey && keymap.direction[keyCode] && this.selection.isShow()){
var textlength = this.textShape.getContent().length;
if(keymap.right == keyCode ){
var endOffset = this.selection.endOffset+1;
if(endOffset > textlength){
endOffset = textlength;
}
this.selection.setEndOffset(endOffset);
}else if(keymap.left == keyCode){
endOffset = this.selection.endOffset-1;
if(endOffset < 0){
endOffset = 0;
}
if(endOffset <= this.selection.startOffset){
if(endOffset == this.selection.startOffset){
this.selection.setEndOffset(endOffset)
}else{
this.selection.setStartOffset(endOffset)
}
}else{
this.selection.setEndOffset(endOffset);
}
}
this.updateContainerRangeBySel();
this.updateSelectionShow();
e.preventDefault();
return;
}
if (e.originEvent.ctrlKey || e.originEvent.metaKey) {
//粘贴
......@@ -289,25 +328,11 @@ Minder.Receiver = kity.createClass('Receiver', {
return this;
},
setContainerStyle: function() {
var textShapeBox = this.getBaseOffset('paper');
var textShapeBox = this.getBaseOffset('screen');
this.container.style.cssText = ';left:' + (browser.ipad ? '-' : '') +
textShapeBox.x + 'px;top:' + (textShapeBox.y + textShapeBox.height * 0.1) +
textShapeBox.x + 'px;top:' + (textShapeBox.y ) +
'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
if (!this.selection.isShow()) {
var paperContainer = this.km.getPaper();
var width = paperContainer.node.parentNode.clientWidth;
var height = paperContainer.node.parentNode.clientHeight;
if (width < this.container.offsetWidth + this.container.offsetLeft) {
this.km.getRenderContainer().translate(width / -3, 0);
this.setContainerStyle();
} else if (height < this.container.offsetTop + this.container.offsetHeight) {
this.km.getRenderContainer().translate(0, height / -3);
this.setContainerStyle();
}
}
return this;
},
getTextOffsetData: function() {
......
......@@ -5,8 +5,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this.callBase();
this.height = height || 20;
this.setAttr('id','_kity_selection');
this.stroke( color || 'rgb(27,171,255)', width || 1 );
this.width = 0;
this.width = 2;
this.fill('rgb(27,171,255)');
this.setHide();
this.timer = null;
......@@ -18,14 +17,11 @@ Minder.Selection = kity.createClass( 'Selection', {
},
setColor:function(color){
this.stroke(color);
this.fill(color);
},
collapse : function(toEnd){
// this.stroke( 'rgb(27,171,255)', 1 );
this.setOpacity(1);
this.width = 1;
this.width = 2;
this.collapsed = true;
if(toEnd){
this.startOffset = this.endOffset;
......@@ -45,7 +41,6 @@ Minder.Selection = kity.createClass( 'Selection', {
return this;
}
this.collapsed = false;
this.stroke('none',0);
this.setOpacity(0.5);
return this;
},
......@@ -60,7 +55,7 @@ Minder.Selection = kity.createClass( 'Selection', {
return this;
}
this.collapsed = false;
this.stroke('none',0);
// this.stroke('none',0);
this.setOpacity(0.5);
return this;
},
......@@ -69,19 +64,13 @@ Minder.Selection = kity.createClass( 'Selection', {
this.setShowHold();
}
this.setPosition(offset).setWidth(width);
//解决在框选内容时,出现很窄的光标
if(width === 0){
this.setOpacity(0);
}else{
this.setOpacity(0.5);
}
this.bringTop();
return this;
},
setPosition: function ( offset ) {
try {
this.x = offset.x;
this.y = offset.y;
this.x = Math.round(offset.x);
this.y = Math.round(offset.y);
} catch ( e ) {
console.log(e);
......
......@@ -45,6 +45,7 @@ KityMinder.registerModule( "pasteModule", function () {
break;
case keys.x:
getNodes(km.getSelectedAncestors(),true);
km.layout(300);
_curstatus = true;
break;
case keys.v:
......
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