Lucas_Werkmeister_WMDE added a comment.
> Due to the fact that wiki syntax is used, we will not be able to add data
attributes directly to the hyperlink elements. However, we can add children to
the hyperlinks, which then are part of the anchor (see edit pen of the example
above).
Unfortunately, wikitext also restricts the ability to add data attributes
below the hyperlinks. The variant you demonstrated works, but unfortunately
adds an external link marker after the link, which I don’t think is an
acceptable change. Changing it to internal wikilink syntax works –
[[:d:Q42#P31|<span data-bridge-edit-flow="overwrite">🖊</span>]]
– but only because it uses an emoji character for the edit icon; the parser
won’t recognize an image link nested inside a wikilink (or rather, it won’t
recognize the outer wikilink):
[[:d:Q42#P31|<span data-bridge-edit-flow="theflow">[[File:OOjs UI icon
edit-ltr-progressive.svg|frameless|text-top|10px|link=|alt=Edit this on
Wikidata|Edit this on Wikidata]]</span>]]
> [[:d:Q42#P31|🖊]]
Adding data attributes on or inside the file link doesn’t work:
[[File:OOjs UI icon
edit-ltr-progressive.svg|frameless|text-top|10px|alt=Edit this on
Wikidata|link=https://www.wikidata.org/wiki/Q2013?uselang=en#P856|data-bridge-edit-flow="overwrite"|<span
data-bridge-edit-flow="overwrite">Edit this on Wikidata</span>]]
<a href="https://www.wikidata.org/wiki/Q2013?uselang=en#P856" title="Edit
this on Wikidata" rel="nofollow"><img alt="Edit this on Wikidata"
src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/10px-OOjs_UI_icon_edit-ltr-progressive.svg.png"
decoding="async" style="vertical-align: text-top"
srcset="https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/15px-OOjs_UI_icon_edit-ltr-progressive.svg.png
1.5x,
https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/20px-OOjs_UI_icon_edit-ltr-progressive.svg.png
2x" width="10" height="10"></a>
In short, I’m unable to find a wikitext trick that lets you produce an
internal link containing an image and custom data attributes.
---
Alternatively, we can go with the outer element variant, but restrict it:
instead of saying that any element content is allowed, and a nested link is
merely an extra convenient case in which you’re allowed to omit the
`data-bridge-entity-id` and `data-bridge-property-id`, we could say that the
element with a `data-bridge-edit-flow` attribute must only contain a single
hyperlink, from which the entity and property ID are extracted – in other
words, turn the common case into the only supported case. This would remove the
problem of making non-clickable elements clickable (if the link is required, we
can attach the event handler to it, not the element with
`data-bridge-edit-flow`), and is still easy to produce in wikitext (put a
suitable `<span>` around whatever wikitext you currently use to create the edit
link).
TASK DETAIL
https://phabricator.wikimedia.org/T227463
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Lucas_Werkmeister_WMDE
Cc: Lydia_Pintscher, Pablo-WMDE, Lucas_Werkmeister_WMDE, Aklapper, Michael,
darthmon_wmde, Nandana, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer,
_jensen, rosalieper, Wikidata-bugs, aude, Mbch331
_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs