VisualEditor depends on the following transform endpoints:
- /transform/html/to/wikitext {/title}{/revision} - accepts modified HTML and transforms it to wikitext. Only works if the data-parsoid was previously stashed.
- /transform/wikitext/to/html {/title}{/revision} - accepts modified wikitext and transforms it to HTML.
PHP implementation of these endpoints already exist in the Parsoid extension, see the MWParsoid\Rest\Handler\TransformHandler class. This class should be copied to MediaWiki core and adjusted. The endpoint in the parsoid extension can be retained for backwards compatibility, but should eventually be backed by the core class rather than a class that lives in the parsoid extension.
When transforming HTML to wikitext, the transform handler makes use of the original wikitext and the data-parsoid mapping. Currently, it expects the original page bundle to come from the request body: $origPb = new PageBundle( '', $original['data-parsoid']['body'] ?? null, $original['data-mw']['body'] ?? null );. In the future, we should look up the stashed page bundle based on the etag if it's not in the request (T310464).