Page MenuHomePhabricator

Investigation: Reuse tab in 2017 wikitext editor
Closed, ResolvedPublic

Description

Goal: understand why it isn’t enabled.
Output: a summary of reasons or decisions made (e.g. product decisions) that led to it being disabled.

Current situation

  • The reuse tab in the citation dialog of the 2017 wikitext editor is disabled
Result
  • There is just no document model were the re-use tab could find the references, only a model with raw wikitext.
  • It's certainly possible to make the re-use tab work, but not trivial. We need to parse and create the required model on demand every time the dialog is opened.
  • Warning: What happens when the wikitext is broken the moment the user opens the dialog? How to communicate this to the user? Needs WMDE-Design input.
  • Most trivial alternative is to entirely remove the "re-use" tab when we know it can never work in wikitext mode.

See also:

Event Timeline

The "Re-use" tab is disabled because the dialog doesn't have access to anything it could reuse. It tries to fetch existing references from the document model, but that list is empty: https://phabricator.wikimedia.org/diffusion/ECEX/browse/master/modules/ve/ve.ui.CitoidInspector.js$458. Why is the model incomplete? Because it's a different model. It's a model with a flat representation of the plain wikitext.

You can actually see this model when you start VisualEditor with &debug=1 in the URL and utilize the debug toolbar at the bottom of the editor.

I'm not 100% sure, but I think it's still possible to make the "Re-use" feature work. What we need to do is to manually parse the wikitext the moment the citation dialog is opened, so we get access to a model that contains everything needed for the "Re-use" workflow. Possible problems with this idea:

  • It's an extra, possibly expensive HTTP request. The user will notice a delay either when the citation dialog opens, or when switching to the "Re-use" tab.
  • The parsing must be done every time the dialog opens because the wikitext might have been changed in the meantime.
  • It's probably a significant amount of extra, rather complicated code.
  • There is still no guarantee the user doesn't destroy the reused reference before saving the page. (However, this is true with or without a re-use feature.)
  • All the feature would do anyway is to add a tiny wikitext snippet like <ref name="a"/>. There is no way to edit this or even understand what it was meant to do after the dialog closed.

Scanning for named references with a regex might sound trivial but shouldn't be done. It effectively means we re-implement parts of Parsoid, which is guaranteed to fail a significant number of times.

I also tried to look into this and found not much more. I'm not sure if we would need to re-implement Parsoid though or if it would be feasible to use parts if it's interface. We could at least talk to someone who might have more insights. I found a random comment regarding the "2017" Editor and Parsoid that says

Also the new editor doesn't really use Parsoid, except when you use some advanced tools from the toolbar.

So there might be a precedent.