mediawiki-extensions-Visual.../modules/ve-mw/ui/dialogs
Roan Kattouw cf17789985 Introduce newFromDocumentReplace() transaction builder
Replaces newFromNodeReplacement(). newFromNodeReplacement was very
simplistic and didn't support metadata or internal list items, so
if you had comments or references inside of the data you were editing
(reference contents or an image caption), they'd get mangled.

With this, you can do:
newDoc = doc.getDocumentSlice( node );
// Edit newDoc
tx = ve.dm.Transaction.newFromDocumentReplace( doc, node, newDoc );
surface.change( newDoc );

and that takes care of metadata, internal list items, and things like
references that reference internal list items.

ve.dm.Document.js:
* In getDocumentSlice(), store a reference to the original document
  and the number of items in its InternalList at the time of slicing
  in the created slice. This is used for reconciliation when the
  modified slice is injected back into the parent document with
  newFromDocumentReplace().

ve.dm.InternalList.js:
* Add a method for merging in another InternalList. This provides a
  mapping from old to new InternalList indexes so the linear model data
  being injected by newFromDocumentReplace() can have its InternalList
  indexes remapped.

ve.dm.Transaction.js:
* Replace newFromNodeReplacement() with newFromDocumentReplace()

ve.ui.MWMediaEditDialog.js, ve.ui.MWReferenceDialog.js:
* Use getDocumentSlice/newFromDocumentReplace for editing captions/refs
* Change insertion code path to insert an empty internalItem/caption, then
  newFromDocumentReplace into that
* Add empty internalList to new mini-documents

ve/test/dm/ve.dm.Transaction.test.js:
* Replace newFromNodeReplacement tests with newFromDocumentReplace tests

ve-mw/test/dm/ve.dm.Transaction.test.js (new):
* Add tests for newFromDocumentReplace with mwReference nodes

ve.dm.mwExample.js:
* Add data for newFromDocumentReplace with mwReference tests

VisualEditor.hooks.php:
* Add new test file

Bug: 52102
Change-Id: I4aa980780114b391924f04df588e81c990c32983
2013-09-25 21:46:38 +00:00
..
ve.ui.MWBetaWelcomeDialog.js Merge "Improve welcome dialog support for large fonts" 2013-09-04 23:02:05 +00:00
ve.ui.MWMediaEditDialog.js Introduce newFromDocumentReplace() transaction builder 2013-09-25 21:46:38 +00:00
ve.ui.MWMediaInsertDialog.js Merge "Insert images after selection, not in place of it" 2013-09-04 23:00:03 +00:00
ve.ui.MWMetaDialog.js Make tools generic and add fancy tool groups 2013-09-03 11:27:39 -07:00
ve.ui.MWReferenceDialog.js Introduce newFromDocumentReplace() transaction builder 2013-09-25 21:46:38 +00:00
ve.ui.MWReferenceListDialog.js Make tools generic and add fancy tool groups 2013-09-03 11:27:39 -07:00
ve.ui.MWTransclusionDialog.js Make tools generic and add fancy tool groups 2013-09-03 11:27:39 -07:00