Commit 726ee5bb authored by techird's avatar techird

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

parents ef6bcd56 548d0666
......@@ -106,6 +106,7 @@ KityMinder.registerModule('TextEditModule', function() {
lastEvtPosition = e.getPosition(this.getRenderContainer());
if(selectionReadyShow){
textShape.setStyle('cursor', 'text');
sel.clearBaseOffset();
receiver.updateSelection();
......@@ -156,7 +157,8 @@ KityMinder.registerModule('TextEditModule', function() {
if (node && !selectionReadyShow && receiver.isReady()) {
sel.collapse();
sel.collapse(true);
sel.setColor(node.getStyle('text-selection-color'));
......@@ -165,6 +167,12 @@ KityMinder.registerModule('TextEditModule', function() {
node.getTextShape().setStyle('cursor', 'text');
receiver.updateSelection();
//必须再次focus,要不不能呼出键盘
if(browser.ipad){
receiver.focus();
}
setTimeout(function() {
sel.setShow();
}, 200);
......
......@@ -10,6 +10,7 @@ Minder.Receiver = kity.createClass('Receiver', {
}
this.index = 0;
this.isTypeText = false;
this.lastMinderNode = null;
return this;
},
constructor: function(km,sel,range) {
......@@ -20,12 +21,19 @@ Minder.Receiver = kity.createClass('Receiver', {
_div.setAttribute('contenteditable', true);
_div.className = 'km_receiver';
this.container = _div;
if (browser.ie && browser.version == 11 || browser.ipad) {
if(browser.ipad) {
utils.listen(this.container, 'keydown keypress keyup input', function(e) {
me.keyboardEvents.call(me, new MinderEvent(e.type == 'keyup' ? 'beforekeyup' : e.type, e));
if(e.type == 'keyup'){
if(me.km.getStatus() == 'normal'){
me.km.fire( 'keyup', e);
}
}
});
}
utils.addCssRule('km_receiver_css', ' .km_receiver{white-space:nowrap;position:absolute;padding:0;margin:0;word-wrap:break-word;clip:rect(1em 1em 1em 1em);'); //
utils.addCssRule('km_receiver_css', ' .km_receiver{white-space:nowrap;position:absolute;padding:0;margin:0;word-wrap:break-word;' + (/\?debug$/.test(location.href)?'':'clip:rect(1em 1em 1em 1em);'));
this.km.on('inputready.beforekeyup inputready.beforekeydown textedit.beforekeyup textedit.beforekeydown textedit.keypress textedit.paste', utils.proxy(this.keyboardEvents, this));
this.timer = null;
this.index = 0;
......@@ -124,7 +132,9 @@ Minder.Receiver = kity.createClass('Receiver', {
if (browser.gecko && /\s$/.test(text)) {
text += '\u200b';
}
if (text.length === 0) {
me.minderNode.setTmpData('_lastTextContent',me.textShape.getContent());
me.minderNode.setText('a');
}else {
......@@ -348,6 +358,13 @@ Minder.Receiver = kity.createClass('Receiver', {
case keymap.Del:
case keymap.Backspace:
case keymap.Spacebar:
if(browser.ipad){
if(this.selection.isHide()){
this.km.setStatus('normal');
return;
}
}
setTextToContainer(keyCode);
return;
}
......@@ -404,7 +421,7 @@ Minder.Receiver = kity.createClass('Receiver', {
setContainerStyle: function() {
var textShapeBox = this.getBaseOffset('screen');
this.container.style.cssText = ';left:' + (browser.ipad ? '-' : '') +
textShapeBox.x + 'px;top:' + (textShapeBox.y) +
textShapeBox.x + 'px;top:' + (textShapeBox.y + (/\?debug$/.test(location.href)?30:0)) +
'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
return this;
......@@ -581,5 +598,8 @@ Minder.Receiver = kity.createClass('Receiver', {
},
isReady:function(){
return this._ready;
},
focus:function(){
this.container.focus();
}
});
\ No newline at end of file
......@@ -182,6 +182,34 @@ KityMinder.registerModule("KeyboardModule", function() {
break;
}
},
'normal.keyup':function(e){
if(browser.ipad){
var keys = KityMinder.keymap;
var node = e.getTargetNode();
var lang = this.getLang();
if (this.receiver) this.receiver.keydownNode = node;
var keyEvent = e.originEvent;
if (keyEvent.altKey || keyEvent.ctrlKey || keyEvent.metaKey || keyEvent.shiftKey) return;
switch (keyEvent.keyCode) {
case keys.Enter:
this.execCommand('AppendSiblingNode', lang.topic);
e.preventDefault();
break;
case keys.Backspace:
case keys.Del:
e.preventDefault();
this.execCommand('RemoveNode');
break;
}
}
}
}
};
......
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