mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "ArticleTarget: building summary in source mode, strip links from section titles"
This commit is contained in:
commit
d4438549e5
|
@ -2055,10 +2055,21 @@ ve.init.mw.ArticleTarget.prototype.restoreEditSection = function () {
|
|||
this.goToHeading( headingNode );
|
||||
}
|
||||
} else if ( mode === 'source' ) {
|
||||
// With elements of extractSectionTitle + stripSectionName TODO:
|
||||
// Arguably, we should just throw this through the API and then do
|
||||
// the same extract-text pass we do in visual mode. Would save us
|
||||
// having to think about wikitext here.
|
||||
headingText = surface.getModel().getDocument().data.getText(
|
||||
false,
|
||||
surface.getModel().getDocument().getDocumentNode().children[ 0 ].getRange()
|
||||
).replace( /^\s*=+\s*(.*?)\s*=+\s*$/, '$1' );
|
||||
)
|
||||
// Extract the title
|
||||
.replace( /^\s*=+\s*(.*?)\s*=+\s*$/, '$1' )
|
||||
// Remove links
|
||||
.replace( /\[\[:?([^[|]+)\|([^[]+)\]\]/, '$2' )
|
||||
.replace( /\[\[:?([^[]+)\|?\]\]/, '$1' )
|
||||
.replace( new RegExp( '\\[(?:' + ve.init.platform.getUnanchoredExternalLinkUrlProtocolsRegExp().source + ')([^ ]+?) ([^\\[]+)\\]', 'i' ), '$3' )
|
||||
;
|
||||
}
|
||||
if ( headingText ) {
|
||||
this.initialEditSummary =
|
||||
|
|
Loading…
Reference in a new issue