mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
6772f92e70
The way we implemented undoing transactions was horrible. We'd process the original transaction, but with a reversed=true flag. That meant we had to keep track of the 'reversed' flag everywhere, and use ternaries like insert = reversed ? op.remove : op.insert; all over the place to access transaction operations. Redo then worked by reapplying the transaction. We would verify that this was OK by tracking whether the transaction was in an applied state or an undone state. This commit makes it so every transaction can only be applied once. To undo, you obtain a mirror image of the transaction with tx.reverse(), then apply that. To redo, you clone the original transaction with tx.clone() and apply that. All the code that had to use ternaries to check whether the transaction was being applied in reverse or not is gone now, because you can only apply a given transaction forwards, never in reverse. Bonus: * Make ve.dm.Document's .completeHistory a simple array of transactions, rather than transaction/boolean pairs * In the protection of double application test, clone the example document properly; it modified ve.dm.example.data, which was "fine" because it ran .commit() and .rollback() the same number of times Change-Id: I3050c5430be4a12510f22e20853560b92acebb67 |
||
---|---|---|
.docs | ||
demos | ||
maintenance | ||
modules | ||
.csslintrc | ||
.gitignore | ||
.gitreview | ||
.jshintignore | ||
.jshintrc | ||
ApiVisualEditor.php | ||
ApiVisualEditorEdit.php | ||
AUTHORS.txt | ||
CONTRIBUTING.md | ||
Gruntfile.js | ||
LICENSE.txt | ||
logo-experimental.png | ||
logo-experimental.svg | ||
package.json | ||
README.md | ||
VisualEditor.hooks.php | ||
VisualEditor.i18n.php | ||
VisualEditor.php | ||
VisualEditorDataModule.php |
VisualEditor
VisualEditor provides a visual editor for wiki pages. It is written in JavaScript and runs in a web browser.
It uses the Parsoid parser to convert wikitext documents to annotated HTML which the VisualEditor is able to load, modify and emit back to Parsoid at which point it is converted back into wikitext.
For more information about these projects, check out the VisualEditor and Parsoid pages on mediawiki.
Developing and installing
For information on installing VisualEditor on a local wiki, please see https://www.mediawiki.org/wiki/Extension:VisualEditor
For information about running tests and contributing code to VisualEditor, see CODING.md. Patch submissions are reviewed and managed with Gerrit. There is also API documentation available for the VisualEditor.