jenkins-bot has submitted this change and it was merged.
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 VisualEditorMessagesModule.php
M modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget.css
M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
M modules/ve/ve.js
4 files changed, 59 insertions(+), 3 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/VisualEditorMessagesModule.php b/VisualEditorMessagesModule.php
index 1f4e80e..54e75c4 100644
--- a/VisualEditorMessagesModule.php
+++ b/VisualEditorMessagesModule.php
@@ -43,6 +43,7 @@
$msgArgs = array(
'minoredit' => array( 'minoredit' ),
'missingsummary' => array( 'missingsummary' ),
+ 'summary' => array( 'summary' ),
'watchthis' => array( 'watchthis' ),
'visualeditor-browserwarning' => array(
'visualeditor-browserwarning' ),
'visualeditor-report-notice' => array(
'visualeditor-report-notice' ),
diff --git a/modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget.css
b/modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget.css
index 9340aba..a260d25 100644
--- a/modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget.css
+++ b/modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget.css
@@ -289,6 +289,10 @@
line-height: 3em;
}
+.ve-init-mw-viewPageTarget-saveDialog-body
.ve-init-mw-viewPageTarget-saveDialog-editSummary-label {
+ line-height: 2em;
+}
+
.ve-init-mw-viewPageTarget-saveDialog-editSummaryCount {
position: absolute;
right: 0;
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..b837305 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,8 @@
this.currentUri = currentUri;
this.messages = {};
this.section = currentUri.query.vesection || null;
+ this.sectionPositionRestored = false;
+ this.sectionTitleRestored = false;
this.namespaceName = mw.config.get( 'wgCanonicalNamespace' );
this.viewUri = new mw.Uri( mw.util.wikiGetlink( this.pageName ) );
this.veEditUri = this.viewUri.clone().extend( { 'veaction': 'edit' } );
@@ -183,6 +185,9 @@
</div>\
<div class="ve-init-mw-viewPageTarget-saveDialog-body">\
<div class="ve-init-mw-viewPageTarget-saveDialog-slide
ve-init-mw-viewPageTarget-saveDialog-slide-save">\
+ <label
class="ve-init-mw-viewPageTarget-saveDialog-editSummary-label"\
+
for="ve-init-mw-viewPageTarget-saveDialog-editSummary"\
+
id="ve-init-mw-viewPageTarget-saveDialog-editSummary-label"></label>\
<div
class="ve-init-mw-viewPageTarget-saveDialog-summary">\
<textarea name="editSummary"
class="ve-init-mw-viewPageTarget-saveDialog-editSummary"\
id="ve-init-mw-viewPageTarget-saveDialog-editSummary" type="text"\
@@ -1467,6 +1472,15 @@
this.saveDialogResolveConflictButton.connect( this, { 'click':
'onSaveDialogResolveConflictButtonClick' } );
this.getSaveDialogHtml( function ( $wrap ) {
+ var sectionTitle = '';
+ if ( viewPage.section ) {
+ sectionTitle = viewPage.$document.find( 'h1, h2, h3,
h4, h5, h6' ).eq( viewPage.section - 1 ).text();
+ sectionTitle = '/* ' + ve.graphemeSafeSubstring(
sectionTitle, 0, 244 ) + ' */ ';
+ viewPage.sectionTitleRestored = true;
+ if ( viewPage.sectionPositionRestored ) {
+ viewPage.onSectionRestored();
+ }
+ }
viewPage.$saveDialog
// Must not use replaceWith because that can't be used
on fragement roots,
// plus, we want to preserve the reference and class
names of the wrapper.
@@ -1494,10 +1508,14 @@
.click( ve.bind(
viewPage.onSaveDialogPrevButtonClick, viewPage ) )
.end()
// Attach contents
+ .find(
'#ve-init-mw-viewPageTarget-saveDialog-editSummary-label' )
+ .html( ve.init.platform.getParsedMessage(
'summary' ) )
+ .end()
.find(
'#ve-init-mw-viewPageTarget-saveDialog-editSummary' )
.attr( {
'placeholder': ve.msg(
'visualeditor-editsummary' )
} )
+ .val( sectionTitle )
.placeholder()
.byteLimit( viewPage.editSummaryByteLimit )
.on( {
@@ -1745,7 +1763,12 @@
if ( slide === 'save' ) {
setTimeout( function () {
- $slide.find( 'textarea' ).eq( 0 ).focus();
+ var $textarea = $slide.find(
'#ve-init-mw-viewPageTarget-saveDialog-editSummary' );
+ $textarea.focus();
+ // If message has be pre-filled (e.g. section edit),
move cursor to end
+ if ( $textarea.val() !== '' ) {
+ ve.selectEnd( $textarea[0] );
+ }
} );
}
@@ -2080,7 +2103,7 @@
};
/**
- * 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
@@ -2130,11 +2153,23 @@
}, 200 );
}
} );
- this.section = null;
+ this.sectionPositionRestored = true;
+ if ( this.sectionTitleRestored ) {
+ this.onSectionRestored();
+ }
}
};
/**
+ * Handle restoration of section editing position and title
+ */
+ve.init.mw.ViewPageTarget.prototype.onSectionRestored = function () {
+ this.section = null;
+ this.sectionPositionRestored = false;
+ this.sectionTitleRestored = false;
+};
+
+/**
* Show a message in the save dialog.
*
* @param {string} name Message's unique name
diff --git a/modules/ve/ve.js b/modules/ve/ve.js
index 91ad745..6a0c5da 100644
--- a/modules/ve/ve.js
+++ b/modules/ve/ve.js
@@ -557,6 +557,22 @@
};
/**
+ * Move the selection to the end of an input.
+ *
+ * @param {HTMLElement} element Input element
+ */
+ ve.selectEnd = function ( element ) {
+ element.focus();
+ if ( element.selectionStart !== undefined ) {
+ element.selectionStart = element.selectionEnd =
element.value.length;
+ } else if ( element.createTextRange ) {
+ var textRange = element.createTextRange();
+ textRange.collapse( false );
+ textRange.select();
+ }
+ };
+
+ /**
* Get a localized message.
*
* @param {string} key Message key
--
To view, visit https://gerrit.wikimedia.org/r/74545
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I44cef7a892b4f2f22f60f8f7f531f4e9dcfe8363
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits