Merge "Typing support after Aliens and Entities for IE"

This commit is contained in:
jenkins-bot 2013-03-29 02:19:15 +00:00 committed by Gerrit Code Review
commit 7b9618ebc2
3 changed files with 32 additions and 10 deletions

View file

@ -19,10 +19,7 @@ ve.ce.AlienNode = function VeCeAlienNode( model ) {
// DOM Changes
this.$.addClass( 've-ce-alienNode' );
// ce="false" inside of ce="true" does not prevent editing in IE
// Strangely enough, ce="true" inside of ce="true" does.
this.$.attr( 'contenteditable', !!$.browser.msie );
this.$.attr( 'contenteditable', false );
// Events
this.model.addListenerMethod( this, 'update', 'onUpdate' );

View file

@ -277,14 +277,28 @@ ve.ce.Surface.prototype.onDocumentDragoverDrop = function () {
* @emits selectionStart
*/
ve.ce.Surface.prototype.onDocumentKeyDown = function ( e ) {
var selection, prevNode;
// Ignore keydowns while in IME mode but do not preventDefault them.
if ( this.inIme === true ) {
return;
}
if ( $.browser.msie === true && e.which === 229 ) {
this.inIme = true;
this.handleInsertion();
return;
if ( $.browser.msie === true ) {
// Aliens/Entities
selection = this.model.getSelection();
if ( selection.start !== 0 && selection.isCollapsed() ) {
prevNode = this.model.getDocument().getDocumentNode().getNodeFromOffset( selection.start - 1 );
if ( !prevNode.canHaveChildren() && !prevNode.canContainContent() ) {
this.model.change( null, new ve.Range( selection.start ) );
}
}
// IME
if ( e.which === 229 ) {
this.inIme = true;
this.handleInsertion();
return;
}
}
if ( ve.ce.isArrowKey( e.keyCode ) ) {
// Detect start of selecting using shift+arrow keys.
@ -1290,4 +1304,4 @@ ve.ce.Surface.prototype.enableRendering = function () {
*/
ve.ce.Surface.prototype.disableRendering = function () {
this.renderingEnabled = false;
};
};

View file

@ -135,6 +135,11 @@ ve.ce.getOffsetFromTextNode = function ( domNode, domOffset ) {
);
nodeModel = $node.data( 'node' ).getModel();
// IE sometimes puts the cursor in a text node inside ce="false". BAD!
if ( $node[0].contentEditable === 'false' ) {
return nodeModel.getOffset() + nodeModel.getOuterLength();
}
if ( ! $node.hasClass( 've-ce-branchNode' ) ) {
return nodeModel.getOffset();
}
@ -204,6 +209,12 @@ ve.ce.getOffsetFromElementNode = function ( domNode, domOffset, addOuterLength )
}
}
// IE sometimes puts the cursor in a text node inside ce="false". BAD!
if ( domNode.contentEditable === 'false' ) {
nodeModel = $domNode.data( 'node' ).getModel();
return nodeModel.getOffset() + nodeModel.getOuterLength();
}
if ( domOffset === 0 ) {
node = $domNode.data( 'node' );
if ( node ) {
@ -268,4 +279,4 @@ ve.ce.isArrowKey = function ( keyCode ) {
*/
ve.ce.isShortcutKey = function ( e ) {
return e.ctrlKey || e.metaKey;
};
};