r106123 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106122‎ | r106123 | r106124 >
Date:23:12, 13 December 2011
Author:tparscal
Status:ok (Comments)
Tags:
Comment:
- Added auto-link selection when opening the link editor without selecting any text
- Resolves bug #33049
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/models/es.DocumentModel.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/tools/es.AnnotationButtonTool.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/tools/es.AnnotationButtonTool.js
@@ -23,11 +23,14 @@
2424 es.AnnotationButtonTool.prototype.onClick = function() {
2525 var surfaceView = this.toolbar.getSurfaceView();
2626 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 );
3235 }
3336 }
3437 } else {
Index: trunk/extensions/VisualEditor/modules/es/models/es.DocumentModel.js
@@ -682,11 +682,11 @@
683683 * @param {Object} annotation Annotation to test for coverage with
684684 * @returns {es.Range|null} Range of content covered by annotation, or null if offset is not covered
685685 */
686 -es.DocumentModel.prototype.getAnnotationBoundaries = function( offset, annotation ) {
 686+es.DocumentModel.prototype.getAnnotationBoundaries = function( offset, annotation, typeOnly ) {
687687 if ( annotation.hash === undefined ) {
688688 annotation.hash = es.DocumentModel.getHash( annotation );
689689 }
690 - if ( es.DocumentModel.getIndexOfAnnotation( this.data[offset], annotation ) === -1 ) {
 690+ if ( es.DocumentModel.getIndexOfAnnotation( this.data[offset], annotation, typeOnly ) === -1 ) {
691691 return null;
692692 }
693693 var start = offset,
@@ -694,13 +694,13 @@
695695 item;
696696 while ( start > 0 ) {
697697 start--;
698 - if ( es.DocumentModel.getIndexOfAnnotation( this.data[start], annotation ) === -1 ) {
 698+ if ( es.DocumentModel.getIndexOfAnnotation( this.data[start], annotation, typeOnly ) === -1 ) {
699699 start++;
700700 break;
701701 }
702702 }
703703 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 ) {
705705 break;
706706 }
707707 end++;
Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js
@@ -626,6 +626,14 @@
627627 case 75:
628628 if ( this.currentSelection.getLength() ) {
629629 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+ }
630638 }
631639 return false;
632640 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r106124Fixes issue with r106123 where creating new links wasn't working anymore with...tparscal23:15, 13 December 2011
r106249MFT r106123, r106124, r106127, r106157, r106224, r106230 misc fixes to common...neilk21:58, 14 December 2011

Comments

#Comment by Trevor Parscal (WMF) (talk | contribs)   23:15, 13 December 2011

This breaks using the button to create a new link

Status & tagging log