Page MenuHomePhabricator

VisualEditor: Fire a hook before the page is saved
Closed, DeclinedPublic


Some Wikipedias have hooks for the source editor that process the wikitext before it is saved. The only thing to currently do this for the Visual Editor seems to be to hook in the 'wikipage.content' event and do an API edit that processes the text as intended.

Instead, the visual editor should offer a different event, such as visualeditor.beforesave, that would allow such processing to take place when saving the content.

Version: unspecified
Severity: enhancement



Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 2:15 AM
bzimport set Reference to bz57536.

What stage of the save do you want?

  • HTML is ready to be saved
  • HTML is converted to wikitext
  • Wikitext is back from Parsoid and is ready to be saved
  • VE just sent the wikitext to MW API
  • VE just got the confirmation token back from MW API

Ideally, there would be an event for each of these stages :)

Realistically, in order to reuse existing code, the best time would probably be when the Wikitext is ready to be saved (since that would be the equivalent for pressing the "Save" button). Of course, the callback needs to be able to give the modified wikitext back to VE.

Re-evaluating – if you want a client-side hook, this is a WONTFIX (both for specific reasons to this bug to do with catastrophic performance hits, and also because events are not a sane way to go).

If you want a VE-specific server-side (PHP) hook on wikitext save, we could do that more reasonably (as MediaWiki's too far down that road to pull back).