Images or galleries have a caption attribute where Wikitext can be used that will be rendered on the page. You can define new references in there or re-use references that where defined outside of the caption. VisualEditor should support both directions.
One part of this seems to be working already:
- I am an editor using visual editor.
- I open the image/gallery dialog to add a new or edit an exiting image/gallery.
- I add a reference to the caption.
- I close the dialog and want to re-use that reference in the article.
- The reference **shows up** in the re-use dialog and I can add it to the article
The other way does not though:
- I am an editor using visual editor.
- I directly add references to the article or there are already references that were directly added there.
- I open the image/gallery dialog to add a new or edit an existing image/gallery.
- I'm trying to re-use a reference that's defined in the article in the caption.
- The reference **does not show** up in the re-use dialog if it's defined on the article.
There seems to be a good way to fix the second part though, by pointing the re-use dialog to the root document of the article when used from of the image dialog.
See also:
* {T62919}
* ~~{T87134}~~ (unrelated)
== Acceptance criteria ==
As a visual editor,
I want to reuse existing citations in the image caption dialog
so that it's more like editing text anywhere else in the document.
**Scenario**: An existing citation can be reused
Given a document with citations
When I add a new image and caption
Then the citation "re-use" menu item is enabled.
Given a document with citations
When I add a new image and caption
and click re-use
Then I see a menu including the existing citations.
Given a document with citations
When I add a new image and caption
and re-use an existing citation with number > 1
Then the inserted ref has a matching number
and shows the ref content in a popped-up preview
and the preview includes a warning about reused citations.
Given a new caption which reuses an existing citation
When I confirm the image dialog
Then the reused citation appears with two backlinks in the reference list
and the existing and new citations both include a reuse warning.
**Scenario**: An existing citation and a new citation play nice together
Given a document with one citation
When I create an image with a caption
and add a new citation to the caption
Then the new citation has number 2.
Given a document with an existing citation and an unsaved caption with a new citation
When I open the citation re-use dialog
Then both the existing and new citations are shown as 1, 2.