Commit 429fb645 authored by campaign's avatar campaign

ipad支持编辑

parent edaec00e
...@@ -106,6 +106,7 @@ KityMinder.registerModule('TextEditModule', function() { ...@@ -106,6 +106,7 @@ KityMinder.registerModule('TextEditModule', function() {
lastEvtPosition = e.getPosition(this.getRenderContainer()); lastEvtPosition = e.getPosition(this.getRenderContainer());
if(selectionReadyShow){ if(selectionReadyShow){
textShape.setStyle('cursor', 'text'); textShape.setStyle('cursor', 'text');
sel.clearBaseOffset(); sel.clearBaseOffset();
receiver.updateSelection(); receiver.updateSelection();
...@@ -156,7 +157,8 @@ KityMinder.registerModule('TextEditModule', function() { ...@@ -156,7 +157,8 @@ KityMinder.registerModule('TextEditModule', function() {
if (node && !selectionReadyShow && receiver.isReady()) { if (node && !selectionReadyShow && receiver.isReady()) {
sel.collapse();
sel.collapse(true);
sel.setColor(node.getStyle('text-selection-color')); sel.setColor(node.getStyle('text-selection-color'));
...@@ -165,6 +167,12 @@ KityMinder.registerModule('TextEditModule', function() { ...@@ -165,6 +167,12 @@ KityMinder.registerModule('TextEditModule', function() {
node.getTextShape().setStyle('cursor', 'text'); node.getTextShape().setStyle('cursor', 'text');
receiver.updateSelection(); receiver.updateSelection();
//必须再次focus,要不不能呼出键盘
if(browser.ipad){
receiver.focus();
}
setTimeout(function() { setTimeout(function() {
sel.setShow(); sel.setShow();
}, 200); }, 200);
......
...@@ -23,9 +23,16 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -23,9 +23,16 @@ Minder.Receiver = kity.createClass('Receiver', {
if (browser.ie && browser.version == 11 || browser.ipad) { if (browser.ie && browser.version == 11 || browser.ipad) {
utils.listen(this.container, 'keydown keypress keyup input', function(e) { utils.listen(this.container, 'keydown keypress keyup input', function(e) {
me.keyboardEvents.call(me, new MinderEvent(e.type == 'keyup' ? 'beforekeyup' : e.type, 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.km.on('inputready.beforekeyup inputready.beforekeydown textedit.beforekeyup textedit.beforekeydown textedit.keypress textedit.paste', utils.proxy(this.keyboardEvents, this));
this.timer = null; this.timer = null;
this.index = 0; this.index = 0;
...@@ -344,6 +351,13 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -344,6 +351,13 @@ Minder.Receiver = kity.createClass('Receiver', {
case keymap.Del: case keymap.Del:
case keymap.Backspace: case keymap.Backspace:
case keymap.Spacebar: case keymap.Spacebar:
if(browser.ipad){
if(this.selection.isHide()){
this.km.setStatus('normal');
return;
}
}
setTextToContainer(keyCode); setTextToContainer(keyCode);
return; return;
} }
...@@ -400,7 +414,7 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -400,7 +414,7 @@ Minder.Receiver = kity.createClass('Receiver', {
setContainerStyle: function() { setContainerStyle: function() {
var textShapeBox = this.getBaseOffset('screen'); 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.x + 'px;top:' + (textShapeBox.y + (/\?debug$/.test(location.href)?30:0)) +
'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;'; 'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
return this; return this;
...@@ -577,5 +591,8 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -577,5 +591,8 @@ Minder.Receiver = kity.createClass('Receiver', {
}, },
isReady:function(){ isReady:function(){
return this._ready; return this._ready;
},
focus:function(){
this.container.focus();
} }
}); });
\ No newline at end of file
...@@ -182,6 +182,34 @@ KityMinder.registerModule("KeyboardModule", function() { ...@@ -182,6 +182,34 @@ KityMinder.registerModule("KeyboardModule", function() {
break; 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