Page MenuHomePhabricator

Investigation: Reusing refs across dialogs in VE (image caption, citation dialog)
Closed, ResolvedPublic

Description

Goal: understand what the problem is and what may need to be done to solve it.
Output: an explanation of the problem and feasibility assessment of solving it.

Problem statements

I am an editor using visual editor.
I'm trying to add a reused reference to an image caption, or to a template parameter.
But I cannot reuse references from the main text in e.g. the template dialog or an image caption.
Because The VE dialogs don't list references from outside of the image caption. The template dialog doesn't have access to the citation dialog at all.

Notes

Results
  • Appears to be trivial for images and galleries thanks to changes to the VE data model that have been made in the meantime (see T49344). Implementation ticket is T336417.
  • Fundamentally different for templates and other sub-documents. Out of scope for the moment. Needs separate investigation/spike if we want to fix this as well.

See also:

Related Objects

Event Timeline

Change 910552 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/Cite@master] [POC] Allow reference re-use and editing in other VE dialogs

https://gerrit.wikimedia.org/r/910552

I dug a little bit into this and found:

  • When you start VisualEditor with &debug=1 you get a nice tool to see the document model VisualEditor uses. In this model:
    • Templates are a single mwTransclusionBlock node. There is no reference node anywhere.
    • Same for a map where the caption contains a reference. There is a single mwMaps node, but nothing else.
    • For some reason this is different for images. There is a mwBlockImage node, but it contains more nodes, including a mwReference node.
    • The model inside of the image dialog is only the relevant sub-model.
  • Still the top-level re-use dialog is somehow able to show most of these references:
    • The reference from the image is always shown.
    • Both references from the map/template show up, but only when they are already re-used outside of the map/template, and only as a number "[2]" with no content.
  • One of the references shows up twice. One time without content and name. (Turns out this was because of temporary hacks I made.)
    • In this situation the re-use dialog shows 4 references, but the reference list at the end of the article only 3.
    • All but the reference from the image are marked as "This reference is defined in a template or other generated block, and for now can only be previewed in source mode."
  • When I actually re-use one of the bogus references VE creates broken wikitext: <ref />

Which means:

  • The proposal in the patch – to use the image's parent document – appears to be correct, but only for images.

To wrap this up: It seems it's quite possible to fix the issue for the images and media and gallery dialogs without much effort.

Change 917903 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Cite@master] Fix empty previews in reference reuse dialog

https://gerrit.wikimedia.org/r/917903