2012-05-03 20:21:13 +00:00
|
|
|
/**
|
|
|
|
* ContentEditable surface.
|
2012-05-03 23:02:21 +00:00
|
|
|
*
|
2012-05-03 20:21:13 +00:00
|
|
|
* @class
|
|
|
|
* @constructor
|
|
|
|
* @param model {ve.dm.Surface} Model to observe
|
|
|
|
*/
|
2012-05-03 21:02:35 +00:00
|
|
|
ve.ce.Surface = function( $container, model ) {
|
2012-05-03 23:02:21 +00:00
|
|
|
// Inheritance
|
|
|
|
ve.EventEmitter.call( this );
|
2012-05-04 00:19:01 +00:00
|
|
|
|
2012-05-03 20:21:13 +00:00
|
|
|
// Properties
|
2012-05-03 23:14:54 +00:00
|
|
|
this.model = model;
|
2012-05-04 22:20:14 +00:00
|
|
|
this.documentView = new ve.ce.Document( model.getDocument() );
|
2012-05-21 23:06:30 +00:00
|
|
|
this.contextView = new ve.ui.Context( this );
|
2012-05-04 00:19:01 +00:00
|
|
|
this.$ = $container;
|
2012-05-25 03:55:45 +00:00
|
|
|
this.isMouseDown = false;
|
2012-05-25 19:02:56 +00:00
|
|
|
this.clipboard = {};
|
2012-05-25 22:46:58 +00:00
|
|
|
|
2012-05-25 03:55:45 +00:00
|
|
|
// Events
|
|
|
|
this.$.on( {
|
2012-05-26 06:52:52 +00:00
|
|
|
'keydown': this.proxy( this.onKeyDown ),
|
2012-05-25 03:55:45 +00:00
|
|
|
'mousedown': this.proxy( this.onMouseDown ),
|
|
|
|
'mouseup': this.proxy( this.onMouseUp ),
|
|
|
|
'mousemove': this.proxy( this.onMouseMove ),
|
2012-05-25 19:02:56 +00:00
|
|
|
'cut copy': this.proxy( this.onCutCopy ),
|
2012-05-25 23:12:58 +00:00
|
|
|
'beforepaste paste': this.proxy( this.onPaste ),
|
2012-05-25 03:55:45 +00:00
|
|
|
} );
|
2012-05-04 00:19:01 +00:00
|
|
|
|
|
|
|
// Initialization
|
|
|
|
this.$.append( this.documentView.documentNode.$ );
|
2012-05-18 18:40:22 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
document.execCommand( "enableObjectResizing", false, false );
|
2012-05-21 23:06:30 +00:00
|
|
|
document.execCommand( "enableInlineTableEditing", false, false );
|
2012-05-18 18:40:22 +00:00
|
|
|
} catch (e) { }
|
2012-05-03 20:21:13 +00:00
|
|
|
};
|
2012-05-03 23:02:21 +00:00
|
|
|
|
2012-05-18 22:19:31 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
2012-05-23 20:34:52 +00:00
|
|
|
ve.ce.Surface.prototype.proxy = function( func ) {
|
|
|
|
var _this = this;
|
|
|
|
return( function() {
|
|
|
|
return func.apply( _this, arguments );
|
|
|
|
});
|
|
|
|
};
|
2012-05-18 22:19:31 +00:00
|
|
|
|
2012-05-26 06:52:52 +00:00
|
|
|
ve.ce.Surface.prototype.onKeyDown = function( e ) {
|
|
|
|
var rangySel = rangy.getSelection();
|
|
|
|
var offset = this.getOffset( rangySel.anchorNode, rangySel.anchorOffset );
|
|
|
|
console.log( 'onKeyDown', 'offset', offset );
|
|
|
|
|
|
|
|
switch ( e.which ) {
|
|
|
|
case 37: // left arrow key
|
|
|
|
var relativeContentOffset = this.documentView.model.getRelativeContentOffset( offset, -1 );
|
|
|
|
var relativeStructuralOffset = this.documentView.model.getRelativeStructuralOffset( offset - 1, -1, true );
|
|
|
|
var relativeStructuralOffsetNode = this.documentView.documentNode.getNodeFromOffset( relativeStructuralOffset );
|
|
|
|
var hasSlug = relativeStructuralOffsetNode.hasSlugAtOffset( relativeStructuralOffset );
|
|
|
|
if ( hasSlug ) {
|
|
|
|
if ( relativeContentOffset > offset ) {
|
|
|
|
this.showCursor( relativeStructuralOffset );
|
|
|
|
} else {
|
|
|
|
this.showCursor( Math.max( relativeContentOffset, relativeStructuralOffset ) );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.showCursor( relativeContentOffset );
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case 39: // right arrow key
|
|
|
|
var relativeContentOffset = this.documentView.model.getRelativeContentOffset( offset, 1 );
|
|
|
|
var relativeStructuralOffset = this.documentView.model.getRelativeStructuralOffset( offset + 1, 1, true );
|
|
|
|
var relativeStructuralOffsetNode = this.documentView.documentNode.getNodeFromOffset( relativeStructuralOffset );
|
|
|
|
var hasSlug = relativeStructuralOffsetNode.hasSlugAtOffset( relativeStructuralOffset );
|
|
|
|
if ( hasSlug ) {
|
|
|
|
if ( relativeContentOffset < offset ) {
|
|
|
|
this.showCursor( relativeStructuralOffset );
|
|
|
|
} else {
|
|
|
|
this.showCursor( Math.min( relativeContentOffset, relativeStructuralOffset ) );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.showCursor( relativeContentOffset );
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-05-25 03:55:45 +00:00
|
|
|
ve.ce.Surface.prototype.onMouseDown = function( e ) {
|
|
|
|
this.isMouseDown = true;
|
|
|
|
|
2012-05-26 06:52:52 +00:00
|
|
|
var _this = this;
|
2012-05-25 03:55:45 +00:00
|
|
|
|
2012-05-26 06:52:52 +00:00
|
|
|
setTimeout( function() {
|
|
|
|
var rangySel = rangy.getSelection();
|
|
|
|
var offset = _this.getOffset( rangySel.anchorNode, rangySel.anchorOffset );
|
|
|
|
console.log( 'onMouseDown', 'rangySel', rangySel.anchorNode, rangySel.anchorOffset );
|
|
|
|
console.log( 'onMouseDown', 'offset', offset );
|
|
|
|
}, 0 );
|
2012-05-25 03:55:45 +00:00
|
|
|
|
2012-05-26 06:52:52 +00:00
|
|
|
var $closestLeaf = $( e.target ).closest( '.ve-ce-leafNode' );
|
2012-05-25 03:55:45 +00:00
|
|
|
|
2012-05-26 06:52:52 +00:00
|
|
|
if ( $closestLeaf.length > 0 ) {
|
|
|
|
console.log( 'onMouseDown', 'closest leaf of e.target', $closestLeaf );
|
2012-05-25 03:55:45 +00:00
|
|
|
|
2012-05-26 06:52:52 +00:00
|
|
|
var closestLeafModel = $closestLeaf.data( 'node' ).getModel();
|
|
|
|
var closestLeafOffset = closestLeafModel.getRoot().getOffsetFromNode( closestLeafModel );
|
|
|
|
console.log( 'onMouseDown', 'closestLeafOffset', closestLeafOffset );
|
2012-05-25 03:55:45 +00:00
|
|
|
|
2012-05-26 06:52:52 +00:00
|
|
|
var nearestContentOffset = this.documentView.model.getNearestContentOffset( closestLeafOffset, -1 );
|
|
|
|
console.log( 'onMouseDown', 'nearestContentOffset', nearestContentOffset );
|
2012-05-25 03:55:45 +00:00
|
|
|
|
2012-05-26 06:52:52 +00:00
|
|
|
var nearestStructuralOffset = this.documentView.model.getNearestStructuralOffset( closestLeafOffset, 0, true );
|
|
|
|
console.log( 'onMouseDown', 'nearestStructuralOffset', nearestStructuralOffset );
|
2012-05-25 03:55:45 +00:00
|
|
|
|
2012-05-26 06:52:52 +00:00
|
|
|
var nearestStructuralOffsetNode = this.documentView.documentNode.getNodeFromOffset( nearestStructuralOffset );
|
|
|
|
console.log( 'onMouseDown', 'nearestStructuralOffsetNode', nearestStructuralOffsetNode );
|
2012-05-25 03:55:45 +00:00
|
|
|
|
2012-05-26 06:52:52 +00:00
|
|
|
var hasSlug = nearestStructuralOffsetNode.hasSlugAtOffset( nearestStructuralOffset );
|
|
|
|
console.log( 'onMouseDown', 'hasSlug', hasSlug );
|
2012-05-25 03:55:45 +00:00
|
|
|
|
2012-05-26 06:52:52 +00:00
|
|
|
if ( hasSlug ) {
|
|
|
|
if ( nearestContentOffset > closestLeafOffset ) {
|
|
|
|
this.showCursor( nearestStructuralOffset );
|
|
|
|
} else {
|
|
|
|
this.showCursor( Math.max( nearestStructuralOffset, nearestContentOffset ) );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.showCursor( nearestContentOffset );
|
|
|
|
}
|
2012-05-25 03:55:45 +00:00
|
|
|
|
2012-05-26 06:52:52 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2012-05-25 03:55:45 +00:00
|
|
|
|
2012-05-26 06:52:52 +00:00
|
|
|
ve.ce.Surface.prototype.onMouseUp = function( e ) {
|
|
|
|
this.isMouseDown = false;
|
2012-05-25 03:55:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ve.ce.Surface.prototype.onMouseMove = function( e ) {
|
|
|
|
if ( this.isMouseDown === true ) {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-05-25 19:02:56 +00:00
|
|
|
/**
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.ce.Surface.prototype.onCutCopy = function( e ) {
|
|
|
|
var _this = this,
|
|
|
|
sel = rangy.getSelection(),
|
|
|
|
key = sel.getRangeAt(0).toString().replace( /\s/gm, '' );
|
|
|
|
|
|
|
|
this.clipboard[key] = ve.copyArray(
|
|
|
|
this.documentView.model.getData( this.getSelectionRange() )
|
|
|
|
);
|
|
|
|
|
2012-05-25 22:46:58 +00:00
|
|
|
if ( e.type == 'cut' ) {
|
2012-05-25 19:02:56 +00:00
|
|
|
setTimeout( function() {
|
|
|
|
// we don't like how browsers cut, so let's undo it and do it ourselves.
|
|
|
|
document.execCommand('undo', false, false);
|
|
|
|
|
|
|
|
var selection = _this.getSelectionRange();
|
|
|
|
|
|
|
|
// transact
|
|
|
|
var tx = _this.model.getDocument().prepareRemoval( selection );
|
|
|
|
|
|
|
|
_this.autoRender = true;
|
|
|
|
_this.model.transact( tx );
|
|
|
|
_this.autoRender = false;
|
|
|
|
|
|
|
|
_this.clearPollData();
|
|
|
|
|
|
|
|
// place cursor
|
|
|
|
_this.showCursor( selection.start );
|
|
|
|
}, 1 );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.ce.Surface.prototype.onPaste = function( e ) {
|
|
|
|
var _this = this,
|
|
|
|
insertionPoint = _this.getSelectionRange().start;
|
|
|
|
|
2012-05-30 20:06:19 +00:00
|
|
|
$('#paste').html('').show().focus();
|
2012-05-25 19:02:56 +00:00
|
|
|
|
|
|
|
setTimeout( function() {
|
2012-05-25 23:26:46 +00:00
|
|
|
var pasteString = $('#paste').hide().text(),
|
|
|
|
key = pasteString.replace( /\s/gm, '' ),
|
|
|
|
pasteData = ( _this.clipboard[key] ) ? _this.clipboard[key] : pasteString.split('');
|
2012-05-25 19:02:56 +00:00
|
|
|
|
2012-05-25 23:26:46 +00:00
|
|
|
// transact
|
|
|
|
var tx = ve.dm.Transaction.newFromInsertion( _this.documentView.model, insertionPoint, pasteData );
|
|
|
|
ve.dm.TransactionProcessor.commit( _this.documentView.model, tx );
|
2012-05-25 19:02:56 +00:00
|
|
|
|
2012-05-25 23:26:46 +00:00
|
|
|
// place cursor
|
|
|
|
_this.showCursor( insertionPoint + pasteData.length );
|
|
|
|
_this.documentView.documentNode.$.focus();
|
2012-05-25 19:02:56 +00:00
|
|
|
}, 1 );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-05-30 21:06:44 +00:00
|
|
|
* Gets the linear offset based on a given DOM node (DOMnode) and offset (DOMoffset)
|
|
|
|
*
|
2012-05-25 19:02:56 +00:00
|
|
|
* @method
|
|
|
|
* @param DOMnode {DOM Element} DOM Element
|
|
|
|
* @param DOMoffset {Integer} DOM offset within the DOM Element
|
|
|
|
* @returns {Integer} Linear model offset
|
|
|
|
*/
|
2012-05-25 03:55:45 +00:00
|
|
|
ve.ce.Surface.prototype.getOffset = function( DOMnode, DOMoffset ) {
|
2012-05-30 18:41:31 +00:00
|
|
|
if ( DOMnode.nodeType === Node.TEXT_NODE ) {
|
2012-05-30 21:06:44 +00:00
|
|
|
var $branch = $( DOMnode ).closest( '.ve-ce-branchNode' ),
|
|
|
|
current = [$branch.contents(), 0],
|
2012-05-25 03:55:45 +00:00
|
|
|
stack = [current],
|
2012-05-30 21:06:44 +00:00
|
|
|
offset = 0,
|
|
|
|
item,
|
|
|
|
$item;
|
|
|
|
|
2012-05-25 03:55:45 +00:00
|
|
|
while ( stack.length > 0 ) {
|
|
|
|
if ( current[1] >= current[0].length ) {
|
2012-05-30 21:06:44 +00:00
|
|
|
stack.pop();
|
2012-05-25 03:55:45 +00:00
|
|
|
current = stack[ stack.length - 1 ];
|
|
|
|
continue;
|
|
|
|
}
|
2012-05-30 21:06:44 +00:00
|
|
|
item = current[0][current[1]];
|
2012-05-30 18:41:31 +00:00
|
|
|
if ( item.nodeType === Node.TEXT_NODE ) {
|
2012-05-25 03:55:45 +00:00
|
|
|
if ( item === DOMnode ) {
|
|
|
|
offset += DOMoffset;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
offset += item.textContent.length;
|
|
|
|
}
|
2012-05-30 18:41:31 +00:00
|
|
|
} else if ( item.nodeType === Node.ELEMENT_NODE ) {
|
2012-05-30 21:06:44 +00:00
|
|
|
$item = current[0].eq( current[1] );
|
2012-05-26 06:52:52 +00:00
|
|
|
if ( $item.hasClass( 've-ce-slug' ) ) {
|
|
|
|
if ( $item.contents()[0] === DOMnode ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if ( $item.hasClass( 've-ce-leafNode' ) ) {
|
2012-05-25 03:55:45 +00:00
|
|
|
offset += 2;
|
2012-05-30 21:06:44 +00:00
|
|
|
} else if ( $item.hasClass( 've-ce-branchNode' ) ) {
|
|
|
|
offset += $item.data( 'node' ).getOuterLength();
|
2012-05-25 03:55:45 +00:00
|
|
|
} else {
|
2012-05-30 21:06:44 +00:00
|
|
|
stack.push( [$item.contents(), 0 ] );
|
2012-05-25 03:55:45 +00:00
|
|
|
current[1]++;
|
|
|
|
current = stack[stack.length-1];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
current[1]++;
|
|
|
|
}
|
2012-05-30 21:06:44 +00:00
|
|
|
var branchModel = $branch.data( 'node' ).getModel(),
|
|
|
|
branchOffset = branchModel.getRoot().getOffsetFromNode( branchModel );
|
|
|
|
return offset + branchOffset + ( ( branchModel.isWrapped() ) ? 1 : 0 );
|
2012-05-30 18:41:31 +00:00
|
|
|
} else if ( DOMnode.nodeType === Node.ELEMENT_NODE ) {
|
2012-05-25 03:55:45 +00:00
|
|
|
if ( DOMoffset === 0 ) {
|
2012-05-30 21:06:44 +00:00
|
|
|
throw "Not implemented";
|
2012-05-25 03:55:45 +00:00
|
|
|
} else {
|
2012-05-30 21:06:44 +00:00
|
|
|
var $node = $( DOMnode ).contents().eq( DOMoffset - 1 ),
|
|
|
|
nodeModel = $node.data( 'node' ).getModel(),
|
|
|
|
nodeOffset = nodeModel.getRoot().getOffsetFromNode( nodeModel );
|
2012-05-25 03:55:45 +00:00
|
|
|
return nodeOffset + nodeModel.getOuterLength();
|
|
|
|
}
|
|
|
|
}
|
2012-05-30 21:06:44 +00:00
|
|
|
throw "Not implemented";
|
2012-05-25 03:55:45 +00:00
|
|
|
};
|
|
|
|
|
2012-05-25 19:02:56 +00:00
|
|
|
|
|
|
|
/**
|
2012-05-30 22:19:39 +00:00
|
|
|
* Based on a given offset returns DOM node and offset that can be used to place a cursor (with rangy)
|
|
|
|
*
|
2012-05-25 19:02:56 +00:00
|
|
|
* @method
|
|
|
|
* @param offset {Integer} Linear model offset
|
2012-05-18 22:19:31 +00:00
|
|
|
*/
|
2012-05-30 22:19:39 +00:00
|
|
|
ve.ce.Surface.prototype.getNodeAndOffset = function( offset ) {
|
|
|
|
var node = this.documentView.getNodeFromOffset( offset ),
|
|
|
|
startOffset = this.documentView.getDocumentNode().getOffsetFromNode( node ) + ( ( node.isWrapped() ) ? 1 : 0 ),
|
|
|
|
current = [node.$.contents(), 0],
|
|
|
|
stack = [current],
|
|
|
|
item,
|
|
|
|
$item,
|
|
|
|
length;
|
2012-05-25 03:55:45 +00:00
|
|
|
|
|
|
|
while ( stack.length > 0 ) {
|
|
|
|
if ( current[1] >= current[0].length ) {
|
|
|
|
stack.pop();
|
|
|
|
current = stack[ stack.length - 1 ];
|
|
|
|
continue;
|
|
|
|
}
|
2012-05-30 22:19:39 +00:00
|
|
|
item = current[0][current[1]];
|
2012-05-30 18:41:31 +00:00
|
|
|
if ( item.nodeType === Node.TEXT_NODE ) {
|
2012-05-30 22:19:39 +00:00
|
|
|
length = item.textContent.length;
|
2012-05-25 03:55:45 +00:00
|
|
|
if ( offset >= startOffset && offset <= startOffset + length ) {
|
2012-05-30 22:19:39 +00:00
|
|
|
return {
|
|
|
|
node: item,
|
|
|
|
offset: offset - startOffset
|
|
|
|
};
|
2012-05-25 03:55:45 +00:00
|
|
|
} else {
|
|
|
|
startOffset += length;
|
|
|
|
}
|
2012-05-30 18:41:31 +00:00
|
|
|
} else if ( item.nodeType === Node.ELEMENT_NODE ) {
|
2012-05-30 22:19:39 +00:00
|
|
|
$item = current[0].eq( current[1] );
|
2012-05-25 03:55:45 +00:00
|
|
|
if ( $item.hasClass('ve-ce-slug') ) {
|
2012-05-26 06:52:52 +00:00
|
|
|
if ( offset === startOffset ) {
|
2012-05-30 22:19:39 +00:00
|
|
|
return {
|
|
|
|
node: $item[0],
|
|
|
|
offset: 1
|
|
|
|
};
|
2012-05-26 06:52:52 +00:00
|
|
|
}
|
2012-05-25 03:55:45 +00:00
|
|
|
} else if ( $item.is( '.ve-ce-branchNode, .ve-ce-leafNode' ) ) {
|
2012-05-30 22:19:39 +00:00
|
|
|
length = $item.data( 'node' ).model.getOuterLength();
|
2012-05-25 03:55:45 +00:00
|
|
|
if ( offset >= startOffset && offset < startOffset + length ) {
|
|
|
|
stack.push( [$item.contents(), 0] );
|
|
|
|
current[1]++;
|
|
|
|
current = stack[stack.length-1];
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
startOffset += length;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
stack.push( [$item.contents(), 0] );
|
|
|
|
current[1]++;
|
|
|
|
current = stack[stack.length-1];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
current[1]++;
|
|
|
|
}
|
2012-05-30 22:19:39 +00:00
|
|
|
throw "Not implemented";
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets closest BranchNode (.ve-ce-branchNode) based on a given DOM node
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param elem {DOM Element} DOM Element
|
|
|
|
* @returns {jQuery} jQuery element
|
|
|
|
*/
|
|
|
|
ve.ce.Surface.getBranchNode = function( elem ) {
|
|
|
|
var $branch = $( elem ).closest( '.ve-ce-branchNode' );
|
|
|
|
return $branch.length ? $branch : null;
|
2012-05-18 22:19:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.ce.Surface.prototype.showCursor = function( offset ) {
|
|
|
|
this.showSelection( new ve.Range( offset ) );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.ce.Surface.prototype.showSelection = function( range ) {
|
2012-05-30 22:19:39 +00:00
|
|
|
var start = this.getNodeAndOffset( range.start ),
|
|
|
|
stop = this.getNodeAndOffset( range.end ),
|
2012-05-18 22:19:31 +00:00
|
|
|
rangySel = rangy.getSelection(),
|
|
|
|
rangyRange = rangy.createRange();
|
|
|
|
|
|
|
|
rangyRange.setStart( start.node, start.offset );
|
|
|
|
rangyRange.setEnd( stop.node, stop.offset );
|
|
|
|
rangySel.setSingleRange( rangyRange, range.start !== range.from );
|
|
|
|
};
|
|
|
|
|
2012-05-25 19:02:56 +00:00
|
|
|
/**
|
|
|
|
* @method
|
|
|
|
* @returns {ve.Range} Current selection range
|
|
|
|
*/
|
|
|
|
ve.ce.Surface.prototype.getSelectionRange = function() {
|
|
|
|
var rangySel = rangy.getSelection();
|
|
|
|
|
|
|
|
if ( rangySel.isCollapsed ) {
|
|
|
|
var offset = this.getOffset( rangySel.anchorNode, rangySel.anchorOffset, true );
|
|
|
|
return new ve.Range( offset, offset );
|
|
|
|
} else {
|
|
|
|
return new ve.Range(
|
|
|
|
this.getOffset( rangySel.anchorNode, rangySel.anchorOffset, true ),
|
|
|
|
this.getOffset( rangySel.focusNode, rangySel.focusOffset, true )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @method
|
|
|
|
*/
|
2012-05-21 23:06:30 +00:00
|
|
|
ve.ce.Surface.prototype.getSelectionRect = function() {
|
|
|
|
var rangySel = rangy.getSelection();
|
|
|
|
return {
|
|
|
|
start: rangySel.getStartDocumentPos(),
|
|
|
|
end: rangySel.getEndDocumentPos()
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2012-05-25 19:02:56 +00:00
|
|
|
|
2012-05-03 23:02:21 +00:00
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
ve.extendClass( ve.ce.Surface, ve.EventEmitter );
|