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