Make LinkInspector works (using annotate method in SurfaceView)

This commit is contained in:
Inez Korczynski 2012-03-16 22:16:15 +00:00
parent b2f4b48a9a
commit 299c77db84
Notes: Inez Korczynski 2012-03-16 22:16:15 +00:00
2 changed files with 11 additions and 25 deletions

View file

@ -115,7 +115,7 @@ ve.ce.Surface = function( $container, model ) {
/* Methods */
ve.ce.Surface.prototype.annotate = function( method, annotation ) {
var range = this.getSelectionRange(),
var range = this.currentSelection,
_this = this;
if ( method === 'toggle' ) {
@ -511,8 +511,9 @@ ve.ce.Surface.prototype.onKeyDown = function( e ) {
};
ve.ce.Surface.prototype.getOffset = function( elem, offset, global ) {
var $leafNode = this.getLeafNode( elem ),
current = [$leafNode.contents(), 0],
var $leafNode = this.getLeafNode( elem );
if($leafNode === null)return;
var current = [$leafNode.contents(), 0],
stack = [current],
localOffset = 0;

View file

@ -22,14 +22,10 @@ ve.ui.LinkInspector = function( toolbar, context ) {
if ( $(this).is( '.es-inspector-button-disabled' ) ) {
return;
}
var surfaceView = _this.context.getSurfaceView(),
surfaceModel = surfaceView.getModel(),
tx = surfaceModel.getDocument().prepareContentAnnotation(
surfaceView.currentSelection,
'clear',
/link\/.*/
);
surfaceModel.transact( tx );
var surfaceView = _this.context.getSurfaceView();
surfaceView.annotate( 'clear', /link\/.*/ );
_this.$locationInput.val( '' );
_this.context.closeInspector();
} );
@ -86,20 +82,9 @@ ve.ui.LinkInspector.prototype.onClose = function( accept ) {
if ( title === this.getTitleFromSelection() || !title ) {
return;
}
var surfaceView = this.context.getSurfaceView(),
surfaceModel = surfaceView.getModel();
var clear = surfaceModel.getDocument().prepareContentAnnotation(
surfaceView.currentSelection,
'clear',
/link\/.*/
);
surfaceModel.transact( clear );
var set = surfaceModel.getDocument().prepareContentAnnotation(
surfaceView.currentSelection,
'set',
{ 'type': 'link/internal', 'data': { 'title': title } }
);
surfaceModel.transact( set );
var surfaceView = this.context.getSurfaceView();
surfaceView.annotate( 'clear', /link\/.*/ );
surfaceView.annotate( 'set', { 'type': 'link/internal', 'data': { 'title': title } } );
}
};