Index: trunk/extensions/VisualEditor/modules/es/tools/es.AnnotationButtonTool.js |
— | — | @@ -23,11 +23,14 @@ |
24 | 24 | es.AnnotationButtonTool.prototype.onClick = function() { |
25 | 25 | var surfaceView = this.toolbar.getSurfaceView(); |
26 | 26 | if ( this.inspector ) { |
27 | | - if ( surfaceView.getModel().getSelection().getLength() ) { |
28 | | - this.toolbar.getSurfaceView().getContextView().openInspector( this.inspector ); |
29 | | - } else { |
30 | | - if ( !this.active ) { |
31 | | - surfaceView.annotate( 'set', this.annotation ); |
| 27 | + if ( !surfaceView.getModel().getSelection().getLength() ) { |
| 28 | + if ( this.active ) { |
| 29 | + var surfaceModel = surfaceView.getModel(), |
| 30 | + documentModel = surfaceModel.getDocument(), |
| 31 | + selection = surfaceModel.getSelection(), |
| 32 | + range = documentModel.getAnnotationBoundaries( selection.from, this.annotation, true ); |
| 33 | + surfaceModel.select( range ); |
| 34 | + this.toolbar.getSurfaceView().getContextView().openInspector( this.inspector ); |
32 | 35 | } |
33 | 36 | } |
34 | 37 | } else { |
Index: trunk/extensions/VisualEditor/modules/es/models/es.DocumentModel.js |
— | — | @@ -682,11 +682,11 @@ |
683 | 683 | * @param {Object} annotation Annotation to test for coverage with |
684 | 684 | * @returns {es.Range|null} Range of content covered by annotation, or null if offset is not covered |
685 | 685 | */ |
686 | | -es.DocumentModel.prototype.getAnnotationBoundaries = function( offset, annotation ) { |
| 686 | +es.DocumentModel.prototype.getAnnotationBoundaries = function( offset, annotation, typeOnly ) { |
687 | 687 | if ( annotation.hash === undefined ) { |
688 | 688 | annotation.hash = es.DocumentModel.getHash( annotation ); |
689 | 689 | } |
690 | | - if ( es.DocumentModel.getIndexOfAnnotation( this.data[offset], annotation ) === -1 ) { |
| 690 | + if ( es.DocumentModel.getIndexOfAnnotation( this.data[offset], annotation, typeOnly ) === -1 ) { |
691 | 691 | return null; |
692 | 692 | } |
693 | 693 | var start = offset, |
— | — | @@ -694,13 +694,13 @@ |
695 | 695 | item; |
696 | 696 | while ( start > 0 ) { |
697 | 697 | start--; |
698 | | - if ( es.DocumentModel.getIndexOfAnnotation( this.data[start], annotation ) === -1 ) { |
| 698 | + if ( es.DocumentModel.getIndexOfAnnotation( this.data[start], annotation, typeOnly ) === -1 ) { |
699 | 699 | start++; |
700 | 700 | break; |
701 | 701 | } |
702 | 702 | } |
703 | 703 | while ( end < this.data.length ) { |
704 | | - if ( es.DocumentModel.getIndexOfAnnotation( this.data[end], annotation ) === -1 ) { |
| 704 | + if ( es.DocumentModel.getIndexOfAnnotation( this.data[end], annotation, typeOnly ) === -1 ) { |
705 | 705 | break; |
706 | 706 | } |
707 | 707 | end++; |
Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -626,6 +626,14 @@ |
627 | 627 | case 75: |
628 | 628 | if ( this.currentSelection.getLength() ) { |
629 | 629 | this.contextView.openInspector( 'link' ); |
| 630 | + } else { |
| 631 | + var range = this.model.getDocument().getAnnotationBoundaries( |
| 632 | + this.currentSelection.from, { 'type': 'link/internal' }, true |
| 633 | + ); |
| 634 | + if ( range ) { |
| 635 | + this.model.select( range ); |
| 636 | + this.contextView.openInspector( 'link' ); |
| 637 | + } |
630 | 638 | } |
631 | 639 | return false; |
632 | 640 | } |