Make auto-generated reference names like name=":0" visible in VE

This is a prerequisite before any work related to T52568 (being able
to manually name references in VisualEditor) can start.

Why these names should not be hidden:
* We don't know if the name is actually part of the auto-generated
  sequence in the current article or copy-pasted from somewhere else.
* Manually given names that start with a colon are currently hidden
  even if they are unrelated to the auto-generated sequence.
* The information is highly relevant for users switching between VE
  and wikitext. Especially when a reference is used multiple times
  the relevant wikitext can be as short as <ref name=":0" />. The
  literally only information in this case is the number.

Since these numbers are still more technical than anything we make
them very dim to emphasize the contrast to non-numeric names.

Bug: T52568
Bug: T92432
Change-Id: I65cb6998cb5f8659cd9043f3d4aaeac1c5f69da8
This commit is contained in:
thiemowmde 2023-02-23 12:09:15 +01:00
parent 91ebe18ee3
commit fd90304b23
2 changed files with 6 additions and 5 deletions

View file

@ -11,8 +11,12 @@
}
.ve-ui-mwReferenceSearchWidget-name {
color: #72777d;
opacity: 0.53; /* results in #787878 which is almost exactly @wmui-color-base30 */
float: right;
margin-left: 0.75em;
margin-bottom: 0.05em;
}
.ve-ui-mwReferenceSearchWidget-name-autogenerated {
opacity: 0.2; /* results in #cccccc which is almost exactly @wmui-color-base70 */
}

View file

@ -156,10 +156,6 @@ ve.ui.MWReferenceSearchWidget.prototype.buildIndex = function () {
// Use [\s\S]* instead of .* to catch esoteric whitespace (T263698)
var matches = refModel.getListKey().match( /^literal\/([\s\S]*)$/ );
var name = matches && matches[ 1 ] || '';
// Hide previously auto-generated reference names
if ( /^:[0-9]+$/.test( name ) ) {
name = '';
}
// TODO: At some point we need to make sure this text is updated in
// case the view node is still rendering. This shouldn't happen because
@ -217,6 +213,7 @@ ve.ui.MWReferenceSearchWidget.prototype.addResults = function () {
.text( '[' + item.citation + ']' );
var $name = $( '<div>' )
.addClass( 've-ui-mwReferenceSearchWidget-name' )
.toggleClass( 've-ui-mwReferenceSearchWidget-name-autogenerated', /^:\d+$/.test( item.name ) )
.text( item.name );
items.push(
new ve.ui.MWReferenceResultWidget( {