Commit a7f18700 authored by campaign's avatar campaign

修复ie11的光标

parent 0a733593
...@@ -11,7 +11,12 @@ Minder.Range = kity.createClass('Range',{ ...@@ -11,7 +11,12 @@ Minder.Range = kity.createClass('Range',{
this.nativeRange.setStart(char,1); this.nativeRange.setStart(char,1);
this.nativeRange.collapse(true); this.nativeRange.collapse(true);
} }
this.nativeSel.removeAllRanges(); try{
this.nativeSel.removeAllRanges();
}catch(e){
}
this.nativeSel.addRange(this.nativeRange); this.nativeSel.addRange(this.nativeRange);
return this; return this;
}, },
......
...@@ -16,12 +16,18 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -16,12 +16,18 @@ Minder.Receiver = kity.createClass( 'Receiver', {
return this.textEditStatus; return this.textEditStatus;
}, },
constructor: function ( km ) { constructor: function ( km ) {
var me = this;
this.setKityMinder( km ); this.setKityMinder( km );
this.textEditStatus = false; this.textEditStatus = false;
var _div = document.createElement( 'div' ); var _div = document.createElement( 'div' );
_div.setAttribute( 'contenteditable', true ); _div.setAttribute( 'contenteditable', true );
_div.className = 'km_receiver'; _div.className = 'km_receiver';
this.container = document.body.insertBefore( _div, document.body.firstChild ); this.container = document.body.insertBefore( _div, document.body.firstChild );
if(browser.ie && browser.version == 11){
utils.listen(this.container,'keydown keypress keyup',function(e){
me.keyboardEvents.call(me,new MinderEvent(e.type == 'keyup' ? "beforekeyup": e.type,e))
})
}
utils.addCssRule( 'km_receiver_css', ' .km_receiver{position:absolute;padding:0;margin:0;word-wrap:break-word;clip:rect(1em 1em 1em 1em);}' ); // utils.addCssRule( 'km_receiver_css', ' .km_receiver{position:absolute;padding:0;margin:0;word-wrap:break-word;clip:rect(1em 1em 1em 1em);}' ); //
this.km.on( 'textedit.beforekeyup textedit.keydown textedit.keypress textedit.paste', utils.proxy( this.keyboardEvents, this ) ); this.km.on( 'textedit.beforekeyup textedit.keydown textedit.keypress textedit.paste', utils.proxy( this.keyboardEvents, this ) );
this.timer = null; this.timer = null;
...@@ -114,6 +120,7 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -114,6 +120,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
switch ( e.type ) { switch ( e.type ) {
case 'keydown': case 'keydown':
isTypeText = false; isTypeText = false;
isKeypress = false; isKeypress = false;
switch ( e.originEvent.keyCode ) { switch ( e.originEvent.keyCode ) {
...@@ -162,6 +169,7 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -162,6 +169,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
case 'keypress': case 'keypress':
if ( isTypeText ) if ( isTypeText )
setTextToContainer(); setTextToContainer();
isKeypress = true; isKeypress = true;
...@@ -169,7 +177,6 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -169,7 +177,6 @@ Minder.Receiver = kity.createClass( 'Receiver', {
case 'beforekeyup': case 'beforekeyup':
switch ( keyCode ) { switch ( keyCode ) {
case keymap.Enter: case keymap.Enter:
case keymap.Tab: case keymap.Tab:
...@@ -241,18 +248,15 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -241,18 +248,15 @@ Minder.Receiver = kity.createClass( 'Receiver', {
}, },
setContainerStyle: function () { setContainerStyle: function () {
var textShapeBox = this.getBaseOffset('screen'); var textShapeBox = this.getBaseOffset('screen');
this.container.style.cssText = ";left:" + textShapeBox.x + 'px;top:' + ( textShapeBox.y - 5 ) + 'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;'; this.container.style.cssText = ";left:" + textShapeBox.x + 'px;top:' + ( textShapeBox.y - 35 ) + 'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
if(!this.selection.isShow()){ if(!this.selection.isShow()){
var paperContainer = this.km.getPaper(); var paperContainer = this.km.getPaper();
var width = paperContainer.node.parentNode.clientWidth; var width = paperContainer.node.parentNode.clientWidth;
var height = paperContainer.node.parentNode.clientHeight; var height = paperContainer.node.parentNode.clientHeight;
if(width < this.container.offsetWidth + this.container.offsetLeft){ if(width < this.container.offsetWidth + this.container.offsetLeft){
this.km.getRenderContainer().translate(width/-3, 0); this.km.getRenderContainer().translate(width/-3, 0);
this.setContainerStyle(); this.setContainerStyle();
}else if (height < this.container.offsetTop + this.container.offsetHeight){ }else if (height < this.container.offsetTop + this.container.offsetHeight){
this.km.getRenderContainer().translate(0, height/-3); this.km.getRenderContainer().translate(0, height/-3);
this.setContainerStyle() this.setContainerStyle()
......
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