Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/74545
Change subject: Prepend section title to edit summary
......................................................................
Prepend section title to edit summary
When section edit links are used.
Bug: 50872
Change-Id: I44cef7a892b4f2f22f60f8f7f531f4e9dcfe8363
---
M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
2 files changed, 13 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/45/74545/1
diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
index ea2f59d..a61dc9f 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
@@ -267,7 +267,8 @@
$editLink
.attr( 'href', function ( i, val ) {
return new mw.Uri( veEditUri
).extend( {
- 'vesection': new
mw.Uri( val ).query.section
+ 'vesection': new
mw.Uri( val ).query.section,
+ 'vesectiontitle': $(
this ).closest( 'h1, h2, h3, h4, h5, h6' ).find( '.mw-headline' ).text()
} );
} )
.addClass(
'mw-editsection-link-primary' );
diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
index 8e3c784..9624a42 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
@@ -70,6 +70,7 @@
this.currentUri = currentUri;
this.messages = {};
this.section = currentUri.query.vesection || null;
+ this.sectionTitle = currentUri.query.vesectiontitle || null;
this.namespaceName = mw.config.get( 'wgCanonicalNamespace' );
this.viewUri = new mw.Uri( mw.util.wikiGetlink( this.pageName ) );
this.veEditUri = this.viewUri.clone().extend( { 'veaction': 'edit' } );
@@ -1498,6 +1499,7 @@
.attr( {
'placeholder': ve.msg(
'visualeditor-editsummary' )
} )
+ .val( viewPage.sectionTitle !== null ? '/* ' +
viewPage.sectionTitle + ' */ ' : '' )
.placeholder()
.byteLimit( viewPage.editSummaryByteLimit )
.on( {
@@ -1745,7 +1747,12 @@
if ( slide === 'save' ) {
setTimeout( function () {
- $slide.find( 'textarea' ).eq( 0 ).focus();
+ var $textarea = $slide.find( 'textarea' ).eq( 0 );
+ $textarea.focus();
+ // If message has be pre-filled (e.g. seciton edit),
move cursor to end
+ if ( $textarea.val() !== '' ) {
+ $textarea[0].selectionStart =
$textarea[0].selectionEnd = $textarea.val().length;
+ }
} );
}
@@ -2080,13 +2087,14 @@
};
/**
- * Get the numeric index of a section in the page.
+ * Store the section for which the edit link has been triggered.
*
* @method
* @param {HTMLElement} heading Heading element of section
*/
ve.init.mw.ViewPageTarget.prototype.saveEditSection = function ( heading ) {
this.section = this.getEditSection( heading );
+ this.sectionTitle = $( heading ).find( '.mw-headline' ).text();
};
/**
@@ -2131,6 +2139,7 @@
}
} );
this.section = null;
+ this.sectionText = null;
}
};
--
To view, visit https://gerrit.wikimedia.org/r/74545
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I44cef7a892b4f2f22f60f8f7f531f4e9dcfe8363
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits